@assistant-ui/mcp-docs-server 0.1.15 → 0.1.16

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 (55) hide show
  1. package/.docs/organized/code-examples/store-example.md +112 -38
  2. package/.docs/organized/code-examples/with-ag-ui.md +248 -184
  3. package/.docs/organized/code-examples/with-ai-sdk-v5.md +247 -196
  4. package/.docs/organized/code-examples/with-assistant-transport.md +192 -240
  5. package/.docs/organized/code-examples/with-cloud.md +275 -224
  6. package/.docs/organized/code-examples/with-custom-thread-list.md +1855 -0
  7. package/.docs/organized/code-examples/with-external-store.md +244 -178
  8. package/.docs/organized/code-examples/with-ffmpeg.md +253 -187
  9. package/.docs/organized/code-examples/with-langgraph.md +291 -240
  10. package/.docs/organized/code-examples/with-parent-id-grouping.md +241 -261
  11. package/.docs/organized/code-examples/with-react-hook-form.md +260 -194
  12. package/.docs/organized/code-examples/with-tanstack.md +1574 -0
  13. package/.docs/raw/blog/2024-07-29-hello/index.mdx +2 -2
  14. package/.docs/raw/docs/api-reference/overview.mdx +6 -6
  15. package/.docs/raw/docs/api-reference/primitives/ActionBar.mdx +85 -4
  16. package/.docs/raw/docs/api-reference/primitives/AssistantIf.mdx +200 -0
  17. package/.docs/raw/docs/api-reference/primitives/Composer.mdx +0 -20
  18. package/.docs/raw/docs/api-reference/primitives/Message.mdx +0 -45
  19. package/.docs/raw/docs/api-reference/primitives/Thread.mdx +0 -50
  20. package/.docs/raw/docs/cloud/persistence/ai-sdk.mdx +2 -3
  21. package/.docs/raw/docs/cloud/persistence/langgraph.mdx +2 -3
  22. package/.docs/raw/docs/devtools.mdx +2 -3
  23. package/.docs/raw/docs/getting-started.mdx +36 -1102
  24. package/.docs/raw/docs/guides/Attachments.mdx +3 -25
  25. package/.docs/raw/docs/guides/Branching.mdx +1 -1
  26. package/.docs/raw/docs/guides/Speech.mdx +1 -1
  27. package/.docs/raw/docs/guides/ToolUI.mdx +1 -1
  28. package/.docs/raw/docs/legacy/styled/AssistantModal.mdx +2 -3
  29. package/.docs/raw/docs/legacy/styled/Decomposition.mdx +6 -5
  30. package/.docs/raw/docs/legacy/styled/Markdown.mdx +2 -3
  31. package/.docs/raw/docs/legacy/styled/Thread.mdx +2 -3
  32. package/.docs/raw/docs/react-compatibility.mdx +2 -5
  33. package/.docs/raw/docs/runtimes/ai-sdk/use-chat.mdx +3 -4
  34. package/.docs/raw/docs/runtimes/ai-sdk/v4-legacy.mdx +3 -6
  35. package/.docs/raw/docs/runtimes/custom/external-store.mdx +2 -3
  36. package/.docs/raw/docs/runtimes/custom/local.mdx +11 -41
  37. package/.docs/raw/docs/runtimes/data-stream.mdx +15 -11
  38. package/.docs/raw/docs/runtimes/langgraph/index.mdx +3 -3
  39. package/.docs/raw/docs/runtimes/langgraph/tutorial/part-2.mdx +1 -1
  40. package/.docs/raw/docs/runtimes/langgraph/tutorial/part-3.mdx +2 -3
  41. package/.docs/raw/docs/runtimes/langserve.mdx +2 -3
  42. package/.docs/raw/docs/runtimes/mastra/full-stack-integration.mdx +2 -3
  43. package/.docs/raw/docs/runtimes/mastra/separate-server-integration.mdx +2 -3
  44. package/.docs/raw/docs/ui/AssistantModal.mdx +3 -25
  45. package/.docs/raw/docs/ui/AssistantSidebar.mdx +2 -24
  46. package/.docs/raw/docs/ui/Attachment.mdx +3 -25
  47. package/.docs/raw/docs/ui/Markdown.mdx +2 -24
  48. package/.docs/raw/docs/ui/Mermaid.mdx +2 -24
  49. package/.docs/raw/docs/ui/Reasoning.mdx +2 -24
  50. package/.docs/raw/docs/ui/Scrollbar.mdx +4 -6
  51. package/.docs/raw/docs/ui/SyntaxHighlighting.mdx +3 -47
  52. package/.docs/raw/docs/ui/Thread.mdx +38 -53
  53. package/.docs/raw/docs/ui/ThreadList.mdx +4 -47
  54. package/.docs/raw/docs/ui/ToolFallback.mdx +2 -24
  55. package/package.json +5 -6
@@ -6,8 +6,8 @@ date: 2024-07-29T12:00:00
6
6
  ---
7
7
 
8
8
  import Image from "next/image";
9
- import { TestimonialContainer } from "@/components/testimonials/TestimonialContainer";
10
- import { BLOG_TESTIMONIALS } from "@/components/testimonials/testimonials";
9
+ import { TestimonialContainer } from "@/components/home/testimonials/testimonials";
10
+ import { BLOG_TESTIMONIALS } from "@/components/home/testimonials/data";
11
11
  import npmDownloads from "./npm-downloads.png";
12
12
  import assistantUi from "./assistant-ui-screenshot.png";
13
13
 
@@ -239,9 +239,9 @@ A conversation thread.
239
239
  tooltip="Displayed when the thread is empty"
240
240
  />
241
241
  <Component
242
- name="ThreadPrimitive.If"
243
- docsLink="#thread-primitive-if"
244
- tooltip="Conditional rendering within the thread"
242
+ name="AssistantIf"
243
+ docsLink="#assistant-if"
244
+ tooltip="Conditional rendering based on assistant state"
245
245
  />
246
246
  <Component
247
247
  name="ThreadPrimitive.Suggestion"
@@ -383,9 +383,9 @@ Manages the state and actions for individual messages
383
383
  tooltip="Displays attachments in the message"
384
384
  />
385
385
  <Component
386
- name="MessagePrimitive.If"
387
- docsLink="#message-primitive-if"
388
- tooltip="Conditional rendering within the message"
386
+ name="AssistantIf"
387
+ docsLink="#assistant-if"
388
+ tooltip="Conditional rendering based on assistant state"
389
389
  />
390
390
  </Component>
391
391
 
@@ -167,12 +167,12 @@ Show a different icon for a few seconds after the message is copied.
167
167
 
168
168
  ```tsx
169
169
  <ActionBarPrimitive.Copy>
170
- <MessagePrimitive.If copied={false}>
170
+ <AssistantIf condition={({ message }) => !message.isCopied}>
171
171
  <CopyIcon />
172
- </MessagePrimitive.If>
173
- <MessagePrimitive.If copied>
172
+ </AssistantIf>
173
+ <AssistantIf condition={({ message }) => message.isCopied}>
174
174
  <CopySuccessIcon />
175
- </MessagePrimitive.If>
175
+ </AssistantIf>
176
176
  </ActionBarPrimitive.Copy>
177
177
  ```
178
178
 
@@ -262,3 +262,84 @@ This primitive renders a `<button>` element unless `asChild` is set.
262
262
  },
263
263
  ]}
264
264
  />
265
+
266
+ ### ExportMarkdown
267
+
268
+ Exports the message content as a Markdown file download by default, or calls a custom export handler when `onExport` is provided.
269
+
270
+ This primitive renders a `<button>` element unless `asChild` is set.
271
+
272
+ <ParametersTable
273
+ type="ActionBarPrimitiveExportMarkdownProps"
274
+ parameters={[
275
+ {
276
+ name: "asChild",
277
+ },
278
+ {
279
+ name: "filename",
280
+ type: "string",
281
+ description:
282
+ "The filename for the downloaded Markdown file. Defaults to 'message-{timestamp}.md'. Ignored when onExport is provided.",
283
+ },
284
+ {
285
+ name: "onExport",
286
+ type: "(content: string) => void | Promise<void>",
287
+ description:
288
+ "Optional callback function that receives the message content. When provided, overrides the default Markdown download behavior. Use this to implement custom export logic (PDF, JSON, TXT, etc.).",
289
+ },
290
+ ]}
291
+ />
292
+
293
+ #### Examples
294
+
295
+ Default Markdown export:
296
+
297
+ ```tsx
298
+ <ActionBarPrimitive.ExportMarkdown>
299
+ <DownloadIcon />
300
+ Export as Markdown
301
+ </ActionBarPrimitive.ExportMarkdown>
302
+ ```
303
+
304
+ With custom filename:
305
+
306
+ ```tsx
307
+ <ActionBarPrimitive.ExportMarkdown filename="chat-response.md">
308
+ <DownloadIcon />
309
+ Download
310
+ </ActionBarPrimitive.ExportMarkdown>
311
+ ```
312
+
313
+ Export as PDF (with custom logic):
314
+
315
+ ```tsx
316
+ <ActionBarPrimitive.ExportMarkdown
317
+ onExport={async (content) => {
318
+ const pdf = await generatePdf(content);
319
+ downloadFile(pdf, "message.pdf");
320
+ }}
321
+ >
322
+ <FileIcon />
323
+ Export PDF
324
+ </ActionBarPrimitive.ExportMarkdown>
325
+ ```
326
+
327
+ Export as JSON:
328
+
329
+ ```tsx
330
+ <ActionBarPrimitive.ExportMarkdown
331
+ onExport={(content) => {
332
+ const json = JSON.stringify({ content, timestamp: Date.now() });
333
+ const blob = new Blob([json], { type: "application/json" });
334
+ const url = URL.createObjectURL(blob);
335
+ const a = document.createElement("a");
336
+ a.href = url;
337
+ a.download = "message.json";
338
+ a.click();
339
+ URL.revokeObjectURL(url);
340
+ }}
341
+ >
342
+ <CodeIcon />
343
+ Export JSON
344
+ </ActionBarPrimitive.ExportMarkdown>
345
+ ```
@@ -0,0 +1,200 @@
1
+ ---
2
+ title: AssistantIf
3
+ ---
4
+
5
+ Conditionally render children based on assistant state.
6
+
7
+ import { ParametersTable } from "@/components/docs";
8
+ import { Callout } from "fumadocs-ui/components/callout";
9
+
10
+ ## Anatomy
11
+
12
+ ```tsx
13
+ import { AssistantIf } from "@assistant-ui/react";
14
+
15
+ <AssistantIf condition={({ thread }) => thread.isEmpty}>
16
+ <WelcomeScreen />
17
+ </AssistantIf>
18
+ ```
19
+
20
+ ## Overview
21
+
22
+ `AssistantIf` is a generic conditional rendering component that provides access to the full assistant state. It replaces the deprecated `ThreadPrimitive.If`, `MessagePrimitive.If`, and `ComposerPrimitive.If` components with a single, flexible API.
23
+
24
+ ## API Reference
25
+
26
+ <ParametersTable
27
+ type="AssistantIfProps"
28
+ parameters={[
29
+ {
30
+ name: "condition",
31
+ type: "(state: AssistantState) => boolean",
32
+ required: true,
33
+ description: "A function that receives the assistant state and returns whether to render children.",
34
+ },
35
+ {
36
+ name: "children",
37
+ type: "ReactNode",
38
+ description: "Content to render when the condition returns true.",
39
+ },
40
+ ]}
41
+ />
42
+
43
+ ## AssistantState
44
+
45
+ The condition function receives an `AssistantState` object with the following properties:
46
+
47
+ <ParametersTable
48
+ type="AssistantState"
49
+ parameters={[
50
+ {
51
+ name: "thread",
52
+ type: "ThreadState",
53
+ description: "The current thread state (always available).",
54
+ },
55
+ {
56
+ name: "message",
57
+ type: "MessageState",
58
+ description: "The current message state (available within a message context).",
59
+ },
60
+ {
61
+ name: "composer",
62
+ type: "ComposerState",
63
+ description: "The current composer state (always available).",
64
+ },
65
+ {
66
+ name: "part",
67
+ type: "PartState",
68
+ description: "The current message part state (available within a part context).",
69
+ },
70
+ {
71
+ name: "attachment",
72
+ type: "AttachmentState",
73
+ description: "The current attachment state (available within an attachment context).",
74
+ },
75
+ ]}
76
+ />
77
+
78
+ ## Examples
79
+
80
+ ### Thread State Conditions
81
+
82
+ ```tsx
83
+ // Show welcome screen when thread is empty
84
+ <AssistantIf condition={({ thread }) => thread.isEmpty}>
85
+ <WelcomeScreen />
86
+ </AssistantIf>
87
+
88
+ // Show loading indicator while running
89
+ <AssistantIf condition={({ thread }) => thread.isRunning}>
90
+ <LoadingSpinner />
91
+ </AssistantIf>
92
+
93
+ // Conditional send/cancel button
94
+ <AssistantIf condition={({ thread }) => !thread.isRunning}>
95
+ <ComposerPrimitive.Send>Send</ComposerPrimitive.Send>
96
+ </AssistantIf>
97
+ <AssistantIf condition={({ thread }) => thread.isRunning}>
98
+ <ComposerPrimitive.Cancel>Cancel</ComposerPrimitive.Cancel>
99
+ </AssistantIf>
100
+ ```
101
+
102
+ ### Message State Conditions
103
+
104
+ ```tsx
105
+ // Show avatar only for assistant messages
106
+ <AssistantIf condition={({ message }) => message.role === "assistant"}>
107
+ <AssistantAvatar />
108
+ </AssistantIf>
109
+
110
+ // Show disclaimer on last message
111
+ <AssistantIf condition={({ message }) => message.isLast}>
112
+ <Disclaimer />
113
+ </AssistantIf>
114
+
115
+ // Toggle copy icon based on copied state
116
+ <ActionBarPrimitive.Copy>
117
+ <AssistantIf condition={({ message }) => !message.isCopied}>
118
+ <CopyIcon />
119
+ </AssistantIf>
120
+ <AssistantIf condition={({ message }) => message.isCopied}>
121
+ <CheckIcon />
122
+ </AssistantIf>
123
+ </ActionBarPrimitive.Copy>
124
+
125
+ // Show speak/stop button based on speech state
126
+ <AssistantIf condition={({ message }) => message.speech == null}>
127
+ <ActionBarPrimitive.Speak>
128
+ <SpeakIcon />
129
+ </ActionBarPrimitive.Speak>
130
+ </AssistantIf>
131
+ <AssistantIf condition={({ message }) => message.speech != null}>
132
+ <ActionBarPrimitive.StopSpeaking>
133
+ <StopIcon />
134
+ </ActionBarPrimitive.StopSpeaking>
135
+ </AssistantIf>
136
+ ```
137
+
138
+ ### Composer State Conditions
139
+
140
+ ```tsx
141
+ // Show placeholder when composer is empty
142
+ <AssistantIf condition={({ composer }) => composer.isEmpty}>
143
+ <PlaceholderText />
144
+ </AssistantIf>
145
+
146
+ // Show attachment preview when editing
147
+ <AssistantIf condition={({ composer }) => composer.isEditing}>
148
+ <EditingIndicator />
149
+ </AssistantIf>
150
+ ```
151
+
152
+ ### Complex Conditions
153
+
154
+ ```tsx
155
+ // Combine multiple conditions
156
+ <AssistantIf condition={({ thread, message }) =>
157
+ !thread.isRunning && message.role === "assistant"
158
+ }>
159
+ <ActionBar />
160
+ </AssistantIf>
161
+
162
+ // Custom logic
163
+ <AssistantIf condition={({ thread }) =>
164
+ thread.messages.length > 0 && !thread.isRunning
165
+ }>
166
+ <FollowUpSuggestions />
167
+ </AssistantIf>
168
+ ```
169
+
170
+ ## Type Export
171
+
172
+ You can import the `AssistantIf.Condition` type for typing your condition functions:
173
+
174
+ ```tsx
175
+ import { AssistantIf } from "@assistant-ui/react";
176
+
177
+ const isThreadEmpty: AssistantIf.Condition = ({ thread }) => thread.isEmpty;
178
+
179
+ <AssistantIf condition={isThreadEmpty}>
180
+ <WelcomeScreen />
181
+ </AssistantIf>
182
+ ```
183
+
184
+ ## Migration from Deprecated Components
185
+
186
+ <Callout type="warn">
187
+ `ThreadPrimitive.If`, `MessagePrimitive.If`, and `ComposerPrimitive.If` are deprecated. Use `AssistantIf` instead.
188
+ </Callout>
189
+
190
+ | Before | After |
191
+ |--------|-------|
192
+ | `<ThreadPrimitive.If empty>` | `<AssistantIf condition={({ thread }) => thread.isEmpty}>` |
193
+ | `<ThreadPrimitive.If running>` | `<AssistantIf condition={({ thread }) => thread.isRunning}>` |
194
+ | `<ThreadPrimitive.If running={false}>` | `<AssistantIf condition={({ thread }) => !thread.isRunning}>` |
195
+ | `<MessagePrimitive.If user>` | `<AssistantIf condition={({ message }) => message.role === "user"}>` |
196
+ | `<MessagePrimitive.If assistant>` | `<AssistantIf condition={({ message }) => message.role === "assistant"}>` |
197
+ | `<MessagePrimitive.If copied>` | `<AssistantIf condition={({ message }) => message.isCopied}>` |
198
+ | `<MessagePrimitive.If speaking>` | `<AssistantIf condition={({ message }) => message.speech != null}>` |
199
+ | `<MessagePrimitive.If last>` | `<AssistantIf condition={({ message }) => message.isLast}>` |
200
+ | `<ComposerPrimitive.If editing>` | `<AssistantIf condition={({ composer }) => composer.isEditing}>` |
@@ -213,23 +213,3 @@ This primitive renders a `<button>` element unless `asChild` is set.
213
213
  },
214
214
  ]}
215
215
  />
216
-
217
- ### If
218
-
219
- Renders children if a condition is met.
220
-
221
- <ParametersTable
222
- type="UseComposerIfProps"
223
- parameters={[
224
- {
225
- name: "editing",
226
- required: false,
227
- type: "boolean | undefined",
228
- description: "Render children if the message is being edited.",
229
- },
230
- ]}
231
- />
232
-
233
- ```tsx
234
- <Composer.If editing>{/* rendered if message is being edited */}</Composer.If>
235
- ```
@@ -259,51 +259,6 @@ Renders a single attachment at the specified index within the message.
259
259
  ]}
260
260
  />
261
261
 
262
- ### If
263
-
264
- Renders children if a condition is met.
265
-
266
- <ParametersTable
267
- type="UseMessageIfProps"
268
- parameters={[
269
- {
270
- name: "user",
271
- type: "boolean | undefined",
272
- description: "Render children if the message is from the user.",
273
- },
274
- {
275
- name: "assistant",
276
- type: "boolean | undefined",
277
- description: "Render children if the message is from the assistant.",
278
- },
279
- {
280
- name: "hasBranches",
281
- type: "boolean | undefined",
282
- description: "Render children if the message has branches.",
283
- },
284
- {
285
- name: "copied",
286
- type: "boolean | undefined",
287
- description: "Render children if the message is copied.",
288
- },
289
- {
290
- name: "lastOrHover",
291
- type: "boolean | undefined",
292
- description:
293
- "Render children if the message is the last or hovered over.",
294
- },
295
- ]}
296
- />
297
-
298
- ```tsx
299
- <Message.If user>
300
- {/* rendered if message is from the user */}
301
- </Message.If>
302
- <Message.If assistant>
303
- {/* rendered if message is from the assistant */}
304
- </Message.If>
305
- ```
306
-
307
262
  ### Error
308
263
 
309
264
  Renders children only if the message has an error status.
@@ -236,53 +236,3 @@ const Suggestion = () => {
236
236
  },
237
237
  ]}
238
238
  />
239
-
240
- ### If
241
-
242
- Renders children if a condition is met.
243
-
244
- <ParametersTable
245
- type="ThreadPrimitiveIfProps"
246
- parameters={[
247
- {
248
- name: "empty",
249
- type: "boolean | undefined",
250
- description: "Render children if the thread is empty.",
251
- },
252
- {
253
- name: "running",
254
- type: "boolean | undefined",
255
- description: "Render children if the thread is running.",
256
- },
257
- {
258
- name: "disabled",
259
- type: "boolean | undefined",
260
- description: "Render children if the thread is disabled.",
261
- },
262
- {
263
- name: "loading",
264
- type: "boolean | undefined",
265
- description: "Render children if the thread is loading.",
266
- },
267
- {
268
- name: "new",
269
- type: "boolean | undefined",
270
- description: "Render children if the thread is new.",
271
- },
272
- ]}
273
- />
274
-
275
- ```tsx
276
- <Thread.If empty>
277
- {/* equivalent to <Thread.Empty> */}
278
- </Thread.If>
279
- <Thread.If empty={false}>
280
- {/* rendered if thread is not empty */}
281
- </Thread.If>
282
- <Thread.If loading>
283
- {/* rendered if thread is loading */}
284
- </Thread.If>
285
- <Thread.If new>
286
- {/* rendered if thread is new */}
287
- </Thread.If>
288
- ```
@@ -4,6 +4,7 @@ title: Chat History for AI SDK
4
4
 
5
5
  import { Steps, Step } from 'fumadocs-ui/components/steps';
6
6
  import { Callout } from 'fumadocs-ui/components/callout';
7
+ import { InstallCommand } from "@/components/docs/install-command";
7
8
 
8
9
  ## Overview
9
10
 
@@ -52,9 +53,7 @@ ASSISTANT_API_KEY=your-api-key-here
52
53
 
53
54
  Install the required packages:
54
55
 
55
- ```bash
56
- npm install @assistant-ui/react @assistant-ui/react-ai-sdk
57
- ```
56
+ <InstallCommand npm={["@assistant-ui/react", "@assistant-ui/react-ai-sdk"]} />
58
57
 
59
58
  </Step>
60
59
 
@@ -5,6 +5,7 @@ title: Chat History for LangGraph Cloud
5
5
  import { Steps, Step } from "fumadocs-ui/components/steps";
6
6
  import { Callout } from "fumadocs-ui/components/callout";
7
7
  import { Tab, Tabs } from "fumadocs-ui/components/tabs";
8
+ import { InstallCommand } from "@/components/docs/install-command";
8
9
 
9
10
  ## Overview
10
11
 
@@ -54,9 +55,7 @@ ASSISTANT_API_KEY=your-api-key-here
54
55
 
55
56
  Install the required packages:
56
57
 
57
- ```bash
58
- npm install @assistant-ui/react @assistant-ui/react-langgraph
59
- ```
58
+ <InstallCommand npm={["@assistant-ui/react", "@assistant-ui/react-langgraph"]} />
60
59
 
61
60
  </Step>
62
61
 
@@ -3,6 +3,7 @@ title: DevTools
3
3
  ---
4
4
 
5
5
  import { Step, Steps } from "fumadocs-ui/components/steps";
6
+ import { InstallCommand } from "@/components/docs/install-command";
6
7
 
7
8
  Hey, the assistant-ui DevTools allows you to debug the assistant-ui state and context, and events without resorting to `console.log`. It's an easy way to see how data flows to the assistant-ui's runtime layer.
8
9
 
@@ -15,9 +16,7 @@ Hey, the assistant-ui DevTools allows you to debug the assistant-ui state and co
15
16
 
16
17
  ### Install the DevTools package
17
18
 
18
- ```bash
19
- npm install @assistant-ui/react-devtools
20
- ```
19
+ <InstallCommand npm={["@assistant-ui/react-devtools"]} />
21
20
 
22
21
  </Step>
23
22
  <Step>