phonic 0.31.8 → 0.31.10

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.
Files changed (119) hide show
  1. package/README.md +1 -0
  2. package/dist/cjs/BaseClient.js +2 -2
  3. package/dist/cjs/Client.d.ts +9 -1
  4. package/dist/cjs/Client.js +1 -1
  5. package/dist/cjs/api/resources/agents/client/Client.d.ts +3 -0
  6. package/dist/cjs/api/resources/agents/client/Client.js +3 -0
  7. package/dist/cjs/api/resources/agents/client/requests/AgentsCreateRequest.d.ts +3 -0
  8. package/dist/cjs/api/resources/agents/client/requests/UpdateAgentRequest.d.ts +3 -0
  9. package/dist/cjs/api/resources/agents/client/requests/UpsertAgentRequest.d.ts +1 -0
  10. package/dist/cjs/api/resources/conversations/client/Client.d.ts +8 -1
  11. package/dist/cjs/api/resources/conversations/client/Client.js +37 -3
  12. package/dist/cjs/api/resources/conversations/client/Socket.d.ts +2 -1
  13. package/dist/cjs/api/resources/conversations/client/Socket.js +4 -0
  14. package/dist/cjs/api/resources/conversations/client/requests/ConversationsSipOutboundCallRequest.d.ts +2 -0
  15. package/dist/cjs/api/resources/conversations/client/requests/OutboundCallRequest.d.ts +5 -1
  16. package/dist/cjs/api/resources/conversations/types/ConversationsOutboundCallResponse.d.ts +2 -4
  17. package/dist/cjs/api/resources/conversations/types/ConversationsSipOutboundCallResponse.d.ts +2 -6
  18. package/dist/cjs/api/types/Agent.d.ts +2 -0
  19. package/dist/cjs/api/types/ConfigOptions.d.ts +94 -0
  20. package/dist/cjs/api/types/ConfigOptions.js +32 -0
  21. package/dist/cjs/api/types/ConfigPayload.d.ts +2 -88
  22. package/dist/cjs/api/types/ConfigPayload.js +0 -29
  23. package/dist/cjs/api/types/Conversation.d.ts +2 -0
  24. package/dist/cjs/api/types/CreateAgentRequest.d.ts +2 -0
  25. package/dist/cjs/api/types/OutboundCallConfig.d.ts +2 -0
  26. package/dist/cjs/api/types/OutboundCallInitiatedResponse.d.ts +6 -0
  27. package/dist/cjs/api/types/{InterruptedResponsePayload.js → OutboundCallInitiatedResponse.js} +1 -3
  28. package/dist/cjs/api/types/OutboundDryRunResponse.d.ts +6 -0
  29. package/dist/cjs/api/{resources/agents/client/requests/AgentsRemoveCustomPhoneNumberRequest.js → types/OutboundDryRunResponse.js} +1 -3
  30. package/dist/cjs/api/types/ResetPayload.d.ts +5 -0
  31. package/dist/cjs/api/types/{AudioFinishedPayload.js → ResetPayload.js} +1 -3
  32. package/dist/cjs/api/types/SipOutboundCallInitiatedResponse.d.ts +8 -0
  33. package/dist/cjs/api/{resources/agents/types/AgentsRemoveCustomPhoneNumberResponse.js → types/SipOutboundCallInitiatedResponse.js} +1 -3
  34. package/dist/cjs/api/types/SipOutboundDryRunResponse.d.ts +8 -0
  35. package/dist/cjs/api/types/SipOutboundDryRunResponse.js +3 -0
  36. package/dist/cjs/api/types/index.d.ts +6 -0
  37. package/dist/cjs/api/types/index.js +6 -0
  38. package/dist/cjs/custom/ReconnectableConversationsSocket.d.ts +74 -0
  39. package/dist/cjs/custom/ReconnectableConversationsSocket.js +283 -0
  40. package/dist/cjs/custom/index.d.ts +1 -0
  41. package/dist/cjs/custom/index.js +5 -0
  42. package/dist/cjs/index.d.ts +1 -0
  43. package/dist/cjs/index.js +3 -1
  44. package/dist/cjs/version.d.ts +1 -1
  45. package/dist/cjs/version.js +1 -1
  46. package/dist/esm/BaseClient.mjs +2 -2
  47. package/dist/esm/Client.d.mts +9 -1
  48. package/dist/esm/Client.mjs +1 -1
  49. package/dist/esm/api/resources/agents/client/Client.d.mts +3 -0
  50. package/dist/esm/api/resources/agents/client/Client.mjs +3 -0
  51. package/dist/esm/api/resources/agents/client/requests/AgentsCreateRequest.d.mts +3 -0
  52. package/dist/esm/api/resources/agents/client/requests/UpdateAgentRequest.d.mts +3 -0
  53. package/dist/esm/api/resources/agents/client/requests/UpsertAgentRequest.d.mts +1 -0
  54. package/dist/esm/api/resources/conversations/client/Client.d.mts +8 -1
  55. package/dist/esm/api/resources/conversations/client/Client.mjs +37 -3
  56. package/dist/esm/api/resources/conversations/client/Socket.d.mts +2 -1
  57. package/dist/esm/api/resources/conversations/client/Socket.mjs +4 -0
  58. package/dist/esm/api/resources/conversations/client/requests/ConversationsSipOutboundCallRequest.d.mts +2 -0
  59. package/dist/esm/api/resources/conversations/client/requests/OutboundCallRequest.d.mts +5 -1
  60. package/dist/esm/api/resources/conversations/types/ConversationsOutboundCallResponse.d.mts +2 -4
  61. package/dist/esm/api/resources/conversations/types/ConversationsSipOutboundCallResponse.d.mts +2 -6
  62. package/dist/esm/api/types/Agent.d.mts +2 -0
  63. package/dist/esm/api/types/ConfigOptions.d.mts +94 -0
  64. package/dist/esm/api/types/ConfigOptions.mjs +29 -0
  65. package/dist/esm/api/types/ConfigPayload.d.mts +2 -88
  66. package/dist/esm/api/types/ConfigPayload.mjs +1 -28
  67. package/dist/esm/api/types/Conversation.d.mts +2 -0
  68. package/dist/esm/api/types/CreateAgentRequest.d.mts +2 -0
  69. package/dist/esm/api/types/OutboundCallConfig.d.mts +2 -0
  70. package/dist/esm/api/types/OutboundCallInitiatedResponse.d.mts +6 -0
  71. package/dist/esm/api/types/OutboundCallInitiatedResponse.mjs +2 -0
  72. package/dist/esm/api/types/OutboundDryRunResponse.d.mts +6 -0
  73. package/dist/esm/api/types/OutboundDryRunResponse.mjs +2 -0
  74. package/dist/esm/api/types/ResetPayload.d.mts +5 -0
  75. package/dist/esm/api/types/ResetPayload.mjs +2 -0
  76. package/dist/esm/api/types/SipOutboundCallInitiatedResponse.d.mts +8 -0
  77. package/dist/esm/api/types/SipOutboundCallInitiatedResponse.mjs +2 -0
  78. package/dist/esm/api/types/SipOutboundDryRunResponse.d.mts +8 -0
  79. package/dist/esm/api/types/SipOutboundDryRunResponse.mjs +2 -0
  80. package/dist/esm/api/types/index.d.mts +6 -0
  81. package/dist/esm/api/types/index.mjs +6 -0
  82. package/dist/esm/custom/ReconnectableConversationsSocket.d.mts +74 -0
  83. package/dist/esm/custom/ReconnectableConversationsSocket.mjs +246 -0
  84. package/dist/esm/custom/index.d.mts +1 -0
  85. package/dist/esm/custom/index.mjs +1 -0
  86. package/dist/esm/index.d.mts +1 -0
  87. package/dist/esm/index.mjs +1 -0
  88. package/dist/esm/version.d.mts +1 -1
  89. package/dist/esm/version.mjs +1 -1
  90. package/package.json +1 -1
  91. package/reference.md +6 -1
  92. package/dist/cjs/api/resources/agents/client/requests/AgentsRemoveCustomPhoneNumberRequest.d.ts +0 -16
  93. package/dist/cjs/api/resources/agents/types/AgentsRemoveCustomPhoneNumberResponse.d.ts +0 -6
  94. package/dist/cjs/api/types/AudioFinishedPayload.d.ts +0 -6
  95. package/dist/cjs/api/types/InterruptedResponsePayload.d.ts +0 -8
  96. package/dist/cjs/api/types/IsUserSpeakingPayload.d.ts +0 -8
  97. package/dist/cjs/api/types/IsUserSpeakingPayload.js +0 -5
  98. package/dist/cjs/api/types/SetTwilioCallSidPayload.d.ts +0 -8
  99. package/dist/cjs/api/types/SetTwilioCallSidPayload.js +0 -5
  100. package/dist/cjs/core/fetcher/ResponseWithBody.d.ts +0 -4
  101. package/dist/cjs/core/fetcher/ResponseWithBody.js +0 -6
  102. package/dist/esm/api/resources/agents/client/requests/AgentsRemoveCustomPhoneNumberRequest.d.mts +0 -16
  103. package/dist/esm/api/resources/agents/client/requests/AgentsRemoveCustomPhoneNumberRequest.mjs +0 -4
  104. package/dist/esm/api/resources/agents/types/AgentsRemoveCustomPhoneNumberResponse.d.mts +0 -6
  105. package/dist/esm/api/resources/agents/types/AgentsRemoveCustomPhoneNumberResponse.mjs +0 -4
  106. package/dist/esm/api/types/AudioFinishedPayload.d.mts +0 -6
  107. package/dist/esm/api/types/AudioFinishedPayload.mjs +0 -4
  108. package/dist/esm/api/types/InterruptedResponsePayload.d.mts +0 -8
  109. package/dist/esm/api/types/InterruptedResponsePayload.mjs +0 -4
  110. package/dist/esm/api/types/IsUserSpeakingPayload.d.mts +0 -8
  111. package/dist/esm/api/types/IsUserSpeakingPayload.mjs +0 -4
  112. package/dist/esm/api/types/SetTwilioCallSidPayload.d.mts +0 -8
  113. package/dist/esm/api/types/SetTwilioCallSidPayload.mjs +0 -4
  114. package/dist/esm/core/fetcher/ResponseWithBody.d.mts +0 -4
  115. package/dist/esm/core/fetcher/ResponseWithBody.mjs +0 -3
  116. package/dist/index.d.mts +0 -686
  117. package/dist/index.d.ts +0 -686
  118. package/dist/index.js +0 -643
  119. package/dist/index.mjs +0 -606
package/README.md CHANGED
@@ -71,6 +71,7 @@ await client.agents.create({
71
71
  additional_languages: ["es"],
72
72
  multilingual_mode: "request",
73
73
  boosted_keywords: ["Load ID", "dispatch"],
74
+ min_words_to_interrupt: 1,
74
75
  configuration_endpoint: {
75
76
  url: "https://api.example.com/config",
76
77
  headers: {
@@ -43,8 +43,8 @@ function normalizeClientOptions(options) {
43
43
  const headers = (0, headers_js_1.mergeHeaders)({
44
44
  "X-Fern-Language": "JavaScript",
45
45
  "X-Fern-SDK-Name": "phonic",
46
- "X-Fern-SDK-Version": "0.31.8",
47
- "User-Agent": "phonic/0.31.8",
46
+ "X-Fern-SDK-Version": "0.31.10",
47
+ "User-Agent": "phonic/0.31.10",
48
48
  "X-Fern-Runtime": core.RUNTIME.type,
49
49
  "X-Fern-Runtime-Version": core.RUNTIME.version,
50
50
  }, options === null || options === void 0 ? void 0 : options.headers);
@@ -9,7 +9,15 @@ import type { BaseClientOptions, BaseRequestOptions } from "./BaseClient.js";
9
9
  import { type NormalizedClientOptionsWithAuth } from "./BaseClient.js";
10
10
  import * as core from "./core/index.js";
11
11
  export declare namespace PhonicClient {
12
- type Options = BaseClientOptions;
12
+ type Options = BaseClientOptions & {
13
+ /**
14
+ * When `true`, conversation WebSockets automatically reconnect after an
15
+ * abnormal disconnect (WebSocket close code 1006) using `reconnect_conv_id`.
16
+ * Defaults to `false` until the behavior is broadly validated in production;
17
+ * set to `true` to opt in early.
18
+ */
19
+ reconnectConversationOnAbnormalDisconnect?: boolean;
20
+ };
13
21
  interface RequestOptions extends BaseRequestOptions {
14
22
  }
15
23
  }
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- // This file was auto-generated by Fern from our API Definition.
2
+ // Maintained manually (listed in .fernignore). Fern does not overwrite this file.
3
3
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
4
  if (k2 === undefined) k2 = k;
5
5
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -63,6 +63,7 @@ export declare class AgentsClient {
63
63
  * additional_languages: ["es"],
64
64
  * multilingual_mode: "request",
65
65
  * boosted_keywords: ["Load ID", "dispatch"],
66
+ * min_words_to_interrupt: 1,
66
67
  * configuration_endpoint: {
67
68
  * url: "https://api.example.com/config",
68
69
  * headers: {
@@ -111,6 +112,7 @@ export declare class AgentsClient {
111
112
  * additional_languages: ["es"],
112
113
  * multilingual_mode: "request",
113
114
  * boosted_keywords: ["Load ID", "dispatch"],
115
+ * min_words_to_interrupt: 1,
114
116
  * configuration_endpoint: {
115
117
  * url: "https://api.example.com/config",
116
118
  * headers: {
@@ -195,6 +197,7 @@ export declare class AgentsClient {
195
197
  * additional_languages: ["es"],
196
198
  * multilingual_mode: "request",
197
199
  * boosted_keywords: ["Load ID", "dispatch"],
200
+ * min_words_to_interrupt: 1,
198
201
  * configuration_endpoint: {
199
202
  * url: "https://api.example.com/config",
200
203
  * headers: {
@@ -161,6 +161,7 @@ class AgentsClient {
161
161
  * additional_languages: ["es"],
162
162
  * multilingual_mode: "request",
163
163
  * boosted_keywords: ["Load ID", "dispatch"],
164
+ * min_words_to_interrupt: 1,
164
165
  * configuration_endpoint: {
165
166
  * url: "https://api.example.com/config",
166
167
  * headers: {
@@ -258,6 +259,7 @@ class AgentsClient {
258
259
  * additional_languages: ["es"],
259
260
  * multilingual_mode: "request",
260
261
  * boosted_keywords: ["Load ID", "dispatch"],
262
+ * min_words_to_interrupt: 1,
261
263
  * configuration_endpoint: {
262
264
  * url: "https://api.example.com/config",
263
265
  * headers: {
@@ -471,6 +473,7 @@ class AgentsClient {
471
473
  * additional_languages: ["es"],
472
474
  * multilingual_mode: "request",
473
475
  * boosted_keywords: ["Load ID", "dispatch"],
476
+ * min_words_to_interrupt: 1,
474
477
  * configuration_endpoint: {
475
478
  * url: "https://api.example.com/config",
476
479
  * headers: {
@@ -28,6 +28,7 @@ import type * as Phonic from "../../../../index.js";
28
28
  * additional_languages: ["es"],
29
29
  * multilingual_mode: "request",
30
30
  * boosted_keywords: ["Load ID", "dispatch"],
31
+ * min_words_to_interrupt: 1,
31
32
  * configuration_endpoint: {
32
33
  * url: "https://api.example.com/config",
33
34
  * headers: {
@@ -90,6 +91,8 @@ export interface AgentsCreateRequest {
90
91
  multilingual_mode?: Phonic.CreateAgentRequest.MultilingualMode;
91
92
  /** These words, or short phrases, will be more accurately recognized by the agent. */
92
93
  boosted_keywords?: string[];
94
+ /** Minimum number of words required to interrupt the assistant. */
95
+ min_words_to_interrupt?: number;
93
96
  /** When not `null`, at the beginning of the conversation the agent will make a POST request to this endpoint to get configuration options. */
94
97
  configuration_endpoint?: Phonic.CreateAgentRequest.ConfigurationEndpoint | null;
95
98
  /** Float between 0.0 and 1.0 representing the percentage of inbound calls handled by Agent. Defaults to `1.0`. Requires `phone_number` to be set when less than 1.0. */
@@ -28,6 +28,7 @@ import type * as Phonic from "../../../../index.js";
28
28
  * additional_languages: ["es"],
29
29
  * multilingual_mode: "request",
30
30
  * boosted_keywords: ["Load ID", "dispatch"],
31
+ * min_words_to_interrupt: 1,
31
32
  * configuration_endpoint: {
32
33
  * url: "https://api.example.com/config",
33
34
  * headers: {
@@ -90,6 +91,8 @@ export interface UpdateAgentRequest {
90
91
  multilingual_mode?: UpdateAgentRequest.MultilingualMode;
91
92
  /** These words, or short phrases, will be more accurately recognized by the agent. */
92
93
  boosted_keywords?: string[];
94
+ /** Minimum number of words required to interrupt the assistant. */
95
+ min_words_to_interrupt?: number;
93
96
  /** When not `null`, at the beginning of the conversation the agent will make a POST request to this endpoint to get configuration options. */
94
97
  configuration_endpoint?: UpdateAgentRequest.ConfigurationEndpoint | null;
95
98
  /** Float between 0.0 and 1.0 representing the percentage of inbound calls handled by Agent. Requires `phone_number` to be set when less than 1.0. */
@@ -28,6 +28,7 @@ import type * as Phonic from "../../../../index.js";
28
28
  * additional_languages: ["es"],
29
29
  * multilingual_mode: "request",
30
30
  * boosted_keywords: ["Load ID", "dispatch"],
31
+ * min_words_to_interrupt: 1,
31
32
  * configuration_endpoint: {
32
33
  * url: "https://api.example.com/config",
33
34
  * headers: {
@@ -4,7 +4,14 @@ import * as core from "../../../../core/index.js";
4
4
  import * as Phonic from "../../../index.js";
5
5
  import { ConversationsSocket } from "./Socket.js";
6
6
  export declare namespace ConversationsClient {
7
- type Options = BaseClientOptions;
7
+ type Options = BaseClientOptions & {
8
+ /**
9
+ * When `true`, `connect()` uses session-aware reconnection on abnormal
10
+ * disconnect (1006). Set via `PhonicClient` options as
11
+ * `reconnectConversationOnAbnormalDisconnect`.
12
+ */
13
+ reconnectConversationOnAbnormalDisconnect?: boolean;
14
+ };
8
15
  interface RequestOptions extends BaseRequestOptions {
9
16
  }
10
17
  interface ConnectArgs {
@@ -62,6 +62,7 @@ const environments = __importStar(require("../../../../environments.js"));
62
62
  const handleNonStatusCodeError_js_1 = require("../../../../errors/handleNonStatusCodeError.js");
63
63
  const errors = __importStar(require("../../../../errors/index.js"));
64
64
  const Phonic = __importStar(require("../../../index.js"));
65
+ const ReconnectableConversationsSocket_js_1 = require("../../../../custom/ReconnectableConversationsSocket.js");
65
66
  const Socket_js_1 = require("./Socket.js");
66
67
  class ConversationsClient {
67
68
  constructor(options = {}) {
@@ -750,11 +751,44 @@ class ConversationsClient {
750
751
  const _queryParams = {
751
752
  downstream_websocket_url: downstreamWebsocketUrl,
752
753
  };
754
+ const baseWsUrl = core.url.join((_a = (yield core.Supplier.get(this._options.baseUrl))) !== null && _a !== void 0 ? _a : ((_b = (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.PhonicEnvironment.Default)
755
+ .production, "/v1/sts/ws");
756
+ if (this._options.reconnectConversationOnAbnormalDisconnect) {
757
+ const connectionTimeoutMs = connectionTimeoutInSeconds != null ? connectionTimeoutInSeconds * 1000 : undefined;
758
+ const createSocket = (reconnectConvId) => __awaiter(this, void 0, void 0, function* () {
759
+ var _a, _b, _c;
760
+ const freshAuth = yield this._options.authProvider.getAuthRequest();
761
+ const mergedHeaders = Object.assign(Object.assign(Object.assign({}, ((_a = freshAuth.headers) !== null && _a !== void 0 ? _a : {})), ((_c = (_b = this._options) === null || _b === void 0 ? void 0 : _b.headers) !== null && _c !== void 0 ? _c : {})), headers);
762
+ const isSessionReconnect = reconnectConvId != null;
763
+ return new core.ReconnectingWebSocket({
764
+ url: baseWsUrl,
765
+ protocols: protocols !== null && protocols !== void 0 ? protocols : [],
766
+ queryParameters: Object.assign(Object.assign(Object.assign({}, _queryParams), queryParams), (reconnectConvId ? { reconnect_conv_id: reconnectConvId } : {})),
767
+ headers: mergedHeaders,
768
+ options: {
769
+ debug: debug !== null && debug !== void 0 ? debug : false,
770
+ // Initial connection keeps transport retries; replacement sockets use 0 so only
771
+ // ReconnectableConversationsSocket performs session-level reconnect.
772
+ maxRetries: isSessionReconnect ? 0 : reconnectAttempts !== null && reconnectAttempts !== void 0 ? reconnectAttempts : 30,
773
+ connectionTimeout: connectionTimeoutMs,
774
+ },
775
+ // Only pass abortSignal to the initial socket. Reconnect sockets
776
+ // don't get it — each would register a new listener on the signal
777
+ // that's never removed, leaking memory over many reconnects.
778
+ abortSignal: isSessionReconnect ? undefined : abortSignal,
779
+ });
780
+ });
781
+ const initialSocket = yield createSocket();
782
+ return new ReconnectableConversationsSocket_js_1.ReconnectableConversationsSocket({
783
+ socket: initialSocket,
784
+ createReconnectSocket: (conversationId) => createSocket(conversationId),
785
+ abortSignal,
786
+ });
787
+ }
753
788
  const _authRequest = yield this._options.authProvider.getAuthRequest();
754
- const _headers = Object.assign(Object.assign(Object.assign({}, ((_a = _authRequest.headers) !== null && _a !== void 0 ? _a : {})), ((_c = (_b = this._options) === null || _b === void 0 ? void 0 : _b.headers) !== null && _c !== void 0 ? _c : {})), headers);
789
+ const _headers = Object.assign(Object.assign(Object.assign({}, ((_c = _authRequest.headers) !== null && _c !== void 0 ? _c : {})), ((_e = (_d = this._options) === null || _d === void 0 ? void 0 : _d.headers) !== null && _e !== void 0 ? _e : {})), headers);
755
790
  const socket = new core.ReconnectingWebSocket({
756
- url: core.url.join((_d = (yield core.Supplier.get(this._options.baseUrl))) !== null && _d !== void 0 ? _d : ((_e = (yield core.Supplier.get(this._options.environment))) !== null && _e !== void 0 ? _e : environments.PhonicEnvironment.Default)
757
- .production, "/v1/sts/ws"),
791
+ url: baseWsUrl,
758
792
  protocols: protocols !== null && protocols !== void 0 ? protocols : [],
759
793
  queryParameters: Object.assign(Object.assign({}, _queryParams), queryParams),
760
794
  headers: _headers,
@@ -41,6 +41,7 @@ export declare class ConversationsSocket {
41
41
  sendToolCallOutput(message: Phonic.ToolCallOutputPayload): void;
42
42
  sendGenerateReply(message: Phonic.GenerateReplyPayload): void;
43
43
  sendSay(message: Phonic.SayPayload): void;
44
+ sendReset(message: Phonic.ResetPayload): void;
44
45
  /** Connect to the websocket and register event handlers. */
45
46
  connect(): ConversationsSocket;
46
47
  /** Close the websocket and unregister event handlers. */
@@ -52,5 +53,5 @@ export declare class ConversationsSocket {
52
53
  /** Send a binary payload to the websocket. */
53
54
  protected sendBinary(payload: ArrayBuffer | Blob | ArrayBufferView): void;
54
55
  /** Send a JSON payload to the websocket. */
55
- protected sendJson(payload: Phonic.ConfigPayload | Phonic.AudioChunkPayload | Phonic.UpdateSystemPromptPayload | Phonic.AddSystemMessagePayload | Phonic.SetExternalIdPayload | Phonic.ToolCallOutputPayload | Phonic.GenerateReplyPayload | Phonic.SayPayload): void;
56
+ protected sendJson(payload: Phonic.ConfigPayload | Phonic.AudioChunkPayload | Phonic.UpdateSystemPromptPayload | Phonic.AddSystemMessagePayload | Phonic.SetExternalIdPayload | Phonic.ToolCallOutputPayload | Phonic.GenerateReplyPayload | Phonic.SayPayload | Phonic.ResetPayload): void;
56
57
  }
@@ -122,6 +122,10 @@ class ConversationsSocket {
122
122
  this.assertSocketIsOpen();
123
123
  this.sendJson(message);
124
124
  }
125
+ sendReset(message) {
126
+ this.assertSocketIsOpen();
127
+ this.sendJson(message);
128
+ }
125
129
  /** Connect to the websocket and register event handlers. */
126
130
  connect() {
127
131
  this.socket.reconnect();
@@ -19,4 +19,6 @@ export interface ConversationsSipOutboundCallRequest {
19
19
  /** Destination phone number in E.164 format. */
20
20
  to_phone_number: string;
21
21
  config?: Phonic.OutboundCallConfig;
22
+ /** If true, validates the outbound call setup without placing a call. Returns HTTP 200 with `conversation_id` and `twilio_call_sid` set to null. */
23
+ dry_run?: boolean;
22
24
  }
@@ -20,12 +20,16 @@ import type * as Phonic from "../../../../index.js";
20
20
  * additional_languages: ["es"],
21
21
  * multilingual_mode: "request",
22
22
  * boosted_keywords: ["Load ID", "dispatch"],
23
+ * min_words_to_interrupt: 1,
23
24
  * tools: ["keypad_input"]
24
- * }
25
+ * },
26
+ * dry_run: false
25
27
  * }
26
28
  */
27
29
  export interface OutboundCallRequest {
28
30
  /** The phone number to call in E.164 format. */
29
31
  to_phone_number: string;
30
32
  config?: Phonic.OutboundCallConfig;
33
+ /** If true, validates the outbound call setup without placing a call. Returns HTTP 200 with `conversation_id` set to null. */
34
+ dry_run?: boolean;
31
35
  }
@@ -1,4 +1,2 @@
1
- export interface ConversationsOutboundCallResponse {
2
- /** The ID of the created conversation. */
3
- conversation_id: string;
4
- }
1
+ import type * as Phonic from "../../../index.js";
2
+ export type ConversationsOutboundCallResponse = Phonic.OutboundDryRunResponse | Phonic.OutboundCallInitiatedResponse;
@@ -1,6 +1,2 @@
1
- export interface ConversationsSipOutboundCallResponse {
2
- /** The ID of the created conversation. */
3
- conversation_id: string;
4
- /** The Twilio Call SID. */
5
- twilio_call_sid: string;
6
- }
1
+ import type * as Phonic from "../../../index.js";
2
+ export type ConversationsSipOutboundCallResponse = Phonic.SipOutboundDryRunResponse | Phonic.SipOutboundCallInitiatedResponse;
@@ -52,6 +52,8 @@ export interface Agent {
52
52
  multilingual_mode: Agent.MultilingualMode;
53
53
  /** These words, or short phrases, will be more accurately recognized by the agent. */
54
54
  boosted_keywords: string[];
55
+ /** Minimum number of words required to interrupt the assistant. */
56
+ min_words_to_interrupt: number;
55
57
  /** When not `null`, the agent will call this endpoint to get configuration options. */
56
58
  configuration_endpoint: Agent.ConfigurationEndpoint | null;
57
59
  /** Float between 0.0 and 1.0 representing the percentage of inbound calls handled by Agent. Requires `phone_number` to be set when less than 1.0. */
@@ -0,0 +1,94 @@
1
+ /**
2
+ * Configuration fields for the initial `config` message.
3
+ */
4
+ export interface ConfigOptions {
5
+ /** Agent name to use for conversation */
6
+ agent?: string | undefined;
7
+ /** Project name */
8
+ project?: string | undefined;
9
+ /** STS model to use */
10
+ model?: "merritt" | undefined;
11
+ /** System prompt for AI assistant */
12
+ system_prompt?: string | undefined;
13
+ /** Audio playback speed */
14
+ audio_speed?: number | undefined;
15
+ /** Background noise level for the conversation */
16
+ background_noise_level?: number | undefined;
17
+ /** Background noise type for the conversation */
18
+ background_noise?: (ConfigOptions.BackgroundNoise | null) | undefined;
19
+ /** When `true`, the welcome message will be automatically generated and the `welcome_message` field will be ignored. */
20
+ generate_welcome_message?: boolean | undefined;
21
+ /** Message to play when conversation starts. Ignored when `generate_welcome_message` is `true`. */
22
+ welcome_message?: (string | null) | undefined;
23
+ /** Voice ID to use for speech synthesis */
24
+ voice_id?: string | undefined;
25
+ /** Audio input format */
26
+ input_format?: ConfigOptions.InputFormat | undefined;
27
+ /** Audio output format */
28
+ output_format?: ConfigOptions.OutputFormat | undefined;
29
+ /** Voice activity detection prebuffer duration */
30
+ vad_prebuffer_duration_ms?: number | undefined;
31
+ /** Minimum speech duration for VAD */
32
+ vad_min_speech_duration_ms?: number | undefined;
33
+ /** Minimum silence duration for VAD */
34
+ vad_min_silence_duration_ms?: number | undefined;
35
+ /** Voice activity detection threshold */
36
+ vad_threshold?: number | undefined;
37
+ /** Minimum number of words required to interrupt the assistant. */
38
+ min_words_to_interrupt?: number | undefined;
39
+ /** Whether to have the no-input poke text be generated by AI */
40
+ generate_no_input_poke_text?: boolean | undefined;
41
+ /** Seconds of silence before poke message */
42
+ no_input_poke_sec?: (number | null) | undefined;
43
+ /** Poke message text. Ignored when generate_no_input_poke_text is true. */
44
+ no_input_poke_text?: string | undefined;
45
+ /** Seconds of silence before ending conversation */
46
+ no_input_end_conversation_sec?: number | undefined;
47
+ /** ISO 639-1 language code that sets the agent's default language to recognize and speak. Welcome message and no input poke text should be in this language. */
48
+ default_language?: string | undefined;
49
+ /** Array of additional ISO 639-1 language codes that the agent should be able to recognize and speak. Should not include `default_language`. */
50
+ additional_languages?: string[] | undefined;
51
+ /** If `"auto"`, each user audio is automatically identified for the language to respond in. If `"request"`, user must request to change language (recommended). */
52
+ multilingual_mode?: ConfigOptions.MultilingualMode | undefined;
53
+ /** Keywords to boost in speech recognition */
54
+ boosted_keywords?: string[] | undefined;
55
+ /** Names of tools available to the assistant. */
56
+ tools?: ConfigOptions.Tools.Item[] | undefined;
57
+ /** Template variables for system prompt and welcome message */
58
+ template_variables?: Record<string, string> | undefined;
59
+ }
60
+ export declare namespace ConfigOptions {
61
+ /** Background noise type for the conversation */
62
+ const BackgroundNoise: {
63
+ readonly Office: "office";
64
+ readonly CallCenter: "call-center";
65
+ readonly CoffeeShop: "coffee-shop";
66
+ };
67
+ type BackgroundNoise = (typeof BackgroundNoise)[keyof typeof BackgroundNoise];
68
+ /** Audio input format */
69
+ const InputFormat: {
70
+ readonly Pcm44100: "pcm_44100";
71
+ readonly Pcm16000: "pcm_16000";
72
+ readonly Pcm8000: "pcm_8000";
73
+ readonly Mulaw8000: "mulaw_8000";
74
+ };
75
+ type InputFormat = (typeof InputFormat)[keyof typeof InputFormat];
76
+ /** Audio output format */
77
+ const OutputFormat: {
78
+ readonly Pcm44100: "pcm_44100";
79
+ readonly Pcm16000: "pcm_16000";
80
+ readonly Pcm8000: "pcm_8000";
81
+ readonly Mulaw8000: "mulaw_8000";
82
+ };
83
+ type OutputFormat = (typeof OutputFormat)[keyof typeof OutputFormat];
84
+ /** If `"auto"`, each user audio is automatically identified for the language to respond in. If `"request"`, user must request to change language (recommended). */
85
+ const MultilingualMode: {
86
+ readonly Auto: "auto";
87
+ readonly Request: "request";
88
+ };
89
+ type MultilingualMode = (typeof MultilingualMode)[keyof typeof MultilingualMode];
90
+ type Tools = Tools.Item[];
91
+ namespace Tools {
92
+ type Item = string | Record<string, unknown>;
93
+ }
94
+ }
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ // This file was auto-generated by Fern from our API Definition.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.ConfigOptions = void 0;
5
+ var ConfigOptions;
6
+ (function (ConfigOptions) {
7
+ /** Background noise type for the conversation */
8
+ ConfigOptions.BackgroundNoise = {
9
+ Office: "office",
10
+ CallCenter: "call-center",
11
+ CoffeeShop: "coffee-shop",
12
+ };
13
+ /** Audio input format */
14
+ ConfigOptions.InputFormat = {
15
+ Pcm44100: "pcm_44100",
16
+ Pcm16000: "pcm_16000",
17
+ Pcm8000: "pcm_8000",
18
+ Mulaw8000: "mulaw_8000",
19
+ };
20
+ /** Audio output format */
21
+ ConfigOptions.OutputFormat = {
22
+ Pcm44100: "pcm_44100",
23
+ Pcm16000: "pcm_16000",
24
+ Pcm8000: "pcm_8000",
25
+ Mulaw8000: "mulaw_8000",
26
+ };
27
+ /** If `"auto"`, each user audio is automatically identified for the language to respond in. If `"request"`, user must request to change language (recommended). */
28
+ ConfigOptions.MultilingualMode = {
29
+ Auto: "auto",
30
+ Request: "request",
31
+ };
32
+ })(ConfigOptions || (exports.ConfigOptions = ConfigOptions = {}));
@@ -1,90 +1,4 @@
1
- export interface ConfigPayload {
1
+ import type * as Phonic from "../index.js";
2
+ export interface ConfigPayload extends Phonic.ConfigOptions {
2
3
  type: "config";
3
- /** Agent name to use for conversation */
4
- agent?: string | undefined;
5
- /** Project name */
6
- project?: string | undefined;
7
- /** STS model to use */
8
- model?: "merritt" | undefined;
9
- /** System prompt for AI assistant */
10
- system_prompt?: string | undefined;
11
- /** Audio playback speed */
12
- audio_speed?: number | undefined;
13
- /** Background noise level for the conversation */
14
- background_noise_level?: number | undefined;
15
- /** Background noise type for the conversation */
16
- background_noise?: (ConfigPayload.BackgroundNoise | null) | undefined;
17
- /** When `true`, the welcome message will be automatically generated and the `welcome_message` field will be ignored. */
18
- generate_welcome_message?: boolean | undefined;
19
- /** Message to play when conversation starts. Ignored when `generate_welcome_message` is `true`. */
20
- welcome_message?: (string | null) | undefined;
21
- /** Voice ID to use for speech synthesis */
22
- voice_id?: string | undefined;
23
- /** Audio input format */
24
- input_format?: ConfigPayload.InputFormat | undefined;
25
- /** Audio output format */
26
- output_format?: ConfigPayload.OutputFormat | undefined;
27
- /** Voice activity detection prebuffer duration */
28
- vad_prebuffer_duration_ms?: number | undefined;
29
- /** Minimum speech duration for VAD */
30
- vad_min_speech_duration_ms?: number | undefined;
31
- /** Minimum silence duration for VAD */
32
- vad_min_silence_duration_ms?: number | undefined;
33
- /** Voice activity detection threshold */
34
- vad_threshold?: number | undefined;
35
- /** Whether to have the no-input poke text be generated by AI */
36
- generate_no_input_poke_text?: boolean | undefined;
37
- /** Seconds of silence before poke message */
38
- no_input_poke_sec?: (number | null) | undefined;
39
- /** Poke message text. Ignored when generate_no_input_poke_text is true. */
40
- no_input_poke_text?: string | undefined;
41
- /** Seconds of silence before ending conversation */
42
- no_input_end_conversation_sec?: number | undefined;
43
- /** ISO 639-1 language code that sets the agent's default language to recognize and speak. Welcome message and no input poke text should be in this language. */
44
- default_language?: string | undefined;
45
- /** Array of additional ISO 639-1 language codes that the agent should be able to recognize and speak. Should not include `default_language`. */
46
- additional_languages?: string[] | undefined;
47
- /** If `"auto"`, each user audio is automatically identified for the language to respond in. If `"request"`, user must request to change language (recommended). */
48
- multilingual_mode?: ConfigPayload.MultilingualMode | undefined;
49
- /** Keywords to boost in speech recognition */
50
- boosted_keywords?: string[] | undefined;
51
- /** Names of tools available to the assistant. */
52
- tools?: ConfigPayload.Tools.Item[] | undefined;
53
- /** Template variables for system prompt and welcome message */
54
- template_variables?: Record<string, string> | undefined;
55
- }
56
- export declare namespace ConfigPayload {
57
- /** Background noise type for the conversation */
58
- const BackgroundNoise: {
59
- readonly Office: "office";
60
- readonly CallCenter: "call-center";
61
- readonly CoffeeShop: "coffee-shop";
62
- };
63
- type BackgroundNoise = (typeof BackgroundNoise)[keyof typeof BackgroundNoise];
64
- /** Audio input format */
65
- const InputFormat: {
66
- readonly Pcm44100: "pcm_44100";
67
- readonly Pcm16000: "pcm_16000";
68
- readonly Pcm8000: "pcm_8000";
69
- readonly Mulaw8000: "mulaw_8000";
70
- };
71
- type InputFormat = (typeof InputFormat)[keyof typeof InputFormat];
72
- /** Audio output format */
73
- const OutputFormat: {
74
- readonly Pcm44100: "pcm_44100";
75
- readonly Pcm16000: "pcm_16000";
76
- readonly Pcm8000: "pcm_8000";
77
- readonly Mulaw8000: "mulaw_8000";
78
- };
79
- type OutputFormat = (typeof OutputFormat)[keyof typeof OutputFormat];
80
- /** If `"auto"`, each user audio is automatically identified for the language to respond in. If `"request"`, user must request to change language (recommended). */
81
- const MultilingualMode: {
82
- readonly Auto: "auto";
83
- readonly Request: "request";
84
- };
85
- type MultilingualMode = (typeof MultilingualMode)[keyof typeof MultilingualMode];
86
- type Tools = Tools.Item[];
87
- namespace Tools {
88
- type Item = string | Record<string, unknown>;
89
- }
90
4
  }
@@ -1,32 +1,3 @@
1
1
  "use strict";
2
2
  // This file was auto-generated by Fern from our API Definition.
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.ConfigPayload = void 0;
5
- var ConfigPayload;
6
- (function (ConfigPayload) {
7
- /** Background noise type for the conversation */
8
- ConfigPayload.BackgroundNoise = {
9
- Office: "office",
10
- CallCenter: "call-center",
11
- CoffeeShop: "coffee-shop",
12
- };
13
- /** Audio input format */
14
- ConfigPayload.InputFormat = {
15
- Pcm44100: "pcm_44100",
16
- Pcm16000: "pcm_16000",
17
- Pcm8000: "pcm_8000",
18
- Mulaw8000: "mulaw_8000",
19
- };
20
- /** Audio output format */
21
- ConfigPayload.OutputFormat = {
22
- Pcm44100: "pcm_44100",
23
- Pcm16000: "pcm_16000",
24
- Pcm8000: "pcm_8000",
25
- Mulaw8000: "mulaw_8000",
26
- };
27
- /** If `"auto"`, each user audio is automatically identified for the language to respond in. If `"request"`, user must request to change language (recommended). */
28
- ConfigPayload.MultilingualMode = {
29
- Auto: "auto",
30
- Request: "request",
31
- };
32
- })(ConfigPayload || (exports.ConfigPayload = ConfigPayload = {}));
@@ -46,6 +46,8 @@ export interface Conversation {
46
46
  ended_by: Conversation.EndedBy | null;
47
47
  /** These words, or short phrases, are more accurately recognized by the model. */
48
48
  boosted_keywords: string[] | null;
49
+ /** Minimum number of words required to interrupt the assistant. */
50
+ min_words_to_interrupt: number;
49
51
  /** ISO 639-1 language code that sets the agent's default language to recognize and speak. Welcome message and no input poke text should be in this language. */
50
52
  default_language: string;
51
53
  /** Array of additional ISO 639-1 language codes that the agent should be able to recognize and speak. Should not include `default_language`. */
@@ -50,6 +50,8 @@ export interface CreateAgentRequest {
50
50
  multilingual_mode?: CreateAgentRequest.MultilingualMode | undefined;
51
51
  /** These words, or short phrases, will be more accurately recognized by the agent. */
52
52
  boosted_keywords?: string[] | undefined;
53
+ /** Minimum number of words required to interrupt the assistant. */
54
+ min_words_to_interrupt?: number | undefined;
53
55
  /** When not `null`, at the beginning of the conversation the agent will make a POST request to this endpoint to get configuration options. */
54
56
  configuration_endpoint?: (CreateAgentRequest.ConfigurationEndpoint | null) | undefined;
55
57
  /** Float between 0.0 and 1.0 representing the percentage of inbound calls handled by Agent. Defaults to `1.0`. Requires `phone_number` to be set when less than 1.0. */
@@ -33,6 +33,8 @@ export interface OutboundCallConfig {
33
33
  multilingual_mode?: OutboundCallConfig.MultilingualMode | undefined;
34
34
  /** These words, or short phrases, will be more accurately recognized by the agent. */
35
35
  boosted_keywords?: string[] | undefined;
36
+ /** Minimum number of words required to interrupt the assistant. */
37
+ min_words_to_interrupt?: number | undefined;
36
38
  /** Array of built-in or custom tool names to use. */
37
39
  tools?: OutboundCallConfig.Tools.Item[] | undefined;
38
40
  }
@@ -0,0 +1,6 @@
1
+ export interface OutboundCallInitiatedResponse {
2
+ /** The ID of the created conversation. */
3
+ conversation_id: string;
4
+ /** Always false when a call was placed. */
5
+ dry_run: false;
6
+ }
@@ -1,5 +1,3 @@
1
1
  "use strict";
2
- /**
3
- * This file was auto-generated by Fern from our API Definition.
4
- */
2
+ // This file was auto-generated by Fern from our API Definition.
5
3
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,6 @@
1
+ export interface OutboundDryRunResponse {
2
+ /** Always null when `dry_run` is true. */
3
+ conversation_id: unknown | null;
4
+ /** Always true for this response. */
5
+ dry_run: true;
6
+ }
@@ -1,5 +1,3 @@
1
1
  "use strict";
2
- /**
3
- * This file was auto-generated by Fern from our API Definition.
4
- */
2
+ // This file was auto-generated by Fern from our API Definition.
5
3
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,5 @@
1
+ import type * as Phonic from "../index.js";
2
+ export interface ResetPayload {
3
+ type: "reset";
4
+ config: Phonic.ConfigOptions;
5
+ }
@@ -1,5 +1,3 @@
1
1
  "use strict";
2
- /**
3
- * This file was auto-generated by Fern from our API Definition.
4
- */
2
+ // This file was auto-generated by Fern from our API Definition.
5
3
  Object.defineProperty(exports, "__esModule", { value: true });