UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

33 lines (32 loc) • 2.69 kB
import type { TaskNotificationPayload } from "./task-notification.js"; import { type RegistryCore, type RegisterMonitorInput, type MonitorTaskHandle, type StopSource, type UnifiedTaskResult } from "./task-registry-shared.js"; export declare function registerMonitorLane(core: RegistryCore, input: RegisterMonitorInput): string; /** ONE absorption arithmetic for a monitor poll — env-side-loss accounting * (RB-238), the spool roll (registry memory bound) and the completed-line split — shared by the * watcher tick and the stop-time final drain. A hand-copied twin in stopMonitor is how half-fixes * happen: any change to the roll/line rules must reach both consumers through this method. Returns * the COMPLETE lines (the newline-less tail stays in `lineBuf` for the next poll / terminal flush). */ export declare function absorbMonitorPollLane(handle: MonitorTaskHandle, v: { stdout: string; stderr: string; truncated?: boolean; bytesDroppedBeforeCursor?: number; }): string[]; /** Append one poll's increment (stdout AND stderr) to the watch's output file — the bash watcher's mirror, for the * same absorption's two consumers (the watcher tick and the stop-time drain). Never throws; a failed append is * accounted on `spool.mirrorFailed` so the terminal frame says the file is incomplete instead of passing it off as whole. */ export declare function mirrorMonitorPollLane(handle: MonitorTaskHandle, v: { stdout: string; stderr: string; }): Promise<void>; /** The swallow-guarded event sink, shared by the watcher's emits and the stop-time drain. */ export declare function emitMonitorEventLane(handle: MonitorTaskHandle, n: TaskNotificationPayload): void; /** The monitor watcher tick loop. Same zombie-proofing discipline as {@link startBashWatcher} * (re-entrancy guard / stop on eviction / stop on vanished shell / stop on a throwing adapter), * plus the three monitor-only exits: watcher-enforced timeout, event-storm auto-stop, and the * line→batched-event emission path. All time reads go through the INJECTED clock (design/87). */ export declare function startMonitorWatcherLane(core: RegistryCore, id: string): void; /** design/135 G2: the host poll over a monitor — a RE-READABLE spool snapshot (the watcher owns the env * cursor, exactly the bash G2b spool posture): repeated polls return the same accumulated output. */ export declare function pollMonitorLane(handle: MonitorTaskHandle, filter: string | undefined, deadline?: number, signal?: AbortSignal): Promise<UnifiedTaskResult>; export declare function stopMonitorLane(core: RegistryCore, handle: MonitorTaskHandle, source?: StopSource): Promise<UnifiedTaskResult>;