@assistant-ui/mcp-docs-server 0.1.9 → 0.1.11
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/with-ai-sdk-v5.md +26 -26
- package/.docs/organized/code-examples/with-assistant-transport.md +29 -29
- package/.docs/organized/code-examples/with-cloud.md +21 -21
- package/.docs/organized/code-examples/with-external-store.md +18 -18
- package/.docs/organized/code-examples/with-ffmpeg.md +22 -22
- package/.docs/organized/code-examples/with-langgraph.md +35 -120
- package/.docs/organized/code-examples/with-parent-id-grouping.md +18 -18
- package/.docs/organized/code-examples/with-react-hook-form.md +27 -27
- package/.docs/raw/docs/api-reference/primitives/Thread.mdx +40 -8
- package/.docs/raw/docs/cloud/persistence/langgraph.mdx +64 -68
- package/.docs/raw/docs/getting-started.mdx +541 -152
- package/.docs/raw/docs/guides/Attachments.mdx +21 -0
- package/.docs/raw/docs/guides/ToolUI.mdx +112 -37
- package/.docs/raw/docs/guides/Tools.mdx +170 -6
- package/.docs/raw/docs/migrations/react-langgraph-v0-7.mdx +324 -0
- package/.docs/raw/docs/runtimes/ai-sdk/use-chat.mdx +2 -2
- package/.docs/raw/docs/runtimes/custom/custom-thread-list.mdx +218 -0
- package/.docs/raw/docs/runtimes/custom/external-store.mdx +31 -24
- package/.docs/raw/docs/runtimes/langgraph/index.mdx +55 -20
- package/.docs/raw/docs/runtimes/mastra/separate-server-integration.mdx +8 -3
- package/.docs/raw/docs/runtimes/pick-a-runtime.mdx +1 -1
- package/.docs/raw/docs/ui/AssistantModal.mdx +21 -0
- package/.docs/raw/docs/ui/AssistantSidebar.mdx +21 -0
- package/.docs/raw/docs/ui/Attachment.mdx +21 -0
- package/.docs/raw/docs/ui/Markdown.mdx +22 -1
- package/.docs/raw/docs/ui/Mermaid.mdx +22 -1
- package/.docs/raw/docs/ui/SyntaxHighlighting.mdx +43 -2
- package/.docs/raw/docs/ui/Thread.mdx +374 -5
- package/.docs/raw/docs/ui/ThreadList.mdx +48 -2
- package/.docs/raw/docs/ui/ToolFallback.mdx +21 -0
- package/package.json +7 -7
- package/.docs/raw/docs/migrations/v0-7.mdx +0 -188
- package/.docs/raw/docs/migrations/v0-8.mdx +0 -160
- package/.docs/raw/docs/migrations/v0-9.mdx +0 -75
- package/.docs/raw/docs/ui/primitives/Thread.mdx +0 -197
|
@@ -61,7 +61,6 @@ npm install @assistant-ui/react @assistant-ui/react-ui @assistant-ui/react-langg
|
|
|
61
61
|
```tsx twoslash title="@/api/api/[...path]/route.ts"
|
|
62
62
|
import { NextRequest, NextResponse } from "next/server";
|
|
63
63
|
|
|
64
|
-
|
|
65
64
|
function getCorsHeaders() {
|
|
66
65
|
return {
|
|
67
66
|
"Access-Control-Allow-Origin": "*",
|
|
@@ -188,7 +187,6 @@ export const sendMessage = async (params: {
|
|
|
188
187
|
// ---cut---
|
|
189
188
|
"use client";
|
|
190
189
|
|
|
191
|
-
import { useRef } from "react";
|
|
192
190
|
import { Thread } from "@/components/assistant-ui";
|
|
193
191
|
import { AssistantRuntimeProvider } from "@assistant-ui/react";
|
|
194
192
|
import { useLangGraphRuntime } from "@assistant-ui/react-langgraph";
|
|
@@ -196,27 +194,21 @@ import { useLangGraphRuntime } from "@assistant-ui/react-langgraph";
|
|
|
196
194
|
import { createThread, getThreadState, sendMessage } from "@/lib/chatApi";
|
|
197
195
|
|
|
198
196
|
export function MyAssistant() {
|
|
199
|
-
const threadIdRef = useRef<string | undefined>();
|
|
200
197
|
const runtime = useLangGraphRuntime({
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
if (!
|
|
204
|
-
const { thread_id } = await createThread();
|
|
205
|
-
threadIdRef.current = thread_id;
|
|
206
|
-
}
|
|
207
|
-
const threadId = threadIdRef.current;
|
|
198
|
+
stream: async (messages, { initialize }) => {
|
|
199
|
+
const { externalId } = await initialize();
|
|
200
|
+
if (!externalId) throw new Error("Thread not found");
|
|
208
201
|
return sendMessage({
|
|
209
|
-
threadId,
|
|
202
|
+
threadId: externalId,
|
|
210
203
|
messages,
|
|
211
204
|
});
|
|
212
205
|
},
|
|
213
|
-
|
|
206
|
+
create: async () => {
|
|
214
207
|
const { thread_id } = await createThread();
|
|
215
|
-
|
|
208
|
+
return { externalId: thread_id };
|
|
216
209
|
},
|
|
217
|
-
|
|
218
|
-
const state = await getThreadState(
|
|
219
|
-
threadIdRef.current = threadId;
|
|
210
|
+
load: async (externalId) => {
|
|
211
|
+
const state = await getThreadState(externalId);
|
|
220
212
|
return {
|
|
221
213
|
messages: state.values.messages,
|
|
222
214
|
interrupts: state.tasks[0]?.interrupts,
|
|
@@ -306,14 +298,57 @@ import { convertLangChainMessages } from "@assistant-ui/react-langgraph";
|
|
|
306
298
|
const threadMessage = convertLangChainMessages(langChainMessage);
|
|
307
299
|
```
|
|
308
300
|
|
|
309
|
-
##
|
|
301
|
+
## Thread Management
|
|
302
|
+
|
|
303
|
+
### Basic Thread Support
|
|
304
|
+
|
|
305
|
+
The `useLangGraphRuntime` hook now includes built-in thread management capabilities:
|
|
306
|
+
|
|
307
|
+
```typescript
|
|
308
|
+
const runtime = useLangGraphRuntime({
|
|
309
|
+
stream: async (messages, { initialize }) => {
|
|
310
|
+
// initialize() creates or loads a thread and returns its IDs
|
|
311
|
+
const { remoteId, externalId } = await initialize();
|
|
312
|
+
// Use externalId (your backend's thread ID) for API calls
|
|
313
|
+
return sendMessage({ threadId: externalId, messages });
|
|
314
|
+
},
|
|
315
|
+
create: async () => {
|
|
316
|
+
// Called when creating a new thread
|
|
317
|
+
const { thread_id } = await createThread();
|
|
318
|
+
return { externalId: thread_id };
|
|
319
|
+
},
|
|
320
|
+
load: async (externalId) => {
|
|
321
|
+
// Called when loading an existing thread
|
|
322
|
+
const state = await getThreadState(externalId);
|
|
323
|
+
return {
|
|
324
|
+
messages: state.values.messages,
|
|
325
|
+
interrupts: state.tasks[0]?.interrupts,
|
|
326
|
+
};
|
|
327
|
+
},
|
|
328
|
+
});
|
|
329
|
+
```
|
|
310
330
|
|
|
311
|
-
|
|
331
|
+
### Cloud Persistence
|
|
332
|
+
|
|
333
|
+
For persistent thread history across sessions, integrate with assistant-cloud:
|
|
334
|
+
|
|
335
|
+
```typescript
|
|
336
|
+
const runtime = useLangGraphRuntime({
|
|
337
|
+
cloud: new AssistantCloud({
|
|
338
|
+
baseUrl: process.env.NEXT_PUBLIC_ASSISTANT_BASE_URL,
|
|
339
|
+
}),
|
|
340
|
+
// ... stream, create, load functions
|
|
341
|
+
});
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
See the [Cloud Persistence guide](/docs/cloud/persistence/langgraph) for detailed setup instructions.
|
|
345
|
+
|
|
346
|
+
## Interrupt Persistence
|
|
312
347
|
|
|
313
|
-
|
|
348
|
+
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:
|
|
314
349
|
|
|
315
350
|
1. Make sure your thread state type includes the `interrupts` field
|
|
316
|
-
2. Return the interrupts from `
|
|
351
|
+
2. Return the interrupts from the `load` function along with the messages
|
|
317
352
|
3. The runtime will automatically restore the interrupt state when switching threads
|
|
318
353
|
|
|
319
354
|
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.
|
|
@@ -140,14 +140,19 @@ Open the main page file in your assistant-ui frontend project (usually `app/page
|
|
|
140
140
|
```tsx {10} title="app/page.tsx"
|
|
141
141
|
"use client";
|
|
142
142
|
import { Thread } from "@/components/assistant-ui/thread";
|
|
143
|
-
import {
|
|
143
|
+
import {
|
|
144
|
+
useChatRuntime,
|
|
145
|
+
AssistantChatTransport,
|
|
146
|
+
} from "@assistant-ui/react-ai-sdk";
|
|
144
147
|
import { AssistantRuntimeProvider } from "@assistant-ui/react";
|
|
145
148
|
import { ThreadList } from "@/components/assistant-ui/thread-list";
|
|
146
149
|
|
|
147
150
|
export default function Home() {
|
|
148
151
|
// Point the runtime to the Mastra server endpoint
|
|
149
|
-
const runtime =
|
|
150
|
-
|
|
152
|
+
const runtime = useChatRuntime({
|
|
153
|
+
transport: new AssistantChatTransport({
|
|
154
|
+
api: "MASTRA_ENDPOINT",
|
|
155
|
+
}),
|
|
151
156
|
});
|
|
152
157
|
|
|
153
158
|
return (
|
|
@@ -223,5 +223,5 @@ Explore our implementation examples:
|
|
|
223
223
|
5. **Consider Assistant Cloud** for production persistence
|
|
224
224
|
|
|
225
225
|
<Callout type="info">
|
|
226
|
-
Need help? Join our [Discord community](https://discord.gg/
|
|
226
|
+
Need help? Join our [Discord community](https://discord.gg/S9dwgCNEFs) or check the [GitHub](https://github.com/assistant-ui/assistant-ui).
|
|
227
227
|
</Callout>
|
|
@@ -3,6 +3,7 @@ title: AssistantModal
|
|
|
3
3
|
---
|
|
4
4
|
|
|
5
5
|
import { Steps, Step } from "fumadocs-ui/components/steps";
|
|
6
|
+
import { Tab, Tabs } from "fumadocs-ui/components/tabs";
|
|
6
7
|
import { AssistantModalSample } from "../../../components/samples/assistant-modal-sample";
|
|
7
8
|
|
|
8
9
|
## Overview
|
|
@@ -19,10 +20,30 @@ A chat bubble shown in the bottom right corner of the screen. Useful for support
|
|
|
19
20
|
|
|
20
21
|
### Add `assistant-modal`
|
|
21
22
|
|
|
23
|
+
<Tabs items={["assistant-ui", "shadcn (namespace)", "shadcn"]}>
|
|
24
|
+
<Tab>
|
|
25
|
+
|
|
26
|
+
```sh
|
|
27
|
+
npx assistant-ui@latest add assistant-modal
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
</Tab>
|
|
31
|
+
<Tab>
|
|
32
|
+
|
|
33
|
+
```sh
|
|
34
|
+
npx shadcn@latest add @assistant-ui/assistant-modal
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
</Tab>
|
|
38
|
+
<Tab>
|
|
39
|
+
|
|
22
40
|
```sh
|
|
23
41
|
npx shadcn@latest add "https://r.assistant-ui.com/assistant-modal"
|
|
24
42
|
```
|
|
25
43
|
|
|
44
|
+
</Tab>
|
|
45
|
+
</Tabs>
|
|
46
|
+
|
|
26
47
|
This adds `/components/assistant-ui/assistant-modal.tsx` to your project, which you can adjust as needed.
|
|
27
48
|
|
|
28
49
|
</Step>
|
|
@@ -3,6 +3,7 @@ title: AssistantSidebar
|
|
|
3
3
|
---
|
|
4
4
|
|
|
5
5
|
import { Steps, Step } from "fumadocs-ui/components/steps";
|
|
6
|
+
import { Tab, Tabs } from "fumadocs-ui/components/tabs";
|
|
6
7
|
|
|
7
8
|
## Overview
|
|
8
9
|
|
|
@@ -15,10 +16,30 @@ A chat sidebar show on the right side of the screen. Useful for co-pilot use cas
|
|
|
15
16
|
|
|
16
17
|
### Add `assistant-sidebar`
|
|
17
18
|
|
|
19
|
+
<Tabs items={["assistant-ui", "shadcn (namespace)", "shadcn"]}>
|
|
20
|
+
<Tab>
|
|
21
|
+
|
|
22
|
+
```sh
|
|
23
|
+
npx assistant-ui@latest add assistant-sidebar
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
</Tab>
|
|
27
|
+
<Tab>
|
|
28
|
+
|
|
29
|
+
```sh
|
|
30
|
+
npx shadcn@latest add @assistant-ui/assistant-sidebar
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
</Tab>
|
|
34
|
+
<Tab>
|
|
35
|
+
|
|
18
36
|
```sh
|
|
19
37
|
npx shadcn@latest add "https://r.assistant-ui.com/assistant-sidebar"
|
|
20
38
|
```
|
|
21
39
|
|
|
40
|
+
</Tab>
|
|
41
|
+
</Tabs>
|
|
42
|
+
|
|
22
43
|
This adds `/components/assistant-ui/assistant-sidebar.tsx` to your project, which you can adjust as needed.
|
|
23
44
|
|
|
24
45
|
</Step>
|
|
@@ -5,6 +5,7 @@ title: Attachment
|
|
|
5
5
|
import { Steps, Step } from "fumadocs-ui/components/steps";
|
|
6
6
|
import { AttachmentSample } from "../../../components/samples/attachment-sample";
|
|
7
7
|
import { Callout } from "fumadocs-ui/components/callout";
|
|
8
|
+
import { Tab, Tabs } from "fumadocs-ui/components/tabs";
|
|
8
9
|
|
|
9
10
|
## Overview
|
|
10
11
|
|
|
@@ -26,10 +27,30 @@ The Attachment components let the user attach files and view the attachments.
|
|
|
26
27
|
|
|
27
28
|
### Add `attachment`
|
|
28
29
|
|
|
30
|
+
<Tabs items={["assistant-ui", "shadcn (namespace)", "shadcn"]}>
|
|
31
|
+
<Tab>
|
|
32
|
+
|
|
33
|
+
```sh
|
|
34
|
+
npx assistant-ui@latest add attachment
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
</Tab>
|
|
38
|
+
<Tab>
|
|
39
|
+
|
|
40
|
+
```sh
|
|
41
|
+
npx shadcn@latest add @assistant-ui/attachment
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
</Tab>
|
|
45
|
+
<Tab>
|
|
46
|
+
|
|
29
47
|
```sh
|
|
30
48
|
npx shadcn@latest add "https://r.assistant-ui.com/attachment"
|
|
31
49
|
```
|
|
32
50
|
|
|
51
|
+
</Tab>
|
|
52
|
+
</Tabs>
|
|
53
|
+
|
|
33
54
|
This adds a `/components/assistant-ui/attachment.tsx` file to your project, which you can adjust as needed.
|
|
34
55
|
|
|
35
56
|
</Step>
|
|
@@ -6,6 +6,7 @@ Allow the assistant to display rich text using markdown.
|
|
|
6
6
|
|
|
7
7
|
import { Step, Steps } from "fumadocs-ui/components/steps";
|
|
8
8
|
import { Callout } from "fumadocs-ui/components/callout";
|
|
9
|
+
import { Tab, Tabs } from "fumadocs-ui/components/tabs";
|
|
9
10
|
|
|
10
11
|
<Callout>
|
|
11
12
|
Markdown support is already included by default in the `Thread` component.
|
|
@@ -18,10 +19,30 @@ import { Callout } from "fumadocs-ui/components/callout";
|
|
|
18
19
|
<Step>
|
|
19
20
|
### Add `markdown-text`
|
|
20
21
|
|
|
21
|
-
|
|
22
|
+
<Tabs items={["assistant-ui", "shadcn (namespace)", "shadcn"]}>
|
|
23
|
+
<Tab>
|
|
24
|
+
|
|
25
|
+
```sh
|
|
26
|
+
npx assistant-ui@latest add markdown-text
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
</Tab>
|
|
30
|
+
<Tab>
|
|
31
|
+
|
|
32
|
+
```sh
|
|
33
|
+
npx shadcn@latest add @assistant-ui/markdown-text
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
</Tab>
|
|
37
|
+
<Tab>
|
|
38
|
+
|
|
39
|
+
```sh
|
|
22
40
|
npx shadcn@latest add "https://r.assistant-ui.com/markdown-text"
|
|
23
41
|
```
|
|
24
42
|
|
|
43
|
+
</Tab>
|
|
44
|
+
</Tabs>
|
|
45
|
+
|
|
25
46
|
This adds a `/components/assistant-ui/markdown-text.tsx` file to your project, which you can adjust as needed.
|
|
26
47
|
|
|
27
48
|
</Step>
|
|
@@ -4,6 +4,7 @@ title: "Mermaid Diagrams"
|
|
|
4
4
|
|
|
5
5
|
import { Callout } from "fumadocs-ui/components/callout";
|
|
6
6
|
import { Step, Steps } from "fumadocs-ui/components/steps";
|
|
7
|
+
import { Tab, Tabs } from "fumadocs-ui/components/tabs";
|
|
7
8
|
|
|
8
9
|
Render Mermaid diagrams in chat messages with the `mermaid-diagram` component.
|
|
9
10
|
|
|
@@ -12,10 +13,30 @@ Render Mermaid diagrams in chat messages with the `mermaid-diagram` component.
|
|
|
12
13
|
|
|
13
14
|
### Add `mermaid-diagram` component
|
|
14
15
|
|
|
15
|
-
|
|
16
|
+
<Tabs items={["assistant-ui", "shadcn (namespace)", "shadcn"]}>
|
|
17
|
+
<Tab>
|
|
18
|
+
|
|
19
|
+
```sh
|
|
20
|
+
npx assistant-ui@latest add mermaid-diagram
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
</Tab>
|
|
24
|
+
<Tab>
|
|
25
|
+
|
|
26
|
+
```sh
|
|
27
|
+
npx shadcn@latest add @assistant-ui/mermaid-diagram
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
</Tab>
|
|
31
|
+
<Tab>
|
|
32
|
+
|
|
33
|
+
```sh
|
|
16
34
|
npx shadcn@latest add "https://r.assistant-ui.com/mermaid-diagram"
|
|
17
35
|
```
|
|
18
36
|
|
|
37
|
+
</Tab>
|
|
38
|
+
</Tabs>
|
|
39
|
+
|
|
19
40
|
This will install the required dependencies and add the component to your project.
|
|
20
41
|
|
|
21
42
|
</Step>
|
|
@@ -5,6 +5,7 @@ title: Syntax Highlighting
|
|
|
5
5
|
import { Steps, Step } from "fumadocs-ui/components/steps";
|
|
6
6
|
import { Callout } from "fumadocs-ui/components/callout";
|
|
7
7
|
import { TypeTable } from "fumadocs-ui/components/type-table";
|
|
8
|
+
import { Tab, Tabs } from "fumadocs-ui/components/tabs";
|
|
8
9
|
|
|
9
10
|
Syntax highlighting for code blocks in markdown.
|
|
10
11
|
|
|
@@ -25,10 +26,30 @@ Syntax highlighting for code blocks in markdown.
|
|
|
25
26
|
|
|
26
27
|
#### Add `shiki-highlighter`
|
|
27
28
|
|
|
28
|
-
|
|
29
|
+
<Tabs items={["assistant-ui", "shadcn (namespace)", "shadcn"]}>
|
|
30
|
+
<Tab>
|
|
31
|
+
|
|
32
|
+
```sh
|
|
33
|
+
npx assistant-ui@latest add shiki-highlighter
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
</Tab>
|
|
37
|
+
<Tab>
|
|
38
|
+
|
|
39
|
+
```sh
|
|
40
|
+
npx shadcn@latest add @assistant-ui/shiki-highlighter
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
</Tab>
|
|
44
|
+
<Tab>
|
|
45
|
+
|
|
46
|
+
```sh
|
|
29
47
|
npx shadcn@latest add "https://r.assistant-ui.com/shiki-highlighter"
|
|
30
48
|
```
|
|
31
49
|
|
|
50
|
+
</Tab>
|
|
51
|
+
</Tabs>
|
|
52
|
+
|
|
32
53
|
This adds a `/components/assistant-ui/shiki-highlighter.tsx` file to your project and
|
|
33
54
|
installs the `react-shiki` dependency. The highlighter can be customized by editing
|
|
34
55
|
the config in the `shiki-highlighter.tsx` file.
|
|
@@ -216,10 +237,30 @@ For more information, see [Shiki's documentation on dual and multi themes](https
|
|
|
216
237
|
|
|
217
238
|
#### Add `syntax-highlighter`
|
|
218
239
|
|
|
219
|
-
|
|
240
|
+
<Tabs items={["assistant-ui", "shadcn (namespace)", "shadcn"]}>
|
|
241
|
+
<Tab>
|
|
242
|
+
|
|
243
|
+
```sh
|
|
244
|
+
npx assistant-ui@latest add syntax-highlighter
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
</Tab>
|
|
248
|
+
<Tab>
|
|
249
|
+
|
|
250
|
+
```sh
|
|
251
|
+
npx shadcn@latest add @assistant-ui/syntax-highlighter
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
</Tab>
|
|
255
|
+
<Tab>
|
|
256
|
+
|
|
257
|
+
```sh
|
|
220
258
|
npx shadcn@latest add "https://r.assistant-ui.com/syntax-highlighter"
|
|
221
259
|
```
|
|
222
260
|
|
|
261
|
+
</Tab>
|
|
262
|
+
</Tabs>
|
|
263
|
+
|
|
223
264
|
Adds a `/components/assistant-ui/syntax-highlighter.tsx` file to your project and installs the `react-syntax-highlighter` dependency.
|
|
224
265
|
|
|
225
266
|
</Step>
|