/**
 * chat-transport daemon lifecycle — start / stop / status (CAT.1b).
 *
 * Ported from `src.legacy/chat/daemon/lifecycle.ts` onto the new-tree path
 * helpers (`chatDaemonPidPath` / `chatDaemonLogPath`). Single-instance per
 * machine, keyed on the pidfile under `OPENSQUID_HOME()`.
 *
 *   - `startDaemon` spawns a DETACHED child that re-invokes this binary with
 *     the `chat-daemon-worker` argv token; the child's `runDaemonWorker()`
 *     (worker.ts) writes its own pidfile on boot. Idempotent: a start against
 *     a live daemon returns `{ already_running: true }` without a second spawn.
 *   - `stopDaemon` sends SIGTERM, waits for the grace window, then SIGKILL.
 *     Idempotent.
 *   - `status` is read-only (pidfile + `kill -0` liveness).
 *
 * NOTE — CLI/autospawn wiring is CAT.1d, NOT this task. The `chat-daemon-worker`
 * argv dispatch that actually calls `runDaemonWorker()` is added to the binary
 * entrypoint there; `startDaemon`'s `entrypoint`/`workerArg` options exist so
 * CAT.1d (and tests) can point the spawn wherever they need without editing
 * this module.
 *
 * Imports from: node:child_process, node:fs, node:os, node:path,
 *   ../../runtime/paths.
 * Imported by: CAT.1d CLI + tests.
 */
export type DaemonStatus = {
    running: true;
    pid: number;
    uptime_ms: number | null;
} | {
    running: false;
    stale_pid?: number;
};
/**
 * Read the pidfile and report whether the recorded process is alive. A pidfile
 * pointing at a dead pid reports `{ running: false, stale_pid }` — read-only,
 * the caller decides whether to clean it up.
 */
export declare function status(): Promise<DaemonStatus>;
export interface StartDaemonOptions {
    /** Node binary to spawn. Defaults to `process.execPath`. */
    nodeBin?: string;
    /** Script to re-invoke. Defaults to `process.argv[1]` (the running binary). */
    entrypoint?: string;
    /** argv token the entrypoint dispatches to `runDaemonWorker()`. CAT.1d wires
     *  the dispatch; defaults to `chat-daemon-worker`. */
    workerArg?: string;
}
/**
 * Start the daemon by spawning a detached child running
 * `<nodeBin> <entrypoint> <workerArg>`. Returns once the child has either
 * written its pidfile (success) or the wait timed out (throws). Idempotent.
 */
export declare function startDaemon(options?: StartDaemonOptions): Promise<{
    already_running: boolean;
    pid: number;
}>;
/**
 * Stop a running daemon: SIGTERM, wait for the grace window, SIGKILL fallback.
 * Idempotent — a stop against a not-running daemon returns `{ stopped: false }`.
 */
export declare function stopDaemon(options?: {
    graceMs?: number;
}): Promise<{
    stopped: boolean;
    pid?: number;
}>;
//# sourceMappingURL=lifecycle.d.ts.map