@getsupervisor/agents-studio-sdk 1.41.0-patch.1 → 1.41.0-patch.3
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 +2 -0
- package/dist/index.cjs +85 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +105 -3
- package/dist/index.d.ts +105 -3
- package/dist/index.js +84 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -415,6 +415,8 @@ createClient({
|
|
|
415
415
|
|
|
416
416
|
Puedes fijar el workspace al crear el cliente, actualizarlo en caliente o delegar en una función:
|
|
417
417
|
|
|
418
|
+
> Nota: los recursos _scoped por workspace_ (por ejemplo `client.agents.*`) requieren un workspace seleccionado. Si `client.workspace.get()` retorna `undefined`, el SDK lanzará un error antes de hacer la request.
|
|
419
|
+
|
|
418
420
|
```ts
|
|
419
421
|
const client = createClient({
|
|
420
422
|
baseUrl,
|
package/dist/index.cjs
CHANGED
|
@@ -22,6 +22,7 @@ __export(index_exports, {
|
|
|
22
22
|
HttpError: () => HttpError,
|
|
23
23
|
NetworkError: () => NetworkError,
|
|
24
24
|
TimeoutError: () => TimeoutError,
|
|
25
|
+
WorkspaceNotSelectedError: () => WorkspaceNotSelectedError,
|
|
25
26
|
bindAgentBlueprints: () => bindAgentBlueprints,
|
|
26
27
|
bindAgentPhones: () => bindAgentPhones,
|
|
27
28
|
bindAgentSchedule: () => bindAgentSchedule,
|
|
@@ -81,6 +82,12 @@ var NetworkError = class extends Error {
|
|
|
81
82
|
this.name = "NetworkError";
|
|
82
83
|
}
|
|
83
84
|
};
|
|
85
|
+
var WorkspaceNotSelectedError = class extends Error {
|
|
86
|
+
constructor() {
|
|
87
|
+
super("Workspace is not selected");
|
|
88
|
+
this.name = "WorkspaceNotSelectedError";
|
|
89
|
+
}
|
|
90
|
+
};
|
|
84
91
|
|
|
85
92
|
// src/http.ts
|
|
86
93
|
function toQueryString(query) {
|
|
@@ -1144,9 +1151,21 @@ var createAgentEntity = (dto, options) => {
|
|
|
1144
1151
|
|
|
1145
1152
|
// src/api/agents.ts
|
|
1146
1153
|
function createAgentsApi(cfg, relatedApis) {
|
|
1147
|
-
const { base, doFetch } = createHttp(cfg);
|
|
1154
|
+
const { base, doFetch, resolveWorkspaceId, resolveApiKey } = createHttp(cfg);
|
|
1155
|
+
const requireWorkspace = () => {
|
|
1156
|
+
const workspaceId = resolveWorkspaceId();
|
|
1157
|
+
if (typeof workspaceId === "string" && workspaceId.trim().length > 0) {
|
|
1158
|
+
return;
|
|
1159
|
+
}
|
|
1160
|
+
const apiKey = resolveApiKey();
|
|
1161
|
+
if (typeof apiKey === "string" && apiKey.trim().length > 0) {
|
|
1162
|
+
return;
|
|
1163
|
+
}
|
|
1164
|
+
throw new WorkspaceNotSelectedError();
|
|
1165
|
+
};
|
|
1148
1166
|
const jsonHeaders = { "content-type": "application/json" };
|
|
1149
1167
|
const fetchAgentsPage = async (options = {}) => {
|
|
1168
|
+
requireWorkspace();
|
|
1150
1169
|
const sanitizedOptions = {
|
|
1151
1170
|
page: options.page,
|
|
1152
1171
|
limit: options.limit,
|
|
@@ -1165,12 +1184,14 @@ function createAgentsApi(cfg, relatedApis) {
|
|
|
1165
1184
|
return attachPaginator(response, fetchAgentsPage, normalizedOptions);
|
|
1166
1185
|
};
|
|
1167
1186
|
const getAgentDetail = async (agentId) => {
|
|
1187
|
+
requireWorkspace();
|
|
1168
1188
|
const res = await doFetch(`${base}/agents/${agentId}`, {
|
|
1169
1189
|
method: "GET"
|
|
1170
1190
|
});
|
|
1171
1191
|
return res.json();
|
|
1172
1192
|
};
|
|
1173
1193
|
const createAgent = async (payload) => {
|
|
1194
|
+
requireWorkspace();
|
|
1174
1195
|
const res = await doFetch(`${base}/agents`, {
|
|
1175
1196
|
method: "POST",
|
|
1176
1197
|
body: JSON.stringify(payload),
|
|
@@ -1179,6 +1200,7 @@ function createAgentsApi(cfg, relatedApis) {
|
|
|
1179
1200
|
return res.json();
|
|
1180
1201
|
};
|
|
1181
1202
|
const forkAgentFromTemplate = async (payload) => {
|
|
1203
|
+
requireWorkspace();
|
|
1182
1204
|
const res = await doFetch(`${base}/agents/from-template`, {
|
|
1183
1205
|
method: "POST",
|
|
1184
1206
|
body: JSON.stringify(payload),
|
|
@@ -1187,6 +1209,7 @@ function createAgentsApi(cfg, relatedApis) {
|
|
|
1187
1209
|
return res.json();
|
|
1188
1210
|
};
|
|
1189
1211
|
const updateAgent = async (agentId, payload) => {
|
|
1212
|
+
requireWorkspace();
|
|
1190
1213
|
const res = await doFetch(`${base}/agents/${agentId}`, {
|
|
1191
1214
|
method: "PATCH",
|
|
1192
1215
|
body: JSON.stringify(payload),
|
|
@@ -1198,6 +1221,7 @@ function createAgentsApi(cfg, relatedApis) {
|
|
|
1198
1221
|
return typeof agent === "string" ? agent : agent.agentId;
|
|
1199
1222
|
};
|
|
1200
1223
|
const deleteAgent = async (agent) => {
|
|
1224
|
+
requireWorkspace();
|
|
1201
1225
|
const agentId = resolveAgentId(agent);
|
|
1202
1226
|
await doFetch(`${base}/agents/${agentId}`, {
|
|
1203
1227
|
method: "DELETE"
|
|
@@ -1520,7 +1544,15 @@ function createToolsApi(cfg) {
|
|
|
1520
1544
|
});
|
|
1521
1545
|
return res.json();
|
|
1522
1546
|
};
|
|
1523
|
-
|
|
1547
|
+
const fetchToolConnectionsPage = async (options = {}) => {
|
|
1548
|
+
const query = serializeListOptions(options ?? {});
|
|
1549
|
+
const res = await doFetch(`${base}/tools/connections`, {
|
|
1550
|
+
method: "GET",
|
|
1551
|
+
query
|
|
1552
|
+
});
|
|
1553
|
+
return res.json();
|
|
1554
|
+
};
|
|
1555
|
+
const api = {
|
|
1524
1556
|
async list(options = {}) {
|
|
1525
1557
|
const normalizedOptions = { ...options ?? {} };
|
|
1526
1558
|
const response = await fetchToolsPage(normalizedOptions);
|
|
@@ -1534,6 +1566,17 @@ function createToolsApi(cfg) {
|
|
|
1534
1566
|
const response = await fetchPage(normalizedOptions);
|
|
1535
1567
|
return attachPaginator(response, fetchPage, normalizedOptions);
|
|
1536
1568
|
},
|
|
1569
|
+
async listConnections(options = {}) {
|
|
1570
|
+
const normalizedOptions = {
|
|
1571
|
+
...options ?? {}
|
|
1572
|
+
};
|
|
1573
|
+
const response = await fetchToolConnectionsPage(normalizedOptions);
|
|
1574
|
+
return attachPaginator(
|
|
1575
|
+
response,
|
|
1576
|
+
fetchToolConnectionsPage,
|
|
1577
|
+
normalizedOptions
|
|
1578
|
+
);
|
|
1579
|
+
},
|
|
1537
1580
|
async uploadResource(toolId, payload) {
|
|
1538
1581
|
const formData = toFormData(payload);
|
|
1539
1582
|
const res = await doFetch(`${base}/tools/${toolId}/resources`, {
|
|
@@ -1579,8 +1622,47 @@ function createToolsApi(cfg) {
|
|
|
1579
1622
|
body: JSON.stringify(payload)
|
|
1580
1623
|
});
|
|
1581
1624
|
return res.json();
|
|
1625
|
+
},
|
|
1626
|
+
async createConnection(payload, options = {}) {
|
|
1627
|
+
const idempotencyKey = generateIdempotencyKey(options.idempotencyKey);
|
|
1628
|
+
const res = await doFetch(`${base}/tools/connections`, {
|
|
1629
|
+
method: "POST",
|
|
1630
|
+
headers: {
|
|
1631
|
+
...jsonHeaders,
|
|
1632
|
+
[IDEMPOTENCY_HEADER]: idempotencyKey
|
|
1633
|
+
},
|
|
1634
|
+
body: JSON.stringify(payload)
|
|
1635
|
+
});
|
|
1636
|
+
return res.json();
|
|
1637
|
+
},
|
|
1638
|
+
async executeConnection(toolAgentConnectionId, payload, options = {}) {
|
|
1639
|
+
const idempotencyKey = generateIdempotencyKey(options.idempotencyKey);
|
|
1640
|
+
const res = await doFetch(
|
|
1641
|
+
`${base}/tools/connections/${toolAgentConnectionId}/execute`,
|
|
1642
|
+
{
|
|
1643
|
+
method: "POST",
|
|
1644
|
+
headers: {
|
|
1645
|
+
...jsonHeaders,
|
|
1646
|
+
[IDEMPOTENCY_HEADER]: idempotencyKey
|
|
1647
|
+
},
|
|
1648
|
+
body: JSON.stringify(payload)
|
|
1649
|
+
}
|
|
1650
|
+
);
|
|
1651
|
+
return res.json();
|
|
1582
1652
|
}
|
|
1583
1653
|
};
|
|
1654
|
+
const connections = {
|
|
1655
|
+
connect: api.connect,
|
|
1656
|
+
create: api.createConnection,
|
|
1657
|
+
execute: api.executeConnection,
|
|
1658
|
+
list: api.listConnections,
|
|
1659
|
+
createConnection: api.createConnection,
|
|
1660
|
+
executeConnection: api.executeConnection
|
|
1661
|
+
};
|
|
1662
|
+
return {
|
|
1663
|
+
...api,
|
|
1664
|
+
connections
|
|
1665
|
+
};
|
|
1584
1666
|
}
|
|
1585
1667
|
|
|
1586
1668
|
// src/utils/catalog-voices.ts
|
|
@@ -2122,6 +2204,7 @@ function createClient(initialCfg) {
|
|
|
2122
2204
|
HttpError,
|
|
2123
2205
|
NetworkError,
|
|
2124
2206
|
TimeoutError,
|
|
2207
|
+
WorkspaceNotSelectedError,
|
|
2125
2208
|
bindAgentBlueprints,
|
|
2126
2209
|
bindAgentPhones,
|
|
2127
2210
|
bindAgentSchedule,
|