/** * Compress — selective compression of mid-importance, aging memories. * * Pure orchestration. The LLM call itself is injected as a callback so this * module has zero IO dependencies and is easy to unit-test. Marked experimental: * default `enabled: false` in config. * * Algorithm: * 1. Filter candidates by importance band and age (memories worth keeping * but not worth storing in full). * 2. Call `summarize` (callback) to produce a condensed string. The caller * can plug in any LLM provider (Ollama, OpenAI, etc.). * 3. Return a CompressUpdate per memory describing the payload that the * caller should persist (originalHash, parentId, new content, etc.). * * Compression preserves the original via parentId, so it is reversible at * the data layer. Synapse itself never mutates the DB. */ export interface CompressionCandidate { id: string; content: string; importance: number; /** ms since epoch */ createdAt: number; } export interface CompressConfig { enabled: boolean; /** Min importance for a candidate to be considered (must exceed). */ minImportance: number; /** Max importance — strongest memories are left intact. */ maxImportance: number; /** Min age in ms for compression to apply. */ minAgeMs: number; /** Skip candidates whose content is already short. */ minContentLength: number; /** Batch limit per cycle to avoid hot-pathing the LLM. */ maxBatchSize: number; } export interface CompressUpdate { id: string; newContent: string; parentId: string; originalHash: string; /** Token reduction estimate (chars proxy if no tokenizer available). */ charsBefore: number; charsAfter: number; } export type SummarizeFn = (input: { id: string; content: string; }) => Promise; /** * Filter candidates that match the compression criteria. Pure, no IO. */ export declare function selectCompressionCandidates(memories: CompressionCandidate[], config: CompressConfig, now?: number): CompressionCandidate[]; /** * Compress a batch using the provided summarize callback. Returns the * updates that should be persisted by the caller. Summaries shorter than * 50% of the original are kept as a basic quality gate; longer summaries * are dropped because they would not produce token savings. */ export declare function compressBatch(candidates: CompressionCandidate[], summarize: SummarizeFn, config: CompressConfig): Promise; export declare const DEFAULT_COMPRESS_CONFIG: CompressConfig; //# sourceMappingURL=compress.d.ts.map