@phren/cli
Version:
Knowledge layer for AI agents - CLI, MCP server, and data layer
59 lines (58 loc) • 3.28 kB
TypeScript
import type { HealthFinding } from "./machine-health.js";
export declare const PROBE_EVERY_MS: number;
export declare const UPDATES_EVERY_MS: number;
export interface ProbeDeps {
platform: string;
now: () => number;
home: string;
uid: number;
/** stdout of a command; rejects when it is missing, fails or times out. */
run: (file: string, args: string[], timeoutMs?: number) => Promise<string>;
/** Directories searched (two levels) for `*.lock` files. */
lockDirs: string[];
alive: (pid: number) => boolean;
}
type Probe = {
name: string;
everyMs: number;
platforms: string[];
run: (deps: ProbeDeps) => Promise<HealthFinding[]>;
};
/** `launchctl print gui/<uid>/<label>`: restart count, unless the job is meant to run repeatedly. */
export declare function parseLaunchdService(label: string, text: string): HealthFinding | undefined;
/** `launchctl list`: non-Apple labels, which are the ones worth printing. */
export declare function launchdLabels(text: string): string[];
/** `systemctl show -p Id -p NRestarts <units>`: blocks separated by blank lines. */
export declare function parseSystemdRestarts(text: string, scope: "system" | "user"): HealthFinding[];
/** `systemctl --failed --no-legend --plain`. */
export declare function parseFailedUnits(text: string, scope: "system" | "user"): HealthFinding[];
/** `tmutil latestbackup`: the newest backup's timestamp in its path. */
export declare function parseTimeMachine(latest: string, now: number): HealthFinding | undefined;
/** `softwareupdate -l`, `checkupdates` or `apt list --upgradable`. */
export declare function parseUpdates(text: string, tool: "softwareupdate" | "checkupdates" | "apt"): HealthFinding | undefined;
/** Report file names from DiagnosticReports changed in the last day. */
export declare function parseDiagnosticReports(names: readonly string[]): HealthFinding[];
/** `journalctl -k --grep 'Out of memory: Killed process'` lines. */
export declare function parseOomKills(text: string): HealthFinding | undefined;
/** `coredumpctl list --json=short`: crashes by executable. */
export declare function parseCoredumps(json: string): HealthFinding[];
/** `journalctl --disk-usage`. */
export declare function parseJournalSize(text: string): HealthFinding | undefined;
/** `nvidia-smi --query-gpu=index,name,ecc.errors.uncorrected.volatile.total,temperature.gpu --format=csv,noheader,nounits` plus Xid lines. */
export declare function parseNvidia(query: string, xid: string): HealthFinding[];
export declare function nvidiaFindings(deps: Pick<ProbeDeps, "run">): Promise<HealthFinding[]>;
/** A lock written as `<pid>\n<ms>` whose process is gone and that is older than 30 minutes. */
export declare function staleLocks(deps: Pick<ProbeDeps, "lockDirs" | "alive" | "now">): Promise<HealthFinding | undefined>;
/** Runs the due probes in the background and serves the last results. */
export declare class PlatformProbes {
private readonly probes;
private results;
private ranAt;
private running?;
private readonly deps;
constructor(deps?: Partial<ProbeDeps>, probes?: Probe[]);
/** The cached findings; starts a refresh when a probe is due. */
current(): HealthFinding[];
refresh(): Promise<void>;
}
export {};