/** * Mutable per-session runtime: the transport, the output store, the ordered * input lane, timers, and the single finalization promise. * * Sessions share no locks, queues, cursors, deadlines, or finalization state, so * a failure in one session cannot affect another. */ import type { BoundedArtifactWriter } from "./artifact-writer.js"; import type { InteractiveSessionConfig } from "./config.js"; import type { OutputStore } from "./output-store.js"; import type { InteractiveEngagementState } from "../safety/engagement-policy.js"; import { AsyncMutex, FinalizeOnce, Notifier, OrderedInputQueue, TimerSet, type Clock } from "./runtime.js"; import type { SessionTransport } from "./transport.js"; import type { CloseResult, InteractiveSessionRecord, TerminationReason } from "./types.js"; export interface SessionRuntimeInit { readonly record: InteractiveSessionRecord; readonly transport: SessionTransport; readonly output: OutputStore; readonly artifact: BoundedArtifactWriter; readonly config: InteractiveSessionConfig; readonly clock: Clock; readonly idleTimeoutMs: number | undefined; readonly lifetimeTimeoutMs: number | undefined; readonly engagementState?: InteractiveEngagementState | undefined; readonly onTimeout: (reason: "idle-timeout" | "lifetime-timeout") => void; } export declare class SessionRuntime { readonly record: InteractiveSessionRecord; readonly transport: SessionTransport; readonly output: OutputStore; readonly artifact: BoundedArtifactWriter; readonly config: InteractiveSessionConfig; readonly clock: Clock; readonly input: OrderedInputQueue; readonly mutation: AsyncMutex; readonly policy: AsyncMutex; readonly finalize: FinalizeOnce; readonly timers: TimerSet; readonly exitSignal: Notifier; engagementState: InteractiveEngagementState; /** Set once a terminal transition is chosen so late observations only enrich. */ processExited: boolean; exitObserved: TerminationReason | undefined; disposed: boolean; private readonly unsubscribes; private readonly idleTimeoutMs; constructor(init: SessionRuntimeInit); track(unsubscribe: () => void): void; /** Accepted input and observed output both count as activity. */ touch(): void; syncCursors(): void; releaseListeners(): void; }