@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 +243 -27
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1117 -275
- package/dist/index.d.ts +1117 -275
- package/dist/index.js +239 -27
- 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);
|
|
@@ -1291,7 +1476,7 @@ function ensureCatalogTypeFilter(filter, type) {
|
|
|
1291
1476
|
if (isQueryBuilderLike(filter)) {
|
|
1292
1477
|
return ensureTypeForBuilder(filter, requiredQuery, requiredExpression);
|
|
1293
1478
|
}
|
|
1294
|
-
if (
|
|
1479
|
+
if (isFilterRecord(filter)) {
|
|
1295
1480
|
return ensureTypeForObject(filter, type);
|
|
1296
1481
|
}
|
|
1297
1482
|
return filter;
|
|
@@ -1321,7 +1506,7 @@ function ensureTypeForObject(candidate, type) {
|
|
|
1321
1506
|
return candidate;
|
|
1322
1507
|
}
|
|
1323
1508
|
const typeConfig = candidate.type;
|
|
1324
|
-
const normalizedType =
|
|
1509
|
+
const normalizedType = isFilterOperators(typeConfig) ? { ...typeConfig, eq: type } : { eq: type };
|
|
1325
1510
|
return {
|
|
1326
1511
|
...candidate,
|
|
1327
1512
|
type: normalizedType
|
|
@@ -1332,10 +1517,11 @@ function hasTypeEquality(candidate, type) {
|
|
|
1332
1517
|
if (typeof typeConfig === "string") {
|
|
1333
1518
|
return typeConfig === type;
|
|
1334
1519
|
}
|
|
1335
|
-
if (!
|
|
1520
|
+
if (!isFilterOperators(typeConfig)) {
|
|
1336
1521
|
return false;
|
|
1337
1522
|
}
|
|
1338
|
-
|
|
1523
|
+
const equality = typeConfig.eq;
|
|
1524
|
+
return typeof equality === "string" ? equality === type : false;
|
|
1339
1525
|
}
|
|
1340
1526
|
function containsTypePredicate(expression, required) {
|
|
1341
1527
|
const normalizedExpression = expression.replace(/\s+/g, "").toLowerCase();
|
|
@@ -1352,6 +1538,12 @@ function isPlainObject2(value) {
|
|
|
1352
1538
|
const proto = Object.getPrototypeOf(value);
|
|
1353
1539
|
return proto === Object.prototype || proto === null;
|
|
1354
1540
|
}
|
|
1541
|
+
function isFilterRecord(value) {
|
|
1542
|
+
return isPlainObject2(value);
|
|
1543
|
+
}
|
|
1544
|
+
function isFilterOperators(value) {
|
|
1545
|
+
return isPlainObject2(value);
|
|
1546
|
+
}
|
|
1355
1547
|
|
|
1356
1548
|
// src/api/voices.ts
|
|
1357
1549
|
function mapCatalogResponseToVoiceList(response) {
|
|
@@ -1588,6 +1780,8 @@ function createClient(initialCfg) {
|
|
|
1588
1780
|
const scheduleExceptionsApi = createAgentScheduleExceptionsApi(runtimeCfg);
|
|
1589
1781
|
const versionsApi = createAgentVersionsApi(runtimeCfg);
|
|
1590
1782
|
const blueprintsApi = createAgentBlueprintsApi(runtimeCfg);
|
|
1783
|
+
const stageTriggersApi = createAgentStageTriggersApi(runtimeCfg);
|
|
1784
|
+
const stagesApi = createAgentStagesApi(runtimeCfg);
|
|
1591
1785
|
const voicesApi = createVoicesApi(runtimeCfg);
|
|
1592
1786
|
const apiKeysApi = createApiKeysApi(runtimeCfg);
|
|
1593
1787
|
const catalogsApi = createCatalogsApi(runtimeCfg);
|
|
@@ -1599,7 +1793,9 @@ function createClient(initialCfg) {
|
|
|
1599
1793
|
scheduleApi,
|
|
1600
1794
|
scheduleExceptionsApi,
|
|
1601
1795
|
versionsApi,
|
|
1602
|
-
blueprintsApi
|
|
1796
|
+
blueprintsApi,
|
|
1797
|
+
stagesApi,
|
|
1798
|
+
stageTriggersApi
|
|
1603
1799
|
});
|
|
1604
1800
|
const instructionsNamespace = Object.assign(
|
|
1605
1801
|
(agentId) => bindAgentInstructions(instructionsApi, agentId),
|
|
@@ -1632,6 +1828,17 @@ function createClient(initialCfg) {
|
|
|
1632
1828
|
(agentId) => bindAgentBlueprints(blueprintsApi, agentId),
|
|
1633
1829
|
blueprintsApi
|
|
1634
1830
|
);
|
|
1831
|
+
const stageTriggersNamespace = Object.assign(
|
|
1832
|
+
(agentId, stageId) => bindAgentStageTriggers(stageTriggersApi, agentId, stageId),
|
|
1833
|
+
stageTriggersApi
|
|
1834
|
+
);
|
|
1835
|
+
const stagesNamespace = Object.assign(
|
|
1836
|
+
(agentId) => bindAgentStages(stagesApi, stageTriggersApi, agentId),
|
|
1837
|
+
{
|
|
1838
|
+
...stagesApi,
|
|
1839
|
+
triggers: stageTriggersNamespace
|
|
1840
|
+
}
|
|
1841
|
+
);
|
|
1635
1842
|
const apis = {
|
|
1636
1843
|
agents: {
|
|
1637
1844
|
...agentsApi,
|
|
@@ -1640,7 +1847,8 @@ function createClient(initialCfg) {
|
|
|
1640
1847
|
phones: phonesNamespace,
|
|
1641
1848
|
schedule: scheduleNamespace,
|
|
1642
1849
|
versions: versionsNamespace,
|
|
1643
|
-
blueprints: blueprintsNamespace
|
|
1850
|
+
blueprints: blueprintsNamespace,
|
|
1851
|
+
stages: stagesNamespace
|
|
1644
1852
|
},
|
|
1645
1853
|
workspaces: createWorkspacesApi(runtimeCfg),
|
|
1646
1854
|
tools: createToolsApi(runtimeCfg),
|
|
@@ -1713,6 +1921,8 @@ export {
|
|
|
1713
1921
|
bindAgentPhones,
|
|
1714
1922
|
bindAgentSchedule,
|
|
1715
1923
|
bindAgentScheduleExceptions,
|
|
1924
|
+
bindAgentStageTriggers,
|
|
1925
|
+
bindAgentStages,
|
|
1716
1926
|
bindAgentTags,
|
|
1717
1927
|
bindAgentVersions,
|
|
1718
1928
|
createAgentBlueprintsApi,
|
|
@@ -1721,6 +1931,8 @@ export {
|
|
|
1721
1931
|
createAgentPhonesApi,
|
|
1722
1932
|
createAgentScheduleApi,
|
|
1723
1933
|
createAgentScheduleExceptionsApi,
|
|
1934
|
+
createAgentStageTriggersApi,
|
|
1935
|
+
createAgentStagesApi,
|
|
1724
1936
|
createAgentTagsApi,
|
|
1725
1937
|
createAgentVersionsApi,
|
|
1726
1938
|
createAgentsApi,
|