@assistant-ui/mcp-docs-server 0.1.30 → 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 +1 -1
- package/.docs/organized/code-examples/with-a2a.md +2 -2
- package/.docs/organized/code-examples/with-ag-ui.md +3 -3
- package/.docs/organized/code-examples/with-ai-sdk-v6.md +5 -5
- package/.docs/organized/code-examples/with-artifacts.md +5 -5
- package/.docs/organized/code-examples/with-assistant-transport.md +3 -3
- package/.docs/organized/code-examples/with-chain-of-thought.md +79 -50
- package/.docs/organized/code-examples/with-cloud-standalone.md +4 -4
- package/.docs/organized/code-examples/with-cloud.md +4 -4
- package/.docs/organized/code-examples/with-custom-thread-list.md +56 -11
- package/.docs/organized/code-examples/with-elevenlabs-conversational.md +7 -7
- package/.docs/organized/code-examples/with-elevenlabs-scribe.md +7 -7
- package/.docs/organized/code-examples/with-expo.md +16 -16
- package/.docs/organized/code-examples/with-external-store.md +2 -2
- package/.docs/organized/code-examples/with-ffmpeg.md +5 -5
- package/.docs/organized/code-examples/with-generative-ui.md +5 -5
- package/.docs/organized/code-examples/with-google-adk.md +4 -4
- package/.docs/organized/code-examples/with-heat-graph.md +1 -1
- package/.docs/organized/code-examples/with-interactables.md +5 -5
- package/.docs/organized/code-examples/with-langchain.md +3 -3
- package/.docs/organized/code-examples/with-langgraph.md +3 -3
- package/.docs/organized/code-examples/with-livekit.md +8 -8
- package/.docs/organized/code-examples/with-opencode.md +99 -54
- package/.docs/organized/code-examples/with-parent-id-grouping.md +4 -4
- package/.docs/organized/code-examples/with-react-hook-form.md +5 -5
- package/.docs/organized/code-examples/with-react-ink.md +1 -1
- package/.docs/organized/code-examples/with-react-router.md +8 -8
- package/.docs/organized/code-examples/with-store.md +1 -1
- package/.docs/organized/code-examples/with-tanstack.md +5 -5
- package/.docs/organized/code-examples/with-tap-runtime.md +2 -2
- 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 +1 -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/index.mdx +65 -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 +5 -0
- package/.docs/raw/docs/(reference)/migrations/v0-14.mdx +144 -6
- package/.docs/raw/docs/cloud/ai-sdk-assistant-ui.mdx +230 -2
- 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/{(docs)/guides → guides}/mentions.mdx +61 -86
- 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/{(docs)/guides → guides}/slash-commands.mdx +103 -37
- 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 +2 -1
- 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 +330 -123
- package/.docs/raw/docs/runtimes/concepts/adapters.mdx +265 -0
- package/.docs/raw/docs/runtimes/concepts/architecture.mdx +125 -0
- package/.docs/raw/docs/runtimes/concepts/stability.mdx +67 -0
- package/.docs/raw/docs/runtimes/concepts/threads.mdx +428 -0
- package/.docs/raw/docs/runtimes/custom/assistant-transport.mdx +703 -0
- package/.docs/raw/docs/runtimes/custom/data-stream.mdx +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 +71 -203
- package/.docs/raw/docs/ui/accordion.mdx +1 -0
- package/.docs/raw/docs/ui/assistant-modal.mdx +1 -0
- package/.docs/raw/docs/ui/assistant-sidebar.mdx +1 -0
- package/.docs/raw/docs/ui/attachment.mdx +1 -0
- package/.docs/raw/docs/ui/badge.mdx +1 -0
- package/.docs/raw/docs/ui/composer-trigger-popover.mdx +1 -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 +1 -0
- package/.docs/raw/docs/ui/file.mdx +1 -0
- package/.docs/raw/docs/ui/image.mdx +1 -0
- package/.docs/raw/docs/ui/markdown.mdx +2 -14
- package/.docs/raw/docs/ui/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 +66 -33
- package/.docs/raw/docs/ui/scrollbar.mdx +1 -0
- package/.docs/raw/docs/ui/select.mdx +1 -0
- package/.docs/raw/docs/ui/sources.mdx +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/package.json +3 -3
- package/src/tools/tests/path-traversal.test.ts +1 -1
- package/.docs/raw/docs/(docs)/guides/branching.mdx +0 -65
- package/.docs/raw/docs/(docs)/guides/chain-of-thought.mdx +0 -164
- package/.docs/raw/docs/(docs)/guides/editing.mdx +0 -66
- package/.docs/raw/docs/(docs)/guides/speech.mdx +0 -38
- package/.docs/raw/docs/runtimes/a2a/index.mdx +0 -298
- package/.docs/raw/docs/runtimes/assistant-transport.mdx +0 -1033
- package/.docs/raw/docs/runtimes/custom/custom-thread-list.mdx +0 -314
- package/.docs/raw/docs/runtimes/custom/local.mdx +0 -1464
- package/.docs/raw/docs/runtimes/data-stream.mdx +0 -422
- package/.docs/raw/docs/runtimes/google-adk/index.mdx +0 -686
- package/.docs/raw/docs/runtimes/helicone.mdx +0 -61
- package/.docs/raw/docs/runtimes/langchain/comparison.mdx +0 -60
- package/.docs/raw/docs/runtimes/langchain/index.mdx +0 -210
- package/.docs/raw/docs/runtimes/langgraph/index.mdx +0 -699
- package/.docs/raw/docs/runtimes/langgraph/tutorial/index.mdx +0 -12
- package/.docs/raw/docs/runtimes/langserve.mdx +0 -116
- package/.docs/raw/docs/runtimes/mastra/full-stack-integration.mdx +0 -218
- package/.docs/raw/docs/runtimes/mastra/overview.mdx +0 -18
- package/.docs/raw/docs/runtimes/mastra/separate-server-integration.mdx +0 -217
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Generative UI
|
|
3
|
+
description: Render structured UI components emitted by LangGraph alongside assistant messages.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
LangGraph's [Generative UI](https://docs.langchain.com/langsmith/generative-ui-react) lets your graph emit structured UI components alongside assistant messages via `push_ui_message` (Python) or `typedUi().push()` (TypeScript). The assistant-ui adapter translates these into [`DataMessagePart`s](/docs/guides/tool-ui) on the associated assistant message, which you render with the existing `makeAssistantDataUI` API.
|
|
7
|
+
|
|
8
|
+
## Enable the `custom` stream mode
|
|
9
|
+
|
|
10
|
+
UI messages are emitted through LangGraph's `custom` stream channel. Make sure your `sendMessage` helper includes `"custom"` in `streamMode`:
|
|
11
|
+
|
|
12
|
+
```ts
|
|
13
|
+
streamMode: ["messages", "updates", "custom"];
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
If your graph accumulates UI messages in state under the `ui` key (the default for `typedUi`), `"values"` also works; the adapter reads both paths.
|
|
17
|
+
|
|
18
|
+
## Custom state key
|
|
19
|
+
|
|
20
|
+
If your graph uses a non-default `stateKey` with `typedUi(config, { stateKey: "my_ui" })` on the server, pass the matching `uiStateKey` option to `useLangGraphRuntime`:
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
const runtime = useLangGraphRuntime({
|
|
24
|
+
stream: async function* (messages, { initialize }) {
|
|
25
|
+
/* ... */
|
|
26
|
+
},
|
|
27
|
+
uiStateKey: "my_ui",
|
|
28
|
+
});
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
This only affects the `values` stream path; the `custom` channel carries each UI event individually and does not rely on the state key.
|
|
32
|
+
|
|
33
|
+
## Emit a UI message from your graph
|
|
34
|
+
|
|
35
|
+
<Tabs items={["Python", "TypeScript"]}>
|
|
36
|
+
<Tab value="Python">
|
|
37
|
+
|
|
38
|
+
```python
|
|
39
|
+
from langgraph.graph.ui import push_ui_message
|
|
40
|
+
from langchain_core.messages import AIMessage
|
|
41
|
+
|
|
42
|
+
async def chart_node(state, config):
|
|
43
|
+
message = AIMessage(id="msg-1", content="Here's your chart.")
|
|
44
|
+
push_ui_message(
|
|
45
|
+
"chart",
|
|
46
|
+
{"series": [1, 2, 3], "title": "Sales"},
|
|
47
|
+
message=message, # Links the UI to this AI message
|
|
48
|
+
)
|
|
49
|
+
return {"messages": [message]}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
</Tab>
|
|
53
|
+
<Tab value="TypeScript">
|
|
54
|
+
|
|
55
|
+
```ts
|
|
56
|
+
import { typedUi } from "@langchain/langgraph-sdk/react-ui/server";
|
|
57
|
+
import type { ComponentRegistry } from "./components";
|
|
58
|
+
|
|
59
|
+
export async function chartNode(state, config) {
|
|
60
|
+
const ui = typedUi<ComponentRegistry>(config);
|
|
61
|
+
const message = { id: "msg-1", type: "ai", content: "Here's your chart." };
|
|
62
|
+
ui.push(
|
|
63
|
+
{ name: "chart", props: { series: [1, 2, 3], title: "Sales" } },
|
|
64
|
+
{ message },
|
|
65
|
+
);
|
|
66
|
+
return { messages: [message] };
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
</Tab>
|
|
71
|
+
</Tabs>
|
|
72
|
+
|
|
73
|
+
Passing `message` (Python) or `{ message }` (TypeScript) is what links the UI component to a specific assistant message. The adapter reads `metadata.message_id` to attach the generated `DataMessagePart` to the correct message in the thread.
|
|
74
|
+
|
|
75
|
+
## Register a renderer on the client
|
|
76
|
+
|
|
77
|
+
<PlatformTabs>
|
|
78
|
+
<Tab value="React">
|
|
79
|
+
|
|
80
|
+
```tsx title="@/components/ChartUI.tsx"
|
|
81
|
+
import { makeAssistantDataUI } from "@assistant-ui/react";
|
|
82
|
+
|
|
83
|
+
type ChartProps = {
|
|
84
|
+
series: number[];
|
|
85
|
+
title: string;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
export const ChartUI = makeAssistantDataUI<ChartProps>({
|
|
89
|
+
name: "chart",
|
|
90
|
+
render: ({ data }) => (
|
|
91
|
+
<div>
|
|
92
|
+
<h3>{data.title}</h3>
|
|
93
|
+
<Chart series={data.series} />
|
|
94
|
+
</div>
|
|
95
|
+
),
|
|
96
|
+
});
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
</Tab>
|
|
100
|
+
<Tab value="React Native">
|
|
101
|
+
|
|
102
|
+
```tsx title="components/ChartUI.tsx"
|
|
103
|
+
import { makeAssistantDataUI } from "@assistant-ui/react-native";
|
|
104
|
+
import { Text, View } from "react-native";
|
|
105
|
+
|
|
106
|
+
type ChartProps = {
|
|
107
|
+
series: number[];
|
|
108
|
+
title: string;
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
export const ChartUI = makeAssistantDataUI<ChartProps>({
|
|
112
|
+
name: "chart",
|
|
113
|
+
render: ({ data }) => (
|
|
114
|
+
<View>
|
|
115
|
+
<Text>{data.title}</Text>
|
|
116
|
+
<Chart series={data.series} />
|
|
117
|
+
</View>
|
|
118
|
+
),
|
|
119
|
+
});
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
</Tab>
|
|
123
|
+
<Tab value="React Ink">
|
|
124
|
+
|
|
125
|
+
```tsx title="components/chart-ui.tsx"
|
|
126
|
+
import { makeAssistantDataUI } from "@assistant-ui/react-ink";
|
|
127
|
+
import { Box, Text } from "ink";
|
|
128
|
+
|
|
129
|
+
type ChartProps = {
|
|
130
|
+
series: number[];
|
|
131
|
+
title: string;
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
export const ChartUI = makeAssistantDataUI<ChartProps>({
|
|
135
|
+
name: "chart",
|
|
136
|
+
render: ({ data }) => (
|
|
137
|
+
<Box flexDirection="column">
|
|
138
|
+
<Text bold>{data.title}</Text>
|
|
139
|
+
<Chart series={data.series} />
|
|
140
|
+
</Box>
|
|
141
|
+
),
|
|
142
|
+
});
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
</Tab>
|
|
146
|
+
</PlatformTabs>
|
|
147
|
+
|
|
148
|
+
Mount the component once somewhere inside the `AssistantRuntimeProvider` tree. It renders nothing itself; it only registers the renderer:
|
|
149
|
+
|
|
150
|
+
<PlatformTabs>
|
|
151
|
+
<Tab value="React">
|
|
152
|
+
|
|
153
|
+
```tsx title="@/components/MyAssistant.tsx"
|
|
154
|
+
<AssistantRuntimeProvider runtime={runtime}>
|
|
155
|
+
<ChartUI />
|
|
156
|
+
<Thread />
|
|
157
|
+
</AssistantRuntimeProvider>
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
</Tab>
|
|
161
|
+
<Tab value="React Native">
|
|
162
|
+
|
|
163
|
+
```tsx title="components/MyAssistant.tsx"
|
|
164
|
+
import { View } from "react-native";
|
|
165
|
+
import { Thread } from "@/components/assistant-ui/thread";
|
|
166
|
+
|
|
167
|
+
<AssistantRuntimeProvider runtime={runtime}>
|
|
168
|
+
<ChartUI />
|
|
169
|
+
<View style={{ flex: 1 }}>
|
|
170
|
+
<Thread />
|
|
171
|
+
</View>
|
|
172
|
+
</AssistantRuntimeProvider>;
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
</Tab>
|
|
176
|
+
<Tab value="React Ink">
|
|
177
|
+
|
|
178
|
+
```tsx title="components/my-assistant.tsx"
|
|
179
|
+
import { Box } from "ink";
|
|
180
|
+
import { Thread } from "./thread.js";
|
|
181
|
+
|
|
182
|
+
<AssistantRuntimeProvider runtime={runtime}>
|
|
183
|
+
<ChartUI />
|
|
184
|
+
<Box flexDirection="column">
|
|
185
|
+
<Thread />
|
|
186
|
+
</Box>
|
|
187
|
+
</AssistantRuntimeProvider>;
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
</Tab>
|
|
191
|
+
</PlatformTabs>
|
|
192
|
+
|
|
193
|
+
When a matching UI message arrives, the adapter appends a `{ type: "data", name: "chart", data: { series, title } }` part to the parent assistant message and the registered component renders inline.
|
|
194
|
+
|
|
195
|
+
## Register renderers via `uiComponents`
|
|
196
|
+
|
|
197
|
+
Instead of mounting separate `makeAssistantDataUI` components, register renderers directly on the runtime hook:
|
|
198
|
+
|
|
199
|
+
```tsx
|
|
200
|
+
const runtime = useLangGraphRuntime({
|
|
201
|
+
stream: async function* (messages, { initialize }) {
|
|
202
|
+
/* ... */
|
|
203
|
+
},
|
|
204
|
+
uiComponents: {
|
|
205
|
+
renderers: {
|
|
206
|
+
chart: ({ data }) => <Chart series={data.series} title={data.title} />,
|
|
207
|
+
table: ({ data }) => <DataTable rows={data.rows} />,
|
|
208
|
+
},
|
|
209
|
+
},
|
|
210
|
+
});
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
Static `renderers` are matched by `ui_message` name. If no match is found, the part renders nothing unless a `fallback` is provided.
|
|
214
|
+
|
|
215
|
+
## Dynamic loading with `fallback`
|
|
216
|
+
|
|
217
|
+
LangSmith's [Generative UI](https://docs.langchain.com/langsmith/generative-ui-react) supports colocating UI code with your graph and loading it at runtime via `LoadExternalComponent`. The `fallback` option handles any `ui_message` name that has no static renderer:
|
|
218
|
+
|
|
219
|
+
```tsx
|
|
220
|
+
import { LoadExternalComponent } from "@langchain/langgraph-sdk/react-ui";
|
|
221
|
+
|
|
222
|
+
const runtime = useLangGraphRuntime({
|
|
223
|
+
stream: async function* (messages, { initialize }) {
|
|
224
|
+
/* ... */
|
|
225
|
+
},
|
|
226
|
+
uiComponents: {
|
|
227
|
+
fallback: ({ name, data }) => (
|
|
228
|
+
<LoadExternalComponent name={name} props={data} />
|
|
229
|
+
),
|
|
230
|
+
renderers: {
|
|
231
|
+
chart: ({ data }) => <Chart {...data} />,
|
|
232
|
+
},
|
|
233
|
+
},
|
|
234
|
+
});
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
With this setup:
|
|
238
|
+
|
|
239
|
+
- A `ui_message` with `name: "chart"` renders the static `Chart` component.
|
|
240
|
+
- Any other name (e.g. `"dashboard"`, `"form"`) is handled by `fallback`, which fetches the component from LangSmith at runtime.
|
|
241
|
+
|
|
242
|
+
`fallback` receives the same props as any data renderer: `name`, `data`, and part state metadata.
|
|
243
|
+
|
|
244
|
+
## Semantics
|
|
245
|
+
|
|
246
|
+
The adapter mirrors the reducer in `@langchain/langgraph-sdk/react-ui` exactly:
|
|
247
|
+
|
|
248
|
+
- UI messages are keyed by their own `id`. Pushing the same id again **replaces** the existing entry.
|
|
249
|
+
- Passing `metadata: { merge: true }` shallow-merges `props` onto the previous entry.
|
|
250
|
+
- Emitting `{ type: "remove-ui", id }` (via `delete_ui_message` or `ui.delete(id)`) removes the entry.
|
|
251
|
+
- UI messages without `metadata.message_id` are held in the runtime but not injected into any message; use `useLangGraphUIMessages()` to access the raw list if needed.
|
|
252
|
+
|
|
253
|
+
## Restore persisted UI messages on thread switch
|
|
254
|
+
|
|
255
|
+
If your graph persists UI messages in state via `typedUi`, return them from the `load` callback so they are restored when the user switches threads or refreshes the page:
|
|
256
|
+
|
|
257
|
+
```tsx
|
|
258
|
+
const runtime = useLangGraphRuntime({
|
|
259
|
+
stream: async function* (messages, { initialize }) {
|
|
260
|
+
/* ... */
|
|
261
|
+
},
|
|
262
|
+
load: async (externalId) => {
|
|
263
|
+
const state = await getThreadState(externalId);
|
|
264
|
+
return {
|
|
265
|
+
messages: state.values.messages,
|
|
266
|
+
uiMessages: state.values.ui,
|
|
267
|
+
interrupts: state.tasks[0]?.interrupts,
|
|
268
|
+
};
|
|
269
|
+
},
|
|
270
|
+
});
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
Without this, each reload starts with an empty UI list even though the messages themselves are loaded.
|
|
274
|
+
|
|
275
|
+
## Escape hatch: `useLangGraphUIMessages`
|
|
276
|
+
|
|
277
|
+
```tsx
|
|
278
|
+
import { useLangGraphUIMessages } from "@assistant-ui/react-langgraph";
|
|
279
|
+
|
|
280
|
+
function Sidebar() {
|
|
281
|
+
const uiMessages = useLangGraphUIMessages();
|
|
282
|
+
// Filter, group, or render UI messages outside the thread
|
|
283
|
+
return <>{uiMessages.map(/* ... */)}</>;
|
|
284
|
+
}
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
## Related
|
|
288
|
+
|
|
289
|
+
<Cards>
|
|
290
|
+
<Card
|
|
291
|
+
title="Streaming"
|
|
292
|
+
description="Event handlers, message accumulator, conversion, metadata."
|
|
293
|
+
href="/docs/runtimes/langgraph/streaming"
|
|
294
|
+
/>
|
|
295
|
+
<Card
|
|
296
|
+
title="Interrupts"
|
|
297
|
+
description="Interrupt persistence and checkpoint-based message editing."
|
|
298
|
+
href="/docs/runtimes/langgraph/interrupts"
|
|
299
|
+
/>
|
|
300
|
+
<Card
|
|
301
|
+
title="Threads"
|
|
302
|
+
description="Basic thread support, AssistantCloud, custom thread list adapter."
|
|
303
|
+
href="/docs/runtimes/langgraph/threads"
|
|
304
|
+
/>
|
|
305
|
+
</Cards>
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Interrupts and message editing
|
|
3
|
+
description: Interrupt persistence and checkpoint-based message editing.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Both interrupt persistence and message editing rely on LangGraph's server-side checkpoints. Once you have one wired up, the other is mostly free.
|
|
7
|
+
|
|
8
|
+
## Interrupt persistence
|
|
9
|
+
|
|
10
|
+
LangGraph supports interrupting the execution flow to request user input or handle specific interactions. These interrupts can be persisted and restored when switching between threads:
|
|
11
|
+
|
|
12
|
+
1. Make sure your thread state type includes the `interrupts` field.
|
|
13
|
+
2. Return the interrupts from the `load` function along with the messages.
|
|
14
|
+
3. The runtime automatically restores the interrupt state when switching threads.
|
|
15
|
+
|
|
16
|
+
```ts
|
|
17
|
+
const runtime = useLangGraphRuntime({
|
|
18
|
+
stream: async (messages, { initialize, ...config }) => {
|
|
19
|
+
/* ... */
|
|
20
|
+
},
|
|
21
|
+
load: async (externalId) => {
|
|
22
|
+
const state = await getThreadState(externalId);
|
|
23
|
+
return {
|
|
24
|
+
messages: state.values.messages,
|
|
25
|
+
interrupts: state.tasks[0]?.interrupts,
|
|
26
|
+
};
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
This is particularly useful for applications that require user approval flows, multi-step forms, or other interactive elements that span multiple thread switches.
|
|
32
|
+
|
|
33
|
+
## Message editing and regeneration
|
|
34
|
+
|
|
35
|
+
LangGraph uses server-side checkpoints for state management. To support message editing (branching) and regeneration, provide a `getCheckpointId` callback that resolves the appropriate checkpoint for server-side forking.
|
|
36
|
+
|
|
37
|
+
```ts
|
|
38
|
+
const runtime = useLangGraphRuntime({
|
|
39
|
+
stream: async (messages, { initialize, ...config }) => {
|
|
40
|
+
const { externalId } = await initialize();
|
|
41
|
+
if (!externalId) throw new Error("Thread not found");
|
|
42
|
+
return sendMessage({ threadId: externalId, messages, config });
|
|
43
|
+
},
|
|
44
|
+
create: async () => {
|
|
45
|
+
const { thread_id } = await createThread();
|
|
46
|
+
return { externalId: thread_id };
|
|
47
|
+
},
|
|
48
|
+
load: async (externalId) => {
|
|
49
|
+
const state = await getThreadState(externalId);
|
|
50
|
+
return {
|
|
51
|
+
messages: state.values.messages,
|
|
52
|
+
interrupts: state.tasks[0]?.interrupts,
|
|
53
|
+
};
|
|
54
|
+
},
|
|
55
|
+
getCheckpointId: async (threadId, parentMessages) => {
|
|
56
|
+
const client = createClient();
|
|
57
|
+
const history = await client.threads.getHistory(threadId);
|
|
58
|
+
for (const state of history) {
|
|
59
|
+
const stateMessages = state.values.messages;
|
|
60
|
+
if (!stateMessages || stateMessages.length !== parentMessages.length) {
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
const hasStableIds =
|
|
64
|
+
parentMessages.every((m) => typeof m.id === "string") &&
|
|
65
|
+
stateMessages.every((m) => typeof m.id === "string");
|
|
66
|
+
if (!hasStableIds) continue;
|
|
67
|
+
|
|
68
|
+
const isMatch = parentMessages.every(
|
|
69
|
+
(m, i) => m.id === stateMessages[i]?.id,
|
|
70
|
+
);
|
|
71
|
+
if (isMatch) {
|
|
72
|
+
return state.checkpoint.checkpoint_id ?? null;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return null;
|
|
76
|
+
},
|
|
77
|
+
});
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
When `getCheckpointId` is provided:
|
|
81
|
+
|
|
82
|
+
- **Edit buttons** appear on user messages, allowing users to edit and resend from that point.
|
|
83
|
+
- **Regenerate buttons** appear on assistant messages, allowing users to regenerate the response.
|
|
84
|
+
|
|
85
|
+
The resolved `checkpointId` is passed to your `stream` callback via `config.checkpointId`. Your `sendMessage` helper should map it to the LangGraph SDK's `checkpoint_id` parameter (see [quickstart](/docs/runtimes/langgraph/quickstart) for the helper).
|
|
86
|
+
|
|
87
|
+
<Callout type="info">
|
|
88
|
+
Without `getCheckpointId`, edit and regenerate buttons will not appear. This is intentional; truncating client-side messages without forking from the correct server-side checkpoint would produce incorrect state.
|
|
89
|
+
</Callout>
|
|
90
|
+
|
|
91
|
+
## Next
|
|
92
|
+
|
|
93
|
+
<Cards>
|
|
94
|
+
<Card
|
|
95
|
+
title="Threads"
|
|
96
|
+
description="Basic thread support, AssistantCloud, custom thread list adapter."
|
|
97
|
+
href="/docs/runtimes/langgraph/threads"
|
|
98
|
+
/>
|
|
99
|
+
<Card
|
|
100
|
+
title="Streaming"
|
|
101
|
+
description="Event handlers, message metadata, generative UI."
|
|
102
|
+
href="/docs/runtimes/langgraph/streaming"
|
|
103
|
+
/>
|
|
104
|
+
</Cards>
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Overview
|
|
3
|
+
description: Connect to LangGraph Cloud for agent workflows with streaming.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
`@assistant-ui/react-langgraph` integrates with [`@langchain/langgraph-sdk`](https://docs.langchain.com/oss/javascript/langgraph-sdk) directly, exposing the full LangGraph Cloud feature set in assistant-ui: streaming, subgraph events, UI messages, message metadata, interrupts, and end-to-end cancellation.
|
|
7
|
+
|
|
8
|
+
<Callout type="info">
|
|
9
|
+
**Migrating from LangServe?** LangChain has deprecated `RemoteRunnable` upstream and consolidated the chain and agent execution stories under LangGraph. Rebuild your chain as a LangGraph graph (LangChain's [LangServe → LangGraph migration guide](https://github.com/langchain-ai/langserve/blob/main/MIGRATION.md) covers the shape change), deploy via LangGraph Cloud or self-host LangGraph Studio, and use this runtime on the frontend. The runtime ships streaming, interrupts, generative UI, message metadata, and end-to-end cancellation out of the box.
|
|
10
|
+
</Callout>
|
|
11
|
+
|
|
12
|
+
## When to use it
|
|
13
|
+
|
|
14
|
+
Pick the LangGraph runtime when:
|
|
15
|
+
|
|
16
|
+
- You have (or want) a LangGraph Cloud server, locally via [LangGraph Studio](https://github.com/langchain-ai/langgraph-studio) or hosted via [LangSmith](https://www.langchain.com/langsmith).
|
|
17
|
+
- Your graph state has a `messages` key with LangChain-alike messages.
|
|
18
|
+
- You want generative UI (`ui_message`), per-message metadata, subgraph events, or checkpoint-based message editing.
|
|
19
|
+
|
|
20
|
+
<Callout type="info">
|
|
21
|
+
If you are already using `@langchain/react`'s `useStream` hook, the alternative [`@assistant-ui/react-langchain`](/docs/runtimes/langchain) adapter may fit better. It delegates the stream plumbing to the upstream hook; the feature surface differs, see [LangChain useStream](/docs/runtimes/langchain) for the comparison table.
|
|
22
|
+
</Callout>
|
|
23
|
+
|
|
24
|
+
## Architecture
|
|
25
|
+
|
|
26
|
+
`@assistant-ui/react-langgraph` is layered on `ExternalStoreRuntime` (see [architecture](/docs/runtimes/concepts/architecture)). Graph state is the source of truth; the runtime renders messages from `state.values.messages` and submits user input back to the graph.
|
|
27
|
+
|
|
28
|
+
Shared adapters (attachments, speech, feedback, history) work the same way described in [adapters](/docs/runtimes/concepts/adapters).
|
|
29
|
+
|
|
30
|
+
## Requirements
|
|
31
|
+
|
|
32
|
+
- A LangGraph Cloud API server.
|
|
33
|
+
- React 18 or 19.
|
|
34
|
+
- The graph state must include a `messages` key with LangChain-alike messages.
|
|
35
|
+
|
|
36
|
+
## Install
|
|
37
|
+
|
|
38
|
+
<PlatformTabs>
|
|
39
|
+
<Tab value="React">
|
|
40
|
+
|
|
41
|
+
<InstallCommand npm={["@assistant-ui/react", "@assistant-ui/react-langgraph", "@langchain/langgraph-sdk"]} />
|
|
42
|
+
|
|
43
|
+
</Tab>
|
|
44
|
+
<Tab value="React Native">
|
|
45
|
+
|
|
46
|
+
<InstallCommand expo={["@assistant-ui/react-native", "@assistant-ui/react-langgraph", "@langchain/langgraph-sdk"]} />
|
|
47
|
+
|
|
48
|
+
</Tab>
|
|
49
|
+
<Tab value="React Ink">
|
|
50
|
+
|
|
51
|
+
<InstallCommand npm={["@assistant-ui/react-ink", "@assistant-ui/react-langgraph", "@langchain/langgraph-sdk", "ink", "react"]} />
|
|
52
|
+
|
|
53
|
+
</Tab>
|
|
54
|
+
</PlatformTabs>
|
|
55
|
+
|
|
56
|
+
## Next
|
|
57
|
+
|
|
58
|
+
<Cards>
|
|
59
|
+
<Card
|
|
60
|
+
title="Quickstart"
|
|
61
|
+
description="From-template and manual setup paths to a working LangGraph chat."
|
|
62
|
+
href="/docs/runtimes/langgraph/quickstart"
|
|
63
|
+
/>
|
|
64
|
+
<Card
|
|
65
|
+
title="Streaming"
|
|
66
|
+
description="Event handlers, message metadata, generative UI."
|
|
67
|
+
href="/docs/runtimes/langgraph/streaming"
|
|
68
|
+
/>
|
|
69
|
+
<Card
|
|
70
|
+
title="Interrupts"
|
|
71
|
+
description="Interrupt persistence and checkpoint-based message editing."
|
|
72
|
+
href="/docs/runtimes/langgraph/interrupts"
|
|
73
|
+
/>
|
|
74
|
+
<Card
|
|
75
|
+
title="Threads"
|
|
76
|
+
description="Basic thread support, AssistantCloud, custom thread list adapter."
|
|
77
|
+
href="/docs/runtimes/langgraph/threads"
|
|
78
|
+
/>
|
|
79
|
+
<Card
|
|
80
|
+
title="Tutorial: Stockbroker"
|
|
81
|
+
description="End-to-end stockbroker assistant with generative UI and approval flows."
|
|
82
|
+
href="/docs/runtimes/langgraph/tutorial/introduction"
|
|
83
|
+
/>
|
|
84
|
+
</Cards>
|