@getsupervisor/agents-studio-sdk 1.30.0 → 1.32.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/README.md +15 -2
- package/dist/index.cjs +22 -99
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -51
- package/dist/index.d.ts +1 -51
- package/dist/index.js +22 -97
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -22,9 +22,22 @@ const client = createClient({
|
|
|
22
22
|
const { data: agents } = await client.agents.list({ limit: 10 });
|
|
23
23
|
const agent = await client.agents.get('agent-123');
|
|
24
24
|
|
|
25
|
+
const { data: versions } = await client.agents
|
|
26
|
+
.versions(agent.agentId)
|
|
27
|
+
.list({ limit: 1 });
|
|
28
|
+
const versionId = versions[0]?.id;
|
|
29
|
+
if (!versionId) {
|
|
30
|
+
throw new Error('Agent has no versions yet');
|
|
31
|
+
}
|
|
32
|
+
|
|
25
33
|
// helpers de agente sin repetir IDs
|
|
26
|
-
const instructions = client.agents
|
|
27
|
-
|
|
34
|
+
const instructions = client.agents
|
|
35
|
+
.versions(agent.agentId)
|
|
36
|
+
.instructions(versionId);
|
|
37
|
+
await instructions.create({
|
|
38
|
+
order: 1,
|
|
39
|
+
content: 'Responde en español neutro',
|
|
40
|
+
});
|
|
28
41
|
|
|
29
42
|
// administrar versiones e instrucciones
|
|
30
43
|
await client.agents
|
package/dist/index.cjs
CHANGED
|
@@ -23,7 +23,6 @@ __export(index_exports, {
|
|
|
23
23
|
NetworkError: () => NetworkError,
|
|
24
24
|
TimeoutError: () => TimeoutError,
|
|
25
25
|
bindAgentBlueprints: () => bindAgentBlueprints,
|
|
26
|
-
bindAgentInstructions: () => bindAgentInstructions,
|
|
27
26
|
bindAgentPhones: () => bindAgentPhones,
|
|
28
27
|
bindAgentSchedule: () => bindAgentSchedule,
|
|
29
28
|
bindAgentScheduleExceptions: () => bindAgentScheduleExceptions,
|
|
@@ -33,7 +32,6 @@ __export(index_exports, {
|
|
|
33
32
|
bindAgentVersions: () => bindAgentVersions,
|
|
34
33
|
createAgentBlueprintsApi: () => createAgentBlueprintsApi,
|
|
35
34
|
createAgentEntity: () => createAgentEntity,
|
|
36
|
-
createAgentInstructionsApi: () => createAgentInstructionsApi,
|
|
37
35
|
createAgentPhonesApi: () => createAgentPhonesApi,
|
|
38
36
|
createAgentScheduleApi: () => createAgentScheduleApi,
|
|
39
37
|
createAgentScheduleExceptionsApi: () => createAgentScheduleExceptionsApi,
|
|
@@ -403,6 +401,27 @@ function createAgentBlueprintsApi(cfg) {
|
|
|
403
401
|
};
|
|
404
402
|
}
|
|
405
403
|
|
|
404
|
+
// src/api/agent-phones.ts
|
|
405
|
+
function createAgentPhonesApi(cfg) {
|
|
406
|
+
const { base, doFetch } = createHttp(cfg);
|
|
407
|
+
const jsonHeaders = { "content-type": "application/json" };
|
|
408
|
+
return {
|
|
409
|
+
async connect(agentId, payload) {
|
|
410
|
+
const res = await doFetch(`${base}/agents/${agentId}/phones`, {
|
|
411
|
+
method: "POST",
|
|
412
|
+
headers: jsonHeaders,
|
|
413
|
+
body: JSON.stringify(payload)
|
|
414
|
+
});
|
|
415
|
+
return res.json();
|
|
416
|
+
},
|
|
417
|
+
async disconnect(agentId, phoneId) {
|
|
418
|
+
await doFetch(`${base}/agents/${agentId}/phones/${phoneId}`, {
|
|
419
|
+
method: "DELETE"
|
|
420
|
+
});
|
|
421
|
+
}
|
|
422
|
+
};
|
|
423
|
+
}
|
|
424
|
+
|
|
406
425
|
// src/utils/pagination.ts
|
|
407
426
|
var toNumber = (value) => {
|
|
408
427
|
return typeof value === "number" ? value : void 0;
|
|
@@ -495,76 +514,6 @@ function attachPaginator(response, fetchPage, options) {
|
|
|
495
514
|
});
|
|
496
515
|
}
|
|
497
516
|
|
|
498
|
-
// src/api/agent-instructions.ts
|
|
499
|
-
function createAgentInstructionsApi(cfg) {
|
|
500
|
-
const { base, doFetch } = createHttp(cfg);
|
|
501
|
-
const jsonHeaders = { "content-type": "application/json" };
|
|
502
|
-
const fetchInstructionPage = async (agentId, opts = {}) => {
|
|
503
|
-
const { versionId, ...queryOptions } = opts ?? {};
|
|
504
|
-
const query = serializeListOptions(queryOptions, { versionId });
|
|
505
|
-
const res = await doFetch(`${base}/agents/${agentId}/instructions`, {
|
|
506
|
-
method: "GET",
|
|
507
|
-
query
|
|
508
|
-
});
|
|
509
|
-
return res.json();
|
|
510
|
-
};
|
|
511
|
-
return {
|
|
512
|
-
async list(agentId, opts = {}) {
|
|
513
|
-
const normalizedOptions = {
|
|
514
|
-
...opts ?? {}
|
|
515
|
-
};
|
|
516
|
-
const fetchPage = (options) => fetchInstructionPage(agentId, options);
|
|
517
|
-
const response = await fetchPage(normalizedOptions);
|
|
518
|
-
return attachPaginator(response, fetchPage, normalizedOptions);
|
|
519
|
-
},
|
|
520
|
-
async create(agentId, payload) {
|
|
521
|
-
const res = await doFetch(`${base}/agents/${agentId}/instructions`, {
|
|
522
|
-
method: "POST",
|
|
523
|
-
headers: jsonHeaders,
|
|
524
|
-
body: JSON.stringify(payload)
|
|
525
|
-
});
|
|
526
|
-
return res.json();
|
|
527
|
-
},
|
|
528
|
-
async update(agentId, instructionId, payload) {
|
|
529
|
-
const res = await doFetch(
|
|
530
|
-
`${base}/agents/${agentId}/instructions/${instructionId}`,
|
|
531
|
-
{
|
|
532
|
-
method: "PATCH",
|
|
533
|
-
headers: jsonHeaders,
|
|
534
|
-
body: JSON.stringify(payload)
|
|
535
|
-
}
|
|
536
|
-
);
|
|
537
|
-
return res.json();
|
|
538
|
-
},
|
|
539
|
-
async delete(agentId, instructionId) {
|
|
540
|
-
await doFetch(`${base}/agents/${agentId}/instructions/${instructionId}`, {
|
|
541
|
-
method: "DELETE"
|
|
542
|
-
});
|
|
543
|
-
}
|
|
544
|
-
};
|
|
545
|
-
}
|
|
546
|
-
|
|
547
|
-
// src/api/agent-phones.ts
|
|
548
|
-
function createAgentPhonesApi(cfg) {
|
|
549
|
-
const { base, doFetch } = createHttp(cfg);
|
|
550
|
-
const jsonHeaders = { "content-type": "application/json" };
|
|
551
|
-
return {
|
|
552
|
-
async connect(agentId, payload) {
|
|
553
|
-
const res = await doFetch(`${base}/agents/${agentId}/phones`, {
|
|
554
|
-
method: "POST",
|
|
555
|
-
headers: jsonHeaders,
|
|
556
|
-
body: JSON.stringify(payload)
|
|
557
|
-
});
|
|
558
|
-
return res.json();
|
|
559
|
-
},
|
|
560
|
-
async disconnect(agentId, phoneId) {
|
|
561
|
-
await doFetch(`${base}/agents/${agentId}/phones/${phoneId}`, {
|
|
562
|
-
method: "DELETE"
|
|
563
|
-
});
|
|
564
|
-
}
|
|
565
|
-
};
|
|
566
|
-
}
|
|
567
|
-
|
|
568
517
|
// src/api/agent-schedule-exceptions.ts
|
|
569
518
|
function createAgentScheduleExceptionsApi(cfg) {
|
|
570
519
|
const { base, doFetch } = createHttp(cfg);
|
|
@@ -954,20 +903,6 @@ function createAgentVersionsApi(cfg) {
|
|
|
954
903
|
}
|
|
955
904
|
|
|
956
905
|
// src/entities/agent.ts
|
|
957
|
-
var bindAgentInstructions = (api, agentId) => ({
|
|
958
|
-
list(opts) {
|
|
959
|
-
return api.list(agentId, opts);
|
|
960
|
-
},
|
|
961
|
-
create(payload) {
|
|
962
|
-
return api.create(agentId, payload);
|
|
963
|
-
},
|
|
964
|
-
update(instructionId, payload) {
|
|
965
|
-
return api.update(agentId, instructionId, payload);
|
|
966
|
-
},
|
|
967
|
-
delete(instructionId) {
|
|
968
|
-
return api.delete(agentId, instructionId);
|
|
969
|
-
}
|
|
970
|
-
});
|
|
971
906
|
var bindAgentStageTriggers = (api, agentId, blueprintId, stageId) => ({
|
|
972
907
|
list(opts) {
|
|
973
908
|
return api.list(agentId, blueprintId, stageId, opts);
|
|
@@ -1139,7 +1074,6 @@ var bindAgentBlueprints = (api, agentId) => ({
|
|
|
1139
1074
|
});
|
|
1140
1075
|
var createAgentEntity = (dto, options) => {
|
|
1141
1076
|
const {
|
|
1142
|
-
instructionsApi,
|
|
1143
1077
|
tagsApi,
|
|
1144
1078
|
phonesApi,
|
|
1145
1079
|
scheduleApi,
|
|
@@ -1154,7 +1088,6 @@ var createAgentEntity = (dto, options) => {
|
|
|
1154
1088
|
} = options;
|
|
1155
1089
|
const entity = {
|
|
1156
1090
|
...dto,
|
|
1157
|
-
instructions: bindAgentInstructions(instructionsApi, dto.agentId),
|
|
1158
1091
|
tagAssignments: bindAgentTags(tagsApi, dto.agentId),
|
|
1159
1092
|
phones: bindAgentPhones(phonesApi, dto.agentId),
|
|
1160
1093
|
schedule: bindAgentSchedule(
|
|
@@ -1215,7 +1148,7 @@ function createAgentsApi(cfg, relatedApis) {
|
|
|
1215
1148
|
return res.json();
|
|
1216
1149
|
};
|
|
1217
1150
|
const forkAgentFromTemplate = async (payload) => {
|
|
1218
|
-
const res = await doFetch(`${base}/agents
|
|
1151
|
+
const res = await doFetch(`${base}/agents/from-template`, {
|
|
1219
1152
|
method: "POST",
|
|
1220
1153
|
body: JSON.stringify(payload),
|
|
1221
1154
|
headers: jsonHeaders
|
|
@@ -1251,7 +1184,6 @@ function createAgentsApi(cfg, relatedApis) {
|
|
|
1251
1184
|
return baseApi;
|
|
1252
1185
|
}
|
|
1253
1186
|
const wrapAgent = (detail) => createAgentEntity(detail, {
|
|
1254
|
-
instructionsApi: relatedApis.instructionsApi,
|
|
1255
1187
|
tagsApi: relatedApis.tagsApi,
|
|
1256
1188
|
phonesApi: relatedApis.phonesApi,
|
|
1257
1189
|
scheduleApi: relatedApis.scheduleApi,
|
|
@@ -1915,7 +1847,6 @@ function createClient(initialCfg) {
|
|
|
1915
1847
|
const setAccessTokenGetter = (getter) => {
|
|
1916
1848
|
runtimeCfg.getAccessToken = getter;
|
|
1917
1849
|
};
|
|
1918
|
-
const instructionsApi = createAgentInstructionsApi(runtimeCfg);
|
|
1919
1850
|
const tagsApi = createAgentTagsApi(runtimeCfg);
|
|
1920
1851
|
const phonesApi = createAgentPhonesApi(runtimeCfg);
|
|
1921
1852
|
const scheduleApi = createAgentScheduleApi(runtimeCfg);
|
|
@@ -1930,7 +1861,6 @@ function createClient(initialCfg) {
|
|
|
1930
1861
|
const catalogTemplatesApi = createCatalogTemplatesApi(runtimeCfg);
|
|
1931
1862
|
const webhooksApi = createWebhooksApi(runtimeCfg);
|
|
1932
1863
|
const agentsApi = createAgentsApi(runtimeCfg, {
|
|
1933
|
-
instructionsApi,
|
|
1934
1864
|
tagsApi,
|
|
1935
1865
|
phonesApi,
|
|
1936
1866
|
scheduleApi,
|
|
@@ -1940,10 +1870,6 @@ function createClient(initialCfg) {
|
|
|
1940
1870
|
stagesApi,
|
|
1941
1871
|
stageTriggersApi
|
|
1942
1872
|
});
|
|
1943
|
-
const instructionsNamespace = Object.assign(
|
|
1944
|
-
(agentId) => bindAgentInstructions(instructionsApi, agentId),
|
|
1945
|
-
instructionsApi
|
|
1946
|
-
);
|
|
1947
1873
|
const tagsNamespace = Object.assign(
|
|
1948
1874
|
(agentId) => bindAgentTags(tagsApi, agentId),
|
|
1949
1875
|
tagsApi
|
|
@@ -1985,7 +1911,6 @@ function createClient(initialCfg) {
|
|
|
1985
1911
|
const apis = {
|
|
1986
1912
|
agents: {
|
|
1987
1913
|
...agentsApi,
|
|
1988
|
-
instructions: instructionsNamespace,
|
|
1989
1914
|
tags: tagsNamespace,
|
|
1990
1915
|
phones: phonesNamespace,
|
|
1991
1916
|
schedule: scheduleNamespace,
|
|
@@ -2064,7 +1989,6 @@ function createClient(initialCfg) {
|
|
|
2064
1989
|
NetworkError,
|
|
2065
1990
|
TimeoutError,
|
|
2066
1991
|
bindAgentBlueprints,
|
|
2067
|
-
bindAgentInstructions,
|
|
2068
1992
|
bindAgentPhones,
|
|
2069
1993
|
bindAgentSchedule,
|
|
2070
1994
|
bindAgentScheduleExceptions,
|
|
@@ -2074,7 +1998,6 @@ function createClient(initialCfg) {
|
|
|
2074
1998
|
bindAgentVersions,
|
|
2075
1999
|
createAgentBlueprintsApi,
|
|
2076
2000
|
createAgentEntity,
|
|
2077
|
-
createAgentInstructionsApi,
|
|
2078
2001
|
createAgentPhonesApi,
|
|
2079
2002
|
createAgentScheduleApi,
|
|
2080
2003
|
createAgentScheduleExceptionsApi,
|