@assistant-ui/mcp-docs-server 0.2.3 → 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 (452) 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 +8 -12
  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 -675
  16. package/.docs/organized/code-examples/with-ag-ui.md +0 -553
  17. package/.docs/organized/code-examples/with-ai-sdk-v7.md +0 -466
  18. package/.docs/organized/code-examples/with-artifacts.md +0 -815
  19. package/.docs/organized/code-examples/with-assistant-transport.md +0 -576
  20. package/.docs/organized/code-examples/with-browser-extension.md +0 -371
  21. package/.docs/organized/code-examples/with-chain-of-thought.md +0 -962
  22. package/.docs/organized/code-examples/with-cloud-standalone.md +0 -681
  23. package/.docs/organized/code-examples/with-cloud.md +0 -439
  24. package/.docs/organized/code-examples/with-custom-thread-list.md +0 -569
  25. package/.docs/organized/code-examples/with-elevenlabs-conversational.md +0 -527
  26. package/.docs/organized/code-examples/with-elevenlabs-scribe.md +0 -697
  27. package/.docs/organized/code-examples/with-eve.md +0 -405
  28. package/.docs/organized/code-examples/with-expo.md +0 -2246
  29. package/.docs/organized/code-examples/with-external-store.md +0 -421
  30. package/.docs/organized/code-examples/with-ffmpeg.md +0 -829
  31. package/.docs/organized/code-examples/with-generative-ui.md +0 -1810
  32. package/.docs/organized/code-examples/with-google-adk.md +0 -368
  33. package/.docs/organized/code-examples/with-heat-graph.md +0 -304
  34. package/.docs/organized/code-examples/with-image-generation.md +0 -463
  35. package/.docs/organized/code-examples/with-interactables.md +0 -733
  36. package/.docs/organized/code-examples/with-langchain.md +0 -446
  37. package/.docs/organized/code-examples/with-langgraph.md +0 -855
  38. package/.docs/organized/code-examples/with-livekit.md +0 -643
  39. package/.docs/organized/code-examples/with-mcp.md +0 -782
  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 -450
  43. package/.docs/organized/code-examples/with-pi.md +0 -2084
  44. package/.docs/organized/code-examples/with-react-hook-form.md +0 -727
  45. package/.docs/organized/code-examples/with-react-ink-web.md +0 -740
  46. package/.docs/organized/code-examples/with-react-ink.md +0 -473
  47. package/.docs/organized/code-examples/with-react-router.md +0 -936
  48. package/.docs/organized/code-examples/with-resumable-stream.md +0 -668
  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 -812
  53. package/.docs/organized/code-examples/with-tap-runtime.md +0 -813
  54. package/.docs/organized/code-examples/with-virtualized-thread.md +0 -681
  55. package/.docs/organized/code-examples/with-vue.md +0 -408
  56. package/.docs/raw/docs/(getting-started)/architecture.mdx +0 -146
  57. package/.docs/raw/docs/(getting-started)/base-ui.mdx +0 -39
  58. package/.docs/raw/docs/(getting-started)/cli.mdx +0 -542
  59. package/.docs/raw/docs/(getting-started)/devtools.mdx +0 -79
  60. package/.docs/raw/docs/(getting-started)/index.mdx +0 -23
  61. package/.docs/raw/docs/(getting-started)/installation.mdx +0 -483
  62. package/.docs/raw/docs/(getting-started)/llm.mdx +0 -211
  63. package/.docs/raw/docs/(getting-started)/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 -26
  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 -57
  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/ai-sdk.mdx +0 -200
  94. package/.docs/raw/docs/(reference)/api-reference/integrations/cloud-ai-sdk.mdx +0 -24
  95. package/.docs/raw/docs/(reference)/api-reference/integrations/eve.mdx +0 -118
  96. package/.docs/raw/docs/(reference)/api-reference/integrations/index.mdx +0 -28
  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 -637
  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 -152
  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 -604
  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 -411
  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 -215
  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 -237
  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.mdx +0 -283
  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 -976
  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 -267
  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 -731
  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 -363
  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 -1020
  289. package/.docs/raw/docs/tools/user-managed-mcp.mdx +0 -428
  290. package/.docs/raw/docs/ui/assistant-modal.mdx +0 -166
  291. package/.docs/raw/docs/ui/assistant-sidebar.mdx +0 -89
  292. package/.docs/raw/docs/ui/attachment.mdx +0 -279
  293. package/.docs/raw/docs/ui/composer-trigger-popover.mdx +0 -247
  294. package/.docs/raw/docs/ui/context-display.mdx +0 -148
  295. package/.docs/raw/docs/ui/directive-text.mdx +0 -114
  296. package/.docs/raw/docs/ui/file.mdx +0 -159
  297. package/.docs/raw/docs/ui/follow-up-suggestions.mdx +0 -82
  298. package/.docs/raw/docs/ui/image.mdx +0 -102
  299. package/.docs/raw/docs/ui/markdown.mdx +0 -103
  300. package/.docs/raw/docs/ui/mcp-config.mdx +0 -107
  301. package/.docs/raw/docs/ui/mermaid.mdx +0 -92
  302. package/.docs/raw/docs/ui/message-timing.mdx +0 -93
  303. package/.docs/raw/docs/ui/model-selector.mdx +0 -455
  304. package/.docs/raw/docs/ui/part-grouping.mdx +0 -614
  305. package/.docs/raw/docs/ui/quote.mdx +0 -211
  306. package/.docs/raw/docs/ui/reasoning.mdx +0 -214
  307. package/.docs/raw/docs/ui/scrollbar.mdx +0 -77
  308. package/.docs/raw/docs/ui/sources.mdx +0 -186
  309. package/.docs/raw/docs/ui/streamdown.mdx +0 -392
  310. package/.docs/raw/docs/ui/syntax-highlighting.mdx +0 -205
  311. package/.docs/raw/docs/ui/thread-list.mdx +0 -411
  312. package/.docs/raw/docs/ui/thread.mdx +0 -559
  313. package/.docs/raw/docs/ui/tool-fallback.mdx +0 -141
  314. package/.docs/raw/docs/ui/tool-group.mdx +0 -240
  315. package/.docs/raw/docs/ui/voice.mdx +0 -173
  316. package/.docs/raw/docs/utilities/heat-graph.mdx +0 -237
  317. package/.docs/raw/docs/utilities/react-o11y.mdx +0 -362
  318. package/.docs/raw/docs/utilities/tw-shimmer.mdx +0 -212
  319. package/dist/constants.d.ts +0 -14
  320. package/dist/constants.d.ts.map +0 -1
  321. package/dist/constants.js +0 -19
  322. package/dist/constants.js.map +0 -1
  323. package/dist/prepare-docs/code-examples.d.ts +0 -5
  324. package/dist/prepare-docs/code-examples.d.ts.map +0 -1
  325. package/dist/prepare-docs/code-examples.js +0 -117
  326. package/dist/prepare-docs/code-examples.js.map +0 -1
  327. package/dist/prepare-docs/copy-raw.d.ts +0 -5
  328. package/dist/prepare-docs/copy-raw.d.ts.map +0 -1
  329. package/dist/prepare-docs/copy-raw.js +0 -49
  330. package/dist/prepare-docs/copy-raw.js.map +0 -1
  331. package/dist/prepare-docs/prepare.d.ts +0 -1
  332. package/dist/prepare-docs/prepare.js +0 -22
  333. package/dist/prepare-docs/prepare.js.map +0 -1
  334. package/dist/prompts/xulux-playground.d.ts +0 -12
  335. package/dist/prompts/xulux-playground.d.ts.map +0 -1
  336. package/dist/prompts/xulux-playground.js +0 -33
  337. package/dist/prompts/xulux-playground.js.map +0 -1
  338. package/dist/tools/docs.d.ts +0 -22
  339. package/dist/tools/docs.d.ts.map +0 -1
  340. package/dist/tools/docs.js +0 -177
  341. package/dist/tools/docs.js.map +0 -1
  342. package/dist/tools/examples.d.ts +0 -24
  343. package/dist/tools/examples.d.ts.map +0 -1
  344. package/dist/tools/examples.js +0 -87
  345. package/dist/tools/examples.js.map +0 -1
  346. package/dist/tools/resources.d.ts +0 -6
  347. package/dist/tools/resources.d.ts.map +0 -1
  348. package/dist/tools/resources.js +0 -75
  349. package/dist/tools/resources.js.map +0 -1
  350. package/dist/tools/search.d.ts +0 -24
  351. package/dist/tools/search.d.ts.map +0 -1
  352. package/dist/tools/search.js +0 -39
  353. package/dist/tools/search.js.map +0 -1
  354. package/dist/tools/tests/mcp-test-client.d.ts +0 -15
  355. package/dist/tools/tests/mcp-test-client.d.ts.map +0 -1
  356. package/dist/tools/tests/mcp-test-client.js +0 -68
  357. package/dist/tools/tests/mcp-test-client.js.map +0 -1
  358. package/dist/tools/tests/test-setup.d.ts +0 -7
  359. package/dist/tools/tests/test-setup.d.ts.map +0 -1
  360. package/dist/tools/tests/test-setup.js +0 -36
  361. package/dist/tools/tests/test-setup.js.map +0 -1
  362. package/dist/tools/xulux-templates.d.ts +0 -58
  363. package/dist/tools/xulux-templates.d.ts.map +0 -1
  364. package/dist/tools/xulux-templates.js +0 -84
  365. package/dist/tools/xulux-templates.js.map +0 -1
  366. package/dist/utils/cache.d.ts +0 -5
  367. package/dist/utils/cache.d.ts.map +0 -1
  368. package/dist/utils/cache.js +0 -18
  369. package/dist/utils/cache.js.map +0 -1
  370. package/dist/utils/logger.d.ts +0 -10
  371. package/dist/utils/logger.d.ts.map +0 -1
  372. package/dist/utils/logger.js +0 -20
  373. package/dist/utils/logger.js.map +0 -1
  374. package/dist/utils/mcp-format.d.ts +0 -11
  375. package/dist/utils/mcp-format.d.ts.map +0 -1
  376. package/dist/utils/mcp-format.js +0 -14
  377. package/dist/utils/mcp-format.js.map +0 -1
  378. package/dist/utils/mdx.d.ts +0 -12
  379. package/dist/utils/mdx.d.ts.map +0 -1
  380. package/dist/utils/mdx.js +0 -45
  381. package/dist/utils/mdx.js.map +0 -1
  382. package/dist/utils/paths.d.ts +0 -12
  383. package/dist/utils/paths.d.ts.map +0 -1
  384. package/dist/utils/paths.js +0 -93
  385. package/dist/utils/paths.js.map +0 -1
  386. package/dist/utils/search.d.ts +0 -10
  387. package/dist/utils/search.d.ts.map +0 -1
  388. package/dist/utils/search.js +0 -97
  389. package/dist/utils/search.js.map +0 -1
  390. package/dist/utils/security.d.ts +0 -5
  391. package/dist/utils/security.d.ts.map +0 -1
  392. package/dist/utils/security.js +0 -22
  393. package/dist/utils/security.js.map +0 -1
  394. package/dist/xulux/catalog-client.d.ts +0 -14
  395. package/dist/xulux/catalog-client.d.ts.map +0 -1
  396. package/dist/xulux/catalog-client.js +0 -112
  397. package/dist/xulux/catalog-client.js.map +0 -1
  398. package/dist/xulux/fallback-catalog.d.ts +0 -7
  399. package/dist/xulux/fallback-catalog.d.ts.map +0 -1
  400. package/dist/xulux/fallback-catalog.js +0 -47
  401. package/dist/xulux/fallback-catalog.js.map +0 -1
  402. package/dist/xulux/fetch-sandbox.d.ts +0 -5
  403. package/dist/xulux/fetch-sandbox.d.ts.map +0 -1
  404. package/dist/xulux/fetch-sandbox.js +0 -40
  405. package/dist/xulux/fetch-sandbox.js.map +0 -1
  406. package/dist/xulux/template-service.d.ts +0 -84
  407. package/dist/xulux/template-service.d.ts.map +0 -1
  408. package/dist/xulux/template-service.js +0 -223
  409. package/dist/xulux/template-service.js.map +0 -1
  410. package/dist/xulux/types.d.ts +0 -55
  411. package/dist/xulux/types.d.ts.map +0 -1
  412. package/dist/xulux/types.js +0 -6
  413. package/dist/xulux/types.js.map +0 -1
  414. package/src/constants.ts +0 -24
  415. package/src/prepare-docs/code-examples.ts +0 -158
  416. package/src/prepare-docs/copy-raw.ts +0 -50
  417. package/src/prepare-docs/prepare.ts +0 -24
  418. package/src/prompts/xulux-playground.ts +0 -36
  419. package/src/tools/docs.ts +0 -255
  420. package/src/tools/examples.ts +0 -114
  421. package/src/tools/resources.ts +0 -111
  422. package/src/tools/search.ts +0 -46
  423. package/src/tools/tests/completions.test.ts +0 -60
  424. package/src/tools/tests/directory-size-cap.test.ts +0 -50
  425. package/src/tools/tests/docs.test.ts +0 -147
  426. package/src/tools/tests/examples.test.ts +0 -94
  427. package/src/tools/tests/integration.test.ts +0 -45
  428. package/src/tools/tests/json-parsing.test.ts +0 -23
  429. package/src/tools/tests/listings-cache.test.ts +0 -19
  430. package/src/tools/tests/mcp-protocol.test.ts +0 -216
  431. package/src/tools/tests/mcp-test-client.ts +0 -111
  432. package/src/tools/tests/path-traversal.test.ts +0 -84
  433. package/src/tools/tests/resources.test.ts +0 -133
  434. package/src/tools/tests/search.test.ts +0 -37
  435. package/src/tools/tests/test-setup.ts +0 -50
  436. package/src/tools/tests/xulux-templates.test.ts +0 -325
  437. package/src/tools/xulux-templates.ts +0 -141
  438. package/src/utils/cache.ts +0 -20
  439. package/src/utils/logger.ts +0 -20
  440. package/src/utils/mcp-format.ts +0 -14
  441. package/src/utils/mdx.ts +0 -59
  442. package/src/utils/paths.ts +0 -139
  443. package/src/utils/search.ts +0 -131
  444. package/src/utils/security.ts +0 -52
  445. package/src/utils/tests/cache.test.ts +0 -51
  446. package/src/utils/tests/mcp-format.test.ts +0 -22
  447. package/src/utils/tests/security.test.ts +0 -119
  448. package/src/xulux/catalog-client.ts +0 -150
  449. package/src/xulux/fallback-catalog.ts +0 -63
  450. package/src/xulux/fetch-sandbox.ts +0 -56
  451. package/src/xulux/template-service.ts +0 -406
  452. package/src/xulux/types.ts +0 -64
@@ -1,902 +0,0 @@
1
- ---
2
- title: LocalRuntime
3
- description: Quickest path to a working chat. Handles state while you handle the API.
4
- ---
5
-
6
- `LocalRuntime` is the simplest way to connect a custom backend. You implement a single `ChatModelAdapter` (one `run` function) and the runtime handles everything else: messages, threads, branching, editing, regeneration, cancellation.
7
-
8
- State lives inside the runtime by default. Multi-thread persistence and shared adapters are added via the standard interfaces, see [adapters](/docs/runtimes/concepts/adapters) and [threads](/docs/runtimes/concepts/threads).
9
-
10
- ## When to use it
11
-
12
- Pick `LocalRuntime` when:
13
-
14
- - You want assistant-ui to manage chat state for you.
15
- - Your backend exposes a function-call shaped API (REST, OpenAI SDK, your own model client).
16
- - Branching, editing, and regeneration should work without you writing extra code.
17
- - You want to compose adapters (attachments, speech, feedback, history, suggestions).
18
-
19
- If you already keep messages in redux, zustand, tanstack-query, or another store, use [`ExternalStoreRuntime`](/docs/runtimes/custom/external-store) instead.
20
-
21
- ## Quickstart
22
-
23
- <Steps>
24
- <Step>
25
-
26
- ### Create a project
27
-
28
- <PlatformTabs>
29
- <Tab value="React">
30
-
31
- ```sh
32
- npx create-next-app@latest my-app
33
- cd my-app
34
- ```
35
-
36
- </Tab>
37
- <Tab value="React Native">
38
-
39
- ```sh
40
- npx create-expo-app@latest my-app
41
- cd my-app
42
- ```
43
-
44
- </Tab>
45
- <Tab value="React Ink">
46
-
47
- ```sh
48
- mkdir my-app
49
- cd my-app
50
- npm init -y
51
- ```
52
-
53
- </Tab>
54
- </PlatformTabs>
55
-
56
- </Step>
57
- <Step>
58
-
59
- ### Install dependencies
60
-
61
- <PlatformTabs>
62
- <Tab value="React">
63
-
64
- <InstallCommand npm={["@assistant-ui/react"]} />
65
-
66
- </Tab>
67
- <Tab value="React Native">
68
-
69
- <InstallCommand expo={["@assistant-ui/react-native"]} />
70
-
71
- </Tab>
72
- <Tab value="React Ink">
73
-
74
- <InstallCommand npm={["@assistant-ui/react-ink", "ink", "react"]} />
75
-
76
- </Tab>
77
- </PlatformTabs>
78
-
79
- </Step>
80
- <Step>
81
-
82
- ### Add the Thread component
83
-
84
- <PlatformTabs>
85
- <Tab value="React">
86
-
87
- ```sh
88
- npx assistant-ui@latest add thread
89
- ```
90
-
91
- </Tab>
92
- <Tab value="React Native">
93
-
94
- Use your React Native thread component from the [React Native setup](/docs/react-native).
95
-
96
- </Tab>
97
- <Tab value="React Ink">
98
-
99
- Use your terminal thread component from the [Ink setup](/docs/ink).
100
-
101
- </Tab>
102
- </PlatformTabs>
103
-
104
- </Step>
105
- <Step>
106
-
107
- ### Define a `MyRuntimeProvider`
108
-
109
- Replace the `MyModelAdapter` body with your backend call.
110
-
111
- <PlatformTabs>
112
- <Tab value="React">
113
-
114
- ```tsx title="app/MyRuntimeProvider.tsx"
115
- "use client";
116
-
117
- import type { ReactNode } from "react";
118
- import {
119
- AssistantRuntimeProvider,
120
- useLocalRuntime,
121
- type ChatModelAdapter,
122
- } from "@assistant-ui/react";
123
-
124
- const MyModelAdapter: ChatModelAdapter = {
125
- async run({ messages, abortSignal }) {
126
- const result = await fetch("<YOUR_API_ENDPOINT>", {
127
- method: "POST",
128
- headers: { "Content-Type": "application/json" },
129
- body: JSON.stringify({ messages }),
130
- signal: abortSignal,
131
- });
132
- const data = await result.json();
133
- return {
134
- content: [{ type: "text", text: data.text }],
135
- };
136
- },
137
- };
138
-
139
- export function MyRuntimeProvider({
140
- children,
141
- }: Readonly<{ children: ReactNode }>) {
142
- const runtime = useLocalRuntime(MyModelAdapter);
143
- return (
144
- <AssistantRuntimeProvider runtime={runtime}>
145
- {children}
146
- </AssistantRuntimeProvider>
147
- );
148
- }
149
- ```
150
-
151
- </Tab>
152
- <Tab value="React Native">
153
-
154
- ```tsx title="runtime/MyRuntimeProvider.tsx"
155
- import type { ReactNode } from "react";
156
- import {
157
- AssistantRuntimeProvider,
158
- useLocalRuntime,
159
- type ChatModelAdapter,
160
- } from "@assistant-ui/react-native";
161
-
162
- const MyModelAdapter: ChatModelAdapter = {
163
- async run({ messages, abortSignal }) {
164
- const result = await fetch("<YOUR_API_ENDPOINT>", {
165
- method: "POST",
166
- headers: { "Content-Type": "application/json" },
167
- body: JSON.stringify({ messages }),
168
- signal: abortSignal,
169
- });
170
- const data = await result.json();
171
- return {
172
- content: [{ type: "text", text: data.text }],
173
- };
174
- },
175
- };
176
-
177
- export function MyRuntimeProvider({
178
- children,
179
- }: Readonly<{ children: ReactNode }>) {
180
- const runtime = useLocalRuntime(MyModelAdapter);
181
- return (
182
- <AssistantRuntimeProvider runtime={runtime}>
183
- {children}
184
- </AssistantRuntimeProvider>
185
- );
186
- }
187
- ```
188
-
189
- </Tab>
190
- <Tab value="React Ink">
191
-
192
- ```tsx title="runtime/MyRuntimeProvider.tsx"
193
- import type { ReactNode } from "react";
194
- import {
195
- AssistantRuntimeProvider,
196
- useLocalRuntime,
197
- type ChatModelAdapter,
198
- } from "@assistant-ui/react-ink";
199
-
200
- const MyModelAdapter: ChatModelAdapter = {
201
- async run({ messages, abortSignal }) {
202
- const result = await fetch("<YOUR_API_ENDPOINT>", {
203
- method: "POST",
204
- headers: { "Content-Type": "application/json" },
205
- body: JSON.stringify({ messages }),
206
- signal: abortSignal,
207
- });
208
- const data = await result.json();
209
- return {
210
- content: [{ type: "text", text: data.text }],
211
- };
212
- },
213
- };
214
-
215
- export function MyRuntimeProvider({
216
- children,
217
- }: Readonly<{ children: ReactNode }>) {
218
- const runtime = useLocalRuntime(MyModelAdapter);
219
- return (
220
- <AssistantRuntimeProvider runtime={runtime}>
221
- {children}
222
- </AssistantRuntimeProvider>
223
- );
224
- }
225
- ```
226
-
227
- </Tab>
228
- </PlatformTabs>
229
-
230
- </Step>
231
- <Step>
232
-
233
- ### Wrap your app
234
-
235
- <PlatformTabs>
236
- <Tab value="React">
237
-
238
- ```tsx title="app/layout.tsx"
239
- import type { ReactNode } from "react";
240
- import { MyRuntimeProvider } from "@/app/MyRuntimeProvider";
241
-
242
- export default function RootLayout({ children }: { children: ReactNode }) {
243
- return (
244
- <MyRuntimeProvider>
245
- <html lang="en">
246
- <body>{children}</body>
247
- </html>
248
- </MyRuntimeProvider>
249
- );
250
- }
251
- ```
252
-
253
- </Tab>
254
- <Tab value="React Native">
255
-
256
- ```tsx title="app/_layout.tsx"
257
- import { Stack } from "expo-router";
258
- import { MyRuntimeProvider } from "@/runtime/MyRuntimeProvider";
259
-
260
- export default function RootLayout() {
261
- return (
262
- <MyRuntimeProvider>
263
- <Stack />
264
- </MyRuntimeProvider>
265
- );
266
- }
267
- ```
268
-
269
- </Tab>
270
- <Tab value="React Ink">
271
-
272
- ```tsx title="app.tsx"
273
- import { Box } from "ink";
274
- import { Thread } from "./components/thread.js";
275
- import { MyRuntimeProvider } from "./runtime/MyRuntimeProvider.js";
276
-
277
- export function App() {
278
- return (
279
- <MyRuntimeProvider>
280
- <Box flexDirection="column">
281
- <Thread />
282
- </Box>
283
- </MyRuntimeProvider>
284
- );
285
- }
286
- ```
287
-
288
- </Tab>
289
- </PlatformTabs>
290
-
291
- </Step>
292
- <Step>
293
-
294
- ### Render the Thread
295
-
296
- <PlatformTabs>
297
- <Tab value="React">
298
-
299
- ```tsx title="app/page.tsx"
300
- import { Thread } from "@/components/assistant-ui/thread";
301
-
302
- export default function Page() {
303
- return <Thread />;
304
- }
305
- ```
306
-
307
- </Tab>
308
- <Tab value="React Native">
309
-
310
- ```tsx title="app/index.tsx"
311
- import { View } from "react-native";
312
- import { Thread } from "@/components/assistant-ui/thread";
313
-
314
- export default function Page() {
315
- return (
316
- <View style={{ flex: 1 }}>
317
- <Thread />
318
- </View>
319
- );
320
- }
321
- ```
322
-
323
- </Tab>
324
- <Tab value="React Ink">
325
-
326
- ```tsx title="index.tsx"
327
- import { render } from "ink";
328
- import { App } from "./app.js";
329
-
330
- render(<App />);
331
- ```
332
-
333
- </Tab>
334
- </PlatformTabs>
335
-
336
- </Step>
337
- </Steps>
338
-
339
- ## Streaming responses
340
-
341
- Declare `run` as an `async *` generator and yield the full cumulative content on each iteration:
342
-
343
- ```tsx
344
- import {
345
- ChatModelAdapter,
346
- ThreadMessage,
347
- type ModelContext,
348
- } from "@assistant-ui/react";
349
- import { OpenAI } from "openai";
350
-
351
- const openai = new OpenAI();
352
-
353
- const MyModelAdapter: ChatModelAdapter = {
354
- async *run({ messages, abortSignal, context }) {
355
- const stream = await openai.chat.completions.create({
356
- model: "gpt-5.6-luna",
357
- messages: convertToOpenAIMessages(messages),
358
- stream: true,
359
- signal: abortSignal,
360
- });
361
-
362
- let text = "";
363
- for await (const part of stream) {
364
- text += part.choices[0]?.delta?.content || "";
365
- yield {
366
- content: [{ type: "text", text }],
367
- };
368
- }
369
- },
370
- };
371
- ```
372
-
373
- Each yield replaces the previous content. Yield the full state every time, not deltas.
374
-
375
- ### Only the last part streams
376
-
377
- A text or reasoning part reports `status.type === "running"` only while it is the last part of the message. Every earlier one reads as complete, and the components that react to streaming follow that status: the reasoning disclosure auto-opens and pins its live preview while its part is running, and part status indicators resolve the same way. Tool-call parts are exempt, since their status comes from whether they have a result.
378
-
379
- That makes an empty trailing part destructive. Yielding `[reasoning, text("")]` to reserve the text slot marks the reasoning part complete the moment the empty text part appears, even though reasoning is still streaming, and nothing in the UI signals why. Add a part on its first token instead of reserving it:
380
-
381
- ```tsx
382
- let reasoning = "";
383
- let text = "";
384
-
385
- for await (const chunk of stream) {
386
- const delta = chunk.choices[0]?.delta;
387
- text += delta?.content ?? "";
388
- // Reasoning deltas are provider-specific; read whichever field yours sends
389
- reasoning += (delta as { reasoning?: string })?.reasoning ?? "";
390
-
391
- // Include each part only once it has content
392
- yield {
393
- content: [
394
- ...(reasoning ? [{ type: "reasoning" as const, text: reasoning }] : []),
395
- ...(text ? [{ type: "text" as const, text }] : []),
396
- ],
397
- };
398
- }
399
- ```
400
-
401
- Guard every text or reasoning part this way, not just the trailing one. An empty part that is never filled also renders as an empty block, and whichever part ends up last is the only one that can report `running`.
402
-
403
- ### Streaming with tool calls
404
-
405
- Accumulate tool calls in a `Map` outside the streaming loop so they persist across chunks:
406
-
407
- ```tsx
408
- async *run({ messages, abortSignal, context }) {
409
- const stream = await openai.chat.completions.create({
410
- model: "gpt-5.6-luna",
411
- messages: convertToOpenAIMessages(messages),
412
- tools: context.tools,
413
- stream: true,
414
- signal: abortSignal,
415
- });
416
-
417
- let text = "";
418
- const toolCallsMap = new Map();
419
-
420
- for await (const chunk of stream) {
421
- text += chunk.choices[0]?.delta?.content ?? "";
422
-
423
- for (const toolCall of chunk.choices[0]?.delta?.tool_calls ?? []) {
424
- toolCallsMap.set(toolCall.id, {
425
- type: "tool-call",
426
- toolName: toolCall.function?.name,
427
- toolCallId: toolCall.id,
428
- args: JSON.parse(toolCall.function?.arguments ?? "{}"),
429
- });
430
- }
431
-
432
- yield {
433
- content: [
434
- ...(text ? [{ type: "text" as const, text }] : []),
435
- ...Array.from(toolCallsMap.values()),
436
- ],
437
- };
438
- }
439
- }
440
- ```
441
-
442
- If you build the `content` array fresh from the current chunk each iteration, tool calls from earlier chunks will disappear when a later chunk carries only text. The Map outside the loop is the fix.
443
-
444
- ## Tool calling
445
-
446
- `LocalRuntime` supports OpenAI-compatible function calling. Register tools through the provider's `config` so the runtime exposes them to your adapter via `context.tools`:
447
-
448
- ```tsx title="app/toolkit.tsx"
449
- "use generative";
450
-
451
- import { defineToolkit } from "@assistant-ui/react";
452
- import { z } from "zod";
453
-
454
- export default defineToolkit({
455
- getWeather: {
456
- description: "Get the current weather in a location",
457
- parameters: z.object({
458
- location: z.string(),
459
- unit: z.enum(["celsius", "fahrenheit"]).default("celsius"),
460
- }),
461
- execute: async ({ location, unit }) => {
462
- "use client";
463
- return fetchWeather(location, unit);
464
- },
465
- renderText: { running: "Checking the weather…", complete: "Weather ready" },
466
- },
467
- });
468
- ```
469
-
470
- ```tsx title="app/MyRuntimeProvider.tsx"
471
- import { AuiConfig, Tools } from "@assistant-ui/react";
472
- import toolkit from "./toolkit";
473
-
474
- function MyRuntimeProvider({ children }: { children: React.ReactNode }) {
475
- const runtime = useLocalRuntime(MyModelAdapter);
476
- const config = AuiConfig({ tools: Tools({ toolkit }) });
477
- return (
478
- <AssistantRuntimeProvider runtime={runtime} config={config}>
479
- {children}
480
- </AssistantRuntimeProvider>
481
- );
482
- }
483
- ```
484
-
485
- See the [tools guide](/docs/tools/defining-tools) for advanced patterns.
486
-
487
- ### Human-in-the-loop tools
488
-
489
- Tools listed in `unstable_humanToolNames` are not executed by code. The run pauses on the tool call and the user supplies the result through the tool UI:
490
-
491
- ```ts
492
- const runtime = useLocalRuntime(MyModelAdapter, {
493
- unstable_humanToolNames: ["send_email"],
494
- });
495
- ```
496
-
497
- The pause is driven by the message status your adapter returns; `LocalRuntime` never sets it for you. When the model requests a human tool call, end the run with `status: { type: "requires-action", reason: "tool-calls" }`. Without that status, the runtime marks the message complete and nothing waits. Only return it while a listed tool call is missing its result: unresolved tool calls that are not listed do not hold the run, so the runtime would invoke your adapter again immediately.
498
-
499
- ```tsx
500
- const MyModelAdapter: ChatModelAdapter = {
501
- async run({ messages, abortSignal, unstable_getMessage }) {
502
- const toolResults = unstable_getMessage().content.flatMap((part) =>
503
- part.type === "tool-call" && part.result !== undefined
504
- ? [{ toolCallId: part.toolCallId, result: part.result }]
505
- : [],
506
- );
507
-
508
- const result = await fetch("<YOUR_API_ENDPOINT>", {
509
- method: "POST",
510
- headers: { "Content-Type": "application/json" },
511
- body: JSON.stringify({ messages, toolResults }),
512
- signal: abortSignal,
513
- });
514
- const data = await result.json();
515
-
516
- if (data.toolCall) {
517
- return {
518
- content: [
519
- {
520
- type: "tool-call",
521
- toolCallId: data.toolCall.id,
522
- toolName: data.toolCall.name,
523
- args: data.toolCall.args,
524
- argsText: JSON.stringify(data.toolCall.args),
525
- },
526
- ],
527
- status: { type: "requires-action", reason: "tool-calls" },
528
- };
529
- }
530
-
531
- return { content: [{ type: "text", text: data.text }] };
532
- },
533
- };
534
- ```
535
-
536
- The full loop:
537
-
538
- 1. **The run pauses.** While a listed tool call has no result, the runtime stops invoking your adapter. The unresolved tool call part reports `status.type === "requires-action"` to its renderer.
539
- 2. **The user responds.** The tool UI completes the call with `addResult(...)`. The stock [`ToolFallback`](/docs/ui/tool-fallback) component handles this out of the box: in the requires-action state it shows Allow and Deny buttons that record the decision as the tool result.
540
- 3. **The run resumes.** Once every listed tool call has a result, the runtime invokes your adapter again. The resumed call receives the same `messages` array as before (it ends at the user message; the in-progress assistant message is not part of it), so read the recorded results from `unstable_getMessage().content` as shown above. Content returned by the resumed call is appended to the same assistant message.
541
-
542
- For a custom confirmation UI, register a human tool whose `render` completes the call with `addResult`. The shape of the result payload is yours to define; the adapter receives it verbatim and translates it for your backend:
543
-
544
- ```tsx
545
- const toolkit = defineToolkit({
546
- send_email: {
547
- type: "human",
548
- description: "Send an email after the user confirms",
549
- parameters: z.object({ to: z.string(), subject: z.string() }),
550
- render: ({ args, result, addResult }) => {
551
- if (result) {
552
- return <p>{result.approved ? "Sent" : `Cancelled: ${result.reason}`}</p>;
553
- }
554
- return (
555
- <div>
556
- <p>
557
- Send "{args.subject}" to {args.to}?
558
- </p>
559
- <button onClick={() => addResult({ approved: true })}>Allow</button>
560
- <button
561
- onClick={() =>
562
- addResult({ approved: false, reason: "User declined" })
563
- }
564
- >
565
- Deny
566
- </button>
567
- </div>
568
- );
569
- },
570
- },
571
- });
572
- ```
573
-
574
- `unstable_humanToolNames` is unstable; see [stability](/docs/runtimes/concepts/stability).
575
-
576
- ### Approval gates
577
-
578
- The [server-side approval gate](/docs/tools/tool-ui#server-side-approval-gates) is also supported on `LocalRuntime`, for actions your backend executes after the user authorizes them. Where a human tool asks the user to supply the tool result, an approval gate asks the user to allow or block an action the adapter performs. Emit `approval: { id }` on the tool call part and end the run with the same `requires-action` status:
579
-
580
- ```tsx
581
- return {
582
- content: [
583
- {
584
- type: "tool-call",
585
- toolCallId: data.toolCall.id,
586
- toolName: data.toolCall.name,
587
- args: data.toolCall.args,
588
- argsText: JSON.stringify(data.toolCall.args),
589
- approval: { id: data.toolCall.id },
590
- },
591
- ],
592
- status: { type: "requires-action", reason: "tool-calls" },
593
- };
594
- ```
595
-
596
- A tool call with a pending approval pauses the run, whether or not the tool is listed in `unstable_humanToolNames`. Always emit gates in the pending state (`approval: { id }` with no `approved` field); a part that arrives already decided is treated as resolved and the runtime invokes the adapter again immediately. The stock [`ToolFallback`](/docs/ui/tool-fallback) Allow and Deny buttons, or a custom renderer calling `respondToApproval({ approved, reason? })`, record the decision:
597
-
598
- - **Deny** sets `approval.approved: false` and synthesizes an error result (`{ error: reason || "Tool approval denied" }` with `isError: true`), so the model sees the denial.
599
- - **Allow** sets `approval.approved: true` and leaves the result empty; performing the action is your adapter's job.
600
-
601
- Once every pending approval on the message is decided and every listed human tool has a result, the runtime invokes your adapter again. Read the decisions from `unstable_getMessage().content`, perform the approved actions, and return the follow-up response. A tool call that carries an approval is owned by the gate: it does not additionally require a result, even when its name is listed in `unstable_humanToolNames`.
602
-
603
- ## Resuming a run
604
-
605
- `resumeRun` reconnects to an in-progress assistant run. Useful for page refresh, network reconnect, tab backgrounding, or thread switching when the backend is still generating.
606
-
607
- Unlike `startRun` (which uses the `ChatModelAdapter`), `resumeRun` requires a `stream` parameter; you provide the async generator that produces the response.
608
-
609
- ```tsx
610
- import { useAui } from "@assistant-ui/react";
611
- import type { ChatModelRunResult } from "@assistant-ui/core";
612
-
613
- const aui = useAui();
614
-
615
- async function* createCustomStream(): AsyncGenerator<ChatModelRunResult> {
616
- yield { content: [{ type: "text", text: "Initial response" }] };
617
- await new Promise((r) => setTimeout(r, 500));
618
- yield {
619
- content: [
620
- { type: "text", text: "Initial response. And here's more content..." },
621
- ],
622
- };
623
- }
624
-
625
- aui.thread.resumeRun({
626
- parentId: "message-id",
627
- stream: createCustomStream,
628
- });
629
- ```
630
-
631
- A common pattern is to check whether the backend is still running on mount, then reconnect:
632
-
633
- ```tsx
634
- function useStreamReconnect(threadId: string) {
635
- const aui = useAui();
636
- const checkedRef = useRef(false);
637
-
638
- useEffect(() => {
639
- if (checkedRef.current) return;
640
- checkedRef.current = true;
641
-
642
- (async () => {
643
- const status = await fetch(`/api/status/${threadId}`).then((r) =>
644
- r.json(),
645
- );
646
- if (status.isRunning) {
647
- const parentId = aui.thread.getState().messages.at(-1)?.id ?? null;
648
- aui.thread.resumeRun({ parentId });
649
- }
650
- })();
651
- }, [aui, threadId]);
652
- }
653
- ```
654
-
655
- ## Queueing messages during a run
656
-
657
- Set `unstable_enableMessageQueue` to keep the composer usable while a run is in progress. A message sent during a queued run steers by default — it lands in the steer lane, ahead of previously queued items; `send({ steer: false })` queues a follow-up behind them instead. Pending items are held in `composer.queue` and drain once the run settles.
658
-
659
- ```tsx
660
- const runtime = useLocalRuntime(MyModelAdapter, {
661
- unstable_enableMessageQueue: true,
662
- });
663
- ```
664
-
665
- Render the pending messages with [`ComposerPrimitive.Queue`](/docs/api-reference/primitives/composer) and [`QueueItemPrimitive`](/docs/api-reference/primitives/queue-item).
666
-
667
- ## Adapters
668
-
669
- Attachments, speech, feedback, history, and suggestions are wired through the standard adapter contracts, see [adapters](/docs/runtimes/concepts/adapters):
670
-
671
- ```tsx
672
- const runtime = useLocalRuntime(MyModelAdapter, {
673
- adapters: {
674
- attachments: myAttachmentAdapter,
675
- speech: mySpeechAdapter,
676
- feedback: myFeedbackAdapter,
677
- history: myHistoryAdapter,
678
- suggestion: mySuggestionAdapter,
679
- },
680
- });
681
- ```
682
-
683
- ## Multi-thread
684
-
685
- `LocalRuntime` supports multi-thread either via [AssistantCloud](/docs/cloud) or via a custom `RemoteThreadListAdapter`. See [threads](/docs/runtimes/concepts/threads) for the contract and full examples.
686
-
687
- ```tsx
688
- // managed (see "AssistantCloud" in /docs/runtimes/concepts/threads for cloud setup)
689
- const runtime = useLocalRuntime(MyModelAdapter, { cloud });
690
- ```
691
-
692
- ## Integration examples
693
-
694
- ### OpenAI
695
-
696
- ```tsx
697
- import { OpenAI } from "openai";
698
-
699
- const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
700
-
701
- const OpenAIAdapter: ChatModelAdapter = {
702
- async *run({ messages, abortSignal, context }) {
703
- const stream = await openai.chat.completions.create({
704
- model: "gpt-5.6-luna",
705
- messages: messages.map((m) => ({
706
- role: m.role,
707
- content: m.content
708
- .filter((c) => c.type === "text")
709
- .map((c) => c.text)
710
- .join("\n"),
711
- })),
712
- stream: true,
713
- signal: abortSignal,
714
- });
715
-
716
- let fullText = "";
717
- for await (const chunk of stream) {
718
- const content = chunk.choices[0]?.delta?.content;
719
- if (content) {
720
- fullText += content;
721
- yield { content: [{ type: "text", text: fullText }] };
722
- }
723
- }
724
- },
725
- };
726
- ```
727
-
728
- For local development on a ChatGPT Plus or Pro plan, the same client can run without a real API key by pointing `baseURL` at a local OAuth proxy and passing a placeholder `apiKey`; see [ChatGPT Subscription](/docs/guides/chatgpt-subscription#openai-compatible-proxy).
729
-
730
- ### Custom REST API
731
-
732
- ```tsx
733
- const CustomAPIAdapter: ChatModelAdapter = {
734
- async run({ messages, abortSignal, unstable_threadId }) {
735
- const response = await fetch("/api/chat", {
736
- method: "POST",
737
- headers: { "Content-Type": "application/json" },
738
- body: JSON.stringify({
739
- messages: messages.map((m) => ({
740
- role: m.role,
741
- content: m.content,
742
- })),
743
- threadId: unstable_threadId,
744
- }),
745
- signal: abortSignal,
746
- });
747
- if (!response.ok) throw new Error(`API error: ${response.statusText}`);
748
- const data = await response.json();
749
- return { content: [{ type: "text", text: data.message }] };
750
- },
751
- };
752
- ```
753
-
754
- ## Best practices
755
-
756
- 1. **Always pass `abortSignal`** to `fetch` and SDK calls so cancel works:
757
- ```tsx
758
- fetch(url, { signal: abortSignal });
759
- ```
760
- 2. **Handle errors gracefully.** Swallow `AbortError` (it is the user cancelling); rethrow others to surface in the UI.
761
- 3. **Yield cumulative state, not deltas.** Each yield replaces the previous content; if you yield deltas the UI flickers.
762
- 4. **Accumulate tool calls outside the streaming loop**, otherwise they vanish on the first text-only chunk.
763
-
764
- ## Troubleshooting
765
-
766
- **Messages not appearing.** Ensure your adapter returns the correct shape: `{ content: [{ type: "text", text: "..." }] }`.
767
-
768
- **Streaming not working.** Use `async *run` (with the asterisk). A plain `async run` cannot yield.
769
-
770
- **Tool UI flickers and disappears.** state is being reset between chunks. Accumulate tool calls in a `Map` declared outside the `for await` loop.
771
-
772
- ## API reference
773
-
774
- ### `ChatModelAdapter`
775
-
776
- <ParametersTable
777
- type="ChatModelAdapter"
778
- parameters={[
779
- {
780
- name: "run",
781
- type: "ChatModelRunOptions => ChatModelRunResult | AsyncGenerator<ChatModelRunResult>",
782
- description:
783
- "Function that sends messages to your API and returns the response.",
784
- required: true,
785
- },
786
- ]}
787
- />
788
-
789
- ### `ChatModelRunOptions`
790
-
791
- <ParametersTable
792
- type="ChatModelRunOptions"
793
- parameters={[
794
- {
795
- name: "messages",
796
- type: "readonly ThreadMessage[]",
797
- description: "The conversation history to send to your API.",
798
- required: true,
799
- },
800
- {
801
- name: "runConfig",
802
- type: "RunConfig",
803
- description:
804
- "Run configuration with optional custom metadata. RunConfig is { readonly custom?: Record<string, unknown> }.",
805
- required: true,
806
- },
807
- {
808
- name: "abortSignal",
809
- type: "AbortSignal",
810
- description: "Signal to cancel the request if user interrupts.",
811
- required: true,
812
- },
813
- {
814
- name: "context",
815
- type: "ModelContext",
816
- description: "Additional context including configuration and tools.",
817
- required: true,
818
- },
819
- {
820
- name: "unstable_assistantMessageId",
821
- type: "string | Undefined",
822
- description:
823
- "ID of the assistant message being generated. Useful for tracking or updating specific messages.",
824
- },
825
- {
826
- name: "unstable_threadId",
827
- type: "string | Undefined",
828
- description:
829
- "Current thread/conversation identifier. Useful for passing to your backend API.",
830
- },
831
- {
832
- name: "unstable_parentId",
833
- type: "string | Null | Undefined",
834
- description:
835
- "ID of the parent message this response is replying to. null if this is the first message.",
836
- },
837
- {
838
- name: "unstable_getMessage",
839
- type: "() => ThreadMessage",
840
- description:
841
- "Returns the current assistant message being generated. Useful during streaming.",
842
- },
843
- ]}
844
- />
845
-
846
- ### `LocalRuntimeOptions`
847
-
848
- <ParametersTable
849
- type="LocalRuntimeOptions"
850
- parameters={[
851
- {
852
- name: "initialMessages",
853
- type: "readonly ThreadMessageLike[]",
854
- description: "Pre-populate the thread with messages.",
855
- },
856
- {
857
- name: "maxSteps",
858
- type: "number",
859
- description:
860
- "Maximum number of sequential tool calls before requiring user input.",
861
- default: "2",
862
- },
863
- {
864
- name: "cloud",
865
- type: "AssistantCloud",
866
- description:
867
- "Enable Assistant Cloud integration for multi-thread support and persistence.",
868
- },
869
- {
870
- name: "adapters",
871
- type: "LocalRuntimeAdapters",
872
- description:
873
- "Capability adapters. UI features automatically enable based on which adapters are provided. See /docs/runtimes/concepts/adapters.",
874
- },
875
- {
876
- name: "unstable_humanToolNames",
877
- type: "string[]",
878
- description:
879
- "Tool names that pause the run until the user supplies a result via addResult (unstable).",
880
- },
881
- ]}
882
- />
883
-
884
- ## Related
885
-
886
- <Cards>
887
- <Card
888
- title="ExternalStoreRuntime"
889
- description="Bring your own state store."
890
- href="/docs/runtimes/custom/external-store"
891
- />
892
- <Card
893
- title="Adapters"
894
- description="Attachments, speech, feedback, history, suggestions."
895
- href="/docs/runtimes/concepts/adapters"
896
- />
897
- <Card
898
- title="Threads"
899
- description="Cloud, custom database, ExternalStore-based."
900
- href="/docs/runtimes/concepts/threads"
901
- />
902
- </Cards>