/** A message appended to the conversation. `ts` is the turn's boundary timestamp * (unix ms), captured when the turn happened — the server mints a K-sortable id * from it, so order is fixed independently of when the transcript text arrives. */ export interface VoiceTranscriptMessage { /** OpenAI conversation item id — the idempotency seed for the minted message id. */ itemId: string; /** Turn boundary time (unix ms). Sorts the message; trusted within margin. */ ts: number; role: "user" | "assistant"; parts: Array<{ type: "text"; text: string; }>; } /** * Turns out-of-order Realtime transcript events into an **append-only** stream of * independently-ordered messages. * * User input transcription is asynchronous and can complete *after* the assistant * has already replied, so a user turn reserves its boundary timestamp at the VAD * speech boundary (`userTurn(ts)`) — that time sorts it before the assistant * reply even though its text lands later. Each settled transcript becomes one * message; there is no buffer holding the whole conversation and no * contiguous-prefix gate, so a missing or empty transcript drops only that one * message, never the rest. * * Messages stay in `unacked` (keyed by `itemId`) until the server confirms them; * that set doubles as the retry queue (failed POST), the defer queue (a greeting * that arrives before any user turn), and the `pagehide` beacon payload. It holds * only in-flight messages — normally zero or one — never history. */ export declare class VoiceTranscriptSequencer { /** Reserved boundary timestamps for user turns whose transcript hasn't arrived (FIFO). */ private pendingUserTs; /** Item ids already recorded, to drop duplicate transcript-completion events. */ private seenItemIds; /** Messages awaiting server confirmation, keyed by itemId. */ private unacked; /** Reserve the boundary timestamp for a user turn (its transcript arrives later). */ userTurn(ts: number): void; /** Release the oldest reserved user boundary when its input transcription failed. */ userTranscriptFailed(): void; /** * Record a settled transcript as a message and queue it for sending. Returns the * message, or null if it was a duplicate or had no text. A user message takes its * reserved boundary timestamp (so it sorts before the assistant reply); anything * else takes `ts` (the moment it settled). */ record(itemId: string, role: "user" | "assistant", text: string, ts: number): VoiceTranscriptMessage | null; /** Messages awaiting confirmation, oldest first — the batch to send or beacon. */ pending(): VoiceTranscriptMessage[]; /** Drop the given item ids once the server confirms them. */ ack(itemIds: string[]): void; } //# sourceMappingURL=voice-transcript.d.ts.map