@assistant-ui/mcp-docs-server 0.1.31 → 0.1.33
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 +23 -25
- package/.docs/organized/code-examples/with-a2a.md +28 -28
- package/.docs/organized/code-examples/with-ag-ui.md +35 -30
- package/.docs/organized/code-examples/with-ai-sdk-v6.md +16 -14
- package/.docs/organized/code-examples/with-artifacts.md +44 -38
- package/.docs/organized/code-examples/with-assistant-transport.md +68 -56
- package/.docs/organized/code-examples/with-browser-extension.md +357 -0
- package/.docs/organized/code-examples/with-chain-of-thought.md +425 -90
- package/.docs/organized/code-examples/with-cloud-standalone.md +30 -29
- package/.docs/organized/code-examples/with-cloud.md +16 -14
- package/.docs/organized/code-examples/with-custom-thread-list.md +19 -17
- package/.docs/organized/code-examples/with-elevenlabs-conversational.md +29 -26
- package/.docs/organized/code-examples/with-elevenlabs-scribe.md +20 -18
- package/.docs/organized/code-examples/with-expo.md +37 -31
- package/.docs/organized/code-examples/with-external-store.md +13 -11
- package/.docs/organized/code-examples/with-ffmpeg.md +327 -290
- package/.docs/organized/code-examples/with-generative-ui.md +1195 -194
- package/.docs/organized/code-examples/with-google-adk.md +13 -11
- package/.docs/organized/code-examples/with-heat-graph.md +16 -14
- package/.docs/organized/code-examples/with-image-generation.md +456 -0
- package/.docs/organized/code-examples/with-interactables.md +322 -244
- package/.docs/organized/code-examples/with-langchain.md +18 -16
- package/.docs/organized/code-examples/with-langgraph.md +95 -88
- package/.docs/organized/code-examples/with-livekit.md +30 -27
- package/.docs/organized/code-examples/with-mcp.md +754 -0
- package/.docs/organized/code-examples/with-opencode.md +70 -70
- package/.docs/organized/code-examples/with-react-hook-form.md +24 -22
- package/.docs/organized/code-examples/with-react-ink.md +4 -4
- package/.docs/organized/code-examples/with-react-router.md +20 -18
- package/.docs/organized/code-examples/with-resumable-stream.md +661 -0
- package/.docs/organized/code-examples/with-store.md +22 -20
- package/.docs/organized/code-examples/with-tanstack.md +18 -19
- package/.docs/organized/code-examples/with-tap-runtime.md +31 -28
- package/.docs/raw/docs/(docs)/architecture.mdx +43 -2
- package/.docs/raw/docs/(docs)/cli.mdx +2 -2
- package/.docs/raw/docs/(docs)/copilots/model-context.mdx +34 -26
- package/.docs/raw/docs/(docs)/copilots/motivation.mdx +32 -26
- package/.docs/raw/docs/(docs)/index.mdx +2 -2
- package/.docs/raw/docs/(docs)/installation.mdx +2 -2
- package/.docs/raw/docs/(reference)/api-reference/adapters/attachments.mdx +26 -24
- package/.docs/raw/docs/(reference)/api-reference/adapters/feedback.mdx +20 -0
- package/.docs/raw/docs/(reference)/api-reference/adapters/index.mdx +20 -12
- package/.docs/raw/docs/(reference)/api-reference/adapters/model.mdx +44 -0
- package/.docs/raw/docs/(reference)/api-reference/adapters/persistence.mdx +41 -16
- package/.docs/raw/docs/(reference)/api-reference/adapters/runtime.mdx +12 -23
- 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 +11 -9
- 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 +46 -0
- package/.docs/raw/docs/(reference)/api-reference/generative-ui/index.mdx +18 -0
- package/.docs/raw/docs/(reference)/api-reference/generative-ui/rendering.mdx +33 -0
- package/.docs/raw/docs/(reference)/api-reference/generative-ui/spec.mdx +45 -0
- package/.docs/raw/docs/(reference)/api-reference/hooks/composer-triggers.mdx +98 -0
- package/.docs/raw/docs/(reference)/api-reference/hooks/index.mdx +18 -13
- package/.docs/raw/docs/(reference)/api-reference/hooks/model-context.mdx +31 -52
- package/.docs/raw/docs/(reference)/api-reference/hooks/primitives.mdx +640 -0
- package/.docs/raw/docs/(reference)/api-reference/hooks/runtimes.mdx +15 -28
- package/.docs/raw/docs/(reference)/api-reference/hooks/state.mdx +64 -18
- package/.docs/raw/docs/(reference)/api-reference/hooks/utilities.mdx +434 -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 +11 -12
- package/.docs/raw/docs/(reference)/api-reference/integrations/react-ai-sdk.mdx +109 -0
- package/.docs/raw/docs/(reference)/api-reference/model-context/context.mdx +58 -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 +109 -132
- 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 +39 -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 +29 -24
- package/.docs/raw/docs/(reference)/api-reference/primitives/message-part.mdx +63 -245
- package/.docs/raw/docs/(reference)/api-reference/primitives/message.mdx +202 -588
- 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 +77 -96
- package/.docs/raw/docs/(reference)/api-reference/primitives/thread.mdx +173 -349
- 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 +18 -13
- 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 -47
- package/.docs/raw/docs/(reference)/api-reference/runtimes/thread-runtime.mdx +18 -30
- package/.docs/raw/docs/(reference)/api-reference/tools/component-tools.mdx +85 -0
- package/.docs/raw/docs/(reference)/api-reference/tools/index.mdx +39 -0
- package/.docs/raw/docs/(reference)/api-reference/tools/rendering.mdx +127 -0
- package/.docs/raw/docs/(reference)/api-reference/tools/status.mdx +42 -0
- package/.docs/raw/docs/(reference)/api-reference/tools/toolkits.mdx +91 -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 +143 -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.mdx +1 -3
- package/.docs/raw/docs/cloud/index.mdx +2 -2
- package/.docs/raw/docs/guides/attachments.mdx +4 -4
- package/.docs/raw/docs/guides/branching.mdx +1 -1
- package/.docs/raw/docs/guides/chain-of-thought.mdx +12 -14
- package/.docs/raw/docs/guides/context-api.mdx +6 -5
- package/.docs/raw/docs/guides/dictation.mdx +2 -2
- package/.docs/raw/docs/guides/editing.mdx +1 -1
- package/.docs/raw/docs/guides/image-generation.mdx +74 -0
- package/.docs/raw/docs/guides/index.mdx +5 -14
- package/.docs/raw/docs/guides/latex.mdx +2 -2
- package/.docs/raw/docs/guides/mentions.mdx +6 -6
- package/.docs/raw/docs/guides/message-timing.mdx +38 -5
- package/.docs/raw/docs/guides/quoting.mdx +1 -1
- 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/guides/slash-commands.mdx +2 -2
- package/.docs/raw/docs/guides/speech.mdx +2 -2
- package/.docs/raw/docs/guides/suggestions.mdx +89 -5
- package/.docs/raw/docs/guides/voice.mdx +2 -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/hooks.mdx +98 -85
- package/.docs/raw/docs/ink/index.mdx +10 -11
- package/.docs/raw/docs/ink/migration.mdx +1 -1
- package/.docs/raw/docs/ink/primitives.mdx +350 -9
- package/.docs/raw/docs/integrations/auth/better-auth.mdx +1 -1
- package/.docs/raw/docs/integrations/auth/clerk.mdx +1 -1
- package/.docs/raw/docs/integrations/auth/next-auth.mdx +1 -1
- package/.docs/raw/docs/integrations/frameworks/ai-sdk.mdx +3 -3
- package/.docs/raw/docs/integrations/frameworks/cloudflare-agents/overview.mdx +282 -0
- package/.docs/raw/docs/integrations/frameworks/mastra/overview.mdx +2 -2
- package/.docs/raw/docs/integrations/frameworks/mastra/separate-server.mdx +1 -1
- package/.docs/raw/docs/integrations/gateways/index.mdx +9 -4
- package/.docs/raw/docs/integrations/index.mdx +17 -5
- package/.docs/raw/docs/integrations/observability/langfuse.mdx +8 -1
- package/.docs/raw/docs/integrations/observability/langsmith.mdx +8 -4
- package/.docs/raw/docs/integrations/persistence/custom-adapter.mdx +17 -2
- package/.docs/raw/docs/migrations/toolkit-tools.mdx +226 -0
- package/.docs/raw/docs/primitives/chain-of-thought.mdx +10 -16
- package/.docs/raw/docs/primitives/composer.mdx +53 -0
- package/.docs/raw/docs/primitives/index.mdx +2 -2
- package/.docs/raw/docs/primitives/message.mdx +9 -10
- package/.docs/raw/docs/primitives/suggestion.mdx +9 -0
- package/.docs/raw/docs/react-native/hooks.mdx +57 -82
- package/.docs/raw/docs/react-native/index.mdx +4 -4
- package/.docs/raw/docs/react-native/migration.mdx +1 -1
- package/.docs/raw/docs/react-native/primitives.mdx +2 -2
- package/.docs/raw/docs/runtimes/a2a/client-and-hooks.mdx +7 -4
- package/.docs/raw/docs/runtimes/a2a/overview.mdx +2 -2
- package/.docs/raw/docs/runtimes/ag-ui/overview.mdx +2 -2
- package/.docs/raw/docs/runtimes/ag-ui/runtime-options.mdx +32 -1
- package/.docs/raw/docs/runtimes/ai-sdk/overview.mdx +2 -2
- package/.docs/raw/docs/runtimes/ai-sdk/v4-legacy.mdx +7 -2
- package/.docs/raw/docs/runtimes/ai-sdk/v5-legacy.mdx +1 -1
- package/.docs/raw/docs/runtimes/ai-sdk/v6.mdx +129 -1
- package/.docs/raw/docs/runtimes/concepts/threads.mdx +7 -1
- package/.docs/raw/docs/runtimes/custom/data-stream.mdx +27 -2
- package/.docs/raw/docs/runtimes/custom/external-store.mdx +9 -1
- package/.docs/raw/docs/runtimes/custom/local-runtime.mdx +18 -7
- package/.docs/raw/docs/runtimes/custom/overview.mdx +2 -2
- package/.docs/raw/docs/runtimes/google-adk/hooks.mdx +108 -38
- package/.docs/raw/docs/runtimes/google-adk/overview.mdx +2 -2
- package/.docs/raw/docs/runtimes/langchain.mdx +2 -2
- package/.docs/raw/docs/runtimes/langgraph/generative-ui.mdx +2 -2
- package/.docs/raw/docs/runtimes/langgraph/overview.mdx +2 -2
- package/.docs/raw/docs/runtimes/langgraph/streaming.mdx +1 -1
- package/.docs/raw/docs/runtimes/langgraph/tutorial/part-2.mdx +64 -50
- package/.docs/raw/docs/runtimes/langgraph/tutorial/part-3.mdx +98 -86
- package/.docs/raw/docs/runtimes/opencode/overview.mdx +2 -2
- package/.docs/raw/docs/runtimes/opencode/quickstart.mdx +1 -1
- package/.docs/raw/docs/runtimes/pick-a-runtime.mdx +12 -5
- package/.docs/raw/docs/tools/backend.mdx +136 -0
- package/.docs/raw/docs/tools/defining-tools.mdx +413 -0
- package/.docs/raw/docs/tools/dynamic-tools.mdx +110 -0
- package/.docs/raw/docs/tools/generative-ui.mdx +214 -0
- package/.docs/raw/docs/tools/index.mdx +76 -0
- package/.docs/raw/docs/{guides → tools}/interactables.mdx +3 -3
- package/.docs/raw/docs/tools/mcp-apps.mdx +231 -0
- package/.docs/raw/docs/{integrations/tools → tools}/mcp.mdx +77 -50
- package/.docs/raw/docs/{guides → tools}/multi-agent.mdx +19 -21
- package/.docs/raw/docs/tools/tool-ui.mdx +967 -0
- package/.docs/raw/docs/tools/user-managed-mcp.mdx +337 -0
- package/.docs/raw/docs/ui/composer-trigger-popover.mdx +11 -1
- package/.docs/raw/docs/ui/directive-text.mdx +3 -3
- package/.docs/raw/docs/ui/mcp-config.mdx +102 -0
- package/.docs/raw/docs/ui/model-selector.mdx +8 -8
- package/.docs/raw/docs/ui/part-grouping.mdx +84 -50
- package/.docs/raw/docs/ui/reasoning.mdx +4 -5
- package/.docs/raw/docs/ui/sources.mdx +17 -0
- package/.docs/raw/docs/ui/streamdown.mdx +34 -2
- package/.docs/raw/docs/ui/thread-list.mdx +2 -2
- package/.docs/raw/docs/ui/thread.mdx +2 -2
- package/.docs/raw/docs/ui/tool-group.mdx +5 -6
- package/.docs/raw/docs/utilities/heat-graph.mdx +1 -1
- 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 +5 -5
- package/.docs/organized/code-examples/with-parent-id-grouping.md +0 -596
- package/.docs/raw/docs/(docs)/copilots/make-assistant-tool-ui.mdx +0 -151
- package/.docs/raw/docs/(docs)/copilots/make-assistant-tool.mdx +0 -230
- package/.docs/raw/docs/(reference)/api-reference/adapters/feedback-speech.mdx +0 -41
- 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/guides/tool-ui.mdx +0 -858
- package/.docs/raw/docs/guides/tools.mdx +0 -675
- 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
- /package/.docs/raw/docs/{(reference)/migrations → migrations}/v0-14.mdx +0 -0
|
@@ -81,46 +81,44 @@ type PurchaseStockResult = {
|
|
|
81
81
|
};
|
|
82
82
|
```
|
|
83
83
|
|
|
84
|
-
Then we
|
|
84
|
+
Then we define a tool UI renderer:
|
|
85
85
|
|
|
86
86
|
```tsx title="@/components/tools/purchase-stock/PurchaseStockTool.tsx"
|
|
87
87
|
"use client";
|
|
88
88
|
|
|
89
89
|
import { TransactionConfirmationPending } from "./transaction-confirmation-pending";
|
|
90
90
|
import { TransactionConfirmationFinal } from "./transaction-confirmation-final";
|
|
91
|
-
import {
|
|
92
|
-
|
|
93
|
-
export const
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
},
|
|
123
|
-
);
|
|
91
|
+
import type { ToolCallMessagePartComponent } from "@assistant-ui/react";
|
|
92
|
+
|
|
93
|
+
export const PurchaseStockToolUI: ToolCallMessagePartComponent<
|
|
94
|
+
PurchaseStockArgs,
|
|
95
|
+
string
|
|
96
|
+
> = function PurchaseStockUI({ args, result, status, addResult }) {
|
|
97
|
+
const handleReject = async () => {
|
|
98
|
+
addResult(JSON.stringify({ approve: false }));
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
const handleConfirm = async () => {
|
|
102
|
+
addResult(JSON.stringify({ approve: true }));
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
return (
|
|
106
|
+
<div className="mb-4 flex flex-col items-center gap-2">
|
|
107
|
+
<div>
|
|
108
|
+
<pre className="whitespace-pre-wrap break-all text-center">
|
|
109
|
+
purchase_stock({JSON.stringify(args)})
|
|
110
|
+
</pre>
|
|
111
|
+
</div>
|
|
112
|
+
{!result && status.type !== "running" && (
|
|
113
|
+
<TransactionConfirmationPending
|
|
114
|
+
{...args}
|
|
115
|
+
onConfirm={handleConfirm}
|
|
116
|
+
onReject={handleReject}
|
|
117
|
+
/>
|
|
118
|
+
)}
|
|
119
|
+
</div>
|
|
120
|
+
);
|
|
121
|
+
};
|
|
124
122
|
```
|
|
125
123
|
|
|
126
124
|
Finally, we add a `TransactionConfirmationPending` component to ask for approval.
|
|
@@ -208,16 +206,32 @@ export function TransactionConfirmationPending(props: TransactionConfirmation) {
|
|
|
208
206
|
|
|
209
207
|
### Bind approval UI
|
|
210
208
|
|
|
211
|
-
```tsx title="@/app/page.tsx" {1,
|
|
212
|
-
|
|
209
|
+
```tsx title="@/app/page.tsx" {1-5,12}
|
|
210
|
+
"use client";
|
|
211
|
+
|
|
212
|
+
import { Thread } from "@/components/assistant-ui/thread";
|
|
213
|
+
import { PriceSnapshotToolUI } from "@/components/tools/price-snapshot/PriceSnapshotTool";
|
|
214
|
+
import { PurchaseStockToolUI } from "@/components/tools/purchase-stock/PurchaseStockTool";
|
|
215
|
+
import { AuiProvider, Tools, type Toolkit, useAui } from "@assistant-ui/react";
|
|
216
|
+
|
|
217
|
+
const toolkit = {
|
|
218
|
+
price_snapshot: {
|
|
219
|
+
type: "backend",
|
|
220
|
+
render: PriceSnapshotToolUI,
|
|
221
|
+
},
|
|
222
|
+
purchase_stock: {
|
|
223
|
+
type: "backend",
|
|
224
|
+
render: PurchaseStockToolUI,
|
|
225
|
+
},
|
|
226
|
+
} satisfies Toolkit;
|
|
213
227
|
|
|
214
228
|
export default function Home() {
|
|
229
|
+
const aui = useAui({ tools: Tools({ toolkit }) });
|
|
230
|
+
|
|
215
231
|
return (
|
|
216
|
-
<
|
|
217
|
-
<PriceSnapshotTool />
|
|
218
|
-
<PurchaseStockTool />
|
|
232
|
+
<AuiProvider value={aui}>
|
|
219
233
|
<Thread />
|
|
220
|
-
</
|
|
234
|
+
</AuiProvider>
|
|
221
235
|
);
|
|
222
236
|
}
|
|
223
237
|
```
|
|
@@ -305,7 +319,7 @@ We will import the new `<TransactionConfirmationFinal />` component and use it i
|
|
|
305
319
|
|
|
306
320
|
import { TransactionConfirmationPending } from "./transaction-confirmation-pending";
|
|
307
321
|
import { TransactionConfirmationFinal } from "./transaction-confirmation-final";
|
|
308
|
-
import {
|
|
322
|
+
import type { ToolCallMessagePartComponent } from "@assistant-ui/react";
|
|
309
323
|
|
|
310
324
|
type PurchaseStockArgs = {
|
|
311
325
|
ticker: string;
|
|
@@ -320,51 +334,49 @@ type PurchaseStockResult = {
|
|
|
320
334
|
error?: string;
|
|
321
335
|
};
|
|
322
336
|
|
|
323
|
-
export const
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
},
|
|
367
|
-
);
|
|
337
|
+
export const PurchaseStockToolUI: ToolCallMessagePartComponent<
|
|
338
|
+
PurchaseStockArgs,
|
|
339
|
+
string
|
|
340
|
+
> = function PurchaseStockUI({ args, result, status, addResult }) {
|
|
341
|
+
let resultObj: PurchaseStockResult;
|
|
342
|
+
try {
|
|
343
|
+
resultObj = result ? JSON.parse(result) : {};
|
|
344
|
+
} catch (e) {
|
|
345
|
+
resultObj = { error: result! };
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
const handleReject = () => {
|
|
349
|
+
addResult(JSON.stringify({ approve: false }));
|
|
350
|
+
};
|
|
351
|
+
|
|
352
|
+
const handleConfirm = async () => {
|
|
353
|
+
addResult(JSON.stringify({ approve: true }));
|
|
354
|
+
};
|
|
355
|
+
|
|
356
|
+
return (
|
|
357
|
+
<div className="mb-4 flex flex-col items-center gap-2">
|
|
358
|
+
<div>
|
|
359
|
+
<pre className="whitespace-pre-wrap break-all text-center">
|
|
360
|
+
purchase_stock({JSON.stringify(args)})
|
|
361
|
+
</pre>
|
|
362
|
+
</div>
|
|
363
|
+
{!result && status.type !== "running" && (
|
|
364
|
+
<TransactionConfirmationPending
|
|
365
|
+
{...args}
|
|
366
|
+
onConfirm={handleConfirm}
|
|
367
|
+
onReject={handleReject}
|
|
368
|
+
/>
|
|
369
|
+
)}
|
|
370
|
+
{resultObj.approve && <TransactionConfirmationFinal {...args} />}
|
|
371
|
+
{resultObj.approve === false && (
|
|
372
|
+
<pre className="font-bold text-red-600">User rejected purchase</pre>
|
|
373
|
+
)}
|
|
374
|
+
{resultObj.cancelled && (
|
|
375
|
+
<pre className="font-bold text-red-600">Cancelled</pre>
|
|
376
|
+
)}
|
|
377
|
+
</div>
|
|
378
|
+
);
|
|
379
|
+
};
|
|
368
380
|
```
|
|
369
381
|
|
|
370
382
|
### Try it out!
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
|
-
title:
|
|
3
|
-
description:
|
|
2
|
+
title: OpenCode Runtime
|
|
3
|
+
description: Build a React chat UI for OpenCode coding agents with assistant-ui — streaming, tool calls, file edits, and terminal output rendered in chat.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
`@assistant-ui/react-opencode` is a runtime adapter for [OpenCode](https://opencode.ai/), an open-source AI coding agent. It wires the OpenCode server's session and event APIs into an assistant-ui thread, including tool permissions, interactive questions, and session state.
|
|
@@ -72,7 +72,7 @@ Pin a default model or agent when starting new sessions:
|
|
|
72
72
|
```tsx
|
|
73
73
|
const runtime = useOpenCodeRuntime({
|
|
74
74
|
baseUrl: "http://localhost:4096",
|
|
75
|
-
defaultModel: { providerID: "anthropic", modelID: "claude-sonnet-4" },
|
|
75
|
+
defaultModel: { providerID: "anthropic", modelID: "claude-sonnet-4-6" },
|
|
76
76
|
defaultAgent: "coder",
|
|
77
77
|
});
|
|
78
78
|
```
|
|
@@ -3,14 +3,15 @@ title: Picking a runtime
|
|
|
3
3
|
description: Decision guide for choosing the right runtime, by framework or by feature.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
+
import { A2AIcon } from "@/components/icons/a2a";
|
|
7
|
+
import { AdkIcon } from "@/components/icons/adk";
|
|
6
8
|
import { AguiIcon } from "@/components/icons/agui";
|
|
7
|
-
import {
|
|
9
|
+
import { CloudflareIcon } from "@/components/icons/cloudflare";
|
|
8
10
|
import { LangChainIcon } from "@/components/icons/langchain";
|
|
9
11
|
import { LangGraphIcon } from "@/components/icons/langgraph";
|
|
10
12
|
import { MastraIcon } from "@/components/icons/mastra";
|
|
11
13
|
import { OpenCodeIcon } from "@/components/icons/opencode";
|
|
12
14
|
import { VercelIcon } from "@/components/icons/vercel";
|
|
13
|
-
import { Network } from "lucide-react";
|
|
14
15
|
|
|
15
16
|
A runtime is the connection between assistant-ui's UI primitives and your AI backend. This page helps you pick one. Two lenses, pick whichever maps to what you already know.
|
|
16
17
|
|
|
@@ -42,16 +43,16 @@ assistant-ui ships React adapter packages for these. Pick the matching card and
|
|
|
42
43
|
href="/docs/runtimes/langchain"
|
|
43
44
|
/>
|
|
44
45
|
<Card
|
|
45
|
-
icon={<
|
|
46
|
+
icon={<AdkIcon width={20} height={20} />}
|
|
46
47
|
title="Google ADK"
|
|
47
48
|
description="ADK JS or Python agents. Tool confirmations, auth flows, multi-agent, code execution."
|
|
48
49
|
href="/docs/runtimes/google-adk"
|
|
49
50
|
/>
|
|
50
51
|
<Card
|
|
51
|
-
icon={<
|
|
52
|
+
icon={<A2AIcon width={20} height={20} />}
|
|
52
53
|
title="A2A Protocol"
|
|
53
54
|
description="Any A2A v1.0-compliant agent server. Streaming task state, artifacts, multi-tenancy."
|
|
54
|
-
href="/docs/runtimes/a2a"
|
|
55
|
+
href="/docs/runtimes/a2a/overview"
|
|
55
56
|
/>
|
|
56
57
|
<Card
|
|
57
58
|
icon={<AguiIcon width={20} height={20} />}
|
|
@@ -76,6 +77,12 @@ assistant-ui ships React adapter packages for these. Pick the matching card and
|
|
|
76
77
|
For frameworks without a dedicated adapter, these wiring guides route through one of the adapters above.
|
|
77
78
|
|
|
78
79
|
<Cards>
|
|
80
|
+
<Card
|
|
81
|
+
icon={<CloudflareIcon width={20} height={20} />}
|
|
82
|
+
title="Cloudflare Agents"
|
|
83
|
+
description="Stateful agents on Durable Objects with WebSocket streaming. Wired through the Vercel AI SDK runtime."
|
|
84
|
+
href="/docs/integrations/frameworks/cloudflare-agents/overview"
|
|
85
|
+
/>
|
|
79
86
|
<Card
|
|
80
87
|
icon={<MastraIcon width={20} height={20} />}
|
|
81
88
|
title="Mastra"
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Backend Tools
|
|
3
|
+
description: Wire assistant-ui toolkits into your server with the AI SDK — generativeTools, frontendTools, mixing client and server tools, and multi-modal results.
|
|
4
|
+
platforms: ["react"]
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
A tool is only callable if the **model** knows about it, and the model is configured on your server. This page covers wiring a toolkit into an AI SDK route handler: exposing your generative toolkit, receiving client-defined tools, mixing the two, and round-tripping multi-modal results.
|
|
8
|
+
|
|
9
|
+
For authoring tools, see [Defining Tools](/docs/tools/defining-tools). For MCP servers, see [MCP](/docs/tools/mcp).
|
|
10
|
+
|
|
11
|
+
## The request body
|
|
12
|
+
|
|
13
|
+
`@assistant-ui/react-ai-sdk` posts `{ messages, system, tools }` to your route. `tools` is the map of **frontend** tools the client serialized for this request (the model needs their schemas to call them, even though they run in the browser):
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
const {
|
|
17
|
+
messages,
|
|
18
|
+
system,
|
|
19
|
+
tools,
|
|
20
|
+
}: {
|
|
21
|
+
messages: UIMessage[];
|
|
22
|
+
system?: string;
|
|
23
|
+
tools?: Record<string, { description?: string; parameters: JSONSchema7 }>;
|
|
24
|
+
} = await req.json();
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Generative toolkits: `generativeTools`
|
|
28
|
+
|
|
29
|
+
When you author tools in a [`"use generative"` file](/docs/tools/defining-tools#quick-start-use-generative), the same import resolves to the **server build** inside a route handler — schema plus any backend `execute`, with renderers stripped. Pass it to `generativeTools` together with the uploaded `tools`:
|
|
30
|
+
|
|
31
|
+
```ts title="app/api/chat/route.ts"
|
|
32
|
+
import { generativeTools } from "@assistant-ui/react-ai-sdk";
|
|
33
|
+
import { streamText, convertToModelMessages, type UIMessage } from "ai";
|
|
34
|
+
import { openai } from "@ai-sdk/openai";
|
|
35
|
+
import toolkit from "../../toolkit";
|
|
36
|
+
|
|
37
|
+
export async function POST(req: Request) {
|
|
38
|
+
const { messages, system, tools } = await req.json();
|
|
39
|
+
|
|
40
|
+
const result = streamText({
|
|
41
|
+
model: openai("gpt-5.4-nano"),
|
|
42
|
+
system,
|
|
43
|
+
messages: await convertToModelMessages(messages),
|
|
44
|
+
tools: generativeTools({ toolkit, frontendTools: tools }),
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
return result.toUIMessageStreamResponse();
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
`generativeTools` registers every toolkit tool with the model using its schema, wires the backend `execute` where the server build carries one, and merges in the uploaded `frontendTools`. A server `execute` wins over an uploaded entry of the same name. Frontend and human tools (no server `execute`) are exposed schema-only and left for the client and the user to fulfill.
|
|
52
|
+
|
|
53
|
+
<Callout type="info">
|
|
54
|
+
If your toolkit spreads in MCP server tools (`defineMcpToolkit`), use
|
|
55
|
+
`new AISDKToolkit({ toolkit }).tools({ frontend })` instead of
|
|
56
|
+
`generativeTools` — it also opens the MCP connections. See [MCP](/docs/tools/mcp).
|
|
57
|
+
</Callout>
|
|
58
|
+
|
|
59
|
+
## Client-defined tools: `frontendTools`
|
|
60
|
+
|
|
61
|
+
If you don't use the generative compiler — for example a plain [`satisfies Toolkit`](/docs/tools/defining-tools#render-only-tools-for-externally-executed-tools) with browser-executed tools — the AI SDK adapter still serializes those tools into the request `tools`. Convert them to the AI SDK shape with `frontendTools` and spread your own server tools alongside:
|
|
62
|
+
|
|
63
|
+
```ts title="app/api/chat/route.ts"
|
|
64
|
+
import { frontendTools } from "@assistant-ui/react-ai-sdk";
|
|
65
|
+
import { streamText, convertToModelMessages, tool, zodSchema } from "ai";
|
|
66
|
+
import { openai } from "@ai-sdk/openai";
|
|
67
|
+
import { z } from "zod";
|
|
68
|
+
|
|
69
|
+
export async function POST(req: Request) {
|
|
70
|
+
const { messages, tools } = await req.json();
|
|
71
|
+
|
|
72
|
+
const result = streamText({
|
|
73
|
+
model: openai("gpt-5.4-nano"),
|
|
74
|
+
messages: await convertToModelMessages(messages),
|
|
75
|
+
tools: {
|
|
76
|
+
...frontendTools(tools ?? {}),
|
|
77
|
+
query_database: tool({
|
|
78
|
+
description: "Query the application database.",
|
|
79
|
+
inputSchema: zodSchema(z.object({ query: z.string() })),
|
|
80
|
+
execute: async ({ query }) => db.query(query),
|
|
81
|
+
}),
|
|
82
|
+
},
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
return result.toUIMessageStreamResponse();
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
`generativeTools` calls `frontendTools` for you under the hood; reach for `frontendTools` directly when you're not on the generative build.
|
|
90
|
+
|
|
91
|
+
<Callout type="tip">
|
|
92
|
+
`toToolsJSONSchema` emits the uploaded tools in alphabetical order, so two
|
|
93
|
+
renders that register the same set produce byte-identical request bodies —
|
|
94
|
+
which keeps provider prompt caches stable across renders.
|
|
95
|
+
</Callout>
|
|
96
|
+
|
|
97
|
+
## Multi-modal results
|
|
98
|
+
|
|
99
|
+
When a tool declares [`toModelOutput`](/docs/tools/defining-tools#multi-modal-tool-results), frontend tool results round-trip through the AI SDK chat protocol back to your route on the next turn. For `toModelOutput` to fire on those round-tripped results, pass the tool registry to `convertToModelMessages` as well — the [same pattern the AI SDK documents](https://ai-sdk.dev/docs/reference/ai-sdk-ui/convert-to-model-messages#multi-modal-tool-responses) for any multi-modal tool response:
|
|
100
|
+
|
|
101
|
+
```ts
|
|
102
|
+
const aiSDKTools = { ...frontendTools(tools ?? {}) };
|
|
103
|
+
|
|
104
|
+
const result = streamText({
|
|
105
|
+
model,
|
|
106
|
+
// Pass tools to BOTH calls so prior results are projected via toModelOutput.
|
|
107
|
+
messages: await convertToModelMessages(messages, { tools: aiSDKTools }),
|
|
108
|
+
tools: aiSDKTools,
|
|
109
|
+
});
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
Skip the `{ tools }` argument and prior results are sent as a plain JSON blob — `toModelOutput` is silently ignored. Tools without `toModelOutput` are unaffected either way.
|
|
113
|
+
|
|
114
|
+
<Callout type="warn">
|
|
115
|
+
**Read/write compatibility for persisted threads.** When `toModelOutput` is
|
|
116
|
+
set, the runtime persists the AI SDK output as
|
|
117
|
+
`{ __aui_modelContent, value }`. Upgrade every reader before any writer starts
|
|
118
|
+
producing `toModelOutput`; older readers treat the whole envelope as the
|
|
119
|
+
`result` and break that tool's `render`. Don't return objects whose top-level
|
|
120
|
+
key is literally `__aui_modelContent` from any `execute`.
|
|
121
|
+
</Callout>
|
|
122
|
+
|
|
123
|
+
## Multi-step tool calls
|
|
124
|
+
|
|
125
|
+
To let the model see a frontend tool's result and continue, configure the runtime to send back automatically when the last assistant message is complete with tool calls:
|
|
126
|
+
|
|
127
|
+
```tsx
|
|
128
|
+
import { lastAssistantMessageIsCompleteWithToolCalls } from "ai";
|
|
129
|
+
|
|
130
|
+
const runtime = useChatRuntime({
|
|
131
|
+
api: "/api/chat",
|
|
132
|
+
sendAutomaticallyWhen: lastAssistantMessageIsCompleteWithToolCalls,
|
|
133
|
+
});
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
For the full AI SDK v6 backend setup — history persistence, reasoning, server-side approvals — see the [AI SDK v6 guide](/docs/runtimes/ai-sdk/v6).
|