//#region extensions/crypto/src/services/session-recall.d.ts /** * Session Recall Service — full-text search over past conversations. * * Indexes conversation turns to JSONL on disk and provides in-memory * full-text search with relevance ranking. No external dependencies * (no SQLite — uses JSONL + in-memory search to match the codebase's * file-based persistence pattern). * * How it works: * 1. message_received and after_tool_call hooks feed messages in * 2. Messages are appended to ~/.openclawnch/recall/sessions.jsonl * 3. On startup, the index is loaded into memory * 4. Search queries tokenize and match against the index * 5. Results are grouped by session with context windows * * The in-memory approach works well for single-agent deployments with * thousands of conversations. For multi-agent or very large histories, * this can be upgraded to SQLite FTS5 later. * * Inspired by Hermes Agent's session_search_tool.py. */ interface RecallEntry { /** Monotonically increasing sequence number. */ seq: number; /** Session identifier (e.g., "telegram-123456789"). */ sessionKey: string; /** Message role: user, assistant, tool, system. */ role: 'user' | 'assistant' | 'tool' | 'system'; /** Message content (truncated to MAX_ENTRY_CHARS). */ content: string; /** Tool name (if role is 'tool'). */ toolName?: string; /** User ID. */ userId?: string; /** Timestamp in ms. */ timestamp: number; } interface RecallSearchResult { /** Session key that had matches. */ sessionKey: string; /** Matching entries from this session. */ matches: RecallEntry[]; /** Relevance score (higher = more relevant). */ score: number; /** Earliest timestamp in matched entries. */ earliestTimestamp: number; /** Latest timestamp in matched entries. */ latestTimestamp: number; } interface RecallConfig { /** Base directory. Default: ~/.openclawnch/recall/ */ baseDir?: string; /** Max characters per entry content. Default: 2000. */ maxEntryChars?: number; /** Max entries to keep in memory. Default: 50000. */ maxEntries?: number; /** Max search results to return. Default: 5. */ maxResults?: number; } declare class SessionRecallService { private config; private entries; private nextSeq; private loaded; constructor(config?: RecallConfig); /** * Record a conversation turn for future recall. */ recordTurn(entry: Omit): void; /** * Search past conversations for relevant context. * Returns sessions ranked by relevance. */ search(query: string, maxResults?: number): RecallSearchResult[]; private getFilePath; private ensureLoaded; private diskWrites; private static readonly COMPACT_INTERVAL; private static readonly MAX_FILE_SIZE_BYTES; private appendToDisk; /** * Compact the JSONL file by rewriting it with only the in-memory entries. * Prevents unbounded disk growth — the file is capped at maxEntries lines. */ private maybeCompact; getStats(): { totalEntries: number; uniqueSessions: number; oldestTimestamp: number; newestTimestamp: number; }; } declare function getSessionRecall(config?: RecallConfig): SessionRecallService; declare function resetSessionRecall(): void; //#endregion export { RecallConfig, RecallEntry, RecallSearchResult, getSessionRecall, resetSessionRecall }; //# sourceMappingURL=session-recall.d.mts.map