/** * Interactive session manager: the single owner of persistent interactive * process lifecycle. * * Ownership is conversation-scoped. Every operation requires an owner id, and a * lookup for another owner is indistinguishable from a missing session so the * manager cannot be used as an existence oracle. Direct user-terminal handoff is * outside this contract by design. */ import type { EngagementScope } from "../store/scope.js"; import { type InteractiveSessionConfig, type InteractiveSessionOverrides } from "./config.js"; import { RecoveryJournal, type ReconciliationEntry } from "./recovery-journal.js"; import { type Clock } from "./runtime.js"; import { SessionTelemetry } from "./telemetry.js"; import { type SessionTransportFactory } from "./transport.js"; import { type CloseAllResult, type CloseOwnerResult, type CloseRequest, type CloseResult, type ListResult, type ReadRequest, type ReadResult, type ResizeRequest, type ResizeResult, type SendRequest, type SendResult, type SessionInput, type SessionOperation, type StartRequest, type StartResult, type StatusResult, type TerminationReason } from "./types.js"; /** Confirmation surface for a `confirm`-level action. Previews are redacted. */ export type ConfirmPreview = (request: { readonly title: string; readonly description: string; readonly reason: string; }) => Promise; export interface ManagerRequestExtras { readonly confirm?: ConfirmPreview | undefined; readonly scope?: EngagementScope | undefined; } export interface InteractiveSessionManagerDeps { readonly config?: InteractiveSessionOverrides | undefined; readonly transports?: SessionTransportFactory | undefined; readonly clock?: Clock | undefined; readonly journal?: RecoveryJournal | undefined; readonly telemetry?: SessionTelemetry | undefined; readonly artifactBaseDir?: string | undefined; } export declare class InteractiveSessionManager { private readonly registry; private readonly runtimes; private readonly approvals; private readonly telemetry; private readonly journal; private readonly cleanup; private readonly transports; private readonly clock; private readonly baseConfig; private readonly artifactBaseDir; private readonly ownerCloses; private readonly ownerActivations; private readonly pendingStarts; private readonly lateLaunches; constructor(deps?: InteractiveSessionManagerDeps); get config(): InteractiveSessionConfig; /** Reconcile crashed-session records. Must run before tools are enabled. */ reconcileOrphans(): ReconciliationEntry[]; ptyCapability(): Promise<{ available: boolean; reason?: string | undefined; }>; start(request: StartRequest & ManagerRequestExtras): Promise; private startManaged; private launchError; private launchWithDeadline; send(request: SendRequest & ManagerRequestExtras): Promise; private sendError; /** * Acceptance is all-or-nothing under the mutation lock: either the whole action * is reserved within the backpressure bound, or no sequence or queue state * changes at all. */ private accept; private assertControlSupported; /** * Quiet detection starts at delivery completion: only output observed after * this point resets the quiet timer, while the absolute deadline never extends. */ private gather; read(request: ReadRequest): Promise; private waitForOutput; status(request: { ownerId: string; id: string; }): StatusResult; list(request: { ownerId: string; }): ListResult; resize(request: ResizeRequest): Promise; close(request: CloseRequest): Promise; /** Owner cancellation: closes every live session owned by a conversation. */ cancelOwner(ownerId: string): Promise; /** * Fence an owner synchronously, then start one tracked close. Callers rebinding * a conversation id must fence before the old id becomes unreachable. */ beginCloseOwner(ownerId: string, reason?: TerminationReason): Promise; /** Await any teardown already started for an owner. */ awaitOwnerClose(ownerId: string): Promise; activateOwner(ownerId: string): Promise; private awaitOwnerActivation; closeAll(reason?: TerminationReason): Promise; private closeOwnerSessions; private finalizeRecord; private finalize; private authorizeCommand; private authorizeInput; private registerPendingStart; private trackLateLaunch; private cancelPendingStarts; private releaseUnmanagedTransport; private throwIfCancelled; private assertOwner; private assertNotFenced; private assertEnabled; private notFound; private requireRuntime; } /** Strict validation of the dependent input fields before acceptance. */ export declare function validateInput(input: SessionInput | undefined, operation: SessionOperation): SessionInput; /** Process-wide manager, mirroring the existing process-wide job manager. */ export declare const interactiveSessionManager: InteractiveSessionManager;