@getsupervisor/agents-studio-sdk 1.37.0 → 1.39.0-patch.1

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/README.md CHANGED
@@ -73,6 +73,28 @@ await client.tools.uploadResource(tools.data[0].identifier, formData);
73
73
 
74
74
  // eliminar un agente
75
75
  await client.agents.delete(agent.agentId);
76
+
77
+ // campañas masivas desde CSV
78
+ const campaign = await client.campaigns.create(agent.agentId, versionId, {
79
+ name: 'Holiday follow-up',
80
+ objective: 'Re-engage dormant customers',
81
+ file: new File([csvBlob], 'campaign-rows.csv', { type: 'text/csv' }),
82
+ });
83
+
84
+ const recentCampaigns = await client.campaigns.list({ limit: 10 });
85
+ console.log(recentCampaigns.data.map((item) => item.name));
86
+
87
+ // ejecuciones individuales con correlación al toolExecutionId
88
+ const executions = await client.campaigns.listExecutions(campaign.campaignId, {
89
+ limit: 20,
90
+ });
91
+
92
+ executions.data.forEach((row) => {
93
+ console.log(
94
+ `Row ${row.rowNumber} => status=${row.status} agentExecutionId=${row.agentExecutionId}`,
95
+ );
96
+ });
97
+ // agentExecutionId coincide con el toolExecutionId expuesto por client.tools.execute
76
98
  ```
77
99
 
78
100
  ## Catálogos (Catalogs)
package/dist/index.cjs CHANGED
@@ -42,6 +42,7 @@ __export(index_exports, {
42
42
  createAgentVersionsApi: () => createAgentVersionsApi,
43
43
  createAgentsApi: () => createAgentsApi,
44
44
  createApiKeysApi: () => createApiKeysApi,
45
+ createCampaignsApi: () => createCampaignsApi,
45
46
  createCatalogTemplatesApi: () => createCatalogTemplatesApi,
46
47
  createCatalogsApi: () => createCatalogsApi,
47
48
  createClient: () => createClient,
@@ -515,6 +516,56 @@ function attachPaginator(response, fetchPage, options) {
515
516
  });
516
517
  }
517
518
 
519
+ // src/api/agent-schedule.ts
520
+ function createAgentScheduleApi(cfg) {
521
+ const { base, doFetch } = createHttp(cfg);
522
+ const jsonHeaders = { "content-type": "application/json" };
523
+ const fetchSchedulesPage = async (agentId, options = {}) => {
524
+ const query = serializeListOptions({ ...options ?? {} });
525
+ const res = await doFetch(`${base}/agents/${agentId}/schedules`, {
526
+ method: "GET",
527
+ query
528
+ });
529
+ return res.json();
530
+ };
531
+ return {
532
+ async list(agentId, options = {}) {
533
+ const normalized = { ...options ?? {} };
534
+ const fetchPage = (pageOptions) => fetchSchedulesPage(agentId, pageOptions);
535
+ const response = await fetchPage(normalized);
536
+ return attachPaginator(response, fetchPage, normalized);
537
+ },
538
+ async get(agentId, scheduleId) {
539
+ const res = await doFetch(
540
+ `${base}/agents/${agentId}/schedules/${scheduleId}`,
541
+ {
542
+ method: "GET"
543
+ }
544
+ );
545
+ return res.json();
546
+ },
547
+ async create(agentId, payload) {
548
+ const res = await doFetch(`${base}/agents/${agentId}/schedules`, {
549
+ method: "POST",
550
+ headers: jsonHeaders,
551
+ body: JSON.stringify(payload)
552
+ });
553
+ return res.json();
554
+ },
555
+ async update(agentId, scheduleId, payload) {
556
+ const res = await doFetch(
557
+ `${base}/agents/${agentId}/schedules/${scheduleId}`,
558
+ {
559
+ method: "PUT",
560
+ headers: jsonHeaders,
561
+ body: JSON.stringify(payload)
562
+ }
563
+ );
564
+ return res.json();
565
+ }
566
+ };
567
+ }
568
+
518
569
  // src/api/agent-schedule-exceptions.ts
519
570
  function createAgentScheduleExceptionsApi(cfg) {
520
571
  const { base, doFetch } = createHttp(cfg);
@@ -581,56 +632,6 @@ function createAgentScheduleExceptionsApi(cfg) {
581
632
  };
582
633
  }
583
634
 
584
- // src/api/agent-schedule.ts
585
- function createAgentScheduleApi(cfg) {
586
- const { base, doFetch } = createHttp(cfg);
587
- const jsonHeaders = { "content-type": "application/json" };
588
- const fetchSchedulesPage = async (agentId, options = {}) => {
589
- const query = serializeListOptions({ ...options ?? {} });
590
- const res = await doFetch(`${base}/agents/${agentId}/schedules`, {
591
- method: "GET",
592
- query
593
- });
594
- return res.json();
595
- };
596
- return {
597
- async list(agentId, options = {}) {
598
- const normalized = { ...options ?? {} };
599
- const fetchPage = (pageOptions) => fetchSchedulesPage(agentId, pageOptions);
600
- const response = await fetchPage(normalized);
601
- return attachPaginator(response, fetchPage, normalized);
602
- },
603
- async get(agentId, scheduleId) {
604
- const res = await doFetch(
605
- `${base}/agents/${agentId}/schedules/${scheduleId}`,
606
- {
607
- method: "GET"
608
- }
609
- );
610
- return res.json();
611
- },
612
- async create(agentId, payload) {
613
- const res = await doFetch(`${base}/agents/${agentId}/schedules`, {
614
- method: "POST",
615
- headers: jsonHeaders,
616
- body: JSON.stringify(payload)
617
- });
618
- return res.json();
619
- },
620
- async update(agentId, scheduleId, payload) {
621
- const res = await doFetch(
622
- `${base}/agents/${agentId}/schedules/${scheduleId}`,
623
- {
624
- method: "PUT",
625
- headers: jsonHeaders,
626
- body: JSON.stringify(payload)
627
- }
628
- );
629
- return res.json();
630
- }
631
- };
632
- }
633
-
634
635
  // src/api/agent-stage-triggers.ts
635
636
  function createAgentStageTriggersApi(cfg) {
636
637
  const { base, doFetch } = createHttp(cfg);
@@ -1299,6 +1300,82 @@ function createApiKeysApi(cfg) {
1299
1300
  };
1300
1301
  }
1301
1302
 
1303
+ // src/api/campaigns.ts
1304
+ function createCampaignsApi(cfg) {
1305
+ const { base, doFetch } = createHttp(cfg);
1306
+ const isFormData2 = (value) => {
1307
+ return typeof FormData !== "undefined" && value instanceof FormData;
1308
+ };
1309
+ const fetchCampaignsPage = async (options = {}) => {
1310
+ const query = serializeListOptions(options ?? {});
1311
+ const res = await doFetch(`${base}/campaigns`, {
1312
+ method: "GET",
1313
+ query
1314
+ });
1315
+ return res.json();
1316
+ };
1317
+ const fetchExecutionsPage = async (campaignId, options = {}) => {
1318
+ const query = serializeListOptions({
1319
+ page: options.page,
1320
+ limit: options.limit
1321
+ });
1322
+ const res = await doFetch(`${base}/campaigns/${campaignId}/executions`, {
1323
+ method: "GET",
1324
+ query
1325
+ });
1326
+ return res.json();
1327
+ };
1328
+ const buildMultipart = (payload) => {
1329
+ if (isFormData2(payload)) {
1330
+ return payload;
1331
+ }
1332
+ if (typeof FormData === "undefined") {
1333
+ throw new TypeError(
1334
+ "FormData is not available in this environment. Pass a FormData instance instead."
1335
+ );
1336
+ }
1337
+ const form = new FormData();
1338
+ form.append("name", payload.name);
1339
+ if (payload.objective !== void 0 && payload.objective !== null) {
1340
+ form.append("objective", payload.objective);
1341
+ }
1342
+ form.append("file", payload.file);
1343
+ return form;
1344
+ };
1345
+ return {
1346
+ async list(options = {}) {
1347
+ const normalizedOptions = { ...options ?? {} };
1348
+ const response = await fetchCampaignsPage(normalizedOptions);
1349
+ return attachPaginator(response, fetchCampaignsPage, normalizedOptions);
1350
+ },
1351
+ async get(campaignId) {
1352
+ const res = await doFetch(`${base}/campaigns/${campaignId}`, {
1353
+ method: "GET"
1354
+ });
1355
+ return res.json();
1356
+ },
1357
+ async create(agentId, versionId, payload) {
1358
+ const body = buildMultipart(payload);
1359
+ const res = await doFetch(
1360
+ `${base}/agents/${agentId}/versions/${versionId}/campaigns`,
1361
+ {
1362
+ method: "POST",
1363
+ body
1364
+ }
1365
+ );
1366
+ return res.json();
1367
+ },
1368
+ async listExecutions(campaignId, options = {}) {
1369
+ const normalizedOptions = {
1370
+ ...options ?? {}
1371
+ };
1372
+ const response = await fetchExecutionsPage(campaignId, normalizedOptions);
1373
+ const fetchPage = (opts) => fetchExecutionsPage(campaignId, opts);
1374
+ return attachPaginator(response, fetchPage, normalizedOptions);
1375
+ }
1376
+ };
1377
+ }
1378
+
1302
1379
  // src/api/catalog-templates.ts
1303
1380
  function createCatalogTemplatesApi(cfg) {
1304
1381
  const { base, doFetch } = createHttp(cfg);
@@ -1955,6 +2032,7 @@ function createClient(initialCfg) {
1955
2032
  ...catalogsApi,
1956
2033
  templates: catalogTemplatesApi
1957
2034
  },
2035
+ campaigns: createCampaignsApi(runtimeCfg),
1958
2036
  voices: voicesApi,
1959
2037
  apiKeys: apiKeysApi,
1960
2038
  webhooks: webhooksApi
@@ -2039,6 +2117,7 @@ function createClient(initialCfg) {
2039
2117
  createAgentVersionsApi,
2040
2118
  createAgentsApi,
2041
2119
  createApiKeysApi,
2120
+ createCampaignsApi,
2042
2121
  createCatalogTemplatesApi,
2043
2122
  createCatalogsApi,
2044
2123
  createClient,