import { Event } from "../../../../../sessions/sessions.web.main.internal.js"; import { IVoicePttStartOptions, IVoiceSessionContext, IVoiceDispatchResult, VoiceNarrationKind, IVoiceCheckpointNarrationMetadata, VoiceConfirmationType, IVoicePriorTimelineEntry, IVoiceTurnConfig, IVoiceFeedbackPayload, IVoiceTranscription, IVoiceAudioResponse, IVoiceBargeIn, IVoiceNarrationAck, IVoiceNarrationSignal, IVoiceToolCall, IVoiceSpeechStarted, IVoiceSessionInit, IVoiceFatalDisconnect, IVoiceConnectionIssue, IVoiceTurnAutoEnded } from "./voiceClientService.js"; export interface IVoiceClientService { readonly _serviceBrand: undefined; hasGptLiveByok(): Promise; connect(window: Window & typeof globalThis, authToken?: string): Promise; disconnect(): void; sendPttStart(turnId: string, options: IVoicePttStartOptions): void; sendPttAudioChunk(audio: string): void; sendPttEnd(): void; /** * Send a per-press post-mortem diagnostic payload for tail-loss * investigation. Fired ~500ms after `pttUp` by the mic service. * `metrics` is an opaque object echoed straight into a structured * backend log keyed by `turnId`. */ sendPttDiagnostic(turnId: string, metrics: Record): void; sendSessionContext(context: IVoiceSessionContext): void; /** * Synchronously flush any pending debounced ``session_context`` delta on the * wire. Use this before sending a ``session_state_change`` so the backend * has the latest per-session ``last_response_summary`` / ``agent_state`` * before it reacts to the state transition (e.g. to run summarisation). * Safe to call when no flush is pending — it just no-ops. */ flushSessionContext(): void; /** * Clear the cached last-sent fields for a session so the next * ``_sendDelta`` treats it as a brand-new session (full field send). * Use when the confirmation detail changes within the same * ``agent_state`` — the normal merge-patch would strip the detail * because the state field itself didn't change. */ invalidateSessionCache(sessionId: string): void; sendToolResult(callId: string, result: string | IVoiceDispatchResult, toolName?: string, toolArgs?: Readonly>): void; /** Report that one correlated checkpoint playback attempt finished locally. */ sendNarrationPlaybackComplete(codingSessionId: string, narrationId: string, playbackId: string): void; /** * Ask the backend to speak `text` for a session now; returns the narration id * echoed on the resulting `audio_response`, or `undefined` if nothing was * sent. Pass `narrationId` to reuse a prior id (a `busy` retry) so the backend * can dedup a lost ack; omit it to mint a fresh one. * * `pending` names the form a `'question'` narration speaks. The backend drops * the request if that form has moved on, and otherwise re-renders whichever * question the form is now waiting on: it owns the draft of answers given so * far, which is why the caller names a form and not a question. `text` is * therefore only spoken verbatim during the debounce window before the * backend's mirror has caught up. The id is deliberately *not* folded into * `text`, which every dedup and retry-reuse guard keys on. */ requestNarration(codingSessionId: string, kind: VoiceNarrationKind, text: string, narrationId?: string, checkpoint?: IVoiceCheckpointNarrationMetadata, confirmationType?: VoiceConfirmationType, pending?: { pendingId: string; }): string | undefined; /** * Notify the backend of a session state transition. * * ``detail`` carries the human-readable description of the transition * (e.g. the confirmation prompt content for ``waiting_for_confirmation``) * and ``lastResponseSummary`` carries the agent's last response text for * ``idle`` transitions. Including them inline ensures the BE has the data * it needs to react/summarise without depending on the separate (debounced) * ``session_context`` delta arriving first or being current. */ sendSessionStateChange(sessionId: string, newState: string, label: string, detail?: string, lastResponseSummary?: string): void; stopSpeaking(): void; prepareForInputTargetChange(): void; sendStartSession(context: IVoiceSessionContext, machineId: string, priorTimeline?: readonly IVoicePriorTimelineEntry[], turnConfigOverride?: IVoiceTurnConfig, voiceInstructions?: string): void; sendResumeSession(context: IVoiceSessionContext, machineId: string, voiceInstructions?: string): void; submitFeedback(payload: IVoiceFeedbackPayload): Promise<{ ok: boolean; error?: string; }>; readonly onTranscription: Event; readonly onAudioResponse: Event; readonly onBargeIn: Event; /** Fired on `narration_ack`. Absent from older backends, so consumers must tolerate a narration that is never acked. */ readonly onNarrationAck: Event; /** Fired when the guard clears for a narration earlier bounced `busy`; see {@link IVoiceNarrationSignal}. */ readonly onNarrationUnblocked: Event; /** Fired when an accepted narration is cancelled by barge-in; see {@link IVoiceNarrationSignal}. */ readonly onNarrationInterrupted: Event; readonly onToolCall: Event; readonly onSpeechStarted: Event; readonly onSessionInit: Event; readonly onError: Event; readonly onDidChangeConnectionState: Event; /** Fired for transports that play remote audio directly instead of emitting PCM chunks. */ readonly onDidChangeRemoteAudioState: Event; /** * Fired when the current socket will not reconnect: a refusal, an expected * end of session, or a give-up. Consumers should tear down to a clean, * restartable state rather than entering a reconnect loop. */ readonly onFatalDisconnect: Event; /** Fired on a recoverable close so the UI can explain what it is waiting on. */ readonly onConnectionIssue: Event; /** * Fired when the backend ends a held turn on its own (server VAD silence or * a matched stop phrase). Consumers stop capturing for that turn and clear * the recording UI without sending their own ``ptt_end``. */ readonly onTurnAutoEnded: Event; readonly isConnected: boolean; readonly isResuming: boolean; /** Whether the current connection was started with GPT Live session awareness enabled. */ readonly isSessionAwarenessEnabled: boolean; /** Whether the current socket close has an automatic retry scheduled. */ readonly willReconnect: boolean; /** Backend session id assigned by the realtime server, or ``undefined`` when not yet established. */ readonly currentSessionId: string | undefined; } export declare const IVoiceClientService: import("../../../../../platform/instantiation/common/instantiation.js").ServiceIdentifier;