phonic 0.24.0 → 0.24.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/README.md CHANGED
@@ -423,6 +423,27 @@ phonicWebSocket.onError((event) => {
423
423
 
424
424
  ### Messages that Phonic sends back to you
425
425
 
426
+ #### `conversation_created`
427
+
428
+ ```ts
429
+ {
430
+ type: "conversation_created";
431
+ conversation_id: string;
432
+ }
433
+ ```
434
+
435
+ Sent when the conversation has been successfully created.
436
+
437
+ #### `ready_to_start_conversation`
438
+
439
+ ```ts
440
+ {
441
+ type: "ready_to_start_conversation";
442
+ }
443
+ ```
444
+
445
+ Sent when Phonic is ready to begin processing audio. You should start sending audio chunks after receiving this message.
446
+
426
447
  #### `input_text`
427
448
 
428
449
  ```ts
@@ -456,6 +477,26 @@ These are the assistant response audio chunks.
456
477
 
457
478
  Sent after the last "audio_chunk" is sent.
458
479
 
480
+ #### `user_started_speaking`
481
+
482
+ ```ts
483
+ {
484
+ type: "user_started_speaking";
485
+ }
486
+ ```
487
+
488
+ Sent when the user begins speaking.
489
+
490
+ #### `user_finished_speaking`
491
+
492
+ ```ts
493
+ {
494
+ type: "user_finished_speaking";
495
+ }
496
+ ```
497
+
498
+ Sent when the user stops speaking.
499
+
459
500
  #### `interrupted_response`
460
501
 
461
502
  ```ts
@@ -467,7 +508,17 @@ Sent after the last "audio_chunk" is sent.
467
508
 
468
509
  Sent when the user interrupts the assistant, after the user has finished speaking.
469
510
 
470
- ### `assistant_ended_conversation`
511
+ #### `assistant_chose_not_to_respond`
512
+
513
+ ```ts
514
+ {
515
+ type: "assistant_chose_not_to_respond";
516
+ }
517
+ ```
518
+
519
+ Sent when the assistant decides not to respond to the user's input.
520
+
521
+ #### `assistant_ended_conversation`
471
522
 
472
523
  ```ts
473
524
  {
@@ -477,6 +528,46 @@ Sent when the user interrupts the assistant, after the user has finished speakin
477
528
 
478
529
  Sent when the assistant decides to end the conversation.
479
530
 
531
+ #### `tool_call`
532
+
533
+ ```ts
534
+ {
535
+ type: "tool_call";
536
+ id: string;
537
+ tool: {
538
+ id: string;
539
+ name: string;
540
+ };
541
+ endpoint_url: string | null;
542
+ endpoint_timeout_ms: number | null;
543
+ endpoint_called_at: string | null;
544
+ request_body: object | null;
545
+ response_body: object | null;
546
+ response_status_code: number | null;
547
+ timed_out: boolean | null;
548
+ error_message: string | null;
549
+ }
550
+ ```
551
+ Sent when a tool is called during the conversation. Built-in tools will have null values for endpoint-related fields.
552
+
553
+ When a custom tool is called, the `request_body` field always includes a `call_info` field.
554
+ If the conversation is not a phone call, `call_info` will be `null`. If it is a phone call, `call_info` will be an object with `from_phone_number` and `to_phone_number` fields, both formatted as E.164 phone numbers (e.g., "+1234567890").
555
+
556
+ #### `error`
557
+
558
+ ```ts
559
+ {
560
+ type: "error";
561
+ error: {
562
+ message: string;
563
+ code?: string;
564
+ };
565
+ param_errors?: Record<string, string>;
566
+ }
567
+ ```
568
+
569
+ Sent when an error occurs during the conversation.
570
+
480
571
  ## License
481
572
 
482
573
  MIT
package/dist/index.d.mts CHANGED
@@ -57,6 +57,9 @@ interface PhonicSTSConfigWithProject extends PhonicSTSConfigBase {
57
57
  }
58
58
  type PhonicSTSConfig = PhonicSTSConfigWithAgent | PhonicSTSConfigWithProject;
59
59
  type PhonicSTSWebSocketResponseMessage = {
60
+ type: "conversation_created";
61
+ conversation_id: string;
62
+ } | {
60
63
  type: "ready_to_start_conversation";
61
64
  } | {
62
65
  type: "input_text";
@@ -65,14 +68,40 @@ type PhonicSTSWebSocketResponseMessage = {
65
68
  type: "audio_chunk";
66
69
  text: string;
67
70
  audio: string;
71
+ } | {
72
+ type: "audio_finished";
68
73
  } | {
69
74
  type: "is_user_speaking";
70
75
  isUserSpeaking: boolean;
76
+ } | {
77
+ type: "user_started_speaking";
78
+ } | {
79
+ type: "user_finished_speaking";
71
80
  } | {
72
81
  type: "interrupted_response";
73
82
  interruptedResponse: string;
83
+ } | {
84
+ type: "assistant_chose_not_to_respond";
74
85
  } | {
75
86
  type: "assistant_ended_conversation";
87
+ } | {
88
+ type: "dtmf";
89
+ digits: string;
90
+ } | {
91
+ type: "tool_call";
92
+ id: string;
93
+ tool: {
94
+ id: string;
95
+ name: string;
96
+ };
97
+ endpoint_url: string | null;
98
+ endpoint_timeout_ms: number | null;
99
+ endpoint_called_at: string | null;
100
+ request_body: object | null;
101
+ response_body: object | null;
102
+ response_status_code: number | null;
103
+ timed_out: boolean | null;
104
+ error_message: string | null;
76
105
  } | {
77
106
  type: "error";
78
107
  error: {
package/dist/index.d.ts CHANGED
@@ -57,6 +57,9 @@ interface PhonicSTSConfigWithProject extends PhonicSTSConfigBase {
57
57
  }
58
58
  type PhonicSTSConfig = PhonicSTSConfigWithAgent | PhonicSTSConfigWithProject;
59
59
  type PhonicSTSWebSocketResponseMessage = {
60
+ type: "conversation_created";
61
+ conversation_id: string;
62
+ } | {
60
63
  type: "ready_to_start_conversation";
61
64
  } | {
62
65
  type: "input_text";
@@ -65,14 +68,40 @@ type PhonicSTSWebSocketResponseMessage = {
65
68
  type: "audio_chunk";
66
69
  text: string;
67
70
  audio: string;
71
+ } | {
72
+ type: "audio_finished";
68
73
  } | {
69
74
  type: "is_user_speaking";
70
75
  isUserSpeaking: boolean;
76
+ } | {
77
+ type: "user_started_speaking";
78
+ } | {
79
+ type: "user_finished_speaking";
71
80
  } | {
72
81
  type: "interrupted_response";
73
82
  interruptedResponse: string;
83
+ } | {
84
+ type: "assistant_chose_not_to_respond";
74
85
  } | {
75
86
  type: "assistant_ended_conversation";
87
+ } | {
88
+ type: "dtmf";
89
+ digits: string;
90
+ } | {
91
+ type: "tool_call";
92
+ id: string;
93
+ tool: {
94
+ id: string;
95
+ name: string;
96
+ };
97
+ endpoint_url: string | null;
98
+ endpoint_timeout_ms: number | null;
99
+ endpoint_called_at: string | null;
100
+ request_body: object | null;
101
+ response_body: object | null;
102
+ response_status_code: number | null;
103
+ timed_out: boolean | null;
104
+ error_message: string | null;
76
105
  } | {
77
106
  type: "error";
78
107
  error: {
package/dist/index.js CHANGED
@@ -35,7 +35,7 @@ __export(index_exports, {
35
35
  module.exports = __toCommonJS(index_exports);
36
36
 
37
37
  // package.json
38
- var version = "0.24.0";
38
+ var version = "0.24.1";
39
39
 
40
40
  // src/agents/index.ts
41
41
  var Agents = class {
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  // package.json
2
- var version = "0.24.0";
2
+ var version = "0.24.1";
3
3
 
4
4
  // src/agents/index.ts
5
5
  var Agents = class {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "phonic",
3
- "version": "0.24.0",
3
+ "version": "0.24.1",
4
4
  "description": "Phonic Node.js SDK",
5
5
  "scripts": {
6
6
  "build": "tsup",