HistoryService class
Service for managing conversation history, search, and analytics.
Constructors
- HistoryService({String? baseDir})
Properties
-
entryStream
→ Stream<
HistoryEntry> -
Entry stream for new entries.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
sessionStream
→ Stream<
SessionSummary> -
Session update stream.
no setter
Methods
-
compactHistory(
{Duration retention = const Duration(days: 90)}) → Future< int> - Compact old session history files (entries older than retention period).
-
deleteSession(
String sessionId) → Future< void> - Delete a session's history.
-
dispose(
) → void - Dispose resources.
-
exportSession(
String sessionId, {String format = 'markdown'}) → Future< String> - Export a session's history.
-
flush(
) → Future< void> - Flush pending writes to disk.
-
forkSession(
String sessionId, {required int fromTurnIndex}) → Future< String> - Fork a session from a specific point.
-
getAnalytics(
{required DateTime start, required DateTime end}) → Future< UsageAnalytics> - Compute usage analytics for a time period.
-
getSessionHistory(
String sessionId) → Future< List< HistoryEntry> > - Get all entries for a session.
-
getSessionSummary(
String sessionId) → Future< SessionSummary?> - Get session summary.
-
initialize(
) → Future< void> - Initialize history service and create directories.
-
listSessions(
{String? searchText, DateTime? after, DateTime? before, int limit = 50, int offset = 0, String sortBy = 'lastActive', bool descending = true}) → Future< List< SessionSummary> > - List all sessions.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
record(
{required String sessionId, required HistoryEntryType type, required String role, required String content, Map< String, dynamic> ? metadata, String? toolName, String? toolId, int? tokenCount, double? cost, Duration? latency, String? parentId, int turnIndex = 0}) → Future<HistoryEntry> - Record a new history entry.
-
recordAssistantMessage(
String sessionId, String content, {int? tokenCount, double? cost, Duration? latency, int turnIndex = 0}) → Future< HistoryEntry> - Record an assistant message.
-
recordCommand(
String sessionId, {required String commandName, required String args, required String result, int turnIndex = 0}) → Future< HistoryEntry> - Record a slash command execution.
-
recordToolResult(
String sessionId, {required String toolId, required String toolName, required String output, bool isError = false, Duration? latency, int turnIndex = 0}) → Future< HistoryEntry> - Record a tool result.
-
recordToolUse(
String sessionId, {required String toolName, required String toolId, required Map< String, dynamic> input, int turnIndex = 0}) → Future<HistoryEntry> - Record a tool use.
-
recordUserMessage(
String sessionId, String content, {int turnIndex = 0}) → Future< HistoryEntry> - Record a user message.
-
replayJumpTo(
ReplayState state, int index) → ReplayState - Jump to a specific point in replay.
-
replayNext(
ReplayState state) → ReplayState - Step forward in replay.
-
replayPrevious(
ReplayState state) → ReplayState - Step backward in replay.
-
replayVisibleEntries(
ReplayState state) → List< HistoryEntry> - Get entries up to current replay point (for rendering).
-
search(
HistorySearchQuery query) → Future< HistorySearchResult> - Search across all history.
-
startReplay(
String sessionId) → Future< ReplayState> - Start a replay of a session.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited