import type { LinkStatusView } from "./cloud/link.js"; import type { Events } from "./events.js"; import { type JobRecord } from "./jobs.js"; import type { Paths } from "./paths.js"; export type CheckStatus = "ok" | "warn" | "fail" | "skip"; export type HealthGroup = "system" | "skillhook" | "runners" | "tools" | "skills" | "exposure"; export declare const HEALTH_GROUPS: HealthGroup[]; export interface Check { name: string; status: CheckStatus; detail: string; hint?: string; group: HealthGroup; /** Structured facts behind the line (versions, server lists, sizes) for dashboards. */ data?: Record; } export interface HealthSummary { ok: number; warn: number; fail: number; skip: number; } export interface HealthReport { checks: Check[]; ok: boolean; summary: HealthSummary; groups: Record; public_url?: string; server?: { base_url: string; running: boolean; version?: string; }; generated_at: string; duration_ms: number; /** The deep checks (MCP servers, plugins, `codex doctor`, last runs) were included. */ deep: boolean; /** The npm registry was asked and the public URL probed. */ network: boolean; } export interface HealthOptions { /** Environment consulted for the update check (`SKILLHOOK_NO_UPDATE_CHECK`, `CI`, `SKILLHOOK_NPM_REGISTRY`) and for the probes' base environment. */ env?: NodeJS.ProcessEnv; fetchImpl?: typeof fetch; /** Probe MCP servers, plugins, the CLIs' own doctor and each skill's last run (one process per listing). Default true. */ deep?: boolean; /** Ask the npm registry for the newest version and probe the public URL. Default true (the server's cache asks for false unless told otherwise). */ network?: boolean; /** Look at Tailscale and the public URL. Default true. */ exposure?: boolean; /** Look at the launchd / systemd service. Default true. */ service?: boolean; /** Read systemd lingering (tests). Default: `loginctl show-user`. */ linger?: () => Promise<"yes" | "no" | "unknown">; /** Facts of the server this runs inside, instead of probing it over HTTP. */ live?: () => { started_at: string; queue: { running: number; queued: number; }; }; /** For the slow probes (`claude mcp list` connects to every server, `codex doctor`). Default 20 s. */ timeoutMs?: number; /** The cloud link of the server this runs inside. */ cloud?: () => LinkStatusView | undefined; } export declare function formatUptime(seconds: number): string; /** The `sleep` value of `pmset -g custom` on macOS (AC power when listed), in minutes; undefined when pmset is unavailable or unreadable. */ export declare function macSleepMinutes(): Promise; /** Asked for Claude Code and ran on another runner because Claude Code's login did not work (a run refused, or the pre-flight). */ export declare function claudeLoginFallback(job: JobRecord): boolean; /** The `claude fallbacks` row over recent jobs: failing while the newest fallback is newer than Claude Code's newest successful run. */ export declare function claudeFallbackCheck(jobs: JobRecord[]): { status: CheckStatus; detail: string; hint?: string; data: Record; }; export declare function runHealth(paths: Paths, options?: HealthOptions): Promise; /** The report grouped, one line per check, hints indented. */ export declare function formatHealth(report: HealthReport): string; export interface HealthChange { name: string; from: CheckStatus | null; to: CheckStatus; } /** Which checks changed status between two reports (new checks come from `null`). */ export declare function diffHealth(previous: HealthReport | undefined, next: HealthReport): HealthChange[]; export interface HealthCacheDeps { /** How long a report stays fresh. */ ttlMs: () => number; /** The options every run starts from (`live`, `timeoutMs`, `env`). */ options?: () => HealthOptions; events?: Events; } /** * One report per flavour (deep or quick, with or without network), reused within the TTL; concurrent callers share * one run. Emits `health.changed` for the first report of a flavour and whenever a check changed status. */ export declare class HealthCache { private readonly paths; private readonly deps; private readonly cached; private readonly pending; constructor(paths: Paths, deps: HealthCacheDeps); get(input?: { deep?: boolean; network?: boolean; refresh?: boolean; }): Promise<{ report: HealthReport; cached: boolean; }>; /** The newest report of any flavour, without running anything. */ last(): HealthReport | undefined; }