@getsupervisor/agents-studio-sdk 1.25.0 → 1.26.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 CHANGED
@@ -1,3 +1,15 @@
1
+ ## v1.25.0
2
+
3
+ ## [1.25.0](https://github.com/julio-supervisor/agents-studio-be/compare/v1.24.0...v1.25.0) (2025-11-06)
4
+
5
+ ### Features
6
+
7
+ * enhance blueprint stage functionality with goalPrompt and promptInstructions attributes ([9d13681](https://github.com/julio-supervisor/agents-studio-be/commit/9d13681346f9ea48f5dd6b9c16ab90c95a81356d))
8
+ * implement blueprint stages and triggers ([b94e0d9](https://github.com/julio-supervisor/agents-studio-be/commit/b94e0d9723bf6406a9163d3d9dc998ada06be10a))
9
+ * refactor agent creation and blueprint building for improved test clarity and functionality ([136d5b1](https://github.com/julio-supervisor/agents-studio-be/commit/136d5b12a725d65e6d2fd77e224cc6615e3707d1))
10
+ * update blueprint stage to use goalPrompt and promptInstructions ([0e7bf89](https://github.com/julio-supervisor/agents-studio-be/commit/0e7bf89ed94853ad856c155e0f71e1ba1dafea84))
11
+
12
+
1
13
  ## v1.24.0
2
14
 
3
15
  ## [1.24.0](https://github.com/julio-supervisor/agents-studio-be/compare/v1.23.0...v1.24.0) (2025-11-05)
package/README.md CHANGED
@@ -34,22 +34,20 @@ await client.agents
34
34
 
35
35
  // administrar blueprints por versión
36
36
  const blueprints = client.agents.blueprints(agent.agentId);
37
- await blueprints
38
- .version('version-1')
39
- .create({
40
- languageId: 'es-MX',
41
- personalityName: 'Embajador de marca',
42
- personalityRole: 'Consultor de adopción',
43
- targetAudience: 'Usuarios nuevos',
44
- mainGoal: 'Incrementar la activación',
45
- personalityInitialGreeting: '¡Hola! Soy tu asistente de onboarding.',
46
- personalityMessageStyleId: 'style-uuid',
47
- personalityToneStyleId: 'tone-uuid',
48
- requiredData: [{ key: 'industry', label: 'Industria' }],
49
- criticalRules: ['Nunca compartas precios internos'],
50
- topicsAllowed: ['onboarding', 'soporte'],
51
- topicsForbidden: ['facturación'],
52
- });
37
+ await blueprints.version('version-1').create({
38
+ languageId: 'es-MX',
39
+ personalityName: 'Embajador de marca',
40
+ personalityRole: 'Consultor de adopción',
41
+ targetAudience: 'Usuarios nuevos',
42
+ mainGoal: 'Incrementar la activación',
43
+ personalityInitialGreeting: '¡Hola! Soy tu asistente de onboarding.',
44
+ personalityMessageStyleId: 'style-uuid',
45
+ personalityToneStyleId: 'tone-uuid',
46
+ requiredData: [{ key: 'industry', label: 'Industria' }],
47
+ criticalRules: ['Nunca compartas precios internos'],
48
+ topicsAllowed: ['onboarding', 'soporte'],
49
+ topicsForbidden: ['facturación'],
50
+ });
53
51
 
54
52
  // los helpers del entity también exponen blueprints
55
53
  const agentBlueprint = await agent.blueprints.version('version-1').get();
@@ -166,36 +164,42 @@ Estados soportados: `draft`, `active`, `archived`.
166
164
 
167
165
  ## Stages del blueprint
168
166
 
169
- Modela el flujo conversacional de cada agente con los helpers `client.agents.stages(agentId)`.
167
+ Modela el flujo conversacional de cada agente con los helpers `client.agents.stages(agentId)`, indicando siempre qué blueprint deseas administrar.
170
168
 
171
169
  ```ts
172
170
  const stages = client.agents.stages(agent.agentId);
171
+ const activeBlueprint = await client.agents.blueprints(agent.agentId).list();
172
+ const blueprintId = activeBlueprint.data[0].blueprint.id;
173
173
 
174
174
  // Paginar stages existentes
175
- const page = await stages.list({ limit: 10, search: 'greeting' });
175
+ const page = await stages.list(blueprintId, { limit: 10, search: 'greeting' });
176
176
  console.log(page.meta.total);
177
177
 
178
+ // También puedes obtener un helper con el blueprint preseleccionado
179
+ const blueprintStages = stages(blueprintId);
180
+
178
181
  // Crear un stage
179
- const created = await stages.create({
182
+ const created = await blueprintStages.create({
180
183
  name: 'proposal',
181
184
  title: 'Propuesta y cierre',
182
- prompt: 'Explica la solución recomendada y ofrece una llamada con humano.',
185
+ goalPrompt:
186
+ 'Explica la solución recomendada y ofrece una llamada con humano.',
183
187
  order: 2,
184
188
  metadata: { requiresSupervisor: false },
185
189
  });
186
190
 
187
191
  // Actualizar y reordenar
188
- await stages.update(created.id, {
189
- prompt: 'Resume beneficios en < 3 bullets y ofrece agendar demo.',
192
+ await blueprintStages.update(created.id, {
193
+ goalPrompt: 'Resume beneficios en < 3 bullets y ofrece agendar demo.',
190
194
  });
191
195
 
192
- await stages.reorder({
196
+ await stages.reorder(blueprintId, {
193
197
  stageIds: [page.data[0].id, created.id],
194
198
  startingStageName: 'greeting',
195
199
  });
196
200
 
197
201
  // Triggers por stage
198
- const triggers = stages.triggers(created.id);
202
+ const triggers = stages.triggers(blueprintId, created.id);
199
203
  await triggers.create({
200
204
  condition: { type: 'intent', value: 'schedule_call' },
201
205
  nextStageName: 'handoff',
@@ -205,7 +209,7 @@ const listing = await triggers.list();
205
209
  console.log(listing.data[0].condition);
206
210
  ```
207
211
 
208
- Los métodos de triggers permiten `list`, `get`, `create`, `update` y `delete`. Recuerda habilitar los scopes `stages:*` y `stage-triggers:*` en la credencial utilizada.
212
+ Los métodos de triggers permiten `list`, `get`, `create`, `update` y `delete`. Recuerda habilitar los scopes `blueprint-stages:*` y `stage-triggers:*` en la credencial utilizada.
209
213
 
210
214
  ## Horarios del agente (Agent Schedules)
211
215
 
@@ -352,7 +356,9 @@ client.workspace.get(); // 'ws-123'
352
356
  client.workspace.set('ws-456');
353
357
 
354
358
  // o delegar en un getter dinámico (por ejemplo, almacenamiento local)
355
- client.workspace.useGetter(() => sessionStorage.getItem('workspace') ?? undefined);
359
+ client.workspace.useGetter(
360
+ () => sessionStorage.getItem('workspace') ?? undefined,
361
+ );
356
362
 
357
363
  // crear un cliente aislado para otro workspace
358
364
  const scoped = client.workspace.scoped('ws-789');
@@ -442,26 +448,26 @@ const { key, ...metadata } = await http
442
448
 
443
449
  ### Scopes disponibles (octubre 2025)
444
450
 
445
- | Scope | Permiso principal |
446
- |-------|-------------------|
447
- | `agents:read` | Consultar agentes, versiones, instrucciones, teléfonos y blueprints asociados. |
448
- | `agents:write` | Crear, actualizar o eliminar agentes, versiones, teléfonos y su configuración operativa. |
449
- | `agent-instructions:read` | Leer instrucciones tanto a nivel agente como por versión publicada. |
450
- | `agent-instructions:write` | Crear, actualizar o borrar instrucciones personalizadas. |
451
- | `agent-blueprints:read` | Consultar blueprint y resúmenes sincronizados con proveedores externos. |
452
- | `agent-blueprints:write` | Editar blueprint, personalidad y reglas de cada versión. |
453
- | `agent-schedules:read` | Consultar horario semanal y excepciones vigentes. |
454
- | `agent-schedules:write` | Crear o modificar horarios y excepciones. |
455
- | `catalogs:read` | Navegar catálogos globales y por workspace (idiomas, estilos, voces, etc.). |
456
- | `catalogs:write` | Registrar o ajustar ítems de catálogo. |
457
- | `tools:read` | Descubrir tools disponibles, recursos y capacidades declaradas. |
458
- | `tools:connections:write` | Crear conexiones entre agentes y tools (p. ej. `voice.calls`). |
459
- | `tools:execute` | Ejecutar acciones de una tool (`startCall`, `reload`, etc.). |
460
- | `webhooks:read` | Listar webhooks y sus suscripciones activas. |
461
- | `webhooks:write` | Crear, actualizar o eliminar webhooks y suscripciones. |
462
- | `api-keys:read` | Listar credenciales existentes y revelar su valor. |
463
- | `api-keys:write` | Emitir o revocar API Keys. |
464
- | `workspaces:read` | Consultar metadatos y estado de habilitación de un workspace. |
451
+ | Scope | Permiso principal |
452
+ | -------------------------- | ---------------------------------------------------------------------------------------- |
453
+ | `agents:read` | Consultar agentes, versiones, instrucciones, teléfonos y blueprints asociados. |
454
+ | `agents:write` | Crear, actualizar o eliminar agentes, versiones, teléfonos y su configuración operativa. |
455
+ | `agent-instructions:read` | Leer instrucciones tanto a nivel agente como por versión publicada. |
456
+ | `agent-instructions:write` | Crear, actualizar o borrar instrucciones personalizadas. |
457
+ | `agent-blueprints:read` | Consultar blueprint y resúmenes sincronizados con proveedores externos. |
458
+ | `agent-blueprints:write` | Editar blueprint, personalidad y reglas de cada versión. |
459
+ | `agent-schedules:read` | Consultar horario semanal y excepciones vigentes. |
460
+ | `agent-schedules:write` | Crear o modificar horarios y excepciones. |
461
+ | `catalogs:read` | Navegar catálogos globales y por workspace (idiomas, estilos, voces, etc.). |
462
+ | `catalogs:write` | Registrar o ajustar ítems de catálogo. |
463
+ | `tools:read` | Descubrir tools disponibles, recursos y capacidades declaradas. |
464
+ | `tools:connections:write` | Crear conexiones entre agentes y tools (p. ej. `voice.calls`). |
465
+ | `tools:execute` | Ejecutar acciones de una tool (`startCall`, `reload`, etc.). |
466
+ | `webhooks:read` | Listar webhooks y sus suscripciones activas. |
467
+ | `webhooks:write` | Crear, actualizar o eliminar webhooks y suscripciones. |
468
+ | `api-keys:read` | Listar credenciales existentes y revelar su valor. |
469
+ | `api-keys:write` | Emitir o revocar API Keys. |
470
+ | `workspaces:read` | Consultar metadatos y estado de habilitación de un workspace. |
465
471
 
466
472
  Consulta el OpenAPI (`docs/api-spec/openapi.yaml`) para validar scopes adicionales (por ejemplo, específicos de conocimientos o teléfonos) y su mapeo exacto por operación.
467
473
 
package/dist/index.cjs CHANGED
@@ -661,7 +661,7 @@ function createAgentScheduleApi(cfg) {
661
661
  function createAgentStageTriggersApi(cfg) {
662
662
  const { base, doFetch } = createHttp(cfg);
663
663
  const jsonHeaders = { "content-type": "application/json" };
664
- const fetchTriggerPage = async (agentId, stageId, options = {}) => {
664
+ const fetchTriggerPage = async (agentId, blueprintId, stageId, options = {}) => {
665
665
  const normalizedOptions = {
666
666
  page: options.page,
667
667
  limit: options.limit,
@@ -674,7 +674,7 @@ function createAgentStageTriggersApi(cfg) {
674
674
  };
675
675
  const query = serializeListOptions(normalizedOptions);
676
676
  const res = await doFetch(
677
- `${base}/agents/${agentId}/stages/${stageId}/triggers`,
677
+ `${base}/agents/${agentId}/blueprints/${blueprintId}/stages/${stageId}/triggers`,
678
678
  {
679
679
  method: "GET",
680
680
  query
@@ -683,26 +683,26 @@ function createAgentStageTriggersApi(cfg) {
683
683
  return res.json();
684
684
  };
685
685
  return {
686
- async list(agentId, stageId, options = {}) {
686
+ async list(agentId, blueprintId, stageId, options = {}) {
687
687
  const normalized = {
688
688
  ...options ?? {}
689
689
  };
690
- const fetchPage = (opts) => fetchTriggerPage(agentId, stageId, opts);
690
+ const fetchPage = (opts) => fetchTriggerPage(agentId, blueprintId, stageId, opts);
691
691
  const response = await fetchPage(normalized);
692
692
  return attachPaginator(response, fetchPage, normalized);
693
693
  },
694
- async get(agentId, stageId, triggerId) {
694
+ async get(agentId, blueprintId, stageId, triggerId) {
695
695
  const res = await doFetch(
696
- `${base}/agents/${agentId}/stages/${stageId}/triggers/${triggerId}`,
696
+ `${base}/agents/${agentId}/blueprints/${blueprintId}/stages/${stageId}/triggers/${triggerId}`,
697
697
  {
698
698
  method: "GET"
699
699
  }
700
700
  );
701
701
  return res.json();
702
702
  },
703
- async create(agentId, stageId, payload) {
703
+ async create(agentId, blueprintId, stageId, payload) {
704
704
  const res = await doFetch(
705
- `${base}/agents/${agentId}/stages/${stageId}/triggers`,
705
+ `${base}/agents/${agentId}/blueprints/${blueprintId}/stages/${stageId}/triggers`,
706
706
  {
707
707
  method: "POST",
708
708
  headers: jsonHeaders,
@@ -711,9 +711,9 @@ function createAgentStageTriggersApi(cfg) {
711
711
  );
712
712
  return res.json();
713
713
  },
714
- async update(agentId, stageId, triggerId, payload) {
714
+ async update(agentId, blueprintId, stageId, triggerId, payload) {
715
715
  const res = await doFetch(
716
- `${base}/agents/${agentId}/stages/${stageId}/triggers/${triggerId}`,
716
+ `${base}/agents/${agentId}/blueprints/${blueprintId}/stages/${stageId}/triggers/${triggerId}`,
717
717
  {
718
718
  method: "PATCH",
719
719
  headers: jsonHeaders,
@@ -722,9 +722,9 @@ function createAgentStageTriggersApi(cfg) {
722
722
  );
723
723
  return res.json();
724
724
  },
725
- async delete(agentId, stageId, triggerId) {
725
+ async delete(agentId, blueprintId, stageId, triggerId) {
726
726
  await doFetch(
727
- `${base}/agents/${agentId}/stages/${stageId}/triggers/${triggerId}`,
727
+ `${base}/agents/${agentId}/blueprints/${blueprintId}/stages/${stageId}/triggers/${triggerId}`,
728
728
  {
729
729
  method: "DELETE"
730
730
  }
@@ -737,7 +737,7 @@ function createAgentStageTriggersApi(cfg) {
737
737
  function createAgentStagesApi(cfg) {
738
738
  const { base, doFetch } = createHttp(cfg);
739
739
  const jsonHeaders = { "content-type": "application/json" };
740
- const fetchStagePage = async (agentId, options = {}) => {
740
+ const fetchStagePage = async (agentId, blueprintId, options = {}) => {
741
741
  const normalizedOptions = {
742
742
  page: options.page,
743
743
  limit: options.limit,
@@ -746,52 +746,70 @@ function createAgentStagesApi(cfg) {
746
746
  search: options.search
747
747
  };
748
748
  const query = serializeListOptions(normalizedOptions);
749
- const res = await doFetch(`${base}/agents/${agentId}/stages`, {
750
- method: "GET",
751
- query
752
- });
749
+ const res = await doFetch(
750
+ `${base}/agents/${agentId}/blueprints/${blueprintId}/stages`,
751
+ {
752
+ method: "GET",
753
+ query
754
+ }
755
+ );
753
756
  return res.json();
754
757
  };
755
758
  return {
756
- async list(agentId, options = {}) {
759
+ async list(agentId, blueprintId, options = {}) {
757
760
  const normalized = { ...options ?? {} };
758
- const fetchPage = (opts) => fetchStagePage(agentId, opts);
761
+ const fetchPage = (opts) => fetchStagePage(agentId, blueprintId, opts);
759
762
  const response = await fetchPage(normalized);
760
763
  return attachPaginator(response, fetchPage, normalized);
761
764
  },
762
- async get(agentId, stageId) {
763
- const res = await doFetch(`${base}/agents/${agentId}/stages/${stageId}`, {
764
- method: "GET"
765
- });
765
+ async get(agentId, blueprintId, stageId) {
766
+ const res = await doFetch(
767
+ `${base}/agents/${agentId}/blueprints/${blueprintId}/stages/${stageId}`,
768
+ {
769
+ method: "GET"
770
+ }
771
+ );
766
772
  return res.json();
767
773
  },
768
- async create(agentId, payload) {
769
- const res = await doFetch(`${base}/agents/${agentId}/stages`, {
770
- method: "POST",
771
- headers: jsonHeaders,
772
- body: JSON.stringify(payload)
773
- });
774
+ async create(agentId, blueprintId, payload) {
775
+ const res = await doFetch(
776
+ `${base}/agents/${agentId}/blueprints/${blueprintId}/stages`,
777
+ {
778
+ method: "POST",
779
+ headers: jsonHeaders,
780
+ body: JSON.stringify(payload)
781
+ }
782
+ );
774
783
  return res.json();
775
784
  },
776
- async update(agentId, stageId, payload) {
777
- const res = await doFetch(`${base}/agents/${agentId}/stages/${stageId}`, {
778
- method: "PATCH",
779
- headers: jsonHeaders,
780
- body: JSON.stringify(payload)
781
- });
785
+ async update(agentId, blueprintId, stageId, payload) {
786
+ const res = await doFetch(
787
+ `${base}/agents/${agentId}/blueprints/${blueprintId}/stages/${stageId}`,
788
+ {
789
+ method: "PATCH",
790
+ headers: jsonHeaders,
791
+ body: JSON.stringify(payload)
792
+ }
793
+ );
782
794
  return res.json();
783
795
  },
784
- async delete(agentId, stageId) {
785
- await doFetch(`${base}/agents/${agentId}/stages/${stageId}`, {
786
- method: "DELETE"
787
- });
796
+ async delete(agentId, blueprintId, stageId) {
797
+ await doFetch(
798
+ `${base}/agents/${agentId}/blueprints/${blueprintId}/stages/${stageId}`,
799
+ {
800
+ method: "DELETE"
801
+ }
802
+ );
788
803
  },
789
- async reorder(agentId, payload) {
790
- const res = await doFetch(`${base}/agents/${agentId}/stages:reorder`, {
791
- method: "POST",
792
- headers: jsonHeaders,
793
- body: JSON.stringify(payload)
794
- });
804
+ async reorder(agentId, blueprintId, payload) {
805
+ const res = await doFetch(
806
+ `${base}/agents/${agentId}/blueprints/${blueprintId}/stages:reorder`,
807
+ {
808
+ method: "POST",
809
+ headers: jsonHeaders,
810
+ body: JSON.stringify(payload)
811
+ }
812
+ );
795
813
  return res.json();
796
814
  }
797
815
  };
@@ -949,46 +967,71 @@ var bindAgentInstructions = (api, agentId) => ({
949
967
  return api.delete(agentId, instructionId);
950
968
  }
951
969
  });
952
- var bindAgentStageTriggers = (api, agentId, stageId) => ({
970
+ var bindAgentStageTriggers = (api, agentId, blueprintId, stageId) => ({
953
971
  list(opts) {
954
- return api.list(agentId, stageId, opts);
972
+ return api.list(agentId, blueprintId, stageId, opts);
955
973
  },
956
974
  get(triggerId) {
957
- return api.get(agentId, stageId, triggerId);
975
+ return api.get(agentId, blueprintId, stageId, triggerId);
958
976
  },
959
977
  create(payload) {
960
- return api.create(agentId, stageId, payload);
978
+ return api.create(agentId, blueprintId, stageId, payload);
961
979
  },
962
980
  update(triggerId, payload) {
963
- return api.update(agentId, stageId, triggerId, payload);
981
+ return api.update(agentId, blueprintId, stageId, triggerId, payload);
964
982
  },
965
983
  delete(triggerId) {
966
- return api.delete(agentId, stageId, triggerId);
967
- }
968
- });
969
- var bindAgentStages = (stagesApi, triggersApi, agentId) => ({
970
- list(opts) {
971
- return stagesApi.list(agentId, opts);
972
- },
973
- get(stageId) {
974
- return stagesApi.get(agentId, stageId);
975
- },
976
- create(payload) {
977
- return stagesApi.create(agentId, payload);
978
- },
979
- update(stageId, payload) {
980
- return stagesApi.update(agentId, stageId, payload);
981
- },
982
- delete(stageId) {
983
- return stagesApi.delete(agentId, stageId);
984
- },
985
- reorder(payload) {
986
- return stagesApi.reorder(agentId, payload);
987
- },
988
- triggers(stageId) {
989
- return bindAgentStageTriggers(triggersApi, agentId, stageId);
984
+ return api.delete(agentId, blueprintId, stageId, triggerId);
990
985
  }
991
986
  });
987
+ var bindAgentStages = (stagesApi, triggersApi, agentId) => {
988
+ const forBlueprint = (blueprintId) => ({
989
+ list(opts) {
990
+ return stagesApi.list(agentId, blueprintId, opts);
991
+ },
992
+ get(stageId) {
993
+ return stagesApi.get(agentId, blueprintId, stageId);
994
+ },
995
+ create(payload) {
996
+ return stagesApi.create(agentId, blueprintId, payload);
997
+ },
998
+ update(stageId, payload) {
999
+ return stagesApi.update(agentId, blueprintId, stageId, payload);
1000
+ },
1001
+ delete(stageId) {
1002
+ return stagesApi.delete(agentId, blueprintId, stageId);
1003
+ },
1004
+ reorder(payload) {
1005
+ return stagesApi.reorder(agentId, blueprintId, payload);
1006
+ },
1007
+ triggers(stageId) {
1008
+ return bindAgentStageTriggers(triggersApi, agentId, blueprintId, stageId);
1009
+ }
1010
+ });
1011
+ return Object.assign(forBlueprint, {
1012
+ list(blueprintId, opts) {
1013
+ return stagesApi.list(agentId, blueprintId, opts);
1014
+ },
1015
+ get(blueprintId, stageId) {
1016
+ return stagesApi.get(agentId, blueprintId, stageId);
1017
+ },
1018
+ create(blueprintId, payload) {
1019
+ return stagesApi.create(agentId, blueprintId, payload);
1020
+ },
1021
+ update(blueprintId, stageId, payload) {
1022
+ return stagesApi.update(agentId, blueprintId, stageId, payload);
1023
+ },
1024
+ delete(blueprintId, stageId) {
1025
+ return stagesApi.delete(agentId, blueprintId, stageId);
1026
+ },
1027
+ reorder(blueprintId, payload) {
1028
+ return stagesApi.reorder(agentId, blueprintId, payload);
1029
+ },
1030
+ triggers(blueprintId, stageId) {
1031
+ return bindAgentStageTriggers(triggersApi, agentId, blueprintId, stageId);
1032
+ }
1033
+ });
1034
+ };
992
1035
  var bindAgentTags = (api, agentId) => ({
993
1036
  add(tagId) {
994
1037
  return api.add(agentId, { tagId });
@@ -1884,7 +1927,7 @@ function createClient(initialCfg) {
1884
1927
  blueprintsApi
1885
1928
  );
1886
1929
  const stageTriggersNamespace = Object.assign(
1887
- (agentId, stageId) => bindAgentStageTriggers(stageTriggersApi, agentId, stageId),
1930
+ (agentId, blueprintId, stageId) => bindAgentStageTriggers(stageTriggersApi, agentId, blueprintId, stageId),
1888
1931
  stageTriggersApi
1889
1932
  );
1890
1933
  const stagesNamespace = Object.assign(