import { type Exec } from './exec.js'; export declare const TEMP_SUPERVISOR_FILE = ".temp-supervisor.json"; export declare const TEMP_TERMINATION_FILE = "termination.jsonl"; export declare const TEMP_STOP_REQUEST_FILE = ".temp-stop-request.json"; export declare const TEMP_RECLAIM_BATCH = 32; export declare const TEMP_LAUNCH_GRACE_MS = 60000; export type TempSupervisorKind = 'systemd-transient' | 'launchd-transient' | 'detached'; export type TempTerminationReason = 'identity-closed' | 'session-ended' | 'operator-stop' | 'supervisor-signal' | 'supervisor-recycle' | 'startup-failure' | 'stale-supervisor'; export interface TempSupervisorRecord { version: 1; role: string; launchId: string; createdAt: string; phase: 'launching' | 'active'; kind?: TempSupervisorKind; target?: string; pid?: number; binPath?: string; } export interface TempTerminationRecord { version: 1; role: string; launchId?: string; at: string; reason: TempTerminationReason; outcome: 'retired' | 'reclaimed' | 'failed'; detail: string; } export type SupervisorLauncher = (binPath: string, args: string[], dir: string) => void | Promise; export declare const tempSystemdUnit: (name: string) => string; export declare const tempLaunchdLabel: (name: string) => string; export declare function prepareTempSupervisor(dir: string, role: string): TempSupervisorRecord; export declare function readTempSupervisor(dir: string): TempSupervisorRecord | undefined; /** * Launch a temp supervisor outside the caller's service-manager ownership * boundary. `detached: true` creates a new process group but does not escape a * systemd cgroup; a transient unit does, and is not enabled across reboot. */ export declare function makeTempSupervisorLauncher(options?: { exec?: Exec; platform?: NodeJS.Platform; supervisor?: string; spawnDetached?: (binPath: string, args: string[], dir: string) => number; }): SupervisorLauncher; export declare function markTempSupervisorActive(dir: string, pid?: number): Promise; export declare function requestedTempStopReason(dir: string): 'operator-stop' | undefined; /** Move retired state out of the live roster without deleting any evidence. */ export declare function archiveTempState(role: string, reason: TempTerminationReason, outcome: TempTerminationRecord['outcome'], detail: string, now?: Date): string | undefined; /** Resolve only an exact role+launch archive; names and timestamps are never proof. */ export declare function tempArchiveForLaunch(role: string, launchId: string): string | undefined; /** Resolve one terminated archive by exact role + durable creation action. */ export declare function tempArchiveForCreationAction(role: string, creationActionId: string): { path: string; launchId: string; } | undefined; /** * Preserve a definitively stopped launch as recovery evidence, or prove that * its supervisor already did so. Never creates a second archive. */ export declare function secureStoppedTempArchive(role: string, launchId: string, deps?: TempLifecycleDeps): Promise; export interface TempLifecycleDeps { exec?: Exec; now?(): number; kill?(pid: number, signal: NodeJS.Signals | 0): void; log?(line: string): void; sleep?(ms: number): Promise; } export declare function tempSupervisorLiveness(dir: string, deps?: TempLifecycleDeps): Promise<'running' | 'stopped' | 'unknown'>; export declare function stopTempSupervisor(role: string, deps?: TempLifecycleDeps): Promise<'stopped' | 'already-stopped'>; /** * Move a bounded batch of definitely-dead temp state into the evidence archive. * Unknown/legacy/live entries are preserved; absence of proof is never cleanup authority. */ export declare function reclaimStaleTempState(deps?: TempLifecycleDeps): Promise;