chat-js 1.0.0-alpha.8 → 1.0.0-beta.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/README.md +7 -5
- package/dist/index.js +7161 -6308
- package/package.json +2 -2
- package/templates/chat-app/agent/agent.ts +0 -2
- package/templates/chat-app/app/editor.css +0 -6
- package/templates/chat-app/app/layout.tsx +11 -18
- package/templates/chat-app/app/opengraph-image.png +0 -0
- package/templates/chat-app/chat.config.ts +0 -44
- package/templates/chat-app/chatjs/core/gateway/runtime.ts +0 -7
- package/templates/chat-app/chatjs/core/ui/slots.tsx +15 -5
- package/templates/chat-app/chatjs/generated/installed-chat-ui.ts +4 -0
- package/templates/chat-app/chatjs/generated/installed.ts +2 -0
- package/templates/chat-app/chatjs/plugins/guest-chat/signed-out.tsx +7 -4
- package/templates/chat-app/chatjs/plugins/mcp/routes/connectors-page.tsx +4 -1
- package/templates/chat-app/chatjs/plugins/mcp/ui/connectors-settings.tsx +1 -1
- package/templates/chat-app/chatjs/plugins/mcp/ui/mcp-connect-dialog.tsx +1 -1
- package/templates/chat-app/chatjs/plugins/mcp/ui/mcp-create-dialog.tsx +1 -1
- package/templates/chat-app/chatjs/plugins/model-preferences/model-row.tsx +3 -0
- package/templates/chat-app/chatjs/plugins/model-preferences/models-settings.tsx +1 -0
- package/templates/chat-app/chatjs/plugins/projects/routes/project-page.tsx +10 -1
- package/templates/chat-app/chatjs/plugins/projects/ui/delete-project-dialog.tsx +0 -3
- package/templates/chat-app/chatjs/plugins/projects/ui/project-icon-picker.tsx +1 -0
- package/templates/chat-app/chatjs/plugins/streamdown-math/chat-ui.ts +11 -0
- package/templates/chat-app/chatjs/plugins/streamdown-math/plugin.json +6 -0
- package/templates/chat-app/chatjs/plugins/streamdown-mermaid/chat-ui.ts +10 -0
- package/templates/chat-app/chatjs/plugins/streamdown-mermaid/plugin.json +6 -0
- package/templates/chat-app/chatjs/providers/gateway.ts +49 -55
- package/templates/chat-app/chatjs/tools/generate-image/tool.test.ts +3 -14
- package/templates/chat-app/components/ai-elements/response.tsx +16 -15
- package/templates/chat-app/components/auth-form-view.tsx +35 -43
- package/templates/chat-app/components/chat/chat-composer.tsx +55 -20
- package/templates/chat-app/components/chat/chat-sidebar.tsx +5 -3
- package/templates/chat-app/components/composer/prompt-form.tsx +7 -1
- package/templates/chat-app/components/eve/eve-chat-error.tsx +12 -2
- package/templates/chat-app/components/eve/eve-conversation.tsx +223 -154
- package/templates/chat-app/components/eve/eve-creation-recovery.tsx +32 -1
- package/templates/chat-app/components/eve/eve-history-list.tsx +1 -1
- package/templates/chat-app/components/model-selection-indicator.tsx +12 -10
- package/templates/chat-app/components/model-selector-view.tsx +211 -186
- package/templates/chat-app/components/new-chat-button.tsx +1 -1
- package/templates/chat-app/components/settings/settings-nav.tsx +1 -1
- package/templates/chat-app/components/settings/settings-navigation-link.tsx +1 -0
- package/templates/chat-app/components/sidebar-top-row.tsx +1 -1
- package/templates/chat-app/components/ui/sidebar.tsx +1 -1
- package/templates/chat-app/components/ui/trace.tsx +1 -1
- package/templates/chat-app/hooks/use-auto-focus.ts +12 -13
- package/templates/chat-app/lib/ai/active-gateway.ts +0 -9
- package/templates/chat-app/lib/ai/app-models.test.ts +0 -4
- package/templates/chat-app/lib/ai/app-models.ts +11 -6
- package/templates/chat-app/lib/ai/gateways/registry.ts +4 -31
- package/templates/chat-app/lib/ai/model-catalog.ts +50 -0
- package/templates/chat-app/lib/ai/models.ts +4 -39
- package/templates/chat-app/lib/ai/providers.ts +2 -16
- package/templates/chat-app/lib/config-schema.ts +0 -96
- package/templates/chat-app/lib/devtools-disabled.ts +1 -0
- package/templates/chat-app/lib/eve/model-selection.test.ts +47 -50
- package/templates/chat-app/lib/eve/model-selection.ts +5 -37
- package/templates/chat-app/lib/eve/tool-cost.test.ts +18 -6
- package/templates/chat-app/lib/eve/tool-cost.ts +10 -18
- package/templates/chat-app/oxfmt.config.ts +0 -2
- package/templates/chat-app/package.json +7 -9
- package/templates/chat-app/proxy.ts +2 -4
- package/templates/chat-app/scripts/build-eve.test.ts +56 -0
- package/templates/chat-app/scripts/build-eve.ts +12 -5
- package/templates/chat-app/scripts/check-env.ts +2 -17
- package/templates/chat-app/scripts/environment-validation-report.ts +1 -20
- package/templates/chat-app/trpc/react.tsx +2 -2
- package/templates/electron/forge.config.ts +1 -19
- package/templates/electron/scripts/write-branding.ts +1 -5
- package/templates/chat-app/app/privacy/page.tsx +0 -153
- package/templates/chat-app/app/terms/page.tsx +0 -270
- package/templates/chat-app/components/ai-elements/context-hover.radix.tsx +0 -15
- package/templates/chat-app/components/ai-elements/context-hover.tsx +0 -17
- package/templates/chat-app/components/ai-elements/context.tsx +0 -405
- package/templates/chat-app/components/composer/editor.css +0 -96
- package/templates/chat-app/components/lexical-chat-input.tsx +0 -276
- package/templates/chat-app/components/model-selection-indicator.radix.tsx +0 -17
- package/templates/chat-app/components/ui/resizable.tsx +0 -49
- package/templates/chat-app/lib/ai/gateways/fallback-models.ts +0 -29
- package/templates/chat-app/lib/ai/models.generated.ts +0 -4242
- package/templates/chat-app/lib/ai/usage-token-details.test.ts +0 -76
- package/templates/chat-app/lib/ai/usage-token-details.ts +0 -33
- package/templates/chat-app/scripts/fetch-models.ts +0 -30
- package/templates/chat-app/scripts/gateway-snapshot-warning.test.ts +0 -9
|
@@ -8,7 +8,6 @@ import {
|
|
|
8
8
|
CardTitle,
|
|
9
9
|
} from "@/components/ui/card";
|
|
10
10
|
import { InternalLink } from "@/components/internal-link";
|
|
11
|
-
import { cn } from "@/lib/utils";
|
|
12
11
|
|
|
13
12
|
export const AuthFormView = ({
|
|
14
13
|
mode,
|
|
@@ -27,46 +26,39 @@ export const AuthFormView = ({
|
|
|
27
26
|
readonly children: ReactNode;
|
|
28
27
|
readonly className?: string;
|
|
29
28
|
}) => (
|
|
30
|
-
<
|
|
31
|
-
<
|
|
32
|
-
<
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
<
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
</Card>
|
|
66
|
-
<div className="text-muted-foreground [&_a]:hover:text-primary text-center text-xs text-balance [&_a]:underline [&_a]:underline-offset-4">
|
|
67
|
-
By clicking continue, you agree to our{" "}
|
|
68
|
-
<InternalLink href="/terms">Terms of Service</InternalLink> and{" "}
|
|
69
|
-
<InternalLink href="/privacy">Privacy Policy</InternalLink>.
|
|
70
|
-
</div>
|
|
71
|
-
</div>
|
|
29
|
+
<Card className={className}>
|
|
30
|
+
<CardHeader className="text-center">
|
|
31
|
+
<CardTitle className="text-xl">
|
|
32
|
+
{title ?? (mode === "login" ? "Welcome back" : "Create an account")}
|
|
33
|
+
</CardTitle>
|
|
34
|
+
<CardDescription>
|
|
35
|
+
{description ??
|
|
36
|
+
(mode === "login"
|
|
37
|
+
? "Sign in to your account"
|
|
38
|
+
: "Get started in seconds")}
|
|
39
|
+
</CardDescription>
|
|
40
|
+
</CardHeader>
|
|
41
|
+
<CardContent>
|
|
42
|
+
<div className="grid gap-6">
|
|
43
|
+
{children}
|
|
44
|
+
{footer ?? (
|
|
45
|
+
<div className="text-center text-sm">
|
|
46
|
+
{mode === "login"
|
|
47
|
+
? "Don't have an account? "
|
|
48
|
+
: "Already have an account? "}
|
|
49
|
+
<InternalLink
|
|
50
|
+
className="underline underline-offset-4"
|
|
51
|
+
href={
|
|
52
|
+
mode === "login"
|
|
53
|
+
? `/register?${new URLSearchParams(query)}`
|
|
54
|
+
: `/login?${new URLSearchParams(query)}`
|
|
55
|
+
}
|
|
56
|
+
>
|
|
57
|
+
{mode === "login" ? "Sign up" : "Sign in"}
|
|
58
|
+
</InternalLink>
|
|
59
|
+
</div>
|
|
60
|
+
)}
|
|
61
|
+
</div>
|
|
62
|
+
</CardContent>
|
|
63
|
+
</Card>
|
|
72
64
|
);
|
|
@@ -7,14 +7,16 @@ import {
|
|
|
7
7
|
InputGroup,
|
|
8
8
|
InputGroupAddon,
|
|
9
9
|
InputGroupButton,
|
|
10
|
+
InputGroupTextarea,
|
|
10
11
|
} from "@/components/ui/input-group";
|
|
11
12
|
import { ArrowUpIcon, Loader2Icon, SquareIcon } from "lucide-react";
|
|
12
13
|
|
|
13
14
|
import type { ChatStatus } from "ai";
|
|
14
15
|
|
|
15
|
-
import {
|
|
16
|
+
import { useAutoFocus } from "@/hooks/use-auto-focus";
|
|
17
|
+
import { useMounted } from "@/hooks/use-mounted";
|
|
16
18
|
|
|
17
|
-
import React from "react";
|
|
19
|
+
import React, { useLayoutEffect } from "react";
|
|
18
20
|
import type { ReadonlyReactNode } from "@/lib/readonly-react-node";
|
|
19
21
|
|
|
20
22
|
import { useIsMobile } from "@/hooks/use-mobile";
|
|
@@ -105,7 +107,7 @@ const canSubmitDraft = (
|
|
|
105
107
|
* @param {boolean | undefined} readOnly Runtime-owned readOnly value.
|
|
106
108
|
* @param {boolean | undefined} allowDraftWhileBusy Allows typing during a submission without a Stop action.
|
|
107
109
|
* @param {boolean | undefined} allowSendWhileStreaming Switches Stop to Send when the draft contains text or files.
|
|
108
|
-
* @param {ComponentProps<
|
|
110
|
+
* @param {ComponentProps<"textarea">["onPaste"] | undefined} onPaste Runtime-owned onPaste value.
|
|
109
111
|
* @returns {React.JSX.Element} The composed message interface.
|
|
110
112
|
*/
|
|
111
113
|
export const ChatComposer = ({
|
|
@@ -134,7 +136,7 @@ export const ChatComposer = ({
|
|
|
134
136
|
readonly readOnly?: boolean;
|
|
135
137
|
readonly allowDraftWhileBusy?: boolean;
|
|
136
138
|
readonly allowSendWhileStreaming?: boolean;
|
|
137
|
-
readonly onPaste?: ComponentProps<
|
|
139
|
+
readonly onPaste?: ComponentProps<"textarea">["onPaste"];
|
|
138
140
|
readonly draft: string;
|
|
139
141
|
readonly onDraftChange: (draft: string) => void;
|
|
140
142
|
readonly onSubmit: () => void;
|
|
@@ -146,6 +148,7 @@ export const ChatComposer = ({
|
|
|
146
148
|
readonly tools?: ReadonlyReactNode;
|
|
147
149
|
}): ReactJSX.Element => {
|
|
148
150
|
const isMobile = useIsMobile();
|
|
151
|
+
const mounted = useMounted();
|
|
149
152
|
const busy = status === "submitted" || status === "streaming";
|
|
150
153
|
const hasDraft = Boolean(draft.trim()) || hasAttachments;
|
|
151
154
|
const actionStatus = composerActionStatus(
|
|
@@ -154,6 +157,35 @@ export const ChatComposer = ({
|
|
|
154
157
|
hasDraft
|
|
155
158
|
);
|
|
156
159
|
const editorReadOnly = readOnly || (busy && !onStop && !allowDraftWhileBusy);
|
|
160
|
+
const inputRef = useAutoFocus(autoFocus && !editorReadOnly);
|
|
161
|
+
useLayoutEffect((): (() => void) | undefined => {
|
|
162
|
+
const input = inputRef.current;
|
|
163
|
+
if (!input || !draft || CSS.supports("field-sizing", "content")) {
|
|
164
|
+
return undefined;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// Clearing the explicit height lets shorter or newly unwrapped drafts shrink.
|
|
168
|
+
const fitDraft = (): void => {
|
|
169
|
+
input.style.height = "";
|
|
170
|
+
input.style.height = `${input.scrollHeight}px`;
|
|
171
|
+
};
|
|
172
|
+
fitDraft();
|
|
173
|
+
let width = input.offsetWidth;
|
|
174
|
+
let frame = 0;
|
|
175
|
+
const observer = new ResizeObserver(() => {
|
|
176
|
+
if (input.offsetWidth !== width) {
|
|
177
|
+
width = input.offsetWidth;
|
|
178
|
+
cancelAnimationFrame(frame);
|
|
179
|
+
frame = requestAnimationFrame(fitDraft);
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
observer.observe(input);
|
|
183
|
+
return () => {
|
|
184
|
+
observer.disconnect();
|
|
185
|
+
cancelAnimationFrame(frame);
|
|
186
|
+
input.style.height = "";
|
|
187
|
+
};
|
|
188
|
+
}, [draft, inputRef]);
|
|
157
189
|
const canSend =
|
|
158
190
|
!disabled &&
|
|
159
191
|
!editorReadOnly &&
|
|
@@ -191,34 +223,37 @@ export const ChatComposer = ({
|
|
|
191
223
|
) : undefined
|
|
192
224
|
}
|
|
193
225
|
>
|
|
194
|
-
<
|
|
226
|
+
<InputGroupTextarea
|
|
195
227
|
aria-label="Message"
|
|
196
|
-
|
|
197
|
-
className="max-h-[max(35svh,5rem)] min-h-[60px] overflow-y-scroll sm:min-h-[80px]"
|
|
228
|
+
className="max-h-[max(35svh,5rem)] min-h-[60px] flex-none [scrollbar-width:thin] overflow-y-auto px-2.5 pt-2.5 pb-[5px] leading-normal [tab-size:1] placeholder:text-base placeholder-shown:pt-2 placeholder-shown:pl-3 sm:min-h-[80px] md:text-[15px]"
|
|
198
229
|
data-testid="multimodal-input"
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
) => {
|
|
230
|
+
dir="auto"
|
|
231
|
+
ref={inputRef}
|
|
232
|
+
rows={1}
|
|
233
|
+
spellCheck
|
|
234
|
+
value={draft}
|
|
235
|
+
onChange={(event) => {
|
|
236
|
+
onDraftChange(event.currentTarget.value);
|
|
237
|
+
}}
|
|
238
|
+
onKeyDown={(event) => {
|
|
205
239
|
if (
|
|
206
|
-
event.
|
|
207
|
-
!
|
|
240
|
+
event.key === "Enter" &&
|
|
241
|
+
!event.nativeEvent.isComposing &&
|
|
242
|
+
// oxlint-disable-next-line typescript/no-deprecated -- WebKit clears isComposing before the IME confirmation keydown; 229 still identifies it.
|
|
243
|
+
event.nativeEvent.keyCode !== 229 &&
|
|
244
|
+
(isMobile ? event.ctrlKey : !event.shiftKey)
|
|
208
245
|
) {
|
|
209
|
-
|
|
246
|
+
event.preventDefault();
|
|
247
|
+
submit();
|
|
210
248
|
}
|
|
211
|
-
submit();
|
|
212
|
-
return true;
|
|
213
249
|
}}
|
|
214
|
-
onInputChange={onDraftChange}
|
|
215
250
|
onPaste={onPaste}
|
|
216
251
|
placeholder={
|
|
217
252
|
isMobile
|
|
218
253
|
? "Send a message... (Ctrl+Enter to send)"
|
|
219
254
|
: "Send a message..."
|
|
220
255
|
}
|
|
221
|
-
readOnly={editorReadOnly}
|
|
256
|
+
readOnly={!mounted || editorReadOnly}
|
|
222
257
|
/>
|
|
223
258
|
</PromptForm>
|
|
224
259
|
);
|
|
@@ -98,10 +98,12 @@ export const ChatSidebar = ({
|
|
|
98
98
|
>
|
|
99
99
|
<SidebarHeader className="shrink-0">
|
|
100
100
|
<SidebarMenu>
|
|
101
|
-
<
|
|
101
|
+
<SidebarMenuItem>
|
|
102
102
|
<SidebarTopRow />
|
|
103
|
-
</
|
|
104
|
-
<
|
|
103
|
+
</SidebarMenuItem>
|
|
104
|
+
<SidebarMenuItem>
|
|
105
|
+
<NewChatButton />
|
|
106
|
+
</SidebarMenuItem>
|
|
105
107
|
<Suspense
|
|
106
108
|
fallback={
|
|
107
109
|
<SidebarMenuItem>
|
|
@@ -28,7 +28,13 @@ export const PromptForm = ({
|
|
|
28
28
|
InputGroupAddon: typeof InputGroupAddon;
|
|
29
29
|
};
|
|
30
30
|
}): JSX.Element => (
|
|
31
|
-
<form
|
|
31
|
+
<form
|
|
32
|
+
className={cn(
|
|
33
|
+
"@container w-full [--muted-foreground:color-mix(in_oklab,var(--foreground)_65%,var(--background))]",
|
|
34
|
+
className
|
|
35
|
+
)}
|
|
36
|
+
{...props}
|
|
37
|
+
>
|
|
32
38
|
<primitives.InputGroup
|
|
33
39
|
className={cn("overflow-hidden", editable && "has-disabled:opacity-100")}
|
|
34
40
|
>
|
|
@@ -4,13 +4,23 @@ import { CircleAlert } from "lucide-react";
|
|
|
4
4
|
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";
|
|
5
5
|
|
|
6
6
|
export const EveChatError = ({
|
|
7
|
+
children,
|
|
7
8
|
message,
|
|
9
|
+
title = "Chat error",
|
|
8
10
|
}: {
|
|
11
|
+
readonly children?: ReactNode;
|
|
9
12
|
readonly message: string;
|
|
13
|
+
readonly title?: string;
|
|
10
14
|
}): ReactNode => (
|
|
11
|
-
<Alert
|
|
15
|
+
<Alert
|
|
16
|
+
className="has-[>svg]:grid-cols-[auto_minmax(0,1fr)]"
|
|
17
|
+
variant="destructive"
|
|
18
|
+
>
|
|
12
19
|
<CircleAlert className="size-4" aria-hidden="true" />
|
|
13
|
-
<AlertTitle>
|
|
20
|
+
<AlertTitle>{title}</AlertTitle>
|
|
14
21
|
<AlertDescription className="wrap-anywhere">{message}</AlertDescription>
|
|
22
|
+
{children !== undefined && (
|
|
23
|
+
<div className="col-start-2 mt-2">{children}</div>
|
|
24
|
+
)}
|
|
15
25
|
</Alert>
|
|
16
26
|
);
|