import type { ChatHistoryEntry } from './chat-runtime-adapters.js'; export declare const PROACTIVE_COMPACTION_RATIO = 0.75; export declare const RECENT_TURNS_KEPT = 4; /** * Rough token estimate for a prompt. The model budgets in `context-builder` * are expressed in BYTES, so callers compare bytes-to-bytes; this helper exists * for callers/tests that want a token-ish number (≈ bytes / 4 for English text). */ export declare function estimateTokens(text: string): number; /** Byte size of a string (the unit `getContextBudgetForModel` returns). */ export declare function estimateBytes(text: string): number; /** * Decide whether the outgoing prompt should be compacted before sending. * Compares the estimated prompt byte size against the model's byte budget and * trips once the prompt crosses PROACTIVE_COMPACTION_RATIO of that budget. */ export declare function shouldCompactProactively(promptBytes: number, budgetBytes: number): boolean; /** * True when CLI stderr / output signals a context-overflow ("prompt too long") * failure that compaction-and-retry can recover from. Deliberately permissive — * the precise wording varies by CLI version, so prefer false positives (a * harmless extra compaction) over missing a real overflow. */ export declare function isContextOverflowError(text: string | null | undefined): boolean; /** * Build a concise, dependency-free digest of the conversation. Preserves the * thread's load-bearing state verbatim: the first user goal, any task ids, and * any explicit decisions, plus short per-turn takeaways. This avoids a separate * LLM summarization call (latency/cost/another failure mode); an LLM summary is * a possible future refinement noted in the issue. * * @param activeTaskId optionally pin the active task id (e.g. from the workflow) */ export declare function summarizeHistory(history: ChatHistoryEntry[], activeTaskId?: string): string; export type CompactionResult = { /** Whether compaction actually changed the history. */ compacted: boolean; /** The deterministic summary block (empty when not compacted). */ summary: string; /** * The compacted history to send to the model: a single synthetic assistant * "summary" turn followed by the most recent verbatim turns. When not * compacted this is the original history unchanged. */ history: ChatHistoryEntry[]; }; /** * Collapse older history into a summary turn, keeping the most recent * `recentTurns` verbatim. Returns the original history untouched when it is * already short enough to keep all turns verbatim. */ export declare function compactHistory(history: ChatHistoryEntry[], options?: { recentTurns?: number; activeTaskId?: string; }): CompactionResult; /** * Render a history list as the "Prior conversation" text block injected into the * outgoing prompt. Mirrors the formatting used by the /send handler so the * proactive path can measure and compact the exact text that would be sent. */ export declare function renderHistoryBlock(history: ChatHistoryEntry[]): string;