@getsupervisor/agents-studio-sdk 1.4.0 → 1.6.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 +51 -0
- package/README.md +31 -23
- package/dist/index.cjs +180 -73
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +249 -931
- package/dist/index.d.ts +249 -931
- package/dist/index.js +178 -71
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,54 @@
|
|
|
1
|
+
## v1.4.0
|
|
2
|
+
|
|
3
|
+
## [1.4.0](https://github.com/julio-supervisor/agents-studio-be/compare/v1.3.0...v1.4.0) (2025-10-12)
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
* Add new SVG icons, images, and documentation updates for Agents Studio API ([3687495](https://github.com/julio-supervisor/agents-studio-be/commit/3687495640477794754b731e912d3f15b9e6db4e))
|
|
8
|
+
* enhance API documentation for agent management and workspace onboarding processes ([819c26c](https://github.com/julio-supervisor/agents-studio-be/commit/819c26cb662401b60004828ac7364aebd7eca039))
|
|
9
|
+
|
|
10
|
+
## v1.3.0
|
|
11
|
+
|
|
12
|
+
## [1.3.0](https://github.com/julio-supervisor/agents-studio-be/compare/v1.2.0...v1.3.0) (2025-10-11)
|
|
13
|
+
|
|
14
|
+
### Features
|
|
15
|
+
|
|
16
|
+
* actualizar la configuración de autenticación de npm para usar NODE_AUTH_TOKEN en los flujos de trabajo de despliegue y pruebas ([1817bde](https://github.com/julio-supervisor/agents-studio-be/commit/1817bdef6894d52d8be9b6c9649894446ae8dbf4))
|
|
17
|
+
* actualizar la versión de @getsupervisor/api-query-builder a 1.3.0 y agregar script de ejemplos ([dfc83c5](https://github.com/julio-supervisor/agents-studio-be/commit/dfc83c5c7ffccac704a4212c20f054b37bf4c620))
|
|
18
|
+
* **agents:** mejorar la API de agentes para incluir entidades y respuestas con datos adicionales ([7f0103a](https://github.com/julio-supervisor/agents-studio-be/commit/7f0103a4fd881f74cacaa7057562998ad6cd12a5))
|
|
19
|
+
* agregar autenticación npm en flujos de trabajo y mejorar ejemplos de agente ([7ef9dd5](https://github.com/julio-supervisor/agents-studio-be/commit/7ef9dd54f548d017609e143f1a06200b8e7da121))
|
|
20
|
+
* agregar configuración de autenticación npm para el alcance [@getsupervisor](https://github.com/getsupervisor) en flujos de trabajo ([7cd5890](https://github.com/julio-supervisor/agents-studio-be/commit/7cd5890936e96318f52852898a9d740b87b1eb2f))
|
|
21
|
+
* agregar exclusión de ejemplos de SDK en tsconfig.build.json ([5fe700c](https://github.com/julio-supervisor/agents-studio-be/commit/5fe700c48a04f0419729bdb854f18ad7580d5850))
|
|
22
|
+
* ajustar el directorio de trabajo y mejorar la depuración de autenticación npm en el flujo de trabajo de lanzamiento ([acef050](https://github.com/julio-supervisor/agents-studio-be/commit/acef0502b58d9edd15abf1d252c4c33052536661))
|
|
23
|
+
* ajustar el directorio de trabajo y simplificar la instalación de dependencias en el flujo de trabajo de lanzamiento ([dd2b009](https://github.com/julio-supervisor/agents-studio-be/commit/dd2b0090f3e781472fb1401290ba7e971c4c7b17))
|
|
24
|
+
* **api:** add query builder utilities and enhance OpenAPI spec ([1a6744a](https://github.com/julio-supervisor/agents-studio-be/commit/1a6744ac73c0eb4b5e35a7aadfb8093012c18b29))
|
|
25
|
+
* especificar la ruta del Dockerfile en el proceso de construcción de la imagen ([1a7ac54](https://github.com/julio-supervisor/agents-studio-be/commit/1a7ac5406072a81b316e41014ad9bf482b9733fb))
|
|
26
|
+
* habilitar la ejecución manual del flujo de trabajo de lanzamiento del SDK ([25c3654](https://github.com/julio-supervisor/agents-studio-be/commit/25c365481c81a9d7408e8846aee77af193c271e6))
|
|
27
|
+
* reemplazar npm por yarn para la instalación de dependencias y construcción del paquete ([7f09844](https://github.com/julio-supervisor/agents-studio-be/commit/7f09844a26c311e6762570338063ff1a37002ee7))
|
|
28
|
+
* simplificar la configuración de autenticación npm en el flujo de trabajo de lanzamiento ([94fce18](https://github.com/julio-supervisor/agents-studio-be/commit/94fce181286649a276e5556eb256ac6b62ac178e))
|
|
29
|
+
|
|
30
|
+
## v1.2.0
|
|
31
|
+
|
|
32
|
+
## [1.2.0](https://github.com/julio-supervisor/agents-studio-be/compare/v1.1.0...v1.2.0) (2025-10-10)
|
|
33
|
+
|
|
34
|
+
### Features
|
|
35
|
+
|
|
36
|
+
* **authorization:** mejorar la configuración y pruebas del sistema de autorización ([d963e9d](https://github.com/julio-supervisor/agents-studio-be/commit/d963e9da8d0f97547c7fb93b9b2fb5689e164cbb))
|
|
37
|
+
* **authz:** add casbin authorization module and tests ([2340f5f](https://github.com/julio-supervisor/agents-studio-be/commit/2340f5f0dc6e3a439b78e8147053c30762cd9dad))
|
|
38
|
+
* **authz:** ajustar rutas de mapeo y mejorar pruebas de autorización ([d8e10ef](https://github.com/julio-supervisor/agents-studio-be/commit/d8e10efcbcf41e07b929fa9578ec65d947d83c66))
|
|
39
|
+
* **authz:** implementar configuración de características de la aplicación y adaptador Casbin sin operaciones ([74599a7](https://github.com/julio-supervisor/agents-studio-be/commit/74599a722452c19599e13be3318a096400a9b8e0))
|
|
40
|
+
* **authz:** refactor NullAuthorizationCache methods and improve policy management logic ([93beddf](https://github.com/julio-supervisor/agents-studio-be/commit/93beddfdb832ab7d3d0562c42e99fdae6eb9fb8b))
|
|
41
|
+
* **docker:** agregar copiado de modelos de Casbin y políticas en el Dockerfile ([8122479](https://github.com/julio-supervisor/agents-studio-be/commit/81224793ed1d6756734f884a1e01950713885ec8))
|
|
42
|
+
* **docker:** ajustar Dockerfile para construir desde el directorio correcto y mejorar la gestión de dependencias ([b382edf](https://github.com/julio-supervisor/agents-studio-be/commit/b382edfd7aaac87b2f8c88cc8f9b270abeaff3a9))
|
|
43
|
+
* enhance agent management with new API endpoints and entity bindings ([ff7fd49](https://github.com/julio-supervisor/agents-studio-be/commit/ff7fd49c572828b394cbc3724568cc1ac3a81664))
|
|
44
|
+
* **issue-templates:** agregar plantillas para reportes de bugs, solicitudes de características y problemas de documentación ([eae8404](https://github.com/julio-supervisor/agents-studio-be/commit/eae840448e403afa783dd5301ff2ebe0e811a724))
|
|
45
|
+
|
|
46
|
+
### Bug Fixes
|
|
47
|
+
|
|
48
|
+
* **docker:** corregir rutas en el entrypoint y el comando de inicio para la aplicación ([a8e0c0b](https://github.com/julio-supervisor/agents-studio-be/commit/a8e0c0b7adcb1de5b6a409e99dfc4c4f6c4247ef))
|
|
49
|
+
* **migrations:** corregir rutas de migraciones para asegurar la correcta ejecución ([b2a7ed1](https://github.com/julio-supervisor/agents-studio-be/commit/b2a7ed1eaa153a77646220e7d57d61653bb07919))
|
|
50
|
+
|
|
51
|
+
|
|
1
52
|
## v1.1.0
|
|
2
53
|
|
|
3
54
|
## [1.1.0](https://github.com/julio-supervisor/agents-studio-be/compare/v1.0.0...v1.1.0) (2025-10-09)
|
package/README.md
CHANGED
|
@@ -1,34 +1,39 @@
|
|
|
1
|
-
# @getsupervisor/
|
|
1
|
+
# @getsupervisor/agents-studio-sdk
|
|
2
2
|
|
|
3
|
-
SDK JS/TS para
|
|
3
|
+
SDK JS/TS oficial para interactuar con la Public API de Agents Studio.
|
|
4
4
|
|
|
5
5
|
## Instalación
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
npm i @getsupervisor/
|
|
8
|
+
npm i @getsupervisor/agents-studio-sdk
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
## Uso básico
|
|
12
12
|
|
|
13
13
|
```ts
|
|
14
|
-
import { createClient } from '@getsupervisor/
|
|
14
|
+
import { createClient } from '@getsupervisor/agents-studio-sdk';
|
|
15
15
|
|
|
16
|
-
const client = createClient({
|
|
17
|
-
|
|
16
|
+
const client = createClient({
|
|
17
|
+
baseUrl: 'https://public-api.getsupervisor.ai',
|
|
18
|
+
headers: { Authorization: 'Bearer <token>' },
|
|
19
|
+
workspaceId: 'ws-123',
|
|
20
|
+
});
|
|
18
21
|
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
console.log(qr.qr);
|
|
22
|
+
const { data: agents } = await client.agents.list({ limit: 10 });
|
|
23
|
+
const agent = await client.agents.get('agent-123');
|
|
22
24
|
|
|
23
|
-
//
|
|
24
|
-
|
|
25
|
+
// administrar versiones e instrucciones
|
|
26
|
+
await client.agents
|
|
27
|
+
.versions(agent.agentId)
|
|
28
|
+
.instructions('version-1')
|
|
29
|
+
.create({ order: 1, content: 'Saluda con empatía' });
|
|
25
30
|
|
|
26
|
-
//
|
|
27
|
-
const
|
|
31
|
+
// catálogo y recursos de tools
|
|
32
|
+
const tools = await client.tools.list({ agentType: 'chat' });
|
|
33
|
+
await client.tools.uploadResource(tools.data[0].identifier, formData);
|
|
28
34
|
|
|
29
|
-
//
|
|
30
|
-
await client.
|
|
31
|
-
off();
|
|
35
|
+
// eliminar un agente
|
|
36
|
+
await client.agents.delete(agent.agentId);
|
|
32
37
|
```
|
|
33
38
|
|
|
34
39
|
## Configuración
|
|
@@ -69,16 +74,19 @@ const scoped = client.workspace.scoped('ws-789');
|
|
|
69
74
|
await scoped.agents.get('agentId');
|
|
70
75
|
```
|
|
71
76
|
|
|
77
|
+
## Novedades (septiembre 2024)
|
|
78
|
+
|
|
79
|
+
- **Sincronización completa con el OpenAPI más reciente**: se regeneraron los tipos `openapi-types.ts` y se actualizó la superficie pública para reflejar nuevos contratos.
|
|
80
|
+
- **Instrucciones por versión**: ahora puedes gestionar instrucciones directamente sobre versiones (`client.agents.versions(...).instructions(...)`) incluyendo operaciones de listar, crear, actualizar y eliminar.
|
|
81
|
+
- **Catálogo y recursos de tools**: soporte para listar tools filtrando por `agentType`, subir/eliminar/recargar recursos y establecer conexiones (`connect`) de manera tipada.
|
|
82
|
+
- **Deprecación de knowledge en agentes**: las rutas de knowledge fueron removidas del API. El helper anterior arroja un error explícito y los tipos asociados ya no se exportan.
|
|
83
|
+
- **Pruebas actualizadas**: la suite de Vitest se ajustó para cubrir helpers de versiones e instrucciones; `npm test` reporta 11 pruebas exitosas.
|
|
84
|
+
|
|
72
85
|
## Errores tipados y reintentos
|
|
73
86
|
|
|
74
|
-
|
|
75
|
-
- TimeoutError(ms)
|
|
76
|
-
- NetworkError(cause)
|
|
77
|
-
- Política de reintentos con backoff exponencial y jitter.
|
|
87
|
+
Los errores siguen modelados como `HttpError`, `TimeoutError` y `NetworkError`. Puedes configurar la política de reintentos con `retry: { maxRetries, baseDelayMs }` en el `createClient`.
|
|
78
88
|
|
|
79
89
|
## Compatibilidad
|
|
80
90
|
|
|
81
91
|
- Soporta ESM y CJS.
|
|
82
|
-
-
|
|
83
|
-
|
|
84
|
-
..
|
|
92
|
+
- Compatible con navegadores y Node.js (requiere `fetch` y `FormData` disponibles en el entorno).
|
package/dist/index.cjs
CHANGED
|
@@ -23,15 +23,15 @@ __export(index_exports, {
|
|
|
23
23
|
NetworkError: () => NetworkError,
|
|
24
24
|
TimeoutError: () => TimeoutError,
|
|
25
25
|
bindAgentInstructions: () => bindAgentInstructions,
|
|
26
|
-
bindAgentKnowledge: () => bindAgentKnowledge,
|
|
27
26
|
bindAgentPhones: () => bindAgentPhones,
|
|
28
27
|
bindAgentSchedule: () => bindAgentSchedule,
|
|
28
|
+
bindAgentTags: () => bindAgentTags,
|
|
29
29
|
bindAgentVersions: () => bindAgentVersions,
|
|
30
30
|
createAgentEntity: () => createAgentEntity,
|
|
31
31
|
createAgentInstructionsApi: () => createAgentInstructionsApi,
|
|
32
|
-
createAgentKnowledgeApi: () => createAgentKnowledgeApi,
|
|
33
32
|
createAgentPhonesApi: () => createAgentPhonesApi,
|
|
34
33
|
createAgentScheduleApi: () => createAgentScheduleApi,
|
|
34
|
+
createAgentTagsApi: () => createAgentTagsApi,
|
|
35
35
|
createAgentVersionsApi: () => createAgentVersionsApi,
|
|
36
36
|
createAgentsApi: () => createAgentsApi,
|
|
37
37
|
createClient: () => createClient,
|
|
@@ -470,60 +470,6 @@ function createAgentInstructionsApi(cfg) {
|
|
|
470
470
|
};
|
|
471
471
|
}
|
|
472
472
|
|
|
473
|
-
// src/api/agent-knowledge.ts
|
|
474
|
-
function createAgentKnowledgeApi(cfg) {
|
|
475
|
-
const { base, doFetch } = createHttp(cfg);
|
|
476
|
-
const jsonHeaders = { "content-type": "application/json" };
|
|
477
|
-
const fetchBasesPage = async (agentId, opts = {}) => {
|
|
478
|
-
const query = serializeListOptions(opts);
|
|
479
|
-
const res = await doFetch(`${base}/v1/agents/${agentId}/knowledge/bases`, {
|
|
480
|
-
method: "GET",
|
|
481
|
-
query
|
|
482
|
-
});
|
|
483
|
-
return res.json();
|
|
484
|
-
};
|
|
485
|
-
const fetchUploadsPage = async (agentId, opts = {}) => {
|
|
486
|
-
const query = serializeListOptions(opts);
|
|
487
|
-
const res = await doFetch(
|
|
488
|
-
`${base}/v1/agents/${agentId}/knowledge/uploads`,
|
|
489
|
-
{
|
|
490
|
-
method: "GET",
|
|
491
|
-
query
|
|
492
|
-
}
|
|
493
|
-
);
|
|
494
|
-
return res.json();
|
|
495
|
-
};
|
|
496
|
-
return {
|
|
497
|
-
async upload(agentId, payload) {
|
|
498
|
-
const res = await doFetch(
|
|
499
|
-
`${base}/v1/agents/${agentId}/knowledge/upload`,
|
|
500
|
-
{
|
|
501
|
-
method: "POST",
|
|
502
|
-
headers: jsonHeaders,
|
|
503
|
-
body: JSON.stringify(payload)
|
|
504
|
-
}
|
|
505
|
-
);
|
|
506
|
-
return res.json();
|
|
507
|
-
},
|
|
508
|
-
async listBases(agentId, opts = {}) {
|
|
509
|
-
const normalizedOptions = {
|
|
510
|
-
...opts ?? {}
|
|
511
|
-
};
|
|
512
|
-
const fetchPage = (options) => fetchBasesPage(agentId, options);
|
|
513
|
-
const response = await fetchPage(normalizedOptions);
|
|
514
|
-
return attachPaginator(response, fetchPage, normalizedOptions);
|
|
515
|
-
},
|
|
516
|
-
async listUploads(agentId, opts = {}) {
|
|
517
|
-
const normalizedOptions = {
|
|
518
|
-
...opts ?? {}
|
|
519
|
-
};
|
|
520
|
-
const fetchPage = (options) => fetchUploadsPage(agentId, options);
|
|
521
|
-
const response = await fetchPage(normalizedOptions);
|
|
522
|
-
return attachPaginator(response, fetchPage, normalizedOptions);
|
|
523
|
-
}
|
|
524
|
-
};
|
|
525
|
-
}
|
|
526
|
-
|
|
527
473
|
// src/api/agent-phones.ts
|
|
528
474
|
function createAgentPhonesApi(cfg) {
|
|
529
475
|
const { base, doFetch } = createHttp(cfg);
|
|
@@ -567,6 +513,27 @@ function createAgentScheduleApi(cfg) {
|
|
|
567
513
|
};
|
|
568
514
|
}
|
|
569
515
|
|
|
516
|
+
// src/api/agent-tags.ts
|
|
517
|
+
function createAgentTagsApi(cfg) {
|
|
518
|
+
const { base, doFetch } = createHttp(cfg);
|
|
519
|
+
const jsonHeaders = { "content-type": "application/json" };
|
|
520
|
+
return {
|
|
521
|
+
async add(agentId, payload) {
|
|
522
|
+
const res = await doFetch(`${base}/v1/agents/${agentId}/tags`, {
|
|
523
|
+
method: "POST",
|
|
524
|
+
headers: jsonHeaders,
|
|
525
|
+
body: JSON.stringify(payload)
|
|
526
|
+
});
|
|
527
|
+
return res.json();
|
|
528
|
+
},
|
|
529
|
+
async remove(agentId, tagId) {
|
|
530
|
+
await doFetch(`${base}/v1/agents/${agentId}/tags/${tagId}`, {
|
|
531
|
+
method: "DELETE"
|
|
532
|
+
});
|
|
533
|
+
}
|
|
534
|
+
};
|
|
535
|
+
}
|
|
536
|
+
|
|
570
537
|
// src/api/agent-versions.ts
|
|
571
538
|
function createAgentVersionsApi(cfg) {
|
|
572
539
|
const { base, doFetch } = createHttp(cfg);
|
|
@@ -614,6 +581,52 @@ function createAgentVersionsApi(cfg) {
|
|
|
614
581
|
}
|
|
615
582
|
);
|
|
616
583
|
return res.json();
|
|
584
|
+
},
|
|
585
|
+
async delete(agentId, versionId) {
|
|
586
|
+
await doFetch(`${base}/v1/agents/${agentId}/versions/${versionId}`, {
|
|
587
|
+
method: "DELETE"
|
|
588
|
+
});
|
|
589
|
+
},
|
|
590
|
+
async listInstructions(agentId, versionId, opts = {}) {
|
|
591
|
+
const query = serializeListOptions(opts);
|
|
592
|
+
const res = await doFetch(
|
|
593
|
+
`${base}/v1/agents/${agentId}/versions/${versionId}/instructions`,
|
|
594
|
+
{
|
|
595
|
+
method: "GET",
|
|
596
|
+
query
|
|
597
|
+
}
|
|
598
|
+
);
|
|
599
|
+
return res.json();
|
|
600
|
+
},
|
|
601
|
+
async createInstruction(agentId, versionId, payload) {
|
|
602
|
+
const res = await doFetch(
|
|
603
|
+
`${base}/v1/agents/${agentId}/versions/${versionId}/instructions`,
|
|
604
|
+
{
|
|
605
|
+
method: "POST",
|
|
606
|
+
headers: jsonHeaders,
|
|
607
|
+
body: JSON.stringify(payload)
|
|
608
|
+
}
|
|
609
|
+
);
|
|
610
|
+
return res.json();
|
|
611
|
+
},
|
|
612
|
+
async updateInstruction(agentId, versionId, instructionId, payload) {
|
|
613
|
+
const res = await doFetch(
|
|
614
|
+
`${base}/v1/agents/${agentId}/versions/${versionId}/instructions/${instructionId}`,
|
|
615
|
+
{
|
|
616
|
+
method: "PATCH",
|
|
617
|
+
headers: jsonHeaders,
|
|
618
|
+
body: JSON.stringify(payload)
|
|
619
|
+
}
|
|
620
|
+
);
|
|
621
|
+
return res.json();
|
|
622
|
+
},
|
|
623
|
+
async deleteInstruction(agentId, versionId, instructionId) {
|
|
624
|
+
await doFetch(
|
|
625
|
+
`${base}/v1/agents/${agentId}/versions/${versionId}/instructions/${instructionId}`,
|
|
626
|
+
{
|
|
627
|
+
method: "DELETE"
|
|
628
|
+
}
|
|
629
|
+
);
|
|
617
630
|
}
|
|
618
631
|
};
|
|
619
632
|
}
|
|
@@ -633,15 +646,12 @@ var bindAgentInstructions = (api, agentId) => ({
|
|
|
633
646
|
return api.delete(agentId, instructionId);
|
|
634
647
|
}
|
|
635
648
|
});
|
|
636
|
-
var
|
|
637
|
-
|
|
638
|
-
return api.
|
|
639
|
-
},
|
|
640
|
-
listBases(opts) {
|
|
641
|
-
return api.listBases(agentId, opts);
|
|
649
|
+
var bindAgentTags = (api, agentId) => ({
|
|
650
|
+
add(tagId) {
|
|
651
|
+
return api.add(agentId, { tagId });
|
|
642
652
|
},
|
|
643
|
-
|
|
644
|
-
return api.
|
|
653
|
+
remove(tagId) {
|
|
654
|
+
return api.remove(agentId, tagId);
|
|
645
655
|
}
|
|
646
656
|
});
|
|
647
657
|
var bindAgentPhones = (api, agentId) => ({
|
|
@@ -672,12 +682,36 @@ var bindAgentVersions = (api, agentId) => ({
|
|
|
672
682
|
},
|
|
673
683
|
update(versionId, payload) {
|
|
674
684
|
return api.update(agentId, versionId, payload);
|
|
685
|
+
},
|
|
686
|
+
delete(versionId) {
|
|
687
|
+
return api.delete(agentId, versionId);
|
|
688
|
+
},
|
|
689
|
+
instructions(versionId) {
|
|
690
|
+
return {
|
|
691
|
+
list(opts) {
|
|
692
|
+
return api.listInstructions(agentId, versionId, opts);
|
|
693
|
+
},
|
|
694
|
+
create(payload) {
|
|
695
|
+
return api.createInstruction(agentId, versionId, payload);
|
|
696
|
+
},
|
|
697
|
+
update(instructionId, payload) {
|
|
698
|
+
return api.updateInstruction(
|
|
699
|
+
agentId,
|
|
700
|
+
versionId,
|
|
701
|
+
instructionId,
|
|
702
|
+
payload
|
|
703
|
+
);
|
|
704
|
+
},
|
|
705
|
+
delete(instructionId) {
|
|
706
|
+
return api.deleteInstruction(agentId, versionId, instructionId);
|
|
707
|
+
}
|
|
708
|
+
};
|
|
675
709
|
}
|
|
676
710
|
});
|
|
677
711
|
var createAgentEntity = (dto, options) => {
|
|
678
712
|
const {
|
|
679
713
|
instructionsApi,
|
|
680
|
-
|
|
714
|
+
tagsApi,
|
|
681
715
|
phonesApi,
|
|
682
716
|
scheduleApi,
|
|
683
717
|
versionsApi,
|
|
@@ -688,7 +722,7 @@ var createAgentEntity = (dto, options) => {
|
|
|
688
722
|
const entity = {
|
|
689
723
|
...dto,
|
|
690
724
|
instructions: bindAgentInstructions(instructionsApi, dto.agentId),
|
|
691
|
-
|
|
725
|
+
tagAssignments: bindAgentTags(tagsApi, dto.agentId),
|
|
692
726
|
phones: bindAgentPhones(phonesApi, dto.agentId),
|
|
693
727
|
schedule: bindAgentSchedule(scheduleApi, dto.agentId),
|
|
694
728
|
versions: bindAgentVersions(versionsApi, dto.agentId),
|
|
@@ -765,7 +799,7 @@ function createAgentsApi(cfg, relatedApis) {
|
|
|
765
799
|
}
|
|
766
800
|
const wrapAgent = (detail) => createAgentEntity(detail, {
|
|
767
801
|
instructionsApi: relatedApis.instructionsApi,
|
|
768
|
-
|
|
802
|
+
tagsApi: relatedApis.tagsApi,
|
|
769
803
|
phonesApi: relatedApis.phonesApi,
|
|
770
804
|
scheduleApi: relatedApis.scheduleApi,
|
|
771
805
|
versionsApi: relatedApis.versionsApi,
|
|
@@ -812,23 +846,88 @@ function createAgentsApi(cfg, relatedApis) {
|
|
|
812
846
|
}
|
|
813
847
|
|
|
814
848
|
// src/api/tools.ts
|
|
849
|
+
var isFormData = (value) => {
|
|
850
|
+
return typeof FormData !== "undefined" && value instanceof FormData;
|
|
851
|
+
};
|
|
852
|
+
var toFormData = (payload) => {
|
|
853
|
+
if (isFormData(payload)) {
|
|
854
|
+
return payload;
|
|
855
|
+
}
|
|
856
|
+
if (typeof FormData === "undefined") {
|
|
857
|
+
throw new TypeError(
|
|
858
|
+
"FormData is not available in this environment. Pass a FormData instance instead."
|
|
859
|
+
);
|
|
860
|
+
}
|
|
861
|
+
const formData = new FormData();
|
|
862
|
+
formData.append("file", payload.file);
|
|
863
|
+
if (payload.type) {
|
|
864
|
+
formData.append("type", payload.type);
|
|
865
|
+
}
|
|
866
|
+
if (payload.title) {
|
|
867
|
+
formData.append("title", payload.title);
|
|
868
|
+
}
|
|
869
|
+
if (payload.metadata) {
|
|
870
|
+
formData.append("metadata", JSON.stringify(payload.metadata));
|
|
871
|
+
}
|
|
872
|
+
return formData;
|
|
873
|
+
};
|
|
815
874
|
function createToolsApi(cfg) {
|
|
816
875
|
const { base, doFetch } = createHttp(cfg);
|
|
817
876
|
const jsonHeaders = { "content-type": "application/json" };
|
|
818
877
|
const fetchToolsPage = async (options = {}) => {
|
|
819
|
-
const
|
|
878
|
+
const { agentType, ...queryOptions } = options ?? {};
|
|
879
|
+
const query = serializeListOptions(queryOptions, { agentType });
|
|
820
880
|
const res = await doFetch(`${base}/v1/tools`, {
|
|
821
881
|
method: "GET",
|
|
822
882
|
query
|
|
823
883
|
});
|
|
824
884
|
return res.json();
|
|
825
885
|
};
|
|
886
|
+
const fetchToolResourcesPage = async (toolId, options = {}) => {
|
|
887
|
+
const { type, ...queryOptions } = options ?? {};
|
|
888
|
+
const query = serializeListOptions(queryOptions, { type });
|
|
889
|
+
const res = await doFetch(`${base}/v1/tools/${toolId}/resources`, {
|
|
890
|
+
method: "GET",
|
|
891
|
+
query
|
|
892
|
+
});
|
|
893
|
+
return res.json();
|
|
894
|
+
};
|
|
826
895
|
return {
|
|
827
896
|
async list(options = {}) {
|
|
828
897
|
const normalizedOptions = { ...options ?? {} };
|
|
829
898
|
const response = await fetchToolsPage(normalizedOptions);
|
|
830
899
|
return attachPaginator(response, fetchToolsPage, normalizedOptions);
|
|
831
900
|
},
|
|
901
|
+
async listResources(toolId, options = {}) {
|
|
902
|
+
const normalizedOptions = {
|
|
903
|
+
...options ?? {}
|
|
904
|
+
};
|
|
905
|
+
const fetchPage = (opts) => fetchToolResourcesPage(toolId, opts);
|
|
906
|
+
const response = await fetchPage(normalizedOptions);
|
|
907
|
+
return attachPaginator(response, fetchPage, normalizedOptions);
|
|
908
|
+
},
|
|
909
|
+
async uploadResource(toolId, payload) {
|
|
910
|
+
const formData = toFormData(payload);
|
|
911
|
+
const res = await doFetch(`${base}/v1/tools/${toolId}/resources`, {
|
|
912
|
+
method: "POST",
|
|
913
|
+
body: formData
|
|
914
|
+
});
|
|
915
|
+
return res.json();
|
|
916
|
+
},
|
|
917
|
+
async deleteResource(toolId, resourceId) {
|
|
918
|
+
await doFetch(`${base}/v1/tools/${toolId}/resources/${resourceId}`, {
|
|
919
|
+
method: "DELETE"
|
|
920
|
+
});
|
|
921
|
+
},
|
|
922
|
+
async reloadResource(toolId, resourceId) {
|
|
923
|
+
const res = await doFetch(
|
|
924
|
+
`${base}/v1/tools/${toolId}/resources/${resourceId}/reload`,
|
|
925
|
+
{
|
|
926
|
+
method: "POST"
|
|
927
|
+
}
|
|
928
|
+
);
|
|
929
|
+
return res.json();
|
|
930
|
+
},
|
|
832
931
|
async execute(toolId, payload) {
|
|
833
932
|
const res = await doFetch(`${base}/v1/tools/${toolId}/execute`, {
|
|
834
933
|
method: "POST",
|
|
@@ -836,6 +935,14 @@ function createToolsApi(cfg) {
|
|
|
836
935
|
body: JSON.stringify(payload)
|
|
837
936
|
});
|
|
838
937
|
return res.json();
|
|
938
|
+
},
|
|
939
|
+
async connect(toolId, payload) {
|
|
940
|
+
const res = await doFetch(`${base}/v1/tools/${toolId}/connect`, {
|
|
941
|
+
method: "POST",
|
|
942
|
+
headers: jsonHeaders,
|
|
943
|
+
body: JSON.stringify(payload)
|
|
944
|
+
});
|
|
945
|
+
return res.json();
|
|
839
946
|
}
|
|
840
947
|
};
|
|
841
948
|
}
|
|
@@ -936,14 +1043,14 @@ function createClient(initialCfg) {
|
|
|
936
1043
|
runtimeCfg.getWorkspaceId = getter;
|
|
937
1044
|
};
|
|
938
1045
|
const instructionsApi = createAgentInstructionsApi(runtimeCfg);
|
|
939
|
-
const
|
|
1046
|
+
const tagsApi = createAgentTagsApi(runtimeCfg);
|
|
940
1047
|
const phonesApi = createAgentPhonesApi(runtimeCfg);
|
|
941
1048
|
const scheduleApi = createAgentScheduleApi(runtimeCfg);
|
|
942
1049
|
const versionsApi = createAgentVersionsApi(runtimeCfg);
|
|
943
1050
|
const voicesApi = createVoicesApi(runtimeCfg);
|
|
944
1051
|
const agentsApi = createAgentsApi(runtimeCfg, {
|
|
945
1052
|
instructionsApi,
|
|
946
|
-
|
|
1053
|
+
tagsApi,
|
|
947
1054
|
phonesApi,
|
|
948
1055
|
scheduleApi,
|
|
949
1056
|
versionsApi
|
|
@@ -951,8 +1058,8 @@ function createClient(initialCfg) {
|
|
|
951
1058
|
const apis = {
|
|
952
1059
|
agents: {
|
|
953
1060
|
...agentsApi,
|
|
954
|
-
knowledge: knowledgeApi,
|
|
955
1061
|
instructions: instructionsApi,
|
|
1062
|
+
tags: tagsApi,
|
|
956
1063
|
phones: phonesApi,
|
|
957
1064
|
schedule: scheduleApi,
|
|
958
1065
|
versions: versionsApi
|
|
@@ -992,15 +1099,15 @@ function createClient(initialCfg) {
|
|
|
992
1099
|
NetworkError,
|
|
993
1100
|
TimeoutError,
|
|
994
1101
|
bindAgentInstructions,
|
|
995
|
-
bindAgentKnowledge,
|
|
996
1102
|
bindAgentPhones,
|
|
997
1103
|
bindAgentSchedule,
|
|
1104
|
+
bindAgentTags,
|
|
998
1105
|
bindAgentVersions,
|
|
999
1106
|
createAgentEntity,
|
|
1000
1107
|
createAgentInstructionsApi,
|
|
1001
|
-
createAgentKnowledgeApi,
|
|
1002
1108
|
createAgentPhonesApi,
|
|
1003
1109
|
createAgentScheduleApi,
|
|
1110
|
+
createAgentTagsApi,
|
|
1004
1111
|
createAgentVersionsApi,
|
|
1005
1112
|
createAgentsApi,
|
|
1006
1113
|
createClient,
|