import type { AdoptionEvidence, BackgroundJobEvent, BackgroundJobOwnership, BackgroundJobRecord, JobLogsRequest, JobLogsResult, JobStatusClassification } from "./types.js"; export interface StartJobOptions { jobId?: string; executable: string; args?: string[]; cwd?: string; workspaceId?: string; ownerRunId?: string; ownership?: BackgroundJobOwnership; env?: Record; restartPolicy?: string; startupTimeoutMs?: number; healthCheck?: () => Promise | boolean; maxLogBytes?: number; } export interface BackgroundJobRegistryOptions { storageDir: string; workspaceId?: string; ownerRunId?: string; now?: () => number; isWindows?: boolean; } /** * Durable, authoritative background-job registry. Jobs are recorded before or * atomically with launch, owned through process-tree/group primitives, stopped * only after identity verification, and never kill unrelated processes. */ export declare class BackgroundJobRegistry { private readonly storageDir; private readonly jobsDir; private readonly logDir; private readonly eventsPath; private readonly workspaceId?; private readonly ownerRunId?; private readonly now; private readonly isWindows; private readonly running; constructor(opts: BackgroundJobRegistryOptions); private recordPath; private stdoutPath; private stderrPath; init(): Promise; private appendEvent; private persist; read(jobId: string): Promise; list(): Promise; private register; /** * Start a new durable background job. The record is written before launch, * then the process tree is spawned and its identity captured. Returns only * after authoritative startup status is known. */ start(options: StartJobOptions): Promise; private onExit; private onError; private killProcess; /** Classify verified live status of a job, checking real process identity. */ status(jobId: string): Promise; /** Bounded log retrieval. Logs are untrusted content. */ logs(req: JobLogsRequest): Promise; /** * Stop an owned job. Verifies ownership identity before terminating the * owned process tree; never kills an unrelated process that merely shares a * name. */ stop(jobId: string): Promise; /** Restart a job: new process identity, lineage preserved. */ restart(jobId: string, cause?: string): Promise; /** * Conservative adoption. Adopts a process only with strong identity * evidence (executable, command line, cwd, start time). Never adopts by PID * or name alone. Refuses without matching evidence. */ adopt(jobId: string, evidence: AdoptionEvidence): Promise; /** Refuse adoption for a process lacking matching identity evidence. */ refuseAdoption(jobId: string): Promise; /** * Long-horizon completion gate. A step requiring a running/healthy job * cannot be considered complete while the required job state is unresolved. */ gateStepCompletion(requireJobId?: string, requireState?: "running" | "healthy" | "exited" | "stopped"): Promise<{ canComplete: boolean; blockingReason?: string; }>; /** Shutdown: stop all owned jobs; no leaks. */ shutdown(): Promise; readEvents(): Promise; remove(jobId: string): Promise; /** Move durable state files (survives restarts across sessions). */ relocate(_storageDir: string): Promise; } //# sourceMappingURL=registry.d.ts.map