import { type MonitorErrorCode, type MonitorProjection, type MonitorState } from "@mono-agent/agent-contracts"; import { type ProcessIncarnation } from "./process-incarnation.js"; import { type ProcessJobOriginRecord } from "./process-jobs-store.js"; export declare const MONITOR_RECORD_SCHEMA = 2; export declare const MONITOR_STATE_FILE = "monitors-v1.json"; export declare const MONITOR_OWNER_LOCK_FILE = ".monitors-owner"; export declare const MONITOR_OWNER_SCHEMA = "mono-agent.monitors-owner.v1"; /** Bounded by the compiled active cap plus retained terminal wake obligations. */ export declare const MONITOR_STORE_MAX_RECORDS: number; /** * A record holds only bounded identity, lifecycle and counters, never argv, * environment values, or event text, so the whole file stays small. */ export declare const MAX_MONITOR_STATE_BYTES: number; export interface DurableMonitorRecord { readonly schemaVersion: typeof MONITOR_RECORD_SCHEMA; readonly monitorId: string; state: MonitorState; /** Bounded, redacted, model-authored purpose. */ readonly description: string; /** Kernel-produced summary; contains no argument values. */ readonly summary: string; readonly persistent: boolean; readonly wakeOn: "batch" | "exit"; readonly dedupe: "none" | "batch"; readonly minWakeIntervalMs: number; readonly origin: ProcessJobOriginRecord; readonly chainDepth: number; readonly agentIncarnation: ProcessIncarnation; processIncarnation?: ProcessIncarnation; pid: number | null; pgid: number | null; sandboxSettingsPath: string | null; readonly maxRuntimeMs: number; readonly coalesceMs: number; readonly maxBatchLines: number; readonly maxBatchBytes: number; readonly startedAt: string; runtimeDeadlineAt: string | null; lastEventAt: string | null; completedAt: string | null; exitCode: number | null; signal: string | null; cancelRequested: boolean; seq: number; batchesDelivered: number; batchesSuppressed: number; linesSuppressed: number; followUpWakes: number; steeredWakes: number; unknownDispositionWakes: number; linesObserved: number; linesDelivered: number; droppedLines: number; pendingLines: number; /** Only a count, never event text; null means no unresolved dispatch. */ inFlightWakeLines: number | null; /** True only while the single terminal wake for this monitor is still owed. */ terminalWakePending: boolean; lastError: { code: MonitorErrorCode; message: string; } | null; } export interface MonitorStoreSnapshot { readonly schemaVersion: typeof MONITOR_RECORD_SCHEMA; readonly records: readonly DurableMonitorRecord[]; } /** * Derive the monitor operator bearer from the SAME owner-private secret the * process-job operator surface uses. A distinct HMAC label keeps the two bearers * unrelated, so a leaked monitor token can never authorize job routes. */ export declare function monitorOperatorToken(secret: Uint8Array): string; export declare function monitorStatePath(stateDir: string): string; /** * Read the durable snapshot. A missing file is an empty store. A corrupt or * oversized file is reported to the caller rather than silently discarded: the * only durable obligation monitors carry is the restart wake, and losing it * quietly would make an interrupted watch look like one that never existed. */ export declare function readMonitorStore(stateDir: string): Promise<{ readonly snapshot: MonitorStoreSnapshot; readonly corrupt: boolean; /** Why the state was rejected, for the operator-facing log. Never the bytes. */ readonly reason?: string; }>; export declare function writeMonitorStore(stateDir: string, records: readonly DurableMonitorRecord[]): Promise; export declare function projectMonitor(record: DurableMonitorRecord): MonitorProjection; /** Bound and neutralize the model-authored description before it is retained. */ export declare function boundMonitorDescription(value: string): string; export declare function isDurableMonitorRecord(value: unknown): value is DurableMonitorRecord; //# sourceMappingURL=monitors-store.d.ts.map