@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,2063 +0,0 @@
1
- # Example: with-expo
2
-
3
- ## .vscode/extensions.json
4
-
5
- ```json
6
- { "recommendations": ["expo.vscode-expo-tools"] }
7
-
8
- ```
9
-
10
- ## .vscode/settings.json
11
-
12
- ```json
13
- {
14
- "editor.codeActionsOnSave": {
15
- "source.fixAll": "explicit",
16
- "source.organizeImports": "explicit",
17
- "source.sortMembers": "explicit"
18
- }
19
- }
20
-
21
- ```
22
-
23
- ## app.json
24
-
25
- ```json
26
- {
27
- "expo": {
28
- "name": "with-expo",
29
- "slug": "with-expo",
30
- "version": "0.0.0",
31
- "orientation": "portrait",
32
- "icon": "./assets/images/icon.png",
33
- "scheme": "withexpo",
34
- "userInterfaceStyle": "automatic",
35
- "newArchEnabled": true,
36
- "ios": {
37
- "supportsTablet": true,
38
- "bundleIdentifier": "com.assistant-ui.with-expo"
39
- },
40
- "android": {
41
- "adaptiveIcon": {
42
- "backgroundColor": "#E6F4FE",
43
- "foregroundImage": "./assets/images/android-icon-foreground.png",
44
- "backgroundImage": "./assets/images/android-icon-background.png",
45
- "monochromeImage": "./assets/images/android-icon-monochrome.png"
46
- },
47
- "edgeToEdgeEnabled": true,
48
- "predictiveBackGestureEnabled": false
49
- },
50
- "web": {
51
- "output": "static",
52
- "favicon": "./assets/images/favicon.png"
53
- },
54
- "plugins": [
55
- "expo-router",
56
- [
57
- "expo-splash-screen",
58
- {
59
- "image": "./assets/images/splash-icon.png",
60
- "imageWidth": 200,
61
- "resizeMode": "contain",
62
- "backgroundColor": "#ffffff",
63
- "dark": {
64
- "backgroundColor": "#18181b"
65
- }
66
- }
67
- ],
68
- "expo-font",
69
- "expo-image",
70
- "expo-status-bar"
71
- ],
72
- "experiments": {
73
- "typedRoutes": true,
74
- "reactCompiler": true
75
- }
76
- }
77
- }
78
-
79
- ```
80
-
81
- ## app/_layout.tsx
82
-
83
- ```tsx
84
- import {
85
- DarkTheme,
86
- DefaultTheme,
87
- ThemeProvider,
88
- type Theme,
89
- } from "@react-navigation/native";
90
- import { Drawer } from "expo-router/drawer";
91
- import { StatusBar } from "expo-status-bar";
92
- import "react-native-reanimated";
93
- import { Platform, Pressable } from "react-native";
94
- import MaterialIcons from "@expo/vector-icons/MaterialIcons";
95
- import { useFonts } from "expo-font";
96
- import { GestureHandlerRootView } from "react-native-gesture-handler";
97
-
98
- import {
99
- AssistantRuntimeProvider,
100
- AuiConfig,
101
- useAui,
102
- Tools,
103
- } from "@assistant-ui/react-native";
104
- import { useAppRuntime } from "@/hooks/use-app-runtime";
105
- import { useTheme } from "@/hooks/use-theme";
106
- import { Icon } from "@/components/ui/icon";
107
- import { ThreadListDrawer } from "@/components/thread-list/ThreadListDrawer";
108
- import { haptics } from "@/lib/haptics";
109
- import toolkit from "@/components/assistant-ui/tools";
110
-
111
- function NewChatButton() {
112
- const aui = useAui();
113
- const { colors } = useTheme();
114
-
115
- return (
116
- <Pressable
117
- accessibilityLabel="New chat"
118
- hitSlop={8}
119
- onPress={() => {
120
- haptics.selection();
121
- aui.threads.switchToNewThread();
122
- }}
123
- style={{ marginRight: 16 }}
124
- >
125
- <Icon name="compose" size={22} color={colors.foreground} />
126
- </Pressable>
127
- );
128
- }
129
-
130
- function DrawerLayout() {
131
- const { isDark, colors } = useTheme();
132
-
133
- const base = isDark ? DarkTheme : DefaultTheme;
134
- const navTheme: Theme = {
135
- ...base,
136
- colors: {
137
- ...base.colors,
138
- background: colors.background,
139
- card: colors.background,
140
- text: colors.foreground,
141
- border: colors.border,
142
- primary: colors.foreground,
143
- },
144
- };
145
-
146
- return (
147
- <ThemeProvider value={navTheme}>
148
- <Drawer
149
- drawerContent={(props) => <ThreadListDrawer {...props} />}
150
- screenOptions={{
151
- headerRight: () => <NewChatButton />,
152
- headerShadowVisible: false,
153
- headerTintColor: colors.foreground,
154
- headerStyle: { backgroundColor: colors.background },
155
- headerTitleStyle: { fontWeight: "600" },
156
- drawerType: "front",
157
- swipeEnabled: true,
158
- drawerStyle: { backgroundColor: colors.background },
159
- }}
160
- >
161
- <Drawer.Screen name="index" options={{ title: "Chat" }} />
162
- </Drawer>
163
- <StatusBar style="auto" />
164
- </ThemeProvider>
165
- );
166
- }
167
-
168
- export default function RootLayout() {
169
- // iOS renders SF Symbols, so it never needs the MaterialIcons glyph font.
170
- const [fontsLoaded] = useFonts(
171
- Platform.OS === "ios" ? {} : MaterialIcons.font,
172
- );
173
- const runtime = useAppRuntime();
174
- const config = AuiConfig({
175
- tools: Tools({ toolkit }),
176
- });
177
-
178
- if (!fontsLoaded) return null;
179
-
180
- return (
181
- <GestureHandlerRootView style={{ flex: 1 }}>
182
- <AssistantRuntimeProvider runtime={runtime} config={config}>
183
- <DrawerLayout />
184
- </AssistantRuntimeProvider>
185
- </GestureHandlerRootView>
186
- );
187
- }
188
-
189
- ```
190
-
191
- ## app/api/chat+api.ts
192
-
193
- ```typescript
194
- import { frontendTools } from "@assistant-ui/react-ai-sdk";
195
- import { openai } from "@ai-sdk/openai";
196
- import {
197
- convertToModelMessages,
198
- pruneMessages,
199
- stepCountIs,
200
- streamText,
201
- } from "ai";
202
-
203
- export async function POST(req: Request) {
204
- const body = await req.json();
205
- const { messages, tools } = body;
206
-
207
- const model = openai("gpt-5.6-luna");
208
-
209
- const prunedMessages = pruneMessages({
210
- messages: await convertToModelMessages(messages),
211
- reasoning: "none",
212
- });
213
-
214
- const result = streamText({
215
- model,
216
- messages: prunedMessages,
217
- maxOutputTokens: 15000,
218
- stopWhen: stepCountIs(10),
219
- tools: frontendTools(tools),
220
- });
221
-
222
- return result.toUIMessageStreamResponse();
223
- }
224
-
225
- ```
226
-
227
- ## app/index.tsx
228
-
229
- ```tsx
230
- import { Thread } from "@/components/assistant-ui/thread";
231
-
232
- export default function ChatPage() {
233
- return <Thread />;
234
- }
235
-
236
- ```
237
-
238
- ## babel.config.js
239
-
240
- ```javascript
241
- const path = require("node:path");
242
-
243
- module.exports = (api) => {
244
- api.cache(true);
245
- return {
246
- presets: [
247
- [
248
- "babel-preset-expo",
249
- {
250
- "react-compiler": {
251
- // Workspace packages resolve to paths outside node_modules, so the
252
- // preset's node_modules exclusion does not cover them. Restrict the
253
- // compiler to this app's own sources.
254
- sources: (filename) => filename.startsWith(__dirname + path.sep),
255
- },
256
- },
257
- ],
258
- ],
259
- };
260
- };
261
-
262
- ```
263
-
264
- ## components/assistant-ui/composer.tsx
265
-
266
- ```tsx
267
- import { View, Pressable, Platform, StyleSheet } from "react-native";
268
- import { Image } from "expo-image";
269
- import * as ImagePicker from "expo-image-picker";
270
- import {
271
- useAui,
272
- useAuiState,
273
- AuiIf,
274
- ComposerPrimitive,
275
- AttachmentPrimitive,
276
- } from "@assistant-ui/react-native";
277
- import { Icon } from "@/components/ui/icon";
278
- import { useTheme } from "@/hooks/use-theme";
279
- import { Radius, Spacing } from "@/constants/theme";
280
- import { haptics } from "@/lib/haptics";
281
-
282
- function AttachmentPreview() {
283
- const { colors } = useTheme();
284
- const attachment = useAuiState((s) => s.attachment);
285
- if (!attachment) return null;
286
-
287
- const imageContent = attachment.content?.find((c: any) => c.type === "image");
288
- const uri = (imageContent as any)?.image;
289
-
290
- return (
291
- <AttachmentPrimitive.Root style={styles.attachmentItem}>
292
- {uri ? (
293
- <Image
294
- source={{ uri }}
295
- style={[styles.attachmentImage, { backgroundColor: colors.muted }]}
296
- contentFit="cover"
297
- transition={120}
298
- />
299
- ) : null}
300
- <AttachmentPrimitive.Remove
301
- onPressIn={haptics.light}
302
- style={styles.attachmentRemove}
303
- >
304
- <View
305
- style={[styles.removeBadge, { backgroundColor: colors.foreground }]}
306
- >
307
- <Icon name="remove" size={16} color={colors.background} />
308
- </View>
309
- </AttachmentPrimitive.Remove>
310
- </AttachmentPrimitive.Root>
311
- );
312
- }
313
-
314
- function SendButton() {
315
- const { colors } = useTheme();
316
- const canSend = useAuiState((s) => s.composer.canSend);
317
-
318
- return (
319
- <ComposerPrimitive.Send
320
- accessibilityLabel="Send message"
321
- onPressIn={() => canSend && haptics.success()}
322
- style={[
323
- styles.actionButton,
324
- { backgroundColor: canSend ? colors.primary : colors.muted },
325
- ]}
326
- >
327
- <Icon
328
- name="send"
329
- size={18}
330
- color={canSend ? colors.primaryForeground : colors.mutedForeground}
331
- />
332
- </ComposerPrimitive.Send>
333
- );
334
- }
335
-
336
- function CancelButton() {
337
- const { colors } = useTheme();
338
- return (
339
- <ComposerPrimitive.Cancel
340
- accessibilityLabel="Stop generating"
341
- onPressIn={haptics.light}
342
- style={[styles.actionButton, { backgroundColor: colors.foreground }]}
343
- >
344
- <Icon name="stop" size={15} color={colors.background} />
345
- </ComposerPrimitive.Cancel>
346
- );
347
- }
348
-
349
- function AttachButton() {
350
- const { colors } = useTheme();
351
- const aui = useAui();
352
-
353
- const pickImage = async () => {
354
- haptics.selection();
355
- const result = await ImagePicker.launchImageLibraryAsync({
356
- mediaTypes: ["images"],
357
- allowsMultipleSelection: true,
358
- quality: 0.8,
359
- base64: true,
360
- });
361
- if (result.canceled) return;
362
-
363
- for (const asset of result.assets) {
364
- // iOS may report HEIC, which OpenAI rejects; normalize to JPEG.
365
- const dataUrl = `data:image/jpeg;base64,${asset.base64}`;
366
- await aui.composer.addAttachment({
367
- name: asset.fileName ?? "image.jpg",
368
- contentType: "image/jpeg",
369
- type: "image",
370
- content: [{ type: "image", image: dataUrl }],
371
- });
372
- }
373
- };
374
-
375
- return (
376
- <Pressable
377
- accessibilityLabel="Add image"
378
- onPress={pickImage}
379
- hitSlop={6}
380
- style={({ pressed }) => [
381
- styles.attachButton,
382
- { backgroundColor: pressed ? colors.muted : "transparent" },
383
- ]}
384
- >
385
- <Icon name="add" size={20} color={colors.mutedForeground} />
386
- </Pressable>
387
- );
388
- }
389
-
390
- export function Composer() {
391
- const { colors } = useTheme();
392
- const hasAttachments = useAuiState((s) => s.composer.attachments.length > 0);
393
-
394
- return (
395
- <View style={styles.container}>
396
- <View
397
- style={[
398
- styles.shell,
399
- { backgroundColor: colors.composer, borderColor: colors.border },
400
- ]}
401
- >
402
- {hasAttachments && (
403
- <View style={styles.attachmentsRow}>
404
- <ComposerPrimitive.Attachments>
405
- {() => <AttachmentPreview />}
406
- </ComposerPrimitive.Attachments>
407
- </View>
408
- )}
409
-
410
- <ComposerPrimitive.Input
411
- style={[styles.input, { color: colors.foreground }]}
412
- placeholder="Message…"
413
- placeholderTextColor={colors.mutedForeground}
414
- multiline
415
- maxLength={4000}
416
- />
417
-
418
- <View style={styles.actionRow}>
419
- <AttachButton />
420
- <AuiIf condition={(s) => !s.thread.isRunning}>
421
- <SendButton />
422
- </AuiIf>
423
- <AuiIf condition={(s) => s.thread.isRunning}>
424
- <CancelButton />
425
- </AuiIf>
426
- </View>
427
- </View>
428
- </View>
429
- );
430
- }
431
-
432
- const styles = StyleSheet.create({
433
- container: {
434
- width: "100%",
435
- maxWidth: Spacing.threadMaxWidth + 24,
436
- alignSelf: "center",
437
- paddingHorizontal: 12,
438
- paddingTop: 8,
439
- },
440
- shell: {
441
- flexDirection: "column",
442
- gap: 6,
443
- borderRadius: Radius.composer,
444
- borderWidth: StyleSheet.hairlineWidth,
445
- padding: 8,
446
- },
447
- attachmentsRow: {
448
- flexDirection: "row",
449
- flexWrap: "wrap",
450
- gap: 8,
451
- paddingHorizontal: 4,
452
- paddingTop: 4,
453
- },
454
- attachmentItem: {
455
- position: "relative",
456
- },
457
- attachmentImage: {
458
- width: 56,
459
- height: 56,
460
- borderRadius: Radius.attachment,
461
- },
462
- attachmentRemove: {
463
- position: "absolute",
464
- top: -6,
465
- right: -6,
466
- },
467
- removeBadge: {
468
- width: 20,
469
- height: 20,
470
- borderRadius: 10,
471
- alignItems: "center",
472
- justifyContent: "center",
473
- },
474
- input: {
475
- fontSize: 16,
476
- lineHeight: 22,
477
- minHeight: 28,
478
- maxHeight: 132,
479
- paddingHorizontal: 10,
480
- paddingTop: 6,
481
- paddingBottom: 2,
482
- ...Platform.select({
483
- web: { outlineStyle: "none" } as any,
484
- default: {},
485
- }),
486
- },
487
- actionRow: {
488
- flexDirection: "row",
489
- alignItems: "center",
490
- justifyContent: "space-between",
491
- },
492
- attachButton: {
493
- width: 32,
494
- height: 32,
495
- borderRadius: Radius.pill,
496
- alignItems: "center",
497
- justifyContent: "center",
498
- },
499
- actionButton: {
500
- width: 32,
501
- height: 32,
502
- borderRadius: Radius.pill,
503
- alignItems: "center",
504
- justifyContent: "center",
505
- },
506
- });
507
-
508
- ```
509
-
510
- ## components/assistant-ui/message-action-bar.tsx
511
-
512
- ```tsx
513
- import { View, StyleSheet } from "react-native";
514
- import * as Clipboard from "expo-clipboard";
515
- import { Icon } from "@/components/ui/icon";
516
- import { ActionBarPrimitive } from "@assistant-ui/react-native";
517
- import { useTheme } from "@/hooks/use-theme";
518
- import { haptics } from "@/lib/haptics";
519
- import { Radius } from "@/constants/theme";
520
-
521
- const copyToClipboard = async (text: string) => {
522
- await Clipboard.setStringAsync(text);
523
- };
524
-
525
- export function MessageActionBar() {
526
- const { colors } = useTheme();
527
-
528
- const buttonStyle = ({ pressed }: { pressed: boolean }) => [
529
- styles.button,
530
- pressed && { backgroundColor: colors.muted },
531
- ];
532
-
533
- return (
534
- <View style={styles.container}>
535
- <ActionBarPrimitive.Copy
536
- copyToClipboard={copyToClipboard}
537
- onPressIn={haptics.selection}
538
- style={buttonStyle}
539
- >
540
- {({ isCopied }) => (
541
- <Icon
542
- name={isCopied ? "check" : "copy"}
543
- size={16}
544
- color={isCopied ? colors.foreground : colors.mutedForeground}
545
- />
546
- )}
547
- </ActionBarPrimitive.Copy>
548
- <ActionBarPrimitive.Reload
549
- onPressIn={haptics.selection}
550
- style={buttonStyle}
551
- >
552
- <Icon name="reload" size={16} color={colors.mutedForeground} />
553
- </ActionBarPrimitive.Reload>
554
- </View>
555
- );
556
- }
557
-
558
- const styles = StyleSheet.create({
559
- container: {
560
- flexDirection: "row",
561
- alignItems: "center",
562
- gap: 2,
563
- },
564
- button: {
565
- padding: 6,
566
- borderRadius: Radius.sm,
567
- },
568
- });
569
-
570
- ```
571
-
572
- ## components/assistant-ui/message-branch-picker.tsx
573
-
574
- ```tsx
575
- import { View, Text, StyleSheet } from "react-native";
576
- import { Icon } from "@/components/ui/icon";
577
- import { BranchPickerPrimitive, useAuiState } from "@assistant-ui/react-native";
578
- import { useTheme } from "@/hooks/use-theme";
579
-
580
- export function MessageBranchPicker({
581
- align = "flex-start",
582
- }: {
583
- align?: "flex-start" | "flex-end";
584
- }) {
585
- const { colors } = useTheme();
586
- const branchNumber = useAuiState((s) => s.message.branchNumber);
587
- const branchCount = useAuiState((s) => s.message.branchCount);
588
-
589
- if (branchCount <= 1) return null;
590
-
591
- return (
592
- <View style={[styles.container, { justifyContent: align }]}>
593
- <BranchPickerPrimitive.Previous
594
- style={[styles.button, { opacity: branchNumber <= 1 ? 0.35 : 1 }]}
595
- hitSlop={4}
596
- >
597
- <Icon name="chevron-left" size={16} color={colors.mutedForeground} />
598
- </BranchPickerPrimitive.Previous>
599
- <Text style={[styles.label, { color: colors.mutedForeground }]}>
600
- <BranchPickerPrimitive.Number /> / <BranchPickerPrimitive.Count />
601
- </Text>
602
- <BranchPickerPrimitive.Next
603
- style={[
604
- styles.button,
605
- { opacity: branchNumber >= branchCount ? 0.35 : 1 },
606
- ]}
607
- hitSlop={4}
608
- >
609
- <Icon name="chevron-right" size={16} color={colors.mutedForeground} />
610
- </BranchPickerPrimitive.Next>
611
- </View>
612
- );
613
- }
614
-
615
- const styles = StyleSheet.create({
616
- container: {
617
- flexDirection: "row",
618
- alignItems: "center",
619
- gap: 2,
620
- },
621
- button: {
622
- padding: 4,
623
- },
624
- label: {
625
- fontSize: 12,
626
- fontVariant: ["tabular-nums"],
627
- },
628
- });
629
-
630
- ```
631
-
632
- ## components/assistant-ui/message.tsx
633
-
634
- ```tsx
635
- import { useEffect, useRef } from "react";
636
- import { View, Text, Animated, Platform, StyleSheet } from "react-native";
637
- import { Image } from "expo-image";
638
- import {
639
- useAuiState,
640
- MessagePrimitive,
641
- ErrorPrimitive,
642
- type TextMessagePartComponent,
643
- } from "@assistant-ui/react-native";
644
- import { useTheme } from "@/hooks/use-theme";
645
- import { Radius } from "@/constants/theme";
646
- import { MessageActionBar } from "./message-action-bar";
647
- import { MessageBranchPicker } from "./message-branch-picker";
648
-
649
- const UserText: TextMessagePartComponent = ({ text }) => {
650
- const { colors } = useTheme();
651
- return (
652
- <Text style={[styles.userText, { color: colors.foreground }]}>{text}</Text>
653
- );
654
- };
655
-
656
- const AssistantText: TextMessagePartComponent = ({ text }) => {
657
- const { colors } = useTheme();
658
- return (
659
- <Text style={[styles.assistantText, { color: colors.foreground }]}>
660
- {text}
661
- </Text>
662
- );
663
- };
664
-
665
- function TypingDot({ delay }: { delay: number }) {
666
- const { colors } = useTheme();
667
- const opacity = useRef(new Animated.Value(0.3)).current;
668
-
669
- useEffect(() => {
670
- const anim = Animated.loop(
671
- Animated.sequence([
672
- Animated.timing(opacity, {
673
- toValue: 1,
674
- duration: 400,
675
- delay,
676
- useNativeDriver: Platform.OS !== "web",
677
- }),
678
- Animated.timing(opacity, {
679
- toValue: 0.3,
680
- duration: 400,
681
- useNativeDriver: Platform.OS !== "web",
682
- }),
683
- ]),
684
- );
685
- anim.start();
686
- return () => anim.stop();
687
- }, [opacity, delay]);
688
-
689
- return (
690
- <Animated.View
691
- style={[styles.dot, { opacity, backgroundColor: colors.mutedForeground }]}
692
- />
693
- );
694
- }
695
-
696
- function TypingIndicator() {
697
- const isRunning = useAuiState((s) => s.message.status?.type === "running");
698
- if (!isRunning) return null;
699
-
700
- return (
701
- <View style={styles.typing}>
702
- <TypingDot delay={0} />
703
- <TypingDot delay={160} />
704
- <TypingDot delay={320} />
705
- </View>
706
- );
707
- }
708
-
709
- function MessageImageAttachment() {
710
- const { colors } = useTheme();
711
- const attachment = useAuiState((s) => s.attachment);
712
- if (!attachment) return null;
713
-
714
- const imageContent = attachment.content?.find((c: any) => c.type === "image");
715
- const uri = (imageContent as any)?.image;
716
- if (!uri) return null;
717
-
718
- return (
719
- <Image
720
- source={{ uri }}
721
- style={[styles.messageImage, { backgroundColor: colors.muted }]}
722
- contentFit="cover"
723
- transition={120}
724
- />
725
- );
726
- }
727
-
728
- function UserMessage() {
729
- const { colors } = useTheme();
730
- return (
731
- <MessagePrimitive.Root style={styles.userContainer}>
732
- <View style={styles.userAttachments}>
733
- <MessagePrimitive.Attachments>
734
- {() => <MessageImageAttachment />}
735
- </MessagePrimitive.Attachments>
736
- </View>
737
- <View style={[styles.userBubble, { backgroundColor: colors.muted }]}>
738
- <MessagePrimitive.Parts components={{ Text: UserText }} />
739
- </View>
740
- <MessageBranchPicker align="flex-end" />
741
- </MessagePrimitive.Root>
742
- );
743
- }
744
-
745
- function AssistantMessage() {
746
- const { colors } = useTheme();
747
- return (
748
- <MessagePrimitive.Root style={styles.assistantContainer}>
749
- <View style={styles.assistantContent}>
750
- <MessagePrimitive.Parts
751
- components={{ Text: AssistantText, Empty: TypingIndicator }}
752
- />
753
- <ErrorPrimitive.Root
754
- style={[
755
- styles.error,
756
- {
757
- backgroundColor: colors.destructiveSurface,
758
- borderColor: colors.destructive,
759
- },
760
- ]}
761
- >
762
- <ErrorPrimitive.Message
763
- style={[styles.errorText, { color: colors.destructive }]}
764
- />
765
- </ErrorPrimitive.Root>
766
- </View>
767
- <MessagePrimitive.If running={false}>
768
- <View style={styles.actionsRow}>
769
- <MessageBranchPicker align="flex-start" />
770
- <MessageActionBar />
771
- </View>
772
- </MessagePrimitive.If>
773
- </MessagePrimitive.Root>
774
- );
775
- }
776
-
777
- export function MessageBubble() {
778
- const role = useAuiState((s) => s.message.role);
779
- if (role === "user") return <UserMessage />;
780
- return <AssistantMessage />;
781
- }
782
-
783
- const styles = StyleSheet.create({
784
- userContainer: {
785
- alignItems: "flex-end",
786
- },
787
- userAttachments: {
788
- flexDirection: "row",
789
- flexWrap: "wrap",
790
- justifyContent: "flex-end",
791
- gap: 6,
792
- },
793
- userBubble: {
794
- maxWidth: "85%",
795
- paddingHorizontal: 16,
796
- paddingVertical: 10,
797
- borderRadius: Radius.bubble,
798
- },
799
- assistantContainer: {
800
- alignItems: "flex-start",
801
- },
802
- assistantContent: {
803
- paddingHorizontal: 2,
804
- },
805
- userText: {
806
- fontSize: 16,
807
- lineHeight: 22,
808
- letterSpacing: -0.2,
809
- },
810
- assistantText: {
811
- fontSize: 16,
812
- lineHeight: 25,
813
- letterSpacing: -0.2,
814
- },
815
- typing: {
816
- flexDirection: "row",
817
- alignItems: "center",
818
- gap: 5,
819
- paddingVertical: 8,
820
- },
821
- dot: {
822
- width: 7,
823
- height: 7,
824
- borderRadius: 3.5,
825
- },
826
- messageImage: {
827
- width: 200,
828
- height: 200,
829
- borderRadius: Radius.card,
830
- marginBottom: 6,
831
- },
832
- actionsRow: {
833
- flexDirection: "row",
834
- alignItems: "center",
835
- gap: 4,
836
- marginTop: 6,
837
- marginLeft: -4,
838
- },
839
- error: {
840
- marginTop: 8,
841
- borderRadius: Radius.md,
842
- borderWidth: StyleSheet.hairlineWidth,
843
- paddingHorizontal: 12,
844
- paddingVertical: 10,
845
- },
846
- errorText: {
847
- fontSize: 14,
848
- lineHeight: 20,
849
- },
850
- });
851
-
852
- ```
853
-
854
- ## components/assistant-ui/thread.tsx
855
-
856
- ```tsx
857
- import {
858
- View,
859
- Text,
860
- StyleSheet,
861
- KeyboardAvoidingView,
862
- Platform,
863
- } from "react-native";
864
- import { useSafeAreaInsets } from "react-native-safe-area-context";
865
- import { MessageBubble } from "./message";
866
- import { Composer } from "./composer";
867
- import { ThreadPrimitive } from "@assistant-ui/react-native";
868
- import { useTheme } from "@/hooks/use-theme";
869
- import { Radius, Spacing } from "@/constants/theme";
870
- import { haptics } from "@/lib/haptics";
871
-
872
- const suggestions = [
873
- "What's the weather in Tokyo?",
874
- "Tell me a joke",
875
- "Help me write an email",
876
- ];
877
-
878
- function SuggestionChip({ prompt }: { prompt: string }) {
879
- const { colors } = useTheme();
880
- return (
881
- <ThreadPrimitive.Suggestion
882
- prompt={prompt}
883
- send
884
- onPressIn={haptics.selection}
885
- style={({ pressed }: { pressed: boolean }) => [
886
- styles.chip,
887
- {
888
- borderColor: colors.border,
889
- backgroundColor: pressed ? colors.muted : colors.background,
890
- },
891
- ]}
892
- >
893
- <Text style={[styles.chipText, { color: colors.foreground }]}>
894
- {prompt}
895
- </Text>
896
- </ThreadPrimitive.Suggestion>
897
- );
898
- }
899
-
900
- function EmptyState() {
901
- const { colors } = useTheme();
902
- return (
903
- <View style={styles.empty}>
904
- <Text style={[styles.welcome, { color: colors.foreground }]}>
905
- How can I help you today?
906
- </Text>
907
- <View style={styles.chips}>
908
- {suggestions.map((prompt) => (
909
- <SuggestionChip key={prompt} prompt={prompt} />
910
- ))}
911
- </View>
912
- </View>
913
- );
914
- }
915
-
916
- function ChatMessages() {
917
- return (
918
- <>
919
- <ThreadPrimitive.Empty>
920
- <EmptyState />
921
- </ThreadPrimitive.Empty>
922
- <ThreadPrimitive.If empty={false}>
923
- <ThreadPrimitive.MessagesFlatList
924
- style={styles.flex}
925
- contentContainerStyle={styles.messageList}
926
- showsVerticalScrollIndicator={false}
927
- >
928
- {() => <MessageBubble />}
929
- </ThreadPrimitive.MessagesFlatList>
930
- </ThreadPrimitive.If>
931
- </>
932
- );
933
- }
934
-
935
- export function Thread() {
936
- const insets = useSafeAreaInsets();
937
- const { colors } = useTheme();
938
-
939
- return (
940
- <View style={[styles.container, { backgroundColor: colors.background }]}>
941
- <KeyboardAvoidingView
942
- style={styles.flex}
943
- behavior={Platform.OS === "ios" ? "padding" : undefined}
944
- >
945
- <View style={styles.flex}>
946
- <ChatMessages />
947
- </View>
948
- <View style={{ paddingBottom: insets.bottom + 8 }}>
949
- <Composer />
950
- </View>
951
- </KeyboardAvoidingView>
952
- </View>
953
- );
954
- }
955
-
956
- const styles = StyleSheet.create({
957
- container: {
958
- flex: 1,
959
- },
960
- flex: {
961
- flex: 1,
962
- },
963
- messageList: {
964
- width: "100%",
965
- maxWidth: Spacing.threadMaxWidth,
966
- marginHorizontal: "auto",
967
- paddingVertical: 20,
968
- paddingHorizontal: 12,
969
- gap: 18,
970
- },
971
- empty: {
972
- flex: 1,
973
- justifyContent: "center",
974
- alignItems: "center",
975
- paddingHorizontal: 24,
976
- },
977
- welcome: {
978
- fontSize: 24,
979
- fontWeight: "600",
980
- letterSpacing: -0.4,
981
- textAlign: "center",
982
- marginBottom: 24,
983
- },
984
- chips: {
985
- flexDirection: "row",
986
- flexWrap: "wrap",
987
- justifyContent: "center",
988
- gap: 8,
989
- },
990
- chip: {
991
- paddingHorizontal: 14,
992
- paddingVertical: 8,
993
- borderRadius: Radius.pill,
994
- borderWidth: StyleSheet.hairlineWidth,
995
- },
996
- chipText: {
997
- fontSize: 14,
998
- letterSpacing: -0.2,
999
- },
1000
- });
1001
-
1002
- ```
1003
-
1004
- ## components/assistant-ui/tools.tsx
1005
-
1006
- ```tsx
1007
- "use generative";
1008
-
1009
- import type { ReactNode } from "react";
1010
- import { View, Text, StyleSheet } from "react-native";
1011
- import {
1012
- defineToolkit,
1013
- type ToolCallMessagePartProps,
1014
- } from "@assistant-ui/react-native";
1015
- import { z } from "zod";
1016
- import { useTheme } from "@/hooks/use-theme";
1017
- import { Radius } from "@/constants/theme";
1018
-
1019
- // Open-Meteo API adapters (free, no API key needed)
1020
-
1021
- const geocodeLocationWithOpenMeteo = async (query: string) => {
1022
- try {
1023
- const response = await fetch(
1024
- `https://geocoding-api.open-meteo.com/v1/search?name=${encodeURIComponent(query)}&count=1`,
1025
- );
1026
- if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`);
1027
- const data = await response.json();
1028
- if (!data.results || data.results.length === 0)
1029
- throw new Error("No results found");
1030
- return { success: true as const, result: data.results[0] };
1031
- } catch (error) {
1032
- return {
1033
- success: false as const,
1034
- error:
1035
- error instanceof Error ? error.message : "Failed to geocode location",
1036
- };
1037
- }
1038
- };
1039
-
1040
- const mapWeatherCode = (code: number): string => {
1041
- if (code === 0) return "Clear";
1042
- if (code <= 3) return "Partly Cloudy";
1043
- if (code <= 48) return "Foggy";
1044
- if (code <= 57) return "Drizzle";
1045
- if (code <= 67) return "Rain";
1046
- if (code <= 77) return "Snow";
1047
- if (code <= 82) return "Showers";
1048
- if (code <= 86) return "Snow Showers";
1049
- if (code === 95) return "Thunderstorm";
1050
- return "Stormy";
1051
- };
1052
-
1053
- const mapWeatherEmoji = (code: number): string => {
1054
- if (code === 0) return "☀️";
1055
- if (code <= 3) return "⛅";
1056
- if (code <= 48) return "🌫️";
1057
- if (code <= 57) return "🌦️";
1058
- if (code <= 67) return "🌧️";
1059
- if (code <= 77) return "❄️";
1060
- if (code <= 82) return "🌦️";
1061
- if (code <= 86) return "🌨️";
1062
- if (code === 95) return "⛈️";
1063
- return "🌩️";
1064
- };
1065
-
1066
- const fetchWeatherFromOpenMeteo = async ({
1067
- query,
1068
- longitude,
1069
- latitude,
1070
- }: {
1071
- query: string;
1072
- longitude: number;
1073
- latitude: number;
1074
- }) => {
1075
- try {
1076
- const response = await fetch(
1077
- `https://api.open-meteo.com/v1/forecast?latitude=${latitude}&longitude=${longitude}&timezone=auto&temperature_unit=fahrenheit&current=temperature_2m,weather_code,wind_speed_10m&daily=weather_code,temperature_2m_max,temperature_2m_min&forecast_days=5`,
1078
- );
1079
- if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`);
1080
- const data = await response.json();
1081
- const current = data.current;
1082
- const daily = data.daily;
1083
- if (!current || !daily?.time) throw new Error("Invalid API response");
1084
-
1085
- const forecast = daily.time.slice(0, 5).map((date: string, i: number) => {
1086
- const d = new Date(`${date}T12:00:00Z`);
1087
- const label =
1088
- i === 0
1089
- ? "Today"
1090
- : new Intl.DateTimeFormat("en-US", {
1091
- weekday: "short",
1092
- timeZone: "UTC",
1093
- }).format(d);
1094
- return {
1095
- label,
1096
- code: daily.weather_code[i],
1097
- min: Math.round(daily.temperature_2m_min[i]),
1098
- max: Math.round(daily.temperature_2m_max[i]),
1099
- };
1100
- });
1101
-
1102
- return {
1103
- success: true as const,
1104
- location: query,
1105
- temperature: Math.round(current.temperature_2m),
1106
- weatherCode: current.weather_code,
1107
- windSpeed: Math.round(current.wind_speed_10m),
1108
- forecast,
1109
- };
1110
- } catch (error) {
1111
- return {
1112
- success: false as const,
1113
- error: error instanceof Error ? error.message : "Failed to fetch weather",
1114
- };
1115
- }
1116
- };
1117
-
1118
- // Tool UI Components
1119
-
1120
- function ToolCard({ children }: { children: ReactNode }) {
1121
- const { colors } = useTheme();
1122
- return (
1123
- <View
1124
- style={[
1125
- styles.card,
1126
- { backgroundColor: colors.muted, borderColor: colors.border },
1127
- ]}
1128
- >
1129
- {children}
1130
- </View>
1131
- );
1132
- }
1133
-
1134
- function ToolStatus({ label }: { label: string }) {
1135
- const { colors } = useTheme();
1136
- return (
1137
- <ToolCard>
1138
- <Text style={[styles.statusText, { color: colors.mutedForeground }]}>
1139
- {label}
1140
- </Text>
1141
- </ToolCard>
1142
- );
1143
- }
1144
-
1145
- function ToolError({ label }: { label: string }) {
1146
- const { colors } = useTheme();
1147
- return (
1148
- <View
1149
- style={[
1150
- styles.card,
1151
- {
1152
- backgroundColor: colors.destructiveSurface,
1153
- borderColor: colors.destructive,
1154
- },
1155
- ]}
1156
- >
1157
- <Text style={[styles.statusText, { color: colors.destructive }]}>
1158
- {label}
1159
- </Text>
1160
- </View>
1161
- );
1162
- }
1163
-
1164
- function GeocodeToolUI(
1165
- props: ToolCallMessagePartProps<
1166
- { query: string },
1167
- {
1168
- success: boolean;
1169
- result?: { name: string; latitude: number; longitude: number };
1170
- error?: string;
1171
- }
1172
- >,
1173
- ) {
1174
- const { colors } = useTheme();
1175
-
1176
- if (props.status?.type === "running") {
1177
- return <ToolStatus label="Finding location…" />;
1178
- }
1179
-
1180
- if (props.result?.error) {
1181
- return <ToolError label={`Geocoding failed: ${props.result.error}`} />;
1182
- }
1183
-
1184
- const result = props.result?.result;
1185
- if (!result) return null;
1186
-
1187
- return (
1188
- <ToolCard>
1189
- <View style={styles.row}>
1190
- <Text style={styles.pin}>{"📍"}</Text>
1191
- <View>
1192
- <Text style={[styles.locationName, { color: colors.foreground }]}>
1193
- {result.name}
1194
- </Text>
1195
- <Text style={[styles.coords, { color: colors.mutedForeground }]}>
1196
- {Math.abs(result.latitude).toFixed(2)}
1197
- {"°"}
1198
- {result.latitude >= 0 ? "N" : "S"},{" "}
1199
- {Math.abs(result.longitude).toFixed(2)}
1200
- {"°"}
1201
- {result.longitude >= 0 ? "E" : "W"}
1202
- </Text>
1203
- </View>
1204
- </View>
1205
- </ToolCard>
1206
- );
1207
- }
1208
-
1209
- function WeatherToolUI(
1210
- props: ToolCallMessagePartProps<
1211
- { query: string; longitude: number; latitude: number },
1212
- {
1213
- success: boolean;
1214
- location?: string;
1215
- temperature?: number;
1216
- weatherCode?: number;
1217
- windSpeed?: number;
1218
- forecast?: Array<{
1219
- label: string;
1220
- code: number;
1221
- min: number;
1222
- max: number;
1223
- }>;
1224
- error?: string;
1225
- }
1226
- >,
1227
- ) {
1228
- const { colors } = useTheme();
1229
-
1230
- if (props.status?.type === "running") {
1231
- return <ToolStatus label={`Fetching weather for ${props.args.query}…`} />;
1232
- }
1233
-
1234
- if (!props.result?.success) {
1235
- return (
1236
- <ToolError
1237
- label={`Weather unavailable: ${props.result?.error ?? "Unknown error"}`}
1238
- />
1239
- );
1240
- }
1241
-
1242
- const { location, temperature, weatherCode, windSpeed, forecast } =
1243
- props.result;
1244
-
1245
- return (
1246
- <ToolCard>
1247
- <View style={styles.weatherHeader}>
1248
- <Text style={styles.weatherEmoji}>
1249
- {mapWeatherEmoji(weatherCode ?? 0)}
1250
- </Text>
1251
- <View>
1252
- <Text style={[styles.locationName, { color: colors.foreground }]}>
1253
- {location}
1254
- </Text>
1255
- <Text style={[styles.condition, { color: colors.mutedForeground }]}>
1256
- {mapWeatherCode(weatherCode ?? 0)}
1257
- </Text>
1258
- </View>
1259
- </View>
1260
-
1261
- <Text style={[styles.tempLarge, { color: colors.foreground }]}>
1262
- {temperature ?? "--"}
1263
- {"°"}F
1264
- </Text>
1265
-
1266
- {windSpeed != null && (
1267
- <Text style={[styles.wind, { color: colors.mutedForeground }]}>
1268
- Wind: {windSpeed} mph
1269
- </Text>
1270
- )}
1271
-
1272
- {forecast && forecast.length > 0 && (
1273
- <View style={[styles.forecastRow, { borderTopColor: colors.border }]}>
1274
- {forecast.map((day, i) => (
1275
- <View key={i} style={styles.forecastDay}>
1276
- <Text
1277
- style={[
1278
- styles.forecastLabel,
1279
- { color: colors.mutedForeground },
1280
- ]}
1281
- >
1282
- {day.label}
1283
- </Text>
1284
- <Text style={styles.forecastEmoji}>
1285
- {mapWeatherEmoji(day.code)}
1286
- </Text>
1287
- <Text style={[styles.forecastTemp, { color: colors.foreground }]}>
1288
- {day.max}
1289
- {"°"}
1290
- </Text>
1291
- <Text
1292
- style={[
1293
- styles.forecastTempLow,
1294
- { color: colors.mutedForeground },
1295
- ]}
1296
- >
1297
- {day.min}
1298
- {"°"}
1299
- </Text>
1300
- </View>
1301
- ))}
1302
- </View>
1303
- )}
1304
- </ToolCard>
1305
- );
1306
- }
1307
-
1308
- // Toolkit definition
1309
-
1310
- export default defineToolkit({
1311
- geocode_location: {
1312
- description: "Geocode a location using Open-Meteo's geocoding API",
1313
- parameters: z.object({
1314
- query: z.string(),
1315
- }),
1316
- execute: async (args: { query: string }) => {
1317
- "use client";
1318
- return geocodeLocationWithOpenMeteo(args.query);
1319
- },
1320
- render: GeocodeToolUI,
1321
- },
1322
- weather_search: {
1323
- description:
1324
- "Find the weather in a location given a longitude and latitude",
1325
- parameters: z.object({
1326
- query: z.string(),
1327
- longitude: z.number(),
1328
- latitude: z.number(),
1329
- }),
1330
- execute: async (args: {
1331
- query: string;
1332
- longitude: number;
1333
- latitude: number;
1334
- }) => {
1335
- "use client";
1336
- return fetchWeatherFromOpenMeteo(args);
1337
- },
1338
- render: WeatherToolUI,
1339
- },
1340
- });
1341
-
1342
- const styles = StyleSheet.create({
1343
- card: {
1344
- padding: 14,
1345
- borderRadius: Radius.card,
1346
- borderWidth: StyleSheet.hairlineWidth,
1347
- marginVertical: 4,
1348
- gap: 4,
1349
- },
1350
- statusText: {
1351
- fontSize: 13,
1352
- },
1353
- row: {
1354
- flexDirection: "row",
1355
- alignItems: "center",
1356
- gap: 10,
1357
- },
1358
- pin: {
1359
- fontSize: 20,
1360
- },
1361
- locationName: {
1362
- fontSize: 15,
1363
- fontWeight: "600",
1364
- },
1365
- coords: {
1366
- fontSize: 13,
1367
- marginTop: 2,
1368
- },
1369
- weatherHeader: {
1370
- flexDirection: "row",
1371
- alignItems: "center",
1372
- gap: 10,
1373
- marginBottom: 4,
1374
- },
1375
- weatherEmoji: {
1376
- fontSize: 32,
1377
- },
1378
- condition: {
1379
- fontSize: 13,
1380
- marginTop: 2,
1381
- },
1382
- tempLarge: {
1383
- fontSize: 40,
1384
- fontWeight: "700",
1385
- letterSpacing: -1,
1386
- },
1387
- wind: {
1388
- fontSize: 13,
1389
- marginTop: 2,
1390
- },
1391
- forecastRow: {
1392
- flexDirection: "row",
1393
- justifyContent: "space-between",
1394
- marginTop: 12,
1395
- paddingTop: 12,
1396
- borderTopWidth: StyleSheet.hairlineWidth,
1397
- },
1398
- forecastDay: {
1399
- alignItems: "center",
1400
- flex: 1,
1401
- gap: 4,
1402
- },
1403
- forecastLabel: {
1404
- fontSize: 11,
1405
- fontWeight: "500",
1406
- },
1407
- forecastEmoji: {
1408
- fontSize: 18,
1409
- },
1410
- forecastTemp: {
1411
- fontSize: 13,
1412
- fontWeight: "600",
1413
- },
1414
- forecastTempLow: {
1415
- fontSize: 12,
1416
- },
1417
- });
1418
-
1419
- ```
1420
-
1421
- ## components/thread-list/ThreadListDrawer.tsx
1422
-
1423
- ```tsx
1424
- import { View, Text, Pressable, StyleSheet } from "react-native";
1425
- import { useSafeAreaInsets } from "react-native-safe-area-context";
1426
- import { ThreadListPrimitive, useAui } from "@assistant-ui/react-native";
1427
- import type { DrawerContentComponentProps } from "expo-router/build/react-navigation/drawer/types";
1428
- import { ThreadListItem } from "./ThreadListItem";
1429
- import { Icon } from "@/components/ui/icon";
1430
- import { useTheme } from "@/hooks/use-theme";
1431
- import { Radius } from "@/constants/theme";
1432
- import { haptics } from "@/lib/haptics";
1433
-
1434
- export function ThreadListDrawer({ navigation }: DrawerContentComponentProps) {
1435
- const { colors } = useTheme();
1436
- const aui = useAui();
1437
- const insets = useSafeAreaInsets();
1438
-
1439
- return (
1440
- <View
1441
- style={[
1442
- styles.container,
1443
- { backgroundColor: colors.background, paddingTop: insets.top + 12 },
1444
- ]}
1445
- >
1446
- <ThreadListPrimitive.Root style={styles.root}>
1447
- <Pressable
1448
- onPressIn={haptics.selection}
1449
- onPress={() => {
1450
- aui.threads.switchToNewThread();
1451
- navigation.closeDrawer();
1452
- }}
1453
- style={({ pressed }) => [
1454
- styles.newButton,
1455
- { backgroundColor: pressed ? colors.muted : "transparent" },
1456
- ]}
1457
- >
1458
- <Icon name="compose" size={18} color={colors.foreground} />
1459
- <Text style={[styles.newLabel, { color: colors.foreground }]}>
1460
- New chat
1461
- </Text>
1462
- </Pressable>
1463
-
1464
- <Text style={[styles.sectionLabel, { color: colors.mutedForeground }]}>
1465
- Recent
1466
- </Text>
1467
-
1468
- <ThreadListPrimitive.Items
1469
- renderItem={() => (
1470
- <ThreadListItem onSelect={() => navigation.closeDrawer()} />
1471
- )}
1472
- style={styles.list}
1473
- contentContainerStyle={styles.listContent}
1474
- showsVerticalScrollIndicator={false}
1475
- />
1476
- </ThreadListPrimitive.Root>
1477
- </View>
1478
- );
1479
- }
1480
-
1481
- const styles = StyleSheet.create({
1482
- container: {
1483
- flex: 1,
1484
- },
1485
- root: {
1486
- flex: 1,
1487
- },
1488
- newButton: {
1489
- flexDirection: "row",
1490
- alignItems: "center",
1491
- gap: 10,
1492
- height: 40,
1493
- paddingHorizontal: 12,
1494
- marginHorizontal: 8,
1495
- marginBottom: 4,
1496
- borderRadius: Radius.md,
1497
- },
1498
- newLabel: {
1499
- fontSize: 15,
1500
- fontWeight: "500",
1501
- letterSpacing: -0.2,
1502
- },
1503
- sectionLabel: {
1504
- fontSize: 12,
1505
- fontWeight: "500",
1506
- paddingHorizontal: 20,
1507
- paddingTop: 12,
1508
- paddingBottom: 6,
1509
- },
1510
- list: {
1511
- flex: 1,
1512
- },
1513
- listContent: {
1514
- paddingBottom: 8,
1515
- },
1516
- });
1517
-
1518
- ```
1519
-
1520
- ## components/thread-list/ThreadListItem.tsx
1521
-
1522
- ```tsx
1523
- import { Text, Pressable, StyleSheet } from "react-native";
1524
- import {
1525
- ThreadListItemPrimitive,
1526
- useAui,
1527
- useAuiState,
1528
- } from "@assistant-ui/react-native";
1529
- import { useTheme } from "@/hooks/use-theme";
1530
- import { Radius } from "@/constants/theme";
1531
- import { haptics } from "@/lib/haptics";
1532
-
1533
- export function ThreadListItem({ onSelect }: { onSelect: () => void }) {
1534
- const { colors } = useTheme();
1535
- const aui = useAui();
1536
- const isActive = useAuiState(
1537
- (s) => s.threads.mainThreadId === s.threadListItem.id,
1538
- );
1539
-
1540
- return (
1541
- <ThreadListItemPrimitive.Root>
1542
- <Pressable
1543
- onPressIn={haptics.selection}
1544
- onPress={() => {
1545
- aui.threadListItem.switchTo();
1546
- onSelect();
1547
- }}
1548
- style={({ pressed }) => [
1549
- styles.item,
1550
- (isActive || pressed) && { backgroundColor: colors.muted },
1551
- ]}
1552
- >
1553
- <Text
1554
- numberOfLines={1}
1555
- style={[
1556
- styles.title,
1557
- {
1558
- color: colors.foreground,
1559
- fontWeight: isActive ? "600" : "400",
1560
- },
1561
- ]}
1562
- >
1563
- <ThreadListItemPrimitive.Title fallback="New chat" />
1564
- </Text>
1565
- </Pressable>
1566
- </ThreadListItemPrimitive.Root>
1567
- );
1568
- }
1569
-
1570
- const styles = StyleSheet.create({
1571
- item: {
1572
- height: 38,
1573
- justifyContent: "center",
1574
- paddingHorizontal: 12,
1575
- marginHorizontal: 8,
1576
- borderRadius: Radius.md,
1577
- },
1578
- title: {
1579
- fontSize: 15,
1580
- letterSpacing: -0.2,
1581
- },
1582
- });
1583
-
1584
- ```
1585
-
1586
- ## components/ui/icon-mappings.ts
1587
-
1588
- ```typescript
1589
- import type { ComponentProps } from "react";
1590
- import type MaterialIcons from "@expo/vector-icons/MaterialIcons";
1591
- import type { SymbolViewProps, SymbolWeight } from "expo-symbols";
1592
-
1593
- export type IconName =
1594
- | "compose"
1595
- | "send"
1596
- | "stop"
1597
- | "add"
1598
- | "remove"
1599
- | "copy"
1600
- | "check"
1601
- | "reload"
1602
- | "chevron-left"
1603
- | "chevron-right"
1604
- | "menu"
1605
- | "location";
1606
-
1607
- export type IconProps = {
1608
- name: IconName;
1609
- size?: number;
1610
- color: string;
1611
- weight?: SymbolWeight;
1612
- };
1613
-
1614
- /** SF Symbols rendered natively on iOS via `expo-symbols`. */
1615
- export const SF_SYMBOLS: Record<IconName, SymbolViewProps["name"]> = {
1616
- compose: "square.and.pencil",
1617
- send: "arrow.up",
1618
- stop: "stop.fill",
1619
- add: "plus",
1620
- remove: "xmark",
1621
- copy: "doc.on.doc",
1622
- check: "checkmark",
1623
- reload: "arrow.clockwise",
1624
- "chevron-left": "chevron.left",
1625
- "chevron-right": "chevron.right",
1626
- menu: "line.3.horizontal",
1627
- location: "location.fill",
1628
- };
1629
-
1630
- /** Material Icons fallback for Android and web. */
1631
- export const MATERIAL_ICONS: Record<
1632
- IconName,
1633
- ComponentProps<typeof MaterialIcons>["name"]
1634
- > = {
1635
- compose: "edit",
1636
- send: "arrow-upward",
1637
- stop: "stop",
1638
- add: "add",
1639
- remove: "close",
1640
- copy: "content-copy",
1641
- check: "check",
1642
- reload: "refresh",
1643
- "chevron-left": "chevron-left",
1644
- "chevron-right": "chevron-right",
1645
- menu: "menu",
1646
- location: "place",
1647
- };
1648
-
1649
- ```
1650
-
1651
- ## components/ui/icon.ios.tsx
1652
-
1653
- ```tsx
1654
- import { SymbolView } from "expo-symbols";
1655
- import { SF_SYMBOLS, type IconProps } from "./icon-mappings";
1656
-
1657
- export function Icon({
1658
- name,
1659
- size = 24,
1660
- color,
1661
- weight = "regular",
1662
- }: IconProps) {
1663
- return (
1664
- <SymbolView
1665
- name={SF_SYMBOLS[name]}
1666
- tintColor={color}
1667
- weight={weight}
1668
- resizeMode="scaleAspectFit"
1669
- style={{ width: size, height: size }}
1670
- />
1671
- );
1672
- }
1673
-
1674
- ```
1675
-
1676
- ## components/ui/icon.tsx
1677
-
1678
- ```tsx
1679
- import MaterialIcons from "@expo/vector-icons/MaterialIcons";
1680
- import { MATERIAL_ICONS, type IconProps } from "./icon-mappings";
1681
-
1682
- export function Icon({ name, size = 24, color }: IconProps) {
1683
- return (
1684
- <MaterialIcons name={MATERIAL_ICONS[name]} size={size} color={color} />
1685
- );
1686
- }
1687
-
1688
- ```
1689
-
1690
- ## constants/theme.ts
1691
-
1692
- ```typescript
1693
- /**
1694
- * Design tokens for the assistant-ui Expo example.
1695
- *
1696
- * These mirror the canonical web kit (`packages/ui`): a neutral zinc palette,
1697
- * a clean ChatGPT-grade look with subtle hairline borders and no heavy glass or
1698
- * shadow. Values are the sRGB equivalents of the web `oklch` tokens.
1699
- */
1700
-
1701
- export type Palette = {
1702
- background: string;
1703
- foreground: string;
1704
- card: string;
1705
- cardForeground: string;
1706
- muted: string;
1707
- mutedForeground: string;
1708
- accent: string;
1709
- border: string;
1710
- primary: string;
1711
- primaryForeground: string;
1712
- composer: string;
1713
- destructive: string;
1714
- destructiveForeground: string;
1715
- destructiveSurface: string;
1716
- ring: string;
1717
- };
1718
-
1719
- export const Colors: { light: Palette; dark: Palette } = {
1720
- light: {
1721
- background: "#ffffff",
1722
- foreground: "#18181b",
1723
- card: "#ffffff",
1724
- cardForeground: "#18181b",
1725
- muted: "#f4f4f5",
1726
- mutedForeground: "#71717a",
1727
- accent: "#f4f4f5",
1728
- border: "#e4e4e7",
1729
- primary: "#18181b",
1730
- primaryForeground: "#fafafa",
1731
- composer: "#fafafa",
1732
- destructive: "#dc2626",
1733
- destructiveForeground: "#ffffff",
1734
- destructiveSurface: "rgba(220, 38, 38, 0.08)",
1735
- ring: "#a1a1aa",
1736
- },
1737
- dark: {
1738
- background: "#18181b",
1739
- foreground: "#fafafa",
1740
- card: "#27272a",
1741
- cardForeground: "#fafafa",
1742
- muted: "#3f3f46",
1743
- mutedForeground: "#a1a1aa",
1744
- accent: "#3f3f46",
1745
- border: "rgba(255, 255, 255, 0.1)",
1746
- primary: "#e4e4e7",
1747
- primaryForeground: "#18181b",
1748
- composer: "#232326",
1749
- destructive: "#f87171",
1750
- destructiveForeground: "#18181b",
1751
- destructiveSurface: "rgba(248, 113, 113, 0.12)",
1752
- ring: "#52525b",
1753
- },
1754
- };
1755
-
1756
- export const Radius = {
1757
- sm: 6,
1758
- md: 8,
1759
- lg: 10,
1760
- card: 16,
1761
- bubble: 18,
1762
- composer: 24,
1763
- attachment: 14,
1764
- pill: 999,
1765
- } as const;
1766
-
1767
- export const Spacing = {
1768
- threadMaxWidth: 768,
1769
- gutter: 16,
1770
- } as const;
1771
-
1772
- ```
1773
-
1774
- ## hooks/use-app-runtime.ts
1775
-
1776
- ```typescript
1777
- import { useMemo } from "react";
1778
- import {
1779
- useChatRuntime,
1780
- AssistantChatTransport,
1781
- } from "@assistant-ui/react-ai-sdk";
1782
- import { lastAssistantMessageIsCompleteWithToolCalls } from "ai";
1783
-
1784
- const CHAT_API = process.env.EXPO_PUBLIC_CHAT_ENDPOINT_URL ?? "/api/chat";
1785
-
1786
- export function useAppRuntime() {
1787
- const transport = useMemo(
1788
- () => new AssistantChatTransport({ api: CHAT_API }),
1789
- [],
1790
- );
1791
- return useChatRuntime({
1792
- transport,
1793
- sendAutomaticallyWhen: lastAssistantMessageIsCompleteWithToolCalls,
1794
- });
1795
- }
1796
-
1797
- ```
1798
-
1799
- ## hooks/use-color-scheme.ts
1800
-
1801
- ```typescript
1802
- export { useColorScheme } from "react-native";
1803
-
1804
- ```
1805
-
1806
- ## hooks/use-color-scheme.web.ts
1807
-
1808
- ```typescript
1809
- import { useEffect, useState } from "react";
1810
- import { useColorScheme as useRNColorScheme } from "react-native";
1811
-
1812
- /**
1813
- * To support static rendering, this value needs to be re-calculated on the client side for web
1814
- */
1815
- export function useColorScheme() {
1816
- const [hasHydrated, setHasHydrated] = useState(false);
1817
-
1818
- useEffect(() => {
1819
- setHasHydrated(true);
1820
- }, []);
1821
-
1822
- const colorScheme = useRNColorScheme();
1823
-
1824
- if (hasHydrated) {
1825
- return colorScheme;
1826
- }
1827
-
1828
- return "light";
1829
- }
1830
-
1831
- ```
1832
-
1833
- ## hooks/use-theme.ts
1834
-
1835
- ```typescript
1836
- import { Colors, type Palette } from "@/constants/theme";
1837
- import { useColorScheme } from "@/hooks/use-color-scheme";
1838
-
1839
- export function useTheme(): { isDark: boolean; colors: Palette } {
1840
- const isDark = useColorScheme() === "dark";
1841
- return { isDark, colors: isDark ? Colors.dark : Colors.light };
1842
- }
1843
-
1844
- ```
1845
-
1846
- ## lib/haptics.ts
1847
-
1848
- ```typescript
1849
- import { Platform } from "react-native";
1850
- import * as Haptics from "expo-haptics";
1851
-
1852
- const enabled = Platform.OS === "ios" || Platform.OS === "android";
1853
-
1854
- export const haptics = {
1855
- selection() {
1856
- if (enabled) void Haptics.selectionAsync();
1857
- },
1858
- light() {
1859
- if (enabled) void Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Light);
1860
- },
1861
- success() {
1862
- if (enabled)
1863
- void Haptics.notificationAsync(Haptics.NotificationFeedbackType.Success);
1864
- },
1865
- };
1866
-
1867
- ```
1868
-
1869
- ## metro.config.js
1870
-
1871
- ```javascript
1872
- const { getDefaultConfig } = require("expo/metro-config");
1873
- const { withAui } = require("@assistant-ui/metro");
1874
- const path = require("node:path");
1875
-
1876
- const projectRoot = __dirname;
1877
- const monorepoRoot = path.resolve(projectRoot, "../..");
1878
-
1879
- const config = getDefaultConfig(projectRoot);
1880
-
1881
- // Watch all files within the monorepo
1882
- config.watchFolders = [monorepoRoot];
1883
-
1884
- // Enable symlinks support for pnpm
1885
- config.resolver.unstable_enableSymlinks = true;
1886
-
1887
- // Let Metro know where to resolve packages
1888
- config.resolver.nodeModulesPaths = [
1889
- path.resolve(projectRoot, "node_modules"),
1890
- path.resolve(monorepoRoot, "node_modules"),
1891
- ];
1892
-
1893
- // Force resolving shared dependencies from the app's node_modules
1894
- config.resolver.resolveRequest = (context, moduleName, platform) => {
1895
- if (
1896
- moduleName === "react" ||
1897
- moduleName === "react-native" ||
1898
- moduleName.startsWith("react/") ||
1899
- moduleName.startsWith("react-native/")
1900
- ) {
1901
- return context.resolveRequest(
1902
- {
1903
- ...context,
1904
- originModulePath: path.resolve(projectRoot, "package.json"),
1905
- },
1906
- moduleName,
1907
- platform,
1908
- );
1909
- }
1910
-
1911
- return context.resolveRequest(context, moduleName, platform);
1912
- };
1913
-
1914
- module.exports = withAui(config);
1915
-
1916
- ```
1917
-
1918
- ## package.json
1919
-
1920
- ```json
1921
- {
1922
- "name": "with-expo",
1923
- "main": "expo-router/entry",
1924
- "version": "0.0.0",
1925
- "scripts": {
1926
- "start": "expo start",
1927
- "android": "expo run:android",
1928
- "ios": "expo run:ios",
1929
- "web": "expo start --web",
1930
- "export:web": "expo export --platform web && node scripts/flatten-assets.mjs"
1931
- },
1932
- "dependencies": {
1933
- "@ai-sdk/openai": "^4.0.40",
1934
- "@ai-sdk/react": "^4.0.65",
1935
- "@assistant-ui/react-ai-sdk": "workspace:*",
1936
- "@assistant-ui/react-native": "workspace:*",
1937
- "@expo/vector-icons": "^15.1.1",
1938
- "@react-navigation/drawer": "7.9.4",
1939
- "@react-navigation/native": "7.1.33",
1940
- "ai": "^7.0.62",
1941
- "expo": "~57.0.12",
1942
- "expo-clipboard": "~57.0.1",
1943
- "expo-constants": "~57.0.10",
1944
- "expo-font": "~57.0.1",
1945
- "expo-haptics": "~57.0.1",
1946
- "expo-image": "~57.0.2",
1947
- "expo-image-picker": "~57.0.9",
1948
- "expo-linking": "~57.0.5",
1949
- "expo-router": "~57.0.12",
1950
- "expo-server": "~57.0.2",
1951
- "expo-splash-screen": "~57.0.6",
1952
- "expo-status-bar": "~57.0.1",
1953
- "expo-symbols": "^57.0.2",
1954
- "expo-system-ui": "~57.0.2",
1955
- "react": "19.2.3",
1956
- "react-dom": "19.2.3",
1957
- "react-native": "0.86.2",
1958
- "react-native-gesture-handler": "~2.32.0",
1959
- "react-native-reanimated": "4.5.1",
1960
- "react-native-safe-area-context": "~5.7.0",
1961
- "react-native-screens": "4.26.2",
1962
- "react-native-web": "~0.21.2",
1963
- "react-native-worklets": "0.10.1",
1964
- "zod": "^4.4.3"
1965
- },
1966
- "devDependencies": {
1967
- "@assistant-ui/metro": "workspace:*",
1968
- "@babel/core": "^7.29.7",
1969
- "@types/react": "~19.2.18",
1970
- "typescript": "npm:@typescript/typescript6@^6.0.2",
1971
- "typescript-7": "npm:typescript@~7.0.2"
1972
- },
1973
- "private": true
1974
- }
1975
-
1976
- ```
1977
-
1978
- ## README.md
1979
-
1980
- ```markdown
1981
- # assistant-ui + Expo
1982
-
1983
- A native chat app built with [assistant-ui](https://www.assistant-ui.com) and [Expo](https://expo.dev). It runs on iOS, Android, and the web from a single codebase, and is styled to match the assistant-ui web kit: a clean, neutral, ChatGPT-grade look with subtle hairline borders.
1984
-
1985
- The chat is powered by `@assistant-ui/react-native` with the AI SDK runtime (`@assistant-ui/react-ai-sdk`). The example leans on native Expo APIs throughout:
1986
-
1987
- - **SF Symbols** (`expo-symbols`) for native iconography on iOS, with a Material Icons fallback on Android and the web.
1988
- - **Haptics** (`expo-haptics`) for tactile feedback on send, stop, and selection.
1989
- - **Image picker** (`expo-image-picker`) and **expo-image** for attachments.
1990
- - **Clipboard** (`expo-clipboard`) so the copy action works natively.
1991
- - A native **drawer** (`@react-navigation/drawer`) for the thread list, with a swipe gesture to switch conversations.
1992
-
1993
- It follows the assistant-ui component conventions: `MessagePrimitive.Parts` for message rendering, `AuiIf` for declarative state-driven UI, the `ThreadList` / `ThreadListItem` primitives for the drawer, and a `"use generative"` toolkit (`components/assistant-ui/tools.tsx`) that renders weather cards inline.
1994
-
1995
- ## Get started
1996
-
1997
- 1. Install dependencies from the repository root:
1998
-
1999
- ```bash
2000
- pnpm install
2001
- ```
2002
-
2003
- 2. Configure the chat backend. Copy `.env.example` to `.env` and set your key:
2004
-
2005
- ```bash
2006
- cp .env.example .env
2007
- ```
2008
-
2009
- The bundled API route (`app/api/chat+api.ts`) needs `OPENAI_API_KEY`. To point the app at a separately hosted backend instead, set `EXPO_PUBLIC_CHAT_ENDPOINT_URL`.
2010
-
2011
- 3. Start the app:
2012
-
2013
- ```bash
2014
- pnpm --filter with-expo start
2015
- ```
2016
-
2017
- From there you can open it in the iOS simulator, an Android emulator, or the browser.
2018
-
2019
- ## Project structure
2020
-
2021
- - `app/_layout.tsx` wires the runtime, the toolkit, and the drawer navigation.
2022
- - `app/index.tsx` renders the `Thread`.
2023
- - `components/assistant-ui/` holds the composer, message, action bar, branch picker, and tool UIs.
2024
- - `components/thread-list/` holds the drawer thread list.
2025
- - `constants/theme.ts` and `hooks/use-theme.ts` define the shared design tokens.
2026
- - `components/ui/icon.tsx` is the cross-platform icon (SF Symbols on iOS, Material Icons elsewhere).
2027
-
2028
- ## Learn more
2029
-
2030
- - [assistant-ui documentation](https://www.assistant-ui.com/docs)
2031
- - [Expo documentation](https://docs.expo.dev)
2032
-
2033
- ```
2034
-
2035
- ## tsconfig.json
2036
-
2037
- ```json
2038
- {
2039
- "extends": "expo/tsconfig.base",
2040
- "compilerOptions": {
2041
- "strict": true,
2042
- "paths": {
2043
- "@/*": ["./*"]
2044
- }
2045
- },
2046
- "include": ["**/*.ts", "**/*.tsx", ".expo/types/**/*.ts", "expo-env.d.ts"]
2047
- }
2048
-
2049
- ```
2050
-
2051
- ## vercel.json
2052
-
2053
- ```json
2054
- {
2055
- "$schema": "https://openapi.vercel.sh/vercel.json",
2056
- "ignoreCommand": "bash ../../scripts/vercel-ignore-changeset-release.sh",
2057
- "buildCommand": "cd ../.. && pnpm turbo build --filter=@assistant-ui/react-native --filter=@assistant-ui/react-ai-sdk --filter=@assistant-ui/metro && cd examples/with-expo && pnpm run export:web",
2058
- "outputDirectory": "dist",
2059
- "framework": null
2060
- }
2061
-
2062
- ```
2063
-