@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.
Files changed (214) hide show
  1. package/.docs/organized/code-examples/waterfall.md +15 -7
  2. package/.docs/organized/code-examples/with-a2a.md +9 -21
  3. package/.docs/organized/code-examples/with-ag-ui.md +11 -8
  4. package/.docs/organized/code-examples/with-ai-sdk-v6.md +10 -10
  5. package/.docs/organized/code-examples/with-artifacts.md +12 -10
  6. package/.docs/organized/code-examples/with-assistant-transport.md +11 -12
  7. package/.docs/organized/code-examples/with-chain-of-thought.md +83 -54
  8. package/.docs/organized/code-examples/with-cloud-standalone.md +14 -11
  9. package/.docs/organized/code-examples/with-cloud.md +9 -10
  10. package/.docs/organized/code-examples/with-custom-thread-list.md +61 -16
  11. package/.docs/organized/code-examples/with-elevenlabs-conversational.md +17 -12
  12. package/.docs/organized/code-examples/with-elevenlabs-scribe.md +13 -13
  13. package/.docs/organized/code-examples/with-expo.md +25 -21
  14. package/.docs/organized/code-examples/with-external-store.md +8 -8
  15. package/.docs/organized/code-examples/with-ffmpeg.md +17 -12
  16. package/.docs/organized/code-examples/with-generative-ui.md +9 -9
  17. package/.docs/organized/code-examples/with-google-adk.md +8 -8
  18. package/.docs/organized/code-examples/with-heat-graph.md +5 -5
  19. package/.docs/organized/code-examples/with-interactables.md +10 -25
  20. package/.docs/organized/code-examples/with-langchain.md +437 -0
  21. package/.docs/organized/code-examples/with-langgraph.md +16 -16
  22. package/.docs/organized/code-examples/with-livekit.md +18 -13
  23. package/.docs/organized/code-examples/with-opencode.md +105 -62
  24. package/.docs/organized/code-examples/with-parent-id-grouping.md +10 -10
  25. package/.docs/organized/code-examples/with-react-hook-form.md +220 -148
  26. package/.docs/organized/code-examples/with-react-ink.md +2 -2
  27. package/.docs/organized/code-examples/with-react-router.md +12 -12
  28. package/.docs/organized/code-examples/with-store.md +8 -5
  29. package/.docs/organized/code-examples/with-tanstack.md +10 -10
  30. package/.docs/organized/code-examples/with-tap-runtime.md +10 -6
  31. package/.docs/raw/docs/(docs)/cli.mdx +2 -1
  32. package/.docs/raw/docs/(docs)/copilots/assistant-frame.mdx +1 -0
  33. package/.docs/raw/docs/(docs)/copilots/make-assistant-tool-ui.mdx +10 -3
  34. package/.docs/raw/docs/(docs)/copilots/make-assistant-tool.mdx +8 -3
  35. package/.docs/raw/docs/(docs)/copilots/make-assistant-visible.mdx +1 -0
  36. package/.docs/raw/docs/(docs)/copilots/model-context.mdx +1 -0
  37. package/.docs/raw/docs/(docs)/copilots/motivation.mdx +1 -0
  38. package/.docs/raw/docs/(docs)/copilots/use-assistant-instructions.mdx +1 -0
  39. package/.docs/raw/docs/(docs)/devtools.mdx +1 -0
  40. package/.docs/raw/docs/(docs)/index.mdx +1 -0
  41. package/.docs/raw/docs/(docs)/installation.mdx +1 -0
  42. package/.docs/raw/docs/(docs)/rtl.mdx +80 -0
  43. package/.docs/raw/docs/(reference)/api-reference/adapters/attachments.mdx +34 -0
  44. package/.docs/raw/docs/(reference)/api-reference/adapters/feedback-speech.mdx +41 -0
  45. package/.docs/raw/docs/(reference)/api-reference/adapters/index.mdx +26 -0
  46. package/.docs/raw/docs/(reference)/api-reference/adapters/persistence.mdx +34 -0
  47. package/.docs/raw/docs/(reference)/api-reference/adapters/runtime.mdx +31 -0
  48. package/.docs/raw/docs/(reference)/api-reference/context-providers/index.mdx +20 -0
  49. package/.docs/raw/docs/(reference)/api-reference/hooks/index.mdx +26 -0
  50. package/.docs/raw/docs/(reference)/api-reference/hooks/model-context.mdx +72 -0
  51. package/.docs/raw/docs/(reference)/api-reference/hooks/runtimes.mdx +41 -0
  52. package/.docs/raw/docs/(reference)/api-reference/hooks/state.mdx +48 -0
  53. package/.docs/raw/docs/(reference)/api-reference/hooks/utilities.mdx +30 -0
  54. package/.docs/raw/docs/(reference)/api-reference/integrations/index.mdx +23 -0
  55. package/.docs/raw/docs/(reference)/api-reference/overview.mdx +21 -0
  56. package/.docs/raw/docs/(reference)/api-reference/primitives/assistant-if.mdx +7 -0
  57. package/.docs/raw/docs/(reference)/api-reference/primitives/composer.mdx +149 -40
  58. package/.docs/raw/docs/(reference)/api-reference/primitives/index.mdx +65 -0
  59. package/.docs/raw/docs/(reference)/api-reference/primitives/message-part.mdx +2 -0
  60. package/.docs/raw/docs/(reference)/api-reference/primitives/message.mdx +50 -6
  61. package/.docs/raw/docs/(reference)/api-reference/primitives/thread-list.mdx +15 -0
  62. package/.docs/raw/docs/(reference)/api-reference/primitives/thread.mdx +36 -1
  63. package/.docs/raw/docs/(reference)/api-reference/runtimes/index.mdx +38 -0
  64. package/.docs/raw/docs/(reference)/api-reference/runtimes/thread-list-runtime.mdx +9 -0
  65. package/.docs/raw/docs/(reference)/migrations/v0-14.mdx +144 -6
  66. package/.docs/raw/docs/cloud/ai-sdk-assistant-ui.mdx +231 -3
  67. package/.docs/raw/docs/cloud/ai-sdk.mdx +221 -3
  68. package/.docs/raw/docs/cloud/langgraph.mdx +274 -2
  69. package/.docs/raw/docs/{(docs)/guides → guides}/attachments.mdx +41 -36
  70. package/.docs/raw/docs/guides/branching.mdx +76 -0
  71. package/.docs/raw/docs/guides/chain-of-thought.mdx +166 -0
  72. package/.docs/raw/docs/{(docs)/guides → guides}/context-api.mdx +50 -22
  73. package/.docs/raw/docs/{(docs)/guides → guides}/dictation.mdx +2 -0
  74. package/.docs/raw/docs/guides/editing.mdx +102 -0
  75. package/.docs/raw/docs/guides/index.mdx +103 -0
  76. package/.docs/raw/docs/{(docs)/guides → guides}/interactables.mdx +49 -0
  77. package/.docs/raw/docs/{(docs)/guides → guides}/latex.mdx +51 -8
  78. package/.docs/raw/docs/guides/mentions.mdx +520 -0
  79. package/.docs/raw/docs/{(docs)/guides → guides}/message-timing.mdx +8 -2
  80. package/.docs/raw/docs/{(docs)/guides → guides}/multi-agent.mdx +64 -4
  81. package/.docs/raw/docs/{(docs)/guides → guides}/quoting.mdx +10 -17
  82. package/.docs/raw/docs/guides/slash-commands.mdx +361 -0
  83. package/.docs/raw/docs/guides/speech.mdx +156 -0
  84. package/.docs/raw/docs/{(docs)/guides → guides}/suggestions.mdx +21 -83
  85. package/.docs/raw/docs/{(docs)/guides → guides}/tool-ui.mdx +108 -36
  86. package/.docs/raw/docs/{(docs)/guides → guides}/tools.mdx +131 -35
  87. package/.docs/raw/docs/{(docs)/guides → guides}/voice.mdx +39 -0
  88. package/.docs/raw/docs/ink/index.mdx +1 -3
  89. package/.docs/raw/docs/ink/migration.mdx +1 -3
  90. package/.docs/raw/docs/ink/primitives.mdx +37 -1
  91. package/.docs/raw/docs/integrations/attachments/custom-adapter.mdx +520 -0
  92. package/.docs/raw/docs/integrations/auth/better-auth.mdx +191 -0
  93. package/.docs/raw/docs/integrations/auth/clerk.mdx +172 -0
  94. package/.docs/raw/docs/integrations/auth/next-auth.mdx +196 -0
  95. package/.docs/raw/docs/integrations/frameworks/ai-sdk.mdx +79 -0
  96. package/.docs/raw/docs/integrations/frameworks/mastra/full-stack.mdx +188 -0
  97. package/.docs/raw/docs/integrations/frameworks/mastra/overview.mdx +57 -0
  98. package/.docs/raw/docs/integrations/frameworks/mastra/separate-server.mdx +201 -0
  99. package/.docs/raw/docs/integrations/gateways/index.mdx +157 -0
  100. package/.docs/raw/docs/integrations/index.mdx +173 -0
  101. package/.docs/raw/docs/integrations/observability/helicone.mdx +130 -0
  102. package/.docs/raw/docs/integrations/observability/langfuse.mdx +156 -0
  103. package/.docs/raw/docs/integrations/observability/langsmith.mdx +146 -0
  104. package/.docs/raw/docs/integrations/persistence/custom-adapter.mdx +712 -0
  105. package/.docs/raw/docs/integrations/tools/mcp.mdx +267 -0
  106. package/.docs/raw/docs/primitives/action-bar.mdx +1 -0
  107. package/.docs/raw/docs/primitives/assistant-modal.mdx +1 -0
  108. package/.docs/raw/docs/primitives/attachment.mdx +1 -0
  109. package/.docs/raw/docs/primitives/branch-picker.mdx +1 -0
  110. package/.docs/raw/docs/primitives/chain-of-thought.mdx +90 -85
  111. package/.docs/raw/docs/primitives/composer.mdx +96 -63
  112. package/.docs/raw/docs/primitives/error.mdx +1 -0
  113. package/.docs/raw/docs/primitives/index.mdx +2 -1
  114. package/.docs/raw/docs/primitives/message.mdx +68 -5
  115. package/.docs/raw/docs/primitives/selection-toolbar.mdx +1 -0
  116. package/.docs/raw/docs/primitives/suggestion.mdx +1 -0
  117. package/.docs/raw/docs/primitives/thread-list.mdx +39 -0
  118. package/.docs/raw/docs/primitives/thread.mdx +16 -13
  119. package/.docs/raw/docs/react-native/index.mdx +1 -3
  120. package/.docs/raw/docs/react-native/migration.mdx +1 -3
  121. package/.docs/raw/docs/runtimes/a2a/client-and-hooks.mdx +396 -0
  122. package/.docs/raw/docs/runtimes/a2a/overview.mdx +60 -0
  123. package/.docs/raw/docs/runtimes/a2a/quickstart.mdx +216 -0
  124. package/.docs/raw/docs/runtimes/ag-ui/overview.mdx +70 -0
  125. package/.docs/raw/docs/runtimes/ag-ui/quickstart.mdx +243 -0
  126. package/.docs/raw/docs/runtimes/ag-ui/runtime-options.mdx +123 -0
  127. package/.docs/raw/docs/runtimes/ai-sdk/overview.mdx +52 -0
  128. package/.docs/raw/docs/runtimes/ai-sdk/v4-legacy.mdx +71 -131
  129. package/.docs/raw/docs/runtimes/ai-sdk/v5-legacy.mdx +69 -63
  130. package/.docs/raw/docs/runtimes/ai-sdk/v6.mdx +365 -101
  131. package/.docs/raw/docs/runtimes/concepts/adapters.mdx +265 -0
  132. package/.docs/raw/docs/runtimes/concepts/architecture.mdx +125 -0
  133. package/.docs/raw/docs/runtimes/concepts/stability.mdx +67 -0
  134. package/.docs/raw/docs/runtimes/concepts/threads.mdx +428 -0
  135. package/.docs/raw/docs/runtimes/custom/assistant-transport.mdx +703 -0
  136. package/.docs/raw/docs/runtimes/custom/data-stream.mdx +323 -0
  137. package/.docs/raw/docs/runtimes/custom/external-store.mdx +253 -1236
  138. package/.docs/raw/docs/runtimes/custom/local-runtime.mdx +746 -0
  139. package/.docs/raw/docs/runtimes/custom/overview.mdx +71 -0
  140. package/.docs/raw/docs/runtimes/google-adk/api.mdx +256 -0
  141. package/.docs/raw/docs/runtimes/google-adk/hooks.mdx +717 -0
  142. package/.docs/raw/docs/runtimes/google-adk/overview.mdx +69 -0
  143. package/.docs/raw/docs/runtimes/google-adk/quickstart.mdx +229 -0
  144. package/.docs/raw/docs/runtimes/langchain.mdx +533 -0
  145. package/.docs/raw/docs/runtimes/langgraph/generative-ui.mdx +305 -0
  146. package/.docs/raw/docs/runtimes/langgraph/interrupts.mdx +104 -0
  147. package/.docs/raw/docs/runtimes/langgraph/overview.mdx +84 -0
  148. package/.docs/raw/docs/runtimes/langgraph/quickstart.mdx +496 -0
  149. package/.docs/raw/docs/runtimes/langgraph/streaming.mdx +127 -0
  150. package/.docs/raw/docs/runtimes/langgraph/threads.mdx +113 -0
  151. package/.docs/raw/docs/runtimes/langgraph/tutorial/introduction.mdx +3 -3
  152. package/.docs/raw/docs/runtimes/langgraph/tutorial/part-1.mdx +0 -23
  153. package/.docs/raw/docs/runtimes/langgraph/tutorial/part-2.mdx +1 -1
  154. package/.docs/raw/docs/runtimes/opencode/hooks.mdx +191 -0
  155. package/.docs/raw/docs/runtimes/opencode/overview.mdx +48 -0
  156. package/.docs/raw/docs/runtimes/opencode/quickstart.mdx +119 -0
  157. package/.docs/raw/docs/runtimes/pick-a-runtime.mdx +74 -198
  158. package/.docs/raw/docs/ui/accordion.mdx +1 -0
  159. package/.docs/raw/docs/ui/assistant-modal.mdx +1 -0
  160. package/.docs/raw/docs/ui/assistant-sidebar.mdx +1 -0
  161. package/.docs/raw/docs/ui/attachment.mdx +1 -0
  162. package/.docs/raw/docs/ui/badge.mdx +1 -0
  163. package/.docs/raw/docs/ui/composer-trigger-popover.mdx +200 -0
  164. package/.docs/raw/docs/ui/context-display.mdx +1 -0
  165. package/.docs/raw/docs/ui/diff-viewer.mdx +1 -0
  166. package/.docs/raw/docs/ui/directive-text.mdx +114 -0
  167. package/.docs/raw/docs/ui/file.mdx +1 -0
  168. package/.docs/raw/docs/ui/image.mdx +1 -0
  169. package/.docs/raw/docs/ui/markdown.mdx +2 -14
  170. package/.docs/raw/docs/ui/mermaid.mdx +1 -0
  171. package/.docs/raw/docs/ui/message-timing.mdx +3 -2
  172. package/.docs/raw/docs/ui/model-selector.mdx +1 -0
  173. package/.docs/raw/docs/ui/part-grouping.mdx +325 -313
  174. package/.docs/raw/docs/ui/quote.mdx +1 -0
  175. package/.docs/raw/docs/ui/reasoning.mdx +69 -32
  176. package/.docs/raw/docs/ui/scrollbar.mdx +1 -0
  177. package/.docs/raw/docs/ui/select.mdx +1 -0
  178. package/.docs/raw/docs/ui/sources.mdx +1 -0
  179. package/.docs/raw/docs/ui/streamdown.mdx +1 -0
  180. package/.docs/raw/docs/ui/syntax-highlighting.mdx +1 -0
  181. package/.docs/raw/docs/ui/tabs.mdx +1 -0
  182. package/.docs/raw/docs/ui/thread-list.mdx +17 -0
  183. package/.docs/raw/docs/ui/thread.mdx +56 -1
  184. package/.docs/raw/docs/ui/tool-fallback.mdx +1 -0
  185. package/.docs/raw/docs/ui/tool-group.mdx +39 -11
  186. package/.docs/raw/docs/ui/voice.mdx +1 -0
  187. package/.docs/raw/docs/utilities/heat-graph.mdx +1 -0
  188. package/.docs/raw/docs/utilities/react-o11y.mdx +278 -0
  189. package/.docs/raw/docs/utilities/tw-shimmer.mdx +1 -0
  190. package/dist/utils/logger.js +1 -1
  191. package/dist/utils/logger.js.map +1 -1
  192. package/package.json +4 -4
  193. package/src/tools/tests/path-traversal.test.ts +1 -1
  194. package/src/utils/logger.ts +1 -1
  195. package/.docs/raw/docs/(docs)/guides/branching.mdx +0 -65
  196. package/.docs/raw/docs/(docs)/guides/chain-of-thought.mdx +0 -164
  197. package/.docs/raw/docs/(docs)/guides/editing.mdx +0 -66
  198. package/.docs/raw/docs/(docs)/guides/mentions.mdx +0 -406
  199. package/.docs/raw/docs/(docs)/guides/slash-commands.mdx +0 -275
  200. package/.docs/raw/docs/(docs)/guides/speech.mdx +0 -38
  201. package/.docs/raw/docs/runtimes/a2a/index.mdx +0 -298
  202. package/.docs/raw/docs/runtimes/assistant-transport.mdx +0 -1033
  203. package/.docs/raw/docs/runtimes/custom/custom-thread-list.mdx +0 -268
  204. package/.docs/raw/docs/runtimes/custom/local.mdx +0 -1464
  205. package/.docs/raw/docs/runtimes/data-stream.mdx +0 -422
  206. package/.docs/raw/docs/runtimes/google-adk/index.mdx +0 -686
  207. package/.docs/raw/docs/runtimes/helicone.mdx +0 -61
  208. package/.docs/raw/docs/runtimes/langgraph/index.mdx +0 -607
  209. package/.docs/raw/docs/runtimes/langgraph/tutorial/index.mdx +0 -12
  210. package/.docs/raw/docs/runtimes/langserve.mdx +0 -116
  211. package/.docs/raw/docs/runtimes/mastra/full-stack-integration.mdx +0 -218
  212. package/.docs/raw/docs/runtimes/mastra/overview.mdx +0 -18
  213. package/.docs/raw/docs/runtimes/mastra/separate-server-integration.mdx +0 -217
  214. package/.docs/raw/docs/ui/mention.mdx +0 -168
@@ -1,61 +0,0 @@
1
- ---
2
- title: Helicone
3
- description: Configure Helicone proxy for OpenAI API logging and monitoring.
4
- ---
5
-
6
- Helicone acts as a proxy for your OpenAI API calls, enabling detailed logging and monitoring. To integrate, update your API base URL and add the Helicone-Auth header.
7
-
8
- ## AI SDK by vercel
9
-
10
- 1. **Set Environment Variables:**
11
-
12
- - `HELICONE_API_KEY`
13
- - `OPENAI_API_KEY`
14
-
15
- 2. **Configure the OpenAI client:**
16
-
17
- ```ts
18
- import { createOpenAI } from "@ai-sdk/openai";
19
- import { streamText } from "ai";
20
-
21
- const openai = createOpenAI({
22
- baseURL: "https://oai.helicone.ai/v1",
23
- headers: {
24
- "Helicone-Auth": `Bearer ${process.env.HELICONE_API_KEY}`,
25
- },
26
- });
27
-
28
- export async function POST(req: Request) {
29
- const { prompt } = await req.json();
30
- return streamText({
31
- model: openai("gpt-4o"),
32
- prompt,
33
- }).toUIMessageStreamResponse();
34
- }
35
- ```
36
-
37
- ## LangChain Integration (Python)
38
-
39
- 1. **Set Environment Variables:**
40
-
41
- - `HELICONE_API_KEY`
42
- - `OPENAI_API_KEY`
43
-
44
- 2. **Configure ChatOpenAI:**
45
-
46
- ```python
47
- from langchain_openai import ChatOpenAI
48
- import os
49
-
50
- llm = ChatOpenAI(
51
- model_name="gpt-4o",
52
- temperature=0,
53
- base_url="https://oai.helicone.ai/v1",
54
- api_key=os.environ["OPENAI_API_KEY"],
55
- default_headers={"Helicone-Auth": f"Bearer {os.environ['HELICONE_API_KEY']}"}
56
- )
57
- ```
58
-
59
- ## Summary
60
-
61
- Update your API base URL to `https://oai.helicone.ai/v1` and add the `Helicone-Auth` header with your API key either in your Vercel AI SDK or LangChain configuration.
@@ -1,607 +0,0 @@
1
- ---
2
- title: Getting Started
3
- description: Connect to LangGraph Cloud API for agent workflows with streaming.
4
- ---
5
-
6
- ## Requirements
7
-
8
- You need a LangGraph Cloud API server. You can start a server locally via [LangGraph Studio](https://github.com/langchain-ai/langgraph-studio) or use [LangSmith](https://www.langchain.com/langsmith) for a hosted version.
9
-
10
- The state of the graph you are using must have a `messages` key with a list of LangChain-alike messages.
11
-
12
- ## New project from template
13
-
14
-
15
- <Steps>
16
- <Step>
17
- ### Create a new project based on the LangGraph assistant-ui template
18
-
19
- ```sh
20
- npx create-assistant-ui@latest -t langgraph my-app
21
- ```
22
-
23
- </Step>
24
- <Step>
25
- ### Set environment variables
26
-
27
- Create a `.env.local` file in your project with the following variables:
28
-
29
- ```sh
30
- # LANGCHAIN_API_KEY=your_api_key # for production
31
- # LANGGRAPH_API_URL=your_api_url # for production
32
- NEXT_PUBLIC_LANGGRAPH_API_URL=your_api_url # for development (no api key required)
33
- NEXT_PUBLIC_LANGGRAPH_ASSISTANT_ID=your_graph_id
34
- ```
35
-
36
- </Step>
37
- </Steps>
38
-
39
-
40
- ## Installation in existing React project
41
-
42
- <Steps>
43
- <Step>
44
-
45
- ### Install dependencies
46
-
47
- <InstallCommand npm={["@assistant-ui/react", "@assistant-ui/react-langgraph", "@langchain/langgraph-sdk"]} />
48
-
49
- </Step>
50
- <Step>
51
-
52
- ### Setup a proxy backend endpoint (optional, for production)
53
-
54
- <Callout type="warn">
55
- This example forwards every request to the LangGraph server directly from the
56
- browser. For production use-cases, you should limit the API calls to the
57
- subset of endpoints that you need and perform authorization checks.
58
- </Callout>
59
-
60
- ```tsx twoslash title="@/app/api/[...path]/route.ts"
61
- import { NextRequest, NextResponse } from "next/server";
62
-
63
- function getCorsHeaders() {
64
- return {
65
- "Access-Control-Allow-Origin": "*",
66
- "Access-Control-Allow-Methods": "GET, POST, PUT, PATCH, DELETE, OPTIONS",
67
- "Access-Control-Allow-Headers": "*",
68
- };
69
- }
70
-
71
- async function handleRequest(req: NextRequest, method: string) {
72
- try {
73
- const path = req.nextUrl.pathname.replace(/^\/?api\//, "");
74
- const url = new URL(req.url);
75
- const searchParams = new URLSearchParams(url.search);
76
- searchParams.delete("_path");
77
- searchParams.delete("nxtP_path");
78
- const queryString = searchParams.toString()
79
- ? `?${searchParams.toString()}`
80
- : "";
81
-
82
- const options: RequestInit = {
83
- method,
84
- headers: {
85
- "x-api-key": process.env["LANGCHAIN_API_KEY"] || "",
86
- },
87
- };
88
-
89
- if (["POST", "PUT", "PATCH"].includes(method)) {
90
- options.body = await req.text();
91
- }
92
-
93
- const res = await fetch(
94
- `${process.env["LANGGRAPH_API_URL"]}/${path}${queryString}`,
95
- options,
96
- );
97
-
98
- const headers = new Headers(res.headers);
99
- headers.delete("content-encoding");
100
- headers.delete("content-length");
101
- headers.delete("transfer-encoding");
102
- const corsHeaders = getCorsHeaders();
103
- for (const [key, value] of Object.entries(corsHeaders)) {
104
- headers.set(key, value);
105
- }
106
-
107
- return new NextResponse(res.body, {
108
- status: res.status,
109
- statusText: res.statusText,
110
- headers,
111
- });
112
- } catch (e: unknown) {
113
- if (e instanceof Error) {
114
- const typedError = e as Error & { status?: number };
115
- return NextResponse.json(
116
- { error: typedError.message },
117
- { status: typedError.status ?? 500 },
118
- );
119
- }
120
- return NextResponse.json({ error: "Unknown error" }, { status: 500 });
121
- }
122
- }
123
-
124
- export const GET = (req: NextRequest) => handleRequest(req, "GET");
125
- export const POST = (req: NextRequest) => handleRequest(req, "POST");
126
- export const PUT = (req: NextRequest) => handleRequest(req, "PUT");
127
- export const PATCH = (req: NextRequest) => handleRequest(req, "PATCH");
128
- export const DELETE = (req: NextRequest) => handleRequest(req, "DELETE");
129
- export const OPTIONS = () =>
130
- new NextResponse(null, {
131
- status: 204,
132
- headers: getCorsHeaders(),
133
- });
134
- ```
135
-
136
- </Step>
137
- <Step>
138
-
139
- ### Setup helper functions
140
-
141
- ```tsx twoslash include chatApi title="@/lib/chatApi.ts"
142
- // @filename: /lib/chatApi.ts
143
-
144
- // ---cut---
145
- import { Client, type ThreadState } from "@langchain/langgraph-sdk";
146
- import { LangChainMessage, LangGraphCommand } from "@assistant-ui/react-langgraph";
147
-
148
- const createClient = () => {
149
- const apiUrl = process.env["NEXT_PUBLIC_LANGGRAPH_API_URL"] || "/api";
150
- return new Client({
151
- apiUrl,
152
- });
153
- };
154
-
155
- export const createThread = async () => {
156
- const client = createClient();
157
- return client.threads.create();
158
- };
159
-
160
- export const getThreadState = async (
161
- threadId: string,
162
- ): Promise<ThreadState<{ messages: LangChainMessage[] }>> => {
163
- const client = createClient();
164
- return client.threads.getState(threadId);
165
- };
166
-
167
- export const sendMessage = async (params: {
168
- threadId: string;
169
- messages?: LangChainMessage[];
170
- command?: LangGraphCommand;
171
- }) => {
172
- const client = createClient();
173
- return client.runs.stream(
174
- params.threadId,
175
- process.env["NEXT_PUBLIC_LANGGRAPH_ASSISTANT_ID"]!,
176
- {
177
- input: params.messages?.length
178
- ? { messages: params.messages }
179
- : null,
180
- command: params.command,
181
- // Include "custom" if you use LangSmith Generative UI
182
- // (`push_ui_message` / `typedUi().push()`). See the Generative UI
183
- // section below for details.
184
- streamMode: ["messages", "updates", "custom"],
185
- },
186
- );
187
- };
188
- ```
189
-
190
- </Step>
191
- <Step>
192
-
193
- ### Define a `MyAssistant` component
194
-
195
- ```tsx twoslash include MyAssistant title="@/components/MyAssistant.tsx"
196
- // @filename: /components/MyAssistant.tsx
197
- // @include: chatApi
198
-
199
- // ---cut---
200
- "use client";
201
-
202
- import { Thread } from "@/components/assistant-ui/thread";
203
- import { AssistantRuntimeProvider } from "@assistant-ui/react";
204
- import { useLangGraphRuntime } from "@assistant-ui/react-langgraph";
205
-
206
- import { createThread, getThreadState, sendMessage } from "@/lib/chatApi";
207
-
208
- export function MyAssistant() {
209
- const runtime = useLangGraphRuntime({
210
- stream: async function* (messages, { initialize, command }) {
211
- const { externalId } = await initialize();
212
- if (!externalId) throw new Error("Thread not found");
213
-
214
- const generator = await sendMessage({
215
- threadId: externalId,
216
- messages,
217
- command,
218
- });
219
-
220
- yield* generator;
221
- },
222
- create: async () => {
223
- const { thread_id } = await createThread();
224
- return { externalId: thread_id };
225
- },
226
- load: async (externalId) => {
227
- const state = await getThreadState(externalId);
228
- return {
229
- messages: state.values.messages,
230
- interrupts: state.tasks[0]?.interrupts,
231
- };
232
- },
233
- });
234
-
235
- return (
236
- <AssistantRuntimeProvider runtime={runtime}>
237
- <Thread />
238
- </AssistantRuntimeProvider>
239
- );
240
- }
241
- ```
242
-
243
- </Step>
244
- <Step>
245
-
246
- ### Use the `MyAssistant` component
247
-
248
- ```tsx twoslash title="@/app/page.tsx" {1,6}
249
- // @include: MyAssistant
250
- // @filename: /app/page.tsx
251
- // ---cut---
252
- import { MyAssistant } from "@/components/MyAssistant";
253
-
254
- export default function Home() {
255
- return (
256
- <main className="h-dvh">
257
- <MyAssistant />
258
- </main>
259
- );
260
- }
261
- ```
262
-
263
- </Step>
264
- <Step>
265
-
266
- ### Setup environment variables
267
-
268
- Create a `.env.local` file in your project with the following variables:
269
-
270
- ```sh
271
- # LANGCHAIN_API_KEY=your_api_key # for production
272
- # LANGGRAPH_API_URL=your_api_url # for production
273
- NEXT_PUBLIC_LANGGRAPH_API_URL=your_api_url # for development (no api key required)
274
- NEXT_PUBLIC_LANGGRAPH_ASSISTANT_ID=your_graph_id
275
- ```
276
-
277
- </Step>
278
- <Step>
279
-
280
- ### Setup UI components
281
-
282
- Follow the [UI Components](/docs/ui/thread) guide to setup the UI components.
283
-
284
- </Step>
285
- </Steps>
286
-
287
- ## Advanced APIs
288
-
289
- ### Message Accumulator
290
-
291
- The `LangGraphMessageAccumulator` lets you append messages incoming from the server to replicate the messages state client side.
292
-
293
- ```typescript
294
- import {
295
- LangGraphMessageAccumulator,
296
- appendLangChainChunk,
297
- } from "@assistant-ui/react-langgraph";
298
-
299
- const accumulator = new LangGraphMessageAccumulator({
300
- appendMessage: appendLangChainChunk,
301
- });
302
-
303
- // Add new chunks from the server
304
- if (event.event === "messages/partial") accumulator.addMessages(event.data);
305
- ```
306
-
307
- ### Message Conversion
308
-
309
- Use `convertLangChainMessages` to transform LangChain messages to assistant-ui format:
310
-
311
- ```typescript
312
- import { convertLangChainMessages } from "@assistant-ui/react-langgraph";
313
-
314
- const threadMessage = convertLangChainMessages(langChainMessage);
315
- ```
316
-
317
- ### Event Handlers
318
-
319
- You can listen to streaming events by passing `eventHandlers` to `useLangGraphRuntime`:
320
-
321
- ```typescript
322
- const runtime = useLangGraphRuntime({
323
- stream: async (messages, { initialize, ...config }) => { /* ... */ },
324
- eventHandlers: {
325
- onMessageChunk: (chunk, metadata) => {
326
- // Fired for each chunk in messages-tuple mode
327
- // metadata contains langgraph_step, langgraph_node, ls_model_name, etc.
328
- },
329
- onValues: (values) => {
330
- // Fired when a "values" event is received
331
- },
332
- onUpdates: (updates) => {
333
- // Fired when an "updates" event is received
334
- },
335
- onMetadata: (metadata) => { /* thread metadata */ },
336
- onInfo: (info) => { /* informational messages */ },
337
- onError: (error) => { /* stream errors */ },
338
- onCustomEvent: (type, data) => { /* custom events */ },
339
- },
340
- });
341
- ```
342
-
343
- ### Message Metadata
344
-
345
- When using `streamMode: "messages-tuple"`, each chunk includes metadata from the LangGraph server. Access accumulated metadata per message with the `useLangGraphMessageMetadata` hook:
346
-
347
- ```typescript
348
- import { useLangGraphMessageMetadata } from "@assistant-ui/react-langgraph";
349
-
350
- function MyComponent() {
351
- const metadata = useLangGraphMessageMetadata();
352
- // Map<string, LangGraphTupleMetadata> keyed by message ID
353
- }
354
- ```
355
-
356
- ## Thread Management
357
-
358
- ### Basic Thread Support
359
-
360
- The `useLangGraphRuntime` hook now includes built-in thread management capabilities:
361
-
362
- ```typescript
363
- const runtime = useLangGraphRuntime({
364
- stream: async (messages, { initialize, ...config }) => {
365
- // initialize() creates or loads a thread and returns its IDs
366
- const { remoteId, externalId } = await initialize();
367
- // Use externalId (your backend's thread ID) for API calls
368
- return sendMessage({ threadId: externalId, messages, config });
369
- },
370
- create: async () => {
371
- // Called when creating a new thread
372
- const { thread_id } = await createThread();
373
- return { externalId: thread_id };
374
- },
375
- load: async (externalId) => {
376
- // Called when loading an existing thread
377
- const state = await getThreadState(externalId);
378
- return {
379
- messages: state.values.messages,
380
- interrupts: state.tasks[0]?.interrupts,
381
- };
382
- },
383
- });
384
- ```
385
-
386
- ### Cloud Persistence
387
-
388
- For persistent thread history across sessions, integrate with assistant-cloud:
389
-
390
- ```typescript
391
- const runtime = useLangGraphRuntime({
392
- cloud: new AssistantCloud({
393
- baseUrl: process.env.NEXT_PUBLIC_ASSISTANT_BASE_URL,
394
- anonymous: true,
395
- }),
396
- // ... stream, create, load functions
397
- });
398
- ```
399
-
400
- See the [Cloud Persistence guide](/docs/cloud/langgraph) for detailed setup instructions.
401
-
402
- ## Message Editing & Regeneration
403
-
404
- LangGraph uses server-side checkpoints for state management. To support message editing (branching) and regeneration, you need to provide a `getCheckpointId` callback that resolves the appropriate checkpoint for server-side forking.
405
-
406
- ```typescript
407
- const runtime = useLangGraphRuntime({
408
- stream: async (messages, { initialize, ...config }) => {
409
- const { externalId } = await initialize();
410
- if (!externalId) throw new Error("Thread not found");
411
- return sendMessage({ threadId: externalId, messages, config });
412
- },
413
- create: async () => {
414
- const { thread_id } = await createThread();
415
- return { externalId: thread_id };
416
- },
417
- load: async (externalId) => {
418
- const state = await getThreadState(externalId);
419
- return {
420
- messages: state.values.messages,
421
- interrupts: state.tasks[0]?.interrupts,
422
- };
423
- },
424
- getCheckpointId: async (threadId, parentMessages) => {
425
- const client = createClient();
426
- // Get the thread state history and find the checkpoint
427
- // that matches the parent messages by exact message ID sequence.
428
- // If IDs are missing, return null and skip edit/reload for safety.
429
- const history = await client.threads.getHistory(threadId);
430
- for (const state of history) {
431
- const stateMessages = state.values.messages;
432
- if (!stateMessages || stateMessages.length !== parentMessages.length) {
433
- continue;
434
- }
435
-
436
- const hasStableIds =
437
- parentMessages.every((message) => typeof message.id === "string") &&
438
- stateMessages.every((message) => typeof message.id === "string");
439
- if (!hasStableIds) {
440
- continue;
441
- }
442
-
443
- const isMatch = parentMessages.every(
444
- (message, index) => message.id === stateMessages[index]?.id,
445
- );
446
-
447
- if (isMatch) {
448
- return state.checkpoint.checkpoint_id ?? null;
449
- }
450
- }
451
- return null;
452
- },
453
- });
454
- ```
455
-
456
- When `getCheckpointId` is provided:
457
- - **Edit buttons** appear on user messages, allowing users to edit and resend from that point
458
- - **Regenerate buttons** appear on assistant messages, allowing users to regenerate the response
459
-
460
- 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 the helper function in the setup section above).
461
-
462
- <Callout type="info">
463
- Without `getCheckpointId`, the edit and regenerate buttons will not appear. This is intentional — simply truncating client-side messages without forking from the correct server-side checkpoint would produce incorrect state.
464
- </Callout>
465
-
466
- ## Interrupt Persistence
467
-
468
- 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:
469
-
470
- 1. Make sure your thread state type includes the `interrupts` field
471
- 2. Return the interrupts from the `load` function along with the messages
472
- 3. The runtime will automatically restore the interrupt state when switching threads
473
-
474
- This feature is particularly useful for applications that require user approval flows, multi-step forms, or any other interactive elements that might span multiple thread switches.
475
-
476
- ## Generative UI (`ui_message`)
477
-
478
- 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 LangGraph adapter translates these into [`DataMessagePart`s](/docs/guides/tool-ui) on the associated assistant message, which you render with the existing `makeAssistantDataUI` API.
479
-
480
- ### Enable the `custom` stream mode
481
-
482
- UI messages are emitted through LangGraph's `custom` stream channel. Make sure your `sendMessage` helper includes `"custom"` in `streamMode`:
483
-
484
- ```ts
485
- streamMode: ["messages", "updates", "custom"]
486
- ```
487
-
488
- Alternatively, if your graph accumulates UI messages in state under the `ui` key (the default for `typedUi`), `"values"` also works — the adapter reads both paths.
489
-
490
- ### Custom state key
491
-
492
- If your graph uses a non-default `stateKey` with `typedUi(config, { stateKey: "my_ui" })` on the server, pass the matching `uiStateKey` option to `useLangGraphRuntime` on the client:
493
-
494
- ```ts
495
- const runtime = useLangGraphRuntime({
496
- stream: async function* (messages, { initialize }) { /* ... */ },
497
- uiStateKey: "my_ui",
498
- });
499
- ```
500
-
501
- This only affects the `values` stream path — the `custom` channel carries each UI event individually and doesn't rely on the state key.
502
-
503
- ### Emit a UI message from your graph
504
-
505
- ```python title="Python"
506
- from langgraph.graph.ui import push_ui_message
507
- from langchain_core.messages import AIMessage
508
-
509
- async def chart_node(state, config):
510
- message = AIMessage(id="msg-1", content="Here's your chart.")
511
- push_ui_message(
512
- "chart",
513
- {"series": [1, 2, 3], "title": "Sales"},
514
- message=message, # Links the UI to this AI message
515
- )
516
- return {"messages": [message]}
517
- ```
518
-
519
- ```ts title="TypeScript"
520
- import { typedUi } from "@langchain/langgraph-sdk/react-ui/server";
521
- import type { ComponentRegistry } from "./components";
522
-
523
- export async function chartNode(state, config) {
524
- const ui = typedUi<ComponentRegistry>(config);
525
- const message = { id: "msg-1", type: "ai", content: "Here's your chart." };
526
- ui.push(
527
- { name: "chart", props: { series: [1, 2, 3], title: "Sales" } },
528
- { message },
529
- );
530
- return { messages: [message] };
531
- }
532
- ```
533
-
534
- 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.
535
-
536
- ### Register a renderer on the client
537
-
538
- ```tsx title="@/components/ChartUI.tsx"
539
- import { makeAssistantDataUI } from "@assistant-ui/react";
540
-
541
- type ChartProps = {
542
- series: number[];
543
- title: string;
544
- };
545
-
546
- export const ChartUI = makeAssistantDataUI<ChartProps>({
547
- name: "chart",
548
- render: ({ data }) => (
549
- <div>
550
- <h3>{data.title}</h3>
551
- <Chart series={data.series} />
552
- </div>
553
- ),
554
- });
555
- ```
556
-
557
- Mount the component once somewhere inside the `AssistantRuntimeProvider` tree. It renders nothing itself — it only registers the renderer:
558
-
559
- ```tsx title="@/components/MyAssistant.tsx"
560
- <AssistantRuntimeProvider runtime={runtime}>
561
- <ChartUI />
562
- <Thread />
563
- </AssistantRuntimeProvider>
564
- ```
565
-
566
- 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.
567
-
568
- ### Semantics
569
-
570
- The adapter mirrors the reducer in `@langchain/langgraph-sdk/react-ui` exactly:
571
-
572
- - UI messages are keyed by their own `id`. Pushing the same id again **replaces** the existing entry
573
- - Passing `metadata: { merge: true }` shallow-merges `props` onto the previous entry
574
- - Emitting `{ type: "remove-ui", id }` (via `delete_ui_message` / `ui.delete(id)`) removes the entry
575
- - 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
576
-
577
- ### Restore persisted UI messages on thread switch
578
-
579
- If your graph persists UI messages in state via `typedUi`, return them from the `load` callback so they're restored when the user switches threads or refreshes the page:
580
-
581
- ```tsx
582
- const runtime = useLangGraphRuntime({
583
- stream: async function* (messages, { initialize }) { /* ... */ },
584
- load: async (externalId) => {
585
- const state = await getThreadState(externalId);
586
- return {
587
- messages: state.values.messages,
588
- uiMessages: state.values.ui,
589
- interrupts: state.tasks[0]?.interrupts,
590
- };
591
- },
592
- });
593
- ```
594
-
595
- Without this, each reload starts with an empty UI list even though the messages themselves are loaded.
596
-
597
- ### Escape hatch: `useLangGraphUIMessages`
598
-
599
- ```tsx
600
- import { useLangGraphUIMessages } from "@assistant-ui/react-langgraph";
601
-
602
- function Sidebar() {
603
- const uiMessages = useLangGraphUIMessages();
604
- // Filter, group, or render UI messages outside the thread
605
- return <>{uiMessages.map(/* ... */)}</>;
606
- }
607
- ```
@@ -1,12 +0,0 @@
1
- ---
2
- title: "Introduction"
3
- description: Build a stockbroker assistant with LangGraph and assistant-ui.
4
- ---
5
-
6
- import { redirect } from "next/navigation";
7
-
8
- <>
9
- {redirect(
10
- "/docs/runtimes/langgraph/tutorial/introduction",
11
- )}
12
- </>