@chat-js/cli 0.4.0 → 0.6.0
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 +1163 -959
- package/package.json +1 -1
- package/templates/chat-app/app/(auth)/device-login/page.tsx +37 -0
- package/templates/chat-app/app/(auth)/login/page.tsx +26 -2
- package/templates/chat-app/app/(auth)/register/page.tsx +0 -12
- package/templates/chat-app/app/(chat)/api/chat/filter-reasoning-parts.ts +1 -1
- package/templates/chat-app/app/(chat)/api/chat/route.ts +13 -5
- package/templates/chat-app/app/(chat)/layout.tsx +4 -1
- package/templates/chat-app/app/api/trpc/[trpc]/route.ts +1 -0
- package/templates/chat-app/app/globals.css +9 -9
- package/templates/chat-app/app/layout.tsx +4 -2
- package/templates/chat-app/biome.jsonc +3 -3
- package/templates/chat-app/chat.config.ts +144 -141
- package/templates/chat-app/components/ai-elements/prompt-input.tsx +1 -1
- package/templates/chat-app/components/anonymous-session-init.tsx +10 -6
- package/templates/chat-app/components/artifact-actions.tsx +81 -18
- package/templates/chat-app/components/artifact-panel.tsx +142 -41
- package/templates/chat-app/components/attachment-list.tsx +1 -1
- package/templates/chat-app/components/{social-auth-providers.tsx → auth-providers.tsx} +49 -4
- package/templates/chat-app/components/chat/chat-welcome.tsx +3 -3
- package/templates/chat-app/components/chat-menu-items.tsx +1 -1
- package/templates/chat-app/components/chat-sync.tsx +3 -8
- package/templates/chat-app/components/console.tsx +9 -9
- package/templates/chat-app/components/context-usage.tsx +2 -2
- package/templates/chat-app/components/create-artifact.tsx +15 -5
- package/templates/chat-app/components/data-stream-handler.tsx +57 -16
- package/templates/chat-app/components/device-login-page.tsx +191 -0
- package/templates/chat-app/components/diffview.tsx +8 -2
- package/templates/chat-app/components/electron-auth-handler.tsx +184 -0
- package/templates/chat-app/components/electron-auth-ui.tsx +121 -0
- package/templates/chat-app/components/favicon-group.tsx +1 -1
- package/templates/chat-app/components/feedback-actions.tsx +1 -1
- package/templates/chat-app/components/greeting.tsx +1 -1
- package/templates/chat-app/components/interactive-chart-impl.tsx +3 -4
- package/templates/chat-app/components/interactive-charts.tsx +1 -1
- package/templates/chat-app/components/login-form.tsx +52 -10
- package/templates/chat-app/components/message-editor.tsx +4 -5
- package/templates/chat-app/components/model-selector.tsx +661 -655
- package/templates/chat-app/components/multimodal-input.tsx +13 -10
- package/templates/chat-app/components/parallel-response-cards.tsx +53 -35
- package/templates/chat-app/components/part/code-execution.tsx +8 -2
- package/templates/chat-app/components/part/document-common.tsx +1 -1
- package/templates/chat-app/components/part/document-preview.tsx +5 -5
- package/templates/chat-app/components/part/retrieve-url.tsx +12 -12
- package/templates/chat-app/components/part/text-message-part.tsx +13 -9
- package/templates/chat-app/components/project-chat-item.tsx +1 -1
- package/templates/chat-app/components/project-menu-items.tsx +1 -1
- 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/retry-button.tsx +1 -1
- package/templates/chat-app/components/sandbox.tsx +1 -1
- package/templates/chat-app/components/sheet-editor.tsx +7 -7
- package/templates/chat-app/components/sidebar-chats-list.tsx +1 -1
- package/templates/chat-app/components/sidebar-toggle.tsx +15 -2
- package/templates/chat-app/components/sidebar-top-row.tsx +27 -12
- package/templates/chat-app/components/sidebar-user-nav.tsx +10 -1
- package/templates/chat-app/components/signup-form.tsx +49 -10
- package/templates/chat-app/components/sources.tsx +4 -4
- package/templates/chat-app/components/text-editor.tsx +5 -2
- package/templates/chat-app/components/toolbar.tsx +3 -3
- package/templates/chat-app/components/ui/sidebar.tsx +0 -1
- package/templates/chat-app/components/upgrade-cta/limit-display.tsx +1 -1
- package/templates/chat-app/components/user-message.tsx +135 -134
- package/templates/chat-app/electron.d.ts +41 -0
- package/templates/chat-app/evals/my-eval.eval.ts +3 -1
- package/templates/chat-app/hooks/use-artifact.tsx +13 -13
- package/templates/chat-app/lib/ai/gateways/provider-types.ts +19 -10
- package/templates/chat-app/lib/ai/stream-errors.test.ts +72 -0
- package/templates/chat-app/lib/ai/stream-errors.ts +94 -0
- package/templates/chat-app/lib/ai/tools/code-execution.javascript.ts +171 -0
- package/templates/chat-app/lib/ai/tools/code-execution.python.ts +336 -0
- package/templates/chat-app/lib/ai/tools/code-execution.shared.test.ts +71 -0
- package/templates/chat-app/lib/ai/tools/code-execution.shared.ts +59 -0
- package/templates/chat-app/lib/ai/tools/code-execution.ts +62 -391
- package/templates/chat-app/lib/ai/tools/code-execution.types.ts +24 -0
- package/templates/chat-app/lib/ai/tools/steps/multi-query-web-search.ts +3 -2
- package/templates/chat-app/lib/anonymous-session-client.ts +0 -3
- package/templates/chat-app/lib/artifacts/code/client.tsx +35 -5
- package/templates/chat-app/lib/artifacts/sheet/client.tsx +11 -3
- package/templates/chat-app/lib/auth-client.ts +23 -1
- package/templates/chat-app/lib/auth.ts +18 -1
- package/templates/chat-app/lib/blob.ts +1 -1
- package/templates/chat-app/lib/clone-messages.ts +1 -1
- package/templates/chat-app/lib/config-schema.ts +13 -1
- package/templates/chat-app/lib/constants.ts +3 -4
- package/templates/chat-app/lib/db/migrations/meta/0044_snapshot.json +42 -129
- package/templates/chat-app/lib/db/migrations/meta/_journal.json +1 -1
- package/templates/chat-app/lib/editor/config.ts +4 -4
- package/templates/chat-app/lib/electron-auth.ts +96 -0
- package/templates/chat-app/lib/env-schema.ts +33 -4
- package/templates/chat-app/lib/message-conversion.ts +1 -1
- package/templates/chat-app/lib/playwright-test-environment.ts +18 -0
- package/templates/chat-app/lib/social-auth.ts +5 -0
- package/templates/chat-app/lib/stores/hooks-threads.ts +2 -1
- package/templates/chat-app/lib/stores/with-threads.test.ts +1 -1
- package/templates/chat-app/lib/stores/with-threads.ts +5 -6
- package/templates/chat-app/lib/stores/with-tracing.ts +1 -1
- package/templates/chat-app/lib/thread-utils.ts +19 -21
- package/templates/chat-app/lib/utils/download-assets.ts +6 -7
- package/templates/chat-app/lib/utils/rate-limit.ts +9 -3
- package/templates/chat-app/package.json +20 -18
- package/templates/chat-app/playwright.config.ts +0 -19
- package/templates/chat-app/providers/chat-input-provider.tsx +1 -1
- package/templates/chat-app/proxy.ts +28 -3
- package/templates/chat-app/scripts/check-env.ts +10 -0
- package/templates/chat-app/trpc/server.tsx +7 -2
- package/templates/chat-app/tsconfig.json +2 -1
- package/templates/chat-app/vercel.json +0 -10
- package/templates/electron/CHANGELOG.md +7 -0
- package/templates/electron/README.md +54 -0
- package/templates/electron/entitlements.mac.plist +10 -0
- package/templates/electron/forge.config.ts +157 -0
- package/templates/electron/icon.png +0 -0
- package/templates/electron/package.json +53 -0
- package/templates/electron/scripts/generate-icons.test.js +37 -0
- package/templates/electron/scripts/generate-icons.ts +29 -0
- package/templates/electron/scripts/run-forge.cjs +28 -0
- package/templates/electron/scripts/write-branding.ts +18 -0
- package/templates/electron/src/config.ts +16 -0
- package/templates/electron/src/lib/auth-client.ts +64 -0
- package/templates/electron/src/main.ts +670 -0
- package/templates/electron/src/preload.d.ts +27 -0
- package/templates/electron/src/preload.ts +25 -0
- package/templates/electron/tsconfig.json +18 -0
|
@@ -4,7 +4,7 @@ import { Card } from "@/components/ui/card";
|
|
|
4
4
|
export type { BaseChart } from "./interactive-chart-impl";
|
|
5
5
|
|
|
6
6
|
const ChartSkeleton = () => (
|
|
7
|
-
<Card className="overflow-hidden border-
|
|
7
|
+
<Card className="overflow-hidden border-border bg-card">
|
|
8
8
|
<div className="flex h-[400px] items-center justify-center p-6">
|
|
9
9
|
<div className="size-8 animate-pulse rounded-md bg-muted" />
|
|
10
10
|
</div>
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import Link from "next/link";
|
|
4
|
-
import {
|
|
4
|
+
import { useSearchParams } from "next/navigation";
|
|
5
|
+
import { Suspense, useEffect, useState } from "react";
|
|
6
|
+
import { SocialAuthProviders } from "@/components/auth-providers";
|
|
5
7
|
import {
|
|
6
8
|
Card,
|
|
7
9
|
CardContent,
|
|
@@ -9,28 +11,68 @@ import {
|
|
|
9
11
|
CardHeader,
|
|
10
12
|
CardTitle,
|
|
11
13
|
} from "@/components/ui/card";
|
|
14
|
+
import {
|
|
15
|
+
buildSocialAuthRequest,
|
|
16
|
+
isElectronRenderer,
|
|
17
|
+
} from "@/lib/electron-auth";
|
|
12
18
|
import { cn } from "@/lib/utils";
|
|
13
19
|
|
|
14
20
|
export function LoginForm({
|
|
15
21
|
className,
|
|
16
22
|
...props
|
|
17
23
|
}: React.ComponentPropsWithoutRef<"div">) {
|
|
24
|
+
const searchParams = useSearchParams();
|
|
25
|
+
const query = Object.fromEntries(searchParams.entries());
|
|
26
|
+
const [isElectron, setIsElectron] = useState(false);
|
|
27
|
+
const { callbackURL, onRedirectToUrl, signInOptions } =
|
|
28
|
+
buildSocialAuthRequest(query, globalThis.location?.origin);
|
|
29
|
+
const registerHref = { pathname: "/register" as const, query };
|
|
30
|
+
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
setIsElectron(isElectronRenderer());
|
|
33
|
+
}, []);
|
|
34
|
+
|
|
18
35
|
return (
|
|
19
36
|
<div className={cn("flex flex-col gap-6", className)} {...props}>
|
|
20
37
|
<Card>
|
|
21
38
|
<CardHeader className="text-center">
|
|
22
|
-
<CardTitle className="text-xl">
|
|
23
|
-
|
|
39
|
+
<CardTitle className="text-xl">
|
|
40
|
+
{isElectron ? "Continue in browser" : "Welcome back"}
|
|
41
|
+
</CardTitle>
|
|
42
|
+
<CardDescription>
|
|
43
|
+
{isElectron
|
|
44
|
+
? "Use your browser to sign in or create an account."
|
|
45
|
+
: "Sign in to your account"}
|
|
46
|
+
</CardDescription>
|
|
24
47
|
</CardHeader>
|
|
25
48
|
<CardContent>
|
|
26
49
|
<div className="grid gap-6">
|
|
27
|
-
<
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
50
|
+
<Suspense>
|
|
51
|
+
<SocialAuthProviders
|
|
52
|
+
callbackURL={callbackURL}
|
|
53
|
+
electronBrowserLabel="Continue in browser"
|
|
54
|
+
isElectron={isElectron}
|
|
55
|
+
onRedirectToUrl={onRedirectToUrl}
|
|
56
|
+
query={query}
|
|
57
|
+
signInOptions={signInOptions}
|
|
58
|
+
/>
|
|
59
|
+
</Suspense>
|
|
60
|
+
{isElectron ? (
|
|
61
|
+
<div className="text-center text-muted-foreground text-sm">
|
|
62
|
+
New and existing accounts both continue through the browser
|
|
63
|
+
flow.
|
|
64
|
+
</div>
|
|
65
|
+
) : (
|
|
66
|
+
<div className="text-center text-sm">
|
|
67
|
+
Don't have an account?{" "}
|
|
68
|
+
<Link
|
|
69
|
+
className="underline underline-offset-4"
|
|
70
|
+
href={registerHref}
|
|
71
|
+
>
|
|
72
|
+
Sign up
|
|
73
|
+
</Link>
|
|
74
|
+
</div>
|
|
75
|
+
)}
|
|
34
76
|
</div>
|
|
35
77
|
</CardContent>
|
|
36
78
|
</Card>
|
|
@@ -2,10 +2,7 @@
|
|
|
2
2
|
import { useChatStatus } from "@ai-sdk-tools/store";
|
|
3
3
|
import { type Dispatch, type SetStateAction, useCallback } from "react";
|
|
4
4
|
import type { ModelId } from "@/lib/ai/app-models";
|
|
5
|
-
import {
|
|
6
|
-
getPrimarySelectedModelId,
|
|
7
|
-
type ChatMessage,
|
|
8
|
-
} from "@/lib/ai/types";
|
|
5
|
+
import { type ChatMessage, getPrimarySelectedModelId } from "@/lib/ai/types";
|
|
9
6
|
import {
|
|
10
7
|
getAttachmentsFromMessage,
|
|
11
8
|
getTextContentFromMessage,
|
|
@@ -56,7 +53,9 @@ export function MessageEditor(
|
|
|
56
53
|
|
|
57
54
|
// Use selectedModel from the message metadata, or fall back to current selected model
|
|
58
55
|
const messageSelectedModel = props.message.metadata?.selectedModel;
|
|
59
|
-
const primaryModelId = getPrimarySelectedModelId(
|
|
56
|
+
const primaryModelId = getPrimarySelectedModelId(
|
|
57
|
+
messageSelectedModel
|
|
58
|
+
) as ModelId | null;
|
|
60
59
|
const { parentMessageId: _parentMessageId, ...rest } = props;
|
|
61
60
|
return (
|
|
62
61
|
<ChatInputProvider
|