@assistant-ui/mcp-docs-server 0.1.29 → 0.1.31
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 +15 -7
- package/.docs/organized/code-examples/with-a2a.md +9 -21
- package/.docs/organized/code-examples/with-ag-ui.md +11 -8
- package/.docs/organized/code-examples/with-ai-sdk-v6.md +10 -10
- package/.docs/organized/code-examples/with-artifacts.md +12 -10
- package/.docs/organized/code-examples/with-assistant-transport.md +11 -12
- package/.docs/organized/code-examples/with-chain-of-thought.md +83 -54
- package/.docs/organized/code-examples/with-cloud-standalone.md +14 -11
- package/.docs/organized/code-examples/with-cloud.md +9 -10
- package/.docs/organized/code-examples/with-custom-thread-list.md +61 -16
- package/.docs/organized/code-examples/with-elevenlabs-conversational.md +17 -12
- package/.docs/organized/code-examples/with-elevenlabs-scribe.md +13 -13
- package/.docs/organized/code-examples/with-expo.md +25 -21
- package/.docs/organized/code-examples/with-external-store.md +8 -8
- package/.docs/organized/code-examples/with-ffmpeg.md +17 -12
- package/.docs/organized/code-examples/with-generative-ui.md +9 -9
- package/.docs/organized/code-examples/with-google-adk.md +8 -8
- package/.docs/organized/code-examples/with-heat-graph.md +5 -5
- package/.docs/organized/code-examples/with-interactables.md +10 -25
- package/.docs/organized/code-examples/with-langchain.md +437 -0
- package/.docs/organized/code-examples/with-langgraph.md +16 -16
- package/.docs/organized/code-examples/with-livekit.md +18 -13
- package/.docs/organized/code-examples/with-opencode.md +105 -62
- package/.docs/organized/code-examples/with-parent-id-grouping.md +10 -10
- package/.docs/organized/code-examples/with-react-hook-form.md +220 -148
- package/.docs/organized/code-examples/with-react-ink.md +2 -2
- package/.docs/organized/code-examples/with-react-router.md +12 -12
- package/.docs/organized/code-examples/with-store.md +8 -5
- package/.docs/organized/code-examples/with-tanstack.md +10 -10
- package/.docs/organized/code-examples/with-tap-runtime.md +10 -6
- package/.docs/raw/docs/(docs)/cli.mdx +2 -1
- package/.docs/raw/docs/(docs)/copilots/assistant-frame.mdx +1 -0
- package/.docs/raw/docs/(docs)/copilots/make-assistant-tool-ui.mdx +10 -3
- package/.docs/raw/docs/(docs)/copilots/make-assistant-tool.mdx +8 -3
- package/.docs/raw/docs/(docs)/copilots/make-assistant-visible.mdx +1 -0
- package/.docs/raw/docs/(docs)/copilots/model-context.mdx +1 -0
- package/.docs/raw/docs/(docs)/copilots/motivation.mdx +1 -0
- package/.docs/raw/docs/(docs)/copilots/use-assistant-instructions.mdx +1 -0
- package/.docs/raw/docs/(docs)/devtools.mdx +1 -0
- package/.docs/raw/docs/(docs)/index.mdx +1 -0
- package/.docs/raw/docs/(docs)/installation.mdx +1 -0
- package/.docs/raw/docs/(docs)/rtl.mdx +80 -0
- package/.docs/raw/docs/(reference)/api-reference/adapters/attachments.mdx +34 -0
- package/.docs/raw/docs/(reference)/api-reference/adapters/feedback-speech.mdx +41 -0
- package/.docs/raw/docs/(reference)/api-reference/adapters/index.mdx +26 -0
- package/.docs/raw/docs/(reference)/api-reference/adapters/persistence.mdx +34 -0
- package/.docs/raw/docs/(reference)/api-reference/adapters/runtime.mdx +31 -0
- package/.docs/raw/docs/(reference)/api-reference/context-providers/index.mdx +20 -0
- package/.docs/raw/docs/(reference)/api-reference/hooks/index.mdx +26 -0
- package/.docs/raw/docs/(reference)/api-reference/hooks/model-context.mdx +72 -0
- package/.docs/raw/docs/(reference)/api-reference/hooks/runtimes.mdx +41 -0
- package/.docs/raw/docs/(reference)/api-reference/hooks/state.mdx +48 -0
- package/.docs/raw/docs/(reference)/api-reference/hooks/utilities.mdx +30 -0
- package/.docs/raw/docs/(reference)/api-reference/integrations/index.mdx +23 -0
- package/.docs/raw/docs/(reference)/api-reference/overview.mdx +21 -0
- package/.docs/raw/docs/(reference)/api-reference/primitives/assistant-if.mdx +7 -0
- package/.docs/raw/docs/(reference)/api-reference/primitives/composer.mdx +149 -40
- package/.docs/raw/docs/(reference)/api-reference/primitives/index.mdx +65 -0
- package/.docs/raw/docs/(reference)/api-reference/primitives/message-part.mdx +2 -0
- package/.docs/raw/docs/(reference)/api-reference/primitives/message.mdx +50 -6
- package/.docs/raw/docs/(reference)/api-reference/primitives/thread-list.mdx +15 -0
- package/.docs/raw/docs/(reference)/api-reference/primitives/thread.mdx +36 -1
- package/.docs/raw/docs/(reference)/api-reference/runtimes/index.mdx +38 -0
- package/.docs/raw/docs/(reference)/api-reference/runtimes/thread-list-runtime.mdx +9 -0
- package/.docs/raw/docs/(reference)/migrations/v0-14.mdx +144 -6
- package/.docs/raw/docs/cloud/ai-sdk-assistant-ui.mdx +231 -3
- package/.docs/raw/docs/cloud/ai-sdk.mdx +221 -3
- package/.docs/raw/docs/cloud/langgraph.mdx +274 -2
- package/.docs/raw/docs/{(docs)/guides → guides}/attachments.mdx +41 -36
- package/.docs/raw/docs/guides/branching.mdx +76 -0
- package/.docs/raw/docs/guides/chain-of-thought.mdx +166 -0
- package/.docs/raw/docs/{(docs)/guides → guides}/context-api.mdx +50 -22
- package/.docs/raw/docs/{(docs)/guides → guides}/dictation.mdx +2 -0
- package/.docs/raw/docs/guides/editing.mdx +102 -0
- package/.docs/raw/docs/guides/index.mdx +103 -0
- package/.docs/raw/docs/{(docs)/guides → guides}/interactables.mdx +49 -0
- package/.docs/raw/docs/{(docs)/guides → guides}/latex.mdx +51 -8
- package/.docs/raw/docs/guides/mentions.mdx +520 -0
- package/.docs/raw/docs/{(docs)/guides → guides}/message-timing.mdx +8 -2
- package/.docs/raw/docs/{(docs)/guides → guides}/multi-agent.mdx +64 -4
- package/.docs/raw/docs/{(docs)/guides → guides}/quoting.mdx +10 -17
- package/.docs/raw/docs/guides/slash-commands.mdx +361 -0
- package/.docs/raw/docs/guides/speech.mdx +156 -0
- package/.docs/raw/docs/{(docs)/guides → guides}/suggestions.mdx +21 -83
- package/.docs/raw/docs/{(docs)/guides → guides}/tool-ui.mdx +108 -36
- package/.docs/raw/docs/{(docs)/guides → guides}/tools.mdx +131 -35
- package/.docs/raw/docs/{(docs)/guides → guides}/voice.mdx +39 -0
- package/.docs/raw/docs/ink/index.mdx +1 -3
- package/.docs/raw/docs/ink/migration.mdx +1 -3
- package/.docs/raw/docs/ink/primitives.mdx +37 -1
- package/.docs/raw/docs/integrations/attachments/custom-adapter.mdx +520 -0
- package/.docs/raw/docs/integrations/auth/better-auth.mdx +191 -0
- package/.docs/raw/docs/integrations/auth/clerk.mdx +172 -0
- package/.docs/raw/docs/integrations/auth/next-auth.mdx +196 -0
- package/.docs/raw/docs/integrations/frameworks/ai-sdk.mdx +79 -0
- package/.docs/raw/docs/integrations/frameworks/mastra/full-stack.mdx +188 -0
- package/.docs/raw/docs/integrations/frameworks/mastra/overview.mdx +57 -0
- package/.docs/raw/docs/integrations/frameworks/mastra/separate-server.mdx +201 -0
- package/.docs/raw/docs/integrations/gateways/index.mdx +157 -0
- package/.docs/raw/docs/integrations/index.mdx +173 -0
- package/.docs/raw/docs/integrations/observability/helicone.mdx +130 -0
- package/.docs/raw/docs/integrations/observability/langfuse.mdx +156 -0
- package/.docs/raw/docs/integrations/observability/langsmith.mdx +146 -0
- package/.docs/raw/docs/integrations/persistence/custom-adapter.mdx +712 -0
- package/.docs/raw/docs/integrations/tools/mcp.mdx +267 -0
- package/.docs/raw/docs/primitives/action-bar.mdx +1 -0
- package/.docs/raw/docs/primitives/assistant-modal.mdx +1 -0
- package/.docs/raw/docs/primitives/attachment.mdx +1 -0
- package/.docs/raw/docs/primitives/branch-picker.mdx +1 -0
- package/.docs/raw/docs/primitives/chain-of-thought.mdx +90 -85
- package/.docs/raw/docs/primitives/composer.mdx +96 -63
- package/.docs/raw/docs/primitives/error.mdx +1 -0
- package/.docs/raw/docs/primitives/index.mdx +2 -1
- package/.docs/raw/docs/primitives/message.mdx +68 -5
- package/.docs/raw/docs/primitives/selection-toolbar.mdx +1 -0
- package/.docs/raw/docs/primitives/suggestion.mdx +1 -0
- package/.docs/raw/docs/primitives/thread-list.mdx +39 -0
- package/.docs/raw/docs/primitives/thread.mdx +16 -13
- package/.docs/raw/docs/react-native/index.mdx +1 -3
- package/.docs/raw/docs/react-native/migration.mdx +1 -3
- package/.docs/raw/docs/runtimes/a2a/client-and-hooks.mdx +396 -0
- package/.docs/raw/docs/runtimes/a2a/overview.mdx +60 -0
- package/.docs/raw/docs/runtimes/a2a/quickstart.mdx +216 -0
- package/.docs/raw/docs/runtimes/ag-ui/overview.mdx +70 -0
- package/.docs/raw/docs/runtimes/ag-ui/quickstart.mdx +243 -0
- package/.docs/raw/docs/runtimes/ag-ui/runtime-options.mdx +123 -0
- package/.docs/raw/docs/runtimes/ai-sdk/overview.mdx +52 -0
- package/.docs/raw/docs/runtimes/ai-sdk/v4-legacy.mdx +71 -131
- package/.docs/raw/docs/runtimes/ai-sdk/v5-legacy.mdx +69 -63
- package/.docs/raw/docs/runtimes/ai-sdk/v6.mdx +365 -101
- package/.docs/raw/docs/runtimes/concepts/adapters.mdx +265 -0
- package/.docs/raw/docs/runtimes/concepts/architecture.mdx +125 -0
- package/.docs/raw/docs/runtimes/concepts/stability.mdx +67 -0
- package/.docs/raw/docs/runtimes/concepts/threads.mdx +428 -0
- package/.docs/raw/docs/runtimes/custom/assistant-transport.mdx +703 -0
- package/.docs/raw/docs/runtimes/custom/data-stream.mdx +323 -0
- package/.docs/raw/docs/runtimes/custom/external-store.mdx +253 -1236
- package/.docs/raw/docs/runtimes/custom/local-runtime.mdx +746 -0
- package/.docs/raw/docs/runtimes/custom/overview.mdx +71 -0
- package/.docs/raw/docs/runtimes/google-adk/api.mdx +256 -0
- package/.docs/raw/docs/runtimes/google-adk/hooks.mdx +717 -0
- package/.docs/raw/docs/runtimes/google-adk/overview.mdx +69 -0
- package/.docs/raw/docs/runtimes/google-adk/quickstart.mdx +229 -0
- package/.docs/raw/docs/runtimes/langchain.mdx +533 -0
- package/.docs/raw/docs/runtimes/langgraph/generative-ui.mdx +305 -0
- package/.docs/raw/docs/runtimes/langgraph/interrupts.mdx +104 -0
- package/.docs/raw/docs/runtimes/langgraph/overview.mdx +84 -0
- package/.docs/raw/docs/runtimes/langgraph/quickstart.mdx +496 -0
- package/.docs/raw/docs/runtimes/langgraph/streaming.mdx +127 -0
- package/.docs/raw/docs/runtimes/langgraph/threads.mdx +113 -0
- package/.docs/raw/docs/runtimes/langgraph/tutorial/introduction.mdx +3 -3
- package/.docs/raw/docs/runtimes/langgraph/tutorial/part-1.mdx +0 -23
- package/.docs/raw/docs/runtimes/langgraph/tutorial/part-2.mdx +1 -1
- package/.docs/raw/docs/runtimes/opencode/hooks.mdx +191 -0
- package/.docs/raw/docs/runtimes/opencode/overview.mdx +48 -0
- package/.docs/raw/docs/runtimes/opencode/quickstart.mdx +119 -0
- package/.docs/raw/docs/runtimes/pick-a-runtime.mdx +74 -198
- package/.docs/raw/docs/ui/accordion.mdx +1 -0
- package/.docs/raw/docs/ui/assistant-modal.mdx +1 -0
- package/.docs/raw/docs/ui/assistant-sidebar.mdx +1 -0
- package/.docs/raw/docs/ui/attachment.mdx +1 -0
- package/.docs/raw/docs/ui/badge.mdx +1 -0
- package/.docs/raw/docs/ui/composer-trigger-popover.mdx +200 -0
- package/.docs/raw/docs/ui/context-display.mdx +1 -0
- package/.docs/raw/docs/ui/diff-viewer.mdx +1 -0
- package/.docs/raw/docs/ui/directive-text.mdx +114 -0
- package/.docs/raw/docs/ui/file.mdx +1 -0
- package/.docs/raw/docs/ui/image.mdx +1 -0
- package/.docs/raw/docs/ui/markdown.mdx +2 -14
- package/.docs/raw/docs/ui/mermaid.mdx +1 -0
- package/.docs/raw/docs/ui/message-timing.mdx +3 -2
- package/.docs/raw/docs/ui/model-selector.mdx +1 -0
- package/.docs/raw/docs/ui/part-grouping.mdx +325 -313
- package/.docs/raw/docs/ui/quote.mdx +1 -0
- package/.docs/raw/docs/ui/reasoning.mdx +69 -32
- package/.docs/raw/docs/ui/scrollbar.mdx +1 -0
- package/.docs/raw/docs/ui/select.mdx +1 -0
- package/.docs/raw/docs/ui/sources.mdx +1 -0
- package/.docs/raw/docs/ui/streamdown.mdx +1 -0
- package/.docs/raw/docs/ui/syntax-highlighting.mdx +1 -0
- package/.docs/raw/docs/ui/tabs.mdx +1 -0
- package/.docs/raw/docs/ui/thread-list.mdx +17 -0
- package/.docs/raw/docs/ui/thread.mdx +56 -1
- package/.docs/raw/docs/ui/tool-fallback.mdx +1 -0
- package/.docs/raw/docs/ui/tool-group.mdx +39 -11
- package/.docs/raw/docs/ui/voice.mdx +1 -0
- package/.docs/raw/docs/utilities/heat-graph.mdx +1 -0
- package/.docs/raw/docs/utilities/react-o11y.mdx +278 -0
- package/.docs/raw/docs/utilities/tw-shimmer.mdx +1 -0
- package/dist/utils/logger.js +1 -1
- package/dist/utils/logger.js.map +1 -1
- package/package.json +4 -4
- package/src/tools/tests/path-traversal.test.ts +1 -1
- package/src/utils/logger.ts +1 -1
- package/.docs/raw/docs/(docs)/guides/branching.mdx +0 -65
- package/.docs/raw/docs/(docs)/guides/chain-of-thought.mdx +0 -164
- package/.docs/raw/docs/(docs)/guides/editing.mdx +0 -66
- package/.docs/raw/docs/(docs)/guides/mentions.mdx +0 -406
- package/.docs/raw/docs/(docs)/guides/slash-commands.mdx +0 -275
- package/.docs/raw/docs/(docs)/guides/speech.mdx +0 -38
- package/.docs/raw/docs/runtimes/a2a/index.mdx +0 -298
- package/.docs/raw/docs/runtimes/assistant-transport.mdx +0 -1033
- package/.docs/raw/docs/runtimes/custom/custom-thread-list.mdx +0 -268
- package/.docs/raw/docs/runtimes/custom/local.mdx +0 -1464
- package/.docs/raw/docs/runtimes/data-stream.mdx +0 -422
- package/.docs/raw/docs/runtimes/google-adk/index.mdx +0 -686
- package/.docs/raw/docs/runtimes/helicone.mdx +0 -61
- package/.docs/raw/docs/runtimes/langgraph/index.mdx +0 -607
- package/.docs/raw/docs/runtimes/langgraph/tutorial/index.mdx +0 -12
- package/.docs/raw/docs/runtimes/langserve.mdx +0 -116
- package/.docs/raw/docs/runtimes/mastra/full-stack-integration.mdx +0 -218
- package/.docs/raw/docs/runtimes/mastra/overview.mdx +0 -18
- package/.docs/raw/docs/runtimes/mastra/separate-server-integration.mdx +0 -217
- package/.docs/raw/docs/ui/mention.mdx +0 -168
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Adapters
|
|
3
|
+
description: Reusable extension points for attachments, speech, feedback, history, and suggestions.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Adapters are how assistant-ui adds capabilities like file uploads or message persistence to a runtime without coupling the runtime to a specific backend. You implement a small interface, plug it into the runtime's `adapters` option, and the matching UI surfaces (paperclip button, audio button, history reload) light up.
|
|
7
|
+
|
|
8
|
+
Every adapter on this page works the same way regardless of which runtime you use. When an adapter is supported by a runtime, you provide it via that runtime's `adapters` option:
|
|
9
|
+
|
|
10
|
+
```ts
|
|
11
|
+
const runtime = useLocalRuntime(modelAdapter, {
|
|
12
|
+
adapters: { attachments, history, speech, feedback, suggestion },
|
|
13
|
+
});
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Framework adapters take the same shape:
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
const runtime = useChatRuntime({ adapters: { attachments, history } });
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Support matrix
|
|
23
|
+
|
|
24
|
+
| Adapter | LocalRuntime | ExternalStoreRuntime | DataStream | AssistantTransport | react-ai-sdk | react-langgraph | react-langchain | react-google-adk | react-a2a | react-ag-ui | react-opencode |
|
|
25
|
+
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
|
|
26
|
+
| Attachments | Yes | Yes | Yes | Yes | Yes | (via thread state) | (via thread state) | Yes | Yes | Yes | (no) |
|
|
27
|
+
| Speech | Yes | Yes | Yes | (no) | Yes | Yes | Yes | Yes | Yes | Yes | (no) |
|
|
28
|
+
| Dictation | Yes | Yes | Yes | (no) | Yes | Yes | (no) | Yes | (no) | Yes | (no) |
|
|
29
|
+
| Feedback | Yes | Yes | Yes | (no) | Yes | Yes | Yes | Yes | Yes | Yes | (no) |
|
|
30
|
+
| History | Yes | (use your store) | Yes | (use thread converter) | Yes | (via load) | (via load) | Yes | Yes | Yes | (server-managed) |
|
|
31
|
+
| Suggestion | Yes | (no) | Yes | (no) | (no) | (no) | (no) | (no) | (no) | (no) | (no) |
|
|
32
|
+
| threadList | Yes (`RemoteThreadListAdapter`) | Yes (`ExternalStoreThreadListAdapter`) | Yes (`RemoteThreadListAdapter`) | Yes | Yes | Yes | Yes | Yes | Yes | Yes (experimental) | Built-in (sessions) |
|
|
33
|
+
|
|
34
|
+
`(no)` means the adapter slot is not exposed by that runtime today. You would need to drop down a layer to use it.
|
|
35
|
+
|
|
36
|
+
## Attachment adapter
|
|
37
|
+
|
|
38
|
+
Handles file and image uploads. When present, the composer renders a paperclip button.
|
|
39
|
+
|
|
40
|
+
```ts
|
|
41
|
+
type AttachmentAdapter = {
|
|
42
|
+
accept: string;
|
|
43
|
+
add: (input: { file: File }) => Promise<PendingAttachment>;
|
|
44
|
+
send: (attachment: PendingAttachment) => Promise<CompleteAttachment>;
|
|
45
|
+
remove?: (attachment: Attachment) => Promise<void>;
|
|
46
|
+
};
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Three lifecycle methods:
|
|
50
|
+
|
|
51
|
+
- `add` runs when the user picks a file. Upload it, return a record with status `requires-action` so the composer holds the file before sending.
|
|
52
|
+
- `send` runs when the user submits the message. Finalize the upload, attach a `content` payload, and mark status `complete`.
|
|
53
|
+
- `remove` is optional and runs when the user removes the attachment before sending.
|
|
54
|
+
|
|
55
|
+
Minimal upload-and-send example:
|
|
56
|
+
|
|
57
|
+
```ts
|
|
58
|
+
const attachmentAdapter: AttachmentAdapter = {
|
|
59
|
+
accept: "image/*,application/pdf",
|
|
60
|
+
async add({ file }) {
|
|
61
|
+
const form = new FormData();
|
|
62
|
+
form.append("file", file);
|
|
63
|
+
const { id, url } = await fetch("/api/upload", {
|
|
64
|
+
method: "POST",
|
|
65
|
+
body: form,
|
|
66
|
+
}).then((r) => r.json());
|
|
67
|
+
return {
|
|
68
|
+
id,
|
|
69
|
+
type: file.type.startsWith("image/") ? "image" : "document",
|
|
70
|
+
name: file.name,
|
|
71
|
+
contentType: file.type,
|
|
72
|
+
file,
|
|
73
|
+
url,
|
|
74
|
+
status: { type: "requires-action", reason: "composer-send" },
|
|
75
|
+
};
|
|
76
|
+
},
|
|
77
|
+
async send(attachment) {
|
|
78
|
+
return {
|
|
79
|
+
...attachment,
|
|
80
|
+
status: { type: "complete" },
|
|
81
|
+
content: [
|
|
82
|
+
attachment.type === "image"
|
|
83
|
+
? { type: "image", image: attachment.url! }
|
|
84
|
+
: { type: "text", text: `[${attachment.name}](${attachment.url})` },
|
|
85
|
+
],
|
|
86
|
+
};
|
|
87
|
+
},
|
|
88
|
+
};
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
For multiple file types use `CompositeAttachmentAdapter`:
|
|
92
|
+
|
|
93
|
+
```ts
|
|
94
|
+
import {
|
|
95
|
+
CompositeAttachmentAdapter,
|
|
96
|
+
SimpleImageAttachmentAdapter,
|
|
97
|
+
SimpleTextAttachmentAdapter,
|
|
98
|
+
} from "@assistant-ui/react";
|
|
99
|
+
|
|
100
|
+
const attachmentAdapter = new CompositeAttachmentAdapter([
|
|
101
|
+
new SimpleImageAttachmentAdapter(),
|
|
102
|
+
new SimpleTextAttachmentAdapter(),
|
|
103
|
+
]);
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## Speech adapter
|
|
107
|
+
|
|
108
|
+
Text-to-speech for assistant messages. When present, message bubbles render an audio button.
|
|
109
|
+
|
|
110
|
+
```ts
|
|
111
|
+
type SpeechSynthesisAdapter = {
|
|
112
|
+
speak: (text: string) => Utterance;
|
|
113
|
+
};
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
`speak` returns an `Utterance` with `cancel()`, a `status` field, and `subscribe(callback)`. Browser-native example:
|
|
117
|
+
|
|
118
|
+
```ts
|
|
119
|
+
const speechAdapter: SpeechSynthesisAdapter = {
|
|
120
|
+
speak(text) {
|
|
121
|
+
const utterance = new SpeechSynthesisUtterance(text);
|
|
122
|
+
const subscribers = new Set<() => void>();
|
|
123
|
+
const result: SpeechSynthesisAdapter.Utterance = {
|
|
124
|
+
status: { type: "running" },
|
|
125
|
+
cancel: () => {
|
|
126
|
+
speechSynthesis.cancel();
|
|
127
|
+
result.status = { type: "ended", reason: "cancelled" };
|
|
128
|
+
subscribers.forEach((cb) => cb());
|
|
129
|
+
},
|
|
130
|
+
subscribe(cb) {
|
|
131
|
+
subscribers.add(cb);
|
|
132
|
+
return () => subscribers.delete(cb);
|
|
133
|
+
},
|
|
134
|
+
};
|
|
135
|
+
utterance.addEventListener("end", () => {
|
|
136
|
+
result.status = { type: "ended", reason: "finished" };
|
|
137
|
+
subscribers.forEach((cb) => cb());
|
|
138
|
+
});
|
|
139
|
+
speechSynthesis.speak(utterance);
|
|
140
|
+
return result;
|
|
141
|
+
},
|
|
142
|
+
};
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
## Dictation adapter
|
|
146
|
+
|
|
147
|
+
Speech-to-text input for the composer. When present, the composer renders a microphone button. The contract is parallel to the speech adapter.
|
|
148
|
+
|
|
149
|
+
## Feedback adapter
|
|
150
|
+
|
|
151
|
+
Thumbs up / thumbs down on assistant messages. When present, message bubbles render feedback buttons.
|
|
152
|
+
|
|
153
|
+
```ts
|
|
154
|
+
type FeedbackAdapter = {
|
|
155
|
+
submit: (feedback: {
|
|
156
|
+
type: "positive" | "negative";
|
|
157
|
+
message: ThreadMessage;
|
|
158
|
+
}) => Promise<void>;
|
|
159
|
+
};
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
```ts
|
|
163
|
+
const feedbackAdapter: FeedbackAdapter = {
|
|
164
|
+
async submit({ type, message }) {
|
|
165
|
+
await fetch("/api/feedback", {
|
|
166
|
+
method: "POST",
|
|
167
|
+
headers: { "Content-Type": "application/json" },
|
|
168
|
+
body: JSON.stringify({ messageId: message.id, rating: type }),
|
|
169
|
+
});
|
|
170
|
+
},
|
|
171
|
+
};
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
## History adapter
|
|
175
|
+
|
|
176
|
+
Per-thread message persistence. Used by `LocalRuntime` and adapters built on it (`react-ai-sdk`, `react-google-adk`, `react-a2a`, `useDataStreamRuntime`).
|
|
177
|
+
|
|
178
|
+
`ExternalStoreRuntime` does not use a history adapter directly, since you already own the message array. Persist via your store instead. `react-langgraph` and `react-langchain` source persistence from server-side thread state, exposed through their `load` callbacks.
|
|
179
|
+
|
|
180
|
+
```ts
|
|
181
|
+
type ThreadHistoryAdapter = {
|
|
182
|
+
load: () => Promise<{
|
|
183
|
+
messages: { parentId: string | null; message: ThreadMessage }[];
|
|
184
|
+
}>;
|
|
185
|
+
append: (item: {
|
|
186
|
+
parentId: string | null;
|
|
187
|
+
message: ThreadMessage;
|
|
188
|
+
}) => Promise<void>;
|
|
189
|
+
resume?: (input: {
|
|
190
|
+
messages: ThreadMessage[];
|
|
191
|
+
}) => Promise<ReadableStream | undefined>;
|
|
192
|
+
withFormat?: <Fmt>(fmt: Fmt) => ThreadHistoryAdapter;
|
|
193
|
+
};
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
`load` runs when a thread opens. `append` runs after each message completes.
|
|
197
|
+
|
|
198
|
+
<Callout type="info">
|
|
199
|
+
`react-ai-sdk` requires `withFormat` so messages round-trip as AI SDK `UIMessage` objects. An adapter without `withFormat` throws at runtime in the AI SDK path. See the [AI SDK history docs](/docs/runtimes/ai-sdk/v6) for the full pattern.
|
|
200
|
+
</Callout>
|
|
201
|
+
|
|
202
|
+
## Suggestion adapter
|
|
203
|
+
|
|
204
|
+
Proposes follow-up prompts after each assistant message. When present, suggestion chips render under the latest assistant message.
|
|
205
|
+
|
|
206
|
+
```ts
|
|
207
|
+
type SuggestionAdapter = {
|
|
208
|
+
generate: (input: {
|
|
209
|
+
messages: readonly ThreadMessage[];
|
|
210
|
+
}) => AsyncGenerator<{ prompt: string }[]>;
|
|
211
|
+
};
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
```ts
|
|
215
|
+
const suggestionAdapter: SuggestionAdapter = {
|
|
216
|
+
async *generate({ messages }) {
|
|
217
|
+
const last = messages.at(-1);
|
|
218
|
+
if (!last) return;
|
|
219
|
+
const response = await fetch("/api/suggestions", {
|
|
220
|
+
method: "POST",
|
|
221
|
+
body: JSON.stringify(last),
|
|
222
|
+
});
|
|
223
|
+
yield (await response.json()).suggestions;
|
|
224
|
+
},
|
|
225
|
+
};
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
## Thread list adapter
|
|
229
|
+
|
|
230
|
+
Multi-thread support is documented separately, since the contract differs by runtime. See [threads](/docs/runtimes/concepts/threads).
|
|
231
|
+
|
|
232
|
+
## Composing adapters
|
|
233
|
+
|
|
234
|
+
Adapters compose freely. Provide as many or as few as you need; UI surfaces enable based on which slots are filled.
|
|
235
|
+
|
|
236
|
+
```ts
|
|
237
|
+
const runtime = useLocalRuntime(modelAdapter, {
|
|
238
|
+
adapters: {
|
|
239
|
+
attachments: myAttachmentAdapter,
|
|
240
|
+
history: myHistoryAdapter,
|
|
241
|
+
speech: mySpeechAdapter,
|
|
242
|
+
feedback: myFeedbackAdapter,
|
|
243
|
+
},
|
|
244
|
+
});
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
## Related
|
|
248
|
+
|
|
249
|
+
<Cards>
|
|
250
|
+
<Card
|
|
251
|
+
title="Threads"
|
|
252
|
+
description="Multi-thread support: cloud, custom database, ExternalStore."
|
|
253
|
+
href="/docs/runtimes/concepts/threads"
|
|
254
|
+
/>
|
|
255
|
+
<Card
|
|
256
|
+
title="Architecture"
|
|
257
|
+
description="The three-layer runtime model and how adapters fit in."
|
|
258
|
+
href="/docs/runtimes/concepts/architecture"
|
|
259
|
+
/>
|
|
260
|
+
<Card
|
|
261
|
+
title="Pick a runtime"
|
|
262
|
+
description="Choose the right runtime for your backend."
|
|
263
|
+
href="/docs/runtimes/pick-a-runtime"
|
|
264
|
+
/>
|
|
265
|
+
</Cards>
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Runtime architecture
|
|
3
|
+
description: How core runtimes, protocol layers, and framework adapters fit together.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
assistant-ui exposes runtime integrations at three layers. Understanding which layer you are picking from clarifies what each runtime gives you and how features flow between them.
|
|
7
|
+
|
|
8
|
+
## The three layers
|
|
9
|
+
|
|
10
|
+
```mermaid
|
|
11
|
+
graph TD
|
|
12
|
+
subgraph Framework["Framework adapters"]
|
|
13
|
+
A1[react-ai-sdk]
|
|
14
|
+
A2[react-langgraph]
|
|
15
|
+
A3[react-langchain]
|
|
16
|
+
A4[react-google-adk]
|
|
17
|
+
A5[react-a2a]
|
|
18
|
+
A6[react-ag-ui]
|
|
19
|
+
A7[react-opencode]
|
|
20
|
+
end
|
|
21
|
+
subgraph Protocol["Protocol layers"]
|
|
22
|
+
P1[DataStream]
|
|
23
|
+
P2[AssistantTransport]
|
|
24
|
+
end
|
|
25
|
+
subgraph Core["Core runtimes"]
|
|
26
|
+
C1[LocalRuntime]
|
|
27
|
+
C2[ExternalStoreRuntime]
|
|
28
|
+
end
|
|
29
|
+
A1 --> C2
|
|
30
|
+
A2 --> C2
|
|
31
|
+
A3 --> C2
|
|
32
|
+
A4 --> C2
|
|
33
|
+
A5 --> C2
|
|
34
|
+
A6 --> C2
|
|
35
|
+
A7 --> C2
|
|
36
|
+
P1 --> C1
|
|
37
|
+
P2 --> C2
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Each upper layer is implemented in terms of a lower one. You can drop down a layer whenever you need more control, but most users start at the framework layer and never touch the others.
|
|
41
|
+
|
|
42
|
+
## Core runtimes
|
|
43
|
+
|
|
44
|
+
These own everything assistant-ui considers a runtime: messages, threads, branching, edit and regenerate state, run lifecycle. Every other layer is built on one of them.
|
|
45
|
+
|
|
46
|
+
**`LocalRuntime`** keeps state inside the runtime itself and exposes a `ChatModelAdapter` interface. You implement a single `run` function (or `async *run` for streaming) and the runtime takes care of branching, editing, regeneration, and history through built-in plumbing.
|
|
47
|
+
|
|
48
|
+
**`ExternalStoreRuntime`** is the inverse: you own the message array and provide callbacks (`onNew`, `onEdit`, `onReload`, etc.). The runtime renders whatever you give it. UI features turn on based on which callbacks are present.
|
|
49
|
+
|
|
50
|
+
| Concern | LocalRuntime | ExternalStoreRuntime |
|
|
51
|
+
| --- | --- | --- |
|
|
52
|
+
| State ownership | Runtime | You |
|
|
53
|
+
| Setup complexity | Low | Medium |
|
|
54
|
+
| Branching | Built in | Requires `setMessages` |
|
|
55
|
+
| Editing | Built in | Requires `onEdit` |
|
|
56
|
+
| Best fit | Greenfield projects | Redux, zustand, tanstack-query stacks |
|
|
57
|
+
|
|
58
|
+
See [LocalRuntime](/docs/runtimes/custom/local-runtime) and [ExternalStoreRuntime](/docs/runtimes/custom/external-store) for full guides.
|
|
59
|
+
|
|
60
|
+
## Protocol layers
|
|
61
|
+
|
|
62
|
+
These wrap a core runtime with a wire-protocol contract so a generic backend can talk to assistant-ui without writing a custom `ChatModelAdapter` each time.
|
|
63
|
+
|
|
64
|
+
**`DataStream`** is a message-streaming protocol. Your backend emits a standardized stream of message parts (text deltas, tool calls) and `useDataStreamRuntime` consumes it on top of `LocalRuntime`. Closest to "AI SDK style streaming for any backend".
|
|
65
|
+
|
|
66
|
+
**`AssistantTransport`** is a state-streaming protocol. Your backend sends snapshots of its agent state and the runtime converts them into UI messages on top of `ExternalStoreRuntime`. Closest to "stream the whole agent state, not just messages".
|
|
67
|
+
|
|
68
|
+
| Protocol | Layered on | Choose when |
|
|
69
|
+
| --- | --- | --- |
|
|
70
|
+
| DataStream | LocalRuntime | Your backend already speaks the data stream protocol, or you want a thin message-stream contract |
|
|
71
|
+
| AssistantTransport | ExternalStoreRuntime | Your agent has internal state worth surfacing, or you need bidirectional commands and custom command types |
|
|
72
|
+
|
|
73
|
+
## Framework adapters
|
|
74
|
+
|
|
75
|
+
The fastest path. Each adapter wraps one of the core or protocol layers and adds framework-specific conveniences.
|
|
76
|
+
|
|
77
|
+
| Adapter | Layered on | Targets |
|
|
78
|
+
| --- | --- | --- |
|
|
79
|
+
| `react-ai-sdk` | `ExternalStoreRuntime` | Vercel AI SDK v6 (`useChat`) |
|
|
80
|
+
| `react-langgraph` | `ExternalStoreRuntime` | LangGraph Cloud via `@langchain/langgraph-sdk` |
|
|
81
|
+
| `react-langchain` | `ExternalStoreRuntime` | LangGraph Cloud via `@langchain/react`'s `useStream` |
|
|
82
|
+
| `react-google-adk` | `ExternalStoreRuntime` | Google ADK JS or Python agents |
|
|
83
|
+
| `react-a2a` | `ExternalStoreRuntime` | Any A2A v1.0 protocol server |
|
|
84
|
+
| `react-ag-ui` | `ExternalStoreRuntime` | AG-UI protocol agents (CopilotKit, custom servers) |
|
|
85
|
+
| `react-opencode` | `ExternalStoreRuntime` | OpenCode coding-agent server (experimental) |
|
|
86
|
+
|
|
87
|
+
When an adapter exposes a feature like attachments, speech, or feedback, it does so through the same [adapter interfaces](/docs/runtimes/concepts/adapters) the core runtimes use. A feature implemented once works the same way across runtimes.
|
|
88
|
+
|
|
89
|
+
## How features flow
|
|
90
|
+
|
|
91
|
+
A few things follow predictable patterns regardless of layer:
|
|
92
|
+
|
|
93
|
+
- **Adapters** (attachments, speech, feedback, history, suggestions) are configured the same way and carry the same contract everywhere. See [adapters](/docs/runtimes/concepts/adapters).
|
|
94
|
+
- **Threads** (single, cloud, custom database) work via a shared `RemoteThreadListAdapter` for `LocalRuntime`-based runtimes and a separate `ExternalStoreThreadListAdapter` for `ExternalStoreRuntime`. See [threads](/docs/runtimes/concepts/threads).
|
|
95
|
+
- **Unstable APIs** are surfaced with an `unstable_` prefix and may change in any release. See [stability](/docs/runtimes/concepts/stability).
|
|
96
|
+
|
|
97
|
+
## Choosing a layer
|
|
98
|
+
|
|
99
|
+
Start at the top, descend only when blocked.
|
|
100
|
+
|
|
101
|
+
1. **Framework adapter** if your backend matches one. You get streaming, threads, and adapter slots without writing protocol code.
|
|
102
|
+
2. **Protocol layer** if no framework adapter fits but you can pick a wire format. `DataStream` for message streaming, `AssistantTransport` for state streaming.
|
|
103
|
+
3. **Core runtime** if your situation is too custom for a protocol. `LocalRuntime` for simple cases, `ExternalStoreRuntime` if you already have a store.
|
|
104
|
+
|
|
105
|
+
If you are unsure, start at [picking a runtime](/docs/runtimes/pick-a-runtime).
|
|
106
|
+
|
|
107
|
+
## Related
|
|
108
|
+
|
|
109
|
+
<Cards>
|
|
110
|
+
<Card
|
|
111
|
+
title="Adapters"
|
|
112
|
+
description="Attachments, speech, feedback, history, suggestions across runtimes."
|
|
113
|
+
href="/docs/runtimes/concepts/adapters"
|
|
114
|
+
/>
|
|
115
|
+
<Card
|
|
116
|
+
title="Threads"
|
|
117
|
+
description="Multi-thread support: cloud, custom database, ExternalStore."
|
|
118
|
+
href="/docs/runtimes/concepts/threads"
|
|
119
|
+
/>
|
|
120
|
+
<Card
|
|
121
|
+
title="Stability"
|
|
122
|
+
description="What unstable_ means and which APIs may change."
|
|
123
|
+
href="/docs/runtimes/concepts/stability"
|
|
124
|
+
/>
|
|
125
|
+
</Cards>
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Stability
|
|
3
|
+
description: What unstable_ means, when APIs become stable, and how to track changes.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
assistant-ui ships some APIs with an `unstable_` prefix. This is a deliberate signal, not a bug.
|
|
7
|
+
|
|
8
|
+
## What `unstable_` means
|
|
9
|
+
|
|
10
|
+
An `unstable_` prefix tells you that the API is exposed publicly so you can build against it, but the surface (signature, naming, semantics, return shape) may change in any release including patch releases.
|
|
11
|
+
|
|
12
|
+
If you depend on an unstable API:
|
|
13
|
+
|
|
14
|
+
- **Pin your dependency range** so an automatic minor or patch update cannot rewrite the contract under you.
|
|
15
|
+
- **Isolate the call site** behind a small wrapper in your code so you can adapt to upstream changes in one place.
|
|
16
|
+
- **Expect renames or removals** when the API stabilizes; the prefix gets dropped on the stable form.
|
|
17
|
+
|
|
18
|
+
## Why we ship them
|
|
19
|
+
|
|
20
|
+
Three reasons something stays `unstable_`:
|
|
21
|
+
|
|
22
|
+
1. **The design is still in flux** and we want feedback on the current shape before committing.
|
|
23
|
+
2. **The API depends on internals** we are still rearranging, so the surface tracks that motion.
|
|
24
|
+
3. **The use case is real today** but stable-api expectations (semver discipline, comprehensive coverage, docs) have not been met yet.
|
|
25
|
+
|
|
26
|
+
## Currently unstable APIs
|
|
27
|
+
|
|
28
|
+
A non-exhaustive list of `unstable_` exports surfaced in the runtime docs.
|
|
29
|
+
|
|
30
|
+
| API | Package | Notes |
|
|
31
|
+
| --- | --- | --- |
|
|
32
|
+
| `unstable_createMessageConverter` | `@assistant-ui/react` | Message-format converter used by AssistantTransport and DataStream. |
|
|
33
|
+
| `unstable_humanToolNames` | `@assistant-ui/react` | Tool names that pause for human approval. Only available on LocalRuntime; not supported in DataStream. |
|
|
34
|
+
| `unstable_threadListAdapter` | `@assistant-ui/react-langgraph` | LangGraph thread-list adapter slot on `useLangGraphRuntime`. |
|
|
35
|
+
| `unstable_createLangGraphStream` | `@assistant-ui/react-langgraph` | End-to-end cancellation primitive. |
|
|
36
|
+
| `unstable_Provider` | Various adapters | Thread-scoped provider on `RemoteThreadListAdapter`. Must render children synchronously. |
|
|
37
|
+
| `unstable_capabilities` | `ExternalStoreRuntime` | Toggle copy and other thread capabilities. |
|
|
38
|
+
| `unstable_state`, `unstable_annotations`, `unstable_data` | Message metadata | Runtime-internal fields exposed for advanced use cases. |
|
|
39
|
+
| `unstable_assistantMessageId`, `unstable_threadId`, `unstable_parentId`, `unstable_getMessage` | `ChatModelRunOptions` | Identifiers and accessors passed to your `ChatModelAdapter.run`. |
|
|
40
|
+
|
|
41
|
+
Framework adapters list their own unstable surface in the corresponding adapter pages.
|
|
42
|
+
|
|
43
|
+
## When something stabilizes
|
|
44
|
+
|
|
45
|
+
Stabilization usually drops the prefix. If `unstable_foo` becomes stable, the new export is `foo`, the old name is kept as a deprecated alias for at least one minor cycle, and the changelog calls out the change.
|
|
46
|
+
|
|
47
|
+
Watch the [release notes](https://github.com/assistant-ui/assistant-ui/releases) and the [migration guides](/docs/migrations) for transitions.
|
|
48
|
+
|
|
49
|
+
## Related
|
|
50
|
+
|
|
51
|
+
<Cards>
|
|
52
|
+
<Card
|
|
53
|
+
title="Architecture"
|
|
54
|
+
description="The three-layer runtime model."
|
|
55
|
+
href="/docs/runtimes/concepts/architecture"
|
|
56
|
+
/>
|
|
57
|
+
<Card
|
|
58
|
+
title="Adapters"
|
|
59
|
+
description="The shared adapter contracts."
|
|
60
|
+
href="/docs/runtimes/concepts/adapters"
|
|
61
|
+
/>
|
|
62
|
+
<Card
|
|
63
|
+
title="Threads"
|
|
64
|
+
description="Multi-thread support patterns."
|
|
65
|
+
href="/docs/runtimes/concepts/threads"
|
|
66
|
+
/>
|
|
67
|
+
</Cards>
|