/** * meta-proxy process lifecycle (ADR-307) — start/stop/status/logs. * * Adapts daemon.ts's proven pattern (PID file, O_EXCL lockfile for atomic * check-then-start, signal-0 liveness, SIGTERM->1000ms->SIGKILL) to a * native binary instead of a forked Node process. `spawn()` here passes zero * arguments, always — starting the server is the argument-free behavior and * the only one this module wants. * * That is now a choice rather than a constraint. The 2026-07-16 note here * ("the binary takes no CLI flags — no `--version`/`--help`, any invocation * just starts the server") was true of the release pinned at the time, and * stopped being true: meta-proxy v0.7.2 handles `--help` before binding, and * v0.7.3 makes `--help`/`--version` win from any argv position. Do not read * the old note as "the binary cannot be asked what it is" — it can. The * installed version is still read from the install manifest rather than by * executing the binary, because a filesystem read cannot start a listener * and an exec of an old build can (a `--version` probe against 0.4.0 leaves * a daemon bound to 127.0.0.1:11435). * * Foreground `start` (the ADR-307 default) uses `stdio: 'inherit'` and * blocks directly — simplest and safest, no log-file redirection needed. * `start --service` needs REAL file-descriptor redirection * (`stdio: ['ignore', fd, fd]`) + `detached: true` + `unref()` via * `child_process.spawn()` directly — `SafeExecutor.executeStreaming()` * buffers output in-process, which is wrong for a process meant to outlive * the `ruflo` invocation that started it. * * @module proxy/lifecycle */ import * as fs from 'node:fs'; export declare class ProxyNotInstalledError extends Error { constructor(); } export declare class ProxyAlreadyRunningError extends Error { readonly pid: number; constructor(pid: number); } export interface ProxyStatus { installed: boolean; running: boolean; pid: number | null; stalePidFile: boolean; /** * The release recorded by the install that produced the binary on disk, or * null when unknown — either nothing is installed, or the binary predates * the manifest / the manifest was hand-removed. Callers must treat null as * "cannot tell", never as "up to date". */ version: string | null; } export declare function getProxyStatus(): ProxyStatus; /** * Foreground start (ADR-307 default) — blocks the caller until the process * exits or is interrupted. `stdio: 'inherit'` passes the proxy's own output * straight through to the terminal; signals (Ctrl+C) propagate naturally to * the child, no manual forwarding needed. */ export declare function startForeground(supervised?: boolean): Promise; /** * Background/`--service` start — detaches so the process outlives this * `ruflo` invocation, redirecting stdout/stderr to a real log file (not * buffered in-process). Returns once the child's PID is confirmed written, * without waiting for the process to exit. */ export declare function startBackground(): Promise<{ pid: number; }>; export interface StopResult { wasRunning: boolean; pid: number | null; } /** SIGTERM -> 1000ms -> SIGKILL if still alive, mirroring daemon.ts's killBackgroundDaemon. */ export declare function stopProxy(): Promise; export declare function readProxyLogTail(maxBytes?: number): string; /** Streams new log lines as they're appended, starting from the current end of file. */ export declare function watchProxyLog(onLine: (line: string) => void): fs.FSWatcher; //# sourceMappingURL=lifecycle.d.ts.map