@getsupervisor/agents-studio-sdk 1.40.0 → 1.41.0-patch.2
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 +155 -64
- package/README.md +42 -0
- package/dist/index.cjs +207 -51
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +143 -16
- package/dist/index.d.ts +143 -16
- package/dist/index.js +205 -51
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -25,6 +25,12 @@ var NetworkError = class extends Error {
|
|
|
25
25
|
this.name = "NetworkError";
|
|
26
26
|
}
|
|
27
27
|
};
|
|
28
|
+
var WorkspaceNotSelectedError = class extends Error {
|
|
29
|
+
constructor() {
|
|
30
|
+
super("Workspace is not selected");
|
|
31
|
+
this.name = "WorkspaceNotSelectedError";
|
|
32
|
+
}
|
|
33
|
+
};
|
|
28
34
|
|
|
29
35
|
// src/http.ts
|
|
30
36
|
function toQueryString(query) {
|
|
@@ -460,6 +466,56 @@ function attachPaginator(response, fetchPage, options) {
|
|
|
460
466
|
});
|
|
461
467
|
}
|
|
462
468
|
|
|
469
|
+
// src/api/agent-schedule.ts
|
|
470
|
+
function createAgentScheduleApi(cfg) {
|
|
471
|
+
const { base, doFetch } = createHttp(cfg);
|
|
472
|
+
const jsonHeaders = { "content-type": "application/json" };
|
|
473
|
+
const fetchSchedulesPage = async (agentId, options = {}) => {
|
|
474
|
+
const query = serializeListOptions({ ...options ?? {} });
|
|
475
|
+
const res = await doFetch(`${base}/agents/${agentId}/schedules`, {
|
|
476
|
+
method: "GET",
|
|
477
|
+
query
|
|
478
|
+
});
|
|
479
|
+
return res.json();
|
|
480
|
+
};
|
|
481
|
+
return {
|
|
482
|
+
async list(agentId, options = {}) {
|
|
483
|
+
const normalized = { ...options ?? {} };
|
|
484
|
+
const fetchPage = (pageOptions) => fetchSchedulesPage(agentId, pageOptions);
|
|
485
|
+
const response = await fetchPage(normalized);
|
|
486
|
+
return attachPaginator(response, fetchPage, normalized);
|
|
487
|
+
},
|
|
488
|
+
async get(agentId, scheduleId) {
|
|
489
|
+
const res = await doFetch(
|
|
490
|
+
`${base}/agents/${agentId}/schedules/${scheduleId}`,
|
|
491
|
+
{
|
|
492
|
+
method: "GET"
|
|
493
|
+
}
|
|
494
|
+
);
|
|
495
|
+
return res.json();
|
|
496
|
+
},
|
|
497
|
+
async create(agentId, payload) {
|
|
498
|
+
const res = await doFetch(`${base}/agents/${agentId}/schedules`, {
|
|
499
|
+
method: "POST",
|
|
500
|
+
headers: jsonHeaders,
|
|
501
|
+
body: JSON.stringify(payload)
|
|
502
|
+
});
|
|
503
|
+
return res.json();
|
|
504
|
+
},
|
|
505
|
+
async update(agentId, scheduleId, payload) {
|
|
506
|
+
const res = await doFetch(
|
|
507
|
+
`${base}/agents/${agentId}/schedules/${scheduleId}`,
|
|
508
|
+
{
|
|
509
|
+
method: "PUT",
|
|
510
|
+
headers: jsonHeaders,
|
|
511
|
+
body: JSON.stringify(payload)
|
|
512
|
+
}
|
|
513
|
+
);
|
|
514
|
+
return res.json();
|
|
515
|
+
}
|
|
516
|
+
};
|
|
517
|
+
}
|
|
518
|
+
|
|
463
519
|
// src/api/agent-schedule-exceptions.ts
|
|
464
520
|
function createAgentScheduleExceptionsApi(cfg) {
|
|
465
521
|
const { base, doFetch } = createHttp(cfg);
|
|
@@ -526,56 +582,6 @@ function createAgentScheduleExceptionsApi(cfg) {
|
|
|
526
582
|
};
|
|
527
583
|
}
|
|
528
584
|
|
|
529
|
-
// src/api/agent-schedule.ts
|
|
530
|
-
function createAgentScheduleApi(cfg) {
|
|
531
|
-
const { base, doFetch } = createHttp(cfg);
|
|
532
|
-
const jsonHeaders = { "content-type": "application/json" };
|
|
533
|
-
const fetchSchedulesPage = async (agentId, options = {}) => {
|
|
534
|
-
const query = serializeListOptions({ ...options ?? {} });
|
|
535
|
-
const res = await doFetch(`${base}/agents/${agentId}/schedules`, {
|
|
536
|
-
method: "GET",
|
|
537
|
-
query
|
|
538
|
-
});
|
|
539
|
-
return res.json();
|
|
540
|
-
};
|
|
541
|
-
return {
|
|
542
|
-
async list(agentId, options = {}) {
|
|
543
|
-
const normalized = { ...options ?? {} };
|
|
544
|
-
const fetchPage = (pageOptions) => fetchSchedulesPage(agentId, pageOptions);
|
|
545
|
-
const response = await fetchPage(normalized);
|
|
546
|
-
return attachPaginator(response, fetchPage, normalized);
|
|
547
|
-
},
|
|
548
|
-
async get(agentId, scheduleId) {
|
|
549
|
-
const res = await doFetch(
|
|
550
|
-
`${base}/agents/${agentId}/schedules/${scheduleId}`,
|
|
551
|
-
{
|
|
552
|
-
method: "GET"
|
|
553
|
-
}
|
|
554
|
-
);
|
|
555
|
-
return res.json();
|
|
556
|
-
},
|
|
557
|
-
async create(agentId, payload) {
|
|
558
|
-
const res = await doFetch(`${base}/agents/${agentId}/schedules`, {
|
|
559
|
-
method: "POST",
|
|
560
|
-
headers: jsonHeaders,
|
|
561
|
-
body: JSON.stringify(payload)
|
|
562
|
-
});
|
|
563
|
-
return res.json();
|
|
564
|
-
},
|
|
565
|
-
async update(agentId, scheduleId, payload) {
|
|
566
|
-
const res = await doFetch(
|
|
567
|
-
`${base}/agents/${agentId}/schedules/${scheduleId}`,
|
|
568
|
-
{
|
|
569
|
-
method: "PUT",
|
|
570
|
-
headers: jsonHeaders,
|
|
571
|
-
body: JSON.stringify(payload)
|
|
572
|
-
}
|
|
573
|
-
);
|
|
574
|
-
return res.json();
|
|
575
|
-
}
|
|
576
|
-
};
|
|
577
|
-
}
|
|
578
|
-
|
|
579
585
|
// src/api/agent-stage-triggers.ts
|
|
580
586
|
function createAgentStageTriggersApi(cfg) {
|
|
581
587
|
const { base, doFetch } = createHttp(cfg);
|
|
@@ -1088,9 +1094,21 @@ var createAgentEntity = (dto, options) => {
|
|
|
1088
1094
|
|
|
1089
1095
|
// src/api/agents.ts
|
|
1090
1096
|
function createAgentsApi(cfg, relatedApis) {
|
|
1091
|
-
const { base, doFetch } = createHttp(cfg);
|
|
1097
|
+
const { base, doFetch, resolveWorkspaceId, resolveApiKey } = createHttp(cfg);
|
|
1098
|
+
const requireWorkspace = () => {
|
|
1099
|
+
const workspaceId = resolveWorkspaceId();
|
|
1100
|
+
if (typeof workspaceId === "string" && workspaceId.trim().length > 0) {
|
|
1101
|
+
return;
|
|
1102
|
+
}
|
|
1103
|
+
const apiKey = resolveApiKey();
|
|
1104
|
+
if (typeof apiKey === "string" && apiKey.trim().length > 0) {
|
|
1105
|
+
return;
|
|
1106
|
+
}
|
|
1107
|
+
throw new WorkspaceNotSelectedError();
|
|
1108
|
+
};
|
|
1092
1109
|
const jsonHeaders = { "content-type": "application/json" };
|
|
1093
1110
|
const fetchAgentsPage = async (options = {}) => {
|
|
1111
|
+
requireWorkspace();
|
|
1094
1112
|
const sanitizedOptions = {
|
|
1095
1113
|
page: options.page,
|
|
1096
1114
|
limit: options.limit,
|
|
@@ -1109,12 +1127,14 @@ function createAgentsApi(cfg, relatedApis) {
|
|
|
1109
1127
|
return attachPaginator(response, fetchAgentsPage, normalizedOptions);
|
|
1110
1128
|
};
|
|
1111
1129
|
const getAgentDetail = async (agentId) => {
|
|
1130
|
+
requireWorkspace();
|
|
1112
1131
|
const res = await doFetch(`${base}/agents/${agentId}`, {
|
|
1113
1132
|
method: "GET"
|
|
1114
1133
|
});
|
|
1115
1134
|
return res.json();
|
|
1116
1135
|
};
|
|
1117
1136
|
const createAgent = async (payload) => {
|
|
1137
|
+
requireWorkspace();
|
|
1118
1138
|
const res = await doFetch(`${base}/agents`, {
|
|
1119
1139
|
method: "POST",
|
|
1120
1140
|
body: JSON.stringify(payload),
|
|
@@ -1123,6 +1143,7 @@ function createAgentsApi(cfg, relatedApis) {
|
|
|
1123
1143
|
return res.json();
|
|
1124
1144
|
};
|
|
1125
1145
|
const forkAgentFromTemplate = async (payload) => {
|
|
1146
|
+
requireWorkspace();
|
|
1126
1147
|
const res = await doFetch(`${base}/agents/from-template`, {
|
|
1127
1148
|
method: "POST",
|
|
1128
1149
|
body: JSON.stringify(payload),
|
|
@@ -1131,6 +1152,7 @@ function createAgentsApi(cfg, relatedApis) {
|
|
|
1131
1152
|
return res.json();
|
|
1132
1153
|
};
|
|
1133
1154
|
const updateAgent = async (agentId, payload) => {
|
|
1155
|
+
requireWorkspace();
|
|
1134
1156
|
const res = await doFetch(`${base}/agents/${agentId}`, {
|
|
1135
1157
|
method: "PATCH",
|
|
1136
1158
|
body: JSON.stringify(payload),
|
|
@@ -1142,6 +1164,7 @@ function createAgentsApi(cfg, relatedApis) {
|
|
|
1142
1164
|
return typeof agent === "string" ? agent : agent.agentId;
|
|
1143
1165
|
};
|
|
1144
1166
|
const deleteAgent = async (agent) => {
|
|
1167
|
+
requireWorkspace();
|
|
1145
1168
|
const agentId = resolveAgentId(agent);
|
|
1146
1169
|
await doFetch(`${base}/agents/${agentId}`, {
|
|
1147
1170
|
method: "DELETE"
|
|
@@ -1244,6 +1267,82 @@ function createApiKeysApi(cfg) {
|
|
|
1244
1267
|
};
|
|
1245
1268
|
}
|
|
1246
1269
|
|
|
1270
|
+
// src/api/campaigns.ts
|
|
1271
|
+
function createCampaignsApi(cfg) {
|
|
1272
|
+
const { base, doFetch } = createHttp(cfg);
|
|
1273
|
+
const isFormData2 = (value) => {
|
|
1274
|
+
return typeof FormData !== "undefined" && value instanceof FormData;
|
|
1275
|
+
};
|
|
1276
|
+
const fetchCampaignsPage = async (options = {}) => {
|
|
1277
|
+
const query = serializeListOptions(options ?? {});
|
|
1278
|
+
const res = await doFetch(`${base}/campaigns`, {
|
|
1279
|
+
method: "GET",
|
|
1280
|
+
query
|
|
1281
|
+
});
|
|
1282
|
+
return res.json();
|
|
1283
|
+
};
|
|
1284
|
+
const fetchExecutionsPage = async (campaignId, options = {}) => {
|
|
1285
|
+
const query = serializeListOptions({
|
|
1286
|
+
page: options.page,
|
|
1287
|
+
limit: options.limit
|
|
1288
|
+
});
|
|
1289
|
+
const res = await doFetch(`${base}/campaigns/${campaignId}/executions`, {
|
|
1290
|
+
method: "GET",
|
|
1291
|
+
query
|
|
1292
|
+
});
|
|
1293
|
+
return res.json();
|
|
1294
|
+
};
|
|
1295
|
+
const buildMultipart = (payload) => {
|
|
1296
|
+
if (isFormData2(payload)) {
|
|
1297
|
+
return payload;
|
|
1298
|
+
}
|
|
1299
|
+
if (typeof FormData === "undefined") {
|
|
1300
|
+
throw new TypeError(
|
|
1301
|
+
"FormData is not available in this environment. Pass a FormData instance instead."
|
|
1302
|
+
);
|
|
1303
|
+
}
|
|
1304
|
+
const form = new FormData();
|
|
1305
|
+
form.append("name", payload.name);
|
|
1306
|
+
if (payload.objective !== void 0 && payload.objective !== null) {
|
|
1307
|
+
form.append("objective", payload.objective);
|
|
1308
|
+
}
|
|
1309
|
+
form.append("file", payload.file);
|
|
1310
|
+
return form;
|
|
1311
|
+
};
|
|
1312
|
+
return {
|
|
1313
|
+
async list(options = {}) {
|
|
1314
|
+
const normalizedOptions = { ...options ?? {} };
|
|
1315
|
+
const response = await fetchCampaignsPage(normalizedOptions);
|
|
1316
|
+
return attachPaginator(response, fetchCampaignsPage, normalizedOptions);
|
|
1317
|
+
},
|
|
1318
|
+
async get(campaignId) {
|
|
1319
|
+
const res = await doFetch(`${base}/campaigns/${campaignId}`, {
|
|
1320
|
+
method: "GET"
|
|
1321
|
+
});
|
|
1322
|
+
return res.json();
|
|
1323
|
+
},
|
|
1324
|
+
async create(agentId, versionId, payload) {
|
|
1325
|
+
const body = buildMultipart(payload);
|
|
1326
|
+
const res = await doFetch(
|
|
1327
|
+
`${base}/agents/${agentId}/versions/${versionId}/campaigns`,
|
|
1328
|
+
{
|
|
1329
|
+
method: "POST",
|
|
1330
|
+
body
|
|
1331
|
+
}
|
|
1332
|
+
);
|
|
1333
|
+
return res.json();
|
|
1334
|
+
},
|
|
1335
|
+
async listExecutions(campaignId, options = {}) {
|
|
1336
|
+
const normalizedOptions = {
|
|
1337
|
+
...options ?? {}
|
|
1338
|
+
};
|
|
1339
|
+
const response = await fetchExecutionsPage(campaignId, normalizedOptions);
|
|
1340
|
+
const fetchPage = (opts) => fetchExecutionsPage(campaignId, opts);
|
|
1341
|
+
return attachPaginator(response, fetchPage, normalizedOptions);
|
|
1342
|
+
}
|
|
1343
|
+
};
|
|
1344
|
+
}
|
|
1345
|
+
|
|
1247
1346
|
// src/api/catalog-templates.ts
|
|
1248
1347
|
function createCatalogTemplatesApi(cfg) {
|
|
1249
1348
|
const { base, doFetch } = createHttp(cfg);
|
|
@@ -1447,6 +1546,33 @@ function createToolsApi(cfg) {
|
|
|
1447
1546
|
body: JSON.stringify(payload)
|
|
1448
1547
|
});
|
|
1449
1548
|
return res.json();
|
|
1549
|
+
},
|
|
1550
|
+
async createConnection(payload, options = {}) {
|
|
1551
|
+
const idempotencyKey = generateIdempotencyKey(options.idempotencyKey);
|
|
1552
|
+
const res = await doFetch(`${base}/tools/connections`, {
|
|
1553
|
+
method: "POST",
|
|
1554
|
+
headers: {
|
|
1555
|
+
...jsonHeaders,
|
|
1556
|
+
[IDEMPOTENCY_HEADER]: idempotencyKey
|
|
1557
|
+
},
|
|
1558
|
+
body: JSON.stringify(payload)
|
|
1559
|
+
});
|
|
1560
|
+
return res.json();
|
|
1561
|
+
},
|
|
1562
|
+
async executeConnection(toolAgentConnectionId, payload, options = {}) {
|
|
1563
|
+
const idempotencyKey = generateIdempotencyKey(options.idempotencyKey);
|
|
1564
|
+
const res = await doFetch(
|
|
1565
|
+
`${base}/tools/connections/${toolAgentConnectionId}/execute`,
|
|
1566
|
+
{
|
|
1567
|
+
method: "POST",
|
|
1568
|
+
headers: {
|
|
1569
|
+
...jsonHeaders,
|
|
1570
|
+
[IDEMPOTENCY_HEADER]: idempotencyKey
|
|
1571
|
+
},
|
|
1572
|
+
body: JSON.stringify(payload)
|
|
1573
|
+
}
|
|
1574
|
+
);
|
|
1575
|
+
return res.json();
|
|
1450
1576
|
}
|
|
1451
1577
|
};
|
|
1452
1578
|
}
|
|
@@ -1755,6 +1881,26 @@ function createWebhooksApi(cfg) {
|
|
|
1755
1881
|
function createWorkspacesApi(cfg) {
|
|
1756
1882
|
const { base, doFetch } = createHttp(cfg);
|
|
1757
1883
|
const jsonHeaders = { "content-type": "application/json" };
|
|
1884
|
+
const fetchWorkspacesPage = async (options = {}) => {
|
|
1885
|
+
const normalized = { ...options ?? {} };
|
|
1886
|
+
const query = serializeListOptions({
|
|
1887
|
+
page: normalized.page,
|
|
1888
|
+
limit: normalized.limit,
|
|
1889
|
+
sort: normalized.sort,
|
|
1890
|
+
fields: normalized.fields,
|
|
1891
|
+
include: normalized.include,
|
|
1892
|
+
search: normalized.search,
|
|
1893
|
+
filter: normalized.filter,
|
|
1894
|
+
or: normalized.or
|
|
1895
|
+
});
|
|
1896
|
+
const headers = normalized.refreshCache ? { "X-Cache-Refresh": "true" } : void 0;
|
|
1897
|
+
const res = await doFetch(`${base}/workspaces`, {
|
|
1898
|
+
method: "GET",
|
|
1899
|
+
query,
|
|
1900
|
+
headers
|
|
1901
|
+
});
|
|
1902
|
+
return res.json();
|
|
1903
|
+
};
|
|
1758
1904
|
const fetchPhonesPage = async (workspaceId, opts = {}) => {
|
|
1759
1905
|
const { channel } = opts ?? {};
|
|
1760
1906
|
const query = serializeListOptions(
|
|
@@ -1777,6 +1923,11 @@ function createWorkspacesApi(cfg) {
|
|
|
1777
1923
|
return res.json();
|
|
1778
1924
|
};
|
|
1779
1925
|
return {
|
|
1926
|
+
async list(options = {}) {
|
|
1927
|
+
const normalizedOptions = { ...options ?? {} };
|
|
1928
|
+
const response = await fetchWorkspacesPage(normalizedOptions);
|
|
1929
|
+
return attachPaginator(response, fetchWorkspacesPage, normalizedOptions);
|
|
1930
|
+
},
|
|
1780
1931
|
async listPhones(workspaceId, opts = {}) {
|
|
1781
1932
|
const normalizedOptions = {
|
|
1782
1933
|
...opts ?? {}
|
|
@@ -1900,6 +2051,7 @@ function createClient(initialCfg) {
|
|
|
1900
2051
|
...catalogsApi,
|
|
1901
2052
|
templates: catalogTemplatesApi
|
|
1902
2053
|
},
|
|
2054
|
+
campaigns: createCampaignsApi(runtimeCfg),
|
|
1903
2055
|
voices: voicesApi,
|
|
1904
2056
|
apiKeys: apiKeysApi,
|
|
1905
2057
|
webhooks: webhooksApi
|
|
@@ -1963,6 +2115,7 @@ export {
|
|
|
1963
2115
|
HttpError,
|
|
1964
2116
|
NetworkError,
|
|
1965
2117
|
TimeoutError,
|
|
2118
|
+
WorkspaceNotSelectedError,
|
|
1966
2119
|
bindAgentBlueprints,
|
|
1967
2120
|
bindAgentPhones,
|
|
1968
2121
|
bindAgentSchedule,
|
|
@@ -1983,6 +2136,7 @@ export {
|
|
|
1983
2136
|
createAgentVersionsApi,
|
|
1984
2137
|
createAgentsApi,
|
|
1985
2138
|
createApiKeysApi,
|
|
2139
|
+
createCampaignsApi,
|
|
1986
2140
|
createCatalogTemplatesApi,
|
|
1987
2141
|
createCatalogsApi,
|
|
1988
2142
|
createClient,
|