@getsupervisor/agents-studio-sdk 1.11.0 → 1.13.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/CHANGELOG.md +30 -0
- package/README.md +48 -31
- package/dist/index.cjs +67 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +46 -1
- package/dist/index.d.ts +46 -1
- package/dist/index.js +66 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,33 @@
|
|
|
1
|
+
## v1.12.0
|
|
2
|
+
|
|
3
|
+
## [1.12.0](https://github.com/julio-supervisor/agents-studio-be/compare/v1.11.0...v1.12.0) (2025-10-20)
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
* **api-keys:** implement API key management endpoints and client integration ([1eceb00](https://github.com/julio-supervisor/agents-studio-be/commit/1eceb002c296ba017a71516f4710d28bbee6a235))
|
|
8
|
+
* **ci:** add pull request permissions for CI jobs ([1adef4a](https://github.com/julio-supervisor/agents-studio-be/commit/1adef4af2e459b2cd44f156ac6771a7e18d45b68))
|
|
9
|
+
* **ci:** update coverage badge generation to create a pull request ([967d1a0](https://github.com/julio-supervisor/agents-studio-be/commit/967d1a0f8c207db2929f36e686bb2ab327b413f5))
|
|
10
|
+
* **ci:** update coverage badge PR creation to include branch and base parameters ([769c696](https://github.com/julio-supervisor/agents-studio-be/commit/769c696c438d5945043bf9bcd6d001c10285e3b3))
|
|
11
|
+
* expose api key reveal flow ([612cf69](https://github.com/julio-supervisor/agents-studio-be/commit/612cf695ff9cad480cafc27daf831095290eccfa))
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* **ci:** agregar badges a la lista de rutas ignoradas en eventos de push y pull_request ([4928c13](https://github.com/julio-supervisor/agents-studio-be/commit/4928c1324e26d0e0db7ba62784b3df159ca48488))
|
|
16
|
+
* **ci:** agregar rutas ignoradas para badges en eventos de push ([f99328a](https://github.com/julio-supervisor/agents-studio-be/commit/f99328ae76e953d1254f068dd4675f2843ac1587))
|
|
17
|
+
* **ci:** change contents permission from write to read for unit tests ([2cb24e0](https://github.com/julio-supervisor/agents-studio-be/commit/2cb24e0b33fd6e62d02a8f642669255e94b6b3bd))
|
|
18
|
+
* **ci:** update permissions for unit tests to include write access for contents, issues, and id-token ([a5078db](https://github.com/julio-supervisor/agents-studio-be/commit/a5078dbbe52b1f6406848f30bd470231c22ce2c9))
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
## v1.11.0
|
|
22
|
+
|
|
23
|
+
## [1.11.0](https://github.com/julio-supervisor/agents-studio-be/compare/v1.10.0...v1.11.0) (2025-10-19)
|
|
24
|
+
|
|
25
|
+
### Features
|
|
26
|
+
|
|
27
|
+
* **agent-blueprints:** add module implementation and tests ([d631ce5](https://github.com/julio-supervisor/agents-studio-be/commit/d631ce59cf439306020d7e06fe561a808d1f2753))
|
|
28
|
+
* **blueprints:** implement agent blueprints API and integrate with client ([d166104](https://github.com/julio-supervisor/agents-studio-be/commit/d166104f04951d434f5cf89d068babff76ceb42d))
|
|
29
|
+
|
|
30
|
+
|
|
1
31
|
## v1.10.0
|
|
2
32
|
|
|
3
33
|
## [1.10.0](https://github.com/julio-supervisor/agents-studio-be/compare/v1.9.0...v1.10.0) (2025-10-17)
|
package/README.md
CHANGED
|
@@ -123,60 +123,77 @@ await scoped.agents.get('agentId');
|
|
|
123
123
|
|
|
124
124
|
## Gestión de API Keys
|
|
125
125
|
|
|
126
|
-
Los endpoints `/v1/api-keys` permiten listar, crear y revocar credenciales por workspace.
|
|
126
|
+
Los endpoints `/v1/api-keys` permiten listar, crear y revocar credenciales por workspace. Desde la versión 1.10 el SDK expone un namespace dedicado para gestionar el ciclo de vida completo de las claves sin escribir boilerplate adicional.
|
|
127
127
|
|
|
128
128
|
> También puedes consumir el CRUD de agentes con API Keys pasando `apiKey` a `createClient` o usando `client.auth.setApiKey('sk_...')`. El SDK enviará el header `X-API-Key` automáticamente en cada llamada.
|
|
129
129
|
|
|
130
|
+
### Cliente dedicado: `client.apiKeys`
|
|
131
|
+
|
|
130
132
|
```ts
|
|
131
|
-
import {
|
|
133
|
+
import { createClient } from '@getsupervisor/agents-studio-sdk';
|
|
132
134
|
|
|
133
|
-
const
|
|
135
|
+
const client = createClient({
|
|
134
136
|
baseUrl: 'https://public-api.getsupervisor.ai',
|
|
135
137
|
headers: { Authorization: `Bearer ${token}` },
|
|
136
138
|
workspaceId: 'ws-123',
|
|
137
139
|
});
|
|
138
|
-
```
|
|
139
140
|
|
|
140
|
-
|
|
141
|
+
// 1. Listar credenciales activas
|
|
142
|
+
const keys = await client.apiKeys.list();
|
|
141
143
|
|
|
142
|
-
|
|
143
|
-
const
|
|
144
|
-
|
|
144
|
+
// 2. Emitir una nueva credencial (recuerda guardar el valor completo)
|
|
145
|
+
const created = await client.apiKeys.create({
|
|
146
|
+
name: 'Backend Integration',
|
|
147
|
+
environment: 'production',
|
|
148
|
+
scopes: ['agents:read', 'api-keys:read'],
|
|
149
|
+
});
|
|
150
|
+
console.log(created.key); // sólo se entrega una vez
|
|
151
|
+
|
|
152
|
+
// 3. Revelar el valor completo cuando necesites consultarlo de nuevo
|
|
153
|
+
const revealed = await client.apiKeys.show(created.id);
|
|
154
|
+
console.log(revealed.key); // también incluye metadatos actualizados
|
|
145
155
|
|
|
146
|
-
//
|
|
156
|
+
// 4. Revocar cuando deje de ser necesaria
|
|
157
|
+
await client.apiKeys.revoke(created.id);
|
|
147
158
|
```
|
|
148
159
|
|
|
149
|
-
Cada entrada incluye `id`, `name`, `environment`, `scopes`, fechas de auditoría y un `keyPreview` para
|
|
160
|
+
Cada entrada (`ApiKeySummary`) incluye `id`, `name`, `environment`, `scopes`, fechas de auditoría y un `keyPreview` para identificar la credencial sin exponerla por completo.
|
|
150
161
|
|
|
151
|
-
###
|
|
162
|
+
### Usar API Keys dinámicas
|
|
163
|
+
|
|
164
|
+
Puedes rotar claves en caliente con los helpers de autenticación:
|
|
152
165
|
|
|
153
166
|
```ts
|
|
154
|
-
|
|
155
|
-
method: 'POST',
|
|
156
|
-
headers: { 'Content-Type': 'application/json' },
|
|
157
|
-
body: JSON.stringify({
|
|
158
|
-
name: 'Backend Integration',
|
|
159
|
-
description: 'Sincronización nocturna de métricas',
|
|
160
|
-
environment: 'production',
|
|
161
|
-
scopes: ['agents:read', 'api-keys:read'],
|
|
162
|
-
}),
|
|
163
|
-
});
|
|
167
|
+
client.auth.setApiKey('sk_prod_live');
|
|
164
168
|
|
|
165
|
-
|
|
166
|
-
|
|
169
|
+
client.auth.useApiKey(() => readSecretFromVault());
|
|
170
|
+
|
|
171
|
+
client.auth.clearApiKey();
|
|
167
172
|
```
|
|
168
173
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
174
|
+
El SDK enviará siempre el header `X-API-Key`; si lo borras, retomará la autenticación configurada en `headers`.
|
|
175
|
+
|
|
176
|
+
### Alternativa low-level con `createHttp`
|
|
172
177
|
|
|
173
|
-
|
|
178
|
+
Si necesitas controlar manualmente las peticiones (por ejemplo, en un entorno con fetch custom), puedes reutilizar la misma librería interna:
|
|
174
179
|
|
|
175
180
|
```ts
|
|
176
|
-
|
|
177
|
-
```
|
|
181
|
+
import { createHttp } from '@getsupervisor/agents-studio-sdk';
|
|
178
182
|
|
|
179
|
-
|
|
183
|
+
const http = createHttp({
|
|
184
|
+
baseUrl: 'https://public-api.getsupervisor.ai',
|
|
185
|
+
headers: { Authorization: `Bearer ${token}` },
|
|
186
|
+
workspaceId: 'ws-123',
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
const { key, ...metadata } = await http
|
|
190
|
+
.doFetch(`${http.base}/v1/api-keys`, {
|
|
191
|
+
method: 'POST',
|
|
192
|
+
headers: { 'content-type': 'application/json' },
|
|
193
|
+
body: JSON.stringify({ name: 'Automation', scopes: ['agents:read'] }),
|
|
194
|
+
})
|
|
195
|
+
.then((res) => res.json());
|
|
196
|
+
```
|
|
180
197
|
|
|
181
198
|
### Buenas prácticas
|
|
182
199
|
|
|
@@ -198,7 +215,7 @@ Consulta el OpenAPI (`docs/api-spec/openapi.yaml`) para revisar nuevos scopes co
|
|
|
198
215
|
|
|
199
216
|
## Novedades (octubre 2025)
|
|
200
217
|
|
|
201
|
-
- **Gestión de API Keys desde el SDK**:
|
|
218
|
+
- **Gestión de API Keys desde el SDK**: `client.apiKeys` expone helpers tipados para listar, crear y revocar credenciales con el mismo manejo de cabeceras, timeouts y reintentos del resto del cliente.
|
|
202
219
|
- **Scopes documentados**: tabla de scopes disponibles y recomendaciones para definir permisos mínimos por workspace.
|
|
203
220
|
- **Mejoras de gobernanza**: se incorporaron pautas de rotación, almacenamiento seguro y segmentación por entorno directamente en la guía del SDK.
|
|
204
221
|
|
package/dist/index.cjs
CHANGED
|
@@ -36,6 +36,7 @@ __export(index_exports, {
|
|
|
36
36
|
createAgentTagsApi: () => createAgentTagsApi,
|
|
37
37
|
createAgentVersionsApi: () => createAgentVersionsApi,
|
|
38
38
|
createAgentsApi: () => createAgentsApi,
|
|
39
|
+
createApiKeysApi: () => createApiKeysApi,
|
|
39
40
|
createClient: () => createClient,
|
|
40
41
|
createHttp: () => createHttp,
|
|
41
42
|
createToolsApi: () => createToolsApi,
|
|
@@ -147,8 +148,10 @@ function createHttp(cfg) {
|
|
|
147
148
|
const retry = cfg.retry;
|
|
148
149
|
const WORKSPACE_HEADER = "x-workspace-id";
|
|
149
150
|
const API_KEY_HEADER = "x-api-key";
|
|
151
|
+
const AUTHORIZATION_HEADER = "authorization";
|
|
150
152
|
const resolveWorkspaceId = () => cfg.getWorkspaceId?.() ?? cfg.workspaceId ?? void 0;
|
|
151
153
|
const resolveApiKey = () => cfg.getApiKey?.() ?? cfg.apiKey ?? void 0;
|
|
154
|
+
const resolveAccessToken = () => cfg.getAccessToken?.() ?? cfg.accessToken ?? void 0;
|
|
152
155
|
const normalizeHeaders = (headers) => {
|
|
153
156
|
if (!headers) {
|
|
154
157
|
return {};
|
|
@@ -174,10 +177,15 @@ function createHttp(cfg) {
|
|
|
174
177
|
const headersWithWorkspace = workspaceId ? { [WORKSPACE_HEADER]: workspaceId } : {};
|
|
175
178
|
const apiKey = resolveApiKey();
|
|
176
179
|
const headersWithApiKey = apiKey ? { [API_KEY_HEADER]: apiKey } : {};
|
|
180
|
+
const accessToken = resolveAccessToken();
|
|
181
|
+
const headersWithAuthorization = accessToken ? {
|
|
182
|
+
[AUTHORIZATION_HEADER]: accessToken.startsWith("Bearer ") ? accessToken : `Bearer ${accessToken}`
|
|
183
|
+
} : {};
|
|
177
184
|
return {
|
|
178
185
|
...baseHeaders,
|
|
179
186
|
...headersWithWorkspace,
|
|
180
187
|
...headersWithApiKey,
|
|
188
|
+
...headersWithAuthorization,
|
|
181
189
|
...normalizedExtra
|
|
182
190
|
};
|
|
183
191
|
};
|
|
@@ -219,7 +227,8 @@ function createHttp(cfg) {
|
|
|
219
227
|
doFetch,
|
|
220
228
|
buildHeaders,
|
|
221
229
|
resolveWorkspaceId,
|
|
222
|
-
resolveApiKey
|
|
230
|
+
resolveApiKey,
|
|
231
|
+
resolveAccessToken
|
|
223
232
|
};
|
|
224
233
|
}
|
|
225
234
|
|
|
@@ -930,6 +939,37 @@ function createAgentsApi(cfg, relatedApis) {
|
|
|
930
939
|
};
|
|
931
940
|
}
|
|
932
941
|
|
|
942
|
+
// src/api/api-keys.ts
|
|
943
|
+
function createApiKeysApi(cfg) {
|
|
944
|
+
const { base, doFetch } = createHttp(cfg);
|
|
945
|
+
const jsonHeaders = { "content-type": "application/json" };
|
|
946
|
+
return {
|
|
947
|
+
async list() {
|
|
948
|
+
const res = await doFetch(`${base}/v1/api-keys`, { method: "GET" });
|
|
949
|
+
return res.json();
|
|
950
|
+
},
|
|
951
|
+
async create(payload) {
|
|
952
|
+
const res = await doFetch(`${base}/v1/api-keys`, {
|
|
953
|
+
method: "POST",
|
|
954
|
+
headers: jsonHeaders,
|
|
955
|
+
body: JSON.stringify(payload)
|
|
956
|
+
});
|
|
957
|
+
return res.json();
|
|
958
|
+
},
|
|
959
|
+
async revoke(apiKeyId) {
|
|
960
|
+
await doFetch(`${base}/v1/api-keys/${apiKeyId}`, {
|
|
961
|
+
method: "DELETE"
|
|
962
|
+
});
|
|
963
|
+
},
|
|
964
|
+
async show(apiKeyId) {
|
|
965
|
+
const res = await doFetch(`${base}/v1/api-keys/${apiKeyId}/show`, {
|
|
966
|
+
method: "GET"
|
|
967
|
+
});
|
|
968
|
+
return res.json();
|
|
969
|
+
}
|
|
970
|
+
};
|
|
971
|
+
}
|
|
972
|
+
|
|
933
973
|
// src/api/tools.ts
|
|
934
974
|
var isFormData = (value) => {
|
|
935
975
|
return typeof FormData !== "undefined" && value instanceof FormData;
|
|
@@ -1122,6 +1162,7 @@ function createClient(initialCfg) {
|
|
|
1122
1162
|
};
|
|
1123
1163
|
const resolveWorkspaceId = () => runtimeCfg.workspaceId ?? runtimeCfg.getWorkspaceId?.();
|
|
1124
1164
|
const resolveApiKey = () => runtimeCfg.apiKey ?? runtimeCfg.getApiKey?.();
|
|
1165
|
+
const resolveAccessToken = () => runtimeCfg.accessToken ?? runtimeCfg.getAccessToken?.();
|
|
1125
1166
|
const setWorkspaceId = (workspaceId) => {
|
|
1126
1167
|
runtimeCfg.workspaceId = workspaceId;
|
|
1127
1168
|
};
|
|
@@ -1134,6 +1175,12 @@ function createClient(initialCfg) {
|
|
|
1134
1175
|
const setApiKeyGetter = (getter) => {
|
|
1135
1176
|
runtimeCfg.getApiKey = getter;
|
|
1136
1177
|
};
|
|
1178
|
+
const setAccessToken = (token) => {
|
|
1179
|
+
runtimeCfg.accessToken = token;
|
|
1180
|
+
};
|
|
1181
|
+
const setAccessTokenGetter = (getter) => {
|
|
1182
|
+
runtimeCfg.getAccessToken = getter;
|
|
1183
|
+
};
|
|
1137
1184
|
const instructionsApi = createAgentInstructionsApi(runtimeCfg);
|
|
1138
1185
|
const tagsApi = createAgentTagsApi(runtimeCfg);
|
|
1139
1186
|
const phonesApi = createAgentPhonesApi(runtimeCfg);
|
|
@@ -1141,6 +1188,7 @@ function createClient(initialCfg) {
|
|
|
1141
1188
|
const versionsApi = createAgentVersionsApi(runtimeCfg);
|
|
1142
1189
|
const blueprintsApi = createAgentBlueprintsApi(runtimeCfg);
|
|
1143
1190
|
const voicesApi = createVoicesApi(runtimeCfg);
|
|
1191
|
+
const apiKeysApi = createApiKeysApi(runtimeCfg);
|
|
1144
1192
|
const agentsApi = createAgentsApi(runtimeCfg, {
|
|
1145
1193
|
instructionsApi,
|
|
1146
1194
|
tagsApi,
|
|
@@ -1185,7 +1233,8 @@ function createClient(initialCfg) {
|
|
|
1185
1233
|
},
|
|
1186
1234
|
workspaces: createWorkspacesApi(runtimeCfg),
|
|
1187
1235
|
tools: createToolsApi(runtimeCfg),
|
|
1188
|
-
voices: voicesApi
|
|
1236
|
+
voices: voicesApi,
|
|
1237
|
+
apiKeys: apiKeysApi
|
|
1189
1238
|
};
|
|
1190
1239
|
return {
|
|
1191
1240
|
...apis,
|
|
@@ -1201,6 +1250,18 @@ function createClient(initialCfg) {
|
|
|
1201
1250
|
clearApiKey() {
|
|
1202
1251
|
setApiKeyGetter(void 0);
|
|
1203
1252
|
setApiKey(void 0);
|
|
1253
|
+
},
|
|
1254
|
+
getAccessToken: resolveAccessToken,
|
|
1255
|
+
setAccessToken(token) {
|
|
1256
|
+
setAccessTokenGetter(void 0);
|
|
1257
|
+
setAccessToken(token);
|
|
1258
|
+
},
|
|
1259
|
+
useAccessToken(getter) {
|
|
1260
|
+
setAccessTokenGetter(getter);
|
|
1261
|
+
},
|
|
1262
|
+
clearAccessToken() {
|
|
1263
|
+
setAccessTokenGetter(void 0);
|
|
1264
|
+
setAccessToken(void 0);
|
|
1204
1265
|
}
|
|
1205
1266
|
},
|
|
1206
1267
|
workspace: {
|
|
@@ -1222,7 +1283,9 @@ function createClient(initialCfg) {
|
|
|
1222
1283
|
workspaceId: id,
|
|
1223
1284
|
getWorkspaceId: void 0,
|
|
1224
1285
|
apiKey: runtimeCfg.apiKey,
|
|
1225
|
-
getApiKey: runtimeCfg.getApiKey
|
|
1286
|
+
getApiKey: runtimeCfg.getApiKey,
|
|
1287
|
+
accessToken: runtimeCfg.accessToken,
|
|
1288
|
+
getAccessToken: runtimeCfg.getAccessToken
|
|
1226
1289
|
});
|
|
1227
1290
|
}
|
|
1228
1291
|
}
|
|
@@ -1247,6 +1310,7 @@ function createClient(initialCfg) {
|
|
|
1247
1310
|
createAgentTagsApi,
|
|
1248
1311
|
createAgentVersionsApi,
|
|
1249
1312
|
createAgentsApi,
|
|
1313
|
+
createApiKeysApi,
|
|
1250
1314
|
createClient,
|
|
1251
1315
|
createHttp,
|
|
1252
1316
|
createToolsApi,
|