import { ITokenizer } from './tokenizers/i-tokenizer.js'; import { ISummarizer } from './summarization.js'; /** * Session state — addresses issues #121 and #122. * * A Session holds a single user's conversation history plus a per-file * content snapshot. The history is token-budgeted (see #121) and the file * snapshots feed context-delta tracking (#122). */ export type MessageRole = 'system' | 'user' | 'assistant' | 'tool'; export interface Message { role: MessageRole; content: string; timestamp: number; } export interface SessionFileState { [filePath: string]: string; } export interface SessionSnapshot { id: string; history: Message[]; fileState: SessionFileState; maxTokens: number; createdAt: number; updatedAt: number; } export interface SessionOptions { id?: string; maxTokens?: number; preserveTailRatio?: number; tokenizer?: ITokenizer; summarizer?: ISummarizer; /** * When true, getHistoryTokenCount may fall back to a character/4 * heuristic if no tokenizer is supplied. Production code should * always pass a real tokenizer and leave this false (the default). */ allowCharHeuristic?: boolean; /** Override for createdAt — used by fromSnapshot. */ createdAt?: number; /** Override for updatedAt — used by fromSnapshot. */ updatedAt?: number; } export declare class Session { readonly id: string; maxTokens: number; readonly createdAt: number; updatedAt: number; private history; private fileState; private readonly preserveTailRatio; private readonly tokenizer; private readonly summarizer; private readonly allowCharHeuristic; constructor(options?: SessionOptions); addMessage(role: MessageRole, content: string): Message; getHistory(): readonly Message[]; getFileState(): Readonly; getFileContent(filePath: string): string | undefined; setFileContent(filePath: string, content: string): void; clearFileContent(filePath: string): void; /** * Total token count of the current history. * * Requires a tokenizer unless the caller opted into the character/4 * heuristic via `allowCharHeuristic: true`. We default to requiring a * tokenizer because #124's whole point is eliminating char/4. */ getHistoryTokenCount(): Promise; /** * Compress the history by summarizing everything except the * preserve-tail fraction. Does nothing if history fits under maxTokens. * * Returns the new token count after compression. */ compressHistory(): Promise; toSnapshot(): SessionSnapshot; static fromSnapshot(snapshot: SessionSnapshot, options?: Omit): Session; } //# sourceMappingURL=session.d.ts.map