/**
 * AIChatRTCLocal.session.ts — LocalRTCSession
 *
 * 管理单次本地语音会话生命周期：VAD → ASR → LLM → TTS。
 * 依赖 ChildSessionMixin、SandboxToolEnv、backend 类。
 */
import { WebSpeechASRBackend, WhisperASRBackend, LocalNeuralASRBackend, BrowserSpeechTTSBackend, LocalNeuralTTSBackend } from './AIChatRTCLocal.backends';
type SessAny = Record<string, any>;
declare class LocalRTCSession {
    parent: SessAny;
    sdk: SessAny;
    _cleanupChildSessions: () => void;
    _cancelDebounceTimers: () => void;
    _consumePendingChildResults: () => unknown[];
    [key: string]: any;
    /**
     * @param {AIChatRTCLocal} parent - Parent AIChatRTCLocal instance
     * @param {Object} config - Session configuration
     */
    constructor(parent: SessAny, config?: SessAny);
    on(event: string, callback: (data?: unknown) => void): this;
    off(event: string, callback: (data?: unknown) => void): this;
    emit(event: string, data?: unknown): void;
    /**
     * Start the session: load VAD SDK → request mic → init VAD + STT.
     * @returns {Promise<void>}
     */
    start(): Promise<void>;
    /**
     * Stop the session and release all resources.
     * @returns {Promise<void>}
     */
    stop(): Promise<void>;
    /** Alias for stop() */
    destroy(): Promise<void>;
    _cleanup(): void;
    _cleanupChildSessionsSafe(): void;
    _mergeConfigSection(currentConfig?: SessAny, nextConfig?: SessAny): SessAny;
    _buildTTSBackendSignature(ttsConfig?: SessAny): string;
    _reloadTTSBackend(): Promise<void>;
    updateTTSConfig(nextTTSConfig?: SessAny, options?: SessAny): Promise<{
        applied: boolean;
        reinitialized: boolean;
    }>;
    /**
     * Send text to the LLM (bypass voice pipeline).
     * @param {string} text
     */
    sendText(text: string): void;
    /**
     * Interrupt: cancel TTS + abort LLM.
     */
    interrupt(): void;
    /**
     * Mute: pause VAD (stop detecting speech).
     */
    mute(): void;
    /**
     * Unmute: resume VAD.
     */
    unmute(): void;
    /**
     * Get accumulated conversation history.
     * @returns {Array<{ role: string, text: string, roundId: string|null }>}
     */
    getHistory(): any[];
    /** Clear conversation history. */
    clear(): void;
    _getAudioConstraints(): any;
    _getMicrophoneStream(): Promise<MediaStream>;
    _releaseMediaStream(stream?: any): void;
    _initSileroVAD(): Promise<void>;
    _initEnergyVAD(): Promise<void>;
    _onSpeechStart(): void;
    _onSpeechEnd(audio?: SessAny): void;
    _initializeASRBackend(): Promise<void>;
    _createASRBackend(provider: string, asrConfig: SessAny): WebSpeechASRBackend | WhisperASRBackend | LocalNeuralASRBackend | null;
    _emitASRStatus(phase: string, extra?: SessAny): void;
    _initializeTTSBackend(): Promise<void>;
    _createTTSBackend(provider: string, ttsConfig: SessAny): BrowserSpeechTTSBackend | LocalNeuralTTSBackend | null;
    _emitTTSStatus(phase: string, extra?: SessAny): void;
    _resolveLocalNeuralTTSSpeakerId(ttsConfig: SessAny, defaultSpeakerId: number): number | undefined;
    _notifyMediaStreamChanged(stream: SessAny | null): void;
    _beginRecognitionRound(): void;
    _handleASRInterimText(text: string): void;
    _handleASRFinalText(text: string): void;
    _handleASRUtteranceEnd(): void;
    _handleASRError(message: unknown, { fatal }?: {
        fatal?: boolean;
    }): void;
    _startRecognition(): Promise<void>;
    _stopRecognition(): Promise<void>;
    _finalizeSpeech(): void;
    _sendToLLM(userText: string, roundId: unknown): Promise<void>;
    /**
     * Execute one LLM round. If the LLM returns tool_calls, execute them and recurse.
     * @param {string} roundId
     * @param {Array} tools - Tool definitions for the LLM
     * @param {number} iteration - Current iteration (guards against runaway loops)
     */
    _llmRound(roundId: unknown, tools: unknown, iteration: number): Promise<void>;
    _getSystemMessages(): any[];
    /**
     * Expand all ${...} template expressions in SystemMessages using the sandbox.
     * Called once during start().
     */
    _expandSystemMessages(): Promise<void>;
    /**
     * Split buffered text on sentence boundaries and enqueue complete sentences.
     */
    _flushSentencesToTTS(): void;
    _enqueueTTS(text: string): void;
    _cancelTTS(): void;
    _drainTTSQueue(): Promise<void>;
    _startTTSLevelTimer(): void;
    _stopTTSLevelTimer(): void;
    _applyTTSConfig(utterance: SessAny, ttsConfig: SessAny): void;
    _selectVoice(utterance: SessAny, voiceType: string, lang: string): void;
    /**
     * Speak text directly (utility method, bypasses queue).
     */
    _speak(text: string): void;
    _setState(code: number): void;
    _addHistory(role: string, text: string, roundId?: unknown): void;
}
/**
 * 安装 LocalRTCSession 的 ChildSessionMixin 相关 prototype 注册。
 *
 * 注意：必须用「导出函数 + 在聚合入口（AIChatRTCLocal.core.ts）实际调用」的方式注册，
 * 而非模块顶层裸语句。后者是对被聚合引用类的无返回值顶层副作用语句，Rollup
 * tree-shaking 会因其无外部可观测副作用而删除，导致本地 RTC 子 agent 方法缺失。
 * 集中到本函数并由 core 引用调用，可被 Rollup 当作有副作用的调用保留。
 */
export declare function installLocalRTCSessionMixin(): void;
export default LocalRTCSession;
export { LocalRTCSession };
//# sourceMappingURL=AIChatRTCLocal.session.d.ts.map