@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.
Files changed (338) hide show
  1. package/README.md +2 -0
  2. package/dist/a2ui.d.ts +1 -4
  3. package/dist/a2ui.d.ts.map +1 -1
  4. package/dist/a2ui.js +1 -4
  5. package/dist/index.d.ts +1 -2
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +1 -10
  8. package/dist/index.server.d.ts +1 -2
  9. package/dist/index.server.d.ts.map +1 -1
  10. package/dist/index.server.js +1 -10
  11. package/dist/ir.d.ts +1 -111
  12. package/dist/ir.d.ts.map +1 -1
  13. package/dist/ir.js +1 -175
  14. package/dist/slack.d.ts +1 -4
  15. package/dist/slack.d.ts.map +1 -1
  16. package/dist/slack.js +1 -4
  17. package/dist/teams.d.ts +1 -4
  18. package/dist/teams.d.ts.map +1 -1
  19. package/dist/teams.js +1 -4
  20. package/package.json +4 -5
  21. package/src/a2ui.ts +1 -22
  22. package/src/index.server.ts +1 -2
  23. package/src/index.test.ts +75 -0
  24. package/src/index.ts +1 -2
  25. package/src/ir.ts +1 -279
  26. package/src/slack.ts +1 -39
  27. package/src/teams.ts +1 -35
  28. package/dist/JSONGenerativeUI.client.d.ts +0 -28
  29. package/dist/JSONGenerativeUI.client.d.ts.map +0 -1
  30. package/dist/JSONGenerativeUI.client.js +0 -101
  31. package/dist/JSONGenerativeUI.client.js.map +0 -1
  32. package/dist/JSONGenerativeUI.server.d.ts +0 -21
  33. package/dist/JSONGenerativeUI.server.d.ts.map +0 -1
  34. package/dist/JSONGenerativeUI.server.js +0 -32
  35. package/dist/JSONGenerativeUI.server.js.map +0 -1
  36. package/dist/JSONGenerativeUI.shared.d.ts +0 -63
  37. package/dist/JSONGenerativeUI.shared.d.ts.map +0 -1
  38. package/dist/JSONGenerativeUI.shared.js +0 -31
  39. package/dist/JSONGenerativeUI.shared.js.map +0 -1
  40. package/dist/RadioGroupScope.d.ts +0 -6
  41. package/dist/RadioGroupScope.d.ts.map +0 -1
  42. package/dist/RadioGroupScope.js +0 -25
  43. package/dist/RadioGroupScope.js.map +0 -1
  44. package/dist/a2ui/BindingContext.d.ts +0 -11
  45. package/dist/a2ui/BindingContext.d.ts.map +0 -1
  46. package/dist/a2ui/BindingContext.js +0 -12
  47. package/dist/a2ui/BindingContext.js.map +0 -1
  48. package/dist/a2ui/PresentRenderer.d.ts +0 -11
  49. package/dist/a2ui/PresentRenderer.d.ts.map +0 -1
  50. package/dist/a2ui/PresentRenderer.js +0 -39
  51. package/dist/a2ui/PresentRenderer.js.map +0 -1
  52. package/dist/a2ui/convert.d.ts +0 -15
  53. package/dist/a2ui/convert.d.ts.map +0 -1
  54. package/dist/a2ui/convert.js +0 -728
  55. package/dist/a2ui/convert.js.map +0 -1
  56. package/dist/a2ui/dataModel.d.ts +0 -9
  57. package/dist/a2ui/dataModel.d.ts.map +0 -1
  58. package/dist/a2ui/dataModel.js +0 -44
  59. package/dist/a2ui/dataModel.js.map +0 -1
  60. package/dist/a2ui/reducer.d.ts +0 -8
  61. package/dist/a2ui/reducer.d.ts.map +0 -1
  62. package/dist/a2ui/reducer.js +0 -242
  63. package/dist/a2ui/reducer.js.map +0 -1
  64. package/dist/a2ui/snapshot.d.ts +0 -3
  65. package/dist/a2ui/snapshot.d.ts.map +0 -1
  66. package/dist/a2ui/snapshot.js +0 -33
  67. package/dist/a2ui/snapshot.js.map +0 -1
  68. package/dist/a2ui/types.d.ts +0 -88
  69. package/dist/a2ui/types.d.ts.map +0 -1
  70. package/dist/a2ui/types.js +0 -6
  71. package/dist/a2ui/types.js.map +0 -1
  72. package/dist/a2ui/valueFunctions.d.ts +0 -16
  73. package/dist/a2ui/valueFunctions.d.ts.map +0 -1
  74. package/dist/a2ui/valueFunctions.js +0 -332
  75. package/dist/a2ui/valueFunctions.js.map +0 -1
  76. package/dist/actionRegistry.d.ts +0 -29
  77. package/dist/actionRegistry.d.ts.map +0 -1
  78. package/dist/actionRegistry.js +0 -41
  79. package/dist/actionRegistry.js.map +0 -1
  80. package/dist/answeredValues.d.ts +0 -16
  81. package/dist/answeredValues.d.ts.map +0 -1
  82. package/dist/answeredValues.js +0 -37
  83. package/dist/answeredValues.js.map +0 -1
  84. package/dist/buildPresentParameters.d.ts +0 -21
  85. package/dist/buildPresentParameters.d.ts.map +0 -1
  86. package/dist/buildPresentParameters.js +0 -95
  87. package/dist/buildPresentParameters.js.map +0 -1
  88. package/dist/constants.d.ts +0 -15
  89. package/dist/constants.d.ts.map +0 -1
  90. package/dist/constants.js +0 -19
  91. package/dist/constants.js.map +0 -1
  92. package/dist/convert/boundSpec.d.ts +0 -48
  93. package/dist/convert/boundSpec.d.ts.map +0 -1
  94. package/dist/convert/boundSpec.js +0 -108
  95. package/dist/convert/boundSpec.js.map +0 -1
  96. package/dist/convert/copyBounded.d.ts +0 -25
  97. package/dist/convert/copyBounded.d.ts.map +0 -1
  98. package/dist/convert/copyBounded.js +0 -38
  99. package/dist/convert/copyBounded.js.map +0 -1
  100. package/dist/convert/isElement.d.ts +0 -3
  101. package/dist/convert/isElement.d.ts.map +0 -1
  102. package/dist/convert/isElement.js +0 -6
  103. package/dist/convert/isElement.js.map +0 -1
  104. package/dist/convert/takeRun.d.ts +0 -6
  105. package/dist/convert/takeRun.d.ts.map +0 -1
  106. package/dist/convert/takeRun.js +0 -20
  107. package/dist/convert/takeRun.js.map +0 -1
  108. package/dist/defineGenerativeComponents.d.ts +0 -29
  109. package/dist/defineGenerativeComponents.d.ts.map +0 -1
  110. package/dist/defineGenerativeComponents.js +0 -34
  111. package/dist/defineGenerativeComponents.js.map +0 -1
  112. package/dist/fieldReferences.d.ts +0 -9
  113. package/dist/fieldReferences.d.ts.map +0 -1
  114. package/dist/fieldReferences.js +0 -53
  115. package/dist/fieldReferences.js.map +0 -1
  116. package/dist/generativeUIToJSX.d.ts +0 -18
  117. package/dist/generativeUIToJSX.d.ts.map +0 -1
  118. package/dist/generativeUIToJSX.js +0 -76
  119. package/dist/generativeUIToJSX.js.map +0 -1
  120. package/dist/index.shared.d.ts +0 -15
  121. package/dist/index.shared.d.ts.map +0 -1
  122. package/dist/index.shared.js +0 -9
  123. package/dist/ir.js.map +0 -1
  124. package/dist/renderGenerativeUI.d.ts +0 -14
  125. package/dist/renderGenerativeUI.d.ts.map +0 -1
  126. package/dist/renderGenerativeUI.js +0 -83
  127. package/dist/renderGenerativeUI.js.map +0 -1
  128. package/dist/scopeSchema.d.ts +0 -6
  129. package/dist/scopeSchema.d.ts.map +0 -1
  130. package/dist/scopeSchema.js +0 -56
  131. package/dist/scopeSchema.js.map +0 -1
  132. package/dist/slack/constants.d.ts +0 -93
  133. package/dist/slack/constants.d.ts.map +0 -1
  134. package/dist/slack/constants.js +0 -146
  135. package/dist/slack/constants.js.map +0 -1
  136. package/dist/slack/decodeBlockAction.d.ts +0 -10
  137. package/dist/slack/decodeBlockAction.d.ts.map +0 -1
  138. package/dist/slack/decodeBlockAction.js +0 -129
  139. package/dist/slack/decodeBlockAction.js.map +0 -1
  140. package/dist/slack/fromSlackBlocks.d.ts +0 -27
  141. package/dist/slack/fromSlackBlocks.d.ts.map +0 -1
  142. package/dist/slack/fromSlackBlocks.js +0 -483
  143. package/dist/slack/fromSlackBlocks.js.map +0 -1
  144. package/dist/slack/toSlackBlocks.d.ts +0 -4
  145. package/dist/slack/toSlackBlocks.d.ts.map +0 -1
  146. package/dist/slack/toSlackBlocks.js +0 -901
  147. package/dist/slack/toSlackBlocks.js.map +0 -1
  148. package/dist/slack/types.d.ts +0 -204
  149. package/dist/slack/types.d.ts.map +0 -1
  150. package/dist/slack/types.js +0 -0
  151. package/dist/teams/constants.d.ts +0 -34
  152. package/dist/teams/constants.d.ts.map +0 -1
  153. package/dist/teams/constants.js +0 -68
  154. package/dist/teams/constants.js.map +0 -1
  155. package/dist/teams/decodeSubmitData.d.ts +0 -26
  156. package/dist/teams/decodeSubmitData.d.ts.map +0 -1
  157. package/dist/teams/decodeSubmitData.js +0 -70
  158. package/dist/teams/decodeSubmitData.js.map +0 -1
  159. package/dist/teams/temporalId.d.ts +0 -5
  160. package/dist/teams/temporalId.d.ts.map +0 -1
  161. package/dist/teams/temporalId.js +0 -28
  162. package/dist/teams/temporalId.js.map +0 -1
  163. package/dist/teams/toAdaptiveCard.d.ts +0 -45
  164. package/dist/teams/toAdaptiveCard.d.ts.map +0 -1
  165. package/dist/teams/toAdaptiveCard.js +0 -642
  166. package/dist/teams/toAdaptiveCard.js.map +0 -1
  167. package/dist/teams/toTeamsAttachments.d.ts +0 -10
  168. package/dist/teams/toTeamsAttachments.d.ts.map +0 -1
  169. package/dist/teams/toTeamsAttachments.js +0 -99
  170. package/dist/teams/toTeamsAttachments.js.map +0 -1
  171. package/dist/teams/types.d.ts +0 -224
  172. package/dist/teams/types.d.ts.map +0 -1
  173. package/dist/teams/types.js +0 -0
  174. package/dist/temporal.d.ts +0 -33
  175. package/dist/temporal.d.ts.map +0 -1
  176. package/dist/temporal.js +0 -153
  177. package/dist/temporal.js.map +0 -1
  178. package/dist/types.d.ts +0 -99
  179. package/dist/types.d.ts.map +0 -1
  180. package/dist/types.js +0 -0
  181. package/dist/vocabulary/alert.d.ts +0 -32
  182. package/dist/vocabulary/alert.d.ts.map +0 -1
  183. package/dist/vocabulary/alert.js +0 -160
  184. package/dist/vocabulary/alert.js.map +0 -1
  185. package/dist/vocabulary/collectFormValues.d.ts +0 -23
  186. package/dist/vocabulary/collectFormValues.d.ts.map +0 -1
  187. package/dist/vocabulary/collectFormValues.js +0 -44
  188. package/dist/vocabulary/collectFormValues.js.map +0 -1
  189. package/dist/vocabulary/data.d.ts +0 -66
  190. package/dist/vocabulary/data.d.ts.map +0 -1
  191. package/dist/vocabulary/data.js +0 -503
  192. package/dist/vocabulary/data.js.map +0 -1
  193. package/dist/vocabulary/dispatch.d.ts +0 -9
  194. package/dist/vocabulary/dispatch.d.ts.map +0 -1
  195. package/dist/vocabulary/dispatch.js +0 -50
  196. package/dist/vocabulary/dispatch.js.map +0 -1
  197. package/dist/vocabulary/fact.d.ts +0 -19
  198. package/dist/vocabulary/fact.d.ts.map +0 -1
  199. package/dist/vocabulary/fact.js +0 -51
  200. package/dist/vocabulary/fact.js.map +0 -1
  201. package/dist/vocabulary/form.d.ts +0 -11
  202. package/dist/vocabulary/form.d.ts.map +0 -1
  203. package/dist/vocabulary/form.js +0 -23
  204. package/dist/vocabulary/form.js.map +0 -1
  205. package/dist/vocabulary/formatValue.d.ts +0 -7
  206. package/dist/vocabulary/formatValue.d.ts.map +0 -1
  207. package/dist/vocabulary/formatValue.js +0 -76
  208. package/dist/vocabulary/formatValue.js.map +0 -1
  209. package/dist/vocabulary/icon.d.ts +0 -41
  210. package/dist/vocabulary/icon.d.ts.map +0 -1
  211. package/dist/vocabulary/icon.js +0 -272
  212. package/dist/vocabulary/icon.js.map +0 -1
  213. package/dist/vocabulary/index.d.ts +0 -12
  214. package/dist/vocabulary/index.d.ts.map +0 -1
  215. package/dist/vocabulary/index.js +0 -36
  216. package/dist/vocabulary/index.js.map +0 -1
  217. package/dist/vocabulary/interactive.d.ts +0 -230
  218. package/dist/vocabulary/interactive.d.ts.map +0 -1
  219. package/dist/vocabulary/interactive.js +0 -584
  220. package/dist/vocabulary/interactive.js.map +0 -1
  221. package/dist/vocabulary/layout.d.ts +0 -79
  222. package/dist/vocabulary/layout.d.ts.map +0 -1
  223. package/dist/vocabulary/layout.js +0 -139
  224. package/dist/vocabulary/layout.js.map +0 -1
  225. package/dist/vocabulary/list.d.ts +0 -14
  226. package/dist/vocabulary/list.d.ts.map +0 -1
  227. package/dist/vocabulary/list.js +0 -50
  228. package/dist/vocabulary/list.js.map +0 -1
  229. package/dist/vocabulary/media.d.ts +0 -25
  230. package/dist/vocabulary/media.d.ts.map +0 -1
  231. package/dist/vocabulary/media.js +0 -42
  232. package/dist/vocabulary/media.js.map +0 -1
  233. package/dist/vocabulary/text.d.ts +0 -57
  234. package/dist/vocabulary/text.d.ts.map +0 -1
  235. package/dist/vocabulary/text.js +0 -49
  236. package/dist/vocabulary/text.js.map +0 -1
  237. package/dist/vocabulary/toTextContent.d.ts +0 -2
  238. package/dist/vocabulary/toTextContent.d.ts.map +0 -1
  239. package/dist/vocabulary/toTextContent.js +0 -6
  240. package/dist/vocabulary/toTextContent.js.map +0 -1
  241. package/src/JSONGenerativeUI.client.tsx +0 -168
  242. package/src/JSONGenerativeUI.server.tsx +0 -39
  243. package/src/JSONGenerativeUI.shared.ts +0 -90
  244. package/src/JSONGenerativeUI.test.tsx +0 -1298
  245. package/src/RadioGroupScope.server.test.tsx +0 -24
  246. package/src/RadioGroupScope.tsx +0 -34
  247. package/src/a2ui/BindingContext.ts +0 -26
  248. package/src/a2ui/PresentRenderer.tsx +0 -83
  249. package/src/a2ui/convert.test.ts +0 -2923
  250. package/src/a2ui/convert.ts +0 -1207
  251. package/src/a2ui/dataModel.ts +0 -69
  252. package/src/a2ui/reducer.test.ts +0 -422
  253. package/src/a2ui/reducer.ts +0 -363
  254. package/src/a2ui/snapshot.test.ts +0 -52
  255. package/src/a2ui/snapshot.ts +0 -52
  256. package/src/a2ui/types.ts +0 -114
  257. package/src/a2ui/valueFunctions.test.ts +0 -271
  258. package/src/a2ui/valueFunctions.ts +0 -523
  259. package/src/actionRegistry.test.ts +0 -90
  260. package/src/actionRegistry.ts +0 -88
  261. package/src/answeredValues.test.ts +0 -33
  262. package/src/answeredValues.tsx +0 -70
  263. package/src/buildPresentParameters.test.ts +0 -246
  264. package/src/buildPresentParameters.ts +0 -130
  265. package/src/constants.ts +0 -17
  266. package/src/convert/boundSpec.test.ts +0 -192
  267. package/src/convert/boundSpec.ts +0 -134
  268. package/src/convert/copyBounded.test.ts +0 -131
  269. package/src/convert/copyBounded.ts +0 -38
  270. package/src/convert/isElement.ts +0 -6
  271. package/src/convert/takeRun.test.ts +0 -64
  272. package/src/convert/takeRun.ts +0 -19
  273. package/src/defineGenerativeComponents.ts +0 -38
  274. package/src/fieldReferences.test.ts +0 -66
  275. package/src/fieldReferences.ts +0 -83
  276. package/src/generativeUIToJSX.test.ts +0 -268
  277. package/src/generativeUIToJSX.ts +0 -152
  278. package/src/index.server.test.ts +0 -106
  279. package/src/index.shared.ts +0 -61
  280. package/src/ir.test.ts +0 -203
  281. package/src/renderGenerativeUI.test.tsx +0 -373
  282. package/src/renderGenerativeUI.tsx +0 -165
  283. package/src/scopeSchema.test.ts +0 -72
  284. package/src/scopeSchema.ts +0 -71
  285. package/src/slack/a2uiSlack.test.ts +0 -198
  286. package/src/slack/constants.ts +0 -194
  287. package/src/slack/datePicker.test.ts +0 -612
  288. package/src/slack/decodeBlockAction.test.ts +0 -233
  289. package/src/slack/decodeBlockAction.ts +0 -232
  290. package/src/slack/fromSlackBlocks.test.ts +0 -1465
  291. package/src/slack/fromSlackBlocks.ts +0 -789
  292. package/src/slack/toSlackBlocks.test.ts +0 -3065
  293. package/src/slack/toSlackBlocks.ts +0 -1818
  294. package/src/slack/types.ts +0 -264
  295. package/src/teams/constants.ts +0 -93
  296. package/src/teams/decodeSubmitData.test.ts +0 -397
  297. package/src/teams/decodeSubmitData.ts +0 -110
  298. package/src/teams/temporal.test.ts +0 -766
  299. package/src/teams/temporalId.ts +0 -56
  300. package/src/teams/toAdaptiveCard.test.ts +0 -1897
  301. package/src/teams/toAdaptiveCard.ts +0 -1057
  302. package/src/teams/toTeamsAttachments.test.ts +0 -74
  303. package/src/teams/toTeamsAttachments.ts +0 -133
  304. package/src/teams/types.ts +0 -266
  305. package/src/temporal.test.ts +0 -337
  306. package/src/temporal.ts +0 -263
  307. package/src/types.ts +0 -119
  308. package/src/vocabulary/alert.test.tsx +0 -427
  309. package/src/vocabulary/alert.tsx +0 -217
  310. package/src/vocabulary/collectFormValues.test.ts +0 -389
  311. package/src/vocabulary/collectFormValues.ts +0 -116
  312. package/src/vocabulary/data.test.tsx +0 -858
  313. package/src/vocabulary/data.tsx +0 -819
  314. package/src/vocabulary/datepicker.dom.test.tsx +0 -1457
  315. package/src/vocabulary/dispatch.ts +0 -83
  316. package/src/vocabulary/fact.test.tsx +0 -94
  317. package/src/vocabulary/fact.tsx +0 -54
  318. package/src/vocabulary/form.test.tsx +0 -113
  319. package/src/vocabulary/form.tsx +0 -39
  320. package/src/vocabulary/formatValue.test.ts +0 -72
  321. package/src/vocabulary/formatValue.ts +0 -127
  322. package/src/vocabulary/icon.test.tsx +0 -64
  323. package/src/vocabulary/icon.tsx +0 -174
  324. package/src/vocabulary/index.test.ts +0 -65
  325. package/src/vocabulary/index.ts +0 -33
  326. package/src/vocabulary/interactive.dispatch.test.tsx +0 -454
  327. package/src/vocabulary/interactive.dom.test.tsx +0 -1747
  328. package/src/vocabulary/interactive.test.tsx +0 -377
  329. package/src/vocabulary/interactive.tsx +0 -1109
  330. package/src/vocabulary/layout.test.tsx +0 -323
  331. package/src/vocabulary/layout.tsx +0 -247
  332. package/src/vocabulary/list.test.tsx +0 -222
  333. package/src/vocabulary/list.tsx +0 -50
  334. package/src/vocabulary/media.test.tsx +0 -85
  335. package/src/vocabulary/media.tsx +0 -56
  336. package/src/vocabulary/text.test.tsx +0 -102
  337. package/src/vocabulary/text.tsx +0 -60
  338. package/src/vocabulary/toTextContent.ts +0 -2
@@ -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,2 +0,0 @@
1
- export declare const toTextContent: (value: unknown) => string | number | null;
2
- //# sourceMappingURL=toTextContent.d.ts.map
@@ -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,6 +0,0 @@
1
- //#region src/vocabulary/toTextContent.ts
2
- const toTextContent = (value) => typeof value === "string" || typeof value === "number" ? value : null;
3
- //#endregion
4
- export { toTextContent };
5
-
6
- //# sourceMappingURL=toTextContent.js.map
@@ -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
- }