import type { Message } from "@kenkaiiii/gg-ai"; import type { BackgroundProcess } from "./process-manager.js"; /** * Pre-stop gate for background processes. * * `ProcessManager` pushes progress and exit checkpoints into the *steering* * path, which only lands while the agent is still looping. An agent about to * stop never sees them, so a run can claim "done" with a test run still in * flight, or with a build that already exited non-zero and was never read. * * This module is the process-side twin of `SubAgentManager.completionGateMessage` * and is deliberately pure so both hosts (AgentSession and the Ink app) wire it * identically. */ /** * Hard bound on gate injections per run. A wedged gate that never lets the turn * finish is worse than a premature "done", so after this many nudges the gate * goes silent. */ export declare const MAX_PROCESS_GATE_INJECTIONS = 2; /** The subset of `BackgroundProcess` the gate reasons about. */ export type GateableProcess = Pick; /** * A process blocks completion only when all three hold: * * 1. it started during the current run — a dev server the user deliberately * left running from an earlier turn must never deadlock the agent; * 2. it is unresolved: still running, or exited non-zero; * 3. its output was never consumed in that state — nothing read at all for a * running process, or unread bytes remaining for an exited one. */ export declare function isUnresolvedProcess(proc: GateableProcess, runStartedAt: number): boolean; /** Unresolved processes in stable start order, so the message is deterministic. */ export declare function selectUnresolvedProcesses(procs: readonly GateableProcess[], runStartedAt: number): GateableProcess[]; /** * The gate text, or undefined when nothing blocks completion. Wording mirrors * the child-agent gate so the model reads one contract for both. */ export declare function buildProcessCompletionGateMessage(procs: readonly GateableProcess[], runStartedAt: number): string | undefined; /** * Shared pre-finalization hook used by both AgentSession and the Ink host. * Returns null once `injected` reaches `MAX_PROCESS_GATE_INJECTIONS`. */ export declare function buildProcessCompletionFollowUp(procs: readonly GateableProcess[], runStartedAt: number, injected: number): Message[] | null; //# sourceMappingURL=process-gate.d.ts.map