import type { SDKMessage, SessionDeviceStatus } from "./types.js"; import { type ProtocolMessage, type RuntimeScope, type TurnTracker } from "./remote-session-protocol.js"; type RemoteTurnCoordinatorConfig = { label: string; requestTimeoutMs?: number; autoHandlesToolApprovals?: boolean; onDeviceStatus(status: SessionDeviceStatus): void; }; /** * Owns the portable session's turn correlation and stream queue. * * Transport setup and public SDK methods stay in RemoteClientSessionCore. * This class only translates protocol events into SDK messages and correlates * those events with active or queued turns. */ export declare class RemoteTurnCoordinator { private readonly label; private readonly requestTimeoutMs; private readonly autoHandlesToolApprovals; private readonly onDeviceStatus; private streamQueue; private streamResolvers; private activeTurn; private pendingTurns; private settledRunIds; private nextTurnId; private messageCounter; private clientMessageCounter; private closed; private _activeTurnStartedAt; constructor(config: RemoteTurnCoordinatorConfig); get activeTurnStartedAt(): number; hasInFlightTurn(): boolean; /** * Start tracking a turn. A caller-supplied OTID doubles as the turn's * `clientMessageId` so queue updates carry the same correlation id the * persisted message will; otherwise the SDK mints one. */ trackSentTurn(runtime: RuntimeScope, callerOtid?: string): TurnTracker; removeTrackedTurn(turn: TurnTracker): void; markAbortRequested(): void; handleProtocolMessage(message: ProtocolMessage, runtime: RuntimeScope): void; nextMessage(): Promise; /** * Close after the transport dropped, surfacing the failure to stream * consumers first. * * A plain close() resolves waiting consumers with `null`, which is * indistinguishable from a conversation ending normally. A dead socket * cannot deliver a turn-scoped failure of its own, so the error is * synthesized here before the queue drains. */ closeWithError(detail: string): void; close(): void; private activateTurn; private activateNextTurnFromProtocol; private failTurn; private completeActiveTurn; private rememberSettledRunIds; private handleLoopStatusMessage; private handleTurnFinished; private handleTurnTerminalDelta; private transformStreamDelta; private resultFromTurn; private enqueue; private resolveAll; } export {}; //# sourceMappingURL=remote-turn-coordinator.d.ts.map