phonic 0.30.4 → 0.30.6

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.
@@ -58,31 +58,29 @@ export declare class Agents {
58
58
  * @example
59
59
  * await client.agents.create({
60
60
  * project: "main",
61
- * body: {
62
- * name: "support-agent",
63
- * phone_number: "assign-automatically",
64
- * timezone: "America/Los_Angeles",
65
- * voice_id: "grant",
66
- * audio_speed: 1,
67
- * welcome_message: "Hi {{customer_name}}. How can I help you today?",
68
- * system_prompt: "You are an expert in {{subject}}. Be friendly, helpful and concise.",
69
- * template_variables: {
70
- * "customer_name": {},
71
- * "subject": {
72
- * default_value: "Chess"
73
- * }
74
- * },
75
- * tools: ["keypad_input"],
76
- * no_input_poke_sec: 30,
77
- * no_input_poke_text: "Are you still there?",
78
- * boosted_keywords: ["Load ID", "dispatch"],
79
- * configuration_endpoint: {
80
- * url: "https://api.example.com/config",
81
- * headers: {
82
- * "Authorization": "Bearer token123"
83
- * },
84
- * timeout_ms: 7000
61
+ * name: "support-agent",
62
+ * phone_number: "assign-automatically",
63
+ * timezone: "America/Los_Angeles",
64
+ * voice_id: "grant",
65
+ * audio_speed: 1,
66
+ * welcome_message: "Hi {{customer_name}}. How can I help you today?",
67
+ * system_prompt: "You are an expert in {{subject}}. Be friendly, helpful and concise.",
68
+ * template_variables: {
69
+ * "customer_name": {},
70
+ * "subject": {
71
+ * default_value: "Chess"
85
72
  * }
73
+ * },
74
+ * tools: ["keypad_input"],
75
+ * no_input_poke_sec: 30,
76
+ * no_input_poke_text: "Are you still there?",
77
+ * boosted_keywords: ["Load ID", "dispatch"],
78
+ * configuration_endpoint: {
79
+ * url: "https://api.example.com/config",
80
+ * headers: {
81
+ * "Authorization": "Bearer token123"
82
+ * },
83
+ * timeout_ms: 7000
86
84
  * }
87
85
  * })
88
86
  */
@@ -112,31 +112,29 @@ export class Agents {
112
112
  * @example
113
113
  * await client.agents.create({
114
114
  * project: "main",
115
- * body: {
116
- * name: "support-agent",
117
- * phone_number: "assign-automatically",
118
- * timezone: "America/Los_Angeles",
119
- * voice_id: "grant",
120
- * audio_speed: 1,
121
- * welcome_message: "Hi {{customer_name}}. How can I help you today?",
122
- * system_prompt: "You are an expert in {{subject}}. Be friendly, helpful and concise.",
123
- * template_variables: {
124
- * "customer_name": {},
125
- * "subject": {
126
- * default_value: "Chess"
127
- * }
128
- * },
129
- * tools: ["keypad_input"],
130
- * no_input_poke_sec: 30,
131
- * no_input_poke_text: "Are you still there?",
132
- * boosted_keywords: ["Load ID", "dispatch"],
133
- * configuration_endpoint: {
134
- * url: "https://api.example.com/config",
135
- * headers: {
136
- * "Authorization": "Bearer token123"
137
- * },
138
- * timeout_ms: 7000
115
+ * name: "support-agent",
116
+ * phone_number: "assign-automatically",
117
+ * timezone: "America/Los_Angeles",
118
+ * voice_id: "grant",
119
+ * audio_speed: 1,
120
+ * welcome_message: "Hi {{customer_name}}. How can I help you today?",
121
+ * system_prompt: "You are an expert in {{subject}}. Be friendly, helpful and concise.",
122
+ * template_variables: {
123
+ * "customer_name": {},
124
+ * "subject": {
125
+ * default_value: "Chess"
139
126
  * }
127
+ * },
128
+ * tools: ["keypad_input"],
129
+ * no_input_poke_sec: 30,
130
+ * no_input_poke_text: "Are you still there?",
131
+ * boosted_keywords: ["Load ID", "dispatch"],
132
+ * configuration_endpoint: {
133
+ * url: "https://api.example.com/config",
134
+ * headers: {
135
+ * "Authorization": "Bearer token123"
136
+ * },
137
+ * timeout_ms: 7000
140
138
  * }
141
139
  * })
142
140
  */
@@ -146,7 +144,7 @@ export class Agents {
146
144
  __create(request, requestOptions) {
147
145
  return __awaiter(this, void 0, void 0, function* () {
148
146
  var _a, _b, _c, _d;
149
- const { project, body: _body } = request;
147
+ const { project } = request, _body = __rest(request, ["project"]);
150
148
  const _queryParams = {};
151
149
  if (project != null) {
152
150
  _queryParams["project"] = project;
@@ -6,36 +6,64 @@ import * as Phonic from "../../../../index.mjs";
6
6
  * @example
7
7
  * {
8
8
  * project: "main",
9
- * body: {
10
- * name: "support-agent",
11
- * phone_number: "assign-automatically",
12
- * timezone: "America/Los_Angeles",
13
- * voice_id: "grant",
14
- * audio_speed: 1,
15
- * welcome_message: "Hi {{customer_name}}. How can I help you today?",
16
- * system_prompt: "You are an expert in {{subject}}. Be friendly, helpful and concise.",
17
- * template_variables: {
18
- * "customer_name": {},
19
- * "subject": {
20
- * default_value: "Chess"
21
- * }
22
- * },
23
- * tools: ["keypad_input"],
24
- * no_input_poke_sec: 30,
25
- * no_input_poke_text: "Are you still there?",
26
- * boosted_keywords: ["Load ID", "dispatch"],
27
- * configuration_endpoint: {
28
- * url: "https://api.example.com/config",
29
- * headers: {
30
- * "Authorization": "Bearer token123"
31
- * },
32
- * timeout_ms: 7000
9
+ * name: "support-agent",
10
+ * phone_number: "assign-automatically",
11
+ * timezone: "America/Los_Angeles",
12
+ * voice_id: "grant",
13
+ * audio_speed: 1,
14
+ * welcome_message: "Hi {{customer_name}}. How can I help you today?",
15
+ * system_prompt: "You are an expert in {{subject}}. Be friendly, helpful and concise.",
16
+ * template_variables: {
17
+ * "customer_name": {},
18
+ * "subject": {
19
+ * default_value: "Chess"
33
20
  * }
21
+ * },
22
+ * tools: ["keypad_input"],
23
+ * no_input_poke_sec: 30,
24
+ * no_input_poke_text: "Are you still there?",
25
+ * boosted_keywords: ["Load ID", "dispatch"],
26
+ * configuration_endpoint: {
27
+ * url: "https://api.example.com/config",
28
+ * headers: {
29
+ * "Authorization": "Bearer token123"
30
+ * },
31
+ * timeout_ms: 7000
34
32
  * }
35
33
  * }
36
34
  */
37
35
  export interface AgentsCreateRequest {
38
36
  /** The name of the project to create the agent in. */
39
37
  project?: string;
40
- body: Phonic.CreateAgentRequest;
38
+ /** The name of the agent. Can only contain lowercase letters, numbers and hyphens. Must be unique within the project. */
39
+ name: string;
40
+ phone_number?: "assign-automatically";
41
+ /** The timezone of the agent. Used to format system variables like `{{system_time}}`. */
42
+ timezone?: string;
43
+ /** The voice ID to use. */
44
+ voice_id?: string;
45
+ /** The audio format of the agent. */
46
+ audio_format?: Phonic.CreateAgentRequest.AudioFormat;
47
+ /** The audio speed of the agent. */
48
+ audio_speed?: number;
49
+ /** Message to play when the conversation starts. Can contain template variables like `{{customer_name}}`. */
50
+ welcome_message?: string;
51
+ /** Instructions for the conversation. Can contain template variables like `{{subject}}`. */
52
+ system_prompt?: string;
53
+ /** Variables that can be used in the welcome message and the system prompt. */
54
+ template_variables?: Record<string, Phonic.CreateAgentRequest.TemplateVariables.Value>;
55
+ /** Array of built-in or custom tool names to use. */
56
+ tools?: Phonic.CreateAgentRequest.Tools.Item[];
57
+ /** Array of task objects with `name` and `description` fields. */
58
+ tasks?: Phonic.Task[];
59
+ /** Number of seconds of silence before sending a poke message. `null` disables the poke message. */
60
+ no_input_poke_sec?: number;
61
+ /** The message to send after the specified silence. */
62
+ no_input_poke_text?: string;
63
+ /** Seconds of silence before ending the conversation. */
64
+ no_input_end_conversation_sec?: number;
65
+ /** These words, or short phrases, will be more accurately recognized by the agent. */
66
+ boosted_keywords?: string[];
67
+ /** When not `null`, at the beginning of the conversation the agent will make a POST request to this endpoint when to get configuration options. */
68
+ configuration_endpoint?: Phonic.CreateAgentRequest.ConfigurationEndpoint;
41
69
  }
@@ -201,7 +201,7 @@ export declare class Conversations {
201
201
  * "customer_name": "David",
202
202
  * "subject": "Chess"
203
203
  * },
204
- * voice_id: "sarah",
204
+ * voice_id: "grant",
205
205
  * no_input_poke_sec: 30,
206
206
  * no_input_poke_text: "Are you still there?",
207
207
  * no_input_end_conversation_sec: 180,
@@ -81,11 +81,12 @@ export class Conversations {
81
81
  if (limit != null) {
82
82
  _queryParams["limit"] = limit.toString();
83
83
  }
84
- const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
85
- url: core.url.join((_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : ((_c = (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.PhonicEnvironment.Default)
84
+ let _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
85
+ const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
86
+ url: core.url.join((_c = (yield core.Supplier.get(this._options.baseUrl))) !== null && _c !== void 0 ? _c : ((_d = (yield core.Supplier.get(this._options.environment))) !== null && _d !== void 0 ? _d : environments.PhonicEnvironment.Default)
86
87
  .base, "conversations"),
87
88
  method: "GET",
88
- headers: mergeHeaders((_d = this._options) === null || _d === void 0 ? void 0 : _d.headers, mergeOnlyDefinedHeaders({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
89
+ headers: _headers,
89
90
  queryParameters: Object.assign(Object.assign({}, _queryParams), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams),
90
91
  timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
91
92
  maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
@@ -151,11 +152,12 @@ export class Conversations {
151
152
  __get(id, requestOptions) {
152
153
  return __awaiter(this, void 0, void 0, function* () {
153
154
  var _a, _b, _c, _d;
154
- const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
155
- url: core.url.join((_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : ((_c = (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.PhonicEnvironment.Default)
155
+ let _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
156
+ const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
157
+ url: core.url.join((_c = (yield core.Supplier.get(this._options.baseUrl))) !== null && _c !== void 0 ? _c : ((_d = (yield core.Supplier.get(this._options.environment))) !== null && _d !== void 0 ? _d : environments.PhonicEnvironment.Default)
156
158
  .base, `conversations/${encodeURIComponent(id)}`),
157
159
  method: "GET",
158
- headers: mergeHeaders((_d = this._options) === null || _d === void 0 ? void 0 : _d.headers, mergeOnlyDefinedHeaders({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
160
+ headers: _headers,
159
161
  queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
160
162
  timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
161
163
  maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
@@ -221,11 +223,12 @@ export class Conversations {
221
223
  __cancel(id, requestOptions) {
222
224
  return __awaiter(this, void 0, void 0, function* () {
223
225
  var _a, _b, _c, _d;
224
- const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
225
- url: core.url.join((_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : ((_c = (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.PhonicEnvironment.Default)
226
+ let _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
227
+ const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
228
+ url: core.url.join((_c = (yield core.Supplier.get(this._options.baseUrl))) !== null && _c !== void 0 ? _c : ((_d = (yield core.Supplier.get(this._options.environment))) !== null && _d !== void 0 ? _d : environments.PhonicEnvironment.Default)
226
229
  .base, `conversations/${encodeURIComponent(id)}/cancel`),
227
230
  method: "POST",
228
- headers: mergeHeaders((_d = this._options) === null || _d === void 0 ? void 0 : _d.headers, mergeOnlyDefinedHeaders({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
231
+ headers: _headers,
229
232
  queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
230
233
  timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
231
234
  maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
@@ -293,11 +296,12 @@ export class Conversations {
293
296
  __getAnalysis(id, requestOptions) {
294
297
  return __awaiter(this, void 0, void 0, function* () {
295
298
  var _a, _b, _c, _d;
296
- const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
297
- url: core.url.join((_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : ((_c = (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.PhonicEnvironment.Default)
299
+ let _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
300
+ const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
301
+ url: core.url.join((_c = (yield core.Supplier.get(this._options.baseUrl))) !== null && _c !== void 0 ? _c : ((_d = (yield core.Supplier.get(this._options.environment))) !== null && _d !== void 0 ? _d : environments.PhonicEnvironment.Default)
298
302
  .base, `conversations/${encodeURIComponent(id)}/analysis`),
299
303
  method: "GET",
300
- headers: mergeHeaders((_d = this._options) === null || _d === void 0 ? void 0 : _d.headers, mergeOnlyDefinedHeaders({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
304
+ headers: _headers,
301
305
  queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
302
306
  timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
303
307
  maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
@@ -364,11 +368,12 @@ export class Conversations {
364
368
  __listExtractions(id, requestOptions) {
365
369
  return __awaiter(this, void 0, void 0, function* () {
366
370
  var _a, _b, _c, _d;
367
- const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
368
- url: core.url.join((_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : ((_c = (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.PhonicEnvironment.Default)
371
+ let _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
372
+ const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
373
+ url: core.url.join((_c = (yield core.Supplier.get(this._options.baseUrl))) !== null && _c !== void 0 ? _c : ((_d = (yield core.Supplier.get(this._options.environment))) !== null && _d !== void 0 ? _d : environments.PhonicEnvironment.Default)
369
374
  .base, `conversations/${encodeURIComponent(id)}/extractions`),
370
375
  method: "GET",
371
- headers: mergeHeaders((_d = this._options) === null || _d === void 0 ? void 0 : _d.headers, mergeOnlyDefinedHeaders({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
376
+ headers: _headers,
372
377
  queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
373
378
  timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
374
379
  maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
@@ -439,11 +444,12 @@ export class Conversations {
439
444
  __extractData(id, request, requestOptions) {
440
445
  return __awaiter(this, void 0, void 0, function* () {
441
446
  var _a, _b, _c, _d;
442
- const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
443
- url: core.url.join((_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : ((_c = (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.PhonicEnvironment.Default)
447
+ let _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
448
+ const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
449
+ url: core.url.join((_c = (yield core.Supplier.get(this._options.baseUrl))) !== null && _c !== void 0 ? _c : ((_d = (yield core.Supplier.get(this._options.environment))) !== null && _d !== void 0 ? _d : environments.PhonicEnvironment.Default)
444
450
  .base, `conversations/${encodeURIComponent(id)}/extractions`),
445
451
  method: "POST",
446
- headers: mergeHeaders((_d = this._options) === null || _d === void 0 ? void 0 : _d.headers, mergeOnlyDefinedHeaders({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
452
+ headers: _headers,
447
453
  contentType: "application/json",
448
454
  queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
449
455
  requestType: "json",
@@ -515,11 +521,12 @@ export class Conversations {
515
521
  __listEvaluations(id, requestOptions) {
516
522
  return __awaiter(this, void 0, void 0, function* () {
517
523
  var _a, _b, _c, _d;
518
- const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
519
- url: core.url.join((_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : ((_c = (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.PhonicEnvironment.Default)
524
+ let _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
525
+ const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
526
+ url: core.url.join((_c = (yield core.Supplier.get(this._options.baseUrl))) !== null && _c !== void 0 ? _c : ((_d = (yield core.Supplier.get(this._options.environment))) !== null && _d !== void 0 ? _d : environments.PhonicEnvironment.Default)
520
527
  .base, `conversations/${encodeURIComponent(id)}/evals`),
521
528
  method: "GET",
522
- headers: mergeHeaders((_d = this._options) === null || _d === void 0 ? void 0 : _d.headers, mergeOnlyDefinedHeaders({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
529
+ headers: _headers,
523
530
  queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
524
531
  timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
525
532
  maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
@@ -590,11 +597,12 @@ export class Conversations {
590
597
  __evaluate(id, request, requestOptions) {
591
598
  return __awaiter(this, void 0, void 0, function* () {
592
599
  var _a, _b, _c, _d;
593
- const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
594
- url: core.url.join((_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : ((_c = (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.PhonicEnvironment.Default)
600
+ let _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
601
+ const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
602
+ url: core.url.join((_c = (yield core.Supplier.get(this._options.baseUrl))) !== null && _c !== void 0 ? _c : ((_d = (yield core.Supplier.get(this._options.environment))) !== null && _d !== void 0 ? _d : environments.PhonicEnvironment.Default)
595
603
  .base, `conversations/${encodeURIComponent(id)}/evals`),
596
604
  method: "POST",
597
- headers: mergeHeaders((_d = this._options) === null || _d === void 0 ? void 0 : _d.headers, mergeOnlyDefinedHeaders({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
605
+ headers: _headers,
598
606
  contentType: "application/json",
599
607
  queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
600
608
  requestType: "json",
@@ -665,7 +673,7 @@ export class Conversations {
665
673
  * "customer_name": "David",
666
674
  * "subject": "Chess"
667
675
  * },
668
- * voice_id: "sarah",
676
+ * voice_id: "grant",
669
677
  * no_input_poke_sec: 30,
670
678
  * no_input_poke_text: "Are you still there?",
671
679
  * no_input_end_conversation_sec: 180,
@@ -680,11 +688,12 @@ export class Conversations {
680
688
  __outboundCall(request, requestOptions) {
681
689
  return __awaiter(this, void 0, void 0, function* () {
682
690
  var _a, _b, _c, _d;
683
- const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
684
- url: core.url.join((_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : ((_c = (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.PhonicEnvironment.Default)
691
+ let _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
692
+ const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
693
+ url: core.url.join((_c = (yield core.Supplier.get(this._options.baseUrl))) !== null && _c !== void 0 ? _c : ((_d = (yield core.Supplier.get(this._options.environment))) !== null && _d !== void 0 ? _d : environments.PhonicEnvironment.Default)
685
694
  .base, "conversations/outbound_call"),
686
695
  method: "POST",
687
- headers: mergeHeaders((_d = this._options) === null || _d === void 0 ? void 0 : _d.headers, mergeOnlyDefinedHeaders({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
696
+ headers: _headers,
688
697
  contentType: "application/json",
689
698
  queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
690
699
  requestType: "json",
@@ -765,16 +774,17 @@ export class Conversations {
765
774
  if (downstreamWebsocketUrl != null) {
766
775
  _queryParams["downstream_websocket_url"] = downstreamWebsocketUrl;
767
776
  }
768
- const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
769
- url: core.url.join((_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : ((_c = (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.PhonicEnvironment.Default)
777
+ let _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders({
778
+ Authorization: yield this._getAuthorizationHeader(),
779
+ "X-Sip-Address": sipAddress,
780
+ "X-Sip-Auth-Username": sipAuthUsername != null ? sipAuthUsername : undefined,
781
+ "X-Sip-Auth-Password": sipAuthPassword != null ? sipAuthPassword : undefined,
782
+ }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
783
+ const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
784
+ url: core.url.join((_c = (yield core.Supplier.get(this._options.baseUrl))) !== null && _c !== void 0 ? _c : ((_d = (yield core.Supplier.get(this._options.environment))) !== null && _d !== void 0 ? _d : environments.PhonicEnvironment.Default)
770
785
  .base, "conversations/sip/outbound_call"),
771
786
  method: "POST",
772
- headers: mergeHeaders((_d = this._options) === null || _d === void 0 ? void 0 : _d.headers, mergeOnlyDefinedHeaders({
773
- Authorization: yield this._getAuthorizationHeader(),
774
- "X-Sip-Address": sipAddress,
775
- "X-Sip-Auth-Username": sipAuthUsername != null ? sipAuthUsername : undefined,
776
- "X-Sip-Auth-Password": sipAuthPassword != null ? sipAuthPassword : undefined,
777
- }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
787
+ headers: _headers,
778
788
  contentType: "application/json",
779
789
  queryParameters: Object.assign(Object.assign({}, _queryParams), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams),
780
790
  requestType: "json",
@@ -830,8 +840,7 @@ export class Conversations {
830
840
  if (downstream_websocket_url != null) {
831
841
  _queryParams["downstream_websocket_url"] = downstream_websocket_url;
832
842
  }
833
- let _headers = Object.assign({}, headers);
834
- _headers["Authorization"] = yield this._getAuthorizationHeader();
843
+ let _headers = mergeHeaders(mergeOnlyDefinedHeaders({ Authorization: yield this._getAuthorizationHeader() }), headers);
835
844
  const socket = new core.ReconnectingWebSocket({
836
845
  url: 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)
837
846
  .production, "/v1/sts/ws"),
@@ -9,12 +9,16 @@ export interface Conversation {
9
9
  agent?: Conversation.Agent;
10
10
  /** The organization/workspace name. */
11
11
  workspace: string;
12
+ /** The project associated with the conversation. */
13
+ project: Conversation.Project;
12
14
  /** External ID for conversation tracking. */
13
15
  external_id?: string;
14
16
  /** The STS model used. */
15
17
  model: string;
16
18
  /** Welcome message played at start. */
17
19
  welcome_message?: string;
20
+ /** Template variables used in the conversation. */
21
+ template_variables: Record<string, string>;
18
22
  /** Audio input format. */
19
23
  input_format: string;
20
24
  /** Audio output format. */
@@ -31,8 +35,6 @@ export interface Conversation {
31
35
  started_at: string;
32
36
  /** When the conversation ended. */
33
37
  ended_at?: string;
34
- /** System prompt used for the conversation. */
35
- system_prompt: string;
36
38
  /** Array of conversation items (turns). */
37
39
  items: Phonic.ConversationItem[];
38
40
  /** Results from conversation evaluations and extractions. */
@@ -47,5 +49,16 @@ export declare namespace Conversation {
47
49
  id: string;
48
50
  /** The name of the agent. */
49
51
  name: string;
52
+ /** Whether the agent has been deleted. */
53
+ is_deleted: boolean;
54
+ }
55
+ /**
56
+ * The project associated with the conversation.
57
+ */
58
+ interface Project {
59
+ /** The ID of the project. */
60
+ id: string;
61
+ /** The name of the project. */
62
+ name: string;
50
63
  }
51
64
  }
@@ -18,6 +18,10 @@ export interface ConversationItem {
18
18
  voice_id?: string;
19
19
  /** Audio speed used (assistant only). */
20
20
  audio_speed?: number;
21
+ /** System prompt used for this assistant turn. */
22
+ system_prompt?: string;
23
+ /** Tool calls made by the assistant. */
24
+ tool_calls?: ConversationItem.ToolCalls.Item[];
21
25
  }
22
26
  export declare namespace ConversationItem {
23
27
  /**
@@ -28,4 +32,44 @@ export declare namespace ConversationItem {
28
32
  readonly User: "user";
29
33
  readonly Assistant: "assistant";
30
34
  };
35
+ type ToolCalls = ToolCalls.Item[];
36
+ namespace ToolCalls {
37
+ interface Item {
38
+ /** The tool call ID. */
39
+ id: string;
40
+ tool: Item.Tool;
41
+ /** HTTP method for webhook tool calls. */
42
+ endpoint_method?: string;
43
+ /** URL for webhook tool calls. */
44
+ endpoint_url?: string;
45
+ /** Headers for webhook tool calls. */
46
+ endpoint_headers?: Record<string, string | undefined>;
47
+ /** Timeout in milliseconds for webhook tool calls. */
48
+ endpoint_timeout_ms?: number;
49
+ /** When the webhook endpoint was called (null on error). */
50
+ endpoint_called_at?: string;
51
+ /** Query parameters for webhook tool calls (null on error or when no params). */
52
+ query_params?: Record<string, unknown>;
53
+ /** HTTP response status code for webhook tool calls (null on error). */
54
+ response_status_code?: number;
55
+ /** Timeout in milliseconds for websocket tool calls. */
56
+ tool_call_output_timeout_ms?: number;
57
+ /** The request body sent to the tool. */
58
+ request_body?: Record<string, unknown>;
59
+ /** The response body received from the tool. */
60
+ response_body?: Record<string, unknown>;
61
+ /** Whether the tool call timed out. */
62
+ timed_out?: boolean;
63
+ /** Error message if the tool call failed. */
64
+ error_message?: string;
65
+ }
66
+ namespace Item {
67
+ interface Tool {
68
+ /** The tool ID. */
69
+ id: string;
70
+ /** The tool name. */
71
+ name: string;
72
+ }
73
+ }
74
+ }
31
75
  }
@@ -7,7 +7,7 @@ export declare namespace ReconnectingWebSocket {
7
7
  url: string;
8
8
  protocols?: string | string[];
9
9
  options?: ReconnectingWebSocket.Options;
10
- headers?: Record<string, string>;
10
+ headers?: Record<string, any>;
11
11
  queryParameters?: Record<string, string | string[] | object | object[] | null | undefined>;
12
12
  }
13
13
  type Options = {
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "0.30.4";
1
+ export declare const SDK_VERSION = "0.30.6";
@@ -1 +1 @@
1
- export const SDK_VERSION = "0.30.4";
1
+ export const SDK_VERSION = "0.30.6";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "phonic",
3
- "version": "0.30.4",
3
+ "version": "0.30.6",
4
4
  "private": false,
5
5
  "repository": "github:Phonic-Co/phonic-node",
6
6
  "type": "commonjs",
package/reference.md CHANGED
@@ -95,31 +95,29 @@ Creates a new agent in a project.
95
95
  ```typescript
96
96
  await client.agents.create({
97
97
  project: "main",
98
- body: {
99
- name: "support-agent",
100
- phone_number: "assign-automatically",
101
- timezone: "America/Los_Angeles",
102
- voice_id: "grant",
103
- audio_speed: 1,
104
- welcome_message: "Hi {{customer_name}}. How can I help you today?",
105
- system_prompt: "You are an expert in {{subject}}. Be friendly, helpful and concise.",
106
- template_variables: {
107
- customer_name: {},
108
- subject: {
109
- default_value: "Chess",
110
- },
98
+ name: "support-agent",
99
+ phone_number: "assign-automatically",
100
+ timezone: "America/Los_Angeles",
101
+ voice_id: "grant",
102
+ audio_speed: 1,
103
+ welcome_message: "Hi {{customer_name}}. How can I help you today?",
104
+ system_prompt: "You are an expert in {{subject}}. Be friendly, helpful and concise.",
105
+ template_variables: {
106
+ customer_name: {},
107
+ subject: {
108
+ default_value: "Chess",
111
109
  },
112
- tools: ["keypad_input"],
113
- no_input_poke_sec: 30,
114
- no_input_poke_text: "Are you still there?",
115
- boosted_keywords: ["Load ID", "dispatch"],
116
- configuration_endpoint: {
117
- url: "https://api.example.com/config",
118
- headers: {
119
- Authorization: "Bearer token123",
120
- },
121
- timeout_ms: 7000,
110
+ },
111
+ tools: ["keypad_input"],
112
+ no_input_poke_sec: 30,
113
+ no_input_poke_text: "Are you still there?",
114
+ boosted_keywords: ["Load ID", "dispatch"],
115
+ configuration_endpoint: {
116
+ url: "https://api.example.com/config",
117
+ headers: {
118
+ Authorization: "Bearer token123",
122
119
  },
120
+ timeout_ms: 7000,
123
121
  },
124
122
  });
125
123
  ```