/** * Inter-agent message compressor (#2727 dream-cycle, IB+VQ inspired). * * Dream-cycle #2727 (IB+VQ messaging 181.8% task gain): variable- * bandwidth compression at the inter-agent message boundary breaks the * performance/bandwidth tradeoff. Real VQ needs a codebook trained on * actual agent-to-agent traffic (own PR, own dataset). This v1 MVP * delivers the SPIRIT of the finding with a deterministic pipeline: * * 1. Extract structured "must-preserve" spans (code fences, inline * code, URLs, file paths, tool-call directives) — never compress * those; they're load-bearing. * 2. Score sentences by keyword density (TF-IDF against a domain * stop-list) and keep the top-K sentences that fit `budgetTokens`. * 3. Reassemble: preserved spans in original order + top scored * sentences. * * v2 wires a real VQ codec once the training pipeline lands. * * SCOPE: advisory tool + library. Callers decide whether to use the * compressed form. No auto-wire into SendMessage / hooks in v1. */ /** Result of a compression pass. */ export interface CompressionResult { original: string; compressed: string; stats: { originalTokens: number; compressedTokens: number; compressionRatio: number; preservedSpans: number; sentencesKept: number; sentencesTotal: number; /** Rough info-retention proxy: fraction of top-quartile-scored sentences kept. */ infoRetainedEstimate: number; }; } export interface CompressOptions { /** * Target token budget. The compressor keeps preserved spans first * (they're mandatory) and then fills the remaining budget with the * highest-scored sentences. Approximate — actual output may exceed * budget by up to one sentence if a preserved span is very large. */ budgetTokens?: number; /** * Mode: * 'keyword' → sentence score = sum(TF-IDF-approx) of unique keywords * 'sentence' → sentence score = length + position penalty (favor lead) * 'hybrid' → 0.7·keyword + 0.3·sentence (default) */ mode?: 'keyword' | 'sentence' | 'hybrid'; } /** ~1 token per 4 chars — matches the OpenAI/Anthropic rule-of-thumb. */ export declare function estimateTokens(text: string): number; export declare function compressMessage(message: string, options?: CompressOptions): CompressionResult; //# sourceMappingURL=message-compressor.d.ts.map