export interface SessionChunk { index: number; content: string; tokenEstimate: number; } export interface SessionSearchResult { sessionId: string; isCurrentSession: boolean; content_snippet: string; score: number; chunkIndex: number; } /** * Manages a single session document — an append-only markdown file * that accumulates conversation context, chunked and embedded for * semantic search alongside regular messages. */ export declare class SessionManager { readonly sessionId: string; readonly sessionsDir: string; readonly sessionPath: string; readonly startedAt: number; private exchangeCount; private threadName; constructor(sessionsDir: string, threadName: string, existingSessionId?: string); getSessionId(): string; /** * Create the session file with its header. */ initialize(): Promise; /** * Append an exchange to the session document. * Does not re-embed — that happens lazily at search time. */ appendExchange(userMsg: string, assistantMsg: string): Promise; /** * Read the session file and chunk it on exchange boundaries, * accumulating exchanges until the chunk reaches ~DEFAULT_CHUNK_SIZE tokens. */ getChunks(): Promise; /** * Generate embeddings for new/changed chunks and merge them into the thread's * consolidated session blob ({thread}.sessions/_sessions.embeddings.bin). * Only the last chunk can change (we only append), so earlier chunks are skipped. * Called fire-and-forget after each turn (embed-on-write) — keeps the active * session current so search regenerates nothing in steady state. */ generateMissingEmbeddings(): Promise; /** * Search ALL sessions in a directory against a query embedding. * * Reads the consolidated binary blob once (cached in memory — 0 reads warm), * scans it in memory, and lazily reads the `.md` file only for sessions that * actually matched. Replaces the old per-file fan-out (~2N stat + 2N read for * N sessions) that became the 21–24s contended `searchSessions` long pole. */ static searchAllSessions(sessionsDir: string, queryEmbedding: number[], currentSessionId: string, threshold?: number): Promise; /** * Reconstruct chunk content from parts given a chunk index. * Mirrors the chunking logic in getChunks(). */ private static getChunkContent; } //# sourceMappingURL=session.d.ts.map