@getsupervisor/agents-studio-sdk 1.41.0-patch.1 → 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/README.md +2 -0
- package/dist/index.cjs +53 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +40 -3
- package/dist/index.d.ts +40 -3
- package/dist/index.js +52 -1
- 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"
|
|
@@ -1579,6 +1603,33 @@ function createToolsApi(cfg) {
|
|
|
1579
1603
|
body: JSON.stringify(payload)
|
|
1580
1604
|
});
|
|
1581
1605
|
return res.json();
|
|
1606
|
+
},
|
|
1607
|
+
async createConnection(payload, options = {}) {
|
|
1608
|
+
const idempotencyKey = generateIdempotencyKey(options.idempotencyKey);
|
|
1609
|
+
const res = await doFetch(`${base}/tools/connections`, {
|
|
1610
|
+
method: "POST",
|
|
1611
|
+
headers: {
|
|
1612
|
+
...jsonHeaders,
|
|
1613
|
+
[IDEMPOTENCY_HEADER]: idempotencyKey
|
|
1614
|
+
},
|
|
1615
|
+
body: JSON.stringify(payload)
|
|
1616
|
+
});
|
|
1617
|
+
return res.json();
|
|
1618
|
+
},
|
|
1619
|
+
async executeConnection(toolAgentConnectionId, payload, options = {}) {
|
|
1620
|
+
const idempotencyKey = generateIdempotencyKey(options.idempotencyKey);
|
|
1621
|
+
const res = await doFetch(
|
|
1622
|
+
`${base}/tools/connections/${toolAgentConnectionId}/execute`,
|
|
1623
|
+
{
|
|
1624
|
+
method: "POST",
|
|
1625
|
+
headers: {
|
|
1626
|
+
...jsonHeaders,
|
|
1627
|
+
[IDEMPOTENCY_HEADER]: idempotencyKey
|
|
1628
|
+
},
|
|
1629
|
+
body: JSON.stringify(payload)
|
|
1630
|
+
}
|
|
1631
|
+
);
|
|
1632
|
+
return res.json();
|
|
1582
1633
|
}
|
|
1583
1634
|
};
|
|
1584
1635
|
}
|
|
@@ -2122,6 +2173,7 @@ function createClient(initialCfg) {
|
|
|
2122
2173
|
HttpError,
|
|
2123
2174
|
NetworkError,
|
|
2124
2175
|
TimeoutError,
|
|
2176
|
+
WorkspaceNotSelectedError,
|
|
2125
2177
|
bindAgentBlueprints,
|
|
2126
2178
|
bindAgentPhones,
|
|
2127
2179
|
bindAgentSchedule,
|