@elevenlabs/react-native 0.3.1 → 0.3.2
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/.turbo/turbo-build.log +22 -0
- package/.turbo/turbo-generate-version.log +4 -0
- package/LICENSE +1 -1
- package/README.md +26 -15
- package/dist/components/LiveKitRoomWrapper.d.ts +1 -1
- package/dist/components/MessageHandler.d.ts +4 -4
- package/dist/hooks/useConversationCallbacks.d.ts +1 -1
- package/dist/lib.js +1 -1
- package/dist/lib.js.map +1 -1
- package/dist/lib.modern.js +1 -1
- package/dist/lib.modern.js.map +1 -1
- package/dist/lib.module.js +1 -1
- package/dist/lib.module.js.map +1 -1
- package/dist/lib.umd.js +1 -1
- package/dist/lib.umd.js.map +1 -1
- package/dist/types.d.ts +27 -185
- package/dist/version.d.ts +1 -1
- package/package.json +9 -3
- package/src/ElevenLabsProvider.test.tsx +7 -0
- package/src/components/LiveKitRoomWrapper.tsx +7 -1
- package/src/components/MessageHandler.tsx +34 -15
- package/src/hooks/useConversationSession.ts +1 -1
- package/src/hooks/useLiveKitRoom.ts +1 -1
- package/src/types.ts +47 -236
- package/src/utils/overrides.ts +5 -4
- package/src/version.ts +1 -1
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 =
|
|
18
|
+
export type Role = MessageRole;
|
|
5
19
|
|
|
6
20
|
/**
|
|
7
21
|
* Current mode of the conversation
|
|
8
22
|
*/
|
|
9
|
-
export type Mode =
|
|
23
|
+
export type Mode = ConversationMode;
|
|
10
24
|
|
|
11
|
-
export type ConversationStatus =
|
|
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,35 @@ export type ConversationConfig = {
|
|
|
117
83
|
userId?: string;
|
|
118
84
|
};
|
|
119
85
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
export type
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
export type
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
export type
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
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
|
+
|
|
101
|
+
// Outgoing event types
|
|
102
|
+
export type PongEvent = Outgoing.PongClientToOrchestratorEvent;
|
|
103
|
+
export type UserAudioEvent = Outgoing.UserAudio;
|
|
104
|
+
export type UserFeedbackEvent = Outgoing.UserFeedbackClientToOrchestratorEvent;
|
|
105
|
+
export type ClientToolResultEvent =
|
|
106
|
+
Outgoing.ClientToolResultClientToOrchestratorEvent;
|
|
107
|
+
export type ContextualUpdateEvent =
|
|
108
|
+
Outgoing.ContextualUpdateClientToOrchestratorEvent;
|
|
109
|
+
export type UserMessageEvent = Outgoing.UserMessageClientToOrchestratorEvent;
|
|
110
|
+
export type UserActivityEvent = Outgoing.UserActivityClientToOrchestratorEvent;
|
|
111
|
+
export type MCPToolApprovalResultEvent =
|
|
112
|
+
Outgoing.McpToolApprovalResultClientToOrchestratorEvent;
|
|
113
|
+
export type InitiationClientDataEvent =
|
|
114
|
+
Outgoing.ConversationInitiationClientToOrchestratorEvent;
|
|
304
115
|
|
|
305
116
|
export type ConversationEvent =
|
|
306
117
|
| UserTranscriptionEvent
|
package/src/utils/overrides.ts
CHANGED
|
@@ -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.
|
|
2
|
+
export const PACKAGE_VERSION = "0.3.2";
|