@getsupervisor/agents-studio-sdk 1.2.0 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -25,60 +25,23 @@ __export(index_exports, {
25
25
  bindAgentInstructions: () => bindAgentInstructions,
26
26
  bindAgentKnowledge: () => bindAgentKnowledge,
27
27
  bindAgentPhones: () => bindAgentPhones,
28
+ bindAgentSchedule: () => bindAgentSchedule,
29
+ bindAgentVersions: () => bindAgentVersions,
28
30
  createAgentEntity: () => createAgentEntity,
29
31
  createAgentInstructionsApi: () => createAgentInstructionsApi,
30
32
  createAgentKnowledgeApi: () => createAgentKnowledgeApi,
31
33
  createAgentPhonesApi: () => createAgentPhonesApi,
34
+ createAgentScheduleApi: () => createAgentScheduleApi,
35
+ createAgentVersionsApi: () => createAgentVersionsApi,
32
36
  createAgentsApi: () => createAgentsApi,
33
37
  createClient: () => createClient,
34
38
  createHttp: () => createHttp,
35
39
  createToolsApi: () => createToolsApi,
40
+ createVoicesApi: () => createVoicesApi,
36
41
  createWorkspacesApi: () => createWorkspacesApi
37
42
  });
38
43
  module.exports = __toCommonJS(index_exports);
39
44
 
40
- // src/entities/agent.ts
41
- var bindAgentInstructions = (api, agentId) => ({
42
- list(opts) {
43
- return api.list(agentId, opts);
44
- },
45
- create(payload) {
46
- return api.create(agentId, payload);
47
- }
48
- });
49
- var bindAgentKnowledge = (api, agentId) => ({
50
- upload(payload) {
51
- return api.upload(agentId, payload);
52
- },
53
- listBases() {
54
- return api.listBases(agentId);
55
- },
56
- listUploads() {
57
- return api.listUploads(agentId);
58
- }
59
- });
60
- var bindAgentPhones = (api, agentId) => ({
61
- connect(payload) {
62
- return api.connect(agentId, payload);
63
- },
64
- disconnect(phoneId) {
65
- return api.disconnect(agentId, phoneId);
66
- }
67
- });
68
- var createAgentEntity = (dto, options) => {
69
- const { instructionsApi, knowledgeApi, phonesApi, reload } = options;
70
- const entity = {
71
- ...dto,
72
- instructions: bindAgentInstructions(instructionsApi, dto.agentId),
73
- knowledge: bindAgentKnowledge(knowledgeApi, dto.agentId),
74
- phones: bindAgentPhones(phonesApi, dto.agentId),
75
- async refresh() {
76
- return reload(dto.agentId);
77
- }
78
- };
79
- return Object.freeze(entity);
80
- };
81
-
82
45
  // src/errors.ts
83
46
  var HttpError = class extends Error {
84
47
  constructor(status, statusText, body, url) {
@@ -108,6 +71,36 @@ var NetworkError = class extends Error {
108
71
  };
109
72
 
110
73
  // src/http.ts
74
+ function toQueryString(query) {
75
+ if (!query) return void 0;
76
+ if (typeof query === "string") {
77
+ const normalized = query.trim().replace(/^\?/, "");
78
+ return normalized.length > 0 ? normalized : void 0;
79
+ }
80
+ if (query instanceof URLSearchParams) {
81
+ const result2 = query.toString();
82
+ return result2.length > 0 ? result2 : void 0;
83
+ }
84
+ const params = new URLSearchParams();
85
+ Object.entries(query).forEach(([key, value]) => {
86
+ if (value === null || value === void 0) return;
87
+ const values = Array.isArray(value) ? value : [value];
88
+ values.forEach((item) => {
89
+ params.append(key, String(item));
90
+ });
91
+ });
92
+ const result = params.toString();
93
+ return result.length > 0 ? result : void 0;
94
+ }
95
+ function appendQuery(url, query) {
96
+ const qs = toQueryString(query);
97
+ if (!qs) return url;
98
+ const [base, hash] = url.split("#");
99
+ const hasQuery = base.includes("?");
100
+ const needsSeparator = hasQuery ? base.endsWith("?") || base.endsWith("&") ? "" : "&" : "?";
101
+ const built = `${base}${needsSeparator}${qs}`;
102
+ return hash ? `${built}#${hash}` : built;
103
+ }
111
104
  function sleep(ms) {
112
105
  return new Promise((r) => setTimeout(r, ms));
113
106
  }
@@ -182,25 +175,31 @@ function createHttp(cfg) {
182
175
  };
183
176
  };
184
177
  async function doFetch(url, init = {}) {
178
+ const { query, ...requestInit } = init;
179
+ const targetUrl = appendQuery(url, query);
185
180
  const ab = new AbortController();
186
181
  const req = async () => {
187
182
  try {
188
- const finalHeaders = buildHeaders(init.headers);
183
+ const finalHeaders = buildHeaders(requestInit.headers);
189
184
  const res = await withTimeout(
190
- fx(url, { ...init, headers: finalHeaders, signal: ab.signal }),
185
+ fx(targetUrl, {
186
+ ...requestInit,
187
+ headers: finalHeaders,
188
+ signal: ab.signal
189
+ }),
191
190
  timeout,
192
191
  ab,
193
- url
192
+ targetUrl
194
193
  );
195
194
  if (!res.ok) {
196
195
  const body = await res.clone().json().catch(() => void 0);
197
- throw new HttpError(res.status, res.statusText, body, url);
196
+ throw new HttpError(res.status, res.statusText, body, targetUrl);
198
197
  }
199
198
  return res;
200
199
  } catch (e) {
201
- if (e.name === "AbortError") throw new TimeoutError(timeout, url);
200
+ if (e.name === "AbortError") throw new TimeoutError(timeout, targetUrl);
202
201
  if (e instanceof HttpError) throw e;
203
- throw new NetworkError(e, url);
202
+ throw new NetworkError(e, targetUrl);
204
203
  }
205
204
  };
206
205
  return withRetry(req, retry);
@@ -216,13 +215,378 @@ function createHttp(cfg) {
216
215
  };
217
216
  }
218
217
 
218
+ // src/utils/query.ts
219
+ function serializeListOptions(options = {}, extra = {}) {
220
+ const params = new URLSearchParams();
221
+ appendParam(params, "page", options.page);
222
+ appendParam(params, "limit", options.limit);
223
+ appendParam(params, "sort", options.sort);
224
+ appendParam(params, "fields", options.fields);
225
+ appendParam(params, "include", options.include);
226
+ appendParam(params, "q", options.search);
227
+ appendParam(params, "filter", mapQueryValue(options.filter));
228
+ appendParam(params, "or", mapQueryValue(options.or));
229
+ Object.entries(extra).forEach(([key, value]) => {
230
+ appendParam(params, key, value);
231
+ });
232
+ return params.toString();
233
+ }
234
+ function mapQueryValue(value) {
235
+ if (value === void 0 || value === null) {
236
+ return void 0;
237
+ }
238
+ if (isQueryBuilderSerializable(value)) {
239
+ return getQueryBuilderString(value);
240
+ }
241
+ return value;
242
+ }
243
+ function appendParam(params, key, value) {
244
+ if (value === void 0 || value === null) {
245
+ return;
246
+ }
247
+ if (value instanceof Date) {
248
+ params.set(key, value.toISOString());
249
+ return;
250
+ }
251
+ if (isQueryBuilderSerializable(value)) {
252
+ params.set(key, getQueryBuilderString(value));
253
+ return;
254
+ }
255
+ if (typeof value === "string") {
256
+ params.set(key, value);
257
+ return;
258
+ }
259
+ if (typeof value === "number" || typeof value === "boolean") {
260
+ params.set(key, String(value));
261
+ return;
262
+ }
263
+ if (typeof value === "bigint") {
264
+ params.set(key, value.toString());
265
+ return;
266
+ }
267
+ if (Array.isArray(value)) {
268
+ if (value.length === 0) {
269
+ return;
270
+ }
271
+ if (value.every(isPrimitive)) {
272
+ params.set(key, value.map((item) => String(item)).join(","));
273
+ return;
274
+ }
275
+ value.forEach((item, idx) => {
276
+ appendParam(params, `${key}[${idx}]`, item);
277
+ });
278
+ return;
279
+ }
280
+ if (isPlainObject(value)) {
281
+ Object.entries(value).forEach(([childKey, childValue]) => {
282
+ appendParam(params, `${key}[${childKey}]`, childValue);
283
+ });
284
+ return;
285
+ }
286
+ params.set(key, String(value));
287
+ }
288
+ function isPrimitive(value) {
289
+ return typeof value === "string" || typeof value === "number" || typeof value === "boolean" || typeof value === "bigint";
290
+ }
291
+ function isPlainObject(value) {
292
+ if (value === null || typeof value !== "object") {
293
+ return false;
294
+ }
295
+ const proto = Object.getPrototypeOf(value);
296
+ return proto === Object.prototype || proto === null;
297
+ }
298
+ function isQueryBuilderSerializable(value) {
299
+ return !!value && typeof value === "object" && typeof value.build === "function";
300
+ }
301
+ function getQueryBuilderString(value) {
302
+ const build = value.build;
303
+ if (typeof build !== "function") {
304
+ throw new TypeError(
305
+ "Query builder values must expose a build() method returning a string."
306
+ );
307
+ }
308
+ if (build.length > 0) {
309
+ const stringValue = value.toString?.();
310
+ if (stringValue && stringValue !== "[object Object]") {
311
+ return stringValue;
312
+ }
313
+ throw new TypeError(
314
+ "Query builder instances passed to the SDK must expose a zero-argument build() method. Did you pass QueryBuilder instead of Query?"
315
+ );
316
+ }
317
+ const result = build.call(value);
318
+ if (typeof result === "string") {
319
+ return result;
320
+ }
321
+ if (result === void 0 || result === null) {
322
+ throw new TypeError(
323
+ "Query builder build() must return a string representation of the query."
324
+ );
325
+ }
326
+ return String(result);
327
+ }
328
+
329
+ // src/api/agent-instructions.ts
330
+ function createAgentInstructionsApi(cfg) {
331
+ const { base, doFetch } = createHttp(cfg);
332
+ const jsonHeaders = { "content-type": "application/json" };
333
+ return {
334
+ async list(agentId, opts = {}) {
335
+ const { versionId, ...queryOptions } = opts;
336
+ const query = serializeListOptions(queryOptions, { versionId });
337
+ const res = await doFetch(`${base}/v1/agents/${agentId}/instructions`, {
338
+ method: "GET",
339
+ query
340
+ });
341
+ return res.json();
342
+ },
343
+ async create(agentId, payload) {
344
+ const res = await doFetch(`${base}/v1/agents/${agentId}/instructions`, {
345
+ method: "POST",
346
+ headers: jsonHeaders,
347
+ body: JSON.stringify(payload)
348
+ });
349
+ return res.json();
350
+ },
351
+ async update(agentId, instructionId, payload) {
352
+ const res = await doFetch(
353
+ `${base}/v1/agents/${agentId}/instructions/${instructionId}`,
354
+ {
355
+ method: "PATCH",
356
+ headers: jsonHeaders,
357
+ body: JSON.stringify(payload)
358
+ }
359
+ );
360
+ return res.json();
361
+ },
362
+ async delete(agentId, instructionId) {
363
+ await doFetch(
364
+ `${base}/v1/agents/${agentId}/instructions/${instructionId}`,
365
+ {
366
+ method: "DELETE"
367
+ }
368
+ );
369
+ }
370
+ };
371
+ }
372
+
373
+ // src/api/agent-knowledge.ts
374
+ function createAgentKnowledgeApi(cfg) {
375
+ const { base, doFetch } = createHttp(cfg);
376
+ const jsonHeaders = { "content-type": "application/json" };
377
+ return {
378
+ async upload(agentId, payload) {
379
+ const res = await doFetch(
380
+ `${base}/v1/agents/${agentId}/knowledge/upload`,
381
+ {
382
+ method: "POST",
383
+ headers: jsonHeaders,
384
+ body: JSON.stringify(payload)
385
+ }
386
+ );
387
+ return res.json();
388
+ },
389
+ async listBases(agentId, opts = {}) {
390
+ const query = serializeListOptions(opts);
391
+ const res = await doFetch(
392
+ `${base}/v1/agents/${agentId}/knowledge/bases`,
393
+ {
394
+ method: "GET",
395
+ query
396
+ }
397
+ );
398
+ return res.json();
399
+ },
400
+ async listUploads(agentId, opts = {}) {
401
+ const query = serializeListOptions(opts);
402
+ const res = await doFetch(
403
+ `${base}/v1/agents/${agentId}/knowledge/uploads`,
404
+ {
405
+ method: "GET",
406
+ query
407
+ }
408
+ );
409
+ return res.json();
410
+ }
411
+ };
412
+ }
413
+
414
+ // src/api/agent-phones.ts
415
+ function createAgentPhonesApi(cfg) {
416
+ const { base, doFetch } = createHttp(cfg);
417
+ const jsonHeaders = { "content-type": "application/json" };
418
+ return {
419
+ async connect(agentId, payload) {
420
+ const res = await doFetch(`${base}/v1/agents/${agentId}/phones`, {
421
+ method: "POST",
422
+ headers: jsonHeaders,
423
+ body: JSON.stringify(payload)
424
+ });
425
+ return res.json();
426
+ },
427
+ async disconnect(agentId, phoneId) {
428
+ await doFetch(`${base}/v1/agents/${agentId}/phones/${phoneId}`, {
429
+ method: "DELETE"
430
+ });
431
+ }
432
+ };
433
+ }
434
+
435
+ // src/api/agent-schedule.ts
436
+ function createAgentScheduleApi(cfg) {
437
+ const { base, doFetch } = createHttp(cfg);
438
+ const jsonHeaders = { "content-type": "application/json" };
439
+ return {
440
+ async get(agentId) {
441
+ const res = await doFetch(`${base}/v1/agents/${agentId}/schedule`, {
442
+ method: "GET"
443
+ });
444
+ return res.json();
445
+ },
446
+ async update(agentId, payload) {
447
+ const res = await doFetch(`${base}/v1/agents/${agentId}/schedule`, {
448
+ method: "PUT",
449
+ headers: jsonHeaders,
450
+ body: JSON.stringify(payload)
451
+ });
452
+ return res.json();
453
+ }
454
+ };
455
+ }
456
+
457
+ // src/api/agent-versions.ts
458
+ function createAgentVersionsApi(cfg) {
459
+ const { base, doFetch } = createHttp(cfg);
460
+ const jsonHeaders = { "content-type": "application/json" };
461
+ return {
462
+ async list(agentId, opts = {}) {
463
+ const { status, ...queryOptions } = opts;
464
+ const query = serializeListOptions(queryOptions, { status });
465
+ const res = await doFetch(`${base}/v1/agents/${agentId}/versions`, {
466
+ method: "GET",
467
+ query
468
+ });
469
+ return res.json();
470
+ },
471
+ async get(agentId, versionId) {
472
+ const res = await doFetch(
473
+ `${base}/v1/agents/${agentId}/versions/${versionId}`,
474
+ {
475
+ method: "GET"
476
+ }
477
+ );
478
+ return res.json();
479
+ },
480
+ async create(agentId, payload) {
481
+ const res = await doFetch(`${base}/v1/agents/${agentId}/versions`, {
482
+ method: "POST",
483
+ headers: jsonHeaders,
484
+ body: JSON.stringify(payload)
485
+ });
486
+ return res.json();
487
+ },
488
+ async update(agentId, versionId, payload) {
489
+ const res = await doFetch(
490
+ `${base}/v1/agents/${agentId}/versions/${versionId}`,
491
+ {
492
+ method: "PATCH",
493
+ headers: jsonHeaders,
494
+ body: JSON.stringify(payload)
495
+ }
496
+ );
497
+ return res.json();
498
+ }
499
+ };
500
+ }
501
+
502
+ // src/entities/agent.ts
503
+ var bindAgentInstructions = (api, agentId) => ({
504
+ list(opts) {
505
+ return api.list(agentId, opts);
506
+ },
507
+ create(payload) {
508
+ return api.create(agentId, payload);
509
+ },
510
+ update(instructionId, payload) {
511
+ return api.update(agentId, instructionId, payload);
512
+ },
513
+ delete(instructionId) {
514
+ return api.delete(agentId, instructionId);
515
+ }
516
+ });
517
+ var bindAgentKnowledge = (api, agentId) => ({
518
+ upload(payload) {
519
+ return api.upload(agentId, payload);
520
+ },
521
+ listBases(opts) {
522
+ return api.listBases(agentId, opts);
523
+ },
524
+ listUploads(opts) {
525
+ return api.listUploads(agentId, opts);
526
+ }
527
+ });
528
+ var bindAgentPhones = (api, agentId) => ({
529
+ connect(payload) {
530
+ return api.connect(agentId, payload);
531
+ },
532
+ disconnect(phoneId) {
533
+ return api.disconnect(agentId, phoneId);
534
+ }
535
+ });
536
+ var bindAgentSchedule = (api, agentId) => ({
537
+ get() {
538
+ return api.get(agentId);
539
+ },
540
+ update(payload) {
541
+ return api.update(agentId, payload);
542
+ }
543
+ });
544
+ var bindAgentVersions = (api, agentId) => ({
545
+ list(opts) {
546
+ return api.list(agentId, opts);
547
+ },
548
+ get(versionId) {
549
+ return api.get(agentId, versionId);
550
+ },
551
+ create(payload) {
552
+ return api.create(agentId, payload);
553
+ },
554
+ update(versionId, payload) {
555
+ return api.update(agentId, versionId, payload);
556
+ }
557
+ });
558
+ var createAgentEntity = (dto, options) => {
559
+ const {
560
+ instructionsApi,
561
+ knowledgeApi,
562
+ phonesApi,
563
+ scheduleApi,
564
+ versionsApi,
565
+ reload
566
+ } = options;
567
+ const entity = {
568
+ ...dto,
569
+ instructions: bindAgentInstructions(instructionsApi, dto.agentId),
570
+ knowledge: bindAgentKnowledge(knowledgeApi, dto.agentId),
571
+ phones: bindAgentPhones(phonesApi, dto.agentId),
572
+ schedule: bindAgentSchedule(scheduleApi, dto.agentId),
573
+ versions: bindAgentVersions(versionsApi, dto.agentId),
574
+ async refresh() {
575
+ return reload(dto.agentId);
576
+ }
577
+ };
578
+ return Object.freeze(entity);
579
+ };
580
+
219
581
  // src/api/agents.ts
220
582
  function createAgentsApi(cfg, relatedApis) {
221
583
  const { base, doFetch } = createHttp(cfg);
222
584
  const jsonHeaders = { "content-type": "application/json" };
223
- const listAgents = async () => {
585
+ const listAgents = async (options = {}) => {
586
+ const query = serializeListOptions(options);
224
587
  const res = await doFetch(`${base}/v1/agents`, {
225
- method: "GET"
588
+ method: "GET",
589
+ query
226
590
  });
227
591
  return res.json();
228
592
  };
@@ -267,6 +631,8 @@ function createAgentsApi(cfg, relatedApis) {
267
631
  instructionsApi: relatedApis.instructionsApi,
268
632
  knowledgeApi: relatedApis.knowledgeApi,
269
633
  phonesApi: relatedApis.phonesApi,
634
+ scheduleApi: relatedApis.scheduleApi,
635
+ versionsApi: relatedApis.versionsApi,
270
636
  reload: async (agentId) => {
271
637
  const latest = await getAgentDetail(agentId);
272
638
  return wrapAgent(latest);
@@ -274,6 +640,14 @@ function createAgentsApi(cfg, relatedApis) {
274
640
  });
275
641
  return {
276
642
  ...baseApi,
643
+ async list(options = {}) {
644
+ const response = await listAgents(options);
645
+ const items = Array.isArray(response.data) ? response.data : [];
646
+ return {
647
+ ...response,
648
+ data: items.map((summary) => wrapAgent(summary))
649
+ };
650
+ },
277
651
  async get(agentId) {
278
652
  const detail = await getAgentDetail(agentId);
279
653
  return wrapAgent(detail);
@@ -289,60 +663,21 @@ function createAgentsApi(cfg, relatedApis) {
289
663
  };
290
664
  }
291
665
 
292
- // src/api/agent-knowledge.ts
293
- function createAgentKnowledgeApi(cfg) {
294
- const { base, doFetch } = createHttp(cfg);
295
- const jsonHeaders = { "content-type": "application/json" };
296
- return {
297
- async upload(agentId, payload) {
298
- const res = await doFetch(
299
- `${base}/v1/agents/${agentId}/knowledge/upload`,
300
- {
301
- method: "POST",
302
- headers: jsonHeaders,
303
- body: JSON.stringify(payload)
304
- }
305
- );
306
- return res.json();
307
- },
308
- async listBases(agentId) {
309
- const res = await doFetch(
310
- `${base}/v1/agents/${agentId}/knowledge/bases`,
311
- {
312
- method: "GET"
313
- }
314
- );
315
- return res.json();
316
- },
317
- async listUploads(agentId) {
318
- const res = await doFetch(
319
- `${base}/v1/agents/${agentId}/knowledge/uploads`,
320
- {
321
- method: "GET"
322
- }
323
- );
324
- return res.json();
325
- }
326
- };
327
- }
328
-
329
- // src/api/agent-instructions.ts
330
- function createAgentInstructionsApi(cfg) {
666
+ // src/api/tools.ts
667
+ function createToolsApi(cfg) {
331
668
  const { base, doFetch } = createHttp(cfg);
332
669
  const jsonHeaders = { "content-type": "application/json" };
333
670
  return {
334
- async list(agentId, opts) {
335
- const search = opts?.versionId ? `?versionId=${encodeURIComponent(opts.versionId)}` : "";
336
- const res = await doFetch(
337
- `${base}/v1/agents/${agentId}/instructions${search}`,
338
- {
339
- method: "GET"
340
- }
341
- );
671
+ async list(options = {}) {
672
+ const query = serializeListOptions(options);
673
+ const res = await doFetch(`${base}/v1/tools`, {
674
+ method: "GET",
675
+ query
676
+ });
342
677
  return res.json();
343
678
  },
344
- async create(agentId, payload) {
345
- const res = await doFetch(`${base}/v1/agents/${agentId}/instructions`, {
679
+ async execute(toolId, payload) {
680
+ const res = await doFetch(`${base}/v1/tools/${toolId}/execute`, {
346
681
  method: "POST",
347
682
  headers: jsonHeaders,
348
683
  body: JSON.stringify(payload)
@@ -352,23 +687,35 @@ function createAgentInstructionsApi(cfg) {
352
687
  };
353
688
  }
354
689
 
355
- // src/api/agent-phones.ts
356
- function createAgentPhonesApi(cfg) {
690
+ // src/api/voices.ts
691
+ function createVoicesApi(cfg) {
357
692
  const { base, doFetch } = createHttp(cfg);
358
- const jsonHeaders = { "content-type": "application/json" };
359
693
  return {
360
- async connect(agentId, payload) {
361
- const res = await doFetch(`${base}/v1/agents/${agentId}/phones`, {
362
- method: "POST",
363
- headers: jsonHeaders,
364
- body: JSON.stringify(payload)
694
+ async list(options = {}) {
695
+ const { agentId, agentVersionId, gender, locale } = options;
696
+ const query = serializeListOptions(
697
+ {
698
+ page: options.page,
699
+ limit: options.limit ?? options.pageSize,
700
+ sort: options.sort,
701
+ fields: options.fields,
702
+ include: options.include,
703
+ search: options.search,
704
+ filter: options.filter,
705
+ or: options.or
706
+ },
707
+ {
708
+ agentId,
709
+ agentVersionId,
710
+ gender,
711
+ locale
712
+ }
713
+ );
714
+ const res = await doFetch(`${base}/v1/voices`, {
715
+ method: "GET",
716
+ query
365
717
  });
366
718
  return res.json();
367
- },
368
- async disconnect(agentId, phoneId) {
369
- await doFetch(`${base}/v1/agents/${agentId}/phones/${phoneId}`, {
370
- method: "DELETE"
371
- });
372
719
  }
373
720
  };
374
721
  }
@@ -378,14 +725,25 @@ function createWorkspacesApi(cfg) {
378
725
  const { base, doFetch } = createHttp(cfg);
379
726
  const jsonHeaders = { "content-type": "application/json" };
380
727
  return {
381
- async listPhones(workspaceId, opts) {
382
- const search = opts?.channel ? `?channel=${opts.channel}` : "";
383
- const res = await doFetch(
384
- `${base}/v1/workspaces/${workspaceId}/phones${search}`,
728
+ async listPhones(workspaceId, opts = {}) {
729
+ const { channel } = opts;
730
+ const query = serializeListOptions(
385
731
  {
386
- method: "GET"
387
- }
732
+ page: opts.page,
733
+ limit: opts.limit,
734
+ sort: opts.sort,
735
+ fields: opts.fields,
736
+ include: opts.include,
737
+ search: opts.search,
738
+ filter: opts.filter,
739
+ or: opts.or
740
+ },
741
+ { channel }
388
742
  );
743
+ const res = await doFetch(`${base}/v1/workspaces/${workspaceId}/phones`, {
744
+ method: "GET",
745
+ query
746
+ });
389
747
  return res.json();
390
748
  },
391
749
  async enable(workspaceId, payload) {
@@ -399,28 +757,6 @@ function createWorkspacesApi(cfg) {
399
757
  };
400
758
  }
401
759
 
402
- // src/api/tools.ts
403
- function createToolsApi(cfg) {
404
- const { base, doFetch } = createHttp(cfg);
405
- const jsonHeaders = { "content-type": "application/json" };
406
- return {
407
- async list() {
408
- const res = await doFetch(`${base}/v1/tools`, {
409
- method: "GET"
410
- });
411
- return res.json();
412
- },
413
- async execute(toolId, payload) {
414
- const res = await doFetch(`${base}/v1/tools/${toolId}/execute`, {
415
- method: "POST",
416
- headers: jsonHeaders,
417
- body: JSON.stringify(payload)
418
- });
419
- return res.json();
420
- }
421
- };
422
- }
423
-
424
760
  // src/client.ts
425
761
  function createClient(initialCfg) {
426
762
  const runtimeCfg = {
@@ -436,20 +772,28 @@ function createClient(initialCfg) {
436
772
  const instructionsApi = createAgentInstructionsApi(runtimeCfg);
437
773
  const knowledgeApi = createAgentKnowledgeApi(runtimeCfg);
438
774
  const phonesApi = createAgentPhonesApi(runtimeCfg);
775
+ const scheduleApi = createAgentScheduleApi(runtimeCfg);
776
+ const versionsApi = createAgentVersionsApi(runtimeCfg);
777
+ const voicesApi = createVoicesApi(runtimeCfg);
439
778
  const agentsApi = createAgentsApi(runtimeCfg, {
440
779
  instructionsApi,
441
780
  knowledgeApi,
442
- phonesApi
781
+ phonesApi,
782
+ scheduleApi,
783
+ versionsApi
443
784
  });
444
785
  const apis = {
445
786
  agents: {
446
787
  ...agentsApi,
447
788
  knowledge: knowledgeApi,
448
789
  instructions: instructionsApi,
449
- phones: phonesApi
790
+ phones: phonesApi,
791
+ schedule: scheduleApi,
792
+ versions: versionsApi
450
793
  },
451
794
  workspaces: createWorkspacesApi(runtimeCfg),
452
- tools: createToolsApi(runtimeCfg)
795
+ tools: createToolsApi(runtimeCfg),
796
+ voices: voicesApi
453
797
  };
454
798
  return {
455
799
  ...apis,
@@ -484,14 +828,19 @@ function createClient(initialCfg) {
484
828
  bindAgentInstructions,
485
829
  bindAgentKnowledge,
486
830
  bindAgentPhones,
831
+ bindAgentSchedule,
832
+ bindAgentVersions,
487
833
  createAgentEntity,
488
834
  createAgentInstructionsApi,
489
835
  createAgentKnowledgeApi,
490
836
  createAgentPhonesApi,
837
+ createAgentScheduleApi,
838
+ createAgentVersionsApi,
491
839
  createAgentsApi,
492
840
  createClient,
493
841
  createHttp,
494
842
  createToolsApi,
843
+ createVoicesApi,
495
844
  createWorkspacesApi
496
845
  });
497
846
  //# sourceMappingURL=index.cjs.map