UNPKG

@code-yeongyu/senpi

Version:

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

48 lines • 3.06 kB
import type { TerminalBackgroundAgeEvent, WakeSourceStateItem } from "../monitor-state-event.ts"; import { TerminalManager, type TerminalManagerOptions } from "./manager.ts"; import type { MonitorEndedEvent } from "./monitor-registry.ts"; import { type MonitorEvent, MonitorRegistry, type MonitorSnapshotEntry } from "./monitor-registry.ts"; import type { TerminalExitView } from "./tools/context.ts"; export interface TerminalEventSinks { readonly onMonitorEvent: (event: MonitorEvent) => void; readonly onMonitorState: (snapshot: readonly MonitorSnapshotEntry[], transition?: boolean) => void; readonly onMonitorEnded: (event: MonitorEndedEvent) => void; readonly onBackgroundState: (snapshot: readonly WakeSourceStateItem[]) => void; readonly onBackgroundExit: (id: string, runtime: TerminalExitView) => void; readonly onBackgroundAge: (event: TerminalBackgroundAgeEvent) => void; } export interface BackgroundStartDetails { readonly command?: string; readonly autoReapMinutes?: number; } /** * The long-lived terminal runtime for one agent session: the PTY session manager plus * the monitor registry. A session reload replaces the extension runner and re-runs the * extension factory, so this state must outlive any single extension instance; event * routing goes through mutable sinks the current owner instance binds. While parked * (the reload window, or a headless reload that never re-binds) events buffer bounded. */ export declare class TerminalSessionBundle { #private; readonly manager: TerminalManager; readonly monitors: MonitorRegistry; constructor(options: TerminalManagerOptions); /** Install live sinks, re-publish channel state, and flush everything buffered while parked. */ bind(sinks: TerminalEventSinks): void; park(): void; backgroundSnapshot(): readonly WakeSourceStateItem[]; notifyBackgroundStart(id: string, description: string, startedAtMs?: number, details?: BackgroundStartDetails): void; /** Hold the release of the run job `id` was recorded as; its exit drops it. */ trackRunJob(id: string, release: () => void): void; /** Stop a session the interrupted turn `turnId` started; its exit notice then reaches the next turn without waking. */ stopForInterrupt(id: string, turnId: string): Promise<void>; /** The auto-reap's stop did not end a session still on the schedule: one notice; its age notices go on. */ notifyBackgroundReapFailed(id: string, autoReapMinutes: number, reason: string): void; notifyBackgroundExit(id: string, exited: TerminalExitView): void; teardown(): Promise<void>; } /** Park a bundle across a reload; at most one parked bundle per session, older ones torn down. */ export declare function parkBundle(sessionKey: string, bundle: TerminalSessionBundle): Promise<void>; export declare function claimParkedBundle(sessionKey: string): TerminalSessionBundle | undefined; export declare function teardownParkedBundle(sessionKey: string): Promise<void>; //# sourceMappingURL=session-bundle.d.ts.map