@assistant-ui/mcp-docs-server 0.1.30 → 0.1.32
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.
- package/.docs/organized/code-examples/waterfall.md +8 -8
- package/.docs/organized/code-examples/with-a2a.md +10 -10
- package/.docs/organized/code-examples/with-ag-ui.md +12 -12
- package/.docs/organized/code-examples/with-ai-sdk-v6.md +14 -14
- package/.docs/organized/code-examples/with-artifacts.md +14 -14
- package/.docs/organized/code-examples/with-assistant-transport.md +11 -11
- package/.docs/organized/code-examples/with-browser-extension.md +345 -0
- package/.docs/organized/code-examples/with-chain-of-thought.md +129 -63
- package/.docs/organized/code-examples/with-cloud-standalone.md +13 -13
- package/.docs/organized/code-examples/with-cloud.md +13 -13
- package/.docs/organized/code-examples/with-custom-thread-list.md +65 -20
- package/.docs/organized/code-examples/with-elevenlabs-conversational.md +18 -17
- package/.docs/organized/code-examples/with-elevenlabs-scribe.md +18 -17
- package/.docs/organized/code-examples/with-expo.md +25 -25
- package/.docs/organized/code-examples/with-external-store.md +10 -10
- package/.docs/organized/code-examples/with-ffmpeg.md +14 -14
- package/.docs/organized/code-examples/with-generative-ui.md +211 -14
- package/.docs/organized/code-examples/with-google-adk.md +12 -12
- package/.docs/organized/code-examples/with-heat-graph.md +8 -8
- package/.docs/organized/code-examples/with-image-generation.md +454 -0
- package/.docs/organized/code-examples/with-interactables.md +14 -14
- package/.docs/organized/code-examples/with-langchain.md +12 -12
- package/.docs/organized/code-examples/with-langgraph.md +15 -12
- package/.docs/organized/code-examples/with-livekit.md +19 -18
- package/.docs/organized/code-examples/with-mcp.md +748 -0
- package/.docs/organized/code-examples/with-opencode.md +107 -62
- package/.docs/organized/code-examples/with-parent-id-grouping.md +12 -12
- package/.docs/organized/code-examples/with-react-hook-form.md +14 -14
- package/.docs/organized/code-examples/with-react-ink.md +4 -4
- package/.docs/organized/code-examples/with-react-router.md +16 -16
- package/.docs/organized/code-examples/with-resumable-stream.md +660 -0
- package/.docs/organized/code-examples/with-store.md +8 -8
- package/.docs/organized/code-examples/with-tanstack.md +14 -14
- package/.docs/organized/code-examples/with-tap-runtime.md +11 -10
- package/.docs/raw/docs/(docs)/cli.mdx +3 -1
- package/.docs/raw/docs/(docs)/copilots/assistant-frame.mdx +1 -0
- package/.docs/raw/docs/(docs)/copilots/make-assistant-tool-ui.mdx +10 -3
- package/.docs/raw/docs/(docs)/copilots/make-assistant-tool.mdx +8 -3
- package/.docs/raw/docs/(docs)/copilots/make-assistant-visible.mdx +1 -0
- package/.docs/raw/docs/(docs)/copilots/model-context.mdx +1 -0
- package/.docs/raw/docs/(docs)/copilots/motivation.mdx +1 -0
- package/.docs/raw/docs/(docs)/copilots/use-assistant-instructions.mdx +1 -0
- package/.docs/raw/docs/(docs)/devtools.mdx +1 -0
- package/.docs/raw/docs/(docs)/index.mdx +3 -2
- package/.docs/raw/docs/(docs)/installation.mdx +2 -1
- package/.docs/raw/docs/(docs)/rtl.mdx +1 -0
- package/.docs/raw/docs/(reference)/api-reference/adapters/attachments.mdx +36 -0
- package/.docs/raw/docs/(reference)/api-reference/adapters/feedback.mdx +20 -0
- package/.docs/raw/docs/(reference)/api-reference/adapters/index.mdx +34 -0
- package/.docs/raw/docs/(reference)/api-reference/adapters/model.mdx +44 -0
- package/.docs/raw/docs/(reference)/api-reference/adapters/persistence.mdx +55 -0
- package/.docs/raw/docs/(reference)/api-reference/adapters/runtime.mdx +20 -0
- package/.docs/raw/docs/(reference)/api-reference/adapters/suggestions.mdx +20 -0
- package/.docs/raw/docs/(reference)/api-reference/context-providers/assistant-runtime-provider.mdx +37 -8
- package/.docs/raw/docs/(reference)/api-reference/context-providers/index.mdx +22 -0
- package/.docs/raw/docs/(reference)/api-reference/context-providers/scoped-providers.mdx +64 -0
- package/.docs/raw/docs/(reference)/api-reference/external-store/index.mdx +22 -0
- package/.docs/raw/docs/(reference)/api-reference/external-store/message-conversion.mdx +52 -0
- package/.docs/raw/docs/(reference)/api-reference/external-store/runtime.mdx +36 -0
- package/.docs/raw/docs/(reference)/api-reference/hooks/composer-triggers.mdx +98 -0
- package/.docs/raw/docs/(reference)/api-reference/hooks/index.mdx +31 -0
- package/.docs/raw/docs/(reference)/api-reference/hooks/model-context.mdx +33 -0
- package/.docs/raw/docs/(reference)/api-reference/hooks/primitives.mdx +640 -0
- package/.docs/raw/docs/(reference)/api-reference/hooks/runtimes.mdx +28 -0
- package/.docs/raw/docs/(reference)/api-reference/hooks/state.mdx +94 -0
- package/.docs/raw/docs/(reference)/api-reference/hooks/utilities.mdx +464 -0
- package/.docs/raw/docs/(reference)/api-reference/integrations/cloud-ai-sdk.mdx +24 -0
- package/.docs/raw/docs/(reference)/api-reference/integrations/index.mdx +22 -0
- package/.docs/raw/docs/(reference)/api-reference/integrations/react-ai-sdk.mdx +79 -0
- package/.docs/raw/docs/(reference)/api-reference/model-context/context.mdx +52 -0
- package/.docs/raw/docs/(reference)/api-reference/model-context/index.mdx +22 -0
- package/.docs/raw/docs/(reference)/api-reference/model-context/registry.mdx +20 -0
- package/.docs/raw/docs/(reference)/api-reference/overview.mdx +125 -125
- package/.docs/raw/docs/(reference)/api-reference/primitives/action-bar-more.mdx +78 -221
- package/.docs/raw/docs/(reference)/api-reference/primitives/action-bar.mdx +127 -242
- package/.docs/raw/docs/(reference)/api-reference/primitives/assistant-if.mdx +46 -20
- package/.docs/raw/docs/(reference)/api-reference/primitives/assistant-modal.mdx +66 -87
- package/.docs/raw/docs/(reference)/api-reference/primitives/attachment.mdx +50 -58
- package/.docs/raw/docs/(reference)/api-reference/primitives/branch-picker.mdx +80 -48
- package/.docs/raw/docs/(reference)/api-reference/primitives/chain-of-thought.mdx +67 -0
- package/.docs/raw/docs/(reference)/api-reference/primitives/composer.mdx +323 -461
- package/.docs/raw/docs/(reference)/api-reference/primitives/error.mdx +36 -43
- package/.docs/raw/docs/(reference)/api-reference/primitives/index.mdx +70 -0
- package/.docs/raw/docs/(reference)/api-reference/primitives/message-part.mdx +63 -245
- package/.docs/raw/docs/(reference)/api-reference/primitives/message.mdx +182 -554
- package/.docs/raw/docs/(reference)/api-reference/primitives/queue-item.mdx +65 -0
- package/.docs/raw/docs/(reference)/api-reference/primitives/selection-toolbar.mdx +35 -22
- package/.docs/raw/docs/(reference)/api-reference/primitives/suggestion.mdx +57 -140
- package/.docs/raw/docs/(reference)/api-reference/primitives/thread-list-item-more.mdx +70 -161
- package/.docs/raw/docs/(reference)/api-reference/primitives/thread-list-item.mdx +84 -108
- package/.docs/raw/docs/(reference)/api-reference/primitives/thread-list.mdx +82 -86
- package/.docs/raw/docs/(reference)/api-reference/primitives/thread.mdx +173 -314
- package/.docs/raw/docs/(reference)/api-reference/runtimes/assistant-runtime.mdx +9 -21
- package/.docs/raw/docs/(reference)/api-reference/runtimes/attachment-runtime.mdx +10 -21
- package/.docs/raw/docs/(reference)/api-reference/runtimes/composer-runtime.mdx +15 -70
- package/.docs/raw/docs/(reference)/api-reference/runtimes/index.mdx +43 -0
- package/.docs/raw/docs/(reference)/api-reference/runtimes/message-part-runtime.mdx +25 -28
- package/.docs/raw/docs/(reference)/api-reference/runtimes/message-runtime.mdx +11 -63
- package/.docs/raw/docs/(reference)/api-reference/runtimes/queue-state.mdx +20 -0
- package/.docs/raw/docs/(reference)/api-reference/runtimes/thread-list-item-runtime.mdx +11 -48
- package/.docs/raw/docs/(reference)/api-reference/runtimes/thread-list-runtime.mdx +10 -42
- package/.docs/raw/docs/(reference)/api-reference/runtimes/thread-runtime.mdx +18 -30
- package/.docs/raw/docs/(reference)/api-reference/tools/component-tools.mdx +68 -0
- package/.docs/raw/docs/(reference)/api-reference/tools/index.mdx +39 -0
- package/.docs/raw/docs/(reference)/api-reference/tools/rendering.mdx +79 -0
- package/.docs/raw/docs/(reference)/api-reference/tools/status.mdx +42 -0
- package/.docs/raw/docs/(reference)/api-reference/tools/toolkits.mdx +92 -0
- package/.docs/raw/docs/(reference)/api-reference/transport/assistant-transport.mdx +48 -0
- package/.docs/raw/docs/(reference)/api-reference/transport/frame.mdx +62 -0
- package/.docs/raw/docs/(reference)/api-reference/transport/index.mdx +22 -0
- package/.docs/raw/docs/(reference)/api-reference/utilities/index.mdx +19 -0
- package/.docs/raw/docs/(reference)/api-reference/utilities/miscellaneous.mdx +131 -0
- package/.docs/raw/docs/(reference)/api-reference/voice/index.mdx +22 -0
- package/.docs/raw/docs/(reference)/api-reference/voice/session.mdx +54 -0
- package/.docs/raw/docs/(reference)/api-reference/voice/speech-dictation.mdx +36 -0
- package/.docs/raw/docs/cloud/ai-sdk-assistant-ui.mdx +230 -2
- package/.docs/raw/docs/cloud/ai-sdk.mdx +222 -4
- package/.docs/raw/docs/cloud/index.mdx +2 -2
- package/.docs/raw/docs/cloud/langgraph.mdx +274 -2
- package/.docs/raw/docs/{(docs)/guides → guides}/attachments.mdx +45 -40
- package/.docs/raw/docs/guides/branching.mdx +76 -0
- package/.docs/raw/docs/guides/chain-of-thought.mdx +166 -0
- package/.docs/raw/docs/{(docs)/guides → guides}/context-api.mdx +54 -26
- package/.docs/raw/docs/{(docs)/guides → guides}/dictation.mdx +3 -1
- package/.docs/raw/docs/guides/editing.mdx +102 -0
- package/.docs/raw/docs/guides/generative-ui.mdx +142 -0
- package/.docs/raw/docs/guides/image-generation.mdx +74 -0
- package/.docs/raw/docs/guides/index.mdx +103 -0
- package/.docs/raw/docs/{(docs)/guides → guides}/interactables.mdx +51 -2
- package/.docs/raw/docs/{(docs)/guides → guides}/latex.mdx +53 -10
- package/.docs/raw/docs/guides/mcp-apps.mdx +231 -0
- package/.docs/raw/docs/{(docs)/guides → guides}/mentions.mdx +63 -88
- package/.docs/raw/docs/{(docs)/guides → guides}/message-timing.mdx +45 -6
- package/.docs/raw/docs/{(docs)/guides → guides}/multi-agent.mdx +66 -6
- package/.docs/raw/docs/{(docs)/guides → guides}/quoting.mdx +11 -18
- package/.docs/raw/docs/guides/resumable-stream-deployment.mdx +212 -0
- package/.docs/raw/docs/guides/resumable-stream-stores.mdx +152 -0
- package/.docs/raw/docs/guides/resumable-streams.mdx +210 -0
- package/.docs/raw/docs/{(docs)/guides → guides}/slash-commands.mdx +104 -38
- package/.docs/raw/docs/guides/speech.mdx +156 -0
- package/.docs/raw/docs/{(docs)/guides → guides}/suggestions.mdx +91 -69
- package/.docs/raw/docs/{(docs)/guides → guides}/tool-ui.mdx +110 -38
- package/.docs/raw/docs/{(docs)/guides → guides}/tools.mdx +197 -40
- package/.docs/raw/docs/{(docs)/guides → guides}/voice.mdx +41 -2
- package/.docs/raw/docs/ink/adapters.mdx +37 -1
- package/.docs/raw/docs/ink/custom-backend.mdx +59 -8
- package/.docs/raw/docs/ink/index.mdx +11 -14
- package/.docs/raw/docs/ink/migration.mdx +1 -3
- package/.docs/raw/docs/ink/primitives.mdx +386 -9
- package/.docs/raw/docs/integrations/attachments/custom-adapter.mdx +520 -0
- package/.docs/raw/docs/integrations/auth/better-auth.mdx +191 -0
- package/.docs/raw/docs/integrations/auth/clerk.mdx +172 -0
- package/.docs/raw/docs/integrations/auth/next-auth.mdx +196 -0
- package/.docs/raw/docs/integrations/frameworks/ai-sdk.mdx +79 -0
- package/.docs/raw/docs/integrations/frameworks/cloudflare-agents/overview.mdx +282 -0
- package/.docs/raw/docs/integrations/frameworks/mastra/full-stack.mdx +188 -0
- package/.docs/raw/docs/integrations/frameworks/mastra/overview.mdx +57 -0
- package/.docs/raw/docs/integrations/frameworks/mastra/separate-server.mdx +201 -0
- package/.docs/raw/docs/integrations/gateways/index.mdx +162 -0
- package/.docs/raw/docs/integrations/index.mdx +185 -0
- package/.docs/raw/docs/integrations/observability/helicone.mdx +130 -0
- package/.docs/raw/docs/integrations/observability/langfuse.mdx +163 -0
- package/.docs/raw/docs/integrations/observability/langsmith.mdx +150 -0
- package/.docs/raw/docs/integrations/persistence/custom-adapter.mdx +712 -0
- package/.docs/raw/docs/integrations/tools/mcp.mdx +267 -0
- package/.docs/raw/docs/integrations/tools/react-mcp.mdx +337 -0
- package/.docs/raw/docs/migrations/v0-14.mdx +297 -0
- package/.docs/raw/docs/primitives/action-bar.mdx +1 -0
- package/.docs/raw/docs/primitives/assistant-modal.mdx +1 -0
- package/.docs/raw/docs/primitives/attachment.mdx +1 -0
- package/.docs/raw/docs/primitives/branch-picker.mdx +1 -0
- package/.docs/raw/docs/primitives/chain-of-thought.mdx +90 -85
- package/.docs/raw/docs/primitives/composer.mdx +55 -1
- package/.docs/raw/docs/primitives/error.mdx +1 -0
- package/.docs/raw/docs/primitives/index.mdx +4 -3
- package/.docs/raw/docs/primitives/message.mdx +68 -5
- package/.docs/raw/docs/primitives/selection-toolbar.mdx +1 -0
- package/.docs/raw/docs/primitives/suggestion.mdx +10 -0
- package/.docs/raw/docs/primitives/thread-list.mdx +39 -0
- package/.docs/raw/docs/primitives/thread.mdx +16 -13
- package/.docs/raw/docs/react-native/hooks.mdx +2 -2
- package/.docs/raw/docs/react-native/index.mdx +5 -7
- package/.docs/raw/docs/react-native/migration.mdx +1 -3
- package/.docs/raw/docs/runtimes/a2a/client-and-hooks.mdx +396 -0
- package/.docs/raw/docs/runtimes/a2a/overview.mdx +60 -0
- package/.docs/raw/docs/runtimes/a2a/quickstart.mdx +216 -0
- package/.docs/raw/docs/runtimes/ag-ui/overview.mdx +70 -0
- package/.docs/raw/docs/runtimes/ag-ui/quickstart.mdx +243 -0
- package/.docs/raw/docs/runtimes/ag-ui/runtime-options.mdx +154 -0
- package/.docs/raw/docs/runtimes/ai-sdk/overview.mdx +52 -0
- package/.docs/raw/docs/runtimes/ai-sdk/v4-legacy.mdx +73 -128
- package/.docs/raw/docs/runtimes/ai-sdk/v5-legacy.mdx +70 -64
- package/.docs/raw/docs/runtimes/ai-sdk/v6.mdx +337 -123
- package/.docs/raw/docs/runtimes/concepts/adapters.mdx +265 -0
- package/.docs/raw/docs/runtimes/concepts/architecture.mdx +125 -0
- package/.docs/raw/docs/runtimes/concepts/stability.mdx +67 -0
- package/.docs/raw/docs/runtimes/concepts/threads.mdx +428 -0
- package/.docs/raw/docs/runtimes/custom/assistant-transport.mdx +703 -0
- package/.docs/raw/docs/runtimes/custom/data-stream.mdx +348 -0
- package/.docs/raw/docs/runtimes/custom/external-store.mdx +261 -1236
- package/.docs/raw/docs/runtimes/custom/local-runtime.mdx +746 -0
- package/.docs/raw/docs/runtimes/custom/overview.mdx +71 -0
- package/.docs/raw/docs/runtimes/google-adk/api.mdx +256 -0
- package/.docs/raw/docs/runtimes/google-adk/hooks.mdx +717 -0
- package/.docs/raw/docs/runtimes/google-adk/overview.mdx +69 -0
- package/.docs/raw/docs/runtimes/google-adk/quickstart.mdx +229 -0
- package/.docs/raw/docs/runtimes/langchain.mdx +533 -0
- package/.docs/raw/docs/runtimes/langgraph/generative-ui.mdx +305 -0
- package/.docs/raw/docs/runtimes/langgraph/interrupts.mdx +104 -0
- package/.docs/raw/docs/runtimes/langgraph/overview.mdx +84 -0
- package/.docs/raw/docs/runtimes/langgraph/quickstart.mdx +496 -0
- package/.docs/raw/docs/runtimes/langgraph/streaming.mdx +127 -0
- package/.docs/raw/docs/runtimes/langgraph/threads.mdx +113 -0
- package/.docs/raw/docs/runtimes/langgraph/tutorial/introduction.mdx +3 -3
- package/.docs/raw/docs/runtimes/langgraph/tutorial/part-1.mdx +0 -23
- package/.docs/raw/docs/runtimes/langgraph/tutorial/part-2.mdx +1 -1
- package/.docs/raw/docs/runtimes/opencode/hooks.mdx +191 -0
- package/.docs/raw/docs/runtimes/opencode/overview.mdx +48 -0
- package/.docs/raw/docs/runtimes/opencode/quickstart.mdx +119 -0
- package/.docs/raw/docs/runtimes/pick-a-runtime.mdx +78 -203
- package/.docs/raw/docs/ui/accordion.mdx +1 -0
- package/.docs/raw/docs/ui/assistant-modal.mdx +1 -0
- package/.docs/raw/docs/ui/assistant-sidebar.mdx +1 -0
- package/.docs/raw/docs/ui/attachment.mdx +1 -0
- package/.docs/raw/docs/ui/badge.mdx +1 -0
- package/.docs/raw/docs/ui/composer-trigger-popover.mdx +12 -1
- package/.docs/raw/docs/ui/context-display.mdx +1 -0
- package/.docs/raw/docs/ui/diff-viewer.mdx +1 -0
- package/.docs/raw/docs/ui/directive-text.mdx +1 -0
- package/.docs/raw/docs/ui/file.mdx +1 -0
- package/.docs/raw/docs/ui/image.mdx +1 -0
- package/.docs/raw/docs/ui/markdown.mdx +2 -14
- package/.docs/raw/docs/ui/mcp-config.mdx +102 -0
- package/.docs/raw/docs/ui/mermaid.mdx +1 -0
- package/.docs/raw/docs/ui/message-timing.mdx +3 -2
- package/.docs/raw/docs/ui/model-selector.mdx +9 -8
- package/.docs/raw/docs/ui/part-grouping.mdx +325 -313
- package/.docs/raw/docs/ui/quote.mdx +1 -0
- package/.docs/raw/docs/ui/reasoning.mdx +66 -33
- package/.docs/raw/docs/ui/scrollbar.mdx +1 -0
- package/.docs/raw/docs/ui/select.mdx +1 -0
- package/.docs/raw/docs/ui/sources.mdx +18 -0
- package/.docs/raw/docs/ui/streamdown.mdx +35 -2
- package/.docs/raw/docs/ui/syntax-highlighting.mdx +1 -0
- package/.docs/raw/docs/ui/tabs.mdx +1 -0
- package/.docs/raw/docs/ui/thread-list.mdx +19 -2
- package/.docs/raw/docs/ui/thread.mdx +58 -3
- package/.docs/raw/docs/ui/tool-fallback.mdx +1 -0
- package/.docs/raw/docs/ui/tool-group.mdx +39 -11
- package/.docs/raw/docs/ui/voice.mdx +1 -0
- package/.docs/raw/docs/utilities/heat-graph.mdx +1 -0
- package/.docs/raw/docs/utilities/react-o11y.mdx +278 -0
- package/.docs/raw/docs/utilities/tw-shimmer.mdx +1 -0
- package/README.md +14 -72
- package/dist/constants.d.ts +12 -9
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +13 -9
- package/dist/constants.js.map +1 -1
- package/dist/index.d.ts +7 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +25 -24
- package/dist/index.js.map +1 -1
- package/dist/prepare-docs/code-examples.d.ts +4 -1
- package/dist/prepare-docs/code-examples.d.ts.map +1 -1
- package/dist/prepare-docs/code-examples.js +109 -121
- package/dist/prepare-docs/code-examples.js.map +1 -1
- package/dist/prepare-docs/copy-raw.d.ts +4 -1
- package/dist/prepare-docs/copy-raw.d.ts.map +1 -1
- package/dist/prepare-docs/copy-raw.js +45 -42
- package/dist/prepare-docs/copy-raw.js.map +1 -1
- package/dist/prepare-docs/prepare.d.ts +1 -2
- package/dist/prepare-docs/prepare.js +17 -17
- package/dist/prepare-docs/prepare.js.map +1 -1
- package/dist/stdio.d.ts +1 -3
- package/dist/stdio.js +6 -3
- package/dist/stdio.js.map +1 -1
- package/dist/tools/docs.d.ts +20 -15
- package/dist/tools/docs.d.ts.map +1 -1
- package/dist/tools/docs.js +140 -161
- package/dist/tools/docs.js.map +1 -1
- package/dist/tools/examples.d.ts +20 -15
- package/dist/tools/examples.d.ts.map +1 -1
- package/dist/tools/examples.js +74 -86
- package/dist/tools/examples.js.map +1 -1
- package/dist/tools/tests/test-setup.d.ts +5 -2
- package/dist/tools/tests/test-setup.d.ts.map +1 -1
- package/dist/tools/tests/test-setup.js +21 -28
- package/dist/tools/tests/test-setup.js.map +1 -1
- package/dist/utils/logger.d.ts +8 -5
- package/dist/utils/logger.d.ts.map +1 -1
- package/dist/utils/logger.js +17 -17
- package/dist/utils/logger.js.map +1 -1
- package/dist/utils/mcp-format.d.ts +8 -5
- package/dist/utils/mcp-format.d.ts.map +1 -1
- package/dist/utils/mcp-format.js +9 -9
- package/dist/utils/mcp-format.js.map +1 -1
- package/dist/utils/mdx.d.ts +8 -6
- package/dist/utils/mdx.d.ts.map +1 -1
- package/dist/utils/mdx.js +22 -22
- package/dist/utils/mdx.js.map +1 -1
- package/dist/utils/paths.d.ts +9 -6
- package/dist/utils/paths.d.ts.map +1 -1
- package/dist/utils/paths.js +66 -76
- package/dist/utils/paths.js.map +1 -1
- package/dist/utils/security.d.ts +4 -1
- package/dist/utils/security.d.ts.map +1 -1
- package/dist/utils/security.js +19 -40
- package/dist/utils/security.js.map +1 -1
- package/package.json +6 -6
- package/src/tools/tests/path-traversal.test.ts +1 -1
- package/.docs/raw/docs/(docs)/guides/branching.mdx +0 -65
- package/.docs/raw/docs/(docs)/guides/chain-of-thought.mdx +0 -164
- package/.docs/raw/docs/(docs)/guides/editing.mdx +0 -66
- package/.docs/raw/docs/(docs)/guides/speech.mdx +0 -38
- package/.docs/raw/docs/(reference)/api-reference/context-providers/text-message-part-provider.mdx +0 -40
- package/.docs/raw/docs/(reference)/api-reference/integrations/react-data-stream.mdx +0 -260
- package/.docs/raw/docs/(reference)/api-reference/integrations/react-hook-form.mdx +0 -103
- package/.docs/raw/docs/(reference)/api-reference/integrations/vercel-ai-sdk.mdx +0 -254
- package/.docs/raw/docs/(reference)/migrations/v0-14.mdx +0 -159
- package/.docs/raw/docs/runtimes/a2a/index.mdx +0 -298
- package/.docs/raw/docs/runtimes/assistant-transport.mdx +0 -1033
- package/.docs/raw/docs/runtimes/custom/custom-thread-list.mdx +0 -314
- package/.docs/raw/docs/runtimes/custom/local.mdx +0 -1464
- package/.docs/raw/docs/runtimes/data-stream.mdx +0 -422
- package/.docs/raw/docs/runtimes/google-adk/index.mdx +0 -686
- package/.docs/raw/docs/runtimes/helicone.mdx +0 -61
- package/.docs/raw/docs/runtimes/langchain/comparison.mdx +0 -60
- package/.docs/raw/docs/runtimes/langchain/index.mdx +0 -210
- package/.docs/raw/docs/runtimes/langgraph/index.mdx +0 -699
- package/.docs/raw/docs/runtimes/langgraph/tutorial/index.mdx +0 -12
- package/.docs/raw/docs/runtimes/langserve.mdx +0 -116
- package/.docs/raw/docs/runtimes/mastra/full-stack-integration.mdx +0 -218
- package/.docs/raw/docs/runtimes/mastra/overview.mdx +0 -18
- package/.docs/raw/docs/runtimes/mastra/separate-server-integration.mdx +0 -217
- package/dist/prepare-docs/prepare.d.ts.map +0 -1
- package/dist/stdio.d.ts.map +0 -1
- /package/.docs/raw/docs/{(reference)/migrations → migrations}/deprecation-policy.mdx +0 -0
- /package/.docs/raw/docs/{(reference) → migrations}/react-compatibility.mdx +0 -0
- /package/.docs/raw/docs/{(reference)/migrations → migrations}/react-langgraph-v0-7.mdx +0 -0
- /package/.docs/raw/docs/{(reference)/migrations → migrations}/v0-11.mdx +0 -0
- /package/.docs/raw/docs/{(reference)/migrations → migrations}/v0-12.mdx +0 -0
|
@@ -3,37 +3,75 @@ title: AI SDK v6
|
|
|
3
3
|
description: Integrate Vercel AI SDK v6 with assistant-ui for streaming chat.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
+
Current-version integration. Requires `ai@^6` and `@ai-sdk/react@^3`. For older versions see the [overview](/docs/runtimes/ai-sdk).
|
|
6
7
|
|
|
7
|
-
##
|
|
8
|
+
## Quickstart
|
|
8
9
|
|
|
9
|
-
|
|
10
|
+
<Steps>
|
|
11
|
+
<Step>
|
|
10
12
|
|
|
11
|
-
|
|
13
|
+
### Create a project
|
|
12
14
|
|
|
13
|
-
<
|
|
14
|
-
|
|
15
|
-
### Create a Next.js project
|
|
15
|
+
<PlatformTabs>
|
|
16
|
+
<Tab value="React">
|
|
16
17
|
|
|
17
18
|
```sh
|
|
18
19
|
npx create-next-app@latest my-app
|
|
19
20
|
cd my-app
|
|
20
21
|
```
|
|
21
22
|
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
</Tab>
|
|
24
|
+
<Tab value="React Native">
|
|
25
|
+
|
|
26
|
+
```sh
|
|
27
|
+
npx create-expo-app@latest my-app
|
|
28
|
+
cd my-app
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
</Tab>
|
|
32
|
+
<Tab value="React Ink">
|
|
33
|
+
|
|
34
|
+
```sh
|
|
35
|
+
mkdir my-app
|
|
36
|
+
cd my-app
|
|
37
|
+
npm init -y
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
</Tab>
|
|
41
|
+
</PlatformTabs>
|
|
42
|
+
|
|
43
|
+
</Step>
|
|
44
|
+
<Step>
|
|
24
45
|
|
|
25
46
|
### Install dependencies
|
|
26
47
|
|
|
48
|
+
<PlatformTabs>
|
|
49
|
+
<Tab value="React">
|
|
50
|
+
|
|
27
51
|
<InstallCommand npm={["@assistant-ui/react", "@assistant-ui/react-ai-sdk", "ai@^6", "@ai-sdk/react@^3", "@ai-sdk/openai", "zod"]} />
|
|
28
52
|
|
|
29
|
-
|
|
30
|
-
|
|
53
|
+
</Tab>
|
|
54
|
+
<Tab value="React Native">
|
|
31
55
|
|
|
32
|
-
|
|
56
|
+
<InstallCommand expo={["@assistant-ui/react-native", "@assistant-ui/react-ai-sdk", "ai@^6", "@ai-sdk/react@^3", "@ai-sdk/openai", "zod"]} />
|
|
33
57
|
|
|
34
|
-
|
|
58
|
+
</Tab>
|
|
59
|
+
<Tab value="React Ink">
|
|
35
60
|
|
|
36
|
-
|
|
61
|
+
<InstallCommand npm={["@assistant-ui/react-ink", "@assistant-ui/react-ai-sdk", "ai@^6", "@ai-sdk/react@^3", "@ai-sdk/openai", "zod", "ink", "react"]} />
|
|
62
|
+
|
|
63
|
+
</Tab>
|
|
64
|
+
</PlatformTabs>
|
|
65
|
+
|
|
66
|
+
</Step>
|
|
67
|
+
<Step>
|
|
68
|
+
|
|
69
|
+
### Set up the backend route
|
|
70
|
+
|
|
71
|
+
For React Native and Ink, host this route in a separate backend project and
|
|
72
|
+
point the client runtime at its absolute URL.
|
|
73
|
+
|
|
74
|
+
```ts title="@/app/api/chat/route.ts"
|
|
37
75
|
import { openai } from "@ai-sdk/openai";
|
|
38
76
|
import {
|
|
39
77
|
streamText,
|
|
@@ -50,16 +88,12 @@ export async function POST(req: Request) {
|
|
|
50
88
|
const { messages }: { messages: UIMessage[] } = await req.json();
|
|
51
89
|
|
|
52
90
|
const result = streamText({
|
|
53
|
-
model: openai("gpt-
|
|
54
|
-
messages: await convertToModelMessages(messages), //
|
|
91
|
+
model: openai("gpt-5.4-mini"),
|
|
92
|
+
messages: await convertToModelMessages(messages), // async in v6
|
|
55
93
|
tools: {
|
|
56
94
|
get_current_weather: tool({
|
|
57
95
|
description: "Get the current weather",
|
|
58
|
-
inputSchema: zodSchema(
|
|
59
|
-
z.object({
|
|
60
|
-
city: z.string(),
|
|
61
|
-
}),
|
|
62
|
-
),
|
|
96
|
+
inputSchema: zodSchema(z.object({ city: z.string() })),
|
|
63
97
|
execute: async ({ city }) => {
|
|
64
98
|
return `The weather in ${city} is sunny`;
|
|
65
99
|
},
|
|
@@ -71,14 +105,15 @@ export async function POST(req: Request) {
|
|
|
71
105
|
}
|
|
72
106
|
```
|
|
73
107
|
|
|
74
|
-
|
|
75
|
-
|
|
108
|
+
</Step>
|
|
109
|
+
<Step>
|
|
76
110
|
|
|
77
|
-
###
|
|
111
|
+
### Set up the frontend
|
|
78
112
|
|
|
79
|
-
|
|
113
|
+
<PlatformTabs>
|
|
114
|
+
<Tab value="React">
|
|
80
115
|
|
|
81
|
-
```tsx
|
|
116
|
+
```tsx title="@/app/page.tsx"
|
|
82
117
|
"use client";
|
|
83
118
|
|
|
84
119
|
import { Thread } from "@/components/assistant-ui/thread";
|
|
@@ -87,7 +122,6 @@ import { useChatRuntime } from "@assistant-ui/react-ai-sdk";
|
|
|
87
122
|
|
|
88
123
|
export default function Home() {
|
|
89
124
|
const runtime = useChatRuntime();
|
|
90
|
-
|
|
91
125
|
return (
|
|
92
126
|
<AssistantRuntimeProvider runtime={runtime}>
|
|
93
127
|
<div className="h-full">
|
|
@@ -98,18 +132,192 @@ export default function Home() {
|
|
|
98
132
|
}
|
|
99
133
|
```
|
|
100
134
|
|
|
101
|
-
|
|
135
|
+
</Tab>
|
|
136
|
+
<Tab value="React Native">
|
|
137
|
+
|
|
138
|
+
```tsx title="app/index.tsx"
|
|
139
|
+
import { AssistantRuntimeProvider } from "@assistant-ui/react-native";
|
|
140
|
+
import {
|
|
141
|
+
AssistantChatTransport,
|
|
142
|
+
useChatRuntime,
|
|
143
|
+
} from "@assistant-ui/react-ai-sdk";
|
|
144
|
+
import { View } from "react-native";
|
|
145
|
+
import { Thread } from "@/components/assistant-ui/thread";
|
|
146
|
+
|
|
147
|
+
const API_URL = process.env.EXPO_PUBLIC_API_URL ?? "http://localhost:3000";
|
|
148
|
+
|
|
149
|
+
export default function Home() {
|
|
150
|
+
const runtime = useChatRuntime({
|
|
151
|
+
transport: new AssistantChatTransport({
|
|
152
|
+
api: `${API_URL}/api/chat`,
|
|
153
|
+
}),
|
|
154
|
+
});
|
|
155
|
+
return (
|
|
156
|
+
<AssistantRuntimeProvider runtime={runtime}>
|
|
157
|
+
<View style={{ flex: 1 }}>
|
|
158
|
+
<Thread />
|
|
159
|
+
</View>
|
|
160
|
+
</AssistantRuntimeProvider>
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
</Tab>
|
|
166
|
+
<Tab value="React Ink">
|
|
167
|
+
|
|
168
|
+
```tsx title="app.tsx"
|
|
169
|
+
import { AssistantRuntimeProvider } from "@assistant-ui/react-ink";
|
|
170
|
+
import {
|
|
171
|
+
AssistantChatTransport,
|
|
172
|
+
useChatRuntime,
|
|
173
|
+
} from "@assistant-ui/react-ai-sdk";
|
|
174
|
+
import { Box } from "ink";
|
|
175
|
+
import { Thread } from "./components/thread.js";
|
|
176
|
+
|
|
177
|
+
export function App() {
|
|
178
|
+
const runtime = useChatRuntime({
|
|
179
|
+
transport: new AssistantChatTransport({
|
|
180
|
+
api: "http://localhost:3000/api/chat",
|
|
181
|
+
}),
|
|
182
|
+
});
|
|
183
|
+
return (
|
|
184
|
+
<AssistantRuntimeProvider runtime={runtime}>
|
|
185
|
+
<Box flexDirection="column">
|
|
186
|
+
<Thread />
|
|
187
|
+
</Box>
|
|
188
|
+
</AssistantRuntimeProvider>
|
|
189
|
+
);
|
|
190
|
+
}
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
</Tab>
|
|
194
|
+
</PlatformTabs>
|
|
195
|
+
|
|
196
|
+
</Step>
|
|
197
|
+
<Step>
|
|
198
|
+
|
|
199
|
+
### Set up UI components
|
|
200
|
+
|
|
201
|
+
<PlatformTabs>
|
|
202
|
+
<Tab value="React">
|
|
203
|
+
|
|
204
|
+
Follow the [UI Components guide](/docs/ui/thread) to wire up the Thread, composer, and supporting primitives.
|
|
205
|
+
|
|
206
|
+
</Tab>
|
|
207
|
+
<Tab value="React Native">
|
|
208
|
+
|
|
209
|
+
Follow the [React Native setup](/docs/react-native) to add a native Thread, composer, and supporting primitives.
|
|
210
|
+
|
|
211
|
+
</Tab>
|
|
212
|
+
<Tab value="React Ink">
|
|
213
|
+
|
|
214
|
+
Follow the [Ink setup](/docs/ink) to add a terminal Thread, composer, and supporting primitives.
|
|
215
|
+
|
|
216
|
+
</Tab>
|
|
217
|
+
</PlatformTabs>
|
|
218
|
+
|
|
219
|
+
</Step>
|
|
102
220
|
</Steps>
|
|
103
221
|
|
|
104
|
-
##
|
|
222
|
+
## Frontend tools and system messages
|
|
105
223
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
224
|
+
`AssistantChatTransport` (used by default) forwards system messages and frontend tools to your backend on every request. Consume them with `frontendTools`:
|
|
225
|
+
|
|
226
|
+
```ts title="@/app/api/chat/route.ts"
|
|
227
|
+
import { openai } from "@ai-sdk/openai";
|
|
228
|
+
import { streamText, convertToModelMessages, zodSchema } from "ai";
|
|
229
|
+
import type { UIMessage } from "ai";
|
|
230
|
+
import { frontendTools } from "@assistant-ui/react-ai-sdk";
|
|
231
|
+
|
|
232
|
+
export async function POST(req: Request) {
|
|
233
|
+
const {
|
|
234
|
+
messages,
|
|
235
|
+
system,
|
|
236
|
+
tools,
|
|
237
|
+
}: {
|
|
238
|
+
messages: UIMessage[];
|
|
239
|
+
system?: string;
|
|
240
|
+
tools?: any;
|
|
241
|
+
} = await req.json();
|
|
242
|
+
|
|
243
|
+
const result = streamText({
|
|
244
|
+
model: openai("gpt-5.4-mini"),
|
|
245
|
+
system,
|
|
246
|
+
messages: await convertToModelMessages(messages),
|
|
247
|
+
tools: {
|
|
248
|
+
...frontendTools(tools),
|
|
249
|
+
// your backend tools...
|
|
250
|
+
},
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
return result.toUIMessageStreamResponse();
|
|
254
|
+
}
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
Frontend tools are registered through `useAui` (see the [tools guide](/docs/guides/tools)) and serialized for the backend via `frontendTools`.
|
|
258
|
+
|
|
259
|
+
## Multi-step tool calls
|
|
260
|
+
|
|
261
|
+
AI SDK v6 supports running multiple tool-call rounds in a single request via `stopWhen`. Use `stepCountIs(N)` to cap iterations:
|
|
262
|
+
|
|
263
|
+
```ts title="@/app/api/chat/route.ts"
|
|
264
|
+
import { openai } from "@ai-sdk/openai";
|
|
265
|
+
import {
|
|
266
|
+
streamText,
|
|
267
|
+
convertToModelMessages,
|
|
268
|
+
stepCountIs,
|
|
269
|
+
} from "ai";
|
|
270
|
+
|
|
271
|
+
export async function POST(req: Request) {
|
|
272
|
+
const { messages } = await req.json();
|
|
273
|
+
|
|
274
|
+
const result = streamText({
|
|
275
|
+
model: openai("gpt-5.4-mini"),
|
|
276
|
+
messages: await convertToModelMessages(messages),
|
|
277
|
+
tools: {
|
|
278
|
+
/* ... */
|
|
279
|
+
},
|
|
280
|
+
stopWhen: stepCountIs(10), // cap at 10 tool-call iterations
|
|
281
|
+
});
|
|
282
|
+
|
|
283
|
+
return result.toUIMessageStreamResponse();
|
|
284
|
+
}
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
Without a `stopWhen`, AI SDK runs a single inference step. Set `stepCountIs` (or one of AI SDK's other stop conditions) when your tools chain multiple calls.
|
|
288
|
+
|
|
289
|
+
## Quote context
|
|
290
|
+
|
|
291
|
+
assistant-ui's composer can attach quote metadata to user messages (e.g. when the user selects text and clicks "Quote"). On the server, `injectQuoteContext` flattens that metadata into a markdown blockquote prefix so the LLM sees the quoted text:
|
|
292
|
+
|
|
293
|
+
```ts title="@/app/api/chat/route.ts"
|
|
294
|
+
import {
|
|
295
|
+
streamText,
|
|
296
|
+
convertToModelMessages,
|
|
297
|
+
} from "ai";
|
|
298
|
+
import { injectQuoteContext } from "@assistant-ui/react-ai-sdk";
|
|
299
|
+
import { openai } from "@ai-sdk/openai";
|
|
300
|
+
|
|
301
|
+
export async function POST(req: Request) {
|
|
302
|
+
const { messages } = await req.json();
|
|
303
|
+
const result = streamText({
|
|
304
|
+
model: openai("gpt-5.4-mini"),
|
|
305
|
+
messages: await convertToModelMessages(injectQuoteContext(messages)),
|
|
306
|
+
});
|
|
307
|
+
return result.toUIMessageStreamResponse();
|
|
308
|
+
}
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
`injectQuoteContext` is idempotent: if the blockquote prefix is already present, it is not duplicated.
|
|
312
|
+
|
|
313
|
+
## Token usage
|
|
314
|
+
|
|
315
|
+
`useThreadTokenUsage` exposes thread-level token usage on the client. Attach `usage` and `modelId` via `messageMetadata` on the server:
|
|
316
|
+
|
|
317
|
+
```ts title="@/app/api/chat/route.ts"
|
|
111
318
|
import { streamText, convertToModelMessages } from "ai";
|
|
112
319
|
import { frontendTools } from "@assistant-ui/react-ai-sdk";
|
|
320
|
+
|
|
113
321
|
export async function POST(req: Request) {
|
|
114
322
|
const { messages, tools, config } = await req.json();
|
|
115
323
|
const result = streamText({
|
|
@@ -120,54 +328,72 @@ export async function POST(req: Request) {
|
|
|
120
328
|
return result.toUIMessageStreamResponse({
|
|
121
329
|
messageMetadata: ({ part }) => {
|
|
122
330
|
if (part.type === "finish") {
|
|
123
|
-
return {
|
|
124
|
-
usage: part.totalUsage,
|
|
125
|
-
};
|
|
331
|
+
return { usage: part.totalUsage };
|
|
126
332
|
}
|
|
127
333
|
if (part.type === "finish-step") {
|
|
128
|
-
return {
|
|
129
|
-
modelId: part.response.modelId,
|
|
130
|
-
};
|
|
334
|
+
return { modelId: part.response.modelId };
|
|
131
335
|
}
|
|
132
336
|
return undefined;
|
|
133
337
|
},
|
|
134
338
|
});
|
|
135
339
|
}
|
|
136
340
|
```
|
|
137
|
-
</Step>
|
|
138
|
-
<Step>
|
|
139
|
-
Use `useThreadTokenUsage` to render token usage on the client.
|
|
140
341
|
|
|
141
|
-
```tsx
|
|
342
|
+
```tsx title="@/components/TokenCounter.tsx"
|
|
142
343
|
"use client";
|
|
143
344
|
|
|
144
345
|
import { useThreadTokenUsage } from "@assistant-ui/react-ai-sdk";
|
|
145
346
|
|
|
146
347
|
export function TokenCounter() {
|
|
147
348
|
const usage = useThreadTokenUsage();
|
|
148
|
-
|
|
149
349
|
if (!usage) return null;
|
|
150
|
-
|
|
151
350
|
return <div>{usage.totalTokens} total tokens</div>;
|
|
152
351
|
}
|
|
153
352
|
```
|
|
154
|
-
</Step>
|
|
155
|
-
</Steps>
|
|
156
353
|
|
|
157
|
-
|
|
354
|
+
`getThreadMessageTokenUsage(message)` returns per-message usage if you need to show it inline.
|
|
355
|
+
|
|
356
|
+
## Attachments
|
|
357
|
+
|
|
358
|
+
Attachments work through the standard [attachment adapter](/docs/runtimes/concepts/adapters#attachment-adapter). Pass it via `useChatRuntime`:
|
|
359
|
+
|
|
360
|
+
```tsx
|
|
361
|
+
const runtime = useChatRuntime({
|
|
362
|
+
adapters: { attachments: myAttachmentAdapter },
|
|
363
|
+
});
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
Your attachment adapter's `send` should return `content` parts in the AI SDK shape, e.g. for files:
|
|
367
|
+
|
|
368
|
+
```ts
|
|
369
|
+
return {
|
|
370
|
+
...attachment,
|
|
371
|
+
status: { type: "complete" },
|
|
372
|
+
content: [
|
|
373
|
+
{
|
|
374
|
+
type: "file",
|
|
375
|
+
mimeType: attachment.contentType ?? "",
|
|
376
|
+
filename: attachment.name,
|
|
377
|
+
data: await getFileDataURL(attachment.file),
|
|
378
|
+
},
|
|
379
|
+
],
|
|
380
|
+
};
|
|
381
|
+
```
|
|
382
|
+
|
|
383
|
+
For images, use `{ type: "image", image: <data url or remote url> }`. AI SDK will pass these to providers that accept multimodal content.
|
|
384
|
+
|
|
385
|
+
## Persisting chat history
|
|
158
386
|
|
|
159
387
|
By default, messages live only in memory and reset on reload. To persist and restore history per thread, provide a `ThreadHistoryAdapter` via `adapters.history`.
|
|
160
388
|
|
|
161
389
|
<Callout type="warn">
|
|
162
|
-
|
|
390
|
+
The adapter **must** implement `withFormat`. `useChatRuntime` persists history through `withFormat(fmt)` so messages round-trip as AI SDK `UIMessage` objects. An adapter without `withFormat` throws at runtime; `load` and `append` on the top level are unused in the AI SDK path.
|
|
163
391
|
</Callout>
|
|
164
392
|
|
|
165
393
|
<Callout type="info">
|
|
166
|
-
|
|
394
|
+
For server-side cloud persistence with zero adapter code, see the [AssistantCloud integration](/docs/cloud/ai-sdk-assistant-ui).
|
|
167
395
|
</Callout>
|
|
168
396
|
|
|
169
|
-
### Example
|
|
170
|
-
|
|
171
397
|
```tsx
|
|
172
398
|
"use client";
|
|
173
399
|
|
|
@@ -181,7 +407,7 @@ const historyAdapter: ThreadHistoryAdapter = {
|
|
|
181
407
|
},
|
|
182
408
|
async append() {},
|
|
183
409
|
|
|
184
|
-
//
|
|
410
|
+
// fmt encodes UIMessage <-> storage rows (ai-sdk/v6 format).
|
|
185
411
|
withFormat: (fmt) => ({
|
|
186
412
|
async load() {
|
|
187
413
|
const rows = await fetch("/api/history").then((r) => r.json());
|
|
@@ -202,90 +428,33 @@ const historyAdapter: ThreadHistoryAdapter = {
|
|
|
202
428
|
};
|
|
203
429
|
|
|
204
430
|
function Chat() {
|
|
205
|
-
const runtime = useChatRuntime({
|
|
206
|
-
adapters: { history: historyAdapter },
|
|
207
|
-
});
|
|
431
|
+
const runtime = useChatRuntime({ adapters: { history: historyAdapter } });
|
|
208
432
|
// ...
|
|
209
433
|
}
|
|
210
434
|
```
|
|
211
435
|
|
|
212
|
-
Each persisted row follows `{ id, parent_id, format, content }
|
|
436
|
+
Each persisted row follows `{ id, parent_id, format, content }`. `fmt.encode` produces the `content` payload and `fmt.decode` reverses it, so your backend never needs to know about `UIMessage` internals.
|
|
213
437
|
|
|
214
|
-
##
|
|
438
|
+
## Custom transport
|
|
215
439
|
|
|
216
|
-
|
|
217
|
-
|---------|----|----|
|
|
218
|
-
| **ai package** | `ai@^5` | `ai@^6` |
|
|
219
|
-
| **@ai-sdk/react** | `@ai-sdk/react@^2` | `@ai-sdk/react@^3` |
|
|
220
|
-
| **convertToModelMessages** | Sync | Async (`await`) |
|
|
221
|
-
| **Tool schema** | `parameters: z.object({...})` | `inputSchema: zodSchema(z.object({...}))` |
|
|
222
|
-
|
|
223
|
-
## API Reference
|
|
224
|
-
|
|
225
|
-
### useChatRuntime
|
|
226
|
-
|
|
227
|
-
Creates a runtime integrated with AI SDK's `useChat` hook.
|
|
440
|
+
`AssistantChatTransport` is the default. To point at a non-default endpoint, instantiate it with a custom `api`:
|
|
228
441
|
|
|
229
442
|
```tsx
|
|
230
|
-
import {
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
### Custom API URL
|
|
236
|
-
|
|
237
|
-
To use a different endpoint, pass a custom `AssistantChatTransport`:
|
|
238
|
-
|
|
239
|
-
```tsx
|
|
240
|
-
import { useChatRuntime, AssistantChatTransport } from "@assistant-ui/react-ai-sdk";
|
|
443
|
+
import {
|
|
444
|
+
useChatRuntime,
|
|
445
|
+
AssistantChatTransport,
|
|
446
|
+
} from "@assistant-ui/react-ai-sdk";
|
|
241
447
|
|
|
242
448
|
const runtime = useChatRuntime({
|
|
243
|
-
transport: new AssistantChatTransport({
|
|
244
|
-
api: "/my-custom-api/chat",
|
|
245
|
-
}),
|
|
449
|
+
transport: new AssistantChatTransport({ api: "/my-custom-api/chat" }),
|
|
246
450
|
});
|
|
247
451
|
```
|
|
248
452
|
|
|
249
|
-
|
|
453
|
+
If you need a transport that does not inherit from `AssistantChatTransport`, you forfeit automatic system-message and frontend-tool forwarding; the transport is then a regular AI SDK `ChatTransport` and you control everything explicitly.
|
|
250
454
|
|
|
251
|
-
|
|
455
|
+
## Advanced: useAISDKRuntime
|
|
252
456
|
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
```tsx
|
|
256
|
-
import { openai } from "@ai-sdk/openai";
|
|
257
|
-
import { streamText, convertToModelMessages, zodSchema } from "ai";
|
|
258
|
-
import type { UIMessage } from "ai";
|
|
259
|
-
import { frontendTools } from "@assistant-ui/react-ai-sdk";
|
|
260
|
-
|
|
261
|
-
export async function POST(req: Request) {
|
|
262
|
-
const {
|
|
263
|
-
messages,
|
|
264
|
-
system,
|
|
265
|
-
tools,
|
|
266
|
-
}: {
|
|
267
|
-
messages: UIMessage[];
|
|
268
|
-
system?: string;
|
|
269
|
-
tools?: any;
|
|
270
|
-
} = await req.json();
|
|
271
|
-
|
|
272
|
-
const result = streamText({
|
|
273
|
-
model: openai("gpt-4o"),
|
|
274
|
-
system,
|
|
275
|
-
messages: await convertToModelMessages(messages),
|
|
276
|
-
tools: {
|
|
277
|
-
...frontendTools(tools),
|
|
278
|
-
// your backend tools...
|
|
279
|
-
},
|
|
280
|
-
});
|
|
281
|
-
|
|
282
|
-
return result.toUIMessageStreamResponse();
|
|
283
|
-
}
|
|
284
|
-
```
|
|
285
|
-
|
|
286
|
-
### useAISDKRuntime (Advanced)
|
|
287
|
-
|
|
288
|
-
For advanced use cases where you need direct access to the `useChat` hook:
|
|
457
|
+
When you need direct access to the `useChat` instance (e.g. to share it with non-assistant-ui code), drop down to `useAISDKRuntime`:
|
|
289
458
|
|
|
290
459
|
```tsx
|
|
291
460
|
import { useChat } from "@ai-sdk/react";
|
|
@@ -295,6 +464,51 @@ const chat = useChat();
|
|
|
295
464
|
const runtime = useAISDKRuntime(chat);
|
|
296
465
|
```
|
|
297
466
|
|
|
467
|
+
`useAISDKRuntime` does not provide `cloud` or the higher-level adapter slots; those are part of `useChatRuntime`. If you need both your own `useChat` access AND cloud thread support, you generally want `useChatRuntime` and to read the chat state through assistant-ui hooks instead.
|
|
468
|
+
|
|
469
|
+
## Adapter support
|
|
470
|
+
|
|
471
|
+
| Adapter | Supported via |
|
|
472
|
+
| --- | --- |
|
|
473
|
+
| Attachments | `adapters.attachments` |
|
|
474
|
+
| Speech | `adapters.speech` |
|
|
475
|
+
| Dictation | `adapters.dictation` |
|
|
476
|
+
| Feedback | `adapters.feedback` |
|
|
477
|
+
| History | `adapters.history` (must implement `withFormat`) |
|
|
478
|
+
| threadList | Via `cloud` (managed) or [RemoteThreadListRuntime](/docs/runtimes/concepts/threads) (custom DB) |
|
|
479
|
+
|
|
480
|
+
## Key changes from v5
|
|
481
|
+
|
|
482
|
+
| Feature | v5 | v6 |
|
|
483
|
+
| --- | --- | --- |
|
|
484
|
+
| `ai` package | `ai@^5` | `ai@^6` |
|
|
485
|
+
| `@ai-sdk/react` | `@ai-sdk/react@^2` | `@ai-sdk/react@^3` |
|
|
486
|
+
| `convertToModelMessages` | Sync | Async (`await`) |
|
|
487
|
+
| Tool schema | `parameters: z.object({...})` | `inputSchema: zodSchema(z.object({...}))` |
|
|
488
|
+
| Response | `toDataStreamResponse()` | `toUIMessageStreamResponse()` |
|
|
489
|
+
|
|
298
490
|
## Example
|
|
299
491
|
|
|
300
|
-
|
|
492
|
+
[`examples/with-ai-sdk-v6`](https://github.com/assistant-ui/assistant-ui/tree/main/examples/with-ai-sdk-v6) shows a complete reference implementation.
|
|
493
|
+
|
|
494
|
+
For responses that should survive a page reload mid-stream, see [Resumable streams](/docs/guides/resumable-streams), which wraps the same v6 byte stream in `assistant-stream/resumable`.
|
|
495
|
+
|
|
496
|
+
## Next
|
|
497
|
+
|
|
498
|
+
<Cards>
|
|
499
|
+
<Card
|
|
500
|
+
title="Adapters"
|
|
501
|
+
description="Attachments, speech, feedback, history, suggestions; one source of truth."
|
|
502
|
+
href="/docs/runtimes/concepts/adapters"
|
|
503
|
+
/>
|
|
504
|
+
<Card
|
|
505
|
+
title="Threads"
|
|
506
|
+
description="Single-thread, AssistantCloud, custom thread list."
|
|
507
|
+
href="/docs/runtimes/concepts/threads"
|
|
508
|
+
/>
|
|
509
|
+
<Card
|
|
510
|
+
title="Resumable streams"
|
|
511
|
+
description="Survive page reloads and connection drops mid-response."
|
|
512
|
+
href="/docs/guides/resumable-streams"
|
|
513
|
+
/>
|
|
514
|
+
</Cards>
|