UNPKG

@code-yeongyu/senpi

Version:

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

133 lines • 5.71 kB
/** * The terminal manifest's data model: the durable per-session record of live monitors and * background sessions that `restore.ts` strict-parses back after a restart. Types and the * constants that govern them live here; all runtime behaviour is in `terminal-manifest.ts`. */ import type { SessionManager } from "../../../session-manager.ts"; import type { ChildProcessIdentity } from "./process-identity.ts"; export declare const TERMINAL_MANIFEST_VERSION = 1; /** Minimum debounce for checkpoint writes; a burst inside this window collapses to one write. */ export declare const TERMINAL_MANIFEST_CHECKPOINT_DEBOUNCE_MS = 30000; /** * Re-exported so manifest consumers read one durability deadline. The value lives in * `shared.ts` with the rest of the terminal caps; there is exactly one definition of it. */ export { DURABLE_MONITOR_EXPIRY_MS } from "./shared.ts"; export type TerminalManifestSession = Pick<SessionManager, "getSessionDir" | "getSessionId">; export type MonitorRuntimeKind = "command" | "file" | "rpc"; export type MonitorDurabilityClass = "ephemeral" | "restartable-command" | "checkpointed-file" | "checkpointed-rpc"; /** Rpc-monitor checkpoint: each endpoint's host identity and each watched session's last status. */ export interface TerminalManifestRpcCheckpoint { readonly hosts: Readonly<Record<string, { readonly instanceId: string; readonly generation: string; }>>; readonly statuses: Readonly<Record<string, string>>; /** A remote target's source cursor and the turn ids already reported per session. */ readonly remote?: { readonly cursor?: string; readonly settled: Readonly<Record<string, readonly string[]>>; }; } /** * File-monitor checkpoint persisted by the writer: the registry's live identity tuple. `digest` * is required — without it a same-size, same-mtime rewrite is undetectable across a restart. */ export interface TerminalManifestCheckpoint { readonly dev: number; readonly ino: number; readonly size: number; readonly mtimeMs: number; readonly digest: string; readonly present: boolean; } export interface ManifestMonitor { readonly monitorId: string; /** Owning agent session id — never the bash_N/watch_N runtime id. */ readonly sessionId: string; readonly description: string; readonly runtimeKind: MonitorRuntimeKind; readonly durabilityClass: MonitorDurabilityClass; readonly command?: string; readonly path?: string; readonly event?: "create" | "modify"; readonly filter?: string; /** Command watch whose output lines are a person's words; absent on older entries. */ readonly humanInput?: boolean; /** Per-monitor wake-rate override of a persistent command watch; absent uses the setting. */ readonly wakesPerHour?: number; readonly cwd?: string; readonly approvedParent?: string; /** Rpc watches: the target as written, the record kinds reported and dropped. */ readonly target?: string; readonly events?: "all" | readonly string[]; readonly exclude?: readonly string[]; readonly rpcCheckpoint?: TerminalManifestRpcCheckpoint; readonly createdAt: number; readonly expiresAt: number | null; readonly persistent: boolean; readonly suspended: boolean; readonly lastCheckpoint: TerminalManifestCheckpoint | null; readonly deliveryPaused: boolean; readonly fireWindow: { startMs: number; count: number; }; /** The child process a restore must recognise (and stop) before re-spawning; absent on v1 entries. */ readonly runtime?: ChildProcessIdentity; /** Absolute runtime deadline of an ephemeral watch, so a restore can hand back the time left. */ readonly deadlineMs?: number; } export interface ManifestBackgroundSession { readonly id: string; readonly command: string; readonly startedAtMs: number; readonly runtime?: ChildProcessIdentity; } export interface TerminalManifest { readonly version: typeof TERMINAL_MANIFEST_VERSION; readonly sessionId: string; readonly monitors: readonly ManifestMonitor[]; readonly backgroundSessions: readonly ManifestBackgroundSession[]; readonly updatedAt: number; } /** What the monitor tool captures at its call site — the only place the branch inputs live. */ export interface CommandMonitorSpec { readonly kind: "command"; readonly description: string; readonly command: string; readonly filter?: string; readonly humanInput?: boolean; readonly wakesPerHour?: number; readonly cwd?: string; readonly persistent: boolean; } export interface FileMonitorSpec { readonly kind: "file"; readonly description: string; readonly path: string; readonly event: "create" | "modify"; readonly timeoutMs: number; readonly cwd: string; readonly approvedParent?: string; /** Persistent file watches are the durable `checkpointed-file` class; one-shot ones stay ephemeral. */ readonly persistent: boolean; } export interface RpcMonitorSpec { readonly kind: "rpc"; readonly description: string; readonly target: string; readonly events?: "all" | readonly string[]; readonly exclude?: readonly string[]; readonly filter?: string; /** Persistent rpc watches are the durable `checkpointed-rpc` class. */ readonly persistent: boolean; } export type MonitorSpec = CommandMonitorSpec | FileMonitorSpec | RpcMonitorSpec; export interface MonitorRegistration { readonly monitorId: string; readonly spec: MonitorSpec; readonly runtime?: ChildProcessIdentity; readonly deadlineMs?: number; } //# sourceMappingURL=terminal-manifest-model.d.ts.map