import { type ChildProcess, type SpawnOptions } from 'node:child_process'; import type { CentralTaskRepository } from '../../infra/task/centralStateRepository.js'; export declare const CENTRAL_OWNER_TOKEN_ENV = "TAKT_CENTRAL_OWNER_TOKEN"; export declare const CENTRAL_STATE_ID_ENV = "TAKT_CENTRAL_STATE_ID"; export declare const CENTRAL_TASK_ID_ENV = "TAKT_CENTRAL_TASK_ID"; export declare const CENTRAL_EXECUTION_ID_ENV = "TAKT_CENTRAL_EXECUTION_ID"; export declare const CENTRAL_GENERATION_ENV = "TAKT_CENTRAL_GENERATION"; export type SpawnProcess = (command: string, args: readonly string[], options: SpawnOptions) => ChildProcess; export declare function buildWorkerArguments(workerEntryPath: string, input: { readonly stateId: string; readonly taskId: string; readonly generation: number; readonly executionId: string; }): string[]; export declare function buildCentralWorkerStderrPath(eventsDirectory: string, taskId: string, executionId: string): string; export interface SpawnCentralWorkerOptions { readonly workerEntryPath: string; readonly projectDirectory: string; readonly globalConfigDirectory: string; readonly stateId: string; readonly taskId: string; readonly generation: number; readonly executionId: string; readonly ownerToken: string; /** Durable central-state diagnostics for failures before worker adoption. */ readonly stderrPath?: string; readonly spawnProcess?: SpawnProcess; } export interface SpawnedCentralWorker { readonly child: ChildProcess; readonly pid: number; } export interface CentralWorkerReservation { readonly taskId: string; readonly generation: number; readonly executionId: string; readonly ownerToken: string; readonly runId?: string; } export declare class CentralWorkerStartupError extends Error { readonly code = "CENTRAL_WORKER_STARTUP_FAILED"; readonly recoveryRequired: boolean; constructor(message: string, recoveryRequired?: boolean); } export declare function centralWorkerHasExited(child: ChildProcess): boolean; /** * Keep the initial launcher subscribed after HTTP returns. A child that exits * before adoption is terminalized immediately by the reservation CAS rather * than waiting for a later request or reconciliation pass. */ export declare function monitorCentralStartupExit(repository: Pick, input: CentralWorkerReservation, child: ChildProcess): () => void; /** Wait for a successor to commit running/terminal state before its parent exits. */ export declare function waitForCentralWorkerStartup(repository: Pick, input: CentralWorkerReservation, child: ChildProcess, timeoutMs?: number): Promise<'adopted' | 'terminal'>; export declare function waitForSpawn(child: ChildProcess): Promise; /** * The owner token is deliberately present only in this private worker handoff * environment. It is never included in argv or the persisted task ledger. */ export declare function spawnCentralWorker(options: SpawnCentralWorkerOptions): Promise; //# sourceMappingURL=central-worker-spawn.d.ts.map