UNPKG

@code-yeongyu/senpi

Version:

Coding agent CLI with read, bash, edit, write tools and session management

76 lines • 4.28 kB
/** * Tracks live monitors across their sources (command watches over PTY output, native file watches), * alongside the terminal manager's bash-id registry. Every source emits through one sink here, so the * fire stats, the wake budget's change notifications and the ended observer apply to all of them. */ import { type RegisterMonitorOptions } from "./command-monitor-source.ts"; import { type RegisterFileMonitorOptions } from "./file-monitor-source.ts"; import type { MonitorEndedEvent, MonitorEvent, MonitorFireWindow, MonitorRearmResult, MonitorResumeResult, MonitorSnapshotEntry } from "./monitor-types.ts"; import type { RegisterRpcMonitorOptions } from "./rpc-monitor-source.ts"; import type { MonitorRunawayGuard } from "./settings.ts"; export type { RegisterMonitorOptions } from "./command-monitor-source.ts"; export type { RegisterFileMonitorOptions } from "./file-monitor-source.ts"; export { allocateMonitorId, type MonitorEndedEvent, type MonitorEndedReason, type MonitorEvent, type MonitorFireWindow, type MonitorLineEvent, type MonitorRearmResult, type MonitorResumeResult, type MonitorSnapshotEntry, type MonitorSummaryEvent, } from "./monitor-types.ts"; export interface MonitorRegistryOptions { /** Observes every registry transition (register/pause/rearm/settle/dispose) with the live snapshot. */ readonly onChange?: (snapshot: readonly MonitorSnapshotEntry[]) => void; /** Fire-stat refreshes are separate from lifecycle transitions (which persist the manifest). */ readonly onFire?: (snapshot: readonly MonitorSnapshotEntry[]) => void; /** Observes each monitor exactly once when it leaves the registry. */ readonly onEnded?: (event: MonitorEndedEvent) => void; /** Reserves one shared terminal capacity slot for a native watch. */ readonly reserve?: () => (() => void) | null; } export declare class MonitorRegistry { #private; constructor(emit: (event: MonitorEvent) => void, options?: MonitorRegistryOptions); /** Apply the resolved runaway-guard settings; the registry outlives a reload, the settings do not. */ setRunawayGuard(guard: MonitorRunawayGuard): void; /** * Wake pacing of a live watch: only persistent command watches are paced. Returns the watch's * own wake-rate override (undefined = the setting) or undefined when the watch is not paced. */ wakePacing(id: string): { readonly wakesPerHour: number | undefined; } | undefined; /** Attachment parking is independent of persisted monitor mute and wake budgets. */ setParked(parked: boolean): void; snapshot(): readonly MonitorSnapshotEntry[]; registerFile(options: RegisterFileMonitorOptions): Promise<{ id: string; monitorId: string; }>; /** Live identity tuple of one file watch; undefined when the id is not a live file watch. */ fileCheckpoint(id: string): { dev: number; ino: number; size: number; mtimeMs: number; digest: string; present: boolean; } | undefined; /** Emit one restored-watch line through the SAME sink a live watch uses (coalescing, wake budget). */ emitFileLine(id: string, line: string): boolean; /** Inject one line into a live command or file watch's event stream (e.g. a restore notice). */ emitLine(id: string, line: string): boolean; stopFile(id: string): Promise<boolean>; stopAllFiles(): Promise<number>; register(options: RegisterMonitorOptions): string; /** Arms an rpc watch (the source loads on the first one); resolves with the arm-time session rows. */ registerRpc(options: RegisterRpcMonitorOptions): Promise<{ id: string; monitorId: string; rows: string[]; }>; stopRpc(id: string): boolean; stopAllRpc(): number; pause(ids: readonly string[]): string[]; pauseAll(): string[]; resume(ids?: readonly string[]): MonitorResumeResult[]; mutedDropped(id: string): number; rearm(id: string): MonitorRearmResult; /** Re-bind a persisted fire window onto the record for a durable monitor id (a restore re-arms the budget). */ adoptFireWindow(monitorId: string, fireWindow: MonitorFireWindow): boolean; dispose(): void; } //# sourceMappingURL=monitor-registry.d.ts.map