@getsupervisor/agents-studio-sdk 1.41.2-patch.1 → 1.41.2-patch.10

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.js CHANGED
@@ -200,6 +200,11 @@ function createHttp(cfg) {
200
200
  }
201
201
 
202
202
  // src/utils/query.ts
203
+ function buildSearchParams(entries) {
204
+ const searchParams = new URLSearchParams();
205
+ entries.forEach(([key, value]) => appendParam(searchParams, key, value));
206
+ return searchParams;
207
+ }
203
208
  function serializeListOptions(options = {}, extra = {}) {
204
209
  const params = new URLSearchParams();
205
210
  appendParam(params, "page", options.page);
@@ -1071,7 +1076,8 @@ var createAgentEntity = (dto, options) => {
1071
1076
  stageTriggersApi,
1072
1077
  reload,
1073
1078
  updateAgent,
1074
- deleteAgent
1079
+ deleteAgent,
1080
+ cloneAgent
1075
1081
  } = options;
1076
1082
  const schedulesHelper = bindAgentSchedules(
1077
1083
  scheduleApi,
@@ -1090,6 +1096,9 @@ var createAgentEntity = (dto, options) => {
1090
1096
  async save(patch) {
1091
1097
  return updateAgent(dto.agentId, patch);
1092
1098
  },
1099
+ async clone(payload) {
1100
+ return cloneAgent(dto.agentId, payload);
1101
+ },
1093
1102
  async delete() {
1094
1103
  await deleteAgent(dto.agentId);
1095
1104
  },
@@ -1115,6 +1124,22 @@ function createAgentsApi(cfg, relatedApis) {
1115
1124
  throw new WorkspaceNotSelectedError();
1116
1125
  };
1117
1126
  const jsonHeaders = { "content-type": "application/json" };
1127
+ const normalizeCloneSelection = (selection) => {
1128
+ if (!selection) {
1129
+ return [];
1130
+ }
1131
+ if (Array.isArray(selection)) {
1132
+ return selection;
1133
+ }
1134
+ return Object.entries(selection).filter(([, enabled]) => enabled).map(([component]) => component);
1135
+ };
1136
+ const buildCloneAgentRequest = (payload) => {
1137
+ const { clone, ...rest } = payload;
1138
+ return {
1139
+ ...rest,
1140
+ clone: normalizeCloneSelection(clone)
1141
+ };
1142
+ };
1118
1143
  const fetchAgentsPage = async (options = {}) => {
1119
1144
  requireWorkspace();
1120
1145
  const sanitizedOptions = {
@@ -1159,6 +1184,16 @@ function createAgentsApi(cfg, relatedApis) {
1159
1184
  });
1160
1185
  return res.json();
1161
1186
  };
1187
+ const cloneAgent = async (agentId, payload) => {
1188
+ requireWorkspace();
1189
+ const requestPayload = buildCloneAgentRequest(payload);
1190
+ const res = await doFetch(`${base}/agents/${agentId}/clone`, {
1191
+ method: "POST",
1192
+ body: JSON.stringify(requestPayload),
1193
+ headers: jsonHeaders
1194
+ });
1195
+ return res.json();
1196
+ };
1162
1197
  const updateAgent = async (agentId, payload) => {
1163
1198
  requireWorkspace();
1164
1199
  const res = await doFetch(`${base}/agents/${agentId}`, {
@@ -1182,6 +1217,7 @@ function createAgentsApi(cfg, relatedApis) {
1182
1217
  list: listAgents,
1183
1218
  get: getAgentDetail,
1184
1219
  create: createAgent,
1220
+ clone: cloneAgent,
1185
1221
  forkFromTemplate: forkAgentFromTemplate,
1186
1222
  update: updateAgent,
1187
1223
  delete: deleteAgent
@@ -1208,6 +1244,10 @@ function createAgentsApi(cfg, relatedApis) {
1208
1244
  },
1209
1245
  deleteAgent: async (agentId) => {
1210
1246
  await deleteAgent(agentId);
1247
+ },
1248
+ cloneAgent: async (agentId, payload) => {
1249
+ const cloned = await cloneAgent(agentId, payload);
1250
+ return wrapAgent(cloned);
1211
1251
  }
1212
1252
  });
1213
1253
  return {
@@ -1233,6 +1273,10 @@ function createAgentsApi(cfg, relatedApis) {
1233
1273
  const detail = await createAgent(payload);
1234
1274
  return wrapAgent(detail);
1235
1275
  },
1276
+ async clone(agentId, payload) {
1277
+ const detail = await cloneAgent(agentId, payload);
1278
+ return wrapAgent(detail);
1279
+ },
1236
1280
  async forkFromTemplate(payload) {
1237
1281
  const detail = await forkAgentFromTemplate(payload);
1238
1282
  return wrapAgent(detail);
@@ -1275,6 +1319,69 @@ function createApiKeysApi(cfg) {
1275
1319
  };
1276
1320
  }
1277
1321
 
1322
+ // src/api/calls.ts
1323
+ function createCallsApi(cfg) {
1324
+ const { base, doFetch } = createHttp(cfg);
1325
+ const fetchCallsPage = async (options = {}) => {
1326
+ const {
1327
+ agentBatchId,
1328
+ agentId,
1329
+ executionId,
1330
+ recordedAfter,
1331
+ recordedBefore,
1332
+ durationBucket,
1333
+ goalStatus,
1334
+ query: searchQuery,
1335
+ ...listOptions
1336
+ } = options ?? {};
1337
+ const query = serializeListOptions(listOptions, {
1338
+ agentBatchId,
1339
+ agentId,
1340
+ executionId,
1341
+ recordedAfter,
1342
+ recordedBefore,
1343
+ durationBucket,
1344
+ goalStatus,
1345
+ query: searchQuery
1346
+ });
1347
+ const res = await doFetch(`${base}/calls`, {
1348
+ method: "GET",
1349
+ query
1350
+ });
1351
+ return res.json();
1352
+ };
1353
+ return {
1354
+ async list(options = {}) {
1355
+ const normalizedOptions = { ...options ?? {} };
1356
+ const response = await fetchCallsPage(normalizedOptions);
1357
+ return attachPaginator(response, fetchCallsPage, normalizedOptions);
1358
+ },
1359
+ async stream(options) {
1360
+ const query = buildSearchParams([
1361
+ ["after", options.after],
1362
+ ["limit", options.limit],
1363
+ ["agentBatchId", options.agentBatchId],
1364
+ ["agentId", options.agentId],
1365
+ ["executionId", options.executionId],
1366
+ ["durationBucket", options.durationBucket],
1367
+ ["goalStatus", options.goalStatus],
1368
+ ["query", options.query]
1369
+ ]);
1370
+ const res = await doFetch(`${base}/calls/stream`, {
1371
+ method: "GET",
1372
+ query
1373
+ });
1374
+ return res.json();
1375
+ },
1376
+ async get(callId) {
1377
+ const res = await doFetch(`${base}/calls/${callId}`, {
1378
+ method: "GET"
1379
+ });
1380
+ return res.json();
1381
+ }
1382
+ };
1383
+ }
1384
+
1278
1385
  // src/api/campaigns.ts
1279
1386
  function createCampaignsApi(cfg) {
1280
1387
  const { base, doFetch } = createHttp(cfg);
@@ -1912,6 +2019,35 @@ function createWebhooksApi(cfg) {
1912
2019
  `${base}/webhooks/${webhookId}/subscriptions/${subscriptionId}`,
1913
2020
  { method: "DELETE" }
1914
2021
  );
2022
+ },
2023
+ // Deliveries
2024
+ async listDeliveries(webhookId, options = {}) {
2025
+ const fetchPage = async (opts) => {
2026
+ const query = serializeListOptions({
2027
+ page: opts.page,
2028
+ limit: opts.limit,
2029
+ sort: opts.sort,
2030
+ fields: opts.fields,
2031
+ include: opts.include,
2032
+ search: opts.search,
2033
+ filter: opts.filter
2034
+ });
2035
+ const res = await doFetch(`${base}/webhooks/${webhookId}/deliveries`, {
2036
+ method: "GET",
2037
+ query
2038
+ });
2039
+ return res.json();
2040
+ };
2041
+ const normalized = { ...options ?? {} };
2042
+ const response = await fetchPage(normalized);
2043
+ return attachPaginator(response, fetchPage, normalized);
2044
+ },
2045
+ async getDelivery(webhookId, deliveryId) {
2046
+ const res = await doFetch(
2047
+ `${base}/webhooks/${webhookId}/deliveries/${deliveryId}`,
2048
+ { method: "GET" }
2049
+ );
2050
+ return res.json();
1915
2051
  }
1916
2052
  };
1917
2053
  }
@@ -1975,8 +2111,8 @@ function createWorkspacesApi(cfg) {
1975
2111
  const fetchPage = (options) => fetchPhonesPage(workspaceId, options);
1976
2112
  return attachPaginator(response, fetchPage, normalizedOptions);
1977
2113
  },
1978
- async enable(workspaceId, payload) {
1979
- const res = await doFetch(`${base}/workspaces/${workspaceId}/enable`, {
2114
+ async enable(payload) {
2115
+ const res = await doFetch(`${base}/workspaces/enable`, {
1980
2116
  method: "POST",
1981
2117
  headers: jsonHeaders,
1982
2118
  body: JSON.stringify(payload)
@@ -2022,6 +2158,7 @@ function createClient(initialCfg) {
2022
2158
  const stagesApi = createAgentStagesApi(runtimeCfg);
2023
2159
  const voicesApi = createVoicesApi(runtimeCfg);
2024
2160
  const apiKeysApi = createApiKeysApi(runtimeCfg);
2161
+ const callsApi = createCallsApi(runtimeCfg);
2025
2162
  const catalogsApi = createCatalogsApi(runtimeCfg);
2026
2163
  const catalogTemplatesApi = createCatalogTemplatesApi(runtimeCfg);
2027
2164
  const webhooksApi = createWebhooksApi(runtimeCfg);
@@ -2093,6 +2230,7 @@ function createClient(initialCfg) {
2093
2230
  campaigns: createCampaignsApi(runtimeCfg),
2094
2231
  voices: voicesApi,
2095
2232
  apiKeys: apiKeysApi,
2233
+ calls: callsApi,
2096
2234
  webhooks: webhooksApi
2097
2235
  };
2098
2236
  return {
@@ -2175,6 +2313,7 @@ export {
2175
2313
  createAgentVersionsApi,
2176
2314
  createAgentsApi,
2177
2315
  createApiKeysApi,
2316
+ createCallsApi,
2178
2317
  createCampaignsApi,
2179
2318
  createCatalogTemplatesApi,
2180
2319
  createCatalogsApi,