@getsupervisor/agents-studio-sdk 1.22.1 → 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/CHANGELOG.md +56 -225
- package/README.md +4 -4
- package/dist/index.cjs +390 -34
- 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 +386 -34
- 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);
|
|
@@ -1268,21 +1457,167 @@ function createToolsApi(cfg) {
|
|
|
1268
1457
|
};
|
|
1269
1458
|
}
|
|
1270
1459
|
|
|
1460
|
+
// src/utils/catalog-voices.ts
|
|
1461
|
+
var FALLBACK_LOCALE = "und";
|
|
1462
|
+
var FALLBACK_PROVIDER = "catalog";
|
|
1463
|
+
function catalogItemToVoice(item) {
|
|
1464
|
+
const metadata = normalizeVoiceMetadata(item.metadata);
|
|
1465
|
+
const locale = metadata.locale ?? metadata.language ?? FALLBACK_LOCALE;
|
|
1466
|
+
return {
|
|
1467
|
+
id: item.id,
|
|
1468
|
+
providerVoiceId: metadata.providerVoiceId ?? item.systemIdentifier,
|
|
1469
|
+
name: item.name,
|
|
1470
|
+
gender: metadata.gender,
|
|
1471
|
+
locale,
|
|
1472
|
+
tags: metadata.tags ?? [],
|
|
1473
|
+
previewUrl: metadata.previewUrl ?? void 0,
|
|
1474
|
+
provider: metadata.provider ?? FALLBACK_PROVIDER
|
|
1475
|
+
};
|
|
1476
|
+
}
|
|
1477
|
+
function normalizeVoiceMetadata(metadata) {
|
|
1478
|
+
if (!metadata || typeof metadata !== "object") {
|
|
1479
|
+
return {};
|
|
1480
|
+
}
|
|
1481
|
+
const raw = metadata;
|
|
1482
|
+
return {
|
|
1483
|
+
language: pickString(raw.language),
|
|
1484
|
+
locale: pickString(raw.locale, true),
|
|
1485
|
+
gender: pickGender(raw.gender),
|
|
1486
|
+
provider: pickString(raw.provider, true),
|
|
1487
|
+
previewUrl: pickString(raw.previewUrl, true),
|
|
1488
|
+
tags: pickStringArray(raw.tags),
|
|
1489
|
+
providerVoiceId: pickString(raw.providerVoiceId)
|
|
1490
|
+
};
|
|
1491
|
+
}
|
|
1492
|
+
function pickString(value, allowNull = false) {
|
|
1493
|
+
if (typeof value === "string") {
|
|
1494
|
+
return value;
|
|
1495
|
+
}
|
|
1496
|
+
if (allowNull && value === null) {
|
|
1497
|
+
return null;
|
|
1498
|
+
}
|
|
1499
|
+
return void 0;
|
|
1500
|
+
}
|
|
1501
|
+
function pickStringArray(value) {
|
|
1502
|
+
if (!Array.isArray(value)) {
|
|
1503
|
+
return void 0;
|
|
1504
|
+
}
|
|
1505
|
+
const items = value.filter(
|
|
1506
|
+
(item) => typeof item === "string"
|
|
1507
|
+
);
|
|
1508
|
+
return items.length > 0 ? items : void 0;
|
|
1509
|
+
}
|
|
1510
|
+
function pickGender(value) {
|
|
1511
|
+
if (value === "female" || value === "male" || value === "neutral") {
|
|
1512
|
+
return value;
|
|
1513
|
+
}
|
|
1514
|
+
return void 0;
|
|
1515
|
+
}
|
|
1516
|
+
|
|
1517
|
+
// src/utils/catalog-filter.ts
|
|
1518
|
+
var import_api_query_builder = require("@getsupervisor/api-query-builder");
|
|
1519
|
+
function createCatalogTypeQuery(type) {
|
|
1520
|
+
return new import_api_query_builder.Query((qb) => qb.eq("type", type));
|
|
1521
|
+
}
|
|
1522
|
+
function ensureCatalogTypeFilter(filter, type) {
|
|
1523
|
+
const requiredQuery = createCatalogTypeQuery(type);
|
|
1524
|
+
const requiredExpression = requiredQuery.build();
|
|
1525
|
+
if (filter === void 0 || filter === null) {
|
|
1526
|
+
return requiredQuery;
|
|
1527
|
+
}
|
|
1528
|
+
if (typeof filter === "string") {
|
|
1529
|
+
return ensureTypeForString(filter, requiredQuery, requiredExpression);
|
|
1530
|
+
}
|
|
1531
|
+
if (isQueryBuilderLike(filter)) {
|
|
1532
|
+
return ensureTypeForBuilder(filter, requiredQuery, requiredExpression);
|
|
1533
|
+
}
|
|
1534
|
+
if (isPlainObject2(filter)) {
|
|
1535
|
+
return ensureTypeForObject(filter, type);
|
|
1536
|
+
}
|
|
1537
|
+
return filter;
|
|
1538
|
+
}
|
|
1539
|
+
function ensureTypeForString(value, requiredQuery, requiredExpression) {
|
|
1540
|
+
const normalized = value.trim();
|
|
1541
|
+
if (!normalized.length) {
|
|
1542
|
+
return requiredQuery;
|
|
1543
|
+
}
|
|
1544
|
+
return containsTypePredicate(normalized, requiredExpression) ? normalized : `and(${requiredExpression},${normalized})`;
|
|
1545
|
+
}
|
|
1546
|
+
function ensureTypeForBuilder(builder, requiredQuery, requiredExpression) {
|
|
1547
|
+
const normalized = builder.build().trim();
|
|
1548
|
+
if (!normalized.length) {
|
|
1549
|
+
return requiredQuery;
|
|
1550
|
+
}
|
|
1551
|
+
if (containsTypePredicate(normalized, requiredExpression)) {
|
|
1552
|
+
return builder;
|
|
1553
|
+
}
|
|
1554
|
+
const combined = `and(${requiredExpression},${normalized})`;
|
|
1555
|
+
return {
|
|
1556
|
+
build: () => combined
|
|
1557
|
+
};
|
|
1558
|
+
}
|
|
1559
|
+
function ensureTypeForObject(candidate, type) {
|
|
1560
|
+
if (hasTypeEquality(candidate, type)) {
|
|
1561
|
+
return candidate;
|
|
1562
|
+
}
|
|
1563
|
+
const typeConfig = candidate.type;
|
|
1564
|
+
const normalizedType = isPlainObject2(typeConfig) ? { ...typeConfig, eq: type } : { eq: type };
|
|
1565
|
+
return {
|
|
1566
|
+
...candidate,
|
|
1567
|
+
type: normalizedType
|
|
1568
|
+
};
|
|
1569
|
+
}
|
|
1570
|
+
function hasTypeEquality(candidate, type) {
|
|
1571
|
+
const typeConfig = candidate.type;
|
|
1572
|
+
if (typeof typeConfig === "string") {
|
|
1573
|
+
return typeConfig === type;
|
|
1574
|
+
}
|
|
1575
|
+
if (!isPlainObject2(typeConfig)) {
|
|
1576
|
+
return false;
|
|
1577
|
+
}
|
|
1578
|
+
return typeConfig.eq === type;
|
|
1579
|
+
}
|
|
1580
|
+
function containsTypePredicate(expression, required) {
|
|
1581
|
+
const normalizedExpression = expression.replace(/\s+/g, "").toLowerCase();
|
|
1582
|
+
const normalizedRequired = required.replace(/\s+/g, "").toLowerCase();
|
|
1583
|
+
return normalizedExpression.includes(normalizedRequired);
|
|
1584
|
+
}
|
|
1585
|
+
function isQueryBuilderLike(candidate) {
|
|
1586
|
+
return !!candidate && typeof candidate === "object" && typeof candidate.build === "function";
|
|
1587
|
+
}
|
|
1588
|
+
function isPlainObject2(value) {
|
|
1589
|
+
if (value === null || typeof value !== "object") {
|
|
1590
|
+
return false;
|
|
1591
|
+
}
|
|
1592
|
+
const proto = Object.getPrototypeOf(value);
|
|
1593
|
+
return proto === Object.prototype || proto === null;
|
|
1594
|
+
}
|
|
1595
|
+
|
|
1271
1596
|
// src/api/voices.ts
|
|
1597
|
+
function mapCatalogResponseToVoiceList(response) {
|
|
1598
|
+
return {
|
|
1599
|
+
data: response.data.filter((item) => item.type === "voice").map(catalogItemToVoice),
|
|
1600
|
+
meta: response.meta
|
|
1601
|
+
};
|
|
1602
|
+
}
|
|
1272
1603
|
function createVoicesApi(cfg) {
|
|
1273
1604
|
const { base, doFetch } = createHttp(cfg);
|
|
1274
1605
|
const fetchVoicesPage = async (options = {}) => {
|
|
1275
|
-
const
|
|
1606
|
+
const normalizedOptions = {
|
|
1607
|
+
...options,
|
|
1608
|
+
filter: ensureCatalogTypeFilter(options.filter, "voice")
|
|
1609
|
+
};
|
|
1610
|
+
const { agentId, agentVersionId, gender, locale } = normalizedOptions;
|
|
1276
1611
|
const query = serializeListOptions(
|
|
1277
1612
|
{
|
|
1278
|
-
page:
|
|
1279
|
-
limit:
|
|
1280
|
-
sort:
|
|
1281
|
-
fields:
|
|
1282
|
-
include:
|
|
1283
|
-
search:
|
|
1284
|
-
filter:
|
|
1285
|
-
or:
|
|
1613
|
+
page: normalizedOptions.page,
|
|
1614
|
+
limit: normalizedOptions.limit ?? normalizedOptions.pageSize,
|
|
1615
|
+
sort: normalizedOptions.sort,
|
|
1616
|
+
fields: normalizedOptions.fields,
|
|
1617
|
+
include: normalizedOptions.include,
|
|
1618
|
+
search: normalizedOptions.search,
|
|
1619
|
+
filter: normalizedOptions.filter,
|
|
1620
|
+
or: normalizedOptions.or
|
|
1286
1621
|
},
|
|
1287
1622
|
{
|
|
1288
1623
|
agentId,
|
|
@@ -1291,11 +1626,12 @@ function createVoicesApi(cfg) {
|
|
|
1291
1626
|
locale
|
|
1292
1627
|
}
|
|
1293
1628
|
);
|
|
1294
|
-
const res = await doFetch(`${base}/
|
|
1629
|
+
const res = await doFetch(`${base}/catalogs/items`, {
|
|
1295
1630
|
method: "GET",
|
|
1296
1631
|
query
|
|
1297
1632
|
});
|
|
1298
|
-
|
|
1633
|
+
const raw = await res.json();
|
|
1634
|
+
return mapCatalogResponseToVoiceList(raw);
|
|
1299
1635
|
};
|
|
1300
1636
|
return {
|
|
1301
1637
|
async list(options = {}) {
|
|
@@ -1492,6 +1828,8 @@ function createClient(initialCfg) {
|
|
|
1492
1828
|
const scheduleExceptionsApi = createAgentScheduleExceptionsApi(runtimeCfg);
|
|
1493
1829
|
const versionsApi = createAgentVersionsApi(runtimeCfg);
|
|
1494
1830
|
const blueprintsApi = createAgentBlueprintsApi(runtimeCfg);
|
|
1831
|
+
const stageTriggersApi = createAgentStageTriggersApi(runtimeCfg);
|
|
1832
|
+
const stagesApi = createAgentStagesApi(runtimeCfg);
|
|
1495
1833
|
const voicesApi = createVoicesApi(runtimeCfg);
|
|
1496
1834
|
const apiKeysApi = createApiKeysApi(runtimeCfg);
|
|
1497
1835
|
const catalogsApi = createCatalogsApi(runtimeCfg);
|
|
@@ -1503,7 +1841,9 @@ function createClient(initialCfg) {
|
|
|
1503
1841
|
scheduleApi,
|
|
1504
1842
|
scheduleExceptionsApi,
|
|
1505
1843
|
versionsApi,
|
|
1506
|
-
blueprintsApi
|
|
1844
|
+
blueprintsApi,
|
|
1845
|
+
stagesApi,
|
|
1846
|
+
stageTriggersApi
|
|
1507
1847
|
});
|
|
1508
1848
|
const instructionsNamespace = Object.assign(
|
|
1509
1849
|
(agentId) => bindAgentInstructions(instructionsApi, agentId),
|
|
@@ -1536,6 +1876,17 @@ function createClient(initialCfg) {
|
|
|
1536
1876
|
(agentId) => bindAgentBlueprints(blueprintsApi, agentId),
|
|
1537
1877
|
blueprintsApi
|
|
1538
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
|
+
);
|
|
1539
1890
|
const apis = {
|
|
1540
1891
|
agents: {
|
|
1541
1892
|
...agentsApi,
|
|
@@ -1544,7 +1895,8 @@ function createClient(initialCfg) {
|
|
|
1544
1895
|
phones: phonesNamespace,
|
|
1545
1896
|
schedule: scheduleNamespace,
|
|
1546
1897
|
versions: versionsNamespace,
|
|
1547
|
-
blueprints: blueprintsNamespace
|
|
1898
|
+
blueprints: blueprintsNamespace,
|
|
1899
|
+
stages: stagesNamespace
|
|
1548
1900
|
},
|
|
1549
1901
|
workspaces: createWorkspacesApi(runtimeCfg),
|
|
1550
1902
|
tools: createToolsApi(runtimeCfg),
|
|
@@ -1618,6 +1970,8 @@ function createClient(initialCfg) {
|
|
|
1618
1970
|
bindAgentPhones,
|
|
1619
1971
|
bindAgentSchedule,
|
|
1620
1972
|
bindAgentScheduleExceptions,
|
|
1973
|
+
bindAgentStageTriggers,
|
|
1974
|
+
bindAgentStages,
|
|
1621
1975
|
bindAgentTags,
|
|
1622
1976
|
bindAgentVersions,
|
|
1623
1977
|
createAgentBlueprintsApi,
|
|
@@ -1626,6 +1980,8 @@ function createClient(initialCfg) {
|
|
|
1626
1980
|
createAgentPhonesApi,
|
|
1627
1981
|
createAgentScheduleApi,
|
|
1628
1982
|
createAgentScheduleExceptionsApi,
|
|
1983
|
+
createAgentStageTriggersApi,
|
|
1984
|
+
createAgentStagesApi,
|
|
1629
1985
|
createAgentTagsApi,
|
|
1630
1986
|
createAgentVersionsApi,
|
|
1631
1987
|
createAgentsApi,
|