@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
|
@@ -3,9 +3,9 @@ title: Client and hooks
|
|
|
3
3
|
description: A2AClient, useA2ARuntime options, hooks, task states, artifacts, errors.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import { A2AIcon } from "@/components/icons/a2a";
|
|
7
7
|
|
|
8
|
-
Deep dive on the runtime's API surface. Start with [overview](/docs/runtimes/a2a) and [quickstart](/docs/runtimes/a2a/quickstart) if you have not already.
|
|
8
|
+
Deep dive on the runtime's API surface. Start with [overview](/docs/runtimes/a2a/overview) and [quickstart](/docs/runtimes/a2a/quickstart) if you have not already.
|
|
9
9
|
|
|
10
10
|
## A2AClient
|
|
11
11
|
|
|
@@ -19,6 +19,7 @@ const client = new A2AClient({
|
|
|
19
19
|
headers: { Authorization: "Bearer <token>" },
|
|
20
20
|
tenant: "my-org",
|
|
21
21
|
extensions: ["urn:a2a:ext:my-extension"],
|
|
22
|
+
fetchOptions: { credentials: "include" },
|
|
22
23
|
});
|
|
23
24
|
```
|
|
24
25
|
|
|
@@ -37,6 +38,7 @@ const runtime = useA2ARuntime({ client });
|
|
|
37
38
|
| `headers` | `Record<string, string>` or `() => Record<string, string>` | Static or dynamic headers (e.g. for auth tokens). |
|
|
38
39
|
| `tenant` | `string` | Tenant ID for multi-tenant servers (prepended to URL paths). |
|
|
39
40
|
| `extensions` | `string[]` | Extension URIs to negotiate via `A2A-Extensions` header. |
|
|
41
|
+
| `fetchOptions` | `RequestInit` (partial) | Extra fetch options applied to every request (e.g. `{ credentials: "include" }`). `headers`, `body`, `method`, and `signal` are managed internally. |
|
|
40
42
|
|
|
41
43
|
### Client methods
|
|
42
44
|
|
|
@@ -67,6 +69,7 @@ Pass either a pre-built `client` or a `baseUrl` (the runtime creates a client fo
|
|
|
67
69
|
| `tenant` | `string` | Tenant ID for multi-tenant servers. Only used with `baseUrl`. |
|
|
68
70
|
| `headers` | `Record<string, string>` or `() => Record<string, string>` | Headers for the auto-created client. |
|
|
69
71
|
| `extensions` | `string[]` | Extension URIs to negotiate. Only used with `baseUrl`. |
|
|
72
|
+
| `fetchOptions` | `RequestInit` (partial) | Extra fetch options for the auto-created client (e.g. `{ credentials: "include" }`). `headers`, `body`, `method`, and `signal` are managed internally. Only used with `baseUrl`. |
|
|
70
73
|
| `contextId` | `string` | Initial context ID for the conversation. |
|
|
71
74
|
| `configuration` | `A2ASendMessageConfiguration` | Default send message configuration. |
|
|
72
75
|
| `onError` | `(error: Error) => void` | Error callback. |
|
|
@@ -378,10 +381,10 @@ This prepends `/{tenant}` to all API paths (e.g. `/my-org/message:send`).
|
|
|
378
381
|
|
|
379
382
|
<Cards>
|
|
380
383
|
<Card
|
|
381
|
-
icon={<
|
|
384
|
+
icon={<A2AIcon width={20} height={20} />}
|
|
382
385
|
title="A2A overview"
|
|
383
386
|
description="What A2A is and when to pick it."
|
|
384
|
-
href="/docs/runtimes/a2a"
|
|
387
|
+
href="/docs/runtimes/a2a/overview"
|
|
385
388
|
/>
|
|
386
389
|
<Card
|
|
387
390
|
title="Quickstart"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
|
-
title:
|
|
3
|
-
description: Connect
|
|
2
|
+
title: A2A Agent Runtime
|
|
3
|
+
description: Connect any A2A v1.0 protocol-compliant agent server to a React chat UI with assistant-ui — full streaming, tool calls, and message metadata supported.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
`@assistant-ui/react-a2a` is a runtime adapter for the [A2A (Agent-to-Agent) v1.0 protocol](https://github.com/a2aproject/A2A). Use it when your backend speaks A2A; the adapter handles the wire protocol so you can focus on the UI.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
|
-
title:
|
|
3
|
-
description:
|
|
2
|
+
title: AG-UI Agent Runtime
|
|
3
|
+
description: Wire AG-UI (Agent-User Interaction) protocol agents into a React chat UI with assistant-ui — bidirectional events, generative UI, and human-in-the-loop.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
`@assistant-ui/react-ag-ui` is a runtime adapter for the [AG-UI (Agent-User Interaction) protocol](https://github.com/ag-ui-protocol/ag-ui). It lets your assistant-ui frontend speak to any AG-UI-compliant agent server, including CopilotKit-based backends.
|
|
@@ -62,13 +62,43 @@ const runtime = useAgUiRuntime({
|
|
|
62
62
|
});
|
|
63
63
|
```
|
|
64
64
|
|
|
65
|
+
## Interrupts (experimental)
|
|
66
|
+
|
|
67
|
+
<Callout type="warn">
|
|
68
|
+
The interrupt API is experimental and may change without notice.
|
|
69
|
+
</Callout>
|
|
70
|
+
|
|
71
|
+
When the agent emits `RUN_FINISHED` with `outcome = { type: "interrupt", interrupts: [...] }`, the active assistant message is marked `requires-action` with `reason: "interrupt"` and the `Interrupt[]` payload is written to `metadata.custom.agui.interrupts`. Render an approval / input UI from there.
|
|
72
|
+
|
|
73
|
+
`useAgUiRuntime` returns an `AgUiAssistantRuntime` with two extra methods:
|
|
74
|
+
|
|
75
|
+
| Method | Description |
|
|
76
|
+
| --- | --- |
|
|
77
|
+
| `unstable_getPendingInterrupts(): readonly AgUiInterrupt[]` | Snapshot of the open interrupts on the most recent assistant message. |
|
|
78
|
+
| `unstable_submitInterruptResponses(responses: ResumeEntry[]): Promise<void>` | Submits one `ResumeEntry` per open interrupt and resumes the run. |
|
|
79
|
+
|
|
80
|
+
`responses` must address every open interrupt; missing entries, unknown ids, or expired interrupts (`expiresAt`) reject before any network call. Each entry is `{ interruptId, status: "resolved" | "cancelled", payload? }`. The next `RunAgentInput` carries `resume: ResumeEntry[]`.
|
|
81
|
+
|
|
82
|
+
```tsx
|
|
83
|
+
const runtime = useAgUiRuntime({ agent });
|
|
84
|
+
const pending = runtime.unstable_getPendingInterrupts();
|
|
85
|
+
|
|
86
|
+
await runtime.unstable_submitInterruptResponses(
|
|
87
|
+
pending.map((i) => ({
|
|
88
|
+
interruptId: i.id,
|
|
89
|
+
status: "resolved",
|
|
90
|
+
payload: { approved: true },
|
|
91
|
+
})),
|
|
92
|
+
);
|
|
93
|
+
```
|
|
94
|
+
|
|
65
95
|
## Supported events
|
|
66
96
|
|
|
67
97
|
The runtime parses the AG-UI event stream and maps each event type to assistant-ui state.
|
|
68
98
|
|
|
69
99
|
| Event | Effect |
|
|
70
100
|
| --- | --- |
|
|
71
|
-
| `RUN_STARTED` / `RUN_FINISHED` | Toggles thread `isRunning`. |
|
|
101
|
+
| `RUN_STARTED` / `RUN_FINISHED` | Toggles thread `isRunning`. `RUN_FINISHED.outcome` is honored (success / interrupt). |
|
|
72
102
|
| `RUN_CANCELLED` | Marks the in-flight assistant message as cancelled. |
|
|
73
103
|
| `RUN_ERROR` | Marks the message as errored; fires `onError`. |
|
|
74
104
|
| `TEXT_MESSAGE_START` / `_CONTENT` / `_END` | Streams text content into an assistant message. |
|
|
@@ -98,6 +128,7 @@ The runtime parses the AG-UI event stream and maps each event type to assistant-
|
|
|
98
128
|
| Message editing | Yes |
|
|
99
129
|
| Message reload | Yes |
|
|
100
130
|
| Run resumption | Yes |
|
|
131
|
+
| Interrupts (human-in-the-loop) | Experimental (`unstable_*` API, see [Interrupts](#interrupts-experimental)) |
|
|
101
132
|
| Multi-thread | Experimental (`adapters.threadList`) |
|
|
102
133
|
| History persistence | Via [history adapter](/docs/runtimes/concepts/adapters#history-adapter) |
|
|
103
134
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
|
-
title:
|
|
3
|
-
description: Vercel AI SDK
|
|
2
|
+
title: Vercel AI SDK Runtime
|
|
3
|
+
description: Connect the Vercel AI SDK to a React chat UI via assistant-ui — useChat hooks, custom transports, frontend tools, attachments, multi-step agents, and token usage.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
import { VercelIcon } from "@/components/icons/vercel";
|
|
@@ -35,7 +35,7 @@ import { openai } from "@ai-sdk/openai";
|
|
|
35
35
|
|
|
36
36
|
export async function POST(req: Request) {
|
|
37
37
|
const { messages } = await req.json();
|
|
38
|
-
const result = streamText({ model: openai("gpt-4"), messages });
|
|
38
|
+
const result = streamText({ model: openai("gpt-5.4-nano"), messages });
|
|
39
39
|
return result.toDataStreamResponse();
|
|
40
40
|
}
|
|
41
41
|
```
|
|
@@ -53,7 +53,10 @@ import { useDataStreamRuntime } from "@assistant-ui/react-data-stream";
|
|
|
53
53
|
import { Thread } from "@/components/assistant-ui/thread";
|
|
54
54
|
|
|
55
55
|
export default function Home() {
|
|
56
|
-
const runtime = useDataStreamRuntime({
|
|
56
|
+
const runtime = useDataStreamRuntime({
|
|
57
|
+
api: "/api/chat",
|
|
58
|
+
protocol: "data-stream",
|
|
59
|
+
});
|
|
57
60
|
return (
|
|
58
61
|
<AssistantRuntimeProvider runtime={runtime}>
|
|
59
62
|
<div className="h-full">
|
|
@@ -64,6 +67,8 @@ export default function Home() {
|
|
|
64
67
|
}
|
|
65
68
|
```
|
|
66
69
|
|
|
70
|
+
AI SDK v4's `toDataStreamResponse()` emits the data stream wire format, so `protocol: "data-stream"` is required to pair with it; the default `protocol: "ui-message-stream"` expects the SSE format introduced in AI SDK v6.
|
|
71
|
+
|
|
67
72
|
</Step>
|
|
68
73
|
</Steps>
|
|
69
74
|
|
|
@@ -40,7 +40,7 @@ export const maxDuration = 30;
|
|
|
40
40
|
export async function POST(req: Request) {
|
|
41
41
|
const { messages }: { messages: Message[] } = await req.json();
|
|
42
42
|
const result = streamText({
|
|
43
|
-
model: openai("gpt-
|
|
43
|
+
model: openai("gpt-5.4-nano"),
|
|
44
44
|
messages,
|
|
45
45
|
tools: {
|
|
46
46
|
get_current_weather: tool({
|
|
@@ -254,7 +254,7 @@ export async function POST(req: Request) {
|
|
|
254
254
|
}
|
|
255
255
|
```
|
|
256
256
|
|
|
257
|
-
Frontend tools are registered through `useAui` (see the [tools guide](/docs/
|
|
257
|
+
Frontend tools are registered through `useAui` (see the [tools guide](/docs/tools/defining-tools)) and serialized for the backend via `frontendTools`.
|
|
258
258
|
|
|
259
259
|
## Multi-step tool calls
|
|
260
260
|
|
|
@@ -286,6 +286,127 @@ export async function POST(req: Request) {
|
|
|
286
286
|
|
|
287
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
288
|
|
|
289
|
+
## Server-side tool approval
|
|
290
|
+
|
|
291
|
+
AI SDK v6 lets a tool gate its own execution with `needsApproval`. The server pauses, emits an `approval-requested` part, and resumes once the client posts an approval response. assistant-ui surfaces the gate as `approval` on the tool part and adds a `respondToApproval` prop on the renderer, so tool components stay decoupled from `chatHelpers`.
|
|
292
|
+
|
|
293
|
+
On the backend, mark the tool with `needsApproval` (boolean or function):
|
|
294
|
+
|
|
295
|
+
```ts title="@/app/api/chat/route.ts"
|
|
296
|
+
import { openai } from "@ai-sdk/openai";
|
|
297
|
+
import { streamText, convertToModelMessages, tool } from "ai";
|
|
298
|
+
import { z } from "zod";
|
|
299
|
+
|
|
300
|
+
export async function POST(req: Request) {
|
|
301
|
+
const { messages } = await req.json();
|
|
302
|
+
|
|
303
|
+
const result = streamText({
|
|
304
|
+
model: openai("gpt-5.4-mini"),
|
|
305
|
+
messages: await convertToModelMessages(messages),
|
|
306
|
+
tools: {
|
|
307
|
+
deploy: tool({
|
|
308
|
+
description: "Deploy the current build to an environment.",
|
|
309
|
+
inputSchema: z.object({ target: z.string() }),
|
|
310
|
+
needsApproval: ({ input }) => input.target === "production",
|
|
311
|
+
execute: async ({ target }) => ({ deployed: target }),
|
|
312
|
+
}),
|
|
313
|
+
},
|
|
314
|
+
});
|
|
315
|
+
|
|
316
|
+
return result.toUIMessageStreamResponse();
|
|
317
|
+
}
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
On the client, configure `useChat` with `sendAutomaticallyWhen: lastAssistantMessageIsCompleteWithApprovalResponses` so the response is sent back to the server when the user decides:
|
|
321
|
+
|
|
322
|
+
```tsx title="@/app/page.tsx"
|
|
323
|
+
"use client";
|
|
324
|
+
|
|
325
|
+
import { useChat } from "@ai-sdk/react";
|
|
326
|
+
import {
|
|
327
|
+
AssistantRuntimeProvider,
|
|
328
|
+
useAISDKRuntime,
|
|
329
|
+
} from "@assistant-ui/react-ai-sdk";
|
|
330
|
+
import { lastAssistantMessageIsCompleteWithApprovalResponses } from "ai";
|
|
331
|
+
import { Thread } from "@/components/assistant-ui/thread";
|
|
332
|
+
|
|
333
|
+
export default function Page() {
|
|
334
|
+
const chat = useChat({
|
|
335
|
+
api: "/api/chat",
|
|
336
|
+
sendAutomaticallyWhen: lastAssistantMessageIsCompleteWithApprovalResponses,
|
|
337
|
+
});
|
|
338
|
+
const runtime = useAISDKRuntime(chat);
|
|
339
|
+
|
|
340
|
+
return (
|
|
341
|
+
<AssistantRuntimeProvider runtime={runtime}>
|
|
342
|
+
<Thread />
|
|
343
|
+
</AssistantRuntimeProvider>
|
|
344
|
+
);
|
|
345
|
+
}
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
Render the gate with a toolkit entry. The `approval` field carries the gate state, and `respondToApproval` is the only correct way to acknowledge it (it reads the approval id from the part):
|
|
349
|
+
|
|
350
|
+
```tsx title="@/app/page.tsx"
|
|
351
|
+
"use client";
|
|
352
|
+
|
|
353
|
+
import { useChat } from "@ai-sdk/react";
|
|
354
|
+
import {
|
|
355
|
+
AssistantRuntimeProvider,
|
|
356
|
+
Tools,
|
|
357
|
+
type Toolkit,
|
|
358
|
+
useAui,
|
|
359
|
+
} from "@assistant-ui/react";
|
|
360
|
+
import { useAISDKRuntime } from "@assistant-ui/react-ai-sdk";
|
|
361
|
+
import { lastAssistantMessageIsCompleteWithApprovalResponses } from "ai";
|
|
362
|
+
import { Thread } from "@/components/assistant-ui/thread";
|
|
363
|
+
|
|
364
|
+
const toolkit = {
|
|
365
|
+
deploy: {
|
|
366
|
+
type: "backend",
|
|
367
|
+
render: ({ args, approval, respondToApproval, result }) => {
|
|
368
|
+
if (approval?.approved === undefined) {
|
|
369
|
+
return (
|
|
370
|
+
<div>
|
|
371
|
+
<p>Approve deploy to {args.target}?</p>
|
|
372
|
+
<button onClick={() => respondToApproval({ approved: true })}>
|
|
373
|
+
Approve
|
|
374
|
+
</button>
|
|
375
|
+
<button
|
|
376
|
+
onClick={() =>
|
|
377
|
+
respondToApproval({ approved: false, reason: "user denied" })
|
|
378
|
+
}
|
|
379
|
+
>
|
|
380
|
+
Deny
|
|
381
|
+
</button>
|
|
382
|
+
</div>
|
|
383
|
+
);
|
|
384
|
+
}
|
|
385
|
+
if (approval?.approved === false) return <p>Denied</p>;
|
|
386
|
+
if (result === undefined) return <p>Approved, deploying…</p>;
|
|
387
|
+
return <p>Deployed {result.deployed}</p>;
|
|
388
|
+
},
|
|
389
|
+
},
|
|
390
|
+
} satisfies Toolkit;
|
|
391
|
+
|
|
392
|
+
export default function Page() {
|
|
393
|
+
const chat = useChat({
|
|
394
|
+
api: "/api/chat",
|
|
395
|
+
sendAutomaticallyWhen: lastAssistantMessageIsCompleteWithApprovalResponses,
|
|
396
|
+
});
|
|
397
|
+
const runtime = useAISDKRuntime(chat);
|
|
398
|
+
const aui = useAui({ tools: Tools({ toolkit }) });
|
|
399
|
+
|
|
400
|
+
return (
|
|
401
|
+
<AssistantRuntimeProvider aui={aui} runtime={runtime}>
|
|
402
|
+
<Thread />
|
|
403
|
+
</AssistantRuntimeProvider>
|
|
404
|
+
);
|
|
405
|
+
}
|
|
406
|
+
```
|
|
407
|
+
|
|
408
|
+
See the [tool UI guide](/docs/tools/tool-ui#server-side-approval-gates) for the full three-state semantics of `approval.approved` and the `isAutomatic` flag.
|
|
409
|
+
|
|
289
410
|
## Quote context
|
|
290
411
|
|
|
291
412
|
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:
|
|
@@ -491,6 +612,8 @@ const runtime = useAISDKRuntime(chat);
|
|
|
491
612
|
|
|
492
613
|
[`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
614
|
|
|
615
|
+
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`.
|
|
616
|
+
|
|
494
617
|
## Next
|
|
495
618
|
|
|
496
619
|
<Cards>
|
|
@@ -504,4 +627,9 @@ const runtime = useAISDKRuntime(chat);
|
|
|
504
627
|
description="Single-thread, AssistantCloud, custom thread list."
|
|
505
628
|
href="/docs/runtimes/concepts/threads"
|
|
506
629
|
/>
|
|
630
|
+
<Card
|
|
631
|
+
title="Resumable streams"
|
|
632
|
+
description="Survive page reloads and connection drops mid-response."
|
|
633
|
+
href="/docs/guides/resumable-streams"
|
|
634
|
+
/>
|
|
507
635
|
</Cards>
|
|
@@ -287,6 +287,12 @@ A few invariants worth knowing when wiring a custom UI on top of `loadMore()`:
|
|
|
287
287
|
description: "Persist title changes from the UI.",
|
|
288
288
|
required: true,
|
|
289
289
|
},
|
|
290
|
+
{
|
|
291
|
+
name: "updateCustom",
|
|
292
|
+
type: "(remoteId: string, custom: Record<string, unknown> | undefined) => Promise<void>",
|
|
293
|
+
description:
|
|
294
|
+
"Optional. Persist replacement custom metadata from `aui.threadListItem().updateCustom(custom)`.",
|
|
295
|
+
},
|
|
290
296
|
{
|
|
291
297
|
name: "archive",
|
|
292
298
|
type: "(remoteId: string) => Promise<void>",
|
|
@@ -355,7 +361,7 @@ function ThreadListItemMeta() {
|
|
|
355
361
|
}
|
|
356
362
|
```
|
|
357
363
|
|
|
358
|
-
`custom` is preserved across `rename`, `archive`, `unarchive`, and `generateTitle`. To
|
|
364
|
+
`custom` is preserved across `rename`, `archive`, `unarchive`, and `generateTitle`. To replace it from your UI, implement `RemoteThreadListAdapter.updateCustom` and call `aui.threadListItem().updateCustom(custom)`. The cloud adapter persists this through `cloud.threads.update(threadId, { metadata })`. If your adapter mutates thread metadata through a separate application path, return the updated values from `fetch()` or call `aui.threads().reload()` to re-run `list()`.
|
|
359
365
|
|
|
360
366
|
## ExternalStoreThreadListAdapter
|
|
361
367
|
|
|
@@ -17,6 +17,17 @@ Pick this runtime when:
|
|
|
17
17
|
|
|
18
18
|
If your backend exposes a richer state surface, consider [`AssistantTransport`](/docs/runtimes/custom/assistant-transport) instead.
|
|
19
19
|
|
|
20
|
+
## Wire protocols
|
|
21
|
+
|
|
22
|
+
`useDataStreamRuntime` accepts two wire formats via its `protocol` option:
|
|
23
|
+
|
|
24
|
+
| Protocol | Default | Matching backend |
|
|
25
|
+
| --- | --- | --- |
|
|
26
|
+
| `"ui-message-stream"` | yes | AI SDK v6's `result.toUIMessageStreamResponse()` (SSE) |
|
|
27
|
+
| `"data-stream"` | no | `createAssistantStreamResponse` from `assistant-stream`, or AI SDK v4's `toDataStreamResponse()` (Vercel data stream v1) |
|
|
28
|
+
|
|
29
|
+
Pairing the default decoder with a data stream backend throws `Stream ended abruptly without receiving [DONE] marker` at flush; pass `protocol: "data-stream"` to switch decoders.
|
|
30
|
+
|
|
20
31
|
## Install
|
|
21
32
|
|
|
22
33
|
<PlatformTabs>
|
|
@@ -55,7 +66,10 @@ import { AssistantRuntimeProvider } from "@assistant-ui/react";
|
|
|
55
66
|
import { Thread } from "@/components/assistant-ui/thread";
|
|
56
67
|
|
|
57
68
|
export default function ChatPage() {
|
|
58
|
-
const runtime = useDataStreamRuntime({
|
|
69
|
+
const runtime = useDataStreamRuntime({
|
|
70
|
+
api: "/api/chat",
|
|
71
|
+
protocol: "data-stream",
|
|
72
|
+
});
|
|
59
73
|
return (
|
|
60
74
|
<AssistantRuntimeProvider runtime={runtime}>
|
|
61
75
|
<Thread />
|
|
@@ -76,7 +90,10 @@ import { Thread } from "@/components/assistant-ui/thread";
|
|
|
76
90
|
const API_URL = process.env.EXPO_PUBLIC_API_URL ?? "http://localhost:3000";
|
|
77
91
|
|
|
78
92
|
export default function ChatPage() {
|
|
79
|
-
const runtime = useDataStreamRuntime({
|
|
93
|
+
const runtime = useDataStreamRuntime({
|
|
94
|
+
api: `${API_URL}/api/chat`,
|
|
95
|
+
protocol: "data-stream",
|
|
96
|
+
});
|
|
80
97
|
return (
|
|
81
98
|
<AssistantRuntimeProvider runtime={runtime}>
|
|
82
99
|
<View style={{ flex: 1 }}>
|
|
@@ -99,6 +116,7 @@ import { Thread } from "./components/thread.js";
|
|
|
99
116
|
export function App() {
|
|
100
117
|
const runtime = useDataStreamRuntime({
|
|
101
118
|
api: "http://localhost:3000/api/chat",
|
|
119
|
+
protocol: "data-stream",
|
|
102
120
|
});
|
|
103
121
|
return (
|
|
104
122
|
<AssistantRuntimeProvider runtime={runtime}>
|
|
@@ -139,6 +157,8 @@ export async function POST(request: Request) {
|
|
|
139
157
|
|
|
140
158
|
The request body includes `messages`, `tools`, `system` (if configured), and `threadId`.
|
|
141
159
|
|
|
160
|
+
`createAssistantStreamResponse` returns a standard Web `Response`. It drops into any Fetch-style route (Next.js App Router, Hono, Bun.serve, Deno, Cloudflare Workers) without ceremony. On frameworks that use their own response object (Express, Fastify), copy `status` and `headers` over, then pipe `response.body` into the framework's writable stream. Avoid sending the `Response` body into a `res` object whose lifecycle is already controlled by the framework (that is the `ERR_INVALID_STATE: Controller is already closed` failure mode).
|
|
161
|
+
|
|
142
162
|
</Step>
|
|
143
163
|
</Steps>
|
|
144
164
|
|
|
@@ -147,6 +167,7 @@ The request body includes `messages`, `tools`, `system` (if configured), and `th
|
|
|
147
167
|
```tsx
|
|
148
168
|
const runtime = useDataStreamRuntime({
|
|
149
169
|
api: "/api/chat",
|
|
170
|
+
protocol: "data-stream",
|
|
150
171
|
headers: { Authorization: `Bearer ${token}`, "X-Custom-Header": "value" },
|
|
151
172
|
credentials: "include",
|
|
152
173
|
});
|
|
@@ -157,6 +178,7 @@ Evaluate per-request:
|
|
|
157
178
|
```tsx
|
|
158
179
|
const runtime = useDataStreamRuntime({
|
|
159
180
|
api: "/api/chat",
|
|
181
|
+
protocol: "data-stream",
|
|
160
182
|
headers: async () => ({
|
|
161
183
|
Authorization: `Bearer ${await getAuthToken()}`,
|
|
162
184
|
}),
|
|
@@ -173,6 +195,7 @@ const runtime = useDataStreamRuntime({
|
|
|
173
195
|
```tsx
|
|
174
196
|
const runtime = useDataStreamRuntime({
|
|
175
197
|
api: "/api/chat",
|
|
198
|
+
protocol: "data-stream",
|
|
176
199
|
onResponse: (response) => console.log("status:", response.status),
|
|
177
200
|
onFinish: (message) => console.log("done:", message),
|
|
178
201
|
onError: (error) => console.error(error),
|
|
@@ -207,6 +230,7 @@ const myTools = {
|
|
|
207
230
|
|
|
208
231
|
const runtime = useDataStreamRuntime({
|
|
209
232
|
api: "/api/chat",
|
|
233
|
+
protocol: "data-stream",
|
|
210
234
|
body: { tools: toToolsJSONSchema(myTools) },
|
|
211
235
|
});
|
|
212
236
|
```
|
|
@@ -267,6 +291,7 @@ const runtime = useCloudRuntime({
|
|
|
267
291
|
```tsx
|
|
268
292
|
const runtime = useDataStreamRuntime({
|
|
269
293
|
api: "/api/chat",
|
|
294
|
+
protocol: "data-stream",
|
|
270
295
|
initialMessages: [
|
|
271
296
|
{ role: "user", content: [{ type: "text", text: "Hello" }] },
|
|
272
297
|
{ role: "assistant", content: [{ type: "text", text: "Hi!" }] },
|
|
@@ -627,7 +627,15 @@ useExternalStoreRuntime({
|
|
|
627
627
|
{
|
|
628
628
|
name: "isDisabled",
|
|
629
629
|
type: "boolean",
|
|
630
|
-
description:
|
|
630
|
+
description:
|
|
631
|
+
"Disables the entire composer, including the text input. For a narrower gate that keeps the input usable but blocks only sending, use isSendDisabled.",
|
|
632
|
+
default: "false",
|
|
633
|
+
},
|
|
634
|
+
{
|
|
635
|
+
name: "isSendDisabled",
|
|
636
|
+
type: "boolean",
|
|
637
|
+
description:
|
|
638
|
+
"Blocks new-message sending while leaving the input usable. When true, the thread composer's canSend becomes false, the Send button is disabled, Enter and the steer hotkey are no-ops, and aui.composer().send() short-circuits. Edit composers (saving message edits) ignore this flag. Use this to gate sending on external React state (e.g. while tools or auth are still loading).",
|
|
631
639
|
default: "false",
|
|
632
640
|
},
|
|
633
641
|
{
|
|
@@ -417,24 +417,35 @@ If you build the `content` array fresh from the current chunk each iteration, to
|
|
|
417
417
|
|
|
418
418
|
`LocalRuntime` supports OpenAI-compatible function calling. Register tools through `useAui` so the runtime exposes them to your adapter via `context.tools`:
|
|
419
419
|
|
|
420
|
-
```tsx
|
|
421
|
-
|
|
420
|
+
```tsx title="app/toolkit.tsx"
|
|
421
|
+
"use generative";
|
|
422
|
+
|
|
423
|
+
import { defineToolkit } from "@assistant-ui/react";
|
|
422
424
|
import { z } from "zod";
|
|
423
425
|
|
|
424
|
-
|
|
426
|
+
export default defineToolkit({
|
|
425
427
|
getWeather: {
|
|
426
428
|
description: "Get the current weather in a location",
|
|
427
429
|
parameters: z.object({
|
|
428
430
|
location: z.string(),
|
|
429
431
|
unit: z.enum(["celsius", "fahrenheit"]).default("celsius"),
|
|
430
432
|
}),
|
|
431
|
-
execute: async ({ location, unit }) =>
|
|
433
|
+
execute: async ({ location, unit }) => {
|
|
434
|
+
"use client";
|
|
435
|
+
return fetchWeather(location, unit);
|
|
436
|
+
},
|
|
437
|
+
renderText: { running: "Checking the weather…", complete: "Weather ready" },
|
|
432
438
|
},
|
|
433
|
-
};
|
|
439
|
+
});
|
|
440
|
+
```
|
|
441
|
+
|
|
442
|
+
```tsx title="app/MyRuntimeProvider.tsx"
|
|
443
|
+
import { useAui, Tools } from "@assistant-ui/react";
|
|
444
|
+
import toolkit from "./toolkit";
|
|
434
445
|
|
|
435
446
|
function MyRuntimeProvider({ children }: { children: React.ReactNode }) {
|
|
436
447
|
const runtime = useLocalRuntime(MyModelAdapter);
|
|
437
|
-
const aui = useAui({ tools: Tools({ toolkit
|
|
448
|
+
const aui = useAui({ tools: Tools({ toolkit }) });
|
|
438
449
|
|
|
439
450
|
return (
|
|
440
451
|
<AssistantRuntimeProvider aui={aui} runtime={runtime}>
|
|
@@ -444,7 +455,7 @@ function MyRuntimeProvider({ children }: { children: React.ReactNode }) {
|
|
|
444
455
|
}
|
|
445
456
|
```
|
|
446
457
|
|
|
447
|
-
See the [tools guide](/docs/
|
|
458
|
+
See the [tools guide](/docs/tools/defining-tools) for advanced patterns.
|
|
448
459
|
|
|
449
460
|
### Human-in-the-loop approval
|
|
450
461
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
|
-
title:
|
|
3
|
-
description:
|
|
2
|
+
title: Custom Runtime
|
|
3
|
+
description: Build a React chat UI for any AI backend with assistant-ui — four runtime patterns covering local state, REST, custom protocols, and external runtimes.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
If no [framework adapter](/docs/runtimes/pick-a-runtime) fits your backend, this section gives you four building blocks. All four are built on one of the two core runtimes; understanding the layering (see [architecture](/docs/runtimes/concepts/architecture)) makes the choice clear.
|