import { IStringDictionary } from "../common/Exports.js"; import { CtsAudioContinuation } from "./ServiceMessages/MultichannelAudio/CtsAudioContinuation.js"; import { CtsAudioInfo } from "./ServiceMessages/MultichannelAudio/CtsAudioInfo.js"; /** * Tracks the per-turn state required by the reliable reconnect protocol. * * The service issues a continuation token, per-stream resume offsets and a service tag on its * responses. When a turn is interrupted before "turn.end", the client echoes these values back * in the next "speech.context" so the service can suppress duplicate results, correct media * offsets and correlate the reconnected turn. * * Intentionally dependency-free so it can be unit tested in isolation. */ export declare class ReconnectContinuationState { private privToken?; private privServiceTag?; private privStreamOffset?; private readonly privDefaultStreamId; constructor(defaultStreamId?: string); /** * The stream id used for the single logical audio stream the SDK currently sends. */ get defaultStreamId(): string; /** * The session-absolute resume offset (100ns ticks) most recently acknowledged by the * service, or undefined if none has arrived. Used both to populate the outgoing * continuation block and to trim the replay buffer. */ get streamOffset(): number | undefined; /** * True when the continuation block must be emitted. The block is emitted whenever any of * the three signals is present (token, service tag or stream offset). The signals persist * for the whole session, so the block keeps being * emitted on reconnects and subsequent turns once the first turn.start has been seen. */ get hasPendingContinuation(): boolean; /** * Resets all state. Called when a brand new recognition (session) starts. */ reset(): void; /** * A turn has started ("turn.start"). The service tag arrives in the turn.start body (under * "$.context.serviceTag"), not a header. The tag is stored unconditionally * (empty string when absent) and the token/offset are NOT cleared: the offset is * session-global and the token persists until the service issues a new one. */ onTurnStart(serviceTag?: string): void; /** * Captures the reliable-reconnect headers (continuation token and stream resume offset) * from an inbound message. Header names are case-insensitive, so matching is too. The * service tag is not a header; it comes from the turn.start body via onTurnStart(). * * The per-stream offset header is turn-relative. It is rebased onto the session-absolute * timeline using `turnStartOffset` * (RequestSession.currentTurnAudioOffset) - the same base used to rebase every other * service offset - so the stored offset stays in the same frame as results and replay. */ updateFromHeaders(headers: IStringDictionary, turnStartOffset?: number): void; /** * Builds the "$.audio.streams" metadata section. This is always sent when the feature is * enabled and is the prerequisite for the service to return continuation headers. */ buildAudioStreamsMetadata(): CtsAudioInfo; /** * Builds the "$.continuation" section to resume an aborted turn, or undefined when this * is a fresh turn (and therefore must not carry a continuation). */ buildContinuationContext(): CtsAudioContinuation | undefined; }