/** * @license * Copyright 2026 Qwen * SPDX-License-Identifier: Apache-2.0 */ import type { BackendRegistry } from '../adaptor/registry.js'; import type { ProactiveConfig } from '../config.js'; import { type LiveLanguage } from '../i18n/messages.js'; import type { MemoryService } from '../memory/service.js'; import type { LiveVisualCapture } from '../host/qwen-live-harness-host-coordinator.js'; import type { LiveState, LiveVisualInput, LiveVisualSource } from '../host/types.js'; import { searchQwenRealtime } from '../realtime/web-search.js'; import { synthesizeNotificationSpeech } from '../realtime/notification-speech.js'; import { analyzeQwenRealtimeImage } from '../realtime/visual-analysis.js'; import { openQwenRealtimeSession } from '../realtime/realtime-session.js'; import type { SessionLog } from '../log/session-log.js'; import type { DebugArchive } from '../log/debug-archive.js'; import { type RuntimeFailureSink } from '../log/runtime-failure.js'; import { LiveLogger } from '../logger.js'; import { type PermissionMode } from '../permission-preferences.js'; import { type ProactiveSchedulerControl, type ProactiveSchedulerOptions } from '../proactive/scheduler.js'; import type { MonitorDebugStore } from '../proactive/monitor-debug-store.js'; import type { SubagentsControlRequest, SubagentsControlResult, SubagentsSnapshot } from '../subagents/types.js'; /** * The Host surface LiveSession drives. Structurally satisfied by the ported * LiveHostCoordinator. */ export interface LiveHostControl { setCallState(epoch: number, state: Exclude): boolean; /** Registers the live session as the visual-capture-authorized caller. */ setCoordinator(epoch: number, locator: { workspaceCwd: string; sessionId: string; }): boolean; sendOutputAudio(epoch: number, pcm16: Uint8Array): boolean; finishOutputAudio(epoch: number): void; isOutputMuted?(): boolean; isInputMuted?(): boolean; clearOutput(epoch: number): void; setCaption(epoch: number, caption: string): boolean; setStatusText(epoch: number, statusText?: string): boolean; setTranscript?(epoch: number, transcript: string): boolean; failCall(epoch: number, message?: string): boolean; setProviderReachability?(readiness?: { state: 'ready' | 'checking' | 'unavailable'; blocker?: 'provider_config' | 'provider_unreachable'; message?: string; }): void; captureVisualContext(callerSessionId: string, options?: { persistAsset?: boolean; screenScope?: 'display'; }): Promise; } export interface LiveRealtimeConfig { endpoint: string; apiKey?: string; model: string; voice?: string; } export interface LiveSessionOptions { host: LiveHostControl; registry: BackendRegistry; realtime: LiveRealtimeConfig; getLanguage?: () => LiveLanguage; getPermissionMode?: () => PermissionMode; log: SessionLog; logger?: LiveLogger; onFailure?: RuntimeFailureSink; failureSecrets?: readonly string[]; openRealtime?: typeof openQwenRealtimeSession; searchRealtime?: typeof searchQwenRealtime; notificationSpeech?: typeof synthesizeNotificationSpeech; analyzeRealtimeImage?: typeof analyzeQwenRealtimeImage; proactive?: ProactiveConfig; monitorDebug?: MonitorDebugStore; debugArchive?: DebugArchive; memory?: MemoryService; createProactiveScheduler?: (options: ProactiveSchedulerOptions) => ProactiveSchedulerControl; gracefulStopDrainMs?: number; onSubagentsChanged?: (snapshot: SubagentsSnapshot) => void; } export declare class LiveSession { private readonly options; /** Language evidence from real users survives reconnects, unlike provider history. */ private notificationLanguageSamples; private readonly conversationLanguage; private readonly host; private readonly registry; private readonly log; private readonly logger; private readonly openRealtime; private readonly searchRealtime; private readonly notificationSpeech; private readonly proactiveFallbacks; private readonly analyzeRealtimeImage; private readonly createProactiveScheduler; private readonly gracefulStopDrainMs; private readonly handles; private readonly broker; /** Stream sessions explicitly observed by this Qwen Live Harness daemon across calls. */ private readonly observedSessions; private readonly backendPumps; private readonly pendingSubmissions; private readonly joinedTasks; private readonly subagents; private readonly stopOperations; private readonly requestedStops; private readonly permissionOperations; private readonly permissionDecisions; private readonly toolExecutions; private readonly announcedExecutions; private readonly controlReceipts; private controlReceiptSeq; private searchSeq; private disposed; private deliveryRevision; private readonly deliverySubscriptions; private active?; private readonly reportSubscriptions; private readonly reports; private readonly debugAdaptors; constructor(options: LiveSessionOptions); /** The adaptor that owns a backend handle (registry routing). */ private permissionMode; /** Called only after the user's new mode has been saved successfully. */ permissionModeChanged(): void; private adaptorFor; private observedAdaptor; /** LiveCallHandlers.onStart */ start(call: { epoch: number; callId: string; mode: 'resume' | 'new'; visualInput: LiveVisualInput; }): Promise; /** LiveCallHandlers.onStop */ stop(call: { epoch: number; callId: string; }): Promise; /** LiveCallHandlers.onInputAudio */ pushAudio(call: { epoch: number; callId: string; pcm16: Buffer; }): boolean; /** LiveCallHandlers.onInputMuteChanged */ setInputMuted(call: { epoch: number; inputMuted: boolean; }): void; /** LiveCallHandlers.onPlaybackStarted */ playbackStarted(call: { epoch: number; }): void; /** LiveCallHandlers.onPlaybackCompleted */ playbackCompleted(call: { epoch: number; }): void; /** LiveCallHandlers.onOutputMuted */ outputMuted(call: { epoch: number; }): void; /** LiveCallHandlers.onInputImage */ pushImage(call: { epoch: number; callId: string; source: LiveVisualSource; image: string; displayId?: string; }): boolean; setVisualSettings(call: { epoch: number; callId: string; visualInput: LiveVisualInput; }): void; dispose(): void; getSubagentsSnapshot(): SubagentsSnapshot; private instructionDelivery; private reportContext; private acceptPeerReport; private injectPeerReport; /** One tool-free worker owns one output. It never requests a main-model turn. */ private startResultSpeech; private generateResultSpeech; private finishIsolatedSpeech; private abortResultSpeech; private finishPeerReport; private endPeerReport; private instructionDeliveries; private withPendingPermissions; handleSubagentsRequest(request: SubagentsControlRequest): Promise; private dispatchSubagentsRequest; private decorateSubagent; private stopSubagent; private permissionTaskId; private permissionView; private permissionDetailsText; private executionKey; private approvalSpeechContext; private approvalReadout; private onPermissionDecision; private announceExecution; private publishPendingPermissionState; private respondSubagentPermission; private queueControlReceipt; private enqueueControlReceipts; private finishRequestedStop; private observeJob; private reconcileSubagentSession; private observeProactive; syncMemorySettings(): void; private instructions; private sessionTools; private publishMemoryContext; private attachMemory; private detachMemory; private callbacksFor; private taskAuthorizationFailure; private taskLeaseCurrent; private proactiveControlTargets; private backendControlTargets; private taskTargetAuthorized; private authorizeTaskAction; private dispatchTool; private dispatchMemoryTool; private rememberNarrationInput; private narrationInput; private clearNarrationInputs; private dispatchProactiveTool; private toolHandlers; private handoff; private resolveHandoffTarget; private buildHandoffBlocks; private ensurePump; private pump; private joinedTaskKey; private bindJoinedTask; private onBackendEvent; private enqueuePermission; private permissionContext; private rememberPermissionInput; private recoveredPermissionNeedsConfirmation; private restoreTransportContext; private requeueProactiveAfterTransportRecovery; private enqueuePendingPermissions; private scopedPermissionId; private notificationLanguage; private proactiveTaskContext; private recordCommittedProactiveMutation; private restoreAdjacentTaskAfterIncompleteTurn; private assertProactiveMutationSucceeded; private adjacentProactiveTask; private onProactiveTaskFailed; private settleProactiveResponse; private queueProactiveSpeechFallback; private runProactiveSpeechFallback; private completeProactiveSpeechFallback; private undeliverProactiveSpeech; private abortProactiveFallbacks; private clearProactiveCancellationGrace; private deferInterruptedProactiveDelivery; private suppressProactiveOutput; private failProactiveResponse; private enqueueProactiveDelivery; private invalidateProactiveDelivery; private captureObserverVision; private observeDisplay; private captureVisualContext; private injectContext; private injectSpeech; private injectProactiveEvent; private sendVisualSettings; private forwardVisualFrame; private debug; private realtimeDebugContext; private recordFailure; private finishStop; private stopDiscovery; private cleanupContext; private closeActive; private searchIsCurrent; private webSearch; private createSearchTask; private runVisualAnalysis; private lookupMessageKey; private runWebSearch; private queueSearchResult; private injectSearchResult; /** Correlation and delivery state only; answer text lives in its transcript. */ private logSearchDelivery; private finishSearchResult; private endSearchResult; private finishSearchTask; private cancelSearchTask; private cancelCallSearches; private cancelSearchFallback; private fallbackSearch; }