/** * A handle to a single in-flight utterance (one spoken response) that lets you * await its completion, interrupt it, and observe when its last audio byte plays. * * You can await completion two ways: call `wait()` for a Promise, or `await` the * handle directly (it is thenable). A callback registered via `onLastAudioByte` * after the utterance is already done fires immediately; otherwise it is queued * and fires exactly once when the utterance finishes. */ /** Options for constructing an {@link UtteranceHandle}. */ export type UtteranceHandleOptions = { /** Identifier for the utterance. Default: a generated UUID. */ utteranceId?: string; /** Whether the utterance can be interrupted without `force`. Default: `true`. */ interruptible?: boolean; }; /** See the class-level description for usage. */ export declare class UtteranceHandle { private readonly _id; private readonly _interruptible; private _isDone; private _interrupted; private _lastAudioByteCallbacks; private readonly _donePromise; private _resolveDone; constructor(opts?: UtteranceHandleOptions); /** Unique identifier for this utterance. */ get id(): string; /** Whether this utterance can be interrupted without `force`. */ get isInterruptible(): boolean; /** Whether the utterance has finished (completed or interrupted). */ done(): boolean; /** Whether the utterance was interrupted rather than completing normally. */ get interrupted(): boolean; /** * Interrupt the utterance, marking it done and firing last-audio-byte callbacks. * Has no effect on a non-interruptible utterance unless `force` is `true`. * @param opts.force Interrupt even if {@link isInterruptible} is `false`. Default: `false`. */ interrupt(opts?: { force?: boolean; }): void; /** * Register a callback that fires when the utterance's final audio byte has * played. If the utterance is already done, the callback runs immediately; * otherwise it is queued and fires once when the utterance finishes. Returns * the same callback you passed in. Errors thrown by the callback are caught * and logged, never propagated. */ onLastAudioByte(cb: () => any): () => any; /** Mark the utterance as completed normally, firing last-audio-byte callbacks. */ markDone(): void; /** Returns a promise that resolves when the utterance finishes. */ wait(): Promise; /** Makes the handle awaitable; resolves when the utterance finishes. */ then(onfulfilled?: ((value: void) => TResult1 | PromiseLike) | null, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null): Promise; private _setDone; private _fireLastAudioByte; private static _invokeCallback; }