@assistant-ui/mcp-docs-server 0.1.32 → 0.1.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.docs/organized/code-examples/waterfall.md +20 -22
- package/.docs/organized/code-examples/with-a2a.md +24 -24
- package/.docs/organized/code-examples/with-ag-ui.md +30 -25
- package/.docs/organized/code-examples/with-ai-sdk-v6.md +11 -9
- package/.docs/organized/code-examples/with-artifacts.md +49 -37
- package/.docs/organized/code-examples/with-assistant-transport.md +63 -51
- package/.docs/organized/code-examples/with-browser-extension.md +22 -10
- package/.docs/organized/code-examples/with-chain-of-thought.md +406 -87
- package/.docs/organized/code-examples/with-cloud-standalone.md +25 -24
- package/.docs/organized/code-examples/with-cloud.md +11 -9
- package/.docs/organized/code-examples/with-custom-thread-list.md +14 -12
- package/.docs/organized/code-examples/with-elevenlabs-conversational.md +23 -21
- package/.docs/organized/code-examples/with-elevenlabs-scribe.md +14 -13
- package/.docs/organized/code-examples/with-expo.md +44 -29
- package/.docs/organized/code-examples/with-external-store.md +9 -7
- package/.docs/organized/code-examples/with-ffmpeg.md +322 -285
- package/.docs/organized/code-examples/with-generative-ui.md +1066 -256
- package/.docs/organized/code-examples/with-google-adk.md +10 -8
- package/.docs/organized/code-examples/with-heat-graph.md +13 -11
- package/.docs/organized/code-examples/with-image-generation.md +19 -17
- package/.docs/organized/code-examples/with-interactables.md +317 -239
- package/.docs/organized/code-examples/with-langchain.md +14 -12
- package/.docs/organized/code-examples/with-langgraph.md +91 -83
- package/.docs/organized/code-examples/with-livekit.md +24 -22
- package/.docs/organized/code-examples/with-mcp.md +18 -12
- package/.docs/organized/code-examples/with-opencode.md +66 -66
- package/.docs/organized/code-examples/with-react-hook-form.md +19 -17
- package/.docs/organized/code-examples/with-react-ink.md +297 -102
- package/.docs/organized/code-examples/with-react-router.md +17 -15
- package/.docs/organized/code-examples/with-resumable-stream.md +15 -14
- package/.docs/organized/code-examples/with-store.md +78 -76
- package/.docs/organized/code-examples/with-tanstack.md +13 -14
- package/.docs/organized/code-examples/with-tap-runtime.md +26 -24
- package/.docs/raw/docs/(docs)/architecture.mdx +94 -42
- package/.docs/raw/docs/(docs)/cli.mdx +1 -2
- package/.docs/raw/docs/(docs)/installation.mdx +1 -1
- package/.docs/raw/docs/(reference)/api-reference/adapters/persistence.mdx +5 -1
- package/.docs/raw/docs/(reference)/api-reference/external-store/message-conversion.mdx +15 -15
- package/.docs/raw/docs/(reference)/api-reference/external-store/runtime.mdx +14 -1
- package/.docs/raw/docs/(reference)/api-reference/generative-ui/index.mdx +18 -0
- package/.docs/raw/docs/(reference)/api-reference/generative-ui/rendering.mdx +33 -0
- package/.docs/raw/docs/(reference)/api-reference/generative-ui/spec.mdx +45 -0
- package/.docs/raw/docs/(reference)/api-reference/hooks/composer-triggers.mdx +41 -41
- package/.docs/raw/docs/(reference)/api-reference/hooks/model-context.mdx +19 -1
- package/.docs/raw/docs/(reference)/api-reference/hooks/primitives.mdx +122 -122
- package/.docs/raw/docs/(reference)/api-reference/integrations/react-ai-sdk.mdx +43 -2
- package/.docs/raw/docs/(reference)/api-reference/model-context/context.mdx +6 -0
- package/.docs/raw/docs/(reference)/api-reference/overview.mdx +4 -6
- package/.docs/raw/docs/(reference)/api-reference/primitives/message.mdx +30 -0
- package/.docs/raw/docs/(reference)/api-reference/tools/component-tools.mdx +20 -3
- package/.docs/raw/docs/(reference)/api-reference/tools/index.mdx +8 -8
- package/.docs/raw/docs/(reference)/api-reference/tools/rendering.mdx +52 -4
- package/.docs/raw/docs/(reference)/api-reference/tools/toolkits.mdx +100 -10
- package/.docs/raw/docs/(reference)/api-reference/utilities/miscellaneous.mdx +7 -59
- package/.docs/raw/docs/cloud/ai-sdk.mdx +0 -2
- package/.docs/raw/docs/{(docs)/copilots → copilots}/model-context.mdx +34 -26
- package/.docs/raw/docs/{(docs)/copilots → copilots}/motivation.mdx +32 -26
- package/.docs/raw/docs/guides/chain-of-thought.mdx +7 -9
- package/.docs/raw/docs/guides/context-api.mdx +2 -1
- package/.docs/raw/docs/guides/index.mdx +3 -12
- package/.docs/raw/docs/guides/mentions.mdx +4 -4
- package/.docs/raw/docs/guides/slash-commands.mdx +1 -1
- package/.docs/raw/docs/guides/suggestions.mdx +1 -1
- package/.docs/raw/docs/ink/adapters.mdx +23 -1
- package/.docs/raw/docs/ink/hooks.mdx +101 -85
- package/.docs/raw/docs/ink/migration.mdx +1 -1
- package/.docs/raw/docs/ink/primitives.mdx +2 -2
- package/.docs/raw/docs/integrations/frameworks/ai-sdk.mdx +1 -1
- package/.docs/raw/docs/integrations/index.mdx +2 -2
- package/.docs/raw/docs/integrations/persistence/custom-adapter.mdx +17 -2
- package/.docs/raw/docs/migrations/toolkit-tools.mdx +232 -0
- package/.docs/raw/docs/primitives/chain-of-thought.mdx +10 -16
- package/.docs/raw/docs/primitives/message.mdx +9 -10
- package/.docs/raw/docs/react-native/hooks.mdx +62 -79
- package/.docs/raw/docs/react-native/migration.mdx +1 -1
- package/.docs/raw/docs/react-native/primitives.mdx +2 -2
- package/.docs/raw/docs/runtimes/a2a/client-and-hooks.mdx +3 -0
- package/.docs/raw/docs/runtimes/ag-ui/runtime-options.mdx +41 -0
- package/.docs/raw/docs/runtimes/ai-sdk/v6.mdx +122 -1
- package/.docs/raw/docs/runtimes/concepts/architecture.mdx +46 -4
- package/.docs/raw/docs/runtimes/concepts/threads.mdx +7 -1
- package/.docs/raw/docs/runtimes/custom/assistant-transport.mdx +54 -12
- package/.docs/raw/docs/runtimes/custom/external-store.mdx +62 -4
- package/.docs/raw/docs/runtimes/custom/local-runtime.mdx +30 -7
- package/.docs/raw/docs/runtimes/google-adk/hooks.mdx +108 -38
- package/.docs/raw/docs/runtimes/langgraph/generative-ui.mdx +2 -2
- package/.docs/raw/docs/runtimes/langgraph/streaming.mdx +14 -1
- package/.docs/raw/docs/runtimes/langgraph/tutorial/part-2.mdx +64 -50
- package/.docs/raw/docs/runtimes/langgraph/tutorial/part-3.mdx +98 -86
- package/.docs/raw/docs/tools/backend.mdx +144 -0
- package/.docs/raw/docs/tools/defining-tools.mdx +538 -0
- package/.docs/raw/docs/tools/dynamic-tools.mdx +110 -0
- package/.docs/raw/docs/tools/generative-ui.mdx +214 -0
- package/.docs/raw/docs/tools/index.mdx +71 -0
- package/.docs/raw/docs/{guides → tools}/interactables.mdx +1 -1
- package/.docs/raw/docs/{integrations/tools → tools}/mcp.mdx +145 -50
- package/.docs/raw/docs/{guides → tools}/multi-agent.mdx +15 -17
- package/.docs/raw/docs/tools/tool-ui.mdx +967 -0
- package/.docs/raw/docs/{integrations/tools/react-mcp.mdx → tools/user-managed-mcp.mdx} +7 -7
- package/.docs/raw/docs/ui/directive-text.mdx +3 -3
- package/.docs/raw/docs/ui/mcp-config.mdx +4 -4
- package/.docs/raw/docs/ui/mermaid.mdx +16 -9
- package/.docs/raw/docs/ui/part-grouping.mdx +84 -50
- package/.docs/raw/docs/ui/reasoning.mdx +4 -5
- package/.docs/raw/docs/ui/tool-fallback.mdx +16 -0
- package/.docs/raw/docs/ui/tool-group.mdx +5 -6
- package/.docs/raw/docs/utilities/heat-graph.mdx +1 -1
- package/.docs/raw/docs/utilities/react-o11y.mdx +2 -2
- package/dist/constants.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/prepare-docs/code-examples.d.ts.map +1 -1
- package/dist/prepare-docs/code-examples.js.map +1 -1
- package/dist/prepare-docs/copy-raw.d.ts.map +1 -1
- package/dist/prepare-docs/copy-raw.js.map +1 -1
- package/dist/prepare-docs/prepare.js.map +1 -1
- package/dist/stdio.js.map +1 -1
- package/dist/tools/docs.js.map +1 -1
- package/dist/tools/examples.js.map +1 -1
- package/dist/tools/tests/test-setup.js.map +1 -1
- package/dist/utils/mdx.js.map +1 -1
- package/dist/utils/paths.d.ts.map +1 -1
- package/dist/utils/paths.js.map +1 -1
- package/package.json +5 -5
- package/.docs/organized/code-examples/with-parent-id-grouping.md +0 -596
- package/.docs/raw/docs/(docs)/copilots/make-assistant-tool-ui.mdx +0 -151
- package/.docs/raw/docs/(docs)/copilots/make-assistant-tool.mdx +0 -230
- package/.docs/raw/docs/guides/generative-ui.mdx +0 -142
- package/.docs/raw/docs/guides/tool-ui.mdx +0 -858
- package/.docs/raw/docs/guides/tools.mdx +0 -736
- /package/.docs/raw/docs/{(docs)/copilots → copilots}/assistant-frame.mdx +0 -0
- /package/.docs/raw/docs/{(docs)/copilots → copilots}/make-assistant-visible.mdx +0 -0
- /package/.docs/raw/docs/{(docs)/copilots → copilots}/use-assistant-instructions.mdx +0 -0
- /package/.docs/raw/docs/{guides → tools}/mcp-apps.mdx +0 -0
|
@@ -1,596 +0,0 @@
|
|
|
1
|
-
# Example: with-parent-id-grouping
|
|
2
|
-
|
|
3
|
-
## app/globals.css
|
|
4
|
-
|
|
5
|
-
```css
|
|
6
|
-
@import "tailwindcss";
|
|
7
|
-
@import "tw-animate-css";
|
|
8
|
-
|
|
9
|
-
@source "../../../packages/ui/src";
|
|
10
|
-
|
|
11
|
-
@custom-variant dark (&:is(.dark *));
|
|
12
|
-
|
|
13
|
-
@theme inline {
|
|
14
|
-
--radius-sm: calc(var(--radius) - 4px);
|
|
15
|
-
--radius-md: calc(var(--radius) - 2px);
|
|
16
|
-
--radius-lg: var(--radius);
|
|
17
|
-
--radius-xl: calc(var(--radius) + 4px);
|
|
18
|
-
--color-background: var(--background);
|
|
19
|
-
--color-foreground: var(--foreground);
|
|
20
|
-
--color-card: var(--card);
|
|
21
|
-
--color-card-foreground: var(--card-foreground);
|
|
22
|
-
--color-popover: var(--popover);
|
|
23
|
-
--color-popover-foreground: var(--popover-foreground);
|
|
24
|
-
--color-primary: var(--primary);
|
|
25
|
-
--color-primary-foreground: var(--primary-foreground);
|
|
26
|
-
--color-secondary: var(--secondary);
|
|
27
|
-
--color-secondary-foreground: var(--secondary-foreground);
|
|
28
|
-
--color-muted: var(--muted);
|
|
29
|
-
--color-muted-foreground: var(--muted-foreground);
|
|
30
|
-
--color-accent: var(--accent);
|
|
31
|
-
--color-accent-foreground: var(--accent-foreground);
|
|
32
|
-
--color-destructive: var(--destructive);
|
|
33
|
-
--color-border: var(--border);
|
|
34
|
-
--color-input: var(--input);
|
|
35
|
-
--color-ring: var(--ring);
|
|
36
|
-
--color-chart-1: var(--chart-1);
|
|
37
|
-
--color-chart-2: var(--chart-2);
|
|
38
|
-
--color-chart-3: var(--chart-3);
|
|
39
|
-
--color-chart-4: var(--chart-4);
|
|
40
|
-
--color-chart-5: var(--chart-5);
|
|
41
|
-
--color-sidebar: var(--sidebar);
|
|
42
|
-
--color-sidebar-foreground: var(--sidebar-foreground);
|
|
43
|
-
--color-sidebar-primary: var(--sidebar-primary);
|
|
44
|
-
--color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
|
|
45
|
-
--color-sidebar-accent: var(--sidebar-accent);
|
|
46
|
-
--color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
|
|
47
|
-
--color-sidebar-border: var(--sidebar-border);
|
|
48
|
-
--color-sidebar-ring: var(--sidebar-ring);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
:root {
|
|
52
|
-
--radius: 0.625rem;
|
|
53
|
-
--background: oklch(1 0 0);
|
|
54
|
-
--foreground: oklch(0.141 0.005 285.823);
|
|
55
|
-
--card: oklch(1 0 0);
|
|
56
|
-
--card-foreground: oklch(0.141 0.005 285.823);
|
|
57
|
-
--popover: oklch(1 0 0);
|
|
58
|
-
--popover-foreground: oklch(0.141 0.005 285.823);
|
|
59
|
-
--primary: oklch(0.21 0.006 285.885);
|
|
60
|
-
--primary-foreground: oklch(0.985 0 0);
|
|
61
|
-
--secondary: oklch(0.967 0.001 286.375);
|
|
62
|
-
--secondary-foreground: oklch(0.21 0.006 285.885);
|
|
63
|
-
--muted: oklch(0.967 0.001 286.375);
|
|
64
|
-
--muted-foreground: oklch(0.552 0.016 285.938);
|
|
65
|
-
--accent: oklch(0.967 0.001 286.375);
|
|
66
|
-
--accent-foreground: oklch(0.21 0.006 285.885);
|
|
67
|
-
--destructive: oklch(0.577 0.245 27.325);
|
|
68
|
-
--border: oklch(0.92 0.004 286.32);
|
|
69
|
-
--input: oklch(0.92 0.004 286.32);
|
|
70
|
-
--ring: oklch(0.705 0.015 286.067);
|
|
71
|
-
--chart-1: oklch(0.646 0.222 41.116);
|
|
72
|
-
--chart-2: oklch(0.6 0.118 184.704);
|
|
73
|
-
--chart-3: oklch(0.398 0.07 227.392);
|
|
74
|
-
--chart-4: oklch(0.828 0.189 84.429);
|
|
75
|
-
--chart-5: oklch(0.769 0.188 70.08);
|
|
76
|
-
--sidebar: oklch(0.985 0 0);
|
|
77
|
-
--sidebar-foreground: oklch(0.141 0.005 285.823);
|
|
78
|
-
--sidebar-primary: oklch(0.21 0.006 285.885);
|
|
79
|
-
--sidebar-primary-foreground: oklch(0.985 0 0);
|
|
80
|
-
--sidebar-accent: oklch(0.967 0.001 286.375);
|
|
81
|
-
--sidebar-accent-foreground: oklch(0.21 0.006 285.885);
|
|
82
|
-
--sidebar-border: oklch(0.92 0.004 286.32);
|
|
83
|
-
--sidebar-ring: oklch(0.705 0.015 286.067);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
.dark {
|
|
87
|
-
--background: oklch(0.141 0.005 285.823);
|
|
88
|
-
--foreground: oklch(0.985 0 0);
|
|
89
|
-
--card: oklch(0.21 0.006 285.885);
|
|
90
|
-
--card-foreground: oklch(0.985 0 0);
|
|
91
|
-
--popover: oklch(0.21 0.006 285.885);
|
|
92
|
-
--popover-foreground: oklch(0.985 0 0);
|
|
93
|
-
--primary: oklch(0.92 0.004 286.32);
|
|
94
|
-
--primary-foreground: oklch(0.21 0.006 285.885);
|
|
95
|
-
--secondary: oklch(0.274 0.006 286.033);
|
|
96
|
-
--secondary-foreground: oklch(0.985 0 0);
|
|
97
|
-
--muted: oklch(0.274 0.006 286.033);
|
|
98
|
-
--muted-foreground: oklch(0.705 0.015 286.067);
|
|
99
|
-
--accent: oklch(0.274 0.006 286.033);
|
|
100
|
-
--accent-foreground: oklch(0.985 0 0);
|
|
101
|
-
--destructive: oklch(0.704 0.191 22.216);
|
|
102
|
-
--border: oklch(1 0 0 / 10%);
|
|
103
|
-
--input: oklch(1 0 0 / 15%);
|
|
104
|
-
--ring: oklch(0.552 0.016 285.938);
|
|
105
|
-
--chart-1: oklch(0.488 0.243 264.376);
|
|
106
|
-
--chart-2: oklch(0.696 0.17 162.48);
|
|
107
|
-
--chart-3: oklch(0.769 0.188 70.08);
|
|
108
|
-
--chart-4: oklch(0.627 0.265 303.9);
|
|
109
|
-
--chart-5: oklch(0.645 0.246 16.439);
|
|
110
|
-
--sidebar: oklch(0.21 0.006 285.885);
|
|
111
|
-
--sidebar-foreground: oklch(0.985 0 0);
|
|
112
|
-
--sidebar-primary: oklch(0.488 0.243 264.376);
|
|
113
|
-
--sidebar-primary-foreground: oklch(0.985 0 0);
|
|
114
|
-
--sidebar-accent: oklch(0.274 0.006 286.033);
|
|
115
|
-
--sidebar-accent-foreground: oklch(0.985 0 0);
|
|
116
|
-
--sidebar-border: oklch(1 0 0 / 10%);
|
|
117
|
-
--sidebar-ring: oklch(0.552 0.016 285.938);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
@layer base {
|
|
121
|
-
* {
|
|
122
|
-
@apply border-border outline-ring/50;
|
|
123
|
-
}
|
|
124
|
-
body {
|
|
125
|
-
@apply bg-background text-foreground;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
## app/layout.tsx
|
|
132
|
-
|
|
133
|
-
```tsx
|
|
134
|
-
import type { Metadata } from "next";
|
|
135
|
-
import { MyRuntimeProvider } from "@/app/MyRuntimeProvider";
|
|
136
|
-
|
|
137
|
-
import "./globals.css";
|
|
138
|
-
|
|
139
|
-
export const metadata: Metadata = {
|
|
140
|
-
title: "Create Next App",
|
|
141
|
-
description: "Generated by create next app",
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
export default function RootLayout({
|
|
145
|
-
children,
|
|
146
|
-
}: Readonly<{
|
|
147
|
-
children: React.ReactNode;
|
|
148
|
-
}>) {
|
|
149
|
-
return (
|
|
150
|
-
<MyRuntimeProvider>
|
|
151
|
-
<html lang="en" className="h-dvh">
|
|
152
|
-
<body className="h-dvh font-sans">{children}</body>
|
|
153
|
-
</html>
|
|
154
|
-
</MyRuntimeProvider>
|
|
155
|
-
);
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
```
|
|
159
|
-
|
|
160
|
-
## app/MyRuntimeProvider.tsx
|
|
161
|
-
|
|
162
|
-
```tsx
|
|
163
|
-
"use client";
|
|
164
|
-
|
|
165
|
-
import {
|
|
166
|
-
type ThreadMessageLike,
|
|
167
|
-
type AppendMessage,
|
|
168
|
-
AssistantRuntimeProvider,
|
|
169
|
-
useExternalStoreRuntime,
|
|
170
|
-
} from "@assistant-ui/react";
|
|
171
|
-
import { useState } from "react";
|
|
172
|
-
|
|
173
|
-
const convertMessage = (message: ThreadMessageLike) => {
|
|
174
|
-
return message;
|
|
175
|
-
};
|
|
176
|
-
|
|
177
|
-
export function MyRuntimeProvider({
|
|
178
|
-
children,
|
|
179
|
-
}: Readonly<{
|
|
180
|
-
children: React.ReactNode;
|
|
181
|
-
}>) {
|
|
182
|
-
const [messages, setMessages] = useState<readonly ThreadMessageLike[]>([
|
|
183
|
-
{
|
|
184
|
-
id: "msg-1",
|
|
185
|
-
createdAt: new Date("2024-01-01T10:00:00"),
|
|
186
|
-
role: "user",
|
|
187
|
-
content: [
|
|
188
|
-
{
|
|
189
|
-
type: "text",
|
|
190
|
-
text: "Tell me about climate change and its effects",
|
|
191
|
-
},
|
|
192
|
-
],
|
|
193
|
-
},
|
|
194
|
-
{
|
|
195
|
-
id: "msg-2",
|
|
196
|
-
createdAt: new Date("2024-01-01T10:00:05"),
|
|
197
|
-
role: "assistant",
|
|
198
|
-
content: [
|
|
199
|
-
{
|
|
200
|
-
type: "text",
|
|
201
|
-
text: "Climate change refers to long-term shifts in global temperatures and weather patterns. Let me provide you with information about its causes and effects.",
|
|
202
|
-
},
|
|
203
|
-
{
|
|
204
|
-
type: "tool-call",
|
|
205
|
-
toolCallId: "call-1",
|
|
206
|
-
toolName: "search_research",
|
|
207
|
-
args: { query: "climate change causes" },
|
|
208
|
-
argsText: '{"query": "climate change causes"}',
|
|
209
|
-
result: {
|
|
210
|
-
sources: [
|
|
211
|
-
"https://climate.nasa.gov/causes/",
|
|
212
|
-
"https://www.ipcc.ch/report/ar6/wg1/",
|
|
213
|
-
],
|
|
214
|
-
},
|
|
215
|
-
parentId: "research-climate-causes",
|
|
216
|
-
},
|
|
217
|
-
{
|
|
218
|
-
type: "source",
|
|
219
|
-
sourceType: "url",
|
|
220
|
-
id: "source-1",
|
|
221
|
-
url: "https://climate.nasa.gov/causes/",
|
|
222
|
-
title: "NASA: Climate Change Causes",
|
|
223
|
-
parentId: "research-climate-causes",
|
|
224
|
-
},
|
|
225
|
-
{
|
|
226
|
-
type: "source",
|
|
227
|
-
sourceType: "url",
|
|
228
|
-
id: "source-2",
|
|
229
|
-
url: "https://www.ipcc.ch/report/ar6/wg1/",
|
|
230
|
-
title: "IPCC Sixth Assessment Report",
|
|
231
|
-
parentId: "research-climate-causes",
|
|
232
|
-
},
|
|
233
|
-
{
|
|
234
|
-
type: "text",
|
|
235
|
-
text: "The main causes of climate change include:",
|
|
236
|
-
parentId: "research-climate-causes",
|
|
237
|
-
},
|
|
238
|
-
{
|
|
239
|
-
type: "text",
|
|
240
|
-
text: "1. **Greenhouse Gas Emissions**: The burning of fossil fuels releases CO2 and other greenhouse gases that trap heat in the atmosphere.",
|
|
241
|
-
parentId: "research-climate-causes",
|
|
242
|
-
},
|
|
243
|
-
{
|
|
244
|
-
type: "text",
|
|
245
|
-
text: "2. **Deforestation**: Removing forests reduces the Earth's capacity to absorb CO2.",
|
|
246
|
-
parentId: "research-climate-causes",
|
|
247
|
-
},
|
|
248
|
-
{
|
|
249
|
-
type: "text",
|
|
250
|
-
text: "Now, let me search for information about the effects of climate change:",
|
|
251
|
-
},
|
|
252
|
-
{
|
|
253
|
-
type: "tool-call",
|
|
254
|
-
toolCallId: "call-2",
|
|
255
|
-
toolName: "search_research",
|
|
256
|
-
args: { query: "climate change effects impacts" },
|
|
257
|
-
argsText: '{"query": "climate change effects impacts"}',
|
|
258
|
-
result: {
|
|
259
|
-
sources: [
|
|
260
|
-
"https://www.who.int/health-topics/climate-change",
|
|
261
|
-
"https://www.unep.org/facts-about-climate-emergency",
|
|
262
|
-
],
|
|
263
|
-
},
|
|
264
|
-
parentId: "research-climate-effects",
|
|
265
|
-
},
|
|
266
|
-
{
|
|
267
|
-
type: "source",
|
|
268
|
-
sourceType: "url",
|
|
269
|
-
id: "source-3",
|
|
270
|
-
url: "https://www.who.int/health-topics/climate-change",
|
|
271
|
-
title: "WHO: Climate Change and Health",
|
|
272
|
-
parentId: "research-climate-effects",
|
|
273
|
-
},
|
|
274
|
-
{
|
|
275
|
-
type: "source",
|
|
276
|
-
sourceType: "url",
|
|
277
|
-
id: "source-4",
|
|
278
|
-
url: "https://www.unep.org/facts-about-climate-emergency",
|
|
279
|
-
title: "UNEP: Climate Emergency Facts",
|
|
280
|
-
parentId: "research-climate-effects",
|
|
281
|
-
},
|
|
282
|
-
{
|
|
283
|
-
type: "text",
|
|
284
|
-
text: "The major effects of climate change include:",
|
|
285
|
-
parentId: "research-climate-effects",
|
|
286
|
-
},
|
|
287
|
-
{
|
|
288
|
-
type: "text",
|
|
289
|
-
text: "• **Rising Sea Levels**: Melting ice caps and thermal expansion of oceans threaten coastal communities.",
|
|
290
|
-
parentId: "research-climate-effects",
|
|
291
|
-
},
|
|
292
|
-
{
|
|
293
|
-
type: "text",
|
|
294
|
-
text: "• **Extreme Weather Events**: More frequent and intense hurricanes, droughts, and heatwaves.",
|
|
295
|
-
parentId: "research-climate-effects",
|
|
296
|
-
},
|
|
297
|
-
{
|
|
298
|
-
type: "text",
|
|
299
|
-
text: "• **Ecosystem Disruption**: Changes in temperature and precipitation patterns affect biodiversity and agriculture.",
|
|
300
|
-
parentId: "research-climate-effects",
|
|
301
|
-
},
|
|
302
|
-
{
|
|
303
|
-
type: "text",
|
|
304
|
-
text: "In conclusion, climate change is one of the most pressing challenges facing humanity, requiring immediate action on both mitigation and adaptation strategies.",
|
|
305
|
-
},
|
|
306
|
-
] as any, // Using any to bypass strict typing for demo purposes
|
|
307
|
-
status: { type: "complete", reason: "stop" },
|
|
308
|
-
},
|
|
309
|
-
]);
|
|
310
|
-
|
|
311
|
-
const onNew = async (message: AppendMessage) => {
|
|
312
|
-
if (message.content.length !== 1 || message.content[0]?.type !== "text")
|
|
313
|
-
throw new Error("Only text content is supported");
|
|
314
|
-
|
|
315
|
-
const userMessage: ThreadMessageLike = {
|
|
316
|
-
id: `msg-user-${Date.now()}`,
|
|
317
|
-
createdAt: new Date(),
|
|
318
|
-
role: "user",
|
|
319
|
-
content: [{ type: "text", text: message.content[0].text }],
|
|
320
|
-
};
|
|
321
|
-
setMessages((currentMessages) => [...currentMessages, userMessage]);
|
|
322
|
-
|
|
323
|
-
// Simulate assistant response with parent IDs
|
|
324
|
-
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
325
|
-
|
|
326
|
-
const assistantMessage: ThreadMessageLike = {
|
|
327
|
-
id: `msg-assistant-${Date.now()}`,
|
|
328
|
-
createdAt: new Date(),
|
|
329
|
-
role: "assistant",
|
|
330
|
-
content: [
|
|
331
|
-
{
|
|
332
|
-
type: "text",
|
|
333
|
-
text: "I understand you want to know more. Let me research that for you.",
|
|
334
|
-
},
|
|
335
|
-
{
|
|
336
|
-
type: "tool-call",
|
|
337
|
-
toolCallId: `call-${Date.now()}`,
|
|
338
|
-
toolName: "search",
|
|
339
|
-
args: { query: "recent developments" },
|
|
340
|
-
argsText: '{"query": "recent developments"}',
|
|
341
|
-
result: { data: "Latest information found" },
|
|
342
|
-
parentId: "new-research",
|
|
343
|
-
},
|
|
344
|
-
{
|
|
345
|
-
type: "text",
|
|
346
|
-
text: "Based on my research:",
|
|
347
|
-
parentId: "new-research",
|
|
348
|
-
},
|
|
349
|
-
{
|
|
350
|
-
type: "text",
|
|
351
|
-
text: "Here's what I found about your query...",
|
|
352
|
-
parentId: "new-research",
|
|
353
|
-
},
|
|
354
|
-
{
|
|
355
|
-
type: "text",
|
|
356
|
-
text: "I hope this information helps!",
|
|
357
|
-
},
|
|
358
|
-
] as any, // Using any to bypass strict typing for demo purposes
|
|
359
|
-
status: { type: "complete", reason: "stop" },
|
|
360
|
-
};
|
|
361
|
-
setMessages((currentMessages) => [...currentMessages, assistantMessage]);
|
|
362
|
-
};
|
|
363
|
-
|
|
364
|
-
const runtime = useExternalStoreRuntime<ThreadMessageLike>({
|
|
365
|
-
messages,
|
|
366
|
-
setMessages,
|
|
367
|
-
onNew,
|
|
368
|
-
convertMessage,
|
|
369
|
-
});
|
|
370
|
-
|
|
371
|
-
return (
|
|
372
|
-
<AssistantRuntimeProvider runtime={runtime}>
|
|
373
|
-
{children}
|
|
374
|
-
</AssistantRuntimeProvider>
|
|
375
|
-
);
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
```
|
|
379
|
-
|
|
380
|
-
## app/page.tsx
|
|
381
|
-
|
|
382
|
-
```tsx
|
|
383
|
-
"use client";
|
|
384
|
-
|
|
385
|
-
import { Thread } from "@/components/assistant-ui/thread";
|
|
386
|
-
import { useAui, AuiProvider, Suggestions } from "@assistant-ui/react";
|
|
387
|
-
|
|
388
|
-
function ThreadWithSuggestions() {
|
|
389
|
-
const aui = useAui({
|
|
390
|
-
suggestions: Suggestions([
|
|
391
|
-
{
|
|
392
|
-
title: "Tell me a story",
|
|
393
|
-
label: "with multiple parts",
|
|
394
|
-
prompt: "Tell me a short story with a beginning, middle, and end.",
|
|
395
|
-
},
|
|
396
|
-
{
|
|
397
|
-
title: "Explain quantum computing",
|
|
398
|
-
label: "in simple terms",
|
|
399
|
-
prompt: "Explain quantum computing like I'm five years old.",
|
|
400
|
-
},
|
|
401
|
-
]),
|
|
402
|
-
});
|
|
403
|
-
return (
|
|
404
|
-
<AuiProvider value={aui}>
|
|
405
|
-
<Thread />
|
|
406
|
-
</AuiProvider>
|
|
407
|
-
);
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
export default function Home() {
|
|
411
|
-
return (
|
|
412
|
-
<main className="h-dvh">
|
|
413
|
-
<ThreadWithSuggestions />
|
|
414
|
-
</main>
|
|
415
|
-
);
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
```
|
|
419
|
-
|
|
420
|
-
## components.json
|
|
421
|
-
|
|
422
|
-
```json
|
|
423
|
-
{
|
|
424
|
-
"$schema": "https://ui.shadcn.com/schema.json",
|
|
425
|
-
"style": "new-york",
|
|
426
|
-
"rsc": true,
|
|
427
|
-
"tsx": true,
|
|
428
|
-
"tailwind": {
|
|
429
|
-
"config": "",
|
|
430
|
-
"css": "app/globals.css",
|
|
431
|
-
"baseColor": "zinc",
|
|
432
|
-
"cssVariables": true,
|
|
433
|
-
"prefix": ""
|
|
434
|
-
},
|
|
435
|
-
"aliases": {
|
|
436
|
-
"components": "@/components",
|
|
437
|
-
"utils": "@/lib/utils",
|
|
438
|
-
"ui": "@/components/ui",
|
|
439
|
-
"lib": "@/lib",
|
|
440
|
-
"hooks": "@/hooks"
|
|
441
|
-
},
|
|
442
|
-
"iconLibrary": "lucide",
|
|
443
|
-
"registries": {
|
|
444
|
-
"@assistant-ui": "https://r.assistant-ui.com/{name}.json"
|
|
445
|
-
}
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
```
|
|
449
|
-
|
|
450
|
-
## next.config.ts
|
|
451
|
-
|
|
452
|
-
```typescript
|
|
453
|
-
import type { NextConfig } from "next";
|
|
454
|
-
|
|
455
|
-
const nextConfig: NextConfig = {
|
|
456
|
-
/* config options here */
|
|
457
|
-
};
|
|
458
|
-
|
|
459
|
-
export default nextConfig;
|
|
460
|
-
|
|
461
|
-
```
|
|
462
|
-
|
|
463
|
-
## package.json
|
|
464
|
-
|
|
465
|
-
```json
|
|
466
|
-
{
|
|
467
|
-
"name": "with-parent-id-grouping",
|
|
468
|
-
"version": "0.0.0",
|
|
469
|
-
"private": true,
|
|
470
|
-
"type": "module",
|
|
471
|
-
"scripts": {
|
|
472
|
-
"dev": "next dev",
|
|
473
|
-
"build": "next build",
|
|
474
|
-
"start": "next start"
|
|
475
|
-
},
|
|
476
|
-
"dependencies": {
|
|
477
|
-
"@ai-sdk/openai": "^3.0.64",
|
|
478
|
-
"@assistant-ui/react": "workspace:*",
|
|
479
|
-
"@assistant-ui/react-markdown": "workspace:*",
|
|
480
|
-
"@assistant-ui/ui": "workspace:*",
|
|
481
|
-
"class-variance-authority": "^0.7.1",
|
|
482
|
-
"clsx": "^2.1.1",
|
|
483
|
-
"lucide-react": "^1.16.0",
|
|
484
|
-
"next": "^16.2.6",
|
|
485
|
-
"react": "^19.2.6",
|
|
486
|
-
"react-dom": "^19.2.6",
|
|
487
|
-
"tailwind-merge": "^3.6.0"
|
|
488
|
-
},
|
|
489
|
-
"devDependencies": {
|
|
490
|
-
"@assistant-ui/x-buildutils": "workspace:*",
|
|
491
|
-
"@tailwindcss/postcss": "^4.3.0",
|
|
492
|
-
"@types/node": "^25.9.1",
|
|
493
|
-
"@types/react": "^19.2.15",
|
|
494
|
-
"@types/react-dom": "^19.2.3",
|
|
495
|
-
"postcss": "^8.5.15",
|
|
496
|
-
"tailwindcss": "^4.3.0",
|
|
497
|
-
"tw-animate-css": "^1.4.0",
|
|
498
|
-
"typescript": "^6.0.3"
|
|
499
|
-
}
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
```
|
|
503
|
-
|
|
504
|
-
## README.md
|
|
505
|
-
|
|
506
|
-
```markdown
|
|
507
|
-
# Parent ID Grouping Example
|
|
508
|
-
|
|
509
|
-
This example demonstrates how to use the parent ID feature in assistant-ui to group related message parts together.
|
|
510
|
-
|
|
511
|
-
## Quick Start
|
|
512
|
-
|
|
513
|
-
### Using CLI (Recommended)
|
|
514
|
-
|
|
515
|
-
```bash
|
|
516
|
-
npx assistant-ui@latest create my-app --example with-parent-id-grouping
|
|
517
|
-
cd my-app
|
|
518
|
-
```
|
|
519
|
-
|
|
520
|
-
### Environment Variables
|
|
521
|
-
|
|
522
|
-
Create `.env.local`:
|
|
523
|
-
|
|
524
|
-
```
|
|
525
|
-
OPENAI_API_KEY=sk-...
|
|
526
|
-
```
|
|
527
|
-
|
|
528
|
-
### Run
|
|
529
|
-
|
|
530
|
-
```bash
|
|
531
|
-
npm install
|
|
532
|
-
npm run dev
|
|
533
|
-
```
|
|
534
|
-
|
|
535
|
-
Open [http://localhost:3000](http://localhost:3000) to see the example.
|
|
536
|
-
|
|
537
|
-
## Features
|
|
538
|
-
|
|
539
|
-
- **Parent ID Support**: Message parts can have a `parentId` field that groups them together
|
|
540
|
-
- **Visual Grouping**: Related parts are displayed in collapsible groups
|
|
541
|
-
- **Custom Group Component**: Shows grouped parts in a bordered container with expand/collapse functionality
|
|
542
|
-
|
|
543
|
-
## How it works
|
|
544
|
-
|
|
545
|
-
1. **Message Structure**: The example uses the external store runtime with predefined messages that include parts with `parentId` fields:
|
|
546
|
-
|
|
547
|
-
```typescript
|
|
548
|
-
{
|
|
549
|
-
type: "text",
|
|
550
|
-
text: "Some related text",
|
|
551
|
-
parentId: "research-climate-causes"
|
|
552
|
-
}
|
|
553
|
-
```
|
|
554
|
-
|
|
555
|
-
2. **Non-adjacent grouping component**: Uses the unstable `MessagePrimitive.Unstable_PartsGroupedByParentId` API to collect parts by `parentId`, even when related parts are not adjacent. For normal adjacent grouping, prefer `MessagePrimitive.GroupedParts`.
|
|
556
|
-
|
|
557
|
-
3. **Custom Rendering**: The `ParentIdGroup` component provides collapsible sections for each group
|
|
558
|
-
|
|
559
|
-
## Use Cases
|
|
560
|
-
|
|
561
|
-
This pattern is useful for:
|
|
562
|
-
|
|
563
|
-
- Grouping research sources with their related findings
|
|
564
|
-
- Organizing multi-step tool executions
|
|
565
|
-
- Creating hierarchical content structures
|
|
566
|
-
- Showing related content in collapsible sections
|
|
567
|
-
|
|
568
|
-
## Related Documentation
|
|
569
|
-
|
|
570
|
-
- [assistant-ui Documentation](https://www.assistant-ui.com/docs)
|
|
571
|
-
- [Message Structure Guide](https://www.assistant-ui.com/docs/concepts/messages)
|
|
572
|
-
|
|
573
|
-
```
|
|
574
|
-
|
|
575
|
-
## tsconfig.json
|
|
576
|
-
|
|
577
|
-
```json
|
|
578
|
-
{
|
|
579
|
-
"extends": "@assistant-ui/x-buildutils/ts/next",
|
|
580
|
-
"compilerOptions": {
|
|
581
|
-
"paths": {
|
|
582
|
-
"@/*": ["./*"],
|
|
583
|
-
"@/components/assistant-ui/*": [
|
|
584
|
-
"../../packages/ui/src/components/assistant-ui/*"
|
|
585
|
-
],
|
|
586
|
-
"@/components/ui/*": ["../../packages/ui/src/components/ui/*"],
|
|
587
|
-
"@/lib/utils": ["../../packages/ui/src/lib/utils"],
|
|
588
|
-
"@assistant-ui/ui/*": ["../../packages/ui/src/*"]
|
|
589
|
-
}
|
|
590
|
-
},
|
|
591
|
-
"include": ["**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
|
|
592
|
-
"exclude": ["node_modules"]
|
|
593
|
-
}
|
|
594
|
-
|
|
595
|
-
```
|
|
596
|
-
|