import type { Logger } from "@onenomad/przm-cortex-core"; export interface AdapterRunStats { /** Cron expression this adapter is scheduled on. */ schedule?: string; /** ISO 8601 of the last successful run. */ lastRunAt?: string; /** Duration of the last run in ms. */ lastRunMs?: number; /** Items ingested on the last run. */ lastRunIngested?: number; /** Total runs in this process lifetime. */ runs: number; /** Runs that raised. */ errors: number; /** True when the adapter is actively running. */ running: boolean; } export interface Heartbeat { pid: number; startedAt: string; lastHeartbeatAt: string; uptimeMs: number; mcp: { connected: boolean; transport: string; }; /** Health of the in-process memory backend. Cortex 0.3+ no longer * spawns Engram or Persona MCP subprocesses; the field is retained * in its narrower shape so heartbeat consumers (CLI `cortex status`, * the dashboard) can probe memory health without breaking. */ upstream: { engram: boolean; }; adapters: Record; } export interface HeartbeatWriterOptions { intervalMs?: number; filePath?: string; logger: Logger; } /** * Location of the heartbeat file. Override via `PRZM_CORTEX_HEARTBEAT_PATH` * so operators can point multiple hosts at a shared volume. */ export declare function defaultHeartbeatPath(): string; /** * In-memory state + periodic JSON writer. Scheduler + upstream clients * mutate this; a timer flushes to disk every `intervalMs` so `cortex * status` has a fresh picture without each update doing IO. */ export declare class HeartbeatWriter { private readonly state; private readonly intervalMs; private readonly filePath; private readonly logger; private timer; private readonly startedAtMs; constructor(opts: HeartbeatWriterOptions); start(): Promise; stop(): Promise; setMcpConnected(connected: boolean, transport?: string): void; setUpstream(engram: boolean): void; /** Register an adapter with its schedule. Called at startup. */ registerAdapter(id: string, schedule: string | undefined): void; markRunBegin(id: string): void; markRunEnd(id: string, result: { ingested: number; errors: number; durationMs: number; }): void; /** * Per-item update from a long-running stream worker or webhook receiver. * Each event folds into the shared adapter counters so `cortex status` * shows a unified picture — you can't tell from the report whether a * number came from a cron run, a file save, or an inbound webhook. */ markStreamItem(id: string, result: { ingested: number; errors: number; }): void; /** Snapshot for in-process inspection (tests). */ snapshot(): Heartbeat; private flush; } /** * Read the heartbeat file. Returns `null` when it doesn't exist — the * `cortex status` command treats that as "no daemon running". */ export declare function readHeartbeat(filePath?: string): Promise; //# sourceMappingURL=heartbeat.d.ts.map