import { type CompactTrigger, type ConvergencePlan, type InFlightBatchProbe, type AutoCompactResult } from '../context/auto-compact-types.js'; import type { CompactTarget } from '../context/auto-compact-dispatcher.js'; export interface AutoCompactInput { /** Project root for context (default cwd). */ readonly projectRoot: string; /** Caller-provided in-flight batch probe (default false). */ readonly inFlightBatch?: InFlightBatchProbe | undefined; /** * Force execute even when ratio < threshold (test seam). In * production this is always `false` — peaks-cli drives compact * autonomously at 0.85+ with zero human / zero LLM intervention. */ readonly force?: boolean | undefined; /** Skip the 95% red-line gate (test seam — never true in production). */ readonly bypassRedLine?: boolean | undefined; /** Current session id (default = resolve via session-id-service). */ readonly sessionId?: string | undefined; /** Injectable env for IDE detection (test seam). */ readonly env?: NodeJS.ProcessEnv | undefined; /** Injectable clock for mtime checks (test seam). */ readonly now?: Date | undefined; /** * Slice 2026-06-28-solo-mode-bypass-fix (defect #4): which session * the compact should target. Default `'main'` — the orchestrator * (peaks-solo body) runs in the main-session Claude Code window and * wants to compress *its* context. Sub-agent shells pass * `'sub-agent'` to preserve the legacy shell-spawn behaviour. */ readonly target?: CompactTarget | undefined; } /** * Map a context ratio to a `CompactTrigger` action. Pure; the side * effects (checkpoint + IDE dispatch) live in `runAutoCompact`. Two * tiers: * * - ratio < 0.85 → 'none' or 'soft-warn' * - ratio ≥ 0.85 → 'pre-compact' (async-friendly path) * - ratio ≥ 0.95 → 'red-line' (synchronous gate) */ export declare function evaluateCompactTrigger(ratio: number): CompactTrigger; /** * Decide whether to run the auto-compact flow. Pure function for the * decision; side effects (checkpoint + IDE dispatch) live in * `runAutoCompact` below. Zero human / zero LLM intervention: * * - ratio < 0.85 → skip (LLM keeps working; no action) * - 0.85 ≤ ratio < 0.95 → pre-compact; if in-flight batch * present, defer (D6.e); else dispatch * IDE compact asynchronously. * - ratio ≥ 0.95 → red-line; ALWAYS dispatch synchronously * regardless of in-flight batch. */ export declare function evaluateAutoCompactDecision(input: { ratio: number; inFlightBatch?: InFlightBatchProbe | undefined; force?: boolean | undefined; bypassRedLine?: boolean | undefined; }): { shouldCompact: boolean; reason: 'below-threshold' | 'in-flight-batch' | 'pre-compact' | 'red-line'; trigger: CompactTrigger; }; /** * Build the convergence plan that D7's post-compact-detect will read * back. Includes the current plan, open questions, recent decisions, * todo state, and recent artifact paths — strictly more than what a * raw `/compact` would preserve. */ export declare function buildConvergencePlan(input: { readonly sessionId: string; readonly projectRoot: string; readonly ratio: number; readonly checkpointPath: string; readonly nextActions: readonly string[]; readonly redLine?: boolean; }): ConvergencePlan; /** * Execute the auto-compact flow. * * Steps (orchestration): * 1. Resolve session id. * 2. Read current ratio via AC-1 (`readContextPercent`). * 3. Evaluate trigger via `evaluateCompactTrigger`. * 4. If trigger.kind === 'none' / 'soft-warn' → return skip. * 5. If trigger.kind === 'pre-compact' AND in-flight batch → wait. * 6. If trigger.kind === 'pre-compact' → async dispatch (write * checkpoint + IDE compact; orchestrator returns immediately). * 7. If trigger.kind === 'red-line' → synchronous gate: refuse * sub-agent dispatch, dispatch IDE compact, mark `redLineGated`. * * The caller (CLI or skill body) handles the actual return — D7's * post-compact-detect will pick up the checkpoint on the next turn. * For red-line, the caller MUST block further tool calls until the * post-compact probe confirms ratio < 0.85. */ export declare function runAutoCompact(input: AutoCompactInput): Promise; /** Re-export for callers that need to surface the trigger shape. */ export type { CompactTrigger, ConvergencePlan, InFlightBatchProbe, AutoCompactResult };