import { IObservable } from "../../../../../base/common/observable.js"; import { URI } from "../../../../../sessions/sessions.web.main.internal.js"; import { VoiceState, ITranscriptTurn, IPendingToolConfirmation } from "./voiceSessionController.js"; export interface IVoiceSessionController { readonly _serviceBrand: undefined; readonly voiceState: IObservable; readonly statusText: IObservable; /** Rolling buffer of the last 2 transcript turns (oldest first). */ readonly transcriptTurns: IObservable; readonly isConnected: IObservable; readonly isConnecting: IObservable; readonly isReconnecting: IObservable; /** Whether the current connection uses OpenAI GPT Live rather than hosted voice. */ readonly isUsingGptLive: boolean; /** Whether the user has muted the microphone while keeping the session connected. */ readonly isMuted: IObservable; readonly pendingToolConfirmations: IObservable; /** The session resource that transcriptions will be sent to. undefined = active session. */ readonly targetSession: IObservable; /** Whether Voice Mode is explicitly owned by a new-session draft. */ readonly hasDraftTarget: IObservable; /** Session that produced the response most recently spoken to the user. */ getLastSpokenResponseSession(): URI | undefined; connect(window: Window & typeof globalThis): Promise; /** Update the OS window whose focus controls capture and hands-free listening. */ setActiveWindow(window: Window & typeof globalThis): void; disconnect(source?: "explicit" | "internal"): void; pttDown(source?: "explicit" | "auto" | "connect", forceNewTurn?: boolean): void; pttUp(source?: "explicit" | "internal", forceFinish?: boolean): void; /** * Stop the current recording / auto-listen loop without disconnecting. * Any in-flight push-to-talk press is finished through the normal * `ptt_end` path (the backend finalizes the turn) and the auto-listen * re-arm loop is suppressed until the user talks again. The WebSocket * stays connected so the user can resume via the Voice Mode button * without a new handshake. Use `disconnect()` to fully end the session. */ stopListening(source?: "explicit" | "internal"): void; /** * Mute or unmute the microphone without ending the session. While muted, * captured audio is not forwarded to the backend so background noise or * private speech never reaches transcription, but the WebSocket stays * connected so the user can unmute and resume instantly. */ setMuted(muted: boolean): void; /** * Hold hands-free auto-listen off until released. * * Unlike {@link stopListening}, this is safe to call *before* the session is * connected: it survives the connect handshake, so a caller that needs the * microphone to stay shut while the user reads or decides something can take * the hold at `connect()` time rather than racing `session_init`. Releasing * enters listening immediately if hands-free would have done so. */ setAutoListenHeld(held: boolean): void; /** * Stop the current recording WITHOUT finalizing the turn: any in-flight * push-to-talk press is aborted (no `ptt_end` is sent), so the backend * never finalizes the buffered speech into a `send_to_chat`. Use this on * focus changes so speech captured for one session can't be misrouted to a * newly focused session. Like {@link stopListening}, the WebSocket stays * connected and the auto-listen re-arm loop is suppressed until the user * talks again. */ discardListening(): void; /** * Stop listening on a focus change while the user is actively dictating: * finalize the in-flight press (send `ptt_end`) but pin the resulting * submission to `session` — the session the user was dictating into — so * their words are not misrouted to the newly focused session. The WebSocket * stays connected and the auto-listen re-arm loop is suppressed until the * user talks again. Use {@link discardListening} instead when nothing has * been dictated yet. */ finishListeningAndSubmitTo(session: URI): void; /** * Mark a session as having been cancelled by the user from VS Code UI. The * next state-change detected for this session (typically the chat model * transitioning to `idle`) will be suppressed so the backend doesn't * narrate a status update the user already knows about. */ markUserCancelled(sessionId: string): void; /** * Set the target session for transcription. When set, transcriptions are * sent to this session instead of the currently active one. */ setTargetSession(resource: URI | undefined): void; /** Bind Voice Mode to the currently shown new-session draft. */ setDraftTarget(): void; /** * Create a new chat session and set it as the target for transcription. */ newSessionAsTarget(): void; /** * Declares the session shown in the UI for playback deferral and buffered * flushes. It also supplies `is_active` when no voice target is pinned. * `undefined` restores focus-based detection. * `null` explicitly indicates that a draft with no session is shown. */ setActiveSessionShown(resource: URI | null | undefined): void; /** Promote the owned draft after that draft creates its first chat session. */ promoteDraftTarget(resource: URI): void; /** * Deterministically route audio to and narrate a session in response to an * explicit UI action (e.g. clicking a session's pending-voice indicator). * Unlike the shown/focus heuristics, this activates even when the session is * already the active/shown one - so a completed background reply the user * clicks to hear is played rather than silently ignored because no focus or * view-model change event fired. */ activateSession(resource: URI): void; /** * Submit user feedback along with full diagnostic data (transcript history, * client state, environment info). Returns success/failure. */ submitFeedback(feedbackText: string): Promise<{ ok: boolean; error?: string; }>; /** DEV ONLY: Simulate a connected session with fake transcript for UI testing. */ simulateConnection(): void; } export declare const IVoiceSessionController: import("../../../../../platform/instantiation/common/instantiation.js").ServiceIdentifier;