UNPKG

@code-yeongyu/senpi

Version:

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

74 lines • 3.56 kB
import type { TerminalScreenSnapshot, TerminalSession, TerminalSessionExit, TerminalSessionOptions } from "@earendil-works/pi-pty"; import type { ChildProcessIdentity } from "./process-identity.ts"; export interface TerminalRuntimeOptions extends TerminalSessionOptions { readonly scrollback?: number; readonly redactSecretsInOutput?: boolean; } export interface DeltaRead { readonly text: string; readonly droppedChars: number; } /** * A live terminal session: a pi-pty {@link TerminalSession} plus an xterm screen model * and a bounded decoded-output buffer with a per-consumer read cursor. Reads are pure * non-blocking peeks; watchers subscribe through `onOutput` (the monitor path). * * Once the process exits, the screen model is replaced by its final visible screen: an exited session * stays listed until the registry needs its slot, and a live xterm with its scrollback and replay * history costs tens of MB that nothing reads after exit (senpi#3171). */ export declare class TerminalRuntimeSession { readonly session: TerminalSession; readonly command: string; readonly startedAtMs: number; private readonly argv; private screen; private finalScreen; private readonly screenRelease; private readonly decoder; private readonly redactor; private redactionIdleTimer; private buffer; private droppedChars; private consumed; private readonly outputListeners; private readonly disposeListeners; private unsubscribeData; /** The boot instant this process recorded for its children, resolved by the async creator (the read is async). */ readonly bootAtMs: number; constructor(command: string, options: TerminalRuntimeOptions, bootAtMs: number); /** Resolves once an exited session has kept its final visible screen and dropped the screen model. */ screenReleased(): Promise<void>; private releaseScreen; get backend(): string | null; /** The spawned child as a later process can recognise it; undefined when the backend exposes no pid. */ identity(): ChildProcessIdentity | undefined; get exited(): boolean; get exitResult(): TerminalSessionExit | null; /** Total decoded chars produced so far (including any dropped from the front). */ get totalChars(): number; private ingest; /** Subscribe to decoded output without affecting the read cursor. */ onOutput(listener: (chunk: string) => void): () => void; /** Called once when the wrapper is disposed (registry eviction or teardown). */ onDispose(listener: () => void): () => void; /** Return output produced since the last read and advance the read cursor. */ readDelta(): DeltaRead; /** Full retained decoded output (`view:"log"`), without advancing the cursor. */ fullOutput(): string; snapshot(): TerminalScreenSnapshot; resizeScreen(cols: number, rows: number): void; /** * The screen is a best-effort projection; a rejected feed/resize must never * become an unhandled rejection that kills the host process (#837), and * `buffer` remains the source of truth for reads. The screen hands every * caller coalesced into one queued operation the same memoized promise, so * attach the rejection handler once per distinct promise - re-attaching per * PTY chunk would grow promise reactions without bound while a replay is * stalled behind a slow parser. */ private lastScreenWrite; private ownScreenWrite; dispose(): void; } //# sourceMappingURL=runtime-session.d.ts.map