@chat-js/cli 0.6.1 → 0.6.2
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/dist/index.js +16938 -16786
- package/package.json +1 -1
- package/templates/chat-app/app/(auth)/login/page.tsx +3 -3
- package/templates/chat-app/app/(chat)/api/chat/route.ts +4 -60
- package/templates/chat-app/app/not-found.tsx +2 -2
- package/templates/chat-app/chat.config.ts +3 -0
- package/templates/chat-app/components/ai-elements/actions.tsx +44 -44
- package/templates/chat-app/components/ai-elements/artifact.tsx +92 -92
- package/templates/chat-app/components/ai-elements/code-block.tsx +143 -143
- package/templates/chat-app/components/ai-elements/context.tsx +313 -313
- package/templates/chat-app/components/ai-elements/conversation.tsx +65 -65
- package/templates/chat-app/components/ai-elements/extra/conversation-content-scroll-area.tsx +29 -29
- package/templates/chat-app/components/ai-elements/extra/mcp-tool-header.tsx +27 -27
- package/templates/chat-app/components/ai-elements/message.tsx +341 -344
- package/templates/chat-app/components/ai-elements/parseIncompleteMarkdown.tsx +122 -122
- package/templates/chat-app/components/ai-elements/prompt-input.tsx +1059 -1059
- package/templates/chat-app/components/ai-elements/reasoning.tsx +131 -131
- package/templates/chat-app/components/ai-elements/response.tsx +15 -12
- package/templates/chat-app/components/ai-elements/sandbox.tsx +84 -84
- package/templates/chat-app/components/ai-elements/shimmer.tsx +47 -47
- package/templates/chat-app/components/ai-elements/suggestion.tsx +33 -33
- package/templates/chat-app/components/ai-elements/tool.tsx +118 -118
- package/templates/chat-app/components/app-sidebar-history-conditional.tsx +3 -3
- package/templates/chat-app/components/app-sidebar.tsx +3 -3
- package/templates/chat-app/components/connectors-dropdown.tsx +6 -3
- package/templates/chat-app/components/deep-research-progress.tsx +1 -1
- package/templates/chat-app/components/header-breadcrumb.tsx +14 -11
- package/templates/chat-app/components/internal-link.tsx +73 -0
- package/templates/chat-app/components/login-form.tsx +5 -5
- package/templates/chat-app/components/message-parts.tsx +1 -71
- package/templates/chat-app/components/model-selector.tsx +3 -3
- package/templates/chat-app/components/new-chat-button.tsx +4 -4
- package/templates/chat-app/components/part/document-common.tsx +3 -3
- package/templates/chat-app/components/part/document-tool.tsx +3 -3
- package/templates/chat-app/components/part/message-annotations.tsx +2 -2
- package/templates/chat-app/components/part/tool-part.tsx +92 -0
- package/templates/chat-app/components/project-chat-item.tsx +2 -2
- package/templates/chat-app/components/research-progress.tsx +2 -2
- package/templates/chat-app/components/research-task.tsx +1 -1
- package/templates/chat-app/components/research-tasks.tsx +1 -1
- package/templates/chat-app/components/settings/connectors-settings.tsx +4 -4
- package/templates/chat-app/components/settings/mcp-details-page.tsx +5 -5
- package/templates/chat-app/components/settings/settings-nav.tsx +3 -3
- package/templates/chat-app/components/sidebar-chat-item.tsx +4 -12
- package/templates/chat-app/components/sidebar-project-item.tsx +4 -11
- package/templates/chat-app/components/sidebar-top-row.tsx +7 -7
- package/templates/chat-app/components/sidebar-user-nav.tsx +3 -3
- package/templates/chat-app/components/signup-form.tsx +8 -5
- package/templates/chat-app/components/source-badge.tsx +3 -9
- package/templates/chat-app/components/sources.tsx +1 -1
- package/templates/chat-app/components/ui/accordion.tsx +32 -32
- package/templates/chat-app/components/ui/alert-dialog.tsx +103 -103
- package/templates/chat-app/components/ui/alert.tsx +36 -36
- package/templates/chat-app/components/ui/avatar.tsx +28 -28
- package/templates/chat-app/components/ui/badge.tsx +22 -22
- package/templates/chat-app/components/ui/breadcrumb.tsx +72 -72
- package/templates/chat-app/components/ui/button-group.tsx +58 -58
- package/templates/chat-app/components/ui/button.tsx +45 -45
- package/templates/chat-app/components/ui/card.tsx +65 -65
- package/templates/chat-app/components/ui/checkbox.tsx +16 -16
- package/templates/chat-app/components/ui/collapsible.tsx +1 -1
- package/templates/chat-app/components/ui/command.tsx +137 -137
- package/templates/chat-app/components/ui/dialog.tsx +94 -94
- package/templates/chat-app/components/ui/drawer.tsx +68 -68
- package/templates/chat-app/components/ui/dropdown-menu.tsx +184 -184
- package/templates/chat-app/components/ui/empty.tsx +76 -76
- package/templates/chat-app/components/ui/extra/action-container.tsx +3 -3
- package/templates/chat-app/components/ui/extra/scroll-area-viewport-ref.tsx +24 -24
- package/templates/chat-app/components/ui/form.tsx +112 -112
- package/templates/chat-app/components/ui/hover-card.tsx +25 -25
- package/templates/chat-app/components/ui/input-group.tsx +126 -126
- package/templates/chat-app/components/ui/input.tsx +13 -13
- package/templates/chat-app/components/ui/label.tsx +12 -12
- package/templates/chat-app/components/ui/popover.tsx +25 -25
- package/templates/chat-app/components/ui/progress.tsx +19 -19
- package/templates/chat-app/components/ui/resizable.tsx +27 -27
- package/templates/chat-app/components/ui/scroll-area.tsx +30 -30
- package/templates/chat-app/components/ui/select.tsx +108 -108
- package/templates/chat-app/components/ui/separator.tsx +16 -16
- package/templates/chat-app/components/ui/sheet.tsx +91 -91
- package/templates/chat-app/components/ui/sidebar.tsx +615 -615
- package/templates/chat-app/components/ui/skeleton.tsx +7 -7
- package/templates/chat-app/components/ui/slider.tsx +50 -50
- package/templates/chat-app/components/ui/spinner.tsx +8 -8
- package/templates/chat-app/components/ui/switch.tsx +16 -16
- package/templates/chat-app/components/ui/table.tsx +71 -71
- package/templates/chat-app/components/ui/tabs.tsx +31 -31
- package/templates/chat-app/components/ui/textarea.tsx +10 -10
- package/templates/chat-app/components/ui/toggle.tsx +31 -31
- package/templates/chat-app/components/ui/tooltip.tsx +48 -48
- package/templates/chat-app/components/upgrade-cta/limit-display.tsx +7 -7
- package/templates/chat-app/components/upgrade-cta/login-cta-banner.tsx +3 -3
- package/templates/chat-app/components/upgrade-cta/login-prompt.tsx +3 -3
- package/templates/chat-app/hooks/use-mobile.ts +13 -13
- package/templates/chat-app/lib/ai/core-chat-agent.ts +25 -14
- package/templates/chat-app/lib/ai/eval-agent.ts +4 -5
- package/templates/chat-app/lib/ai/installed-tools.ts +12 -0
- package/templates/chat-app/lib/ai/mcp/mcp-client.ts +2 -2
- package/templates/chat-app/lib/ai/models.generated.ts +4236 -4585
- package/templates/chat-app/lib/ai/tool-renderer-registry.ts +31 -0
- package/templates/chat-app/lib/ai/types.ts +15 -20
- package/templates/chat-app/lib/config-requirements.ts +11 -6
- package/templates/chat-app/lib/config-schema.ts +13 -0
- package/templates/chat-app/lib/stores/hooks-message-parts.ts +1 -1
- package/templates/chat-app/lib/utils.ts +157 -157
- package/templates/chat-app/package.json +1 -1
- package/templates/chat-app/scripts/check-env.ts +229 -2
- package/templates/chat-app/tools/chatjs/_shared/lib/tool-part.ts +5 -0
- package/templates/chat-app/{components/part/weather.tsx → tools/chatjs/get-weather/renderer.tsx} +24 -38
- package/templates/chat-app/{components/part/retrieve-url.tsx → tools/chatjs/retrieve-url/renderer.tsx} +20 -15
- package/templates/chat-app/{lib/ai/tools/retrieve-url.ts → tools/chatjs/retrieve-url/tool.ts} +46 -7
- package/templates/chat-app/tools/chatjs/tools.ts +16 -0
- package/templates/chat-app/tools/chatjs/ui.ts +17 -0
- package/templates/chat-app/tools/chatjs/word-count/renderer.tsx +50 -0
- package/templates/chat-app/tools/chatjs/word-count/tool.ts +30 -0
- package/templates/chat-app/{lib/ai/tools → tools/platform}/code-execution.ts +3 -5
- package/templates/chat-app/{lib/ai/tools → tools/platform}/deep-research/deep-research.ts +2 -3
- package/templates/chat-app/{lib/ai/tools → tools/platform}/deep-research/pipeline.ts +1 -1
- package/templates/chat-app/{lib/ai/tools → tools/platform}/deep-research/types.ts +1 -1
- package/templates/chat-app/{lib/ai/tools → tools/platform}/deep-research/utils.ts +7 -7
- package/templates/chat-app/{lib/ai/tools → tools/platform}/documents/types.ts +1 -1
- package/templates/chat-app/{lib/ai/tools → tools/platform}/generate-video.ts +4 -6
- package/templates/chat-app/{lib/ai/tools → tools/platform}/read-document.ts +2 -2
- package/templates/chat-app/{lib/ai/tools → tools/platform}/steps/multi-query-web-search.ts +1 -1
- package/templates/chat-app/{lib/ai/tools → tools/platform}/steps/web-search.ts +1 -1
- package/templates/chat-app/{lib/ai/tools → tools/platform}/tools.ts +20 -20
- package/templates/chat-app/{lib/ai/tools → tools/platform}/web-search.ts +7 -5
- package/templates/electron/CHANGELOG.md +7 -1
- package/templates/electron/package.json +1 -1
- package/templates/chat-app/lib/ai/tools/tools-definitions.ts +0 -83
- /package/templates/chat-app/{lib/ai/tools/get-weather.ts → tools/chatjs/get-weather/tool.ts} +0 -0
- /package/templates/chat-app/{lib/ai/tools → tools/platform}/code-execution.javascript.ts +0 -0
- /package/templates/chat-app/{lib/ai/tools → tools/platform}/code-execution.python.ts +0 -0
- /package/templates/chat-app/{lib/ai/tools → tools/platform}/code-execution.shared.test.ts +0 -0
- /package/templates/chat-app/{lib/ai/tools → tools/platform}/code-execution.shared.ts +0 -0
- /package/templates/chat-app/{lib/ai/tools → tools/platform}/code-execution.types.ts +0 -0
- /package/templates/chat-app/{lib/ai/tools → tools/platform}/deep-research/configuration.ts +0 -0
- /package/templates/chat-app/{lib/ai/tools → tools/platform}/deep-research/prompts.ts +0 -0
- /package/templates/chat-app/{lib/ai/tools → tools/platform}/deep-research/researcher-agent.ts +0 -0
- /package/templates/chat-app/{lib/ai/tools → tools/platform}/deep-research/supervisor-agent.ts +0 -0
- /package/templates/chat-app/{lib/ai/tools → tools/platform}/documents/code-guidelines.ts +0 -0
- /package/templates/chat-app/{lib/ai/tools → tools/platform}/documents/create-code-document.ts +0 -0
- /package/templates/chat-app/{lib/ai/tools → tools/platform}/documents/create-sheet-document.ts +0 -0
- /package/templates/chat-app/{lib/ai/tools → tools/platform}/documents/create-text-document.ts +0 -0
- /package/templates/chat-app/{lib/ai/tools → tools/platform}/documents/edit-code-document.ts +0 -0
- /package/templates/chat-app/{lib/ai/tools → tools/platform}/documents/edit-sheet-document.ts +0 -0
- /package/templates/chat-app/{lib/ai/tools → tools/platform}/documents/edit-text-document.ts +0 -0
- /package/templates/chat-app/{lib/ai/tools → tools/platform}/documents/sheet-guidelines.ts +0 -0
- /package/templates/chat-app/{lib/ai/tools → tools/platform}/documents/text-guidelines.ts +0 -0
- /package/templates/chat-app/{lib/ai/tools → tools/platform}/generate-image.ts +0 -0
- /package/templates/chat-app/{lib/ai/tools → tools/platform}/research-updates-schema.ts +0 -0
- /package/templates/chat-app/{lib/ai/tools → tools/platform}/steps/search-utils.ts +0 -0
- /package/templates/chat-app/{lib/ai/tools → tools/platform}/types.ts +0 -0
|
@@ -6,67 +6,67 @@ import type * as React from "react";
|
|
|
6
6
|
import { cn } from "@/lib/utils";
|
|
7
7
|
|
|
8
8
|
function TooltipProvider({
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
delayDuration = 0,
|
|
10
|
+
...props
|
|
11
11
|
}: React.ComponentProps<typeof TooltipPrimitive.Provider>) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
12
|
+
return (
|
|
13
|
+
<TooltipPrimitive.Provider
|
|
14
|
+
data-slot="tooltip-provider"
|
|
15
|
+
delayDuration={delayDuration}
|
|
16
|
+
{...props}
|
|
17
|
+
/>
|
|
18
|
+
);
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
function Tooltip({
|
|
22
|
-
|
|
22
|
+
...props
|
|
23
23
|
}: React.ComponentProps<typeof TooltipPrimitive.Root>) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
return (
|
|
25
|
+
<TooltipProvider>
|
|
26
|
+
<TooltipPrimitive.Root data-slot="tooltip" {...props} />
|
|
27
|
+
</TooltipProvider>
|
|
28
|
+
);
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
function TooltipTrigger({
|
|
32
|
-
|
|
32
|
+
...props
|
|
33
33
|
}: React.ComponentProps<typeof TooltipPrimitive.Trigger>) {
|
|
34
|
-
|
|
34
|
+
return <TooltipPrimitive.Trigger data-slot="tooltip-trigger" {...props} />;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
function TooltipContent({
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
38
|
+
className,
|
|
39
|
+
sideOffset = 0,
|
|
40
|
+
children,
|
|
41
|
+
variant = "primary",
|
|
42
|
+
...props
|
|
43
43
|
}: React.ComponentProps<typeof TooltipPrimitive.Content> & {
|
|
44
|
-
|
|
44
|
+
variant?: "base" | "primary";
|
|
45
45
|
}) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
46
|
+
return (
|
|
47
|
+
<TooltipPrimitive.Portal>
|
|
48
|
+
<TooltipPrimitive.Content
|
|
49
|
+
className={cn(
|
|
50
|
+
"fade-in-0 zoom-in-95 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) animate-in text-balance rounded-md px-3 py-1.5 text-xs data-[state=closed]:animate-out",
|
|
51
|
+
variant === "primary" && "bg-primary text-primary-foreground",
|
|
52
|
+
variant === "base" && "bg-popover text-popover-foreground",
|
|
53
|
+
className,
|
|
54
|
+
)}
|
|
55
|
+
data-slot="tooltip-content"
|
|
56
|
+
sideOffset={sideOffset}
|
|
57
|
+
{...props}
|
|
58
|
+
>
|
|
59
|
+
{children}
|
|
60
|
+
<TooltipPrimitive.Arrow
|
|
61
|
+
className={cn(
|
|
62
|
+
"z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]",
|
|
63
|
+
variant === "primary" && "bg-primary fill-primary",
|
|
64
|
+
variant === "base" && "bg-popover fill-popover",
|
|
65
|
+
)}
|
|
66
|
+
/>
|
|
67
|
+
</TooltipPrimitive.Content>
|
|
68
|
+
</TooltipPrimitive.Portal>
|
|
69
|
+
);
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
export { Tooltip,
|
|
72
|
+
export { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger };
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
import { X } from "lucide-react";
|
|
4
4
|
import { AnimatePresence, motion } from "motion/react";
|
|
5
|
-
import Link from "next/link";
|
|
6
5
|
import { useState } from "react";
|
|
6
|
+
import { InternalLink } from "@/components/internal-link";
|
|
7
7
|
import { useGetCredits } from "@/hooks/chat-sync-hooks";
|
|
8
8
|
import { cn } from "@/lib/utils";
|
|
9
9
|
import { useSession } from "@/providers/session-provider";
|
|
@@ -29,12 +29,12 @@ const VARIANT_CONFIG: Record<
|
|
|
29
29
|
isAtLimit ? (
|
|
30
30
|
<span>
|
|
31
31
|
You've reached your credit limit.{" "}
|
|
32
|
-
<
|
|
32
|
+
<InternalLink
|
|
33
33
|
className="font-medium text-red-700 underline hover:no-underline dark:text-red-300"
|
|
34
34
|
href="/login"
|
|
35
35
|
>
|
|
36
36
|
Sign in to reset your limits
|
|
37
|
-
</
|
|
37
|
+
</InternalLink>
|
|
38
38
|
</span>
|
|
39
39
|
) : (
|
|
40
40
|
<span>
|
|
@@ -43,12 +43,12 @@ const VARIANT_CONFIG: Record<
|
|
|
43
43
|
{remaining} credit{remaining === 1 ? "" : "s"}
|
|
44
44
|
</strong>{" "}
|
|
45
45
|
left.{" "}
|
|
46
|
-
<
|
|
46
|
+
<InternalLink
|
|
47
47
|
className="font-medium text-amber-700 underline hover:no-underline dark:text-amber-300"
|
|
48
48
|
href="/login"
|
|
49
49
|
>
|
|
50
50
|
Sign in to reset your limits
|
|
51
|
-
</
|
|
51
|
+
</InternalLink>
|
|
52
52
|
</span>
|
|
53
53
|
),
|
|
54
54
|
getClasses: ({ isAtLimit }) =>
|
|
@@ -61,12 +61,12 @@ const VARIANT_CONFIG: Record<
|
|
|
61
61
|
getMessage: () => (
|
|
62
62
|
<span>
|
|
63
63
|
This model isn't available for anonymous users.{" "}
|
|
64
|
-
<
|
|
64
|
+
<InternalLink
|
|
65
65
|
className="font-medium text-amber-700 underline hover:no-underline dark:text-amber-300"
|
|
66
66
|
href="/login"
|
|
67
67
|
>
|
|
68
68
|
Log in to use this model
|
|
69
|
-
</
|
|
69
|
+
</InternalLink>
|
|
70
70
|
</span>
|
|
71
71
|
),
|
|
72
72
|
getClasses: () =>
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
import { LogIn, X } from "lucide-react";
|
|
4
4
|
import { AnimatePresence, motion } from "motion/react";
|
|
5
|
-
import Link from "next/link";
|
|
6
5
|
import { useState } from "react";
|
|
6
|
+
import { InternalLink } from "@/components/internal-link";
|
|
7
7
|
import { Button } from "@/components/ui/button";
|
|
8
8
|
import { cn } from "@/lib/utils";
|
|
9
9
|
|
|
@@ -73,7 +73,7 @@ export function LoginCtaBanner({
|
|
|
73
73
|
)}
|
|
74
74
|
<span className={cn("text-sm", textStyles[variant])}>
|
|
75
75
|
{message}{" "}
|
|
76
|
-
<
|
|
76
|
+
<InternalLink
|
|
77
77
|
className={cn(
|
|
78
78
|
"font-medium underline hover:no-underline",
|
|
79
79
|
linkStyles[variant]
|
|
@@ -81,7 +81,7 @@ export function LoginCtaBanner({
|
|
|
81
81
|
href="/login"
|
|
82
82
|
>
|
|
83
83
|
Sign in
|
|
84
|
-
</
|
|
84
|
+
</InternalLink>
|
|
85
85
|
</span>
|
|
86
86
|
</div>
|
|
87
87
|
{dismissible && (
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import { ArrowRight } from "lucide-react";
|
|
4
|
-
import
|
|
4
|
+
import { InternalLink } from "@/components/internal-link";
|
|
5
5
|
import { cn } from "@/lib/utils";
|
|
6
6
|
|
|
7
7
|
interface LoginPromptProps {
|
|
@@ -22,12 +22,12 @@ export function LoginPrompt({
|
|
|
22
22
|
<h4 className="font-medium text-sm">{title}</h4>
|
|
23
23
|
</div>
|
|
24
24
|
<p className="ml-6 text-muted-foreground text-sm">{description}</p>
|
|
25
|
-
<
|
|
25
|
+
<InternalLink
|
|
26
26
|
className="ml-6 block font-medium text-blue-500 text-sm hover:underline"
|
|
27
27
|
href="/login"
|
|
28
28
|
>
|
|
29
29
|
Sign in
|
|
30
|
-
</
|
|
30
|
+
</InternalLink>
|
|
31
31
|
</div>
|
|
32
32
|
);
|
|
33
33
|
}
|
|
@@ -3,19 +3,19 @@ import * as React from "react";
|
|
|
3
3
|
const MOBILE_BREAKPOINT = 768;
|
|
4
4
|
|
|
5
5
|
export function useIsMobile() {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
const [isMobile, setIsMobile] = React.useState<boolean | undefined>(
|
|
7
|
+
undefined,
|
|
8
|
+
);
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
10
|
+
React.useEffect(() => {
|
|
11
|
+
const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);
|
|
12
|
+
const onChange = () => {
|
|
13
|
+
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
|
|
14
|
+
};
|
|
15
|
+
mql.addEventListener("change", onChange);
|
|
16
|
+
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
|
|
17
|
+
return () => mql.removeEventListener("change", onChange);
|
|
18
|
+
}, []);
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
return !!isMobile;
|
|
21
21
|
}
|
|
@@ -5,11 +5,12 @@ import { getRecentGeneratedImage } from "@/app/(chat)/api/chat/get-recent-genera
|
|
|
5
5
|
import { type AppModelId, getAppModelDefinition } from "@/lib/ai/app-models";
|
|
6
6
|
import { markdownJoinerTransform } from "@/lib/ai/markdown-joiner-transform";
|
|
7
7
|
import { getLanguageModel, getModelProviderOptions } from "@/lib/ai/providers";
|
|
8
|
-
import { getMcpTools, getTools } from "@/lib/ai/tools/tools";
|
|
9
8
|
import type { ChatMessage, StreamWriter, ToolName } from "@/lib/ai/types";
|
|
10
9
|
import type { CostAccumulator } from "@/lib/credits/cost-accumulator";
|
|
11
10
|
import type { McpConnector } from "@/lib/db/schema";
|
|
11
|
+
import { ANONYMOUS_LIMITS } from "@/lib/types/anonymous";
|
|
12
12
|
import { replaceFilePartUrlByBinaryDataInMessages } from "@/lib/utils/download-assets";
|
|
13
|
+
import { getMcpTools, getTools } from "@/tools/platform/tools";
|
|
13
14
|
|
|
14
15
|
export async function createCoreChatAgent({
|
|
15
16
|
system,
|
|
@@ -18,7 +19,7 @@ export async function createCoreChatAgent({
|
|
|
18
19
|
selectedModelId,
|
|
19
20
|
explicitlyRequestedTools,
|
|
20
21
|
userId,
|
|
21
|
-
|
|
22
|
+
isAnonymous = false,
|
|
22
23
|
abortSignal,
|
|
23
24
|
messageId,
|
|
24
25
|
dataStream,
|
|
@@ -33,8 +34,7 @@ export async function createCoreChatAgent({
|
|
|
33
34
|
selectedModelId: AppModelId;
|
|
34
35
|
explicitlyRequestedTools: ToolName[] | null;
|
|
35
36
|
userId: string | null;
|
|
36
|
-
|
|
37
|
-
budgetAllowedTools: ToolName[];
|
|
37
|
+
isAnonymous?: boolean;
|
|
38
38
|
abortSignal?: AbortSignal;
|
|
39
39
|
messageId: string;
|
|
40
40
|
dataStream: StreamWriter;
|
|
@@ -90,16 +90,28 @@ export async function createCoreChatAgent({
|
|
|
90
90
|
...mcpTools,
|
|
91
91
|
};
|
|
92
92
|
|
|
93
|
-
// Compute final activeTools for streamText
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
93
|
+
// Compute final activeTools for streamText
|
|
94
|
+
let activeBaseTools = Object.keys(baseTools) as ToolName[];
|
|
95
|
+
let activeMcpTools = Object.keys(mcpTools) as ToolName[];
|
|
96
|
+
if (!modelDefinition?.input) {
|
|
97
|
+
activeBaseTools = [];
|
|
98
|
+
activeMcpTools = [];
|
|
99
|
+
} else if (isAnonymous) {
|
|
100
|
+
activeBaseTools = activeBaseTools.filter((k) =>
|
|
101
|
+
(ANONYMOUS_LIMITS.AVAILABLE_TOOLS as ToolName[]).includes(k)
|
|
102
|
+
);
|
|
103
|
+
activeMcpTools = [];
|
|
104
|
+
}
|
|
105
|
+
if (explicitlyRequestedTools !== null) {
|
|
106
|
+
activeBaseTools = explicitlyRequestedTools.filter((k) =>
|
|
107
|
+
activeBaseTools.includes(k)
|
|
108
|
+
);
|
|
109
|
+
activeMcpTools = explicitlyRequestedTools.filter((k) =>
|
|
110
|
+
activeMcpTools.includes(k)
|
|
111
|
+
);
|
|
112
|
+
}
|
|
101
113
|
const activeTools = [
|
|
102
|
-
...new Set([...
|
|
114
|
+
...new Set([...activeBaseTools, ...activeMcpTools]),
|
|
103
115
|
] as (keyof typeof allTools)[];
|
|
104
116
|
|
|
105
117
|
// Resolve async model config before streamText to ensure cleanup on failure
|
|
@@ -115,7 +127,6 @@ export async function createCoreChatAgent({
|
|
|
115
127
|
throw error;
|
|
116
128
|
}
|
|
117
129
|
|
|
118
|
-
// Create the streamText result
|
|
119
130
|
const result = streamText({
|
|
120
131
|
model,
|
|
121
132
|
system,
|
|
@@ -38,7 +38,6 @@ async function executeAgentAndGetOutput({
|
|
|
38
38
|
selectedModelId,
|
|
39
39
|
explicitlyRequestedTools,
|
|
40
40
|
userId,
|
|
41
|
-
activeTools,
|
|
42
41
|
abortSignal,
|
|
43
42
|
messageId,
|
|
44
43
|
}: {
|
|
@@ -47,7 +46,6 @@ async function executeAgentAndGetOutput({
|
|
|
47
46
|
selectedModelId: AppModelId;
|
|
48
47
|
explicitlyRequestedTools: ToolName[] | null;
|
|
49
48
|
userId: string | null;
|
|
50
|
-
activeTools: ToolName[];
|
|
51
49
|
abortSignal: AbortSignal | undefined;
|
|
52
50
|
messageId: string;
|
|
53
51
|
}): Promise<{
|
|
@@ -69,7 +67,6 @@ async function executeAgentAndGetOutput({
|
|
|
69
67
|
selectedModelId,
|
|
70
68
|
explicitlyRequestedTools,
|
|
71
69
|
userId,
|
|
72
|
-
budgetAllowedTools: activeTools,
|
|
73
70
|
abortSignal,
|
|
74
71
|
messageId,
|
|
75
72
|
dataStream: noOpStreamWriter,
|
|
@@ -253,8 +250,11 @@ export async function runCoreChatAgentEval({
|
|
|
253
250
|
abortSignal?: AbortSignal;
|
|
254
251
|
}): Promise<EvalAgentResult> {
|
|
255
252
|
const messageId = generateUUID();
|
|
253
|
+
const requestedTools = determineExplicitlyRequestedTools(selectedTool);
|
|
256
254
|
const explicitlyRequestedTools =
|
|
257
|
-
|
|
255
|
+
requestedTools === null
|
|
256
|
+
? activeTools
|
|
257
|
+
: requestedTools.filter((tool) => activeTools.includes(tool));
|
|
258
258
|
|
|
259
259
|
const { result, contextForLLM, output, response } =
|
|
260
260
|
await executeAgentAndGetOutput({
|
|
@@ -263,7 +263,6 @@ export async function runCoreChatAgentEval({
|
|
|
263
263
|
selectedModelId,
|
|
264
264
|
explicitlyRequestedTools,
|
|
265
265
|
userId,
|
|
266
|
-
activeTools,
|
|
267
266
|
abortSignal,
|
|
268
267
|
messageId,
|
|
269
268
|
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { InferUITool } from "ai";
|
|
2
|
+
import { tools } from "@/tools/chatjs/tools";
|
|
3
|
+
|
|
4
|
+
export const installedTools = tools;
|
|
5
|
+
|
|
6
|
+
// Derive UI tool types automatically from the registered tools.
|
|
7
|
+
// When the CLI adds an entry to tools in tools/chatjs/tools.ts, its typed
|
|
8
|
+
// input/output automatically flows into ChatTools via the InstalledTools
|
|
9
|
+
// intersection.
|
|
10
|
+
export type InstalledTools = {
|
|
11
|
+
[K in keyof typeof installedTools]: InferUITool<(typeof installedTools)[K]>;
|
|
12
|
+
};
|
|
@@ -6,7 +6,7 @@ import type {
|
|
|
6
6
|
ListPromptsResult,
|
|
7
7
|
ListResourcesResult,
|
|
8
8
|
} from "@modelcontextprotocol/sdk/types.js";
|
|
9
|
-
import type { Tool } from "ai";
|
|
9
|
+
import type { Tool, ToolSet } from "ai";
|
|
10
10
|
import { config } from "@/lib/config";
|
|
11
11
|
import { createModuleLogger } from "@/lib/logger";
|
|
12
12
|
import { getBaseUrl } from "@/lib/url";
|
|
@@ -217,7 +217,7 @@ export class MCPClient {
|
|
|
217
217
|
throw new Error("Client not connected");
|
|
218
218
|
}
|
|
219
219
|
try {
|
|
220
|
-
return await this.client.tools()
|
|
220
|
+
return (await this.client.tools()) as ToolSet as Record<string, Tool>;
|
|
221
221
|
} catch (error) {
|
|
222
222
|
this.handlePotentialAuthError(error);
|
|
223
223
|
throw error;
|