import { ConnectionQuality } from 'livekit-client'; import { AudioConfig } from './audio-track-manager'; import { AvatarStreamError } from './error'; import { LogLevel } from './logger'; import { TranscriptionData } from './transcription-manager'; import { ConnectionState } from './connection-state-machine'; /** * Configuration options for the LiveKit client */ export interface LiveKitClientConfig { /** Audio configuration options */ audioConfig?: AudioConfig; /** Error handler callback */ onError?: (error: AvatarStreamError) => void; /** Whether to automatically attempt reconnection on unexpected disconnects */ autoReconnect?: boolean; /** Maximum number of reconnection attempts */ maxReconnectAttempts?: number; /** Base interval between reconnection attempts (will increase with backoff) */ reconnectInterval?: number; /** Called when reconnection attempts start */ onReconnecting?: () => void; /** Called when successfully reconnected */ onReconnected?: () => void; /** Minimum log level to display */ logLevel?: LogLevel; } /** * Manages connection to a LiveKit room and handles audio streaming * This class serves as a facade for the underlying components */ export declare class LiveKitClient { private roomManager; private audioManager; private transcriptionManager; private errorRecovery; private logger; /** * Creates a new LiveKit client * @param config Configuration options */ constructor(config?: LiveKitClientConfig); /** * Initializes the LiveKit room connection * @param url LiveKit server URL * @param token Authentication token * @returns Promise resolving to true if connection was successful */ init(url: string, token: string): Promise; /** * Handles track subscription events * @param track The remote track that was subscribed to * @private */ private handleTrackSubscribed; /** * Handles track unsubscription events * @param track The remote track that was unsubscribed * @private */ private handleTrackUnsubscribed; /** * Handles active speaker change events * @param speakers The new active speakers * @private */ private handleActiveSpeakersChanged; /** * Handles data received events * @param payload The data payload received * @private */ private handleDataReceived; /** * Emits a custom event * @param event The event name * @param data The event data * @private */ private emit; /** * Disconnects from the LiveKit room and cleans up resources * @returns Promise that resolves when disconnection is complete */ disconnect(): Promise; /** * Pauses audio playback */ pause(): Promise; /** * Resumes audio playback * @throws Error if playback cannot be resumed */ resume(): Promise; /** * Stops audio playback and cleans up resources without disconnecting */ stop(): Promise; /** * Sets a callback to receive transcription updates * @param callback The callback function */ setTranscriptionCallback(callback: (data: TranscriptionData) => void): void; /** * Initiates audio playback in response to a user gesture * This is needed to work around browser autoplay restrictions * @throws Error if playback cannot be initiated */ userInitiatedPlay(): Promise; /** * Checks if connected to the LiveKit room * @returns True if connected */ isConnected(): boolean; /** * Checks if currently attempting to reconnect * @returns True if reconnecting */ isReconnectingState(): boolean; /** * Gets the current connection state * @returns The current connection state */ getConnectionState(): ConnectionState; /** * Gets the current connection quality * @returns The connection quality, or null if not connected */ getConnectionQuality(): ConnectionQuality | null; }