import type { ChatMessage, ProviderId, SuccessfulRequestSnapshot, ToolDefinition } from "../../types.js"; import type { SessionPlan } from "../../store/plan.js"; import type { resolveToolDialect } from "../../llm/capabilities.js"; import { type CompactionAdmissionOptions } from "./compaction-admission.js"; import { executeAutomaticCompaction } from "./automatic-compaction-execution.js"; import type { CompactionExecutionState } from "./compaction-summarizer.js"; export type CompactionAuditPayload = Readonly>; export interface CompactionAttemptLedger { readonly isSuppressed: (key: string) => boolean; readonly recordFailure: (key: string) => void; readonly recordSuccess: (key: string) => void; readonly isExhausted?: ((key: string) => boolean) | undefined; } export interface CompactionCoordinatorPorts { readonly messages: ChatMessage[]; readonly provider: () => ProviderId; readonly model: () => string; readonly dialect: () => ReturnType; readonly keepRecent: number; readonly contextLimitTokens: () => number | undefined; readonly estimateRequestTokens: (messages: readonly ChatMessage[]) => number; readonly selectTools: () => ToolDefinition[] | undefined; readonly buildDurableEnvelope: () => Promise; readonly attempts: CompactionAttemptLedger; readonly executionState: CompactionExecutionState; readonly newCompactionId: () => string; readonly lastSuccessfulRequestSnapshot: () => SuccessfulRequestSnapshot | undefined; readonly clearSuccessfulRequestSnapshot: () => void; readonly summarize: Parameters[0]["summarize"]; readonly loadPlan: () => Promise; readonly instructionsBlock: () => string | undefined; readonly skillsBlock: () => string | undefined; readonly planApproved: () => boolean; readonly resetReadOnlyGuard: () => void; readonly refreshSessionState: (plan: SessionPlan | undefined) => void; readonly setLastCompactionMsgCount: (count: number) => void; readonly writeStarted: (id: string, beforeTokens: number) => void; readonly writeFailed: (id: string, message: string, beforeTokens: number) => void; readonly writeCompleted: (id: string, summary: string, beforeTokens: number, afterTokens: number) => void; readonly notify: (level: "info" | "warn", message: string) => void; readonly audit: (event: string, payload: CompactionAuditPayload) => void; } export declare const createCompactionCoordinator: (ports: CompactionCoordinatorPorts) => (reason: string, options?: CompactionAdmissionOptions) => Promise;