@elevenlabs/react-native 0.3.1 → 0.4.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.
@@ -86,7 +86,7 @@ export const useConversationSession = (
86
86
  setToken("");
87
87
  setStatus("disconnected");
88
88
  callbacksRef.current.onStatusChange?.({ status: "disconnected" });
89
- callbacksRef.current.onDisconnect?.("User ended conversation");
89
+ callbacksRef.current.onDisconnect?.({ reason: "user" });
90
90
  } catch (error) {
91
91
  callbacksRef.current.onError?.(error as string);
92
92
  throw error;
@@ -40,7 +40,7 @@ export const useLiveKitRoom = (
40
40
  setRoomConnected(false);
41
41
  setStatus("disconnected");
42
42
  setLocalParticipant(null);
43
- callbacksRef.current.onDisconnect?.("disconnected");
43
+ callbacksRef.current.onDisconnect?.({ reason: "user" });
44
44
  }, [callbacksRef, setStatus]);
45
45
 
46
46
  const handleError = useCallback(
package/src/types.ts CHANGED
@@ -1,51 +1,33 @@
1
+ import type * as Types from "@elevenlabs/types";
2
+ import type {
3
+ Incoming,
4
+ Outgoing,
5
+ Interruption,
6
+ ConversationMetadata,
7
+ Ping,
8
+ Role as MessageRole,
9
+ Mode as ConversationMode,
10
+ Status,
11
+ Callbacks,
12
+ } from "@elevenlabs/types";
13
+ export type { Callbacks } from "@elevenlabs/types";
14
+
1
15
  /**
2
16
  * Role in the conversation
3
17
  */
4
- export type Role = "user" | "ai";
18
+ export type Role = MessageRole;
5
19
 
6
20
  /**
7
21
  * Current mode of the conversation
8
22
  */
9
- export type Mode = "speaking" | "listening";
23
+ export type Mode = ConversationMode;
10
24
 
11
- export type ConversationStatus = "disconnected" | "connecting" | "connected";
25
+ export type ConversationStatus = Status;
12
26
 
13
27
  /**
14
28
  * Language support
15
29
  */
16
- export type Language =
17
- | "en"
18
- | "ja"
19
- | "zh"
20
- | "de"
21
- | "hi"
22
- | "fr"
23
- | "ko"
24
- | "pt"
25
- | "pt-br"
26
- | "it"
27
- | "es"
28
- | "id"
29
- | "nl"
30
- | "tr"
31
- | "pl"
32
- | "sv"
33
- | "bg"
34
- | "ro"
35
- | "ar"
36
- | "cs"
37
- | "el"
38
- | "fi"
39
- | "ms"
40
- | "da"
41
- | "ta"
42
- | "uk"
43
- | "ru"
44
- | "hu"
45
- | "hr"
46
- | "sk"
47
- | "no"
48
- | "vi";
30
+ export type Language = Types.ConversationConfigOverrideAgentLanguage;
49
31
 
50
32
  /**
51
33
  * Client tools configuration
@@ -73,22 +55,6 @@ export type ConversationOptions = {
73
55
  >;
74
56
  } & Partial<Callbacks>;
75
57
 
76
- /**
77
- * Callbacks configuration
78
- */
79
- export type Callbacks = {
80
- onConnect?: (props: { conversationId: string }) => void;
81
- // internal debug events, not to be used
82
- onDebug?: (props: unknown) => void;
83
- onDisconnect?: (details: string) => void;
84
- onError?: (message: string, context?: Record<string, unknown>) => void;
85
- onMessage?: (props: { message: ConversationEvent; source: Role }) => void;
86
- onModeChange?: (prop: { mode: Mode }) => void;
87
- onStatusChange?: (prop: { status: ConversationStatus }) => void;
88
- onCanSendFeedbackChange?: (prop: { canSendFeedback: boolean }) => void;
89
- onUnhandledClientToolCall?: (params: ClientToolCallEvent) => void;
90
- };
91
-
92
58
  export type ConversationConfig = {
93
59
  agentId?: string;
94
60
  conversationToken?: string;
@@ -117,190 +83,37 @@ export type ConversationConfig = {
117
83
  userId?: string;
118
84
  };
119
85
 
120
- export type UserTranscriptionEvent = {
121
- type: "user_transcript";
122
- user_transcription_event: { user_transcript: string };
123
- };
124
-
125
- export type AgentResponseEvent = {
126
- type: "agent_response";
127
- agent_response_event: { agent_response: string };
128
- };
129
-
130
- export type AgentResponseCorrectionEvent = {
131
- type: "agent_response_correction";
132
- agent_response_correction_event: {
133
- original_agent_response: string;
134
- corrected_agent_response: string;
135
- };
136
- };
137
-
138
- export type AgentAudioEvent = {
139
- type: "audio";
140
- audio_event: {
141
- audio_base_64: string;
142
- event_id: number;
143
- };
144
- };
145
-
146
- export type InterruptionEvent = {
147
- type: "interruption";
148
- interruption_event: {
149
- event_id: number;
150
- };
151
- };
152
-
153
- export type InternalTentativeAgentResponseEvent = {
154
- type: "internal_tentative_agent_response";
155
- tentative_agent_response_internal_event: {
156
- tentative_agent_response: string;
157
- };
158
- };
159
-
160
- export type ConfigEvent = {
161
- type: "conversation_initiation_metadata";
162
- conversation_initiation_metadata_event: {
163
- conversation_id: string;
164
- agent_output_audio_format: string;
165
- user_input_audio_format?: string;
166
- };
167
- };
168
-
169
- export type PingEvent = {
170
- type: "ping";
171
- ping_event: {
172
- event_id: number;
173
- ping_ms?: number;
174
- };
175
- };
176
-
177
- export type ClientToolCallEvent = {
178
- type: "client_tool_call";
179
- client_tool_call: {
180
- tool_name: string;
181
- tool_call_id: string;
182
- parameters: any;
183
- expects_response: boolean;
184
- };
185
- };
186
-
187
- export type PongEvent = {
188
- type: "pong";
189
- event_id: number;
190
- };
191
-
192
- export type UserAudioEvent = {
193
- user_audio_chunk: string;
194
- };
195
-
196
- export type UserFeedbackEvent = {
197
- type: "feedback";
198
- score: "like" | "dislike";
199
- event_id: number;
200
- };
201
-
202
- export type ClientToolResultEvent = {
203
- type: "client_tool_result";
204
- tool_call_id: string;
205
- result: any;
206
- is_error: boolean;
207
- };
208
-
209
- export type ContextualUpdateEvent = {
210
- type: "contextual_update";
211
- text: string;
212
- };
213
-
214
- export type UserMessageEvent = {
215
- type: "user_message";
216
- text: string;
217
- };
218
-
219
- export type UserActivityEvent = {
220
- type: "user_activity";
221
- };
222
-
223
- export type MCPToolApprovalResultEvent = {
224
- type: "mcp_tool_approval_result";
225
- tool_call_id: string;
226
- is_approved: boolean;
227
- };
228
-
229
- export type VadScoreEvent = {
230
- type: "vad_score";
231
- vad_score_event: {
232
- vad_score: number;
233
- };
234
- };
235
-
236
- export type InitiationClientDataEvent = {
237
- type: "conversation_initiation_client_data";
238
- conversation_config_override?: {
239
- agent?: {
240
- prompt?: {
241
- prompt?: string;
242
- };
243
- first_message?: string;
244
- language?: Language;
245
- };
246
- tts?: {
247
- voice_id?: string;
248
- };
249
- conversation?: {
250
- text_only?: boolean;
251
- };
252
- source_info?: {
253
- source?: string | null;
254
- version?: string | null;
255
- };
256
- };
257
- custom_llm_extra_body?: unknown;
258
- dynamic_variables?: Record<string, string | number | boolean>;
259
- user_id?: string;
260
- };
261
-
262
- interface BaseMCPToolCallClientEventData {
263
- service_id: string;
264
- tool_call_id: string;
265
- tool_name: string;
266
- tool_description?: string;
267
- parameters: Record<string, any>;
268
- timestamp: string; // ISO string format
269
- }
270
-
271
- interface MCPToolCallClientEventLoadingData
272
- extends BaseMCPToolCallClientEventData {
273
- state: "loading";
274
- }
275
-
276
- interface MCPToolCallClientEventAwaitingApprovalData
277
- extends BaseMCPToolCallClientEventData {
278
- state: "awaiting_approval";
279
- approval_timeout_secs: number;
280
- }
281
-
282
- interface MCPToolCallClientEventSuccessData
283
- extends BaseMCPToolCallClientEventData {
284
- state: "success";
285
- result: any[];
286
- }
287
-
288
- interface MCPToolCallClientEventFailureData
289
- extends BaseMCPToolCallClientEventData {
290
- state: "failure";
291
- error_message: string;
292
- }
293
-
294
- type MCPToolCallClientEventData =
295
- | MCPToolCallClientEventLoadingData
296
- | MCPToolCallClientEventAwaitingApprovalData
297
- | MCPToolCallClientEventSuccessData
298
- | MCPToolCallClientEventFailureData;
299
-
300
- export type MCPToolCallClientEvent = {
301
- type: "mcp_tool_call";
302
- mcp_tool_call: MCPToolCallClientEventData;
303
- };
86
+ // Incoming event types
87
+ export type UserTranscriptionEvent = Incoming.UserTranscriptionClientEvent;
88
+ export type AgentResponseEvent = Incoming.AgentResponseClientEvent;
89
+ export type AgentResponseCorrectionEvent =
90
+ Incoming.AgentResponseCorrectionClientEvent;
91
+ export type AgentAudioEvent = Incoming.AudioClientEvent;
92
+ export type InterruptionEvent = Interruption;
93
+ export type InternalTentativeAgentResponseEvent =
94
+ Incoming.TentativeAgentResponseInternalClientEvent;
95
+ export type ConfigEvent = ConversationMetadata;
96
+ export type PingEvent = Ping;
97
+ export type ClientToolCallEvent = Incoming.ClientToolCallClientEvent;
98
+ export type VadScoreEvent = Incoming.VadScoreClientEvent;
99
+ export type MCPToolCallClientEvent = Incoming.McpToolCallClientEvent;
100
+ export type AgentChatResponsePartEvent =
101
+ Incoming.AgentChatResponsePartClientEvent;
102
+
103
+ // Outgoing event types
104
+ export type PongEvent = Outgoing.PongClientToOrchestratorEvent;
105
+ export type UserAudioEvent = Outgoing.UserAudio;
106
+ export type UserFeedbackEvent = Outgoing.UserFeedbackClientToOrchestratorEvent;
107
+ export type ClientToolResultEvent =
108
+ Outgoing.ClientToolResultClientToOrchestratorEvent;
109
+ export type ContextualUpdateEvent =
110
+ Outgoing.ContextualUpdateClientToOrchestratorEvent;
111
+ export type UserMessageEvent = Outgoing.UserMessageClientToOrchestratorEvent;
112
+ export type UserActivityEvent = Outgoing.UserActivityClientToOrchestratorEvent;
113
+ export type MCPToolApprovalResultEvent =
114
+ Outgoing.McpToolApprovalResultClientToOrchestratorEvent;
115
+ export type InitiationClientDataEvent =
116
+ Outgoing.ConversationInitiationClientToOrchestratorEvent;
304
117
 
305
118
  export type ConversationEvent =
306
119
  | UserTranscriptionEvent
@@ -313,4 +126,5 @@ export type ConversationEvent =
313
126
  | PingEvent
314
127
  | ClientToolCallEvent
315
128
  | VadScoreEvent
316
- | MCPToolCallClientEvent;
129
+ | MCPToolCallClientEvent
130
+ | AgentChatResponsePartEvent;
@@ -21,13 +21,14 @@ export function constructOverrides(
21
21
  conversation: {
22
22
  text_only: config.overrides.conversation?.textOnly,
23
23
  },
24
- source_info: {
25
- source: "react_native_sdk",
26
- version: config.overrides?.client?.version || PACKAGE_VERSION,
27
- },
28
24
  };
29
25
  }
30
26
 
27
+ overridesEvent.source_info = {
28
+ source: "react_native_sdk",
29
+ version: config.overrides?.client?.version || PACKAGE_VERSION,
30
+ };
31
+
31
32
  if (config.customLlmExtraBody) {
32
33
  overridesEvent.custom_llm_extra_body = config.customLlmExtraBody;
33
34
  }
package/src/version.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  // This file is auto-generated during build
2
- export const PACKAGE_VERSION = "0.3.1";
2
+ export const PACKAGE_VERSION = "0.4.0";