export interface CompactionConfig { /** Compact once estimated context tokens reach this threshold. */ thresholdTokens: number; /** Always keep this many most-recent events verbatim (never summarized). */ keepRecent: number; } export interface CompactionSeams { /** Estimate the token footprint of a set of events. */ estimateTokens(events: E[]): number; /** * Persist durable facts from the events about to be summarized. MUST resolve * before summarization runs; if it rejects, compaction aborts (facts safe). */ flushDurableFacts(events: E[]): Promise; /** Produce ONE lossy summary event standing in for `events`. */ summarize(events: E[]): Promise; /** Optional: shrink a single event's tool output before it is summarized. */ pruneToolOutput?(event: E): E; } export interface CompactionResult { events: E[]; compacted: boolean; /** Proof the flush ran and resolved before summarize was invoked. */ flushedBeforeSummarize: boolean; /** Tokens estimated before vs after (only meaningful when compacted). */ tokensBefore: number; tokensAfter: number; } export declare const DEFAULT_COMPACTION_CONFIG: CompactionConfig; export declare class CompactionPolicy { private readonly seams; readonly config: CompactionConfig; constructor(seams: CompactionSeams, config?: CompactionConfig); /** True when the events' estimated tokens have reached the threshold. */ shouldCompact(events: E[]): boolean; /** * Compact if over threshold. Older events (all but the last `keepRecent`) are * pruned, their durable facts flushed, then replaced by a single lossy * summary. The flush-before-summarize ordering is enforced here; a flush * rejection aborts compaction with the original events intact. */ compact(events: E[]): Promise>; } //# sourceMappingURL=compaction.d.ts.map