@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.
- package/dist/actions-B0hfoYRd.d.ts +57 -0
- package/dist/actions-CZU_GRy5.d.mts +57 -0
- package/dist/genui/index.d.mts +1 -1
- package/dist/genui/index.d.ts +1 -1
- package/dist/genui/index.js +25 -1
- package/dist/genui/index.js.map +1 -1
- package/dist/genui/index.mjs +25 -1
- package/dist/genui/index.mjs.map +1 -1
- package/dist/hooks/index.d.mts +2 -1
- package/dist/hooks/index.d.ts +2 -1
- package/dist/hooks/index.js +53 -3
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +53 -3
- package/dist/hooks/index.mjs.map +1 -1
- package/dist/types/index.d.mts +2 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.js.map +1 -1
- package/dist/types/index.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/actions-BebMyGqF.d.ts +0 -16
- package/dist/actions-Ca3ro-hX.d.mts +0 -16
package/dist/hooks/index.d.mts
CHANGED
|
@@ -7,7 +7,7 @@ import { createMessageId } from '../utils/index.mjs';
|
|
|
7
7
|
import { W as WorklogState } from '../types-Dvu9y4WM.mjs';
|
|
8
8
|
import { T as ToolExecutionResponse } from '../types-DnfWUE9V.mjs';
|
|
9
9
|
import { C as CatalogManifest } from '../registry-Bcu_ZYL1.mjs';
|
|
10
|
-
import { U as UIAction } from '../actions-
|
|
10
|
+
import { U as UIAction } from '../actions-CZU_GRy5.mjs';
|
|
11
11
|
import '@elastic/apm-rum';
|
|
12
12
|
import 'ai';
|
|
13
13
|
import 'zod';
|
|
@@ -49,6 +49,7 @@ declare function useAlquimia(config: UseAlquimiaConfig): {
|
|
|
49
49
|
surfaces: GenuiSurfaceItem[];
|
|
50
50
|
onAgentAction: (controlId: string) => (action: UIAction) => void;
|
|
51
51
|
awaitingUser: boolean;
|
|
52
|
+
dismiss: (userMessage?: string) => void;
|
|
52
53
|
} | undefined;
|
|
53
54
|
cleanMessages: () => void;
|
|
54
55
|
createMessageId: typeof createMessageId;
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { createMessageId } from '../utils/index.js';
|
|
|
7
7
|
import { W as WorklogState } from '../types-Dvu9y4WM.js';
|
|
8
8
|
import { T as ToolExecutionResponse } from '../types-DnfWUE9V.js';
|
|
9
9
|
import { C as CatalogManifest } from '../registry-Bcu_ZYL1.js';
|
|
10
|
-
import { U as UIAction } from '../actions-
|
|
10
|
+
import { U as UIAction } from '../actions-B0hfoYRd.js';
|
|
11
11
|
import '@elastic/apm-rum';
|
|
12
12
|
import 'ai';
|
|
13
13
|
import 'zod';
|
|
@@ -49,6 +49,7 @@ declare function useAlquimia(config: UseAlquimiaConfig): {
|
|
|
49
49
|
surfaces: GenuiSurfaceItem[];
|
|
50
50
|
onAgentAction: (controlId: string) => (action: UIAction) => void;
|
|
51
51
|
awaitingUser: boolean;
|
|
52
|
+
dismiss: (userMessage?: string) => void;
|
|
52
53
|
} | undefined;
|
|
53
54
|
cleanMessages: () => void;
|
|
54
55
|
createMessageId: typeof createMessageId;
|
package/dist/hooks/index.js
CHANGED
|
@@ -679,6 +679,25 @@ var coreCatalog = {
|
|
|
679
679
|
};
|
|
680
680
|
|
|
681
681
|
// src/genui/actions.ts
|
|
682
|
+
var DISMISS_ACTION = "userDismissedSurface";
|
|
683
|
+
function buildDismissResult(surfaceId, userMessage) {
|
|
684
|
+
const said = typeof userMessage === "string" ? userMessage.trim() : "";
|
|
685
|
+
return {
|
|
686
|
+
action: DISMISS_ACTION,
|
|
687
|
+
surfaceId,
|
|
688
|
+
componentId: "",
|
|
689
|
+
data: {},
|
|
690
|
+
...said ? { userMessage: said } : {}
|
|
691
|
+
};
|
|
692
|
+
}
|
|
693
|
+
function buildSurfaceResult(action) {
|
|
694
|
+
return {
|
|
695
|
+
action: action.action,
|
|
696
|
+
surfaceId: action.surfaceId,
|
|
697
|
+
componentId: action.componentId,
|
|
698
|
+
data: action.payload ?? {}
|
|
699
|
+
};
|
|
700
|
+
}
|
|
682
701
|
var URL_LIKE = /^\s*([a-z][a-z0-9+.-]*:|\/\/)/i;
|
|
683
702
|
function assertSafeActionName(name) {
|
|
684
703
|
if (typeof name !== "string" || name.length === 0) {
|
|
@@ -850,7 +869,9 @@ function buildGenuiClause(manifest, allowlist) {
|
|
|
850
869
|
`Components: ${names.join(", ")}.`,
|
|
851
870
|
`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.`,
|
|
852
871
|
"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`).",
|
|
853
|
-
"To collect input, add a Button with an action { name, wantResponse: true }
|
|
872
|
+
"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.",
|
|
873
|
+
"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.",
|
|
874
|
+
'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.',
|
|
854
875
|
"IMPORTANT: the rendered surface IS your reply \u2014 do NOT reproduce its content as text, markdown, or ASCII; a one-line intro at most.",
|
|
855
876
|
"Prefer plain text for simple replies."
|
|
856
877
|
].join(" ");
|
|
@@ -1276,15 +1297,44 @@ function useAlquimia(config) {
|
|
|
1276
1297
|
control_id: controlId,
|
|
1277
1298
|
tool_name: "render_ui",
|
|
1278
1299
|
status: "success",
|
|
1279
|
-
|
|
1300
|
+
// Includes componentId, so the agent can tell which element was acted on when
|
|
1301
|
+
// several share one action name (a grid of option cards, say).
|
|
1302
|
+
result: buildSurfaceResult(action)
|
|
1280
1303
|
});
|
|
1281
1304
|
},
|
|
1282
1305
|
[completeToolExecution]
|
|
1283
1306
|
);
|
|
1307
|
+
const genuiDismiss = (0, import_react2.useCallback)(
|
|
1308
|
+
(userMessage) => {
|
|
1309
|
+
if (!pendingClientTool || pendingClientTool.toolName !== "render_ui") return;
|
|
1310
|
+
const { controlId } = pendingClientTool;
|
|
1311
|
+
const said = typeof userMessage === "string" ? userMessage.trim() : "";
|
|
1312
|
+
const item = genuiSurfaces.find((s) => s.controlId === controlId);
|
|
1313
|
+
setGenuiSurfaces(
|
|
1314
|
+
(prev) => prev.map(
|
|
1315
|
+
(s) => s.controlId === controlId ? { ...s, submitted: true, dismissedWith: said || void 0 } : s
|
|
1316
|
+
)
|
|
1317
|
+
);
|
|
1318
|
+
if (said) setInput("");
|
|
1319
|
+
void completeToolExecution(controlId, {
|
|
1320
|
+
control_id: controlId,
|
|
1321
|
+
tool_name: "render_ui",
|
|
1322
|
+
status: "success",
|
|
1323
|
+
result: buildDismissResult(item?.surface.surfaceId ?? "", said)
|
|
1324
|
+
});
|
|
1325
|
+
},
|
|
1326
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1327
|
+
[pendingClientTool, genuiSurfaces, completeToolExecution]
|
|
1328
|
+
);
|
|
1284
1329
|
const genuiAwaitingUser = !!(pendingClientTool && pendingClientTool.toolName === "render_ui" && genuiSurfaces.some(
|
|
1285
1330
|
(s) => s.controlId === pendingClientTool.controlId && s.surface.components.some((c) => c.action?.wantResponse === true)
|
|
1286
1331
|
));
|
|
1287
|
-
const genui = config.genui ? {
|
|
1332
|
+
const genui = config.genui ? {
|
|
1333
|
+
surfaces: genuiSurfaces,
|
|
1334
|
+
onAgentAction: genuiOnAgentAction,
|
|
1335
|
+
awaitingUser: genuiAwaitingUser,
|
|
1336
|
+
dismiss: genuiDismiss
|
|
1337
|
+
} : void 0;
|
|
1288
1338
|
return {
|
|
1289
1339
|
sdk,
|
|
1290
1340
|
activeTool,
|