/**
 * CompactionOrchestrator - Manages manual and automatic context compaction.
 *
 * Handles:
 * - Manual compaction (user-triggered /compact)
 * - Auto-compaction when context exceeds threshold
 * - Overflow recovery when LLM returns context overflow errors
 * - Extension integration for custom compaction providers
 * - Branch summarization abort coordination
 */
import type { Agent } from "@nerf/pi-agent-core";
import type { AssistantMessage, Model } from "@nerf/pi-ai";
import { type CompactionResult } from "./compaction/index.js";
import type { ExtensionRunner } from "./extensions/index.js";
import type { ModelRegistry } from "./model-registry.js";
import type { SessionManager } from "./session-manager.js";
import type { SettingsManager } from "./settings-manager.js";
import type { AgentSessionEvent } from "./agent-session.js";
/** Dependencies injected from AgentSession into CompactionOrchestrator */
export interface CompactionOrchestratorDeps {
    readonly agent: Agent;
    readonly sessionManager: SessionManager;
    readonly settingsManager: SettingsManager;
    readonly modelRegistry: ModelRegistry;
    getModel: () => Model<any> | undefined;
    getSessionId: () => string;
    getExtensionRunner: () => ExtensionRunner | undefined;
    emit: (event: AgentSessionEvent) => void;
    disconnectFromAgent: () => void;
    reconnectToAgent: () => void;
    abort: () => Promise<void>;
}
export declare class CompactionOrchestrator {
    private readonly _deps;
    private _compactionAbortController;
    private _autoCompactionAbortController;
    private _overflowRecoveryAttempted;
    private _branchSummaryAbortController;
    constructor(_deps: CompactionOrchestratorDeps);
    /** Whether compaction or branch summarization is currently running */
    get isCompacting(): boolean;
    /** Reset overflow recovery flag (called when a new user message starts) */
    resetOverflowRecovery(): void;
    /** Mark overflow recovery as not needed (called on successful assistant response) */
    clearOverflowRecovery(): void;
    /** Get/set the branch summary abort controller (used by navigateTree) */
    get branchSummaryAbortController(): AbortController | undefined;
    set branchSummaryAbortController(controller: AbortController | undefined);
    /**
     * Manually compact the session context.
     * Aborts current agent operation first.
     * @param customInstructions Optional instructions for the compaction summary
     */
    compact(customInstructions?: string): Promise<CompactionResult>;
    /** Cancel in-progress compaction (manual or auto) */
    abortCompaction(): void;
    /** Cancel in-progress branch summarization */
    abortBranchSummary(): void;
    /**
     * Check if compaction is needed and run it.
     * Called after agent_end and before prompt submission.
     *
     * Two cases:
     * 1. Overflow: LLM returned context overflow error, remove error message, compact, auto-retry
     * 2. Threshold: Context over threshold, compact, NO auto-retry
     *
     * @param assistantMessage The assistant message to check
     * @param skipAbortedCheck If false, include aborted messages (for pre-prompt check). Default: true
     */
    checkCompaction(assistantMessage: AssistantMessage, skipAbortedCheck?: boolean): Promise<void>;
    /** Toggle auto-compaction setting */
    setAutoCompactionEnabled(enabled: boolean): void;
    /** Whether auto-compaction is enabled */
    get autoCompactionEnabled(): boolean;
    private _runAutoCompaction;
}
//# sourceMappingURL=compaction-orchestrator.d.ts.map