@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.js
CHANGED
|
@@ -509,6 +509,69 @@ function createAgentPhonesApi(cfg) {
|
|
|
509
509
|
};
|
|
510
510
|
}
|
|
511
511
|
|
|
512
|
+
// src/api/agent-schedule-exceptions.ts
|
|
513
|
+
function createAgentScheduleExceptionsApi(cfg) {
|
|
514
|
+
const { base, doFetch } = createHttp(cfg);
|
|
515
|
+
const jsonHeaders = { "content-type": "application/json" };
|
|
516
|
+
const fetchExceptionsPage = async (agentId, options = {}) => {
|
|
517
|
+
const query = serializeListOptions(options ?? {});
|
|
518
|
+
const res = await doFetch(`${base}/agents/${agentId}/schedule/exceptions`, {
|
|
519
|
+
method: "GET",
|
|
520
|
+
query
|
|
521
|
+
});
|
|
522
|
+
return res.json();
|
|
523
|
+
};
|
|
524
|
+
return {
|
|
525
|
+
async list(agentId, options = {}) {
|
|
526
|
+
const normalizedOptions = {
|
|
527
|
+
...options ?? {}
|
|
528
|
+
};
|
|
529
|
+
const fetchPage = (pageOptions) => fetchExceptionsPage(agentId, pageOptions);
|
|
530
|
+
const response = await fetchPage(normalizedOptions);
|
|
531
|
+
return attachPaginator(response, fetchPage, normalizedOptions);
|
|
532
|
+
},
|
|
533
|
+
async get(agentId, exceptionId) {
|
|
534
|
+
const res = await doFetch(
|
|
535
|
+
`${base}/agents/${agentId}/schedule/exceptions/${exceptionId}`,
|
|
536
|
+
{
|
|
537
|
+
method: "GET"
|
|
538
|
+
}
|
|
539
|
+
);
|
|
540
|
+
return res.json();
|
|
541
|
+
},
|
|
542
|
+
async create(agentId, payload) {
|
|
543
|
+
const res = await doFetch(
|
|
544
|
+
`${base}/agents/${agentId}/schedule/exceptions`,
|
|
545
|
+
{
|
|
546
|
+
method: "POST",
|
|
547
|
+
headers: jsonHeaders,
|
|
548
|
+
body: JSON.stringify(payload)
|
|
549
|
+
}
|
|
550
|
+
);
|
|
551
|
+
return res.json();
|
|
552
|
+
},
|
|
553
|
+
async update(agentId, exceptionId, payload) {
|
|
554
|
+
const res = await doFetch(
|
|
555
|
+
`${base}/agents/${agentId}/schedule/exceptions/${exceptionId}`,
|
|
556
|
+
{
|
|
557
|
+
method: "PATCH",
|
|
558
|
+
headers: jsonHeaders,
|
|
559
|
+
body: JSON.stringify(payload)
|
|
560
|
+
}
|
|
561
|
+
);
|
|
562
|
+
return res.json();
|
|
563
|
+
},
|
|
564
|
+
async delete(agentId, exceptionId) {
|
|
565
|
+
await doFetch(
|
|
566
|
+
`${base}/agents/${agentId}/schedule/exceptions/${exceptionId}`,
|
|
567
|
+
{
|
|
568
|
+
method: "DELETE"
|
|
569
|
+
}
|
|
570
|
+
);
|
|
571
|
+
}
|
|
572
|
+
};
|
|
573
|
+
}
|
|
574
|
+
|
|
512
575
|
// src/api/agent-schedule.ts
|
|
513
576
|
function createAgentScheduleApi(cfg) {
|
|
514
577
|
const { base, doFetch } = createHttp(cfg);
|
|
@@ -539,39 +602,52 @@ function createAgentScheduleApi(cfg) {
|
|
|
539
602
|
};
|
|
540
603
|
}
|
|
541
604
|
|
|
542
|
-
// src/api/agent-
|
|
543
|
-
function
|
|
605
|
+
// src/api/agent-stage-triggers.ts
|
|
606
|
+
function createAgentStageTriggersApi(cfg) {
|
|
544
607
|
const { base, doFetch } = createHttp(cfg);
|
|
545
608
|
const jsonHeaders = { "content-type": "application/json" };
|
|
546
|
-
const
|
|
547
|
-
const
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
609
|
+
const fetchTriggerPage = async (agentId, stageId, options = {}) => {
|
|
610
|
+
const normalizedOptions = {
|
|
611
|
+
page: options.page,
|
|
612
|
+
limit: options.limit,
|
|
613
|
+
sort: options.sort,
|
|
614
|
+
fields: options.fields,
|
|
615
|
+
include: options.include,
|
|
616
|
+
filter: options.filter,
|
|
617
|
+
search: options.search,
|
|
618
|
+
or: options.or
|
|
619
|
+
};
|
|
620
|
+
const query = serializeListOptions(normalizedOptions);
|
|
621
|
+
const res = await doFetch(
|
|
622
|
+
`${base}/agents/${agentId}/stages/${stageId}/triggers`,
|
|
623
|
+
{
|
|
624
|
+
method: "GET",
|
|
625
|
+
query
|
|
626
|
+
}
|
|
627
|
+
);
|
|
552
628
|
return res.json();
|
|
553
629
|
};
|
|
554
630
|
return {
|
|
555
|
-
async list(agentId, options = {}) {
|
|
556
|
-
const
|
|
631
|
+
async list(agentId, stageId, options = {}) {
|
|
632
|
+
const normalized = {
|
|
557
633
|
...options ?? {}
|
|
558
634
|
};
|
|
559
|
-
const fetchPage = (
|
|
560
|
-
const response = await fetchPage(
|
|
561
|
-
return attachPaginator(response, fetchPage,
|
|
635
|
+
const fetchPage = (opts) => fetchTriggerPage(agentId, stageId, opts);
|
|
636
|
+
const response = await fetchPage(normalized);
|
|
637
|
+
return attachPaginator(response, fetchPage, normalized);
|
|
562
638
|
},
|
|
563
|
-
async get(agentId,
|
|
639
|
+
async get(agentId, stageId, triggerId) {
|
|
564
640
|
const res = await doFetch(
|
|
565
|
-
`${base}/agents/${agentId}/
|
|
641
|
+
`${base}/agents/${agentId}/stages/${stageId}/triggers/${triggerId}`,
|
|
566
642
|
{
|
|
567
643
|
method: "GET"
|
|
568
644
|
}
|
|
569
645
|
);
|
|
570
646
|
return res.json();
|
|
571
647
|
},
|
|
572
|
-
async create(agentId, payload) {
|
|
648
|
+
async create(agentId, stageId, payload) {
|
|
573
649
|
const res = await doFetch(
|
|
574
|
-
`${base}/agents/${agentId}/
|
|
650
|
+
`${base}/agents/${agentId}/stages/${stageId}/triggers`,
|
|
575
651
|
{
|
|
576
652
|
method: "POST",
|
|
577
653
|
headers: jsonHeaders,
|
|
@@ -580,9 +656,9 @@ function createAgentScheduleExceptionsApi(cfg) {
|
|
|
580
656
|
);
|
|
581
657
|
return res.json();
|
|
582
658
|
},
|
|
583
|
-
async update(agentId,
|
|
659
|
+
async update(agentId, stageId, triggerId, payload) {
|
|
584
660
|
const res = await doFetch(
|
|
585
|
-
`${base}/agents/${agentId}/
|
|
661
|
+
`${base}/agents/${agentId}/stages/${stageId}/triggers/${triggerId}`,
|
|
586
662
|
{
|
|
587
663
|
method: "PATCH",
|
|
588
664
|
headers: jsonHeaders,
|
|
@@ -591,9 +667,9 @@ function createAgentScheduleExceptionsApi(cfg) {
|
|
|
591
667
|
);
|
|
592
668
|
return res.json();
|
|
593
669
|
},
|
|
594
|
-
async delete(agentId,
|
|
670
|
+
async delete(agentId, stageId, triggerId) {
|
|
595
671
|
await doFetch(
|
|
596
|
-
`${base}/agents/${agentId}/
|
|
672
|
+
`${base}/agents/${agentId}/stages/${stageId}/triggers/${triggerId}`,
|
|
597
673
|
{
|
|
598
674
|
method: "DELETE"
|
|
599
675
|
}
|
|
@@ -602,6 +678,70 @@ function createAgentScheduleExceptionsApi(cfg) {
|
|
|
602
678
|
};
|
|
603
679
|
}
|
|
604
680
|
|
|
681
|
+
// src/api/agent-stages.ts
|
|
682
|
+
function createAgentStagesApi(cfg) {
|
|
683
|
+
const { base, doFetch } = createHttp(cfg);
|
|
684
|
+
const jsonHeaders = { "content-type": "application/json" };
|
|
685
|
+
const fetchStagePage = async (agentId, options = {}) => {
|
|
686
|
+
const normalizedOptions = {
|
|
687
|
+
page: options.page,
|
|
688
|
+
limit: options.limit,
|
|
689
|
+
sort: options.sort,
|
|
690
|
+
filter: options.filter,
|
|
691
|
+
search: options.search
|
|
692
|
+
};
|
|
693
|
+
const query = serializeListOptions(normalizedOptions);
|
|
694
|
+
const res = await doFetch(`${base}/agents/${agentId}/stages`, {
|
|
695
|
+
method: "GET",
|
|
696
|
+
query
|
|
697
|
+
});
|
|
698
|
+
return res.json();
|
|
699
|
+
};
|
|
700
|
+
return {
|
|
701
|
+
async list(agentId, options = {}) {
|
|
702
|
+
const normalized = { ...options ?? {} };
|
|
703
|
+
const fetchPage = (opts) => fetchStagePage(agentId, opts);
|
|
704
|
+
const response = await fetchPage(normalized);
|
|
705
|
+
return attachPaginator(response, fetchPage, normalized);
|
|
706
|
+
},
|
|
707
|
+
async get(agentId, stageId) {
|
|
708
|
+
const res = await doFetch(`${base}/agents/${agentId}/stages/${stageId}`, {
|
|
709
|
+
method: "GET"
|
|
710
|
+
});
|
|
711
|
+
return res.json();
|
|
712
|
+
},
|
|
713
|
+
async create(agentId, payload) {
|
|
714
|
+
const res = await doFetch(`${base}/agents/${agentId}/stages`, {
|
|
715
|
+
method: "POST",
|
|
716
|
+
headers: jsonHeaders,
|
|
717
|
+
body: JSON.stringify(payload)
|
|
718
|
+
});
|
|
719
|
+
return res.json();
|
|
720
|
+
},
|
|
721
|
+
async update(agentId, stageId, payload) {
|
|
722
|
+
const res = await doFetch(`${base}/agents/${agentId}/stages/${stageId}`, {
|
|
723
|
+
method: "PATCH",
|
|
724
|
+
headers: jsonHeaders,
|
|
725
|
+
body: JSON.stringify(payload)
|
|
726
|
+
});
|
|
727
|
+
return res.json();
|
|
728
|
+
},
|
|
729
|
+
async delete(agentId, stageId) {
|
|
730
|
+
await doFetch(`${base}/agents/${agentId}/stages/${stageId}`, {
|
|
731
|
+
method: "DELETE"
|
|
732
|
+
});
|
|
733
|
+
},
|
|
734
|
+
async reorder(agentId, payload) {
|
|
735
|
+
const res = await doFetch(`${base}/agents/${agentId}/stages:reorder`, {
|
|
736
|
+
method: "POST",
|
|
737
|
+
headers: jsonHeaders,
|
|
738
|
+
body: JSON.stringify(payload)
|
|
739
|
+
});
|
|
740
|
+
return res.json();
|
|
741
|
+
}
|
|
742
|
+
};
|
|
743
|
+
}
|
|
744
|
+
|
|
605
745
|
// src/api/agent-tags.ts
|
|
606
746
|
function createAgentTagsApi(cfg) {
|
|
607
747
|
const { base, doFetch } = createHttp(cfg);
|
|
@@ -754,6 +894,46 @@ var bindAgentInstructions = (api, agentId) => ({
|
|
|
754
894
|
return api.delete(agentId, instructionId);
|
|
755
895
|
}
|
|
756
896
|
});
|
|
897
|
+
var bindAgentStageTriggers = (api, agentId, stageId) => ({
|
|
898
|
+
list(opts) {
|
|
899
|
+
return api.list(agentId, stageId, opts);
|
|
900
|
+
},
|
|
901
|
+
get(triggerId) {
|
|
902
|
+
return api.get(agentId, stageId, triggerId);
|
|
903
|
+
},
|
|
904
|
+
create(payload) {
|
|
905
|
+
return api.create(agentId, stageId, payload);
|
|
906
|
+
},
|
|
907
|
+
update(triggerId, payload) {
|
|
908
|
+
return api.update(agentId, stageId, triggerId, payload);
|
|
909
|
+
},
|
|
910
|
+
delete(triggerId) {
|
|
911
|
+
return api.delete(agentId, stageId, triggerId);
|
|
912
|
+
}
|
|
913
|
+
});
|
|
914
|
+
var bindAgentStages = (stagesApi, triggersApi, agentId) => ({
|
|
915
|
+
list(opts) {
|
|
916
|
+
return stagesApi.list(agentId, opts);
|
|
917
|
+
},
|
|
918
|
+
get(stageId) {
|
|
919
|
+
return stagesApi.get(agentId, stageId);
|
|
920
|
+
},
|
|
921
|
+
create(payload) {
|
|
922
|
+
return stagesApi.create(agentId, payload);
|
|
923
|
+
},
|
|
924
|
+
update(stageId, payload) {
|
|
925
|
+
return stagesApi.update(agentId, stageId, payload);
|
|
926
|
+
},
|
|
927
|
+
delete(stageId) {
|
|
928
|
+
return stagesApi.delete(agentId, stageId);
|
|
929
|
+
},
|
|
930
|
+
reorder(payload) {
|
|
931
|
+
return stagesApi.reorder(agentId, payload);
|
|
932
|
+
},
|
|
933
|
+
triggers(stageId) {
|
|
934
|
+
return bindAgentStageTriggers(triggersApi, agentId, stageId);
|
|
935
|
+
}
|
|
936
|
+
});
|
|
757
937
|
var bindAgentTags = (api, agentId) => ({
|
|
758
938
|
add(tagId) {
|
|
759
939
|
return api.add(agentId, { tagId });
|
|
@@ -867,6 +1047,8 @@ var createAgentEntity = (dto, options) => {
|
|
|
867
1047
|
scheduleExceptionsApi,
|
|
868
1048
|
versionsApi,
|
|
869
1049
|
blueprintsApi,
|
|
1050
|
+
stagesApi,
|
|
1051
|
+
stageTriggersApi,
|
|
870
1052
|
reload,
|
|
871
1053
|
updateAgent,
|
|
872
1054
|
deleteAgent
|
|
@@ -883,6 +1065,7 @@ var createAgentEntity = (dto, options) => {
|
|
|
883
1065
|
),
|
|
884
1066
|
versions: bindAgentVersions(versionsApi, dto.agentId),
|
|
885
1067
|
blueprints: bindAgentBlueprints(blueprintsApi, dto.agentId),
|
|
1068
|
+
stages: bindAgentStages(stagesApi, stageTriggersApi, dto.agentId),
|
|
886
1069
|
async save(patch) {
|
|
887
1070
|
return updateAgent(dto.agentId, patch);
|
|
888
1071
|
},
|
|
@@ -967,6 +1150,8 @@ function createAgentsApi(cfg, relatedApis) {
|
|
|
967
1150
|
scheduleExceptionsApi: relatedApis.scheduleExceptionsApi,
|
|
968
1151
|
versionsApi: relatedApis.versionsApi,
|
|
969
1152
|
blueprintsApi: relatedApis.blueprintsApi,
|
|
1153
|
+
stagesApi: relatedApis.stagesApi,
|
|
1154
|
+
stageTriggersApi: relatedApis.stageTriggersApi,
|
|
970
1155
|
reload: async (agentId) => {
|
|
971
1156
|
const latest = await getAgentDetail(agentId);
|
|
972
1157
|
return wrapAgent(latest);
|
|
@@ -1588,6 +1773,8 @@ function createClient(initialCfg) {
|
|
|
1588
1773
|
const scheduleExceptionsApi = createAgentScheduleExceptionsApi(runtimeCfg);
|
|
1589
1774
|
const versionsApi = createAgentVersionsApi(runtimeCfg);
|
|
1590
1775
|
const blueprintsApi = createAgentBlueprintsApi(runtimeCfg);
|
|
1776
|
+
const stageTriggersApi = createAgentStageTriggersApi(runtimeCfg);
|
|
1777
|
+
const stagesApi = createAgentStagesApi(runtimeCfg);
|
|
1591
1778
|
const voicesApi = createVoicesApi(runtimeCfg);
|
|
1592
1779
|
const apiKeysApi = createApiKeysApi(runtimeCfg);
|
|
1593
1780
|
const catalogsApi = createCatalogsApi(runtimeCfg);
|
|
@@ -1599,7 +1786,9 @@ function createClient(initialCfg) {
|
|
|
1599
1786
|
scheduleApi,
|
|
1600
1787
|
scheduleExceptionsApi,
|
|
1601
1788
|
versionsApi,
|
|
1602
|
-
blueprintsApi
|
|
1789
|
+
blueprintsApi,
|
|
1790
|
+
stagesApi,
|
|
1791
|
+
stageTriggersApi
|
|
1603
1792
|
});
|
|
1604
1793
|
const instructionsNamespace = Object.assign(
|
|
1605
1794
|
(agentId) => bindAgentInstructions(instructionsApi, agentId),
|
|
@@ -1632,6 +1821,17 @@ function createClient(initialCfg) {
|
|
|
1632
1821
|
(agentId) => bindAgentBlueprints(blueprintsApi, agentId),
|
|
1633
1822
|
blueprintsApi
|
|
1634
1823
|
);
|
|
1824
|
+
const stageTriggersNamespace = Object.assign(
|
|
1825
|
+
(agentId, stageId) => bindAgentStageTriggers(stageTriggersApi, agentId, stageId),
|
|
1826
|
+
stageTriggersApi
|
|
1827
|
+
);
|
|
1828
|
+
const stagesNamespace = Object.assign(
|
|
1829
|
+
(agentId) => bindAgentStages(stagesApi, stageTriggersApi, agentId),
|
|
1830
|
+
{
|
|
1831
|
+
...stagesApi,
|
|
1832
|
+
triggers: stageTriggersNamespace
|
|
1833
|
+
}
|
|
1834
|
+
);
|
|
1635
1835
|
const apis = {
|
|
1636
1836
|
agents: {
|
|
1637
1837
|
...agentsApi,
|
|
@@ -1640,7 +1840,8 @@ function createClient(initialCfg) {
|
|
|
1640
1840
|
phones: phonesNamespace,
|
|
1641
1841
|
schedule: scheduleNamespace,
|
|
1642
1842
|
versions: versionsNamespace,
|
|
1643
|
-
blueprints: blueprintsNamespace
|
|
1843
|
+
blueprints: blueprintsNamespace,
|
|
1844
|
+
stages: stagesNamespace
|
|
1644
1845
|
},
|
|
1645
1846
|
workspaces: createWorkspacesApi(runtimeCfg),
|
|
1646
1847
|
tools: createToolsApi(runtimeCfg),
|
|
@@ -1713,6 +1914,8 @@ export {
|
|
|
1713
1914
|
bindAgentPhones,
|
|
1714
1915
|
bindAgentSchedule,
|
|
1715
1916
|
bindAgentScheduleExceptions,
|
|
1917
|
+
bindAgentStageTriggers,
|
|
1918
|
+
bindAgentStages,
|
|
1716
1919
|
bindAgentTags,
|
|
1717
1920
|
bindAgentVersions,
|
|
1718
1921
|
createAgentBlueprintsApi,
|
|
@@ -1721,6 +1924,8 @@ export {
|
|
|
1721
1924
|
createAgentPhonesApi,
|
|
1722
1925
|
createAgentScheduleApi,
|
|
1723
1926
|
createAgentScheduleExceptionsApi,
|
|
1927
|
+
createAgentStageTriggersApi,
|
|
1928
|
+
createAgentStagesApi,
|
|
1724
1929
|
createAgentTagsApi,
|
|
1725
1930
|
createAgentVersionsApi,
|
|
1726
1931
|
createAgentsApi,
|