@getsupervisor/agents-studio-sdk 1.4.0 → 1.6.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.js CHANGED
@@ -426,60 +426,6 @@ function createAgentInstructionsApi(cfg) {
426
426
  };
427
427
  }
428
428
 
429
- // src/api/agent-knowledge.ts
430
- function createAgentKnowledgeApi(cfg) {
431
- const { base, doFetch } = createHttp(cfg);
432
- const jsonHeaders = { "content-type": "application/json" };
433
- const fetchBasesPage = async (agentId, opts = {}) => {
434
- const query = serializeListOptions(opts);
435
- const res = await doFetch(`${base}/v1/agents/${agentId}/knowledge/bases`, {
436
- method: "GET",
437
- query
438
- });
439
- return res.json();
440
- };
441
- const fetchUploadsPage = async (agentId, opts = {}) => {
442
- const query = serializeListOptions(opts);
443
- const res = await doFetch(
444
- `${base}/v1/agents/${agentId}/knowledge/uploads`,
445
- {
446
- method: "GET",
447
- query
448
- }
449
- );
450
- return res.json();
451
- };
452
- return {
453
- async upload(agentId, payload) {
454
- const res = await doFetch(
455
- `${base}/v1/agents/${agentId}/knowledge/upload`,
456
- {
457
- method: "POST",
458
- headers: jsonHeaders,
459
- body: JSON.stringify(payload)
460
- }
461
- );
462
- return res.json();
463
- },
464
- async listBases(agentId, opts = {}) {
465
- const normalizedOptions = {
466
- ...opts ?? {}
467
- };
468
- const fetchPage = (options) => fetchBasesPage(agentId, options);
469
- const response = await fetchPage(normalizedOptions);
470
- return attachPaginator(response, fetchPage, normalizedOptions);
471
- },
472
- async listUploads(agentId, opts = {}) {
473
- const normalizedOptions = {
474
- ...opts ?? {}
475
- };
476
- const fetchPage = (options) => fetchUploadsPage(agentId, options);
477
- const response = await fetchPage(normalizedOptions);
478
- return attachPaginator(response, fetchPage, normalizedOptions);
479
- }
480
- };
481
- }
482
-
483
429
  // src/api/agent-phones.ts
484
430
  function createAgentPhonesApi(cfg) {
485
431
  const { base, doFetch } = createHttp(cfg);
@@ -523,6 +469,27 @@ function createAgentScheduleApi(cfg) {
523
469
  };
524
470
  }
525
471
 
472
+ // src/api/agent-tags.ts
473
+ function createAgentTagsApi(cfg) {
474
+ const { base, doFetch } = createHttp(cfg);
475
+ const jsonHeaders = { "content-type": "application/json" };
476
+ return {
477
+ async add(agentId, payload) {
478
+ const res = await doFetch(`${base}/v1/agents/${agentId}/tags`, {
479
+ method: "POST",
480
+ headers: jsonHeaders,
481
+ body: JSON.stringify(payload)
482
+ });
483
+ return res.json();
484
+ },
485
+ async remove(agentId, tagId) {
486
+ await doFetch(`${base}/v1/agents/${agentId}/tags/${tagId}`, {
487
+ method: "DELETE"
488
+ });
489
+ }
490
+ };
491
+ }
492
+
526
493
  // src/api/agent-versions.ts
527
494
  function createAgentVersionsApi(cfg) {
528
495
  const { base, doFetch } = createHttp(cfg);
@@ -570,6 +537,52 @@ function createAgentVersionsApi(cfg) {
570
537
  }
571
538
  );
572
539
  return res.json();
540
+ },
541
+ async delete(agentId, versionId) {
542
+ await doFetch(`${base}/v1/agents/${agentId}/versions/${versionId}`, {
543
+ method: "DELETE"
544
+ });
545
+ },
546
+ async listInstructions(agentId, versionId, opts = {}) {
547
+ const query = serializeListOptions(opts);
548
+ const res = await doFetch(
549
+ `${base}/v1/agents/${agentId}/versions/${versionId}/instructions`,
550
+ {
551
+ method: "GET",
552
+ query
553
+ }
554
+ );
555
+ return res.json();
556
+ },
557
+ async createInstruction(agentId, versionId, payload) {
558
+ const res = await doFetch(
559
+ `${base}/v1/agents/${agentId}/versions/${versionId}/instructions`,
560
+ {
561
+ method: "POST",
562
+ headers: jsonHeaders,
563
+ body: JSON.stringify(payload)
564
+ }
565
+ );
566
+ return res.json();
567
+ },
568
+ async updateInstruction(agentId, versionId, instructionId, payload) {
569
+ const res = await doFetch(
570
+ `${base}/v1/agents/${agentId}/versions/${versionId}/instructions/${instructionId}`,
571
+ {
572
+ method: "PATCH",
573
+ headers: jsonHeaders,
574
+ body: JSON.stringify(payload)
575
+ }
576
+ );
577
+ return res.json();
578
+ },
579
+ async deleteInstruction(agentId, versionId, instructionId) {
580
+ await doFetch(
581
+ `${base}/v1/agents/${agentId}/versions/${versionId}/instructions/${instructionId}`,
582
+ {
583
+ method: "DELETE"
584
+ }
585
+ );
573
586
  }
574
587
  };
575
588
  }
@@ -589,15 +602,12 @@ var bindAgentInstructions = (api, agentId) => ({
589
602
  return api.delete(agentId, instructionId);
590
603
  }
591
604
  });
592
- var bindAgentKnowledge = (api, agentId) => ({
593
- upload(payload) {
594
- return api.upload(agentId, payload);
595
- },
596
- listBases(opts) {
597
- return api.listBases(agentId, opts);
605
+ var bindAgentTags = (api, agentId) => ({
606
+ add(tagId) {
607
+ return api.add(agentId, { tagId });
598
608
  },
599
- listUploads(opts) {
600
- return api.listUploads(agentId, opts);
609
+ remove(tagId) {
610
+ return api.remove(agentId, tagId);
601
611
  }
602
612
  });
603
613
  var bindAgentPhones = (api, agentId) => ({
@@ -628,12 +638,36 @@ var bindAgentVersions = (api, agentId) => ({
628
638
  },
629
639
  update(versionId, payload) {
630
640
  return api.update(agentId, versionId, payload);
641
+ },
642
+ delete(versionId) {
643
+ return api.delete(agentId, versionId);
644
+ },
645
+ instructions(versionId) {
646
+ return {
647
+ list(opts) {
648
+ return api.listInstructions(agentId, versionId, opts);
649
+ },
650
+ create(payload) {
651
+ return api.createInstruction(agentId, versionId, payload);
652
+ },
653
+ update(instructionId, payload) {
654
+ return api.updateInstruction(
655
+ agentId,
656
+ versionId,
657
+ instructionId,
658
+ payload
659
+ );
660
+ },
661
+ delete(instructionId) {
662
+ return api.deleteInstruction(agentId, versionId, instructionId);
663
+ }
664
+ };
631
665
  }
632
666
  });
633
667
  var createAgentEntity = (dto, options) => {
634
668
  const {
635
669
  instructionsApi,
636
- knowledgeApi,
670
+ tagsApi,
637
671
  phonesApi,
638
672
  scheduleApi,
639
673
  versionsApi,
@@ -644,7 +678,7 @@ var createAgentEntity = (dto, options) => {
644
678
  const entity = {
645
679
  ...dto,
646
680
  instructions: bindAgentInstructions(instructionsApi, dto.agentId),
647
- knowledge: bindAgentKnowledge(knowledgeApi, dto.agentId),
681
+ tagAssignments: bindAgentTags(tagsApi, dto.agentId),
648
682
  phones: bindAgentPhones(phonesApi, dto.agentId),
649
683
  schedule: bindAgentSchedule(scheduleApi, dto.agentId),
650
684
  versions: bindAgentVersions(versionsApi, dto.agentId),
@@ -721,7 +755,7 @@ function createAgentsApi(cfg, relatedApis) {
721
755
  }
722
756
  const wrapAgent = (detail) => createAgentEntity(detail, {
723
757
  instructionsApi: relatedApis.instructionsApi,
724
- knowledgeApi: relatedApis.knowledgeApi,
758
+ tagsApi: relatedApis.tagsApi,
725
759
  phonesApi: relatedApis.phonesApi,
726
760
  scheduleApi: relatedApis.scheduleApi,
727
761
  versionsApi: relatedApis.versionsApi,
@@ -768,23 +802,88 @@ function createAgentsApi(cfg, relatedApis) {
768
802
  }
769
803
 
770
804
  // src/api/tools.ts
805
+ var isFormData = (value) => {
806
+ return typeof FormData !== "undefined" && value instanceof FormData;
807
+ };
808
+ var toFormData = (payload) => {
809
+ if (isFormData(payload)) {
810
+ return payload;
811
+ }
812
+ if (typeof FormData === "undefined") {
813
+ throw new TypeError(
814
+ "FormData is not available in this environment. Pass a FormData instance instead."
815
+ );
816
+ }
817
+ const formData = new FormData();
818
+ formData.append("file", payload.file);
819
+ if (payload.type) {
820
+ formData.append("type", payload.type);
821
+ }
822
+ if (payload.title) {
823
+ formData.append("title", payload.title);
824
+ }
825
+ if (payload.metadata) {
826
+ formData.append("metadata", JSON.stringify(payload.metadata));
827
+ }
828
+ return formData;
829
+ };
771
830
  function createToolsApi(cfg) {
772
831
  const { base, doFetch } = createHttp(cfg);
773
832
  const jsonHeaders = { "content-type": "application/json" };
774
833
  const fetchToolsPage = async (options = {}) => {
775
- const query = serializeListOptions(options);
834
+ const { agentType, ...queryOptions } = options ?? {};
835
+ const query = serializeListOptions(queryOptions, { agentType });
776
836
  const res = await doFetch(`${base}/v1/tools`, {
777
837
  method: "GET",
778
838
  query
779
839
  });
780
840
  return res.json();
781
841
  };
842
+ const fetchToolResourcesPage = async (toolId, options = {}) => {
843
+ const { type, ...queryOptions } = options ?? {};
844
+ const query = serializeListOptions(queryOptions, { type });
845
+ const res = await doFetch(`${base}/v1/tools/${toolId}/resources`, {
846
+ method: "GET",
847
+ query
848
+ });
849
+ return res.json();
850
+ };
782
851
  return {
783
852
  async list(options = {}) {
784
853
  const normalizedOptions = { ...options ?? {} };
785
854
  const response = await fetchToolsPage(normalizedOptions);
786
855
  return attachPaginator(response, fetchToolsPage, normalizedOptions);
787
856
  },
857
+ async listResources(toolId, options = {}) {
858
+ const normalizedOptions = {
859
+ ...options ?? {}
860
+ };
861
+ const fetchPage = (opts) => fetchToolResourcesPage(toolId, opts);
862
+ const response = await fetchPage(normalizedOptions);
863
+ return attachPaginator(response, fetchPage, normalizedOptions);
864
+ },
865
+ async uploadResource(toolId, payload) {
866
+ const formData = toFormData(payload);
867
+ const res = await doFetch(`${base}/v1/tools/${toolId}/resources`, {
868
+ method: "POST",
869
+ body: formData
870
+ });
871
+ return res.json();
872
+ },
873
+ async deleteResource(toolId, resourceId) {
874
+ await doFetch(`${base}/v1/tools/${toolId}/resources/${resourceId}`, {
875
+ method: "DELETE"
876
+ });
877
+ },
878
+ async reloadResource(toolId, resourceId) {
879
+ const res = await doFetch(
880
+ `${base}/v1/tools/${toolId}/resources/${resourceId}/reload`,
881
+ {
882
+ method: "POST"
883
+ }
884
+ );
885
+ return res.json();
886
+ },
788
887
  async execute(toolId, payload) {
789
888
  const res = await doFetch(`${base}/v1/tools/${toolId}/execute`, {
790
889
  method: "POST",
@@ -792,6 +891,14 @@ function createToolsApi(cfg) {
792
891
  body: JSON.stringify(payload)
793
892
  });
794
893
  return res.json();
894
+ },
895
+ async connect(toolId, payload) {
896
+ const res = await doFetch(`${base}/v1/tools/${toolId}/connect`, {
897
+ method: "POST",
898
+ headers: jsonHeaders,
899
+ body: JSON.stringify(payload)
900
+ });
901
+ return res.json();
795
902
  }
796
903
  };
797
904
  }
@@ -892,14 +999,14 @@ function createClient(initialCfg) {
892
999
  runtimeCfg.getWorkspaceId = getter;
893
1000
  };
894
1001
  const instructionsApi = createAgentInstructionsApi(runtimeCfg);
895
- const knowledgeApi = createAgentKnowledgeApi(runtimeCfg);
1002
+ const tagsApi = createAgentTagsApi(runtimeCfg);
896
1003
  const phonesApi = createAgentPhonesApi(runtimeCfg);
897
1004
  const scheduleApi = createAgentScheduleApi(runtimeCfg);
898
1005
  const versionsApi = createAgentVersionsApi(runtimeCfg);
899
1006
  const voicesApi = createVoicesApi(runtimeCfg);
900
1007
  const agentsApi = createAgentsApi(runtimeCfg, {
901
1008
  instructionsApi,
902
- knowledgeApi,
1009
+ tagsApi,
903
1010
  phonesApi,
904
1011
  scheduleApi,
905
1012
  versionsApi
@@ -907,8 +1014,8 @@ function createClient(initialCfg) {
907
1014
  const apis = {
908
1015
  agents: {
909
1016
  ...agentsApi,
910
- knowledge: knowledgeApi,
911
1017
  instructions: instructionsApi,
1018
+ tags: tagsApi,
912
1019
  phones: phonesApi,
913
1020
  schedule: scheduleApi,
914
1021
  versions: versionsApi
@@ -947,15 +1054,15 @@ export {
947
1054
  NetworkError,
948
1055
  TimeoutError,
949
1056
  bindAgentInstructions,
950
- bindAgentKnowledge,
951
1057
  bindAgentPhones,
952
1058
  bindAgentSchedule,
1059
+ bindAgentTags,
953
1060
  bindAgentVersions,
954
1061
  createAgentEntity,
955
1062
  createAgentInstructionsApi,
956
- createAgentKnowledgeApi,
957
1063
  createAgentPhonesApi,
958
1064
  createAgentScheduleApi,
1065
+ createAgentTagsApi,
959
1066
  createAgentVersionsApi,
960
1067
  createAgentsApi,
961
1068
  createClient,