/** * The seat side of a `once` task's handoff. A once task is handed to the harness at most once per * seat process: a second run of it is one the spawner could not see, so an ambiguous handoff ends * the task instead of offering it again. * * A task moves pending → claimed → confirmed, or claimed → sealed. Claimed is a permit an adapter * takes at its dispatch site, right before the native send; confirmed is its native acceptance * ({@link MeshAgent.commitSurfacedTurns}); sealed is a dispatch it gave up on, or a claim that * outlived {@link ONCE_HANDOFF_MS}. The first of confirmed and sealed wins, and neither is undone. * A dispatch whose send is its acceptance, such as a prompt hook that edits the prompt in place in * the same synchronous step as its peek, confirms without a claim. * * The state lives in one registry per process, reached through a `Symbol.for` key, so every copy * of this module loaded in the process and every `MeshAgent` built again for the same seat read * the same entries. A once seat is never restarted, so no second process runs under its uid. */ /** The bound on one dispatch attempt, from the claim to the harness's acceptance. It is above every * adapter's own dispatch timeout and never measures the model's response. */ export declare const ONCE_HANDOFF_MS = 60000; /** How long a seat that must end itself waits for its own graceful shutdown before it exits. */ export declare const ONCE_EXIT_GRACE_MS = 10000; export type OnceHandoffState = "pending" | "claimed" | "confirmed" | "sealed"; export declare function onceHandoffState(uid: string, goalId: string): OnceHandoffState; /** Take the permit for every once task in `goalIds`, or for none: succeeds only when each is still * pending, and starts each one's handoff timer. */ export declare function claimOnceHandoff(uid: string, goalIds: readonly string[]): boolean; /** The harness accepted the task. False when the handoff was already sealed: that task is not * marked surfaced, so no automatic yield follows for it. */ export declare function confirmOnceHandoff(uid: string, goalId: string): boolean; /** Seal a claimed task as not confirmed. True only for the call that sealed it. */ export declare function sealOnceHandoff(uid: string, goalId: string): boolean; /** End the handoff of a task its manager settled without this seat (its deadline, a stop), whether * or not a dispatch had claimed it, so no later claim can send it. A confirmed task stays confirmed. * Nothing is reported: the manager already holds the task's terminal. */ export declare function endOnceHandoff(uid: string, goalId: string): void; /** The dispatch left the seat; the acceptance arrives with the model's response, which the * handoff timer must not measure. */ export declare function stopOnceHandoffTimer(uid: string, goalId: string): void; export declare function onOnceHandoffTimeout(fn: (uid: string, goalId: string) => void): void; /** An adapter's graceful shutdown for a once seat that must end itself. It starts the shutdown and * returns nothing, or answers whether the seat is ending: an adapter whose own process is not the * seat (Claude's MCP server is a child of `claude`) answers false when it cannot end the seat. A * promise must settle, since no forced exit is armed until it does. */ export type OnceExit = () => void | boolean | Promise; /** Register the adapter's graceful shutdown for a once seat that must end itself. */ export declare function registerOnceExit(fn: OnceExit): void; /** End this seat: start the adapter's graceful shutdown, then exit this process after * {@link ONCE_EXIT_GRACE_MS} whatever that shutdown is doing. Its manager proves the exit, and the * exit settles the task. A shutdown that answers false declines: no forced exit is armed, this * process keeps running, and the caller keeps reporting. Resolves whether the seat is ending; a * call while an exit is in flight gets that exit's answer. */ export declare function exitOnceSeat(): Promise; //# sourceMappingURL=once.d.ts.map