@assistant-ui/mcp-docs-server 0.2.2 → 0.3.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 (459) hide show
  1. package/README.md +16 -43
  2. package/dist/index.d.ts +2 -3
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +3 -91
  5. package/dist/index.js.map +1 -1
  6. package/dist/proxy.d.ts +9 -0
  7. package/dist/proxy.d.ts.map +1 -0
  8. package/dist/proxy.js +76 -0
  9. package/dist/proxy.js.map +1 -0
  10. package/package.json +9 -13
  11. package/src/index.ts +3 -115
  12. package/src/proxy.test.ts +250 -0
  13. package/src/proxy.ts +111 -0
  14. package/.docs/organized/code-examples/waterfall.md +0 -807
  15. package/.docs/organized/code-examples/with-a2a.md +0 -674
  16. package/.docs/organized/code-examples/with-ag-ui.md +0 -552
  17. package/.docs/organized/code-examples/with-ai-sdk-v7.md +0 -465
  18. package/.docs/organized/code-examples/with-artifacts.md +0 -814
  19. package/.docs/organized/code-examples/with-assistant-transport.md +0 -575
  20. package/.docs/organized/code-examples/with-browser-extension.md +0 -371
  21. package/.docs/organized/code-examples/with-chain-of-thought.md +0 -960
  22. package/.docs/organized/code-examples/with-cloud-standalone.md +0 -681
  23. package/.docs/organized/code-examples/with-cloud.md +0 -438
  24. package/.docs/organized/code-examples/with-custom-thread-list.md +0 -568
  25. package/.docs/organized/code-examples/with-elevenlabs-conversational.md +0 -526
  26. package/.docs/organized/code-examples/with-elevenlabs-scribe.md +0 -696
  27. package/.docs/organized/code-examples/with-eve.md +0 -404
  28. package/.docs/organized/code-examples/with-expo.md +0 -2063
  29. package/.docs/organized/code-examples/with-external-store.md +0 -420
  30. package/.docs/organized/code-examples/with-ffmpeg.md +0 -828
  31. package/.docs/organized/code-examples/with-generative-ui.md +0 -1812
  32. package/.docs/organized/code-examples/with-google-adk.md +0 -367
  33. package/.docs/organized/code-examples/with-heat-graph.md +0 -304
  34. package/.docs/organized/code-examples/with-image-generation.md +0 -462
  35. package/.docs/organized/code-examples/with-interactables.md +0 -732
  36. package/.docs/organized/code-examples/with-langchain.md +0 -445
  37. package/.docs/organized/code-examples/with-langgraph.md +0 -854
  38. package/.docs/organized/code-examples/with-livekit.md +0 -642
  39. package/.docs/organized/code-examples/with-mcp.md +0 -780
  40. package/.docs/organized/code-examples/with-nuxt.md +0 -2428
  41. package/.docs/organized/code-examples/with-opencode.md +0 -1974
  42. package/.docs/organized/code-examples/with-openui.md +0 -449
  43. package/.docs/organized/code-examples/with-pi.md +0 -2083
  44. package/.docs/organized/code-examples/with-react-hook-form.md +0 -724
  45. package/.docs/organized/code-examples/with-react-ink-web.md +0 -690
  46. package/.docs/organized/code-examples/with-react-ink.md +0 -472
  47. package/.docs/organized/code-examples/with-react-router.md +0 -935
  48. package/.docs/organized/code-examples/with-resumable-stream.md +0 -667
  49. package/.docs/organized/code-examples/with-store.md +0 -679
  50. package/.docs/organized/code-examples/with-svelte.md +0 -415
  51. package/.docs/organized/code-examples/with-sveltekit.md +0 -1061
  52. package/.docs/organized/code-examples/with-tanstack.md +0 -811
  53. package/.docs/organized/code-examples/with-tap-runtime.md +0 -812
  54. package/.docs/organized/code-examples/with-virtualized-thread.md +0 -680
  55. package/.docs/organized/code-examples/with-vue.md +0 -408
  56. package/.docs/raw/docs/(docs)/architecture.mdx +0 -146
  57. package/.docs/raw/docs/(docs)/base-ui.mdx +0 -39
  58. package/.docs/raw/docs/(docs)/cli.mdx +0 -542
  59. package/.docs/raw/docs/(docs)/devtools.mdx +0 -79
  60. package/.docs/raw/docs/(docs)/index.mdx +0 -21
  61. package/.docs/raw/docs/(docs)/installation.mdx +0 -483
  62. package/.docs/raw/docs/(docs)/llm.mdx +0 -211
  63. package/.docs/raw/docs/(docs)/rtl.mdx +0 -78
  64. package/.docs/raw/docs/(reference)/api-reference/adapters/attachments.mdx +0 -36
  65. package/.docs/raw/docs/(reference)/api-reference/adapters/feedback.mdx +0 -20
  66. package/.docs/raw/docs/(reference)/api-reference/adapters/index.mdx +0 -34
  67. package/.docs/raw/docs/(reference)/api-reference/adapters/model.mdx +0 -44
  68. package/.docs/raw/docs/(reference)/api-reference/adapters/persistence.mdx +0 -59
  69. package/.docs/raw/docs/(reference)/api-reference/adapters/runtime.mdx +0 -20
  70. package/.docs/raw/docs/(reference)/api-reference/adapters/suggestions.mdx +0 -20
  71. package/.docs/raw/docs/(reference)/api-reference/context-providers/assistant-runtime-provider.mdx +0 -84
  72. package/.docs/raw/docs/(reference)/api-reference/context-providers/index.mdx +0 -22
  73. package/.docs/raw/docs/(reference)/api-reference/context-providers/scoped-providers.mdx +0 -64
  74. package/.docs/raw/docs/(reference)/api-reference/external-store/index.mdx +0 -22
  75. package/.docs/raw/docs/(reference)/api-reference/external-store/message-conversion.mdx +0 -52
  76. package/.docs/raw/docs/(reference)/api-reference/external-store/runtime.mdx +0 -49
  77. package/.docs/raw/docs/(reference)/api-reference/generative-ui/a2ui.mdx +0 -40
  78. package/.docs/raw/docs/(reference)/api-reference/generative-ui/actions.mdx +0 -56
  79. package/.docs/raw/docs/(reference)/api-reference/generative-ui/components.mdx +0 -86
  80. package/.docs/raw/docs/(reference)/api-reference/generative-ui/index.mdx +0 -39
  81. package/.docs/raw/docs/(reference)/api-reference/generative-ui/json-generative-ui.mdx +0 -42
  82. package/.docs/raw/docs/(reference)/api-reference/generative-ui/rendering.mdx +0 -84
  83. package/.docs/raw/docs/(reference)/api-reference/generative-ui/slack.mdx +0 -85
  84. package/.docs/raw/docs/(reference)/api-reference/generative-ui/spec.mdx +0 -45
  85. package/.docs/raw/docs/(reference)/api-reference/generative-ui/teams.mdx +0 -93
  86. package/.docs/raw/docs/(reference)/api-reference/generative-ui/tokens.mdx +0 -62
  87. package/.docs/raw/docs/(reference)/api-reference/hooks/composer-triggers.mdx +0 -129
  88. package/.docs/raw/docs/(reference)/api-reference/hooks/index.mdx +0 -31
  89. package/.docs/raw/docs/(reference)/api-reference/hooks/model-context.mdx +0 -34
  90. package/.docs/raw/docs/(reference)/api-reference/hooks/primitives.mdx +0 -350
  91. package/.docs/raw/docs/(reference)/api-reference/hooks/runtimes.mdx +0 -28
  92. package/.docs/raw/docs/(reference)/api-reference/hooks/state.mdx +0 -97
  93. package/.docs/raw/docs/(reference)/api-reference/integrations/cloud-ai-sdk.mdx +0 -24
  94. package/.docs/raw/docs/(reference)/api-reference/integrations/eve.mdx +0 -97
  95. package/.docs/raw/docs/(reference)/api-reference/integrations/index.mdx +0 -28
  96. package/.docs/raw/docs/(reference)/api-reference/integrations/react-ai-sdk.mdx +0 -200
  97. package/.docs/raw/docs/(reference)/api-reference/integrations/react-data-stream.mdx +0 -37
  98. package/.docs/raw/docs/(reference)/api-reference/model-context/context.mdx +0 -50
  99. package/.docs/raw/docs/(reference)/api-reference/model-context/index.mdx +0 -22
  100. package/.docs/raw/docs/(reference)/api-reference/model-context/registry.mdx +0 -20
  101. package/.docs/raw/docs/(reference)/api-reference/overview.mdx +0 -566
  102. package/.docs/raw/docs/(reference)/api-reference/primitives/action-bar-more.mdx +0 -152
  103. package/.docs/raw/docs/(reference)/api-reference/primitives/action-bar.mdx +0 -239
  104. package/.docs/raw/docs/(reference)/api-reference/primitives/assistant-if.mdx +0 -208
  105. package/.docs/raw/docs/(reference)/api-reference/primitives/assistant-modal.mdx +0 -108
  106. package/.docs/raw/docs/(reference)/api-reference/primitives/attachment.mdx +0 -99
  107. package/.docs/raw/docs/(reference)/api-reference/primitives/branch-picker.mdx +0 -145
  108. package/.docs/raw/docs/(reference)/api-reference/primitives/chain-of-thought.mdx +0 -82
  109. package/.docs/raw/docs/(reference)/api-reference/primitives/composer.mdx +0 -619
  110. package/.docs/raw/docs/(reference)/api-reference/primitives/composition.mdx +0 -22
  111. package/.docs/raw/docs/(reference)/api-reference/primitives/error.mdx +0 -65
  112. package/.docs/raw/docs/(reference)/api-reference/primitives/index.mdx +0 -73
  113. package/.docs/raw/docs/(reference)/api-reference/primitives/message-part.mdx +0 -117
  114. package/.docs/raw/docs/(reference)/api-reference/primitives/message.mdx +0 -339
  115. package/.docs/raw/docs/(reference)/api-reference/primitives/queue-item.mdx +0 -77
  116. package/.docs/raw/docs/(reference)/api-reference/primitives/selection-toolbar.mdx +0 -88
  117. package/.docs/raw/docs/(reference)/api-reference/primitives/suggestion.mdx +0 -81
  118. package/.docs/raw/docs/(reference)/api-reference/primitives/thread-list-item-more.mdx +0 -129
  119. package/.docs/raw/docs/(reference)/api-reference/primitives/thread-list-item.mdx +0 -138
  120. package/.docs/raw/docs/(reference)/api-reference/primitives/thread-list.mdx +0 -122
  121. package/.docs/raw/docs/(reference)/api-reference/primitives/thread.mdx +0 -289
  122. package/.docs/raw/docs/(reference)/api-reference/runtimes/assistant-runtime.mdx +0 -20
  123. package/.docs/raw/docs/(reference)/api-reference/runtimes/attachment-runtime.mdx +0 -24
  124. package/.docs/raw/docs/(reference)/api-reference/runtimes/composer-runtime.mdx +0 -32
  125. package/.docs/raw/docs/(reference)/api-reference/runtimes/index.mdx +0 -43
  126. package/.docs/raw/docs/(reference)/api-reference/runtimes/message-part-runtime.mdx +0 -43
  127. package/.docs/raw/docs/(reference)/api-reference/runtimes/message-runtime.mdx +0 -24
  128. package/.docs/raw/docs/(reference)/api-reference/runtimes/queue-state.mdx +0 -20
  129. package/.docs/raw/docs/(reference)/api-reference/runtimes/thread-list-item-runtime.mdx +0 -24
  130. package/.docs/raw/docs/(reference)/api-reference/runtimes/thread-list-runtime.mdx +0 -24
  131. package/.docs/raw/docs/(reference)/api-reference/runtimes/thread-runtime.mdx +0 -36
  132. package/.docs/raw/docs/(reference)/api-reference/tools/component-tools.mdx +0 -85
  133. package/.docs/raw/docs/(reference)/api-reference/tools/index.mdx +0 -45
  134. package/.docs/raw/docs/(reference)/api-reference/tools/interactables-legacy.mdx +0 -55
  135. package/.docs/raw/docs/(reference)/api-reference/tools/interactables.mdx +0 -151
  136. package/.docs/raw/docs/(reference)/api-reference/tools/rendering.mdx +0 -106
  137. package/.docs/raw/docs/(reference)/api-reference/tools/status.mdx +0 -62
  138. package/.docs/raw/docs/(reference)/api-reference/tools/toolkits.mdx +0 -178
  139. package/.docs/raw/docs/(reference)/api-reference/transport/assistant-transport.mdx +0 -48
  140. package/.docs/raw/docs/(reference)/api-reference/transport/frame.mdx +0 -62
  141. package/.docs/raw/docs/(reference)/api-reference/transport/index.mdx +0 -22
  142. package/.docs/raw/docs/(reference)/api-reference/utilities/index.mdx +0 -19
  143. package/.docs/raw/docs/(reference)/api-reference/utilities/miscellaneous.mdx +0 -149
  144. package/.docs/raw/docs/(reference)/api-reference/voice/index.mdx +0 -22
  145. package/.docs/raw/docs/(reference)/api-reference/voice/session.mdx +0 -54
  146. package/.docs/raw/docs/(reference)/api-reference/voice/speech-dictation.mdx +0 -36
  147. package/.docs/raw/docs/cloud/ai-sdk-assistant-ui.mdx +0 -527
  148. package/.docs/raw/docs/cloud/ai-sdk.mdx +0 -602
  149. package/.docs/raw/docs/cloud/authorization.mdx +0 -252
  150. package/.docs/raw/docs/cloud/index.mdx +0 -46
  151. package/.docs/raw/docs/cloud/langgraph.mdx +0 -554
  152. package/.docs/raw/docs/copilots/assistant-frame.mdx +0 -400
  153. package/.docs/raw/docs/copilots/make-assistant-visible.mdx +0 -82
  154. package/.docs/raw/docs/copilots/model-context.mdx +0 -156
  155. package/.docs/raw/docs/copilots/motivation.mdx +0 -202
  156. package/.docs/raw/docs/copilots/use-assistant-instructions.mdx +0 -64
  157. package/.docs/raw/docs/guides/attachments.mdx +0 -619
  158. package/.docs/raw/docs/guides/branching.mdx +0 -76
  159. package/.docs/raw/docs/guides/chain-of-thought.mdx +0 -164
  160. package/.docs/raw/docs/guides/chatgpt-subscription.mdx +0 -108
  161. package/.docs/raw/docs/guides/context-api.mdx +0 -619
  162. package/.docs/raw/docs/guides/dictation.mdx +0 -298
  163. package/.docs/raw/docs/guides/editing.mdx +0 -102
  164. package/.docs/raw/docs/guides/electron.mdx +0 -369
  165. package/.docs/raw/docs/guides/headless-composer-input.mdx +0 -113
  166. package/.docs/raw/docs/guides/image-generation.mdx +0 -74
  167. package/.docs/raw/docs/guides/index.mdx +0 -117
  168. package/.docs/raw/docs/guides/input-history.mdx +0 -55
  169. package/.docs/raw/docs/guides/latex.mdx +0 -158
  170. package/.docs/raw/docs/guides/mentions.mdx +0 -575
  171. package/.docs/raw/docs/guides/message-timing.mdx +0 -209
  172. package/.docs/raw/docs/guides/quoting.mdx +0 -169
  173. package/.docs/raw/docs/guides/resumable-stream-deployment.mdx +0 -212
  174. package/.docs/raw/docs/guides/resumable-stream-stores.mdx +0 -152
  175. package/.docs/raw/docs/guides/resumable-streams.mdx +0 -292
  176. package/.docs/raw/docs/guides/slash-commands.mdx +0 -358
  177. package/.docs/raw/docs/guides/speech.mdx +0 -172
  178. package/.docs/raw/docs/guides/suggestions.mdx +0 -384
  179. package/.docs/raw/docs/guides/virtualization.mdx +0 -133
  180. package/.docs/raw/docs/guides/voice.mdx +0 -310
  181. package/.docs/raw/docs/ink/adapters.mdx +0 -99
  182. package/.docs/raw/docs/ink/custom-backend.mdx +0 -254
  183. package/.docs/raw/docs/ink/hooks.mdx +0 -469
  184. package/.docs/raw/docs/ink/index.mdx +0 -236
  185. package/.docs/raw/docs/ink/migration.mdx +0 -138
  186. package/.docs/raw/docs/ink/primitives.mdx +0 -1259
  187. package/.docs/raw/docs/integrations/attachments/custom-adapter.mdx +0 -528
  188. package/.docs/raw/docs/integrations/auth/better-auth.mdx +0 -188
  189. package/.docs/raw/docs/integrations/auth/clerk.mdx +0 -166
  190. package/.docs/raw/docs/integrations/auth/next-auth.mdx +0 -191
  191. package/.docs/raw/docs/integrations/frameworks/ai-sdk.mdx +0 -88
  192. package/.docs/raw/docs/integrations/frameworks/cloudflare-agents/overview.mdx +0 -282
  193. package/.docs/raw/docs/integrations/frameworks/mastra/full-stack.mdx +0 -188
  194. package/.docs/raw/docs/integrations/frameworks/mastra/overview.mdx +0 -57
  195. package/.docs/raw/docs/integrations/frameworks/mastra/separate-server.mdx +0 -201
  196. package/.docs/raw/docs/integrations/gateways/index.mdx +0 -162
  197. package/.docs/raw/docs/integrations/index.mdx +0 -178
  198. package/.docs/raw/docs/integrations/observability/helicone.mdx +0 -129
  199. package/.docs/raw/docs/integrations/observability/langfuse.mdx +0 -161
  200. package/.docs/raw/docs/integrations/observability/langsmith.mdx +0 -151
  201. package/.docs/raw/docs/integrations/persistence/custom-adapter.mdx +0 -773
  202. package/.docs/raw/docs/migrations/deprecation-policy.mdx +0 -42
  203. package/.docs/raw/docs/migrations/index.mdx +0 -50
  204. package/.docs/raw/docs/migrations/react-compatibility.mdx +0 -74
  205. package/.docs/raw/docs/migrations/react-langgraph-v0-7.mdx +0 -328
  206. package/.docs/raw/docs/migrations/toolkit-tools.mdx +0 -236
  207. package/.docs/raw/docs/migrations/v0-11.mdx +0 -172
  208. package/.docs/raw/docs/migrations/v0-12.mdx +0 -302
  209. package/.docs/raw/docs/migrations/v0-14.mdx +0 -297
  210. package/.docs/raw/docs/migrations/v0-15.mdx +0 -270
  211. package/.docs/raw/docs/primitives/action-bar.mdx +0 -352
  212. package/.docs/raw/docs/primitives/assistant-modal.mdx +0 -216
  213. package/.docs/raw/docs/primitives/attachment.mdx +0 -217
  214. package/.docs/raw/docs/primitives/branch-picker.mdx +0 -222
  215. package/.docs/raw/docs/primitives/chain-of-thought.mdx +0 -315
  216. package/.docs/raw/docs/primitives/composer.mdx +0 -659
  217. package/.docs/raw/docs/primitives/error.mdx +0 -142
  218. package/.docs/raw/docs/primitives/index.mdx +0 -99
  219. package/.docs/raw/docs/primitives/message.mdx +0 -618
  220. package/.docs/raw/docs/primitives/selection-toolbar.mdx +0 -191
  221. package/.docs/raw/docs/primitives/suggestion.mdx +0 -254
  222. package/.docs/raw/docs/primitives/thread-list.mdx +0 -467
  223. package/.docs/raw/docs/primitives/thread.mdx +0 -509
  224. package/.docs/raw/docs/react-native/adapters.mdx +0 -94
  225. package/.docs/raw/docs/react-native/custom-backend.mdx +0 -207
  226. package/.docs/raw/docs/react-native/hooks.mdx +0 -339
  227. package/.docs/raw/docs/react-native/index.mdx +0 -289
  228. package/.docs/raw/docs/react-native/migration.mdx +0 -142
  229. package/.docs/raw/docs/react-native/primitives.mdx +0 -839
  230. package/.docs/raw/docs/runtimes/a2a/client-and-hooks.mdx +0 -399
  231. package/.docs/raw/docs/runtimes/a2a/overview.mdx +0 -60
  232. package/.docs/raw/docs/runtimes/a2a/quickstart.mdx +0 -216
  233. package/.docs/raw/docs/runtimes/ag-ui/agent-state.mdx +0 -124
  234. package/.docs/raw/docs/runtimes/ag-ui/overview.mdx +0 -70
  235. package/.docs/raw/docs/runtimes/ag-ui/quickstart.mdx +0 -243
  236. package/.docs/raw/docs/runtimes/ag-ui/runtime-options.mdx +0 -255
  237. package/.docs/raw/docs/runtimes/ai-sdk/overview.mdx +0 -61
  238. package/.docs/raw/docs/runtimes/ai-sdk/v4-legacy.mdx +0 -122
  239. package/.docs/raw/docs/runtimes/ai-sdk/v5-legacy.mdx +0 -135
  240. package/.docs/raw/docs/runtimes/ai-sdk/v6-legacy.mdx +0 -636
  241. package/.docs/raw/docs/runtimes/ai-sdk/v7.mdx +0 -716
  242. package/.docs/raw/docs/runtimes/claude-managed-agents.mdx +0 -118
  243. package/.docs/raw/docs/runtimes/concepts/adapters.mdx +0 -265
  244. package/.docs/raw/docs/runtimes/concepts/architecture.mdx +0 -167
  245. package/.docs/raw/docs/runtimes/concepts/stability.mdx +0 -68
  246. package/.docs/raw/docs/runtimes/concepts/threads.mdx +0 -513
  247. package/.docs/raw/docs/runtimes/custom/assistant-transport.mdx +0 -763
  248. package/.docs/raw/docs/runtimes/custom/data-stream.mdx +0 -339
  249. package/.docs/raw/docs/runtimes/custom/external-store.mdx +0 -957
  250. package/.docs/raw/docs/runtimes/custom/local-runtime.mdx +0 -902
  251. package/.docs/raw/docs/runtimes/custom/overview.mdx +0 -71
  252. package/.docs/raw/docs/runtimes/eve/overview.mdx +0 -151
  253. package/.docs/raw/docs/runtimes/eve/quickstart.mdx +0 -192
  254. package/.docs/raw/docs/runtimes/google-adk/api.mdx +0 -256
  255. package/.docs/raw/docs/runtimes/google-adk/hooks.mdx +0 -784
  256. package/.docs/raw/docs/runtimes/google-adk/overview.mdx +0 -69
  257. package/.docs/raw/docs/runtimes/google-adk/quickstart.mdx +0 -229
  258. package/.docs/raw/docs/runtimes/langchain.mdx +0 -901
  259. package/.docs/raw/docs/runtimes/langgraph/agent-state.mdx +0 -181
  260. package/.docs/raw/docs/runtimes/langgraph/generative-ui.mdx +0 -305
  261. package/.docs/raw/docs/runtimes/langgraph/interrupts.mdx +0 -104
  262. package/.docs/raw/docs/runtimes/langgraph/overview.mdx +0 -84
  263. package/.docs/raw/docs/runtimes/langgraph/quickstart.mdx +0 -496
  264. package/.docs/raw/docs/runtimes/langgraph/streaming.mdx +0 -144
  265. package/.docs/raw/docs/runtimes/langgraph/threads.mdx +0 -113
  266. package/.docs/raw/docs/runtimes/langgraph/tutorial/introduction.mdx +0 -29
  267. package/.docs/raw/docs/runtimes/langgraph/tutorial/part-1.mdx +0 -93
  268. package/.docs/raw/docs/runtimes/langgraph/tutorial/part-2.mdx +0 -347
  269. package/.docs/raw/docs/runtimes/langgraph/tutorial/part-3.mdx +0 -393
  270. package/.docs/raw/docs/runtimes/opencode/hooks.mdx +0 -194
  271. package/.docs/raw/docs/runtimes/opencode/overview.mdx +0 -58
  272. package/.docs/raw/docs/runtimes/opencode/quickstart.mdx +0 -119
  273. package/.docs/raw/docs/runtimes/pick-a-runtime.mdx +0 -133
  274. package/.docs/raw/docs/tools/a2ui.mdx +0 -107
  275. package/.docs/raw/docs/tools/backend.mdx +0 -147
  276. package/.docs/raw/docs/tools/defining-tools.mdx +0 -574
  277. package/.docs/raw/docs/tools/dynamic-tools.mdx +0 -112
  278. package/.docs/raw/docs/tools/generative-ui-primitive.mdx +0 -180
  279. package/.docs/raw/docs/tools/generative-ui-slack.mdx +0 -167
  280. package/.docs/raw/docs/tools/generative-ui-teams.mdx +0 -160
  281. package/.docs/raw/docs/tools/generative-ui.mdx +0 -322
  282. package/.docs/raw/docs/tools/index.mdx +0 -72
  283. package/.docs/raw/docs/tools/interactables.mdx +0 -1084
  284. package/.docs/raw/docs/tools/mcp-apps.mdx +0 -346
  285. package/.docs/raw/docs/tools/mcp.mdx +0 -466
  286. package/.docs/raw/docs/tools/multi-agent.mdx +0 -237
  287. package/.docs/raw/docs/tools/openui.mdx +0 -175
  288. package/.docs/raw/docs/tools/tool-ui.mdx +0 -1008
  289. package/.docs/raw/docs/tools/user-managed-mcp.mdx +0 -428
  290. package/.docs/raw/docs/ui/accordion.mdx +0 -266
  291. package/.docs/raw/docs/ui/assistant-modal.mdx +0 -166
  292. package/.docs/raw/docs/ui/assistant-sidebar.mdx +0 -89
  293. package/.docs/raw/docs/ui/attachment.mdx +0 -259
  294. package/.docs/raw/docs/ui/badge.mdx +0 -150
  295. package/.docs/raw/docs/ui/composer-trigger-popover.mdx +0 -212
  296. package/.docs/raw/docs/ui/context-display.mdx +0 -148
  297. package/.docs/raw/docs/ui/diff-viewer.mdx +0 -280
  298. package/.docs/raw/docs/ui/directive-text.mdx +0 -114
  299. package/.docs/raw/docs/ui/dot-matrix.mdx +0 -133
  300. package/.docs/raw/docs/ui/file.mdx +0 -159
  301. package/.docs/raw/docs/ui/follow-up-suggestions.mdx +0 -82
  302. package/.docs/raw/docs/ui/image.mdx +0 -102
  303. package/.docs/raw/docs/ui/markdown.mdx +0 -64
  304. package/.docs/raw/docs/ui/mcp-config.mdx +0 -107
  305. package/.docs/raw/docs/ui/mermaid.mdx +0 -92
  306. package/.docs/raw/docs/ui/message-timing.mdx +0 -93
  307. package/.docs/raw/docs/ui/model-selector.mdx +0 -455
  308. package/.docs/raw/docs/ui/number-roll.mdx +0 -154
  309. package/.docs/raw/docs/ui/part-grouping.mdx +0 -614
  310. package/.docs/raw/docs/ui/quote.mdx +0 -211
  311. package/.docs/raw/docs/ui/reasoning.mdx +0 -186
  312. package/.docs/raw/docs/ui/scrollbar.mdx +0 -77
  313. package/.docs/raw/docs/ui/select.mdx +0 -254
  314. package/.docs/raw/docs/ui/sources.mdx +0 -177
  315. package/.docs/raw/docs/ui/streamdown.mdx +0 -392
  316. package/.docs/raw/docs/ui/syntax-highlighting.mdx +0 -205
  317. package/.docs/raw/docs/ui/tabs.mdx +0 -271
  318. package/.docs/raw/docs/ui/thread-list.mdx +0 -372
  319. package/.docs/raw/docs/ui/thread.mdx +0 -512
  320. package/.docs/raw/docs/ui/tool-fallback.mdx +0 -127
  321. package/.docs/raw/docs/ui/tool-group.mdx +0 -240
  322. package/.docs/raw/docs/ui/voice.mdx +0 -173
  323. package/.docs/raw/docs/utilities/heat-graph.mdx +0 -237
  324. package/.docs/raw/docs/utilities/react-o11y.mdx +0 -362
  325. package/.docs/raw/docs/utilities/tw-shimmer.mdx +0 -212
  326. package/dist/constants.d.ts +0 -14
  327. package/dist/constants.d.ts.map +0 -1
  328. package/dist/constants.js +0 -19
  329. package/dist/constants.js.map +0 -1
  330. package/dist/prepare-docs/code-examples.d.ts +0 -5
  331. package/dist/prepare-docs/code-examples.d.ts.map +0 -1
  332. package/dist/prepare-docs/code-examples.js +0 -117
  333. package/dist/prepare-docs/code-examples.js.map +0 -1
  334. package/dist/prepare-docs/copy-raw.d.ts +0 -5
  335. package/dist/prepare-docs/copy-raw.d.ts.map +0 -1
  336. package/dist/prepare-docs/copy-raw.js +0 -49
  337. package/dist/prepare-docs/copy-raw.js.map +0 -1
  338. package/dist/prepare-docs/prepare.d.ts +0 -1
  339. package/dist/prepare-docs/prepare.js +0 -22
  340. package/dist/prepare-docs/prepare.js.map +0 -1
  341. package/dist/prompts/xulux-playground.d.ts +0 -12
  342. package/dist/prompts/xulux-playground.d.ts.map +0 -1
  343. package/dist/prompts/xulux-playground.js +0 -33
  344. package/dist/prompts/xulux-playground.js.map +0 -1
  345. package/dist/tools/docs.d.ts +0 -22
  346. package/dist/tools/docs.d.ts.map +0 -1
  347. package/dist/tools/docs.js +0 -177
  348. package/dist/tools/docs.js.map +0 -1
  349. package/dist/tools/examples.d.ts +0 -24
  350. package/dist/tools/examples.d.ts.map +0 -1
  351. package/dist/tools/examples.js +0 -87
  352. package/dist/tools/examples.js.map +0 -1
  353. package/dist/tools/resources.d.ts +0 -6
  354. package/dist/tools/resources.d.ts.map +0 -1
  355. package/dist/tools/resources.js +0 -75
  356. package/dist/tools/resources.js.map +0 -1
  357. package/dist/tools/search.d.ts +0 -24
  358. package/dist/tools/search.d.ts.map +0 -1
  359. package/dist/tools/search.js +0 -39
  360. package/dist/tools/search.js.map +0 -1
  361. package/dist/tools/tests/mcp-test-client.d.ts +0 -15
  362. package/dist/tools/tests/mcp-test-client.d.ts.map +0 -1
  363. package/dist/tools/tests/mcp-test-client.js +0 -68
  364. package/dist/tools/tests/mcp-test-client.js.map +0 -1
  365. package/dist/tools/tests/test-setup.d.ts +0 -7
  366. package/dist/tools/tests/test-setup.d.ts.map +0 -1
  367. package/dist/tools/tests/test-setup.js +0 -36
  368. package/dist/tools/tests/test-setup.js.map +0 -1
  369. package/dist/tools/xulux-templates.d.ts +0 -58
  370. package/dist/tools/xulux-templates.d.ts.map +0 -1
  371. package/dist/tools/xulux-templates.js +0 -84
  372. package/dist/tools/xulux-templates.js.map +0 -1
  373. package/dist/utils/cache.d.ts +0 -5
  374. package/dist/utils/cache.d.ts.map +0 -1
  375. package/dist/utils/cache.js +0 -18
  376. package/dist/utils/cache.js.map +0 -1
  377. package/dist/utils/logger.d.ts +0 -10
  378. package/dist/utils/logger.d.ts.map +0 -1
  379. package/dist/utils/logger.js +0 -20
  380. package/dist/utils/logger.js.map +0 -1
  381. package/dist/utils/mcp-format.d.ts +0 -11
  382. package/dist/utils/mcp-format.d.ts.map +0 -1
  383. package/dist/utils/mcp-format.js +0 -14
  384. package/dist/utils/mcp-format.js.map +0 -1
  385. package/dist/utils/mdx.d.ts +0 -12
  386. package/dist/utils/mdx.d.ts.map +0 -1
  387. package/dist/utils/mdx.js +0 -45
  388. package/dist/utils/mdx.js.map +0 -1
  389. package/dist/utils/paths.d.ts +0 -12
  390. package/dist/utils/paths.d.ts.map +0 -1
  391. package/dist/utils/paths.js +0 -93
  392. package/dist/utils/paths.js.map +0 -1
  393. package/dist/utils/search.d.ts +0 -10
  394. package/dist/utils/search.d.ts.map +0 -1
  395. package/dist/utils/search.js +0 -97
  396. package/dist/utils/search.js.map +0 -1
  397. package/dist/utils/security.d.ts +0 -5
  398. package/dist/utils/security.d.ts.map +0 -1
  399. package/dist/utils/security.js +0 -22
  400. package/dist/utils/security.js.map +0 -1
  401. package/dist/xulux/catalog-client.d.ts +0 -14
  402. package/dist/xulux/catalog-client.d.ts.map +0 -1
  403. package/dist/xulux/catalog-client.js +0 -67
  404. package/dist/xulux/catalog-client.js.map +0 -1
  405. package/dist/xulux/fallback-catalog.d.ts +0 -7
  406. package/dist/xulux/fallback-catalog.d.ts.map +0 -1
  407. package/dist/xulux/fallback-catalog.js +0 -47
  408. package/dist/xulux/fallback-catalog.js.map +0 -1
  409. package/dist/xulux/fetch-sandbox.d.ts +0 -5
  410. package/dist/xulux/fetch-sandbox.d.ts.map +0 -1
  411. package/dist/xulux/fetch-sandbox.js +0 -40
  412. package/dist/xulux/fetch-sandbox.js.map +0 -1
  413. package/dist/xulux/template-service.d.ts +0 -84
  414. package/dist/xulux/template-service.d.ts.map +0 -1
  415. package/dist/xulux/template-service.js +0 -223
  416. package/dist/xulux/template-service.js.map +0 -1
  417. package/dist/xulux/types.d.ts +0 -55
  418. package/dist/xulux/types.d.ts.map +0 -1
  419. package/dist/xulux/types.js +0 -6
  420. package/dist/xulux/types.js.map +0 -1
  421. package/src/constants.ts +0 -24
  422. package/src/prepare-docs/code-examples.ts +0 -158
  423. package/src/prepare-docs/copy-raw.ts +0 -50
  424. package/src/prepare-docs/prepare.ts +0 -24
  425. package/src/prompts/xulux-playground.ts +0 -36
  426. package/src/tools/docs.ts +0 -255
  427. package/src/tools/examples.ts +0 -114
  428. package/src/tools/resources.ts +0 -111
  429. package/src/tools/search.ts +0 -46
  430. package/src/tools/tests/completions.test.ts +0 -60
  431. package/src/tools/tests/directory-size-cap.test.ts +0 -50
  432. package/src/tools/tests/docs.test.ts +0 -144
  433. package/src/tools/tests/examples.test.ts +0 -94
  434. package/src/tools/tests/integration.test.ts +0 -45
  435. package/src/tools/tests/json-parsing.test.ts +0 -23
  436. package/src/tools/tests/listings-cache.test.ts +0 -19
  437. package/src/tools/tests/mcp-protocol.test.ts +0 -216
  438. package/src/tools/tests/mcp-test-client.ts +0 -111
  439. package/src/tools/tests/path-traversal.test.ts +0 -81
  440. package/src/tools/tests/resources.test.ts +0 -133
  441. package/src/tools/tests/search.test.ts +0 -37
  442. package/src/tools/tests/test-setup.ts +0 -50
  443. package/src/tools/tests/xulux-templates.test.ts +0 -262
  444. package/src/tools/xulux-templates.ts +0 -141
  445. package/src/utils/cache.ts +0 -20
  446. package/src/utils/logger.ts +0 -20
  447. package/src/utils/mcp-format.ts +0 -14
  448. package/src/utils/mdx.ts +0 -59
  449. package/src/utils/paths.ts +0 -139
  450. package/src/utils/search.ts +0 -131
  451. package/src/utils/security.ts +0 -52
  452. package/src/utils/tests/cache.test.ts +0 -51
  453. package/src/utils/tests/mcp-format.test.ts +0 -22
  454. package/src/utils/tests/security.test.ts +0 -119
  455. package/src/xulux/catalog-client.ts +0 -105
  456. package/src/xulux/fallback-catalog.ts +0 -63
  457. package/src/xulux/fetch-sandbox.ts +0 -56
  458. package/src/xulux/template-service.ts +0 -406
  459. package/src/xulux/types.ts +0 -60
@@ -1,1812 +0,0 @@
1
- # Example: with-generative-ui
2
-
3
- ## app/api/chat/route.ts
4
-
5
- ```typescript
6
- import { openai } from "@ai-sdk/openai";
7
- import {
8
- streamText,
9
- convertToModelMessages,
10
- stepCountIs,
11
- tool,
12
- zodSchema,
13
- } from "ai";
14
- import type { UIMessage } from "ai";
15
- import { z } from "zod";
16
- import {
17
- AISDKToolkit,
18
- type AISDKToolkitToolsOptions,
19
- } from "@assistant-ui/react-ai-sdk";
20
- import {
21
- renderGuiToolDescription,
22
- renderGuiToolInputSchema,
23
- } from "../../../lib/render-gui-tool";
24
- import toolkit from "../../toolkit";
25
-
26
- export const maxDuration = 30;
27
-
28
- const aiToolkit = new AISDKToolkit({ toolkit });
29
-
30
- type FrontendToolDefs = NonNullable<AISDKToolkitToolsOptions["frontend"]>;
31
-
32
- export async function POST(req: Request) {
33
- const {
34
- messages,
35
- system,
36
- tools: clientTools,
37
- }: {
38
- messages: UIMessage[];
39
- system?: string;
40
- tools?: FrontendToolDefs;
41
- } = await req.json();
42
-
43
- const toolkitTools = await aiToolkit.tools({
44
- ...(clientTools && { frontend: clientTools }),
45
- });
46
-
47
- const result = streamText({
48
- model: openai("gpt-5.6-luna"),
49
- messages: await convertToModelMessages(messages),
50
- stopWhen: stepCountIs(10),
51
- ...(system ? { system } : {}),
52
- tools: {
53
- ...toolkitTools,
54
-
55
- render_gui: tool({
56
- description: renderGuiToolDescription,
57
- inputSchema: zodSchema(renderGuiToolInputSchema),
58
- execute: async (input) => ({
59
- spec: input.spec,
60
- }),
61
- }),
62
-
63
- // Backend tool: generate chart data
64
- generate_chart: tool({
65
- description:
66
- "Generate a chart. Return structured data for rendering a bar, line, or pie chart. Use this when the user asks for data visualization, charts, graphs, or comparisons.",
67
- inputSchema: zodSchema(
68
- z.object({
69
- title: z.string().describe("Chart title"),
70
- type: z
71
- .enum(["bar", "line", "pie"])
72
- .describe("Chart type to render"),
73
- data: z
74
- .array(z.record(z.string(), z.union([z.string(), z.number()])))
75
- .describe(
76
- "Array of data objects, e.g. [{month: 'Jan', revenue: 100}]",
77
- ),
78
- xKey: z
79
- .string()
80
- .describe("Key in each data object to use for the x-axis/labels"),
81
- dataKeys: z
82
- .array(z.string())
83
- .describe("Keys in each data object to chart as series/values"),
84
- }),
85
- ),
86
- execute: async () => {
87
- return { success: true };
88
- },
89
- }),
90
-
91
- // Backend tool: show location on map
92
- show_location: tool({
93
- description:
94
- "Show a location on a map. Use this when the user asks about a place, wants to see directions, or needs to see a location.",
95
- inputSchema: zodSchema(
96
- z.object({
97
- name: z.string().describe("Name of the place"),
98
- address: z.string().optional().describe("Street address"),
99
- lat: z.number().describe("Latitude"),
100
- lng: z.number().describe("Longitude"),
101
- }),
102
- ),
103
- execute: async () => {
104
- return { success: true };
105
- },
106
- }),
107
- },
108
- } as Parameters<typeof streamText>[0]);
109
-
110
- return result.toUIMessageStreamResponse();
111
- }
112
-
113
- ```
114
-
115
- ## app/api/present/route.ts
116
-
117
- ```typescript
118
- import { openai } from "@ai-sdk/openai";
119
- import { streamText, convertToModelMessages, stepCountIs } from "ai";
120
- import type { UIMessage } from "ai";
121
- import {
122
- AISDKToolkit,
123
- type AISDKToolkitToolsOptions,
124
- } from "@assistant-ui/react-ai-sdk";
125
- import presentToolkit from "../../present-toolkit";
126
-
127
- export const maxDuration = 30;
128
-
129
- const aiToolkit = new AISDKToolkit({ toolkit: presentToolkit });
130
-
131
- type FrontendToolDefs = NonNullable<AISDKToolkitToolsOptions["frontend"]>;
132
-
133
- export async function POST(req: Request) {
134
- const {
135
- messages,
136
- system,
137
- tools: clientTools,
138
- }: {
139
- messages: UIMessage[];
140
- system?: string;
141
- tools?: FrontendToolDefs;
142
- } = await req.json();
143
-
144
- const result = streamText({
145
- model: openai("gpt-5.6-luna"),
146
- messages: await convertToModelMessages(messages),
147
- stopWhen: stepCountIs(10),
148
- ...(system ? { system } : {}),
149
- tools: await aiToolkit.tools({
150
- ...(clientTools && { frontend: clientTools }),
151
- }),
152
- });
153
-
154
- return result.toUIMessageStreamResponse();
155
- }
156
-
157
- ```
158
-
159
- ## app/globals.css
160
-
161
- ```css
162
- @import "tailwindcss";
163
- @import "tw-animate-css";
164
-
165
- @source "../../../packages/ui/src";
166
-
167
- @custom-variant dark (&:is(.dark *));
168
-
169
- @theme inline {
170
- --radius-sm: calc(var(--radius) - 4px);
171
- --radius-md: calc(var(--radius) - 2px);
172
- --radius-lg: var(--radius);
173
- --radius-xl: calc(var(--radius) + 4px);
174
- --color-background: var(--background);
175
- --color-foreground: var(--foreground);
176
- --color-card: var(--card);
177
- --color-card-foreground: var(--card-foreground);
178
- --color-popover: var(--popover);
179
- --color-popover-foreground: var(--popover-foreground);
180
- --color-primary: var(--primary);
181
- --color-primary-foreground: var(--primary-foreground);
182
- --color-secondary: var(--secondary);
183
- --color-secondary-foreground: var(--secondary-foreground);
184
- --color-muted: var(--muted);
185
- --color-muted-foreground: var(--muted-foreground);
186
- --color-accent: var(--accent);
187
- --color-accent-foreground: var(--accent-foreground);
188
- --color-destructive: var(--destructive);
189
- --color-border: var(--border);
190
- --color-input: var(--input);
191
- --color-ring: var(--ring);
192
- --color-chart-1: var(--chart-1);
193
- --color-chart-2: var(--chart-2);
194
- --color-chart-3: var(--chart-3);
195
- --color-chart-4: var(--chart-4);
196
- --color-chart-5: var(--chart-5);
197
- --color-sidebar: var(--sidebar);
198
- --color-sidebar-foreground: var(--sidebar-foreground);
199
- --color-sidebar-primary: var(--sidebar-primary);
200
- --color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
201
- --color-sidebar-accent: var(--sidebar-accent);
202
- --color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
203
- --color-sidebar-border: var(--sidebar-border);
204
- --color-sidebar-ring: var(--sidebar-ring);
205
- }
206
-
207
- :root {
208
- --radius: 0.625rem;
209
- --background: oklch(1 0 0);
210
- --foreground: oklch(0.141 0.005 285.823);
211
- --card: oklch(1 0 0);
212
- --card-foreground: oklch(0.141 0.005 285.823);
213
- --popover: oklch(1 0 0);
214
- --popover-foreground: oklch(0.141 0.005 285.823);
215
- --primary: oklch(0.21 0.006 285.885);
216
- --primary-foreground: oklch(0.985 0 0);
217
- --secondary: oklch(0.967 0.001 286.375);
218
- --secondary-foreground: oklch(0.21 0.006 285.885);
219
- --muted: oklch(0.967 0.001 286.375);
220
- --muted-foreground: oklch(0.552 0.016 285.938);
221
- --accent: oklch(0.967 0.001 286.375);
222
- --accent-foreground: oklch(0.21 0.006 285.885);
223
- --destructive: oklch(0.577 0.245 27.325);
224
- --border: oklch(0.92 0.004 286.32);
225
- --input: oklch(0.92 0.004 286.32);
226
- --ring: oklch(0.705 0.015 286.067);
227
- --chart-1: oklch(0.646 0.222 41.116);
228
- --chart-2: oklch(0.6 0.118 184.704);
229
- --chart-3: oklch(0.398 0.07 227.392);
230
- --chart-4: oklch(0.828 0.189 84.429);
231
- --chart-5: oklch(0.769 0.188 70.08);
232
- --sidebar: oklch(0.985 0 0);
233
- --sidebar-foreground: oklch(0.141 0.005 285.823);
234
- --sidebar-primary: oklch(0.21 0.006 285.885);
235
- --sidebar-primary-foreground: oklch(0.985 0 0);
236
- --sidebar-accent: oklch(0.967 0.001 286.375);
237
- --sidebar-accent-foreground: oklch(0.21 0.006 285.885);
238
- --sidebar-border: oklch(0.92 0.004 286.32);
239
- --sidebar-ring: oklch(0.705 0.015 286.067);
240
- }
241
-
242
- .dark {
243
- --background: oklch(0.141 0.005 285.823);
244
- --foreground: oklch(0.985 0 0);
245
- --card: oklch(0.21 0.006 285.885);
246
- --card-foreground: oklch(0.985 0 0);
247
- --popover: oklch(0.21 0.006 285.885);
248
- --popover-foreground: oklch(0.985 0 0);
249
- --primary: oklch(0.92 0.004 286.32);
250
- --primary-foreground: oklch(0.21 0.006 285.885);
251
- --secondary: oklch(0.274 0.006 286.033);
252
- --secondary-foreground: oklch(0.985 0 0);
253
- --muted: oklch(0.274 0.006 286.033);
254
- --muted-foreground: oklch(0.705 0.015 286.067);
255
- --accent: oklch(0.274 0.006 286.033);
256
- --accent-foreground: oklch(0.985 0 0);
257
- --destructive: oklch(0.704 0.191 22.216);
258
- --border: oklch(1 0 0 / 10%);
259
- --input: oklch(1 0 0 / 15%);
260
- --ring: oklch(0.552 0.016 285.938);
261
- --chart-1: oklch(0.488 0.243 264.376);
262
- --chart-2: oklch(0.696 0.17 162.48);
263
- --chart-3: oklch(0.769 0.188 70.08);
264
- --chart-4: oklch(0.627 0.265 303.9);
265
- --chart-5: oklch(0.645 0.246 16.439);
266
- --sidebar: oklch(0.21 0.006 285.885);
267
- --sidebar-foreground: oklch(0.985 0 0);
268
- --sidebar-primary: oklch(0.488 0.243 264.376);
269
- --sidebar-primary-foreground: oklch(0.985 0 0);
270
- --sidebar-accent: oklch(0.274 0.006 286.033);
271
- --sidebar-accent-foreground: oklch(0.985 0 0);
272
- --sidebar-border: oklch(1 0 0 / 10%);
273
- --sidebar-ring: oklch(0.552 0.016 285.938);
274
- }
275
-
276
- @layer base {
277
- * {
278
- @apply border-border outline-ring/50;
279
- }
280
- body {
281
- @apply bg-background text-foreground;
282
- }
283
- }
284
-
285
- ```
286
-
287
- ## app/gui-chat/page.tsx
288
-
289
- ```tsx
290
- "use client";
291
-
292
- import { ExampleNav } from "@/components/example-nav";
293
- import { AssistantMessageGui } from "@/components/assistant-message-gui";
294
- import {
295
- Thread,
296
- type ThreadComponents,
297
- } from "@/components/assistant-ui/thread";
298
- import {
299
- AssistantRuntimeProvider,
300
- AuiConfig,
301
- Suggestions,
302
- useAssistantInstructions,
303
- } from "@assistant-ui/react";
304
- import { useChatRuntime } from "@assistant-ui/react-ai-sdk";
305
- import { lastAssistantMessageIsCompleteWithToolCalls } from "ai";
306
- import { renderGuiChatInstructions } from "@/lib/render-gui-tool";
307
-
308
- const GuiChatInstructions = () => {
309
- useAssistantInstructions(renderGuiChatInstructions);
310
- return null;
311
- };
312
-
313
- const GuiWelcome = () => {
314
- return (
315
- <div className="aui-thread-welcome-root mb-6 flex flex-col items-center gap-1 px-4 text-center">
316
- <h1 className="aui-thread-welcome-message-inner fade-in slide-in-from-bottom-1 animate-in fill-mode-both text-2xl font-semibold duration-200">
317
- Compose UI from a spec
318
- </h1>
319
- <p className="aui-thread-welcome-message-inner fade-in slide-in-from-bottom-1 animate-in fill-mode-both text-muted-foreground text-xl delay-75 duration-200">
320
- Ask the agent to call render_gui with Card, Button, and Stack.
321
- </p>
322
- </div>
323
- );
324
- };
325
-
326
- const THREAD_COMPONENTS: ThreadComponents = {
327
- AssistantMessage: AssistantMessageGui,
328
- Welcome: GuiWelcome,
329
- };
330
-
331
- export default function GuiChatPage() {
332
- const runtime = useChatRuntime({
333
- sendAutomaticallyWhen: lastAssistantMessageIsCompleteWithToolCalls,
334
- });
335
-
336
- const config = AuiConfig({
337
- suggestions: Suggestions([
338
- {
339
- title: "Welcome card",
340
- label: "with a Get started button",
341
- prompt:
342
- "Show me a welcome card with a Get started button using render_gui.",
343
- },
344
- {
345
- title: "Stats dashboard",
346
- label: "revenue and users",
347
- prompt:
348
- "Use render_gui to show a stats card with Revenue $124k and Active Users 8.2k.",
349
- },
350
- ]),
351
- });
352
-
353
- return (
354
- <AssistantRuntimeProvider config={config} runtime={runtime}>
355
- <GuiChatInstructions />
356
- <div className="flex h-full flex-col">
357
- <ExampleNav />
358
- <main className="min-h-0 flex-1">
359
- <Thread components={THREAD_COMPONENTS} />
360
- </main>
361
- </div>
362
- </AssistantRuntimeProvider>
363
- );
364
- }
365
-
366
- ```
367
-
368
- ## app/layout.tsx
369
-
370
- ```tsx
371
- import type { Metadata } from "next";
372
- import { GenerativeUIStyle } from "@/components/generative-ui-style";
373
- import "./globals.css";
374
-
375
- export const metadata: Metadata = {
376
- title: "assistant-ui Generative UI Example",
377
- description:
378
- "Example showcasing model-composed interfaces with the present tool and a custom component vocabulary",
379
- };
380
-
381
- export default function RootLayout({
382
- children,
383
- }: Readonly<{
384
- children: React.ReactNode;
385
- }>) {
386
- return (
387
- <html lang="en">
388
- <head>
389
- <GenerativeUIStyle />
390
- </head>
391
- <body className="h-dvh">{children}</body>
392
- </html>
393
- );
394
- }
395
-
396
- ```
397
-
398
- ## app/page.tsx
399
-
400
- ```tsx
401
- "use client";
402
-
403
- import { Thread } from "@/components/assistant-ui/thread";
404
- import {
405
- AssistantRuntimeProvider,
406
- AuiConfig,
407
- Suggestions,
408
- Tools,
409
- } from "@assistant-ui/react";
410
- import {
411
- AssistantChatTransport,
412
- useChatRuntime,
413
- } from "@assistant-ui/react-ai-sdk";
414
- import { lastAssistantMessageIsCompleteWithToolCalls } from "ai";
415
- import { ExampleNav } from "@/components/example-nav";
416
- import toolkit from "./present-toolkit";
417
-
418
- export default function Home() {
419
- const runtime = useChatRuntime({
420
- transport: new AssistantChatTransport({ api: "/api/present" }),
421
- sendAutomaticallyWhen: lastAssistantMessageIsCompleteWithToolCalls,
422
- });
423
-
424
- const config = AuiConfig({
425
- tools: Tools({ toolkit }),
426
- suggestions: Suggestions([
427
- {
428
- title: "Sales dashboard",
429
- label: "for last quarter",
430
- prompt:
431
- "Show me a Q2 2026 sales dashboard. Revenue was $412k in April, $488k in May and $551k in June, on 1,284 orders, at a 3.4% conversion rate.",
432
- },
433
- {
434
- title: "Product analytics",
435
- label: "activation and retention",
436
- prompt:
437
- "How did we trend over the last six weeks? Activation went 41%, 44%, 43%, 48%, 52%, 55%, and week-4 retention went 22%, 24%, 23%, 27%, 29%, 31%.",
438
- },
439
- {
440
- title: "Support overview",
441
- label: "tickets and response time",
442
- prompt:
443
- "Give me a support overview. Open tickets: 12 urgent, 38 high, 91 normal, 24 low. Median first response is 47 minutes, down from 62 last week.",
444
- },
445
- {
446
- title: "Channel performance",
447
- label: "compare acquisition sources",
448
- prompt:
449
- "Compare our acquisition channels. Search: $18k spend, 420 conversions. Social: $11k, 260. Email: $3k, 190. Referral: $6k, 150.",
450
- },
451
- ]),
452
- });
453
-
454
- return (
455
- <AssistantRuntimeProvider config={config} runtime={runtime}>
456
- <div className="flex h-full flex-col">
457
- <ExampleNav />
458
- <main className="min-h-0 flex-1">
459
- <Thread />
460
- </main>
461
- </div>
462
- </AssistantRuntimeProvider>
463
- );
464
- }
465
-
466
- ```
467
-
468
- ## app/present-toolkit.tsx
469
-
470
- ```tsx
471
- "use generative";
472
-
473
- import { defineToolkit } from "@assistant-ui/react";
474
- import {
475
- JSONGenerativeUI,
476
- defaultGenerativeUILibrary,
477
- defineGenerativeComponents,
478
- } from "@assistant-ui/react-generative-ui";
479
- import { styledGenerativeUILibrary } from "@/components/assistant-ui/generative-ui";
480
- import { DashboardHeader } from "@/components/dashboard-header";
481
- import { z } from "zod";
482
-
483
- const markdown = defaultGenerativeUILibrary.Markdown!;
484
-
485
- const generative = new JSONGenerativeUI({
486
- library: {
487
- ...defaultGenerativeUILibrary,
488
- ...defineGenerativeComponents({
489
- Markdown: {
490
- properties: markdown.properties,
491
- streamProperties: markdown.streamProperties,
492
- description:
493
- "A markdown string, rendered with GitHub-flavored markdown.",
494
- render: styledGenerativeUILibrary.Markdown!.render,
495
- },
496
- DashboardHeader: {
497
- description:
498
- "A heading for a dashboard, with an optional description and reporting period.",
499
- properties: z.object({
500
- title: z.string().describe("The dashboard title."),
501
- description: z
502
- .string()
503
- .optional()
504
- .describe("A short description of the dashboard."),
505
- period: z
506
- .string()
507
- .optional()
508
- .describe("The reporting period shown beside the title."),
509
- }),
510
- render: (props) => <DashboardHeader {...props} />,
511
- },
512
- }),
513
- },
514
- });
515
-
516
- export default defineToolkit({
517
- present: generative.present({ display: "standalone" }),
518
- });
519
-
520
- ```
521
-
522
- ## app/primitive/page.tsx
523
-
524
- ```tsx
525
- "use client";
526
-
527
- import { GenerativeUIRender, type GenerativeUISpec } from "@assistant-ui/react";
528
- import {
529
- UnknownComponentFallback,
530
- componentsAllowlist,
531
- } from "@/components/gui";
532
- import { ExampleNav } from "@/components/example-nav";
533
-
534
- /**
535
- * Self-contained demo of the GenerativeUI primitive.
536
- *
537
- * Renders a hand-written `GenerativeUISpec` directly via `GenerativeUIRender`,
538
- * the same renderer that backs `MessagePrimitive.GenerativeUI` when a
539
- * `generative-ui` part flows through `MessagePrimitive.Parts`.
540
- *
541
- * In a real integration the spec arrives as a `generative-ui` message part
542
- * from the agent; the consumer-provided allowlist is the security boundary.
543
- */
544
- const exampleSpec: GenerativeUISpec = {
545
- root: [
546
- {
547
- component: "Card",
548
- props: {
549
- title: "Welcome",
550
- description: "An agent-described card with a primary CTA.",
551
- },
552
- children: [
553
- {
554
- component: "Stack",
555
- props: { gap: "sm" },
556
- children: [
557
- {
558
- component: "Text",
559
- children: [
560
- "This card was rendered from a JSON spec emitted by the agent.",
561
- ],
562
- },
563
- {
564
- component: "Button",
565
- props: {
566
- label: "Get started",
567
- variant: "primary",
568
- onClickPrompt: "open onboarding",
569
- },
570
- },
571
- ],
572
- },
573
- ],
574
- },
575
- {
576
- component: "Card",
577
- props: { title: "Stats" },
578
- children: [
579
- {
580
- component: "Stack",
581
- props: { direction: "row", gap: "md" },
582
- children: [
583
- { component: "Stat", props: { label: "Revenue", value: "$124k" } },
584
- {
585
- component: "Stat",
586
- props: { label: "Active Users", value: "8.2k" },
587
- },
588
- { component: "Stat", props: { label: "Latency", value: "42ms" } },
589
- ],
590
- },
591
- ],
592
- },
593
- ],
594
- };
595
-
596
- export default function GenerativeUIPrimitivePage() {
597
- return (
598
- <div className="flex h-full flex-col">
599
- <ExampleNav />
600
- <main className="mx-auto flex h-full max-w-2xl flex-col gap-6 overflow-y-auto p-8">
601
- <header>
602
- <h1 className="text-2xl font-bold">MessagePrimitive.GenerativeUI</h1>
603
- <p className="text-muted-foreground mt-1 text-sm">
604
- Agent-described React UI rendered from a JSON spec via a
605
- consumer-provided component allowlist.
606
- </p>
607
- </header>
608
-
609
- <section className="flex flex-col gap-4">
610
- <GenerativeUIRender
611
- spec={exampleSpec}
612
- components={componentsAllowlist}
613
- Fallback={UnknownComponentFallback}
614
- />
615
- </section>
616
- </main>
617
- </div>
618
- );
619
- }
620
-
621
- ```
622
-
623
- ## app/tool-ui/page.tsx
624
-
625
- ```tsx
626
- "use client";
627
-
628
- import { Thread } from "@/components/assistant-ui/thread";
629
- import {
630
- AssistantRuntimeProvider,
631
- AuiConfig,
632
- Suggestions,
633
- Tools,
634
- } from "@assistant-ui/react";
635
- import { useChatRuntime } from "@assistant-ui/react-ai-sdk";
636
- import { lastAssistantMessageIsCompleteWithToolCalls } from "ai";
637
- import { ExampleNav } from "@/components/example-nav";
638
- import toolkit from "../toolkit";
639
-
640
- export default function Home() {
641
- const runtime = useChatRuntime({
642
- sendAutomaticallyWhen: lastAssistantMessageIsCompleteWithToolCalls,
643
- });
644
-
645
- const config = AuiConfig({
646
- tools: Tools({ toolkit }),
647
- suggestions: Suggestions([
648
- {
649
- title: "Show a bar chart",
650
- label: "of quarterly revenue",
651
- prompt:
652
- "Create a bar chart showing quarterly revenue: Q1 $45k, Q2 $52k, Q3 $61k, Q4 $58k",
653
- },
654
- {
655
- title: "Pick a date",
656
- label: "for a meeting",
657
- prompt: "I need to schedule a meeting. Ask me to pick a date.",
658
- },
659
- {
660
- title: "Collect my contact info",
661
- label: "name, email, phone",
662
- prompt:
663
- "I want to sign up for the newsletter. Ask for my name, email, and phone number.",
664
- },
665
- {
666
- title: "Show me on the map",
667
- label: "the Eiffel Tower",
668
- prompt: "Show me the Eiffel Tower on a map",
669
- },
670
- ]),
671
- });
672
-
673
- return (
674
- <AssistantRuntimeProvider config={config} runtime={runtime}>
675
- <div className="flex h-full flex-col">
676
- <ExampleNav />
677
- <main className="min-h-0 flex-1">
678
- <Thread />
679
- </main>
680
- </div>
681
- </AssistantRuntimeProvider>
682
- );
683
- }
684
-
685
- ```
686
-
687
- ## app/toolkit.tsx
688
-
689
- ```tsx
690
- "use generative";
691
-
692
- import { defineToolkit, externalTool, humanTool } from "@assistant-ui/react";
693
- import { ChartToolUI } from "@/components/chart-tool-ui";
694
- import { DatePickerToolUI } from "@/components/date-picker-tool-ui";
695
- import { ContactFormToolUI } from "@/components/contact-form-tool-ui";
696
- import { LocationToolUI } from "@/components/location-tool-ui";
697
- import { z } from "zod";
698
-
699
- export default defineToolkit({
700
- select_date: {
701
- description:
702
- "Ask the user to select a date. Use this when you need to collect a date (e.g. for scheduling, booking, deadlines).",
703
- parameters: z.object({
704
- prompt: z.string().describe("Message to display to the user"),
705
- minDate: z.string().optional().describe("Minimum date (ISO string)"),
706
- maxDate: z.string().optional().describe("Maximum date (ISO string)"),
707
- }),
708
- execute: humanTool(),
709
- render: DatePickerToolUI,
710
- },
711
- collect_contact: {
712
- description:
713
- "Collect contact information from the user. Use this when you need the user's name, email, or phone number.",
714
- parameters: z.object({
715
- prompt: z.string().describe("Message to display to the user"),
716
- fields: z
717
- .array(z.enum(["name", "email", "phone"]))
718
- .describe("Which fields to collect"),
719
- }),
720
- execute: humanTool(),
721
- render: ContactFormToolUI,
722
- },
723
- generate_chart: {
724
- execute: externalTool(),
725
- render: ChartToolUI,
726
- },
727
- show_location: {
728
- execute: externalTool(),
729
- render: LocationToolUI,
730
- },
731
- });
732
-
733
- ```
734
-
735
- ## components.json
736
-
737
- ```json
738
- {
739
- "$schema": "https://ui.shadcn.com/schema.json",
740
- "style": "new-york",
741
- "rsc": true,
742
- "tsx": true,
743
- "tailwind": {
744
- "config": "",
745
- "css": "app/globals.css",
746
- "baseColor": "zinc",
747
- "cssVariables": true,
748
- "prefix": ""
749
- },
750
- "aliases": {
751
- "components": "@/components",
752
- "utils": "@/lib/utils",
753
- "ui": "@/components/ui",
754
- "lib": "@/lib",
755
- "hooks": "@/hooks"
756
- },
757
- "iconLibrary": "lucide",
758
- "registries": {
759
- "@assistant-ui": "https://r.assistant-ui.com/{name}.json"
760
- }
761
- }
762
-
763
- ```
764
-
765
- ## components/assistant-message-gui.tsx
766
-
767
- ```tsx
768
- "use client";
769
-
770
- import { MarkdownText } from "@/components/assistant-ui/markdown-text";
771
- import {
772
- Reasoning,
773
- ReasoningContent,
774
- ReasoningRoot,
775
- ReasoningText,
776
- ReasoningTrigger,
777
- } from "@/components/assistant-ui/reasoning";
778
- import { ToolFallback } from "@/components/assistant-ui/tool-fallback";
779
- import {
780
- ToolGroupContent,
781
- ToolGroupRoot,
782
- ToolGroupTrigger,
783
- } from "@/components/assistant-ui/tool-group";
784
- import { TooltipIconButton } from "@/components/assistant-ui/tooltip-icon-button";
785
- import {
786
- UnknownComponentFallback,
787
- componentsAllowlist,
788
- } from "@/components/gui";
789
- import {
790
- RENDER_GUI_TOOL_NAME,
791
- isLeakedRenderGuiText,
792
- parseRenderGuiResult,
793
- } from "@/lib/render-gui-tool";
794
- import { cn } from "@/lib/utils";
795
- import type { GenerativeUISpec } from "@assistant-ui/react";
796
- import {
797
- ActionBarPrimitive,
798
- AuiIf,
799
- BranchPickerPrimitive,
800
- ErrorPrimitive,
801
- getMcpAppFromToolPart,
802
- MessagePrimitive,
803
- useAuiState,
804
- } from "@assistant-ui/react";
805
- import {
806
- CheckIcon,
807
- ChevronLeftIcon,
808
- ChevronRightIcon,
809
- CopyIcon,
810
- RefreshCwIcon,
811
- } from "lucide-react";
812
- import { type FC, useEffect, useRef } from "react";
813
-
814
- type AssistantMessageGuiProps = {
815
- /** Set false in dev to surface the dropped-bridge warning. */
816
- bridgeEnabled?: boolean;
817
- };
818
-
819
- const AllowlistedGenerativeUI = ({ spec }: { spec?: GenerativeUISpec }) => (
820
- <MessagePrimitive.GenerativeUI
821
- spec={spec}
822
- components={componentsAllowlist}
823
- Fallback={UnknownComponentFallback}
824
- />
825
- );
826
-
827
- const useDroppedGenerativeUIWarning = (bridgeEnabled: boolean) => {
828
- const content = useAuiState((s) => s.message.content);
829
- const warned = useRef(false);
830
-
831
- useEffect(() => {
832
- if (
833
- process.env.NODE_ENV === "production" ||
834
- bridgeEnabled ||
835
- warned.current
836
- ) {
837
- return;
838
- }
839
-
840
- const hasRenderGui = content.some(
841
- (part) =>
842
- part.type === "tool-call" &&
843
- part.toolName === RENDER_GUI_TOOL_NAME &&
844
- part.result != null &&
845
- parseRenderGuiResult(part.result) != null,
846
- );
847
-
848
- const hasUnhandledGenerativeUI = content.some(
849
- (part) => part.type === "generative-ui",
850
- );
851
-
852
- if (hasRenderGui || hasUnhandledGenerativeUI) {
853
- warned.current = true;
854
- console.warn(
855
- "[generative-ui] Message contains render_gui or generative-ui parts but the bridge is disabled. " +
856
- "Enable the bridge in assistant-message-gui.tsx or wire MessagePrimitive.GenerativeUI.",
857
- );
858
- }
859
- }, [bridgeEnabled, content]);
860
- };
861
-
862
- export const AssistantMessageGui: FC<AssistantMessageGuiProps> = ({
863
- bridgeEnabled = true,
864
- }) => {
865
- useDroppedGenerativeUIWarning(bridgeEnabled);
866
-
867
- const hasBridgedRenderGui = useAuiState((s) =>
868
- s.message.content.some(
869
- (part) =>
870
- part.type === "tool-call" &&
871
- part.toolName === RENDER_GUI_TOOL_NAME &&
872
- parseRenderGuiResult(part.result) != null,
873
- ),
874
- );
875
-
876
- const ACTION_BAR_PT = "pt-1.5";
877
- const ACTION_BAR_HEIGHT = `-mb-7.5 min-h-7.5 ${ACTION_BAR_PT}`;
878
-
879
- return (
880
- <MessagePrimitive.Root
881
- data-slot="aui_assistant-message-root"
882
- data-role="assistant"
883
- className="fade-in slide-in-from-bottom-1 animate-in relative duration-150"
884
- >
885
- <div
886
- data-slot="aui_assistant-message-content"
887
- // [contain-intrinsic-size:auto_24px] fixes issue #4104, don't change without checking for regressions
888
- className="text-foreground px-2 leading-relaxed wrap-break-word [contain-intrinsic-size:auto_24px] [content-visibility:auto]"
889
- >
890
- <MessagePrimitive.GroupedParts
891
- groupBy={(part) => {
892
- if (part.type === "reasoning") {
893
- return ["group-chainOfThought", "group-reasoning"];
894
- }
895
- if (part.type === "tool-call") {
896
- if (getMcpAppFromToolPart(part)) return [];
897
- if (part.toolName === RENDER_GUI_TOOL_NAME) return [];
898
- return ["group-chainOfThought", "group-tool"];
899
- }
900
- return [];
901
- }}
902
- >
903
- {({ part, children }) => {
904
- switch (part.type) {
905
- case "group-chainOfThought":
906
- return <div data-slot="aui_chain-of-thought">{children}</div>;
907
- case "group-reasoning": {
908
- const running = part.status.type === "running";
909
- return (
910
- <ReasoningRoot streaming={running}>
911
- <ReasoningTrigger active={running} />
912
- <ReasoningContent aria-busy={running}>
913
- <ReasoningText>{children}</ReasoningText>
914
- </ReasoningContent>
915
- </ReasoningRoot>
916
- );
917
- }
918
- case "group-tool":
919
- return (
920
- <ToolGroupRoot>
921
- <ToolGroupTrigger
922
- count={part.indices.length}
923
- active={part.status.type === "running"}
924
- />
925
- <ToolGroupContent>{children}</ToolGroupContent>
926
- </ToolGroupRoot>
927
- );
928
- case "text":
929
- if (
930
- bridgeEnabled &&
931
- hasBridgedRenderGui &&
932
- isLeakedRenderGuiText(part.text)
933
- ) {
934
- return null;
935
- }
936
- return <MarkdownText />;
937
- case "reasoning":
938
- return <Reasoning {...part} />;
939
- case "generative-ui":
940
- return bridgeEnabled ? <AllowlistedGenerativeUI /> : null;
941
- case "tool-call": {
942
- if (bridgeEnabled && part.toolName === RENDER_GUI_TOOL_NAME) {
943
- const spec = parseRenderGuiResult(part.result);
944
- if (spec) return <AllowlistedGenerativeUI spec={spec} />;
945
- }
946
- return part.toolUI ?? <ToolFallback {...part} />;
947
- }
948
- default:
949
- return null;
950
- }
951
- }}
952
- </MessagePrimitive.GroupedParts>
953
- <MessagePrimitive.Error>
954
- <ErrorPrimitive.Root className="aui-message-error-root border-destructive bg-destructive/10 text-destructive dark:bg-destructive/5 mt-2 rounded-md border p-3 text-sm dark:text-red-200">
955
- <ErrorPrimitive.Message className="aui-message-error-message line-clamp-2" />
956
- </ErrorPrimitive.Root>
957
- </MessagePrimitive.Error>
958
- </div>
959
-
960
- <div
961
- data-slot="aui_assistant-message-footer"
962
- className={cn("ms-2 flex items-center", ACTION_BAR_HEIGHT)}
963
- >
964
- <BranchPickerPrimitive.Root
965
- hideWhenSingleBranch
966
- className="aui-branch-picker-root text-muted-foreground -ms-2 me-2 inline-flex items-center text-xs"
967
- >
968
- <BranchPickerPrimitive.Previous asChild>
969
- <TooltipIconButton tooltip="Previous">
970
- <ChevronLeftIcon />
971
- </TooltipIconButton>
972
- </BranchPickerPrimitive.Previous>
973
- <span className="aui-branch-picker-state font-medium">
974
- <BranchPickerPrimitive.Number /> / <BranchPickerPrimitive.Count />
975
- </span>
976
- <BranchPickerPrimitive.Next asChild>
977
- <TooltipIconButton tooltip="Next">
978
- <ChevronRightIcon />
979
- </TooltipIconButton>
980
- </BranchPickerPrimitive.Next>
981
- </BranchPickerPrimitive.Root>
982
- <ActionBarPrimitive.Root
983
- hideWhenRunning
984
- autohide="not-last"
985
- className="aui-assistant-action-bar-root text-muted-foreground -ms-1 flex gap-1"
986
- >
987
- <ActionBarPrimitive.Copy asChild>
988
- <TooltipIconButton tooltip="Copy">
989
- <AuiIf condition={(s) => s.message.isCopied}>
990
- <CheckIcon />
991
- </AuiIf>
992
- <AuiIf condition={(s) => !s.message.isCopied}>
993
- <CopyIcon />
994
- </AuiIf>
995
- </TooltipIconButton>
996
- </ActionBarPrimitive.Copy>
997
- <ActionBarPrimitive.Reload asChild>
998
- <TooltipIconButton tooltip="Refresh">
999
- <RefreshCwIcon />
1000
- </TooltipIconButton>
1001
- </ActionBarPrimitive.Reload>
1002
- </ActionBarPrimitive.Root>
1003
- </div>
1004
- </MessagePrimitive.Root>
1005
- );
1006
- };
1007
-
1008
- ```
1009
-
1010
- ## components/chart-tool-ui.tsx
1011
-
1012
- ```tsx
1013
- "use client";
1014
-
1015
- import type { ToolCallMessagePartComponent } from "@assistant-ui/react";
1016
- import {
1017
- BarChart,
1018
- Bar,
1019
- LineChart,
1020
- Line,
1021
- PieChart,
1022
- Pie,
1023
- Cell,
1024
- XAxis,
1025
- YAxis,
1026
- CartesianGrid,
1027
- Tooltip,
1028
- Legend,
1029
- ResponsiveContainer,
1030
- } from "recharts";
1031
- import { Loader2Icon } from "lucide-react";
1032
-
1033
- type ChartArgs = {
1034
- title: string;
1035
- type: "bar" | "line" | "pie";
1036
- data: Array<Record<string, string | number>>;
1037
- xKey: string;
1038
- dataKeys: string[];
1039
- };
1040
-
1041
- type ChartResult = {
1042
- success: boolean;
1043
- };
1044
-
1045
- const COLORS = [
1046
- "oklch(0.646 0.222 41.116)",
1047
- "oklch(0.6 0.118 184.704)",
1048
- "oklch(0.398 0.07 227.392)",
1049
- "oklch(0.828 0.189 84.429)",
1050
- "oklch(0.769 0.188 70.08)",
1051
- ];
1052
-
1053
- export const ChartToolUI: ToolCallMessagePartComponent<ChartArgs, ChartResult> =
1054
- function ChartUI({ args, status }) {
1055
- if (status.type === "running" && !args.data?.length) {
1056
- return (
1057
- <div className="flex items-center gap-2 rounded-lg border p-4">
1058
- <Loader2Icon className="text-muted-foreground size-4 animate-spin" />
1059
- <span className="text-muted-foreground text-sm">
1060
- Generating chart...
1061
- </span>
1062
- </div>
1063
- );
1064
- }
1065
-
1066
- const { title, type, data, xKey, dataKeys } = args;
1067
- if (!data?.length || !dataKeys?.length) return null;
1068
-
1069
- return (
1070
- <div className="my-2 rounded-lg border p-4">
1071
- <h3 className="mb-3 text-center text-sm font-semibold">{title}</h3>
1072
- <div className="h-[280px] w-full">
1073
- <ResponsiveContainer width="100%" height="100%">
1074
- {type === "bar" ? (
1075
- <BarChart data={data}>
1076
- <CartesianGrid strokeDasharray="3 3" vertical={false} />
1077
- <XAxis
1078
- dataKey={xKey}
1079
- tickLine={false}
1080
- axisLine={false}
1081
- fontSize={12}
1082
- />
1083
- <YAxis tickLine={false} axisLine={false} fontSize={12} />
1084
- <Tooltip />
1085
- <Legend />
1086
- {dataKeys.map((key, i) => (
1087
- <Bar
1088
- key={key}
1089
- dataKey={key}
1090
- fill={COLORS[i % COLORS.length]}
1091
- radius={[4, 4, 0, 0]}
1092
- />
1093
- ))}
1094
- </BarChart>
1095
- ) : type === "line" ? (
1096
- <LineChart data={data}>
1097
- <CartesianGrid strokeDasharray="3 3" vertical={false} />
1098
- <XAxis
1099
- dataKey={xKey}
1100
- tickLine={false}
1101
- axisLine={false}
1102
- fontSize={12}
1103
- />
1104
- <YAxis tickLine={false} axisLine={false} fontSize={12} />
1105
- <Tooltip />
1106
- <Legend />
1107
- {dataKeys.map((key, i) => (
1108
- <Line
1109
- key={key}
1110
- type="monotone"
1111
- dataKey={key}
1112
- stroke={COLORS[i % COLORS.length] ?? "#8884d8"}
1113
- strokeWidth={2}
1114
- dot={false}
1115
- />
1116
- ))}
1117
- </LineChart>
1118
- ) : (
1119
- <PieChart>
1120
- <Tooltip />
1121
- <Legend />
1122
- <Pie
1123
- data={data}
1124
- dataKey={dataKeys[0]!}
1125
- nameKey={xKey}
1126
- cx="50%"
1127
- cy="50%"
1128
- outerRadius={80}
1129
- label
1130
- >
1131
- {data.map((_, i) => (
1132
- <Cell
1133
- key={i}
1134
- fill={COLORS[i % COLORS.length] ?? "#8884d8"}
1135
- />
1136
- ))}
1137
- </Pie>
1138
- </PieChart>
1139
- )}
1140
- </ResponsiveContainer>
1141
- </div>
1142
- </div>
1143
- );
1144
- };
1145
-
1146
- ```
1147
-
1148
- ## components/contact-form-tool-ui.tsx
1149
-
1150
- ```tsx
1151
- "use client";
1152
-
1153
- import { useState } from "react";
1154
- import type { ToolCallMessagePartComponent } from "@assistant-ui/react";
1155
- import { UserIcon, CheckCircle2Icon } from "lucide-react";
1156
-
1157
- type ContactFormArgs = {
1158
- prompt: string;
1159
- fields: Array<"name" | "email" | "phone">;
1160
- };
1161
-
1162
- type ContactFormResult = {
1163
- name?: string;
1164
- email?: string;
1165
- phone?: string;
1166
- };
1167
-
1168
- export const ContactFormToolUI: ToolCallMessagePartComponent<
1169
- ContactFormArgs,
1170
- ContactFormResult
1171
- > = function ContactFormUI({ args, result, addResult }) {
1172
- const [form, setForm] = useState<ContactFormResult>({});
1173
-
1174
- if (result) {
1175
- return (
1176
- <div className="my-2 rounded-lg border border-green-200 bg-green-50 p-3">
1177
- <div className="mb-1 flex items-center gap-2">
1178
- <CheckCircle2Icon className="size-4 text-green-600" />
1179
- <span className="text-sm font-medium text-green-800">
1180
- Contact info collected
1181
- </span>
1182
- </div>
1183
- <div className="ml-6 space-y-0.5 text-xs text-green-700">
1184
- {result.name && <p>Name: {result.name}</p>}
1185
- {result.email && <p>Email: {result.email}</p>}
1186
- {result.phone && <p>Phone: {result.phone}</p>}
1187
- </div>
1188
- </div>
1189
- );
1190
- }
1191
-
1192
- const fields = args.fields ?? ["name", "email", "phone"];
1193
- const isValid = fields.every((f) => form[f]?.trim());
1194
-
1195
- return (
1196
- <div className="my-2 rounded-lg border p-4">
1197
- <div className="mb-3 flex items-center gap-2">
1198
- <UserIcon className="text-muted-foreground size-4" />
1199
- <span className="text-sm font-medium">{args.prompt}</span>
1200
- </div>
1201
- <div className="space-y-2">
1202
- {fields.includes("name") && (
1203
- <input
1204
- type="text"
1205
- placeholder="Name"
1206
- value={form.name ?? ""}
1207
- onChange={(e) => setForm((p) => ({ ...p, name: e.target.value }))}
1208
- className="bg-background w-full rounded-md border px-3 py-2 text-sm"
1209
- />
1210
- )}
1211
- {fields.includes("email") && (
1212
- <input
1213
- type="email"
1214
- placeholder="Email"
1215
- value={form.email ?? ""}
1216
- onChange={(e) => setForm((p) => ({ ...p, email: e.target.value }))}
1217
- className="bg-background w-full rounded-md border px-3 py-2 text-sm"
1218
- />
1219
- )}
1220
- {fields.includes("phone") && (
1221
- <input
1222
- type="tel"
1223
- placeholder="Phone"
1224
- value={form.phone ?? ""}
1225
- onChange={(e) => setForm((p) => ({ ...p, phone: e.target.value }))}
1226
- className="bg-background w-full rounded-md border px-3 py-2 text-sm"
1227
- />
1228
- )}
1229
- <button
1230
- type="button"
1231
- disabled={!isValid}
1232
- onClick={() => addResult(form)}
1233
- className="bg-primary text-primary-foreground w-full rounded-md px-4 py-2 text-sm font-medium disabled:opacity-50"
1234
- >
1235
- Submit
1236
- </button>
1237
- </div>
1238
- </div>
1239
- );
1240
- };
1241
-
1242
- ```
1243
-
1244
- ## components/dashboard-header.tsx
1245
-
1246
- ```tsx
1247
- "use client";
1248
-
1249
- type DashboardHeaderProps = {
1250
- title: string;
1251
- description?: string;
1252
- period?: string;
1253
- };
1254
-
1255
- export function DashboardHeader({
1256
- title,
1257
- description,
1258
- period,
1259
- }: DashboardHeaderProps) {
1260
- return (
1261
- <header className="flex flex-wrap items-start justify-between gap-3">
1262
- <div className="min-w-0">
1263
- <h2 className="text-lg font-semibold tracking-tight">{title}</h2>
1264
- {description ? (
1265
- <p className="text-muted-foreground mt-1 text-sm">{description}</p>
1266
- ) : null}
1267
- </div>
1268
- {period ? (
1269
- <span className="bg-muted text-muted-foreground rounded-full px-2.5 py-1 text-xs font-medium">
1270
- {period}
1271
- </span>
1272
- ) : null}
1273
- </header>
1274
- );
1275
- }
1276
-
1277
- ```
1278
-
1279
- ## components/date-picker-tool-ui.tsx
1280
-
1281
- ```tsx
1282
- "use client";
1283
-
1284
- import { useState } from "react";
1285
- import type { ToolCallMessagePartComponent } from "@assistant-ui/react";
1286
- import { CalendarIcon, CheckCircle2Icon } from "lucide-react";
1287
-
1288
- type DatePickerArgs = {
1289
- prompt: string;
1290
- minDate?: string;
1291
- maxDate?: string;
1292
- };
1293
-
1294
- type DatePickerResult = {
1295
- date: string;
1296
- };
1297
-
1298
- export const DatePickerToolUI: ToolCallMessagePartComponent<
1299
- DatePickerArgs,
1300
- DatePickerResult
1301
- > = function DatePickerUI({ args, result, addResult }) {
1302
- const [value, setValue] = useState("");
1303
-
1304
- if (result) {
1305
- return (
1306
- <div className="my-2 flex items-center gap-2 rounded-lg border border-green-200 bg-green-50 p-3">
1307
- <CheckCircle2Icon className="size-4 text-green-600" />
1308
- <span className="text-sm text-green-800">
1309
- Selected: {new Date(result.date).toLocaleDateString()}
1310
- </span>
1311
- </div>
1312
- );
1313
- }
1314
-
1315
- return (
1316
- <div className="my-2 rounded-lg border p-4">
1317
- <div className="mb-3 flex items-center gap-2">
1318
- <CalendarIcon className="text-muted-foreground size-4" />
1319
- <span className="text-sm font-medium">{args.prompt}</span>
1320
- </div>
1321
- <div className="flex items-center gap-2">
1322
- <input
1323
- type="date"
1324
- value={value}
1325
- min={args.minDate}
1326
- max={args.maxDate}
1327
- onChange={(e) => setValue(e.target.value)}
1328
- className="bg-background rounded-md border px-3 py-2 text-sm"
1329
- />
1330
- <button
1331
- type="button"
1332
- disabled={!value}
1333
- onClick={() => addResult({ date: new Date(value).toISOString() })}
1334
- className="bg-primary text-primary-foreground rounded-md px-4 py-2 text-sm font-medium disabled:opacity-50"
1335
- >
1336
- Confirm
1337
- </button>
1338
- </div>
1339
- </div>
1340
- );
1341
- };
1342
-
1343
- ```
1344
-
1345
- ## components/example-nav.tsx
1346
-
1347
- ```tsx
1348
- import Link from "next/link";
1349
-
1350
- const links = [
1351
- { href: "/", label: "Generative UI" },
1352
- { href: "/tool-ui", label: "Tool UI" },
1353
- { href: "/primitive", label: "Static primitive (legacy)" },
1354
- { href: "/gui-chat", label: "GUI chat (legacy)" },
1355
- ] as const;
1356
-
1357
- export function ExampleNav() {
1358
- return (
1359
- <nav className="bg-background flex flex-wrap items-center gap-2 border-b px-4 py-2 text-sm">
1360
- <span className="text-muted-foreground font-medium">Examples:</span>
1361
- {links.map(({ href, label }) => (
1362
- <Link
1363
- key={href}
1364
- href={href}
1365
- className="text-foreground hover:bg-muted rounded-md px-2 py-1"
1366
- >
1367
- {label}
1368
- </Link>
1369
- ))}
1370
- </nav>
1371
- );
1372
- }
1373
-
1374
- ```
1375
-
1376
- ## components/generative-ui-style.tsx
1377
-
1378
- ```tsx
1379
- import {
1380
- generativeUiCssText,
1381
- generativeUiThemeVars,
1382
- } from "@assistant-ui/ui/lib/generative-ui-vocabulary-css";
1383
-
1384
- function themeVarsBlock(selector: string, vars: Record<string, string>) {
1385
- const body = Object.entries(vars)
1386
- .map(([name, value]) => ` ${name}: ${value};`)
1387
- .join("\n");
1388
- return `${selector} {\n${body}\n}`;
1389
- }
1390
-
1391
- export function GenerativeUIStyle() {
1392
- const css = [
1393
- themeVarsBlock(":root", generativeUiThemeVars.light),
1394
- themeVarsBlock(".dark", generativeUiThemeVars.dark),
1395
- generativeUiCssText(),
1396
- ].join("\n\n");
1397
-
1398
- return <style>{css}</style>;
1399
- }
1400
-
1401
- ```
1402
-
1403
- ## components/gui/index.tsx
1404
-
1405
- ```tsx
1406
- "use client";
1407
-
1408
- import type { ComponentType, PropsWithChildren } from "react";
1409
-
1410
- /**
1411
- * The component allowlist passed to `<MessagePrimitive.GenerativeUI />`.
1412
- * The agent's JSON spec can reference any of these by name.
1413
- */
1414
-
1415
- export const UnknownComponentFallback = ({
1416
- component,
1417
- }: {
1418
- component: string;
1419
- }) => (
1420
- <span className="bg-muted rounded px-1.5 py-0.5 font-mono text-xs">
1421
- unknown component: {component}
1422
- </span>
1423
- );
1424
-
1425
- const Card: ComponentType<
1426
- PropsWithChildren<{ title?: string; description?: string }>
1427
- > = ({ title, description, children }) => (
1428
- <div className="bg-card rounded-xl border p-4 shadow-sm">
1429
- {title ? <div className="text-base font-semibold">{title}</div> : null}
1430
- {description ? (
1431
- <div className="text-muted-foreground mt-1 text-sm">{description}</div>
1432
- ) : null}
1433
- {children ? <div className="mt-3">{children}</div> : null}
1434
- </div>
1435
- );
1436
-
1437
- const Button: ComponentType<
1438
- PropsWithChildren<{
1439
- label?: string;
1440
- variant?: "primary" | "secondary";
1441
- onClickPrompt?: string;
1442
- }>
1443
- > = ({ label, variant = "primary", onClickPrompt, children }) => {
1444
- const cls =
1445
- variant === "primary"
1446
- ? "bg-primary text-primary-foreground hover:bg-primary/90"
1447
- : "bg-secondary text-secondary-foreground hover:bg-secondary/80";
1448
- return (
1449
- <button
1450
- type="button"
1451
- className={`mt-2 inline-flex items-center rounded-md px-3 py-1.5 text-sm font-medium ${cls}`}
1452
- onClick={() => {
1453
- if (onClickPrompt) {
1454
- // In a richer integration this would call composer.setText / send.
1455
- alert(`button -> ${onClickPrompt}`);
1456
- }
1457
- }}
1458
- >
1459
- {children ?? label ?? "Click"}
1460
- </button>
1461
- );
1462
- };
1463
-
1464
- const Stack: ComponentType<
1465
- PropsWithChildren<{ gap?: "sm" | "md" | "lg"; direction?: "row" | "column" }>
1466
- > = ({ gap = "md", direction = "column", children }) => {
1467
- const gapClass = gap === "sm" ? "gap-2" : gap === "lg" ? "gap-6" : "gap-4";
1468
- const dirClass = direction === "row" ? "flex-row" : "flex-col";
1469
- return <div className={`flex ${dirClass} ${gapClass}`}>{children}</div>;
1470
- };
1471
-
1472
- const Heading: ComponentType<
1473
- PropsWithChildren<{ level?: 1 | 2 | 3; children?: React.ReactNode }>
1474
- > = ({ level = 2, children }) => {
1475
- const cls =
1476
- level === 1
1477
- ? "text-2xl font-bold"
1478
- : level === 2
1479
- ? "text-lg font-semibold"
1480
- : "text-base font-semibold";
1481
- const Tag = `h${level}` as keyof React.JSX.IntrinsicElements;
1482
- return <Tag className={cls}>{children}</Tag>;
1483
- };
1484
-
1485
- const Text: ComponentType<PropsWithChildren> = ({ children }) => (
1486
- <p className="text-foreground text-sm leading-6">{children}</p>
1487
- );
1488
-
1489
- const Stat: ComponentType<{ label: string; value: string | number }> = ({
1490
- label,
1491
- value,
1492
- }) => (
1493
- <div className="bg-muted/40 flex flex-col rounded-lg border p-3">
1494
- <span className="text-muted-foreground text-xs">{label}</span>
1495
- <span className="text-xl font-semibold">{value}</span>
1496
- </div>
1497
- );
1498
-
1499
- export const componentsAllowlist = {
1500
- Card,
1501
- Button,
1502
- Stack,
1503
- Heading,
1504
- Text,
1505
- Stat,
1506
- } as const;
1507
-
1508
- ```
1509
-
1510
- ## components/location-tool-ui.tsx
1511
-
1512
- ```tsx
1513
- "use client";
1514
-
1515
- import type { ToolCallMessagePartComponent } from "@assistant-ui/react";
1516
- import { MapPinIcon, Loader2Icon } from "lucide-react";
1517
-
1518
- type LocationArgs = {
1519
- name: string;
1520
- address?: string;
1521
- lat: number;
1522
- lng: number;
1523
- };
1524
-
1525
- type LocationResult = {
1526
- success: boolean;
1527
- };
1528
-
1529
- export const LocationToolUI: ToolCallMessagePartComponent<
1530
- LocationArgs,
1531
- LocationResult
1532
- > = function LocationUI({ args, status }) {
1533
- if (status.type === "running" && (args.lat == null || args.lng == null)) {
1534
- return (
1535
- <div className="flex items-center gap-2 rounded-lg border p-4">
1536
- <Loader2Icon className="text-muted-foreground size-4 animate-spin" />
1537
- <span className="text-muted-foreground text-sm">
1538
- Loading location...
1539
- </span>
1540
- </div>
1541
- );
1542
- }
1543
-
1544
- const { name, address, lat, lng } = args;
1545
- if (lat == null || lng == null) return null;
1546
-
1547
- const mapSrc = `https://www.openstreetmap.org/export/embed.html?bbox=${lng - 0.01},${lat - 0.01},${lng + 0.01},${lat + 0.01}&layer=mapnik&marker=${lat},${lng}`;
1548
-
1549
- return (
1550
- <div className="my-2 overflow-hidden rounded-lg border">
1551
- <div className="flex items-center gap-2 border-b px-3 py-2">
1552
- <MapPinIcon className="text-muted-foreground size-4" />
1553
- <div>
1554
- <p className="text-sm font-medium">{name}</p>
1555
- {address && (
1556
- <p className="text-muted-foreground text-xs">{address}</p>
1557
- )}
1558
- </div>
1559
- </div>
1560
- <iframe
1561
- title={`Map of ${name}`}
1562
- src={mapSrc}
1563
- className="h-[200px] w-full border-0"
1564
- />
1565
- </div>
1566
- );
1567
- };
1568
-
1569
- ```
1570
-
1571
- ## lib/render-gui-tool.test.ts
1572
-
1573
- ```typescript
1574
- import { describe, expect, it } from "vitest";
1575
- import {
1576
- generativeUISpecSchema,
1577
- isLeakedRenderGuiText,
1578
- parseRenderGuiResult,
1579
- renderGuiToolResultSchema,
1580
- } from "./render-gui-tool";
1581
-
1582
- describe("render-gui-tool", () => {
1583
- it("accepts a valid Card + Button spec", () => {
1584
- const spec = {
1585
- root: {
1586
- component: "Card",
1587
- props: { title: "Welcome" },
1588
- children: [
1589
- {
1590
- component: "Button",
1591
- props: { label: "Get started", variant: "primary" },
1592
- },
1593
- ],
1594
- },
1595
- };
1596
-
1597
- expect(generativeUISpecSchema.parse(spec)).toEqual(spec);
1598
- expect(
1599
- parseRenderGuiResult(renderGuiToolResultSchema.parse({ spec })),
1600
- ).toEqual(spec);
1601
- });
1602
-
1603
- it("rejects a spec with empty component name", () => {
1604
- expect(() =>
1605
- generativeUISpecSchema.parse({
1606
- root: { component: "", props: { title: "Bad" } },
1607
- }),
1608
- ).toThrow();
1609
- });
1610
-
1611
- it("returns undefined for malformed tool results", () => {
1612
- expect(parseRenderGuiResult({ notSpec: true })).toBeUndefined();
1613
- expect(parseRenderGuiResult(null)).toBeUndefined();
1614
- });
1615
-
1616
- it("detects leaked render_gui tool result text", () => {
1617
- const payload = renderGuiToolResultSchema.parse({
1618
- spec: {
1619
- root: {
1620
- component: "Card",
1621
- children: [{ component: "Text", children: ["Hello"] }],
1622
- },
1623
- },
1624
- });
1625
-
1626
- expect(isLeakedRenderGuiText(JSON.stringify(payload, null, 2))).toBe(true);
1627
- expect(
1628
- isLeakedRenderGuiText(
1629
- "```json\n" + JSON.stringify(payload, null, 2) + "\n```",
1630
- ),
1631
- ).toBe(true);
1632
- expect(isLeakedRenderGuiText("Here is your card.")).toBe(false);
1633
- });
1634
- });
1635
-
1636
- ```
1637
-
1638
- ## lib/render-gui-tool.ts
1639
-
1640
- ```typescript
1641
- import { z } from "zod";
1642
- import type { GenerativeUISpec } from "@assistant-ui/react";
1643
-
1644
- export const RENDER_GUI_TOOL_NAME = "render_gui" as const;
1645
-
1646
- const generativeUINodeSchema: z.ZodType<unknown> = z.lazy(() =>
1647
- z.union([
1648
- z.string(),
1649
- z.object({
1650
- component: z.string().min(1),
1651
- props: z.record(z.string(), z.unknown()).optional(),
1652
- children: z.array(generativeUINodeSchema).optional(),
1653
- key: z.string().optional(),
1654
- }),
1655
- ]),
1656
- );
1657
-
1658
- export const generativeUISpecSchema = z.object({
1659
- root: z.union([
1660
- generativeUINodeSchema,
1661
- z.array(generativeUINodeSchema).min(1),
1662
- ]),
1663
- });
1664
-
1665
- export const renderGuiToolInputSchema = z.object({
1666
- spec: generativeUISpecSchema,
1667
- });
1668
-
1669
- export const renderGuiToolResultSchema = renderGuiToolInputSchema;
1670
-
1671
- export const parseRenderGuiResult = (
1672
- result: unknown,
1673
- ): GenerativeUISpec | undefined => {
1674
- const parsed = renderGuiToolResultSchema.safeParse(result);
1675
- return parsed.success ? (parsed.data.spec as GenerativeUISpec) : undefined;
1676
- };
1677
-
1678
- export const renderGuiToolDescription =
1679
- "Compose inline UI from the allowlisted component library (Card, Text, Button, Stack, Stat, Heading). " +
1680
- "Pass a JSON spec with a root node tree. Use for dashboards, status panels, and structured layouts — not for user input forms (use interactive tool UI instead).";
1681
-
1682
- export const renderGuiChatInstructions =
1683
- "When the user asks for UI, call render_gui with the spec. " +
1684
- "Do not paste JSON, code blocks, or the tool result in your text reply — the client renders the UI from the tool output automatically. " +
1685
- "Keep any text reply brief or omit it when the UI alone answers the request.";
1686
-
1687
- const stripMarkdownJsonFence = (text: string): string => {
1688
- const trimmed = text.trim();
1689
- const match = trimmed.match(/^```(?:json)?\s*\n?([\s\S]*?)\n?```\s*$/i);
1690
- return match ? match[1]!.trim() : trimmed;
1691
- };
1692
-
1693
- /** Text echo of a render_gui tool result/spec — hide when the bridge already rendered it. */
1694
- export const isLeakedRenderGuiText = (text: string): boolean => {
1695
- const candidate = stripMarkdownJsonFence(text);
1696
- if (!candidate.startsWith("{")) return false;
1697
-
1698
- try {
1699
- const parsed = JSON.parse(candidate);
1700
- if (renderGuiToolResultSchema.safeParse(parsed).success) return true;
1701
- if (generativeUISpecSchema.safeParse(parsed).success) return true;
1702
- } catch {
1703
- return false;
1704
- }
1705
-
1706
- return false;
1707
- };
1708
-
1709
- ```
1710
-
1711
- ## next.config.ts
1712
-
1713
- ```typescript
1714
- import { withAui } from "@assistant-ui/next";
1715
- import type { NextConfig } from "next";
1716
-
1717
- const nextConfig: NextConfig = {/* config options here */};
1718
-
1719
- export default withAui(nextConfig);
1720
-
1721
- ```
1722
-
1723
- ## package.json
1724
-
1725
- ```json
1726
- {
1727
- "name": "with-generative-ui",
1728
- "version": "0.0.0",
1729
- "private": true,
1730
- "type": "module",
1731
- "scripts": {
1732
- "dev": "next dev",
1733
- "build": "next build",
1734
- "start": "next start",
1735
- "test": "vitest run"
1736
- },
1737
- "dependencies": {
1738
- "@ai-sdk/openai": "^4.0.40",
1739
- "@assistant-ui/react": "workspace:*",
1740
- "@assistant-ui/react-ai-sdk": "workspace:*",
1741
- "@assistant-ui/react-generative-ui": "workspace:*",
1742
- "@assistant-ui/ui": "workspace:*",
1743
- "ai": "^7.0.62",
1744
- "class-variance-authority": "^0.7.1",
1745
- "clsx": "^2.1.1",
1746
- "lucide-react": "^1.31.0",
1747
- "next": "^16.3.0",
1748
- "react": "^19.2.8",
1749
- "react-dom": "^19.2.8",
1750
- "recharts": "^3.10.1",
1751
- "tailwind-merge": "^3.6.0",
1752
- "zod": "^4.4.3"
1753
- },
1754
- "devDependencies": {
1755
- "@assistant-ui/next": "workspace:*",
1756
- "@assistant-ui/x-buildutils": "workspace:*",
1757
- "@tailwindcss/postcss": "^4.3.3",
1758
- "@types/node": "^26.2.0",
1759
- "@types/react": "^19.2.18",
1760
- "@types/react-dom": "^19.2.4",
1761
- "postcss": "^8.5.26",
1762
- "tailwindcss": "^4.3.3",
1763
- "tw-animate-css": "^1.4.0",
1764
- "typescript": "^7.0.2",
1765
- "vitest": "^4.1.10"
1766
- }
1767
- }
1768
-
1769
- ```
1770
-
1771
- ## tsconfig.json
1772
-
1773
- ```json
1774
- {
1775
- "extends": "@assistant-ui/x-buildutils/ts/next",
1776
- "compilerOptions": {
1777
- "paths": {
1778
- "@/*": ["./*"],
1779
- "@/components/assistant-ui/*": [
1780
- "../../packages/ui/src/components/assistant-ui/*"
1781
- ],
1782
- "@/components/ui/*": [
1783
- "../../packages/ui/src/components/ui/base/*",
1784
- "../../packages/ui/src/components/ui/radix/*"
1785
- ],
1786
- "@/components/ui/radix/*": [
1787
- "../../packages/ui/src/components/ui/radix/*"
1788
- ],
1789
- "@/lib/utils": ["../../packages/ui/src/lib/utils"],
1790
- "@assistant-ui/ui/*": ["../../packages/ui/src/*"]
1791
- }
1792
- },
1793
- "include": ["**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
1794
- "exclude": ["node_modules"]
1795
- }
1796
-
1797
- ```
1798
-
1799
- ## vitest.config.ts
1800
-
1801
- ```typescript
1802
- import { defineConfig } from "vitest/config";
1803
-
1804
- export default defineConfig({
1805
- test: {
1806
- environment: "node",
1807
- include: ["lib/**/*.test.ts"],
1808
- },
1809
- });
1810
-
1811
- ```
1812
-