@assistant-ui/mcp-docs-server 0.1.38 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.docs/organized/code-examples/waterfall.md +11 -12
- package/.docs/organized/code-examples/with-a2a.md +18 -13
- package/.docs/organized/code-examples/with-ag-ui.md +19 -14
- package/.docs/organized/code-examples/{with-ai-sdk-v6.md → with-ai-sdk-v7.md} +34 -23
- package/.docs/organized/code-examples/with-artifacts.md +473 -141
- package/.docs/organized/code-examples/with-assistant-transport.md +17 -10
- package/.docs/organized/code-examples/with-browser-extension.md +17 -10
- package/.docs/organized/code-examples/with-chain-of-thought.md +21 -14
- package/.docs/organized/code-examples/with-cloud-standalone.md +12 -11
- package/.docs/organized/code-examples/with-cloud.md +20 -15
- package/.docs/organized/code-examples/with-custom-thread-list.md +19 -12
- package/.docs/organized/code-examples/with-elevenlabs-conversational.md +22 -15
- package/.docs/organized/code-examples/with-elevenlabs-scribe.md +22 -15
- package/.docs/organized/code-examples/with-eve.md +18 -11
- package/.docs/organized/code-examples/with-expo.md +35 -52
- package/.docs/organized/code-examples/with-external-store.md +18 -13
- package/.docs/organized/code-examples/with-ffmpeg.md +20 -15
- package/.docs/organized/code-examples/with-generative-ui.md +22 -17
- package/.docs/organized/code-examples/with-google-adk.md +18 -11
- package/.docs/organized/code-examples/with-heat-graph.md +10 -11
- package/.docs/organized/code-examples/with-image-generation.md +19 -12
- package/.docs/organized/code-examples/with-interactables.md +21 -17
- package/.docs/organized/code-examples/with-langchain.md +19 -12
- package/.docs/organized/code-examples/with-langgraph.md +19 -12
- package/.docs/organized/code-examples/with-livekit.md +23 -16
- package/.docs/organized/code-examples/with-mcp.md +46 -28
- package/.docs/organized/code-examples/with-opencode.md +25 -23
- package/.docs/organized/code-examples/with-pi.md +54 -19
- package/.docs/organized/code-examples/with-react-hook-form.md +21 -16
- package/.docs/organized/code-examples/with-react-ink-web.md +9 -9
- package/.docs/organized/code-examples/with-react-ink.md +4 -4
- package/.docs/organized/code-examples/with-react-router.md +22 -17
- package/.docs/organized/code-examples/with-resumable-stream.md +21 -14
- package/.docs/organized/code-examples/with-store.md +10 -11
- package/.docs/organized/code-examples/with-tanstack.md +19 -13
- package/.docs/organized/code-examples/with-tap-runtime.md +18 -13
- package/.docs/organized/code-examples/with-virtualized-thread.md +19 -14
- package/.docs/raw/docs/(docs)/base-ui.mdx +39 -0
- package/.docs/raw/docs/(docs)/cli.mdx +19 -1
- package/.docs/raw/docs/(docs)/devtools.mdx +7 -2
- package/.docs/raw/docs/(docs)/installation.mdx +15 -1
- package/.docs/raw/docs/(docs)/rtl.mdx +2 -4
- package/.docs/raw/docs/(reference)/api-reference/generative-ui/a2ui.mdx +40 -0
- package/.docs/raw/docs/(reference)/api-reference/generative-ui/actions.mdx +56 -0
- package/.docs/raw/docs/(reference)/api-reference/generative-ui/components.mdx +86 -0
- package/.docs/raw/docs/(reference)/api-reference/generative-ui/index.mdx +22 -1
- package/.docs/raw/docs/(reference)/api-reference/generative-ui/json-generative-ui.mdx +42 -0
- package/.docs/raw/docs/(reference)/api-reference/generative-ui/rendering.mdx +53 -2
- package/.docs/raw/docs/(reference)/api-reference/generative-ui/slack.mdx +81 -0
- package/.docs/raw/docs/(reference)/api-reference/generative-ui/teams.mdx +86 -0
- package/.docs/raw/docs/(reference)/api-reference/generative-ui/tokens.mdx +62 -0
- package/.docs/raw/docs/(reference)/api-reference/hooks/primitives.mdx +19 -420
- package/.docs/raw/docs/(reference)/api-reference/hooks/state.mdx +4 -1
- package/.docs/raw/docs/(reference)/api-reference/integrations/index.mdx +4 -1
- package/.docs/raw/docs/(reference)/api-reference/integrations/react-ai-sdk.mdx +25 -2
- package/.docs/raw/docs/(reference)/api-reference/integrations/react-data-stream.mdx +37 -0
- package/.docs/raw/docs/(reference)/api-reference/model-context/context.mdx +1 -9
- package/.docs/raw/docs/(reference)/api-reference/overview.mdx +1 -0
- package/.docs/raw/docs/(reference)/api-reference/primitives/assistant-if.mdx +14 -31
- package/.docs/raw/docs/(reference)/api-reference/primitives/composition.mdx +1 -0
- package/.docs/raw/docs/(reference)/api-reference/primitives/index.mdx +3 -0
- package/.docs/raw/docs/(reference)/api-reference/primitives/selection-toolbar.mdx +2 -0
- package/.docs/raw/docs/(reference)/api-reference/tools/status.mdx +0 -2
- package/.docs/raw/docs/(reference)/api-reference/tools/toolkits.mdx +12 -9
- package/.docs/raw/docs/(reference)/api-reference/utilities/miscellaneous.mdx +4 -0
- package/.docs/raw/docs/cloud/ai-sdk-assistant-ui.mdx +7 -1
- package/.docs/raw/docs/cloud/langgraph.mdx +4 -2
- package/.docs/raw/docs/copilots/model-context.mdx +1 -1
- package/.docs/raw/docs/copilots/motivation.mdx +1 -1
- package/.docs/raw/docs/guides/attachments.mdx +3 -3
- package/.docs/raw/docs/guides/branching.mdx +2 -2
- package/.docs/raw/docs/guides/chatgpt-subscription.mdx +108 -0
- package/.docs/raw/docs/guides/context-api.mdx +89 -111
- package/.docs/raw/docs/guides/dictation.mdx +185 -257
- package/.docs/raw/docs/guides/editing.mdx +5 -5
- package/.docs/raw/docs/guides/electron.mdx +369 -0
- package/.docs/raw/docs/guides/index.mdx +20 -0
- package/.docs/raw/docs/guides/mentions.mdx +31 -3
- package/.docs/raw/docs/guides/quoting.mdx +3 -3
- package/.docs/raw/docs/guides/resumable-stream-deployment.mdx +2 -2
- package/.docs/raw/docs/guides/resumable-streams.mdx +12 -1
- package/.docs/raw/docs/guides/speech.mdx +47 -29
- package/.docs/raw/docs/guides/suggestions.mdx +70 -1
- package/.docs/raw/docs/guides/voice.mdx +197 -267
- package/.docs/raw/docs/ink/hooks.mdx +3 -3
- package/.docs/raw/docs/ink/primitives.mdx +49 -8
- package/.docs/raw/docs/integrations/auth/better-auth.mdx +2 -2
- package/.docs/raw/docs/integrations/auth/clerk.mdx +2 -2
- package/.docs/raw/docs/integrations/auth/next-auth.mdx +3 -3
- package/.docs/raw/docs/integrations/frameworks/ai-sdk.mdx +10 -4
- package/.docs/raw/docs/integrations/frameworks/cloudflare-agents/overview.mdx +3 -3
- package/.docs/raw/docs/integrations/frameworks/mastra/full-stack.mdx +1 -1
- package/.docs/raw/docs/integrations/frameworks/mastra/overview.mdx +3 -3
- package/.docs/raw/docs/integrations/frameworks/mastra/separate-server.mdx +1 -1
- package/.docs/raw/docs/integrations/gateways/index.mdx +2 -2
- package/.docs/raw/docs/integrations/observability/helicone.mdx +1 -1
- package/.docs/raw/docs/integrations/observability/langfuse.mdx +1 -1
- package/.docs/raw/docs/integrations/observability/langsmith.mdx +2 -2
- package/.docs/raw/docs/integrations/persistence/custom-adapter.mdx +36 -9
- package/.docs/raw/docs/migrations/index.mdx +50 -0
- package/.docs/raw/docs/migrations/toolkit-tools.mdx +4 -2
- package/.docs/raw/docs/migrations/v0-15.mdx +156 -0
- package/.docs/raw/docs/primitives/chain-of-thought.mdx +6 -1
- package/.docs/raw/docs/primitives/composer.mdx +17 -1
- package/.docs/raw/docs/primitives/selection-toolbar.mdx +25 -0
- package/.docs/raw/docs/primitives/thread-list.mdx +2 -2
- package/.docs/raw/docs/react-native/hooks.mdx +3 -3
- package/.docs/raw/docs/react-native/index.mdx +2 -2
- package/.docs/raw/docs/react-native/primitives.mdx +62 -5
- package/.docs/raw/docs/runtimes/ag-ui/agent-state.mdx +124 -0
- package/.docs/raw/docs/runtimes/ag-ui/runtime-options.mdx +10 -1
- package/.docs/raw/docs/runtimes/ai-sdk/overview.mdx +14 -5
- package/.docs/raw/docs/runtimes/ai-sdk/v4-legacy.mdx +15 -15
- package/.docs/raw/docs/runtimes/ai-sdk/v5-legacy.mdx +8 -8
- package/.docs/raw/docs/runtimes/ai-sdk/{v6.mdx → v6-legacy.mdx} +11 -9
- package/.docs/raw/docs/runtimes/ai-sdk/v7.mdx +717 -0
- package/.docs/raw/docs/runtimes/concepts/adapters.mdx +1 -1
- package/.docs/raw/docs/runtimes/concepts/architecture.mdx +1 -1
- package/.docs/raw/docs/runtimes/concepts/threads.mdx +10 -10
- package/.docs/raw/docs/runtimes/custom/assistant-transport.mdx +2 -2
- package/.docs/raw/docs/runtimes/custom/data-stream.mdx +10 -19
- package/.docs/raw/docs/runtimes/custom/external-store.mdx +2 -2
- package/.docs/raw/docs/runtimes/custom/local-runtime.mdx +5 -3
- package/.docs/raw/docs/runtimes/eve/overview.mdx +1 -1
- package/.docs/raw/docs/runtimes/langchain.mdx +2 -2
- package/.docs/raw/docs/runtimes/langgraph/agent-state.mdx +181 -0
- package/.docs/raw/docs/runtimes/langgraph/overview.mdx +1 -1
- package/.docs/raw/docs/runtimes/opencode/hooks.mdx +3 -1
- package/.docs/raw/docs/tools/a2ui.mdx +107 -0
- package/.docs/raw/docs/tools/backend.mdx +6 -3
- package/.docs/raw/docs/tools/defining-tools.mdx +7 -1
- package/.docs/raw/docs/tools/generative-ui.mdx +60 -2
- package/.docs/raw/docs/tools/interactables-legacy.mdx +4 -4
- package/.docs/raw/docs/tools/interactables.mdx +3 -3
- package/.docs/raw/docs/tools/mcp-apps.mdx +90 -13
- package/.docs/raw/docs/tools/mcp.mdx +100 -3
- package/.docs/raw/docs/tools/tool-ui.mdx +6 -4
- package/.docs/raw/docs/tools/user-managed-mcp.mdx +77 -9
- package/.docs/raw/docs/ui/accordion.mdx +16 -10
- package/.docs/raw/docs/ui/assistant-modal.mdx +8 -4
- package/.docs/raw/docs/ui/attachment.mdx +5 -1
- package/.docs/raw/docs/ui/badge.mdx +23 -12
- package/.docs/raw/docs/ui/follow-up-suggestions.mdx +4 -2
- package/.docs/raw/docs/ui/model-selector.mdx +33 -3
- package/.docs/raw/docs/ui/part-grouping.mdx +0 -4
- package/.docs/raw/docs/ui/reasoning.mdx +1 -1
- package/.docs/raw/docs/ui/select.mdx +22 -14
- package/.docs/raw/docs/ui/sources.mdx +1 -1
- package/.docs/raw/docs/ui/tabs.mdx +25 -14
- package/.docs/raw/docs/utilities/heat-graph.mdx +2 -2
- package/dist/constants.d.ts.map +1 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +41 -2
- package/dist/index.js.map +1 -1
- package/dist/prepare-docs/code-examples.d.ts.map +1 -1
- package/dist/prepare-docs/code-examples.js.map +1 -1
- package/dist/prepare-docs/copy-raw.d.ts.map +1 -1
- package/dist/prepare-docs/prepare.d.ts +1 -1
- package/dist/prompts/xulux-playground.d.ts +12 -0
- package/dist/prompts/xulux-playground.d.ts.map +1 -0
- package/dist/prompts/xulux-playground.js +33 -0
- package/dist/prompts/xulux-playground.js.map +1 -0
- package/dist/stdio.d.ts +1 -1
- package/dist/tools/docs.d.ts +8 -14
- package/dist/tools/docs.d.ts.map +1 -1
- package/dist/tools/docs.js +26 -10
- package/dist/tools/docs.js.map +1 -1
- package/dist/tools/examples.d.ts +6 -12
- package/dist/tools/examples.d.ts.map +1 -1
- package/dist/tools/examples.js +11 -8
- package/dist/tools/examples.js.map +1 -1
- package/dist/tools/resources.d.ts +1 -2
- package/dist/tools/resources.d.ts.map +1 -1
- package/dist/tools/resources.js +1 -1
- package/dist/tools/resources.js.map +1 -1
- package/dist/tools/search.d.ts +6 -15
- package/dist/tools/search.d.ts.map +1 -1
- package/dist/tools/search.js +2 -2
- package/dist/tools/search.js.map +1 -1
- package/dist/tools/tests/mcp-test-client.d.ts +15 -0
- package/dist/tools/tests/mcp-test-client.d.ts.map +1 -0
- package/dist/tools/tests/mcp-test-client.js +68 -0
- package/dist/tools/tests/mcp-test-client.js.map +1 -0
- package/dist/tools/tests/test-setup.d.ts.map +1 -1
- package/dist/tools/tests/test-setup.js +5 -1
- package/dist/tools/tests/test-setup.js.map +1 -1
- package/dist/tools/xulux-templates.d.ts +58 -0
- package/dist/tools/xulux-templates.d.ts.map +1 -0
- package/dist/tools/xulux-templates.js +82 -0
- package/dist/tools/xulux-templates.js.map +1 -0
- package/dist/utils/cache.d.ts +5 -0
- package/dist/utils/cache.d.ts.map +1 -0
- package/dist/utils/cache.js +18 -0
- package/dist/utils/cache.js.map +1 -0
- package/dist/utils/logger.d.ts.map +1 -1
- package/dist/utils/mcp-format.d.ts +1 -0
- package/dist/utils/mcp-format.d.ts.map +1 -1
- package/dist/utils/mcp-format.js +7 -4
- package/dist/utils/mcp-format.js.map +1 -1
- package/dist/utils/mdx.d.ts.map +1 -1
- package/dist/utils/paths.d.ts +1 -1
- package/dist/utils/paths.d.ts.map +1 -1
- package/dist/utils/paths.js +3 -1
- package/dist/utils/paths.js.map +1 -1
- package/dist/utils/search.d.ts.map +1 -1
- package/dist/utils/security.d.ts.map +1 -1
- package/dist/utils/security.js.map +1 -1
- package/dist/xulux/catalog-client.d.ts +14 -0
- package/dist/xulux/catalog-client.d.ts.map +1 -0
- package/dist/xulux/catalog-client.js +67 -0
- package/dist/xulux/catalog-client.js.map +1 -0
- package/dist/xulux/fallback-catalog.d.ts +7 -0
- package/dist/xulux/fallback-catalog.d.ts.map +1 -0
- package/dist/xulux/fallback-catalog.js +47 -0
- package/dist/xulux/fallback-catalog.js.map +1 -0
- package/dist/xulux/fetch-sandbox.d.ts +5 -0
- package/dist/xulux/fetch-sandbox.d.ts.map +1 -0
- package/dist/xulux/fetch-sandbox.js +40 -0
- package/dist/xulux/fetch-sandbox.js.map +1 -0
- package/dist/xulux/template-service.d.ts +84 -0
- package/dist/xulux/template-service.d.ts.map +1 -0
- package/dist/xulux/template-service.js +223 -0
- package/dist/xulux/template-service.js.map +1 -0
- package/dist/xulux/types.d.ts +55 -0
- package/dist/xulux/types.d.ts.map +1 -0
- package/dist/xulux/types.js +6 -0
- package/dist/xulux/types.js.map +1 -0
- package/package.json +7 -6
- package/src/index.ts +55 -2
- package/src/prompts/xulux-playground.ts +36 -0
- package/src/tools/docs.ts +27 -5
- package/src/tools/examples.ts +17 -12
- package/src/tools/resources.ts +1 -4
- package/src/tools/search.ts +2 -2
- package/src/tools/tests/completions.test.ts +40 -26
- package/src/tools/tests/docs.test.ts +20 -0
- package/src/tools/tests/examples.test.ts +5 -5
- package/src/tools/tests/integration.test.ts +3 -4
- package/src/tools/tests/listings-cache.test.ts +19 -0
- package/src/tools/tests/mcp-protocol.test.ts +173 -108
- package/src/tools/tests/mcp-test-client.ts +111 -0
- package/src/tools/tests/resources.test.ts +97 -66
- package/src/tools/tests/test-setup.ts +8 -0
- package/src/tools/tests/xulux-templates.test.ts +262 -0
- package/src/tools/xulux-templates.ts +141 -0
- package/src/utils/cache.ts +20 -0
- package/src/utils/mcp-format.ts +8 -6
- package/src/utils/paths.ts +4 -1
- package/src/utils/tests/cache.test.ts +51 -0
- package/src/utils/tests/mcp-format.test.ts +22 -0
- package/src/utils/tests/security.test.ts +1 -1
- package/src/xulux/catalog-client.ts +105 -0
- package/src/xulux/fallback-catalog.ts +63 -0
- package/src/xulux/fetch-sandbox.ts +56 -0
- package/src/xulux/template-service.ts +406 -0
- package/src/xulux/types.ts +60 -0
- package/.docs/raw/docs/(reference)/api-reference/hooks/utilities.mdx +0 -464
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Migration to v0.15
|
|
3
|
+
description: Drops the v0.12-era legacy runtime hooks, the deprecated tools map, and the "mcp-app" group key. Scope accessors become properties.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Version 0.15 finishes the deprecation cycle started in v0.12: the legacy context hooks are removed in favor of `useAui` / `useAuiState`, and `aui` scope accessors become properties.
|
|
7
|
+
|
|
8
|
+
## Migrate with an AI Agent
|
|
9
|
+
|
|
10
|
+
Paste this into an AI coding agent to run the migration for you:
|
|
11
|
+
|
|
12
|
+
```text
|
|
13
|
+
Migrate this codebase from assistant-ui v0.14 to v0.15.
|
|
14
|
+
|
|
15
|
+
1. Read the migration guide: https://assistant-ui.com/docs/migrations/v0-15
|
|
16
|
+
2. Run `npx assistant-ui@latest upgrade` to apply the codemods.
|
|
17
|
+
3. Apply the remaining changes from the guide by hand:
|
|
18
|
+
- Replace removed legacy hooks with the useAui / useAuiState
|
|
19
|
+
equivalents from the guide's mapping table.
|
|
20
|
+
- Replace availability checks with `aui.<scope>.source != null`.
|
|
21
|
+
- Replace `s.tools.tools` reads with `s.tools.toolUIs`.
|
|
22
|
+
- Replace the "mcp-app" groupPartByType key with "standalone-tool-call".
|
|
23
|
+
4. Typecheck, build, and run tests; fix any remaining fallout.
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Automatic Migration
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
npx assistant-ui@latest upgrade
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
This runs the `v0-15/aui-accessor-calls-to-properties` codemod, which rewrites nullary accessor calls (`aui.thread()`) to property access (`aui.thread`).
|
|
33
|
+
|
|
34
|
+
## Scope Accessors Are Properties
|
|
35
|
+
|
|
36
|
+
Nullary scope accessors are now properties. Calling them still works but is deprecated:
|
|
37
|
+
|
|
38
|
+
```ts
|
|
39
|
+
// Before
|
|
40
|
+
aui.thread().getState();
|
|
41
|
+
aui.threads().switchToNewThread();
|
|
42
|
+
|
|
43
|
+
// After
|
|
44
|
+
aui.thread.getState();
|
|
45
|
+
aui.threads.switchToNewThread();
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Selecting an unavailable scope no longer throws: `aui.thread` always succeeds and is always truthy. Its `source` is `null` when the scope is unavailable, and any other property read (or a call) throws. Check availability via:
|
|
49
|
+
|
|
50
|
+
```ts
|
|
51
|
+
if (aui.thread.source != null) {
|
|
52
|
+
// scope is available
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Accessors expose `source`, `query`, and `name` selection metadata as properties — previously found on the accessor function, now on the same names on the proxy. These three names are reserved and never resolve to scope methods.
|
|
57
|
+
|
|
58
|
+
## Legacy Context Hooks Removed
|
|
59
|
+
|
|
60
|
+
The v0.12-era runtime hooks are removed. Replace state reads with `useAuiState` and actions with `useAui`:
|
|
61
|
+
|
|
62
|
+
| Removed | Replacement |
|
|
63
|
+
| ------------------------------------------------------------- | ----------------------------------------------- |
|
|
64
|
+
| `useAssistantRuntime()` | `useAui()` |
|
|
65
|
+
| `useThreadList(selector)` | `useAuiState((s) => s.threads)` |
|
|
66
|
+
| `useThreadRuntime()` | `useAui().thread` |
|
|
67
|
+
| `useThread(selector)` | `useAuiState((s) => s.thread)` |
|
|
68
|
+
| `useThreadComposer(selector)` | `useAuiState((s) => s.thread.composer)` |
|
|
69
|
+
| `useThreadModelContext(selector)` | `useAuiState((s) => s.thread.modelContext)` |
|
|
70
|
+
| `useMessageRuntime()` | `useAui().message` |
|
|
71
|
+
| `useMessage(selector)` | `useAuiState((s) => s.message)` |
|
|
72
|
+
| `useEditComposer(selector)` | `useAuiState((s) => s.message.composer)` |
|
|
73
|
+
| `useComposerRuntime()` | `useAui().composer` |
|
|
74
|
+
| `useComposer(selector)` | `useAuiState((s) => s.composer)` |
|
|
75
|
+
| `useMessagePartRuntime()` | `useAui().part` |
|
|
76
|
+
| `useMessagePart(selector)` | `useAuiState((s) => s.part)` |
|
|
77
|
+
| `useAttachmentRuntime()` | `useAui().attachment` |
|
|
78
|
+
| `useAttachment(selector)` | `useAuiState((s) => s.attachment)` |
|
|
79
|
+
| `useThreadListItemRuntime()` | `useAui().threadListItem` |
|
|
80
|
+
| `useThreadListItem(selector)` | `useAuiState((s) => s.threadListItem)` |
|
|
81
|
+
|
|
82
|
+
The attachment variants (`useThreadComposerAttachment(Runtime)`, `useEditComposerAttachment(Runtime)`, `useMessageAttachment(Runtime)`) are removed with them; use `useAui().attachment` / `useAuiState((s) => s.attachment)`.
|
|
83
|
+
|
|
84
|
+
```tsx
|
|
85
|
+
// Before
|
|
86
|
+
const runtime = useAssistantRuntime();
|
|
87
|
+
const isRunning = useThread((s) => s.isRunning);
|
|
88
|
+
runtime.threads.switchToNewThread();
|
|
89
|
+
|
|
90
|
+
// After
|
|
91
|
+
const aui = useAui();
|
|
92
|
+
const isRunning = useAuiState((s) => s.thread.isRunning);
|
|
93
|
+
aui.threads.switchToNewThread();
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## `ToolsState.tools` Removed
|
|
97
|
+
|
|
98
|
+
The component-only tool-UI map is replaced by `toolUIs`, whose entries carry the renderer alongside its presentation options:
|
|
99
|
+
|
|
100
|
+
```tsx
|
|
101
|
+
// Before
|
|
102
|
+
const Render = useAuiState((s) => s.tools.tools[toolName]?.[0]);
|
|
103
|
+
|
|
104
|
+
// After
|
|
105
|
+
const Render = useAuiState((s) => s.tools.toolUIs[toolName]?.[0]?.render);
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## `"mcp-app"` Group Key Removed
|
|
109
|
+
|
|
110
|
+
`groupPartByType` no longer accepts the `"mcp-app"` key. Use `"standalone-tool-call"`, a superset that matches MCP-app tool calls plus any tool call whose registered UI opts into standalone display:
|
|
111
|
+
|
|
112
|
+
```tsx
|
|
113
|
+
// Before
|
|
114
|
+
groupPartByType({
|
|
115
|
+
"tool-call": ["group-tool"],
|
|
116
|
+
"mcp-app": [],
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
// After
|
|
120
|
+
groupPartByType({
|
|
121
|
+
"tool-call": ["group-tool"],
|
|
122
|
+
"standalone-tool-call": [],
|
|
123
|
+
});
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## `useAui` `{ parent }` Config Removed
|
|
127
|
+
|
|
128
|
+
The second argument (`useAui(clients, { parent })`) is removed. Provide the parent via context instead: wrap with `AuiProvider` and call the context form beneath it.
|
|
129
|
+
|
|
130
|
+
```tsx
|
|
131
|
+
// Before
|
|
132
|
+
const aui = useAui(scopes, { parent });
|
|
133
|
+
|
|
134
|
+
// After
|
|
135
|
+
const Scoped = ({ children }) => {
|
|
136
|
+
const aui = useAui(scopes); // extends the AuiProvider parent
|
|
137
|
+
return <AuiProvider value={aui}>{children}</AuiProvider>;
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
<AuiProvider value={parent}>
|
|
141
|
+
<Scoped />
|
|
142
|
+
</AuiProvider>;
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
Where `{ parent: null }` was used to detach from context, `<AuiProvider value={null}>` now provides an isolated empty root (experimental).
|
|
146
|
+
|
|
147
|
+
## Still Deprecated (not removed)
|
|
148
|
+
|
|
149
|
+
- Primitive `If` components (`ThreadPrimitive.If`, `MessagePrimitive.If`, `ThreadPrimitive.Empty`) — replaced by `AuiIf`. The codemod migrates these.
|
|
150
|
+
- `useMessagePartText` / `useMessagePartReasoning` / `useMessagePartSource` / `useMessagePartImage` / `useMessagePartFile` / `useMessagePartData` — use `useAuiState` to select and narrow `s.part`.
|
|
151
|
+
- The `components` prop on primitives — replaced by the children render function pattern (see the [v0.14 guide](/docs/migrations/v0-14)).
|
|
152
|
+
|
|
153
|
+
## Getting Help
|
|
154
|
+
|
|
155
|
+
- File issues at https://github.com/assistant-ui/assistant-ui/issues
|
|
156
|
+
- See the [deprecation policy](/docs/migrations/deprecation-policy) for the support window
|
|
@@ -5,6 +5,8 @@ platforms: ["react"]
|
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
import { ChainOfThoughtPrimitiveSample } from "@/components/docs/samples/chain-of-thought-primitive";
|
|
8
|
+
import { ChainOfThoughtPrimitiveSample as ChainOfThoughtPrimitiveSampleRadix } from "@/components/docs/samples/chain-of-thought-primitive.radix";
|
|
9
|
+
import { Flavored } from "@/components/docs/contexts/flavor.server";
|
|
8
10
|
import {
|
|
9
11
|
ChainOfThoughtPrimitive as ChainOfThoughtPrimitiveDocs,
|
|
10
12
|
MessagePrimitive as MessagePrimitiveDocs,
|
|
@@ -18,7 +20,10 @@ For new grouped reasoning/tool-call UI, use `MessagePrimitive.GroupedParts`. `Ch
|
|
|
18
20
|
|
|
19
21
|
<Tabs items={["Preview", "Code"]}>
|
|
20
22
|
<Tab>
|
|
21
|
-
<
|
|
23
|
+
<Flavored
|
|
24
|
+
base={<ChainOfThoughtPrimitiveSample />}
|
|
25
|
+
radix={<ChainOfThoughtPrimitiveSampleRadix />}
|
|
26
|
+
/>
|
|
22
27
|
</Tab>
|
|
23
28
|
<Tab>
|
|
24
29
|
```tsx
|
|
@@ -165,6 +165,22 @@ Form container for message composition. Renders a `<form>` element unless `asChi
|
|
|
165
165
|
</ComposerPrimitive.Root>
|
|
166
166
|
```
|
|
167
167
|
|
|
168
|
+
#### Compact Mode
|
|
169
|
+
|
|
170
|
+
Pass `compact` to opt into compact detection. While the input holds at most a single line of text and the composer has no attachments, quote, queued messages, or active dictation, the root renders a `data-compact` attribute. The prop only exposes this attribute for styling — it does not change the layout by itself. Target it with CSS to collapse the composer into a single row:
|
|
171
|
+
|
|
172
|
+
```tsx
|
|
173
|
+
<ComposerPrimitive.Root
|
|
174
|
+
compact
|
|
175
|
+
className="group/composer flex flex-col data-[compact]:flex-row data-[compact]:items-center"
|
|
176
|
+
>
|
|
177
|
+
<ComposerPrimitive.Input placeholder="Ask anything..." />
|
|
178
|
+
<ComposerPrimitive.Send>Send</ComposerPrimitive.Send>
|
|
179
|
+
</ComposerPrimitive.Root>
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
Once the text wraps onto a second line, the composer expands and stays expanded until the input is cleared, so the layout doesn't oscillate at the wrap boundary.
|
|
183
|
+
|
|
168
184
|
### Input
|
|
169
185
|
|
|
170
186
|
Text input with keyboard shortcuts. Renders a `<textarea>` element unless `asChild` is set.
|
|
@@ -554,7 +570,7 @@ When `isSendDisabled` is `true`:
|
|
|
554
570
|
- `composer.canSend` becomes `false`
|
|
555
571
|
- `<ComposerPrimitive.Send>` is disabled
|
|
556
572
|
- Enter and the `Cmd/Ctrl+Shift+Enter` steer hotkey become no-ops
|
|
557
|
-
- `aui.composer
|
|
573
|
+
- `aui.composer.send()` short-circuits at the runtime, so direct calls cannot escape the gate
|
|
558
574
|
|
|
559
575
|
Read the same flag from React with `<AuiIf>` to render hints alongside the input:
|
|
560
576
|
|
|
@@ -63,6 +63,31 @@ The toolbar only appears when the selection is entirely within a single message.
|
|
|
63
63
|
|
|
64
64
|
`Root` returns `null` when there is no valid selection (collapsed selection, empty text, or no single-message match).
|
|
65
65
|
|
|
66
|
+
### Quote Regions
|
|
67
|
+
|
|
68
|
+
By default, any selected text inside a message can be quoted. For rich messages with tool cards, attachments, or custom controls, add `data-aui-quote-selectable` to the element that contains the message text. Once a message has a quote-selectable region, selections must stay inside the same marked region for the toolbar to appear.
|
|
69
|
+
|
|
70
|
+
```tsx
|
|
71
|
+
<MessagePrimitive.Root>
|
|
72
|
+
<div data-aui-quote-selectable="">
|
|
73
|
+
<MessagePrimitive.Parts />
|
|
74
|
+
</div>
|
|
75
|
+
<ToolCard />
|
|
76
|
+
</MessagePrimitive.Root>
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Set `data-aui-quote-selectable="false"` to exclude an element instead: on the message root it disables quoting for the entire message, and inside a quotable region it carves that subtree out. The nearest marker wins, and any value other than `"false"` (including empty) marks a quotable region.
|
|
80
|
+
|
|
81
|
+
Apps know the message role at render time, so a role gate is a conditional attribute:
|
|
82
|
+
|
|
83
|
+
```tsx
|
|
84
|
+
const UserMessage = () => (
|
|
85
|
+
<MessagePrimitive.Root data-aui-quote-selectable="false">
|
|
86
|
+
<MessagePrimitive.Parts />
|
|
87
|
+
</MessagePrimitive.Root>
|
|
88
|
+
);
|
|
89
|
+
```
|
|
90
|
+
|
|
66
91
|
### Quote Action
|
|
67
92
|
|
|
68
93
|
The `Quote` button does two things on click:
|
|
@@ -253,7 +253,7 @@ Button that appends the next page of threads. Renders a `<button>` element unles
|
|
|
253
253
|
</ThreadListPrimitive.LoadMore>
|
|
254
254
|
```
|
|
255
255
|
|
|
256
|
-
For scroll-driven loading, wrap `aui.threads
|
|
256
|
+
For scroll-driven loading, wrap `aui.threads.loadMore()` in your own `IntersectionObserver` at the application layer; assistant-ui ships the explicit button to keep the primitive surface predictable.
|
|
257
257
|
|
|
258
258
|
```tsx
|
|
259
259
|
import { useAui, useAuiState } from "@assistant-ui/react";
|
|
@@ -271,7 +271,7 @@ function LoadMoreSentinel() {
|
|
|
271
271
|
const el = ref.current;
|
|
272
272
|
if (!el || disabled) return;
|
|
273
273
|
const observer = new IntersectionObserver(([entry]) => {
|
|
274
|
-
if (entry?.isIntersecting) aui.threads
|
|
274
|
+
if (entry?.isIntersecting) aui.threads.loadMore();
|
|
275
275
|
});
|
|
276
276
|
observer.observe(el);
|
|
277
277
|
return () => observer.disconnect();
|
|
@@ -41,11 +41,11 @@ import { useAui } from "@assistant-ui/react-native";
|
|
|
41
41
|
const aui = useAui();
|
|
42
42
|
|
|
43
43
|
// Composer actions
|
|
44
|
-
aui.composer
|
|
45
|
-
aui.composer
|
|
44
|
+
aui.composer.setText("Hello");
|
|
45
|
+
aui.composer.send();
|
|
46
46
|
|
|
47
47
|
// Thread actions
|
|
48
|
-
aui.thread
|
|
48
|
+
aui.thread.cancelRun();
|
|
49
49
|
```
|
|
50
50
|
|
|
51
51
|
### useAuiEvent
|
|
@@ -197,7 +197,7 @@ function Composer() {
|
|
|
197
197
|
>
|
|
198
198
|
<TextInput
|
|
199
199
|
value={text}
|
|
200
|
-
onChangeText={(t) => aui.composer
|
|
200
|
+
onChangeText={(t) => aui.composer.setText(t)}
|
|
201
201
|
placeholder="Message..."
|
|
202
202
|
multiline
|
|
203
203
|
style={{
|
|
@@ -211,7 +211,7 @@ function Composer() {
|
|
|
211
211
|
}}
|
|
212
212
|
/>
|
|
213
213
|
<Pressable
|
|
214
|
-
onPress={() => aui.composer
|
|
214
|
+
onPress={() => aui.composer.send()}
|
|
215
215
|
disabled={isEmpty}
|
|
216
216
|
style={{
|
|
217
217
|
marginLeft: 8,
|
|
@@ -31,7 +31,9 @@ Container `View` for the thread area.
|
|
|
31
31
|
|
|
32
32
|
### ThreadPrimitive.Messages
|
|
33
33
|
|
|
34
|
-
`FlatList`-based message list
|
|
34
|
+
Deprecated `FlatList`-based message list kept for backwards compatibility. It uses `ThreadPrimitive.MessagesFlatList` internally, but keeps the previous no-auto-scroll default so existing apps with custom scroll handling do not change behavior on upgrade.
|
|
35
|
+
|
|
36
|
+
Use `ThreadPrimitive.MessagesFlatList` for new React Native threads.
|
|
35
37
|
|
|
36
38
|
```tsx
|
|
37
39
|
<ThreadPrimitive.Messages>
|
|
@@ -53,7 +55,29 @@ You can also provide role-specific components:
|
|
|
53
55
|
| Prop | Type | Description |
|
|
54
56
|
|------|------|-------------|
|
|
55
57
|
| `components` | `MessageComponents` | Component map — provide either a `Message` component (used for all roles) or role-specific `UserMessage`, `AssistantMessage`, and optionally `SystemMessage`. Edit composers can be set via `EditComposer` or role-specific variants (`UserEditComposer`, `AssistantEditComposer`, `SystemEditComposer`). |
|
|
56
|
-
| `...rest` | `
|
|
58
|
+
| `...rest` | `ThreadPrimitive.MessagesFlatList` props | Same props as `ThreadPrimitive.MessagesFlatList`, with the auto-scroll options defaulting to `false` on this deprecated wrapper |
|
|
59
|
+
|
|
60
|
+
### ThreadPrimitive.MessagesFlatList
|
|
61
|
+
|
|
62
|
+
Canonical React Native message viewport backed by `FlatList`. It scopes each row to its message, forwards refs to the underlying `FlatList`, and handles scroll-to-bottom behavior for common chat flows.
|
|
63
|
+
|
|
64
|
+
```tsx
|
|
65
|
+
<ThreadPrimitive.MessagesFlatList autoScroll>
|
|
66
|
+
{() => <MyMessage />}
|
|
67
|
+
</ThreadPrimitive.MessagesFlatList>
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
| Prop | Type | Description |
|
|
71
|
+
|------|------|-------------|
|
|
72
|
+
| `children` | `({ message }) => ReactNode` | Render function for each message |
|
|
73
|
+
| `components` | `MessageComponents` | Component map alternative to `children` |
|
|
74
|
+
| `autoScroll` | `boolean` | Automatically keeps the list at the bottom while it is already near the bottom. Defaults to `true` |
|
|
75
|
+
| `scrollToBottomOnRunStart` | `boolean` | Scrolls to the bottom when a run starts. Defaults to `true` |
|
|
76
|
+
| `scrollToBottomOnInitialize` | `boolean` | Scrolls to the bottom when messages first appear. Defaults to `true` |
|
|
77
|
+
| `scrollToBottomOnThreadSwitch` | `boolean` | Scrolls to the bottom when switching threads. Defaults to `true` |
|
|
78
|
+
| `...rest` | `FlatListProps` | Standard FlatList props, except `data`, `renderItem`, and `children` |
|
|
79
|
+
|
|
80
|
+
The built-in auto-scroll behavior assumes the default, non-inverted `FlatList` direction.
|
|
57
81
|
|
|
58
82
|
### ThreadPrimitive.MessageByIndex
|
|
59
83
|
|
|
@@ -362,6 +386,29 @@ Renders message content parts using render-prop functions instead of the compone
|
|
|
362
386
|
| `renderFile` | `(props: { part, index }) => ReactElement` | Renderer for file parts |
|
|
363
387
|
| `renderData` | `(props: { part, index }) => ReactElement` | Fallback renderer for data parts not handled by registered data UIs |
|
|
364
388
|
|
|
389
|
+
#### Rendering Markdown
|
|
390
|
+
|
|
391
|
+
`MessagePrimitive.Content` renders text parts with React Native's `<Text>` by default, so markdown syntax is displayed as plain text. To render markdown, install a React Native markdown renderer and pass it through `renderText`:
|
|
392
|
+
|
|
393
|
+
<InstallCommand npm={["react-native-markdown-display"]} />
|
|
394
|
+
|
|
395
|
+
```tsx
|
|
396
|
+
import Markdown from "react-native-markdown-display";
|
|
397
|
+
import { MessagePrimitive } from "@assistant-ui/react-native";
|
|
398
|
+
|
|
399
|
+
const AssistantMessage = () => {
|
|
400
|
+
return (
|
|
401
|
+
<MessagePrimitive.Root>
|
|
402
|
+
<MessagePrimitive.Content
|
|
403
|
+
renderText={({ part }) => (
|
|
404
|
+
<Markdown>{part.text}</Markdown>
|
|
405
|
+
)}
|
|
406
|
+
/>
|
|
407
|
+
</MessagePrimitive.Root>
|
|
408
|
+
);
|
|
409
|
+
};
|
|
410
|
+
```
|
|
411
|
+
|
|
365
412
|
### MessagePrimitive.Parts
|
|
366
413
|
|
|
367
414
|
Renders message content parts via a `components` prop. Tool call and data parts automatically render registered toolkit renderers and data UIs (via `useAssistantDataUI`), falling back to components provided here. A default `Text` component using React Native's `<Text>` is provided out of the box.
|
|
@@ -518,10 +565,20 @@ import { ActionBarPrimitive } from "@assistant-ui/react-native";
|
|
|
518
565
|
|
|
519
566
|
### ActionBarPrimitive.Copy
|
|
520
567
|
|
|
521
|
-
`Pressable` that copies the message content. Supports function-as-children for copy state feedback.
|
|
568
|
+
`Pressable` that copies the message content. Pass a platform clipboard writer through `copyToClipboard`. Supports function-as-children for copy state feedback.
|
|
522
569
|
|
|
523
570
|
```tsx
|
|
524
|
-
|
|
571
|
+
import * as Clipboard from "expo-clipboard";
|
|
572
|
+
|
|
573
|
+
const copyToClipboard = async (text: string) => {
|
|
574
|
+
const didCopy = await Clipboard.setStringAsync(text);
|
|
575
|
+
if (!didCopy) throw new Error("Clipboard write failed");
|
|
576
|
+
};
|
|
577
|
+
|
|
578
|
+
<ActionBarPrimitive.Copy
|
|
579
|
+
copiedDuration={3000}
|
|
580
|
+
copyToClipboard={copyToClipboard}
|
|
581
|
+
>
|
|
525
582
|
{({ isCopied }) => <Text>{isCopied ? "Copied!" : "Copy"}</Text>}
|
|
526
583
|
</ActionBarPrimitive.Copy>
|
|
527
584
|
```
|
|
@@ -529,7 +586,7 @@ import { ActionBarPrimitive } from "@assistant-ui/react-native";
|
|
|
529
586
|
| Prop | Type | Description |
|
|
530
587
|
|------|------|-------------|
|
|
531
588
|
| `copiedDuration` | `number` | Duration in ms to show "copied" state (default: 3000) |
|
|
532
|
-
| `copyToClipboard` | `(text: string) => void
|
|
589
|
+
| `copyToClipboard` | `(text: string) => void \| Promise<void>` | Platform clipboard writer |
|
|
533
590
|
|
|
534
591
|
### ActionBarPrimitive.Edit
|
|
535
592
|
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Agent state
|
|
3
|
+
description: Read and optimistically update agent-owned state with useAgUiState and useAgUiSetState over AG-UI.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
`useAgUiState` mirrors the state your AG-UI agent owns. It updates live while the agent runs. `useAgUiSetState` lets you apply optimistic local updates that are sent with the next run.
|
|
7
|
+
|
|
8
|
+
## Basic usage
|
|
9
|
+
|
|
10
|
+
```tsx
|
|
11
|
+
import { useAgUiState, useAgUiSetState } from "@assistant-ui/react-ag-ui";
|
|
12
|
+
import { useAuiState } from "@assistant-ui/react";
|
|
13
|
+
|
|
14
|
+
type ResearchState = {
|
|
15
|
+
topic: string;
|
|
16
|
+
sources: string[];
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const state = useAgUiState<ResearchState>();
|
|
20
|
+
// state: ResearchState | undefined (latest agent state; updates live while the agent runs)
|
|
21
|
+
|
|
22
|
+
const setState = useAgUiSetState<ResearchState>();
|
|
23
|
+
// setState(next | (prev) => next) (optimistic local update; sent with the NEXT run)
|
|
24
|
+
|
|
25
|
+
const isRunning = useAuiState((s) => s.thread.isRunning);
|
|
26
|
+
// isRunning: boolean (whether the thread is currently running)
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Example
|
|
30
|
+
|
|
31
|
+
Render agent state beside the chat and push an optimistic update from a control in your UI:
|
|
32
|
+
|
|
33
|
+
```tsx
|
|
34
|
+
"use client";
|
|
35
|
+
|
|
36
|
+
import { useAgUiState, useAgUiSetState } from "@assistant-ui/react-ag-ui";
|
|
37
|
+
import { useAuiState } from "@assistant-ui/react";
|
|
38
|
+
import { Thread } from "@/components/assistant-ui/thread";
|
|
39
|
+
|
|
40
|
+
type ResearchState = {
|
|
41
|
+
topic: string;
|
|
42
|
+
sources: string[];
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export function ResearchAssistant() {
|
|
46
|
+
const state = useAgUiState<ResearchState>();
|
|
47
|
+
const setState = useAgUiSetState<ResearchState>();
|
|
48
|
+
const isRunning = useAuiState((s) => s.thread.isRunning);
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
<div className="flex h-full">
|
|
52
|
+
<aside className="w-72 border-r p-4">
|
|
53
|
+
<h2>Research state</h2>
|
|
54
|
+
{state ? (
|
|
55
|
+
<ul>
|
|
56
|
+
<li>Topic: {state.topic}</li>
|
|
57
|
+
<li>Sources: {state.sources.join(", ") || "none"}</li>
|
|
58
|
+
</ul>
|
|
59
|
+
) : (
|
|
60
|
+
<p>No agent state yet.</p>
|
|
61
|
+
)}
|
|
62
|
+
<button
|
|
63
|
+
type="button"
|
|
64
|
+
disabled={isRunning}
|
|
65
|
+
onClick={() =>
|
|
66
|
+
setState((prev) => ({
|
|
67
|
+
topic: prev?.topic ?? "market analysis",
|
|
68
|
+
sources: [...(prev?.sources ?? []), "sec-filings"],
|
|
69
|
+
}))
|
|
70
|
+
}
|
|
71
|
+
>
|
|
72
|
+
Prefer SEC filings
|
|
73
|
+
</button>
|
|
74
|
+
{isRunning && <p>Agent is running…</p>}
|
|
75
|
+
</aside>
|
|
76
|
+
<main className="flex-1">
|
|
77
|
+
<Thread />
|
|
78
|
+
</main>
|
|
79
|
+
</div>
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
The panel re-renders as `STATE_SNAPSHOT` and `STATE_DELTA` events arrive. The button updates the local snapshot immediately; that value is included as the `state` field of the next run input.
|
|
85
|
+
|
|
86
|
+
## How state is synced
|
|
87
|
+
|
|
88
|
+
The AG-UI protocol delivers agent state on the wire:
|
|
89
|
+
|
|
90
|
+
- `STATE_SNAPSHOT` replaces the full client-side snapshot.
|
|
91
|
+
- `STATE_DELTA` applies a JSON Patch to the current snapshot.
|
|
92
|
+
|
|
93
|
+
The runtime applies both client-side, so `useAgUiState` always reflects the latest merged snapshot. Calling the setter from `useAgUiSetState` updates that same local snapshot. On the next run, the runtime automatically includes it as the `state` field of the run input.
|
|
94
|
+
|
|
95
|
+
This works with any AG-UI agent (Mastra, Pydantic AI, CrewAI, LangGraph via AG-UI adapters, and other AG-UI-compliant servers).
|
|
96
|
+
|
|
97
|
+
## Write-back timing
|
|
98
|
+
|
|
99
|
+
`useAgUiSetState` is optimistic and local first. The value reaches the agent only when the next run starts. It is not a live channel into a run that is already in progress. Use it to stage preferences, filters, or other agent-owned fields that the next turn should see.
|
|
100
|
+
|
|
101
|
+
## Relationship to other state
|
|
102
|
+
|
|
103
|
+
Keep the three state layers distinct:
|
|
104
|
+
|
|
105
|
+
- **Your app state** stays yours (React state, URL, a store). assistant-ui does not own it.
|
|
106
|
+
- **`useAuiState`** reads assistant-ui's client state (messages, composer, thread status).
|
|
107
|
+
- **`useAgUiState` / `useAgUiSetState`** mirror state the **agent** owns, synced over the AG-UI wire via snapshots and deltas.
|
|
108
|
+
|
|
109
|
+
Use `useAgUiState` and `useAgUiSetState` for fields your agent maintains as shared state on the protocol. Use `useAuiState` for UI that depends on the chat thread itself. Use your own state for everything else.
|
|
110
|
+
|
|
111
|
+
## Next
|
|
112
|
+
|
|
113
|
+
<Cards>
|
|
114
|
+
<Card
|
|
115
|
+
title="Runtime options"
|
|
116
|
+
description="useAgUiRuntime options, adapters, supported events."
|
|
117
|
+
href="/docs/runtimes/ag-ui/runtime-options"
|
|
118
|
+
/>
|
|
119
|
+
<Card
|
|
120
|
+
title="Quickstart"
|
|
121
|
+
description="Minimal HttpAgent + useAgUiRuntime setup."
|
|
122
|
+
href="/docs/runtimes/ag-ui/quickstart"
|
|
123
|
+
/>
|
|
124
|
+
</Cards>
|
|
@@ -14,6 +14,7 @@ Reference for the runtime's API surface. Start with [quickstart](/docs/runtimes/
|
|
|
14
14
|
| `agent` | `HttpAgent` | An AG-UI client agent (from `@ag-ui/client`). Required. |
|
|
15
15
|
| `logger` | `Partial<Logger>` | Optional logger overrides. The runtime logs event-parser warnings and run lifecycle events. |
|
|
16
16
|
| `showThinking` | `boolean` | Whether to render `THINKING_*` and `REASONING_*` events as visible reasoning. Defaults to `true`. |
|
|
17
|
+
| `autoCancelPendingToolCalls` | `boolean` | Cancel unresolved client-side tool calls automatically when the user sends, edits, or reloads a message. Defaults to `true`. See [below](#auto-cancelling-pending-tool-calls). |
|
|
17
18
|
| `onError` | `(e: Error) => void` | Error callback fired on `RUN_ERROR` events and protocol errors. |
|
|
18
19
|
| `onCancel` | `() => void` | Cancellation callback fired when the user cancels a run. |
|
|
19
20
|
| `adapters` | `UseAgUiRuntimeAdapters` | Standard adapter slots (see below). |
|
|
@@ -137,7 +138,9 @@ await runtime.unstable_submitInterruptResponses(
|
|
|
137
138
|
|
|
138
139
|
### Steering away from an interrupt
|
|
139
140
|
|
|
140
|
-
When the user ignores the interrupt UI and just sends a new message, use the `useAgUiSteerAway` hook. Every open interrupt defaults to `status: "cancelled"`, the new message is appended, and the run resumes with `resume: ResumeEntry[]` on the wire.
|
|
141
|
+
When the user ignores the interrupt UI and just sends a new message, use the `useAgUiSteerAway` hook. Every open interrupt defaults to `status: "cancelled"`, the new message is appended, and the run resumes with `resume: ResumeEntry[]` on the wire.
|
|
142
|
+
|
|
143
|
+
The same hook also steers away from pending client-side tool calls. When the head assistant message is in `requires-action` with `reason: "tool-calls"` (frontend tools awaiting a result) and the user sends a new message, every unresolved tool call is cancelled with an error result, the message is completed, and a single fresh run starts with those cancellations in its history. Passing `responses` in this case throws, since responses only address interrupts. With nothing pending, `steerAway` behaves like a normal append.
|
|
141
144
|
|
|
142
145
|
```tsx
|
|
143
146
|
const steerAway = useAgUiSteerAway();
|
|
@@ -154,6 +157,12 @@ await steerAway("continue without the file", [
|
|
|
154
157
|
]);
|
|
155
158
|
```
|
|
156
159
|
|
|
160
|
+
### Auto-cancelling pending tool calls
|
|
161
|
+
|
|
162
|
+
By default the runtime does the tool-call half of this automatically: when client-side tool calls are still unresolved and the user sends a new message, edits an earlier one, or reloads, every unresolved tool call receives the same cancellation error result, the assistant message is completed, and the run proceeds with those cancellations in its history. Set `autoCancelPendingToolCalls: false` to opt out, in which case pending tool calls stay unresolved on a plain send and [steering away](#steering-away-from-an-interrupt) remains the explicit way to cancel them.
|
|
163
|
+
|
|
164
|
+
Pending interrupts are never auto-cancelled: sending while an interrupt is open still throws, and the interrupt must be answered with `useAgUiSubmitInterruptResponses` or discarded with `useAgUiSteerAway`.
|
|
165
|
+
|
|
157
166
|
## Supported events
|
|
158
167
|
|
|
159
168
|
The runtime parses the AG-UI event stream and maps each event type to assistant-ui state.
|
|
@@ -11,16 +11,19 @@ import { VercelIcon } from "@/components/icons/vercel";
|
|
|
11
11
|
|
|
12
12
|
| AI SDK | Runtime package | Docs |
|
|
13
13
|
| --- | --- | --- |
|
|
14
|
-
| `ai@^
|
|
15
|
-
| `ai@^
|
|
14
|
+
| `ai@^7` + `@ai-sdk/react@^4` | `@assistant-ui/react-ai-sdk@^1.4` (latest) | [v7 (current)](/docs/runtimes/ai-sdk/v7) |
|
|
15
|
+
| `ai@^6` + `@ai-sdk/react@^3` | `@assistant-ui/react-ai-sdk@1.3.40` | [v6 (legacy)](/docs/runtimes/ai-sdk/v6-legacy) |
|
|
16
|
+
| `ai@^5` + `@ai-sdk/react@^2` | `@assistant-ui/react-ai-sdk@1.1.21` | [v5 (legacy)](/docs/runtimes/ai-sdk/v5-legacy) |
|
|
16
17
|
| `ai@^4` | `@assistant-ui/react-data-stream` | [v4 (legacy)](/docs/runtimes/ai-sdk/v4-legacy) |
|
|
17
18
|
|
|
18
|
-
New projects should target
|
|
19
|
+
New projects should target v7. v6, v5, and v4 are documented for projects that have not migrated yet; all have known compatibility gaps and receive no new features.
|
|
19
20
|
|
|
20
21
|
## Architecture
|
|
21
22
|
|
|
22
23
|
`@assistant-ui/react-ai-sdk` is layered on `ExternalStoreRuntime` (see [architecture](/docs/runtimes/concepts/architecture)). Features that ship as runtime adapters work the same way they do everywhere else; see [adapters](/docs/runtimes/concepts/adapters).
|
|
23
24
|
|
|
25
|
+
For reload-safe streaming (persist an in-flight response so the client can reconnect), see [Resumable Streams](/docs/guides/resumable-streams).
|
|
26
|
+
|
|
24
27
|
## Choosing useChatRuntime vs useAISDKRuntime
|
|
25
28
|
|
|
26
29
|
Both ship in the same package.
|
|
@@ -33,9 +36,15 @@ Both ship in the same package.
|
|
|
33
36
|
<Cards>
|
|
34
37
|
<Card
|
|
35
38
|
icon={<VercelIcon width={20} height={20} />}
|
|
36
|
-
title="
|
|
39
|
+
title="v7 (current)"
|
|
37
40
|
description="Quickstart, frontend tools, attachments, quotes, history, multi-step, useAISDKRuntime."
|
|
38
|
-
href="/docs/runtimes/ai-sdk/
|
|
41
|
+
href="/docs/runtimes/ai-sdk/v7"
|
|
42
|
+
/>
|
|
43
|
+
<Card
|
|
44
|
+
icon={<VercelIcon width={20} height={20} />}
|
|
45
|
+
title="v6 (legacy)"
|
|
46
|
+
description="Reference for projects still on AI SDK v6."
|
|
47
|
+
href="/docs/runtimes/ai-sdk/v6-legacy"
|
|
39
48
|
/>
|
|
40
49
|
<Card
|
|
41
50
|
icon={<VercelIcon width={20} height={20} />}
|