@getsupervisor/agents-studio-sdk 1.22.2 → 1.23.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 +232 -23
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1099 -271
- package/dist/index.d.ts +1099 -271
- package/dist/index.js +228 -23
- package/dist/index.js.map +1 -1
- package/package.json +4 -2
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-
|
|
594
|
-
function
|
|
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
|
|
598
|
-
const
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
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
|
|
686
|
+
async list(agentId, stageId, options = {}) {
|
|
687
|
+
const normalized = {
|
|
608
688
|
...options ?? {}
|
|
609
689
|
};
|
|
610
|
-
const fetchPage = (
|
|
611
|
-
const response = await fetchPage(
|
|
612
|
-
return attachPaginator(response, fetchPage,
|
|
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,
|
|
694
|
+
async get(agentId, stageId, triggerId) {
|
|
615
695
|
const res = await doFetch(
|
|
616
|
-
`${base}/agents/${agentId}/
|
|
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}/
|
|
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,
|
|
714
|
+
async update(agentId, stageId, triggerId, payload) {
|
|
635
715
|
const res = await doFetch(
|
|
636
|
-
`${base}/agents/${agentId}/
|
|
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,
|
|
725
|
+
async delete(agentId, stageId, triggerId) {
|
|
646
726
|
await doFetch(
|
|
647
|
-
`${base}/agents/${agentId}/
|
|
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);
|
|
@@ -1639,6 +1828,8 @@ function createClient(initialCfg) {
|
|
|
1639
1828
|
const scheduleExceptionsApi = createAgentScheduleExceptionsApi(runtimeCfg);
|
|
1640
1829
|
const versionsApi = createAgentVersionsApi(runtimeCfg);
|
|
1641
1830
|
const blueprintsApi = createAgentBlueprintsApi(runtimeCfg);
|
|
1831
|
+
const stageTriggersApi = createAgentStageTriggersApi(runtimeCfg);
|
|
1832
|
+
const stagesApi = createAgentStagesApi(runtimeCfg);
|
|
1642
1833
|
const voicesApi = createVoicesApi(runtimeCfg);
|
|
1643
1834
|
const apiKeysApi = createApiKeysApi(runtimeCfg);
|
|
1644
1835
|
const catalogsApi = createCatalogsApi(runtimeCfg);
|
|
@@ -1650,7 +1841,9 @@ function createClient(initialCfg) {
|
|
|
1650
1841
|
scheduleApi,
|
|
1651
1842
|
scheduleExceptionsApi,
|
|
1652
1843
|
versionsApi,
|
|
1653
|
-
blueprintsApi
|
|
1844
|
+
blueprintsApi,
|
|
1845
|
+
stagesApi,
|
|
1846
|
+
stageTriggersApi
|
|
1654
1847
|
});
|
|
1655
1848
|
const instructionsNamespace = Object.assign(
|
|
1656
1849
|
(agentId) => bindAgentInstructions(instructionsApi, agentId),
|
|
@@ -1683,6 +1876,17 @@ function createClient(initialCfg) {
|
|
|
1683
1876
|
(agentId) => bindAgentBlueprints(blueprintsApi, agentId),
|
|
1684
1877
|
blueprintsApi
|
|
1685
1878
|
);
|
|
1879
|
+
const stageTriggersNamespace = Object.assign(
|
|
1880
|
+
(agentId, stageId) => bindAgentStageTriggers(stageTriggersApi, agentId, stageId),
|
|
1881
|
+
stageTriggersApi
|
|
1882
|
+
);
|
|
1883
|
+
const stagesNamespace = Object.assign(
|
|
1884
|
+
(agentId) => bindAgentStages(stagesApi, stageTriggersApi, agentId),
|
|
1885
|
+
{
|
|
1886
|
+
...stagesApi,
|
|
1887
|
+
triggers: stageTriggersNamespace
|
|
1888
|
+
}
|
|
1889
|
+
);
|
|
1686
1890
|
const apis = {
|
|
1687
1891
|
agents: {
|
|
1688
1892
|
...agentsApi,
|
|
@@ -1691,7 +1895,8 @@ function createClient(initialCfg) {
|
|
|
1691
1895
|
phones: phonesNamespace,
|
|
1692
1896
|
schedule: scheduleNamespace,
|
|
1693
1897
|
versions: versionsNamespace,
|
|
1694
|
-
blueprints: blueprintsNamespace
|
|
1898
|
+
blueprints: blueprintsNamespace,
|
|
1899
|
+
stages: stagesNamespace
|
|
1695
1900
|
},
|
|
1696
1901
|
workspaces: createWorkspacesApi(runtimeCfg),
|
|
1697
1902
|
tools: createToolsApi(runtimeCfg),
|
|
@@ -1765,6 +1970,8 @@ function createClient(initialCfg) {
|
|
|
1765
1970
|
bindAgentPhones,
|
|
1766
1971
|
bindAgentSchedule,
|
|
1767
1972
|
bindAgentScheduleExceptions,
|
|
1973
|
+
bindAgentStageTriggers,
|
|
1974
|
+
bindAgentStages,
|
|
1768
1975
|
bindAgentTags,
|
|
1769
1976
|
bindAgentVersions,
|
|
1770
1977
|
createAgentBlueprintsApi,
|
|
@@ -1773,6 +1980,8 @@ function createClient(initialCfg) {
|
|
|
1773
1980
|
createAgentPhonesApi,
|
|
1774
1981
|
createAgentScheduleApi,
|
|
1775
1982
|
createAgentScheduleExceptionsApi,
|
|
1983
|
+
createAgentStageTriggersApi,
|
|
1984
|
+
createAgentStagesApi,
|
|
1776
1985
|
createAgentTagsApi,
|
|
1777
1986
|
createAgentVersionsApi,
|
|
1778
1987
|
createAgentsApi,
|