import type { RTCOfferOptions } from 'react-native-webrtc/lib/typescript/RTCUtil'; import { VOICE_IDS, VoiceId } from '../helpers'; import type { RealtimeContextValue, Constraints, ChatOptions, RealtimeSuccessCallbacks, RealtimeErrorCallbacks, AddableMessage } from '../types'; import { RealtimeClientClass } from '../components'; export type RTCIceServer = { credential?: string; url?: string; urls?: string | string[]; username?: string; }; export type RTCConfiguration = { bundlePolicy?: 'balanced' | 'max-compat' | 'max-bundle'; iceCandidatePoolSize?: number; iceServers?: RTCIceServer[]; iceTransportPolicy?: 'all' | 'relay'; rtcpMuxPolicy?: 'negotiate' | 'require'; }; export type TokenProvider = () => Promise; export type ChatMode = 'voice' | 'text'; export type SessionConfig = { model?: string; voice?: VoiceId; modalities?: Array<'audio' | 'text'>; turn_detection?: { type: 'server_vad'; silence_duration_ms?: number; threshold?: number; prefix_padding_ms?: number; } | null; input_audio_transcription?: { model: string; language?: string; }; tools?: any[]; instructions?: string; }; export type RealtimeClientHooks = { onOpen?: (dc: any) => void; onEvent?: (evt: any) => void; onError?: (e: any) => void; onUserTranscriptionDelta?: (payload: { itemId: string; delta: string; }) => 'consume' | void; onUserTranscriptionCompleted?: (payload: { itemId: string; transcript: string; }) => 'consume' | void; onAssistantTextDelta?: (payload: { responseId: string; delta: string; channel: 'audio_transcript' | 'output_text'; }) => 'consume' | void; onAssistantCompleted?: (payload: { responseId: string; status: 'done' | 'canceled'; }) => 'consume' | void; onToolCall?: (payload: { name: string; args: any; call_id: string; }) => Promise | any; }; export type MiddlewareCtx = { event: any; send: (e: any) => void | Promise; client: RealtimeClientClass; }; export type IncomingMiddleware = (ctx: MiddlewareCtx) => Promise | any | 'stop' | null | void; export type OutgoingMiddleware = (event: any) => any | null | 'stop' | Promise; export type Logger = { debug?: (...a: any[]) => void; info?: (...a: any[]) => void; warn?: (...a: any[]) => void; error?: (...a: any[]) => void; }; export type RealtimeStatus = 'idle' | 'connecting' | 'connected' | 'disconnected' | 'error' | 'user_speaking' | 'assistant_speaking'; export type RealtimeClientOptionsBeforePrune = { deleteChatHistoryOnDisconnect?: boolean; tokenProvider: TokenProvider; voice?: keyof typeof VOICE_IDS; webrtc?: { iceServers?: RTCIceServer[]; dataChannelLabel?: string; offerOptions?: RTCOfferOptions & { voiceActivityDetection?: boolean; }; configuration?: RTCConfiguration; }; media?: { getUserMedia?: Constraints; }; session?: Partial; autoSessionUpdate?: boolean; greet?: { enabled?: boolean; response?: { instructions?: string; modalities?: Array<'audio' | 'text'>; }; }; hooks?: RealtimeClientHooks; middleware?: { incoming?: IncomingMiddleware[]; outgoing?: OutgoingMiddleware[]; }; policy?: { isMeaningfulText?: (text: string) => boolean; }; chat?: ChatOptions; logger?: Logger; allowConnectWithoutMic?: boolean; }; /** * ОБНОВЛЕНО: Добавлены все Success и Error коллбэки в публичные пропсы */ export type RealTimeClientProps = RealtimeSuccessCallbacks & RealtimeErrorCallbacks & { chatUserAddOnDelta?: boolean; chatInverted?: boolean; deleteChatHistoryOnDisconnect?: boolean; chatUserPlaceholderOnStart?: boolean; chatAssistantAddOnDelta?: boolean; chatAssistantPlaceholderOnStart?: boolean; tokenProvider?: TokenProvider; webrtc?: { iceServers?: RTCIceServer[]; dataChannelLabel?: string; offerOptions?: RTCOfferOptions & { voiceActivityDetection?: boolean; }; configuration?: RTCConfiguration; }; media?: { getUserMedia?: Constraints; }; session?: Partial; autoSessionUpdate?: boolean; greetEnabled?: boolean; greetInstructions?: string; greetModalities?: Array<'audio' | 'text'>; onOpen?: RealtimeClientHooks['onOpen']; onEvent?: RealtimeClientHooks['onEvent']; onUserTranscriptionDelta?: RealtimeClientHooks['onUserTranscriptionDelta']; onUserTranscriptionCompleted?: RealtimeClientHooks['onUserTranscriptionCompleted']; onAssistantTextDelta?: RealtimeClientHooks['onAssistantTextDelta']; onAssistantCompleted?: RealtimeClientHooks['onAssistantCompleted']; onToolCall?: RealtimeClientHooks['onToolCall']; incomingMiddleware?: IncomingMiddleware[]; outgoingMiddleware?: OutgoingMiddleware[]; policyIsMeaningfulText?: (text: string) => boolean; chatEnabled?: boolean; chatIsMeaningfulText?: (text: string) => boolean; logger?: Logger; autoConnect?: boolean; attachChat?: boolean; allowConnectWithoutMic?: boolean; children?: React.ReactNode | ((ctx: RealtimeContextValue) => React.ReactNode); }; export type CoreConfig = Omit; export type SessionMode = 'voice' | 'text'; export type InitializeMode = { type: SessionMode; options?: Partial; }; export type EnhancedRealTimeClientProps = RealTimeClientProps & { initializeMode?: InitializeMode; attemptsToReconnect?: number; onReconnectAttempt?: (attempt: number, maxAttempts: number) => void; onReconnectSuccess?: () => void; onReconnectFailed?: (error: any) => void; }; export type RealTimeClientHandle = { enableMicrophone: () => Promise; getClient: () => RealtimeClientClass | null; getStatus: () => 'idle' | 'connecting' | 'connected' | 'disconnected' | 'error'; setTokenProvider: (tp: TokenProvider) => void; disableMicrophone: () => Promise; connect: () => Promise; disconnect: () => Promise; sendRaw: (e: any) => Promise | void; sendResponse: (opts?: any) => void; sendResponseStrict: (opts: { instructions: string; modalities?: Array<'audio' | 'text'>; conversation?: 'auto' | 'none'; }) => void; updateSession: (patch: Partial) => void; addMessage: (m: AddableMessage | AddableMessage[]) => string | string[]; clearAdded: () => void; clearChatHistory: () => void; getNextTs: () => number; switchToTextMode: (customParams?: Partial) => Promise; switchToVoiceMode: (customParams?: Partial) => Promise; getCurrentMode: () => SessionMode; getModeStatus: () => 'idle' | 'connecting' | 'connected' | 'disconnected'; }; //# sourceMappingURL=ClientStructure.d.ts.map