@humeai/voice-embed 0.1.9 → 0.1.11-beta.1

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,39 +1,6 @@
1
- import { SocketConfig, UserTranscriptMessage, AssistantTranscriptMessage } from '@humeai/voice';
2
- export { AssistantTranscriptMessage, ChatMetadataMessage, EmotionScores, JSONMessage, LanguageModelOption, SocketConfig, ToolCall, ToolError, ToolResponse, UserTranscriptMessage } from '@humeai/voice';
1
+ import { Hume } from 'hume';
3
2
  import { z } from 'zod';
4
-
5
- type EmbeddedVoiceConfig = {
6
- rendererUrl: string;
7
- iframeTitle?: string;
8
- } & SocketConfig;
9
- type TranscriptMessageHandler = (message: UserTranscriptMessage | AssistantTranscriptMessage) => void;
10
- type CloseHandler = () => void;
11
- declare class EmbeddedVoice {
12
- private iframe;
13
- private isMounted;
14
- private managedContainer;
15
- private config;
16
- private onMessage;
17
- private onClose;
18
- private openOnMount;
19
- private constructor();
20
- static create({ rendererUrl, onMessage, onClose, openOnMount, ...config }: Partial<EmbeddedVoiceConfig> & {
21
- onMessage?: TranscriptMessageHandler;
22
- onClose?: CloseHandler;
23
- openOnMount?: boolean;
24
- } & NonNullable<Pick<EmbeddedVoiceConfig, 'auth'>>): EmbeddedVoice;
25
- mount(container?: HTMLElement): () => void;
26
- private createContainer;
27
- private createIframe;
28
- private messageHandler;
29
- openEmbed(): void;
30
- private sendConfigObject;
31
- private sendWindowSize;
32
- private sendMessageToFrame;
33
- private showIframe;
34
- private hideIframe;
35
- private resizeIframe;
36
- }
3
+ export { AssistantMessage, AssistantMessage as AssistantTranscriptMessage, ChatMetadata, ChatMetadata as ChatMetadataMessage, EmotionScores, SubscribeEvent as JSONMessage, SubscribeEvent, ToolCallMessage as ToolCall, ToolCallMessage, ToolErrorMessage as ToolError, ToolErrorMessage, ToolResponseMessage as ToolResponse, ToolResponseMessage, UserMessage, UserMessage as UserTranscriptMessage } from 'hume/api/resources/empathicVoice';
37
4
 
38
5
  /**
39
6
 
@@ -79,97 +46,77 @@ declare const WindowDimensionsSchema: z.ZodObject<{
79
46
  height: number;
80
47
  }>;
81
48
  type WindowDimensions = z.infer<typeof WindowDimensionsSchema>;
82
- declare const ClientToFrameActionSchema: z.ZodUnion<[z.ZodObject<{
83
- type: z.ZodLiteral<"update_config">;
84
- payload: z.ZodObject<{
85
- hostname: z.ZodString;
86
- reconnectAttempts: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
87
- debug: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
88
- auth: z.ZodUnion<[z.ZodObject<{
89
- type: z.ZodLiteral<"apiKey">;
90
- value: z.ZodString;
91
- }, "strip", z.ZodTypeAny, {
92
- type: "apiKey";
93
- value: string;
94
- }, {
95
- type: "apiKey";
96
- value: string;
97
- }>, z.ZodObject<{
98
- type: z.ZodLiteral<"accessToken">;
99
- value: z.ZodString;
100
- }, "strip", z.ZodTypeAny, {
101
- type: "accessToken";
102
- value: string;
103
- }, {
104
- type: "accessToken";
105
- value: string;
106
- }>]>;
107
- configId: z.ZodOptional<z.ZodString>;
108
- configVersion: z.ZodOptional<z.ZodNumber>;
109
- resumedChatGroupId: z.ZodOptional<z.ZodString>;
49
+ declare const SocketConnect: z.ZodType<Hume.empathicVoice.chat.Chat.ConnectArgs, z.ZodTypeDef, Hume.empathicVoice.chat.Chat.ConnectArgs>;
50
+ type SocketConnectSchema = z.infer<typeof SocketConnect>;
51
+ declare const BaseSocketConfig: z.ZodObject<{
52
+ auth: z.ZodUnion<[z.ZodObject<{
53
+ type: z.ZodLiteral<"apiKey">;
54
+ value: z.ZodString;
110
55
  }, "strip", z.ZodTypeAny, {
111
- hostname: string;
112
- reconnectAttempts: number;
113
- debug: boolean;
114
- auth: {
115
- type: "apiKey";
116
- value: string;
117
- } | {
118
- type: "accessToken";
119
- value: string;
120
- };
121
- configId?: string | undefined;
122
- configVersion?: number | undefined;
123
- resumedChatGroupId?: string | undefined;
56
+ value: string;
57
+ type: "apiKey";
124
58
  }, {
125
- hostname: string;
126
- auth: {
127
- type: "apiKey";
128
- value: string;
129
- } | {
130
- type: "accessToken";
131
- value: string;
132
- };
133
- reconnectAttempts?: number | undefined;
134
- debug?: boolean | undefined;
135
- configId?: string | undefined;
136
- configVersion?: number | undefined;
137
- resumedChatGroupId?: string | undefined;
138
- }>;
59
+ value: string;
60
+ type: "apiKey";
61
+ }>, z.ZodObject<{
62
+ type: z.ZodLiteral<"accessToken">;
63
+ value: z.ZodString;
64
+ }, "strip", z.ZodTypeAny, {
65
+ value: string;
66
+ type: "accessToken";
67
+ }, {
68
+ value: string;
69
+ type: "accessToken";
70
+ }>]>;
71
+ hostname: z.ZodOptional<z.ZodString>;
72
+ }, "strip", z.ZodTypeAny, {
73
+ auth: {
74
+ value: string;
75
+ type: "apiKey";
76
+ } | {
77
+ value: string;
78
+ type: "accessToken";
79
+ };
80
+ hostname?: string | undefined;
81
+ }, {
82
+ auth: {
83
+ value: string;
84
+ type: "apiKey";
85
+ } | {
86
+ value: string;
87
+ type: "accessToken";
88
+ };
89
+ hostname?: string | undefined;
90
+ }>;
91
+ type SocketAuthSchema = z.infer<typeof BaseSocketConfig>;
92
+ type SocketConfig = SocketAuthSchema & SocketConnectSchema;
93
+ declare const ClientToFrameActionSchema: z.ZodUnion<[z.ZodObject<{
94
+ type: z.ZodLiteral<"update_config">;
95
+ payload: z.ZodType<SocketConfig, z.ZodTypeDef, SocketConfig>;
139
96
  }, "strip", z.ZodTypeAny, {
140
97
  type: "update_config";
141
98
  payload: {
142
- hostname: string;
143
- reconnectAttempts: number;
144
- debug: boolean;
145
99
  auth: {
146
- type: "apiKey";
147
100
  value: string;
101
+ type: "apiKey";
148
102
  } | {
149
- type: "accessToken";
150
103
  value: string;
104
+ type: "accessToken";
151
105
  };
152
- configId?: string | undefined;
153
- configVersion?: number | undefined;
154
- resumedChatGroupId?: string | undefined;
155
- };
106
+ hostname?: string | undefined;
107
+ } & Hume.empathicVoice.chat.Chat.ConnectArgs;
156
108
  }, {
157
109
  type: "update_config";
158
110
  payload: {
159
- hostname: string;
160
111
  auth: {
161
- type: "apiKey";
162
112
  value: string;
113
+ type: "apiKey";
163
114
  } | {
164
- type: "accessToken";
165
115
  value: string;
116
+ type: "accessToken";
166
117
  };
167
- reconnectAttempts?: number | undefined;
168
- debug?: boolean | undefined;
169
- configId?: string | undefined;
170
- configVersion?: number | undefined;
171
- resumedChatGroupId?: string | undefined;
172
- };
118
+ hostname?: string | undefined;
119
+ } & Hume.empathicVoice.chat.Chat.ConnectArgs;
173
120
  }>, z.ZodObject<{
174
121
  type: z.ZodLiteral<"cancel">;
175
122
  }, "strip", z.ZodTypeAny, {
@@ -253,316 +200,13 @@ declare const FrameToClientActionSchema: z.ZodUnion<[z.ZodObject<{
253
200
  type: "widget_iframe_is_ready";
254
201
  }>, z.ZodObject<{
255
202
  type: z.ZodLiteral<"transcript_message">;
256
- payload: z.ZodUnion<[z.ZodEffects<z.ZodObject<{
257
- type: z.ZodLiteral<"user_message">;
258
- message: z.ZodObject<{
259
- role: z.ZodLiteral<"user">;
260
- content: z.ZodString;
261
- }, "strip", z.ZodTypeAny, {
262
- role: "user";
263
- content: string;
264
- }, {
265
- role: "user";
266
- content: string;
267
- }>;
268
- models: z.ZodObject<{
269
- prosody: z.ZodOptional<z.ZodNullable<z.ZodObject<{
270
- scores: z.ZodRecord<z.ZodString, z.ZodNumber>;
271
- }, "strip", z.ZodTypeAny, {
272
- scores: Record<string, number>;
273
- }, {
274
- scores: Record<string, number>;
275
- }>>>;
276
- time: z.ZodOptional<z.ZodNullable<z.ZodObject<{
277
- begin: z.ZodNumber;
278
- end: z.ZodNumber;
279
- }, "strip", z.ZodTypeAny, {
280
- begin: number;
281
- end: number;
282
- }, {
283
- begin: number;
284
- end: number;
285
- }>>>;
286
- }, "strip", z.ZodTypeAny, {
287
- prosody?: {
288
- scores: Record<string, number>;
289
- } | null | undefined;
290
- time?: {
291
- begin: number;
292
- end: number;
293
- } | null | undefined;
294
- }, {
295
- prosody?: {
296
- scores: Record<string, number>;
297
- } | null | undefined;
298
- time?: {
299
- begin: number;
300
- end: number;
301
- } | null | undefined;
302
- }>;
303
- from_text: z.ZodCatch<z.ZodOptional<z.ZodNullable<z.ZodBoolean>>>;
304
- }, "strip", z.ZodTypeAny, {
305
- type: "user_message";
306
- message: {
307
- role: "user";
308
- content: string;
309
- };
310
- models: {
311
- prosody?: {
312
- scores: Record<string, number>;
313
- } | null | undefined;
314
- time?: {
315
- begin: number;
316
- end: number;
317
- } | null | undefined;
318
- };
319
- from_text?: boolean | null | undefined;
320
- }, {
321
- type: "user_message";
322
- message: {
323
- role: "user";
324
- content: string;
325
- };
326
- models: {
327
- prosody?: {
328
- scores: Record<string, number>;
329
- } | null | undefined;
330
- time?: {
331
- begin: number;
332
- end: number;
333
- } | null | undefined;
334
- };
335
- from_text?: unknown;
336
- }>, {
337
- type: "user_message";
338
- message: {
339
- role: "user";
340
- content: string;
341
- };
342
- models: {
343
- prosody?: {
344
- scores: Record<string, number>;
345
- } | null | undefined;
346
- time?: {
347
- begin: number;
348
- end: number;
349
- } | null | undefined;
350
- };
351
- from_text?: boolean | null | undefined;
352
- } & {
353
- receivedAt: Date;
354
- }, {
355
- type: "user_message";
356
- message: {
357
- role: "user";
358
- content: string;
359
- };
360
- models: {
361
- prosody?: {
362
- scores: Record<string, number>;
363
- } | null | undefined;
364
- time?: {
365
- begin: number;
366
- end: number;
367
- } | null | undefined;
368
- };
369
- from_text?: unknown;
370
- }>, z.ZodEffects<z.ZodObject<{
371
- type: z.ZodLiteral<"assistant_message">;
372
- id: z.ZodString;
373
- message: z.ZodObject<{
374
- role: z.ZodLiteral<"assistant">;
375
- content: z.ZodString;
376
- }, "strip", z.ZodTypeAny, {
377
- role: "assistant";
378
- content: string;
379
- }, {
380
- role: "assistant";
381
- content: string;
382
- }>;
383
- models: z.ZodObject<{
384
- prosody: z.ZodOptional<z.ZodNullable<z.ZodObject<{
385
- scores: z.ZodRecord<z.ZodString, z.ZodNumber>;
386
- }, "strip", z.ZodTypeAny, {
387
- scores: Record<string, number>;
388
- }, {
389
- scores: Record<string, number>;
390
- }>>>;
391
- time: z.ZodOptional<z.ZodNullable<z.ZodObject<{
392
- begin: z.ZodNumber;
393
- end: z.ZodNumber;
394
- }, "strip", z.ZodTypeAny, {
395
- begin: number;
396
- end: number;
397
- }, {
398
- begin: number;
399
- end: number;
400
- }>>>;
401
- }, "strip", z.ZodTypeAny, {
402
- prosody?: {
403
- scores: Record<string, number>;
404
- } | null | undefined;
405
- time?: {
406
- begin: number;
407
- end: number;
408
- } | null | undefined;
409
- }, {
410
- prosody?: {
411
- scores: Record<string, number>;
412
- } | null | undefined;
413
- time?: {
414
- begin: number;
415
- end: number;
416
- } | null | undefined;
417
- }>;
418
- from_text: z.ZodCatch<z.ZodBoolean>;
419
- }, "strip", z.ZodTypeAny, {
420
- type: "assistant_message";
421
- message: {
422
- role: "assistant";
423
- content: string;
424
- };
425
- id: string;
426
- models: {
427
- prosody?: {
428
- scores: Record<string, number>;
429
- } | null | undefined;
430
- time?: {
431
- begin: number;
432
- end: number;
433
- } | null | undefined;
434
- };
435
- from_text: boolean;
436
- }, {
437
- type: "assistant_message";
438
- message: {
439
- role: "assistant";
440
- content: string;
441
- };
442
- id: string;
443
- models: {
444
- prosody?: {
445
- scores: Record<string, number>;
446
- } | null | undefined;
447
- time?: {
448
- begin: number;
449
- end: number;
450
- } | null | undefined;
451
- };
452
- from_text?: unknown;
453
- }>, {
454
- type: "assistant_message";
455
- message: {
456
- role: "assistant";
457
- content: string;
458
- };
459
- id: string;
460
- models: {
461
- prosody?: {
462
- scores: Record<string, number>;
463
- } | null | undefined;
464
- time?: {
465
- begin: number;
466
- end: number;
467
- } | null | undefined;
468
- };
469
- from_text: boolean;
470
- } & {
471
- receivedAt: Date;
472
- }, {
473
- type: "assistant_message";
474
- message: {
475
- role: "assistant";
476
- content: string;
477
- };
478
- id: string;
479
- models: {
480
- prosody?: {
481
- scores: Record<string, number>;
482
- } | null | undefined;
483
- time?: {
484
- begin: number;
485
- end: number;
486
- } | null | undefined;
487
- };
488
- from_text?: unknown;
489
- }>]>;
203
+ payload: z.ZodType<Hume.empathicVoice.UserMessage | Hume.empathicVoice.AssistantMessage, z.ZodTypeDef, Hume.empathicVoice.UserMessage | Hume.empathicVoice.AssistantMessage>;
490
204
  }, "strip", z.ZodTypeAny, {
491
205
  type: "transcript_message";
492
- payload: ({
493
- type: "user_message";
494
- message: {
495
- role: "user";
496
- content: string;
497
- };
498
- models: {
499
- prosody?: {
500
- scores: Record<string, number>;
501
- } | null | undefined;
502
- time?: {
503
- begin: number;
504
- end: number;
505
- } | null | undefined;
506
- };
507
- from_text?: boolean | null | undefined;
508
- } & {
509
- receivedAt: Date;
510
- }) | ({
511
- type: "assistant_message";
512
- message: {
513
- role: "assistant";
514
- content: string;
515
- };
516
- id: string;
517
- models: {
518
- prosody?: {
519
- scores: Record<string, number>;
520
- } | null | undefined;
521
- time?: {
522
- begin: number;
523
- end: number;
524
- } | null | undefined;
525
- };
526
- from_text: boolean;
527
- } & {
528
- receivedAt: Date;
529
- });
206
+ payload: Hume.empathicVoice.UserMessage | Hume.empathicVoice.AssistantMessage;
530
207
  }, {
531
208
  type: "transcript_message";
532
- payload: {
533
- type: "user_message";
534
- message: {
535
- role: "user";
536
- content: string;
537
- };
538
- models: {
539
- prosody?: {
540
- scores: Record<string, number>;
541
- } | null | undefined;
542
- time?: {
543
- begin: number;
544
- end: number;
545
- } | null | undefined;
546
- };
547
- from_text?: unknown;
548
- } | {
549
- type: "assistant_message";
550
- message: {
551
- role: "assistant";
552
- content: string;
553
- };
554
- id: string;
555
- models: {
556
- prosody?: {
557
- scores: Record<string, number>;
558
- } | null | undefined;
559
- time?: {
560
- begin: number;
561
- end: number;
562
- } | null | undefined;
563
- };
564
- from_text?: unknown;
565
- };
209
+ payload: Hume.empathicVoice.UserMessage | Hume.empathicVoice.AssistantMessage;
566
210
  }>, z.ZodObject<{
567
211
  type: z.ZodLiteral<"resize_frame">;
568
212
  payload: z.ZodObject<{
@@ -601,46 +245,9 @@ declare const MINIMIZE_WIDGET_ACTION: {
601
245
  declare const WIDGET_IFRAME_IS_READY_ACTION: {
602
246
  type: "widget_iframe_is_ready";
603
247
  };
604
- declare const TRANSCRIPT_MESSAGE_ACTION: (message: UserTranscriptMessage | AssistantTranscriptMessage) => {
248
+ declare const TRANSCRIPT_MESSAGE_ACTION: (message: Hume.empathicVoice.UserMessage | Hume.empathicVoice.AssistantMessage) => {
605
249
  type: "transcript_message";
606
- payload: ({
607
- type: "user_message";
608
- message: {
609
- role: "user";
610
- content: string;
611
- };
612
- models: {
613
- prosody?: {
614
- scores: Record<string, number>;
615
- } | null | undefined;
616
- time?: {
617
- begin: number;
618
- end: number;
619
- } | null | undefined;
620
- };
621
- from_text?: boolean | null | undefined;
622
- } & {
623
- receivedAt: Date;
624
- }) | ({
625
- type: "assistant_message";
626
- message: {
627
- role: "assistant";
628
- content: string;
629
- };
630
- id: string;
631
- models: {
632
- prosody?: {
633
- scores: Record<string, number>;
634
- } | null | undefined;
635
- time?: {
636
- begin: number;
637
- end: number;
638
- } | null | undefined;
639
- };
640
- from_text: boolean;
641
- } & {
642
- receivedAt: Date;
643
- });
250
+ payload: Hume.empathicVoice.UserMessage | Hume.empathicVoice.AssistantMessage;
644
251
  };
645
252
  declare const RESIZE_FRAME_ACTION: (dimensions: {
646
253
  width: number;
@@ -653,4 +260,49 @@ declare const RESIZE_FRAME_ACTION: (dimensions: {
653
260
  };
654
261
  };
655
262
 
656
- export { COLLAPSE_WIDGET_ACTION, type CloseHandler, EXPAND_WIDGET_ACTION, EmbeddedVoice, type EmbeddedVoiceConfig, type FrameToClientAction, MINIMIZE_WIDGET_ACTION, RESIZE_FRAME_ACTION, TRANSCRIPT_MESSAGE_ACTION, type TranscriptMessageHandler, WIDGET_IFRAME_IS_READY_ACTION, type WindowDimensions, parseClientToFrameAction };
263
+ type EmbeddedVoiceConfig = {
264
+ rendererUrl?: string;
265
+ iframeTitle?: string;
266
+ } & SocketConfig;
267
+ type TranscriptMessageHandler = (message: Hume.empathicVoice.UserMessage | Hume.empathicVoice.AssistantMessage) => void;
268
+ type CloseHandler = () => void;
269
+ declare class EmbeddedVoice {
270
+ private iframe;
271
+ private isMounted;
272
+ private managedContainer;
273
+ private config;
274
+ private onMessage;
275
+ private onClose;
276
+ private openOnMount;
277
+ private constructor();
278
+ static create({ rendererUrl, onMessage, onClose, openOnMount, ...config }: EmbeddedVoiceConfig & {
279
+ onMessage?: TranscriptMessageHandler;
280
+ onClose?: CloseHandler;
281
+ openOnMount?: boolean;
282
+ }): EmbeddedVoice;
283
+ mount(container?: HTMLElement): () => void;
284
+ private createContainer;
285
+ private createIframe;
286
+ private messageHandler;
287
+ openEmbed(): void;
288
+ private sendConfigObject;
289
+ private sendWindowSize;
290
+ private sendMessageToFrame;
291
+ private showIframe;
292
+ private hideIframe;
293
+ private resizeIframe;
294
+ }
295
+
296
+ declare enum LanguageModelOption {
297
+ CLAUDE_3_OPUS = "CLAUDE_3_OPUS",
298
+ CLAUDE_3_SONNET = "CLAUDE_3_SONNET",
299
+ CLAUDE_3_HAIKU = "CLAUDE_3_HAIKU",
300
+ CLAUDE_21 = "CLAUDE_21",
301
+ CLAUDE_INSTANT_12 = "CLAUDE_INSTANT_12",
302
+ GPT_4_TURBO_PREVIEW = "GPT_4_TURBO_PREVIEW",
303
+ GPT_35_TURBO_0125 = "GPT_35_TURBO_0125",
304
+ GPT_35_TURBO = "GPT_35_TURBO",
305
+ FIREWORKS_MIXTRAL_8X7B = "FIREWORKS_MIXTRAL_8X7B"
306
+ }
307
+
308
+ export { COLLAPSE_WIDGET_ACTION, type CloseHandler, EXPAND_WIDGET_ACTION, EmbeddedVoice, type EmbeddedVoiceConfig, type FrameToClientAction, LanguageModelOption, MINIMIZE_WIDGET_ACTION, RESIZE_FRAME_ACTION, type SocketConfig, TRANSCRIPT_MESSAGE_ACTION, type TranscriptMessageHandler, WIDGET_IFRAME_IS_READY_ACTION, type WindowDimensions, parseClientToFrameAction };