import { type MonitorErrorCode, type MonitorProjection, type HostWakeDeliveryResult } from "@mono-agent/agent-contracts"; import type { MonitorsController } from "@mono-agent/runtime-adapter"; import { type OwnerPrivateLock } from "./owner-private-lock.js"; import { type MonitorsSettings } from "./monitors-config.js"; import { writeMonitorStore } from "./monitors-store.js"; import { isSameProcessIncarnation, readProcessIncarnation, type ProcessIncarnation } from "./process-incarnation.js"; import type { ProcessJobOriginRecord } from "./process-jobs-store.js"; export declare class MonitorServiceError extends Error { readonly code: MonitorErrorCode; constructor(code: MonitorErrorCode); } export interface MonitorWakeInput { readonly projection: MonitorProjection; readonly prompt: string; readonly conversationId: string; readonly deliveryKey: string; readonly chainDepth: number; } export interface OpenMonitorsServiceOptions { /** The already-prepared, protected process-job private-state root. */ readonly stateDir: string; readonly settings: MonitorsSettings; readonly wake: (input: MonitorWakeInput) => Promise; readonly logger?: { info?(message: string, details?: Readonly>): void; warn?(message: string, details?: Readonly>): void; }; readonly now?: () => Date; readonly platform?: NodeJS.Platform; readonly randomId?: () => string; readonly currentIncarnation?: () => Promise; readonly readIncarnation?: typeof readProcessIncarnation; readonly sameIncarnation?: typeof isSameProcessIncarnation; readonly signalProcess?: (pid: number, signal: NodeJS.Signals) => void; readonly processGroupExists?: (pgid: number) => boolean; readonly sleep?: (milliseconds: number) => Promise; readonly wakeRearmMs?: number; /** Bounded wait for watchers and wakes at shutdown; a test seam, not a knob. */ readonly shutdownGraceMs?: number; /** Test seam for blocking one durable write at an exact lifecycle boundary. */ readonly writeStore?: typeof writeMonitorStore; /** Test seam for pausing inside the serialized wake-admission boundary. */ readonly beforeWakePreparation?: () => Promise; readonly acquireLock?: () => Promise; readonly operatorSecret?: () => Promise; } export interface MonitorsServiceHandle { readonly settings: MonitorsSettings; /** The protected state root this service actually opened. */ readonly stateDir: string; readonly operatorToken: string; controller(origin: ProcessJobOriginRecord, chainDepth: number | (() => number)): MonitorsController; list(): Promise; get(monitorId: string): Promise; cancel(monitorId: string): Promise; activateWakes(): Promise; stop(): Promise; } /** Acquire exclusive ownership, recover interrupted watches, and expose one controller. */ export declare function openMonitorsService(options: OpenMonitorsServiceOptions): Promise; /** * The envelope has three jobs the model routinely gets wrong without it: this is * not a user message, the fenced text is data and not instruction, and a batch * that changes nothing should end the turn silently rather than posting noise. */ export declare function monitorWakePrompt(projection: MonitorProjection, payload: { readonly lines: readonly string[]; readonly terminal: boolean; readonly stderrTail: string; }): string; //# sourceMappingURL=monitors-service.d.ts.map