phonic 0.30.18 → 0.30.20

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 (46) hide show
  1. package/dist/cjs/Client.js +2 -2
  2. package/dist/cjs/api/resources/agents/client/requests/AgentsCreateRequest.d.ts +5 -1
  3. package/dist/cjs/api/resources/agents/client/requests/UpdateAgentRequest.d.ts +10 -1
  4. package/dist/cjs/api/resources/agents/client/requests/UpdateAgentRequest.js +4 -0
  5. package/dist/cjs/api/resources/conversations/client/Client.js +2 -9
  6. package/dist/cjs/api/resources/conversations/client/requests/ConversationsSipOutboundCallRequest.d.ts +0 -4
  7. package/dist/cjs/api/resources/conversations/types/ConversationsSipOutboundCallResponse.d.ts +2 -0
  8. package/dist/cjs/api/resources/tools/client/Client.d.ts +21 -2
  9. package/dist/cjs/api/resources/tools/client/Client.js +21 -2
  10. package/dist/cjs/api/resources/tools/client/requests/CreateToolRequest.d.ts +25 -3
  11. package/dist/cjs/api/resources/tools/client/requests/CreateToolRequest.js +1 -0
  12. package/dist/cjs/api/resources/tools/client/requests/ToolsGetRequest.d.ts +5 -0
  13. package/dist/cjs/api/resources/tools/client/requests/UpdateToolRequest.d.ts +4 -1
  14. package/dist/cjs/api/resources/tools/client/requests/UpdateToolRequest.js +1 -0
  15. package/dist/cjs/api/types/Agent.d.ts +3 -1
  16. package/dist/cjs/api/types/Conversation.d.ts +13 -0
  17. package/dist/cjs/api/types/CreateAgentRequest.d.ts +10 -1
  18. package/dist/cjs/api/types/CreateAgentRequest.js +4 -0
  19. package/dist/cjs/api/types/Tool.d.ts +4 -1
  20. package/dist/cjs/api/types/Tool.js +1 -0
  21. package/dist/cjs/version.d.ts +1 -1
  22. package/dist/cjs/version.js +1 -1
  23. package/dist/esm/Client.mjs +2 -2
  24. package/dist/esm/api/resources/agents/client/requests/AgentsCreateRequest.d.mts +5 -1
  25. package/dist/esm/api/resources/agents/client/requests/UpdateAgentRequest.d.mts +10 -1
  26. package/dist/esm/api/resources/agents/client/requests/UpdateAgentRequest.mjs +4 -0
  27. package/dist/esm/api/resources/conversations/client/Client.mjs +2 -9
  28. package/dist/esm/api/resources/conversations/client/requests/ConversationsSipOutboundCallRequest.d.mts +0 -4
  29. package/dist/esm/api/resources/conversations/types/ConversationsSipOutboundCallResponse.d.mts +2 -0
  30. package/dist/esm/api/resources/tools/client/Client.d.mts +21 -2
  31. package/dist/esm/api/resources/tools/client/Client.mjs +21 -2
  32. package/dist/esm/api/resources/tools/client/requests/CreateToolRequest.d.mts +25 -3
  33. package/dist/esm/api/resources/tools/client/requests/CreateToolRequest.mjs +1 -0
  34. package/dist/esm/api/resources/tools/client/requests/ToolsGetRequest.d.mts +5 -0
  35. package/dist/esm/api/resources/tools/client/requests/UpdateToolRequest.d.mts +4 -1
  36. package/dist/esm/api/resources/tools/client/requests/UpdateToolRequest.mjs +1 -0
  37. package/dist/esm/api/types/Agent.d.mts +3 -1
  38. package/dist/esm/api/types/Conversation.d.mts +13 -0
  39. package/dist/esm/api/types/CreateAgentRequest.d.mts +10 -1
  40. package/dist/esm/api/types/CreateAgentRequest.mjs +4 -0
  41. package/dist/esm/api/types/Tool.d.mts +4 -1
  42. package/dist/esm/api/types/Tool.mjs +1 -0
  43. package/dist/esm/version.d.mts +1 -1
  44. package/dist/esm/version.mjs +1 -1
  45. package/package.json +1 -1
  46. package/reference.md +6 -20
@@ -50,8 +50,8 @@ class PhonicClient {
50
50
  this._options = Object.assign(Object.assign({}, _options), { headers: (0, headers_js_1.mergeHeaders)({
51
51
  "X-Fern-Language": "JavaScript",
52
52
  "X-Fern-SDK-Name": "phonic",
53
- "X-Fern-SDK-Version": "0.30.18",
54
- "User-Agent": "phonic/0.30.18",
53
+ "X-Fern-SDK-Version": "0.30.20",
54
+ "User-Agent": "phonic/0.30.20",
55
55
  "X-Fern-Runtime": core.RUNTIME.type,
56
56
  "X-Fern-Runtime-Version": core.RUNTIME.version,
57
57
  }, _options === null || _options === void 0 ? void 0 : _options.headers) });
@@ -41,7 +41,11 @@ export interface AgentsCreateRequest {
41
41
  project?: string;
42
42
  /** The name of the agent. Can only contain lowercase letters, numbers and hyphens. Must be unique within the project. */
43
43
  name: string;
44
- phone_number: "assign-automatically" | null;
44
+ phone_number: Phonic.CreateAgentRequest.PhoneNumber | null;
45
+ /** The custom phone number to use for the agent in E.164 format (e.g., +1234567890). This field is deprecated. Use `custom_phone_numbers` instead. */
46
+ custom_phone_number?: string | null;
47
+ /** Array of custom phone numbers in E.164 format (e.g., ["+1234567890", "+0987654321"]). The agent will be able to receive phone calls on any of these numbers. Required when `phone_number` is set to `"custom"`. All phone numbers must be unique. */
48
+ custom_phone_numbers?: string[];
45
49
  /** The timezone of the agent. Used to format system variables like `{{system_time}}`. */
46
50
  timezone?: string;
47
51
  /** The voice ID to use. */
@@ -41,7 +41,11 @@ export interface UpdateAgentRequest {
41
41
  project?: string;
42
42
  /** The name of the agent. Can only contain lowercase letters, numbers and hyphens. Must be unique within the project. */
43
43
  name?: string;
44
- phone_number: "assign-automatically" | null;
44
+ phone_number: UpdateAgentRequest.PhoneNumber | null;
45
+ /** The custom phone number to use for the agent in E.164 format (e.g., +1234567890). This field is deprecated. Use `custom_phone_numbers` instead. */
46
+ custom_phone_number?: string | null;
47
+ /** Array of custom phone numbers in E.164 format (e.g., ["+1234567890", "+0987654321"]). The agent will be able to receive phone calls on any of these numbers. Required when `phone_number` is set to `"custom"`. All phone numbers must be unique. */
48
+ custom_phone_numbers?: string[];
45
49
  /** The timezone of the agent. Used to format system variables like `{{system_time}}`. */
46
50
  timezone?: string;
47
51
  /** The voice ID to use. */
@@ -78,6 +82,11 @@ export interface UpdateAgentRequest {
78
82
  configuration_endpoint?: UpdateAgentRequest.ConfigurationEndpoint | null;
79
83
  }
80
84
  export declare namespace UpdateAgentRequest {
85
+ type PhoneNumber = "assign-automatically" | "custom";
86
+ const PhoneNumber: {
87
+ readonly AssignAutomatically: "assign-automatically";
88
+ readonly Custom: "custom";
89
+ };
81
90
  /**
82
91
  * The audio format of the agent.
83
92
  */
@@ -6,6 +6,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.UpdateAgentRequest = void 0;
7
7
  var UpdateAgentRequest;
8
8
  (function (UpdateAgentRequest) {
9
+ UpdateAgentRequest.PhoneNumber = {
10
+ AssignAutomatically: "assign-automatically",
11
+ Custom: "custom",
12
+ };
9
13
  UpdateAgentRequest.AudioFormat = {
10
14
  Pcm44100: "pcm_44100",
11
15
  Pcm16000: "pcm_16000",
@@ -803,14 +803,7 @@ class Conversations {
803
803
  __sipOutboundCall(request, requestOptions) {
804
804
  return __awaiter(this, void 0, void 0, function* () {
805
805
  var _a, _b, _c, _d;
806
- const { token, downstream_websocket_url: downstreamWebsocketUrl, "X-Sip-Address": sipAddress, "X-Sip-Auth-Username": sipAuthUsername, "X-Sip-Auth-Password": sipAuthPassword } = request, _body = __rest(request, ["token", "downstream_websocket_url", "X-Sip-Address", "X-Sip-Auth-Username", "X-Sip-Auth-Password"]);
807
- const _queryParams = {};
808
- if (token != null) {
809
- _queryParams["token"] = token;
810
- }
811
- if (downstreamWebsocketUrl != null) {
812
- _queryParams["downstream_websocket_url"] = downstreamWebsocketUrl;
813
- }
806
+ const { "X-Sip-Address": sipAddress, "X-Sip-Auth-Username": sipAuthUsername, "X-Sip-Auth-Password": sipAuthPassword } = request, _body = __rest(request, ["X-Sip-Address", "X-Sip-Auth-Username", "X-Sip-Auth-Password"]);
814
807
  let _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({
815
808
  Authorization: yield this._getAuthorizationHeader(),
816
809
  "X-Sip-Address": sipAddress,
@@ -823,7 +816,7 @@ class Conversations {
823
816
  method: "POST",
824
817
  headers: _headers,
825
818
  contentType: "application/json",
826
- queryParameters: Object.assign(Object.assign({}, _queryParams), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams),
819
+ queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
827
820
  requestType: "json",
828
821
  body: _body,
829
822
  timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
@@ -11,10 +11,6 @@ import * as Phonic from "../../../../index.js";
11
11
  * }
12
12
  */
13
13
  export interface ConversationsSipOutboundCallRequest {
14
- /** Optional session token used for STS authorization. */
15
- token?: string;
16
- /** Optional downstream STS WebSocket URL to override the default. */
17
- downstream_websocket_url?: string;
18
14
  /** SIP address of the user's SIP trunk. Required. */
19
15
  "X-Sip-Address": string;
20
16
  /** SIP auth username, if your provider requires it. */
@@ -4,4 +4,6 @@
4
4
  export interface ConversationsSipOutboundCallResponse {
5
5
  /** The ID of the created conversation. */
6
6
  conversation_id: string;
7
+ /** The Twilio Call SID. */
8
+ twilio_call_sid: string;
7
9
  }
@@ -58,6 +58,23 @@ export declare class Tools {
58
58
  * @example
59
59
  * await client.tools.create({
60
60
  * project: "main",
61
+ * name: "context_printer",
62
+ * description: "Gets the specific context for fixing our printer",
63
+ * type: "custom_context",
64
+ * execution_mode: "sync",
65
+ * parameters: [{
66
+ * type: "string",
67
+ * name: "name",
68
+ * description: "description",
69
+ * is_required: true
70
+ * }],
71
+ * require_speech_before_tool_call: false,
72
+ * forbid_speech_after_tool_call: false
73
+ * })
74
+ *
75
+ * @example
76
+ * await client.tools.create({
77
+ * project: "main",
61
78
  * name: "book_appointment",
62
79
  * description: "Books an appointment in the calendar system",
63
80
  * type: "custom_webhook",
@@ -82,7 +99,8 @@ export declare class Tools {
82
99
  * "Content-Type": "application/json"
83
100
  * },
84
101
  * endpoint_timeout_ms: 5000,
85
- * require_speech_before_tool_call: false
102
+ * require_speech_before_tool_call: false,
103
+ * forbid_speech_after_tool_call: false
86
104
  * })
87
105
  *
88
106
  * @example
@@ -99,7 +117,8 @@ export declare class Tools {
99
117
  * is_required: true
100
118
  * }],
101
119
  * tool_call_output_timeout_ms: 5000,
102
- * require_speech_before_tool_call: false
120
+ * require_speech_before_tool_call: false,
121
+ * forbid_speech_after_tool_call: false
103
122
  * })
104
123
  *
105
124
  * @example
@@ -146,6 +146,23 @@ class Tools {
146
146
  * @example
147
147
  * await client.tools.create({
148
148
  * project: "main",
149
+ * name: "context_printer",
150
+ * description: "Gets the specific context for fixing our printer",
151
+ * type: "custom_context",
152
+ * execution_mode: "sync",
153
+ * parameters: [{
154
+ * type: "string",
155
+ * name: "name",
156
+ * description: "description",
157
+ * is_required: true
158
+ * }],
159
+ * require_speech_before_tool_call: false,
160
+ * forbid_speech_after_tool_call: false
161
+ * })
162
+ *
163
+ * @example
164
+ * await client.tools.create({
165
+ * project: "main",
149
166
  * name: "book_appointment",
150
167
  * description: "Books an appointment in the calendar system",
151
168
  * type: "custom_webhook",
@@ -170,7 +187,8 @@ class Tools {
170
187
  * "Content-Type": "application/json"
171
188
  * },
172
189
  * endpoint_timeout_ms: 5000,
173
- * require_speech_before_tool_call: false
190
+ * require_speech_before_tool_call: false,
191
+ * forbid_speech_after_tool_call: false
174
192
  * })
175
193
  *
176
194
  * @example
@@ -187,7 +205,8 @@ class Tools {
187
205
  * is_required: true
188
206
  * }],
189
207
  * tool_call_output_timeout_ms: 5000,
190
- * require_speech_before_tool_call: false
208
+ * require_speech_before_tool_call: false,
209
+ * forbid_speech_after_tool_call: false
191
210
  * })
192
211
  *
193
212
  * @example
@@ -3,6 +3,23 @@
3
3
  */
4
4
  import * as Phonic from "../../../../index.js";
5
5
  /**
6
+ * @example
7
+ * {
8
+ * project: "main",
9
+ * name: "context_printer",
10
+ * description: "Gets the specific context for fixing our printer",
11
+ * type: "custom_context",
12
+ * execution_mode: "sync",
13
+ * parameters: [{
14
+ * type: "string",
15
+ * name: "name",
16
+ * description: "description",
17
+ * is_required: true
18
+ * }],
19
+ * require_speech_before_tool_call: false,
20
+ * forbid_speech_after_tool_call: false
21
+ * }
22
+ *
6
23
  * @example
7
24
  * {
8
25
  * project: "main",
@@ -30,7 +47,8 @@ import * as Phonic from "../../../../index.js";
30
47
  * "Content-Type": "application/json"
31
48
  * },
32
49
  * endpoint_timeout_ms: 5000,
33
- * require_speech_before_tool_call: false
50
+ * require_speech_before_tool_call: false,
51
+ * forbid_speech_after_tool_call: false
34
52
  * }
35
53
  *
36
54
  * @example
@@ -47,7 +65,8 @@ import * as Phonic from "../../../../index.js";
47
65
  * is_required: true
48
66
  * }],
49
67
  * tool_call_output_timeout_ms: 5000,
50
- * require_speech_before_tool_call: false
68
+ * require_speech_before_tool_call: false,
69
+ * forbid_speech_after_tool_call: false
51
70
  * }
52
71
  *
53
72
  * @example
@@ -109,13 +128,16 @@ export interface CreateToolRequest {
109
128
  agents_to_transfer_to?: string[];
110
129
  /** When true, forces the agent to speak before executing the tool. */
111
130
  require_speech_before_tool_call?: boolean;
131
+ /** When true, forbids the agent from speaking after executing the tool. Available for custom_context, custom_webhook and custom_websocket tools. */
132
+ forbid_speech_after_tool_call?: boolean;
112
133
  }
113
134
  export declare namespace CreateToolRequest {
114
135
  /**
115
136
  * The type of tool.
116
137
  */
117
- type Type = "custom_webhook" | "custom_websocket" | "built_in_transfer_to_phone_number" | "built_in_transfer_to_agent";
138
+ type Type = "custom_context" | "custom_webhook" | "custom_websocket" | "built_in_transfer_to_phone_number" | "built_in_transfer_to_agent";
118
139
  const Type: {
140
+ readonly CustomContext: "custom_context";
119
141
  readonly CustomWebhook: "custom_webhook";
120
142
  readonly CustomWebsocket: "custom_websocket";
121
143
  readonly BuiltInTransferToPhoneNumber: "built_in_transfer_to_phone_number";
@@ -7,6 +7,7 @@ exports.CreateToolRequest = void 0;
7
7
  var CreateToolRequest;
8
8
  (function (CreateToolRequest) {
9
9
  CreateToolRequest.Type = {
10
+ CustomContext: "custom_context",
10
11
  CustomWebhook: "custom_webhook",
11
12
  CustomWebsocket: "custom_websocket",
12
13
  BuiltInTransferToPhoneNumber: "built_in_transfer_to_phone_number",
@@ -21,6 +21,11 @@
21
21
  * {
22
22
  * project: "main"
23
23
  * }
24
+ *
25
+ * @example
26
+ * {
27
+ * project: "main"
28
+ * }
24
29
  */
25
30
  export interface ToolsGetRequest {
26
31
  /** The name of the project containing the tool. Only used when `nameOrId` is a name. */
@@ -45,13 +45,16 @@ export interface UpdateToolRequest {
45
45
  agents_to_transfer_to?: string[];
46
46
  /** When true, forces the agent to speak before executing the tool. */
47
47
  require_speech_before_tool_call?: boolean;
48
+ /** When true, forbids the agent from speaking after executing the tool. Available for custom_context, custom_webhook and custom_websocket tools. */
49
+ forbid_speech_after_tool_call?: boolean;
48
50
  }
49
51
  export declare namespace UpdateToolRequest {
50
52
  /**
51
53
  * The type of tool.
52
54
  */
53
- type Type = "custom_webhook" | "custom_websocket" | "built_in_transfer_to_phone_number" | "built_in_transfer_to_agent";
55
+ type Type = "custom_context" | "custom_webhook" | "custom_websocket" | "built_in_transfer_to_phone_number" | "built_in_transfer_to_agent";
54
56
  const Type: {
57
+ readonly CustomContext: "custom_context";
55
58
  readonly CustomWebhook: "custom_webhook";
56
59
  readonly CustomWebsocket: "custom_websocket";
57
60
  readonly BuiltInTransferToPhoneNumber: "built_in_transfer_to_phone_number";
@@ -7,6 +7,7 @@ exports.UpdateToolRequest = void 0;
7
7
  var UpdateToolRequest;
8
8
  (function (UpdateToolRequest) {
9
9
  UpdateToolRequest.Type = {
10
+ CustomContext: "custom_context",
10
11
  CustomWebhook: "custom_webhook",
11
12
  CustomWebsocket: "custom_websocket",
12
13
  BuiltInTransferToPhoneNumber: "built_in_transfer_to_phone_number",
@@ -7,8 +7,10 @@ export interface Agent {
7
7
  id: string;
8
8
  /** The name of the agent. */
9
9
  name: string;
10
- /** The phone number that the agent uses to accept and initiate phone calls. `null` if the agent is not associated with a phone number, in which can the agent can be used via WebSockets. */
10
+ /** The phone number that the agent uses to accept calls. `null` if the agent is not associated with a phone number, in which can the agent can be used via WebSockets. This field is deprecated. Use `phone_numbers` instead. */
11
11
  phone_number: string | null;
12
+ /** Array of phone numbers that the agent uses to accept phone calls. */
13
+ phone_numbers: string[];
12
14
  /** The project the agent belongs to. */
13
15
  project: Agent.Project;
14
16
  /** The timezone of the agent. Used to format system variables like `{{system_time}}`. */
@@ -55,6 +55,8 @@ export interface Conversation {
55
55
  task_results: Record<string, unknown>;
56
56
  /** Array of conversation items (turns). */
57
57
  items: Phonic.ConversationItem[];
58
+ /** Phone call metadata. `null` for non-phone call conversations. */
59
+ call_info: Conversation.CallInfo | null;
58
60
  }
59
61
  export declare namespace Conversation {
60
62
  /**
@@ -97,4 +99,15 @@ export declare namespace Conversation {
97
99
  readonly Assistant: "assistant";
98
100
  readonly Error: "error";
99
101
  };
102
+ /**
103
+ * Phone call metadata. `null` for non-phone call conversations.
104
+ */
105
+ interface CallInfo {
106
+ /** Caller phone number in E.164 format. */
107
+ from_phone_number: string;
108
+ /** Callee phone number in E.164 format. */
109
+ to_phone_number: string;
110
+ /** Twilio Call SID. Only present for user SIP trunking calls. */
111
+ twilio_call_sid?: string;
112
+ }
100
113
  }
@@ -5,7 +5,11 @@ import * as Phonic from "../index.js";
5
5
  export interface CreateAgentRequest {
6
6
  /** The name of the agent. Can only contain lowercase letters, numbers and hyphens. Must be unique within the project. */
7
7
  name: string;
8
- phone_number: "assign-automatically" | null;
8
+ phone_number: CreateAgentRequest.PhoneNumber | null;
9
+ /** The custom phone number to use for the agent in E.164 format (e.g., +1234567890). This field is deprecated. Use `custom_phone_numbers` instead. */
10
+ custom_phone_number?: string | null;
11
+ /** Array of custom phone numbers in E.164 format (e.g., ["+1234567890", "+0987654321"]). The agent will be able to receive phone calls on any of these numbers. Required when `phone_number` is set to `"custom"`. All phone numbers must be unique. */
12
+ custom_phone_numbers?: string[];
9
13
  /** The timezone of the agent. Used to format system variables like `{{system_time}}`. */
10
14
  timezone?: string;
11
15
  /** The voice ID to use. */
@@ -42,6 +46,11 @@ export interface CreateAgentRequest {
42
46
  configuration_endpoint?: CreateAgentRequest.ConfigurationEndpoint | null;
43
47
  }
44
48
  export declare namespace CreateAgentRequest {
49
+ type PhoneNumber = "assign-automatically" | "custom";
50
+ const PhoneNumber: {
51
+ readonly AssignAutomatically: "assign-automatically";
52
+ readonly Custom: "custom";
53
+ };
45
54
  /**
46
55
  * The audio format of the agent.
47
56
  */
@@ -6,6 +6,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.CreateAgentRequest = void 0;
7
7
  var CreateAgentRequest;
8
8
  (function (CreateAgentRequest) {
9
+ CreateAgentRequest.PhoneNumber = {
10
+ AssignAutomatically: "assign-automatically",
11
+ Custom: "custom",
12
+ };
9
13
  CreateAgentRequest.AudioFormat = {
10
14
  Pcm44100: "pcm_44100",
11
15
  Pcm16000: "pcm_16000",
@@ -34,6 +34,8 @@ export interface Tool {
34
34
  agents_to_transfer_to?: string[];
35
35
  /** When true, forces the agent to speak before executing the tool. */
36
36
  require_speech_before_tool_call?: boolean;
37
+ /** When true, forbids the agent from speaking after executing the tool. Available for custom_context, custom_webhook and custom_websocket tools. */
38
+ forbid_speech_after_tool_call?: boolean;
37
39
  }
38
40
  export declare namespace Tool {
39
41
  interface Project {
@@ -43,8 +45,9 @@ export declare namespace Tool {
43
45
  /**
44
46
  * The type of tool.
45
47
  */
46
- type Type = "custom_webhook" | "custom_websocket" | "built_in_transfer_to_phone_number" | "built_in_transfer_to_agent";
48
+ type Type = "custom_context" | "custom_webhook" | "custom_websocket" | "built_in_transfer_to_phone_number" | "built_in_transfer_to_agent";
47
49
  const Type: {
50
+ readonly CustomContext: "custom_context";
48
51
  readonly CustomWebhook: "custom_webhook";
49
52
  readonly CustomWebsocket: "custom_websocket";
50
53
  readonly BuiltInTransferToPhoneNumber: "built_in_transfer_to_phone_number";
@@ -7,6 +7,7 @@ exports.Tool = void 0;
7
7
  var Tool;
8
8
  (function (Tool) {
9
9
  Tool.Type = {
10
+ CustomContext: "custom_context",
10
11
  CustomWebhook: "custom_webhook",
11
12
  CustomWebsocket: "custom_websocket",
12
13
  BuiltInTransferToPhoneNumber: "built_in_transfer_to_phone_number",
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "0.30.18";
1
+ export declare const SDK_VERSION = "0.30.20";
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SDK_VERSION = void 0;
4
- exports.SDK_VERSION = "0.30.18";
4
+ exports.SDK_VERSION = "0.30.20";
@@ -14,8 +14,8 @@ export class PhonicClient {
14
14
  this._options = Object.assign(Object.assign({}, _options), { headers: mergeHeaders({
15
15
  "X-Fern-Language": "JavaScript",
16
16
  "X-Fern-SDK-Name": "phonic",
17
- "X-Fern-SDK-Version": "0.30.18",
18
- "User-Agent": "phonic/0.30.18",
17
+ "X-Fern-SDK-Version": "0.30.20",
18
+ "User-Agent": "phonic/0.30.20",
19
19
  "X-Fern-Runtime": core.RUNTIME.type,
20
20
  "X-Fern-Runtime-Version": core.RUNTIME.version,
21
21
  }, _options === null || _options === void 0 ? void 0 : _options.headers) });
@@ -41,7 +41,11 @@ export interface AgentsCreateRequest {
41
41
  project?: string;
42
42
  /** The name of the agent. Can only contain lowercase letters, numbers and hyphens. Must be unique within the project. */
43
43
  name: string;
44
- phone_number: "assign-automatically" | null;
44
+ phone_number: Phonic.CreateAgentRequest.PhoneNumber | null;
45
+ /** The custom phone number to use for the agent in E.164 format (e.g., +1234567890). This field is deprecated. Use `custom_phone_numbers` instead. */
46
+ custom_phone_number?: string | null;
47
+ /** Array of custom phone numbers in E.164 format (e.g., ["+1234567890", "+0987654321"]). The agent will be able to receive phone calls on any of these numbers. Required when `phone_number` is set to `"custom"`. All phone numbers must be unique. */
48
+ custom_phone_numbers?: string[];
45
49
  /** The timezone of the agent. Used to format system variables like `{{system_time}}`. */
46
50
  timezone?: string;
47
51
  /** The voice ID to use. */
@@ -41,7 +41,11 @@ export interface UpdateAgentRequest {
41
41
  project?: string;
42
42
  /** The name of the agent. Can only contain lowercase letters, numbers and hyphens. Must be unique within the project. */
43
43
  name?: string;
44
- phone_number: "assign-automatically" | null;
44
+ phone_number: UpdateAgentRequest.PhoneNumber | null;
45
+ /** The custom phone number to use for the agent in E.164 format (e.g., +1234567890). This field is deprecated. Use `custom_phone_numbers` instead. */
46
+ custom_phone_number?: string | null;
47
+ /** Array of custom phone numbers in E.164 format (e.g., ["+1234567890", "+0987654321"]). The agent will be able to receive phone calls on any of these numbers. Required when `phone_number` is set to `"custom"`. All phone numbers must be unique. */
48
+ custom_phone_numbers?: string[];
45
49
  /** The timezone of the agent. Used to format system variables like `{{system_time}}`. */
46
50
  timezone?: string;
47
51
  /** The voice ID to use. */
@@ -78,6 +82,11 @@ export interface UpdateAgentRequest {
78
82
  configuration_endpoint?: UpdateAgentRequest.ConfigurationEndpoint | null;
79
83
  }
80
84
  export declare namespace UpdateAgentRequest {
85
+ type PhoneNumber = "assign-automatically" | "custom";
86
+ const PhoneNumber: {
87
+ readonly AssignAutomatically: "assign-automatically";
88
+ readonly Custom: "custom";
89
+ };
81
90
  /**
82
91
  * The audio format of the agent.
83
92
  */
@@ -3,6 +3,10 @@
3
3
  */
4
4
  export var UpdateAgentRequest;
5
5
  (function (UpdateAgentRequest) {
6
+ UpdateAgentRequest.PhoneNumber = {
7
+ AssignAutomatically: "assign-automatically",
8
+ Custom: "custom",
9
+ };
6
10
  UpdateAgentRequest.AudioFormat = {
7
11
  Pcm44100: "pcm_44100",
8
12
  Pcm16000: "pcm_16000",
@@ -767,14 +767,7 @@ export class Conversations {
767
767
  __sipOutboundCall(request, requestOptions) {
768
768
  return __awaiter(this, void 0, void 0, function* () {
769
769
  var _a, _b, _c, _d;
770
- const { token, downstream_websocket_url: downstreamWebsocketUrl, "X-Sip-Address": sipAddress, "X-Sip-Auth-Username": sipAuthUsername, "X-Sip-Auth-Password": sipAuthPassword } = request, _body = __rest(request, ["token", "downstream_websocket_url", "X-Sip-Address", "X-Sip-Auth-Username", "X-Sip-Auth-Password"]);
771
- const _queryParams = {};
772
- if (token != null) {
773
- _queryParams["token"] = token;
774
- }
775
- if (downstreamWebsocketUrl != null) {
776
- _queryParams["downstream_websocket_url"] = downstreamWebsocketUrl;
777
- }
770
+ const { "X-Sip-Address": sipAddress, "X-Sip-Auth-Username": sipAuthUsername, "X-Sip-Auth-Password": sipAuthPassword } = request, _body = __rest(request, ["X-Sip-Address", "X-Sip-Auth-Username", "X-Sip-Auth-Password"]);
778
771
  let _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders({
779
772
  Authorization: yield this._getAuthorizationHeader(),
780
773
  "X-Sip-Address": sipAddress,
@@ -787,7 +780,7 @@ export class Conversations {
787
780
  method: "POST",
788
781
  headers: _headers,
789
782
  contentType: "application/json",
790
- queryParameters: Object.assign(Object.assign({}, _queryParams), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams),
783
+ queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
791
784
  requestType: "json",
792
785
  body: _body,
793
786
  timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
@@ -11,10 +11,6 @@ import * as Phonic from "../../../../index.mjs";
11
11
  * }
12
12
  */
13
13
  export interface ConversationsSipOutboundCallRequest {
14
- /** Optional session token used for STS authorization. */
15
- token?: string;
16
- /** Optional downstream STS WebSocket URL to override the default. */
17
- downstream_websocket_url?: string;
18
14
  /** SIP address of the user's SIP trunk. Required. */
19
15
  "X-Sip-Address": string;
20
16
  /** SIP auth username, if your provider requires it. */
@@ -4,4 +4,6 @@
4
4
  export interface ConversationsSipOutboundCallResponse {
5
5
  /** The ID of the created conversation. */
6
6
  conversation_id: string;
7
+ /** The Twilio Call SID. */
8
+ twilio_call_sid: string;
7
9
  }
@@ -58,6 +58,23 @@ export declare class Tools {
58
58
  * @example
59
59
  * await client.tools.create({
60
60
  * project: "main",
61
+ * name: "context_printer",
62
+ * description: "Gets the specific context for fixing our printer",
63
+ * type: "custom_context",
64
+ * execution_mode: "sync",
65
+ * parameters: [{
66
+ * type: "string",
67
+ * name: "name",
68
+ * description: "description",
69
+ * is_required: true
70
+ * }],
71
+ * require_speech_before_tool_call: false,
72
+ * forbid_speech_after_tool_call: false
73
+ * })
74
+ *
75
+ * @example
76
+ * await client.tools.create({
77
+ * project: "main",
61
78
  * name: "book_appointment",
62
79
  * description: "Books an appointment in the calendar system",
63
80
  * type: "custom_webhook",
@@ -82,7 +99,8 @@ export declare class Tools {
82
99
  * "Content-Type": "application/json"
83
100
  * },
84
101
  * endpoint_timeout_ms: 5000,
85
- * require_speech_before_tool_call: false
102
+ * require_speech_before_tool_call: false,
103
+ * forbid_speech_after_tool_call: false
86
104
  * })
87
105
  *
88
106
  * @example
@@ -99,7 +117,8 @@ export declare class Tools {
99
117
  * is_required: true
100
118
  * }],
101
119
  * tool_call_output_timeout_ms: 5000,
102
- * require_speech_before_tool_call: false
120
+ * require_speech_before_tool_call: false,
121
+ * forbid_speech_after_tool_call: false
103
122
  * })
104
123
  *
105
124
  * @example
@@ -110,6 +110,23 @@ export class Tools {
110
110
  * @example
111
111
  * await client.tools.create({
112
112
  * project: "main",
113
+ * name: "context_printer",
114
+ * description: "Gets the specific context for fixing our printer",
115
+ * type: "custom_context",
116
+ * execution_mode: "sync",
117
+ * parameters: [{
118
+ * type: "string",
119
+ * name: "name",
120
+ * description: "description",
121
+ * is_required: true
122
+ * }],
123
+ * require_speech_before_tool_call: false,
124
+ * forbid_speech_after_tool_call: false
125
+ * })
126
+ *
127
+ * @example
128
+ * await client.tools.create({
129
+ * project: "main",
113
130
  * name: "book_appointment",
114
131
  * description: "Books an appointment in the calendar system",
115
132
  * type: "custom_webhook",
@@ -134,7 +151,8 @@ export class Tools {
134
151
  * "Content-Type": "application/json"
135
152
  * },
136
153
  * endpoint_timeout_ms: 5000,
137
- * require_speech_before_tool_call: false
154
+ * require_speech_before_tool_call: false,
155
+ * forbid_speech_after_tool_call: false
138
156
  * })
139
157
  *
140
158
  * @example
@@ -151,7 +169,8 @@ export class Tools {
151
169
  * is_required: true
152
170
  * }],
153
171
  * tool_call_output_timeout_ms: 5000,
154
- * require_speech_before_tool_call: false
172
+ * require_speech_before_tool_call: false,
173
+ * forbid_speech_after_tool_call: false
155
174
  * })
156
175
  *
157
176
  * @example
@@ -3,6 +3,23 @@
3
3
  */
4
4
  import * as Phonic from "../../../../index.mjs";
5
5
  /**
6
+ * @example
7
+ * {
8
+ * project: "main",
9
+ * name: "context_printer",
10
+ * description: "Gets the specific context for fixing our printer",
11
+ * type: "custom_context",
12
+ * execution_mode: "sync",
13
+ * parameters: [{
14
+ * type: "string",
15
+ * name: "name",
16
+ * description: "description",
17
+ * is_required: true
18
+ * }],
19
+ * require_speech_before_tool_call: false,
20
+ * forbid_speech_after_tool_call: false
21
+ * }
22
+ *
6
23
  * @example
7
24
  * {
8
25
  * project: "main",
@@ -30,7 +47,8 @@ import * as Phonic from "../../../../index.mjs";
30
47
  * "Content-Type": "application/json"
31
48
  * },
32
49
  * endpoint_timeout_ms: 5000,
33
- * require_speech_before_tool_call: false
50
+ * require_speech_before_tool_call: false,
51
+ * forbid_speech_after_tool_call: false
34
52
  * }
35
53
  *
36
54
  * @example
@@ -47,7 +65,8 @@ import * as Phonic from "../../../../index.mjs";
47
65
  * is_required: true
48
66
  * }],
49
67
  * tool_call_output_timeout_ms: 5000,
50
- * require_speech_before_tool_call: false
68
+ * require_speech_before_tool_call: false,
69
+ * forbid_speech_after_tool_call: false
51
70
  * }
52
71
  *
53
72
  * @example
@@ -109,13 +128,16 @@ export interface CreateToolRequest {
109
128
  agents_to_transfer_to?: string[];
110
129
  /** When true, forces the agent to speak before executing the tool. */
111
130
  require_speech_before_tool_call?: boolean;
131
+ /** When true, forbids the agent from speaking after executing the tool. Available for custom_context, custom_webhook and custom_websocket tools. */
132
+ forbid_speech_after_tool_call?: boolean;
112
133
  }
113
134
  export declare namespace CreateToolRequest {
114
135
  /**
115
136
  * The type of tool.
116
137
  */
117
- type Type = "custom_webhook" | "custom_websocket" | "built_in_transfer_to_phone_number" | "built_in_transfer_to_agent";
138
+ type Type = "custom_context" | "custom_webhook" | "custom_websocket" | "built_in_transfer_to_phone_number" | "built_in_transfer_to_agent";
118
139
  const Type: {
140
+ readonly CustomContext: "custom_context";
119
141
  readonly CustomWebhook: "custom_webhook";
120
142
  readonly CustomWebsocket: "custom_websocket";
121
143
  readonly BuiltInTransferToPhoneNumber: "built_in_transfer_to_phone_number";
@@ -4,6 +4,7 @@
4
4
  export var CreateToolRequest;
5
5
  (function (CreateToolRequest) {
6
6
  CreateToolRequest.Type = {
7
+ CustomContext: "custom_context",
7
8
  CustomWebhook: "custom_webhook",
8
9
  CustomWebsocket: "custom_websocket",
9
10
  BuiltInTransferToPhoneNumber: "built_in_transfer_to_phone_number",
@@ -21,6 +21,11 @@
21
21
  * {
22
22
  * project: "main"
23
23
  * }
24
+ *
25
+ * @example
26
+ * {
27
+ * project: "main"
28
+ * }
24
29
  */
25
30
  export interface ToolsGetRequest {
26
31
  /** The name of the project containing the tool. Only used when `nameOrId` is a name. */
@@ -45,13 +45,16 @@ export interface UpdateToolRequest {
45
45
  agents_to_transfer_to?: string[];
46
46
  /** When true, forces the agent to speak before executing the tool. */
47
47
  require_speech_before_tool_call?: boolean;
48
+ /** When true, forbids the agent from speaking after executing the tool. Available for custom_context, custom_webhook and custom_websocket tools. */
49
+ forbid_speech_after_tool_call?: boolean;
48
50
  }
49
51
  export declare namespace UpdateToolRequest {
50
52
  /**
51
53
  * The type of tool.
52
54
  */
53
- type Type = "custom_webhook" | "custom_websocket" | "built_in_transfer_to_phone_number" | "built_in_transfer_to_agent";
55
+ type Type = "custom_context" | "custom_webhook" | "custom_websocket" | "built_in_transfer_to_phone_number" | "built_in_transfer_to_agent";
54
56
  const Type: {
57
+ readonly CustomContext: "custom_context";
55
58
  readonly CustomWebhook: "custom_webhook";
56
59
  readonly CustomWebsocket: "custom_websocket";
57
60
  readonly BuiltInTransferToPhoneNumber: "built_in_transfer_to_phone_number";
@@ -4,6 +4,7 @@
4
4
  export var UpdateToolRequest;
5
5
  (function (UpdateToolRequest) {
6
6
  UpdateToolRequest.Type = {
7
+ CustomContext: "custom_context",
7
8
  CustomWebhook: "custom_webhook",
8
9
  CustomWebsocket: "custom_websocket",
9
10
  BuiltInTransferToPhoneNumber: "built_in_transfer_to_phone_number",
@@ -7,8 +7,10 @@ export interface Agent {
7
7
  id: string;
8
8
  /** The name of the agent. */
9
9
  name: string;
10
- /** The phone number that the agent uses to accept and initiate phone calls. `null` if the agent is not associated with a phone number, in which can the agent can be used via WebSockets. */
10
+ /** The phone number that the agent uses to accept calls. `null` if the agent is not associated with a phone number, in which can the agent can be used via WebSockets. This field is deprecated. Use `phone_numbers` instead. */
11
11
  phone_number: string | null;
12
+ /** Array of phone numbers that the agent uses to accept phone calls. */
13
+ phone_numbers: string[];
12
14
  /** The project the agent belongs to. */
13
15
  project: Agent.Project;
14
16
  /** The timezone of the agent. Used to format system variables like `{{system_time}}`. */
@@ -55,6 +55,8 @@ export interface Conversation {
55
55
  task_results: Record<string, unknown>;
56
56
  /** Array of conversation items (turns). */
57
57
  items: Phonic.ConversationItem[];
58
+ /** Phone call metadata. `null` for non-phone call conversations. */
59
+ call_info: Conversation.CallInfo | null;
58
60
  }
59
61
  export declare namespace Conversation {
60
62
  /**
@@ -97,4 +99,15 @@ export declare namespace Conversation {
97
99
  readonly Assistant: "assistant";
98
100
  readonly Error: "error";
99
101
  };
102
+ /**
103
+ * Phone call metadata. `null` for non-phone call conversations.
104
+ */
105
+ interface CallInfo {
106
+ /** Caller phone number in E.164 format. */
107
+ from_phone_number: string;
108
+ /** Callee phone number in E.164 format. */
109
+ to_phone_number: string;
110
+ /** Twilio Call SID. Only present for user SIP trunking calls. */
111
+ twilio_call_sid?: string;
112
+ }
100
113
  }
@@ -5,7 +5,11 @@ import * as Phonic from "../index.mjs";
5
5
  export interface CreateAgentRequest {
6
6
  /** The name of the agent. Can only contain lowercase letters, numbers and hyphens. Must be unique within the project. */
7
7
  name: string;
8
- phone_number: "assign-automatically" | null;
8
+ phone_number: CreateAgentRequest.PhoneNumber | null;
9
+ /** The custom phone number to use for the agent in E.164 format (e.g., +1234567890). This field is deprecated. Use `custom_phone_numbers` instead. */
10
+ custom_phone_number?: string | null;
11
+ /** Array of custom phone numbers in E.164 format (e.g., ["+1234567890", "+0987654321"]). The agent will be able to receive phone calls on any of these numbers. Required when `phone_number` is set to `"custom"`. All phone numbers must be unique. */
12
+ custom_phone_numbers?: string[];
9
13
  /** The timezone of the agent. Used to format system variables like `{{system_time}}`. */
10
14
  timezone?: string;
11
15
  /** The voice ID to use. */
@@ -42,6 +46,11 @@ export interface CreateAgentRequest {
42
46
  configuration_endpoint?: CreateAgentRequest.ConfigurationEndpoint | null;
43
47
  }
44
48
  export declare namespace CreateAgentRequest {
49
+ type PhoneNumber = "assign-automatically" | "custom";
50
+ const PhoneNumber: {
51
+ readonly AssignAutomatically: "assign-automatically";
52
+ readonly Custom: "custom";
53
+ };
45
54
  /**
46
55
  * The audio format of the agent.
47
56
  */
@@ -3,6 +3,10 @@
3
3
  */
4
4
  export var CreateAgentRequest;
5
5
  (function (CreateAgentRequest) {
6
+ CreateAgentRequest.PhoneNumber = {
7
+ AssignAutomatically: "assign-automatically",
8
+ Custom: "custom",
9
+ };
6
10
  CreateAgentRequest.AudioFormat = {
7
11
  Pcm44100: "pcm_44100",
8
12
  Pcm16000: "pcm_16000",
@@ -34,6 +34,8 @@ export interface Tool {
34
34
  agents_to_transfer_to?: string[];
35
35
  /** When true, forces the agent to speak before executing the tool. */
36
36
  require_speech_before_tool_call?: boolean;
37
+ /** When true, forbids the agent from speaking after executing the tool. Available for custom_context, custom_webhook and custom_websocket tools. */
38
+ forbid_speech_after_tool_call?: boolean;
37
39
  }
38
40
  export declare namespace Tool {
39
41
  interface Project {
@@ -43,8 +45,9 @@ export declare namespace Tool {
43
45
  /**
44
46
  * The type of tool.
45
47
  */
46
- type Type = "custom_webhook" | "custom_websocket" | "built_in_transfer_to_phone_number" | "built_in_transfer_to_agent";
48
+ type Type = "custom_context" | "custom_webhook" | "custom_websocket" | "built_in_transfer_to_phone_number" | "built_in_transfer_to_agent";
47
49
  const Type: {
50
+ readonly CustomContext: "custom_context";
48
51
  readonly CustomWebhook: "custom_webhook";
49
52
  readonly CustomWebsocket: "custom_websocket";
50
53
  readonly BuiltInTransferToPhoneNumber: "built_in_transfer_to_phone_number";
@@ -4,6 +4,7 @@
4
4
  export var Tool;
5
5
  (function (Tool) {
6
6
  Tool.Type = {
7
+ CustomContext: "custom_context",
7
8
  CustomWebhook: "custom_webhook",
8
9
  CustomWebsocket: "custom_websocket",
9
10
  BuiltInTransferToPhoneNumber: "built_in_transfer_to_phone_number",
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "0.30.18";
1
+ export declare const SDK_VERSION = "0.30.20";
@@ -1 +1 @@
1
- export const SDK_VERSION = "0.30.18";
1
+ export const SDK_VERSION = "0.30.20";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "phonic",
3
- "version": "0.30.18",
3
+ "version": "0.30.20",
4
4
  "private": false,
5
5
  "repository": "github:Phonic-Co/phonic-node",
6
6
  "type": "commonjs",
package/reference.md CHANGED
@@ -595,34 +595,20 @@ Creates a new tool in a project.
595
595
  ```typescript
596
596
  await client.tools.create({
597
597
  project: "main",
598
- name: "book_appointment",
599
- description: "Books an appointment in the calendar system",
600
- type: "custom_webhook",
598
+ name: "context_printer",
599
+ description: "Gets the specific context for fixing our printer",
600
+ type: "custom_context",
601
601
  execution_mode: "sync",
602
602
  parameters: [
603
603
  {
604
604
  type: "string",
605
- name: "date",
606
- description: "The date for the appointment in YYYY-MM-DD format",
605
+ name: "name",
606
+ description: "description",
607
607
  is_required: true,
608
- location: "request_body",
609
- },
610
- {
611
- type: "string",
612
- name: "time",
613
- description: "The time for the appointment in HH:MM format",
614
- is_required: true,
615
- location: "request_body",
616
608
  },
617
609
  ],
618
- endpoint_method: "POST",
619
- endpoint_url: "https://api.example.com/book-appointment",
620
- endpoint_headers: {
621
- Authorization: "Bearer token123",
622
- "Content-Type": "application/json",
623
- },
624
- endpoint_timeout_ms: 5000,
625
610
  require_speech_before_tool_call: false,
611
+ forbid_speech_after_tool_call: false,
626
612
  });
627
613
  ```
628
614