@getsupervisor/agents-studio-sdk 1.22.2 → 1.24.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
@@ -27,6 +27,8 @@ __export(index_exports, {
27
27
  bindAgentPhones: () => bindAgentPhones,
28
28
  bindAgentSchedule: () => bindAgentSchedule,
29
29
  bindAgentScheduleExceptions: () => bindAgentScheduleExceptions,
30
+ bindAgentStageTriggers: () => bindAgentStageTriggers,
31
+ bindAgentStages: () => bindAgentStages,
30
32
  bindAgentTags: () => bindAgentTags,
31
33
  bindAgentVersions: () => bindAgentVersions,
32
34
  createAgentBlueprintsApi: () => createAgentBlueprintsApi,
@@ -35,6 +37,8 @@ __export(index_exports, {
35
37
  createAgentPhonesApi: () => createAgentPhonesApi,
36
38
  createAgentScheduleApi: () => createAgentScheduleApi,
37
39
  createAgentScheduleExceptionsApi: () => createAgentScheduleExceptionsApi,
40
+ createAgentStageTriggersApi: () => createAgentStageTriggersApi,
41
+ createAgentStagesApi: () => createAgentStagesApi,
38
42
  createAgentTagsApi: () => createAgentTagsApi,
39
43
  createAgentVersionsApi: () => createAgentVersionsApi,
40
44
  createAgentsApi: () => createAgentsApi,
@@ -560,6 +564,69 @@ function createAgentPhonesApi(cfg) {
560
564
  };
561
565
  }
562
566
 
567
+ // src/api/agent-schedule-exceptions.ts
568
+ function createAgentScheduleExceptionsApi(cfg) {
569
+ const { base, doFetch } = createHttp(cfg);
570
+ const jsonHeaders = { "content-type": "application/json" };
571
+ const fetchExceptionsPage = async (agentId, options = {}) => {
572
+ const query = serializeListOptions(options ?? {});
573
+ const res = await doFetch(`${base}/agents/${agentId}/schedule/exceptions`, {
574
+ method: "GET",
575
+ query
576
+ });
577
+ return res.json();
578
+ };
579
+ return {
580
+ async list(agentId, options = {}) {
581
+ const normalizedOptions = {
582
+ ...options ?? {}
583
+ };
584
+ const fetchPage = (pageOptions) => fetchExceptionsPage(agentId, pageOptions);
585
+ const response = await fetchPage(normalizedOptions);
586
+ return attachPaginator(response, fetchPage, normalizedOptions);
587
+ },
588
+ async get(agentId, exceptionId) {
589
+ const res = await doFetch(
590
+ `${base}/agents/${agentId}/schedule/exceptions/${exceptionId}`,
591
+ {
592
+ method: "GET"
593
+ }
594
+ );
595
+ return res.json();
596
+ },
597
+ async create(agentId, payload) {
598
+ const res = await doFetch(
599
+ `${base}/agents/${agentId}/schedule/exceptions`,
600
+ {
601
+ method: "POST",
602
+ headers: jsonHeaders,
603
+ body: JSON.stringify(payload)
604
+ }
605
+ );
606
+ return res.json();
607
+ },
608
+ async update(agentId, exceptionId, payload) {
609
+ const res = await doFetch(
610
+ `${base}/agents/${agentId}/schedule/exceptions/${exceptionId}`,
611
+ {
612
+ method: "PATCH",
613
+ headers: jsonHeaders,
614
+ body: JSON.stringify(payload)
615
+ }
616
+ );
617
+ return res.json();
618
+ },
619
+ async delete(agentId, exceptionId) {
620
+ await doFetch(
621
+ `${base}/agents/${agentId}/schedule/exceptions/${exceptionId}`,
622
+ {
623
+ method: "DELETE"
624
+ }
625
+ );
626
+ }
627
+ };
628
+ }
629
+
563
630
  // src/api/agent-schedule.ts
564
631
  function createAgentScheduleApi(cfg) {
565
632
  const { base, doFetch } = createHttp(cfg);
@@ -590,39 +657,52 @@ function createAgentScheduleApi(cfg) {
590
657
  };
591
658
  }
592
659
 
593
- // src/api/agent-schedule-exceptions.ts
594
- function createAgentScheduleExceptionsApi(cfg) {
660
+ // src/api/agent-stage-triggers.ts
661
+ function createAgentStageTriggersApi(cfg) {
595
662
  const { base, doFetch } = createHttp(cfg);
596
663
  const jsonHeaders = { "content-type": "application/json" };
597
- const fetchExceptionsPage = async (agentId, options = {}) => {
598
- const query = serializeListOptions(options ?? {});
599
- const res = await doFetch(`${base}/agents/${agentId}/schedule/exceptions`, {
600
- method: "GET",
601
- query
602
- });
664
+ const fetchTriggerPage = async (agentId, stageId, options = {}) => {
665
+ const normalizedOptions = {
666
+ page: options.page,
667
+ limit: options.limit,
668
+ sort: options.sort,
669
+ fields: options.fields,
670
+ include: options.include,
671
+ filter: options.filter,
672
+ search: options.search,
673
+ or: options.or
674
+ };
675
+ const query = serializeListOptions(normalizedOptions);
676
+ const res = await doFetch(
677
+ `${base}/agents/${agentId}/stages/${stageId}/triggers`,
678
+ {
679
+ method: "GET",
680
+ query
681
+ }
682
+ );
603
683
  return res.json();
604
684
  };
605
685
  return {
606
- async list(agentId, options = {}) {
607
- const normalizedOptions = {
686
+ async list(agentId, stageId, options = {}) {
687
+ const normalized = {
608
688
  ...options ?? {}
609
689
  };
610
- const fetchPage = (pageOptions) => fetchExceptionsPage(agentId, pageOptions);
611
- const response = await fetchPage(normalizedOptions);
612
- return attachPaginator(response, fetchPage, normalizedOptions);
690
+ const fetchPage = (opts) => fetchTriggerPage(agentId, stageId, opts);
691
+ const response = await fetchPage(normalized);
692
+ return attachPaginator(response, fetchPage, normalized);
613
693
  },
614
- async get(agentId, exceptionId) {
694
+ async get(agentId, stageId, triggerId) {
615
695
  const res = await doFetch(
616
- `${base}/agents/${agentId}/schedule/exceptions/${exceptionId}`,
696
+ `${base}/agents/${agentId}/stages/${stageId}/triggers/${triggerId}`,
617
697
  {
618
698
  method: "GET"
619
699
  }
620
700
  );
621
701
  return res.json();
622
702
  },
623
- async create(agentId, payload) {
703
+ async create(agentId, stageId, payload) {
624
704
  const res = await doFetch(
625
- `${base}/agents/${agentId}/schedule/exceptions`,
705
+ `${base}/agents/${agentId}/stages/${stageId}/triggers`,
626
706
  {
627
707
  method: "POST",
628
708
  headers: jsonHeaders,
@@ -631,9 +711,9 @@ function createAgentScheduleExceptionsApi(cfg) {
631
711
  );
632
712
  return res.json();
633
713
  },
634
- async update(agentId, exceptionId, payload) {
714
+ async update(agentId, stageId, triggerId, payload) {
635
715
  const res = await doFetch(
636
- `${base}/agents/${agentId}/schedule/exceptions/${exceptionId}`,
716
+ `${base}/agents/${agentId}/stages/${stageId}/triggers/${triggerId}`,
637
717
  {
638
718
  method: "PATCH",
639
719
  headers: jsonHeaders,
@@ -642,9 +722,9 @@ function createAgentScheduleExceptionsApi(cfg) {
642
722
  );
643
723
  return res.json();
644
724
  },
645
- async delete(agentId, exceptionId) {
725
+ async delete(agentId, stageId, triggerId) {
646
726
  await doFetch(
647
- `${base}/agents/${agentId}/schedule/exceptions/${exceptionId}`,
727
+ `${base}/agents/${agentId}/stages/${stageId}/triggers/${triggerId}`,
648
728
  {
649
729
  method: "DELETE"
650
730
  }
@@ -653,6 +733,70 @@ function createAgentScheduleExceptionsApi(cfg) {
653
733
  };
654
734
  }
655
735
 
736
+ // src/api/agent-stages.ts
737
+ function createAgentStagesApi(cfg) {
738
+ const { base, doFetch } = createHttp(cfg);
739
+ const jsonHeaders = { "content-type": "application/json" };
740
+ const fetchStagePage = async (agentId, options = {}) => {
741
+ const normalizedOptions = {
742
+ page: options.page,
743
+ limit: options.limit,
744
+ sort: options.sort,
745
+ filter: options.filter,
746
+ search: options.search
747
+ };
748
+ const query = serializeListOptions(normalizedOptions);
749
+ const res = await doFetch(`${base}/agents/${agentId}/stages`, {
750
+ method: "GET",
751
+ query
752
+ });
753
+ return res.json();
754
+ };
755
+ return {
756
+ async list(agentId, options = {}) {
757
+ const normalized = { ...options ?? {} };
758
+ const fetchPage = (opts) => fetchStagePage(agentId, opts);
759
+ const response = await fetchPage(normalized);
760
+ return attachPaginator(response, fetchPage, normalized);
761
+ },
762
+ async get(agentId, stageId) {
763
+ const res = await doFetch(`${base}/agents/${agentId}/stages/${stageId}`, {
764
+ method: "GET"
765
+ });
766
+ return res.json();
767
+ },
768
+ async create(agentId, payload) {
769
+ const res = await doFetch(`${base}/agents/${agentId}/stages`, {
770
+ method: "POST",
771
+ headers: jsonHeaders,
772
+ body: JSON.stringify(payload)
773
+ });
774
+ return res.json();
775
+ },
776
+ async update(agentId, stageId, payload) {
777
+ const res = await doFetch(`${base}/agents/${agentId}/stages/${stageId}`, {
778
+ method: "PATCH",
779
+ headers: jsonHeaders,
780
+ body: JSON.stringify(payload)
781
+ });
782
+ return res.json();
783
+ },
784
+ async delete(agentId, stageId) {
785
+ await doFetch(`${base}/agents/${agentId}/stages/${stageId}`, {
786
+ method: "DELETE"
787
+ });
788
+ },
789
+ async reorder(agentId, payload) {
790
+ const res = await doFetch(`${base}/agents/${agentId}/stages:reorder`, {
791
+ method: "POST",
792
+ headers: jsonHeaders,
793
+ body: JSON.stringify(payload)
794
+ });
795
+ return res.json();
796
+ }
797
+ };
798
+ }
799
+
656
800
  // src/api/agent-tags.ts
657
801
  function createAgentTagsApi(cfg) {
658
802
  const { base, doFetch } = createHttp(cfg);
@@ -805,6 +949,46 @@ var bindAgentInstructions = (api, agentId) => ({
805
949
  return api.delete(agentId, instructionId);
806
950
  }
807
951
  });
952
+ var bindAgentStageTriggers = (api, agentId, stageId) => ({
953
+ list(opts) {
954
+ return api.list(agentId, stageId, opts);
955
+ },
956
+ get(triggerId) {
957
+ return api.get(agentId, stageId, triggerId);
958
+ },
959
+ create(payload) {
960
+ return api.create(agentId, stageId, payload);
961
+ },
962
+ update(triggerId, payload) {
963
+ return api.update(agentId, stageId, triggerId, payload);
964
+ },
965
+ delete(triggerId) {
966
+ return api.delete(agentId, stageId, triggerId);
967
+ }
968
+ });
969
+ var bindAgentStages = (stagesApi, triggersApi, agentId) => ({
970
+ list(opts) {
971
+ return stagesApi.list(agentId, opts);
972
+ },
973
+ get(stageId) {
974
+ return stagesApi.get(agentId, stageId);
975
+ },
976
+ create(payload) {
977
+ return stagesApi.create(agentId, payload);
978
+ },
979
+ update(stageId, payload) {
980
+ return stagesApi.update(agentId, stageId, payload);
981
+ },
982
+ delete(stageId) {
983
+ return stagesApi.delete(agentId, stageId);
984
+ },
985
+ reorder(payload) {
986
+ return stagesApi.reorder(agentId, payload);
987
+ },
988
+ triggers(stageId) {
989
+ return bindAgentStageTriggers(triggersApi, agentId, stageId);
990
+ }
991
+ });
808
992
  var bindAgentTags = (api, agentId) => ({
809
993
  add(tagId) {
810
994
  return api.add(agentId, { tagId });
@@ -918,6 +1102,8 @@ var createAgentEntity = (dto, options) => {
918
1102
  scheduleExceptionsApi,
919
1103
  versionsApi,
920
1104
  blueprintsApi,
1105
+ stagesApi,
1106
+ stageTriggersApi,
921
1107
  reload,
922
1108
  updateAgent,
923
1109
  deleteAgent
@@ -934,6 +1120,7 @@ var createAgentEntity = (dto, options) => {
934
1120
  ),
935
1121
  versions: bindAgentVersions(versionsApi, dto.agentId),
936
1122
  blueprints: bindAgentBlueprints(blueprintsApi, dto.agentId),
1123
+ stages: bindAgentStages(stagesApi, stageTriggersApi, dto.agentId),
937
1124
  async save(patch) {
938
1125
  return updateAgent(dto.agentId, patch);
939
1126
  },
@@ -1018,6 +1205,8 @@ function createAgentsApi(cfg, relatedApis) {
1018
1205
  scheduleExceptionsApi: relatedApis.scheduleExceptionsApi,
1019
1206
  versionsApi: relatedApis.versionsApi,
1020
1207
  blueprintsApi: relatedApis.blueprintsApi,
1208
+ stagesApi: relatedApis.stagesApi,
1209
+ stageTriggersApi: relatedApis.stageTriggersApi,
1021
1210
  reload: async (agentId) => {
1022
1211
  const latest = await getAgentDetail(agentId);
1023
1212
  return wrapAgent(latest);
@@ -1342,7 +1531,7 @@ function ensureCatalogTypeFilter(filter, type) {
1342
1531
  if (isQueryBuilderLike(filter)) {
1343
1532
  return ensureTypeForBuilder(filter, requiredQuery, requiredExpression);
1344
1533
  }
1345
- if (isPlainObject2(filter)) {
1534
+ if (isFilterRecord(filter)) {
1346
1535
  return ensureTypeForObject(filter, type);
1347
1536
  }
1348
1537
  return filter;
@@ -1372,7 +1561,7 @@ function ensureTypeForObject(candidate, type) {
1372
1561
  return candidate;
1373
1562
  }
1374
1563
  const typeConfig = candidate.type;
1375
- const normalizedType = isPlainObject2(typeConfig) ? { ...typeConfig, eq: type } : { eq: type };
1564
+ const normalizedType = isFilterOperators(typeConfig) ? { ...typeConfig, eq: type } : { eq: type };
1376
1565
  return {
1377
1566
  ...candidate,
1378
1567
  type: normalizedType
@@ -1383,10 +1572,11 @@ function hasTypeEquality(candidate, type) {
1383
1572
  if (typeof typeConfig === "string") {
1384
1573
  return typeConfig === type;
1385
1574
  }
1386
- if (!isPlainObject2(typeConfig)) {
1575
+ if (!isFilterOperators(typeConfig)) {
1387
1576
  return false;
1388
1577
  }
1389
- return typeConfig.eq === type;
1578
+ const equality = typeConfig.eq;
1579
+ return typeof equality === "string" ? equality === type : false;
1390
1580
  }
1391
1581
  function containsTypePredicate(expression, required) {
1392
1582
  const normalizedExpression = expression.replace(/\s+/g, "").toLowerCase();
@@ -1403,6 +1593,12 @@ function isPlainObject2(value) {
1403
1593
  const proto = Object.getPrototypeOf(value);
1404
1594
  return proto === Object.prototype || proto === null;
1405
1595
  }
1596
+ function isFilterRecord(value) {
1597
+ return isPlainObject2(value);
1598
+ }
1599
+ function isFilterOperators(value) {
1600
+ return isPlainObject2(value);
1601
+ }
1406
1602
 
1407
1603
  // src/api/voices.ts
1408
1604
  function mapCatalogResponseToVoiceList(response) {
@@ -1639,6 +1835,8 @@ function createClient(initialCfg) {
1639
1835
  const scheduleExceptionsApi = createAgentScheduleExceptionsApi(runtimeCfg);
1640
1836
  const versionsApi = createAgentVersionsApi(runtimeCfg);
1641
1837
  const blueprintsApi = createAgentBlueprintsApi(runtimeCfg);
1838
+ const stageTriggersApi = createAgentStageTriggersApi(runtimeCfg);
1839
+ const stagesApi = createAgentStagesApi(runtimeCfg);
1642
1840
  const voicesApi = createVoicesApi(runtimeCfg);
1643
1841
  const apiKeysApi = createApiKeysApi(runtimeCfg);
1644
1842
  const catalogsApi = createCatalogsApi(runtimeCfg);
@@ -1650,7 +1848,9 @@ function createClient(initialCfg) {
1650
1848
  scheduleApi,
1651
1849
  scheduleExceptionsApi,
1652
1850
  versionsApi,
1653
- blueprintsApi
1851
+ blueprintsApi,
1852
+ stagesApi,
1853
+ stageTriggersApi
1654
1854
  });
1655
1855
  const instructionsNamespace = Object.assign(
1656
1856
  (agentId) => bindAgentInstructions(instructionsApi, agentId),
@@ -1683,6 +1883,17 @@ function createClient(initialCfg) {
1683
1883
  (agentId) => bindAgentBlueprints(blueprintsApi, agentId),
1684
1884
  blueprintsApi
1685
1885
  );
1886
+ const stageTriggersNamespace = Object.assign(
1887
+ (agentId, stageId) => bindAgentStageTriggers(stageTriggersApi, agentId, stageId),
1888
+ stageTriggersApi
1889
+ );
1890
+ const stagesNamespace = Object.assign(
1891
+ (agentId) => bindAgentStages(stagesApi, stageTriggersApi, agentId),
1892
+ {
1893
+ ...stagesApi,
1894
+ triggers: stageTriggersNamespace
1895
+ }
1896
+ );
1686
1897
  const apis = {
1687
1898
  agents: {
1688
1899
  ...agentsApi,
@@ -1691,7 +1902,8 @@ function createClient(initialCfg) {
1691
1902
  phones: phonesNamespace,
1692
1903
  schedule: scheduleNamespace,
1693
1904
  versions: versionsNamespace,
1694
- blueprints: blueprintsNamespace
1905
+ blueprints: blueprintsNamespace,
1906
+ stages: stagesNamespace
1695
1907
  },
1696
1908
  workspaces: createWorkspacesApi(runtimeCfg),
1697
1909
  tools: createToolsApi(runtimeCfg),
@@ -1765,6 +1977,8 @@ function createClient(initialCfg) {
1765
1977
  bindAgentPhones,
1766
1978
  bindAgentSchedule,
1767
1979
  bindAgentScheduleExceptions,
1980
+ bindAgentStageTriggers,
1981
+ bindAgentStages,
1768
1982
  bindAgentTags,
1769
1983
  bindAgentVersions,
1770
1984
  createAgentBlueprintsApi,
@@ -1773,6 +1987,8 @@ function createClient(initialCfg) {
1773
1987
  createAgentPhonesApi,
1774
1988
  createAgentScheduleApi,
1775
1989
  createAgentScheduleExceptionsApi,
1990
+ createAgentStageTriggersApi,
1991
+ createAgentStagesApi,
1776
1992
  createAgentTagsApi,
1777
1993
  createAgentVersionsApi,
1778
1994
  createAgentsApi,