import type { Context } from '../core/context.js'; import type { CompactReport, Compactor } from '../types/compactor.js'; import type { Provider } from '../types/provider.js'; import type { Logger } from '../types/logger.js'; import { type CompactionSummaryCache } from './compaction-summary-cache.js'; import type { OneShotOrchestrator } from './one-shot-llm.js'; /** * Options for IntelligentCompactor. */ export interface IntelligentCompactorOptions { /** Provider to use for LLM-assisted summarization. Required. */ provider: Provider; /** Fraction of maxContext that triggers a warning (default 0.5). */ warnThreshold?: number | undefined; /** Fraction of maxContext that triggers soft compaction (default 0.65). */ softThreshold?: number | undefined; /** Fraction of maxContext that triggers hard compaction (default 0.8). */ hardThreshold?: number | undefined; /** Max context window in tokens (used only for threshold fraction math). */ maxContext?: number | undefined; /** How many recent (user+assistant) pairs to always preserve (default 4). */ preserveK?: number | undefined; /** Token threshold below which tool results are not elided (default 300). */ eliseThreshold?: number | undefined; /** System prompt for the summarizer sub-LLM. */ summarizerPrompt?: string | undefined; /** * Model ID to use for summarization. When not set, falls back to * "deepseek-chat" when a OneShotOrchestrator is wired, or the agent's * own model otherwise. Set to a fast/cheap configured model for * resilience and cost efficiency. */ summarizerModel?: string | undefined; /** * OneShotOrchestrator for LLM-assisted summarization. When set, * `callSummarizer` uses it instead of the direct provider.complete() * call, gaining fallback chain support and a cheap default model. */ oneShotOrchestrator?: OneShotOrchestrator | undefined; /** * Shared cache for successful semantic summaries. By default uses the process-wide * cache; pass `summaryCache` to inject a private instance for tests or isolation. */ summaryCache?: CompactionSummaryCache | undefined; /** Structured logger. Defaults to noOpLogger (silent). */ logger?: Logger | undefined; } /** * An importance label for a message or message range. */ /** * IntelligentCompactor uses an LLM to: * - Analyze message importance and preserve critical context * - Generate semantic summaries for old message ranges * - Make intelligent decisions about what to compact * * It builds on the shared `compaction-core` elision/boundary primitives and * adds LLM-assisted summarization on top. When the summarizer call fails it * falls back to the same lossless rule-based digest used by HybridCompactor. */ export declare class IntelligentCompactor implements Compactor { private readonly provider; private readonly warnThreshold; private readonly softThreshold; private readonly hardThreshold; private readonly maxContext; private readonly preserveK; private readonly eliseThreshold; private readonly summarizerPrompt; private readonly summarizerModel?; private readonly oneShotOrchestrator?; private readonly summaryCache; private readonly logger; constructor(opts: IntelligentCompactorOptions); compact(ctx: Context, opts?: { aggressive?: boolean | undefined; }): Promise; /** * Estimate the full API request token count: messages + systemPrompt + toolDefs. * This is the accurate figure for context-window pressure monitoring. */ private estimateFullRequest; /** Run shared tool-result elision and commit through ConversationState. */ private elide; private summarizeAncientTurns; private callSummarizer; /** Compact string summary of messages (no TextBlock wrapper). */ private messagesToSummary; /** Match the summarizer's 500-character limit without joining full block payloads first. */ private boundedMessageText; } //# sourceMappingURL=intelligent-compactor.d.ts.map