/**
 * context-compaction.ts
 *
 * Context compaction engine for the GoodVibes platform runtime.
 *
 * Architecture:
 *   - Deterministic structure: fixed sections assembled in order
 *   - Targeted LLM calls for: substance filter, tool relevance, resolved problems,
 *     older agent summary
 *   - Rule-based sections: handoff, memories, current task, running agents,
 *     agent activity table, plan progress, session lineage
 *   - Post-compaction validation: sanity-checks required sections
 *   - Context-window-aware thresholds
 *
 * Public API:
 *   estimateConversationTokens(messages)   — rough token count for a message array
 *   estimateTokens(text)                   — rough token count for a string
 *   shouldAutoCompact(opts)                — check if 15k token buffer threshold is exceeded
 *   compactSmallWindow(messages, keepRecent) — simplified compaction for small context windows
 *   compactMessages(ctx, registry)         — structured compaction entry point
 *   checkAndCompact(autoOpts, ctx)         — check and compact if threshold exceeded
 *   getCompactionEvents()                  — return compaction event log
 *   getLastCompactionEvent()               — return most recent compaction event
 */
import type { ProviderMessage } from '../providers/interface.js';
import type { ProviderRegistry } from '../providers/registry.js';
import type { CompactionContext, CompactionResult, CompactionEvent } from './compaction-types.js';
export type { CompactionEvent, CompactionResult, CompactionContext } from './compaction-types.js';
export interface AutoCompactOptions {
    /** Current input token count from last LLM response. */
    currentTokens: number;
    /** Maximum context window for the current model. */
    contextWindow: number;
    /** Whether auto-compact is already in progress (prevent re-entry). */
    isCompacting: boolean;
}
/**
 * Tokens remaining in the context window at which auto-compaction triggers.
 * Compact when contextWindow - currentTokens <= COMPACTION_BUFFER_TOKENS.
 * 15k gives room for the ~6.5k compaction output + LLM extraction calls.
 */
export declare const COMPACTION_BUFFER_TOKENS = 15000;
/**
 * Context windows smaller than this use simplified compaction (summarize last N messages)
 * instead of the full structured output, since there isn't enough room for extraction calls.
 */
export declare const SMALL_WINDOW_THRESHOLD = 12000;
export declare function getCompactionEvents(): readonly CompactionEvent[];
export declare function getLastCompactionEvent(): CompactionEvent | null;
/** Rough token estimate: 4 chars ≈ 1 token. Used for threshold checks. */
export declare function estimateConversationTokens(messages: ProviderMessage[]): number;
export { estimateTokens } from './compaction-types.js';
/**
 * Returns true if the remaining context window is within COMPACTION_BUFFER_TOKENS
 * and compaction has not already been triggered.
 *
 * Triggers when: contextWindow - currentTokens <= 15000
 * The 15k buffer gives room for the ~6.5k compaction output + LLM extraction calls
 * + post-compaction work before the window is exhausted.
 */
export declare function shouldAutoCompact(opts: AutoCompactOptions): boolean;
/**
 * Simplified compaction for context windows smaller than SMALL_WINDOW_THRESHOLD (12k).
 * There isn't enough room for LLM extraction calls, so we just keep the last
 * `keepRecent` messages and add a brief summary note.
 *
 * @param messages - Full conversation message array
 * @param keepRecent - Number of recent messages to keep verbatim (default: 10)
 * @returns Truncated message array with a summary pair prepended
 */
export declare function compactSmallWindow(messages: ProviderMessage[], keepRecent?: number): ProviderMessage[];
/**
 * compactMessages — structured compaction entry point.
 */
export declare function compactMessages(ctx: CompactionContext, registry: ProviderRegistry): Promise<CompactionResult>;
/**
 * checkAndCompact — Check if context usage exceeds threshold and compact if so.
 * Returns the compaction result if compaction was performed, null otherwise.
 *
 */
export declare function checkAndCompact(autoOpts: AutoCompactOptions, ctx: CompactionContext, registry: ProviderRegistry): Promise<CompactionResult | null>;
//# sourceMappingURL=context-compaction.d.ts.map