@alquimia-ai/tools 2.3.0 → 2.4.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.
@@ -172,6 +172,25 @@ function setPointer(model, pointer, value) {
172
172
  }
173
173
 
174
174
  // src/genui/actions.ts
175
+ var DISMISS_ACTION = "userDismissedSurface";
176
+ function buildDismissResult(surfaceId, userMessage) {
177
+ const said = typeof userMessage === "string" ? userMessage.trim() : "";
178
+ return {
179
+ action: DISMISS_ACTION,
180
+ surfaceId,
181
+ componentId: "",
182
+ data: {},
183
+ ...said ? { userMessage: said } : {}
184
+ };
185
+ }
186
+ function buildSurfaceResult(action) {
187
+ return {
188
+ action: action.action,
189
+ surfaceId: action.surfaceId,
190
+ componentId: action.componentId,
191
+ data: action.payload ?? {}
192
+ };
193
+ }
175
194
  function classifyAction(action) {
176
195
  return action.wantResponse === true ? "agent-bound" : "local";
177
196
  }
@@ -346,7 +365,9 @@ function buildGenuiClause(manifest, allowlist) {
346
365
  `Components: ${names.join(", ")}.`,
347
366
  `Style each component via the semantic vocabulary (never CSS, colors, or HTML): tone (${TONES.join("/")}), size (${SIZES.join("/")}), emphasis (low/medium/high), align (start/center/end), density (compact/comfortable), plus a component-specific variant where offered.`,
348
367
  "Data components MUST carry their data: Chart takes `data` (an array of row objects) + `series` (keys to plot) + `x` (the category key); Table takes `rows` (array of row objects) + `columns` ([{ key, header }] matching the row keys); List takes `items` (array); Stat takes `label`+`value`; KeyValue takes `data` (an object). Put the data inline on the component (or in dataModel referenced via `binding`).",
349
- "To collect input, add a Button with an action { name, wantResponse: true }; its result (the data model) is returned to you. A surface with no such button is display-only.",
368
+ "To collect input, add a Button with an action { name, wantResponse: true }. You get back { action, surfaceId, componentId, data } \u2014 `data` is the collected data model and `componentId` is the id of the component that was acted on. A surface with no such button is display-only.",
369
+ "When you render several options to choose from (a grid of cards, each with its own button), give every option component a MEANINGFUL id (e.g. flight-NH107, hotel-memmo-alfama): `componentId` tells you which one the user picked, so never ask them to repeat a choice they already made.",
370
+ 'The user may ignore an interactive surface and just type instead. You then receive action "userDismissedSurface" with their words in `userMessage` \u2014 treat it as their reply, answer it directly, and do not re-render the same surface or scold them for not using it.',
350
371
  "IMPORTANT: the rendered surface IS your reply \u2014 do NOT reproduce its content as text, markdown, or ASCII; a one-line intro at most.",
351
372
  "Prefer plain text for simple replies."
352
373
  ].join(" ");
@@ -3298,13 +3319,16 @@ export {
3298
3319
  ALIGNS,
3299
3320
  CORE_CATALOG_ID,
3300
3321
  DENSITIES,
3322
+ DISMISS_ACTION,
3301
3323
  EMPHASES,
3302
3324
  SIZES,
3303
3325
  TONES,
3304
3326
  UNKNOWN_COMPONENT,
3305
3327
  assertSafeActionName,
3328
+ buildDismissResult,
3306
3329
  buildGenuiClause,
3307
3330
  buildRenderUiSchema,
3331
+ buildSurfaceResult,
3308
3332
  classifyAction,
3309
3333
  coreCatalog,
3310
3334
  core_v1_catalog_default as coreCatalogJson,