@assistant-ui/react-generative-ui 0.0.20 → 0.0.22

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 (189) hide show
  1. package/LICENSE +1 -1
  2. package/dist/JSONGenerativeUI.client.d.ts.map +1 -1
  3. package/dist/JSONGenerativeUI.client.js +30 -13
  4. package/dist/JSONGenerativeUI.client.js.map +1 -1
  5. package/dist/RadioGroupScope.d.ts +6 -0
  6. package/dist/RadioGroupScope.d.ts.map +1 -0
  7. package/dist/RadioGroupScope.js +25 -0
  8. package/dist/RadioGroupScope.js.map +1 -0
  9. package/dist/a2ui/BindingContext.d.ts +11 -0
  10. package/dist/a2ui/BindingContext.d.ts.map +1 -0
  11. package/dist/a2ui/BindingContext.js +12 -0
  12. package/dist/a2ui/BindingContext.js.map +1 -0
  13. package/dist/a2ui/PresentRenderer.d.ts +11 -0
  14. package/dist/a2ui/PresentRenderer.d.ts.map +1 -0
  15. package/dist/a2ui/PresentRenderer.js +39 -0
  16. package/dist/a2ui/PresentRenderer.js.map +1 -0
  17. package/dist/a2ui/convert.d.ts +6 -0
  18. package/dist/a2ui/convert.d.ts.map +1 -1
  19. package/dist/a2ui/convert.js +369 -87
  20. package/dist/a2ui/convert.js.map +1 -1
  21. package/dist/a2ui/dataModel.d.ts +9 -0
  22. package/dist/a2ui/dataModel.d.ts.map +1 -0
  23. package/dist/a2ui/dataModel.js +44 -0
  24. package/dist/a2ui/dataModel.js.map +1 -0
  25. package/dist/a2ui/reducer.d.ts +5 -0
  26. package/dist/a2ui/reducer.d.ts.map +1 -1
  27. package/dist/a2ui/reducer.js +3 -3
  28. package/dist/a2ui/reducer.js.map +1 -1
  29. package/dist/a2ui/types.d.ts +8 -2
  30. package/dist/a2ui/types.d.ts.map +1 -1
  31. package/dist/a2ui/types.js.map +1 -1
  32. package/dist/a2ui/valueFunctions.d.ts +16 -0
  33. package/dist/a2ui/valueFunctions.d.ts.map +1 -0
  34. package/dist/a2ui/valueFunctions.js +332 -0
  35. package/dist/a2ui/valueFunctions.js.map +1 -0
  36. package/dist/actionRegistry.d.ts +1 -1
  37. package/dist/actionRegistry.js.map +1 -1
  38. package/dist/answeredValues.d.ts +16 -0
  39. package/dist/answeredValues.d.ts.map +1 -0
  40. package/dist/answeredValues.js +37 -0
  41. package/dist/answeredValues.js.map +1 -0
  42. package/dist/constants.d.ts +2 -0
  43. package/dist/constants.d.ts.map +1 -1
  44. package/dist/constants.js +3 -1
  45. package/dist/constants.js.map +1 -1
  46. package/dist/fieldReferences.d.ts +9 -0
  47. package/dist/fieldReferences.d.ts.map +1 -0
  48. package/dist/fieldReferences.js +53 -0
  49. package/dist/fieldReferences.js.map +1 -0
  50. package/dist/generativeUIToJSX.js +3 -3
  51. package/dist/generativeUIToJSX.js.map +1 -1
  52. package/dist/index.js +2 -2
  53. package/dist/index.server.js +2 -2
  54. package/dist/index.shared.js +2 -2
  55. package/dist/ir.d.ts +1 -1
  56. package/dist/ir.js.map +1 -1
  57. package/dist/renderGenerativeUI.d.ts.map +1 -1
  58. package/dist/renderGenerativeUI.js +12 -1
  59. package/dist/renderGenerativeUI.js.map +1 -1
  60. package/dist/slack/constants.d.ts +2 -0
  61. package/dist/slack/constants.d.ts.map +1 -1
  62. package/dist/slack/constants.js +3 -1
  63. package/dist/slack/constants.js.map +1 -1
  64. package/dist/slack/decodeBlockAction.d.ts +3 -1
  65. package/dist/slack/decodeBlockAction.d.ts.map +1 -1
  66. package/dist/slack/decodeBlockAction.js +58 -7
  67. package/dist/slack/decodeBlockAction.js.map +1 -1
  68. package/dist/slack/fromSlackBlocks.d.ts.map +1 -1
  69. package/dist/slack/fromSlackBlocks.js +20 -3
  70. package/dist/slack/fromSlackBlocks.js.map +1 -1
  71. package/dist/slack/toSlackBlocks.d.ts.map +1 -1
  72. package/dist/slack/toSlackBlocks.js +187 -19
  73. package/dist/slack/toSlackBlocks.js.map +1 -1
  74. package/dist/slack/types.d.ts +4 -0
  75. package/dist/slack/types.d.ts.map +1 -1
  76. package/dist/teams/constants.d.ts +1 -1
  77. package/dist/teams/constants.d.ts.map +1 -1
  78. package/dist/teams/constants.js +1 -1
  79. package/dist/teams/constants.js.map +1 -1
  80. package/dist/teams/decodeSubmitData.d.ts +4 -0
  81. package/dist/teams/decodeSubmitData.d.ts.map +1 -1
  82. package/dist/teams/decodeSubmitData.js +6 -1
  83. package/dist/teams/decodeSubmitData.js.map +1 -1
  84. package/dist/teams/toAdaptiveCard.d.ts +5 -4
  85. package/dist/teams/toAdaptiveCard.d.ts.map +1 -1
  86. package/dist/teams/toAdaptiveCard.js +56 -17
  87. package/dist/teams/toAdaptiveCard.js.map +1 -1
  88. package/dist/teams/types.d.ts +4 -1
  89. package/dist/teams/types.d.ts.map +1 -1
  90. package/dist/vocabulary/alert.d.ts +9 -2
  91. package/dist/vocabulary/alert.d.ts.map +1 -1
  92. package/dist/vocabulary/alert.js +116 -19
  93. package/dist/vocabulary/alert.js.map +1 -1
  94. package/dist/vocabulary/collectFormValues.d.ts +2 -1
  95. package/dist/vocabulary/collectFormValues.d.ts.map +1 -1
  96. package/dist/vocabulary/collectFormValues.js +10 -3
  97. package/dist/vocabulary/collectFormValues.js.map +1 -1
  98. package/dist/vocabulary/data.d.ts +22 -5
  99. package/dist/vocabulary/data.d.ts.map +1 -1
  100. package/dist/vocabulary/data.js +278 -83
  101. package/dist/vocabulary/data.js.map +1 -1
  102. package/dist/vocabulary/dispatch.d.ts +3 -2
  103. package/dist/vocabulary/dispatch.d.ts.map +1 -1
  104. package/dist/vocabulary/dispatch.js +33 -4
  105. package/dist/vocabulary/dispatch.js.map +1 -1
  106. package/dist/vocabulary/fact.d.ts +8 -1
  107. package/dist/vocabulary/fact.d.ts.map +1 -1
  108. package/dist/vocabulary/fact.js +37 -11
  109. package/dist/vocabulary/fact.js.map +1 -1
  110. package/dist/vocabulary/form.d.ts.map +1 -1
  111. package/dist/vocabulary/form.js +3 -3
  112. package/dist/vocabulary/form.js.map +1 -1
  113. package/dist/vocabulary/formatValue.d.ts +7 -0
  114. package/dist/vocabulary/formatValue.d.ts.map +1 -0
  115. package/dist/vocabulary/formatValue.js +76 -0
  116. package/dist/vocabulary/formatValue.js.map +1 -0
  117. package/dist/vocabulary/icon.d.ts +1 -1
  118. package/dist/vocabulary/interactive.d.ts +137 -8
  119. package/dist/vocabulary/interactive.d.ts.map +1 -1
  120. package/dist/vocabulary/interactive.js +404 -103
  121. package/dist/vocabulary/interactive.js.map +1 -1
  122. package/dist/vocabulary/layout.d.ts.map +1 -1
  123. package/dist/vocabulary/layout.js +4 -4
  124. package/dist/vocabulary/layout.js.map +1 -1
  125. package/dist/vocabulary/list.js +2 -2
  126. package/dist/vocabulary/list.js.map +1 -1
  127. package/dist/vocabulary/text.d.ts +1 -1
  128. package/package.json +6 -3
  129. package/src/JSONGenerativeUI.client.tsx +84 -40
  130. package/src/JSONGenerativeUI.test.tsx +964 -68
  131. package/src/RadioGroupScope.server.test.tsx +24 -0
  132. package/src/RadioGroupScope.tsx +34 -0
  133. package/src/a2ui/BindingContext.ts +26 -0
  134. package/src/a2ui/PresentRenderer.tsx +83 -0
  135. package/src/a2ui/convert.test.ts +1982 -145
  136. package/src/a2ui/convert.ts +677 -137
  137. package/src/a2ui/dataModel.ts +69 -0
  138. package/src/a2ui/reducer.test.ts +35 -0
  139. package/src/a2ui/reducer.ts +5 -4
  140. package/src/a2ui/types.ts +9 -2
  141. package/src/a2ui/valueFunctions.test.ts +271 -0
  142. package/src/a2ui/valueFunctions.ts +523 -0
  143. package/src/actionRegistry.ts +1 -1
  144. package/src/answeredValues.test.ts +33 -0
  145. package/src/answeredValues.tsx +70 -0
  146. package/src/constants.ts +4 -0
  147. package/src/fieldReferences.test.ts +66 -0
  148. package/src/fieldReferences.ts +83 -0
  149. package/src/generativeUIToJSX.test.ts +18 -0
  150. package/src/generativeUIToJSX.ts +4 -6
  151. package/src/index.server.test.ts +106 -0
  152. package/src/ir.ts +1 -1
  153. package/src/renderGenerativeUI.test.tsx +14 -5
  154. package/src/renderGenerativeUI.tsx +30 -1
  155. package/src/slack/a2uiSlack.test.ts +198 -0
  156. package/src/slack/constants.ts +3 -0
  157. package/src/slack/decodeBlockAction.test.ts +98 -0
  158. package/src/slack/decodeBlockAction.ts +110 -17
  159. package/src/slack/fromSlackBlocks.test.ts +222 -3
  160. package/src/slack/fromSlackBlocks.ts +53 -2
  161. package/src/slack/toSlackBlocks.test.ts +682 -3
  162. package/src/slack/toSlackBlocks.ts +374 -23
  163. package/src/slack/types.ts +4 -0
  164. package/src/teams/constants.ts +1 -1
  165. package/src/teams/decodeSubmitData.test.ts +33 -0
  166. package/src/teams/decodeSubmitData.ts +9 -1
  167. package/src/teams/toAdaptiveCard.test.ts +219 -0
  168. package/src/teams/toAdaptiveCard.ts +93 -19
  169. package/src/teams/types.ts +4 -1
  170. package/src/vocabulary/alert.test.tsx +288 -7
  171. package/src/vocabulary/alert.tsx +168 -26
  172. package/src/vocabulary/collectFormValues.test.ts +28 -1
  173. package/src/vocabulary/collectFormValues.ts +25 -5
  174. package/src/vocabulary/data.test.tsx +248 -6
  175. package/src/vocabulary/data.tsx +398 -100
  176. package/src/vocabulary/dispatch.ts +63 -2
  177. package/src/vocabulary/fact.test.tsx +67 -0
  178. package/src/vocabulary/fact.tsx +40 -9
  179. package/src/vocabulary/form.tsx +7 -2
  180. package/src/vocabulary/formatValue.test.ts +72 -0
  181. package/src/vocabulary/formatValue.ts +127 -0
  182. package/src/vocabulary/index.test.ts +2 -0
  183. package/src/vocabulary/interactive.dispatch.test.tsx +167 -79
  184. package/src/vocabulary/interactive.dom.test.tsx +1699 -0
  185. package/src/vocabulary/interactive.test.tsx +60 -4
  186. package/src/vocabulary/interactive.tsx +770 -151
  187. package/src/vocabulary/layout.test.tsx +6 -4
  188. package/src/vocabulary/layout.tsx +13 -2
  189. package/src/vocabulary/list.tsx +2 -2
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2025 AgentbaseAI Inc.
3
+ Copyright (c) 2026 AgentbaseAI Inc.
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -1 +1 @@
1
- {"version":3,"file":"JSONGenerativeUI.client.d.ts","sourceRoot":"","sources":["../src/JSONGenerativeUI.client.tsx"],"names":[],"mappings":"AAGA,OAAO,EAGL,KAAK,uBAAuB,EAE5B,KAAK,WAAW,EAChB,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACpB,qCAAkC;AAanC;;;;;;;;;;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,CAqDrB;IAEF,OAAO,CAAC,OAAO,CAAC,EAAE,kBAAkB,GAAG,WAAW;IASlD,UAAU,IAAI,cAAc;CAO7B"}
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,14 +1,13 @@
1
+ import { renderGenerativeUI } from "./renderGenerativeUI.js";
2
+ import { A2uiPresentRenderer } from "./a2ui/PresentRenderer.js";
3
+ import { AnsweredValuesProvider, findAnsweredValues } from "./answeredValues.js";
1
4
  import { buildPresentParameters } from "./buildPresentParameters.js";
2
5
  import { presentToolBase, promptUserToolBase } from "./JSONGenerativeUI.shared.js";
3
- import { renderGenerativeUI } from "./renderGenerativeUI.js";
6
+ import { getPartialJsonObjectMeta } from "assistant-stream/utils";
4
7
  import { jsx } from "react/jsx-runtime";
5
8
  //#region src/JSONGenerativeUI.client.tsx
6
- /** Maps a tool-call part status to the generative-UI streaming status. Only a
7
- * `complete` call has fully-arrived args; `running` and `incomplete`
8
- * (aborted/errored, so args may be partial) both render as `"streaming"` so a
9
- * non-streaming component is never handed partial props. */
10
- function uiStatus(status) {
11
- return status.type === "complete" ? "done" : "streaming";
9
+ function uiStatus(status, args) {
10
+ return status.type === "complete" || status.type === "requires-action" && getPartialJsonObjectMeta(args)?.state !== "partial" ? "done" : "streaming";
12
11
  }
13
12
  /**
14
13
  * Client build of {@link JSONGenerativeUI}, resolved through the package's
@@ -36,9 +35,10 @@ var JSONGenerativeUI = class {
36
35
  * between top-level blocks, which the host's message container does not
37
36
  * provide, and stays out of the way while it has nothing to show.
38
37
  */
39
- render = ({ args, status, addResult, result, toolCallId, unstable_recordInteraction }, completesPrompt = false) => {
38
+ render = ({ args, status, addResult, result, toolCallId, artifact, unstable_recordInteraction, unstable_interactions }, completesPrompt = false) => {
39
+ const answered = completesPrompt && result !== void 0;
40
40
  const actions = this.actions;
41
- const dispatch = actions ? (action) => {
41
+ const dispatch = !answered && actions ? (action) => {
42
42
  if (unstable_recordInteraction) try {
43
43
  unstable_recordInteraction({
44
44
  type: "action",
@@ -54,12 +54,29 @@ var JSONGenerativeUI = class {
54
54
  }).catch(() => {});
55
55
  return actionResult;
56
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
+ });
57
70
  return /* @__PURE__ */ jsx("div", {
58
71
  "data-aui": "root",
59
- children: renderGenerativeUI(args, this.library, {
60
- status: uiStatus(status),
61
- ...dispatch ? { dispatch } : {}
62
- })
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
63
80
  });
64
81
  };
65
82
  present(options) {
@@ -1 +1 @@
1
- {"version":3,"file":"JSONGenerativeUI.client.js","names":[],"sources":["../src/JSONGenerativeUI.client.tsx"],"sourcesContent":["import type { ToolCallMessagePartProps } from \"@assistant-ui/react\";\nimport type { ReactNode } from \"react\";\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/** Maps a tool-call part status to the generative-UI streaming status. Only a\n * `complete` call has fully-arrived args; `running` and `incomplete`\n * (aborted/errored, so args may be partial) both render as `\"streaming\"` so a\n * non-streaming component is never handed partial props. */\nfunction uiStatus(status: { type: string }): GenerativeUIStatus {\n return status.type === \"complete\" ? \"done\" : \"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 unstable_recordInteraction,\n }: ToolCallMessagePartProps<Record<string, unknown>, any>,\n completesPrompt = false,\n ): ReactNode => {\n const actions = this.actions;\n const dispatch = 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 return (\n <div data-aui=\"root\">\n {renderGenerativeUI(args, this.library, {\n status: uiStatus(status),\n ...(dispatch ? { dispatch } : {}),\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,SAAS,QAA8C;CAC9D,OAAO,OAAO,SAAS,aAAa,SAAS;AAC/C;;;;;;;;;;;;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,8BAEF,kBAAkB,UACJ;EACd,MAAM,UAAU,KAAK;EACrB,MAAM,WAAW,WACZ,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;EAEJ,OACE,oBAAC,OAAD;GAAK,YAAS;GACX,UAAA,mBAAmB,MAAM,KAAK,SAAS;IACtC,QAAQ,SAAS,MAAM;IACvB,GAAI,WAAW,EAAE,SAAS,IAAI,CAAC;GACjC,CAAC;EACE,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
+ {"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"}
@@ -0,0 +1,6 @@
1
+ import * as React from "react";
2
+ export declare const RadioGroupScope: ({ children, }: {
3
+ children: React.ReactNode;
4
+ }) => string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | React.JSX.Element | null | undefined;
5
+ export declare const useRadioGroupName: (name: string | undefined) => string;
6
+ //# sourceMappingURL=RadioGroupScope.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RadioGroupScope.d.ts","sourceRoot":"","sources":["../src/RadioGroupScope.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAa/B,eAAO,MAAM,eAAe,GAAI,eAE7B;IACD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,oSAQA,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,MAAM,MAAM,GAAG,SAAS,WAMzD,CAAC"}
@@ -0,0 +1,25 @@
1
+ import * as React from "react";
2
+ import { jsx } from "react/jsx-runtime";
3
+ //#region src/RadioGroupScope.tsx
4
+ let radioGroupContext;
5
+ const supportsContext = typeof React.createContext === "function";
6
+ const useScopeId = supportsContext ? React.useId : () => void 0;
7
+ const useScopeContext = supportsContext ? React.useContext : () => void 0;
8
+ const getRadioGroupContext = () => supportsContext ? radioGroupContext ??= React.createContext(void 0) : void 0;
9
+ const RadioGroupScope = ({ children }) => {
10
+ const scopeId = useScopeId();
11
+ const Context = getRadioGroupContext();
12
+ return Context ? /* @__PURE__ */ jsx(Context.Provider, {
13
+ value: scopeId,
14
+ children
15
+ }) : children;
16
+ };
17
+ const useRadioGroupName = (name) => {
18
+ const scopeId = useScopeContext(getRadioGroupContext());
19
+ const groupId = React.useId();
20
+ return scopeId !== void 0 && name != null ? JSON.stringify([scopeId, name]) : name ?? groupId;
21
+ };
22
+ //#endregion
23
+ export { RadioGroupScope, useRadioGroupName };
24
+
25
+ //# sourceMappingURL=RadioGroupScope.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RadioGroupScope.js","names":[],"sources":["../src/RadioGroupScope.tsx"],"sourcesContent":["import * as React from \"react\";\n\nlet radioGroupContext: React.Context<string | undefined> | undefined;\nconst supportsContext = typeof React.createContext === \"function\";\nconst useScopeId = supportsContext ? React.useId : () => undefined;\nconst useScopeContext = supportsContext ? React.useContext : () => undefined;\n\n// Vocabulary schemas are also imported under React's server condition.\nconst getRadioGroupContext = () =>\n supportsContext\n ? (radioGroupContext ??= React.createContext<string | undefined>(undefined))\n : undefined;\n\nexport const RadioGroupScope = ({\n children,\n}: {\n children: React.ReactNode;\n}) => {\n const scopeId = useScopeId();\n const Context = getRadioGroupContext();\n return Context ? (\n <Context.Provider value={scopeId}>{children}</Context.Provider>\n ) : (\n children\n );\n};\n\nexport const useRadioGroupName = (name: string | undefined) => {\n const scopeId = useScopeContext(getRadioGroupContext()!);\n const groupId = React.useId();\n return scopeId !== undefined && name != null\n ? JSON.stringify([scopeId, name])\n : (name ?? groupId);\n};\n"],"mappings":";;;AAEA,IAAI;AACJ,MAAM,kBAAkB,OAAO,MAAM,kBAAkB;AACvD,MAAM,aAAa,kBAAkB,MAAM,cAAc,KAAA;AACzD,MAAM,kBAAkB,kBAAkB,MAAM,mBAAmB,KAAA;AAGnE,MAAM,6BACJ,kBACK,sBAAsB,MAAM,cAAkC,KAAA,CAAS,IACxE,KAAA;AAEN,MAAa,mBAAmB,EAC9B,eAGI;CACJ,MAAM,UAAU,WAAW;CAC3B,MAAM,UAAU,qBAAqB;CACrC,OAAO,UACL,oBAAC,QAAQ,UAAT;EAAkB,OAAO;EAAU;CAA2B,CAAA,IAE9D;AAEJ;AAEA,MAAa,qBAAqB,SAA6B;CAC7D,MAAM,UAAU,gBAAgB,qBAAqB,CAAE;CACvD,MAAM,UAAU,MAAM,MAAM;CAC5B,OAAO,YAAY,KAAA,KAAa,QAAQ,OACpC,KAAK,UAAU,CAAC,SAAS,IAAI,CAAC,IAC7B,QAAQ;AACf"}
@@ -0,0 +1,11 @@
1
+ import * as React from "react";
2
+ export type A2uiBinding = {
3
+ readonly value: unknown;
4
+ readonly arrayValue: boolean;
5
+ };
6
+ export declare const A2uiBindingContext: React.Context<{
7
+ readonly fields: ReadonlyMap<string, A2uiBinding>;
8
+ readonly update: (path: string, value: unknown) => void;
9
+ } | undefined> | undefined;
10
+ export declare const useA2uiBinding: (name: string | undefined) => ((value: unknown) => void) | undefined;
11
+ //# sourceMappingURL=BindingContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BindingContext.d.ts","sourceRoot":"","sources":["../../src/a2ui/BindingContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;CAC9B,CAAC;AAEF,eAAO,MAAM,kBAAkB;qBAIF,WAAW,CAAC,MAAM,EAAE,WAAW,CAAC;qBAChC,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,KAAK,IAAI;0BAIpD,CAAC;AAEhB,eAAO,MAAM,cAAc,GAAI,MAAM,MAAM,GAAG,SAAS,cAIzC,OAAO,sBAGpB,CAAC"}
@@ -0,0 +1,12 @@
1
+ import * as React from "react";
2
+ //#region src/a2ui/BindingContext.ts
3
+ const A2uiBindingContext = typeof React.createContext === "function" ? React.createContext(void 0) : void 0;
4
+ const useA2uiBinding = (name) => {
5
+ const context = React.useContext(A2uiBindingContext);
6
+ const binding = name === void 0 ? void 0 : context?.fields.get(name);
7
+ return context && binding && name !== void 0 ? (value) => context.update(name, binding.arrayValue ? [value] : value) : void 0;
8
+ };
9
+ //#endregion
10
+ export { A2uiBindingContext, useA2uiBinding };
11
+
12
+ //# sourceMappingURL=BindingContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BindingContext.js","names":[],"sources":["../../src/a2ui/BindingContext.ts"],"sourcesContent":["import * as React from \"react\";\n\nexport type A2uiBinding = {\n readonly value: unknown;\n readonly arrayValue: boolean;\n};\n\nexport const A2uiBindingContext =\n typeof React.createContext === \"function\"\n ? React.createContext<\n | {\n readonly fields: ReadonlyMap<string, A2uiBinding>;\n readonly update: (path: string, value: unknown) => void;\n }\n | undefined\n >(undefined)\n : undefined;\n\nexport const useA2uiBinding = (name: string | undefined) => {\n const context = React.useContext(A2uiBindingContext!);\n const binding = name === undefined ? undefined : context?.fields.get(name);\n return context && binding && name !== undefined\n ? (value: unknown) =>\n context.update(name, binding.arrayValue ? [value] : value)\n : undefined;\n};\n"],"mappings":";;AAOA,MAAa,qBACX,OAAO,MAAM,kBAAkB,aAC3B,MAAM,cAMJ,KAAA,CAAS,IACX,KAAA;AAEN,MAAa,kBAAkB,SAA6B;CAC1D,MAAM,UAAU,MAAM,WAAW,kBAAmB;CACpD,MAAM,UAAU,SAAS,KAAA,IAAY,KAAA,IAAY,SAAS,OAAO,IAAI,IAAI;CACzE,OAAO,WAAW,WAAW,SAAS,KAAA,KACjC,UACC,QAAQ,OAAO,MAAM,QAAQ,aAAa,CAAC,KAAK,IAAI,KAAK,IAC3D,KAAA;AACN"}
@@ -0,0 +1,11 @@
1
+ import * as React from "react";
2
+ import type { GenerativeUIDispatch, GenerativeUILibrary, GenerativeUIStatus } from "../types.js";
3
+ export declare function A2uiPresentRenderer({ surfaceId, operations, fallback, library, status, dispatch, }: {
4
+ surfaceId: string;
5
+ operations: unknown;
6
+ fallback: unknown;
7
+ library: GenerativeUILibrary;
8
+ status: GenerativeUIStatus;
9
+ dispatch?: GenerativeUIDispatch;
10
+ }): React.JSX.Element;
11
+ //# sourceMappingURL=PresentRenderer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PresentRenderer.d.ts","sourceRoot":"","sources":["../../src/a2ui/PresentRenderer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EACV,oBAAoB,EACpB,mBAAmB,EACnB,kBAAkB,EACnB,oBAAiB;AAMlB,wBAAgB,mBAAmB,CAAC,EAClC,SAAS,EACT,UAAU,EACV,QAAQ,EACR,OAAO,EACP,MAAM,EACN,QAAQ,GACT,EAAE;IACD,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,OAAO,CAAC;IACpB,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,mBAAmB,CAAC;IAC7B,MAAM,EAAE,kBAAkB,CAAC;IAC3B,QAAQ,CAAC,EAAE,oBAAoB,CAAC;CACjC,qBAwDA"}
@@ -0,0 +1,39 @@
1
+ import { renderGenerativeUI } from "../renderGenerativeUI.js";
2
+ import { A2uiBindingContext } from "./BindingContext.js";
3
+ import { applyA2uiOperations, setAtPointer } from "./reducer.js";
4
+ import { equalData, reconcileDataModel, resolvePointer } from "./dataModel.js";
5
+ import { createLiveSurfaceConverter } from "./convert.js";
6
+ import * as React from "react";
7
+ import { jsx } from "react/jsx-runtime";
8
+ //#region src/a2ui/PresentRenderer.tsx
9
+ function A2uiPresentRenderer({ surfaceId, operations, fallback, library, status, dispatch }) {
10
+ const surface = React.useMemo(() => applyA2uiOperations(/* @__PURE__ */ new Map(), operations).state.get(surfaceId), [operations, surfaceId]);
11
+ const incoming = surface?.dataModel;
12
+ const [local, setLocal] = React.useState(() => ({
13
+ incoming,
14
+ value: incoming,
15
+ editedPaths: /* @__PURE__ */ new Set()
16
+ }));
17
+ const model = Object.is(incoming, local.incoming) ? local : reconcileDataModel(local.incoming, incoming, local.value, local.editedPaths);
18
+ if (model !== local) setLocal(model);
19
+ const convert = React.useMemo(() => surface && createLiveSurfaceConverter(surface), [surface]);
20
+ const converted = React.useMemo(() => convert?.(model.value), [convert, model.value]);
21
+ return /* @__PURE__ */ jsx(A2uiBindingContext.Provider, {
22
+ value: converted ? {
23
+ fields: converted.bindings,
24
+ update: (path, value) => setLocal((current) => equalData(resolvePointer(current.value, path), value) ? current : {
25
+ ...current,
26
+ value: setAtPointer(current.value, path, value, false).value,
27
+ editedPaths: /* @__PURE__ */ new Set([...current.editedPaths, path])
28
+ })
29
+ } : void 0,
30
+ children: renderGenerativeUI(converted?.spec ?? fallback, library, {
31
+ status,
32
+ ...dispatch ? { dispatch } : {}
33
+ })
34
+ });
35
+ }
36
+ //#endregion
37
+ export { A2uiPresentRenderer };
38
+
39
+ //# sourceMappingURL=PresentRenderer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PresentRenderer.js","names":["BindingContext"],"sources":["../../src/a2ui/PresentRenderer.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { renderGenerativeUI } from \"../renderGenerativeUI\";\nimport type {\n GenerativeUIDispatch,\n GenerativeUILibrary,\n GenerativeUIStatus,\n} from \"../types\";\nimport { A2uiBindingContext } from \"./BindingContext\";\nimport { equalData, reconcileDataModel, resolvePointer } from \"./dataModel\";\nimport { applyA2uiOperations, setAtPointer } from \"./reducer\";\nimport { createLiveSurfaceConverter } from \"./convert\";\n\nexport function A2uiPresentRenderer({\n surfaceId,\n operations,\n fallback,\n library,\n status,\n dispatch,\n}: {\n surfaceId: string;\n operations: unknown;\n fallback: unknown;\n library: GenerativeUILibrary;\n status: GenerativeUIStatus;\n dispatch?: GenerativeUIDispatch;\n}) {\n const surface = React.useMemo(\n () => applyA2uiOperations(new Map(), operations).state.get(surfaceId),\n [operations, surfaceId],\n );\n const incoming = surface?.dataModel;\n const [local, setLocal] = React.useState(() => ({\n incoming,\n value: incoming,\n editedPaths: new Set<string>(),\n }));\n const model = Object.is(incoming, local.incoming)\n ? local\n : reconcileDataModel(\n local.incoming,\n incoming,\n local.value,\n local.editedPaths,\n );\n if (model !== local) setLocal(model);\n const convert = React.useMemo(\n () => surface && createLiveSurfaceConverter(surface),\n [surface],\n );\n const converted = React.useMemo(\n () => convert?.(model.value),\n [convert, model.value],\n );\n const BindingContext = A2uiBindingContext!;\n return (\n <BindingContext.Provider\n value={\n converted\n ? {\n fields: converted.bindings,\n update: (path, value) =>\n setLocal((current) =>\n equalData(resolvePointer(current.value, path), value)\n ? current\n : {\n ...current,\n value: setAtPointer(current.value, path, value, false)\n .value,\n editedPaths: new Set([...current.editedPaths, path]),\n },\n ),\n }\n : undefined\n }\n >\n {renderGenerativeUI(converted?.spec ?? fallback, library, {\n status,\n ...(dispatch ? { dispatch } : {}),\n })}\n </BindingContext.Provider>\n );\n}\n"],"mappings":";;;;;;;;AAYA,SAAgB,oBAAoB,EAClC,WACA,YACA,UACA,SACA,QACA,YAQC;CACD,MAAM,UAAU,MAAM,cACd,oCAAoB,IAAI,IAAI,GAAG,UAAU,CAAC,CAAC,MAAM,IAAI,SAAS,GACpE,CAAC,YAAY,SAAS,CACxB;CACA,MAAM,WAAW,SAAS;CAC1B,MAAM,CAAC,OAAO,YAAY,MAAM,gBAAgB;EAC9C;EACA,OAAO;EACP,6BAAa,IAAI,IAAY;CAC/B,EAAE;CACF,MAAM,QAAQ,OAAO,GAAG,UAAU,MAAM,QAAQ,IAC5C,QACA,mBACE,MAAM,UACN,UACA,MAAM,OACN,MAAM,WACR;CACJ,IAAI,UAAU,OAAO,SAAS,KAAK;CACnC,MAAM,UAAU,MAAM,cACd,WAAW,2BAA2B,OAAO,GACnD,CAAC,OAAO,CACV;CACA,MAAM,YAAY,MAAM,cAChB,UAAU,MAAM,KAAK,GAC3B,CAAC,SAAS,MAAM,KAAK,CACvB;CAEA,OACE,oBAACA,mBAAe,UAAhB;EACE,OACE,YACI;GACE,QAAQ,UAAU;GAClB,SAAS,MAAM,UACb,UAAU,YACR,UAAU,eAAe,QAAQ,OAAO,IAAI,GAAG,KAAK,IAChD,UACA;IACE,GAAG;IACH,OAAO,aAAa,QAAQ,OAAO,MAAM,OAAO,KAAK,CAAC,CACnD;IACH,6BAAa,IAAI,IAAI,CAAC,GAAG,QAAQ,aAAa,IAAI,CAAC;GACrD,CACN;EACJ,IACA,KAAA;EAGL,UAAA,mBAAmB,WAAW,QAAQ,UAAU,SAAS;GACxD;GACA,GAAI,WAAW,EAAE,SAAS,IAAI,CAAC;EACjC,CAAC;CACsB,CAAA;AAE7B"}
@@ -1,9 +1,15 @@
1
1
  import { type UIElement } from "../ir.js";
2
2
  import { type A2uiSurfaceState } from "./types.js";
3
+ import type { A2uiBinding } from "./BindingContext.js";
3
4
  export declare function convertSurfaceToUISpec(surface: A2uiSurfaceState, options?: {
4
5
  readonly keepUnknownComponents?: boolean;
5
6
  }): {
6
7
  spec: UIElement | null;
7
8
  warnings: string[];
8
9
  };
10
+ export declare const createLiveSurfaceConverter: (surface: A2uiSurfaceState) => (dataModel: unknown) => {
11
+ bindings: Map<string, A2uiBinding>;
12
+ spec: UIElement | null;
13
+ warnings: string[];
14
+ };
9
15
  //# sourceMappingURL=convert.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"convert.d.ts","sourceRoot":"","sources":["../../src/a2ui/convert.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,SAAS,EAAE,iBAAc;AACnD,OAAO,EAEL,KAAK,gBAAgB,EAEtB,mBAAgB;AA8kBjB,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,gBAAgB,EACzB,OAAO,GAAE;IAAE,QAAQ,CAAC,qBAAqB,CAAC,EAAE,OAAO,CAAA;CAAO,GACzD;IACD,IAAI,EAAE,SAAS,GAAG,IAAI,CAAC;IACvB,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB,CA+BA"}
1
+ {"version":3,"file":"convert.d.ts","sourceRoot":"","sources":["../../src/a2ui/convert.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,SAAS,EAAE,iBAAc;AACnD,OAAO,EAAmB,KAAK,gBAAgB,EAAE,mBAAgB;AAMjE,OAAO,KAAK,EAAE,WAAW,EAAE,4BAAyB;AA0iCpD,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,gBAAgB,EACzB,OAAO,GAAE;IACP,QAAQ,CAAC,qBAAqB,CAAC,EAAE,OAAO,CAAC;CACrC,GACL;IACD,IAAI,EAAE,SAAS,GAAG,IAAI,CAAC;IACvB,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB,CAEA;AAED,eAAO,MAAM,0BAA0B,GAAI,SAAS,gBAAgB,MAG1D,WAAW,OAAO;;UAqBjB,SAAS,GAAG,IAAI;cAAY,MAAM,EAAE;CAT9C,CAAC"}