@assistant-ui/react-generative-ui 0.0.23 → 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 +5 -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 -152
  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 -530
  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 -319
  306. package/src/temporal.ts +0 -259
  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 -1148
  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 -1048
  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
package/src/ir.ts CHANGED
@@ -1,279 +1 @@
1
- /**
2
- * The generative-ui intermediate representation: a model-emitted, cross-platform
3
- * UI tree. React-free, so converters and non-web runtimes consume it without
4
- * pulling React. The flat `$type` shape is the canonical form; the legacy
5
- * `component` shape is accepted as a backward-compatible alias.
6
- *
7
- * Reserved keys are partitioned off from component props so the component prop
8
- * namespace stays fully free:
9
- *
10
- * - `$`-prefixed keys are framework-reserved (`$type`, `$key`, `$action`,
11
- * `$status`). Components never declare `$`-prefixed props, so a component
12
- * can use `type`, `status`, `variant`, etc. as ordinary props without
13
- * colliding with the framework.
14
- * - `children` is additionally reserved (the JSX convention).
15
- * - every other key is an inline prop passed straight to the component.
16
- */
17
-
18
- import { TYPE_KEY } from "./constants";
19
-
20
- export const TEXT_SIZES = ["sm", "md", "lg", "xl", "2xl", "3xl"] as const;
21
- export type TextSize = (typeof TEXT_SIZES)[number];
22
-
23
- export const IMAGE_SIZE_TOKENS = ["sm", "md", "lg"] as const;
24
- export type ImageSize = (typeof IMAGE_SIZE_TOKENS)[number] | number;
25
-
26
- export const WEIGHTS = ["normal", "medium", "semibold", "bold"] as const;
27
- export type Weight = (typeof WEIGHTS)[number];
28
-
29
- export const COLORS = [
30
- "emphasis",
31
- "secondary",
32
- "alpha-70",
33
- "white",
34
- "white-70",
35
- "white-50",
36
- ] as const;
37
- export type Color = (typeof COLORS)[number];
38
-
39
- export const ALIGNS = ["start", "center", "end"] as const;
40
- export type Align = (typeof ALIGNS)[number];
41
-
42
- export const JUSTIFIES = ["start", "center", "end", "between"] as const;
43
- export type Justify = (typeof JUSTIFIES)[number];
44
-
45
- export const BUTTON_STYLES = [
46
- "primary",
47
- "secondary",
48
- "outline",
49
- "ghost",
50
- "danger",
51
- ] as const;
52
- export type ButtonStyle = (typeof BUTTON_STYLES)[number];
53
-
54
- export const ALERT_TONES = ["info", "success", "warning", "danger"] as const;
55
- /** A severity level, from informational to destructive. */
56
- export type AlertTone = (typeof ALERT_TONES)[number];
57
-
58
- export const ICON_NAMES = [
59
- "sun",
60
- "moon",
61
- "cloud",
62
- "rain",
63
- "snow",
64
- "wind",
65
- "play",
66
- "pause",
67
- "check",
68
- "x",
69
- "star",
70
- "heart",
71
- "arrow-right",
72
- "arrow-up-right",
73
- "chevron-right",
74
- "calendar",
75
- "clock",
76
- "map-pin",
77
- "plane",
78
- "truck",
79
- "credit-card",
80
- "user",
81
- "search",
82
- "bell",
83
- ] as const;
84
- /** A name from the built-in icon set; the closed enum lets the model see exactly which icons exist. */
85
- export type IconName = (typeof ICON_NAMES)[number];
86
-
87
- /**
88
- * Behavior payload carried by an interactive node. `type` is resolved by the host's action registry, not the renderer; keeping behavior as data keeps the tree serializable, so the same node renders on web while converters may bind the type to a native action id on other platforms. A `{ "$field": name }` value anywhere in the payload refers to the current value of the control with that `name`, resolved when the action fires, and `{ "$field": name, "fallback": value }` resolves to `fallback` when no control holds a value.
89
- */
90
- export interface Action {
91
- readonly type: string;
92
- readonly [payload: string]: unknown;
93
- }
94
-
95
- /**
96
- * Anything renderable as generative UI, as the model emits it. The renderer
97
- * also accepts `number`, `boolean`, `null`, `undefined`, and arrays at the
98
- * input boundary (numbers render as text, falsy/boolean as nothing, arrays as
99
- * lists); {@link normalizeUINode} accepts that full range.
100
- */
101
- export type UINode = string | number | UIElement | LegacyComponentNode;
102
-
103
- export type UIChildren = UINode | readonly UINode[];
104
-
105
- /** The flat node shape: inline props keep the tree compact and natural for a
106
- * model to emit, instead of a nested `{ type, props }` bag. Reserved keys are
107
- * stripped before props reach the component (see the module header). */
108
- export interface UIElement {
109
- readonly $type: string;
110
- readonly $key?: string | number;
111
- readonly children?: UIChildren;
112
- readonly $action?: Action;
113
- readonly [prop: string]: unknown;
114
- }
115
-
116
- /**
117
- * The legacy node shape: a `component` name plus a nested `props` bag. Kept
118
- * for backward compatibility. New code authors the flat {@link UIElement}
119
- * shape instead.
120
- */
121
- export interface LegacyComponentNode {
122
- readonly component: string;
123
- readonly props?: Record<string, unknown>;
124
- readonly children?: UIChildren;
125
- readonly key?: string;
126
- }
127
-
128
- export type UISpec = UINode | readonly UINode[];
129
-
130
- /**
131
- * A node normalized to a single canonical shape: a `type` string, an inline
132
- * `props` bag, recursive `children`, an optional `key`, and an optional
133
- * `action`. Renderers and platform converters consume this form, so they never
134
- * branch on whether the model emitted the flat `$type` shape or the legacy
135
- * `component` shape, and they never see the reserved `$`-prefixed keys leak
136
- * into component props.
137
- */
138
- export interface NormalizedUIElement {
139
- readonly type: string;
140
- readonly props: Readonly<Record<string, unknown>>;
141
- readonly children?: NormalizedUINode | undefined;
142
- readonly key?: string | number | undefined;
143
- readonly action?: Action | undefined;
144
- }
145
-
146
- export type NormalizedUINode =
147
- | string
148
- | number
149
- | readonly NormalizedUINode[]
150
- | NormalizedUIElement
151
- | null;
152
-
153
- const isRecord = (value: unknown): value is Record<string, unknown> =>
154
- typeof value === "object" && value !== null && !Array.isArray(value);
155
-
156
- type LegacyNodeRecord = { component: string } & Record<string, unknown>;
157
-
158
- const isLegacyNode = (
159
- node: Record<string, unknown>,
160
- ): node is LegacyNodeRecord => typeof node["component"] === "string";
161
-
162
- const isTypeNode = (node: Record<string, unknown>): node is UIElement =>
163
- typeof node[TYPE_KEY] === "string";
164
-
165
- /** Bounds recursion so a runaway or adversarial model response cannot overflow
166
- * the stack; past this depth (far beyond any real UI) we stop. */
167
- const MAX_DEPTH = 64;
168
-
169
- /**
170
- * Steps a streaming partial path down into `key`. `partialPath` is the remaining
171
- * segment of the parse meta's partial path relative to `node` (`undefined` once
172
- * the walk leaves the partial frontier, i.e. everything below is complete).
173
- */
174
- function descend(
175
- partialPath: readonly string[] | undefined,
176
- key: string,
177
- ): readonly string[] | undefined {
178
- return partialPath?.[0] === key ? partialPath.slice(1) : undefined;
179
- }
180
-
181
- /**
182
- * Normalizes a generative-ui input to {@link NormalizedUINode}. The flat
183
- * `$type` shape and the legacy `component` shape both map to the same canonical
184
- * element, with reserved keys (`$type`, `$key`, `$action`, `children`) stripped
185
- * from the prop bag. A node that carries neither a `$type` nor a `component`
186
- * string is not renderable and resolves to `null` rather than throwing, so a
187
- * partially-streamed or malformed node degrades to "render nothing".
188
- *
189
- * `partialPath` carries streaming state from the tool-args parse meta: a node
190
- * whose `$type` is still mid-arrival is held back (resolves to `null`) until it
191
- * completes, and the path is threaded into `children` so a nested streaming
192
- * node is held back while completed siblings render. Omit it for a
193
- * non-streaming (converter) normalize.
194
- */
195
- export function normalizeUINode(
196
- node: unknown,
197
- partialPath?: readonly string[] | undefined,
198
- depth = 0,
199
- ): NormalizedUINode {
200
- if (depth > MAX_DEPTH) return null;
201
- if (node == null || typeof node === "boolean") return null;
202
- if (typeof node === "string" || typeof node === "number") return node;
203
- if (Array.isArray(node))
204
- return node.map((child, index) =>
205
- normalizeUINode(child, descend(partialPath, String(index)), depth + 1),
206
- );
207
- if (!isRecord(node)) return null;
208
-
209
- // The flat `$type` shape is the canonical form; detect it first so a flat
210
- // node that happens to use `component` as an ordinary prop is not swallowed
211
- // by the legacy `component`-shape branch.
212
- if (isTypeNode(node)) {
213
- if (partialPath?.length === 1 && partialPath[0] === TYPE_KEY) return null;
214
- const { [TYPE_KEY]: type, $key, $action, children, ...rest } = node;
215
- // The `$`-prefixed namespace is framework-reserved (see the module header),
216
- // so any model-supplied `$`-prefixed key is stripped from the prop bag the
217
- // component sees. `$type`/`$key`/`$action` are pulled above; sweep the rest
218
- // (e.g. a stray `$status`) so it never leaks to converters or components.
219
- const props = stripReservedProps(rest);
220
- return {
221
- type,
222
- props,
223
- children: normalizeChildren(children, partialPath, depth),
224
- key: $key,
225
- action: $action,
226
- };
227
- }
228
-
229
- if (isLegacyNode(node)) {
230
- const props = stripReservedProps(
231
- (node.props ?? {}) as Record<string, unknown>,
232
- );
233
- return {
234
- type: node.component,
235
- props,
236
- children: normalizeChildren(node.children, partialPath, depth),
237
- key: node.key as string | undefined,
238
- };
239
- }
240
-
241
- return null;
242
- }
243
-
244
- function stripReservedProps(
245
- props: Record<string, unknown>,
246
- ): Record<string, unknown> {
247
- let out: Record<string, unknown> | undefined;
248
- for (const key of Object.keys(props)) {
249
- if (key.startsWith("$")) {
250
- out ??= { ...props };
251
- delete out[key];
252
- }
253
- }
254
- return out ?? props;
255
- }
256
-
257
- function normalizeChildren(
258
- children: unknown,
259
- partialPath: readonly string[] | undefined,
260
- depth: number,
261
- ): NormalizedUINode | undefined {
262
- if (children === undefined) return undefined;
263
- return normalizeUINode(children, descend(partialPath, "children"), depth + 1);
264
- }
265
-
266
- /**
267
- * Normalizes the root of a {@link UISpec}, preserving whether the root was a
268
- * single node or a list.
269
- */
270
- export function normalizeSpec(spec: UISpec): {
271
- readonly root: NormalizedUINode | readonly NormalizedUINode[];
272
- } {
273
- if (Array.isArray(spec)) {
274
- return {
275
- root: (spec as readonly UINode[]).map((node) => normalizeUINode(node)),
276
- };
277
- }
278
- return { root: normalizeUINode(spec) };
279
- }
1
+ export * from "@assistant-ui/generative-ui";
package/src/slack.ts CHANGED
@@ -1,39 +1 @@
1
- export { decodeBlockAction } from "./slack/decodeBlockAction";
2
- export { fromSlackBlocks } from "./slack/fromSlackBlocks";
3
- export { toSlackBlocks } from "./slack/toSlackBlocks";
4
- export type {
5
- FromSlackBlocksResult,
6
- SlackActionElement,
7
- SlackActionsBlock,
8
- SlackAlertBlock,
9
- SlackAlertLevel,
10
- SlackBlock,
11
- SlackBlocksResult,
12
- SlackButtonElement,
13
- SlackCardBlock,
14
- SlackCarouselBlock,
15
- SlackCheckboxesElement,
16
- SlackContextBlock,
17
- SlackConversionWarning,
18
- SlackDataTableBlock,
19
- SlackDataTableCell,
20
- SlackDataTableRawNumberCell,
21
- SlackDataTableRawTextCell,
22
- SlackDatePickerElement,
23
- SlackDateTimePickerElement,
24
- SlackDividerBlock,
25
- SlackHeaderBlock,
26
- SlackImageBlock,
27
- SlackInputBlock,
28
- SlackMarkdownBlock,
29
- SlackMrkdwnText,
30
- SlackOption,
31
- SlackPlainText,
32
- SlackPlainTextInputElement,
33
- SlackRadioButtonsElement,
34
- SlackSectionBlock,
35
- SlackStaticSelectElement,
36
- SlackTextObject,
37
- SlackTimePickerElement,
38
- ToSlackBlocksOptions,
39
- } from "./slack/types";
1
+ export * from "@assistant-ui/generative-ui/slack";
package/src/teams.ts CHANGED
@@ -1,35 +1 @@
1
- export { decodeSubmitData } from "./teams/decodeSubmitData";
2
- export { toAdaptiveCard } from "./teams/toAdaptiveCard";
3
- export { toTeamsAttachments } from "./teams/toTeamsAttachments";
4
- export type {
5
- AdaptiveCardResult,
6
- TeamsAdaptiveCard,
7
- TeamsActionSet,
8
- TeamsAttachmentsResult,
9
- TeamsCardAction,
10
- TeamsCardAttachment,
11
- TeamsCardElement,
12
- TeamsColumn,
13
- TeamsColumnSet,
14
- TeamsContainer,
15
- TeamsContainerStyle,
16
- TeamsConversionWarning,
17
- TeamsFact,
18
- TeamsFactSet,
19
- TeamsImage,
20
- TeamsInputChoice,
21
- TeamsInputChoiceSet,
22
- TeamsInputDate,
23
- TeamsInputText,
24
- TeamsInputTime,
25
- TeamsInputToggle,
26
- TeamsSubmitAction,
27
- TeamsSubmitData,
28
- TeamsTable,
29
- TeamsTableCell,
30
- TeamsTableColumnDefinition,
31
- TeamsTableRow,
32
- TeamsTextBlock,
33
- TeamsTextSize,
34
- ToAdaptiveCardOptions,
35
- } from "./teams/types";
1
+ export * from "@assistant-ui/generative-ui/teams";
@@ -1,28 +0,0 @@
1
- import { type JSONGenerativeUIOptions, type PresentTool, type PresentToolOptions, type PromptUserTool } from "./JSONGenerativeUI.shared.js";
2
- /**
3
- * Client build of {@link JSONGenerativeUI}, resolved through the package's
4
- * `default` export condition (browser and SSR).
5
- *
6
- * `present` is a frontend tool that renders the model's `{ $type, ...props }`
7
- * tree against the library and resolves immediately. `prompt_user` is a
8
- * human-in-the-loop tool: the model pauses and the rendered UI supplies the
9
- * result. Both draw the tree the same way, so they share one `render`. The
10
- * `actions` registry (if provided) is threaded into the render context so
11
- * interactive components can fire `$action` through `$dispatch`.
12
- */
13
- export declare class JSONGenerativeUI {
14
- private readonly library;
15
- private readonly parameters;
16
- private readonly actions;
17
- private readonly completedPromptToolCallIds;
18
- constructor(options: JSONGenerativeUIOptions);
19
- /**
20
- * The surface a `present` call paints into. It owns the vertical rhythm
21
- * between top-level blocks, which the host's message container does not
22
- * provide, and stays out of the way while it has nothing to show.
23
- */
24
- private readonly render;
25
- present(options?: PresentToolOptions): PresentTool;
26
- promptUser(): PromptUserTool;
27
- }
28
- //# sourceMappingURL=JSONGenerativeUI.client.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"JSONGenerativeUI.client.d.ts","sourceRoot":"","sources":["../src/JSONGenerativeUI.client.tsx"],"names":[],"mappings":"AAMA,OAAO,EAGL,KAAK,uBAAuB,EAE5B,KAAK,WAAW,EAChB,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACpB,qCAAkC;AAiBnC;;;;;;;;;;GAUG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAsB;IAC9C,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAoB;IAC/C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA6B;IACrD,OAAO,CAAC,QAAQ,CAAC,0BAA0B,CAAqB;gBAEpD,OAAO,EAAE,uBAAuB;IAM5C;;;;OAIG;IACH,OAAO,CAAC,QAAQ,CAAC,MAAM,CA0FrB;IAEF,OAAO,CAAC,OAAO,CAAC,EAAE,kBAAkB,GAAG,WAAW;IASlD,UAAU,IAAI,cAAc;CAO7B"}
@@ -1,101 +0,0 @@
1
- import { renderGenerativeUI } from "./renderGenerativeUI.js";
2
- import { A2uiPresentRenderer } from "./a2ui/PresentRenderer.js";
3
- import { AnsweredValuesProvider, findAnsweredValues } from "./answeredValues.js";
4
- import { buildPresentParameters } from "./buildPresentParameters.js";
5
- import { presentToolBase, promptUserToolBase } from "./JSONGenerativeUI.shared.js";
6
- import { getPartialJsonObjectMeta } from "assistant-stream/utils";
7
- import { jsx } from "react/jsx-runtime";
8
- //#region src/JSONGenerativeUI.client.tsx
9
- function uiStatus(status, args) {
10
- return status.type === "complete" || status.type === "requires-action" && getPartialJsonObjectMeta(args)?.state !== "partial" ? "done" : "streaming";
11
- }
12
- /**
13
- * Client build of {@link JSONGenerativeUI}, resolved through the package's
14
- * `default` export condition (browser and SSR).
15
- *
16
- * `present` is a frontend tool that renders the model's `{ $type, ...props }`
17
- * tree against the library and resolves immediately. `prompt_user` is a
18
- * human-in-the-loop tool: the model pauses and the rendered UI supplies the
19
- * result. Both draw the tree the same way, so they share one `render`. The
20
- * `actions` registry (if provided) is threaded into the render context so
21
- * interactive components can fire `$action` through `$dispatch`.
22
- */
23
- var JSONGenerativeUI = class {
24
- library;
25
- parameters;
26
- actions;
27
- completedPromptToolCallIds = /* @__PURE__ */ new Set();
28
- constructor(options) {
29
- this.library = options.library;
30
- this.parameters = buildPresentParameters(options.library);
31
- this.actions = options.actions;
32
- }
33
- /**
34
- * The surface a `present` call paints into. It owns the vertical rhythm
35
- * between top-level blocks, which the host's message container does not
36
- * provide, and stays out of the way while it has nothing to show.
37
- */
38
- render = ({ args, status, addResult, result, toolCallId, artifact, unstable_recordInteraction, unstable_interactions }, completesPrompt = false) => {
39
- const answered = completesPrompt && result !== void 0;
40
- const actions = this.actions;
41
- const dispatch = !answered && actions ? (action) => {
42
- if (unstable_recordInteraction) try {
43
- unstable_recordInteraction({
44
- type: "action",
45
- payload: action
46
- }).catch(() => {});
47
- } catch {}
48
- const actionResult = actions.dispatch(action);
49
- if (completesPrompt && actionResult !== void 0 && result === void 0) Promise.resolve(actionResult).then((response) => {
50
- if (response !== void 0 && !this.completedPromptToolCallIds.has(toolCallId)) {
51
- this.completedPromptToolCallIds.add(toolCallId);
52
- addResult(response);
53
- }
54
- }).catch(() => {});
55
- return actionResult;
56
- } : void 0;
57
- const artifactValue = artifact !== null && typeof artifact === "object" ? artifact["a2ui"] : void 0;
58
- const surfaceId = typeof toolCallId === "string" && toolCallId.startsWith("a2ui:") ? toolCallId.slice(5) : void 0;
59
- const rendered = surfaceId && Array.isArray(artifactValue) ? /* @__PURE__ */ jsx(A2uiPresentRenderer, {
60
- surfaceId,
61
- operations: artifactValue,
62
- fallback: args,
63
- library: this.library,
64
- status: uiStatus(status, args),
65
- ...dispatch ? { dispatch } : {}
66
- }, surfaceId) : renderGenerativeUI(args, this.library, {
67
- status: uiStatus(status, args),
68
- ...dispatch ? { dispatch } : {}
69
- });
70
- return /* @__PURE__ */ jsx("div", {
71
- "data-aui": "root",
72
- children: answered ? /* @__PURE__ */ jsx(AnsweredValuesProvider, {
73
- values: findAnsweredValues(unstable_interactions),
74
- children: /* @__PURE__ */ jsx("fieldset", {
75
- disabled: true,
76
- "data-aui": "answered",
77
- children: rendered
78
- })
79
- }) : rendered
80
- });
81
- };
82
- present(options) {
83
- return {
84
- ...presentToolBase(this.parameters, options),
85
- unstable_backendDefault: { parameters: true },
86
- execute: async () => ({}),
87
- render: this.render
88
- };
89
- }
90
- promptUser() {
91
- return {
92
- ...promptUserToolBase(this.parameters),
93
- unstable_backendDefault: { parameters: true },
94
- render: (props) => this.render(props, true)
95
- };
96
- }
97
- };
98
- //#endregion
99
- export { JSONGenerativeUI };
100
-
101
- //# sourceMappingURL=JSONGenerativeUI.client.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"JSONGenerativeUI.client.js","names":[],"sources":["../src/JSONGenerativeUI.client.tsx"],"sourcesContent":["import type { ToolCallMessagePartProps } from \"@assistant-ui/react\";\nimport { getPartialJsonObjectMeta } from \"assistant-stream/utils\";\nimport type { ReactNode } from \"react\";\nimport { A2uiPresentRenderer } from \"./a2ui/PresentRenderer\";\nimport { AnsweredValuesProvider, findAnsweredValues } from \"./answeredValues\";\nimport { buildPresentParameters } from \"./buildPresentParameters\";\nimport {\n presentToolBase,\n promptUserToolBase,\n type JSONGenerativeUIOptions,\n type PresentParameters,\n type PresentTool,\n type PresentToolOptions,\n type PromptUserTool,\n} from \"./JSONGenerativeUI.shared\";\nimport { type ActionRegistry } from \"./actionRegistry\";\nimport { renderGenerativeUI } from \"./renderGenerativeUI\";\nimport type { GenerativeUILibrary, GenerativeUIStatus } from \"./types\";\n\n// A cancelled argument stream can leave a tool waiting with partial arguments.\nfunction uiStatus(\n status: { type: string },\n args: Record<string, unknown>,\n): GenerativeUIStatus {\n return status.type === \"complete\" ||\n (status.type === \"requires-action\" &&\n getPartialJsonObjectMeta(args)?.state !== \"partial\")\n ? \"done\"\n : \"streaming\";\n}\n\n/**\n * Client build of {@link JSONGenerativeUI}, resolved through the package's\n * `default` export condition (browser and SSR).\n *\n * `present` is a frontend tool that renders the model's `{ $type, ...props }`\n * tree against the library and resolves immediately. `prompt_user` is a\n * human-in-the-loop tool: the model pauses and the rendered UI supplies the\n * result. Both draw the tree the same way, so they share one `render`. The\n * `actions` registry (if provided) is threaded into the render context so\n * interactive components can fire `$action` through `$dispatch`.\n */\nexport class JSONGenerativeUI {\n private readonly library: GenerativeUILibrary;\n private readonly parameters: PresentParameters;\n private readonly actions: ActionRegistry | undefined;\n private readonly completedPromptToolCallIds = new Set<string>();\n\n constructor(options: JSONGenerativeUIOptions) {\n this.library = options.library;\n this.parameters = buildPresentParameters(options.library);\n this.actions = options.actions;\n }\n\n /**\n * The surface a `present` call paints into. It owns the vertical rhythm\n * between top-level blocks, which the host's message container does not\n * provide, and stays out of the way while it has nothing to show.\n */\n private readonly render = (\n {\n args,\n status,\n addResult,\n result,\n toolCallId,\n artifact,\n unstable_recordInteraction,\n unstable_interactions,\n }: ToolCallMessagePartProps<Record<string, unknown>, any>,\n completesPrompt = false,\n ): ReactNode => {\n const answered = completesPrompt && result !== undefined;\n const actions = this.actions;\n const dispatch =\n !answered && actions\n ? (action: Parameters<ActionRegistry[\"dispatch\"]>[0]) => {\n if (unstable_recordInteraction) {\n try {\n void unstable_recordInteraction({\n type: \"action\",\n payload: action,\n }).catch(() => {});\n } catch {}\n }\n\n const actionResult = actions.dispatch(action);\n if (\n completesPrompt &&\n actionResult !== undefined &&\n result === undefined\n ) {\n void Promise.resolve(actionResult)\n .then((response) => {\n if (\n response !== undefined &&\n !this.completedPromptToolCallIds.has(toolCallId)\n ) {\n this.completedPromptToolCallIds.add(toolCallId);\n addResult(response);\n }\n })\n .catch(() => {});\n }\n return actionResult;\n }\n : undefined;\n\n const artifactValue =\n artifact !== null && typeof artifact === \"object\"\n ? (artifact as Record<string, unknown>)[\"a2ui\"]\n : undefined;\n const surfaceId =\n typeof toolCallId === \"string\" && toolCallId.startsWith(\"a2ui:\")\n ? toolCallId.slice(\"a2ui:\".length)\n : undefined;\n const rendered =\n surfaceId && Array.isArray(artifactValue) ? (\n <A2uiPresentRenderer\n key={surfaceId}\n surfaceId={surfaceId}\n operations={artifactValue}\n fallback={args}\n library={this.library}\n status={uiStatus(status, args)}\n {...(dispatch ? { dispatch } : {})}\n />\n ) : (\n renderGenerativeUI(args, this.library, {\n status: uiStatus(status, args),\n ...(dispatch ? { dispatch } : {}),\n })\n );\n\n return (\n <div data-aui=\"root\">\n {answered ? (\n <AnsweredValuesProvider\n values={findAnsweredValues(unstable_interactions)}\n >\n <fieldset disabled data-aui=\"answered\">\n {rendered}\n </fieldset>\n </AnsweredValuesProvider>\n ) : (\n rendered\n )}\n </div>\n );\n };\n\n present(options?: PresentToolOptions): PresentTool {\n return {\n ...presentToolBase(this.parameters, options),\n unstable_backendDefault: { parameters: true },\n execute: async () => ({}),\n render: this.render,\n };\n }\n\n promptUser(): PromptUserTool {\n return {\n ...promptUserToolBase(this.parameters),\n unstable_backendDefault: { parameters: true },\n render: (props) => this.render(props, true),\n };\n }\n}\n"],"mappings":";;;;;;;;AAoBA,SAAS,SACP,QACA,MACoB;CACpB,OAAO,OAAO,SAAS,cACpB,OAAO,SAAS,qBACf,yBAAyB,IAAI,CAAC,EAAE,UAAU,YAC1C,SACA;AACN;;;;;;;;;;;;AAaA,IAAa,mBAAb,MAA8B;CAC5B;CACA;CACA;CACA,6CAA8C,IAAI,IAAY;CAE9D,YAAY,SAAkC;EAC5C,KAAK,UAAU,QAAQ;EACvB,KAAK,aAAa,uBAAuB,QAAQ,OAAO;EACxD,KAAK,UAAU,QAAQ;CACzB;;;;;;CAOA,UACE,EACE,MACA,QACA,WACA,QACA,YACA,UACA,4BACA,yBAEF,kBAAkB,UACJ;EACd,MAAM,WAAW,mBAAmB,WAAW,KAAA;EAC/C,MAAM,UAAU,KAAK;EACrB,MAAM,WACJ,CAAC,YAAY,WACR,WAAsD;GACrD,IAAI,4BACF,IAAI;IACF,2BAAgC;KAC9B,MAAM;KACN,SAAS;IACX,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC;GACnB,QAAQ,CAAC;GAGX,MAAM,eAAe,QAAQ,SAAS,MAAM;GAC5C,IACE,mBACA,iBAAiB,KAAA,KACjB,WAAW,KAAA,GAEX,QAAa,QAAQ,YAAY,CAAC,CAC/B,MAAM,aAAa;IAClB,IACE,aAAa,KAAA,KACb,CAAC,KAAK,2BAA2B,IAAI,UAAU,GAC/C;KACA,KAAK,2BAA2B,IAAI,UAAU;KAC9C,UAAU,QAAQ;IACpB;GACF,CAAC,CAAC,CACD,YAAY,CAAC,CAAC;GAEnB,OAAO;EACT,IACA,KAAA;EAEN,MAAM,gBACJ,aAAa,QAAQ,OAAO,aAAa,WACpC,SAAqC,UACtC,KAAA;EACN,MAAM,YACJ,OAAO,eAAe,YAAY,WAAW,WAAW,OAAO,IAC3D,WAAW,MAAM,CAAc,IAC/B,KAAA;EACN,MAAM,WACJ,aAAa,MAAM,QAAQ,aAAa,IACtC,oBAAC,qBAAD;GAEa;GACX,YAAY;GACZ,UAAU;GACV,SAAS,KAAK;GACd,QAAQ,SAAS,QAAQ,IAAI;GAC7B,GAAK,WAAW,EAAE,SAAS,IAAI,CAAC;EACjC,GAPM,SAON,IAED,mBAAmB,MAAM,KAAK,SAAS;GACrC,QAAQ,SAAS,QAAQ,IAAI;GAC7B,GAAI,WAAW,EAAE,SAAS,IAAI,CAAC;EACjC,CAAC;EAGL,OACE,oBAAC,OAAD;GAAK,YAAS;GACX,UAAA,WACC,oBAAC,wBAAD;IACE,QAAQ,mBAAmB,qBAAqB;IAEhD,UAAA,oBAAC,YAAD;KAAU,UAAA;KAAS,YAAS;KACzB,UAAA;IACO,CAAA;GACY,CAAA,IAExB;EAEC,CAAA;CAET;CAEA,QAAQ,SAA2C;EACjD,OAAO;GACL,GAAG,gBAAgB,KAAK,YAAY,OAAO;GAC3C,yBAAyB,EAAE,YAAY,KAAK;GAC5C,SAAS,aAAa,CAAC;GACvB,QAAQ,KAAK;EACf;CACF;CAEA,aAA6B;EAC3B,OAAO;GACL,GAAG,mBAAmB,KAAK,UAAU;GACrC,yBAAyB,EAAE,YAAY,KAAK;GAC5C,SAAS,UAAU,KAAK,OAAO,OAAO,IAAI;EAC5C;CACF;AACF"}
@@ -1,21 +0,0 @@
1
- import { type JSONGenerativeUIOptions, type PresentTool, type PresentToolOptions, type PromptUserTool } from "./JSONGenerativeUI.shared.js";
2
- /**
3
- * Server build of {@link JSONGenerativeUI}, resolved through the package's
4
- * `react-server` export condition.
5
- *
6
- * The model only needs each tool's `type`, `description`, and `parameters` on
7
- * the server, so `present`/`prompt_user` return exactly that — no `execute` and
8
- * no `render`, keeping the renderer (and React) out of the server graph. The
9
- * client build adds those back. The two builds share one set of public types, so
10
- * consumers see a single {@link JSONGenerativeUI} either way.
11
- *
12
- * `as` casts here because the tool types require a `render` for frontend/human
13
- * tools; on the server it is structurally absent and never read.
14
- */
15
- export declare class JSONGenerativeUI {
16
- private readonly parameters;
17
- constructor(options: JSONGenerativeUIOptions);
18
- present(options?: PresentToolOptions): PresentTool;
19
- promptUser(): PromptUserTool;
20
- }
21
- //# sourceMappingURL=JSONGenerativeUI.server.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"JSONGenerativeUI.server.d.ts","sourceRoot":"","sources":["../src/JSONGenerativeUI.server.tsx"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,uBAAuB,EAE5B,KAAK,WAAW,EAChB,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACpB,qCAAkC;AAEnC;;;;;;;;;;;;GAYG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAoB;gBAEnC,OAAO,EAAE,uBAAuB;IAI5C,OAAO,CAAC,OAAO,CAAC,EAAE,kBAAkB,GAAG,WAAW;IAIlD,UAAU,IAAI,cAAc;CAG7B"}
@@ -1,32 +0,0 @@
1
- import { buildPresentParameters } from "./buildPresentParameters.js";
2
- import { presentToolBase, promptUserToolBase } from "./JSONGenerativeUI.shared.js";
3
- //#region src/JSONGenerativeUI.server.tsx
4
- /**
5
- * Server build of {@link JSONGenerativeUI}, resolved through the package's
6
- * `react-server` export condition.
7
- *
8
- * The model only needs each tool's `type`, `description`, and `parameters` on
9
- * the server, so `present`/`prompt_user` return exactly that — no `execute` and
10
- * no `render`, keeping the renderer (and React) out of the server graph. The
11
- * client build adds those back. The two builds share one set of public types, so
12
- * consumers see a single {@link JSONGenerativeUI} either way.
13
- *
14
- * `as` casts here because the tool types require a `render` for frontend/human
15
- * tools; on the server it is structurally absent and never read.
16
- */
17
- var JSONGenerativeUI = class {
18
- parameters;
19
- constructor(options) {
20
- this.parameters = buildPresentParameters(options.library);
21
- }
22
- present(options) {
23
- return presentToolBase(this.parameters, options);
24
- }
25
- promptUser() {
26
- return promptUserToolBase(this.parameters);
27
- }
28
- };
29
- //#endregion
30
- export { JSONGenerativeUI };
31
-
32
- //# sourceMappingURL=JSONGenerativeUI.server.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"JSONGenerativeUI.server.js","names":[],"sources":["../src/JSONGenerativeUI.server.tsx"],"sourcesContent":["import { buildPresentParameters } from \"./buildPresentParameters\";\nimport {\n presentToolBase,\n promptUserToolBase,\n type JSONGenerativeUIOptions,\n type PresentParameters,\n type PresentTool,\n type PresentToolOptions,\n type PromptUserTool,\n} from \"./JSONGenerativeUI.shared\";\n\n/**\n * Server build of {@link JSONGenerativeUI}, resolved through the package's\n * `react-server` export condition.\n *\n * The model only needs each tool's `type`, `description`, and `parameters` on\n * the server, so `present`/`prompt_user` return exactly that — no `execute` and\n * no `render`, keeping the renderer (and React) out of the server graph. The\n * client build adds those back. The two builds share one set of public types, so\n * consumers see a single {@link JSONGenerativeUI} either way.\n *\n * `as` casts here because the tool types require a `render` for frontend/human\n * tools; on the server it is structurally absent and never read.\n */\nexport class JSONGenerativeUI {\n private readonly parameters: PresentParameters;\n\n constructor(options: JSONGenerativeUIOptions) {\n this.parameters = buildPresentParameters(options.library);\n }\n\n present(options?: PresentToolOptions): PresentTool {\n return presentToolBase(this.parameters, options) as PresentTool;\n }\n\n promptUser(): PromptUserTool {\n return promptUserToolBase(this.parameters) as PromptUserTool;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAwBA,IAAa,mBAAb,MAA8B;CAC5B;CAEA,YAAY,SAAkC;EAC5C,KAAK,aAAa,uBAAuB,QAAQ,OAAO;CAC1D;CAEA,QAAQ,SAA2C;EACjD,OAAO,gBAAgB,KAAK,YAAY,OAAO;CACjD;CAEA,aAA6B;EAC3B,OAAO,mBAAmB,KAAK,UAAU;CAC3C;AACF"}
@@ -1,63 +0,0 @@
1
- import type { ToolDefinition } from "@assistant-ui/react";
2
- import type { JSONSchema7 } from "json-schema";
3
- import type { ActionRegistry } from "./actionRegistry.js";
4
- import type { GenerativeUILibrary } from "./types.js";
5
- /** Options for {@link JSONGenerativeUI}. */
6
- export type JSONGenerativeUIOptions = {
7
- /**
8
- * The components the model is allowed to render, keyed by the `$type` it
9
- * selects them with. Author it with `defineGenerativeComponents({ ... })` so a
10
- * `"use generative"` build can split each `render` from its `properties`.
11
- */
12
- library: GenerativeUILibrary;
13
- /**
14
- * Host-provided map from `$action.type` to its handler. Interactive
15
- * components (`Button`/`Select`/`Input`/`DatePicker`) call `$dispatch($action)`
16
- * on their event, which resolves through this registry. Omit it for a
17
- * read-only render where model-emitted actions degrade to a no-op.
18
- */
19
- actions?: ActionRegistry;
20
- };
21
- /** Options for {@link JSONGenerativeUI.present}. */
22
- export type PresentToolOptions = {
23
- /**
24
- * Set `"standalone"` to render the component on its own surface (outside the
25
- * chain-of-thought trace), e.g. a full-bleed artifact like a card. Omit it for
26
- * the default inline rendering — there is no `"inline"` value because that is
27
- * already the default.
28
- */
29
- display?: "standalone";
30
- };
31
- type BackendDefaultMetadata = {
32
- unstable_backendDefault?: {
33
- parameters?: boolean;
34
- };
35
- };
36
- /** The `present` tool, as the model sees it (no client `render`/`execute`). */
37
- export type PresentTool = ToolDefinition<Record<string, unknown>, Record<string, never>> & BackendDefaultMetadata;
38
- /** The `prompt_user` tool, as the model sees it (no client `render`). */
39
- export type PromptUserTool = ToolDefinition<Record<string, unknown>, unknown> & BackendDefaultMetadata;
40
- /** The tool `parameters` schema, built once per instance (see `buildPresentParameters`). */
41
- export type PresentParameters = JSONSchema7;
42
- /**
43
- * The schema-only half of the `present` tool, shared by both builds. The server
44
- * build returns exactly this; the client build adds `execute` and `render`.
45
- * Takes the already-built `parameters` so it isn't recomputed per tool.
46
- */
47
- export declare function presentToolBase(parameters: PresentParameters, options?: PresentToolOptions): {
48
- display?: "standalone";
49
- type: "frontend";
50
- description: string;
51
- parameters: JSONSchema7;
52
- };
53
- /**
54
- * The schema-only half of the `prompt_user` tool, shared by both builds. The
55
- * server build returns exactly this; the client build adds `render`.
56
- */
57
- export declare function promptUserToolBase(parameters: PresentParameters): {
58
- type: "human";
59
- description: string;
60
- parameters: JSONSchema7;
61
- };
62
- export {};
63
- //# sourceMappingURL=JSONGenerativeUI.shared.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"JSONGenerativeUI.shared.d.ts","sourceRoot":"","sources":["../src/JSONGenerativeUI.shared.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EAAE,cAAc,EAAE,4BAAyB;AACvD,OAAO,KAAK,EAAE,mBAAmB,EAAE,mBAAgB;AAEnD,4CAA4C;AAC5C,MAAM,MAAM,uBAAuB,GAAG;IACpC;;;;OAIG;IACH,OAAO,EAAE,mBAAmB,CAAC;IAC7B;;;;;OAKG;IACH,OAAO,CAAC,EAAE,cAAc,CAAC;CAC1B,CAAC;AAEF,oDAAoD;AACpD,MAAM,MAAM,kBAAkB,GAAG;IAC/B;;;;;OAKG;IACH,OAAO,CAAC,EAAE,YAAY,CAAC;CACxB,CAAC;AAEF,KAAK,sBAAsB,GAAG;IAC5B,uBAAuB,CAAC,EAAE;QACxB,UAAU,CAAC,EAAE,OAAO,CAAC;KACtB,CAAC;CACH,CAAC;AAEF,+EAA+E;AAC/E,MAAM,MAAM,WAAW,GAAG,cAAc,CACtC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACvB,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CACtB,GACC,sBAAsB,CAAC;AAEzB,yEAAyE;AACzE,MAAM,MAAM,cAAc,GAAG,cAAc,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,GAC3E,sBAAsB,CAAC;AAWzB,4FAA4F;AAC5F,MAAM,MAAM,iBAAiB,GAAG,WAAW,CAAC;AAE5C;;;;GAIG;AACH,wBAAgB,eAAe,CAC7B,UAAU,EAAE,iBAAiB,EAC7B,OAAO,CAAC,EAAE,kBAAkB;;;;;EAQ7B;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,iBAAiB;;;;EAM/D"}