@cuekit-ai/react 1.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
- import React, { ReactNode } from 'react';
2
-
3
- declare const processVoice: (transcript: string, apiKey?: string, appId?: string, deviceId?: string) => Promise<any | null>;
1
+ import * as React from 'react';
2
+ import React__default, { ReactNode } from 'react';
3
+ import * as livekit_client from 'livekit-client';
4
+ import { ConnectionState, Room } from 'livekit-client';
4
5
 
5
6
  declare global {
6
7
  interface CueKitGlobalStore {
@@ -14,45 +15,361 @@ declare global {
14
15
  }
15
16
  var CuekitStore: CueKitGlobalStore;
16
17
  }
18
+ type QubeCtx = {
19
+ apiKey: string;
20
+ appId: string;
21
+ };
22
+ declare const useQubeContext: () => QubeCtx;
17
23
  type Props = {
18
24
  apiKey: string;
19
25
  deviceId?: string;
20
26
  appId: string;
21
27
  children: ReactNode;
22
- navigator?: any;
23
- };
24
- declare const CuekitProvider: React.FC<Props>;
25
-
26
- declare const useAudioController: () => {
27
- stop: () => void;
28
- isPlaying: () => boolean;
29
- play: (url: string) => Promise<void>;
28
+ navigationHandler?: (path: string, params?: Record<string, any>) => void;
29
+ onConnectionStateChange?: (state: any) => void;
30
+ onParticipantUpdate?: (participants: string[]) => void;
31
+ onToolLog?: (log: any) => void;
30
32
  };
33
+ declare const CuekitProvider: React__default.FC<Props>;
31
34
 
32
- declare function onStateChange(): void;
35
+ interface CuekitConfig {
36
+ apiKey: string;
37
+ appId?: string;
38
+ webRTC?: {
39
+ serverUrl?: string;
40
+ roomName?: string;
41
+ participantName?: string;
42
+ tokenTtlSeconds?: number;
43
+ };
44
+ }
45
+ declare function InitCuekit(config: CuekitConfig): void;
33
46
 
34
47
  type ScreenPosition = 'bottom-center' | 'bottom-left' | 'bottom-right';
48
+ type MicState$1 = 'idle' | 'listening' | 'thinking' | 'replying';
35
49
  type MicButtonProps = {
36
50
  hasText?: boolean;
37
51
  text?: string;
38
- textStyle?: React.CSSProperties;
52
+ textStyle?: React__default.CSSProperties;
39
53
  imageSource?: string;
40
- imageStyle?: React.CSSProperties;
41
- buttonStyle?: React.CSSProperties;
54
+ imageStyle?: React__default.CSSProperties;
55
+ buttonStyle?: React__default.CSSProperties;
42
56
  screenPosition?: ScreenPosition;
43
57
  bottomSpace?: number;
44
58
  buttonSize?: number;
59
+ defaultTheme?: 'light' | 'dark' | 'system';
60
+ showBorderGlow?: boolean;
45
61
  };
46
62
 
47
- declare const MicButton: React.FC<MicButtonProps>;
63
+ declare const MicButton: React__default.FC<MicButtonProps>;
64
+
65
+ interface ChatPopupProps {
66
+ isOpen: boolean;
67
+ isMinimized: boolean;
68
+ onClose: () => void;
69
+ onMinimize: () => void;
70
+ onRestore: () => void;
71
+ onSendText: (text: string) => Promise<any>;
72
+ onEndCall?: () => Promise<void>;
73
+ messages: Array<{
74
+ text: string;
75
+ sender: 'user' | 'assistant';
76
+ }>;
77
+ isConnected: boolean;
78
+ micState: string;
79
+ participants: string[];
80
+ error?: string | null;
81
+ currentTheme?: 'light' | 'dark';
82
+ onThemeToggle?: (theme: 'light' | 'dark') => void;
83
+ status?: string;
84
+ anchor?: {
85
+ position: 'bottom-right' | 'bottom-left' | 'bottom-center';
86
+ bottom: number;
87
+ size: number;
88
+ };
89
+ }
90
+ declare const ChatPopup: React__default.FC<ChatPopupProps>;
91
+
92
+ interface BorderGlowProps {
93
+ isActive: boolean;
94
+ }
95
+ declare const BorderGlow: ({ isActive }: BorderGlowProps) => React__default.JSX.Element | null;
48
96
 
49
- declare function InitCuekit(apiKey: string, navigator?: any): void;
97
+ interface VoiceIntensityVisualizerProps {
98
+ isActive: boolean;
99
+ barCount?: number;
100
+ minHeight?: number;
101
+ className?: string;
102
+ buttonSize?: number;
103
+ }
104
+ declare const VoiceIntensityVisualizer: React__default.FC<VoiceIntensityVisualizerProps>;
50
105
 
51
- declare const useVoiceRecognition: (lang?: string) => {
52
- isListening: boolean;
53
- startListening: () => Promise<string>;
54
- stopListening: () => Promise<void>;
55
- speechText: string;
106
+ interface AuthResponse {
107
+ session_id: string;
108
+ api_key: string;
109
+ user_identity: string;
110
+ app_id: string;
111
+ livekit_url: string;
112
+ livekit_token: string;
113
+ room_name: string;
114
+ }
115
+ interface TokenRequest {
116
+ user_identity: string;
117
+ room_name: string;
118
+ ttl_seconds: number;
119
+ }
120
+ interface TokenResponse {
121
+ token: string;
122
+ room_name: string;
123
+ expires_in: number;
124
+ }
125
+ interface ServerConfig {
126
+ livekit_url: string;
127
+ room_name: string;
128
+ participant_name: string;
129
+ token_ttl_seconds: number;
130
+ server_version: string;
131
+ }
132
+ interface NavigationCommand {
133
+ type: 'static_data_ready' | 'ai_intent' | 'user_speech_text' | 'ai_speech_text';
134
+ data?: {
135
+ app_id?: string;
136
+ components?: any[];
137
+ intents?: any[];
138
+ pages_count?: number;
139
+ elements_count?: number;
140
+ };
141
+ intent?: string;
142
+ actionType?: string;
143
+ text?: string;
144
+ confidence?: number;
145
+ target_element?: string;
146
+ current_page?: string;
147
+ user_input?: string;
148
+ speaker?: 'user' | 'ai';
149
+ duration?: number;
150
+ timestamp?: number;
151
+ }
152
+ declare function sendData(data: any, reliable?: boolean): Promise<void>;
153
+ declare function sendScreenStatus(screenData: any): Promise<void>;
154
+ declare function sendUserCommand(command: string): Promise<void>;
155
+ declare function sendStaticData(componentData: any, appId?: string): Promise<{
156
+ success: boolean;
157
+ data: any;
158
+ error?: undefined;
159
+ } | {
160
+ success: boolean;
161
+ error: string;
162
+ data?: undefined;
163
+ }>;
164
+
165
+ interface UserSpeechChunkData {
166
+ text_chunk: string;
167
+ is_final: boolean;
168
+ }
169
+ interface AISpeechChunkData {
170
+ text_chunk: string;
171
+ is_final: boolean;
172
+ }
173
+ interface AIIntentData {
174
+ intent: string;
175
+ routeName: string | null;
176
+ actionType: string;
177
+ confidence: number;
178
+ actionMetadata: {
179
+ elementId: string | null;
180
+ routeName: string | null;
181
+ };
182
+ }
183
+ interface AIInterruptedData {
184
+ message: string;
185
+ }
186
+ interface RequestRuntimeData {
187
+ session_id: string;
188
+ }
189
+ interface StaticDataReadyData {
190
+ [key: string]: any;
191
+ }
192
+ interface ToolLogData {
193
+ [key: string]: any;
194
+ }
195
+ type SSEActionEvent = {
196
+ type: 'user_speech_chunk';
197
+ timestamp?: number;
198
+ data: UserSpeechChunkData;
199
+ } | {
200
+ type: 'ai_speech_chunk';
201
+ timestamp?: number;
202
+ data: AISpeechChunkData;
203
+ } | {
204
+ type: 'ai_intent';
205
+ timestamp?: number;
206
+ data: AIIntentData;
207
+ } | {
208
+ type: 'ai_interrupted';
209
+ timestamp?: number;
210
+ data: AIInterruptedData;
211
+ } | {
212
+ type: 'request_runtime_data';
213
+ timestamp?: number;
214
+ data: RequestRuntimeData;
215
+ } | {
216
+ type: 'static_data_ready';
217
+ data: StaticDataReadyData;
218
+ } | {
219
+ type: 'tool_log';
220
+ data: ToolLogData;
221
+ } | {
222
+ type: 'connection';
223
+ status: 'connected';
224
+ app_id?: string;
225
+ } | {
226
+ type: 'keepalive';
227
+ timestamp?: number;
56
228
  };
229
+ interface SSEServiceCallbacks {
230
+ onActionEvent?: (event: SSEActionEvent) => void;
231
+ onConnectionChange?: (isConnected: boolean) => void;
232
+ onConversationUpdate?: (entry: {
233
+ speaker: 'user' | 'ai';
234
+ text: string;
235
+ is_final: boolean;
236
+ }) => void;
237
+ onIntentUpdate?: (intent: AIIntentData) => void;
238
+ onToolStatusUpdate?: (status: any) => void;
239
+ onStaticDataUpdate?: (data: any) => void;
240
+ onError?: (error: string) => void;
241
+ }
242
+ declare function setSSECallbacks(newCallbacks: SSEServiceCallbacks): void;
243
+ declare function connectSSE(newSessionId: string): Promise<void>;
244
+ declare function sendRuntimeData(): Promise<void>;
245
+ declare function sendDashboardData(dashboardData: any): Promise<void>;
246
+ declare function sendElementData(appId?: string): Promise<{
247
+ app_id: string;
248
+ current_page: string;
249
+ dom_structure: FullDOMStructure;
250
+ timestamp: number;
251
+ }>;
252
+ declare function disconnectSSE(): void;
253
+ declare function getSSEConnectionStatus(): boolean;
254
+ declare function getSSEConnectionState(): string;
255
+
256
+ interface ChatMessage {
257
+ id: string;
258
+ role: 'user' | 'ai';
259
+ text: string;
260
+ isFinal: boolean;
261
+ timestamp: string;
262
+ }
263
+ type MicState = 'idle' | 'listening' | 'thinking' | 'replying';
264
+ declare const useCuekit: (options?: {
265
+ onNavigationCommand?: (command: NavigationCommand) => void;
266
+ onConnectionStateChange?: (state: ConnectionState) => void;
267
+ onParticipantUpdate?: (participants: string[]) => void;
268
+ onAISpeechStart?: (trackId: string) => void;
269
+ onAISpeechEnd?: (trackId: string) => void;
270
+ appId?: string;
271
+ }) => {
272
+ isSseConnected: boolean;
273
+ lastActionEvent: SSEActionEvent | null;
274
+ messages: ChatMessage[];
275
+ micState: MicState;
276
+ setMicState: React.Dispatch<React.SetStateAction<MicState>>;
277
+ status: string;
278
+ setStatus: React.Dispatch<React.SetStateAction<string>>;
279
+ connect: (identity: string, apiKey?: string, appId?: string) => Promise<void>;
280
+ disconnect: () => Promise<void>;
281
+ isConnected: boolean;
282
+ isConnecting: boolean;
283
+ connectionState: ConnectionState | null;
284
+ room: livekit_client.Room | null;
285
+ roomName: string | null;
286
+ participants: string[];
287
+ error: string | null;
288
+ sendData: typeof sendData;
289
+ sendScreenStatus: typeof sendScreenStatus;
290
+ sendUserCommand: typeof sendUserCommand;
291
+ sendStaticData: typeof sendStaticData;
292
+ audioContainerRef: React.RefObject<HTMLDivElement>;
293
+ };
294
+
295
+ declare const useWebRTC: (options?: {
296
+ onNavigationCommand?: (command: NavigationCommand) => void;
297
+ onConnectionStateChange?: (state: ConnectionState) => void;
298
+ onParticipantUpdate?: (participants: string[]) => void;
299
+ onAISpeechStart?: (trackId: string) => void;
300
+ onAISpeechEnd?: (trackId: string) => void;
301
+ autoConnect?: boolean;
302
+ userIdentity?: string;
303
+ appId?: string;
304
+ }) => {
305
+ isConnected: boolean;
306
+ isConnecting: boolean;
307
+ connectionState: ConnectionState | null;
308
+ room: Room | null;
309
+ roomName: string | null;
310
+ participants: string[];
311
+ error: string | null;
312
+ connect: (identity: string, apiKey?: string, appId?: string) => Promise<AuthResponse | undefined>;
313
+ disconnect: () => Promise<void>;
314
+ sendData: typeof sendData;
315
+ sendScreenStatus: typeof sendScreenStatus;
316
+ sendUserCommand: typeof sendUserCommand;
317
+ sendStaticData: typeof sendStaticData;
318
+ audioContainerRef: React.RefObject<HTMLDivElement>;
319
+ };
320
+
321
+ interface WebRTCServerConfig {
322
+ serverUrl?: string;
323
+ apiKey: string;
324
+ roomName?: string;
325
+ participantName?: string;
326
+ tokenTtlSeconds?: number;
327
+ }
328
+ /**
329
+ * Configure WebRTC server settings
330
+ * @param config WebRTC server configuration (API key is required, others are optional)
331
+ */
332
+ declare const configureWebRTCServer: (config: WebRTCServerConfig) => void;
333
+ /**
334
+ * Get the current WebRTC server configuration
335
+ */
336
+ declare const getWebRTCServerConfig: () => WebRTCServerConfig | null;
337
+ /**
338
+ * Initialize WebRTC with API key (server URL uses default)
339
+ * @param apiKey Your API key for the WebRTC server
340
+ * @param customConfig Optional custom configuration overrides
341
+ */
342
+ declare const initWebRTCWithDeployedBackend: (apiKey: string, customConfig?: Partial<Omit<WebRTCServerConfig, "apiKey">>) => WebRTCServerConfig;
343
+ /**
344
+ * Initialize WebRTC with minimal configuration (requires API key)
345
+ * This is the simplest way to get started
346
+ * @param apiKey Your API key for the WebRTC server
347
+ */
348
+ declare const initWebRTC: (apiKey: string) => WebRTCServerConfig;
349
+
350
+ type DOMNodeData = {
351
+ hash: string;
352
+ text: string;
353
+ isClickable: boolean;
354
+ componentType: string;
355
+ children: DOMNodeData[];
356
+ };
357
+ type FullDOMStructure = {
358
+ components: DOMNodeData[];
359
+ };
360
+
361
+ interface ElementAction {
362
+ action_type: 'click' | 'navigate' | 'input' | 'focus' | 'toggle';
363
+ target_element?: string;
364
+ target?: string;
365
+ instruction?: string;
366
+ }
367
+ declare function executeAction(action: ElementAction): boolean;
368
+ declare function getFullDOMStructure(): FullDOMStructure;
369
+
370
+ /**
371
+ * Capture the full DOM structure as a flat list of interactive elements
372
+ */
373
+ declare function captureFullDOMStructure(): FullDOMStructure;
57
374
 
58
- export { CuekitProvider, InitCuekit, MicButton, onStateChange, processVoice, useAudioController, useVoiceRecognition };
375
+ export { BorderGlow, ChatPopup, type ChatPopupProps, CuekitProvider, type DOMNodeData, type ElementAction, type FullDOMStructure, InitCuekit, MicButton, type MicButtonProps, type MicState$1 as MicState, type NavigationCommand, type SSEActionEvent, type SSEServiceCallbacks, type ServerConfig, type TokenRequest, type TokenResponse, VoiceIntensityVisualizer, type WebRTCServerConfig, captureFullDOMStructure, configureWebRTCServer, connectSSE, disconnectSSE, executeAction, getFullDOMStructure, getSSEConnectionState, getSSEConnectionStatus, getWebRTCServerConfig, initWebRTC, initWebRTCWithDeployedBackend, sendDashboardData, sendElementData, sendRuntimeData, setSSECallbacks, useCuekit, useQubeContext, useWebRTC };