import { type PiSessionForker } from "./pi-session-fork.js"; import { WorkflowRunStore } from "./run-store.js"; import { type PiProcessLaunchCommand, type WorkerLaunchAuthority } from "./worker-launch.js"; import { WorkflowLeaseManager, type ProcessIdentityInspector } from "./workflow-lease.js"; import type { AcceptanceCheck, ReportSchemaV1, RunProjectionV2, WorkerAttemptProjection, WorkerId, WorkerProjection, WorkerRequest } from "./workflow-types.js"; export declare const WORKER_PROTOCOL_LINE_LIMIT_BYTES: number; export declare const WORKER_STDERR_TAIL_LIMIT_BYTES: number; export declare class WorkerProtocolError extends Error { readonly code: "protocol_output_limit" | "protocol_invalid_json"; readonly limitBytes?: number | undefined; constructor(code: "protocol_output_limit" | "protocol_invalid_json", message: string, limitBytes?: number | undefined); } export { BudgetExceededError } from "./run-store.js"; export type { PiProcessLaunchCommand } from "./worker-launch.js"; export interface ProcessExit { readonly code: number | null; readonly signal: string | null; } export interface ManagedWorkerProcess { readonly pid: number; readonly stdout: AsyncIterable; readonly stderr: AsyncIterable; readonly protocol: AsyncIterable; readonly exited: Promise; writeLine(line: string): Promise; endInput(): Promise; signalProcessGroup(signal: NodeJS.Signals): Promise; closeParentLiveness(): Promise; } export interface PiProcessFactory { spawn(command: PiProcessLaunchCommand): Promise; } export interface WorkerTimerScheduler { schedule(delayMs: number, callback: () => void): { cancel(): void; }; } export interface WorkerProcessSupervisorOptions { readonly namespaceDirectory: string; readonly store: WorkflowRunStore; readonly leaseManager: WorkflowLeaseManager; readonly supervisorGeneration: string; readonly inspector: ProcessIdentityInspector; readonly processFactory: PiProcessFactory; readonly launchAuthority: WorkerLaunchAuthority; readonly timerScheduler?: WorkerTimerScheduler; readonly now?: () => Date; readonly cancellationGraceMs?: number; readonly sessionForker?: PiSessionForker; } export type SpawnWorkerResult = { readonly kind: "started"; readonly worker: WorkerProjection; readonly attempt: WorkerAttemptProjection; readonly settlement: Promise; } | { readonly kind: "existing" | "needs-reconcile"; readonly worker: WorkerProjection; readonly attempt: WorkerAttemptProjection; }; export type CancelWorkerResult = { readonly kind: "requested"; readonly projection: RunProjectionV2; } | { readonly kind: "indeterminate"; readonly projection: RunProjectionV2; readonly reason: string; }; export declare class ResumeRefusedError extends Error { constructor(message: string); } export declare class WorkerProcessSupervisor { #private; constructor(options: WorkerProcessSupervisorOptions); updateLaunchAuthority(authority: WorkerLaunchAuthority): void; spawnWorker(requestKey: string, input: { readonly request: WorkerRequest; readonly prompt: string; readonly depth: number; readonly parentWorkerId?: WorkerId | null; readonly continueWorkerId?: WorkerId; }): Promise; resumeWorker(requestKey: string, input: { readonly workerId: WorkerId; readonly prompt: string; }): Promise; cancelWorker(requestKey: string, input: { readonly workerId: WorkerId; readonly reason: string; }): Promise; steerWorker(requestKey: string, input: { readonly workerId: WorkerId; readonly message: string; readonly correlation?: string; }): Promise; reviseWorkerContract(requestKey: string, input: { readonly workerId: WorkerId; readonly correlation?: string; readonly goal?: string; readonly acceptance?: readonly string[]; readonly constraints?: readonly string[]; readonly report_schema?: ReportSchemaV1; readonly requires_human_approval?: boolean; readonly acceptance_check?: AcceptanceCheck; }): Promise; reconcileRun(requestKey: string): Promise; } export declare class NodePiProcessFactory implements PiProcessFactory { spawn(command: PiProcessLaunchCommand): Promise; } //# sourceMappingURL=worker-process-supervisor.d.ts.map