import type { ChatMessage, CompletionResult, ProviderId, SuccessfulRequestSnapshot, ToolDefinition } from "../../../types.js"; import type { ToolDialect } from "../../../llm/tool-protocol.js"; import type { SessionPlan } from "../../../store/plan.js"; import type { BackgroundJob, ResponderNotification } from "../../../tools/jobs.js"; import type { OutcomeEnvelope } from "../../outcomes.js"; import type { WorkLedger } from "../../durable-envelope.js"; import type { CompactionExecutionState } from "../compaction-summarizer.js"; import type { CompactionAttemptLedger } from "../../compaction-attempt.js"; import { createCompactionRequestEstimator } from "../compaction-request-estimator.js"; import { createCompactionDurableEnvelopeBuilder } from "../compaction-durable-envelope.js"; import { createCompactionCoordinator, type CompactionAuditPayload } from "../compaction-coordinator.js"; export type CompactionAuditSink = (event: string, payload: CompactionAuditPayload) => void; export interface CompactionServicesInput { readonly messages: ChatMessage[]; readonly provider: () => ProviderId; readonly model: () => string; readonly dialect: () => ToolDialect; readonly signal: AbortSignal | undefined; readonly keepRecent: number; readonly sessionId: string; readonly outcome: OutcomeEnvelope; readonly ledger: WorkLedger; readonly attempts: CompactionAttemptLedger; readonly executionState: CompactionExecutionState; readonly contextLimitTokens: () => number | undefined; readonly selectTools: () => ToolDefinition[] | undefined; readonly selectToolsForResolvedDialect: () => ToolDefinition[] | undefined; readonly loadPlan: () => Promise; readonly loadPlanStrict: () => Promise; readonly projectRoot: () => string | undefined; readonly detectPackageManager: (root: string) => string | undefined; readonly pendingNotifications: () => readonly ResponderNotification[]; readonly runningJobs: () => readonly BackgroundJob[]; readonly recentJobs: () => readonly BackgroundJob[]; readonly requestSnapshot: () => SuccessfulRequestSnapshot | undefined; readonly clearRequestSnapshot: () => void; 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 writeDelta: (id: string, text: string, replace?: boolean) => void; readonly onUsage: (completion: CompletionResult) => void; readonly writeStarted: (id: string, beforeTokens: number) => void; readonly writeFailed: (id: string, message: string, retainedTokens: number) => void; readonly writeCompleted: (id: string, summary: string, beforeTokens: number, afterTokens: number) => void; readonly notify: (level: "info" | "warn", message: string) => void; readonly audit: CompactionAuditSink; } export interface CompactionServices { readonly estimateNextRequestTokens: ReturnType; readonly buildDurableEnvelope: ReturnType; readonly maybeAutoCompact: ReturnType; } export declare const createCompactionServices: (input: CompactionServicesInput) => CompactionServices;