@assistant-ui/react-generative-ui 0.0.24 → 0.1.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/README.md +2 -0
- package/dist/a2ui.d.ts +1 -4
- package/dist/a2ui.d.ts.map +1 -1
- package/dist/a2ui.js +1 -4
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -10
- package/dist/index.server.d.ts +1 -2
- package/dist/index.server.d.ts.map +1 -1
- package/dist/index.server.js +1 -10
- package/dist/ir.d.ts +1 -111
- package/dist/ir.d.ts.map +1 -1
- package/dist/ir.js +1 -175
- package/dist/slack.d.ts +1 -4
- package/dist/slack.d.ts.map +1 -1
- package/dist/slack.js +1 -4
- package/dist/teams.d.ts +1 -4
- package/dist/teams.d.ts.map +1 -1
- package/dist/teams.js +1 -4
- package/package.json +4 -5
- package/src/a2ui.ts +1 -22
- package/src/index.server.ts +1 -2
- package/src/index.test.ts +75 -0
- package/src/index.ts +1 -2
- package/src/ir.ts +1 -279
- package/src/slack.ts +1 -39
- package/src/teams.ts +1 -35
- package/dist/JSONGenerativeUI.client.d.ts +0 -28
- package/dist/JSONGenerativeUI.client.d.ts.map +0 -1
- package/dist/JSONGenerativeUI.client.js +0 -101
- package/dist/JSONGenerativeUI.client.js.map +0 -1
- package/dist/JSONGenerativeUI.server.d.ts +0 -21
- package/dist/JSONGenerativeUI.server.d.ts.map +0 -1
- package/dist/JSONGenerativeUI.server.js +0 -32
- package/dist/JSONGenerativeUI.server.js.map +0 -1
- package/dist/JSONGenerativeUI.shared.d.ts +0 -63
- package/dist/JSONGenerativeUI.shared.d.ts.map +0 -1
- package/dist/JSONGenerativeUI.shared.js +0 -31
- package/dist/JSONGenerativeUI.shared.js.map +0 -1
- package/dist/RadioGroupScope.d.ts +0 -6
- package/dist/RadioGroupScope.d.ts.map +0 -1
- package/dist/RadioGroupScope.js +0 -25
- package/dist/RadioGroupScope.js.map +0 -1
- package/dist/a2ui/BindingContext.d.ts +0 -11
- package/dist/a2ui/BindingContext.d.ts.map +0 -1
- package/dist/a2ui/BindingContext.js +0 -12
- package/dist/a2ui/BindingContext.js.map +0 -1
- package/dist/a2ui/PresentRenderer.d.ts +0 -11
- package/dist/a2ui/PresentRenderer.d.ts.map +0 -1
- package/dist/a2ui/PresentRenderer.js +0 -39
- package/dist/a2ui/PresentRenderer.js.map +0 -1
- package/dist/a2ui/convert.d.ts +0 -15
- package/dist/a2ui/convert.d.ts.map +0 -1
- package/dist/a2ui/convert.js +0 -728
- package/dist/a2ui/convert.js.map +0 -1
- package/dist/a2ui/dataModel.d.ts +0 -9
- package/dist/a2ui/dataModel.d.ts.map +0 -1
- package/dist/a2ui/dataModel.js +0 -44
- package/dist/a2ui/dataModel.js.map +0 -1
- package/dist/a2ui/reducer.d.ts +0 -8
- package/dist/a2ui/reducer.d.ts.map +0 -1
- package/dist/a2ui/reducer.js +0 -242
- package/dist/a2ui/reducer.js.map +0 -1
- package/dist/a2ui/snapshot.d.ts +0 -3
- package/dist/a2ui/snapshot.d.ts.map +0 -1
- package/dist/a2ui/snapshot.js +0 -33
- package/dist/a2ui/snapshot.js.map +0 -1
- package/dist/a2ui/types.d.ts +0 -88
- package/dist/a2ui/types.d.ts.map +0 -1
- package/dist/a2ui/types.js +0 -6
- package/dist/a2ui/types.js.map +0 -1
- package/dist/a2ui/valueFunctions.d.ts +0 -16
- package/dist/a2ui/valueFunctions.d.ts.map +0 -1
- package/dist/a2ui/valueFunctions.js +0 -332
- package/dist/a2ui/valueFunctions.js.map +0 -1
- package/dist/actionRegistry.d.ts +0 -29
- package/dist/actionRegistry.d.ts.map +0 -1
- package/dist/actionRegistry.js +0 -41
- package/dist/actionRegistry.js.map +0 -1
- package/dist/answeredValues.d.ts +0 -16
- package/dist/answeredValues.d.ts.map +0 -1
- package/dist/answeredValues.js +0 -37
- package/dist/answeredValues.js.map +0 -1
- package/dist/buildPresentParameters.d.ts +0 -21
- package/dist/buildPresentParameters.d.ts.map +0 -1
- package/dist/buildPresentParameters.js +0 -95
- package/dist/buildPresentParameters.js.map +0 -1
- package/dist/constants.d.ts +0 -15
- package/dist/constants.d.ts.map +0 -1
- package/dist/constants.js +0 -19
- package/dist/constants.js.map +0 -1
- package/dist/convert/boundSpec.d.ts +0 -48
- package/dist/convert/boundSpec.d.ts.map +0 -1
- package/dist/convert/boundSpec.js +0 -108
- package/dist/convert/boundSpec.js.map +0 -1
- package/dist/convert/copyBounded.d.ts +0 -25
- package/dist/convert/copyBounded.d.ts.map +0 -1
- package/dist/convert/copyBounded.js +0 -38
- package/dist/convert/copyBounded.js.map +0 -1
- package/dist/convert/isElement.d.ts +0 -3
- package/dist/convert/isElement.d.ts.map +0 -1
- package/dist/convert/isElement.js +0 -6
- package/dist/convert/isElement.js.map +0 -1
- package/dist/convert/takeRun.d.ts +0 -6
- package/dist/convert/takeRun.d.ts.map +0 -1
- package/dist/convert/takeRun.js +0 -20
- package/dist/convert/takeRun.js.map +0 -1
- package/dist/defineGenerativeComponents.d.ts +0 -29
- package/dist/defineGenerativeComponents.d.ts.map +0 -1
- package/dist/defineGenerativeComponents.js +0 -34
- package/dist/defineGenerativeComponents.js.map +0 -1
- package/dist/fieldReferences.d.ts +0 -9
- package/dist/fieldReferences.d.ts.map +0 -1
- package/dist/fieldReferences.js +0 -53
- package/dist/fieldReferences.js.map +0 -1
- package/dist/generativeUIToJSX.d.ts +0 -18
- package/dist/generativeUIToJSX.d.ts.map +0 -1
- package/dist/generativeUIToJSX.js +0 -76
- package/dist/generativeUIToJSX.js.map +0 -1
- package/dist/index.shared.d.ts +0 -15
- package/dist/index.shared.d.ts.map +0 -1
- package/dist/index.shared.js +0 -9
- package/dist/ir.js.map +0 -1
- package/dist/renderGenerativeUI.d.ts +0 -14
- package/dist/renderGenerativeUI.d.ts.map +0 -1
- package/dist/renderGenerativeUI.js +0 -83
- package/dist/renderGenerativeUI.js.map +0 -1
- package/dist/scopeSchema.d.ts +0 -6
- package/dist/scopeSchema.d.ts.map +0 -1
- package/dist/scopeSchema.js +0 -56
- package/dist/scopeSchema.js.map +0 -1
- package/dist/slack/constants.d.ts +0 -93
- package/dist/slack/constants.d.ts.map +0 -1
- package/dist/slack/constants.js +0 -146
- package/dist/slack/constants.js.map +0 -1
- package/dist/slack/decodeBlockAction.d.ts +0 -10
- package/dist/slack/decodeBlockAction.d.ts.map +0 -1
- package/dist/slack/decodeBlockAction.js +0 -129
- package/dist/slack/decodeBlockAction.js.map +0 -1
- package/dist/slack/fromSlackBlocks.d.ts +0 -27
- package/dist/slack/fromSlackBlocks.d.ts.map +0 -1
- package/dist/slack/fromSlackBlocks.js +0 -483
- package/dist/slack/fromSlackBlocks.js.map +0 -1
- package/dist/slack/toSlackBlocks.d.ts +0 -4
- package/dist/slack/toSlackBlocks.d.ts.map +0 -1
- package/dist/slack/toSlackBlocks.js +0 -901
- package/dist/slack/toSlackBlocks.js.map +0 -1
- package/dist/slack/types.d.ts +0 -204
- package/dist/slack/types.d.ts.map +0 -1
- package/dist/slack/types.js +0 -0
- package/dist/teams/constants.d.ts +0 -34
- package/dist/teams/constants.d.ts.map +0 -1
- package/dist/teams/constants.js +0 -68
- package/dist/teams/constants.js.map +0 -1
- package/dist/teams/decodeSubmitData.d.ts +0 -26
- package/dist/teams/decodeSubmitData.d.ts.map +0 -1
- package/dist/teams/decodeSubmitData.js +0 -70
- package/dist/teams/decodeSubmitData.js.map +0 -1
- package/dist/teams/temporalId.d.ts +0 -5
- package/dist/teams/temporalId.d.ts.map +0 -1
- package/dist/teams/temporalId.js +0 -28
- package/dist/teams/temporalId.js.map +0 -1
- package/dist/teams/toAdaptiveCard.d.ts +0 -45
- package/dist/teams/toAdaptiveCard.d.ts.map +0 -1
- package/dist/teams/toAdaptiveCard.js +0 -642
- package/dist/teams/toAdaptiveCard.js.map +0 -1
- package/dist/teams/toTeamsAttachments.d.ts +0 -10
- package/dist/teams/toTeamsAttachments.d.ts.map +0 -1
- package/dist/teams/toTeamsAttachments.js +0 -99
- package/dist/teams/toTeamsAttachments.js.map +0 -1
- package/dist/teams/types.d.ts +0 -224
- package/dist/teams/types.d.ts.map +0 -1
- package/dist/teams/types.js +0 -0
- package/dist/temporal.d.ts +0 -33
- package/dist/temporal.d.ts.map +0 -1
- package/dist/temporal.js +0 -153
- package/dist/temporal.js.map +0 -1
- package/dist/types.d.ts +0 -99
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -0
- package/dist/vocabulary/alert.d.ts +0 -32
- package/dist/vocabulary/alert.d.ts.map +0 -1
- package/dist/vocabulary/alert.js +0 -160
- package/dist/vocabulary/alert.js.map +0 -1
- package/dist/vocabulary/collectFormValues.d.ts +0 -23
- package/dist/vocabulary/collectFormValues.d.ts.map +0 -1
- package/dist/vocabulary/collectFormValues.js +0 -44
- package/dist/vocabulary/collectFormValues.js.map +0 -1
- package/dist/vocabulary/data.d.ts +0 -66
- package/dist/vocabulary/data.d.ts.map +0 -1
- package/dist/vocabulary/data.js +0 -503
- package/dist/vocabulary/data.js.map +0 -1
- package/dist/vocabulary/dispatch.d.ts +0 -9
- package/dist/vocabulary/dispatch.d.ts.map +0 -1
- package/dist/vocabulary/dispatch.js +0 -50
- package/dist/vocabulary/dispatch.js.map +0 -1
- package/dist/vocabulary/fact.d.ts +0 -19
- package/dist/vocabulary/fact.d.ts.map +0 -1
- package/dist/vocabulary/fact.js +0 -51
- package/dist/vocabulary/fact.js.map +0 -1
- package/dist/vocabulary/form.d.ts +0 -11
- package/dist/vocabulary/form.d.ts.map +0 -1
- package/dist/vocabulary/form.js +0 -23
- package/dist/vocabulary/form.js.map +0 -1
- package/dist/vocabulary/formatValue.d.ts +0 -7
- package/dist/vocabulary/formatValue.d.ts.map +0 -1
- package/dist/vocabulary/formatValue.js +0 -76
- package/dist/vocabulary/formatValue.js.map +0 -1
- package/dist/vocabulary/icon.d.ts +0 -41
- package/dist/vocabulary/icon.d.ts.map +0 -1
- package/dist/vocabulary/icon.js +0 -272
- package/dist/vocabulary/icon.js.map +0 -1
- package/dist/vocabulary/index.d.ts +0 -12
- package/dist/vocabulary/index.d.ts.map +0 -1
- package/dist/vocabulary/index.js +0 -36
- package/dist/vocabulary/index.js.map +0 -1
- package/dist/vocabulary/interactive.d.ts +0 -230
- package/dist/vocabulary/interactive.d.ts.map +0 -1
- package/dist/vocabulary/interactive.js +0 -584
- package/dist/vocabulary/interactive.js.map +0 -1
- package/dist/vocabulary/layout.d.ts +0 -79
- package/dist/vocabulary/layout.d.ts.map +0 -1
- package/dist/vocabulary/layout.js +0 -139
- package/dist/vocabulary/layout.js.map +0 -1
- package/dist/vocabulary/list.d.ts +0 -14
- package/dist/vocabulary/list.d.ts.map +0 -1
- package/dist/vocabulary/list.js +0 -50
- package/dist/vocabulary/list.js.map +0 -1
- package/dist/vocabulary/media.d.ts +0 -25
- package/dist/vocabulary/media.d.ts.map +0 -1
- package/dist/vocabulary/media.js +0 -42
- package/dist/vocabulary/media.js.map +0 -1
- package/dist/vocabulary/text.d.ts +0 -57
- package/dist/vocabulary/text.d.ts.map +0 -1
- package/dist/vocabulary/text.js +0 -49
- package/dist/vocabulary/text.js.map +0 -1
- package/dist/vocabulary/toTextContent.d.ts +0 -2
- package/dist/vocabulary/toTextContent.d.ts.map +0 -1
- package/dist/vocabulary/toTextContent.js +0 -6
- package/dist/vocabulary/toTextContent.js.map +0 -1
- package/src/JSONGenerativeUI.client.tsx +0 -168
- package/src/JSONGenerativeUI.server.tsx +0 -39
- package/src/JSONGenerativeUI.shared.ts +0 -90
- package/src/JSONGenerativeUI.test.tsx +0 -1298
- package/src/RadioGroupScope.server.test.tsx +0 -24
- package/src/RadioGroupScope.tsx +0 -34
- package/src/a2ui/BindingContext.ts +0 -26
- package/src/a2ui/PresentRenderer.tsx +0 -83
- package/src/a2ui/convert.test.ts +0 -2923
- package/src/a2ui/convert.ts +0 -1207
- package/src/a2ui/dataModel.ts +0 -69
- package/src/a2ui/reducer.test.ts +0 -422
- package/src/a2ui/reducer.ts +0 -363
- package/src/a2ui/snapshot.test.ts +0 -52
- package/src/a2ui/snapshot.ts +0 -52
- package/src/a2ui/types.ts +0 -114
- package/src/a2ui/valueFunctions.test.ts +0 -271
- package/src/a2ui/valueFunctions.ts +0 -523
- package/src/actionRegistry.test.ts +0 -90
- package/src/actionRegistry.ts +0 -88
- package/src/answeredValues.test.ts +0 -33
- package/src/answeredValues.tsx +0 -70
- package/src/buildPresentParameters.test.ts +0 -246
- package/src/buildPresentParameters.ts +0 -130
- package/src/constants.ts +0 -17
- package/src/convert/boundSpec.test.ts +0 -192
- package/src/convert/boundSpec.ts +0 -134
- package/src/convert/copyBounded.test.ts +0 -131
- package/src/convert/copyBounded.ts +0 -38
- package/src/convert/isElement.ts +0 -6
- package/src/convert/takeRun.test.ts +0 -64
- package/src/convert/takeRun.ts +0 -19
- package/src/defineGenerativeComponents.ts +0 -38
- package/src/fieldReferences.test.ts +0 -66
- package/src/fieldReferences.ts +0 -83
- package/src/generativeUIToJSX.test.ts +0 -268
- package/src/generativeUIToJSX.ts +0 -152
- package/src/index.server.test.ts +0 -106
- package/src/index.shared.ts +0 -61
- package/src/ir.test.ts +0 -203
- package/src/renderGenerativeUI.test.tsx +0 -373
- package/src/renderGenerativeUI.tsx +0 -165
- package/src/scopeSchema.test.ts +0 -72
- package/src/scopeSchema.ts +0 -71
- package/src/slack/a2uiSlack.test.ts +0 -198
- package/src/slack/constants.ts +0 -194
- package/src/slack/datePicker.test.ts +0 -612
- package/src/slack/decodeBlockAction.test.ts +0 -233
- package/src/slack/decodeBlockAction.ts +0 -232
- package/src/slack/fromSlackBlocks.test.ts +0 -1465
- package/src/slack/fromSlackBlocks.ts +0 -789
- package/src/slack/toSlackBlocks.test.ts +0 -3065
- package/src/slack/toSlackBlocks.ts +0 -1818
- package/src/slack/types.ts +0 -264
- package/src/teams/constants.ts +0 -93
- package/src/teams/decodeSubmitData.test.ts +0 -397
- package/src/teams/decodeSubmitData.ts +0 -110
- package/src/teams/temporal.test.ts +0 -766
- package/src/teams/temporalId.ts +0 -56
- package/src/teams/toAdaptiveCard.test.ts +0 -1897
- package/src/teams/toAdaptiveCard.ts +0 -1057
- package/src/teams/toTeamsAttachments.test.ts +0 -74
- package/src/teams/toTeamsAttachments.ts +0 -133
- package/src/teams/types.ts +0 -266
- package/src/temporal.test.ts +0 -337
- package/src/temporal.ts +0 -263
- package/src/types.ts +0 -119
- package/src/vocabulary/alert.test.tsx +0 -427
- package/src/vocabulary/alert.tsx +0 -217
- package/src/vocabulary/collectFormValues.test.ts +0 -389
- package/src/vocabulary/collectFormValues.ts +0 -116
- package/src/vocabulary/data.test.tsx +0 -858
- package/src/vocabulary/data.tsx +0 -819
- package/src/vocabulary/datepicker.dom.test.tsx +0 -1457
- package/src/vocabulary/dispatch.ts +0 -83
- package/src/vocabulary/fact.test.tsx +0 -94
- package/src/vocabulary/fact.tsx +0 -54
- package/src/vocabulary/form.test.tsx +0 -113
- package/src/vocabulary/form.tsx +0 -39
- package/src/vocabulary/formatValue.test.ts +0 -72
- package/src/vocabulary/formatValue.ts +0 -127
- package/src/vocabulary/icon.test.tsx +0 -64
- package/src/vocabulary/icon.tsx +0 -174
- package/src/vocabulary/index.test.ts +0 -65
- package/src/vocabulary/index.ts +0 -33
- package/src/vocabulary/interactive.dispatch.test.tsx +0 -454
- package/src/vocabulary/interactive.dom.test.tsx +0 -1747
- package/src/vocabulary/interactive.test.tsx +0 -377
- package/src/vocabulary/interactive.tsx +0 -1109
- package/src/vocabulary/layout.test.tsx +0 -323
- package/src/vocabulary/layout.tsx +0 -247
- package/src/vocabulary/list.test.tsx +0 -222
- package/src/vocabulary/list.tsx +0 -50
- package/src/vocabulary/media.test.tsx +0 -85
- package/src/vocabulary/media.tsx +0 -56
- package/src/vocabulary/text.test.tsx +0 -102
- package/src/vocabulary/text.tsx +0 -60
- package/src/vocabulary/toTextContent.ts +0 -2
package/dist/vocabulary/text.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { COLORS, TEXT_SIZES, WEIGHTS } from "../ir.js";
|
|
2
|
-
import { toTextContent } from "./toTextContent.js";
|
|
3
|
-
import { jsxs } from "react/jsx-runtime";
|
|
4
|
-
import { z } from "zod";
|
|
5
|
-
//#region src/vocabulary/text.tsx
|
|
6
|
-
const textVocabulary = {
|
|
7
|
-
Header: {
|
|
8
|
-
description: "A section heading. Renders as a bold title.",
|
|
9
|
-
properties: z.object({
|
|
10
|
-
text: z.string().describe("The heading text."),
|
|
11
|
-
size: z.enum(TEXT_SIZES).optional().describe("Heading size; defaults to `lg`.")
|
|
12
|
-
}),
|
|
13
|
-
render: ({ text, size, children }) => /* @__PURE__ */ jsxs("h2", {
|
|
14
|
-
"data-aui": "header",
|
|
15
|
-
"data-aui-size": size ?? "lg",
|
|
16
|
-
children: [toTextContent(text), children]
|
|
17
|
-
})
|
|
18
|
-
},
|
|
19
|
-
Text: {
|
|
20
|
-
description: "A run of text. Use for paragraphs, labels, or inline copy.",
|
|
21
|
-
properties: z.object({
|
|
22
|
-
value: z.string().describe("The text content."),
|
|
23
|
-
size: z.enum(TEXT_SIZES).optional().describe("Text size; defaults to `md`."),
|
|
24
|
-
weight: z.enum(WEIGHTS).optional().describe("Font weight."),
|
|
25
|
-
color: z.enum(COLORS).optional().describe("Foreground color token.")
|
|
26
|
-
}),
|
|
27
|
-
streamProperties: true,
|
|
28
|
-
render: ({ value, size, weight, color, children }) => /* @__PURE__ */ jsxs("span", {
|
|
29
|
-
"data-aui": "text",
|
|
30
|
-
"data-aui-size": size ?? "md",
|
|
31
|
-
"data-aui-weight": weight,
|
|
32
|
-
"data-aui-color": color,
|
|
33
|
-
children: [toTextContent(value), children]
|
|
34
|
-
})
|
|
35
|
-
},
|
|
36
|
-
Caption: {
|
|
37
|
-
description: "Secondary, de-emphasized text under a primary element.",
|
|
38
|
-
properties: z.object({ value: z.string().describe("The caption text.") }),
|
|
39
|
-
streamProperties: true,
|
|
40
|
-
render: ({ value, children }) => /* @__PURE__ */ jsxs("p", {
|
|
41
|
-
"data-aui": "caption",
|
|
42
|
-
children: [toTextContent(value), children]
|
|
43
|
-
})
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
//#endregion
|
|
47
|
-
export { textVocabulary };
|
|
48
|
-
|
|
49
|
-
//# sourceMappingURL=text.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"text.js","names":[],"sources":["../../src/vocabulary/text.tsx"],"sourcesContent":["import { z } from \"zod\";\nimport type { GenerativeUILibrary } from \"../types\";\nimport { COLORS, TEXT_SIZES, WEIGHTS } from \"../ir\";\nimport { toTextContent } from \"./toTextContent\";\n\nexport const textVocabulary = {\n Header: {\n description: \"A section heading. Renders as a bold title.\",\n properties: z.object({\n text: z.string().describe(\"The heading text.\"),\n size: z\n .enum(TEXT_SIZES)\n .optional()\n .describe(\"Heading size; defaults to `lg`.\"),\n }),\n render: ({ text, size, children }) => (\n <h2 data-aui=\"header\" data-aui-size={size ?? \"lg\"}>\n {toTextContent(text)}\n {children}\n </h2>\n ),\n },\n Text: {\n description: \"A run of text. Use for paragraphs, labels, or inline copy.\",\n properties: z.object({\n value: z.string().describe(\"The text content.\"),\n size: z\n .enum(TEXT_SIZES)\n .optional()\n .describe(\"Text size; defaults to `md`.\"),\n weight: z.enum(WEIGHTS).optional().describe(\"Font weight.\"),\n color: z.enum(COLORS).optional().describe(\"Foreground color token.\"),\n }),\n streamProperties: true,\n render: ({ value, size, weight, color, children }) => (\n <span\n data-aui=\"text\"\n data-aui-size={size ?? \"md\"}\n data-aui-weight={weight}\n data-aui-color={color}\n >\n {toTextContent(value)}\n {children}\n </span>\n ),\n },\n Caption: {\n description: \"Secondary, de-emphasized text under a primary element.\",\n properties: z.object({\n value: z.string().describe(\"The caption text.\"),\n }),\n streamProperties: true,\n render: ({ value, children }) => (\n <p data-aui=\"caption\">\n {toTextContent(value)}\n {children}\n </p>\n ),\n },\n} satisfies GenerativeUILibrary;\n"],"mappings":";;;;;AAKA,MAAa,iBAAiB;CAC5B,QAAQ;EACN,aAAa;EACb,YAAY,EAAE,OAAO;GACnB,MAAM,EAAE,OAAO,CAAC,CAAC,SAAS,mBAAmB;GAC7C,MAAM,EACH,KAAK,UAAU,CAAC,CAChB,SAAS,CAAC,CACV,SAAS,iCAAiC;EAC/C,CAAC;EACD,SAAS,EAAE,MAAM,MAAM,eACrB,qBAAC,MAAD;GAAI,YAAS;GAAS,iBAAe,QAAQ;GAA7C,UAAA,CACG,cAAc,IAAI,GAClB,QACC;;CAER;CACA,MAAM;EACJ,aAAa;EACb,YAAY,EAAE,OAAO;GACnB,OAAO,EAAE,OAAO,CAAC,CAAC,SAAS,mBAAmB;GAC9C,MAAM,EACH,KAAK,UAAU,CAAC,CAChB,SAAS,CAAC,CACV,SAAS,8BAA8B;GAC1C,QAAQ,EAAE,KAAK,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS,cAAc;GAC1D,OAAO,EAAE,KAAK,MAAM,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS,yBAAyB;EACrE,CAAC;EACD,kBAAkB;EAClB,SAAS,EAAE,OAAO,MAAM,QAAQ,OAAO,eACrC,qBAAC,QAAD;GACE,YAAS;GACT,iBAAe,QAAQ;GACvB,mBAAiB;GACjB,kBAAgB;GAJlB,UAAA,CAMG,cAAc,KAAK,GACnB,QACG;;CAEV;CACA,SAAS;EACP,aAAa;EACb,YAAY,EAAE,OAAO,EACnB,OAAO,EAAE,OAAO,CAAC,CAAC,SAAS,mBAAmB,EAChD,CAAC;EACD,kBAAkB;EAClB,SAAS,EAAE,OAAO,eAChB,qBAAC,KAAD;GAAG,YAAS;GAAZ,UAAA,CACG,cAAc,KAAK,GACnB,QACA;;CAEP;AACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"toTextContent.d.ts","sourceRoot":"","sources":["../../src/vocabulary/toTextContent.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa,GAAI,OAAO,OAAO,KAAG,MAAM,GAAG,MAAM,GAAG,IACM,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"toTextContent.js","names":[],"sources":["../../src/vocabulary/toTextContent.ts"],"sourcesContent":["export const toTextContent = (value: unknown): string | number | null =>\n typeof value === \"string\" || typeof value === \"number\" ? value : null;\n"],"mappings":";AAAA,MAAa,iBAAiB,UAC5B,OAAO,UAAU,YAAY,OAAO,UAAU,WAAW,QAAQ"}
|
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
import type { ToolCallMessagePartProps } from "@assistant-ui/react";
|
|
2
|
-
import { getPartialJsonObjectMeta } from "assistant-stream/utils";
|
|
3
|
-
import type { ReactNode } from "react";
|
|
4
|
-
import { A2uiPresentRenderer } from "./a2ui/PresentRenderer";
|
|
5
|
-
import { AnsweredValuesProvider, findAnsweredValues } from "./answeredValues";
|
|
6
|
-
import { buildPresentParameters } from "./buildPresentParameters";
|
|
7
|
-
import {
|
|
8
|
-
presentToolBase,
|
|
9
|
-
promptUserToolBase,
|
|
10
|
-
type JSONGenerativeUIOptions,
|
|
11
|
-
type PresentParameters,
|
|
12
|
-
type PresentTool,
|
|
13
|
-
type PresentToolOptions,
|
|
14
|
-
type PromptUserTool,
|
|
15
|
-
} from "./JSONGenerativeUI.shared";
|
|
16
|
-
import { type ActionRegistry } from "./actionRegistry";
|
|
17
|
-
import { renderGenerativeUI } from "./renderGenerativeUI";
|
|
18
|
-
import type { GenerativeUILibrary, GenerativeUIStatus } from "./types";
|
|
19
|
-
|
|
20
|
-
// A cancelled argument stream can leave a tool waiting with partial arguments.
|
|
21
|
-
function uiStatus(
|
|
22
|
-
status: { type: string },
|
|
23
|
-
args: Record<string, unknown>,
|
|
24
|
-
): GenerativeUIStatus {
|
|
25
|
-
return status.type === "complete" ||
|
|
26
|
-
(status.type === "requires-action" &&
|
|
27
|
-
getPartialJsonObjectMeta(args)?.state !== "partial")
|
|
28
|
-
? "done"
|
|
29
|
-
: "streaming";
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Client build of {@link JSONGenerativeUI}, resolved through the package's
|
|
34
|
-
* `default` export condition (browser and SSR).
|
|
35
|
-
*
|
|
36
|
-
* `present` is a frontend tool that renders the model's `{ $type, ...props }`
|
|
37
|
-
* tree against the library and resolves immediately. `prompt_user` is a
|
|
38
|
-
* human-in-the-loop tool: the model pauses and the rendered UI supplies the
|
|
39
|
-
* result. Both draw the tree the same way, so they share one `render`. The
|
|
40
|
-
* `actions` registry (if provided) is threaded into the render context so
|
|
41
|
-
* interactive components can fire `$action` through `$dispatch`.
|
|
42
|
-
*/
|
|
43
|
-
export class JSONGenerativeUI {
|
|
44
|
-
private readonly library: GenerativeUILibrary;
|
|
45
|
-
private readonly parameters: PresentParameters;
|
|
46
|
-
private readonly actions: ActionRegistry | undefined;
|
|
47
|
-
private readonly completedPromptToolCallIds = new Set<string>();
|
|
48
|
-
|
|
49
|
-
constructor(options: JSONGenerativeUIOptions) {
|
|
50
|
-
this.library = options.library;
|
|
51
|
-
this.parameters = buildPresentParameters(options.library);
|
|
52
|
-
this.actions = options.actions;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* The surface a `present` call paints into. It owns the vertical rhythm
|
|
57
|
-
* between top-level blocks, which the host's message container does not
|
|
58
|
-
* provide, and stays out of the way while it has nothing to show.
|
|
59
|
-
*/
|
|
60
|
-
private readonly render = (
|
|
61
|
-
{
|
|
62
|
-
args,
|
|
63
|
-
status,
|
|
64
|
-
addResult,
|
|
65
|
-
result,
|
|
66
|
-
toolCallId,
|
|
67
|
-
artifact,
|
|
68
|
-
unstable_recordInteraction,
|
|
69
|
-
unstable_interactions,
|
|
70
|
-
}: ToolCallMessagePartProps<Record<string, unknown>, any>,
|
|
71
|
-
completesPrompt = false,
|
|
72
|
-
): ReactNode => {
|
|
73
|
-
const answered = completesPrompt && result !== undefined;
|
|
74
|
-
const actions = this.actions;
|
|
75
|
-
const dispatch =
|
|
76
|
-
!answered && actions
|
|
77
|
-
? (action: Parameters<ActionRegistry["dispatch"]>[0]) => {
|
|
78
|
-
if (unstable_recordInteraction) {
|
|
79
|
-
try {
|
|
80
|
-
void unstable_recordInteraction({
|
|
81
|
-
type: "action",
|
|
82
|
-
payload: action,
|
|
83
|
-
}).catch(() => {});
|
|
84
|
-
} catch {}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
const actionResult = actions.dispatch(action);
|
|
88
|
-
if (
|
|
89
|
-
completesPrompt &&
|
|
90
|
-
actionResult !== undefined &&
|
|
91
|
-
result === undefined
|
|
92
|
-
) {
|
|
93
|
-
void Promise.resolve(actionResult)
|
|
94
|
-
.then((response) => {
|
|
95
|
-
if (
|
|
96
|
-
response !== undefined &&
|
|
97
|
-
!this.completedPromptToolCallIds.has(toolCallId)
|
|
98
|
-
) {
|
|
99
|
-
this.completedPromptToolCallIds.add(toolCallId);
|
|
100
|
-
addResult(response);
|
|
101
|
-
}
|
|
102
|
-
})
|
|
103
|
-
.catch(() => {});
|
|
104
|
-
}
|
|
105
|
-
return actionResult;
|
|
106
|
-
}
|
|
107
|
-
: undefined;
|
|
108
|
-
|
|
109
|
-
const artifactValue =
|
|
110
|
-
artifact !== null && typeof artifact === "object"
|
|
111
|
-
? (artifact as Record<string, unknown>)["a2ui"]
|
|
112
|
-
: undefined;
|
|
113
|
-
const surfaceId =
|
|
114
|
-
typeof toolCallId === "string" && toolCallId.startsWith("a2ui:")
|
|
115
|
-
? toolCallId.slice("a2ui:".length)
|
|
116
|
-
: undefined;
|
|
117
|
-
const rendered =
|
|
118
|
-
surfaceId && Array.isArray(artifactValue) ? (
|
|
119
|
-
<A2uiPresentRenderer
|
|
120
|
-
key={surfaceId}
|
|
121
|
-
surfaceId={surfaceId}
|
|
122
|
-
operations={artifactValue}
|
|
123
|
-
fallback={args}
|
|
124
|
-
library={this.library}
|
|
125
|
-
status={uiStatus(status, args)}
|
|
126
|
-
{...(dispatch ? { dispatch } : {})}
|
|
127
|
-
/>
|
|
128
|
-
) : (
|
|
129
|
-
renderGenerativeUI(args, this.library, {
|
|
130
|
-
status: uiStatus(status, args),
|
|
131
|
-
...(dispatch ? { dispatch } : {}),
|
|
132
|
-
})
|
|
133
|
-
);
|
|
134
|
-
|
|
135
|
-
return (
|
|
136
|
-
<div data-aui="root">
|
|
137
|
-
{answered ? (
|
|
138
|
-
<AnsweredValuesProvider
|
|
139
|
-
values={findAnsweredValues(unstable_interactions)}
|
|
140
|
-
>
|
|
141
|
-
<fieldset disabled data-aui="answered">
|
|
142
|
-
{rendered}
|
|
143
|
-
</fieldset>
|
|
144
|
-
</AnsweredValuesProvider>
|
|
145
|
-
) : (
|
|
146
|
-
rendered
|
|
147
|
-
)}
|
|
148
|
-
</div>
|
|
149
|
-
);
|
|
150
|
-
};
|
|
151
|
-
|
|
152
|
-
present(options?: PresentToolOptions): PresentTool {
|
|
153
|
-
return {
|
|
154
|
-
...presentToolBase(this.parameters, options),
|
|
155
|
-
unstable_backendDefault: { parameters: true },
|
|
156
|
-
execute: async () => ({}),
|
|
157
|
-
render: this.render,
|
|
158
|
-
};
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
promptUser(): PromptUserTool {
|
|
162
|
-
return {
|
|
163
|
-
...promptUserToolBase(this.parameters),
|
|
164
|
-
unstable_backendDefault: { parameters: true },
|
|
165
|
-
render: (props) => this.render(props, true),
|
|
166
|
-
};
|
|
167
|
-
}
|
|
168
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { buildPresentParameters } from "./buildPresentParameters";
|
|
2
|
-
import {
|
|
3
|
-
presentToolBase,
|
|
4
|
-
promptUserToolBase,
|
|
5
|
-
type JSONGenerativeUIOptions,
|
|
6
|
-
type PresentParameters,
|
|
7
|
-
type PresentTool,
|
|
8
|
-
type PresentToolOptions,
|
|
9
|
-
type PromptUserTool,
|
|
10
|
-
} from "./JSONGenerativeUI.shared";
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Server build of {@link JSONGenerativeUI}, resolved through the package's
|
|
14
|
-
* `react-server` export condition.
|
|
15
|
-
*
|
|
16
|
-
* The model only needs each tool's `type`, `description`, and `parameters` on
|
|
17
|
-
* the server, so `present`/`prompt_user` return exactly that — no `execute` and
|
|
18
|
-
* no `render`, keeping the renderer (and React) out of the server graph. The
|
|
19
|
-
* client build adds those back. The two builds share one set of public types, so
|
|
20
|
-
* consumers see a single {@link JSONGenerativeUI} either way.
|
|
21
|
-
*
|
|
22
|
-
* `as` casts here because the tool types require a `render` for frontend/human
|
|
23
|
-
* tools; on the server it is structurally absent and never read.
|
|
24
|
-
*/
|
|
25
|
-
export class JSONGenerativeUI {
|
|
26
|
-
private readonly parameters: PresentParameters;
|
|
27
|
-
|
|
28
|
-
constructor(options: JSONGenerativeUIOptions) {
|
|
29
|
-
this.parameters = buildPresentParameters(options.library);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
present(options?: PresentToolOptions): PresentTool {
|
|
33
|
-
return presentToolBase(this.parameters, options) as PresentTool;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
promptUser(): PromptUserTool {
|
|
37
|
-
return promptUserToolBase(this.parameters) as PromptUserTool;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import type { ToolDefinition } from "@assistant-ui/react";
|
|
2
|
-
import type { JSONSchema7 } from "json-schema";
|
|
3
|
-
import type { ActionRegistry } from "./actionRegistry";
|
|
4
|
-
import type { GenerativeUILibrary } from "./types";
|
|
5
|
-
|
|
6
|
-
/** Options for {@link JSONGenerativeUI}. */
|
|
7
|
-
export type JSONGenerativeUIOptions = {
|
|
8
|
-
/**
|
|
9
|
-
* The components the model is allowed to render, keyed by the `$type` it
|
|
10
|
-
* selects them with. Author it with `defineGenerativeComponents({ ... })` so a
|
|
11
|
-
* `"use generative"` build can split each `render` from its `properties`.
|
|
12
|
-
*/
|
|
13
|
-
library: GenerativeUILibrary;
|
|
14
|
-
/**
|
|
15
|
-
* Host-provided map from `$action.type` to its handler. Interactive
|
|
16
|
-
* components (`Button`/`Select`/`Input`/`DatePicker`) call `$dispatch($action)`
|
|
17
|
-
* on their event, which resolves through this registry. Omit it for a
|
|
18
|
-
* read-only render where model-emitted actions degrade to a no-op.
|
|
19
|
-
*/
|
|
20
|
-
actions?: ActionRegistry;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
/** Options for {@link JSONGenerativeUI.present}. */
|
|
24
|
-
export type PresentToolOptions = {
|
|
25
|
-
/**
|
|
26
|
-
* Set `"standalone"` to render the component on its own surface (outside the
|
|
27
|
-
* chain-of-thought trace), e.g. a full-bleed artifact like a card. Omit it for
|
|
28
|
-
* the default inline rendering — there is no `"inline"` value because that is
|
|
29
|
-
* already the default.
|
|
30
|
-
*/
|
|
31
|
-
display?: "standalone";
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
type BackendDefaultMetadata = {
|
|
35
|
-
unstable_backendDefault?: {
|
|
36
|
-
parameters?: boolean;
|
|
37
|
-
};
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
/** The `present` tool, as the model sees it (no client `render`/`execute`). */
|
|
41
|
-
export type PresentTool = ToolDefinition<
|
|
42
|
-
Record<string, unknown>,
|
|
43
|
-
Record<string, never>
|
|
44
|
-
> &
|
|
45
|
-
BackendDefaultMetadata;
|
|
46
|
-
|
|
47
|
-
/** The `prompt_user` tool, as the model sees it (no client `render`). */
|
|
48
|
-
export type PromptUserTool = ToolDefinition<Record<string, unknown>, unknown> &
|
|
49
|
-
BackendDefaultMetadata;
|
|
50
|
-
|
|
51
|
-
const PRESENT_DESCRIPTION =
|
|
52
|
-
"Present a UI component to the user. Select a component with `$type` and " +
|
|
53
|
-
"provide its props inline; nest components with `children`.";
|
|
54
|
-
|
|
55
|
-
const PROMPT_USER_DESCRIPTION =
|
|
56
|
-
"Present a UI component to the user and wait for their response. Select a " +
|
|
57
|
-
"component with `$type` and provide its props inline; nest components with " +
|
|
58
|
-
"`children`. The user interacts with it and the result is returned to you.";
|
|
59
|
-
|
|
60
|
-
/** The tool `parameters` schema, built once per instance (see `buildPresentParameters`). */
|
|
61
|
-
export type PresentParameters = JSONSchema7;
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* The schema-only half of the `present` tool, shared by both builds. The server
|
|
65
|
-
* build returns exactly this; the client build adds `execute` and `render`.
|
|
66
|
-
* Takes the already-built `parameters` so it isn't recomputed per tool.
|
|
67
|
-
*/
|
|
68
|
-
export function presentToolBase(
|
|
69
|
-
parameters: PresentParameters,
|
|
70
|
-
options?: PresentToolOptions,
|
|
71
|
-
) {
|
|
72
|
-
return {
|
|
73
|
-
type: "frontend" as const,
|
|
74
|
-
description: PRESENT_DESCRIPTION,
|
|
75
|
-
parameters,
|
|
76
|
-
...(options?.display !== undefined ? { display: options.display } : {}),
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* The schema-only half of the `prompt_user` tool, shared by both builds. The
|
|
82
|
-
* server build returns exactly this; the client build adds `render`.
|
|
83
|
-
*/
|
|
84
|
-
export function promptUserToolBase(parameters: PresentParameters) {
|
|
85
|
-
return {
|
|
86
|
-
type: "human" as const,
|
|
87
|
-
description: PROMPT_USER_DESCRIPTION,
|
|
88
|
-
parameters,
|
|
89
|
-
};
|
|
90
|
-
}
|