/** * Discover-or-spawn: the shim's guarantee that a healthy daemon of this client's env FAMILY, * at least as new as this client, exists before it proxies. Discovery always goes through * the family pointer + a pid check + /healthz — never a blind dial of the default port — so a * foreign process squatting the port can never be mistaken for the daemon. The spawn lock * makes N concurrently starting shims produce exactly one daemon; losers poll until a * qualifying daemon reports healthy. * * Families: clients are keyed by their env fingerprint (the env the daemon bakes into its ACP * runner at construction). Different env → different family → different daemon; families never * contend, so a host with a custom backend env never flips another host's daemon. * * Succession inside a family is a TOTAL ORDER on version: normally a live daemon OLDER than this * shim is superseded, and an equal/newer daemon is adopted. One bootstrap exception protects the * first run-control upgrade: a busy predecessor that does not advertise control v1 is temporarily * adopted until its active runs/requests drain, so repointing discovery cannot strand them. The * pointer is never moved backward, preserving convergence. Once the predecessor is control-capable, * the successor takes the front door immediately while the predecessor remains the execution owner. */ import { type DaemonInfo } from "../daemon/daemon-info.js"; export interface EnsureDaemonOptions { /** The entry file to spawn with --daemon-run: the same bundle the shim itself runs from. */ bundlePath: string; port?: number; log: (line: string) => void; /** * Test seam: how to launch a daemon process. Defaults to a detached OS spawn of the shim's * own bundle with `--daemon-run` (plus `--supersede` when replacing a stale daemon). * Injected in unit tests to start an in-process successor. */ spawn?: (args: { bundlePath: string; port?: number; supersede: boolean; }) => void; } export type EnsuredDaemonInfo = DaemonInfo & { /** This newer shim temporarily adopted a busy predecessor that predates run control. */ compatibilityDrain?: true; }; declare function stopDaemon(pid: number, timeoutMs?: number): Promise; export declare function ensureDaemonRunning(options: EnsureDaemonOptions): Promise; export { stopDaemon }; //# sourceMappingURL=ensure-daemon.d.ts.map