import { type Exec } from '../exec.js'; import type { SupervisorBackend } from './types.js'; export declare const labelFor: (name: string) => string; /** * What `launchctl print` said about a job, parsed ONCE so that the two questions * asked of it cannot drift apart. They are not the same question: * * - `liveness` asks "does this role's context still exist" — a loaded job counts, * including one waiting between KeepAlive restarts; * - `install` asks "did the job I just bootstrapped actually START" — for which a * job that is loaded, not running, and has already exited once is a failure. * * On systemd one `ActiveState` answers both. Here the answers differ, so what is * shared is the READING of launchd's output, not its classification. */ export interface LaunchdJob { /** `launchctl print` exited 0 — the job is loaded in the domain. */ loaded: boolean; /** launchd's own `state = …`, e.g. `running`, `waiting`, `not running`. */ state?: string; /** * `last exit code|status|reason = …`. Present only once the program has RUN * and exited — which is what separates "died" from "has not started yet". */ lastExit?: string; /** The domain has no such service: a definite negative, not a failed probe. */ notFound: boolean; /** Why the probe itself could not be read, when it could not. */ failure?: string; } /** * Did the job we just bootstrapped actually start? * * `launchctl bootstrap` exits 0 once the job is LOADED. With `RunAtLoad` the * program then starts asynchronously, so a zero exit is a statement about the * load, not about the program — the same shape of lie that `systemctl enable * --now` tells on systemd 255, where the exit code is 0 and the unit is dead. * * Only a DEFINITE stop counts as a failed start, exactly as on systemd: * * - not loaded at all, though bootstrap said it worked → definite; * - loaded, `state` is not running, AND launchd already has an exit status for * it → it ran and died → definite; * - loaded and running, or waiting for a KeepAlive restart, or not running with * nothing exited yet (it simply has not been spawned yet — the asynchrony * RunAtLoad introduces) → NOT a failure; * - an unreadable probe → `unknown`, never a failure. launchd may be fine * and the tool merely unable to answer. */ export declare function classifyStart(job: LaunchdJob): { started: 'yes' | 'no' | 'unknown'; detail: string; }; export declare function makeLaunchdBackend(exec?: Exec, uid?: number): SupervisorBackend;