@assistant-ui/mcp-docs-server 0.1.1

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 (109) hide show
  1. package/.docs/organized/code-examples/local-ollama.md +1135 -0
  2. package/.docs/organized/code-examples/search-agent-for-e-commerce.md +1721 -0
  3. package/.docs/organized/code-examples/with-ai-sdk.md +1081 -0
  4. package/.docs/organized/code-examples/with-cloud.md +1164 -0
  5. package/.docs/organized/code-examples/with-external-store.md +1064 -0
  6. package/.docs/organized/code-examples/with-ffmpeg.md +1305 -0
  7. package/.docs/organized/code-examples/with-langgraph.md +1819 -0
  8. package/.docs/organized/code-examples/with-openai-assistants.md +1175 -0
  9. package/.docs/organized/code-examples/with-react-hook-form.md +1727 -0
  10. package/.docs/organized/code-examples/with-vercel-ai-rsc.md +1157 -0
  11. package/.docs/raw/blog/2024-07-29-hello/index.mdx +65 -0
  12. package/.docs/raw/blog/2024-09-11/index.mdx +10 -0
  13. package/.docs/raw/blog/2024-12-15/index.mdx +10 -0
  14. package/.docs/raw/blog/2025-01-31-changelog/index.mdx +129 -0
  15. package/.docs/raw/docs/about-assistantui.mdx +44 -0
  16. package/.docs/raw/docs/api-reference/context-providers/AssistantRuntimeProvider.mdx +30 -0
  17. package/.docs/raw/docs/api-reference/context-providers/TextContentPartProvider.mdx +26 -0
  18. package/.docs/raw/docs/api-reference/integrations/react-hook-form.mdx +103 -0
  19. package/.docs/raw/docs/api-reference/integrations/vercel-ai-sdk.mdx +145 -0
  20. package/.docs/raw/docs/api-reference/overview.mdx +583 -0
  21. package/.docs/raw/docs/api-reference/primitives/ActionBar.mdx +264 -0
  22. package/.docs/raw/docs/api-reference/primitives/AssistantModal.mdx +129 -0
  23. package/.docs/raw/docs/api-reference/primitives/Attachment.mdx +96 -0
  24. package/.docs/raw/docs/api-reference/primitives/BranchPicker.mdx +87 -0
  25. package/.docs/raw/docs/api-reference/primitives/Composer.mdx +204 -0
  26. package/.docs/raw/docs/api-reference/primitives/ContentPart.mdx +173 -0
  27. package/.docs/raw/docs/api-reference/primitives/Error.mdx +70 -0
  28. package/.docs/raw/docs/api-reference/primitives/Message.mdx +181 -0
  29. package/.docs/raw/docs/api-reference/primitives/Thread.mdx +197 -0
  30. package/.docs/raw/docs/api-reference/primitives/composition.mdx +21 -0
  31. package/.docs/raw/docs/api-reference/runtimes/AssistantRuntime.mdx +33 -0
  32. package/.docs/raw/docs/api-reference/runtimes/AttachmentRuntime.mdx +46 -0
  33. package/.docs/raw/docs/api-reference/runtimes/ComposerRuntime.mdx +69 -0
  34. package/.docs/raw/docs/api-reference/runtimes/ContentPartRuntime.mdx +22 -0
  35. package/.docs/raw/docs/api-reference/runtimes/MessageRuntime.mdx +49 -0
  36. package/.docs/raw/docs/api-reference/runtimes/ThreadListItemRuntime.mdx +32 -0
  37. package/.docs/raw/docs/api-reference/runtimes/ThreadListRuntime.mdx +31 -0
  38. package/.docs/raw/docs/api-reference/runtimes/ThreadRuntime.mdx +48 -0
  39. package/.docs/raw/docs/architecture.mdx +92 -0
  40. package/.docs/raw/docs/cloud/authorization.mdx +152 -0
  41. package/.docs/raw/docs/cloud/overview.mdx +55 -0
  42. package/.docs/raw/docs/cloud/persistence/ai-sdk.mdx +54 -0
  43. package/.docs/raw/docs/cloud/persistence/langgraph.mdx +123 -0
  44. package/.docs/raw/docs/concepts/architecture.mdx +19 -0
  45. package/.docs/raw/docs/concepts/runtime-layer.mdx +163 -0
  46. package/.docs/raw/docs/concepts/why.mdx +9 -0
  47. package/.docs/raw/docs/copilots/make-assistant-readable.mdx +71 -0
  48. package/.docs/raw/docs/copilots/make-assistant-tool-ui.mdx +76 -0
  49. package/.docs/raw/docs/copilots/make-assistant-tool.mdx +117 -0
  50. package/.docs/raw/docs/copilots/model-context.mdx +135 -0
  51. package/.docs/raw/docs/copilots/motivation.mdx +191 -0
  52. package/.docs/raw/docs/copilots/use-assistant-instructions.mdx +62 -0
  53. package/.docs/raw/docs/getting-started.mdx +1133 -0
  54. package/.docs/raw/docs/guides/Attachments.mdx +640 -0
  55. package/.docs/raw/docs/guides/Branching.mdx +59 -0
  56. package/.docs/raw/docs/guides/Editing.mdx +56 -0
  57. package/.docs/raw/docs/guides/Speech.mdx +43 -0
  58. package/.docs/raw/docs/guides/ToolUI.mdx +663 -0
  59. package/.docs/raw/docs/guides/Tools.mdx +496 -0
  60. package/.docs/raw/docs/index.mdx +7 -0
  61. package/.docs/raw/docs/legacy/styled/AssistantModal.mdx +85 -0
  62. package/.docs/raw/docs/legacy/styled/Decomposition.mdx +633 -0
  63. package/.docs/raw/docs/legacy/styled/Markdown.mdx +86 -0
  64. package/.docs/raw/docs/legacy/styled/Scrollbar.mdx +71 -0
  65. package/.docs/raw/docs/legacy/styled/Thread.mdx +84 -0
  66. package/.docs/raw/docs/legacy/styled/ThreadWidth.mdx +21 -0
  67. package/.docs/raw/docs/mcp-docs-server.mdx +324 -0
  68. package/.docs/raw/docs/migrations/deprecation-policy.mdx +41 -0
  69. package/.docs/raw/docs/migrations/v0-7.mdx +188 -0
  70. package/.docs/raw/docs/migrations/v0-8.mdx +160 -0
  71. package/.docs/raw/docs/migrations/v0-9.mdx +75 -0
  72. package/.docs/raw/docs/react-compatibility.mdx +208 -0
  73. package/.docs/raw/docs/runtimes/ai-sdk/rsc.mdx +226 -0
  74. package/.docs/raw/docs/runtimes/ai-sdk/use-assistant-hook.mdx +195 -0
  75. package/.docs/raw/docs/runtimes/ai-sdk/use-chat-hook.mdx +138 -0
  76. package/.docs/raw/docs/runtimes/ai-sdk/use-chat.mdx +136 -0
  77. package/.docs/raw/docs/runtimes/custom/external-store.mdx +1624 -0
  78. package/.docs/raw/docs/runtimes/custom/local.mdx +1185 -0
  79. package/.docs/raw/docs/runtimes/helicone.mdx +60 -0
  80. package/.docs/raw/docs/runtimes/langgraph/index.mdx +320 -0
  81. package/.docs/raw/docs/runtimes/langgraph/tutorial/index.mdx +11 -0
  82. package/.docs/raw/docs/runtimes/langgraph/tutorial/introduction.mdx +28 -0
  83. package/.docs/raw/docs/runtimes/langgraph/tutorial/part-1.mdx +120 -0
  84. package/.docs/raw/docs/runtimes/langgraph/tutorial/part-2.mdx +336 -0
  85. package/.docs/raw/docs/runtimes/langgraph/tutorial/part-3.mdx +385 -0
  86. package/.docs/raw/docs/runtimes/langserve.mdx +126 -0
  87. package/.docs/raw/docs/runtimes/mastra/full-stack-integration.mdx +218 -0
  88. package/.docs/raw/docs/runtimes/mastra/overview.mdx +17 -0
  89. package/.docs/raw/docs/runtimes/mastra/separate-server-integration.mdx +196 -0
  90. package/.docs/raw/docs/runtimes/pick-a-runtime.mdx +222 -0
  91. package/.docs/raw/docs/ui/AssistantModal.mdx +46 -0
  92. package/.docs/raw/docs/ui/AssistantSidebar.mdx +42 -0
  93. package/.docs/raw/docs/ui/Attachment.mdx +82 -0
  94. package/.docs/raw/docs/ui/Markdown.mdx +72 -0
  95. package/.docs/raw/docs/ui/Mermaid.mdx +79 -0
  96. package/.docs/raw/docs/ui/Scrollbar.mdx +59 -0
  97. package/.docs/raw/docs/ui/SyntaxHighlighting.mdx +253 -0
  98. package/.docs/raw/docs/ui/Thread.mdx +47 -0
  99. package/.docs/raw/docs/ui/ThreadList.mdx +49 -0
  100. package/.docs/raw/docs/ui/ToolFallback.mdx +64 -0
  101. package/.docs/raw/docs/ui/primitives/Thread.mdx +197 -0
  102. package/LICENSE +21 -0
  103. package/README.md +128 -0
  104. package/dist/chunk-C7O7EFKU.js +38 -0
  105. package/dist/chunk-CZCDQ3YH.js +420 -0
  106. package/dist/index.js +1 -0
  107. package/dist/prepare-docs/prepare.js +199 -0
  108. package/dist/stdio.js +8 -0
  109. package/package.json +43 -0
@@ -0,0 +1,1157 @@
1
+ # Example: with-vercel-ai-rsc
2
+
3
+ ## app/actions.tsx
4
+
5
+ ```tsx
6
+ "use server";
7
+
8
+ import { openai } from "@ai-sdk/openai";
9
+ import { createAI, getMutableAIState, streamUI } from "ai/rsc";
10
+ import type { ReactNode } from "react";
11
+ import { z } from "zod";
12
+
13
+ export interface ServerMessage {
14
+ role: "user" | "assistant";
15
+ content: string;
16
+ }
17
+
18
+ export interface ClientMessage {
19
+ role: "user" | "assistant";
20
+ display: ReactNode;
21
+ }
22
+
23
+ export async function continueConversation(
24
+ input: string,
25
+ ): Promise<ClientMessage> {
26
+ "use server";
27
+
28
+ const history = getMutableAIState();
29
+
30
+ const result = await streamUI({
31
+ model: openai("gpt-3.5-turbo"),
32
+ messages: [...history.get(), { role: "user", content: input }],
33
+ text: ({ content, done }) => {
34
+ if (done) {
35
+ history.done((messages: ServerMessage[]) => [
36
+ ...messages,
37
+ { role: "assistant", content },
38
+ ]);
39
+ }
40
+
41
+ return <div>{content}</div>;
42
+ },
43
+ tools: {
44
+ showStockInformation: {
45
+ description:
46
+ "Get stock information for symbol for the last numOfMonths months",
47
+ parameters: z.object({
48
+ symbol: z
49
+ .string()
50
+ .describe("The stock symbol to get information for"),
51
+ numOfMonths: z
52
+ .number()
53
+ .describe("The number of months to get historical information for"),
54
+ }),
55
+ generate: async ({ symbol }) => {
56
+ history.done((messages: ServerMessage[]) => [
57
+ ...messages,
58
+ {
59
+ role: "assistant",
60
+ content: `Showing stock information for ${symbol}`,
61
+ },
62
+ ]);
63
+
64
+ return <p className="font-bold">Test</p>;
65
+ },
66
+ },
67
+ },
68
+ });
69
+
70
+ return {
71
+ role: "assistant",
72
+ display: result.value,
73
+ };
74
+ }
75
+
76
+ export const AI = createAI<ServerMessage[], ClientMessage[]>({
77
+ actions: {
78
+ continueConversation,
79
+ },
80
+ initialAIState: [],
81
+ initialUIState: [],
82
+ });
83
+
84
+ ```
85
+
86
+ ## app/globals.css
87
+
88
+ ```css
89
+ @import "tailwindcss";
90
+ @import "tw-animate-css";
91
+
92
+ @custom-variant dark (&:is(.dark *));
93
+
94
+ @theme inline {
95
+ --color-background: var(--background);
96
+ --color-foreground: var(--foreground);
97
+ --font-sans: var(--font-geist-sans);
98
+ --font-mono: var(--font-geist-mono);
99
+ --color-sidebar-ring: var(--sidebar-ring);
100
+ --color-sidebar-border: var(--sidebar-border);
101
+ --color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
102
+ --color-sidebar-accent: var(--sidebar-accent);
103
+ --color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
104
+ --color-sidebar-primary: var(--sidebar-primary);
105
+ --color-sidebar-foreground: var(--sidebar-foreground);
106
+ --color-sidebar: var(--sidebar);
107
+ --color-chart-5: var(--chart-5);
108
+ --color-chart-4: var(--chart-4);
109
+ --color-chart-3: var(--chart-3);
110
+ --color-chart-2: var(--chart-2);
111
+ --color-chart-1: var(--chart-1);
112
+ --color-ring: var(--ring);
113
+ --color-input: var(--input);
114
+ --color-border: var(--border);
115
+ --color-destructive: var(--destructive);
116
+ --color-accent-foreground: var(--accent-foreground);
117
+ --color-accent: var(--accent);
118
+ --color-muted-foreground: var(--muted-foreground);
119
+ --color-muted: var(--muted);
120
+ --color-secondary-foreground: var(--secondary-foreground);
121
+ --color-secondary: var(--secondary);
122
+ --color-primary-foreground: var(--primary-foreground);
123
+ --color-primary: var(--primary);
124
+ --color-popover-foreground: var(--popover-foreground);
125
+ --color-popover: var(--popover);
126
+ --color-card-foreground: var(--card-foreground);
127
+ --color-card: var(--card);
128
+ --radius-sm: calc(var(--radius) - 4px);
129
+ --radius-md: calc(var(--radius) - 2px);
130
+ --radius-lg: var(--radius);
131
+ --radius-xl: calc(var(--radius) + 4px);
132
+ }
133
+
134
+ :root {
135
+ --radius: 0.625rem;
136
+ --background: oklch(1 0 0);
137
+ --foreground: oklch(0.141 0.005 285.823);
138
+ --card: oklch(1 0 0);
139
+ --card-foreground: oklch(0.141 0.005 285.823);
140
+ --popover: oklch(1 0 0);
141
+ --popover-foreground: oklch(0.141 0.005 285.823);
142
+ --primary: oklch(0.21 0.006 285.885);
143
+ --primary-foreground: oklch(0.985 0 0);
144
+ --secondary: oklch(0.967 0.001 286.375);
145
+ --secondary-foreground: oklch(0.21 0.006 285.885);
146
+ --muted: oklch(0.967 0.001 286.375);
147
+ --muted-foreground: oklch(0.552 0.016 285.938);
148
+ --accent: oklch(0.967 0.001 286.375);
149
+ --accent-foreground: oklch(0.21 0.006 285.885);
150
+ --destructive: oklch(0.577 0.245 27.325);
151
+ --border: oklch(0.92 0.004 286.32);
152
+ --input: oklch(0.92 0.004 286.32);
153
+ --ring: oklch(0.705 0.015 286.067);
154
+ --chart-1: oklch(0.646 0.222 41.116);
155
+ --chart-2: oklch(0.6 0.118 184.704);
156
+ --chart-3: oklch(0.398 0.07 227.392);
157
+ --chart-4: oklch(0.828 0.189 84.429);
158
+ --chart-5: oklch(0.769 0.188 70.08);
159
+ --sidebar: oklch(0.985 0 0);
160
+ --sidebar-foreground: oklch(0.141 0.005 285.823);
161
+ --sidebar-primary: oklch(0.21 0.006 285.885);
162
+ --sidebar-primary-foreground: oklch(0.985 0 0);
163
+ --sidebar-accent: oklch(0.967 0.001 286.375);
164
+ --sidebar-accent-foreground: oklch(0.21 0.006 285.885);
165
+ --sidebar-border: oklch(0.92 0.004 286.32);
166
+ --sidebar-ring: oklch(0.705 0.015 286.067);
167
+ }
168
+
169
+ .dark {
170
+ --background: oklch(0.141 0.005 285.823);
171
+ --foreground: oklch(0.985 0 0);
172
+ --card: oklch(0.21 0.006 285.885);
173
+ --card-foreground: oklch(0.985 0 0);
174
+ --popover: oklch(0.21 0.006 285.885);
175
+ --popover-foreground: oklch(0.985 0 0);
176
+ --primary: oklch(0.92 0.004 286.32);
177
+ --primary-foreground: oklch(0.21 0.006 285.885);
178
+ --secondary: oklch(0.274 0.006 286.033);
179
+ --secondary-foreground: oklch(0.985 0 0);
180
+ --muted: oklch(0.274 0.006 286.033);
181
+ --muted-foreground: oklch(0.705 0.015 286.067);
182
+ --accent: oklch(0.274 0.006 286.033);
183
+ --accent-foreground: oklch(0.985 0 0);
184
+ --destructive: oklch(0.704 0.191 22.216);
185
+ --border: oklch(1 0 0 / 10%);
186
+ --input: oklch(1 0 0 / 15%);
187
+ --ring: oklch(0.552 0.016 285.938);
188
+ --chart-1: oklch(0.488 0.243 264.376);
189
+ --chart-2: oklch(0.696 0.17 162.48);
190
+ --chart-3: oklch(0.769 0.188 70.08);
191
+ --chart-4: oklch(0.627 0.265 303.9);
192
+ --chart-5: oklch(0.645 0.246 16.439);
193
+ --sidebar: oklch(0.21 0.006 285.885);
194
+ --sidebar-foreground: oklch(0.985 0 0);
195
+ --sidebar-primary: oklch(0.488 0.243 264.376);
196
+ --sidebar-primary-foreground: oklch(0.985 0 0);
197
+ --sidebar-accent: oklch(0.274 0.006 286.033);
198
+ --sidebar-accent-foreground: oklch(0.985 0 0);
199
+ --sidebar-border: oklch(1 0 0 / 10%);
200
+ --sidebar-ring: oklch(0.552 0.016 285.938);
201
+ }
202
+
203
+ @layer base {
204
+ * {
205
+ @apply border-border outline-ring/50;
206
+ }
207
+ body {
208
+ @apply bg-background text-foreground;
209
+ }
210
+ }
211
+
212
+ ```
213
+
214
+ ## app/layout.tsx
215
+
216
+ ```tsx
217
+ import type { Metadata } from "next";
218
+ import { Geist, Geist_Mono } from "next/font/google";
219
+ import { AI } from "./actions";
220
+
221
+ import "./globals.css";
222
+
223
+ const geistSans = Geist({
224
+ variable: "--font-geist-sans",
225
+ subsets: ["latin"],
226
+ });
227
+
228
+ const geistMono = Geist_Mono({
229
+ variable: "--font-geist-mono",
230
+ subsets: ["latin"],
231
+ });
232
+
233
+ export const metadata: Metadata = {
234
+ title: "assistant-ui App",
235
+ description: "Generated by create-assistant-ui",
236
+ };
237
+
238
+ export default function RootLayout({
239
+ children,
240
+ }: Readonly<{
241
+ children: React.ReactNode;
242
+ }>) {
243
+ return (
244
+ <html lang="en" className="h-dvh">
245
+ <body
246
+ className={`${geistSans.variable} ${geistMono.variable} h-dvh antialiased`}
247
+ >
248
+ <AI>{children}</AI>
249
+ </body>
250
+ </html>
251
+ );
252
+ }
253
+
254
+ ```
255
+
256
+ ## app/page.tsx
257
+
258
+ ```tsx
259
+ "use client";
260
+
261
+ import { useActions, useUIState } from "ai/rsc";
262
+ import { nanoid } from "nanoid";
263
+ import type { AI } from "./actions";
264
+
265
+ import { Thread } from "@/components/assistant-ui/thread";
266
+ import {
267
+ type AppendMessage,
268
+ AssistantRuntimeProvider,
269
+ } from "@assistant-ui/react";
270
+ import { useVercelRSCRuntime } from "@assistant-ui/react-ai-sdk";
271
+ import { useState } from "react";
272
+
273
+ export default function Home() {
274
+ return (
275
+ <main className="h-dvh">
276
+ <MyRuntimeProvider>
277
+ <Thread />
278
+ </MyRuntimeProvider>
279
+ </main>
280
+ );
281
+ }
282
+
283
+ const MyRuntimeProvider = ({ children }: { children: React.ReactNode }) => {
284
+ const { continueConversation } = useActions();
285
+ const [isRunning, setIsRunning] = useState(false);
286
+ const [messages, setMessages] = useUIState<typeof AI>();
287
+
288
+ const onNew = async (m: AppendMessage) => {
289
+ if (m.content[0]?.type !== "text")
290
+ throw new Error("Only text messages are supported");
291
+
292
+ const input = m.content[0].text;
293
+ setMessages((currentConversation) => [
294
+ ...currentConversation,
295
+ { id: nanoid(), role: "user", display: input },
296
+ ]);
297
+
298
+ try {
299
+ setIsRunning(true);
300
+ const message = await continueConversation(input);
301
+ setMessages((currentConversation) => [...currentConversation, message]);
302
+ } finally {
303
+ setIsRunning(false);
304
+ }
305
+ };
306
+
307
+ const runtime = useVercelRSCRuntime({ messages, isRunning, onNew });
308
+
309
+ return (
310
+ <AssistantRuntimeProvider runtime={runtime}>
311
+ {children}
312
+ </AssistantRuntimeProvider>
313
+ );
314
+ };
315
+
316
+ ```
317
+
318
+ ## components.json
319
+
320
+ ```json
321
+ {
322
+ "$schema": "https://ui.shadcn.com/schema.json",
323
+ "style": "new-york",
324
+ "rsc": true,
325
+ "tsx": true,
326
+ "tailwind": {
327
+ "config": "",
328
+ "css": "app/globals.css",
329
+ "baseColor": "zinc",
330
+ "cssVariables": true,
331
+ "prefix": ""
332
+ },
333
+ "aliases": {
334
+ "components": "@/components",
335
+ "utils": "@/lib/utils"
336
+ }
337
+ }
338
+
339
+ ```
340
+
341
+ ## components/assistant-ui/markdown-text.tsx
342
+
343
+ ```tsx
344
+ "use client";
345
+
346
+ import "@assistant-ui/react-markdown/styles/dot.css";
347
+
348
+ import {
349
+ CodeHeaderProps,
350
+ MarkdownTextPrimitive,
351
+ unstable_memoizeMarkdownComponents as memoizeMarkdownComponents,
352
+ useIsMarkdownCodeBlock,
353
+ } from "@assistant-ui/react-markdown";
354
+ import remarkGfm from "remark-gfm";
355
+ import { FC, memo, useState } from "react";
356
+ import { CheckIcon, CopyIcon } from "lucide-react";
357
+
358
+ import { TooltipIconButton } from "@/components/assistant-ui/tooltip-icon-button";
359
+ import { cn } from "@/lib/utils";
360
+
361
+ const MarkdownTextImpl = () => {
362
+ return (
363
+ <MarkdownTextPrimitive
364
+ remarkPlugins={[remarkGfm]}
365
+ className="aui-md"
366
+ components={defaultComponents}
367
+ />
368
+ );
369
+ };
370
+
371
+ export const MarkdownText = memo(MarkdownTextImpl);
372
+
373
+ const CodeHeader: FC<CodeHeaderProps> = ({ language, code }) => {
374
+ const { isCopied, copyToClipboard } = useCopyToClipboard();
375
+ const onCopy = () => {
376
+ if (!code || isCopied) return;
377
+ copyToClipboard(code);
378
+ };
379
+
380
+ return (
381
+ <div className="flex items-center justify-between gap-4 rounded-t-lg bg-zinc-900 px-4 py-2 text-sm font-semibold text-white">
382
+ <span className="lowercase [&>span]:text-xs">{language}</span>
383
+ <TooltipIconButton tooltip="Copy" onClick={onCopy}>
384
+ {!isCopied && <CopyIcon />}
385
+ {isCopied && <CheckIcon />}
386
+ </TooltipIconButton>
387
+ </div>
388
+ );
389
+ };
390
+
391
+ const useCopyToClipboard = ({
392
+ copiedDuration = 3000,
393
+ }: {
394
+ copiedDuration?: number;
395
+ } = {}) => {
396
+ const [isCopied, setIsCopied] = useState<boolean>(false);
397
+
398
+ const copyToClipboard = (value: string) => {
399
+ if (!value) return;
400
+
401
+ navigator.clipboard.writeText(value).then(() => {
402
+ setIsCopied(true);
403
+ setTimeout(() => setIsCopied(false), copiedDuration);
404
+ });
405
+ };
406
+
407
+ return { isCopied, copyToClipboard };
408
+ };
409
+
410
+ const defaultComponents = memoizeMarkdownComponents({
411
+ h1: ({ className, ...props }) => (
412
+ <h1
413
+ className={cn(
414
+ "mb-8 scroll-m-20 text-4xl font-extrabold tracking-tight last:mb-0",
415
+ className,
416
+ )}
417
+ {...props}
418
+ />
419
+ ),
420
+ h2: ({ className, ...props }) => (
421
+ <h2
422
+ className={cn(
423
+ "mb-4 mt-8 scroll-m-20 text-3xl font-semibold tracking-tight first:mt-0 last:mb-0",
424
+ className,
425
+ )}
426
+ {...props}
427
+ />
428
+ ),
429
+ h3: ({ className, ...props }) => (
430
+ <h3
431
+ className={cn(
432
+ "mb-4 mt-6 scroll-m-20 text-2xl font-semibold tracking-tight first:mt-0 last:mb-0",
433
+ className,
434
+ )}
435
+ {...props}
436
+ />
437
+ ),
438
+ h4: ({ className, ...props }) => (
439
+ <h4
440
+ className={cn(
441
+ "mb-4 mt-6 scroll-m-20 text-xl font-semibold tracking-tight first:mt-0 last:mb-0",
442
+ className,
443
+ )}
444
+ {...props}
445
+ />
446
+ ),
447
+ h5: ({ className, ...props }) => (
448
+ <h5
449
+ className={cn(
450
+ "my-4 text-lg font-semibold first:mt-0 last:mb-0",
451
+ className,
452
+ )}
453
+ {...props}
454
+ />
455
+ ),
456
+ h6: ({ className, ...props }) => (
457
+ <h6
458
+ className={cn("my-4 font-semibold first:mt-0 last:mb-0", className)}
459
+ {...props}
460
+ />
461
+ ),
462
+ p: ({ className, ...props }) => (
463
+ <p
464
+ className={cn("mb-5 mt-5 leading-7 first:mt-0 last:mb-0", className)}
465
+ {...props}
466
+ />
467
+ ),
468
+ a: ({ className, ...props }) => (
469
+ <a
470
+ className={cn(
471
+ "text-primary font-medium underline underline-offset-4",
472
+ className,
473
+ )}
474
+ {...props}
475
+ />
476
+ ),
477
+ blockquote: ({ className, ...props }) => (
478
+ <blockquote
479
+ className={cn("border-l-2 pl-6 italic", className)}
480
+ {...props}
481
+ />
482
+ ),
483
+ ul: ({ className, ...props }) => (
484
+ <ul
485
+ className={cn("my-5 ml-6 list-disc [&>li]:mt-2", className)}
486
+ {...props}
487
+ />
488
+ ),
489
+ ol: ({ className, ...props }) => (
490
+ <ol
491
+ className={cn("my-5 ml-6 list-decimal [&>li]:mt-2", className)}
492
+ {...props}
493
+ />
494
+ ),
495
+ hr: ({ className, ...props }) => (
496
+ <hr className={cn("my-5 border-b", className)} {...props} />
497
+ ),
498
+ table: ({ className, ...props }) => (
499
+ <table
500
+ className={cn(
501
+ "my-5 w-full border-separate border-spacing-0 overflow-y-auto",
502
+ className,
503
+ )}
504
+ {...props}
505
+ />
506
+ ),
507
+ th: ({ className, ...props }) => (
508
+ <th
509
+ className={cn(
510
+ "bg-muted px-4 py-2 text-left font-bold first:rounded-tl-lg last:rounded-tr-lg [&[align=center]]:text-center [&[align=right]]:text-right",
511
+ className,
512
+ )}
513
+ {...props}
514
+ />
515
+ ),
516
+ td: ({ className, ...props }) => (
517
+ <td
518
+ className={cn(
519
+ "border-b border-l px-4 py-2 text-left last:border-r [&[align=center]]:text-center [&[align=right]]:text-right",
520
+ className,
521
+ )}
522
+ {...props}
523
+ />
524
+ ),
525
+ tr: ({ className, ...props }) => (
526
+ <tr
527
+ className={cn(
528
+ "m-0 border-b p-0 first:border-t [&:last-child>td:first-child]:rounded-bl-lg [&:last-child>td:last-child]:rounded-br-lg",
529
+ className,
530
+ )}
531
+ {...props}
532
+ />
533
+ ),
534
+ sup: ({ className, ...props }) => (
535
+ <sup
536
+ className={cn("[&>a]:text-xs [&>a]:no-underline", className)}
537
+ {...props}
538
+ />
539
+ ),
540
+ pre: ({ className, ...props }) => (
541
+ <pre
542
+ className={cn(
543
+ "overflow-x-auto rounded-b-lg bg-black p-4 text-white",
544
+ className,
545
+ )}
546
+ {...props}
547
+ />
548
+ ),
549
+ code: function Code({ className, ...props }) {
550
+ const isCodeBlock = useIsMarkdownCodeBlock();
551
+ return (
552
+ <code
553
+ className={cn(
554
+ !isCodeBlock && "bg-muted rounded border font-semibold",
555
+ className,
556
+ )}
557
+ {...props}
558
+ />
559
+ );
560
+ },
561
+ CodeHeader,
562
+ });
563
+
564
+ ```
565
+
566
+ ## components/assistant-ui/thread.tsx
567
+
568
+ ```tsx
569
+ import {
570
+ ActionBarPrimitive,
571
+ BranchPickerPrimitive,
572
+ ComposerPrimitive,
573
+ MessagePrimitive,
574
+ ThreadPrimitive,
575
+ } from "@assistant-ui/react";
576
+ import type { FC } from "react";
577
+ import {
578
+ ArrowDownIcon,
579
+ CheckIcon,
580
+ ChevronLeftIcon,
581
+ ChevronRightIcon,
582
+ CopyIcon,
583
+ PencilIcon,
584
+ RefreshCwIcon,
585
+ SendHorizontalIcon,
586
+ } from "lucide-react";
587
+ import { cn } from "@/lib/utils";
588
+
589
+ import { Button } from "@/components/ui/button";
590
+ import { MarkdownText } from "@/components/assistant-ui/markdown-text";
591
+ import { TooltipIconButton } from "@/components/assistant-ui/tooltip-icon-button";
592
+
593
+ export const Thread: FC = () => {
594
+ return (
595
+ <ThreadPrimitive.Root
596
+ className="bg-background box-border flex h-full flex-col overflow-hidden"
597
+ style={{
598
+ ["--thread-max-width" as string]: "42rem",
599
+ }}
600
+ >
601
+ <ThreadPrimitive.Viewport className="flex h-full flex-col items-center overflow-y-scroll scroll-smooth bg-inherit px-4 pt-8">
602
+ <ThreadWelcome />
603
+
604
+ <ThreadPrimitive.Messages
605
+ components={{
606
+ UserMessage: UserMessage,
607
+ EditComposer: EditComposer,
608
+ AssistantMessage: AssistantMessage,
609
+ }}
610
+ />
611
+
612
+ <ThreadPrimitive.If empty={false}>
613
+ <div className="min-h-8 flex-grow" />
614
+ </ThreadPrimitive.If>
615
+
616
+ <div className="sticky bottom-0 mt-3 flex w-full max-w-[var(--thread-max-width)] flex-col items-center justify-end rounded-t-lg bg-inherit pb-4">
617
+ <ThreadScrollToBottom />
618
+ <Composer />
619
+ </div>
620
+ </ThreadPrimitive.Viewport>
621
+ </ThreadPrimitive.Root>
622
+ );
623
+ };
624
+
625
+ const ThreadScrollToBottom: FC = () => {
626
+ return (
627
+ <ThreadPrimitive.ScrollToBottom asChild>
628
+ <TooltipIconButton
629
+ tooltip="Scroll to bottom"
630
+ variant="outline"
631
+ className="absolute -top-8 rounded-full disabled:invisible"
632
+ >
633
+ <ArrowDownIcon />
634
+ </TooltipIconButton>
635
+ </ThreadPrimitive.ScrollToBottom>
636
+ );
637
+ };
638
+
639
+ const ThreadWelcome: FC = () => {
640
+ return (
641
+ <ThreadPrimitive.Empty>
642
+ <div className="flex w-full max-w-[var(--thread-max-width)] flex-grow flex-col">
643
+ <div className="flex w-full flex-grow flex-col items-center justify-center">
644
+ <p className="mt-4 font-medium">How can I help you today?</p>
645
+ </div>
646
+ <ThreadWelcomeSuggestions />
647
+ </div>
648
+ </ThreadPrimitive.Empty>
649
+ );
650
+ };
651
+
652
+ const ThreadWelcomeSuggestions: FC = () => {
653
+ return (
654
+ <div className="mt-3 flex w-full items-stretch justify-center gap-4">
655
+ <ThreadPrimitive.Suggestion
656
+ className="hover:bg-muted/80 flex max-w-sm grow basis-0 flex-col items-center justify-center rounded-lg border p-3 transition-colors ease-in"
657
+ prompt="What is the weather in Tokyo?"
658
+ method="replace"
659
+ autoSend
660
+ >
661
+ <span className="line-clamp-2 text-ellipsis text-sm font-semibold">
662
+ What is the weather in Tokyo?
663
+ </span>
664
+ </ThreadPrimitive.Suggestion>
665
+ <ThreadPrimitive.Suggestion
666
+ className="hover:bg-muted/80 flex max-w-sm grow basis-0 flex-col items-center justify-center rounded-lg border p-3 transition-colors ease-in"
667
+ prompt="What is assistant-ui?"
668
+ method="replace"
669
+ autoSend
670
+ >
671
+ <span className="line-clamp-2 text-ellipsis text-sm font-semibold">
672
+ What is assistant-ui?
673
+ </span>
674
+ </ThreadPrimitive.Suggestion>
675
+ </div>
676
+ );
677
+ };
678
+
679
+ const Composer: FC = () => {
680
+ return (
681
+ <ComposerPrimitive.Root className="focus-within:border-ring/20 flex w-full flex-wrap items-end rounded-lg border bg-inherit px-2.5 shadow-sm transition-colors ease-in">
682
+ <ComposerPrimitive.Input
683
+ rows={1}
684
+ autoFocus
685
+ placeholder="Write a message..."
686
+ className="placeholder:text-muted-foreground max-h-40 flex-grow resize-none border-none bg-transparent px-2 py-4 text-sm outline-none focus:ring-0 disabled:cursor-not-allowed"
687
+ />
688
+ <ComposerAction />
689
+ </ComposerPrimitive.Root>
690
+ );
691
+ };
692
+
693
+ const ComposerAction: FC = () => {
694
+ return (
695
+ <>
696
+ <ThreadPrimitive.If running={false}>
697
+ <ComposerPrimitive.Send asChild>
698
+ <TooltipIconButton
699
+ tooltip="Send"
700
+ variant="default"
701
+ className="my-2.5 size-8 p-2 transition-opacity ease-in"
702
+ >
703
+ <SendHorizontalIcon />
704
+ </TooltipIconButton>
705
+ </ComposerPrimitive.Send>
706
+ </ThreadPrimitive.If>
707
+ <ThreadPrimitive.If running>
708
+ <ComposerPrimitive.Cancel asChild>
709
+ <TooltipIconButton
710
+ tooltip="Cancel"
711
+ variant="default"
712
+ className="my-2.5 size-8 p-2 transition-opacity ease-in"
713
+ >
714
+ <CircleStopIcon />
715
+ </TooltipIconButton>
716
+ </ComposerPrimitive.Cancel>
717
+ </ThreadPrimitive.If>
718
+ </>
719
+ );
720
+ };
721
+
722
+ const UserMessage: FC = () => {
723
+ return (
724
+ <MessagePrimitive.Root className="grid w-full max-w-[var(--thread-max-width)] auto-rows-auto grid-cols-[minmax(72px,1fr)_auto] gap-y-2 py-4 [&:where(>*)]:col-start-2">
725
+ <UserActionBar />
726
+
727
+ <div className="bg-muted text-foreground col-start-2 row-start-2 max-w-[calc(var(--thread-max-width)*0.8)] break-words rounded-3xl px-5 py-2.5">
728
+ <MessagePrimitive.Content />
729
+ </div>
730
+
731
+ <BranchPicker className="col-span-full col-start-1 row-start-3 -mr-1 justify-end" />
732
+ </MessagePrimitive.Root>
733
+ );
734
+ };
735
+
736
+ const UserActionBar: FC = () => {
737
+ return (
738
+ <ActionBarPrimitive.Root
739
+ hideWhenRunning
740
+ autohide="not-last"
741
+ className="col-start-1 row-start-2 mr-3 mt-2.5 flex flex-col items-end"
742
+ >
743
+ <ActionBarPrimitive.Edit asChild>
744
+ <TooltipIconButton tooltip="Edit">
745
+ <PencilIcon />
746
+ </TooltipIconButton>
747
+ </ActionBarPrimitive.Edit>
748
+ </ActionBarPrimitive.Root>
749
+ );
750
+ };
751
+
752
+ const EditComposer: FC = () => {
753
+ return (
754
+ <ComposerPrimitive.Root className="bg-muted my-4 flex w-full max-w-[var(--thread-max-width)] flex-col gap-2 rounded-xl">
755
+ <ComposerPrimitive.Input className="text-foreground flex h-8 w-full resize-none bg-transparent p-4 pb-0 outline-none" />
756
+
757
+ <div className="mx-3 mb-3 flex items-center justify-center gap-2 self-end">
758
+ <ComposerPrimitive.Cancel asChild>
759
+ <Button variant="ghost">Cancel</Button>
760
+ </ComposerPrimitive.Cancel>
761
+ <ComposerPrimitive.Send asChild>
762
+ <Button>Send</Button>
763
+ </ComposerPrimitive.Send>
764
+ </div>
765
+ </ComposerPrimitive.Root>
766
+ );
767
+ };
768
+
769
+ const AssistantMessage: FC = () => {
770
+ return (
771
+ <MessagePrimitive.Root className="relative grid w-full max-w-[var(--thread-max-width)] grid-cols-[auto_auto_1fr] grid-rows-[auto_1fr] py-4">
772
+ <div className="text-foreground col-span-2 col-start-2 row-start-1 my-1.5 max-w-[calc(var(--thread-max-width)*0.8)] break-words leading-7">
773
+ <MessagePrimitive.Content components={{ Text: MarkdownText }} />
774
+ </div>
775
+
776
+ <AssistantActionBar />
777
+
778
+ <BranchPicker className="col-start-2 row-start-2 -ml-2 mr-2" />
779
+ </MessagePrimitive.Root>
780
+ );
781
+ };
782
+
783
+ const AssistantActionBar: FC = () => {
784
+ return (
785
+ <ActionBarPrimitive.Root
786
+ hideWhenRunning
787
+ autohide="not-last"
788
+ autohideFloat="single-branch"
789
+ className="text-muted-foreground data-[floating]:bg-background col-start-3 row-start-2 -ml-1 flex gap-1 data-[floating]:absolute data-[floating]:rounded-md data-[floating]:border data-[floating]:p-1 data-[floating]:shadow-sm"
790
+ >
791
+ <ActionBarPrimitive.Copy asChild>
792
+ <TooltipIconButton tooltip="Copy">
793
+ <MessagePrimitive.If copied>
794
+ <CheckIcon />
795
+ </MessagePrimitive.If>
796
+ <MessagePrimitive.If copied={false}>
797
+ <CopyIcon />
798
+ </MessagePrimitive.If>
799
+ </TooltipIconButton>
800
+ </ActionBarPrimitive.Copy>
801
+ <ActionBarPrimitive.Reload asChild>
802
+ <TooltipIconButton tooltip="Refresh">
803
+ <RefreshCwIcon />
804
+ </TooltipIconButton>
805
+ </ActionBarPrimitive.Reload>
806
+ </ActionBarPrimitive.Root>
807
+ );
808
+ };
809
+
810
+ const BranchPicker: FC<BranchPickerPrimitive.Root.Props> = ({
811
+ className,
812
+ ...rest
813
+ }) => {
814
+ return (
815
+ <BranchPickerPrimitive.Root
816
+ hideWhenSingleBranch
817
+ className={cn(
818
+ "text-muted-foreground inline-flex items-center text-xs",
819
+ className,
820
+ )}
821
+ {...rest}
822
+ >
823
+ <BranchPickerPrimitive.Previous asChild>
824
+ <TooltipIconButton tooltip="Previous">
825
+ <ChevronLeftIcon />
826
+ </TooltipIconButton>
827
+ </BranchPickerPrimitive.Previous>
828
+ <span className="font-medium">
829
+ <BranchPickerPrimitive.Number /> / <BranchPickerPrimitive.Count />
830
+ </span>
831
+ <BranchPickerPrimitive.Next asChild>
832
+ <TooltipIconButton tooltip="Next">
833
+ <ChevronRightIcon />
834
+ </TooltipIconButton>
835
+ </BranchPickerPrimitive.Next>
836
+ </BranchPickerPrimitive.Root>
837
+ );
838
+ };
839
+
840
+ const CircleStopIcon = () => {
841
+ return (
842
+ <svg
843
+ xmlns="http://www.w3.org/2000/svg"
844
+ viewBox="0 0 16 16"
845
+ fill="currentColor"
846
+ width="16"
847
+ height="16"
848
+ >
849
+ <rect width="10" height="10" x="3" y="3" rx="2" />
850
+ </svg>
851
+ );
852
+ };
853
+
854
+ ```
855
+
856
+ ## components/assistant-ui/tooltip-icon-button.tsx
857
+
858
+ ```tsx
859
+ "use client";
860
+
861
+ import { ComponentPropsWithoutRef, forwardRef } from "react";
862
+
863
+ import {
864
+ Tooltip,
865
+ TooltipContent,
866
+ TooltipTrigger,
867
+ } from "@/components/ui/tooltip";
868
+ import { Button } from "@/components/ui/button";
869
+ import { cn } from "@/lib/utils";
870
+
871
+ export type TooltipIconButtonProps = ComponentPropsWithoutRef<typeof Button> & {
872
+ tooltip: string;
873
+ side?: "top" | "bottom" | "left" | "right";
874
+ };
875
+
876
+ export const TooltipIconButton = forwardRef<
877
+ HTMLButtonElement,
878
+ TooltipIconButtonProps
879
+ >(({ children, tooltip, side = "bottom", className, ...rest }, ref) => {
880
+ return (
881
+ <Tooltip>
882
+ <TooltipTrigger asChild>
883
+ <Button
884
+ variant="ghost"
885
+ size="icon"
886
+ {...rest}
887
+ className={cn("size-6 p-1", className)}
888
+ ref={ref}
889
+ >
890
+ {children}
891
+ <span className="sr-only">{tooltip}</span>
892
+ </Button>
893
+ </TooltipTrigger>
894
+ <TooltipContent side={side}>{tooltip}</TooltipContent>
895
+ </Tooltip>
896
+ );
897
+ });
898
+
899
+ TooltipIconButton.displayName = "TooltipIconButton";
900
+
901
+ ```
902
+
903
+ ## components/ui/button.tsx
904
+
905
+ ```tsx
906
+ import * as React from "react";
907
+ import { Slot } from "@radix-ui/react-slot";
908
+ import { cva, type VariantProps } from "class-variance-authority";
909
+
910
+ import { cn } from "@/lib/utils";
911
+
912
+ const buttonVariants = cva(
913
+ "inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
914
+ {
915
+ variants: {
916
+ variant: {
917
+ default:
918
+ "bg-primary text-primary-foreground shadow-xs hover:bg-primary/90",
919
+ destructive:
920
+ "bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",
921
+ outline:
922
+ "border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",
923
+ secondary:
924
+ "bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80",
925
+ ghost:
926
+ "hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",
927
+ link: "text-primary underline-offset-4 hover:underline",
928
+ },
929
+ size: {
930
+ default: "h-9 px-4 py-2 has-[>svg]:px-3",
931
+ sm: "h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",
932
+ lg: "h-10 rounded-md px-6 has-[>svg]:px-4",
933
+ icon: "size-9",
934
+ },
935
+ },
936
+ defaultVariants: {
937
+ variant: "default",
938
+ size: "default",
939
+ },
940
+ },
941
+ );
942
+
943
+ function Button({
944
+ className,
945
+ variant,
946
+ size,
947
+ asChild = false,
948
+ ...props
949
+ }: React.ComponentProps<"button"> &
950
+ VariantProps<typeof buttonVariants> & {
951
+ asChild?: boolean;
952
+ }) {
953
+ const Comp = asChild ? Slot : "button";
954
+
955
+ return (
956
+ <Comp
957
+ data-slot="button"
958
+ className={cn(buttonVariants({ variant, size, className }))}
959
+ {...props}
960
+ />
961
+ );
962
+ }
963
+
964
+ export { Button, buttonVariants };
965
+
966
+ ```
967
+
968
+ ## components/ui/tooltip.tsx
969
+
970
+ ```tsx
971
+ "use client";
972
+
973
+ import * as React from "react";
974
+ import * as TooltipPrimitive from "@radix-ui/react-tooltip";
975
+
976
+ import { cn } from "@/lib/utils";
977
+
978
+ function TooltipProvider({
979
+ delayDuration = 0,
980
+ ...props
981
+ }: React.ComponentProps<typeof TooltipPrimitive.Provider>) {
982
+ return (
983
+ <TooltipPrimitive.Provider
984
+ data-slot="tooltip-provider"
985
+ delayDuration={delayDuration}
986
+ {...props}
987
+ />
988
+ );
989
+ }
990
+
991
+ function Tooltip({
992
+ ...props
993
+ }: React.ComponentProps<typeof TooltipPrimitive.Root>) {
994
+ return (
995
+ <TooltipProvider>
996
+ <TooltipPrimitive.Root data-slot="tooltip" {...props} />
997
+ </TooltipProvider>
998
+ );
999
+ }
1000
+
1001
+ function TooltipTrigger({
1002
+ ...props
1003
+ }: React.ComponentProps<typeof TooltipPrimitive.Trigger>) {
1004
+ return <TooltipPrimitive.Trigger data-slot="tooltip-trigger" {...props} />;
1005
+ }
1006
+
1007
+ function TooltipContent({
1008
+ className,
1009
+ sideOffset = 0,
1010
+ children,
1011
+ ...props
1012
+ }: React.ComponentProps<typeof TooltipPrimitive.Content>) {
1013
+ return (
1014
+ <TooltipPrimitive.Portal>
1015
+ <TooltipPrimitive.Content
1016
+ data-slot="tooltip-content"
1017
+ sideOffset={sideOffset}
1018
+ className={cn(
1019
+ "bg-primary text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-[--radix-tooltip-content-transform-origin] text-balance rounded-md px-3 py-1.5 text-xs",
1020
+ className,
1021
+ )}
1022
+ {...props}
1023
+ >
1024
+ {children}
1025
+ <TooltipPrimitive.Arrow className="bg-primary fill-primary z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]" />
1026
+ </TooltipPrimitive.Content>
1027
+ </TooltipPrimitive.Portal>
1028
+ );
1029
+ }
1030
+
1031
+ export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider };
1032
+
1033
+ ```
1034
+
1035
+ ## eslint.config.ts
1036
+
1037
+ ```typescript
1038
+ export { default } from "@assistant-ui/x-buildutils/eslint";
1039
+
1040
+ ```
1041
+
1042
+ ## lib/utils.ts
1043
+
1044
+ ```typescript
1045
+ import { type ClassValue, clsx } from "clsx";
1046
+ import { twMerge } from "tailwind-merge";
1047
+
1048
+ export function cn(...inputs: ClassValue[]) {
1049
+ return twMerge(clsx(inputs));
1050
+ }
1051
+
1052
+ ```
1053
+
1054
+ ## next-env.d.ts
1055
+
1056
+ ```typescript
1057
+ /// <reference types="next" />
1058
+ /// <reference types="next/image-types/global" />
1059
+
1060
+ // NOTE: This file should not be edited
1061
+ // see https://nextjs.org/docs/app/api-reference/config/typescript for more information.
1062
+
1063
+ ```
1064
+
1065
+ ## next.config.ts
1066
+
1067
+ ```typescript
1068
+ import type { NextConfig } from "next";
1069
+
1070
+ const nextConfig: NextConfig = {
1071
+ /* config options here */
1072
+ };
1073
+
1074
+ export default nextConfig;
1075
+
1076
+ ```
1077
+
1078
+ ## package.json
1079
+
1080
+ ```json
1081
+ {
1082
+ "name": "with-vercel-ai-rsc",
1083
+ "version": "0.1.0",
1084
+ "private": true,
1085
+ "scripts": {
1086
+ "dev": "next dev --turbo",
1087
+ "build": "next build",
1088
+ "start": "next start",
1089
+ "lint": "next lint"
1090
+ },
1091
+ "dependencies": {
1092
+ "@ai-sdk/openai": "^1.3.22",
1093
+ "@assistant-ui/react": "workspace:*",
1094
+ "@assistant-ui/react-ai-sdk": "workspace:*",
1095
+ "@assistant-ui/react-markdown": "workspace:*",
1096
+ "@radix-ui/react-icons": "^1.3.2",
1097
+ "@radix-ui/react-slot": "^1.2.3",
1098
+ "@radix-ui/react-tooltip": "^1.2.7",
1099
+ "ai": "^4.3.16",
1100
+ "class-variance-authority": "^0.7.1",
1101
+ "clsx": "^2.1.1",
1102
+ "lucide-react": "^0.511.0",
1103
+ "nanoid": "5.1.5",
1104
+ "next": "15.3.3",
1105
+ "react": "19.1.0",
1106
+ "react-dom": "19.1.0",
1107
+ "remark-gfm": "^4.0.1",
1108
+ "tailwind-merge": "^3.3.0",
1109
+ "tw-animate-css": "^1.3.3",
1110
+ "zod": "^3.25.49"
1111
+ },
1112
+ "devDependencies": {
1113
+ "@assistant-ui/x-buildutils": "workspace:*",
1114
+ "@types/node": "^22",
1115
+ "@types/react": "^19",
1116
+ "@types/react-dom": "^19",
1117
+ "eslint": "^9",
1118
+ "eslint-config-next": "15.3.3",
1119
+ "postcss": "^8",
1120
+ "tailwindcss": "^4.1.8",
1121
+ "typescript": "^5.8.3"
1122
+ }
1123
+ }
1124
+
1125
+ ```
1126
+
1127
+ ## tsconfig.json
1128
+
1129
+ ```json
1130
+ {
1131
+ "extends": "@assistant-ui/x-buildutils/ts/base",
1132
+ "compilerOptions": {
1133
+ "target": "ES6",
1134
+ "module": "ESNext",
1135
+ "incremental": true,
1136
+ "plugins": [
1137
+ {
1138
+ "name": "next"
1139
+ }
1140
+ ],
1141
+ "allowJs": true,
1142
+ "strictNullChecks": true,
1143
+ "jsx": "preserve",
1144
+ "paths": {
1145
+ "@/*": ["./*"],
1146
+ "@assistant-ui/*": ["../../packages/*/src"],
1147
+ "@assistant-ui/react/*": ["../../packages/react/src/*"],
1148
+ "assistant-stream": ["../../packages/assistant-stream/src"],
1149
+ "assistant-stream/*": ["../../packages/assistant-stream/src/*"]
1150
+ }
1151
+ },
1152
+ "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
1153
+ "exclude": ["node_modules"]
1154
+ }
1155
+
1156
+ ```
1157
+