export type TerminalSessionState = "live" | "stopping" | "exited"; export type TerminalSessionSignal = NodeJS.Signals; export type MaybePromise = T | Promise; export interface TrackedDetachedChild { readonly pid?: number; readonly processGroupId?: number; readonly exited?: boolean | (() => boolean); readonly kill?: (signal?: TerminalSessionSignal) => MaybePromise; } export interface SessionRegistrySession { readonly command?: string; readonly exited?: boolean; readonly isExited?: boolean | (() => boolean); readonly exitResult?: unknown; readonly exitState?: { readonly status?: string; }; readonly status?: string; readonly trackedDetachedChildren?: readonly TrackedDetachedChild[]; readonly getTrackedDetachedChildren?: () => readonly TrackedDetachedChild[]; readonly onExit?: (handler: () => void) => (() => void) | undefined; readonly stop?: () => MaybePromise; readonly kill?: (signal?: TerminalSessionSignal) => MaybePromise; readonly signal?: (signal: TerminalSessionSignal) => MaybePromise; readonly waitExit?: () => Promise; readonly wait?: () => Promise; } export interface SessionRegistryCreateOptions { readonly command?: string; readonly args?: readonly string[]; readonly cwd?: string; readonly env?: Readonly>; readonly cols?: number; readonly rows?: number; readonly session?: TSession; } export interface SessionRegistryCreateContext { readonly id: string; readonly command: string; readonly args?: readonly string[]; readonly cwd?: string; readonly env?: Readonly>; readonly cols?: number; readonly rows?: number; } export interface InitialSessionRegistryEntry { readonly id: string; readonly session: TSession; readonly command?: string; } export interface SessionRegistryEntry { readonly id: string; readonly command: string; readonly session: TSession; readonly createdAt: number; readonly lastUsedAt: number; readonly state: TerminalSessionState; readonly exitedAt: number | null; } export interface SessionRegistrySweepOptions { readonly remove?: boolean; } export interface SessionRegistryOptions { readonly maxSessions?: number; readonly initialSessions?: readonly InitialSessionRegistryEntry[]; readonly createSession?: (options: SessionRegistryCreateContext) => MaybePromise; readonly killProcess?: (target: number, signal: TerminalSessionSignal) => void; readonly now?: () => number; readonly platform?: string; /** * How long `stop()` waits for a killed session to report exit before it * escalates to SIGKILL (and, if that also fails, marks it `stopping`). * Guards against sessions whose exit never settles (e.g. a surviving * descendant holding the PTY open). Default 5s. */ readonly stopExitGraceMs?: number; /** * How long `stop()` waits for the exit after escalating to SIGKILL before it * gives up and marks the entry `stopping`. Default 1s. */ readonly forcedExitGraceMs?: number; /** * How long tracked detached children may take to exit after SIGTERM before * they are SIGKILLed. `0` escalates immediately. Default 1s. */ readonly detachedExitGraceMs?: number; } export type StoredSessionRegistryEntry = { id: string; command: string; session: TSession; createdAt: number; lastUsedAt: number; state: TerminalSessionState; exitedAt: number | null; unsubscribeExit: (() => void) | null; stopPromise: Promise | null; detachedCleanupPromise: Promise | null; /** Set once the entry was SIGKILLed; a second forced kill would add nothing. */ forceKilled: boolean; }; export declare class SessionRegistryCapacityError extends Error { readonly code = "session_registry_capacity"; readonly maxSessions: number; constructor(maxSessions: number); } //# sourceMappingURL=registry-types.d.ts.map