/**
 * Context Collapse — staged lightweight context reduction that runs
 * BEFORE autocompact and can drain on 413 BEFORE reactive compact.
 *
 * CC parity: services/contextCollapse/index.ts
 *
 * Architecture:
 * 1. applyCollapsesIfNeeded() — runs every iteration, projects the
 *    collapsed view and maybe commits more collapses (by summarizing
 *    old tool-result groups into compact summaries).
 * 2. recoverFromOverflow() — drain all staged collapses on a real
 *    API 413. If it can free enough context, the retry may succeed
 *    without reactive compact (which is heavier and destroys more
 *    context).
 *
 * Collapses are ordered "stages" — oldest first. Each stage replaces
 * a contiguous run of old messages with a single summary line.
 */
export interface CollapseStage {
    /** UUID of the stage (for dedup and ordering). */
    id: string;
    /** Index range [start, end) in the original message array. */
    range: [number, number];
    /** Summary text that replaces the range. */
    summary: string;
    /** Whether this stage has been committed (applied to messages). */
    committed: boolean;
}
export interface CollapseStore {
    stages: CollapseStage[];
}
export declare function createCollapseStore(): CollapseStore;
/**
 * Evaluate whether new collapses should be staged.
 *
 * Heuristic: if the conversation has > thresholdMessages non-system messages,
 * group old tool-result runs into collapse stages.
 */
export declare function applyCollapsesIfNeeded<T extends {
    role: string;
    content?: string | unknown;
}>(messages: T[], store: CollapseStore, opts?: {
    thresholdMessages?: number;
}): {
    messages: T[];
    stagedCount: number;
};
/**
 * Drain all staged (uncommitted) collapses — called on 413 recovery.
 * Commits every pending stage and returns the collapsed messages.
 */
export declare function recoverFromOverflow<T extends {
    role: string;
    content?: string | unknown;
}>(messages: T[], store: CollapseStore): {
    messages: T[];
    committed: number;
};
