import type { CodexOutputSchemaCodec } from './output-schema-codec.js'; import type { CodexReasoningEffort } from './reasoning-effort.js'; import type { CodexWsClient } from './rpc.js'; import type { AgentRuntimeActivitySink, AgentRuntimeResultSink, AgentRuntimeInterruptOutcome, AgentRuntimeSubmissionInput, DreamuxLogger, RuntimeAdmission } from '@excitedjs/dreamux-types'; export interface TurnManagerOptions { threadId: string; client: CodexWsClient; /** * The session-bound output schema codec, compiled once when the runtime was * created. It is fixed for the life of the session: no submission can change * or negotiate it. */ codec: CodexOutputSchemaCodec | null; reasoning: CodexReasoningEffort; activitySink: AgentRuntimeActivitySink; resultSink?: AgentRuntimeResultSink | undefined; logger: DreamuxLogger; } export declare class TurnManager { private readonly opts; private readonly pendingAdmissions; private readonly inFlightNativeAdmissions; private nextNativeAdmission; private readonly nativeTurns; private protocolFailure; private collector; private tokenUsage; private decisionTail; private stopped; constructor(opts: TurnManagerOptions); /** * Admit one already-rendered submission. The manager holds no source ledger: * deduplication is Core's, ahead of this call. */ submitInput(input: AgentRuntimeSubmissionInput): Promise; interrupt(): Promise; stop(): Promise; private submit; private enqueueDecision; /** * Construct the collector once. One TurnManager instance is bound to one * resident runtime session, whose native thread id is fixed before the * manager is built (`CodexRuntime` resolves the thread and only then * constructs its `TurnManager`), so `threadId` never changes across calls. */ private ensureCollector; private bindSubmission; private observeTerminal; private failProtocol; private failRecord; private releaseCompletedRecords; private releaseRecordIfReady; /** * Put what codex reported on this agent's activity stream. * * No record is consulted. A native turn folds any number of Dreamux * submissions, so naming one of them as the item's owner was always a guess * — and the buffer that existed to make that guess possible dropped * everything it could not eventually attribute. The agent is the subject, * and it is known before any submission binds. */ private observeItem; /** The sink is Core's and never throws (`AgentRuntimeActivitySink`). */ private emitActivity; /** * Report a native turn's end on the display line. * * `status` and `reason` are codex's own terminal and nothing else — a * collected turn completed, an error failed with its message, a teardown * interrupted. What the push-back line then makes of that terminal (a decode * it cannot restore, a submission it cannot attribute) is push-back's own * outcome and never colours the card. * * This manager keeps no display state: it does not know, and does not ask, * whether a turn is open before reporting an end. Whether the end is *shown* * is not this layer's decision. A card belongs to no turn * (`feishu-cot-conversation-cards` requirement, rule 1 — a target is "not a * presentation identity, state key, or card partition"), and a native end * "closes an existing open card but never opens a new one; when no card is * open, Feishu ignores it" (rule 8). This layer pushes; the Channel decides. */ private endNativeTurn; private trackAdmission; } //# sourceMappingURL=turn-manager.d.ts.map