/**
 * Daemon lifecycle management.
 *
 * Provides daemon info schema, PID file management, and process lifecycle
 * operations. Separates lifecycle from presentation — `stop_daemon` returns
 * a result object instead of logging directly.
 *
 * @module
 */
import { z } from 'zod';
import { type CommandDeps, type EnvDeps, type FetchDeps, type FsReadDeps, type FsRemoveDeps, type FsWriteDeps, type LogDeps } from '../runtime/deps.js';
/**
 * Daemon info schema for `~/.{name}/run/daemon.json`.
 */
export declare const DaemonInfo: z.ZodObject<{
    /** Schema version. */
    version: z.ZodNumber;
    /** Server process ID. */
    pid: z.ZodNumber;
    /** Port the server is listening on. */
    port: z.ZodNumber;
    /** ISO timestamp when server started. */
    started: z.ZodString;
    /** Package version of the application. */
    app_version: z.ZodString;
}, z.core.$strict>;
export type DaemonInfo = z.infer<typeof DaemonInfo>;
/**
 * Get the daemon info file path (`~/.{name}/run/daemon.json`).
 *
 * @param runtime - runtime with `env_get` capability
 * @param name - application name
 * @returns path to `daemon.json`, or null if `$HOME` is not set
 */
export declare const get_daemon_info_path: (runtime: Pick<EnvDeps, "env_get">, name: string) => string | null;
/**
 * Write daemon info to the PID file, creating directories as needed.
 *
 * @param runtime - runtime with file write and env capabilities
 * @param name - application name
 * @param info - daemon info to write
 * @mutates filesystem - creates `~/.{name}/run/` and atomically writes `daemon.json`
 * @throws Error if `$HOME` is not set
 */
export declare const write_daemon_info: (runtime: Pick<EnvDeps, "env_get"> & Pick<FsWriteDeps, "mkdir" | "write_text_file" | "rename">, name: string, info: DaemonInfo) => Promise<void>;
/**
 * Read and validate daemon info from the PID file.
 *
 * @param runtime - runtime with file read and env capabilities
 * @param name - application name
 * @returns parsed daemon info, or null if missing or invalid
 */
export declare const read_daemon_info: (runtime: Pick<EnvDeps, "env_get"> & Pick<FsReadDeps, "stat" | "read_text_file"> & LogDeps, name: string) => Promise<DaemonInfo | null>;
/**
 * Check if a process is running by PID.
 *
 * @param runtime - runtime with command execution capability
 * @param pid - process ID to check
 * @returns `true` if the process is running
 */
export declare const is_daemon_running: (runtime: CommandDeps, pid: number) => Promise<boolean>;
/**
 * Check if a daemon is healthy by probing its `/health` endpoint.
 *
 * Complements `is_daemon_running` (PID check) with an HTTP liveness probe.
 * Requires the daemon to register a `/health` route (e.g. via `create_health_route_spec`).
 *
 * @param deps - runtime with fetch capability
 * @param port - port the daemon should be listening on
 * @param host - hostname (default `localhost`)
 * @param timeout_ms - request timeout in milliseconds (default 2000)
 * @returns `true` if the health endpoint responds with 2xx
 */
export declare const check_daemon_health: (deps: FetchDeps, port: number, host?: string, timeout_ms?: number) => Promise<boolean>;
/**
 * Result of a `stop_daemon` operation.
 */
export interface StopDaemonResult {
    /** Whether a daemon was stopped. */
    stopped: boolean;
    /** PID of the stopped daemon, if any. */
    pid?: number;
    /** Human-readable message describing the outcome. */
    message: string;
}
/**
 * Stop a running daemon by sending SIGTERM and cleaning up the PID file.
 *
 * Returns a result object instead of logging directly, separating
 * lifecycle from presentation. Errors removing the PID file are swallowed
 * (the daemon's own shutdown handler may have removed it concurrently).
 *
 * @param runtime - runtime with command, file, and env capabilities
 * @param name - application name
 * @returns result describing the outcome
 * @mutates filesystem - removes `~/.{name}/run/daemon.json` on success or when corrupt
 * @mutates external process - sends `SIGTERM` to the daemon process via `kill`
 */
export declare const stop_daemon: (runtime: Pick<EnvDeps, "env_get"> & Pick<FsReadDeps, "stat" | "read_text_file"> & FsRemoveDeps & CommandDeps & LogDeps, name: string) => Promise<StopDaemonResult>;
//# sourceMappingURL=daemon.d.ts.map