@copilotkit/a2ui-renderer 1.53.0 → 1.53.1-next.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 (181) hide show
  1. package/dist/A2UIViewer.d.cts +1 -1
  2. package/dist/A2UIViewer.d.mts +1 -1
  3. package/dist/a2ui-types.cjs +9 -0
  4. package/dist/a2ui-types.cjs.map +1 -0
  5. package/dist/a2ui-types.d.cts +9 -0
  6. package/dist/a2ui-types.d.cts.map +1 -0
  7. package/dist/a2ui-types.d.mts +9 -0
  8. package/dist/a2ui-types.d.mts.map +1 -0
  9. package/dist/a2ui-types.mjs +8 -0
  10. package/dist/a2ui-types.mjs.map +1 -0
  11. package/dist/index.cjs +74 -2
  12. package/dist/index.d.cts +35 -2
  13. package/dist/index.d.cts.map +1 -1
  14. package/dist/index.d.mts +35 -2
  15. package/dist/index.d.mts.map +1 -1
  16. package/dist/index.mjs +33 -2
  17. package/dist/index.umd.js +96 -127
  18. package/dist/index.umd.js.map +1 -1
  19. package/dist/react-renderer/components/content/AudioPlayer.d.cts +12 -0
  20. package/dist/react-renderer/components/content/AudioPlayer.d.cts.map +1 -0
  21. package/dist/react-renderer/components/content/AudioPlayer.d.mts +12 -0
  22. package/dist/react-renderer/components/content/AudioPlayer.d.mts.map +1 -0
  23. package/dist/react-renderer/components/content/Divider.d.cts +17 -0
  24. package/dist/react-renderer/components/content/Divider.d.cts.map +1 -0
  25. package/dist/react-renderer/components/content/Divider.d.mts +17 -0
  26. package/dist/react-renderer/components/content/Divider.d.mts.map +1 -0
  27. package/dist/react-renderer/components/content/Icon.d.cts +20 -0
  28. package/dist/react-renderer/components/content/Icon.d.cts.map +1 -0
  29. package/dist/react-renderer/components/content/Icon.d.mts +20 -0
  30. package/dist/react-renderer/components/content/Icon.d.mts.map +1 -0
  31. package/dist/react-renderer/components/content/Image.d.cts +15 -0
  32. package/dist/react-renderer/components/content/Image.d.cts.map +1 -0
  33. package/dist/react-renderer/components/content/Image.d.mts +15 -0
  34. package/dist/react-renderer/components/content/Image.d.mts.map +1 -0
  35. package/dist/react-renderer/components/content/Text.d.cts +32 -0
  36. package/dist/react-renderer/components/content/Text.d.cts.map +1 -0
  37. package/dist/react-renderer/components/content/Text.d.mts +32 -0
  38. package/dist/react-renderer/components/content/Text.d.mts.map +1 -0
  39. package/dist/react-renderer/components/content/Video.d.cts +14 -0
  40. package/dist/react-renderer/components/content/Video.d.cts.map +1 -0
  41. package/dist/react-renderer/components/content/Video.d.mts +14 -0
  42. package/dist/react-renderer/components/content/Video.d.mts.map +1 -0
  43. package/dist/react-renderer/components/interactive/Button.d.cts +15 -0
  44. package/dist/react-renderer/components/interactive/Button.d.cts.map +1 -0
  45. package/dist/react-renderer/components/interactive/Button.d.mts +15 -0
  46. package/dist/react-renderer/components/interactive/Button.d.mts.map +1 -0
  47. package/dist/react-renderer/components/interactive/CheckBox.d.cts +14 -0
  48. package/dist/react-renderer/components/interactive/CheckBox.d.cts.map +1 -0
  49. package/dist/react-renderer/components/interactive/CheckBox.d.mts +14 -0
  50. package/dist/react-renderer/components/interactive/CheckBox.d.mts.map +1 -0
  51. package/dist/react-renderer/components/interactive/DateTimeInput.d.cts +14 -0
  52. package/dist/react-renderer/components/interactive/DateTimeInput.d.cts.map +1 -0
  53. package/dist/react-renderer/components/interactive/DateTimeInput.d.mts +14 -0
  54. package/dist/react-renderer/components/interactive/DateTimeInput.d.mts.map +1 -0
  55. package/dist/react-renderer/components/interactive/MultipleChoice.d.cts +15 -0
  56. package/dist/react-renderer/components/interactive/MultipleChoice.d.cts.map +1 -0
  57. package/dist/react-renderer/components/interactive/MultipleChoice.d.mts +15 -0
  58. package/dist/react-renderer/components/interactive/MultipleChoice.d.mts.map +1 -0
  59. package/dist/react-renderer/components/interactive/Slider.d.cts +14 -0
  60. package/dist/react-renderer/components/interactive/Slider.d.cts.map +1 -0
  61. package/dist/react-renderer/components/interactive/Slider.d.mts +14 -0
  62. package/dist/react-renderer/components/interactive/Slider.d.mts.map +1 -0
  63. package/dist/react-renderer/components/interactive/TextField.d.cts +14 -0
  64. package/dist/react-renderer/components/interactive/TextField.d.cts.map +1 -0
  65. package/dist/react-renderer/components/interactive/TextField.d.mts +14 -0
  66. package/dist/react-renderer/components/interactive/TextField.d.mts.map +1 -0
  67. package/dist/react-renderer/components/layout/Card.d.cts +21 -0
  68. package/dist/react-renderer/components/layout/Card.d.cts.map +1 -0
  69. package/dist/react-renderer/components/layout/Card.d.mts +21 -0
  70. package/dist/react-renderer/components/layout/Card.d.mts.map +1 -0
  71. package/dist/react-renderer/components/layout/Column.d.cts +14 -0
  72. package/dist/react-renderer/components/layout/Column.d.cts.map +1 -0
  73. package/dist/react-renderer/components/layout/Column.d.mts +14 -0
  74. package/dist/react-renderer/components/layout/Column.d.mts.map +1 -0
  75. package/dist/react-renderer/components/layout/List.d.cts +14 -0
  76. package/dist/react-renderer/components/layout/List.d.cts.map +1 -0
  77. package/dist/react-renderer/components/layout/List.d.mts +14 -0
  78. package/dist/react-renderer/components/layout/List.d.mts.map +1 -0
  79. package/dist/react-renderer/components/layout/Modal.d.cts +19 -0
  80. package/dist/react-renderer/components/layout/Modal.d.cts.map +1 -0
  81. package/dist/react-renderer/components/layout/Modal.d.mts +19 -0
  82. package/dist/react-renderer/components/layout/Modal.d.mts.map +1 -0
  83. package/dist/react-renderer/components/layout/Row.d.cts +14 -0
  84. package/dist/react-renderer/components/layout/Row.d.cts.map +1 -0
  85. package/dist/react-renderer/components/layout/Row.d.mts +14 -0
  86. package/dist/react-renderer/components/layout/Row.d.mts.map +1 -0
  87. package/dist/react-renderer/components/layout/Tabs.d.cts +12 -0
  88. package/dist/react-renderer/components/layout/Tabs.d.cts.map +1 -0
  89. package/dist/react-renderer/components/layout/Tabs.d.mts +12 -0
  90. package/dist/react-renderer/components/layout/Tabs.d.mts.map +1 -0
  91. package/dist/react-renderer/core/A2UIProvider.cjs +35 -0
  92. package/dist/react-renderer/core/A2UIProvider.cjs.map +1 -1
  93. package/dist/react-renderer/core/A2UIProvider.d.cts +91 -0
  94. package/dist/react-renderer/core/A2UIProvider.d.cts.map +1 -0
  95. package/dist/react-renderer/core/A2UIProvider.d.mts +91 -0
  96. package/dist/react-renderer/core/A2UIProvider.d.mts.map +1 -0
  97. package/dist/react-renderer/core/A2UIProvider.mjs +33 -1
  98. package/dist/react-renderer/core/A2UIProvider.mjs.map +1 -1
  99. package/dist/react-renderer/core/A2UIRenderer.d.cts +40 -0
  100. package/dist/react-renderer/core/A2UIRenderer.d.cts.map +1 -0
  101. package/dist/react-renderer/core/A2UIRenderer.d.mts +40 -0
  102. package/dist/react-renderer/core/A2UIRenderer.d.mts.map +1 -0
  103. package/dist/react-renderer/core/A2UIViewer.cjs +11 -0
  104. package/dist/react-renderer/core/A2UIViewer.d.cts +16 -0
  105. package/dist/react-renderer/core/A2UIViewer.d.cts.map +1 -0
  106. package/dist/react-renderer/core/A2UIViewer.d.mts +16 -0
  107. package/dist/react-renderer/core/A2UIViewer.d.mts.map +1 -0
  108. package/dist/react-renderer/core/A2UIViewer.mjs +11 -0
  109. package/dist/react-renderer/core/ComponentNode.d.cts +29 -0
  110. package/dist/react-renderer/core/ComponentNode.d.cts.map +1 -0
  111. package/dist/react-renderer/core/ComponentNode.d.mts +29 -0
  112. package/dist/react-renderer/core/ComponentNode.d.mts.map +1 -0
  113. package/dist/react-renderer/core/store.d.cts +41 -0
  114. package/dist/react-renderer/core/store.d.cts.map +1 -0
  115. package/dist/react-renderer/core/store.d.mts +41 -0
  116. package/dist/react-renderer/core/store.d.mts.map +1 -0
  117. package/dist/react-renderer/hooks/useA2UI.d.cts +50 -0
  118. package/dist/react-renderer/hooks/useA2UI.d.cts.map +1 -0
  119. package/dist/react-renderer/hooks/useA2UI.d.mts +50 -0
  120. package/dist/react-renderer/hooks/useA2UI.d.mts.map +1 -0
  121. package/dist/react-renderer/hooks/useA2UIComponent.d.cts +56 -0
  122. package/dist/react-renderer/hooks/useA2UIComponent.d.cts.map +1 -0
  123. package/dist/react-renderer/hooks/useA2UIComponent.d.mts +56 -0
  124. package/dist/react-renderer/hooks/useA2UIComponent.d.mts.map +1 -0
  125. package/dist/react-renderer/index.cjs +31 -0
  126. package/dist/react-renderer/index.d.cts +32 -0
  127. package/dist/react-renderer/index.d.mts +32 -0
  128. package/dist/react-renderer/index.mjs +33 -0
  129. package/dist/react-renderer/lib/utils.d.cts +18 -0
  130. package/dist/react-renderer/lib/utils.d.cts.map +1 -0
  131. package/dist/react-renderer/lib/utils.d.mts +18 -0
  132. package/dist/react-renderer/lib/utils.d.mts.map +1 -0
  133. package/dist/react-renderer/registry/ComponentRegistry.d.cts +82 -0
  134. package/dist/react-renderer/registry/ComponentRegistry.d.cts.map +1 -0
  135. package/dist/react-renderer/registry/ComponentRegistry.d.mts +82 -0
  136. package/dist/react-renderer/registry/ComponentRegistry.d.mts.map +1 -0
  137. package/dist/react-renderer/registry/defaultCatalog.cjs +1 -0
  138. package/dist/react-renderer/registry/defaultCatalog.d.cts +17 -0
  139. package/dist/react-renderer/registry/defaultCatalog.d.cts.map +1 -0
  140. package/dist/react-renderer/registry/defaultCatalog.d.mts +17 -0
  141. package/dist/react-renderer/registry/defaultCatalog.d.mts.map +1 -0
  142. package/dist/react-renderer/registry/defaultCatalog.mjs +1 -1
  143. package/dist/react-renderer/styles/index.cjs +10 -0
  144. package/dist/react-renderer/styles/index.cjs.map +1 -1
  145. package/dist/react-renderer/styles/index.d.cts +14 -0
  146. package/dist/react-renderer/styles/index.d.cts.map +1 -0
  147. package/dist/react-renderer/styles/index.d.mts +26 -0
  148. package/dist/react-renderer/styles/index.d.mts.map +1 -0
  149. package/dist/react-renderer/styles/index.mjs +10 -1
  150. package/dist/react-renderer/styles/index.mjs.map +1 -1
  151. package/dist/react-renderer/theme/ThemeContext.cjs +9 -0
  152. package/dist/react-renderer/theme/ThemeContext.cjs.map +1 -1
  153. package/dist/react-renderer/theme/ThemeContext.d.cts +37 -0
  154. package/dist/react-renderer/theme/ThemeContext.d.cts.map +1 -0
  155. package/dist/react-renderer/theme/ThemeContext.d.mts +37 -0
  156. package/dist/react-renderer/theme/ThemeContext.d.mts.map +1 -0
  157. package/dist/react-renderer/theme/ThemeContext.mjs +9 -1
  158. package/dist/react-renderer/theme/ThemeContext.mjs.map +1 -1
  159. package/dist/react-renderer/theme/litTheme.cjs +1 -0
  160. package/dist/react-renderer/theme/litTheme.d.cts +12 -0
  161. package/dist/react-renderer/theme/litTheme.d.cts.map +1 -0
  162. package/dist/react-renderer/theme/litTheme.d.mts +12 -0
  163. package/dist/react-renderer/theme/litTheme.d.mts.map +1 -0
  164. package/dist/react-renderer/theme/litTheme.mjs +1 -1
  165. package/dist/react-renderer/theme/utils.d.cts +26 -0
  166. package/dist/react-renderer/theme/utils.d.cts.map +1 -0
  167. package/dist/react-renderer/theme/utils.d.mts +26 -0
  168. package/dist/react-renderer/theme/utils.d.mts.map +1 -0
  169. package/dist/react-renderer/types.d.cts +50 -0
  170. package/dist/react-renderer/types.d.cts.map +1 -0
  171. package/dist/react-renderer/types.d.mts +50 -0
  172. package/dist/react-renderer/types.d.mts.map +1 -0
  173. package/package.json +2 -3
  174. package/dist/A2UIMessageRenderer.cjs +0 -135
  175. package/dist/A2UIMessageRenderer.cjs.map +0 -1
  176. package/dist/A2UIMessageRenderer.d.cts +0 -11
  177. package/dist/A2UIMessageRenderer.d.cts.map +0 -1
  178. package/dist/A2UIMessageRenderer.d.mts +0 -11
  179. package/dist/A2UIMessageRenderer.d.mts.map +0 -1
  180. package/dist/A2UIMessageRenderer.mjs +0 -134
  181. package/dist/A2UIMessageRenderer.mjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"ThemeContext.mjs","names":[],"sources":["../../../src/react-renderer/theme/ThemeContext.tsx"],"sourcesContent":["import { createContext, useContext, type ReactNode } from \"react\";\nimport type { Types } from \"@a2ui/lit/0.8\";\nimport { defaultTheme } from \"./litTheme\";\n\n/**\n * React context for the A2UI theme.\n */\nconst ThemeContext = createContext<Types.Theme | undefined>(undefined);\n\n/**\n * Props for the ThemeProvider component.\n */\nexport interface ThemeProviderProps {\n /** The theme to provide. Falls back to defaultTheme if not specified. */\n theme?: Types.Theme;\n /** Child components that will have access to the theme */\n children: ReactNode;\n}\n\n/**\n * Provider component that makes the A2UI theme available to descendant components.\n */\nexport function ThemeProvider({ theme, children }: ThemeProviderProps) {\n return (\n <ThemeContext.Provider value={theme ?? defaultTheme}>\n {children}\n </ThemeContext.Provider>\n );\n}\n\n/**\n * Hook to access the current A2UI theme.\n *\n * @returns The current theme\n * @throws If used outside of a ThemeProvider\n */\nexport function useTheme(): Types.Theme {\n const theme = useContext(ThemeContext);\n if (!theme) {\n throw new Error(\n \"useTheme must be used within a ThemeProvider or A2UIProvider\",\n );\n }\n return theme;\n}\n\n/**\n * Hook to optionally access the current A2UI theme.\n *\n * @returns The current theme, or undefined if not within a provider\n */\nexport function useThemeOptional(): Types.Theme | undefined {\n return useContext(ThemeContext);\n}\n"],"mappings":";;;;;;;;AAOA,MAAM,eAAe,cAAuC,OAAU;;;;AAetE,SAAgB,cAAc,EAAE,OAAO,YAAgC;AACrE,QACE,oBAAC,aAAa;EAAS,OAAO,SAAS;EACpC;GACqB;;;;;;;;AAU5B,SAAgB,WAAwB;CACtC,MAAM,QAAQ,WAAW,aAAa;AACtC,KAAI,CAAC,MACH,OAAM,IAAI,MACR,+DACD;AAEH,QAAO"}
1
+ {"version":3,"file":"ThemeContext.mjs","names":[],"sources":["../../../src/react-renderer/theme/ThemeContext.tsx"],"sourcesContent":["import { createContext, useContext, type ReactNode } from \"react\";\nimport type { Types } from \"@a2ui/lit/0.8\";\nimport { defaultTheme } from \"./litTheme\";\n\n/**\n * React context for the A2UI theme.\n */\nconst ThemeContext = createContext<Types.Theme | undefined>(undefined);\n\n/**\n * Props for the ThemeProvider component.\n */\nexport interface ThemeProviderProps {\n /** The theme to provide. Falls back to defaultTheme if not specified. */\n theme?: Types.Theme;\n /** Child components that will have access to the theme */\n children: ReactNode;\n}\n\n/**\n * Provider component that makes the A2UI theme available to descendant components.\n */\nexport function ThemeProvider({ theme, children }: ThemeProviderProps) {\n return (\n <ThemeContext.Provider value={theme ?? defaultTheme}>\n {children}\n </ThemeContext.Provider>\n );\n}\n\n/**\n * Hook to access the current A2UI theme.\n *\n * @returns The current theme\n * @throws If used outside of a ThemeProvider\n */\nexport function useTheme(): Types.Theme {\n const theme = useContext(ThemeContext);\n if (!theme) {\n throw new Error(\n \"useTheme must be used within a ThemeProvider or A2UIProvider\",\n );\n }\n return theme;\n}\n\n/**\n * Hook to optionally access the current A2UI theme.\n *\n * @returns The current theme, or undefined if not within a provider\n */\nexport function useThemeOptional(): Types.Theme | undefined {\n return useContext(ThemeContext);\n}\n"],"mappings":";;;;;;;;AAOA,MAAM,eAAe,cAAuC,OAAU;;;;AAetE,SAAgB,cAAc,EAAE,OAAO,YAAgC;AACrE,QACE,oBAAC,aAAa;EAAS,OAAO,SAAS;EACpC;GACqB;;;;;;;;AAU5B,SAAgB,WAAwB;CACtC,MAAM,QAAQ,WAAW,aAAa;AACtC,KAAI,CAAC,MACH,OAAM,IAAI,MACR,+DACD;AAEH,QAAO;;;;;;;AAQT,SAAgB,mBAA4C;AAC1D,QAAO,WAAW,aAAa"}
@@ -365,4 +365,5 @@ const defaultTheme = litTheme;
365
365
 
366
366
  //#endregion
367
367
  exports.defaultTheme = defaultTheme;
368
+ exports.litTheme = litTheme;
368
369
  //# sourceMappingURL=litTheme.cjs.map
@@ -0,0 +1,12 @@
1
+ import { Types } from "@a2ui/lit/0.8";
2
+
3
+ //#region src/react-renderer/theme/litTheme.d.ts
4
+ declare const litTheme: Types.Theme;
5
+ /**
6
+ * Alias for litTheme - the default theme for A2UI React components.
7
+ * @see litTheme
8
+ */
9
+ declare const defaultTheme: Types.Theme;
10
+ //#endregion
11
+ export { defaultTheme, litTheme };
12
+ //# sourceMappingURL=litTheme.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"litTheme.d.cts","names":[],"sources":["../../../src/react-renderer/theme/litTheme.ts"],"mappings":";;;cAoJa,QAAA,EAAU,KAAA,CAAM,KAAA;;AAA7B;;;cAuSa,YAAA,EAAY,KAAA,CAAA,KAAA"}
@@ -0,0 +1,12 @@
1
+ import { Types } from "@a2ui/lit/0.8";
2
+
3
+ //#region src/react-renderer/theme/litTheme.d.ts
4
+ declare const litTheme: Types.Theme;
5
+ /**
6
+ * Alias for litTheme - the default theme for A2UI React components.
7
+ * @see litTheme
8
+ */
9
+ declare const defaultTheme: Types.Theme;
10
+ //#endregion
11
+ export { defaultTheme, litTheme };
12
+ //# sourceMappingURL=litTheme.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"litTheme.d.mts","names":[],"sources":["../../../src/react-renderer/theme/litTheme.ts"],"mappings":";;;cAoJa,QAAA,EAAU,KAAA,CAAM,KAAA;;AAA7B;;;cAuSa,YAAA,EAAY,KAAA,CAAA,KAAA"}
@@ -363,5 +363,5 @@ const litTheme = {
363
363
  const defaultTheme = litTheme;
364
364
 
365
365
  //#endregion
366
- export { defaultTheme };
366
+ export { defaultTheme, litTheme };
367
367
  //# sourceMappingURL=litTheme.mjs.map
@@ -0,0 +1,26 @@
1
+ //#region src/react-renderer/theme/utils.d.ts
2
+ /**
3
+ * Converts a theme class map (Record<string, boolean>) to a className string.
4
+ *
5
+ * @param classMap - An object where keys are class names and values are booleans
6
+ * @returns A space-separated string of class names where the value is true
7
+ *
8
+ * @example
9
+ * classMapToString({ 'a2ui-button': true, 'a2ui-button--primary': true, 'disabled': false })
10
+ * // Returns: 'a2ui-button a2ui-button--primary'
11
+ */
12
+ declare function classMapToString(classMap: Record<string, boolean> | undefined): string;
13
+ /**
14
+ * Converts an additional styles object (Record<string, string>) to a React style object.
15
+ *
16
+ * @param styles - An object with CSS property names as keys and values as strings
17
+ * @returns A React-compatible style object, or undefined if no styles
18
+ *
19
+ * @example
20
+ * stylesToObject({ 'background-color': 'red', 'font-size': '16px', '--custom-var': 'blue' })
21
+ * // Returns: { backgroundColor: 'red', fontSize: '16px', '--custom-var': 'blue' }
22
+ */
23
+ declare function stylesToObject(styles: Record<string, string> | undefined): React.CSSProperties | undefined;
24
+ //#endregion
25
+ export { classMapToString, stylesToObject };
26
+ //# sourceMappingURL=utils.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.cts","names":[],"sources":["../../../src/react-renderer/theme/utils.ts"],"mappings":";;AAUA;;;;;AAoBA;;;;iBApBgB,gBAAA,CACd,QAAA,EAAU,MAAA;;;;;;;;;;;iBAmBI,cAAA,CACd,MAAA,EAAQ,MAAA,+BACP,KAAA,CAAM,aAAA"}
@@ -0,0 +1,26 @@
1
+ //#region src/react-renderer/theme/utils.d.ts
2
+ /**
3
+ * Converts a theme class map (Record<string, boolean>) to a className string.
4
+ *
5
+ * @param classMap - An object where keys are class names and values are booleans
6
+ * @returns A space-separated string of class names where the value is true
7
+ *
8
+ * @example
9
+ * classMapToString({ 'a2ui-button': true, 'a2ui-button--primary': true, 'disabled': false })
10
+ * // Returns: 'a2ui-button a2ui-button--primary'
11
+ */
12
+ declare function classMapToString(classMap: Record<string, boolean> | undefined): string;
13
+ /**
14
+ * Converts an additional styles object (Record<string, string>) to a React style object.
15
+ *
16
+ * @param styles - An object with CSS property names as keys and values as strings
17
+ * @returns A React-compatible style object, or undefined if no styles
18
+ *
19
+ * @example
20
+ * stylesToObject({ 'background-color': 'red', 'font-size': '16px', '--custom-var': 'blue' })
21
+ * // Returns: { backgroundColor: 'red', fontSize: '16px', '--custom-var': 'blue' }
22
+ */
23
+ declare function stylesToObject(styles: Record<string, string> | undefined): React.CSSProperties | undefined;
24
+ //#endregion
25
+ export { classMapToString, stylesToObject };
26
+ //# sourceMappingURL=utils.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.mts","names":[],"sources":["../../../src/react-renderer/theme/utils.ts"],"mappings":";;AAUA;;;;;AAoBA;;;;iBApBgB,gBAAA,CACd,QAAA,EAAU,MAAA;;;;;;;;;;;iBAmBI,cAAA,CACd,MAAA,EAAQ,MAAA,+BACP,KAAA,CAAM,aAAA"}
@@ -0,0 +1,50 @@
1
+ import { ComponentType } from "react";
2
+ import { Primitives as Primitives$1, Types as Types$1 } from "@a2ui/lit/0.8";
3
+
4
+ //#region src/react-renderer/types.d.ts
5
+ type SurfaceID = Types$1.SurfaceID;
6
+ type DataValue = Types$1.DataValue;
7
+ type MessageProcessor = Types$1.MessageProcessor;
8
+ type StringValue = Primitives$1.StringValue;
9
+ type NumberValue = Primitives$1.NumberValue;
10
+ type BooleanValue = Primitives$1.BooleanValue;
11
+ /**
12
+ * Props passed to all A2UI React components.
13
+ */
14
+ interface A2UIComponentProps<T extends Types$1.AnyComponentNode = Types$1.AnyComponentNode> {
15
+ /** The resolved component node from the A2UI message processor */
16
+ node: T;
17
+ /** The surface ID this component belongs to */
18
+ surfaceId: string;
19
+ }
20
+ /**
21
+ * A function that loads a React component asynchronously.
22
+ */
23
+ type ComponentLoader<T extends Types$1.AnyComponentNode = Types$1.AnyComponentNode> = () => Promise<{
24
+ default: ComponentType<A2UIComponentProps<T>>;
25
+ }>;
26
+ /**
27
+ * Registration entry for a component in the registry.
28
+ */
29
+ interface ComponentRegistration<T extends Types$1.AnyComponentNode = Types$1.AnyComponentNode> {
30
+ /** The React component or a loader function for lazy loading */
31
+ component: ComponentType<A2UIComponentProps<T>> | ComponentLoader<T>;
32
+ /** If true, the component will be lazy loaded */
33
+ lazy?: boolean;
34
+ }
35
+ /**
36
+ * Callback for when a user action is dispatched.
37
+ */
38
+ type OnActionCallback = (message: Types$1.A2UIClientEventMessage) => void | Promise<void>;
39
+ /**
40
+ * Configuration options for the A2UI provider.
41
+ */
42
+ interface A2UIProviderConfig {
43
+ /** Callback invoked when a user action is dispatched (button click, etc.) */
44
+ onAction?: OnActionCallback;
45
+ /** Initial theme configuration */
46
+ theme?: Types$1.Theme;
47
+ }
48
+ //#endregion
49
+ export { A2UIComponentProps, A2UIProviderConfig, BooleanValue, ComponentLoader, ComponentRegistration, DataValue, MessageProcessor, NumberValue, OnActionCallback, type Primitives$1 as Primitives, StringValue, SurfaceID, type Types$1 as Types };
50
+ //# sourceMappingURL=types.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.cts","names":[],"sources":["../../src/react-renderer/types.ts"],"mappings":";;;;KASY,SAAA,GAAY,OAAA,CAAM,SAAA;AAAA,KAKlB,SAAA,GAAY,OAAA,CAAM,SAAA;AAAA,KAClB,gBAAA,GAAmB,OAAA,CAAM,gBAAA;AAAA,KAGzB,WAAA,GAAc,YAAA,CAAW,WAAA;AAAA,KACzB,WAAA,GAAc,YAAA,CAAW,WAAA;AAAA,KACzB,YAAA,GAAe,YAAA,CAAW,YAAA;;;;UAKrB,kBAAA,WACL,OAAA,CAAM,gBAAA,GAAmB,OAAA,CAAM,gBAAA;EAR/B;EAWV,IAAA,EAAM,CAAA;;EAEN,SAAA;AAAA;AAZF;;;AAAA,KAkBY,eAAA,WACA,OAAA,CAAM,gBAAA,GAAmB,OAAA,CAAM,gBAAA,UACjC,OAAA;EACR,OAAA,EAAS,aAAA,CAAc,kBAAA,CAAmB,CAAA;AAAA;;;;UAM3B,qBAAA,WACL,OAAA,CAAM,gBAAA,GAAmB,OAAA,CAAM,gBAAA;EAtB1B;EAyBf,SAAA,EAAW,aAAA,CAAc,kBAAA,CAAmB,CAAA,KAAM,eAAA,CAAgB,CAAA;EAzBjC;EA2BjC,IAAA;AAAA;;;;KAMU,gBAAA,IACV,OAAA,EAAS,OAAA,CAAM,sBAAA,YACL,OAAA;;;;UAKK,kBAAA;EApCf;EAsCA,QAAA,GAAW,gBAAA;EApCX;EAsCA,KAAA,GAAQ,OAAA,CAAM,KAAA;AAAA"}
@@ -0,0 +1,50 @@
1
+ import { ComponentType } from "react";
2
+ import { Primitives as Primitives$1, Types as Types$1 } from "@a2ui/lit/0.8";
3
+
4
+ //#region src/react-renderer/types.d.ts
5
+ type SurfaceID = Types$1.SurfaceID;
6
+ type DataValue = Types$1.DataValue;
7
+ type MessageProcessor = Types$1.MessageProcessor;
8
+ type StringValue = Primitives$1.StringValue;
9
+ type NumberValue = Primitives$1.NumberValue;
10
+ type BooleanValue = Primitives$1.BooleanValue;
11
+ /**
12
+ * Props passed to all A2UI React components.
13
+ */
14
+ interface A2UIComponentProps<T extends Types$1.AnyComponentNode = Types$1.AnyComponentNode> {
15
+ /** The resolved component node from the A2UI message processor */
16
+ node: T;
17
+ /** The surface ID this component belongs to */
18
+ surfaceId: string;
19
+ }
20
+ /**
21
+ * A function that loads a React component asynchronously.
22
+ */
23
+ type ComponentLoader<T extends Types$1.AnyComponentNode = Types$1.AnyComponentNode> = () => Promise<{
24
+ default: ComponentType<A2UIComponentProps<T>>;
25
+ }>;
26
+ /**
27
+ * Registration entry for a component in the registry.
28
+ */
29
+ interface ComponentRegistration<T extends Types$1.AnyComponentNode = Types$1.AnyComponentNode> {
30
+ /** The React component or a loader function for lazy loading */
31
+ component: ComponentType<A2UIComponentProps<T>> | ComponentLoader<T>;
32
+ /** If true, the component will be lazy loaded */
33
+ lazy?: boolean;
34
+ }
35
+ /**
36
+ * Callback for when a user action is dispatched.
37
+ */
38
+ type OnActionCallback = (message: Types$1.A2UIClientEventMessage) => void | Promise<void>;
39
+ /**
40
+ * Configuration options for the A2UI provider.
41
+ */
42
+ interface A2UIProviderConfig {
43
+ /** Callback invoked when a user action is dispatched (button click, etc.) */
44
+ onAction?: OnActionCallback;
45
+ /** Initial theme configuration */
46
+ theme?: Types$1.Theme;
47
+ }
48
+ //#endregion
49
+ export { A2UIComponentProps, A2UIProviderConfig, BooleanValue, ComponentLoader, ComponentRegistration, DataValue, MessageProcessor, NumberValue, OnActionCallback, type Primitives$1 as Primitives, StringValue, SurfaceID, type Types$1 as Types };
50
+ //# sourceMappingURL=types.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.mts","names":[],"sources":["../../src/react-renderer/types.ts"],"mappings":";;;;KASY,SAAA,GAAY,OAAA,CAAM,SAAA;AAAA,KAKlB,SAAA,GAAY,OAAA,CAAM,SAAA;AAAA,KAClB,gBAAA,GAAmB,OAAA,CAAM,gBAAA;AAAA,KAGzB,WAAA,GAAc,YAAA,CAAW,WAAA;AAAA,KACzB,WAAA,GAAc,YAAA,CAAW,WAAA;AAAA,KACzB,YAAA,GAAe,YAAA,CAAW,YAAA;;;;UAKrB,kBAAA,WACL,OAAA,CAAM,gBAAA,GAAmB,OAAA,CAAM,gBAAA;EAR/B;EAWV,IAAA,EAAM,CAAA;;EAEN,SAAA;AAAA;AAZF;;;AAAA,KAkBY,eAAA,WACA,OAAA,CAAM,gBAAA,GAAmB,OAAA,CAAM,gBAAA,UACjC,OAAA;EACR,OAAA,EAAS,aAAA,CAAc,kBAAA,CAAmB,CAAA;AAAA;;;;UAM3B,qBAAA,WACL,OAAA,CAAM,gBAAA,GAAmB,OAAA,CAAM,gBAAA;EAtB1B;EAyBf,SAAA,EAAW,aAAA,CAAc,kBAAA,CAAmB,CAAA,KAAM,eAAA,CAAgB,CAAA;EAzBjC;EA2BjC,IAAA;AAAA;;;;KAMU,gBAAA,IACV,OAAA,EAAS,OAAA,CAAM,sBAAA,YACL,OAAA;;;;UAKK,kBAAA;EApCf;EAsCA,QAAA,GAAW,gBAAA;EApCX;EAsCA,KAAA,GAAQ,OAAA,CAAM,KAAA;AAAA"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@copilotkit/a2ui-renderer",
3
3
  "private": false,
4
- "version": "1.53.0",
4
+ "version": "1.53.1-next.0",
5
5
  "description": "A2UI Renderer for CopilotKit - render A2UI surfaces in React applications",
6
6
  "homepage": "https://github.com/CopilotKit/CopilotKit",
7
7
  "repository": {
@@ -43,8 +43,7 @@
43
43
  },
44
44
  "peerDependencies": {
45
45
  "react": "^18 || ^19 || ^19.0.0-rc",
46
- "react-dom": "^18 || ^19 || ^19.0.0-rc",
47
- "@copilotkit/react-core": "1.53.0"
46
+ "react-dom": "^18 || ^19 || ^19.0.0-rc"
48
47
  },
49
48
  "devDependencies": {
50
49
  "@testing-library/react": "^16.0.0",
@@ -1,135 +0,0 @@
1
- const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
2
- const require_A2UIProvider = require('./react-renderer/core/A2UIProvider.cjs');
3
- const require_A2UIRenderer = require('./react-renderer/core/A2UIRenderer.cjs');
4
- const require_defaultCatalog = require('./react-renderer/registry/defaultCatalog.cjs');
5
- const require_index = require('./react-renderer/styles/index.cjs');
6
- let _copilotkit_react_core_v2 = require("@copilotkit/react-core/v2");
7
- let _a2ui_lit = require("@a2ui/lit");
8
- let react = require("react");
9
- let zod = require("zod");
10
- let react_jsx_runtime = require("react/jsx-runtime");
11
-
12
- //#region src/A2UIMessageRenderer.tsx
13
- let initialized = false;
14
- function ensureInitialized() {
15
- if (!initialized) {
16
- require_defaultCatalog.initializeDefaultCatalog();
17
- require_index.injectStyles();
18
- initialized = true;
19
- }
20
- }
21
- function createA2UIMessageRenderer(options) {
22
- const { theme } = options;
23
- return {
24
- activityType: "a2ui-surface",
25
- content: zod.z.any(),
26
- render: ({ content, agent }) => {
27
- ensureInitialized();
28
- const [operations, setOperations] = (0, react.useState)([]);
29
- const lastSignatureRef = (0, react.useRef)(null);
30
- const { copilotkit } = (0, _copilotkit_react_core_v2.useCopilotKit)();
31
- (0, react.useEffect)(() => {
32
- if (!content || !Array.isArray(content.operations)) {
33
- lastSignatureRef.current = null;
34
- setOperations([]);
35
- return;
36
- }
37
- const incoming = content.operations;
38
- const signature = stringifyOperations(incoming);
39
- if (signature && signature === lastSignatureRef.current) return;
40
- lastSignatureRef.current = signature;
41
- setOperations(incoming);
42
- }, [content]);
43
- const groupedOperations = (0, react.useMemo)(() => {
44
- const groups = /* @__PURE__ */ new Map();
45
- for (const operation of operations) {
46
- const surfaceId = getOperationSurfaceId(operation) ?? _a2ui_lit.v0_8.Data.A2uiMessageProcessor.DEFAULT_SURFACE_ID;
47
- if (!groups.has(surfaceId)) groups.set(surfaceId, []);
48
- groups.get(surfaceId).push(operation);
49
- }
50
- return groups;
51
- }, [operations]);
52
- if (!groupedOperations.size) return null;
53
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
54
- className: "flex min-h-0 flex-1 flex-col gap-6 overflow-auto py-6",
55
- children: Array.from(groupedOperations.entries()).map(([surfaceId, ops]) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ReactSurfaceHost, {
56
- surfaceId,
57
- operations: ops,
58
- theme,
59
- agent,
60
- copilotkit
61
- }, surfaceId))
62
- });
63
- }
64
- };
65
- }
66
- /**
67
- * Renders a single A2UI surface using the React renderer.
68
- * Wraps A2UIProvider + A2UIRenderer and bridges actions back to CopilotKit.
69
- */
70
- function ReactSurfaceHost({ surfaceId, operations, theme, agent, copilotkit }) {
71
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
72
- className: "flex w-full flex-none overflow-hidden rounded-lg bg-white/5 p-4",
73
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_A2UIProvider.A2UIProvider, {
74
- onAction: (0, react.useCallback)(async (message) => {
75
- if (!agent) return;
76
- try {
77
- console.info("[A2UI] Action dispatched", message.userAction);
78
- copilotkit.setProperties({
79
- ...copilotkit.properties ?? {},
80
- a2uiAction: message
81
- });
82
- await copilotkit.runAgent({ agent });
83
- } finally {
84
- if (copilotkit.properties) {
85
- const { a2uiAction, ...rest } = copilotkit.properties;
86
- copilotkit.setProperties(rest);
87
- }
88
- }
89
- }, [agent, copilotkit]),
90
- theme,
91
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(SurfaceMessageProcessor, {
92
- surfaceId,
93
- operations
94
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_A2UIRenderer.default, {
95
- surfaceId,
96
- className: "flex flex-1"
97
- })]
98
- })
99
- });
100
- }
101
- /**
102
- * Processes A2UI operations into the provider's message processor.
103
- * Must be a child of A2UIProvider to access the actions context.
104
- */
105
- function SurfaceMessageProcessor({ surfaceId, operations }) {
106
- const { processMessages } = require_A2UIProvider.useA2UIActions();
107
- const lastProcessedRef = (0, react.useRef)("");
108
- (0, react.useEffect)(() => {
109
- const key = `${surfaceId}-${JSON.stringify(operations)}`;
110
- if (key === lastProcessedRef.current) return;
111
- lastProcessedRef.current = key;
112
- processMessages(operations);
113
- }, [
114
- processMessages,
115
- surfaceId,
116
- operations
117
- ]);
118
- return null;
119
- }
120
- function getOperationSurfaceId(operation) {
121
- if (!operation || typeof operation !== "object") return null;
122
- if (typeof operation.surfaceId === "string") return operation.surfaceId;
123
- return operation?.beginRendering?.surfaceId ?? operation?.surfaceUpdate?.surfaceId ?? operation?.dataModelUpdate?.surfaceId ?? operation?.deleteSurface?.surfaceId ?? null;
124
- }
125
- function stringifyOperations(ops) {
126
- try {
127
- return JSON.stringify(ops);
128
- } catch (error) {
129
- return null;
130
- }
131
- }
132
-
133
- //#endregion
134
- exports.createA2UIMessageRenderer = createA2UIMessageRenderer;
135
- //# sourceMappingURL=A2UIMessageRenderer.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"A2UIMessageRenderer.cjs","names":["z","v0_8","A2UIProvider","A2UIRenderer","useA2UIActions"],"sources":["../src/A2UIMessageRenderer.tsx"],"sourcesContent":["import {\n useCopilotKit,\n type ReactActivityMessageRenderer,\n} from \"@copilotkit/react-core/v2\";\nimport { v0_8 } from \"@a2ui/lit\";\nimport { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport { z } from \"zod\";\nimport {\n A2UIProvider,\n useA2UIActions,\n} from \"./react-renderer/core/A2UIProvider\";\nimport { A2UIRenderer } from \"./react-renderer/core/A2UIRenderer\";\nimport { initializeDefaultCatalog } from \"./react-renderer/registry/defaultCatalog\";\nimport { injectStyles } from \"./react-renderer/styles\";\nimport type { Types } from \"@a2ui/lit/0.8\";\n\n// Initialize the React renderer's component catalog and styles once\nlet initialized = false;\nfunction ensureInitialized() {\n if (!initialized) {\n initializeDefaultCatalog();\n injectStyles();\n initialized = true;\n }\n}\n\nexport type A2UIMessageRendererOptions = {\n theme: v0_8.Types.Theme;\n};\n\nexport function createA2UIMessageRenderer(\n options: A2UIMessageRendererOptions,\n): ReactActivityMessageRenderer<any> {\n const { theme } = options;\n\n return {\n activityType: \"a2ui-surface\",\n content: z.any(),\n render: ({ content, agent }) => {\n ensureInitialized();\n\n const [operations, setOperations] = useState<any[]>([]);\n const lastSignatureRef = useRef<string | null>(null);\n const { copilotkit } = useCopilotKit();\n\n useEffect(() => {\n if (!content || !Array.isArray(content.operations)) {\n lastSignatureRef.current = null;\n setOperations([]);\n return;\n }\n\n const incoming = content.operations as any[];\n const signature = stringifyOperations(incoming);\n\n if (signature && signature === lastSignatureRef.current) {\n return;\n }\n\n lastSignatureRef.current = signature;\n setOperations(incoming);\n }, [content]);\n\n // Group operations by surface ID\n const groupedOperations = useMemo(() => {\n const groups = new Map<string, any[]>();\n\n for (const operation of operations) {\n const surfaceId =\n getOperationSurfaceId(operation) ??\n v0_8.Data.A2uiMessageProcessor.DEFAULT_SURFACE_ID;\n\n if (!groups.has(surfaceId)) {\n groups.set(surfaceId, []);\n }\n groups.get(surfaceId)!.push(operation);\n }\n\n return groups;\n }, [operations]);\n\n if (!groupedOperations.size) {\n return null;\n }\n\n return (\n <div className=\"flex min-h-0 flex-1 flex-col gap-6 overflow-auto py-6\">\n {Array.from(groupedOperations.entries()).map(([surfaceId, ops]) => (\n <ReactSurfaceHost\n key={surfaceId}\n surfaceId={surfaceId}\n operations={ops}\n theme={theme}\n agent={agent}\n copilotkit={copilotkit}\n />\n ))}\n </div>\n );\n },\n };\n}\n\ntype ReactSurfaceHostProps = {\n surfaceId: string;\n operations: any[];\n theme: v0_8.Types.Theme;\n agent: any;\n copilotkit: any;\n};\n\n/**\n * Renders a single A2UI surface using the React renderer.\n * Wraps A2UIProvider + A2UIRenderer and bridges actions back to CopilotKit.\n */\nfunction ReactSurfaceHost({\n surfaceId,\n operations,\n theme,\n agent,\n copilotkit,\n}: ReactSurfaceHostProps) {\n // Bridge: when the React renderer dispatches an action, send it to CopilotKit\n const handleAction = useCallback(\n async (message: Types.A2UIClientEventMessage) => {\n if (!agent) return;\n\n try {\n console.info(\"[A2UI] Action dispatched\", message.userAction);\n\n copilotkit.setProperties({\n ...(copilotkit.properties ?? {}),\n a2uiAction: message,\n });\n\n await copilotkit.runAgent({ agent });\n } finally {\n if (copilotkit.properties) {\n const { a2uiAction, ...rest } = copilotkit.properties;\n copilotkit.setProperties(rest);\n }\n }\n },\n [agent, copilotkit],\n );\n\n return (\n <div className=\"flex w-full flex-none overflow-hidden rounded-lg bg-white/5 p-4\">\n <A2UIProvider onAction={handleAction} theme={theme}>\n <SurfaceMessageProcessor\n surfaceId={surfaceId}\n operations={operations}\n />\n <A2UIRenderer surfaceId={surfaceId} className=\"flex flex-1\" />\n </A2UIProvider>\n </div>\n );\n}\n\n/**\n * Processes A2UI operations into the provider's message processor.\n * Must be a child of A2UIProvider to access the actions context.\n */\nfunction SurfaceMessageProcessor({\n surfaceId,\n operations,\n}: {\n surfaceId: string;\n operations: any[];\n}) {\n const { processMessages } = useA2UIActions();\n const lastProcessedRef = useRef<string>(\"\");\n\n useEffect(() => {\n const key = `${surfaceId}-${JSON.stringify(operations)}`;\n if (key === lastProcessedRef.current) return;\n lastProcessedRef.current = key;\n\n processMessages(operations);\n }, [processMessages, surfaceId, operations]);\n\n return null;\n}\n\nfunction getOperationSurfaceId(operation: any): string | null {\n if (!operation || typeof operation !== \"object\") {\n return null;\n }\n\n if (typeof operation.surfaceId === \"string\") {\n return operation.surfaceId;\n }\n\n return (\n operation?.beginRendering?.surfaceId ??\n operation?.surfaceUpdate?.surfaceId ??\n operation?.dataModelUpdate?.surfaceId ??\n operation?.deleteSurface?.surfaceId ??\n null\n );\n}\n\nfunction stringifyOperations(ops: any[]): string | null {\n try {\n return JSON.stringify(ops);\n } catch (error) {\n return null;\n }\n}\n"],"mappings":";;;;;;;;;;;;AAiBA,IAAI,cAAc;AAClB,SAAS,oBAAoB;AAC3B,KAAI,CAAC,aAAa;AAChB,mDAA0B;AAC1B,8BAAc;AACd,gBAAc;;;AAQlB,SAAgB,0BACd,SACmC;CACnC,MAAM,EAAE,UAAU;AAElB,QAAO;EACL,cAAc;EACd,SAASA,MAAE,KAAK;EAChB,SAAS,EAAE,SAAS,YAAY;AAC9B,sBAAmB;GAEnB,MAAM,CAAC,YAAY,qCAAiC,EAAE,CAAC;GACvD,MAAM,qCAAyC,KAAK;GACpD,MAAM,EAAE,6DAA8B;AAEtC,8BAAgB;AACd,QAAI,CAAC,WAAW,CAAC,MAAM,QAAQ,QAAQ,WAAW,EAAE;AAClD,sBAAiB,UAAU;AAC3B,mBAAc,EAAE,CAAC;AACjB;;IAGF,MAAM,WAAW,QAAQ;IACzB,MAAM,YAAY,oBAAoB,SAAS;AAE/C,QAAI,aAAa,cAAc,iBAAiB,QAC9C;AAGF,qBAAiB,UAAU;AAC3B,kBAAc,SAAS;MACtB,CAAC,QAAQ,CAAC;GAGb,MAAM,6CAAkC;IACtC,MAAM,yBAAS,IAAI,KAAoB;AAEvC,SAAK,MAAM,aAAa,YAAY;KAClC,MAAM,YACJ,sBAAsB,UAAU,IAChCC,eAAK,KAAK,qBAAqB;AAEjC,SAAI,CAAC,OAAO,IAAI,UAAU,CACxB,QAAO,IAAI,WAAW,EAAE,CAAC;AAE3B,YAAO,IAAI,UAAU,CAAE,KAAK,UAAU;;AAGxC,WAAO;MACN,CAAC,WAAW,CAAC;AAEhB,OAAI,CAAC,kBAAkB,KACrB,QAAO;AAGT,UACE,2CAAC;IAAI,WAAU;cACZ,MAAM,KAAK,kBAAkB,SAAS,CAAC,CAAC,KAAK,CAAC,WAAW,SACxD,2CAAC;KAEY;KACX,YAAY;KACL;KACA;KACK;OALP,UAML,CACF;KACE;;EAGX;;;;;;AAeH,SAAS,iBAAiB,EACxB,WACA,YACA,OACA,OACA,cACwB;AAyBxB,QACE,2CAAC;EAAI,WAAU;YACb,4CAACC;GAAa,iCAxBhB,OAAO,YAA0C;AAC/C,QAAI,CAAC,MAAO;AAEZ,QAAI;AACF,aAAQ,KAAK,4BAA4B,QAAQ,WAAW;AAE5D,gBAAW,cAAc;MACvB,GAAI,WAAW,cAAc,EAAE;MAC/B,YAAY;MACb,CAAC;AAEF,WAAM,WAAW,SAAS,EAAE,OAAO,CAAC;cAC5B;AACR,SAAI,WAAW,YAAY;MACzB,MAAM,EAAE,YAAY,GAAG,SAAS,WAAW;AAC3C,iBAAW,cAAc,KAAK;;;MAIpC,CAAC,OAAO,WAAW,CACpB;GAIgD;cAC3C,2CAAC;IACY;IACC;KACZ,EACF,2CAACC;IAAwB;IAAW,WAAU;KAAgB;IACjD;GACX;;;;;;AAQV,SAAS,wBAAwB,EAC/B,WACA,cAIC;CACD,MAAM,EAAE,oBAAoBC,qCAAgB;CAC5C,MAAM,qCAAkC,GAAG;AAE3C,4BAAgB;EACd,MAAM,MAAM,GAAG,UAAU,GAAG,KAAK,UAAU,WAAW;AACtD,MAAI,QAAQ,iBAAiB,QAAS;AACtC,mBAAiB,UAAU;AAE3B,kBAAgB,WAAW;IAC1B;EAAC;EAAiB;EAAW;EAAW,CAAC;AAE5C,QAAO;;AAGT,SAAS,sBAAsB,WAA+B;AAC5D,KAAI,CAAC,aAAa,OAAO,cAAc,SACrC,QAAO;AAGT,KAAI,OAAO,UAAU,cAAc,SACjC,QAAO,UAAU;AAGnB,QACE,WAAW,gBAAgB,aAC3B,WAAW,eAAe,aAC1B,WAAW,iBAAiB,aAC5B,WAAW,eAAe,aAC1B;;AAIJ,SAAS,oBAAoB,KAA2B;AACtD,KAAI;AACF,SAAO,KAAK,UAAU,IAAI;UACnB,OAAO;AACd,SAAO"}
@@ -1,11 +0,0 @@
1
- import { ReactActivityMessageRenderer } from "@copilotkit/react-core/v2";
2
- import { v0_8 } from "@a2ui/lit";
3
-
4
- //#region src/A2UIMessageRenderer.d.ts
5
- type A2UIMessageRendererOptions = {
6
- theme: v0_8.Types.Theme;
7
- };
8
- declare function createA2UIMessageRenderer(options: A2UIMessageRendererOptions): ReactActivityMessageRenderer<any>;
9
- //#endregion
10
- export { A2UIMessageRendererOptions, createA2UIMessageRenderer };
11
- //# sourceMappingURL=A2UIMessageRenderer.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"A2UIMessageRenderer.d.cts","names":[],"sources":["../src/A2UIMessageRenderer.tsx"],"mappings":";;;;KA0BY,0BAAA;EACV,KAAA,EAAO,IAAA,CAAK,KAAA,CAAM,KAAA;AAAA;AAAA,iBAGJ,yBAAA,CACd,OAAA,EAAS,0BAAA,GACR,4BAAA"}
@@ -1,11 +0,0 @@
1
- import { ReactActivityMessageRenderer } from "@copilotkit/react-core/v2";
2
- import { v0_8 } from "@a2ui/lit";
3
-
4
- //#region src/A2UIMessageRenderer.d.ts
5
- type A2UIMessageRendererOptions = {
6
- theme: v0_8.Types.Theme;
7
- };
8
- declare function createA2UIMessageRenderer(options: A2UIMessageRendererOptions): ReactActivityMessageRenderer<any>;
9
- //#endregion
10
- export { A2UIMessageRendererOptions, createA2UIMessageRenderer };
11
- //# sourceMappingURL=A2UIMessageRenderer.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"A2UIMessageRenderer.d.mts","names":[],"sources":["../src/A2UIMessageRenderer.tsx"],"mappings":";;;;KA0BY,0BAAA;EACV,KAAA,EAAO,IAAA,CAAK,KAAA,CAAM,KAAA;AAAA;AAAA,iBAGJ,yBAAA,CACd,OAAA,EAAS,0BAAA,GACR,4BAAA"}
@@ -1,134 +0,0 @@
1
- import { A2UIProvider, useA2UIActions } from "./react-renderer/core/A2UIProvider.mjs";
2
- import A2UIRenderer from "./react-renderer/core/A2UIRenderer.mjs";
3
- import { initializeDefaultCatalog } from "./react-renderer/registry/defaultCatalog.mjs";
4
- import { injectStyles } from "./react-renderer/styles/index.mjs";
5
- import { useCopilotKit } from "@copilotkit/react-core/v2";
6
- import { v0_8 } from "@a2ui/lit";
7
- import { useCallback, useEffect, useMemo, useRef, useState } from "react";
8
- import { z } from "zod";
9
- import { jsx, jsxs } from "react/jsx-runtime";
10
-
11
- //#region src/A2UIMessageRenderer.tsx
12
- let initialized = false;
13
- function ensureInitialized() {
14
- if (!initialized) {
15
- initializeDefaultCatalog();
16
- injectStyles();
17
- initialized = true;
18
- }
19
- }
20
- function createA2UIMessageRenderer(options) {
21
- const { theme } = options;
22
- return {
23
- activityType: "a2ui-surface",
24
- content: z.any(),
25
- render: ({ content, agent }) => {
26
- ensureInitialized();
27
- const [operations, setOperations] = useState([]);
28
- const lastSignatureRef = useRef(null);
29
- const { copilotkit } = useCopilotKit();
30
- useEffect(() => {
31
- if (!content || !Array.isArray(content.operations)) {
32
- lastSignatureRef.current = null;
33
- setOperations([]);
34
- return;
35
- }
36
- const incoming = content.operations;
37
- const signature = stringifyOperations(incoming);
38
- if (signature && signature === lastSignatureRef.current) return;
39
- lastSignatureRef.current = signature;
40
- setOperations(incoming);
41
- }, [content]);
42
- const groupedOperations = useMemo(() => {
43
- const groups = /* @__PURE__ */ new Map();
44
- for (const operation of operations) {
45
- const surfaceId = getOperationSurfaceId(operation) ?? v0_8.Data.A2uiMessageProcessor.DEFAULT_SURFACE_ID;
46
- if (!groups.has(surfaceId)) groups.set(surfaceId, []);
47
- groups.get(surfaceId).push(operation);
48
- }
49
- return groups;
50
- }, [operations]);
51
- if (!groupedOperations.size) return null;
52
- return /* @__PURE__ */ jsx("div", {
53
- className: "flex min-h-0 flex-1 flex-col gap-6 overflow-auto py-6",
54
- children: Array.from(groupedOperations.entries()).map(([surfaceId, ops]) => /* @__PURE__ */ jsx(ReactSurfaceHost, {
55
- surfaceId,
56
- operations: ops,
57
- theme,
58
- agent,
59
- copilotkit
60
- }, surfaceId))
61
- });
62
- }
63
- };
64
- }
65
- /**
66
- * Renders a single A2UI surface using the React renderer.
67
- * Wraps A2UIProvider + A2UIRenderer and bridges actions back to CopilotKit.
68
- */
69
- function ReactSurfaceHost({ surfaceId, operations, theme, agent, copilotkit }) {
70
- return /* @__PURE__ */ jsx("div", {
71
- className: "flex w-full flex-none overflow-hidden rounded-lg bg-white/5 p-4",
72
- children: /* @__PURE__ */ jsxs(A2UIProvider, {
73
- onAction: useCallback(async (message) => {
74
- if (!agent) return;
75
- try {
76
- console.info("[A2UI] Action dispatched", message.userAction);
77
- copilotkit.setProperties({
78
- ...copilotkit.properties ?? {},
79
- a2uiAction: message
80
- });
81
- await copilotkit.runAgent({ agent });
82
- } finally {
83
- if (copilotkit.properties) {
84
- const { a2uiAction, ...rest } = copilotkit.properties;
85
- copilotkit.setProperties(rest);
86
- }
87
- }
88
- }, [agent, copilotkit]),
89
- theme,
90
- children: [/* @__PURE__ */ jsx(SurfaceMessageProcessor, {
91
- surfaceId,
92
- operations
93
- }), /* @__PURE__ */ jsx(A2UIRenderer, {
94
- surfaceId,
95
- className: "flex flex-1"
96
- })]
97
- })
98
- });
99
- }
100
- /**
101
- * Processes A2UI operations into the provider's message processor.
102
- * Must be a child of A2UIProvider to access the actions context.
103
- */
104
- function SurfaceMessageProcessor({ surfaceId, operations }) {
105
- const { processMessages } = useA2UIActions();
106
- const lastProcessedRef = useRef("");
107
- useEffect(() => {
108
- const key = `${surfaceId}-${JSON.stringify(operations)}`;
109
- if (key === lastProcessedRef.current) return;
110
- lastProcessedRef.current = key;
111
- processMessages(operations);
112
- }, [
113
- processMessages,
114
- surfaceId,
115
- operations
116
- ]);
117
- return null;
118
- }
119
- function getOperationSurfaceId(operation) {
120
- if (!operation || typeof operation !== "object") return null;
121
- if (typeof operation.surfaceId === "string") return operation.surfaceId;
122
- return operation?.beginRendering?.surfaceId ?? operation?.surfaceUpdate?.surfaceId ?? operation?.dataModelUpdate?.surfaceId ?? operation?.deleteSurface?.surfaceId ?? null;
123
- }
124
- function stringifyOperations(ops) {
125
- try {
126
- return JSON.stringify(ops);
127
- } catch (error) {
128
- return null;
129
- }
130
- }
131
-
132
- //#endregion
133
- export { createA2UIMessageRenderer };
134
- //# sourceMappingURL=A2UIMessageRenderer.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"A2UIMessageRenderer.mjs","names":[],"sources":["../src/A2UIMessageRenderer.tsx"],"sourcesContent":["import {\n useCopilotKit,\n type ReactActivityMessageRenderer,\n} from \"@copilotkit/react-core/v2\";\nimport { v0_8 } from \"@a2ui/lit\";\nimport { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport { z } from \"zod\";\nimport {\n A2UIProvider,\n useA2UIActions,\n} from \"./react-renderer/core/A2UIProvider\";\nimport { A2UIRenderer } from \"./react-renderer/core/A2UIRenderer\";\nimport { initializeDefaultCatalog } from \"./react-renderer/registry/defaultCatalog\";\nimport { injectStyles } from \"./react-renderer/styles\";\nimport type { Types } from \"@a2ui/lit/0.8\";\n\n// Initialize the React renderer's component catalog and styles once\nlet initialized = false;\nfunction ensureInitialized() {\n if (!initialized) {\n initializeDefaultCatalog();\n injectStyles();\n initialized = true;\n }\n}\n\nexport type A2UIMessageRendererOptions = {\n theme: v0_8.Types.Theme;\n};\n\nexport function createA2UIMessageRenderer(\n options: A2UIMessageRendererOptions,\n): ReactActivityMessageRenderer<any> {\n const { theme } = options;\n\n return {\n activityType: \"a2ui-surface\",\n content: z.any(),\n render: ({ content, agent }) => {\n ensureInitialized();\n\n const [operations, setOperations] = useState<any[]>([]);\n const lastSignatureRef = useRef<string | null>(null);\n const { copilotkit } = useCopilotKit();\n\n useEffect(() => {\n if (!content || !Array.isArray(content.operations)) {\n lastSignatureRef.current = null;\n setOperations([]);\n return;\n }\n\n const incoming = content.operations as any[];\n const signature = stringifyOperations(incoming);\n\n if (signature && signature === lastSignatureRef.current) {\n return;\n }\n\n lastSignatureRef.current = signature;\n setOperations(incoming);\n }, [content]);\n\n // Group operations by surface ID\n const groupedOperations = useMemo(() => {\n const groups = new Map<string, any[]>();\n\n for (const operation of operations) {\n const surfaceId =\n getOperationSurfaceId(operation) ??\n v0_8.Data.A2uiMessageProcessor.DEFAULT_SURFACE_ID;\n\n if (!groups.has(surfaceId)) {\n groups.set(surfaceId, []);\n }\n groups.get(surfaceId)!.push(operation);\n }\n\n return groups;\n }, [operations]);\n\n if (!groupedOperations.size) {\n return null;\n }\n\n return (\n <div className=\"flex min-h-0 flex-1 flex-col gap-6 overflow-auto py-6\">\n {Array.from(groupedOperations.entries()).map(([surfaceId, ops]) => (\n <ReactSurfaceHost\n key={surfaceId}\n surfaceId={surfaceId}\n operations={ops}\n theme={theme}\n agent={agent}\n copilotkit={copilotkit}\n />\n ))}\n </div>\n );\n },\n };\n}\n\ntype ReactSurfaceHostProps = {\n surfaceId: string;\n operations: any[];\n theme: v0_8.Types.Theme;\n agent: any;\n copilotkit: any;\n};\n\n/**\n * Renders a single A2UI surface using the React renderer.\n * Wraps A2UIProvider + A2UIRenderer and bridges actions back to CopilotKit.\n */\nfunction ReactSurfaceHost({\n surfaceId,\n operations,\n theme,\n agent,\n copilotkit,\n}: ReactSurfaceHostProps) {\n // Bridge: when the React renderer dispatches an action, send it to CopilotKit\n const handleAction = useCallback(\n async (message: Types.A2UIClientEventMessage) => {\n if (!agent) return;\n\n try {\n console.info(\"[A2UI] Action dispatched\", message.userAction);\n\n copilotkit.setProperties({\n ...(copilotkit.properties ?? {}),\n a2uiAction: message,\n });\n\n await copilotkit.runAgent({ agent });\n } finally {\n if (copilotkit.properties) {\n const { a2uiAction, ...rest } = copilotkit.properties;\n copilotkit.setProperties(rest);\n }\n }\n },\n [agent, copilotkit],\n );\n\n return (\n <div className=\"flex w-full flex-none overflow-hidden rounded-lg bg-white/5 p-4\">\n <A2UIProvider onAction={handleAction} theme={theme}>\n <SurfaceMessageProcessor\n surfaceId={surfaceId}\n operations={operations}\n />\n <A2UIRenderer surfaceId={surfaceId} className=\"flex flex-1\" />\n </A2UIProvider>\n </div>\n );\n}\n\n/**\n * Processes A2UI operations into the provider's message processor.\n * Must be a child of A2UIProvider to access the actions context.\n */\nfunction SurfaceMessageProcessor({\n surfaceId,\n operations,\n}: {\n surfaceId: string;\n operations: any[];\n}) {\n const { processMessages } = useA2UIActions();\n const lastProcessedRef = useRef<string>(\"\");\n\n useEffect(() => {\n const key = `${surfaceId}-${JSON.stringify(operations)}`;\n if (key === lastProcessedRef.current) return;\n lastProcessedRef.current = key;\n\n processMessages(operations);\n }, [processMessages, surfaceId, operations]);\n\n return null;\n}\n\nfunction getOperationSurfaceId(operation: any): string | null {\n if (!operation || typeof operation !== \"object\") {\n return null;\n }\n\n if (typeof operation.surfaceId === \"string\") {\n return operation.surfaceId;\n }\n\n return (\n operation?.beginRendering?.surfaceId ??\n operation?.surfaceUpdate?.surfaceId ??\n operation?.dataModelUpdate?.surfaceId ??\n operation?.deleteSurface?.surfaceId ??\n null\n );\n}\n\nfunction stringifyOperations(ops: any[]): string | null {\n try {\n return JSON.stringify(ops);\n } catch (error) {\n return null;\n }\n}\n"],"mappings":";;;;;;;;;;;AAiBA,IAAI,cAAc;AAClB,SAAS,oBAAoB;AAC3B,KAAI,CAAC,aAAa;AAChB,4BAA0B;AAC1B,gBAAc;AACd,gBAAc;;;AAQlB,SAAgB,0BACd,SACmC;CACnC,MAAM,EAAE,UAAU;AAElB,QAAO;EACL,cAAc;EACd,SAAS,EAAE,KAAK;EAChB,SAAS,EAAE,SAAS,YAAY;AAC9B,sBAAmB;GAEnB,MAAM,CAAC,YAAY,iBAAiB,SAAgB,EAAE,CAAC;GACvD,MAAM,mBAAmB,OAAsB,KAAK;GACpD,MAAM,EAAE,eAAe,eAAe;AAEtC,mBAAgB;AACd,QAAI,CAAC,WAAW,CAAC,MAAM,QAAQ,QAAQ,WAAW,EAAE;AAClD,sBAAiB,UAAU;AAC3B,mBAAc,EAAE,CAAC;AACjB;;IAGF,MAAM,WAAW,QAAQ;IACzB,MAAM,YAAY,oBAAoB,SAAS;AAE/C,QAAI,aAAa,cAAc,iBAAiB,QAC9C;AAGF,qBAAiB,UAAU;AAC3B,kBAAc,SAAS;MACtB,CAAC,QAAQ,CAAC;GAGb,MAAM,oBAAoB,cAAc;IACtC,MAAM,yBAAS,IAAI,KAAoB;AAEvC,SAAK,MAAM,aAAa,YAAY;KAClC,MAAM,YACJ,sBAAsB,UAAU,IAChC,KAAK,KAAK,qBAAqB;AAEjC,SAAI,CAAC,OAAO,IAAI,UAAU,CACxB,QAAO,IAAI,WAAW,EAAE,CAAC;AAE3B,YAAO,IAAI,UAAU,CAAE,KAAK,UAAU;;AAGxC,WAAO;MACN,CAAC,WAAW,CAAC;AAEhB,OAAI,CAAC,kBAAkB,KACrB,QAAO;AAGT,UACE,oBAAC;IAAI,WAAU;cACZ,MAAM,KAAK,kBAAkB,SAAS,CAAC,CAAC,KAAK,CAAC,WAAW,SACxD,oBAAC;KAEY;KACX,YAAY;KACL;KACA;KACK;OALP,UAML,CACF;KACE;;EAGX;;;;;;AAeH,SAAS,iBAAiB,EACxB,WACA,YACA,OACA,OACA,cACwB;AAyBxB,QACE,oBAAC;EAAI,WAAU;YACb,qBAAC;GAAa,UAzBG,YACnB,OAAO,YAA0C;AAC/C,QAAI,CAAC,MAAO;AAEZ,QAAI;AACF,aAAQ,KAAK,4BAA4B,QAAQ,WAAW;AAE5D,gBAAW,cAAc;MACvB,GAAI,WAAW,cAAc,EAAE;MAC/B,YAAY;MACb,CAAC;AAEF,WAAM,WAAW,SAAS,EAAE,OAAO,CAAC;cAC5B;AACR,SAAI,WAAW,YAAY;MACzB,MAAM,EAAE,YAAY,GAAG,SAAS,WAAW;AAC3C,iBAAW,cAAc,KAAK;;;MAIpC,CAAC,OAAO,WAAW,CACpB;GAIgD;cAC3C,oBAAC;IACY;IACC;KACZ,EACF,oBAAC;IAAwB;IAAW,WAAU;KAAgB;IACjD;GACX;;;;;;AAQV,SAAS,wBAAwB,EAC/B,WACA,cAIC;CACD,MAAM,EAAE,oBAAoB,gBAAgB;CAC5C,MAAM,mBAAmB,OAAe,GAAG;AAE3C,iBAAgB;EACd,MAAM,MAAM,GAAG,UAAU,GAAG,KAAK,UAAU,WAAW;AACtD,MAAI,QAAQ,iBAAiB,QAAS;AACtC,mBAAiB,UAAU;AAE3B,kBAAgB,WAAW;IAC1B;EAAC;EAAiB;EAAW;EAAW,CAAC;AAE5C,QAAO;;AAGT,SAAS,sBAAsB,WAA+B;AAC5D,KAAI,CAAC,aAAa,OAAO,cAAc,SACrC,QAAO;AAGT,KAAI,OAAO,UAAU,cAAc,SACjC,QAAO,UAAU;AAGnB,QACE,WAAW,gBAAgB,aAC3B,WAAW,eAAe,aAC1B,WAAW,iBAAiB,aAC5B,WAAW,eAAe,aAC1B;;AAIJ,SAAS,oBAAoB,KAA2B;AACtD,KAAI;AACF,SAAO,KAAK,UAAU,IAAI;UACnB,OAAO;AACd,SAAO"}