@johpaz/hive-agents 1.1.3 → 1.1.4

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/dist/hive.js CHANGED
@@ -51154,7 +51154,7 @@ var package_default;
51154
51154
  var init_package = __esm(() => {
51155
51155
  package_default = {
51156
51156
  name: "@johpaz/hive-agents",
51157
- version: "1.1.3",
51157
+ version: "1.1.4",
51158
51158
  description: "Tu colmena de agentes IA. Local-first. Multi-canal. Open source. Construido desde Colombia para el mundo.",
51159
51159
  private: false,
51160
51160
  bin: {
@@ -66074,6 +66074,23 @@ function findComponentCycle(components) {
66074
66074
  }
66075
66075
  return null;
66076
66076
  }
66077
+ function findIncompleteComponents(components) {
66078
+ const problems = [];
66079
+ for (const raw of components) {
66080
+ if (!raw || typeof raw !== "object")
66081
+ continue;
66082
+ const def = raw;
66083
+ const nested = def.component && typeof def.component === "object" && !Array.isArray(def.component) ? Object.entries(def.component)[0] : undefined;
66084
+ const type = nested ? nested[0] : typeof def.component === "string" ? def.component.trim() : "";
66085
+ const props = nested && nested[1] && typeof nested[1] === "object" ? { ...def, ...nested[1] } : def;
66086
+ for (const alternatives of REQUIRED_PROPS[type] ?? []) {
66087
+ if (!alternatives.some((key) => props[key] !== undefined && props[key] !== null)) {
66088
+ problems.push(`${String(def.id)} (${type}) necesita ${alternatives.join(" o ")}`);
66089
+ }
66090
+ }
66091
+ }
66092
+ return problems;
66093
+ }
66077
66094
  function createA2UISurfaceTool(_config) {
66078
66095
  const log = logger.child("a2ui-surface");
66079
66096
  return {
@@ -66129,6 +66146,16 @@ function createA2UISurfaceTool(_config) {
66129
66146
  const connected = canvasManager.getConnectedSessions();
66130
66147
  log.warn(`No visual sessions connected. Rendering to ${sessionId} anyway. Available: ${connected.join(", ")}`);
66131
66148
  }
66149
+ const built = canvasManager.getCachedComponents(sessionId, params.surfaceId);
66150
+ if (built.length > 0) {
66151
+ return JSON.stringify({
66152
+ status: "exists",
66153
+ surfaceId: params.surfaceId,
66154
+ sessionId,
66155
+ componentCount: built.length,
66156
+ hint: `La superficie '${params.surfaceId}' ya existe con ${built.length} componentes y NO se volvi\xF3 a crear: hacerlo la vaciar\xEDa. Para cambiarla usa a2ui_update_components con los mismos ids (reemplaza por id) o a2ui_update_data_model. Si de verdad necesitas empezar de cero: a2ui_delete_surface y luego crearla, y reenv\xEDa TODOS los componentes.`
66157
+ });
66158
+ }
66132
66159
  await canvasManager.sendA2UIMessage(sessionId, "a2ui:createSurface", {
66133
66160
  surfaceId: params.surfaceId,
66134
66161
  catalogId: params.catalogId,
@@ -66139,7 +66166,8 @@ function createA2UISurfaceTool(_config) {
66139
66166
  return JSON.stringify({
66140
66167
  status: "created",
66141
66168
  surfaceId: params.surfaceId,
66142
- sessionId
66169
+ sessionId,
66170
+ next: "La superficie est\xE1 VAC\xCDA: env\xEDa ahora TODOS los componentes completos con a2ui_update_components (y luego el data model). No des la tarea por terminada antes."
66143
66171
  });
66144
66172
  }
66145
66173
  };
@@ -66150,6 +66178,8 @@ function createA2UIUpdateComponentsTool(_config) {
66150
66178
  name: "a2ui_update_components",
66151
66179
  description: `Send A2UI v0.9 components to an existing surface. Components are a FLAT list with ID references (adjacency list).
66152
66180
 
66181
+ ENV\xCDA TODO COMPLETO EN UNA SOLA LLAMADA: cada componente con sus propiedades (children, text, label, options, action\u2026) seg\xFAn su tipo. Un componente con solo id y component se rechaza y no se publica nada; no mandes un esqueleto para rellenarlo despu\xE9s.
66182
+
66153
66183
  CHILDREN (spec oficial A2UI v0.9):
66154
66184
  Static: "children": ["id1", "id2"] \u2190 array crudo, formato oficial
66155
66185
  Template: "children": {"path": "/items", "componentId": "item_tmpl"} \u2190 formato oficial
@@ -66200,7 +66230,9 @@ Root component: usar id="root" expl\xEDcito.`,
66200
66230
  id: { type: "string", description: "Unique component ID within the surface" },
66201
66231
  component: { type: "string", description: "Component type: Text, Button, Row, Column, Card, List, Divider, Image, Icon, Video, AudioPlayer, TextField, CheckBox, ChoicePicker, Slider, DateTimeInput, Tabs, Modal" },
66202
66232
  weight: { type: "number", description: "Flex weight for proportional sizing inside Row/Column" }
66203
- }
66233
+ },
66234
+ required: ["id", "component"],
66235
+ additionalProperties: true
66204
66236
  }
66205
66237
  }
66206
66238
  },
@@ -66214,6 +66246,10 @@ Root component: usar id="root" expl\xEDcito.`,
66214
66246
  })();
66215
66247
  if (!Array.isArray(params.components))
66216
66248
  throw new Error("components must be an array");
66249
+ const incomplete = findIncompleteComponents(params.components);
66250
+ if (incomplete.length > 0) {
66251
+ throw new Error(`Componentes incompletos: ${incomplete.join("; ")}. Env\xEDa TODOS los componentes COMPLETOS en una sola llamada a a2ui_update_components (con children, text, label, options, action\u2026 seg\xFAn el tipo), no un esqueleto con solo id y component. No se public\xF3 nada.`);
66252
+ }
66217
66253
  const cycle = findComponentCycle(mergeComponentsById(canvasManager.getCachedComponents(sessionId, params.surfaceId), params.components));
66218
66254
  if (cycle) {
66219
66255
  throw new Error(`Ciclo en los componentes: ${cycle.join(" -> ")}. Un componente no puede contenerse a s\xED mismo ni a un ancestro. Dale al hijo un id propio (por ejemplo "${cycle[0]}_contenido") y vuelve a enviar. No se public\xF3 nada.`);
@@ -66322,9 +66358,29 @@ function createTools7(config) {
66322
66358
  createA2UIDeleteSurfaceTool(config)
66323
66359
  ];
66324
66360
  }
66361
+ var REQUIRED_PROPS;
66325
66362
  var init_a2ui = __esm(() => {
66326
66363
  init_canvas_manager();
66327
66364
  init_logger();
66365
+ REQUIRED_PROPS = {
66366
+ Column: [["children"]],
66367
+ Row: [["children"]],
66368
+ List: [["children", "child"]],
66369
+ Card: [["child"]],
66370
+ Text: [["text"]],
66371
+ Button: [["child", "text"]],
66372
+ TextField: [["label", "value"]],
66373
+ CheckBox: [["label"]],
66374
+ ChoicePicker: [["options"]],
66375
+ Slider: [["value", "label"]],
66376
+ DateTimeInput: [["value", "label"]],
66377
+ Tabs: [["tabs", "tabItems"]],
66378
+ Modal: [["trigger", "entryPointChild"], ["content", "contentChild"]],
66379
+ Image: [["url"]],
66380
+ Video: [["url"]],
66381
+ AudioPlayer: [["url"]],
66382
+ Icon: [["name"]]
66383
+ };
66328
66384
  });
66329
66385
 
66330
66386
  // packages/core/src/tools/core/index.ts
@@ -221700,8 +221756,8 @@ var init_agent_catalog = __esm(() => {
221700
221756
  receives: "Sesi\xF3n, surfaceId, flujo solicitado, datos, acciones permitidas y criterios visuales.",
221701
221757
  workflow: [
221702
221758
  "Dise\xF1a una jerarqu\xEDa peque\xF1a con IDs \xFAnicos y un root expl\xEDcito.",
221703
- "Crea la superficie antes de enviar componentes.",
221704
- "Env\xEDa componentes v\xE1lidos y despu\xE9s el data model enlazado.",
221759
+ "Crea la superficie UNA sola vez antes de enviar componentes; si ya existe, no la vuelvas a crear (se vaciar\xEDa): actual\xEDzala.",
221760
+ "Env\xEDa en UNA sola llamada todos los componentes COMPLETOS \u2014con children, text, label, options, action\u2026 seg\xFAn su tipo\u2014; nunca un esqueleto con solo id y component ni los rellenes en llamadas posteriores. Despu\xE9s, el data model enlazado.",
221705
221761
  "Comprueba acknowledgements, IDs y paths; libera la superficie al cancelar."
221706
221762
  ],
221707
221763
  prohibitions: [...COMMON_PROHIBITIONS, "No interpretas acciones del usuario ni conversas; los eventos vuelven al principal."],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@johpaz/hive-agents",
3
- "version": "1.1.3",
3
+ "version": "1.1.4",
4
4
  "description": "Tu colmena de agentes IA. Local-first. Multi-canal. Open source. Construido desde Colombia para el mundo.",
5
5
  "private": false,
6
6
  "bin": {
@@ -194,8 +194,8 @@ const CATALOG_PERSONAS: CatalogPersona[] = [
194
194
  receives: "Sesión, surfaceId, flujo solicitado, datos, acciones permitidas y criterios visuales.",
195
195
  workflow: [
196
196
  "Diseña una jerarquía pequeña con IDs únicos y un root explícito.",
197
- "Crea la superficie antes de enviar componentes.",
198
- "Envía componentes válidos y después el data model enlazado.",
197
+ "Crea la superficie UNA sola vez antes de enviar componentes; si ya existe, no la vuelvas a crear (se vaciaría): actualízala.",
198
+ "Envía en UNA sola llamada todos los componentes COMPLETOS —con children, text, label, options, action… según su tipo—; nunca un esqueleto con solo id y component ni los rellenes en llamadas posteriores. Después, el data model enlazado.",
199
199
  "Comprueba acknowledgements, IDs y paths; libera la superficie al cancelar.",
200
200
  ],
201
201
  prohibitions: [...COMMON_PROHIBITIONS, "No interpretas acciones del usuario ni conversas; los eventos vuelven al principal."],
@@ -57,6 +57,55 @@ export function findComponentCycle(components: unknown[]): string[] | null {
57
57
  return null
58
58
  }
59
59
 
60
+ /**
61
+ * What each component type must carry to render anything. Each entry is a list of alternatives:
62
+ * at least one key of every list has to be present. Unknown types are not checked (the client
63
+ * draws a placeholder for them).
64
+ */
65
+ const REQUIRED_PROPS: Record<string, string[][]> = {
66
+ Column: [["children"]],
67
+ Row: [["children"]],
68
+ List: [["children", "child"]],
69
+ Card: [["child"]],
70
+ Text: [["text"]],
71
+ Button: [["child", "text"]],
72
+ TextField: [["label", "value"]],
73
+ CheckBox: [["label"]],
74
+ ChoicePicker: [["options"]],
75
+ Slider: [["value", "label"]],
76
+ DateTimeInput: [["value", "label"]],
77
+ Tabs: [["tabs", "tabItems"]],
78
+ Modal: [["trigger", "entryPointChild"], ["content", "contentChild"]],
79
+ Image: [["url"]],
80
+ Video: [["url"]],
81
+ AudioPlayer: [["url"]],
82
+ Icon: [["name"]],
83
+ }
84
+
85
+ /**
86
+ * Components that would render empty ("root (Column) necesita children"). A skeleton with only
87
+ * `id` and `component` publishes a blank surface and the agent then believes it is done, so a batch
88
+ * must arrive complete. Both the flat and the nested (`{ Card: {...} }`) forms are understood.
89
+ */
90
+ export function findIncompleteComponents(components: unknown[]): string[] {
91
+ const problems: string[] = []
92
+ for (const raw of components) {
93
+ if (!raw || typeof raw !== "object") continue
94
+ const def = raw as Record<string, unknown>
95
+ const nested = def.component && typeof def.component === "object" && !Array.isArray(def.component)
96
+ ? Object.entries(def.component as Record<string, unknown>)[0]
97
+ : undefined
98
+ const type = nested ? nested[0] : typeof def.component === "string" ? def.component.trim() : ""
99
+ const props = nested && nested[1] && typeof nested[1] === "object" ? { ...def, ...(nested[1] as Record<string, unknown>) } : def
100
+ for (const alternatives of REQUIRED_PROPS[type] ?? []) {
101
+ if (!alternatives.some((key) => props[key] !== undefined && props[key] !== null)) {
102
+ problems.push(`${String(def.id)} (${type}) necesita ${alternatives.join(" o ")}`)
103
+ }
104
+ }
105
+ }
106
+ return problems
107
+ }
108
+
60
109
  export function createA2UISurfaceTool(_config: Config): Tool {
61
110
  const log = logger.child("a2ui-surface");
62
111
 
@@ -115,6 +164,21 @@ export function createA2UISurfaceTool(_config: Config): Tool {
115
164
  log.warn(`No visual sessions connected. Rendering to ${sessionId} anyway. Available: ${connected.join(", ")}`);
116
165
  }
117
166
 
167
+ // Creating a surface that already has components resets it to empty (client and replay cache
168
+ // alike). An agent that repeated the call after building the form left the user an empty panel.
169
+ // There is deliberately no "replace" flag: offering one, the model used it right away. Starting
170
+ // over is a2ui_delete_surface and then create, two explicit steps.
171
+ const built = canvasManager.getCachedComponents(sessionId, params.surfaceId as string)
172
+ if (built.length > 0) {
173
+ return JSON.stringify({
174
+ status: "exists",
175
+ surfaceId: params.surfaceId,
176
+ sessionId,
177
+ componentCount: built.length,
178
+ hint: `La superficie '${params.surfaceId}' ya existe con ${built.length} componentes y NO se volvió a crear: hacerlo la vaciaría. Para cambiarla usa a2ui_update_components con los mismos ids (reemplaza por id) o a2ui_update_data_model. Si de verdad necesitas empezar de cero: a2ui_delete_surface y luego crearla, y reenvía TODOS los componentes.`,
179
+ })
180
+ }
181
+
118
182
  await canvasManager.sendA2UIMessage(sessionId, "a2ui:createSurface", {
119
183
  surfaceId: params.surfaceId as string,
120
184
  catalogId: params.catalogId as string,
@@ -127,6 +191,7 @@ export function createA2UISurfaceTool(_config: Config): Tool {
127
191
  status: "created",
128
192
  surfaceId: params.surfaceId,
129
193
  sessionId,
194
+ next: "La superficie está VACÍA: envía ahora TODOS los componentes completos con a2ui_update_components (y luego el data model). No des la tarea por terminada antes.",
130
195
  });
131
196
  },
132
197
  };
@@ -139,6 +204,8 @@ export function createA2UIUpdateComponentsTool(_config: Config): Tool {
139
204
  name: "a2ui_update_components",
140
205
  description: `Send A2UI v0.9 components to an existing surface. Components are a FLAT list with ID references (adjacency list).
141
206
 
207
+ ENVÍA TODO COMPLETO EN UNA SOLA LLAMADA: cada componente con sus propiedades (children, text, label, options, action…) según su tipo. Un componente con solo id y component se rechaza y no se publica nada; no mandes un esqueleto para rellenarlo después.
208
+
142
209
  CHILDREN (spec oficial A2UI v0.9):
143
210
  Static: "children": ["id1", "id2"] ← array crudo, formato oficial
144
211
  Template: "children": {"path": "/items", "componentId": "item_tmpl"} ← formato oficial
@@ -190,6 +257,11 @@ Root component: usar id="root" explícito.`,
190
257
  component: { type: "string", description: "Component type: Text, Button, Row, Column, Card, List, Divider, Image, Icon, Video, AudioPlayer, TextField, CheckBox, ChoicePicker, Slider, DateTimeInput, Tabs, Modal" },
191
258
  weight: { type: "number", description: "Flex weight for proportional sizing inside Row/Column" },
192
259
  },
260
+ required: ["id", "component"],
261
+ // Each type has its own props (children, text, label, options, action…), listed in the tool
262
+ // description. Without this, a model whose output is constrained to the schema can only emit
263
+ // the three keys above and every component arrives empty.
264
+ additionalProperties: true,
193
265
  },
194
266
  },
195
267
  },
@@ -203,6 +275,10 @@ Root component: usar id="root" explícito.`,
203
275
  : (userId ? `canvas:${userId}` : (() => { throw new Error("No session or user ID provided"); })());
204
276
 
205
277
  if (!Array.isArray(params.components)) throw new Error("components must be an array")
278
+ const incomplete = findIncompleteComponents(params.components)
279
+ if (incomplete.length > 0) {
280
+ throw new Error(`Componentes incompletos: ${incomplete.join("; ")}. Envía TODOS los componentes COMPLETOS en una sola llamada a a2ui_update_components (con children, text, label, options, action… según el tipo), no un esqueleto con solo id y component. No se publicó nada.`)
281
+ }
206
282
  // Checked on the merged tree the client will render, not only this batch.
207
283
  const cycle = findComponentCycle(mergeComponentsById(
208
284
  canvasManager.getCachedComponents(sessionId, params.surfaceId as string),