UNPKG

@code-yeongyu/senpi

Version:

Coding agent CLI with read, bash, edit, write tools and session management

59 lines • 3.2 kB
/** * The child half of the execution barrier (senpi#3566, plan todo 4). Every launch path asks the gate for a slot, which * sends `launch` with the containment handle; the server records it and acknowledges. The launch path then stores its * invoke tick immediately before the real call and calls `invoking`, and the gate publishes `launch_proof` from the * shared clock without waiting for the call to return. `done` reports completion separately, with no deadline. */ import { BarrierClock } from "./barrier-clock.ts"; import type { ToolChildChannel } from "./channel.ts"; import type { LaunchApi, LaunchContainment, LaunchLifetime, LaunchOrigin, ToolChildMessage } from "./protocol.ts"; import type { WorkerLaunchMessage } from "./worker-launch.ts"; export interface LaunchRequest { readonly jobId: string; readonly origin: LaunchOrigin; readonly api: LaunchApi; readonly containment: LaunchContainment; readonly lifetime: LaunchLifetime; readonly pid?: number; readonly pgid?: number; } export interface GatedLaunch { readonly launchId: string; readonly slot: number; /** Resolves when the server's `launch_ack` has been recorded on the shared clock. */ readonly acked: Promise<void>; } export declare class LaunchGateError extends Error { readonly code: string; constructor(code: string, message: string); } export declare class LaunchGate { #private; readonly clock: BarrierClock; constructor(channel: ToolChildChannel, clock?: BarrierClock, env?: NodeJS.ProcessEnv, creatorInJob?: () => boolean); /** Windows: the command a launch started, with whether its creator (this child) was inside a job when it did. */ started(launchId: string, pid: number, breakaway?: boolean): void; /** Test-only `SKIP_ACK_WAIT` mutation: launch paths invoke without awaiting the ack. */ get skipsAckWait(): boolean; request(request: LaunchRequest): GatedLaunch; /** Protocol loop: a launch a worker announced on a slot it claimed itself on the shared clock. */ adopt(launchId: string, slot: number, request: LaunchRequest): void; handleWorker(message: WorkerLaunchMessage): void; /** Protocol loop: a frame the gate owns. Returns false for frames it does not handle. */ handle(message: ToolChildMessage): boolean; /** Main-thread launch path: records the invoke tick and publishes the proof. Call immediately before the real call. */ invokeNow(launchId: string): void; /** Protocol loop: a launch path (any thread) has stored its invoke tick; publish the proof from the clock. */ invoking(launchId: string): void; /** * Ends the owned own-group commands a cancelled job started that are still running (no `launch_done` yet). Their * leaders are this process's unreaped children, so each pgid is still the group this job created - never a reused * one. Detached launches outlive their job by contract and are left alone. Returns the groups signalled. */ endJobGroups(jobId: string): number[]; done(launchId: string, outcome: { readonly exitCode?: number; readonly signal?: string; }): void; } //# sourceMappingURL=launch-gate.d.ts.map