@assistant-ui/mcp-docs-server 0.1.18 → 0.1.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.docs/organized/code-examples/with-ag-ui.md +375 -85
- package/.docs/organized/code-examples/{with-ai-sdk-v5.md → with-ai-sdk-v6.md} +386 -94
- package/.docs/organized/code-examples/with-assistant-transport.md +374 -84
- package/.docs/organized/code-examples/with-cloud.md +405 -100
- package/.docs/organized/code-examples/with-custom-thread-list.md +412 -105
- package/.docs/organized/code-examples/with-elevenlabs-scribe.md +2241 -0
- package/.docs/organized/code-examples/with-external-store.md +374 -83
- package/.docs/organized/code-examples/with-ffmpeg.md +377 -87
- package/.docs/organized/code-examples/with-langgraph.md +403 -98
- package/.docs/organized/code-examples/with-parent-id-grouping.md +374 -83
- package/.docs/organized/code-examples/with-react-hook-form.md +379 -89
- package/.docs/organized/code-examples/with-react-router.md +2167 -0
- package/.docs/organized/code-examples/with-store.md +5 -5
- package/.docs/organized/code-examples/with-tanstack.md +10 -10
- package/.docs/raw/blog/2025-01-31-changelog/index.mdx +0 -2
- package/.docs/raw/docs/{about-assistantui.mdx → (docs)/about-assistantui.mdx} +2 -1
- package/.docs/raw/docs/{architecture.mdx → (docs)/architecture.mdx} +3 -2
- package/.docs/raw/docs/{cli.mdx → (docs)/cli.mdx} +1 -19
- package/.docs/raw/docs/{copilots → (docs)/copilots}/make-assistant-readable.mdx +1 -0
- package/.docs/raw/docs/{copilots → (docs)/copilots}/make-assistant-tool-ui.mdx +2 -1
- package/.docs/raw/docs/{copilots → (docs)/copilots}/make-assistant-tool.mdx +2 -1
- package/.docs/raw/docs/{copilots → (docs)/copilots}/model-context.mdx +1 -0
- package/.docs/raw/docs/{copilots → (docs)/copilots}/motivation.mdx +1 -0
- package/.docs/raw/docs/{copilots → (docs)/copilots}/use-assistant-instructions.mdx +1 -0
- package/.docs/raw/docs/{devtools.mdx → (docs)/devtools.mdx} +4 -4
- package/.docs/raw/docs/{guides/Attachments.mdx → (docs)/guides/attachments.mdx} +4 -5
- package/.docs/raw/docs/{guides/Branching.mdx → (docs)/guides/branching.mdx} +2 -1
- package/.docs/raw/docs/{guides → (docs)/guides}/context-api.mdx +1 -0
- package/.docs/raw/docs/(docs)/guides/dictation.mdx +370 -0
- package/.docs/raw/docs/{guides/Editing.mdx → (docs)/guides/editing.mdx} +1 -0
- package/.docs/raw/docs/{guides/Latex.mdx → (docs)/guides/latex.mdx} +1 -2
- package/.docs/raw/docs/{guides/Speech.mdx → (docs)/guides/speech.mdx} +9 -10
- package/.docs/raw/docs/{guides/ToolUI.mdx → (docs)/guides/tool-ui.mdx} +15 -14
- package/.docs/raw/docs/{guides/Tools.mdx → (docs)/guides/tools.mdx} +10 -7
- package/.docs/raw/docs/{getting-started.mdx → (docs)/index.mdx} +17 -22
- package/.docs/raw/docs/{mcp-docs-server.mdx → (docs)/mcp-docs-server.mdx} +1 -2
- package/.docs/raw/docs/{api-reference/context-providers/AssistantRuntimeProvider.mdx → (reference)/api-reference/context-providers/assistant-runtime-provider.mdx} +2 -1
- package/.docs/raw/docs/{api-reference/context-providers/TextMessagePartProvider.mdx → (reference)/api-reference/context-providers/text-message-part-provider.mdx} +2 -1
- package/.docs/raw/docs/{api-reference → (reference)/api-reference}/integrations/react-data-stream.mdx +2 -1
- package/.docs/raw/docs/{api-reference → (reference)/api-reference}/integrations/react-hook-form.mdx +2 -1
- package/.docs/raw/docs/{api-reference → (reference)/api-reference}/integrations/vercel-ai-sdk.mdx +2 -2
- package/.docs/raw/docs/{api-reference → (reference)/api-reference}/overview.mdx +1 -1
- package/.docs/raw/docs/(reference)/api-reference/primitives/action-bar-more.mdx +327 -0
- package/.docs/raw/docs/{api-reference/primitives/ActionBar.mdx → (reference)/api-reference/primitives/action-bar.mdx} +3 -1
- package/.docs/raw/docs/{api-reference/primitives/AssistantIf.mdx → (reference)/api-reference/primitives/assistant-if.mdx} +2 -2
- package/.docs/raw/docs/{api-reference/primitives/AssistantModal.mdx → (reference)/api-reference/primitives/assistant-modal.mdx} +3 -1
- package/.docs/raw/docs/{api-reference/primitives/Attachment.mdx → (reference)/api-reference/primitives/attachment.mdx} +3 -2
- package/.docs/raw/docs/{api-reference/primitives/BranchPicker.mdx → (reference)/api-reference/primitives/branch-picker.mdx} +2 -1
- package/.docs/raw/docs/{api-reference/primitives/Composer.mdx → (reference)/api-reference/primitives/composer.mdx} +101 -2
- package/.docs/raw/docs/{api-reference → (reference)/api-reference}/primitives/composition.mdx +1 -0
- package/.docs/raw/docs/{api-reference/primitives/Error.mdx → (reference)/api-reference/primitives/error.mdx} +2 -1
- package/.docs/raw/docs/{api-reference/primitives/MessagePart.mdx → (reference)/api-reference/primitives/message-part.mdx} +2 -2
- package/.docs/raw/docs/{api-reference/primitives/Message.mdx → (reference)/api-reference/primitives/message.mdx} +2 -1
- package/.docs/raw/docs/(reference)/api-reference/primitives/thread-list-item-more.mdx +221 -0
- package/.docs/raw/docs/{api-reference/primitives/ThreadListItem.mdx → (reference)/api-reference/primitives/thread-list-item.mdx} +2 -1
- package/.docs/raw/docs/{api-reference/primitives/ThreadList.mdx → (reference)/api-reference/primitives/thread-list.mdx} +2 -1
- package/.docs/raw/docs/{api-reference/primitives/Thread.mdx → (reference)/api-reference/primitives/thread.mdx} +2 -1
- package/.docs/raw/docs/{api-reference/runtimes/AssistantRuntime.mdx → (reference)/api-reference/runtimes/assistant-runtime.mdx} +2 -1
- package/.docs/raw/docs/{api-reference/runtimes/AttachmentRuntime.mdx → (reference)/api-reference/runtimes/attachment-runtime.mdx} +3 -2
- package/.docs/raw/docs/{api-reference/runtimes/ComposerRuntime.mdx → (reference)/api-reference/runtimes/composer-runtime.mdx} +2 -1
- package/.docs/raw/docs/{api-reference/runtimes/MessagePartRuntime.mdx → (reference)/api-reference/runtimes/message-part-runtime.mdx} +3 -2
- package/.docs/raw/docs/{api-reference/runtimes/MessageRuntime.mdx → (reference)/api-reference/runtimes/message-runtime.mdx} +3 -2
- package/.docs/raw/docs/{api-reference/runtimes/ThreadListItemRuntime.mdx → (reference)/api-reference/runtimes/thread-list-item-runtime.mdx} +2 -1
- package/.docs/raw/docs/{api-reference/runtimes/ThreadListRuntime.mdx → (reference)/api-reference/runtimes/thread-list-runtime.mdx} +2 -1
- package/.docs/raw/docs/{api-reference/runtimes/ThreadRuntime.mdx → (reference)/api-reference/runtimes/thread-runtime.mdx} +3 -5
- package/.docs/raw/docs/{legacy/styled/AssistantModal.mdx → (reference)/legacy/styled/assistant-modal.mdx} +2 -3
- package/.docs/raw/docs/{legacy/styled/Decomposition.mdx → (reference)/legacy/styled/decomposition.mdx} +1 -0
- package/.docs/raw/docs/{legacy/styled/Markdown.mdx → (reference)/legacy/styled/markdown.mdx} +2 -4
- package/.docs/raw/docs/{legacy/styled/Scrollbar.mdx → (reference)/legacy/styled/scrollbar.mdx} +2 -1
- package/.docs/raw/docs/{legacy/styled/ThreadWidth.mdx → (reference)/legacy/styled/thread-width.mdx} +1 -0
- package/.docs/raw/docs/{legacy/styled/Thread.mdx → (reference)/legacy/styled/thread.mdx} +2 -3
- package/.docs/raw/docs/{migrations → (reference)/migrations}/deprecation-policy.mdx +1 -0
- package/.docs/raw/docs/{migrations → (reference)/migrations}/react-langgraph-v0-7.mdx +1 -2
- package/.docs/raw/docs/{migrations → (reference)/migrations}/v0-11.mdx +1 -0
- package/.docs/raw/docs/{migrations → (reference)/migrations}/v0-12.mdx +1 -0
- package/.docs/raw/docs/{react-compatibility.mdx → (reference)/react-compatibility.mdx} +2 -3
- package/.docs/raw/docs/cloud/authorization.mdx +1 -0
- package/.docs/raw/docs/cloud/overview.mdx +1 -0
- package/.docs/raw/docs/cloud/persistence/ai-sdk.mdx +2 -3
- package/.docs/raw/docs/cloud/persistence/langgraph.mdx +5 -7
- package/.docs/raw/docs/runtimes/ai-sdk/use-chat.mdx +9 -8
- package/.docs/raw/docs/runtimes/ai-sdk/v4-legacy.mdx +2 -3
- package/.docs/raw/docs/runtimes/assistant-transport.mdx +7 -6
- package/.docs/raw/docs/runtimes/custom/custom-thread-list.mdx +2 -3
- package/.docs/raw/docs/runtimes/custom/external-store.mdx +6 -8
- package/.docs/raw/docs/runtimes/custom/local.mdx +12 -8
- package/.docs/raw/docs/runtimes/data-stream.mdx +32 -4
- package/.docs/raw/docs/runtimes/helicone.mdx +1 -0
- package/.docs/raw/docs/runtimes/langgraph/index.mdx +3 -3
- package/.docs/raw/docs/runtimes/langgraph/tutorial/index.mdx +1 -0
- package/.docs/raw/docs/runtimes/langgraph/tutorial/introduction.mdx +1 -0
- package/.docs/raw/docs/runtimes/langgraph/tutorial/part-1.mdx +1 -0
- package/.docs/raw/docs/runtimes/langgraph/tutorial/part-2.mdx +1 -0
- package/.docs/raw/docs/runtimes/langgraph/tutorial/part-3.mdx +2 -1
- package/.docs/raw/docs/runtimes/langserve.mdx +2 -2
- package/.docs/raw/docs/runtimes/mastra/full-stack-integration.mdx +4 -5
- package/.docs/raw/docs/runtimes/mastra/overview.mdx +1 -0
- package/.docs/raw/docs/runtimes/mastra/separate-server-integration.mdx +3 -4
- package/.docs/raw/docs/runtimes/pick-a-runtime.mdx +2 -4
- package/.docs/raw/docs/ui/assistant-modal.mdx +163 -0
- package/.docs/raw/docs/ui/assistant-sidebar.mdx +90 -0
- package/.docs/raw/docs/ui/attachment.mdx +227 -0
- package/.docs/raw/docs/ui/{Markdown.mdx → markdown.mdx} +11 -6
- package/.docs/raw/docs/ui/{Mermaid.mdx → mermaid.mdx} +12 -5
- package/.docs/raw/docs/ui/{PartGrouping.mdx → part-grouping.mdx} +4 -6
- package/.docs/raw/docs/ui/reasoning.mdx +148 -0
- package/.docs/raw/docs/ui/{Scrollbar.mdx → scrollbar.mdx} +9 -1
- package/.docs/raw/docs/ui/sources.mdx +87 -0
- package/.docs/raw/docs/ui/{SyntaxHighlighting.mdx → syntax-highlighting.mdx} +9 -5
- package/.docs/raw/docs/ui/thread-list.mdx +275 -0
- package/.docs/raw/docs/ui/{Thread.mdx → thread.mdx} +5 -6
- package/.docs/raw/docs/ui/tool-fallback.mdx +112 -0
- package/.docs/raw/docs/ui/tool-group.mdx +214 -0
- package/dist/tools/docs.js +1 -1
- package/dist/tools/examples.js +1 -1
- package/dist/tools/examples.js.map +1 -1
- package/package.json +5 -5
- package/src/tools/docs.ts +1 -1
- package/src/tools/examples.ts +1 -1
- package/src/tools/tests/docs.test.ts +18 -16
- package/src/tools/tests/examples.test.ts +5 -5
- package/src/tools/tests/path-traversal.test.ts +3 -3
- package/src/utils/tests/security.test.ts +3 -3
- package/.docs/raw/docs/index.mdx +0 -7
- package/.docs/raw/docs/ui/AssistantModal.mdx +0 -45
- package/.docs/raw/docs/ui/AssistantSidebar.mdx +0 -41
- package/.docs/raw/docs/ui/Attachment.mdx +0 -84
- package/.docs/raw/docs/ui/Reasoning.mdx +0 -152
- package/.docs/raw/docs/ui/ThreadList.mdx +0 -90
- package/.docs/raw/docs/ui/ToolFallback.mdx +0 -63
- package/.docs/raw/docs/ui/ToolGroup.mdx +0 -96
- /package/.docs/raw/docs/{copilots → (docs)/copilots}/assistant-frame.mdx +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Example: with-ai-sdk-
|
|
1
|
+
# Example: with-ai-sdk-v6
|
|
2
2
|
|
|
3
3
|
## app/api/chat/route.ts
|
|
4
4
|
|
|
@@ -6,11 +6,12 @@
|
|
|
6
6
|
import { openai } from "@ai-sdk/openai";
|
|
7
7
|
import {
|
|
8
8
|
streamText,
|
|
9
|
-
UIMessage,
|
|
10
9
|
convertToModelMessages,
|
|
11
10
|
tool,
|
|
12
11
|
stepCountIs,
|
|
12
|
+
zodSchema,
|
|
13
13
|
} from "ai";
|
|
14
|
+
import type { UIMessage } from "ai";
|
|
14
15
|
import { z } from "zod";
|
|
15
16
|
|
|
16
17
|
// Allow streaming responses up to 30 seconds
|
|
@@ -21,15 +22,16 @@ export async function POST(req: Request) {
|
|
|
21
22
|
|
|
22
23
|
const result = streamText({
|
|
23
24
|
model: openai("gpt-4o"),
|
|
24
|
-
messages: convertToModelMessages(messages),
|
|
25
|
+
messages: await convertToModelMessages(messages),
|
|
25
26
|
stopWhen: stepCountIs(10),
|
|
26
27
|
tools: {
|
|
27
28
|
get_current_weather: tool({
|
|
28
|
-
name: "",
|
|
29
29
|
description: "Get the current weather",
|
|
30
|
-
inputSchema:
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
inputSchema: zodSchema(
|
|
31
|
+
z.object({
|
|
32
|
+
city: z.string(),
|
|
33
|
+
}),
|
|
34
|
+
),
|
|
33
35
|
execute: async ({ city }) => {
|
|
34
36
|
return `The weather in ${city} is sunny`;
|
|
35
37
|
},
|
|
@@ -474,7 +476,7 @@ export const ComposerAddAttachment: FC = () => {
|
|
|
474
476
|
side="bottom"
|
|
475
477
|
variant="ghost"
|
|
476
478
|
size="icon"
|
|
477
|
-
className="aui-composer-add-attachment size-
|
|
479
|
+
className="aui-composer-add-attachment size-8.5 rounded-full p-1 font-semibold text-xs hover:bg-muted-foreground/15 dark:border-muted-foreground/15 dark:hover:bg-muted-foreground/30"
|
|
478
480
|
aria-label="Add Attachment"
|
|
479
481
|
>
|
|
480
482
|
<PlusIcon className="aui-attachment-add-icon size-5 stroke-[1.5px]" />
|
|
@@ -733,6 +735,7 @@ import { TooltipIconButton } from "@/components/assistant-ui/tooltip-icon-button
|
|
|
733
735
|
import { Button } from "@/components/ui/button";
|
|
734
736
|
import { cn } from "@/lib/utils";
|
|
735
737
|
import {
|
|
738
|
+
ActionBarMorePrimitive,
|
|
736
739
|
ActionBarPrimitive,
|
|
737
740
|
AssistantIf,
|
|
738
741
|
BranchPickerPrimitive,
|
|
@@ -749,6 +752,7 @@ import {
|
|
|
749
752
|
ChevronRightIcon,
|
|
750
753
|
CopyIcon,
|
|
751
754
|
DownloadIcon,
|
|
755
|
+
MoreHorizontalIcon,
|
|
752
756
|
PencilIcon,
|
|
753
757
|
RefreshCwIcon,
|
|
754
758
|
SquareIcon,
|
|
@@ -970,16 +974,33 @@ const AssistantActionBar: FC = () => {
|
|
|
970
974
|
</AssistantIf>
|
|
971
975
|
</TooltipIconButton>
|
|
972
976
|
</ActionBarPrimitive.Copy>
|
|
973
|
-
<ActionBarPrimitive.ExportMarkdown asChild>
|
|
974
|
-
<TooltipIconButton tooltip="Export as Markdown">
|
|
975
|
-
<DownloadIcon />
|
|
976
|
-
</TooltipIconButton>
|
|
977
|
-
</ActionBarPrimitive.ExportMarkdown>
|
|
978
977
|
<ActionBarPrimitive.Reload asChild>
|
|
979
978
|
<TooltipIconButton tooltip="Refresh">
|
|
980
979
|
<RefreshCwIcon />
|
|
981
980
|
</TooltipIconButton>
|
|
982
981
|
</ActionBarPrimitive.Reload>
|
|
982
|
+
<ActionBarMorePrimitive.Root>
|
|
983
|
+
<ActionBarMorePrimitive.Trigger asChild>
|
|
984
|
+
<TooltipIconButton
|
|
985
|
+
tooltip="More"
|
|
986
|
+
className="data-[state=open]:bg-accent"
|
|
987
|
+
>
|
|
988
|
+
<MoreHorizontalIcon />
|
|
989
|
+
</TooltipIconButton>
|
|
990
|
+
</ActionBarMorePrimitive.Trigger>
|
|
991
|
+
<ActionBarMorePrimitive.Content
|
|
992
|
+
side="bottom"
|
|
993
|
+
align="start"
|
|
994
|
+
className="aui-action-bar-more-content z-50 min-w-32 overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md"
|
|
995
|
+
>
|
|
996
|
+
<ActionBarPrimitive.ExportMarkdown asChild>
|
|
997
|
+
<ActionBarMorePrimitive.Item className="aui-action-bar-more-item flex cursor-pointer select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground">
|
|
998
|
+
<DownloadIcon className="size-4" />
|
|
999
|
+
Export as Markdown
|
|
1000
|
+
</ActionBarMorePrimitive.Item>
|
|
1001
|
+
</ActionBarPrimitive.ExportMarkdown>
|
|
1002
|
+
</ActionBarMorePrimitive.Content>
|
|
1003
|
+
</ActionBarMorePrimitive.Root>
|
|
983
1004
|
</ActionBarPrimitive.Root>
|
|
984
1005
|
);
|
|
985
1006
|
};
|
|
@@ -1080,98 +1101,329 @@ const BranchPicker: FC<BranchPickerPrimitive.Root.Props> = ({
|
|
|
1080
1101
|
## components/assistant-ui/tool-fallback.tsx
|
|
1081
1102
|
|
|
1082
1103
|
```tsx
|
|
1083
|
-
|
|
1104
|
+
"use client";
|
|
1105
|
+
|
|
1106
|
+
import { memo, useCallback, useRef, useState } from "react";
|
|
1084
1107
|
import {
|
|
1108
|
+
AlertCircleIcon,
|
|
1085
1109
|
CheckIcon,
|
|
1086
1110
|
ChevronDownIcon,
|
|
1087
|
-
|
|
1111
|
+
LoaderIcon,
|
|
1088
1112
|
XCircleIcon,
|
|
1089
1113
|
} from "lucide-react";
|
|
1090
|
-
import {
|
|
1091
|
-
|
|
1114
|
+
import {
|
|
1115
|
+
useScrollLock,
|
|
1116
|
+
type ToolCallMessagePartStatus,
|
|
1117
|
+
type ToolCallMessagePartComponent,
|
|
1118
|
+
} from "@assistant-ui/react";
|
|
1119
|
+
import {
|
|
1120
|
+
Collapsible,
|
|
1121
|
+
CollapsibleContent,
|
|
1122
|
+
CollapsibleTrigger,
|
|
1123
|
+
} from "@/components/ui/collapsible";
|
|
1092
1124
|
import { cn } from "@/lib/utils";
|
|
1093
1125
|
|
|
1094
|
-
|
|
1126
|
+
const ANIMATION_DURATION = 200;
|
|
1127
|
+
|
|
1128
|
+
export type ToolFallbackRootProps = Omit<
|
|
1129
|
+
React.ComponentProps<typeof Collapsible>,
|
|
1130
|
+
"open" | "onOpenChange"
|
|
1131
|
+
> & {
|
|
1132
|
+
open?: boolean;
|
|
1133
|
+
onOpenChange?: (open: boolean) => void;
|
|
1134
|
+
defaultOpen?: boolean;
|
|
1135
|
+
};
|
|
1136
|
+
|
|
1137
|
+
function ToolFallbackRoot({
|
|
1138
|
+
className,
|
|
1139
|
+
open: controlledOpen,
|
|
1140
|
+
onOpenChange: controlledOnOpenChange,
|
|
1141
|
+
defaultOpen = false,
|
|
1142
|
+
children,
|
|
1143
|
+
...props
|
|
1144
|
+
}: ToolFallbackRootProps) {
|
|
1145
|
+
const collapsibleRef = useRef<HTMLDivElement>(null);
|
|
1146
|
+
const [uncontrolledOpen, setUncontrolledOpen] = useState(defaultOpen);
|
|
1147
|
+
const lockScroll = useScrollLock(collapsibleRef, ANIMATION_DURATION);
|
|
1148
|
+
|
|
1149
|
+
const isControlled = controlledOpen !== undefined;
|
|
1150
|
+
const isOpen = isControlled ? controlledOpen : uncontrolledOpen;
|
|
1151
|
+
|
|
1152
|
+
const handleOpenChange = useCallback(
|
|
1153
|
+
(open: boolean) => {
|
|
1154
|
+
if (!open) {
|
|
1155
|
+
lockScroll();
|
|
1156
|
+
}
|
|
1157
|
+
if (!isControlled) {
|
|
1158
|
+
setUncontrolledOpen(open);
|
|
1159
|
+
}
|
|
1160
|
+
controlledOnOpenChange?.(open);
|
|
1161
|
+
},
|
|
1162
|
+
[lockScroll, isControlled, controlledOnOpenChange],
|
|
1163
|
+
);
|
|
1164
|
+
|
|
1165
|
+
return (
|
|
1166
|
+
<Collapsible
|
|
1167
|
+
ref={collapsibleRef}
|
|
1168
|
+
data-slot="tool-fallback-root"
|
|
1169
|
+
open={isOpen}
|
|
1170
|
+
onOpenChange={handleOpenChange}
|
|
1171
|
+
className={cn(
|
|
1172
|
+
"aui-tool-fallback-root group/tool-fallback-root w-full rounded-lg border py-3",
|
|
1173
|
+
className,
|
|
1174
|
+
)}
|
|
1175
|
+
style={
|
|
1176
|
+
{
|
|
1177
|
+
"--animation-duration": `${ANIMATION_DURATION}ms`,
|
|
1178
|
+
} as React.CSSProperties
|
|
1179
|
+
}
|
|
1180
|
+
{...props}
|
|
1181
|
+
>
|
|
1182
|
+
{children}
|
|
1183
|
+
</Collapsible>
|
|
1184
|
+
);
|
|
1185
|
+
}
|
|
1186
|
+
|
|
1187
|
+
type ToolStatus = ToolCallMessagePartStatus["type"];
|
|
1188
|
+
|
|
1189
|
+
const statusIconMap: Record<ToolStatus, React.ElementType> = {
|
|
1190
|
+
running: LoaderIcon,
|
|
1191
|
+
complete: CheckIcon,
|
|
1192
|
+
incomplete: XCircleIcon,
|
|
1193
|
+
"requires-action": AlertCircleIcon,
|
|
1194
|
+
};
|
|
1195
|
+
|
|
1196
|
+
function ToolFallbackTrigger({
|
|
1095
1197
|
toolName,
|
|
1096
|
-
argsText,
|
|
1097
|
-
result,
|
|
1098
1198
|
status,
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1199
|
+
className,
|
|
1200
|
+
...props
|
|
1201
|
+
}: React.ComponentProps<typeof CollapsibleTrigger> & {
|
|
1202
|
+
toolName: string;
|
|
1203
|
+
status?: ToolCallMessagePartStatus;
|
|
1204
|
+
}) {
|
|
1205
|
+
const statusType = status?.type ?? "complete";
|
|
1206
|
+
const isRunning = statusType === "running";
|
|
1102
1207
|
const isCancelled =
|
|
1103
1208
|
status?.type === "incomplete" && status.reason === "cancelled";
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
? status.error
|
|
1108
|
-
: JSON.stringify(status.error)
|
|
1109
|
-
: null;
|
|
1209
|
+
|
|
1210
|
+
const Icon = statusIconMap[statusType];
|
|
1211
|
+
const label = isCancelled ? "Cancelled tool" : "Used tool";
|
|
1110
1212
|
|
|
1111
1213
|
return (
|
|
1112
|
-
<
|
|
1214
|
+
<CollapsibleTrigger
|
|
1215
|
+
data-slot="tool-fallback-trigger"
|
|
1113
1216
|
className={cn(
|
|
1114
|
-
"aui-tool-fallback-
|
|
1115
|
-
|
|
1217
|
+
"aui-tool-fallback-trigger group/trigger flex w-full items-center gap-2 px-4 text-sm transition-colors",
|
|
1218
|
+
className,
|
|
1116
1219
|
)}
|
|
1220
|
+
{...props}
|
|
1117
1221
|
>
|
|
1118
|
-
<
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1222
|
+
<Icon
|
|
1223
|
+
data-slot="tool-fallback-trigger-icon"
|
|
1224
|
+
className={cn(
|
|
1225
|
+
"aui-tool-fallback-trigger-icon size-4 shrink-0",
|
|
1226
|
+
isCancelled && "text-muted-foreground",
|
|
1227
|
+
isRunning && "animate-spin",
|
|
1123
1228
|
)}
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
<div className="aui-tool-fallback-cancelled-root px-4">
|
|
1141
|
-
<p className="aui-tool-fallback-cancelled-header font-semibold text-muted-foreground">
|
|
1142
|
-
Cancelled reason:
|
|
1143
|
-
</p>
|
|
1144
|
-
<p className="aui-tool-fallback-cancelled-reason text-muted-foreground">
|
|
1145
|
-
{cancelledReason}
|
|
1146
|
-
</p>
|
|
1147
|
-
</div>
|
|
1148
|
-
)}
|
|
1149
|
-
<div
|
|
1150
|
-
className={cn(
|
|
1151
|
-
"aui-tool-fallback-args-root px-4",
|
|
1152
|
-
isCancelled && "opacity-60",
|
|
1153
|
-
)}
|
|
1229
|
+
/>
|
|
1230
|
+
<span
|
|
1231
|
+
data-slot="tool-fallback-trigger-label"
|
|
1232
|
+
className={cn(
|
|
1233
|
+
"aui-tool-fallback-trigger-label-wrapper relative inline-block grow text-left leading-none",
|
|
1234
|
+
isCancelled && "text-muted-foreground line-through",
|
|
1235
|
+
)}
|
|
1236
|
+
>
|
|
1237
|
+
<span>
|
|
1238
|
+
{label}: <b>{toolName}</b>
|
|
1239
|
+
</span>
|
|
1240
|
+
{isRunning && (
|
|
1241
|
+
<span
|
|
1242
|
+
aria-hidden
|
|
1243
|
+
data-slot="tool-fallback-trigger-shimmer"
|
|
1244
|
+
className="aui-tool-fallback-trigger-shimmer shimmer pointer-events-none absolute inset-0 motion-reduce:animate-none"
|
|
1154
1245
|
>
|
|
1155
|
-
<
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1246
|
+
{label}: <b>{toolName}</b>
|
|
1247
|
+
</span>
|
|
1248
|
+
)}
|
|
1249
|
+
</span>
|
|
1250
|
+
<ChevronDownIcon
|
|
1251
|
+
data-slot="tool-fallback-trigger-chevron"
|
|
1252
|
+
className={cn(
|
|
1253
|
+
"aui-tool-fallback-trigger-chevron size-4 shrink-0",
|
|
1254
|
+
"transition-transform duration-(--animation-duration) ease-out",
|
|
1255
|
+
"group-data-[state=closed]/trigger:-rotate-90",
|
|
1256
|
+
"group-data-[state=open]/trigger:rotate-0",
|
|
1257
|
+
)}
|
|
1258
|
+
/>
|
|
1259
|
+
</CollapsibleTrigger>
|
|
1260
|
+
);
|
|
1261
|
+
}
|
|
1262
|
+
|
|
1263
|
+
function ToolFallbackContent({
|
|
1264
|
+
className,
|
|
1265
|
+
children,
|
|
1266
|
+
...props
|
|
1267
|
+
}: React.ComponentProps<typeof CollapsibleContent>) {
|
|
1268
|
+
return (
|
|
1269
|
+
<CollapsibleContent
|
|
1270
|
+
data-slot="tool-fallback-content"
|
|
1271
|
+
className={cn(
|
|
1272
|
+
"aui-tool-fallback-content relative overflow-hidden text-sm outline-none",
|
|
1273
|
+
"group/collapsible-content ease-out",
|
|
1274
|
+
"data-[state=closed]:animate-collapsible-up",
|
|
1275
|
+
"data-[state=open]:animate-collapsible-down",
|
|
1276
|
+
"data-[state=closed]:fill-mode-forwards",
|
|
1277
|
+
"data-[state=closed]:pointer-events-none",
|
|
1278
|
+
"data-[state=open]:duration-(--animation-duration)",
|
|
1279
|
+
"data-[state=closed]:duration-(--animation-duration)",
|
|
1280
|
+
className,
|
|
1281
|
+
)}
|
|
1282
|
+
{...props}
|
|
1283
|
+
>
|
|
1284
|
+
<div className="mt-3 flex flex-col gap-2 border-t pt-2">{children}</div>
|
|
1285
|
+
</CollapsibleContent>
|
|
1286
|
+
);
|
|
1287
|
+
}
|
|
1288
|
+
|
|
1289
|
+
function ToolFallbackArgs({
|
|
1290
|
+
argsText,
|
|
1291
|
+
className,
|
|
1292
|
+
...props
|
|
1293
|
+
}: React.ComponentProps<"div"> & {
|
|
1294
|
+
argsText?: string;
|
|
1295
|
+
}) {
|
|
1296
|
+
if (!argsText) return null;
|
|
1297
|
+
|
|
1298
|
+
return (
|
|
1299
|
+
<div
|
|
1300
|
+
data-slot="tool-fallback-args"
|
|
1301
|
+
className={cn("aui-tool-fallback-args px-4", className)}
|
|
1302
|
+
{...props}
|
|
1303
|
+
>
|
|
1304
|
+
<pre className="aui-tool-fallback-args-value whitespace-pre-wrap">
|
|
1305
|
+
{argsText}
|
|
1306
|
+
</pre>
|
|
1307
|
+
</div>
|
|
1308
|
+
);
|
|
1309
|
+
}
|
|
1310
|
+
|
|
1311
|
+
function ToolFallbackResult({
|
|
1312
|
+
result,
|
|
1313
|
+
className,
|
|
1314
|
+
...props
|
|
1315
|
+
}: React.ComponentProps<"div"> & {
|
|
1316
|
+
result?: unknown;
|
|
1317
|
+
}) {
|
|
1318
|
+
if (result === undefined) return null;
|
|
1319
|
+
|
|
1320
|
+
return (
|
|
1321
|
+
<div
|
|
1322
|
+
data-slot="tool-fallback-result"
|
|
1323
|
+
className={cn(
|
|
1324
|
+
"aui-tool-fallback-result border-t border-dashed px-4 pt-2",
|
|
1325
|
+
className,
|
|
1172
1326
|
)}
|
|
1327
|
+
{...props}
|
|
1328
|
+
>
|
|
1329
|
+
<p className="aui-tool-fallback-result-header font-semibold">Result:</p>
|
|
1330
|
+
<pre className="aui-tool-fallback-result-content whitespace-pre-wrap">
|
|
1331
|
+
{typeof result === "string" ? result : JSON.stringify(result, null, 2)}
|
|
1332
|
+
</pre>
|
|
1173
1333
|
</div>
|
|
1174
1334
|
);
|
|
1335
|
+
}
|
|
1336
|
+
|
|
1337
|
+
function ToolFallbackError({
|
|
1338
|
+
status,
|
|
1339
|
+
className,
|
|
1340
|
+
...props
|
|
1341
|
+
}: React.ComponentProps<"div"> & {
|
|
1342
|
+
status?: ToolCallMessagePartStatus;
|
|
1343
|
+
}) {
|
|
1344
|
+
if (status?.type !== "incomplete") return null;
|
|
1345
|
+
|
|
1346
|
+
const error = status.error;
|
|
1347
|
+
const errorText = error
|
|
1348
|
+
? typeof error === "string"
|
|
1349
|
+
? error
|
|
1350
|
+
: JSON.stringify(error)
|
|
1351
|
+
: null;
|
|
1352
|
+
|
|
1353
|
+
if (!errorText) return null;
|
|
1354
|
+
|
|
1355
|
+
const isCancelled = status.reason === "cancelled";
|
|
1356
|
+
const headerText = isCancelled ? "Cancelled reason:" : "Error:";
|
|
1357
|
+
|
|
1358
|
+
return (
|
|
1359
|
+
<div
|
|
1360
|
+
data-slot="tool-fallback-error"
|
|
1361
|
+
className={cn("aui-tool-fallback-error px-4", className)}
|
|
1362
|
+
{...props}
|
|
1363
|
+
>
|
|
1364
|
+
<p className="aui-tool-fallback-error-header font-semibold text-muted-foreground">
|
|
1365
|
+
{headerText}
|
|
1366
|
+
</p>
|
|
1367
|
+
<p className="aui-tool-fallback-error-reason text-muted-foreground">
|
|
1368
|
+
{errorText}
|
|
1369
|
+
</p>
|
|
1370
|
+
</div>
|
|
1371
|
+
);
|
|
1372
|
+
}
|
|
1373
|
+
|
|
1374
|
+
const ToolFallbackImpl: ToolCallMessagePartComponent = ({
|
|
1375
|
+
toolName,
|
|
1376
|
+
argsText,
|
|
1377
|
+
result,
|
|
1378
|
+
status,
|
|
1379
|
+
}) => {
|
|
1380
|
+
const isCancelled =
|
|
1381
|
+
status?.type === "incomplete" && status.reason === "cancelled";
|
|
1382
|
+
|
|
1383
|
+
return (
|
|
1384
|
+
<ToolFallbackRoot
|
|
1385
|
+
className={cn(isCancelled && "border-muted-foreground/30 bg-muted/30")}
|
|
1386
|
+
>
|
|
1387
|
+
<ToolFallbackTrigger toolName={toolName} status={status} />
|
|
1388
|
+
<ToolFallbackContent>
|
|
1389
|
+
<ToolFallbackError status={status} />
|
|
1390
|
+
<ToolFallbackArgs
|
|
1391
|
+
argsText={argsText}
|
|
1392
|
+
className={cn(isCancelled && "opacity-60")}
|
|
1393
|
+
/>
|
|
1394
|
+
{!isCancelled && <ToolFallbackResult result={result} />}
|
|
1395
|
+
</ToolFallbackContent>
|
|
1396
|
+
</ToolFallbackRoot>
|
|
1397
|
+
);
|
|
1398
|
+
};
|
|
1399
|
+
|
|
1400
|
+
const ToolFallback = memo(
|
|
1401
|
+
ToolFallbackImpl,
|
|
1402
|
+
) as unknown as ToolCallMessagePartComponent & {
|
|
1403
|
+
Root: typeof ToolFallbackRoot;
|
|
1404
|
+
Trigger: typeof ToolFallbackTrigger;
|
|
1405
|
+
Content: typeof ToolFallbackContent;
|
|
1406
|
+
Args: typeof ToolFallbackArgs;
|
|
1407
|
+
Result: typeof ToolFallbackResult;
|
|
1408
|
+
Error: typeof ToolFallbackError;
|
|
1409
|
+
};
|
|
1410
|
+
|
|
1411
|
+
ToolFallback.displayName = "ToolFallback";
|
|
1412
|
+
ToolFallback.Root = ToolFallbackRoot;
|
|
1413
|
+
ToolFallback.Trigger = ToolFallbackTrigger;
|
|
1414
|
+
ToolFallback.Content = ToolFallbackContent;
|
|
1415
|
+
ToolFallback.Args = ToolFallbackArgs;
|
|
1416
|
+
ToolFallback.Result = ToolFallbackResult;
|
|
1417
|
+
ToolFallback.Error = ToolFallbackError;
|
|
1418
|
+
|
|
1419
|
+
export {
|
|
1420
|
+
ToolFallback,
|
|
1421
|
+
ToolFallbackRoot,
|
|
1422
|
+
ToolFallbackTrigger,
|
|
1423
|
+
ToolFallbackContent,
|
|
1424
|
+
ToolFallbackArgs,
|
|
1425
|
+
ToolFallbackResult,
|
|
1426
|
+
ToolFallbackError,
|
|
1175
1427
|
};
|
|
1176
1428
|
|
|
1177
1429
|
```
|
|
@@ -1351,6 +1603,45 @@ export { Button, buttonVariants };
|
|
|
1351
1603
|
|
|
1352
1604
|
```
|
|
1353
1605
|
|
|
1606
|
+
## components/ui/collapsible.tsx
|
|
1607
|
+
|
|
1608
|
+
```tsx
|
|
1609
|
+
"use client";
|
|
1610
|
+
|
|
1611
|
+
import * as CollapsiblePrimitive from "@radix-ui/react-collapsible";
|
|
1612
|
+
|
|
1613
|
+
function Collapsible({
|
|
1614
|
+
...props
|
|
1615
|
+
}: React.ComponentProps<typeof CollapsiblePrimitive.Root>) {
|
|
1616
|
+
return <CollapsiblePrimitive.Root data-slot="collapsible" {...props} />;
|
|
1617
|
+
}
|
|
1618
|
+
|
|
1619
|
+
function CollapsibleTrigger({
|
|
1620
|
+
...props
|
|
1621
|
+
}: React.ComponentProps<typeof CollapsiblePrimitive.CollapsibleTrigger>) {
|
|
1622
|
+
return (
|
|
1623
|
+
<CollapsiblePrimitive.CollapsibleTrigger
|
|
1624
|
+
data-slot="collapsible-trigger"
|
|
1625
|
+
{...props}
|
|
1626
|
+
/>
|
|
1627
|
+
);
|
|
1628
|
+
}
|
|
1629
|
+
|
|
1630
|
+
function CollapsibleContent({
|
|
1631
|
+
...props
|
|
1632
|
+
}: React.ComponentProps<typeof CollapsiblePrimitive.CollapsibleContent>) {
|
|
1633
|
+
return (
|
|
1634
|
+
<CollapsiblePrimitive.CollapsibleContent
|
|
1635
|
+
data-slot="collapsible-content"
|
|
1636
|
+
{...props}
|
|
1637
|
+
/>
|
|
1638
|
+
);
|
|
1639
|
+
}
|
|
1640
|
+
|
|
1641
|
+
export { Collapsible, CollapsibleTrigger, CollapsibleContent };
|
|
1642
|
+
|
|
1643
|
+
```
|
|
1644
|
+
|
|
1354
1645
|
## components/ui/dialog.tsx
|
|
1355
1646
|
|
|
1356
1647
|
```tsx
|
|
@@ -1595,7 +1886,7 @@ export default nextConfig;
|
|
|
1595
1886
|
|
|
1596
1887
|
```json
|
|
1597
1888
|
{
|
|
1598
|
-
"name": "with-ai-sdk-
|
|
1889
|
+
"name": "with-ai-sdk-v6",
|
|
1599
1890
|
"version": "0.0.0",
|
|
1600
1891
|
"private": true,
|
|
1601
1892
|
"type": "module",
|
|
@@ -1605,31 +1896,32 @@ export default nextConfig;
|
|
|
1605
1896
|
"start": "next start"
|
|
1606
1897
|
},
|
|
1607
1898
|
"dependencies": {
|
|
1608
|
-
"@ai-sdk/openai": "^
|
|
1899
|
+
"@ai-sdk/openai": "^3.0.13",
|
|
1609
1900
|
"@assistant-ui/react": "workspace:*",
|
|
1610
1901
|
"@assistant-ui/react-ai-sdk": "workspace:*",
|
|
1611
1902
|
"@assistant-ui/react-markdown": "workspace:*",
|
|
1612
1903
|
"@radix-ui/react-avatar": "^1.1.11",
|
|
1904
|
+
"@radix-ui/react-collapsible": "^1.1.12",
|
|
1613
1905
|
"@radix-ui/react-dialog": "^1.1.15",
|
|
1614
1906
|
"@radix-ui/react-slot": "^1.2.4",
|
|
1615
1907
|
"@radix-ui/react-tooltip": "^1.2.8",
|
|
1616
|
-
"ai": "^
|
|
1908
|
+
"ai": "^6.0.42",
|
|
1617
1909
|
"class-variance-authority": "^0.7.1",
|
|
1618
1910
|
"clsx": "^2.1.1",
|
|
1619
1911
|
"lucide-react": "^0.562.0",
|
|
1620
|
-
"next": "16.1.
|
|
1621
|
-
"react": "19.2.3",
|
|
1622
|
-
"react-dom": "19.2.3",
|
|
1912
|
+
"next": "^16.1.4",
|
|
1913
|
+
"react": "^19.2.3",
|
|
1914
|
+
"react-dom": "^19.2.3",
|
|
1623
1915
|
"remark-gfm": "^4.0.1",
|
|
1624
1916
|
"tailwind-merge": "^3.4.0",
|
|
1625
|
-
"zod": "^4.
|
|
1626
|
-
"zustand": "^5.0.
|
|
1917
|
+
"zod": "^4.3.5",
|
|
1918
|
+
"zustand": "^5.0.10"
|
|
1627
1919
|
},
|
|
1628
1920
|
"devDependencies": {
|
|
1629
1921
|
"@assistant-ui/x-buildutils": "workspace:*",
|
|
1630
1922
|
"@tailwindcss/postcss": "^4.1.18",
|
|
1631
|
-
"@types/node": "^25.0.
|
|
1632
|
-
"@types/react": "^19.2.
|
|
1923
|
+
"@types/node": "^25.0.9",
|
|
1924
|
+
"@types/react": "^19.2.9",
|
|
1633
1925
|
"@types/react-dom": "^19.2.3",
|
|
1634
1926
|
"postcss": "^8.5.6",
|
|
1635
1927
|
"tailwindcss": "^4.1.18",
|