export interface GatewayConfig {
    url: string;
    token: string;
    audioProfile?: 'standard' | 'asr_priority';
    iosAudioMode?: 'baseline' | 'aec' | 'aec_full';
    autoReconnect?: boolean;
    reconnectInterval?: number;
    maxReconnectAttempts?: number;
    heartbeatInterval?: number;
    connectTimeout?: number;
    iceServers?: RTCIceServer[];
    authMethod?: 'url' | 'message';
}
export declare enum GatewayState {
    DISCONNECTED = "disconnected",
    CONNECTING = "connecting",
    SOCKET_OPEN = "socket_open",
    AUTHENTICATED = "authenticated",
    CONNECTED = "connected",
    RECONNECTING = "reconnecting",
    CLOSED = "closed"
}
export interface LLMChatParams {
    query: string;
    inputs: {
        character_id: string;
        chat_id?: string;
        tts_enabled?: boolean;
        a2f_enabled?: boolean;
        chunk_type?: 'stream' | 'stream_sentence' | 'block';
        use_webrtc_tts?: boolean;
    };
}
export interface TTSParams {
    character_id: string;
    text: string;
    a2f_enabled?: boolean;
    use_webrtc_tts?: boolean;
    xf?: number;
    dialect?: string;
    synthetic?: boolean;
}
export interface LLMResponseCallback {
    type: 'llm' | 'tts' | 'a2f' | 'end';
    text?: string;
    sampleRate?: number;
    audio?: ArrayBuffer;
    blendShapes?: number[][];
    audioOffset?: number;
    streamId?: string;
    endType?: 'llm' | 'tts' | 'a2f' | 'asr';
}
export interface TTSResponseCallback {
    type: 'rate' | 'audio' | 'a2f' | 'end';
    sampleRate?: number;
    audio?: ArrayBuffer;
    blendShapes?: number[][];
    streamId?: string;
    endType?: 'tts' | 'a2f';
}
export interface ASRResponseCallback {
    text: string;
    isFinal: boolean;
}
export interface WebRTCSDPParams {
    type: 'offer' | 'answer';
    sdp: string;
}
export interface WebRTCICEParams {
    candidate: string;
    sdpMid: string;
    sdpMLineIndex: number;
    usernameFragment?: string;
}
export interface WebRTCSDPResponseCallback {
    type: 'offer' | 'answer';
    sdp: string;
}
export interface WebRTCICEResponseCallback {
    candidate: string;
    sdpMid: string;
    sdpMLineIndex: number;
    usernameFragment?: string;
}
declare class GatewayService {
    private static readonly IOS_AUDIO_MODES;
    private config;
    private ws;
    private state;
    private reconnectAttempts;
    private reconnectTimer;
    private heartbeatTimer;
    private heartbeatPongTimer;
    private isDestroyed;
    private updateTokenWarnedOnce;
    private connectInFlight;
    private lastStateSyncFrame;
    private lastVoiceInteractionConfigFrame;
    private authenticationCount;
    private _sessionId;
    get sessionId(): string;
    private llmCallback;
    private ttsCallback;
    private asrCallback;
    private serverPushTTSCallback;
    private webrtcSDPCallback;
    private webrtcICECallback;
    private currentTTSSampleRate;
    private peerConnection;
    private dataChannel;
    private remoteAudioElement;
    private isWebRTCReady;
    private localAudioTrack;
    private webrtcReconnectAttempts;
    private webrtcReconnectTimer;
    private webrtcASRCallback;
    private isWebRTCReconnecting;
    private isCreatingWebRTC;
    private static readonly WEBRTC_MAX_RECONNECT_ATTEMPTS;
    private static readonly WEBRTC_RECONNECT_INTERVAL;
    private webrtcStatsTimer;
    private lastInboundStats;
    private ttsDataChannelCallback;
    private vadAudioContext;
    private vadAnalyser;
    private vadSourceNode;
    private vadDetectionTimer;
    private vadCallback;
    private vadEnabled;
    private vadEnergyHistory;
    private vadConsecutiveSpikes;
    private vadWarmupComplete;
    private audioLevelCallback;
    private audioLevelTimer;
    private static readonly AUDIO_LEVEL_INTERVAL;
    private static readonly VAD_DETECTION_INTERVAL;
    private static readonly VAD_WINDOW_SIZE;
    private static readonly VAD_SPIKE_THRESHOLD;
    private static readonly VAD_MIN_ABSOLUTE_RMS;
    private static readonly VAD_CONSECUTIVE_SPIKES_REQUIRED;
    private static readonly VAD_MIN_WARMUP_SAMPLES;
    private static readonly VAD_WARMUP_STABILITY_THRESHOLD;
    private ttsDumpEnabled;
    private ttsDumpActive;
    private ttsDumpSampleRate;
    private ttsDumpChunks;
    private ttsDumpTotalBytes;
    private ttsDumpSeq;
    private ttsDumpFinalizeTimer;
    private ttsDumpLastUrl;
    private ttsDumpLastFilename;
    constructor(config: GatewayConfig);
    private resolveIOSAudioMode;
    private buildIOSAudioConstraints;
    connect(): Promise<void>;
    disconnect(): void;
    reconnect(): Promise<void>;
    sendLLMChat(params: LLMChatParams, callback?: (data: LLMResponseCallback) => void): Promise<void>;
    sendToolAction(tool: string, action: string, data: object): void;
    sendTTS(params: TTSParams, callback?: (data: TTSResponseCallback) => void): Promise<void>;
    sendTextToAudio(text: string, characterId: string, options?: {
        useWebRTCTTS?: boolean;
        a2fEnabled?: boolean;
    }): void;
    setServerPushTTSCallback(callback: ((data: TTSResponseCallback) => void) | null): void;
    clearTTSCallback(): void;
    sendASRSync(audioData: ArrayBuffer, callback?: (data: ASRResponseCallback) => void): Promise<void>;
    sendASRAudio(audioData: ArrayBuffer, callback?: (data: ASRResponseCallback) => void): Promise<void>;
    stopASR(): Promise<void>;
    sendWebRTCSDP(params: WebRTCSDPParams, callback?: (data: WebRTCSDPResponseCallback) => void): Promise<void>;
    sendWebRTCICE(params: WebRTCICEParams): Promise<void>;
    createWebRTCConnection(asrCallback?: (data: ASRResponseCallback) => void): Promise<RTCPeerConnection>;
    closeWebRTCConnection(): void;
    private attemptWebRTCReconnect;
    private _muteRefCount;
    muteLocalAudio(): void;
    unmuteLocalAudio(): void;
    forceUnmuteLocalAudio(): void;
    isLocalAudioMuted(): boolean;
    private setupVAD;
    startVADDetection(callback: (detected: boolean, energy: number) => void): void;
    stopVADDetection(): void;
    startAudioLevelMonitor(callback: (level: number) => void): void;
    stopAudioLevelMonitor(): void;
    private cleanupVAD;
    sendWebRTCClose(): Promise<void>;
    sendInterrupt(): Promise<void>;
    sendTTSPlaybackState(event: 'playback_started' | 'playback_ended', context?: 'graceful_exit_prompt' | 'graceful_exit_phase2_prompt'): void;
    sendStateSync(state: 'SLEEPING' | 'IDLE' | 'LISTENING' | 'THINKING' | 'SPEAKING' | 'COOLDOWN'): void;
    sendVoiceInteractionConfig(config: {
        wakeWords: string[];
        syntheticTexts?: string[];
        voiceEngine?: string;
        characterId?: string;
    }): void;
    private replaySessionDirectives;
    setLLMCallback(callback: ((data: LLMResponseCallback) => void) | null): void;
    getState(): GatewayState;
    isConnected(): boolean;
    updateToken(token: string): void;
    refreshAuthToken(token: string): Promise<void>;
    destroy(): void;
    private buildWebSocketUrl;
    private sendLogin;
    private handleMessage;
    private handleLLMResponse;
    private handleTTSSampleRate;
    private handleTTSAudio;
    private handleTTSAudioSequence;
    private handleASRResponse;
    private handleA2FResponse;
    private handleA2FResponseSequence;
    private handleEndMarker;
    private startTtsDump;
    private appendTtsDump;
    private scheduleFinalizeTtsDump;
    private finalizeTtsDump;
    private encodeWavPcm16;
    private handleCharacterAction;
    private handleWebRTCSDPResponse;
    private handleWebRTCICEResponse;
    private handleWebRTCAnswer;
    private handleWebRTCICE;
    private handleWebRTCReady;
    private handleWebRTCClose;
    isWebRTCConnected(): boolean;
    getRemoteAudioElement(): HTMLAudioElement | null;
    resumeRemoteAudio(): void;
    setTTSDataChannelCallback(callback: ((audio: ArrayBuffer) => void) | null): void;
    setRemoteAudioMuted(muted: boolean): void;
    isTTSDataChannelReady(): boolean;
    startWebRTCStatsMonitoring(): void;
    stopWebRTCStatsMonitoring(): void;
    getWebRTCStats(): Promise<{
        packetsReceived: number;
        bytesReceived: number;
        packetsLost: number;
        jitter: number;
        roundTripTime: number;
    } | null>;
    private static readonly GRPC_CANCEL_PATTERNS;
    private handleSystemError;
    private handleLoginError;
    private handleBalanceError;
    private handleError;
    private handleClose;
    private scheduleReconnect;
    private stopReconnect;
    private startHeartbeat;
    private stopHeartbeat;
    private sendHeartbeat;
    private setState;
}
export default GatewayService;
//# sourceMappingURL=GatewayService.d.ts.map