/** * daemonStatus -- the "is a daemon running, which version, since when, is it healthy" diagnostic * surface every consumer's CLI exposes as ` status`. Split out of daemon-client.ts's own * bundled concerns -- still zero runtime imports outside this package's own daemon-client/* * siblings (see daemon-client.ts's own module doc comment for why that invariant matters for * Pi's jiti-based extension loader). */ import type { DaemonHandleLike } from "./connect-with-policy.js"; import type { CircuitBreakerState } from "./retrying-client.js"; export type DaemonStatusState = "running" | "not-running" | "stale-handle" | "unreachable"; export interface DaemonStatus { state: DaemonStatusState; pid?: number; version?: string; uptimeMs?: number; breaker?: CircuitBreakerState; /** Set only for state "unreachable" -- the error the connect/version-read attempt raised. */ lastError?: string; /** One human-readable line, safe to print as-is; every other field is the machine-readable detail behind it. */ summary: string; } export interface DaemonStatusOptions { readHandle: () => Handle | null; buildClient: (handle: Handle) => Client | Promise; /** Optional -- e.g. reads the daemon's /health response. Omit to report liveness without a version. */ readVersion?: (client: Client) => Promise; /** Optional -- computes uptime from whatever the handle/caller already tracks (this module does not itself define where a start timestamp lives). */ startedAtMs?: (handle: Handle) => number | undefined; /** Reports a createRetryingClient's breakerState() inline, so "why is nothing happening" and "is the breaker open" are answered by one call. */ breaker?: () => CircuitBreakerState; /** Defaults to process.kill(pid, 0)/EPERM-is-alive semantics. Injectable for tests. */ isPidAlive?: (pid: number) => boolean; } /** * Answers "is a daemon running, which version, since when, is it healthy" * without the user (or the extension debugging on their behalf) needing to * read the handle file or run `ps` by hand -- the one diagnostic surface * every consumer's CLI can expose as ` status` for parity with the * rest of this house's daemon-backed CLIs. */ export declare function daemonStatus(options: DaemonStatusOptions): Promise;