export declare const LANE_EXECUTION_SCHEMA: "mcp.lane-execution.v1"; export declare const UNKNOWN_LANE_EXECUTION_MESSAGE: "unknown lane execution id"; export declare const MAX_BROKER_TERMINAL_EXECUTIONS = 100; export declare const MAX_BROKER_TASK_CHARS: number; export declare const MAX_BROKER_PATH_CHARS = 4096; export declare const MAX_BROKER_ID_CHARS = 200; export declare const MAX_BROKER_TIMEOUT_MS: number; export type LaneExecutionStatus = "running" | "completed" | "failed" | "timed_out" | "cancelled"; export interface LaneExecutionActivity { stdoutBytes: number; stderrBytes: number; lastOutputAt: number | null; /** Cumulative CPU ms for the exact process tree the daemon owns, when available. */ cpuMs?: number; /** Relay traffic for this execution's private activity tag, when the daemon has seen any. */ relayInFlight?: number; relayLastActivityAt?: number; } export interface LaneExecutionRunResult { code: number | null; stdout: string; stderr: string; timedOut: boolean; } export interface LaneExecutionLaunchHandle { result: Promise; cancel: () => void; /** May sample OS process state, so status collection allows an async reader. */ activity?: () => LaneExecutionActivity | Promise; /** * Bounded launch corrections the caller would have recorded locally before D1. Never include * environment VALUES; the existing correction producers name only variable/reference names. */ launchNotes?: readonly string[]; } export interface LaneExecutionStartRequest { action: "start"; executionId: string; jobId: string; laneId: string; task: string; cwd: string; timeoutMs: number; /** Current MCP dispatch recursion depth; the daemon launcher writes depth + 1 into the child. */ depth: number; /** Routing ladder key; config may use names beyond the four effort bands. */ tier?: string; readOnly?: boolean; callerRoot?: string; host?: "routed" | "bypassed" | "unknown"; entrypoint?: string; } export interface LaneExecutionStatusRequest { action: "status"; executionId: string; } export interface LaneExecutionCancelRequest { action: "cancel"; executionId: string; } export type LaneExecutionBrokerRequest = LaneExecutionStartRequest | LaneExecutionStatusRequest | LaneExecutionCancelRequest; export interface LaneExecutionSnapshot { schema: typeof LANE_EXECUTION_SCHEMA; executionId: string; jobId: string; laneId: string; status: LaneExecutionStatus; startedAt: number; endedAt: number | null; stdoutBytes: number; stderrBytes: number; lastOutputAt: number | null; cpuMs?: number; relayInFlight?: number; relayLastActivityAt?: number; launchNotes?: string[]; /** Terminal-only process result. */ code?: number | null; stdout?: string; stderr?: string; timedOut?: boolean; } export type LaneExecutionBrokerResult = { ok: true; execution: LaneExecutionSnapshot; } | { ok: false; status: 400 | 404 | 409 | 503; message: string; }; /** * Parse the broker's public snapshot at an untrusted HTTP/file boundary. * * The optional process-result fields travel as one group: a running execution has none; a * cancelled execution may have none until its killed child settles; every other terminal * execution carries the full quartet. Unknown keys fail closed so a protocol revision cannot be * silently misread by an older MCP client. */ export declare function parseLaneExecutionSnapshot(value: unknown): LaneExecutionSnapshot | null; export type LaneExecutionLauncher = (request: LaneExecutionStartRequest) => LaneExecutionLaunchHandle | { refusal: string; }; export interface LaneExecutionBrokerPort { handle(request: LaneExecutionBrokerRequest): Promise; /** Daemon shutdown owns and terminates every still-running broker process tree. */ shutdown?(): void; } export declare function parseLaneExecutionBrokerRequest(value: unknown): LaneExecutionBrokerRequest | null; export declare class LaneExecutionBroker implements LaneExecutionBrokerPort { private readonly launch; private readonly now; private readonly maxTerminal; private readonly executions; constructor(launch: LaneExecutionLauncher, now?: () => number, maxTerminal?: number); /** Graceful daemon shutdown: cancel every process tree this broker still owns. */ shutdown(): void; handle(request: LaneExecutionBrokerRequest): Promise; private start; private status; private cancel; private settle; private snapshot; private prune; }