@object-ui/plugin-chatbot 7.0.0 → 7.2.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/CHANGELOG.md +23 -0
- package/dist/ChatbotEnhanced.d.ts +42 -2
- package/dist/ChatbotEnhanced.d.ts.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1137 -899
- package/dist/index.umd.cjs +1 -1
- package/dist/mapMessages.d.ts +18 -0
- package/dist/mapMessages.d.ts.map +1 -1
- package/dist/useAiModels.d.ts +26 -0
- package/dist/useAiModels.d.ts.map +1 -0
- package/dist/useObjectChat.d.ts.map +1 -1
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -1,45 +1,45 @@
|
|
|
1
1
|
import * as e from "react";
|
|
2
2
|
import { Children as t, Fragment as n, createContext as r, isValidElement as i, memo as a, useCallback as o, useContext as s, useEffect as c, useMemo as l, useRef as u, useState as d } from "react";
|
|
3
|
-
import { Alert as f, AlertDescription as p, Avatar as m, AvatarFallback as h, AvatarImage as g, Badge as _, Button as v, Card as y, CardContent as b, CardDescription as x, CardHeader as S, CardTitle as C, Collapsible as w, CollapsibleContent as T, CollapsibleTrigger as E, Command as D, CommandEmpty as O, CommandGroup as k, CommandInput as A, CommandItem as j, CommandList as M, CommandSeparator as N, DropdownMenu as
|
|
4
|
-
import { AlertCircle as
|
|
3
|
+
import { Alert as f, AlertDescription as p, Avatar as m, AvatarFallback as h, AvatarImage as g, Badge as _, Button as v, Card as y, CardContent as b, CardDescription as x, CardHeader as S, CardTitle as C, Collapsible as w, CollapsibleContent as T, CollapsibleTrigger as E, Command as D, CommandEmpty as O, CommandGroup as k, CommandInput as A, CommandItem as j, CommandList as M, CommandSeparator as N, DropdownMenu as P, DropdownMenuContent as ee, DropdownMenuItem as F, DropdownMenuTrigger as I, Empty as te, EmptyDescription as ne, EmptyHeader as L, EmptyMedia as re, EmptyTitle as ie, HoverCard as R, HoverCardContent as ae, HoverCardTrigger as oe, Input as se, Label as z, ScrollArea as ce, ScrollBar as le, Select as ue, SelectContent as de, SelectItem as fe, SelectTrigger as pe, SelectValue as me, Separator as he, Sheet as ge, SheetContent as _e, SheetDescription as ve, SheetHeader as ye, SheetTitle as be, Skeleton as xe, Table as B, TableBody as Se, TableCell as V, TableHead as H, TableHeader as Ce, TableRow as we, Tabs as U, TabsList as W, TabsTrigger as G, Textarea as Te, Tooltip as K, TooltipContent as Ee, TooltipProvider as De, TooltipTrigger as Oe, cn as q } from "@object-ui/components";
|
|
4
|
+
import { AlertCircle as ke, ArrowDownIcon as Ae, ArrowRight as je, BookIcon as Me, Bot as Ne, BrainIcon as Pe, Check as Fe, CheckCircle2 as J, CheckCircleIcon as Y, CheckIcon as Ie, ChevronDownIcon as Le, ChevronLeftIcon as Re, ChevronRightIcon as ze, CircleIcon as Be, ClipboardList as Ve, Clock as He, Clock3 as Ue, ClockIcon as We, Copy as Ge, CopyIcon as Ke, CornerDownLeft as qe, CornerDownLeftIcon as Je, Eye as Ye, GitCompareArrows as Xe, HelpCircle as Ze, ImageIcon as Qe, Inbox as $e, Loader2 as et, Loader2Icon as tt, Maximize2 as nt, MicIcon as rt, Minimize2 as it, PaperclipIcon as at, PlusIcon as ot, RefreshCw as st, Rocket as ct, Send as lt, ShieldCheck as ut, SquareIcon as dt, Table2 as ft, TriangleAlert as pt, WifiOff as mt, WrenchIcon as ht, X as gt, XCircle as X, XCircleIcon as _t, XIcon as vt } from "lucide-react";
|
|
5
5
|
import { Fragment as Z, jsx as Q, jsxs as $ } from "react/jsx-runtime";
|
|
6
|
-
import { useChat as
|
|
7
|
-
import { DefaultChatTransport as
|
|
8
|
-
import * as
|
|
9
|
-
import { SchemaRenderer as
|
|
10
|
-
import { StickToBottom as
|
|
11
|
-
import { cva as
|
|
12
|
-
import { Slot as
|
|
13
|
-
import { Streamdown as
|
|
14
|
-
import { nanoid as
|
|
15
|
-
import { codeToHtml as
|
|
16
|
-
import { useControllableState as
|
|
17
|
-
import { motion as
|
|
18
|
-
import { ComponentRegistry as
|
|
6
|
+
import { useChat as yt } from "@ai-sdk/react";
|
|
7
|
+
import { DefaultChatTransport as bt } from "ai";
|
|
8
|
+
import * as xt from "react-dom";
|
|
9
|
+
import { SchemaRenderer as St, useObjectTranslation as Ct } from "@object-ui/react";
|
|
10
|
+
import { StickToBottom as wt, useStickToBottomContext as Tt } from "use-stick-to-bottom";
|
|
11
|
+
import { cva as Et } from "class-variance-authority";
|
|
12
|
+
import { Slot as Dt } from "@radix-ui/react-slot";
|
|
13
|
+
import { Streamdown as Ot } from "streamdown";
|
|
14
|
+
import { nanoid as kt } from "nanoid";
|
|
15
|
+
import { codeToHtml as At } from "shiki";
|
|
16
|
+
import { useControllableState as jt } from "@radix-ui/react-use-controllable-state";
|
|
17
|
+
import { motion as Mt } from "motion/react";
|
|
18
|
+
import { ComponentRegistry as Nt } from "@object-ui/core";
|
|
19
19
|
//#region \0rolldown/runtime.js
|
|
20
|
-
var
|
|
20
|
+
var Pt = Object.defineProperty, Ft = (e, t) => {
|
|
21
21
|
let n = {};
|
|
22
|
-
for (var r in e)
|
|
22
|
+
for (var r in e) Pt(n, r, {
|
|
23
23
|
get: e[r],
|
|
24
24
|
enumerable: !0
|
|
25
25
|
});
|
|
26
|
-
return t ||
|
|
26
|
+
return t || Pt(n, Symbol.toStringTag, { value: "Module" }), n;
|
|
27
27
|
};
|
|
28
28
|
//#endregion
|
|
29
29
|
//#region src/utils.ts
|
|
30
|
-
function
|
|
30
|
+
function It(e = "msg") {
|
|
31
31
|
return typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID() : `${e}-${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
|
32
32
|
}
|
|
33
33
|
//#endregion
|
|
34
34
|
//#region src/mapMessages.ts
|
|
35
|
-
function
|
|
35
|
+
function Lt(e, t) {
|
|
36
36
|
return typeof e.content == "string" ? e.content : t.filter((e) => e.type === "text").map((e) => e.text ?? "").join("");
|
|
37
37
|
}
|
|
38
|
-
function
|
|
38
|
+
function Rt(e) {
|
|
39
39
|
let t = e.filter((e) => e.type === "reasoning" || e.type === "reasoning-delta").map((e) => e.text ?? "").join("\n").trim();
|
|
40
40
|
return t.length > 0 ? t : void 0;
|
|
41
41
|
}
|
|
42
|
-
function
|
|
42
|
+
function zt(e) {
|
|
43
43
|
let t = (e) => {
|
|
44
44
|
if (e && typeof e == "object") return e;
|
|
45
45
|
if (typeof e != "string") return;
|
|
@@ -62,8 +62,8 @@ function Rt(e) {
|
|
|
62
62
|
}
|
|
63
63
|
return r;
|
|
64
64
|
}
|
|
65
|
-
function
|
|
66
|
-
let t =
|
|
65
|
+
function Bt(e) {
|
|
66
|
+
let t = zt(e);
|
|
67
67
|
if (!t) return;
|
|
68
68
|
let n = t.pendingActionId;
|
|
69
69
|
if (t.status === "pending_approval" && typeof n == "string" && n.length > 0) return {
|
|
@@ -71,11 +71,11 @@ function zt(e) {
|
|
|
71
71
|
raw: t
|
|
72
72
|
};
|
|
73
73
|
}
|
|
74
|
-
function
|
|
74
|
+
function Vt(e) {
|
|
75
75
|
return Array.isArray(e) ? e.filter((e) => typeof e == "string" && e.trim().length > 0) : [];
|
|
76
76
|
}
|
|
77
|
-
function
|
|
78
|
-
let t =
|
|
77
|
+
function Ht(e) {
|
|
78
|
+
let t = zt(e);
|
|
79
79
|
if (!t || t.status !== "blueprint_proposed") return;
|
|
80
80
|
let n = t.blueprint, r = n && typeof n == "object" ? n : {}, i = (Array.isArray(r.objects) ? r.objects : []).flatMap((e) => {
|
|
81
81
|
let t = e;
|
|
@@ -91,7 +91,7 @@ function Vt(e) {
|
|
|
91
91
|
views: a(o.views, Array.isArray(r.views) ? r.views.length : 0),
|
|
92
92
|
dashboards: a(o.dashboards, Array.isArray(r.dashboards) ? r.dashboards.length : 0),
|
|
93
93
|
seedData: a(o.seedData, Array.isArray(r.seedData) ? r.seedData.length : 0)
|
|
94
|
-
}, c =
|
|
94
|
+
}, c = Vt(t.questions), l = t.questionChoices, u = Array.isArray(l) ? l.flatMap((e) => {
|
|
95
95
|
let t = e;
|
|
96
96
|
if (typeof t?.text != "string" || !t.text) return [];
|
|
97
97
|
let n = Array.isArray(t.options) ? t.options.filter((e) => typeof e == "string" && e.trim().length > 0) : [];
|
|
@@ -104,14 +104,33 @@ function Vt(e) {
|
|
|
104
104
|
...d ? { summary: d } : {},
|
|
105
105
|
objects: i,
|
|
106
106
|
counts: s,
|
|
107
|
-
questions: c.length ? c :
|
|
107
|
+
questions: c.length ? c : Vt(r.questions),
|
|
108
108
|
...u.length ? { questionChoices: u } : {},
|
|
109
|
-
assumptions:
|
|
109
|
+
assumptions: Vt(r.assumptions),
|
|
110
110
|
...typeof f == "string" && f ? { targetApp: f } : {}
|
|
111
111
|
};
|
|
112
112
|
}
|
|
113
|
-
function
|
|
114
|
-
let t =
|
|
113
|
+
function Ut(e) {
|
|
114
|
+
let t = zt(e);
|
|
115
|
+
if (!t || t.status !== "changes_proposed") return;
|
|
116
|
+
let n = (e) => typeof e == "string" && e ? e : void 0, r = t.changes, i = (Array.isArray(r) ? r : []).flatMap((e) => {
|
|
117
|
+
let t = e;
|
|
118
|
+
return typeof t?.verb != "string" || !t.verb ? [] : [{
|
|
119
|
+
verb: t.verb,
|
|
120
|
+
...n(t.object) ? { object: n(t.object) } : {},
|
|
121
|
+
...n(t.field) ? { field: n(t.field) } : {},
|
|
122
|
+
...n(t.type) ? { type: n(t.type) } : {},
|
|
123
|
+
...n(t.name) ? { name: n(t.name) } : {},
|
|
124
|
+
...n(t.details) ? { details: n(t.details) } : {}
|
|
125
|
+
}];
|
|
126
|
+
});
|
|
127
|
+
if (i.length !== 0) return {
|
|
128
|
+
...n(t.summary) ? { summary: n(t.summary) } : {},
|
|
129
|
+
changes: i
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
function Wt(e) {
|
|
133
|
+
let t = zt(e);
|
|
115
134
|
if (!t || t.status !== "drafted") return;
|
|
116
135
|
let n = [];
|
|
117
136
|
if (Array.isArray(t.drafted)) {
|
|
@@ -151,37 +170,38 @@ function Ht(e) {
|
|
|
151
170
|
...s.length ? { issues: s } : {}
|
|
152
171
|
};
|
|
153
172
|
}
|
|
154
|
-
function
|
|
173
|
+
function Gt(e) {
|
|
155
174
|
return e.replace(/[._-]+/g, " ").replace(/\s+/g, " ").trim().replace(/\b\w/g, (e) => e.toUpperCase());
|
|
156
175
|
}
|
|
157
|
-
function
|
|
176
|
+
function Kt(e) {
|
|
158
177
|
if (!e || !Array.isArray(e.items) || e.items.length === 0) return;
|
|
159
178
|
let t = e.items.find((e) => e.type === "app");
|
|
160
179
|
if (t) return {
|
|
161
180
|
phase: "done",
|
|
162
|
-
appLabel:
|
|
181
|
+
appLabel: Gt(t.name),
|
|
163
182
|
items: e.items,
|
|
164
183
|
done: e.items.length,
|
|
165
184
|
total: e.items.length
|
|
166
185
|
};
|
|
167
186
|
}
|
|
168
|
-
function
|
|
187
|
+
function qt(e, t = {}) {
|
|
169
188
|
return e.filter((e) => e.type === "dynamic-tool" ? !0 : typeof e.type == "string" && e.type.startsWith("tool-")).map((e) => {
|
|
170
|
-
let n = e.type === "dynamic-tool" ? e.toolName ?? "tool" : typeof e.type == "string" ? e.type.replace(/^tool-/, "") : "tool", r = e.output ?? e.result, i =
|
|
189
|
+
let n = e.type === "dynamic-tool" ? e.toolName ?? "tool" : typeof e.type == "string" ? e.type.replace(/^tool-/, "") : "tool", r = e.output ?? e.result, i = Bt(r), a = Wt(r), o = Ht(r), s = Ut(r), c = e.state, l = (c === "input-available" || c === "input-streaming") && (r !== void 0 || !t.liveTail) ? "output-available" : c, u = i && l !== "output-error" ? "approval-requested" : l;
|
|
171
190
|
return {
|
|
172
191
|
toolCallId: e.toolCallId ?? e.id ?? `${e.type ?? "tool"}-${Math.random().toString(36).slice(2, 8)}`,
|
|
173
192
|
toolName: n,
|
|
174
193
|
args: e.input ?? e.args,
|
|
175
194
|
result: r,
|
|
176
195
|
errorText: e.errorText,
|
|
177
|
-
state:
|
|
196
|
+
state: u,
|
|
178
197
|
pendingActionId: i?.pendingActionId,
|
|
179
198
|
draftReview: a,
|
|
180
|
-
proposedPlan: o
|
|
199
|
+
proposedPlan: o,
|
|
200
|
+
proposedChanges: s
|
|
181
201
|
};
|
|
182
202
|
});
|
|
183
203
|
}
|
|
184
|
-
function
|
|
204
|
+
function Jt(e) {
|
|
185
205
|
let t = e.filter((e) => e.type === "source-url" || e.type === "source").map((e) => ({
|
|
186
206
|
id: e.id,
|
|
187
207
|
title: e.title,
|
|
@@ -189,7 +209,7 @@ function Kt(e) {
|
|
|
189
209
|
})).filter((e) => !!e.url);
|
|
190
210
|
return t.length > 0 ? t : void 0;
|
|
191
211
|
}
|
|
192
|
-
function
|
|
212
|
+
function Yt(e) {
|
|
193
213
|
let t = e.filter((e) => e.type === "data-build-progress").pop()?.data;
|
|
194
214
|
if (!t || typeof t != "object") return;
|
|
195
215
|
let n = t, r = Array.isArray(n.items) ? n.items.filter((e) => typeof e?.type == "string" && typeof e?.name == "string").map((e) => ({
|
|
@@ -205,7 +225,7 @@ function qt(e) {
|
|
|
205
225
|
...typeof n.seq == "number" ? { seq: n.seq } : {}
|
|
206
226
|
};
|
|
207
227
|
}
|
|
208
|
-
function
|
|
228
|
+
function Xt(e) {
|
|
209
229
|
let t = [];
|
|
210
230
|
for (let n of e) {
|
|
211
231
|
if (n.type !== "data-chart") continue;
|
|
@@ -225,28 +245,28 @@ function Jt(e) {
|
|
|
225
245
|
}
|
|
226
246
|
return t.length > 0 ? t : void 0;
|
|
227
247
|
}
|
|
228
|
-
function
|
|
229
|
-
let n = Array.isArray(e.parts) ? e.parts : [], r =
|
|
248
|
+
function Zt(e, t = {}) {
|
|
249
|
+
let n = Array.isArray(e.parts) ? e.parts : [], r = qt(n, { liveTail: t.streaming }), i = Array.isArray(e.toolInvocations) ? e.toolInvocations : [], a = r.length > 0 ? r : i, o = Yt(n) ?? a.map((e) => Kt(e.draftReview)).find((e) => !!e);
|
|
230
250
|
return {
|
|
231
251
|
id: e.id ?? `msg-${Math.random().toString(36).slice(2, 8)}`,
|
|
232
252
|
role: e.role ?? "assistant",
|
|
233
|
-
content:
|
|
234
|
-
reasoning:
|
|
253
|
+
content: Lt(e, n),
|
|
254
|
+
reasoning: Rt(n),
|
|
235
255
|
toolInvocations: a,
|
|
236
|
-
sources:
|
|
256
|
+
sources: Jt(n),
|
|
237
257
|
buildProgress: o,
|
|
238
|
-
charts:
|
|
258
|
+
charts: Xt(n),
|
|
239
259
|
streaming: t.streaming
|
|
240
260
|
};
|
|
241
261
|
}
|
|
242
|
-
function
|
|
262
|
+
function Qt(e, t = {}) {
|
|
243
263
|
if (!Array.isArray(e) || e.length === 0) return [];
|
|
244
264
|
let n = e.length - 1;
|
|
245
|
-
return e.map((e, r) =>
|
|
265
|
+
return e.map((e, r) => Zt(e, { streaming: !!t.isStreaming && r === n && e.role === "assistant" }));
|
|
246
266
|
}
|
|
247
267
|
//#endregion
|
|
248
268
|
//#region src/useObjectChat.ts
|
|
249
|
-
function
|
|
269
|
+
function $t(e) {
|
|
250
270
|
let t = [...e.messages].reverse().find((e) => e.role === "user");
|
|
251
271
|
return { body: {
|
|
252
272
|
...e.body ?? {},
|
|
@@ -257,7 +277,7 @@ function Zt(e) {
|
|
|
257
277
|
...t ? { turnId: t.id } : {}
|
|
258
278
|
} };
|
|
259
279
|
}
|
|
260
|
-
function
|
|
280
|
+
function en(e) {
|
|
261
281
|
return (e ?? []).map((e, t) => ({
|
|
262
282
|
id: e.id || `msg-${t}`,
|
|
263
283
|
role: e.role || "user",
|
|
@@ -268,14 +288,14 @@ function Qt(e) {
|
|
|
268
288
|
toolInvocations: e.toolInvocations
|
|
269
289
|
}));
|
|
270
290
|
}
|
|
271
|
-
function
|
|
291
|
+
function tn(e = {}) {
|
|
272
292
|
let { api: t, initialMessages: n, conversationId: r, systemPrompt: i, model: a, streamingEnabled: s = !0, headers: f, body: p, maxToolRoundtrips: m = 5, onError: h, showTimestamp: g, autoResponse: _, autoResponseText: v, autoResponseDelay: y = 1e3, onSend: b } = e, x = u(t ? "api" : "local").current === "api", S = l(() => (n ?? []).map((e, t) => {
|
|
273
293
|
if (Array.isArray(e.parts) && e.parts.length > 0) return {
|
|
274
294
|
id: e.id || `msg-${t}`,
|
|
275
295
|
role: e.role || "user",
|
|
276
296
|
parts: e.parts
|
|
277
297
|
};
|
|
278
|
-
let n =
|
|
298
|
+
let n = en([e])[0], r = [];
|
|
279
299
|
n.content && r.push({
|
|
280
300
|
type: "text",
|
|
281
301
|
text: n.content
|
|
@@ -300,9 +320,11 @@ function $t(e = {}) {
|
|
|
300
320
|
text: ""
|
|
301
321
|
}]
|
|
302
322
|
};
|
|
303
|
-
}), []), C =
|
|
323
|
+
}), []), C = u(a);
|
|
324
|
+
C.current = a;
|
|
325
|
+
let w = yt({
|
|
304
326
|
transport: l(() => {
|
|
305
|
-
if (x) return new
|
|
327
|
+
if (x) return new bt({
|
|
306
328
|
api: t,
|
|
307
329
|
headers: { ...f },
|
|
308
330
|
body: {
|
|
@@ -312,13 +334,16 @@ function $t(e = {}) {
|
|
|
312
334
|
...i ? { systemPrompt: i } : {},
|
|
313
335
|
...s === void 0 ? {} : { stream: s }
|
|
314
336
|
},
|
|
315
|
-
prepareSendMessagesRequest: ({ id: e, body: t, messages: n, trigger: r, messageId: i }) =>
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
337
|
+
prepareSendMessagesRequest: ({ id: e, body: t, messages: n, trigger: r, messageId: i }) => {
|
|
338
|
+
let a = $t({
|
|
339
|
+
id: e,
|
|
340
|
+
body: t,
|
|
341
|
+
messages: n,
|
|
342
|
+
trigger: r,
|
|
343
|
+
messageId: i
|
|
344
|
+
});
|
|
345
|
+
return C.current && (a.body.model = C.current), a;
|
|
346
|
+
}
|
|
322
347
|
});
|
|
323
348
|
}, [
|
|
324
349
|
x,
|
|
@@ -334,11 +359,11 @@ function $t(e = {}) {
|
|
|
334
359
|
onError: x ? (e) => {
|
|
335
360
|
h?.(e);
|
|
336
361
|
} : void 0
|
|
337
|
-
}), [
|
|
362
|
+
}), [T, E] = d(() => en(n)), [D, O] = d(!1), [k, A] = d(""), [j, M] = d(""), N = u(null);
|
|
338
363
|
if (c(() => () => {
|
|
339
|
-
|
|
364
|
+
N.current &&= (clearTimeout(N.current), null);
|
|
340
365
|
}, []), x) {
|
|
341
|
-
let { messages: e, status: t, error: n, sendMessage: r, regenerate: i, stop: a, setMessages: s } =
|
|
366
|
+
let { messages: e, status: t, error: n, sendMessage: r, regenerate: i, stop: a, setMessages: s } = w, c = t === "submitted" || t === "streaming", l = Qt(e, { isStreaming: c }).map((t, n) => ({
|
|
342
367
|
...t,
|
|
343
368
|
metadata: e[n]?.metadata
|
|
344
369
|
}));
|
|
@@ -350,11 +375,11 @@ function $t(e = {}) {
|
|
|
350
375
|
let t = e.trim();
|
|
351
376
|
if (!t) return;
|
|
352
377
|
let n = [...l, {
|
|
353
|
-
id:
|
|
378
|
+
id: It("msg"),
|
|
354
379
|
role: "user",
|
|
355
380
|
content: t
|
|
356
381
|
}];
|
|
357
|
-
r({ text: t }),
|
|
382
|
+
r({ text: t }), M(""), b?.(t, n);
|
|
358
383
|
}, [
|
|
359
384
|
r,
|
|
360
385
|
b,
|
|
@@ -367,39 +392,39 @@ function $t(e = {}) {
|
|
|
367
392
|
}, [s]),
|
|
368
393
|
setMessages: s,
|
|
369
394
|
isApiMode: !0,
|
|
370
|
-
input:
|
|
371
|
-
setInput:
|
|
395
|
+
input: j,
|
|
396
|
+
setInput: M,
|
|
372
397
|
handleInputChange: o((e) => {
|
|
373
|
-
|
|
398
|
+
M(e.target.value);
|
|
374
399
|
}, [])
|
|
375
400
|
};
|
|
376
401
|
}
|
|
377
|
-
let
|
|
378
|
-
|
|
402
|
+
let P = o(() => {
|
|
403
|
+
N.current &&= (clearTimeout(N.current), null), O(!1);
|
|
379
404
|
}, []);
|
|
380
405
|
return {
|
|
381
|
-
messages:
|
|
382
|
-
isLoading:
|
|
406
|
+
messages: T,
|
|
407
|
+
isLoading: D,
|
|
383
408
|
error: void 0,
|
|
384
409
|
sendMessage: o((e) => {
|
|
385
410
|
if (!e.trim()) return;
|
|
386
411
|
let t = {
|
|
387
|
-
id:
|
|
412
|
+
id: It("msg"),
|
|
388
413
|
role: "user",
|
|
389
414
|
content: e.trim(),
|
|
390
415
|
timestamp: g ? (/* @__PURE__ */ new Date()).toLocaleTimeString() : void 0
|
|
391
416
|
};
|
|
392
|
-
|
|
417
|
+
E((n) => {
|
|
393
418
|
let r = [...n, t];
|
|
394
419
|
return b?.(e.trim(), r), r;
|
|
395
|
-
}),
|
|
420
|
+
}), A(""), _ && (O(!0), N.current = setTimeout(() => {
|
|
396
421
|
let e = {
|
|
397
|
-
id:
|
|
422
|
+
id: It("msg"),
|
|
398
423
|
role: "assistant",
|
|
399
424
|
content: v || "Thank you for your message!",
|
|
400
425
|
timestamp: g ? (/* @__PURE__ */ new Date()).toLocaleTimeString() : void 0
|
|
401
426
|
};
|
|
402
|
-
|
|
427
|
+
E((t) => [...t, e]), O(!1);
|
|
403
428
|
}, y));
|
|
404
429
|
}, [
|
|
405
430
|
g,
|
|
@@ -408,56 +433,56 @@ function $t(e = {}) {
|
|
|
408
433
|
y,
|
|
409
434
|
b
|
|
410
435
|
]),
|
|
411
|
-
stop:
|
|
436
|
+
stop: P,
|
|
412
437
|
reload: o(() => {}, []),
|
|
413
438
|
clear: o(() => {
|
|
414
|
-
|
|
415
|
-
}, [
|
|
439
|
+
P(), E([]);
|
|
440
|
+
}, [P]),
|
|
416
441
|
isApiMode: !1,
|
|
417
|
-
input:
|
|
418
|
-
setInput:
|
|
442
|
+
input: k,
|
|
443
|
+
setInput: A,
|
|
419
444
|
handleInputChange: o((e) => {
|
|
420
|
-
|
|
445
|
+
A(e.target.value);
|
|
421
446
|
}, [])
|
|
422
447
|
};
|
|
423
448
|
}
|
|
424
449
|
//#endregion
|
|
425
450
|
//#region src/agentAliases.ts
|
|
426
|
-
var
|
|
427
|
-
function
|
|
428
|
-
return
|
|
451
|
+
var nn = [["build", "metadata_assistant"], ["ask", "data_chat"]];
|
|
452
|
+
function rn(e) {
|
|
453
|
+
return nn.find((t) => t.includes(e)) ?? [e];
|
|
429
454
|
}
|
|
430
|
-
function
|
|
431
|
-
return
|
|
455
|
+
function an(e) {
|
|
456
|
+
return rn(e)[0];
|
|
432
457
|
}
|
|
433
|
-
function
|
|
458
|
+
function on(e, t) {
|
|
434
459
|
if (e) {
|
|
435
460
|
if (t.includes(e)) return e;
|
|
436
|
-
for (let n of
|
|
461
|
+
for (let n of rn(e)) if (t.includes(n)) return n;
|
|
437
462
|
}
|
|
438
463
|
}
|
|
439
|
-
function
|
|
440
|
-
return e != null &&
|
|
464
|
+
function sn(e) {
|
|
465
|
+
return e != null && nn.some((t) => t.includes(e));
|
|
441
466
|
}
|
|
442
|
-
function
|
|
443
|
-
return e != null &&
|
|
467
|
+
function cn(e) {
|
|
468
|
+
return e != null && an(e) === "build";
|
|
444
469
|
}
|
|
445
|
-
function
|
|
446
|
-
return e != null &&
|
|
470
|
+
function ln(e) {
|
|
471
|
+
return e != null && an(e) === "ask";
|
|
447
472
|
}
|
|
448
473
|
//#endregion
|
|
449
474
|
//#region src/useAgents.ts
|
|
450
|
-
var
|
|
451
|
-
function
|
|
475
|
+
var un = "ask";
|
|
476
|
+
function dn(e, t) {
|
|
452
477
|
if (e.length === 0) return;
|
|
453
478
|
let n = e.map((e) => e.name);
|
|
454
479
|
if (t) {
|
|
455
|
-
let e =
|
|
480
|
+
let e = on(t, n);
|
|
456
481
|
if (e) return e;
|
|
457
482
|
}
|
|
458
|
-
return
|
|
483
|
+
return on("ask", n) || e[0].name;
|
|
459
484
|
}
|
|
460
|
-
function
|
|
485
|
+
function fn(e) {
|
|
461
486
|
return e.filter((e) => typeof e?.name == "string" && e.name.length > 0).map((e) => ({
|
|
462
487
|
name: e.name,
|
|
463
488
|
label: e.label || e.name,
|
|
@@ -466,7 +491,7 @@ function un(e) {
|
|
|
466
491
|
active: e.active !== !1
|
|
467
492
|
}));
|
|
468
493
|
}
|
|
469
|
-
function
|
|
494
|
+
function pn(e = {}) {
|
|
470
495
|
let { apiBase: t, headers: n, enabled: r = !0, fallback: i = [] } = e, [a, s] = d(i), [l, f] = d(!1), [p, m] = d(void 0), [h, g] = d(0), _ = u(n);
|
|
471
496
|
return _.current = n, c(() => {
|
|
472
497
|
if (!r || !t) return;
|
|
@@ -486,7 +511,7 @@ function dn(e = {}) {
|
|
|
486
511
|
return e.json();
|
|
487
512
|
}).then((e) => {
|
|
488
513
|
if (n) return;
|
|
489
|
-
let t =
|
|
514
|
+
let t = fn(Array.isArray(e) ? e : e?.agents ?? []);
|
|
490
515
|
s(t.length > 0 ? t : i);
|
|
491
516
|
}).catch((e) => {
|
|
492
517
|
n || e.name === "AbortError" || (m(e), s(i));
|
|
@@ -507,9 +532,64 @@ function dn(e = {}) {
|
|
|
507
532
|
};
|
|
508
533
|
}
|
|
509
534
|
//#endregion
|
|
535
|
+
//#region src/useAiModels.ts
|
|
536
|
+
function mn(e) {
|
|
537
|
+
return e.filter((e) => typeof e?.id == "string" && e.id.length > 0).map((e) => ({
|
|
538
|
+
id: e.id,
|
|
539
|
+
label: e.label || e.id
|
|
540
|
+
}));
|
|
541
|
+
}
|
|
542
|
+
function hn(e = {}) {
|
|
543
|
+
let { apiBase: t, headers: n, enabled: r = !0 } = e, [i, a] = d([]), [s, l] = d(void 0), [f, p] = d(!1), [m, h] = d(void 0), [g, _] = d(0), v = u(n);
|
|
544
|
+
return v.current = n, c(() => {
|
|
545
|
+
if (!r || !t) return;
|
|
546
|
+
let e = new AbortController(), n = !1, i = `${t.replace(/\/$/, "")}/models`, o = 0, s = async () => {
|
|
547
|
+
if (!n) {
|
|
548
|
+
p(!0), h(void 0);
|
|
549
|
+
try {
|
|
550
|
+
let t = await fetch(i, {
|
|
551
|
+
method: "GET",
|
|
552
|
+
headers: {
|
|
553
|
+
Accept: "application/json",
|
|
554
|
+
...v.current ?? {}
|
|
555
|
+
},
|
|
556
|
+
credentials: "include",
|
|
557
|
+
signal: e.signal
|
|
558
|
+
});
|
|
559
|
+
if (!t.ok) throw Error(`Failed to load AI models (${t.status})`);
|
|
560
|
+
let r = await t.json();
|
|
561
|
+
if (n) return;
|
|
562
|
+
let c = Array.isArray(r) ? r : r?.models ?? [], u = Array.isArray(r) ? void 0 : r?.defaultModel, d = mn(c);
|
|
563
|
+
a(d), l(u ?? c.find((e) => e?.default)?.id ?? c[0]?.id), p(!1), d.length === 0 && o < 5 && !n && (o += 1, setTimeout(() => {
|
|
564
|
+
s();
|
|
565
|
+
}, 1200));
|
|
566
|
+
} catch (e) {
|
|
567
|
+
if (n || e?.name === "AbortError") return;
|
|
568
|
+
o < 5 ? (o += 1, setTimeout(() => {
|
|
569
|
+
s();
|
|
570
|
+
}, 1200)) : (h(e), a([]), l(void 0), p(!1));
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
};
|
|
574
|
+
return s(), () => {
|
|
575
|
+
n = !0, e.abort();
|
|
576
|
+
};
|
|
577
|
+
}, [
|
|
578
|
+
t,
|
|
579
|
+
r,
|
|
580
|
+
g
|
|
581
|
+
]), {
|
|
582
|
+
models: i,
|
|
583
|
+
defaultModelId: s,
|
|
584
|
+
isLoading: f,
|
|
585
|
+
error: m,
|
|
586
|
+
refetch: o(() => _((e) => e + 1), [])
|
|
587
|
+
};
|
|
588
|
+
}
|
|
589
|
+
//#endregion
|
|
510
590
|
//#region src/FloatingChatbotProvider.tsx
|
|
511
|
-
var
|
|
512
|
-
function
|
|
591
|
+
var gn = e.createContext(null);
|
|
592
|
+
function _n({ defaultOpen: t = !1, children: n }) {
|
|
513
593
|
let [r, i] = e.useState(t), [a, o] = e.useState(!1), s = e.useMemo(() => ({
|
|
514
594
|
isOpen: r,
|
|
515
595
|
isFullscreen: a,
|
|
@@ -520,21 +600,21 @@ function pn({ defaultOpen: t = !1, children: n }) {
|
|
|
520
600
|
toggle: () => i((e) => !e),
|
|
521
601
|
toggleFullscreen: () => o((e) => !e)
|
|
522
602
|
}), [r, a]);
|
|
523
|
-
return /* @__PURE__ */ Q(
|
|
603
|
+
return /* @__PURE__ */ Q(gn.Provider, {
|
|
524
604
|
value: s,
|
|
525
605
|
children: n
|
|
526
606
|
});
|
|
527
607
|
}
|
|
528
|
-
function
|
|
529
|
-
let t = e.useContext(
|
|
608
|
+
function vn() {
|
|
609
|
+
let t = e.useContext(gn);
|
|
530
610
|
if (!t) throw Error("useFloatingChatbot must be used within a <FloatingChatbotProvider>");
|
|
531
611
|
return t;
|
|
532
612
|
}
|
|
533
613
|
//#endregion
|
|
534
614
|
//#region src/FloatingChatbotTrigger.tsx
|
|
535
|
-
function
|
|
615
|
+
function yn() {
|
|
536
616
|
try {
|
|
537
|
-
let { t: e } =
|
|
617
|
+
let { t: e } = Ct();
|
|
538
618
|
return (t, n) => {
|
|
539
619
|
let r = e(`common.${t}`);
|
|
540
620
|
return !r || r === `common.${t}` ? n : r;
|
|
@@ -543,7 +623,7 @@ function hn() {
|
|
|
543
623
|
return (e, t) => t;
|
|
544
624
|
}
|
|
545
625
|
}
|
|
546
|
-
var
|
|
626
|
+
var bn = {
|
|
547
627
|
32: "size-8",
|
|
548
628
|
36: "size-9",
|
|
549
629
|
40: "size-10",
|
|
@@ -556,26 +636,26 @@ var gn = {
|
|
|
556
636
|
72: "size-[72px]",
|
|
557
637
|
80: "size-20"
|
|
558
638
|
};
|
|
559
|
-
function
|
|
639
|
+
function xn(e, t) {
|
|
560
640
|
return t.reduce((t, n) => Math.abs(n - e) < Math.abs(t - e) ? n : t);
|
|
561
641
|
}
|
|
562
|
-
function
|
|
563
|
-
return
|
|
642
|
+
function Sn(e) {
|
|
643
|
+
return bn[e] ?? bn[xn(e, Object.keys(bn).map(Number))];
|
|
564
644
|
}
|
|
565
|
-
function
|
|
566
|
-
let { isOpen: r, toggle: i } =
|
|
645
|
+
function Cn({ position: e = "bottom-right", size: t = 56, className: n }) {
|
|
646
|
+
let { isOpen: r, toggle: i } = vn(), a = yn();
|
|
567
647
|
return /* @__PURE__ */ Q(v, {
|
|
568
648
|
onClick: i,
|
|
569
|
-
className:
|
|
649
|
+
className: q("fixed z-50 rounded-full shadow-lg transition-transform hover:scale-105", Sn(t), r && "hidden", e === "bottom-right" ? "right-6 bottom-20 sm:bottom-6" : "left-6 bottom-20 sm:bottom-6", n),
|
|
570
650
|
size: "icon",
|
|
571
651
|
"aria-label": r ? a("closeChat", "Close chat") : a("openChat", "Open chat"),
|
|
572
652
|
"data-testid": "floating-chatbot-trigger",
|
|
573
|
-
children: Q(r ?
|
|
653
|
+
children: Q(r ? gt : Ne, { className: "h-6 w-6" })
|
|
574
654
|
});
|
|
575
655
|
}
|
|
576
656
|
//#endregion
|
|
577
657
|
//#region src/FloatingChatbotPanel.tsx
|
|
578
|
-
var
|
|
658
|
+
var wn = {
|
|
579
659
|
300: "sm:w-[300px]",
|
|
580
660
|
320: "sm:w-[320px]",
|
|
581
661
|
340: "sm:w-[340px]",
|
|
@@ -594,7 +674,7 @@ var bn = {
|
|
|
594
674
|
640: "sm:w-[640px]",
|
|
595
675
|
720: "sm:w-[720px]",
|
|
596
676
|
800: "sm:w-[800px]"
|
|
597
|
-
},
|
|
677
|
+
}, Tn = {
|
|
598
678
|
360: "h-[min(360px,calc(100svh_-_6rem_-_env(safe-area-inset-bottom)))] sm:h-[360px]",
|
|
599
679
|
400: "h-[min(400px,calc(100svh_-_6rem_-_env(safe-area-inset-bottom)))] sm:h-[400px]",
|
|
600
680
|
420: "h-[min(420px,calc(100svh_-_6rem_-_env(safe-area-inset-bottom)))] sm:h-[420px]",
|
|
@@ -608,19 +688,19 @@ var bn = {
|
|
|
608
688
|
720: "h-[min(720px,calc(100svh_-_6rem_-_env(safe-area-inset-bottom)))] sm:h-[720px]",
|
|
609
689
|
800: "h-[min(800px,calc(100svh_-_6rem_-_env(safe-area-inset-bottom)))] sm:h-[800px]"
|
|
610
690
|
};
|
|
611
|
-
function
|
|
691
|
+
function En(e, t) {
|
|
612
692
|
return t.reduce((t, n) => Math.abs(n - e) < Math.abs(t - e) ? n : t);
|
|
613
693
|
}
|
|
614
|
-
function
|
|
615
|
-
return
|
|
694
|
+
function Dn(e) {
|
|
695
|
+
return wn[e] ?? wn[En(e, Object.keys(wn).map(Number))];
|
|
616
696
|
}
|
|
617
|
-
function
|
|
618
|
-
return
|
|
697
|
+
function On(e) {
|
|
698
|
+
return Tn[e] ?? Tn[En(e, Object.keys(Tn).map(Number))];
|
|
619
699
|
}
|
|
620
|
-
function
|
|
621
|
-
let { isOpen: c, isFullscreen: l, close: u, toggleFullscreen: d } =
|
|
700
|
+
function kn({ title: e = "Chat", position: t = "bottom-right", width: n = 400, height: r = 520, children: i, className: a, headerExtra: o, headerActions: s }) {
|
|
701
|
+
let { isOpen: c, isFullscreen: l, close: u, toggleFullscreen: d } = vn();
|
|
622
702
|
return c ? /* @__PURE__ */ $("div", {
|
|
623
|
-
className:
|
|
703
|
+
className: q("fixed z-50 flex flex-col overflow-hidden border bg-background shadow-xl transition-all", l ? "inset-0 h-svh w-screen rounded-none" : t === "bottom-right" ? q("left-3 right-3 bottom-[calc(4rem_+_env(safe-area-inset-bottom))] rounded-lg", "sm:left-auto sm:right-6 sm:bottom-20 sm:max-h-[calc(100vh_-_100px)]", Dn(n), On(r)) : q("left-3 right-3 bottom-[calc(4rem_+_env(safe-area-inset-bottom))] rounded-lg", "sm:right-auto sm:left-6 sm:bottom-20 sm:max-h-[calc(100vh_-_100px)]", Dn(n), On(r)), a),
|
|
624
704
|
role: "dialog",
|
|
625
705
|
"aria-label": e,
|
|
626
706
|
"data-testid": "floating-chatbot-panel",
|
|
@@ -656,7 +736,7 @@ function Tn({ title: e = "Chat", position: t = "bottom-right", width: n = 400, h
|
|
|
656
736
|
onClick: u,
|
|
657
737
|
"aria-label": "Close chat",
|
|
658
738
|
"data-testid": "floating-chatbot-close",
|
|
659
|
-
children: /* @__PURE__ */ Q(
|
|
739
|
+
children: /* @__PURE__ */ Q(gt, { className: "h-4 w-4" })
|
|
660
740
|
})
|
|
661
741
|
]
|
|
662
742
|
})
|
|
@@ -669,7 +749,7 @@ function Tn({ title: e = "Chat", position: t = "bottom-right", width: n = 400, h
|
|
|
669
749
|
}
|
|
670
750
|
//#endregion
|
|
671
751
|
//#region src/tool-display.ts
|
|
672
|
-
var
|
|
752
|
+
var An = {
|
|
673
753
|
ai: "AI",
|
|
674
754
|
api: "API",
|
|
675
755
|
crm: "CRM",
|
|
@@ -681,17 +761,17 @@ var En = {
|
|
|
681
761
|
url: "URL",
|
|
682
762
|
utc: "UTC"
|
|
683
763
|
};
|
|
684
|
-
function
|
|
764
|
+
function jn(e) {
|
|
685
765
|
if (!e) return "";
|
|
686
766
|
let t = String(e).trim();
|
|
687
767
|
if (!t) return "";
|
|
688
768
|
let n = t.replace(/[_-]+/g, " ").replace(/([a-z])([A-Z])/g, "$1 $2").split(/\s+/).filter(Boolean);
|
|
689
769
|
return n.length === 0 ? t : n.map((e, t) => {
|
|
690
770
|
let n = e.toLowerCase();
|
|
691
|
-
return
|
|
771
|
+
return An[n] ? An[n] : t === 0 ? n.charAt(0).toUpperCase() + n.slice(1) : n;
|
|
692
772
|
}).join(" ");
|
|
693
773
|
}
|
|
694
|
-
function
|
|
774
|
+
function Mn(e) {
|
|
695
775
|
if (e == null) return e;
|
|
696
776
|
let t = e;
|
|
697
777
|
for (let e = 0; e < 2; e++) {
|
|
@@ -709,7 +789,7 @@ function On(e) {
|
|
|
709
789
|
}
|
|
710
790
|
return t;
|
|
711
791
|
}
|
|
712
|
-
function
|
|
792
|
+
function Nn(e) {
|
|
713
793
|
let t = (e instanceof Error ? e.message : String(e ?? "")).replace(/\s+/g, " ").trim();
|
|
714
794
|
if (!t) return { summary: "Something went wrong. Please try again." };
|
|
715
795
|
let n = t.replace(/^Failed after \d+ attempts?\.\s*Last error:\s*/i, ""), r = n.match(/^Invalid error response format:\s*(.+)$/i)?.[1]?.trim() ?? n, i = r.match(/^([^:]{8,80}):\s+(.+)$/)?.[1]?.trim() ?? r.match(/^([^.;!?]+[.;!?])\s/)?.[1]?.trim() ?? (r.length > 140 ? `${r.slice(0, 137).trimEnd()}…` : r);
|
|
@@ -718,12 +798,12 @@ function kn(e) {
|
|
|
718
798
|
details: n.length > i.length ? n : void 0
|
|
719
799
|
};
|
|
720
800
|
}
|
|
721
|
-
var
|
|
801
|
+
var Pn = new Set([
|
|
722
802
|
"ai_design_quota_exhausted",
|
|
723
803
|
"ai_data_chat_trial_exhausted",
|
|
724
804
|
"ai_allowance_exhausted"
|
|
725
805
|
]);
|
|
726
|
-
function
|
|
806
|
+
function Fn(e) {
|
|
727
807
|
let t = e instanceof Error ? e.message : String(e ?? "");
|
|
728
808
|
if (!t) return null;
|
|
729
809
|
let n = t.replace(/^Failed after \d+ attempts?\.\s*Last error:\s*/i, "").replace(/^Invalid error response format:\s*/i, "").trim(), r = n.indexOf("{"), i = n.lastIndexOf("}");
|
|
@@ -734,7 +814,7 @@ function jn(e) {
|
|
|
734
814
|
} catch {
|
|
735
815
|
return null;
|
|
736
816
|
}
|
|
737
|
-
return !a || typeof a.error != "string" || !
|
|
817
|
+
return !a || typeof a.error != "string" || !Pn.has(a.error) ? null : {
|
|
738
818
|
code: a.error,
|
|
739
819
|
message: typeof a.message == "string" ? a.message : "",
|
|
740
820
|
messageEn: typeof a.messageEn == "string" ? a.messageEn : void 0,
|
|
@@ -744,17 +824,17 @@ function jn(e) {
|
|
|
744
824
|
}
|
|
745
825
|
//#endregion
|
|
746
826
|
//#region src/elements/conversation.tsx
|
|
747
|
-
var
|
|
748
|
-
className:
|
|
827
|
+
var In = ({ className: e, ...t }) => /* @__PURE__ */ Q(wt, {
|
|
828
|
+
className: q("relative flex-1 overflow-y-hidden", e),
|
|
749
829
|
initial: "smooth",
|
|
750
830
|
resize: "smooth",
|
|
751
831
|
role: "log",
|
|
752
832
|
...t
|
|
753
|
-
}),
|
|
754
|
-
className:
|
|
833
|
+
}), Ln = ({ className: e, ...t }) => /* @__PURE__ */ Q(wt.Content, {
|
|
834
|
+
className: q("flex flex-col gap-8 p-4", e),
|
|
755
835
|
...t
|
|
756
|
-
}),
|
|
757
|
-
className:
|
|
836
|
+
}), Rn = ({ className: e, title: t = "No messages yet", description: n = "Start a conversation to see messages here", icon: r, children: i, ...a }) => /* @__PURE__ */ Q("div", {
|
|
837
|
+
className: q("flex size-full flex-col items-center justify-center gap-3 p-8 text-center", e),
|
|
758
838
|
...a,
|
|
759
839
|
children: i ?? /* @__PURE__ */ $(Z, { children: [r && /* @__PURE__ */ Q("div", {
|
|
760
840
|
className: "text-muted-foreground",
|
|
@@ -769,55 +849,55 @@ var Mn = ({ className: e, ...t }) => /* @__PURE__ */ Q(Ct, {
|
|
|
769
849
|
children: n
|
|
770
850
|
})]
|
|
771
851
|
})] })
|
|
772
|
-
}),
|
|
773
|
-
let { isAtBottom: n, scrollToBottom: r } =
|
|
852
|
+
}), zn = ({ className: e, ...t }) => {
|
|
853
|
+
let { isAtBottom: n, scrollToBottom: r } = Tt(), i = o(() => {
|
|
774
854
|
r();
|
|
775
855
|
}, [r]);
|
|
776
856
|
return !n && /* @__PURE__ */ Q(v, {
|
|
777
|
-
className:
|
|
857
|
+
className: q("absolute bottom-4 left-[50%] translate-x-[-50%] rounded-full", e),
|
|
778
858
|
onClick: i,
|
|
779
859
|
size: "icon",
|
|
780
860
|
type: "button",
|
|
781
861
|
variant: "outline",
|
|
782
862
|
...t,
|
|
783
|
-
children: /* @__PURE__ */ Q(
|
|
863
|
+
children: /* @__PURE__ */ Q(Ae, { className: "size-4" })
|
|
784
864
|
});
|
|
785
|
-
},
|
|
865
|
+
}, Bn = Et("flex w-fit items-stretch has-[>[data-slot=button-group]]:gap-2 [&>*]:focus-visible:relative [&>*]:focus-visible:z-10 has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-r-md [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1", {
|
|
786
866
|
variants: { orientation: {
|
|
787
867
|
horizontal: "[&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0 [&>*:not(:last-child)]:rounded-r-none",
|
|
788
868
|
vertical: "flex-col [&>*:not(:first-child)]:rounded-t-none [&>*:not(:first-child)]:border-t-0 [&>*:not(:last-child)]:rounded-b-none"
|
|
789
869
|
} },
|
|
790
870
|
defaultVariants: { orientation: "horizontal" }
|
|
791
871
|
});
|
|
792
|
-
function
|
|
872
|
+
function Vn({ className: e, orientation: t, ...n }) {
|
|
793
873
|
return /* @__PURE__ */ Q("div", {
|
|
794
874
|
role: "group",
|
|
795
875
|
"data-slot": "button-group",
|
|
796
876
|
"data-orientation": t,
|
|
797
|
-
className:
|
|
877
|
+
className: q(Bn({ orientation: t }), e),
|
|
798
878
|
...n
|
|
799
879
|
});
|
|
800
880
|
}
|
|
801
|
-
function
|
|
802
|
-
return /* @__PURE__ */ Q(t ?
|
|
803
|
-
className:
|
|
881
|
+
function Hn({ className: e, asChild: t = !1, ...n }) {
|
|
882
|
+
return /* @__PURE__ */ Q(t ? Dt : "div", {
|
|
883
|
+
className: q("flex items-center gap-2 rounded-md border bg-muted px-4 text-sm font-medium shadow-xs [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4", e),
|
|
804
884
|
...n
|
|
805
885
|
});
|
|
806
886
|
}
|
|
807
887
|
//#endregion
|
|
808
888
|
//#region src/elements/message.tsx
|
|
809
|
-
var
|
|
810
|
-
className:
|
|
889
|
+
var Un = ({ className: e, from: t, ...n }) => /* @__PURE__ */ Q("div", {
|
|
890
|
+
className: q("group flex w-full max-w-[95%] flex-col gap-2", t === "user" ? "is-user ml-auto justify-end" : "is-assistant", e),
|
|
811
891
|
...n
|
|
812
|
-
}),
|
|
813
|
-
className:
|
|
892
|
+
}), Wn = ({ children: e, className: t, ...n }) => /* @__PURE__ */ Q("div", {
|
|
893
|
+
className: q("is-user:dark flex w-fit max-w-full min-w-0 flex-col gap-2 overflow-hidden text-sm", "group-[.is-user]:ml-auto group-[.is-user]:rounded-lg group-[.is-user]:bg-secondary group-[.is-user]:px-4 group-[.is-user]:py-3 group-[.is-user]:text-foreground", "group-[.is-assistant]:text-foreground", t),
|
|
814
894
|
...n,
|
|
815
895
|
children: e
|
|
816
|
-
}),
|
|
817
|
-
className:
|
|
896
|
+
}), Gn = ({ className: e, children: t, ...n }) => /* @__PURE__ */ Q("div", {
|
|
897
|
+
className: q("flex items-center gap-1", e),
|
|
818
898
|
...n,
|
|
819
899
|
children: t
|
|
820
|
-
}),
|
|
900
|
+
}), Kn = ({ tooltip: e, children: t, label: n, variant: r = "ghost", size: i = "icon", ...a }) => {
|
|
821
901
|
let o = /* @__PURE__ */ $(v, {
|
|
822
902
|
size: i,
|
|
823
903
|
type: "button",
|
|
@@ -828,15 +908,15 @@ var zn = ({ className: e, from: t, ...n }) => /* @__PURE__ */ Q("div", {
|
|
|
828
908
|
children: n || e
|
|
829
909
|
})]
|
|
830
910
|
});
|
|
831
|
-
return e ? /* @__PURE__ */ Q(
|
|
911
|
+
return e ? /* @__PURE__ */ Q(De, { children: /* @__PURE__ */ $(K, { children: [/* @__PURE__ */ Q(Oe, {
|
|
832
912
|
asChild: !0,
|
|
833
913
|
children: o
|
|
834
|
-
}), /* @__PURE__ */ Q(
|
|
835
|
-
},
|
|
836
|
-
let e = s(
|
|
914
|
+
}), /* @__PURE__ */ Q(Ee, { children: /* @__PURE__ */ Q("p", { children: e }) })] }) }) : o;
|
|
915
|
+
}, qn = r(null), Jn = () => {
|
|
916
|
+
let e = s(qn);
|
|
837
917
|
if (!e) throw Error("MessageBranch components must be used within MessageBranch");
|
|
838
918
|
return e;
|
|
839
|
-
},
|
|
919
|
+
}, Yn = ({ defaultBranch: e = 0, onBranchChange: t, className: n, ...r }) => {
|
|
840
920
|
let [i, a] = d(e), [o, s] = d([]), c = (e) => {
|
|
841
921
|
a(e), t?.(e);
|
|
842
922
|
}, l = {
|
|
@@ -851,15 +931,15 @@ var zn = ({ className: e, from: t, ...n }) => /* @__PURE__ */ Q("div", {
|
|
|
851
931
|
branches: o,
|
|
852
932
|
setBranches: s
|
|
853
933
|
};
|
|
854
|
-
return /* @__PURE__ */ Q(
|
|
934
|
+
return /* @__PURE__ */ Q(qn.Provider, {
|
|
855
935
|
value: l,
|
|
856
936
|
children: /* @__PURE__ */ Q("div", {
|
|
857
|
-
className:
|
|
937
|
+
className: q("grid w-full gap-2 [&>div]:pb-0", n),
|
|
858
938
|
...r
|
|
859
939
|
})
|
|
860
940
|
});
|
|
861
|
-
},
|
|
862
|
-
let { currentBranch: n, setBranches: r, branches: i } =
|
|
941
|
+
}, Xn = ({ children: e, ...t }) => {
|
|
942
|
+
let { currentBranch: n, setBranches: r, branches: i } = Jn(), a = Array.isArray(e) ? e : [e];
|
|
863
943
|
return c(() => {
|
|
864
944
|
i.length !== a.length && r(a);
|
|
865
945
|
}, [
|
|
@@ -867,19 +947,19 @@ var zn = ({ className: e, from: t, ...n }) => /* @__PURE__ */ Q("div", {
|
|
|
867
947
|
i,
|
|
868
948
|
r
|
|
869
949
|
]), a.map((e, r) => /* @__PURE__ */ Q("div", {
|
|
870
|
-
className:
|
|
950
|
+
className: q("grid gap-2 overflow-hidden [&>div]:pb-0", r === n ? "block" : "hidden"),
|
|
871
951
|
...t,
|
|
872
952
|
children: e
|
|
873
953
|
}, e.key));
|
|
874
|
-
},
|
|
875
|
-
let { totalBranches: r } =
|
|
876
|
-
return r <= 1 ? null : /* @__PURE__ */ Q(
|
|
954
|
+
}, Zn = ({ className: e, from: t, ...n }) => {
|
|
955
|
+
let { totalBranches: r } = Jn();
|
|
956
|
+
return r <= 1 ? null : /* @__PURE__ */ Q(Vn, {
|
|
877
957
|
className: "[&>*:not(:first-child)]:rounded-l-md [&>*:not(:last-child)]:rounded-r-md",
|
|
878
958
|
orientation: "horizontal",
|
|
879
959
|
...n
|
|
880
960
|
});
|
|
881
|
-
},
|
|
882
|
-
let { goToPrevious: n, totalBranches: r } =
|
|
961
|
+
}, Qn = ({ children: e, ...t }) => {
|
|
962
|
+
let { goToPrevious: n, totalBranches: r } = Jn();
|
|
883
963
|
return /* @__PURE__ */ Q(v, {
|
|
884
964
|
"aria-label": "Previous branch",
|
|
885
965
|
disabled: r <= 1,
|
|
@@ -890,8 +970,8 @@ var zn = ({ className: e, from: t, ...n }) => /* @__PURE__ */ Q("div", {
|
|
|
890
970
|
...t,
|
|
891
971
|
children: e ?? /* @__PURE__ */ Q(Re, { size: 14 })
|
|
892
972
|
});
|
|
893
|
-
},
|
|
894
|
-
let { goToNext: r, totalBranches: i } =
|
|
973
|
+
}, $n = ({ children: e, className: t, ...n }) => {
|
|
974
|
+
let { goToNext: r, totalBranches: i } = Jn();
|
|
895
975
|
return /* @__PURE__ */ Q(v, {
|
|
896
976
|
"aria-label": "Next branch",
|
|
897
977
|
disabled: i <= 1,
|
|
@@ -902,10 +982,10 @@ var zn = ({ className: e, from: t, ...n }) => /* @__PURE__ */ Q("div", {
|
|
|
902
982
|
...n,
|
|
903
983
|
children: e ?? /* @__PURE__ */ Q(ze, { size: 14 })
|
|
904
984
|
});
|
|
905
|
-
},
|
|
906
|
-
let { currentBranch: n, totalBranches: r } =
|
|
907
|
-
return /* @__PURE__ */ $(
|
|
908
|
-
className:
|
|
985
|
+
}, er = ({ className: e, ...t }) => {
|
|
986
|
+
let { currentBranch: n, totalBranches: r } = Jn();
|
|
987
|
+
return /* @__PURE__ */ $(Hn, {
|
|
988
|
+
className: q("border-none bg-transparent text-muted-foreground shadow-none", e),
|
|
909
989
|
...t,
|
|
910
990
|
children: [
|
|
911
991
|
n + 1,
|
|
@@ -913,15 +993,15 @@ var zn = ({ className: e, from: t, ...n }) => /* @__PURE__ */ Q("div", {
|
|
|
913
993
|
r
|
|
914
994
|
]
|
|
915
995
|
});
|
|
916
|
-
},
|
|
917
|
-
className:
|
|
996
|
+
}, tr = a(({ className: e, ...t }) => /* @__PURE__ */ Q(Ot, {
|
|
997
|
+
className: q("size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0", e),
|
|
918
998
|
...t
|
|
919
999
|
}), (e, t) => e.children === t.children);
|
|
920
|
-
|
|
921
|
-
function
|
|
1000
|
+
tr.displayName = "MessageResponse";
|
|
1001
|
+
function nr({ data: e, className: t, onRemove: n, ...r }) {
|
|
922
1002
|
let i = e.filename || "", a = (e.mediaType?.startsWith("image/") && e.url ? "image" : "file") == "image", o = i || (a ? "Image" : "Attachment");
|
|
923
1003
|
return /* @__PURE__ */ Q("div", {
|
|
924
|
-
className:
|
|
1004
|
+
className: q("group relative size-24 overflow-hidden rounded-lg", t),
|
|
925
1005
|
...r,
|
|
926
1006
|
children: a ? /* @__PURE__ */ $(Z, { children: [/* @__PURE__ */ Q("img", {
|
|
927
1007
|
alt: i || "attachment",
|
|
@@ -937,17 +1017,17 @@ function Qn({ data: e, className: t, onRemove: n, ...r }) {
|
|
|
937
1017
|
},
|
|
938
1018
|
type: "button",
|
|
939
1019
|
variant: "ghost",
|
|
940
|
-
children: [/* @__PURE__ */ Q(
|
|
1020
|
+
children: [/* @__PURE__ */ Q(vt, {}), /* @__PURE__ */ Q("span", {
|
|
941
1021
|
className: "sr-only",
|
|
942
1022
|
children: "Remove"
|
|
943
1023
|
})]
|
|
944
|
-
})] }) : /* @__PURE__ */ $(Z, { children: [/* @__PURE__ */ $(
|
|
1024
|
+
})] }) : /* @__PURE__ */ $(Z, { children: [/* @__PURE__ */ $(K, { children: [/* @__PURE__ */ Q(Oe, {
|
|
945
1025
|
asChild: !0,
|
|
946
1026
|
children: /* @__PURE__ */ Q("div", {
|
|
947
1027
|
className: "flex size-full shrink-0 items-center justify-center rounded-lg bg-muted text-muted-foreground",
|
|
948
1028
|
children: /* @__PURE__ */ Q(at, { className: "size-4" })
|
|
949
1029
|
})
|
|
950
|
-
}), /* @__PURE__ */ Q(
|
|
1030
|
+
}), /* @__PURE__ */ Q(Ee, { children: /* @__PURE__ */ Q("p", { children: o }) })] }), n && /* @__PURE__ */ $(v, {
|
|
951
1031
|
"aria-label": "Remove attachment",
|
|
952
1032
|
className: "size-6 shrink-0 rounded-full p-0 opacity-0 transition-opacity hover:bg-accent group-hover:opacity-100 [&>svg]:size-3",
|
|
953
1033
|
onClick: (e) => {
|
|
@@ -955,36 +1035,36 @@ function Qn({ data: e, className: t, onRemove: n, ...r }) {
|
|
|
955
1035
|
},
|
|
956
1036
|
type: "button",
|
|
957
1037
|
variant: "ghost",
|
|
958
|
-
children: [/* @__PURE__ */ Q(
|
|
1038
|
+
children: [/* @__PURE__ */ Q(vt, {}), /* @__PURE__ */ Q("span", {
|
|
959
1039
|
className: "sr-only",
|
|
960
1040
|
children: "Remove"
|
|
961
1041
|
})]
|
|
962
1042
|
})] })
|
|
963
1043
|
});
|
|
964
1044
|
}
|
|
965
|
-
function
|
|
1045
|
+
function rr({ children: e, className: t, ...n }) {
|
|
966
1046
|
return e ? /* @__PURE__ */ Q("div", {
|
|
967
|
-
className:
|
|
1047
|
+
className: q("ml-auto flex w-fit flex-wrap items-start gap-2", t),
|
|
968
1048
|
...n,
|
|
969
1049
|
children: e
|
|
970
1050
|
}) : null;
|
|
971
1051
|
}
|
|
972
|
-
var
|
|
973
|
-
className:
|
|
1052
|
+
var ir = ({ className: e, children: t, ...n }) => /* @__PURE__ */ Q("div", {
|
|
1053
|
+
className: q("mt-4 flex w-full items-center justify-between gap-4", e),
|
|
974
1054
|
...n,
|
|
975
1055
|
children: t
|
|
976
1056
|
});
|
|
977
1057
|
//#endregion
|
|
978
1058
|
//#region src/elements/ui/input-group.tsx
|
|
979
|
-
function
|
|
1059
|
+
function ar({ className: e, ...t }) {
|
|
980
1060
|
return /* @__PURE__ */ Q("div", {
|
|
981
1061
|
"data-slot": "input-group",
|
|
982
1062
|
role: "group",
|
|
983
|
-
className:
|
|
1063
|
+
className: q("group/input-group relative flex w-full items-center rounded-md border border-input shadow-xs transition-[color,box-shadow] outline-none dark:bg-input/30", "h-9 min-w-0 has-[>textarea]:h-auto", "has-[>[data-align=inline-start]]:[&>input]:pl-2", "has-[>[data-align=inline-end]]:[&>input]:pr-2", "has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>[data-align=block-start]]:[&>input]:pb-3", "has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-end]]:[&>input]:pt-3", "has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-[3px] has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50", "has-[[data-slot][aria-invalid=true]]:border-destructive has-[[data-slot][aria-invalid=true]]:ring-destructive/20 dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40", e),
|
|
984
1064
|
...t
|
|
985
1065
|
});
|
|
986
1066
|
}
|
|
987
|
-
var
|
|
1067
|
+
var or = Et("flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-sm font-medium text-muted-foreground select-none group-data-[disabled=true]/input-group:opacity-50 [&>kbd]:rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-4", {
|
|
988
1068
|
variants: { align: {
|
|
989
1069
|
"inline-start": "order-first pl-3 has-[>button]:ml-[-0.45rem] has-[>kbd]:ml-[-0.35rem]",
|
|
990
1070
|
"inline-end": "order-last pr-3 has-[>button]:mr-[-0.45rem] has-[>kbd]:mr-[-0.35rem]",
|
|
@@ -993,19 +1073,19 @@ var nr = Tt("flex h-auto cursor-text items-center justify-center gap-2 py-1.5 te
|
|
|
993
1073
|
} },
|
|
994
1074
|
defaultVariants: { align: "inline-start" }
|
|
995
1075
|
});
|
|
996
|
-
function
|
|
1076
|
+
function sr({ className: e, align: t = "inline-start", ...n }) {
|
|
997
1077
|
return /* @__PURE__ */ Q("div", {
|
|
998
1078
|
role: "group",
|
|
999
1079
|
"data-slot": "input-group-addon",
|
|
1000
1080
|
"data-align": t,
|
|
1001
|
-
className:
|
|
1081
|
+
className: q(or({ align: t }), e),
|
|
1002
1082
|
onClick: (e) => {
|
|
1003
1083
|
e.target.closest("button") || e.currentTarget.parentElement?.querySelector("input")?.focus();
|
|
1004
1084
|
},
|
|
1005
1085
|
...n
|
|
1006
1086
|
});
|
|
1007
1087
|
}
|
|
1008
|
-
var
|
|
1088
|
+
var cr = Et("flex items-center gap-2 text-sm shadow-none", {
|
|
1009
1089
|
variants: { size: {
|
|
1010
1090
|
xs: "h-6 gap-1 rounded-[calc(var(--radius)-5px)] px-2 has-[>svg]:px-2 [&>svg:not([class*='size-'])]:size-3.5",
|
|
1011
1091
|
sm: "h-8 gap-1.5 rounded-md px-2.5 has-[>svg]:px-2.5",
|
|
@@ -1014,38 +1094,38 @@ var ir = Tt("flex items-center gap-2 text-sm shadow-none", {
|
|
|
1014
1094
|
} },
|
|
1015
1095
|
defaultVariants: { size: "xs" }
|
|
1016
1096
|
});
|
|
1017
|
-
function
|
|
1097
|
+
function lr({ className: e, type: t = "button", variant: n = "ghost", size: r = "xs", ...i }) {
|
|
1018
1098
|
return /* @__PURE__ */ Q(v, {
|
|
1019
1099
|
type: t,
|
|
1020
1100
|
"data-size": r,
|
|
1021
1101
|
variant: n,
|
|
1022
|
-
className:
|
|
1102
|
+
className: q(cr({ size: r }), e),
|
|
1023
1103
|
...i
|
|
1024
1104
|
});
|
|
1025
1105
|
}
|
|
1026
|
-
function
|
|
1027
|
-
return /* @__PURE__ */ Q(
|
|
1106
|
+
function ur({ className: e, ...t }) {
|
|
1107
|
+
return /* @__PURE__ */ Q(Te, {
|
|
1028
1108
|
"data-slot": "input-group-control",
|
|
1029
|
-
className:
|
|
1109
|
+
className: q("flex-1 resize-none rounded-none border-0 bg-transparent py-3 shadow-none focus-visible:ring-0 dark:bg-transparent", e),
|
|
1030
1110
|
...t
|
|
1031
1111
|
});
|
|
1032
1112
|
}
|
|
1033
1113
|
//#endregion
|
|
1034
1114
|
//#region src/elements/prompt-input.tsx
|
|
1035
|
-
var
|
|
1036
|
-
let e = s(
|
|
1115
|
+
var dr = r(null), fr = r(null), pr = () => {
|
|
1116
|
+
let e = s(dr);
|
|
1037
1117
|
if (!e) throw Error("Wrap your component inside <PromptInputProvider> to use usePromptInputController().");
|
|
1038
1118
|
return e;
|
|
1039
|
-
},
|
|
1040
|
-
let e = s(
|
|
1119
|
+
}, mr = () => s(dr), hr = () => {
|
|
1120
|
+
let e = s(fr);
|
|
1041
1121
|
if (!e) throw Error("Wrap your component inside <PromptInputProvider> to use useProviderAttachments().");
|
|
1042
1122
|
return e;
|
|
1043
|
-
},
|
|
1044
|
-
function
|
|
1123
|
+
}, gr = () => s(fr);
|
|
1124
|
+
function _r({ initialInput: e = "", children: t }) {
|
|
1045
1125
|
let [n, r] = d(e), i = o(() => r(""), []), [a, s] = d([]), f = u(null), p = u(() => {}), m = o((e) => {
|
|
1046
1126
|
let t = Array.from(e);
|
|
1047
1127
|
t.length !== 0 && s((e) => e.concat(t.map((e) => ({
|
|
1048
|
-
id:
|
|
1128
|
+
id: kt(),
|
|
1049
1129
|
type: "file",
|
|
1050
1130
|
url: URL.createObjectURL(e),
|
|
1051
1131
|
mediaType: e.type,
|
|
@@ -1096,25 +1176,25 @@ function pr({ initialInput: e = "", children: t }) {
|
|
|
1096
1176
|
y,
|
|
1097
1177
|
b
|
|
1098
1178
|
]);
|
|
1099
|
-
return /* @__PURE__ */ Q(
|
|
1179
|
+
return /* @__PURE__ */ Q(dr.Provider, {
|
|
1100
1180
|
value: x,
|
|
1101
|
-
children: /* @__PURE__ */ Q(
|
|
1181
|
+
children: /* @__PURE__ */ Q(fr.Provider, {
|
|
1102
1182
|
value: y,
|
|
1103
1183
|
children: t
|
|
1104
1184
|
})
|
|
1105
1185
|
});
|
|
1106
1186
|
}
|
|
1107
|
-
var
|
|
1108
|
-
let e =
|
|
1187
|
+
var vr = r(null), yr = () => {
|
|
1188
|
+
let e = gr(), t = s(vr), n = e ?? t;
|
|
1109
1189
|
if (!n) throw Error("usePromptInputAttachments must be used within a PromptInput or PromptInputProvider");
|
|
1110
1190
|
return n;
|
|
1111
1191
|
};
|
|
1112
|
-
function
|
|
1113
|
-
let r =
|
|
1114
|
-
return /* @__PURE__ */ $(
|
|
1192
|
+
function br({ data: e, className: t, ...n }) {
|
|
1193
|
+
let r = yr(), i = e.filename || "", a = (e.mediaType?.startsWith("image/") && e.url ? "image" : "file") == "image", o = i || (a ? "Image" : "Attachment");
|
|
1194
|
+
return /* @__PURE__ */ $(Vr, { children: [/* @__PURE__ */ Q(oe, {
|
|
1115
1195
|
asChild: !0,
|
|
1116
1196
|
children: /* @__PURE__ */ $("div", {
|
|
1117
|
-
className:
|
|
1197
|
+
className: q("group relative flex h-8 cursor-pointer select-none items-center gap-1.5 rounded-md border border-border px-1.5 font-medium text-sm transition-all hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50", t),
|
|
1118
1198
|
...n,
|
|
1119
1199
|
children: [/* @__PURE__ */ $("div", {
|
|
1120
1200
|
className: "relative size-5 shrink-0",
|
|
@@ -1138,7 +1218,7 @@ function gr({ data: e, className: t, ...n }) {
|
|
|
1138
1218
|
},
|
|
1139
1219
|
type: "button",
|
|
1140
1220
|
variant: "ghost",
|
|
1141
|
-
children: [/* @__PURE__ */ Q(
|
|
1221
|
+
children: [/* @__PURE__ */ Q(vt, {}), /* @__PURE__ */ Q("span", {
|
|
1142
1222
|
className: "sr-only",
|
|
1143
1223
|
children: "Remove"
|
|
1144
1224
|
})]
|
|
@@ -1148,7 +1228,7 @@ function gr({ data: e, className: t, ...n }) {
|
|
|
1148
1228
|
children: o
|
|
1149
1229
|
})]
|
|
1150
1230
|
}, e.id)
|
|
1151
|
-
}), /* @__PURE__ */ Q(
|
|
1231
|
+
}), /* @__PURE__ */ Q(Ur, {
|
|
1152
1232
|
className: "w-auto p-2",
|
|
1153
1233
|
children: /* @__PURE__ */ $("div", {
|
|
1154
1234
|
className: "w-auto space-y-3",
|
|
@@ -1177,17 +1257,17 @@ function gr({ data: e, className: t, ...n }) {
|
|
|
1177
1257
|
})
|
|
1178
1258
|
})] });
|
|
1179
1259
|
}
|
|
1180
|
-
function
|
|
1181
|
-
let i =
|
|
1260
|
+
function xr({ children: e, className: t, ...r }) {
|
|
1261
|
+
let i = yr();
|
|
1182
1262
|
return i.files.length ? /* @__PURE__ */ Q("div", {
|
|
1183
|
-
className:
|
|
1263
|
+
className: q("flex flex-wrap items-center gap-2 p-3 w-full", t),
|
|
1184
1264
|
...r,
|
|
1185
1265
|
children: i.files.map((t) => /* @__PURE__ */ Q(n, { children: e(t) }, t.id))
|
|
1186
1266
|
}) : null;
|
|
1187
1267
|
}
|
|
1188
|
-
var
|
|
1189
|
-
let n =
|
|
1190
|
-
return /* @__PURE__ */ $(
|
|
1268
|
+
var Sr = ({ label: e = "Add photos or files", ...t }) => {
|
|
1269
|
+
let n = yr();
|
|
1270
|
+
return /* @__PURE__ */ $(F, {
|
|
1191
1271
|
...t,
|
|
1192
1272
|
onSelect: (e) => {
|
|
1193
1273
|
e.preventDefault(), n.openFileDialog();
|
|
@@ -1198,8 +1278,8 @@ var vr = ({ label: e = "Add photos or files", ...t }) => {
|
|
|
1198
1278
|
e
|
|
1199
1279
|
]
|
|
1200
1280
|
});
|
|
1201
|
-
},
|
|
1202
|
-
let _ =
|
|
1281
|
+
}, Cr = ({ className: e, accept: t, multiple: n, fileInputLabel: r = "Upload files", globalDrop: i, syncHiddenInput: a, maxFiles: s, maxFileSize: f, onError: p, onSubmit: m, children: h, ...g }) => {
|
|
1282
|
+
let _ = mr(), v = !!_, y = u(null), b = u(null), [x, S] = d([]), C = v ? _.attachments.files : x, w = u(C);
|
|
1203
1283
|
w.current = C;
|
|
1204
1284
|
let T = o(() => {
|
|
1205
1285
|
y.current?.click();
|
|
@@ -1234,7 +1314,7 @@ var vr = ({ label: e = "Add photos or files", ...t }) => {
|
|
|
1234
1314
|
});
|
|
1235
1315
|
let i = [];
|
|
1236
1316
|
for (let e of n) i.push({
|
|
1237
|
-
id:
|
|
1317
|
+
id: kt(),
|
|
1238
1318
|
type: "file",
|
|
1239
1319
|
url: URL.createObjectURL(e),
|
|
1240
1320
|
mediaType: e.type,
|
|
@@ -1282,9 +1362,9 @@ var vr = ({ label: e = "Add photos or files", ...t }) => {
|
|
|
1282
1362
|
}, [A, i]), c(() => () => {
|
|
1283
1363
|
if (!v) for (let e of w.current) e.url && URL.revokeObjectURL(e.url);
|
|
1284
1364
|
}, [v]);
|
|
1285
|
-
let
|
|
1365
|
+
let P = (e) => {
|
|
1286
1366
|
e.currentTarget.files && A(e.currentTarget.files), e.currentTarget.value = "";
|
|
1287
|
-
},
|
|
1367
|
+
}, ee = async (e) => {
|
|
1288
1368
|
try {
|
|
1289
1369
|
let t = await (await fetch(e)).blob();
|
|
1290
1370
|
return new Promise((e) => {
|
|
@@ -1294,7 +1374,7 @@ var vr = ({ label: e = "Add photos or files", ...t }) => {
|
|
|
1294
1374
|
} catch {
|
|
1295
1375
|
return null;
|
|
1296
1376
|
}
|
|
1297
|
-
},
|
|
1377
|
+
}, F = l(() => ({
|
|
1298
1378
|
files: C.map((e) => ({
|
|
1299
1379
|
...e,
|
|
1300
1380
|
id: e.id
|
|
@@ -1310,23 +1390,23 @@ var vr = ({ label: e = "Add photos or files", ...t }) => {
|
|
|
1310
1390
|
j,
|
|
1311
1391
|
M,
|
|
1312
1392
|
N
|
|
1313
|
-
]),
|
|
1393
|
+
]), I = /* @__PURE__ */ $(Z, { children: [/* @__PURE__ */ Q("input", {
|
|
1314
1394
|
accept: t,
|
|
1315
1395
|
"aria-label": r,
|
|
1316
1396
|
className: "hidden",
|
|
1317
1397
|
multiple: n,
|
|
1318
|
-
onChange:
|
|
1398
|
+
onChange: P,
|
|
1319
1399
|
ref: y,
|
|
1320
1400
|
title: r,
|
|
1321
1401
|
type: "file"
|
|
1322
1402
|
}), /* @__PURE__ */ Q("form", {
|
|
1323
|
-
className:
|
|
1403
|
+
className: q("w-full", e),
|
|
1324
1404
|
onSubmit: (e) => {
|
|
1325
1405
|
e.preventDefault();
|
|
1326
1406
|
let t = e.currentTarget, n = v ? _.textInput.value : new FormData(t).get("message") || "";
|
|
1327
1407
|
v || t.reset(), Promise.all(C.map(async ({ id: e, ...t }) => {
|
|
1328
1408
|
if (t.url && t.url.startsWith("blob:")) {
|
|
1329
|
-
let e = await
|
|
1409
|
+
let e = await ee(t.url);
|
|
1330
1410
|
return {
|
|
1331
1411
|
...t,
|
|
1332
1412
|
url: e ?? t.url
|
|
@@ -1347,20 +1427,20 @@ var vr = ({ label: e = "Add photos or files", ...t }) => {
|
|
|
1347
1427
|
},
|
|
1348
1428
|
ref: b,
|
|
1349
1429
|
...g,
|
|
1350
|
-
children: /* @__PURE__ */ Q(
|
|
1430
|
+
children: /* @__PURE__ */ Q(ar, {
|
|
1351
1431
|
className: "overflow-hidden",
|
|
1352
1432
|
children: h
|
|
1353
1433
|
})
|
|
1354
1434
|
})] });
|
|
1355
|
-
return v ?
|
|
1356
|
-
value:
|
|
1357
|
-
children:
|
|
1435
|
+
return v ? I : /* @__PURE__ */ Q(vr.Provider, {
|
|
1436
|
+
value: F,
|
|
1437
|
+
children: I
|
|
1358
1438
|
});
|
|
1359
|
-
},
|
|
1360
|
-
className:
|
|
1439
|
+
}, wr = ({ className: e, ...t }) => /* @__PURE__ */ Q("div", {
|
|
1440
|
+
className: q("contents", e),
|
|
1361
1441
|
...t
|
|
1362
|
-
}),
|
|
1363
|
-
let i =
|
|
1442
|
+
}), Tr = ({ onChange: e, className: t, placeholder: n = "What would you like to know?", ...r }) => {
|
|
1443
|
+
let i = mr(), a = yr(), [o, s] = d(!1), c = (e) => {
|
|
1364
1444
|
if (e.key === "Enter") {
|
|
1365
1445
|
if (o || e.nativeEvent.isComposing || e.shiftKey) return;
|
|
1366
1446
|
e.preventDefault();
|
|
@@ -1388,8 +1468,8 @@ var vr = ({ label: e = "Add photos or files", ...t }) => {
|
|
|
1388
1468
|
i.textInput.setInput(t.currentTarget.value), e?.(t);
|
|
1389
1469
|
}
|
|
1390
1470
|
} : { onChange: e };
|
|
1391
|
-
return /* @__PURE__ */ Q(
|
|
1392
|
-
className:
|
|
1471
|
+
return /* @__PURE__ */ Q(ur, {
|
|
1472
|
+
className: q("field-sizing-content max-h-48 min-h-16", t),
|
|
1393
1473
|
name: "message",
|
|
1394
1474
|
onCompositionEnd: () => s(!1),
|
|
1395
1475
|
onCompositionStart: () => s(!0),
|
|
@@ -1399,52 +1479,52 @@ var vr = ({ label: e = "Add photos or files", ...t }) => {
|
|
|
1399
1479
|
...r,
|
|
1400
1480
|
...u
|
|
1401
1481
|
});
|
|
1402
|
-
},
|
|
1482
|
+
}, Er = ({ className: e, ...t }) => /* @__PURE__ */ Q(sr, {
|
|
1403
1483
|
align: "block-end",
|
|
1404
|
-
className:
|
|
1484
|
+
className: q("order-first flex-wrap gap-1", e),
|
|
1405
1485
|
...t
|
|
1406
|
-
}),
|
|
1486
|
+
}), Dr = ({ className: e, ...t }) => /* @__PURE__ */ Q(sr, {
|
|
1407
1487
|
align: "block-end",
|
|
1408
|
-
className:
|
|
1488
|
+
className: q("justify-between gap-1", e),
|
|
1409
1489
|
...t
|
|
1410
|
-
}),
|
|
1411
|
-
className:
|
|
1490
|
+
}), Or = ({ className: e, ...t }) => /* @__PURE__ */ Q("div", {
|
|
1491
|
+
className: q("flex items-center gap-1", e),
|
|
1412
1492
|
...t
|
|
1413
|
-
}),
|
|
1493
|
+
}), kr = ({ variant: e = "ghost", className: n, size: r, ...i }) => {
|
|
1414
1494
|
let a = r ?? (t.count(i.children) > 1 ? "sm" : "icon-sm");
|
|
1415
|
-
return /* @__PURE__ */ Q(
|
|
1416
|
-
className:
|
|
1495
|
+
return /* @__PURE__ */ Q(lr, {
|
|
1496
|
+
className: q(n),
|
|
1417
1497
|
size: a,
|
|
1418
1498
|
type: "button",
|
|
1419
1499
|
variant: e,
|
|
1420
1500
|
...i
|
|
1421
1501
|
});
|
|
1422
|
-
},
|
|
1502
|
+
}, Ar = (e) => /* @__PURE__ */ Q(P, { ...e }), jr = ({ className: e, children: t, ...n }) => /* @__PURE__ */ Q(I, {
|
|
1423
1503
|
asChild: !0,
|
|
1424
|
-
children: /* @__PURE__ */ Q(
|
|
1504
|
+
children: /* @__PURE__ */ Q(kr, {
|
|
1425
1505
|
className: e,
|
|
1426
1506
|
...n,
|
|
1427
1507
|
children: t ?? /* @__PURE__ */ Q(ot, { className: "size-4" })
|
|
1428
1508
|
})
|
|
1429
|
-
}),
|
|
1509
|
+
}), Mr = ({ className: e, ...t }) => /* @__PURE__ */ Q(ee, {
|
|
1430
1510
|
align: "start",
|
|
1431
|
-
className:
|
|
1511
|
+
className: q(e),
|
|
1432
1512
|
...t
|
|
1433
|
-
}),
|
|
1434
|
-
className:
|
|
1513
|
+
}), Nr = ({ className: e, ...t }) => /* @__PURE__ */ Q(F, {
|
|
1514
|
+
className: q(e),
|
|
1435
1515
|
...t
|
|
1436
|
-
}),
|
|
1516
|
+
}), Pr = ({ className: e, variant: t = "default", size: n = "icon-sm", status: r, children: i, ...a }) => {
|
|
1437
1517
|
let o = /* @__PURE__ */ Q(Je, { className: "size-4" });
|
|
1438
|
-
return r === "submitted" ? o = /* @__PURE__ */ Q(tt, { className: "size-4 animate-spin" }) : r === "streaming" ? o = /* @__PURE__ */ Q(dt, { className: "size-4" }) : r === "error" && (o = /* @__PURE__ */ Q(
|
|
1518
|
+
return r === "submitted" ? o = /* @__PURE__ */ Q(tt, { className: "size-4 animate-spin" }) : r === "streaming" ? o = /* @__PURE__ */ Q(dt, { className: "size-4" }) : r === "error" && (o = /* @__PURE__ */ Q(vt, { className: "size-4" })), /* @__PURE__ */ Q(lr, {
|
|
1439
1519
|
"aria-label": "Submit",
|
|
1440
|
-
className:
|
|
1520
|
+
className: q(e),
|
|
1441
1521
|
size: n,
|
|
1442
1522
|
type: "submit",
|
|
1443
1523
|
variant: t,
|
|
1444
1524
|
...a,
|
|
1445
1525
|
children: i ?? o
|
|
1446
1526
|
});
|
|
1447
|
-
},
|
|
1527
|
+
}, Fr = ({ className: e, textareaRef: t, onTranscriptionChange: n, ...r }) => {
|
|
1448
1528
|
let [i, a] = d(!1), [s, l] = d(null), f = u(null);
|
|
1449
1529
|
c(() => {
|
|
1450
1530
|
if (typeof window < "u" && ("SpeechRecognition" in window || "webkitSpeechRecognition" in window)) {
|
|
@@ -1474,80 +1554,80 @@ var vr = ({ label: e = "Add photos or files", ...t }) => {
|
|
|
1474
1554
|
let p = o(() => {
|
|
1475
1555
|
s && (i ? s.stop() : s.start());
|
|
1476
1556
|
}, [s, i]);
|
|
1477
|
-
return /* @__PURE__ */ Q(
|
|
1478
|
-
className:
|
|
1557
|
+
return /* @__PURE__ */ Q(kr, {
|
|
1558
|
+
className: q("relative transition-all duration-200", i && "animate-pulse bg-accent text-accent-foreground", e),
|
|
1479
1559
|
disabled: !s,
|
|
1480
1560
|
onClick: p,
|
|
1481
1561
|
...r,
|
|
1482
1562
|
children: /* @__PURE__ */ Q(rt, { className: "size-4" })
|
|
1483
1563
|
});
|
|
1484
|
-
},
|
|
1485
|
-
className:
|
|
1564
|
+
}, Ir = (e) => /* @__PURE__ */ Q(ue, { ...e }), Lr = ({ className: e, ...t }) => /* @__PURE__ */ Q(pe, {
|
|
1565
|
+
className: q("border-none bg-transparent font-medium text-muted-foreground shadow-none transition-colors", "hover:bg-accent hover:text-foreground aria-expanded:bg-accent aria-expanded:text-foreground", e),
|
|
1486
1566
|
...t
|
|
1487
|
-
}),
|
|
1488
|
-
className:
|
|
1567
|
+
}), Rr = ({ className: e, ...t }) => /* @__PURE__ */ Q(de, {
|
|
1568
|
+
className: q(e),
|
|
1489
1569
|
...t
|
|
1490
|
-
}),
|
|
1491
|
-
className:
|
|
1570
|
+
}), zr = ({ className: e, ...t }) => /* @__PURE__ */ Q(fe, {
|
|
1571
|
+
className: q(e),
|
|
1492
1572
|
...t
|
|
1493
|
-
}),
|
|
1494
|
-
className:
|
|
1573
|
+
}), Br = ({ className: e, ...t }) => /* @__PURE__ */ Q(me, {
|
|
1574
|
+
className: q(e),
|
|
1495
1575
|
...t
|
|
1496
|
-
}),
|
|
1576
|
+
}), Vr = ({ openDelay: e = 0, closeDelay: t = 0, ...n }) => /* @__PURE__ */ Q(R, {
|
|
1497
1577
|
closeDelay: t,
|
|
1498
1578
|
openDelay: e,
|
|
1499
1579
|
...n
|
|
1500
|
-
}),
|
|
1580
|
+
}), Hr = (e) => /* @__PURE__ */ Q(oe, { ...e }), Ur = ({ align: e = "start", ...t }) => /* @__PURE__ */ Q(ae, {
|
|
1501
1581
|
align: e,
|
|
1502
1582
|
...t
|
|
1503
|
-
}),
|
|
1504
|
-
className:
|
|
1583
|
+
}), Wr = ({ className: e, ...t }) => /* @__PURE__ */ Q("div", {
|
|
1584
|
+
className: q(e),
|
|
1505
1585
|
...t
|
|
1506
|
-
}),
|
|
1507
|
-
className:
|
|
1586
|
+
}), Gr = ({ className: e, ...t }) => /* @__PURE__ */ Q("div", {
|
|
1587
|
+
className: q(e),
|
|
1508
1588
|
...t
|
|
1509
|
-
}),
|
|
1510
|
-
className:
|
|
1589
|
+
}), Kr = ({ className: e, ...t }) => /* @__PURE__ */ Q("h3", {
|
|
1590
|
+
className: q("mb-2 px-3 font-medium text-muted-foreground text-xs", e),
|
|
1511
1591
|
...t
|
|
1512
|
-
}),
|
|
1513
|
-
className:
|
|
1592
|
+
}), qr = ({ className: e, ...t }) => /* @__PURE__ */ Q("div", {
|
|
1593
|
+
className: q("space-y-1", e),
|
|
1514
1594
|
...t
|
|
1515
|
-
}),
|
|
1516
|
-
className:
|
|
1595
|
+
}), Jr = ({ className: e, ...t }) => /* @__PURE__ */ Q("div", {
|
|
1596
|
+
className: q("flex items-center gap-2 px-3 py-2 text-xs hover:bg-accent", e),
|
|
1517
1597
|
...t
|
|
1518
|
-
}),
|
|
1519
|
-
className:
|
|
1598
|
+
}), Yr = ({ className: e, ...t }) => /* @__PURE__ */ Q(D, {
|
|
1599
|
+
className: q(e),
|
|
1520
1600
|
...t
|
|
1521
|
-
}),
|
|
1522
|
-
className:
|
|
1601
|
+
}), Xr = ({ className: e, ...t }) => /* @__PURE__ */ Q(A, {
|
|
1602
|
+
className: q(e),
|
|
1523
1603
|
...t
|
|
1524
|
-
}),
|
|
1525
|
-
className:
|
|
1604
|
+
}), Zr = ({ className: e, ...t }) => /* @__PURE__ */ Q(M, {
|
|
1605
|
+
className: q(e),
|
|
1526
1606
|
...t
|
|
1527
|
-
}),
|
|
1528
|
-
className:
|
|
1607
|
+
}), Qr = ({ className: e, ...t }) => /* @__PURE__ */ Q(O, {
|
|
1608
|
+
className: q(e),
|
|
1529
1609
|
...t
|
|
1530
|
-
}),
|
|
1531
|
-
className:
|
|
1610
|
+
}), $r = ({ className: e, ...t }) => /* @__PURE__ */ Q(k, {
|
|
1611
|
+
className: q(e),
|
|
1532
1612
|
...t
|
|
1533
|
-
}),
|
|
1534
|
-
className:
|
|
1613
|
+
}), ei = ({ className: e, ...t }) => /* @__PURE__ */ Q(j, {
|
|
1614
|
+
className: q(e),
|
|
1535
1615
|
...t
|
|
1536
|
-
}),
|
|
1537
|
-
className:
|
|
1616
|
+
}), ti = ({ className: e, ...t }) => /* @__PURE__ */ Q(N, {
|
|
1617
|
+
className: q(e),
|
|
1538
1618
|
...t
|
|
1539
|
-
}),
|
|
1619
|
+
}), ni = ({ className: e, children: t, ...n }) => /* @__PURE__ */ $(ce, {
|
|
1540
1620
|
className: "w-full overflow-x-auto whitespace-nowrap",
|
|
1541
1621
|
...n,
|
|
1542
1622
|
children: [/* @__PURE__ */ Q("div", {
|
|
1543
|
-
className:
|
|
1623
|
+
className: q("flex w-max flex-nowrap items-center gap-2", e),
|
|
1544
1624
|
children: t
|
|
1545
|
-
}), /* @__PURE__ */ Q(
|
|
1625
|
+
}), /* @__PURE__ */ Q(le, {
|
|
1546
1626
|
className: "hidden",
|
|
1547
1627
|
orientation: "horizontal"
|
|
1548
1628
|
})]
|
|
1549
|
-
}),
|
|
1550
|
-
className:
|
|
1629
|
+
}), ri = ({ suggestion: e, onClick: t, className: n, variant: r = "outline", size: i = "sm", children: a, ...o }) => /* @__PURE__ */ Q(v, {
|
|
1630
|
+
className: q("cursor-pointer rounded-full px-4", n),
|
|
1551
1631
|
onClick: () => {
|
|
1552
1632
|
t?.(e);
|
|
1553
1633
|
},
|
|
@@ -1556,7 +1636,7 @@ var vr = ({ label: e = "Add photos or files", ...t }) => {
|
|
|
1556
1636
|
variant: r,
|
|
1557
1637
|
...o,
|
|
1558
1638
|
children: a || e
|
|
1559
|
-
}),
|
|
1639
|
+
}), ii = r({ code: "" }), ai = {
|
|
1560
1640
|
name: "line-numbers",
|
|
1561
1641
|
line(e, t) {
|
|
1562
1642
|
e.children.unshift({
|
|
@@ -1577,21 +1657,21 @@ var vr = ({ label: e = "Add photos or files", ...t }) => {
|
|
|
1577
1657
|
});
|
|
1578
1658
|
}
|
|
1579
1659
|
};
|
|
1580
|
-
async function
|
|
1581
|
-
let r = n ? [
|
|
1582
|
-
return await Promise.all([
|
|
1660
|
+
async function oi(e, t, n = !1) {
|
|
1661
|
+
let r = n ? [ai] : [];
|
|
1662
|
+
return await Promise.all([At(e, {
|
|
1583
1663
|
lang: t,
|
|
1584
1664
|
theme: "one-light",
|
|
1585
1665
|
transformers: r
|
|
1586
|
-
}),
|
|
1666
|
+
}), At(e, {
|
|
1587
1667
|
lang: t,
|
|
1588
1668
|
theme: "one-dark-pro",
|
|
1589
1669
|
transformers: r
|
|
1590
1670
|
})]);
|
|
1591
1671
|
}
|
|
1592
|
-
var
|
|
1672
|
+
var si = ({ code: e, language: t, showLineNumbers: n = !1, className: r, children: i, ...a }) => {
|
|
1593
1673
|
let [o, s] = d(""), [l, f] = d(""), p = u(!1);
|
|
1594
|
-
return c(() => (
|
|
1674
|
+
return c(() => (oi(e, t, n).then(([e, t]) => {
|
|
1595
1675
|
p.current ||= (s(e), f(t), !0);
|
|
1596
1676
|
}), () => {
|
|
1597
1677
|
p.current = !1;
|
|
@@ -1599,10 +1679,10 @@ var ri = ({ code: e, language: t, showLineNumbers: n = !1, className: r, childre
|
|
|
1599
1679
|
e,
|
|
1600
1680
|
t,
|
|
1601
1681
|
n
|
|
1602
|
-
]), /* @__PURE__ */ Q(
|
|
1682
|
+
]), /* @__PURE__ */ Q(ii.Provider, {
|
|
1603
1683
|
value: { code: e },
|
|
1604
1684
|
children: /* @__PURE__ */ Q("div", {
|
|
1605
|
-
className:
|
|
1685
|
+
className: q("group relative w-full overflow-hidden rounded-md border bg-background text-foreground", r),
|
|
1606
1686
|
...a,
|
|
1607
1687
|
children: /* @__PURE__ */ $("div", {
|
|
1608
1688
|
className: "relative",
|
|
@@ -1623,8 +1703,8 @@ var ri = ({ code: e, language: t, showLineNumbers: n = !1, className: r, childre
|
|
|
1623
1703
|
})
|
|
1624
1704
|
})
|
|
1625
1705
|
});
|
|
1626
|
-
},
|
|
1627
|
-
let [o, c] = d(!1), { code: l } = s(
|
|
1706
|
+
}, ci = ({ onCopy: e, onError: t, timeout: n = 2e3, children: r, className: i, ...a }) => {
|
|
1707
|
+
let [o, c] = d(!1), { code: l } = s(ii), u = async () => {
|
|
1628
1708
|
if (typeof window > "u" || !navigator?.clipboard?.writeText) {
|
|
1629
1709
|
t?.(/* @__PURE__ */ Error("Clipboard API not available"));
|
|
1630
1710
|
return;
|
|
@@ -1636,27 +1716,27 @@ var ri = ({ code: e, language: t, showLineNumbers: n = !1, className: r, childre
|
|
|
1636
1716
|
}
|
|
1637
1717
|
}, f = o ? Ie : Ke;
|
|
1638
1718
|
return /* @__PURE__ */ Q(v, {
|
|
1639
|
-
className:
|
|
1719
|
+
className: q("shrink-0", i),
|
|
1640
1720
|
onClick: u,
|
|
1641
1721
|
size: "icon",
|
|
1642
1722
|
variant: "ghost",
|
|
1643
1723
|
...a,
|
|
1644
1724
|
children: r ?? /* @__PURE__ */ Q(f, { size: 14 })
|
|
1645
1725
|
});
|
|
1646
|
-
},
|
|
1647
|
-
className:
|
|
1726
|
+
}, li = ({ className: e, ...t }) => /* @__PURE__ */ Q(w, {
|
|
1727
|
+
className: q("not-prose mb-4 w-full rounded-md border", e),
|
|
1648
1728
|
...t
|
|
1649
|
-
}),
|
|
1729
|
+
}), ui = (e) => /* @__PURE__ */ $(_, {
|
|
1650
1730
|
className: "gap-1.5 rounded-full text-xs",
|
|
1651
1731
|
variant: "secondary",
|
|
1652
1732
|
children: [{
|
|
1653
1733
|
"input-streaming": /* @__PURE__ */ Q(Be, { className: "size-4" }),
|
|
1654
1734
|
"input-available": /* @__PURE__ */ Q(We, { className: "size-4 animate-pulse" }),
|
|
1655
1735
|
"approval-requested": /* @__PURE__ */ Q(We, { className: "size-4 text-yellow-600" }),
|
|
1656
|
-
"approval-responded": /* @__PURE__ */ Q(
|
|
1657
|
-
"output-available": /* @__PURE__ */ Q(
|
|
1658
|
-
"output-error": /* @__PURE__ */ Q(
|
|
1659
|
-
"output-denied": /* @__PURE__ */ Q(
|
|
1736
|
+
"approval-responded": /* @__PURE__ */ Q(Y, { className: "size-4 text-blue-600" }),
|
|
1737
|
+
"output-available": /* @__PURE__ */ Q(Y, { className: "size-4 text-green-600" }),
|
|
1738
|
+
"output-error": /* @__PURE__ */ Q(_t, { className: "size-4 text-red-600" }),
|
|
1739
|
+
"output-denied": /* @__PURE__ */ Q(_t, { className: "size-4 text-orange-600" })
|
|
1660
1740
|
}[e], {
|
|
1661
1741
|
"input-streaming": "Pending",
|
|
1662
1742
|
"input-available": "Running",
|
|
@@ -1666,61 +1746,61 @@ var ri = ({ code: e, language: t, showLineNumbers: n = !1, className: r, childre
|
|
|
1666
1746
|
"output-error": "Error",
|
|
1667
1747
|
"output-denied": "Denied"
|
|
1668
1748
|
}[e]]
|
|
1669
|
-
}),
|
|
1670
|
-
className:
|
|
1749
|
+
}), di = ({ className: e, title: t, type: n, state: r, ...i }) => /* @__PURE__ */ $(E, {
|
|
1750
|
+
className: q("flex w-full items-center justify-between gap-4 p-3", e),
|
|
1671
1751
|
...i,
|
|
1672
1752
|
children: [/* @__PURE__ */ $("div", {
|
|
1673
1753
|
className: "flex items-center gap-2",
|
|
1674
1754
|
children: [
|
|
1675
|
-
/* @__PURE__ */ Q(
|
|
1755
|
+
/* @__PURE__ */ Q(ht, { className: "size-4 text-muted-foreground" }),
|
|
1676
1756
|
/* @__PURE__ */ Q("span", {
|
|
1677
1757
|
className: "font-medium text-sm",
|
|
1678
1758
|
children: t ?? n.split("-").slice(1).join("-")
|
|
1679
1759
|
}),
|
|
1680
|
-
|
|
1760
|
+
ui(r)
|
|
1681
1761
|
]
|
|
1682
1762
|
}), /* @__PURE__ */ Q(Le, { className: "size-4 text-muted-foreground transition-transform group-data-[state=open]:rotate-180" })]
|
|
1683
|
-
}),
|
|
1684
|
-
className:
|
|
1763
|
+
}), fi = ({ className: e, ...t }) => /* @__PURE__ */ Q(T, {
|
|
1764
|
+
className: q("data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 text-popover-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in", e),
|
|
1685
1765
|
...t
|
|
1686
|
-
}),
|
|
1687
|
-
className:
|
|
1766
|
+
}), pi = ({ className: e, input: t, ...n }) => /* @__PURE__ */ $("div", {
|
|
1767
|
+
className: q("space-y-2 overflow-hidden p-4", e),
|
|
1688
1768
|
...n,
|
|
1689
1769
|
children: [/* @__PURE__ */ Q("h4", {
|
|
1690
1770
|
className: "font-medium text-muted-foreground text-xs uppercase tracking-wide",
|
|
1691
1771
|
children: "Parameters"
|
|
1692
1772
|
}), /* @__PURE__ */ Q("div", {
|
|
1693
1773
|
className: "rounded-md bg-muted/50",
|
|
1694
|
-
children: /* @__PURE__ */ Q(
|
|
1774
|
+
children: /* @__PURE__ */ Q(si, {
|
|
1695
1775
|
code: JSON.stringify(t, null, 2),
|
|
1696
1776
|
language: "json"
|
|
1697
1777
|
})
|
|
1698
1778
|
})]
|
|
1699
|
-
}),
|
|
1779
|
+
}), mi = ({ className: e, output: t, errorText: n, ...r }) => {
|
|
1700
1780
|
if (!(t || n)) return null;
|
|
1701
1781
|
let a = /* @__PURE__ */ Q("div", { children: t });
|
|
1702
|
-
return typeof t == "object" && !i(t) ? a = /* @__PURE__ */ Q(
|
|
1782
|
+
return typeof t == "object" && !i(t) ? a = /* @__PURE__ */ Q(si, {
|
|
1703
1783
|
code: JSON.stringify(t, null, 2),
|
|
1704
1784
|
language: "json"
|
|
1705
|
-
}) : typeof t == "string" && (a = /* @__PURE__ */ Q(
|
|
1785
|
+
}) : typeof t == "string" && (a = /* @__PURE__ */ Q(si, {
|
|
1706
1786
|
code: t,
|
|
1707
1787
|
language: "json"
|
|
1708
1788
|
})), /* @__PURE__ */ $("div", {
|
|
1709
|
-
className:
|
|
1789
|
+
className: q("space-y-2 p-4", e),
|
|
1710
1790
|
...r,
|
|
1711
1791
|
children: [/* @__PURE__ */ Q("h4", {
|
|
1712
1792
|
className: "font-medium text-muted-foreground text-xs uppercase tracking-wide",
|
|
1713
1793
|
children: n ? "Error" : "Result"
|
|
1714
1794
|
}), /* @__PURE__ */ $("div", {
|
|
1715
|
-
className:
|
|
1795
|
+
className: q("overflow-x-auto rounded-md text-xs [&_table]:w-full", n ? "bg-destructive/10 text-destructive" : "bg-muted/50 text-foreground"),
|
|
1716
1796
|
children: [n && /* @__PURE__ */ Q("div", { children: n }), a]
|
|
1717
1797
|
})]
|
|
1718
1798
|
});
|
|
1719
|
-
},
|
|
1720
|
-
let a =
|
|
1799
|
+
}, hi = a(({ children: e, as: t = "p", className: n, duration: r = 2, spread: i = 2 }) => {
|
|
1800
|
+
let a = Mt.create(t), o = l(() => (e?.length ?? 0) * i, [e, i]);
|
|
1721
1801
|
return /* @__PURE__ */ Q(a, {
|
|
1722
1802
|
animate: { backgroundPosition: "0% center" },
|
|
1723
|
-
className:
|
|
1803
|
+
className: q("relative inline-block bg-[length:250%_100%,auto] bg-clip-text text-transparent", "[--bg:linear-gradient(90deg,#0000_calc(50%-var(--spread)),var(--color-background),#0000_calc(50%+var(--spread)))] [background-repeat:no-repeat,padding-box]", n),
|
|
1724
1804
|
initial: { backgroundPosition: "100% center" },
|
|
1725
1805
|
style: {
|
|
1726
1806
|
"--spread": `${o}px`,
|
|
@@ -1733,21 +1813,21 @@ var ri = ({ code: e, language: t, showLineNumbers: n = !1, className: r, childre
|
|
|
1733
1813
|
},
|
|
1734
1814
|
children: e
|
|
1735
1815
|
});
|
|
1736
|
-
}),
|
|
1737
|
-
let e = s(
|
|
1816
|
+
}), gi = r(null), _i = () => {
|
|
1817
|
+
let e = s(gi);
|
|
1738
1818
|
if (!e) throw Error("Reasoning components must be used within Reasoning");
|
|
1739
1819
|
return e;
|
|
1740
|
-
},
|
|
1741
|
-
let [l, u] =
|
|
1820
|
+
}, vi = 1e3, yi = 1e3, bi = a(({ className: e, isStreaming: t = !1, open: n, defaultOpen: r = !0, onOpenChange: i, duration: a, children: o, ...s }) => {
|
|
1821
|
+
let [l, u] = jt({
|
|
1742
1822
|
prop: n,
|
|
1743
1823
|
defaultProp: r,
|
|
1744
1824
|
onChange: i
|
|
1745
|
-
}), [f, p] =
|
|
1825
|
+
}), [f, p] = jt({
|
|
1746
1826
|
prop: a,
|
|
1747
1827
|
defaultProp: void 0
|
|
1748
1828
|
}), [m, h] = d(!1), [g, _] = d(null);
|
|
1749
1829
|
return c(() => {
|
|
1750
|
-
t ? g === null && _(Date.now()) : g !== null && (p(Math.ceil((Date.now() - g) /
|
|
1830
|
+
t ? g === null && _(Date.now()) : g !== null && (p(Math.ceil((Date.now() - g) / yi)), _(null));
|
|
1751
1831
|
}, [
|
|
1752
1832
|
t,
|
|
1753
1833
|
g,
|
|
@@ -1756,7 +1836,7 @@ var ri = ({ code: e, language: t, showLineNumbers: n = !1, className: r, childre
|
|
|
1756
1836
|
if (r && !t && l && !m) {
|
|
1757
1837
|
let e = setTimeout(() => {
|
|
1758
1838
|
u(!1), h(!0);
|
|
1759
|
-
},
|
|
1839
|
+
}, vi);
|
|
1760
1840
|
return () => clearTimeout(e);
|
|
1761
1841
|
}
|
|
1762
1842
|
}, [
|
|
@@ -1765,7 +1845,7 @@ var ri = ({ code: e, language: t, showLineNumbers: n = !1, className: r, childre
|
|
|
1765
1845
|
r,
|
|
1766
1846
|
u,
|
|
1767
1847
|
m
|
|
1768
|
-
]), /* @__PURE__ */ Q(
|
|
1848
|
+
]), /* @__PURE__ */ Q(gi.Provider, {
|
|
1769
1849
|
value: {
|
|
1770
1850
|
isStreaming: t,
|
|
1771
1851
|
isOpen: l,
|
|
@@ -1773,7 +1853,7 @@ var ri = ({ code: e, language: t, showLineNumbers: n = !1, className: r, childre
|
|
|
1773
1853
|
duration: f
|
|
1774
1854
|
},
|
|
1775
1855
|
children: /* @__PURE__ */ Q(w, {
|
|
1776
|
-
className:
|
|
1856
|
+
className: q("not-prose mb-4", e),
|
|
1777
1857
|
onOpenChange: (e) => {
|
|
1778
1858
|
u(e);
|
|
1779
1859
|
},
|
|
@@ -1782,37 +1862,37 @@ var ri = ({ code: e, language: t, showLineNumbers: n = !1, className: r, childre
|
|
|
1782
1862
|
children: o
|
|
1783
1863
|
})
|
|
1784
1864
|
});
|
|
1785
|
-
}),
|
|
1865
|
+
}), xi = (e, t) => e || t === 0 ? /* @__PURE__ */ Q(hi, {
|
|
1786
1866
|
duration: 1,
|
|
1787
1867
|
children: "Thinking..."
|
|
1788
1868
|
}) : t === void 0 ? /* @__PURE__ */ Q("p", { children: "Thought for a few seconds" }) : /* @__PURE__ */ $("p", { children: [
|
|
1789
1869
|
"Thought for ",
|
|
1790
1870
|
t,
|
|
1791
1871
|
" seconds"
|
|
1792
|
-
] }),
|
|
1793
|
-
let { isStreaming: i, isOpen: a, duration: o } =
|
|
1872
|
+
] }), Si = a(({ className: e, children: t, getThinkingMessage: n = xi, ...r }) => {
|
|
1873
|
+
let { isStreaming: i, isOpen: a, duration: o } = _i();
|
|
1794
1874
|
return /* @__PURE__ */ Q(E, {
|
|
1795
|
-
className:
|
|
1875
|
+
className: q("flex w-full items-center gap-2 text-muted-foreground text-sm transition-colors hover:text-foreground", e),
|
|
1796
1876
|
...r,
|
|
1797
1877
|
children: t ?? /* @__PURE__ */ $(Z, { children: [
|
|
1798
|
-
/* @__PURE__ */ Q(
|
|
1878
|
+
/* @__PURE__ */ Q(Pe, { className: "size-4" }),
|
|
1799
1879
|
n(i, o),
|
|
1800
|
-
/* @__PURE__ */ Q(Le, { className:
|
|
1880
|
+
/* @__PURE__ */ Q(Le, { className: q("size-4 transition-transform", a ? "rotate-180" : "rotate-0") })
|
|
1801
1881
|
] })
|
|
1802
1882
|
});
|
|
1803
|
-
}),
|
|
1804
|
-
className:
|
|
1883
|
+
}), Ci = a(({ className: e, children: t, ...n }) => /* @__PURE__ */ Q(T, {
|
|
1884
|
+
className: q("mt-4 text-sm", "data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 text-muted-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in", e),
|
|
1805
1885
|
...n,
|
|
1806
|
-
children: /* @__PURE__ */ Q(
|
|
1886
|
+
children: /* @__PURE__ */ Q(Ot, { children: t })
|
|
1807
1887
|
}));
|
|
1808
|
-
|
|
1888
|
+
bi.displayName = "Reasoning", Si.displayName = "ReasoningTrigger", Ci.displayName = "ReasoningContent";
|
|
1809
1889
|
//#endregion
|
|
1810
1890
|
//#region src/elements/sources.tsx
|
|
1811
|
-
var
|
|
1812
|
-
className:
|
|
1891
|
+
var wi = ({ className: e, ...t }) => /* @__PURE__ */ Q(w, {
|
|
1892
|
+
className: q("not-prose mb-4 text-primary text-xs", e),
|
|
1813
1893
|
...t
|
|
1814
|
-
}),
|
|
1815
|
-
className:
|
|
1894
|
+
}), Ti = ({ className: e, count: t, children: n, ...r }) => /* @__PURE__ */ Q(E, {
|
|
1895
|
+
className: q("flex items-center gap-2", e),
|
|
1816
1896
|
...r,
|
|
1817
1897
|
children: n ?? /* @__PURE__ */ $(Z, { children: [/* @__PURE__ */ $("p", {
|
|
1818
1898
|
className: "font-medium",
|
|
@@ -1822,23 +1902,23 @@ var bi = ({ className: e, ...t }) => /* @__PURE__ */ Q(w, {
|
|
|
1822
1902
|
" sources"
|
|
1823
1903
|
]
|
|
1824
1904
|
}), /* @__PURE__ */ Q(Le, { className: "h-4 w-4" })] })
|
|
1825
|
-
}),
|
|
1826
|
-
className:
|
|
1905
|
+
}), Ei = ({ className: e, ...t }) => /* @__PURE__ */ Q(T, {
|
|
1906
|
+
className: q("mt-3 flex w-fit flex-col gap-2", "data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 outline-none data-[state=closed]:animate-out data-[state=open]:animate-in", e),
|
|
1827
1907
|
...t
|
|
1828
|
-
}),
|
|
1908
|
+
}), Di = ({ href: e, title: t, children: n, ...r }) => /* @__PURE__ */ Q("a", {
|
|
1829
1909
|
className: "flex items-center gap-2",
|
|
1830
1910
|
href: e,
|
|
1831
1911
|
rel: "noreferrer",
|
|
1832
1912
|
target: "_blank",
|
|
1833
1913
|
...r,
|
|
1834
|
-
children: n ?? /* @__PURE__ */ $(Z, { children: [/* @__PURE__ */ Q(
|
|
1914
|
+
children: n ?? /* @__PURE__ */ $(Z, { children: [/* @__PURE__ */ Q(Me, { className: "h-4 w-4" }), /* @__PURE__ */ Q("span", {
|
|
1835
1915
|
className: "block font-medium",
|
|
1836
1916
|
children: t
|
|
1837
1917
|
})] })
|
|
1838
1918
|
});
|
|
1839
1919
|
//#endregion
|
|
1840
1920
|
//#region src/ChatbotEnhanced.tsx
|
|
1841
|
-
function
|
|
1921
|
+
function Oi(e) {
|
|
1842
1922
|
let t = e ?? {}, n = t.data && typeof t.data == "object" ? t.data : t, r = n.seedApplied, i = n.probes;
|
|
1843
1923
|
if (!r && !i) return;
|
|
1844
1924
|
let a = {};
|
|
@@ -1852,10 +1932,10 @@ function wi(e) {
|
|
|
1852
1932
|
message: String(e.message)
|
|
1853
1933
|
}))), a;
|
|
1854
1934
|
}
|
|
1855
|
-
function
|
|
1935
|
+
function ki(e) {
|
|
1856
1936
|
return e === "user" ? "user" : "assistant";
|
|
1857
1937
|
}
|
|
1858
|
-
function
|
|
1938
|
+
function Ai(e) {
|
|
1859
1939
|
let t = e.trim();
|
|
1860
1940
|
if (t.length < 2 || !(t.startsWith("{") || t.startsWith("[")) || !(t.endsWith("}") || t.endsWith("]"))) return !1;
|
|
1861
1941
|
try {
|
|
@@ -1864,15 +1944,31 @@ function Ei(e) {
|
|
|
1864
1944
|
return !1;
|
|
1865
1945
|
}
|
|
1866
1946
|
}
|
|
1867
|
-
function
|
|
1947
|
+
function ji(e) {
|
|
1868
1948
|
let t = e.state ?? (e.errorText ? "output-error" : e.result === void 0 ? "input-available" : "output-available");
|
|
1869
1949
|
return t === "output-error" || t === "output-denied" ? "failed" : t === "approval-requested" || t === "approval-responded" ? "awaiting" : t === "output-available" ? "completed" : "running";
|
|
1870
1950
|
}
|
|
1871
|
-
function
|
|
1872
|
-
|
|
1873
|
-
|
|
1951
|
+
function Mi(e) {
|
|
1952
|
+
return [
|
|
1953
|
+
{
|
|
1954
|
+
create_object: "新建对象",
|
|
1955
|
+
add_field: "新增字段",
|
|
1956
|
+
modify_field: "修改字段",
|
|
1957
|
+
delete_field: "删除字段",
|
|
1958
|
+
create_metadata: "新建",
|
|
1959
|
+
update_metadata: "修改",
|
|
1960
|
+
create_seed: "生成示例数据",
|
|
1961
|
+
create_package: "新建应用包"
|
|
1962
|
+
}[e.verb] ?? e.verb,
|
|
1963
|
+
`${e.field ? `${e.object ? `${e.object}.` : ""}${e.field}` : e.object ?? e.name ?? ""}${e.type ? `(${e.type})` : ""}`,
|
|
1964
|
+
e.details
|
|
1965
|
+
].filter(Boolean).join(" ");
|
|
1874
1966
|
}
|
|
1875
|
-
function
|
|
1967
|
+
function Ni(e) {
|
|
1968
|
+
let t = ji(e);
|
|
1969
|
+
return t === "awaiting" || t === "failed" || !!e.pendingActionId || !!e.draftReview?.items.length || !!e.proposedPlan || !!e.proposedChanges;
|
|
1970
|
+
}
|
|
1971
|
+
function Pi(e) {
|
|
1876
1972
|
switch (e) {
|
|
1877
1973
|
case "failed": return 4;
|
|
1878
1974
|
case "awaiting": return 3;
|
|
@@ -1880,17 +1976,17 @@ function ki(e) {
|
|
|
1880
1976
|
case "completed": return 1;
|
|
1881
1977
|
}
|
|
1882
1978
|
}
|
|
1883
|
-
function
|
|
1979
|
+
function Fi(e) {
|
|
1884
1980
|
let t = /* @__PURE__ */ new Map();
|
|
1885
1981
|
for (let n of e) {
|
|
1886
|
-
let e =
|
|
1982
|
+
let e = ji(n), r = `${n.toolName}:${e}`, i = t.get(r);
|
|
1887
1983
|
if (i) {
|
|
1888
1984
|
i.count += 1, i.errorText = i.errorText ?? n.errorText;
|
|
1889
1985
|
continue;
|
|
1890
1986
|
}
|
|
1891
1987
|
t.set(r, {
|
|
1892
1988
|
key: r,
|
|
1893
|
-
title:
|
|
1989
|
+
title: jn(n.toolName) || n.toolName,
|
|
1894
1990
|
rawName: n.toolName,
|
|
1895
1991
|
count: 1,
|
|
1896
1992
|
state: e,
|
|
@@ -1898,11 +1994,11 @@ function Ai(e) {
|
|
|
1898
1994
|
});
|
|
1899
1995
|
}
|
|
1900
1996
|
return Array.from(t.values()).sort((e, t) => {
|
|
1901
|
-
let n =
|
|
1997
|
+
let n = Pi(t.state) - Pi(e.state);
|
|
1902
1998
|
return n === 0 ? e.title.localeCompare(t.title) : n;
|
|
1903
1999
|
});
|
|
1904
2000
|
}
|
|
1905
|
-
function
|
|
2001
|
+
function Ii({ health: e }) {
|
|
1906
2002
|
if (!e) return null;
|
|
1907
2003
|
let t = e.issues ?? [], n = t.filter((e) => e.severity === "error"), r = t.filter((e) => e.severity !== "error"), i = e.checked, a = !!i && i.seeds + i.views + i.widgets > 0, o = [];
|
|
1908
2004
|
if (typeof e.seededRows == "number" && e.seededRows > 0 && !e.seedError && o.push(`${e.seededRows} sample row${e.seededRows === 1 ? "" : "s"} live`), a && n.length === 0) {
|
|
@@ -1915,7 +2011,7 @@ function ji({ health: e }) {
|
|
|
1915
2011
|
children: [
|
|
1916
2012
|
o.length > 0 ? /* @__PURE__ */ $("div", {
|
|
1917
2013
|
className: "flex items-center gap-1.5 text-xs text-emerald-700",
|
|
1918
|
-
children: [/* @__PURE__ */ Q(
|
|
2014
|
+
children: [/* @__PURE__ */ Q(J, { className: "size-3.5 shrink-0" }), /* @__PURE__ */ Q("span", { children: o.join(" · ") })]
|
|
1919
2015
|
}) : null,
|
|
1920
2016
|
e.seedError ? /* @__PURE__ */ $("div", {
|
|
1921
2017
|
className: "flex items-start gap-1.5 text-xs text-red-600",
|
|
@@ -1927,81 +2023,83 @@ function ji({ health: e }) {
|
|
|
1927
2023
|
}, `e${t}`)),
|
|
1928
2024
|
r.map((e, t) => /* @__PURE__ */ $("div", {
|
|
1929
2025
|
className: "flex items-start gap-1.5 text-xs text-amber-600",
|
|
1930
|
-
children: [/* @__PURE__ */ Q(
|
|
2026
|
+
children: [/* @__PURE__ */ Q(ke, { className: "mt-0.5 size-3.5 shrink-0" }), /* @__PURE__ */ Q("span", { children: e.message })]
|
|
1931
2027
|
}, `w${t}`))
|
|
1932
2028
|
]
|
|
1933
2029
|
});
|
|
1934
2030
|
}
|
|
1935
|
-
var
|
|
1936
|
-
let
|
|
1937
|
-
emptyTitle:
|
|
1938
|
-
emptyDescription:
|
|
1939
|
-
clear:
|
|
1940
|
-
sendHint:
|
|
1941
|
-
agentActivity:
|
|
1942
|
-
toolCompleted:
|
|
1943
|
-
toolRunning:
|
|
1944
|
-
toolAwaitingApproval:
|
|
1945
|
-
toolFailed:
|
|
1946
|
-
toolDetailsHidden:
|
|
1947
|
-
copy:
|
|
1948
|
-
copied:
|
|
1949
|
-
regenerate:
|
|
1950
|
-
model:
|
|
1951
|
-
submit:
|
|
1952
|
-
uploadFiles:
|
|
1953
|
-
stopResponse:
|
|
1954
|
-
trace:
|
|
1955
|
-
viewTrace:
|
|
1956
|
-
connectionWaiting:
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
2031
|
+
var Li = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type your message...", onSendMessage: i, onClear: a, onStop: o, onReload: s, onUpgrade: c, disabled: l = !1, readOnly: u = !1, isLoading: d = !1, error: f, showTimestamp: p = !1, showAvatars: m = !1, userAvatarUrl: h, userAvatarFallback: g = "You", assistantAvatarUrl: _, assistantAvatarFallback: v = "AI", hideClearBar: y = !1, maxHeight: b = "500px", enableMarkdown: x = !0, enableFileUpload: S = !1, acceptedFileTypes: C = "image/*,.pdf,.doc,.docx,.txt", maxFileSize: w = 10 * 1024 * 1024, suggestions: T, labels: E, models: D, selectedModelId: O, onModelChange: k, headerSlot: A, promptOverlaySlot: j, onInputChange: M, onToolApprove: N, toolApproveLabel: P = "Approve", toolDenyLabel: ee = "Deny", toolDenyReason: F = "User denied the operation", toolDecisions: I, onReviewDraft: te, toolReviewLabel: ne = (e) => `Review ${e} change${e === 1 ? "" : "s"}`, onPublishDrafts: L, onOpenBuiltApp: re, openBuiltAppLabel: ie = "Open app", onPreviewDraftApp: R, previewDraftLabel: ae = "Preview", onDraftArtifacts: oe, onBuildMaterialized: se, publishDraftsLabel: z = "Publish", publishedLabel: ce = "Published", verifiedLabel: le = "Verified", nextStepsLabel: ue = "What's next", planTitleLabel: de = "Proposed plan", planExtendLabel: fe = "Adding to existing app", planQuestionsLabel: pe = "Confirm before building", planAssumptionsLabel: me = "Assumptions", planApproveHintLabel: he = "Reply to approve or adjust this plan.", planApproveLabel: ge = "Build it", planAdjustLabel: _e = "Adjust", planBuiltLabel: ve = "Built", planApproveMessage: ye = "Looks good — build it as proposed.", planApproveDefaultsMessage: be = "Build it with your best assumptions; use sensible defaults for the open questions.", planAnswerMessage: xe = (e, t) => `For "${e}", go with: ${t}.`, fetchPendingDraftCount: B, autoPublishDrafts: Se = !1, processVisibility: V = "summary", surface: H = "card", ...Ce }, we) => {
|
|
2032
|
+
let U = d ? "streaming" : "ready", W = H === "plain", [G, Te] = e.useState(null), K = e.useMemo(() => ({
|
|
2033
|
+
emptyTitle: E?.emptyTitle ?? "Start a conversation",
|
|
2034
|
+
emptyDescription: E?.emptyDescription ?? "Ask anything — the assistant has access to your current app context.",
|
|
2035
|
+
clear: E?.clear ?? "Clear",
|
|
2036
|
+
sendHint: E?.sendHint ?? "to send",
|
|
2037
|
+
agentActivity: E?.agentActivity ?? "Agent activity",
|
|
2038
|
+
toolCompleted: E?.toolCompleted ?? "Completed",
|
|
2039
|
+
toolRunning: E?.toolRunning ?? "Running",
|
|
2040
|
+
toolAwaitingApproval: E?.toolAwaitingApproval ?? "Awaiting approval",
|
|
2041
|
+
toolFailed: E?.toolFailed ?? "Failed",
|
|
2042
|
+
toolDetailsHidden: E?.toolDetailsHidden ?? "Detailed tool inputs and outputs are hidden in this view.",
|
|
2043
|
+
copy: E?.copy ?? "Copy",
|
|
2044
|
+
copied: E?.copied ?? "Copied",
|
|
2045
|
+
regenerate: E?.regenerate ?? "Regenerate",
|
|
2046
|
+
model: E?.model ?? "Model",
|
|
2047
|
+
submit: E?.submit ?? "Submit",
|
|
2048
|
+
uploadFiles: E?.uploadFiles ?? "Upload files",
|
|
2049
|
+
stopResponse: E?.stopResponse ?? "Stop response",
|
|
2050
|
+
trace: E?.trace ?? "trace",
|
|
2051
|
+
viewTrace: E?.viewTrace ?? "View trace",
|
|
2052
|
+
connectionWaiting: E?.connectionWaiting ?? "Waiting for server…",
|
|
2053
|
+
connectionStalledLabel: E?.connectionStalledLabel ?? "Still working…",
|
|
2054
|
+
connectionOfflineLabel: E?.connectionOfflineLabel ?? "Connection lost — reconnecting…"
|
|
2055
|
+
}), [E]), [Ee, De] = e.useState(() => /* @__PURE__ */ new Set()), [Oe, Ae] = e.useState(() => /* @__PURE__ */ new Map()), [je, Me] = e.useState(() => /* @__PURE__ */ new Map()), Pe = e.useRef(/* @__PURE__ */ new Set()), Y = e.useCallback(async (e) => {
|
|
2056
|
+
if (B) try {
|
|
2057
|
+
let t = await B(e);
|
|
2058
|
+
Me((n) => {
|
|
1961
2059
|
if (n.get(e) === t) return n;
|
|
1962
2060
|
let r = new Map(n);
|
|
1963
2061
|
return r.set(e, t), r;
|
|
1964
2062
|
});
|
|
1965
2063
|
} catch {}
|
|
1966
|
-
}, [
|
|
2064
|
+
}, [B]);
|
|
1967
2065
|
e.useEffect(() => {
|
|
1968
|
-
if (!
|
|
2066
|
+
if (!B || d) return;
|
|
1969
2067
|
let e = /* @__PURE__ */ new Set();
|
|
1970
2068
|
for (let t of n) for (let n of t.toolInvocations ?? []) {
|
|
1971
2069
|
let t = n.draftReview?.packageId, r = n.toolCallId;
|
|
1972
|
-
t && r && !
|
|
2070
|
+
t && r && !Pe.current.has(r) && (Pe.current.add(r), e.add(t));
|
|
1973
2071
|
}
|
|
1974
|
-
for (let t of e)
|
|
2072
|
+
for (let t of e) Y(t);
|
|
1975
2073
|
}, [
|
|
1976
2074
|
n,
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
2075
|
+
d,
|
|
2076
|
+
B,
|
|
2077
|
+
Y
|
|
1980
2078
|
]);
|
|
1981
|
-
let
|
|
1982
|
-
if (!
|
|
2079
|
+
let Ie = e.useCallback(async (e) => {
|
|
2080
|
+
if (!L) return;
|
|
1983
2081
|
let t = [];
|
|
1984
2082
|
for (let r of n) for (let n of r.toolInvocations ?? []) n.draftReview?.packageId === e && n.toolCallId && t.push(n.toolCallId);
|
|
1985
|
-
let r = await
|
|
2083
|
+
let r = await L(e), i = r && typeof r == "object" ? r : void 0;
|
|
1986
2084
|
if ((i ? i.ok !== !1 : r !== !1) && t.length > 0) {
|
|
1987
|
-
|
|
2085
|
+
De((e) => {
|
|
1988
2086
|
let n = new Set(e);
|
|
1989
2087
|
for (let e of t) n.add(e);
|
|
1990
2088
|
return n;
|
|
1991
2089
|
});
|
|
1992
2090
|
let e = i?.health;
|
|
1993
|
-
e &&
|
|
2091
|
+
e && Ae((n) => {
|
|
1994
2092
|
let r = new Map(n);
|
|
1995
2093
|
for (let n of t) r.set(n, e);
|
|
1996
2094
|
return r;
|
|
1997
2095
|
});
|
|
1998
2096
|
}
|
|
1999
|
-
|
|
2097
|
+
Y(e);
|
|
2000
2098
|
}, [
|
|
2001
|
-
|
|
2099
|
+
L,
|
|
2002
2100
|
n,
|
|
2003
|
-
|
|
2004
|
-
]),
|
|
2101
|
+
Y
|
|
2102
|
+
]), Le = e.useRef(/* @__PURE__ */ new Set()), Re = e.useRef(!1);
|
|
2005
2103
|
e.useEffect(() => {
|
|
2006
2104
|
let e = [];
|
|
2007
2105
|
for (let t of n) for (let n of t.toolInvocations ?? []) {
|
|
@@ -2011,78 +2109,106 @@ var Mi = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2011
2109
|
packageId: t.packageId
|
|
2012
2110
|
});
|
|
2013
2111
|
}
|
|
2014
|
-
if (!
|
|
2015
|
-
|
|
2016
|
-
for (let t of e)
|
|
2112
|
+
if (!Re.current) {
|
|
2113
|
+
Re.current = !0;
|
|
2114
|
+
for (let t of e) Le.current.add(t.key);
|
|
2017
2115
|
return;
|
|
2018
2116
|
}
|
|
2019
|
-
if (!
|
|
2020
|
-
let t = e.filter((e) => !
|
|
2117
|
+
if (!Se || !L || d) return;
|
|
2118
|
+
let t = e.filter((e) => !Le.current.has(e.key));
|
|
2021
2119
|
if (t.length !== 0) {
|
|
2022
|
-
for (let e of t)
|
|
2023
|
-
for (let e of [...new Set(t.map((e) => e.packageId))])
|
|
2120
|
+
for (let e of t) Le.current.add(e.key);
|
|
2121
|
+
for (let e of [...new Set(t.map((e) => e.packageId))]) Ie(e);
|
|
2024
2122
|
}
|
|
2025
2123
|
}, [
|
|
2026
2124
|
n,
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2125
|
+
d,
|
|
2126
|
+
Se,
|
|
2127
|
+
L,
|
|
2128
|
+
Ie
|
|
2031
2129
|
]);
|
|
2032
|
-
let
|
|
2130
|
+
let ze = e.useRef(/* @__PURE__ */ new Set());
|
|
2033
2131
|
e.useEffect(() => {
|
|
2034
|
-
if (!
|
|
2035
|
-
let e = /* @__PURE__ */ new Map();
|
|
2036
|
-
for (let
|
|
2037
|
-
for (let
|
|
2038
|
-
for (let n of
|
|
2132
|
+
if (!oe) return;
|
|
2133
|
+
let e = /* @__PURE__ */ new Map(), t;
|
|
2134
|
+
for (let r of n) {
|
|
2135
|
+
for (let t of r.buildProgress?.items ?? []) t?.type && t?.name && e.set(`${t.type}:${t.name}`, t);
|
|
2136
|
+
for (let n of r.toolInvocations ?? []) {
|
|
2137
|
+
let r = n.draftReview;
|
|
2138
|
+
for (let t of r?.items ?? []) t?.type && t?.name && e.set(`${t.type}:${t.name}`, t);
|
|
2139
|
+
r?.packageId && r.items?.some((e) => e.type === "app") && (t = r.packageId);
|
|
2140
|
+
}
|
|
2039
2141
|
}
|
|
2040
|
-
let
|
|
2041
|
-
for (let
|
|
2042
|
-
|
|
2043
|
-
}, [n,
|
|
2044
|
-
let
|
|
2142
|
+
let r = ze.current, i = !1;
|
|
2143
|
+
for (let t of e.keys()) r.has(t) || (r.add(t), i = !0);
|
|
2144
|
+
i && oe([...e.values()], t);
|
|
2145
|
+
}, [n, oe]);
|
|
2146
|
+
let Be = e.useRef(/* @__PURE__ */ new Set());
|
|
2045
2147
|
e.useEffect(() => {
|
|
2046
|
-
if (
|
|
2148
|
+
if (se) for (let e of n) for (let t of e.toolInvocations ?? []) {
|
|
2047
2149
|
let e = t.draftReview;
|
|
2048
2150
|
if (!e?.materialized || !t.toolCallId) continue;
|
|
2049
2151
|
let n = e.items.find((e) => e.type === "app");
|
|
2050
|
-
!n ||
|
|
2152
|
+
!n || Be.current.has(t.toolCallId) || (Be.current.add(t.toolCallId), se(n.name));
|
|
2051
2153
|
}
|
|
2052
|
-
}, [n,
|
|
2053
|
-
let
|
|
2154
|
+
}, [n, se]);
|
|
2155
|
+
let He = e.useCallback((e) => {
|
|
2054
2156
|
let t = !!e.text?.trim(), n = e.files?.map((e) => e.file).filter(Boolean), r = !!(n && n.length > 0);
|
|
2055
2157
|
(t || r) && i?.(e.text?.trim() ?? "", n);
|
|
2056
|
-
}, [i]),
|
|
2158
|
+
}, [i]), Ue = e.useCallback((e) => {
|
|
2057
2159
|
i?.(e);
|
|
2058
|
-
}, [i]),
|
|
2059
|
-
i?.(e ?
|
|
2160
|
+
}, [i]), We = e.useRef(null), Ke = e.useCallback((e) => {
|
|
2161
|
+
i?.(e ? be : ye);
|
|
2060
2162
|
}, [
|
|
2061
2163
|
i,
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
]),
|
|
2065
|
-
let e =
|
|
2164
|
+
ye,
|
|
2165
|
+
be
|
|
2166
|
+
]), Je = e.useCallback(() => {
|
|
2167
|
+
let e = We.current?.querySelector("textarea");
|
|
2066
2168
|
e && (e.focus(), e.scrollIntoView({ block: "nearest" }));
|
|
2067
|
-
}, []),
|
|
2068
|
-
navigator.clipboard?.writeText(e.content),
|
|
2069
|
-
}, []),
|
|
2070
|
-
let
|
|
2169
|
+
}, []), Qe = e.useCallback((e) => {
|
|
2170
|
+
navigator.clipboard?.writeText(e.content), Te(e.id), window.setTimeout(() => Te((t) => t === e.id ? null : t), 1500);
|
|
2171
|
+
}, []), $e = e.useMemo(() => {
|
|
2172
|
+
let e = /* @__PURE__ */ new Set(), t = [], r = -1, i = 0;
|
|
2173
|
+
for (let e of n) for (let n of e.toolInvocations ?? []) n.proposedPlan && n.toolCallId && t.push({
|
|
2174
|
+
id: n.toolCallId,
|
|
2175
|
+
order: i
|
|
2176
|
+
}), n.toolName === "apply_blueprint" && (r = i), i += 1;
|
|
2177
|
+
for (let n of t) n.order < r && e.add(n.id);
|
|
2178
|
+
return e;
|
|
2179
|
+
}, [n]), et = e.useMemo(() => {
|
|
2180
|
+
let e = /* @__PURE__ */ new Set(), t = [], r = /* @__PURE__ */ new Map(), i = 0;
|
|
2181
|
+
for (let e of n) for (let n of e.toolInvocations ?? []) n.proposedChanges && n.toolCallId ? t.push({
|
|
2182
|
+
id: n.toolCallId,
|
|
2183
|
+
toolName: n.toolName ?? "",
|
|
2184
|
+
order: i
|
|
2185
|
+
}) : n.toolName && r.set(n.toolName, i), i += 1;
|
|
2186
|
+
for (let n of t) {
|
|
2187
|
+
let t = r.get(n.toolName);
|
|
2188
|
+
t !== void 0 && t > n.order && e.add(n.id);
|
|
2189
|
+
}
|
|
2190
|
+
return e;
|
|
2191
|
+
}, [n]), tt = (e) => {
|
|
2192
|
+
let t = e.state ?? (e.errorText ? "output-error" : e.result === void 0 ? "input-available" : "output-available"), n = `tool-${e.toolName}`, r = I?.[e.toolCallId], a = t === "approval-requested" && !!N && !r, o = t === "approval-requested" && !!e.pendingActionId, s = jn(e.toolName), c = Mn(e.result), l = V === "debug" && s && s.toLowerCase() !== e.toolName.toLowerCase(), u = V === "debug" || a, d = e.draftReview?.packageId, f = d === void 0 ? void 0 : je.get(d), p = f === void 0 ? Ee.has(e.toolCallId) : f === 0, m = t === "input-streaming" || t === "input-available", h = /* @__PURE__ */ $("span", {
|
|
2071
2193
|
className: "inline-flex items-center gap-2",
|
|
2072
|
-
children: [
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2194
|
+
children: [
|
|
2195
|
+
/* @__PURE__ */ Q("span", { children: s || e.toolName }),
|
|
2196
|
+
l ? /* @__PURE__ */ Q("code", {
|
|
2197
|
+
className: "rounded bg-muted px-1 py-px text-[10px] font-mono text-muted-foreground",
|
|
2198
|
+
children: e.toolName
|
|
2199
|
+
}) : null,
|
|
2200
|
+
m ? /* @__PURE__ */ Q(Ki, { offlineLabel: K.connectionOfflineLabel }) : null
|
|
2201
|
+
]
|
|
2076
2202
|
});
|
|
2077
|
-
return /* @__PURE__ */ $(
|
|
2078
|
-
defaultOpen: t === "output-error" || t === "approval-requested" || !!(e.draftReview && e.draftReview.items.length > 0) || !!e.proposedPlan,
|
|
2079
|
-
children: [/* @__PURE__ */ Q(
|
|
2203
|
+
return /* @__PURE__ */ $(li, {
|
|
2204
|
+
defaultOpen: t === "output-error" || t === "approval-requested" || !!(e.draftReview && e.draftReview.items.length > 0) || !!e.proposedPlan || !!e.proposedChanges,
|
|
2205
|
+
children: [/* @__PURE__ */ Q(di, {
|
|
2080
2206
|
type: n,
|
|
2081
2207
|
state: t,
|
|
2082
|
-
title:
|
|
2083
|
-
}), /* @__PURE__ */ $(
|
|
2084
|
-
u && e.args !== void 0 ? /* @__PURE__ */ Q(
|
|
2085
|
-
o ? null : u || t === "output-error" ? /* @__PURE__ */ Q(
|
|
2208
|
+
title: h
|
|
2209
|
+
}), /* @__PURE__ */ $(fi, { children: [
|
|
2210
|
+
u && e.args !== void 0 ? /* @__PURE__ */ Q(pi, { input: e.args }) : null,
|
|
2211
|
+
o ? null : u || t === "output-error" ? /* @__PURE__ */ Q(ea, {
|
|
2086
2212
|
output: c,
|
|
2087
2213
|
errorText: e.errorText
|
|
2088
2214
|
}) : null,
|
|
@@ -2097,52 +2223,55 @@ var Mi = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2097
2223
|
className: "flex gap-2 p-3 border-t bg-muted/30",
|
|
2098
2224
|
children: [/* @__PURE__ */ Q("button", {
|
|
2099
2225
|
type: "button",
|
|
2100
|
-
onClick: () =>
|
|
2226
|
+
onClick: () => N?.(e.toolCallId, !0),
|
|
2101
2227
|
className: "inline-flex h-7 items-center rounded-md bg-primary px-3 text-xs font-medium text-primary-foreground hover:bg-primary/90",
|
|
2102
|
-
children:
|
|
2228
|
+
children: P
|
|
2103
2229
|
}), /* @__PURE__ */ Q("button", {
|
|
2104
2230
|
type: "button",
|
|
2105
|
-
onClick: () =>
|
|
2231
|
+
onClick: () => N?.(e.toolCallId, !1, F),
|
|
2106
2232
|
className: "inline-flex h-7 items-center rounded-md border bg-background px-3 text-xs font-medium hover:bg-accent",
|
|
2107
2233
|
children: ee
|
|
2108
2234
|
})]
|
|
2109
2235
|
}) : null,
|
|
2110
|
-
e.draftReview && e.draftReview.items.length > 0 && (
|
|
2236
|
+
e.draftReview && e.draftReview.items.length > 0 && (te || L && e.draftReview.packageId) ? /* @__PURE__ */ $(Z, { children: [
|
|
2111
2237
|
/* @__PURE__ */ $("div", {
|
|
2112
2238
|
className: "flex items-center gap-2 p-3 border-t bg-muted/30",
|
|
2113
2239
|
children: [
|
|
2114
|
-
|
|
2240
|
+
L && e.draftReview.packageId ? p ? /* @__PURE__ */ $("span", {
|
|
2115
2241
|
className: "inline-flex h-7 items-center gap-1.5 rounded-md border border-emerald-200 bg-emerald-50 px-3 text-xs font-medium text-emerald-700",
|
|
2116
2242
|
children: [
|
|
2117
|
-
/* @__PURE__ */ Q(
|
|
2118
|
-
|
|
2243
|
+
/* @__PURE__ */ Q(J, { className: "size-3.5" }),
|
|
2244
|
+
ce,
|
|
2119
2245
|
e.draftReview.failedCount ? ` · ${e.draftReview.failedCount} need${e.draftReview.failedCount === 1 ? "s" : ""} attention` : ""
|
|
2120
2246
|
]
|
|
2121
2247
|
}) : /* @__PURE__ */ $("button", {
|
|
2122
2248
|
type: "button",
|
|
2123
|
-
onClick: () => void
|
|
2249
|
+
onClick: () => void Ie(e.draftReview.packageId),
|
|
2124
2250
|
className: "inline-flex h-7 items-center gap-1.5 rounded-md bg-primary px-3 text-xs font-medium text-primary-foreground hover:bg-primary/90",
|
|
2125
2251
|
"data-testid": "draft-publish",
|
|
2126
2252
|
children: [
|
|
2127
2253
|
/* @__PURE__ */ Q(ct, { className: "size-3.5" }),
|
|
2128
|
-
|
|
2254
|
+
z,
|
|
2129
2255
|
typeof f == "number" && f > 0 ? ` (${f})` : ""
|
|
2130
2256
|
]
|
|
2131
2257
|
}) : null,
|
|
2132
|
-
|
|
2258
|
+
te ? /* @__PURE__ */ $("button", {
|
|
2133
2259
|
type: "button",
|
|
2134
|
-
onClick: () =>
|
|
2135
|
-
className:
|
|
2260
|
+
onClick: () => te(e.draftReview.items),
|
|
2261
|
+
className: L && e.draftReview.packageId ? "inline-flex h-7 items-center gap-1.5 rounded-md border px-3 text-xs font-medium hover:bg-muted" : "inline-flex h-7 items-center gap-1.5 rounded-md bg-primary px-3 text-xs font-medium text-primary-foreground hover:bg-primary/90",
|
|
2136
2262
|
children: [/* @__PURE__ */ Q(Xe, { className: "size-3.5" }), ne(e.draftReview.items.length)]
|
|
2137
2263
|
}) : null,
|
|
2138
|
-
|
|
2264
|
+
R && !p ? (() => {
|
|
2139
2265
|
let t = e.draftReview.items.find((e) => e.type === "app");
|
|
2140
2266
|
return t ? /* @__PURE__ */ $("button", {
|
|
2141
2267
|
type: "button",
|
|
2142
|
-
onClick: () =>
|
|
2268
|
+
onClick: () => R(t.name, {
|
|
2269
|
+
materialized: e.draftReview.materialized === !0,
|
|
2270
|
+
appSegment: e.draftReview.packageId
|
|
2271
|
+
}),
|
|
2143
2272
|
className: "inline-flex h-7 items-center gap-1.5 rounded-md border px-3 text-xs font-medium hover:bg-muted",
|
|
2144
2273
|
"data-testid": "draft-preview-app",
|
|
2145
|
-
children: [/* @__PURE__ */ Q(Ye, { className: "size-3.5" }),
|
|
2274
|
+
children: [/* @__PURE__ */ Q(Ye, { className: "size-3.5" }), ae]
|
|
2146
2275
|
}) : null;
|
|
2147
2276
|
})() : null,
|
|
2148
2277
|
e.draftReview.verification ? e.draftReview.verification.errors > 0 ? /* @__PURE__ */ $("span", {
|
|
@@ -2152,7 +2281,7 @@ var Mi = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2152
2281
|
}) : /* @__PURE__ */ $("span", {
|
|
2153
2282
|
className: "inline-flex h-7 shrink-0 items-center gap-1.5 rounded-md border border-emerald-200 bg-emerald-50 px-2.5 text-xs font-medium text-emerald-700",
|
|
2154
2283
|
"data-testid": "draft-verification-chip",
|
|
2155
|
-
children: [/* @__PURE__ */ Q(ut, { className: "size-3.5" }),
|
|
2284
|
+
children: [/* @__PURE__ */ Q(ut, { className: "size-3.5" }), le]
|
|
2156
2285
|
}) : null,
|
|
2157
2286
|
e.draftReview.summary ? /* @__PURE__ */ Q("span", {
|
|
2158
2287
|
className: "truncate text-xs text-muted-foreground",
|
|
@@ -2168,16 +2297,16 @@ var Mi = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2168
2297
|
children: [/* @__PURE__ */ Q(X, { className: "mt-0.5 size-3.5 shrink-0" }), /* @__PURE__ */ Q("span", { children: e.fix ? `${e.message} — ${e.fix}` : e.message })]
|
|
2169
2298
|
}, `e${t}`)), e.draftReview.issues.filter((e) => e.severity !== "error").map((e, t) => /* @__PURE__ */ $("div", {
|
|
2170
2299
|
className: "flex items-start gap-1.5 text-xs text-amber-600",
|
|
2171
|
-
children: [/* @__PURE__ */ Q(
|
|
2300
|
+
children: [/* @__PURE__ */ Q(ke, { className: "mt-0.5 size-3.5 shrink-0" }), /* @__PURE__ */ Q("span", { children: e.message })]
|
|
2172
2301
|
}, `w${t}`))]
|
|
2173
2302
|
}) : null,
|
|
2174
|
-
|
|
2303
|
+
Ee.has(e.toolCallId) ? /* @__PURE__ */ Q(Ii, { health: Oe.get(e.toolCallId) }) : null,
|
|
2175
2304
|
e.draftReview.nextSteps && e.draftReview.nextSteps.length > 0 ? /* @__PURE__ */ $("div", {
|
|
2176
2305
|
className: "flex flex-col gap-1 border-t bg-muted/20 px-3 py-2",
|
|
2177
2306
|
"data-testid": "draft-next-steps",
|
|
2178
2307
|
children: [/* @__PURE__ */ Q("span", {
|
|
2179
2308
|
className: "text-xs font-medium text-foreground/80",
|
|
2180
|
-
children:
|
|
2309
|
+
children: ue
|
|
2181
2310
|
}), e.draftReview.nextSteps.map((e, t) => /* @__PURE__ */ $("div", {
|
|
2182
2311
|
className: "flex items-start gap-1.5 text-xs text-muted-foreground",
|
|
2183
2312
|
children: [/* @__PURE__ */ Q("span", {
|
|
@@ -2193,8 +2322,19 @@ var Mi = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2193
2322
|
children: [
|
|
2194
2323
|
/* @__PURE__ */ $("span", {
|
|
2195
2324
|
className: "inline-flex items-center gap-1.5 text-xs font-medium text-foreground/80",
|
|
2196
|
-
children: [/* @__PURE__ */ Q(Ve, { className: "size-3.5" }),
|
|
2325
|
+
children: [/* @__PURE__ */ Q(Ve, { className: "size-3.5" }), de]
|
|
2197
2326
|
}),
|
|
2327
|
+
e.proposedPlan.targetApp ? /* @__PURE__ */ $("span", {
|
|
2328
|
+
className: "inline-flex w-fit items-center gap-1 rounded-md border border-blue-200 bg-blue-50 px-2 py-0.5 text-[11px] font-medium text-blue-700 dark:border-blue-900/50 dark:bg-blue-950/30 dark:text-blue-300",
|
|
2329
|
+
"data-testid": "proposed-plan-extend",
|
|
2330
|
+
children: [
|
|
2331
|
+
"+ ",
|
|
2332
|
+
fe,
|
|
2333
|
+
" 「",
|
|
2334
|
+
e.proposedPlan.targetApp,
|
|
2335
|
+
"」"
|
|
2336
|
+
]
|
|
2337
|
+
}) : null,
|
|
2198
2338
|
e.proposedPlan.summary ? /* @__PURE__ */ Q("p", {
|
|
2199
2339
|
className: "text-xs text-muted-foreground",
|
|
2200
2340
|
children: e.proposedPlan.summary
|
|
@@ -2225,7 +2365,7 @@ var Mi = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2225
2365
|
className: "flex flex-col gap-0.5",
|
|
2226
2366
|
children: [/* @__PURE__ */ Q("span", {
|
|
2227
2367
|
className: "text-[11px] font-medium text-foreground/70",
|
|
2228
|
-
children:
|
|
2368
|
+
children: me
|
|
2229
2369
|
}), e.proposedPlan.assumptions.map((e, t) => /* @__PURE__ */ $("div", {
|
|
2230
2370
|
className: "flex items-start gap-1.5 text-[11px] text-muted-foreground",
|
|
2231
2371
|
children: [/* @__PURE__ */ Q("span", {
|
|
@@ -2239,7 +2379,7 @@ var Mi = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2239
2379
|
"data-testid": "proposed-plan-questions",
|
|
2240
2380
|
children: [/* @__PURE__ */ $("span", {
|
|
2241
2381
|
className: "inline-flex items-center gap-1.5 text-[11px] font-medium text-amber-800 dark:text-amber-300",
|
|
2242
|
-
children: [/* @__PURE__ */ Q(Ze, { className: "size-3.5" }),
|
|
2382
|
+
children: [/* @__PURE__ */ Q(Ze, { className: "size-3.5" }), pe]
|
|
2243
2383
|
}), e.proposedPlan.questions.map((t, n) => {
|
|
2244
2384
|
let r = e.proposedPlan.questionChoices?.find((e) => e.text === t);
|
|
2245
2385
|
return /* @__PURE__ */ $("div", {
|
|
@@ -2255,7 +2395,7 @@ var Mi = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2255
2395
|
"data-testid": "proposed-plan-choice",
|
|
2256
2396
|
children: r.options.map((e, n) => /* @__PURE__ */ Q("button", {
|
|
2257
2397
|
type: "button",
|
|
2258
|
-
onClick: () => i(
|
|
2398
|
+
onClick: () => i(xe(t, e)),
|
|
2259
2399
|
className: "inline-flex h-6 items-center rounded-full border border-amber-300 bg-background px-2 text-[11px] font-medium text-amber-900 hover:bg-amber-100 dark:border-amber-800 dark:text-amber-200 dark:hover:bg-amber-900/40",
|
|
2260
2400
|
children: e
|
|
2261
2401
|
}, n))
|
|
@@ -2263,25 +2403,82 @@ var Mi = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2263
2403
|
}, n);
|
|
2264
2404
|
})]
|
|
2265
2405
|
}) : null,
|
|
2266
|
-
i ? /* @__PURE__ */
|
|
2406
|
+
i ? $e.has(e.toolCallId) ? /* @__PURE__ */ Q("div", {
|
|
2407
|
+
className: "flex flex-wrap items-center gap-1.5 pt-0.5",
|
|
2408
|
+
"data-testid": "proposed-plan-actions",
|
|
2409
|
+
children: /* @__PURE__ */ $("span", {
|
|
2410
|
+
className: "inline-flex h-7 items-center gap-1.5 rounded-md border border-emerald-200 bg-emerald-50 px-3 text-xs font-medium text-emerald-700 dark:border-emerald-900/50 dark:bg-emerald-950/30 dark:text-emerald-300",
|
|
2411
|
+
"data-testid": "proposed-plan-built",
|
|
2412
|
+
children: [/* @__PURE__ */ Q(J, { className: "size-3.5" }), ve]
|
|
2413
|
+
})
|
|
2414
|
+
}) : /* @__PURE__ */ $("div", {
|
|
2267
2415
|
className: "flex flex-wrap items-center gap-1.5 pt-0.5",
|
|
2268
2416
|
"data-testid": "proposed-plan-actions",
|
|
2269
2417
|
children: [/* @__PURE__ */ $("button", {
|
|
2270
2418
|
type: "button",
|
|
2271
|
-
onClick: () =>
|
|
2419
|
+
onClick: () => Ke(e.proposedPlan.questions.length > 0),
|
|
2272
2420
|
className: "inline-flex h-7 items-center gap-1.5 rounded-md bg-primary px-3 text-xs font-medium text-primary-foreground hover:bg-primary/90",
|
|
2273
2421
|
"data-testid": "proposed-plan-approve",
|
|
2274
|
-
children: [/* @__PURE__ */ Q(ct, { className: "size-3.5" }),
|
|
2422
|
+
children: [/* @__PURE__ */ Q(ct, { className: "size-3.5" }), ge]
|
|
2275
2423
|
}), /* @__PURE__ */ Q("button", {
|
|
2276
2424
|
type: "button",
|
|
2277
|
-
onClick:
|
|
2425
|
+
onClick: Je,
|
|
2278
2426
|
className: "inline-flex h-7 items-center rounded-md border bg-background px-3 text-xs font-medium hover:bg-accent",
|
|
2279
2427
|
"data-testid": "proposed-plan-adjust",
|
|
2280
|
-
children:
|
|
2428
|
+
children: _e
|
|
2429
|
+
})]
|
|
2430
|
+
}) : /* @__PURE__ */ Q("span", {
|
|
2431
|
+
className: "text-[11px] italic text-muted-foreground/80",
|
|
2432
|
+
children: he
|
|
2433
|
+
})
|
|
2434
|
+
]
|
|
2435
|
+
}) : null,
|
|
2436
|
+
e.proposedChanges ? /* @__PURE__ */ $("div", {
|
|
2437
|
+
className: "flex flex-col gap-2 border-t bg-muted/20 px-3 py-2.5",
|
|
2438
|
+
"data-testid": "proposed-changes",
|
|
2439
|
+
children: [
|
|
2440
|
+
/* @__PURE__ */ $("span", {
|
|
2441
|
+
className: "inline-flex items-center gap-1.5 text-xs font-medium text-foreground/80",
|
|
2442
|
+
children: [/* @__PURE__ */ Q(Ve, { className: "size-3.5" }), "确认改动"]
|
|
2443
|
+
}),
|
|
2444
|
+
e.proposedChanges.summary ? /* @__PURE__ */ Q("p", {
|
|
2445
|
+
className: "text-xs text-muted-foreground",
|
|
2446
|
+
children: e.proposedChanges.summary
|
|
2447
|
+
}) : null,
|
|
2448
|
+
/* @__PURE__ */ Q("div", {
|
|
2449
|
+
className: "flex flex-col gap-1",
|
|
2450
|
+
children: e.proposedChanges.changes.map((e, t) => /* @__PURE__ */ $("div", {
|
|
2451
|
+
className: "flex items-start gap-1.5 rounded-md border bg-background px-2 py-1 text-[11px] text-foreground/80",
|
|
2452
|
+
children: [/* @__PURE__ */ Q(ft, { className: "mt-px size-3 shrink-0 text-foreground/40" }), /* @__PURE__ */ Q("span", { children: Mi(e) })]
|
|
2453
|
+
}, t))
|
|
2454
|
+
}),
|
|
2455
|
+
i ? et.has(e.toolCallId) ? /* @__PURE__ */ Q("div", {
|
|
2456
|
+
className: "flex flex-wrap items-center gap-1.5 pt-0.5",
|
|
2457
|
+
"data-testid": "proposed-changes-actions",
|
|
2458
|
+
children: /* @__PURE__ */ $("span", {
|
|
2459
|
+
className: "inline-flex h-7 items-center gap-1.5 rounded-md border border-emerald-200 bg-emerald-50 px-3 text-xs font-medium text-emerald-700 dark:border-emerald-900/50 dark:bg-emerald-950/30 dark:text-emerald-300",
|
|
2460
|
+
"data-testid": "proposed-changes-confirmed",
|
|
2461
|
+
children: [/* @__PURE__ */ Q(J, { className: "size-3.5" }), "已确认"]
|
|
2462
|
+
})
|
|
2463
|
+
}) : /* @__PURE__ */ $("div", {
|
|
2464
|
+
className: "flex flex-wrap items-center gap-1.5 pt-0.5",
|
|
2465
|
+
"data-testid": "proposed-changes-actions",
|
|
2466
|
+
children: [/* @__PURE__ */ $("button", {
|
|
2467
|
+
type: "button",
|
|
2468
|
+
onClick: () => i("确认修改,应用你刚才提议的改动。"),
|
|
2469
|
+
className: "inline-flex h-7 items-center gap-1.5 rounded-md bg-primary px-3 text-xs font-medium text-primary-foreground hover:bg-primary/90",
|
|
2470
|
+
"data-testid": "proposed-changes-confirm",
|
|
2471
|
+
children: [/* @__PURE__ */ Q(J, { className: "size-3.5" }), "确认修改"]
|
|
2472
|
+
}), /* @__PURE__ */ Q("button", {
|
|
2473
|
+
type: "button",
|
|
2474
|
+
onClick: Je,
|
|
2475
|
+
className: "inline-flex h-7 items-center rounded-md border bg-background px-3 text-xs font-medium hover:bg-accent",
|
|
2476
|
+
"data-testid": "proposed-changes-adjust",
|
|
2477
|
+
children: "调整"
|
|
2281
2478
|
})]
|
|
2282
2479
|
}) : /* @__PURE__ */ Q("span", {
|
|
2283
2480
|
className: "text-[11px] italic text-muted-foreground/80",
|
|
2284
|
-
children:
|
|
2481
|
+
children: "回复以确认或调整该改动。"
|
|
2285
2482
|
})
|
|
2286
2483
|
]
|
|
2287
2484
|
}) : null
|
|
@@ -2289,93 +2486,95 @@ var Mi = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2289
2486
|
}, e.toolCallId);
|
|
2290
2487
|
};
|
|
2291
2488
|
return /* @__PURE__ */ $("div", {
|
|
2292
|
-
ref:
|
|
2293
|
-
className:
|
|
2294
|
-
style: { maxHeight:
|
|
2295
|
-
...
|
|
2489
|
+
ref: we,
|
|
2490
|
+
className: q(W ? "flex min-h-0 flex-col overflow-hidden bg-background" : "flex min-h-0 flex-col overflow-hidden rounded-lg border bg-background", t),
|
|
2491
|
+
style: { maxHeight: b },
|
|
2492
|
+
...Ce,
|
|
2296
2493
|
children: [
|
|
2297
|
-
a && !
|
|
2298
|
-
className:
|
|
2494
|
+
a && !y && n.length > 0 && /* @__PURE__ */ Q("div", {
|
|
2495
|
+
className: q("flex items-center justify-end px-4 py-2", W ? "bg-background" : "border-b bg-muted/30"),
|
|
2299
2496
|
children: /* @__PURE__ */ Q("button", {
|
|
2300
2497
|
type: "button",
|
|
2301
2498
|
onClick: a,
|
|
2302
2499
|
className: "text-xs text-muted-foreground hover:text-foreground transition-colors",
|
|
2303
|
-
children:
|
|
2500
|
+
children: K.clear
|
|
2304
2501
|
})
|
|
2305
2502
|
}),
|
|
2306
|
-
|
|
2307
|
-
className:
|
|
2308
|
-
children:
|
|
2503
|
+
A ? /* @__PURE__ */ Q("div", {
|
|
2504
|
+
className: q("shrink-0", !W && "border-b bg-background/50"),
|
|
2505
|
+
children: A
|
|
2309
2506
|
}) : null,
|
|
2310
|
-
/* @__PURE__ */ $(
|
|
2507
|
+
/* @__PURE__ */ $(In, {
|
|
2311
2508
|
className: "flex-1 min-h-0",
|
|
2312
|
-
children: [/* @__PURE__ */ $(
|
|
2313
|
-
className:
|
|
2314
|
-
children: [n.length === 0 ? /* @__PURE__ */ $(
|
|
2509
|
+
children: [/* @__PURE__ */ $(Ln, {
|
|
2510
|
+
className: q("space-y-4", W ? "mx-auto w-full max-w-2xl px-4 py-8 sm:px-0" : "px-4 py-3"),
|
|
2511
|
+
children: [n.length === 0 ? /* @__PURE__ */ $(Rn, {
|
|
2315
2512
|
className: "gap-3 px-0 py-8",
|
|
2316
2513
|
children: [
|
|
2317
2514
|
/* @__PURE__ */ Q("div", {
|
|
2318
2515
|
className: "flex size-9 items-center justify-center rounded-md bg-muted/70 text-muted-foreground",
|
|
2319
|
-
children:
|
|
2320
|
-
src:
|
|
2516
|
+
children: _ ? /* @__PURE__ */ Q("img", {
|
|
2517
|
+
src: _,
|
|
2321
2518
|
alt: "",
|
|
2322
2519
|
className: "size-full rounded-md object-cover"
|
|
2323
|
-
}) : /* @__PURE__ */ Q(
|
|
2520
|
+
}) : /* @__PURE__ */ Q(Ne, { className: "size-4" })
|
|
2324
2521
|
}),
|
|
2325
2522
|
/* @__PURE__ */ $("div", {
|
|
2326
2523
|
className: "space-y-1",
|
|
2327
2524
|
children: [/* @__PURE__ */ Q("h3", {
|
|
2328
2525
|
className: "text-sm font-medium text-foreground/90",
|
|
2329
|
-
children:
|
|
2526
|
+
children: K.emptyTitle
|
|
2330
2527
|
}), /* @__PURE__ */ Q("p", {
|
|
2331
2528
|
className: "text-sm text-muted-foreground",
|
|
2332
|
-
children:
|
|
2529
|
+
children: K.emptyDescription
|
|
2333
2530
|
})]
|
|
2334
2531
|
}),
|
|
2335
|
-
|
|
2532
|
+
T && T.length > 0 ? /* @__PURE__ */ Q(ni, {
|
|
2336
2533
|
className: "justify-center gap-2",
|
|
2337
|
-
children:
|
|
2534
|
+
children: T.map((e) => /* @__PURE__ */ Q(ri, {
|
|
2338
2535
|
className: "h-8 border-border/60 bg-background/80 px-3 text-xs font-medium text-foreground/90 shadow-none hover:bg-muted/60",
|
|
2339
2536
|
suggestion: e,
|
|
2340
|
-
onClick:
|
|
2537
|
+
onClick: Ue
|
|
2341
2538
|
}, e))
|
|
2342
2539
|
}) : null
|
|
2343
2540
|
]
|
|
2344
2541
|
}) : n.map((e) => {
|
|
2345
|
-
let t = e.role === "user", n = e.toolInvocations ?? [], r = e.reasoning?.trim(), i = e.sources ?? [], a = t ? void 0 : e.buildProgress, o = !t && !!e.streaming && !e.content && n.length === 0 && !r && !a, c = !t &&
|
|
2346
|
-
return /* @__PURE__ */ Q(
|
|
2347
|
-
from:
|
|
2542
|
+
let t = e.role === "user", n = e.toolInvocations ?? [], r = e.reasoning?.trim(), i = e.sources ?? [], a = t ? void 0 : e.buildProgress, o = !t && !!e.streaming && !e.content && n.length === 0 && !r && !a, c = !t && V === "summary" ? n.filter((e) => !Ni(e)) : [], l = !t && V === "debug" ? n : !t && V !== "debug" ? n.filter(Ni) : [];
|
|
2543
|
+
return /* @__PURE__ */ Q(Un, {
|
|
2544
|
+
from: ki(e.role),
|
|
2348
2545
|
children: /* @__PURE__ */ $("div", {
|
|
2349
|
-
className:
|
|
2350
|
-
children: [
|
|
2546
|
+
className: q("flex w-full gap-2.5", m ? t ? "flex-row-reverse items-start" : "flex-row items-start" : "flex-col"),
|
|
2547
|
+
children: [m ? /* @__PURE__ */ Q(Ri, {
|
|
2351
2548
|
isUser: t,
|
|
2352
|
-
url: t ?
|
|
2353
|
-
fallback: t ?
|
|
2549
|
+
url: t ? h : _,
|
|
2550
|
+
fallback: t ? g : v
|
|
2354
2551
|
}) : null, /* @__PURE__ */ $("div", {
|
|
2355
|
-
className:
|
|
2356
|
-
children: [/* @__PURE__ */ $(
|
|
2357
|
-
a ? /* @__PURE__ */ Q(
|
|
2552
|
+
className: q("flex min-w-0 flex-col gap-2", m && !t && "flex-1"),
|
|
2553
|
+
children: [/* @__PURE__ */ $(Wn, { children: [
|
|
2554
|
+
a ? /* @__PURE__ */ Q(Yi, {
|
|
2358
2555
|
progress: a,
|
|
2359
2556
|
onOpenBuiltApp: re,
|
|
2360
2557
|
openBuiltAppLabel: ie,
|
|
2361
|
-
onPreviewDraftApp:
|
|
2362
|
-
previewDraftLabel:
|
|
2363
|
-
waitingLabel:
|
|
2558
|
+
onPreviewDraftApp: R,
|
|
2559
|
+
previewDraftLabel: ae,
|
|
2560
|
+
waitingLabel: K.connectionWaiting,
|
|
2561
|
+
stalledLabel: K.connectionStalledLabel,
|
|
2562
|
+
offlineLabel: K.connectionOfflineLabel
|
|
2364
2563
|
}) : null,
|
|
2365
|
-
!t &&
|
|
2564
|
+
!t && V === "debug" && r ? /* @__PURE__ */ $(bi, {
|
|
2366
2565
|
isStreaming: !!e.streaming && !e.content,
|
|
2367
2566
|
className: "mb-2",
|
|
2368
|
-
children: [/* @__PURE__ */ Q(
|
|
2567
|
+
children: [/* @__PURE__ */ Q(Si, {}), /* @__PURE__ */ Q(Ci, { children: r })]
|
|
2369
2568
|
}) : null,
|
|
2370
|
-
!t &&
|
|
2371
|
-
groups:
|
|
2372
|
-
labels:
|
|
2569
|
+
!t && V === "summary" && c.length > 0 ? /* @__PURE__ */ Q(Xi, {
|
|
2570
|
+
groups: Fi(c),
|
|
2571
|
+
labels: K
|
|
2373
2572
|
}) : null,
|
|
2374
|
-
!t && l.length > 0 ? l.map(
|
|
2573
|
+
!t && l.length > 0 ? l.map(tt) : null,
|
|
2375
2574
|
t ? e.content ? /* @__PURE__ */ Q("div", {
|
|
2376
2575
|
className: "whitespace-pre-wrap break-words",
|
|
2377
2576
|
children: e.content
|
|
2378
|
-
}) : null : o ? /* @__PURE__ */ Q(
|
|
2577
|
+
}) : null : o ? /* @__PURE__ */ Q(Bi, {}) : e.content ? /* @__PURE__ */ Q(tr, { children: e.content }) : null,
|
|
2379
2578
|
e.streaming && !o ? /* @__PURE__ */ Q("span", {
|
|
2380
2579
|
"aria-hidden": !0,
|
|
2381
2580
|
className: "ml-0.5 inline-block w-[2px] h-4 align-middle bg-current animate-pulse"
|
|
@@ -2390,7 +2589,7 @@ var Mi = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2390
2589
|
children: [e.title ? /* @__PURE__ */ Q("div", {
|
|
2391
2590
|
className: "mb-2 text-sm font-medium text-foreground",
|
|
2392
2591
|
children: e.title
|
|
2393
|
-
}) : null, /* @__PURE__ */ Q(
|
|
2592
|
+
}) : null, /* @__PURE__ */ Q(St, { schema: {
|
|
2394
2593
|
type: "chart",
|
|
2395
2594
|
chartType: e.chartType ?? "bar",
|
|
2396
2595
|
data: e.data,
|
|
@@ -2399,83 +2598,85 @@ var Mi = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2399
2598
|
} })]
|
|
2400
2599
|
}, t))
|
|
2401
2600
|
}) : null,
|
|
2402
|
-
!t && i.length > 0 ? /* @__PURE__ */ $(
|
|
2601
|
+
!t && i.length > 0 ? /* @__PURE__ */ $(wi, { children: [/* @__PURE__ */ Q(Ti, { count: i.length }), /* @__PURE__ */ Q(Ei, { children: i.map((e, t) => /* @__PURE__ */ Q(Di, {
|
|
2403
2602
|
href: e.url,
|
|
2404
2603
|
title: e.title ?? e.url
|
|
2405
2604
|
}, e.id ?? e.url ?? t)) })] }) : null,
|
|
2406
|
-
|
|
2605
|
+
p && e.timestamp ? /* @__PURE__ */ Q("div", {
|
|
2407
2606
|
className: "text-[10px] opacity-70 mt-1",
|
|
2408
2607
|
children: e.timestamp
|
|
2409
2608
|
}) : null
|
|
2410
|
-
] }), !t && !o ? /* @__PURE__ */ $(
|
|
2609
|
+
] }), !t && !o ? /* @__PURE__ */ $(Gn, {
|
|
2411
2610
|
className: "opacity-0 transition-opacity group-focus-within:opacity-100 group-hover:opacity-100",
|
|
2412
2611
|
children: [
|
|
2413
|
-
/* @__PURE__ */ Q(
|
|
2414
|
-
label:
|
|
2415
|
-
tooltip:
|
|
2416
|
-
onClick: () =>
|
|
2417
|
-
children:
|
|
2612
|
+
/* @__PURE__ */ Q(Kn, {
|
|
2613
|
+
label: G === e.id ? K.copied : K.copy,
|
|
2614
|
+
tooltip: G === e.id ? K.copied : K.copy,
|
|
2615
|
+
onClick: () => Qe(e),
|
|
2616
|
+
children: G === e.id ? /* @__PURE__ */ Q(Fe, { className: "size-3.5" }) : /* @__PURE__ */ Q(Ge, { className: "size-3.5" })
|
|
2418
2617
|
}),
|
|
2419
|
-
s ? /* @__PURE__ */ Q(
|
|
2420
|
-
label:
|
|
2421
|
-
tooltip:
|
|
2618
|
+
s ? /* @__PURE__ */ Q(Kn, {
|
|
2619
|
+
label: K.regenerate,
|
|
2620
|
+
tooltip: K.regenerate,
|
|
2422
2621
|
onClick: s,
|
|
2423
2622
|
children: /* @__PURE__ */ Q(st, { className: "size-3.5" })
|
|
2424
2623
|
}) : null,
|
|
2425
|
-
|
|
2624
|
+
V === "debug" && e.traceId ? /* @__PURE__ */ Q("a", {
|
|
2426
2625
|
href: `#trace/${e.traceId}`,
|
|
2427
2626
|
"data-trace-id": e.traceId,
|
|
2428
2627
|
className: "text-[10px] text-muted-foreground hover:text-foreground ml-1 underline",
|
|
2429
|
-
title:
|
|
2430
|
-
children:
|
|
2628
|
+
title: K.viewTrace,
|
|
2629
|
+
children: K.trace
|
|
2431
2630
|
}) : null
|
|
2432
2631
|
]
|
|
2433
2632
|
}) : null]
|
|
2434
2633
|
})]
|
|
2435
2634
|
})
|
|
2436
2635
|
}, e.id);
|
|
2437
|
-
}),
|
|
2438
|
-
showAvatar:
|
|
2439
|
-
assistantAvatarUrl:
|
|
2440
|
-
assistantAvatarFallback:
|
|
2441
|
-
waitingLabel:
|
|
2636
|
+
}), d && !n.some((e) => e.streaming) ? /* @__PURE__ */ Q(zi, {
|
|
2637
|
+
showAvatar: m,
|
|
2638
|
+
assistantAvatarUrl: _,
|
|
2639
|
+
assistantAvatarFallback: v,
|
|
2640
|
+
waitingLabel: K.connectionWaiting,
|
|
2641
|
+
stalledLabel: K.connectionStalledLabel,
|
|
2642
|
+
offlineLabel: K.connectionOfflineLabel
|
|
2442
2643
|
}) : null]
|
|
2443
|
-
}), /* @__PURE__ */ Q(
|
|
2644
|
+
}), /* @__PURE__ */ Q(zn, {})]
|
|
2444
2645
|
}),
|
|
2445
|
-
|
|
2446
|
-
error:
|
|
2646
|
+
f ? /* @__PURE__ */ Q($i, {
|
|
2647
|
+
error: f,
|
|
2447
2648
|
onReload: s,
|
|
2448
2649
|
onUpgrade: c
|
|
2449
2650
|
}) : null,
|
|
2450
|
-
/* @__PURE__ */ $("div", {
|
|
2451
|
-
ref:
|
|
2452
|
-
className:
|
|
2453
|
-
children: [
|
|
2651
|
+
u ? null : /* @__PURE__ */ $("div", {
|
|
2652
|
+
ref: We,
|
|
2653
|
+
className: q("relative", W && "mx-auto w-full max-w-2xl px-4 pb-4 sm:px-0"),
|
|
2654
|
+
children: [j ? /* @__PURE__ */ Q("div", {
|
|
2454
2655
|
className: "absolute bottom-full left-0 right-0 z-10 px-3 pb-1",
|
|
2455
|
-
children:
|
|
2456
|
-
}) : null, /* @__PURE__ */ $(
|
|
2457
|
-
accept:
|
|
2458
|
-
fileInputLabel:
|
|
2459
|
-
maxFileSize:
|
|
2460
|
-
onSubmit:
|
|
2656
|
+
children: j
|
|
2657
|
+
}) : null, /* @__PURE__ */ $(Cr, {
|
|
2658
|
+
accept: C,
|
|
2659
|
+
fileInputLabel: K.uploadFiles,
|
|
2660
|
+
maxFileSize: w,
|
|
2661
|
+
onSubmit: He,
|
|
2461
2662
|
onError: (e) => {
|
|
2462
2663
|
console.warn("[plugin-chatbot] prompt-input error", e);
|
|
2463
2664
|
},
|
|
2464
2665
|
children: [
|
|
2465
|
-
|
|
2466
|
-
/* @__PURE__ */ Q(
|
|
2666
|
+
S ? /* @__PURE__ */ Q(wr, { children: /* @__PURE__ */ Q(xr, { children: (e) => /* @__PURE__ */ Q(br, { data: e }) }) }) : null,
|
|
2667
|
+
/* @__PURE__ */ Q(Tr, {
|
|
2467
2668
|
placeholder: r,
|
|
2468
|
-
disabled: l ||
|
|
2469
|
-
onChange:
|
|
2669
|
+
disabled: l || U === "streaming",
|
|
2670
|
+
onChange: M ? (e) => M(e.currentTarget.value) : void 0
|
|
2470
2671
|
}),
|
|
2471
|
-
/* @__PURE__ */ $(
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
"aria-label":
|
|
2475
|
-
value:
|
|
2476
|
-
onChange: (e) =>
|
|
2672
|
+
/* @__PURE__ */ $(Dr, { children: [/* @__PURE__ */ $(Or, { children: [
|
|
2673
|
+
S ? /* @__PURE__ */ $(Ar, { children: [/* @__PURE__ */ Q(jr, {}), /* @__PURE__ */ Q(Mr, { children: /* @__PURE__ */ Q(Sr, {}) })] }) : null,
|
|
2674
|
+
D && D.length > 0 ? /* @__PURE__ */ Q("select", {
|
|
2675
|
+
"aria-label": K.model,
|
|
2676
|
+
value: O ?? D[0].id,
|
|
2677
|
+
onChange: (e) => k?.(e.target.value),
|
|
2477
2678
|
className: "h-7 rounded-md border bg-background px-2 text-xs text-muted-foreground hover:text-foreground focus:outline-none focus:ring-1 focus:ring-ring",
|
|
2478
|
-
children:
|
|
2679
|
+
children: D.map((e) => /* @__PURE__ */ $("option", {
|
|
2479
2680
|
value: e.id,
|
|
2480
2681
|
children: [e.label ?? e.id, e.provider ? ` · ${e.provider}` : ""]
|
|
2481
2682
|
}, e.id))
|
|
@@ -2491,16 +2692,16 @@ var Mi = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2491
2692
|
/* @__PURE__ */ Q(qe, { className: "h-3 w-3" }),
|
|
2492
2693
|
/* @__PURE__ */ Q("span", {
|
|
2493
2694
|
className: "opacity-70",
|
|
2494
|
-
children:
|
|
2695
|
+
children: K.sendHint
|
|
2495
2696
|
})
|
|
2496
2697
|
]
|
|
2497
2698
|
})
|
|
2498
|
-
] }), /* @__PURE__ */ Q(
|
|
2499
|
-
"aria-label":
|
|
2500
|
-
status:
|
|
2699
|
+
] }), /* @__PURE__ */ Q(Pr, {
|
|
2700
|
+
"aria-label": U === "streaming" ? K.stopResponse : K.submit,
|
|
2701
|
+
status: U,
|
|
2501
2702
|
disabled: l,
|
|
2502
|
-
onClick:
|
|
2503
|
-
type:
|
|
2703
|
+
onClick: U === "streaming" ? o : void 0,
|
|
2704
|
+
type: U === "streaming" ? "button" : "submit"
|
|
2504
2705
|
})] })
|
|
2505
2706
|
]
|
|
2506
2707
|
})]
|
|
@@ -2508,44 +2709,46 @@ var Mi = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2508
2709
|
]
|
|
2509
2710
|
});
|
|
2510
2711
|
});
|
|
2511
|
-
|
|
2512
|
-
function
|
|
2712
|
+
Li.displayName = "ChatbotEnhanced";
|
|
2713
|
+
function Ri({ isUser: e, url: t, fallback: n }) {
|
|
2513
2714
|
return /* @__PURE__ */ Q("div", {
|
|
2514
|
-
className:
|
|
2715
|
+
className: q("mt-0.5 flex size-7 shrink-0 items-center justify-center overflow-hidden rounded-full text-[11px] font-medium", e ? "bg-secondary text-secondary-foreground" : "bg-primary/10 text-primary"),
|
|
2515
2716
|
"aria-hidden": "true",
|
|
2516
2717
|
children: t ? /* @__PURE__ */ Q("img", {
|
|
2517
2718
|
src: t,
|
|
2518
2719
|
alt: "",
|
|
2519
2720
|
className: "size-full object-cover"
|
|
2520
|
-
}) : e ? n?.trim()?.charAt(0)?.toUpperCase() || "U" : /* @__PURE__ */ Q(
|
|
2721
|
+
}) : e ? n?.trim()?.charAt(0)?.toUpperCase() || "U" : /* @__PURE__ */ Q(Ne, { className: "size-4" })
|
|
2521
2722
|
});
|
|
2522
2723
|
}
|
|
2523
|
-
function
|
|
2524
|
-
return /* @__PURE__ */ Q(
|
|
2724
|
+
function zi({ showAvatar: e, assistantAvatarUrl: t, assistantAvatarFallback: n, waitingLabel: r, stalledLabel: i, offlineLabel: a }) {
|
|
2725
|
+
return /* @__PURE__ */ Q(Un, {
|
|
2525
2726
|
from: "assistant",
|
|
2526
2727
|
"aria-live": "polite",
|
|
2527
2728
|
children: /* @__PURE__ */ $("div", {
|
|
2528
|
-
className:
|
|
2529
|
-
children: [e ? /* @__PURE__ */ Q(
|
|
2729
|
+
className: q("flex w-full gap-2.5", e ? "flex-row items-start" : "flex-col"),
|
|
2730
|
+
children: [e ? /* @__PURE__ */ Q(Ri, {
|
|
2530
2731
|
isUser: !1,
|
|
2531
2732
|
url: t,
|
|
2532
2733
|
fallback: n
|
|
2533
|
-
}) : null, /* @__PURE__ */ Q(
|
|
2734
|
+
}) : null, /* @__PURE__ */ Q(Wn, {
|
|
2534
2735
|
className: "rounded-lg border bg-muted/30 px-3 py-2 text-muted-foreground",
|
|
2535
2736
|
children: /* @__PURE__ */ $("span", {
|
|
2536
2737
|
className: "inline-flex items-center gap-2",
|
|
2537
|
-
children: [/* @__PURE__ */ Q(
|
|
2738
|
+
children: [/* @__PURE__ */ Q(Bi, {}), /* @__PURE__ */ Q(Gi, {
|
|
2538
2739
|
active: !0,
|
|
2539
2740
|
pending: !0,
|
|
2540
2741
|
activityKey: 0,
|
|
2541
|
-
waitingLabel: r
|
|
2742
|
+
waitingLabel: r,
|
|
2743
|
+
stalledLabel: i,
|
|
2744
|
+
offlineLabel: a
|
|
2542
2745
|
})]
|
|
2543
2746
|
})
|
|
2544
2747
|
})]
|
|
2545
2748
|
})
|
|
2546
2749
|
});
|
|
2547
2750
|
}
|
|
2548
|
-
function
|
|
2751
|
+
function Bi() {
|
|
2549
2752
|
return /* @__PURE__ */ $(Z, { children: [/* @__PURE__ */ Q("span", {
|
|
2550
2753
|
className: "sr-only",
|
|
2551
2754
|
children: "Assistant is responding"
|
|
@@ -2559,12 +2762,12 @@ function Fi() {
|
|
|
2559
2762
|
]
|
|
2560
2763
|
})] });
|
|
2561
2764
|
}
|
|
2562
|
-
function
|
|
2765
|
+
function Vi(e) {
|
|
2563
2766
|
let t = Math.floor(e / 60), n = e % 60;
|
|
2564
2767
|
return `${t}:${String(n).padStart(2, "0")}`;
|
|
2565
2768
|
}
|
|
2566
|
-
var
|
|
2567
|
-
function
|
|
2769
|
+
var Hi = 6;
|
|
2770
|
+
function Ui(t, n) {
|
|
2568
2771
|
let r = e.useRef(0), i = e.useRef(0), [a, o] = e.useState({
|
|
2569
2772
|
elapsed: 0,
|
|
2570
2773
|
quiet: 0
|
|
@@ -2593,49 +2796,82 @@ function Ri(t, n) {
|
|
|
2593
2796
|
}, [t]), {
|
|
2594
2797
|
elapsedSeconds: a.elapsed,
|
|
2595
2798
|
quietSeconds: a.quiet,
|
|
2596
|
-
live: a.quiet <
|
|
2799
|
+
live: a.quiet < Hi
|
|
2597
2800
|
};
|
|
2598
2801
|
}
|
|
2599
|
-
function
|
|
2600
|
-
let
|
|
2802
|
+
function Wi() {
|
|
2803
|
+
let [t, n] = e.useState(() => typeof navigator < "u" && navigator.onLine === !1);
|
|
2804
|
+
return e.useEffect(() => {
|
|
2805
|
+
if (typeof window > "u") return;
|
|
2806
|
+
let e = () => n(!1), t = () => n(!0);
|
|
2807
|
+
return window.addEventListener("online", e), window.addEventListener("offline", t), () => {
|
|
2808
|
+
window.removeEventListener("online", e), window.removeEventListener("offline", t);
|
|
2809
|
+
};
|
|
2810
|
+
}, []), t;
|
|
2811
|
+
}
|
|
2812
|
+
function Gi({ active: e, activityKey: t, pending: n = !1, waitingLabel: r, stalledLabel: i = "Still working…", offlineLabel: a = "Connection lost — reconnecting…" }) {
|
|
2813
|
+
let { elapsedSeconds: o, quietSeconds: s, live: c } = Ui(e, t), l = Wi() ? "offline" : c ? n ? "waiting" : "receiving" : "stalled", u = Vi(o);
|
|
2601
2814
|
return /* @__PURE__ */ $("span", {
|
|
2602
|
-
className:
|
|
2815
|
+
className: q("inline-flex items-center gap-1.5 text-xs tabular-nums", l === "offline" ? "text-red-600 font-medium" : l === "stalled" ? "text-amber-600 font-medium" : "font-normal text-muted-foreground"),
|
|
2603
2816
|
"aria-live": "polite",
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
"
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2817
|
+
"data-liveness-tier": l,
|
|
2818
|
+
title: l === "offline" ? `${a} · ${u} elapsed` : l === "receiving" ? `Receiving from server · ${u} elapsed` : l === "stalled" ? `${i} (${s}s with no response) · ${u} elapsed` : `${r} · ${u} elapsed`,
|
|
2819
|
+
children: [
|
|
2820
|
+
l === "offline" ? /* @__PURE__ */ Q(mt, {
|
|
2821
|
+
className: "size-3 shrink-0",
|
|
2822
|
+
"aria-hidden": !0
|
|
2823
|
+
}) : /* @__PURE__ */ Q("span", {
|
|
2824
|
+
"aria-hidden": !0,
|
|
2825
|
+
className: q("size-1.5 shrink-0 rounded-full", l === "receiving" ? "bg-emerald-500 animate-pulse" : l === "stalled" ? "bg-amber-500" : "bg-muted-foreground/50 animate-pulse")
|
|
2826
|
+
}),
|
|
2827
|
+
/* @__PURE__ */ Q(Ue, {
|
|
2828
|
+
className: "size-3 shrink-0",
|
|
2829
|
+
"aria-hidden": !0
|
|
2830
|
+
}),
|
|
2831
|
+
/* @__PURE__ */ Q("span", { children: u }),
|
|
2832
|
+
l === "receiving" ? null : /* @__PURE__ */ $("span", { children: ["· ", l === "offline" ? a : l === "stalled" ? i : r] })
|
|
2833
|
+
]
|
|
2834
|
+
});
|
|
2835
|
+
}
|
|
2836
|
+
function Ki({ offlineLabel: t }) {
|
|
2837
|
+
let [n, r] = e.useState(0), i = Wi();
|
|
2838
|
+
return e.useEffect(() => {
|
|
2839
|
+
let e = Date.now(), t = setInterval(() => r(Math.floor((Date.now() - e) / 1e3)), 1e3);
|
|
2840
|
+
return () => clearInterval(t);
|
|
2841
|
+
}, []), /* @__PURE__ */ $("span", {
|
|
2842
|
+
className: q("inline-flex items-center gap-1 text-xs tabular-nums", i ? "text-red-600 font-medium" : "text-muted-foreground"),
|
|
2843
|
+
"aria-live": "polite",
|
|
2844
|
+
"data-tool-running-timer": !0,
|
|
2845
|
+
children: [
|
|
2846
|
+
Q(i ? mt : Ue, {
|
|
2847
|
+
className: "size-3 shrink-0",
|
|
2848
|
+
"aria-hidden": !0
|
|
2849
|
+
}),
|
|
2850
|
+
/* @__PURE__ */ Q("span", { children: Vi(n) }),
|
|
2851
|
+
i ? /* @__PURE__ */ $("span", { children: ["· ", t] }) : null
|
|
2852
|
+
]
|
|
2617
2853
|
});
|
|
2618
2854
|
}
|
|
2619
|
-
var
|
|
2855
|
+
var qi = [
|
|
2620
2856
|
"object",
|
|
2621
2857
|
"view",
|
|
2622
2858
|
"dashboard",
|
|
2623
2859
|
"app",
|
|
2624
2860
|
"seed"
|
|
2625
|
-
],
|
|
2861
|
+
], Ji = {
|
|
2626
2862
|
object: "Objects",
|
|
2627
2863
|
view: "Views",
|
|
2628
2864
|
dashboard: "Dashboards",
|
|
2629
2865
|
app: "App",
|
|
2630
2866
|
seed: "Sample data"
|
|
2631
2867
|
};
|
|
2632
|
-
function
|
|
2633
|
-
let { phase:
|
|
2634
|
-
for (let e of
|
|
2635
|
-
let t =
|
|
2636
|
-
t.push(e.name.replace(/_sample$/, "")),
|
|
2868
|
+
function Yi({ progress: e, onOpenBuiltApp: t, openBuiltAppLabel: n = "Open app", onPreviewDraftApp: r, previewDraftLabel: i = "Preview", waitingLabel: a = "Waiting for server…", stalledLabel: o = "Still working…", offlineLabel: s = "Connection lost — reconnecting…" }) {
|
|
2869
|
+
let { phase: c, appLabel: l, items: u, done: d, total: f, seq: p } = e, m = c === "done", h = p ?? `${c}:${d}:${u.length}`, g = u.find((e) => e.type === "app"), _ = f > 0 ? Math.min(100, Math.round(d / f * 100)) : m ? 100 : 6, v = /* @__PURE__ */ new Map();
|
|
2870
|
+
for (let e of u) {
|
|
2871
|
+
let t = v.get(e.type) ?? [];
|
|
2872
|
+
t.push(e.name.replace(/_sample$/, "")), v.set(e.type, t);
|
|
2637
2873
|
}
|
|
2638
|
-
let
|
|
2874
|
+
let y = [...qi.filter((e) => v.has(e)), ...[...v.keys()].filter((e) => !qi.includes(e))];
|
|
2639
2875
|
return /* @__PURE__ */ $("div", {
|
|
2640
2876
|
className: "rounded-lg border bg-muted/30 p-3 text-sm",
|
|
2641
2877
|
"data-testid": "build-progress",
|
|
@@ -2643,18 +2879,20 @@ function Hi({ progress: e, onOpenBuiltApp: t, openBuiltAppLabel: n = "Open app",
|
|
|
2643
2879
|
/* @__PURE__ */ $("div", {
|
|
2644
2880
|
className: "mb-2 flex items-center gap-2 font-medium",
|
|
2645
2881
|
children: [
|
|
2646
|
-
|
|
2647
|
-
/* @__PURE__ */ Q("span", { children:
|
|
2648
|
-
!
|
|
2882
|
+
m ? /* @__PURE__ */ Q(J, { className: "size-4 shrink-0 text-emerald-600" }) : /* @__PURE__ */ Q(et, { className: "size-4 shrink-0 animate-spin text-primary" }),
|
|
2883
|
+
/* @__PURE__ */ Q("span", { children: m ? `Built ${l ?? "your app"}` : `Building ${l ?? "your app"}…` }),
|
|
2884
|
+
!m && c === "data" ? /* @__PURE__ */ Q("span", {
|
|
2649
2885
|
className: "text-xs font-normal text-muted-foreground",
|
|
2650
2886
|
children: "adding sample data"
|
|
2651
2887
|
}) : null,
|
|
2652
|
-
|
|
2888
|
+
m ? null : /* @__PURE__ */ Q("span", {
|
|
2653
2889
|
className: "ml-auto",
|
|
2654
|
-
children: /* @__PURE__ */ Q(
|
|
2890
|
+
children: /* @__PURE__ */ Q(Gi, {
|
|
2655
2891
|
active: !0,
|
|
2656
|
-
activityKey:
|
|
2657
|
-
waitingLabel: a
|
|
2892
|
+
activityKey: h,
|
|
2893
|
+
waitingLabel: a,
|
|
2894
|
+
stalledLabel: o,
|
|
2895
|
+
offlineLabel: s
|
|
2658
2896
|
})
|
|
2659
2897
|
})
|
|
2660
2898
|
]
|
|
@@ -2662,22 +2900,22 @@ function Hi({ progress: e, onOpenBuiltApp: t, openBuiltAppLabel: n = "Open app",
|
|
|
2662
2900
|
/* @__PURE__ */ Q("div", {
|
|
2663
2901
|
className: "mb-2 h-1.5 w-full overflow-hidden rounded-full bg-muted",
|
|
2664
2902
|
children: /* @__PURE__ */ Q("div", {
|
|
2665
|
-
className:
|
|
2666
|
-
style: { width: `${
|
|
2903
|
+
className: q("h-full rounded-full transition-all duration-500", m ? "bg-emerald-500" : "bg-primary"),
|
|
2904
|
+
style: { width: `${_}%` }
|
|
2667
2905
|
})
|
|
2668
2906
|
}),
|
|
2669
2907
|
/* @__PURE__ */ Q("ul", {
|
|
2670
2908
|
className: "space-y-1",
|
|
2671
|
-
children:
|
|
2672
|
-
let t =
|
|
2909
|
+
children: y.map((e) => {
|
|
2910
|
+
let t = v.get(e);
|
|
2673
2911
|
return /* @__PURE__ */ $("li", {
|
|
2674
2912
|
className: "flex items-start gap-2",
|
|
2675
|
-
children: [/* @__PURE__ */ Q(
|
|
2913
|
+
children: [/* @__PURE__ */ Q(J, { className: "mt-0.5 size-3.5 shrink-0 text-emerald-600" }), /* @__PURE__ */ $("span", {
|
|
2676
2914
|
className: "min-w-0 text-muted-foreground",
|
|
2677
2915
|
children: [
|
|
2678
2916
|
/* @__PURE__ */ Q("span", {
|
|
2679
2917
|
className: "font-medium text-foreground",
|
|
2680
|
-
children:
|
|
2918
|
+
children: Ji[e] ?? e
|
|
2681
2919
|
}),
|
|
2682
2920
|
" ",
|
|
2683
2921
|
t.slice(0, 6).join(", "),
|
|
@@ -2687,17 +2925,17 @@ function Hi({ progress: e, onOpenBuiltApp: t, openBuiltAppLabel: n = "Open app",
|
|
|
2687
2925
|
}, e);
|
|
2688
2926
|
})
|
|
2689
2927
|
}),
|
|
2690
|
-
|
|
2928
|
+
m && g && (t || r) ? /* @__PURE__ */ $("div", {
|
|
2691
2929
|
className: "mt-3 flex items-center gap-2",
|
|
2692
2930
|
children: [t ? /* @__PURE__ */ $("button", {
|
|
2693
2931
|
type: "button",
|
|
2694
|
-
onClick: () => t(
|
|
2932
|
+
onClick: () => t(g.name),
|
|
2695
2933
|
className: "inline-flex h-7 items-center gap-1.5 rounded-md bg-primary px-3 text-xs font-medium text-primary-foreground hover:bg-primary/90",
|
|
2696
2934
|
"data-testid": "build-progress-open-app",
|
|
2697
|
-
children: [n, /* @__PURE__ */ Q(
|
|
2935
|
+
children: [n, /* @__PURE__ */ Q(je, { className: "size-3.5" })]
|
|
2698
2936
|
}) : null, r ? /* @__PURE__ */ $("button", {
|
|
2699
2937
|
type: "button",
|
|
2700
|
-
onClick: () => r(
|
|
2938
|
+
onClick: () => r(g.name),
|
|
2701
2939
|
className: "inline-flex h-7 items-center gap-1.5 rounded-md border px-3 text-xs font-medium hover:bg-muted",
|
|
2702
2940
|
"data-testid": "build-progress-preview-app",
|
|
2703
2941
|
children: [/* @__PURE__ */ Q(Ye, { className: "size-3.5" }), i]
|
|
@@ -2706,7 +2944,7 @@ function Hi({ progress: e, onOpenBuiltApp: t, openBuiltAppLabel: n = "Open app",
|
|
|
2706
2944
|
]
|
|
2707
2945
|
});
|
|
2708
2946
|
}
|
|
2709
|
-
function
|
|
2947
|
+
function Xi({ groups: e, labels: t }) {
|
|
2710
2948
|
return e.length === 0 ? null : /* @__PURE__ */ Q("div", {
|
|
2711
2949
|
className: "not-prose mb-2 border-l border-border/70 pl-3",
|
|
2712
2950
|
children: /* @__PURE__ */ Q("div", {
|
|
@@ -2716,7 +2954,7 @@ function Ui({ groups: e, labels: t }) {
|
|
|
2716
2954
|
children: [/* @__PURE__ */ $("div", {
|
|
2717
2955
|
className: "flex min-w-0 items-center gap-2",
|
|
2718
2956
|
children: [
|
|
2719
|
-
/* @__PURE__ */ Q(
|
|
2957
|
+
/* @__PURE__ */ Q(Zi, { state: e.state }),
|
|
2720
2958
|
/* @__PURE__ */ Q("span", {
|
|
2721
2959
|
className: "truncate font-medium text-foreground",
|
|
2722
2960
|
children: e.title
|
|
@@ -2726,18 +2964,18 @@ function Ui({ groups: e, labels: t }) {
|
|
|
2726
2964
|
children: ["x", e.count]
|
|
2727
2965
|
}) : null
|
|
2728
2966
|
]
|
|
2729
|
-
}), /* @__PURE__ */ Q("span", {
|
|
2730
|
-
className:
|
|
2731
|
-
children:
|
|
2967
|
+
}), e.state === "running" ? /* @__PURE__ */ Q(Ki, { offlineLabel: t.connectionOfflineLabel }) : /* @__PURE__ */ Q("span", {
|
|
2968
|
+
className: q("shrink-0 text-[10px] font-medium", e.state === "failed" ? "text-destructive" : e.state === "completed" ? "text-emerald-700 dark:text-emerald-400" : "text-muted-foreground"),
|
|
2969
|
+
children: Qi(e.state, t)
|
|
2732
2970
|
})]
|
|
2733
2971
|
}, e.key))
|
|
2734
2972
|
})
|
|
2735
2973
|
});
|
|
2736
2974
|
}
|
|
2737
|
-
function
|
|
2738
|
-
return e === "failed" ? /* @__PURE__ */ Q(X, { className: "size-3.5 shrink-0 text-destructive" }) : e === "completed" ? /* @__PURE__ */ Q(
|
|
2975
|
+
function Zi({ state: e }) {
|
|
2976
|
+
return e === "failed" ? /* @__PURE__ */ Q(X, { className: "size-3.5 shrink-0 text-destructive" }) : e === "completed" ? /* @__PURE__ */ Q(J, { className: "size-3.5 shrink-0 text-emerald-600" }) : /* @__PURE__ */ Q(Ue, { className: "size-3.5 shrink-0 text-muted-foreground" });
|
|
2739
2977
|
}
|
|
2740
|
-
function
|
|
2978
|
+
function Qi(e, t) {
|
|
2741
2979
|
switch (e) {
|
|
2742
2980
|
case "failed": return t.toolFailed;
|
|
2743
2981
|
case "awaiting": return t.toolAwaitingApproval;
|
|
@@ -2745,8 +2983,8 @@ function Gi(e, t) {
|
|
|
2745
2983
|
case "completed": return t.toolCompleted;
|
|
2746
2984
|
}
|
|
2747
2985
|
}
|
|
2748
|
-
function
|
|
2749
|
-
let i = e.useMemo(() =>
|
|
2986
|
+
function $i({ error: t, onReload: n, onUpgrade: r }) {
|
|
2987
|
+
let i = e.useMemo(() => Fn(t), [t]), { summary: a, details: o } = e.useMemo(() => Nn(t), [t]), [s, c] = e.useState(!1);
|
|
2750
2988
|
if (i) {
|
|
2751
2989
|
let e = typeof navigator < "u" && !!navigator.language?.toLowerCase().startsWith("zh"), t = (e ? i.message : i.messageEn ?? i.message) || (e ? "AI 额度已用完。" : "You have reached your AI quota."), n = i.topUp ? e ? "购买额度包" : "Buy a credit pack" : e ? "升级方案" : "Upgrade plan";
|
|
2752
2990
|
return /* @__PURE__ */ Q("div", {
|
|
@@ -2783,7 +3021,7 @@ function Ki({ error: t, onReload: n, onUpgrade: r }) {
|
|
|
2783
3021
|
children: [/* @__PURE__ */ $("div", {
|
|
2784
3022
|
className: "flex items-start gap-2",
|
|
2785
3023
|
children: [
|
|
2786
|
-
/* @__PURE__ */ Q(
|
|
3024
|
+
/* @__PURE__ */ Q(ke, { className: "mt-0.5 h-4 w-4 shrink-0 text-destructive" }),
|
|
2787
3025
|
/* @__PURE__ */ $("div", {
|
|
2788
3026
|
className: "min-w-0 flex-1",
|
|
2789
3027
|
children: [/* @__PURE__ */ Q("div", {
|
|
@@ -2817,27 +3055,27 @@ function Ki({ error: t, onReload: n, onUpgrade: r }) {
|
|
|
2817
3055
|
})
|
|
2818
3056
|
});
|
|
2819
3057
|
}
|
|
2820
|
-
function
|
|
2821
|
-
return t ? /* @__PURE__ */ Q(
|
|
3058
|
+
function ea({ output: e, errorText: t }) {
|
|
3059
|
+
return t ? /* @__PURE__ */ Q(mi, {
|
|
2822
3060
|
output: void 0,
|
|
2823
3061
|
errorText: t
|
|
2824
|
-
}) : e == null || e === "" ? null : typeof e == "string" && !
|
|
3062
|
+
}) : e == null || e === "" ? null : typeof e == "string" && !Ai(e) ? /* @__PURE__ */ $("div", {
|
|
2825
3063
|
className: "space-y-2 p-4",
|
|
2826
3064
|
children: [/* @__PURE__ */ Q("h4", {
|
|
2827
3065
|
className: "font-medium text-muted-foreground text-xs uppercase tracking-wide",
|
|
2828
3066
|
children: "Result"
|
|
2829
3067
|
}), /* @__PURE__ */ Q("div", {
|
|
2830
3068
|
className: "overflow-x-auto rounded-md bg-muted/40 px-3 py-2 text-sm text-foreground",
|
|
2831
|
-
children: /* @__PURE__ */ Q(
|
|
3069
|
+
children: /* @__PURE__ */ Q(tr, { children: e })
|
|
2832
3070
|
})]
|
|
2833
|
-
}) : /* @__PURE__ */ Q(
|
|
3071
|
+
}) : /* @__PURE__ */ Q(mi, {
|
|
2834
3072
|
output: e,
|
|
2835
3073
|
errorText: void 0
|
|
2836
3074
|
});
|
|
2837
3075
|
}
|
|
2838
3076
|
//#endregion
|
|
2839
3077
|
//#region src/FloatingChatbot.tsx
|
|
2840
|
-
function
|
|
3078
|
+
function ta({ floatingConfig: t, headerExtra: n, headerActions: r, ...i }) {
|
|
2841
3079
|
let { position: a = "bottom-right", defaultOpen: o = !1, panelWidth: s = 400, panelHeight: c = 520, title: l = "Chat", triggerSize: u = 56 } = t ?? {}, [d, f] = e.useState(null);
|
|
2842
3080
|
e.useEffect(() => {
|
|
2843
3081
|
let e = document.getElementById("floating-chatbot-portal");
|
|
@@ -2845,29 +3083,29 @@ function Ji({ floatingConfig: t, headerExtra: n, headerActions: r, ...i }) {
|
|
|
2845
3083
|
e && e.parentNode && !e.hasChildNodes() && e.parentNode.removeChild(e);
|
|
2846
3084
|
};
|
|
2847
3085
|
}, []);
|
|
2848
|
-
let p = /* @__PURE__ */ $(
|
|
3086
|
+
let p = /* @__PURE__ */ $(_n, {
|
|
2849
3087
|
defaultOpen: o,
|
|
2850
|
-
children: [/* @__PURE__ */ Q(
|
|
3088
|
+
children: [/* @__PURE__ */ Q(Cn, {
|
|
2851
3089
|
position: a,
|
|
2852
3090
|
size: u
|
|
2853
|
-
}), /* @__PURE__ */ Q(
|
|
3091
|
+
}), /* @__PURE__ */ Q(kn, {
|
|
2854
3092
|
title: l,
|
|
2855
3093
|
position: a,
|
|
2856
3094
|
width: s,
|
|
2857
3095
|
height: c,
|
|
2858
3096
|
headerExtra: n,
|
|
2859
3097
|
headerActions: r,
|
|
2860
|
-
children: /* @__PURE__ */ Q(
|
|
3098
|
+
children: /* @__PURE__ */ Q(Li, {
|
|
2861
3099
|
...i,
|
|
2862
3100
|
maxHeight: "100%",
|
|
2863
3101
|
className: "h-full border-0 rounded-none"
|
|
2864
3102
|
})
|
|
2865
3103
|
})]
|
|
2866
3104
|
});
|
|
2867
|
-
return d ?
|
|
3105
|
+
return d ? xt.createPortal(p, d) : p;
|
|
2868
3106
|
}
|
|
2869
|
-
|
|
2870
|
-
let { messages: r, isLoading: i, sendMessage: a } =
|
|
3107
|
+
Nt.register("chatbot", ({ schema: e, className: t, ...n }) => {
|
|
3108
|
+
let { messages: r, isLoading: i, sendMessage: a } = tn({
|
|
2871
3109
|
api: e.api,
|
|
2872
3110
|
initialMessages: e.messages,
|
|
2873
3111
|
conversationId: e.conversationId,
|
|
@@ -2884,7 +3122,7 @@ Mt.register("chatbot", ({ schema: e, className: t, ...n }) => {
|
|
|
2884
3122
|
autoResponseDelay: e.autoResponseDelay,
|
|
2885
3123
|
onSend: e.onSend
|
|
2886
3124
|
});
|
|
2887
|
-
return /* @__PURE__ */ Q(
|
|
3125
|
+
return /* @__PURE__ */ Q(Sa, {
|
|
2888
3126
|
messages: r,
|
|
2889
3127
|
placeholder: e.placeholder,
|
|
2890
3128
|
onSendMessage: (e) => {
|
|
@@ -3032,8 +3270,8 @@ Mt.register("chatbot", ({ schema: e, className: t, ...n }) => {
|
|
|
3032
3270
|
autoResponseDelay: 1e3,
|
|
3033
3271
|
className: "w-full max-w-2xl"
|
|
3034
3272
|
}
|
|
3035
|
-
}),
|
|
3036
|
-
let { messages: r, isLoading: i, error: a, sendMessage: o, stop: s, reload: c, clear: l, isApiMode: u } =
|
|
3273
|
+
}), Nt.register("chatbot-enhanced", ({ schema: e, className: t, ...n }) => {
|
|
3274
|
+
let { messages: r, isLoading: i, error: a, sendMessage: o, stop: s, reload: c, clear: l, isApiMode: u } = tn({
|
|
3037
3275
|
api: e.api,
|
|
3038
3276
|
initialMessages: e.messages,
|
|
3039
3277
|
conversationId: e.conversationId,
|
|
@@ -3050,7 +3288,7 @@ Mt.register("chatbot", ({ schema: e, className: t, ...n }) => {
|
|
|
3050
3288
|
autoResponseDelay: e.autoResponseDelay,
|
|
3051
3289
|
onSend: e.onSend
|
|
3052
3290
|
});
|
|
3053
|
-
return /* @__PURE__ */ Q(
|
|
3291
|
+
return /* @__PURE__ */ Q(Li, {
|
|
3054
3292
|
messages: r,
|
|
3055
3293
|
placeholder: e.placeholder,
|
|
3056
3294
|
onSendMessage: (e, t) => {
|
|
@@ -3219,8 +3457,8 @@ Mt.register("chatbot", ({ schema: e, className: t, ...n }) => {
|
|
|
3219
3457
|
autoResponseDelay: 1e3,
|
|
3220
3458
|
className: "w-full max-w-2xl"
|
|
3221
3459
|
}
|
|
3222
|
-
}),
|
|
3223
|
-
let { messages: r, isLoading: i, error: a, sendMessage: o, stop: s, reload: c, clear: l, isApiMode: u } =
|
|
3460
|
+
}), Nt.register("chatbot-floating", ({ schema: e, className: t, ...n }) => {
|
|
3461
|
+
let { messages: r, isLoading: i, error: a, sendMessage: o, stop: s, reload: c, clear: l, isApiMode: u } = tn({
|
|
3224
3462
|
api: e.api,
|
|
3225
3463
|
initialMessages: e.messages,
|
|
3226
3464
|
conversationId: e.conversationId,
|
|
@@ -3237,7 +3475,7 @@ Mt.register("chatbot", ({ schema: e, className: t, ...n }) => {
|
|
|
3237
3475
|
autoResponseDelay: e.autoResponseDelay,
|
|
3238
3476
|
onSend: e.onSend
|
|
3239
3477
|
});
|
|
3240
|
-
return /* @__PURE__ */ Q(
|
|
3478
|
+
return /* @__PURE__ */ Q(ta, {
|
|
3241
3479
|
floatingConfig: e.floatingConfig,
|
|
3242
3480
|
messages: r,
|
|
3243
3481
|
placeholder: e.placeholder,
|
|
@@ -3409,7 +3647,7 @@ Mt.register("chatbot", ({ schema: e, className: t, ...n }) => {
|
|
|
3409
3647
|
});
|
|
3410
3648
|
//#endregion
|
|
3411
3649
|
//#region src/elements/loader.tsx
|
|
3412
|
-
var
|
|
3650
|
+
var na = ({ size: e = 16 }) => /* @__PURE__ */ $("svg", {
|
|
3413
3651
|
height: e,
|
|
3414
3652
|
strokeLinejoin: "round",
|
|
3415
3653
|
style: { color: "currentcolor" },
|
|
@@ -3490,97 +3728,97 @@ var Yi = ({ size: e = 16 }) => /* @__PURE__ */ $("svg", {
|
|
|
3490
3728
|
})
|
|
3491
3729
|
}) })
|
|
3492
3730
|
]
|
|
3493
|
-
}),
|
|
3494
|
-
className:
|
|
3731
|
+
}), ra = ({ className: e, size: t = 16, ...n }) => /* @__PURE__ */ Q("div", {
|
|
3732
|
+
className: q("inline-flex animate-spin items-center justify-center", e),
|
|
3495
3733
|
...n,
|
|
3496
|
-
children: /* @__PURE__ */ Q(
|
|
3497
|
-
}),
|
|
3498
|
-
CodeBlock: () =>
|
|
3499
|
-
CodeBlockCopyButton: () =>
|
|
3500
|
-
Conversation: () =>
|
|
3501
|
-
ConversationContent: () =>
|
|
3502
|
-
ConversationEmptyState: () =>
|
|
3503
|
-
ConversationScrollButton: () =>
|
|
3504
|
-
Loader: () =>
|
|
3505
|
-
Message: () =>
|
|
3506
|
-
MessageAction: () =>
|
|
3507
|
-
MessageActions: () =>
|
|
3508
|
-
MessageAttachment: () =>
|
|
3509
|
-
MessageAttachments: () =>
|
|
3510
|
-
MessageBranch: () =>
|
|
3511
|
-
MessageBranchContent: () =>
|
|
3512
|
-
MessageBranchNext: () =>
|
|
3513
|
-
MessageBranchPage: () =>
|
|
3514
|
-
MessageBranchPrevious: () =>
|
|
3515
|
-
MessageBranchSelector: () =>
|
|
3516
|
-
MessageContent: () =>
|
|
3517
|
-
MessageResponse: () =>
|
|
3518
|
-
MessageToolbar: () =>
|
|
3519
|
-
PromptInput: () =>
|
|
3520
|
-
PromptInputActionAddAttachments: () =>
|
|
3521
|
-
PromptInputActionMenu: () =>
|
|
3522
|
-
PromptInputActionMenuContent: () =>
|
|
3523
|
-
PromptInputActionMenuItem: () =>
|
|
3524
|
-
PromptInputActionMenuTrigger: () =>
|
|
3525
|
-
PromptInputAttachment: () =>
|
|
3526
|
-
PromptInputAttachments: () =>
|
|
3527
|
-
PromptInputBody: () =>
|
|
3528
|
-
PromptInputButton: () =>
|
|
3529
|
-
PromptInputCommand: () =>
|
|
3530
|
-
PromptInputCommandEmpty: () =>
|
|
3531
|
-
PromptInputCommandGroup: () =>
|
|
3532
|
-
PromptInputCommandInput: () =>
|
|
3533
|
-
PromptInputCommandItem: () =>
|
|
3534
|
-
PromptInputCommandList: () =>
|
|
3535
|
-
PromptInputCommandSeparator: () =>
|
|
3536
|
-
PromptInputFooter: () =>
|
|
3537
|
-
PromptInputHeader: () =>
|
|
3538
|
-
PromptInputHoverCard: () =>
|
|
3539
|
-
PromptInputHoverCardContent: () =>
|
|
3540
|
-
PromptInputHoverCardTrigger: () =>
|
|
3541
|
-
PromptInputProvider: () =>
|
|
3542
|
-
PromptInputSelect: () =>
|
|
3543
|
-
PromptInputSelectContent: () =>
|
|
3544
|
-
PromptInputSelectItem: () =>
|
|
3545
|
-
PromptInputSelectTrigger: () =>
|
|
3546
|
-
PromptInputSelectValue: () =>
|
|
3547
|
-
PromptInputSpeechButton: () =>
|
|
3548
|
-
PromptInputSubmit: () =>
|
|
3549
|
-
PromptInputTab: () =>
|
|
3550
|
-
PromptInputTabBody: () =>
|
|
3551
|
-
PromptInputTabItem: () =>
|
|
3552
|
-
PromptInputTabLabel: () =>
|
|
3553
|
-
PromptInputTabsList: () =>
|
|
3554
|
-
PromptInputTextarea: () =>
|
|
3555
|
-
PromptInputTools: () =>
|
|
3556
|
-
Reasoning: () =>
|
|
3557
|
-
ReasoningContent: () =>
|
|
3558
|
-
ReasoningTrigger: () =>
|
|
3559
|
-
Shimmer: () =>
|
|
3560
|
-
Source: () =>
|
|
3561
|
-
Sources: () =>
|
|
3562
|
-
SourcesContent: () =>
|
|
3563
|
-
SourcesTrigger: () =>
|
|
3564
|
-
Suggestion: () =>
|
|
3565
|
-
Suggestions: () =>
|
|
3566
|
-
Tool: () =>
|
|
3567
|
-
ToolContent: () =>
|
|
3568
|
-
ToolHeader: () =>
|
|
3569
|
-
ToolInput: () =>
|
|
3570
|
-
ToolOutput: () =>
|
|
3571
|
-
highlightCode: () =>
|
|
3572
|
-
usePromptInputAttachments: () =>
|
|
3573
|
-
usePromptInputController: () =>
|
|
3574
|
-
useProviderAttachments: () =>
|
|
3575
|
-
useReasoning: () =>
|
|
3576
|
-
}),
|
|
3577
|
-
function
|
|
3734
|
+
children: /* @__PURE__ */ Q(na, { size: t })
|
|
3735
|
+
}), ia = /* @__PURE__ */ Ft({
|
|
3736
|
+
CodeBlock: () => si,
|
|
3737
|
+
CodeBlockCopyButton: () => ci,
|
|
3738
|
+
Conversation: () => In,
|
|
3739
|
+
ConversationContent: () => Ln,
|
|
3740
|
+
ConversationEmptyState: () => Rn,
|
|
3741
|
+
ConversationScrollButton: () => zn,
|
|
3742
|
+
Loader: () => ra,
|
|
3743
|
+
Message: () => Un,
|
|
3744
|
+
MessageAction: () => Kn,
|
|
3745
|
+
MessageActions: () => Gn,
|
|
3746
|
+
MessageAttachment: () => nr,
|
|
3747
|
+
MessageAttachments: () => rr,
|
|
3748
|
+
MessageBranch: () => Yn,
|
|
3749
|
+
MessageBranchContent: () => Xn,
|
|
3750
|
+
MessageBranchNext: () => $n,
|
|
3751
|
+
MessageBranchPage: () => er,
|
|
3752
|
+
MessageBranchPrevious: () => Qn,
|
|
3753
|
+
MessageBranchSelector: () => Zn,
|
|
3754
|
+
MessageContent: () => Wn,
|
|
3755
|
+
MessageResponse: () => tr,
|
|
3756
|
+
MessageToolbar: () => ir,
|
|
3757
|
+
PromptInput: () => Cr,
|
|
3758
|
+
PromptInputActionAddAttachments: () => Sr,
|
|
3759
|
+
PromptInputActionMenu: () => Ar,
|
|
3760
|
+
PromptInputActionMenuContent: () => Mr,
|
|
3761
|
+
PromptInputActionMenuItem: () => Nr,
|
|
3762
|
+
PromptInputActionMenuTrigger: () => jr,
|
|
3763
|
+
PromptInputAttachment: () => br,
|
|
3764
|
+
PromptInputAttachments: () => xr,
|
|
3765
|
+
PromptInputBody: () => wr,
|
|
3766
|
+
PromptInputButton: () => kr,
|
|
3767
|
+
PromptInputCommand: () => Yr,
|
|
3768
|
+
PromptInputCommandEmpty: () => Qr,
|
|
3769
|
+
PromptInputCommandGroup: () => $r,
|
|
3770
|
+
PromptInputCommandInput: () => Xr,
|
|
3771
|
+
PromptInputCommandItem: () => ei,
|
|
3772
|
+
PromptInputCommandList: () => Zr,
|
|
3773
|
+
PromptInputCommandSeparator: () => ti,
|
|
3774
|
+
PromptInputFooter: () => Dr,
|
|
3775
|
+
PromptInputHeader: () => Er,
|
|
3776
|
+
PromptInputHoverCard: () => Vr,
|
|
3777
|
+
PromptInputHoverCardContent: () => Ur,
|
|
3778
|
+
PromptInputHoverCardTrigger: () => Hr,
|
|
3779
|
+
PromptInputProvider: () => _r,
|
|
3780
|
+
PromptInputSelect: () => Ir,
|
|
3781
|
+
PromptInputSelectContent: () => Rr,
|
|
3782
|
+
PromptInputSelectItem: () => zr,
|
|
3783
|
+
PromptInputSelectTrigger: () => Lr,
|
|
3784
|
+
PromptInputSelectValue: () => Br,
|
|
3785
|
+
PromptInputSpeechButton: () => Fr,
|
|
3786
|
+
PromptInputSubmit: () => Pr,
|
|
3787
|
+
PromptInputTab: () => Gr,
|
|
3788
|
+
PromptInputTabBody: () => qr,
|
|
3789
|
+
PromptInputTabItem: () => Jr,
|
|
3790
|
+
PromptInputTabLabel: () => Kr,
|
|
3791
|
+
PromptInputTabsList: () => Wr,
|
|
3792
|
+
PromptInputTextarea: () => Tr,
|
|
3793
|
+
PromptInputTools: () => Or,
|
|
3794
|
+
Reasoning: () => bi,
|
|
3795
|
+
ReasoningContent: () => Ci,
|
|
3796
|
+
ReasoningTrigger: () => Si,
|
|
3797
|
+
Shimmer: () => hi,
|
|
3798
|
+
Source: () => Di,
|
|
3799
|
+
Sources: () => wi,
|
|
3800
|
+
SourcesContent: () => Ei,
|
|
3801
|
+
SourcesTrigger: () => Ti,
|
|
3802
|
+
Suggestion: () => ri,
|
|
3803
|
+
Suggestions: () => ni,
|
|
3804
|
+
Tool: () => li,
|
|
3805
|
+
ToolContent: () => fi,
|
|
3806
|
+
ToolHeader: () => di,
|
|
3807
|
+
ToolInput: () => pi,
|
|
3808
|
+
ToolOutput: () => mi,
|
|
3809
|
+
highlightCode: () => oi,
|
|
3810
|
+
usePromptInputAttachments: () => yr,
|
|
3811
|
+
usePromptInputController: () => pr,
|
|
3812
|
+
useProviderAttachments: () => hr,
|
|
3813
|
+
useReasoning: () => _i
|
|
3814
|
+
}), aa = "/api/v1/ai";
|
|
3815
|
+
function oa(e, t, n) {
|
|
3578
3816
|
let r = e.replace(/\/$/, ""), i = new URLSearchParams();
|
|
3579
3817
|
if (n) for (let [e, t] of Object.entries(n)) t == null || t === "" || i.set(e, String(t));
|
|
3580
3818
|
let a = i.toString();
|
|
3581
3819
|
return `${r}${t}${a ? `?${a}` : ""}`;
|
|
3582
3820
|
}
|
|
3583
|
-
async function
|
|
3821
|
+
async function sa(e, t, n) {
|
|
3584
3822
|
let r = await fetch(e, {
|
|
3585
3823
|
credentials: "include",
|
|
3586
3824
|
...t,
|
|
@@ -3600,8 +3838,8 @@ async function ea(e, t, n) {
|
|
|
3600
3838
|
}
|
|
3601
3839
|
return i;
|
|
3602
3840
|
}
|
|
3603
|
-
function
|
|
3604
|
-
let { apiBase: n =
|
|
3841
|
+
function ca(t = {}) {
|
|
3842
|
+
let { apiBase: n = aa, status: r = "pending", conversationId: i, limit: a, headers: o, pollInterval: s = 5e3, enabled: c = !0 } = t, [l, u] = e.useState([]), [d, f] = e.useState(0), [p, m] = e.useState(!1), [h, g] = e.useState(void 0), _ = e.useRef({
|
|
3605
3843
|
apiBase: n,
|
|
3606
3844
|
status: r,
|
|
3607
3845
|
conversationId: i,
|
|
@@ -3619,7 +3857,7 @@ function ta(t = {}) {
|
|
|
3619
3857
|
let { apiBase: e, status: t, conversationId: n, limit: r, headers: i } = _.current;
|
|
3620
3858
|
m(!0), g(void 0);
|
|
3621
3859
|
try {
|
|
3622
|
-
let a = await
|
|
3860
|
+
let a = await sa(oa(e, "/pending-actions", {
|
|
3623
3861
|
status: t && t !== "all" ? t : void 0,
|
|
3624
3862
|
conversationId: n,
|
|
3625
3863
|
limit: r
|
|
@@ -3631,9 +3869,9 @@ function ta(t = {}) {
|
|
|
3631
3869
|
m(!1);
|
|
3632
3870
|
}
|
|
3633
3871
|
}, []), y = e.useCallback(async (e) => {
|
|
3634
|
-
let { apiBase: t, headers: n } = _.current, r =
|
|
3872
|
+
let { apiBase: t, headers: n } = _.current, r = oa(t, `/pending-actions/${encodeURIComponent(e)}/approve`);
|
|
3635
3873
|
try {
|
|
3636
|
-
return await
|
|
3874
|
+
return await sa(r, {
|
|
3637
3875
|
method: "POST",
|
|
3638
3876
|
body: "{}"
|
|
3639
3877
|
}, n);
|
|
@@ -3641,9 +3879,9 @@ function ta(t = {}) {
|
|
|
3641
3879
|
v();
|
|
3642
3880
|
}
|
|
3643
3881
|
}, [v]), b = e.useCallback(async (e, t) => {
|
|
3644
|
-
let { apiBase: n, headers: r } = _.current, i =
|
|
3882
|
+
let { apiBase: n, headers: r } = _.current, i = oa(n, `/pending-actions/${encodeURIComponent(e)}/reject`);
|
|
3645
3883
|
try {
|
|
3646
|
-
return await
|
|
3884
|
+
return await sa(i, {
|
|
3647
3885
|
method: "POST",
|
|
3648
3886
|
body: JSON.stringify(t ? { reason: t } : {})
|
|
3649
3887
|
}, r);
|
|
@@ -3677,7 +3915,7 @@ function ta(t = {}) {
|
|
|
3677
3915
|
}
|
|
3678
3916
|
//#endregion
|
|
3679
3917
|
//#region src/AiPendingActionsInbox.tsx
|
|
3680
|
-
var
|
|
3918
|
+
var la = {
|
|
3681
3919
|
pending: {
|
|
3682
3920
|
variant: "secondary",
|
|
3683
3921
|
label: "Pending"
|
|
@@ -3699,8 +3937,8 @@ var na = {
|
|
|
3699
3937
|
label: "Rejected"
|
|
3700
3938
|
}
|
|
3701
3939
|
};
|
|
3702
|
-
function
|
|
3703
|
-
let t =
|
|
3940
|
+
function ua({ status: e }) {
|
|
3941
|
+
let t = la[e] ?? {
|
|
3704
3942
|
variant: "outline",
|
|
3705
3943
|
label: e
|
|
3706
3944
|
};
|
|
@@ -3709,7 +3947,7 @@ function ra({ status: e }) {
|
|
|
3709
3947
|
children: t.label
|
|
3710
3948
|
});
|
|
3711
3949
|
}
|
|
3712
|
-
function
|
|
3950
|
+
function da(e) {
|
|
3713
3951
|
if (!e) return "—";
|
|
3714
3952
|
let t = Date.parse(e);
|
|
3715
3953
|
if (Number.isNaN(t)) return e;
|
|
@@ -3727,7 +3965,7 @@ function ia(e) {
|
|
|
3727
3965
|
return e;
|
|
3728
3966
|
}
|
|
3729
3967
|
}
|
|
3730
|
-
function
|
|
3968
|
+
function fa(e) {
|
|
3731
3969
|
if (!e) return null;
|
|
3732
3970
|
try {
|
|
3733
3971
|
return JSON.parse(e);
|
|
@@ -3735,7 +3973,7 @@ function aa(e) {
|
|
|
3735
3973
|
return e;
|
|
3736
3974
|
}
|
|
3737
3975
|
}
|
|
3738
|
-
function
|
|
3976
|
+
function pa({ value: e, max: t = 320 }) {
|
|
3739
3977
|
let n = typeof e == "string" ? e : JSON.stringify(e, null, 2);
|
|
3740
3978
|
return n == null || n === "" ? /* @__PURE__ */ Q("span", {
|
|
3741
3979
|
className: "text-muted-foreground text-xs",
|
|
@@ -3746,24 +3984,24 @@ function oa({ value: e, max: t = 320 }) {
|
|
|
3746
3984
|
children: n
|
|
3747
3985
|
});
|
|
3748
3986
|
}
|
|
3749
|
-
function
|
|
3987
|
+
function ma(e) {
|
|
3750
3988
|
switch (e) {
|
|
3751
3989
|
case "pending": return "pending";
|
|
3752
3990
|
case "all": return "all";
|
|
3753
3991
|
case "decided": return "all";
|
|
3754
3992
|
}
|
|
3755
3993
|
}
|
|
3756
|
-
function
|
|
3757
|
-
let [l, u] = e.useState("pending"), [d, m] = e.useState(null), [h, g] = e.useState(null), [_, w] = e.useState(""), [T, E] = e.useState(null), [D, O] = e.useState(null), [k, A] = e.useState(null), { items: j, isLoading: M, error: N, refresh:
|
|
3994
|
+
function ha({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i, variant: a = "card", title: o = "AI Approvals", description: s = "Actions an AI agent proposed that need a human review before execution.", className: c }) {
|
|
3995
|
+
let [l, u] = e.useState("pending"), [d, m] = e.useState(null), [h, g] = e.useState(null), [_, w] = e.useState(""), [T, E] = e.useState(null), [D, O] = e.useState(null), [k, A] = e.useState(null), { items: j, isLoading: M, error: N, refresh: P, approve: ee, reject: F } = ca({
|
|
3758
3996
|
apiBase: t,
|
|
3759
3997
|
headers: n,
|
|
3760
3998
|
pollInterval: r,
|
|
3761
3999
|
conversationId: i,
|
|
3762
|
-
status:
|
|
3763
|
-
}),
|
|
4000
|
+
status: ma(l)
|
|
4001
|
+
}), I = e.useMemo(() => l === "decided" ? j.filter((e) => e.status !== "pending") : j, [j, l]), R = e.useMemo(() => d ? j.find((e) => e.id === d) ?? null : null, [d, j]), ae = e.useCallback(async (e) => {
|
|
3764
4002
|
E(e), O(null);
|
|
3765
4003
|
try {
|
|
3766
|
-
let t = await
|
|
4004
|
+
let t = await ee(e), n = t.status === "executed";
|
|
3767
4005
|
A({
|
|
3768
4006
|
id: e,
|
|
3769
4007
|
kind: "approve",
|
|
@@ -3781,10 +4019,10 @@ function ca({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
|
|
|
3781
4019
|
} finally {
|
|
3782
4020
|
E(null);
|
|
3783
4021
|
}
|
|
3784
|
-
}, [
|
|
4022
|
+
}, [ee]), oe = e.useCallback(async (e, t) => {
|
|
3785
4023
|
E(e), O(null);
|
|
3786
4024
|
try {
|
|
3787
|
-
await
|
|
4025
|
+
await F(e, t.trim() || void 0), A({
|
|
3788
4026
|
id: e,
|
|
3789
4027
|
kind: "reject",
|
|
3790
4028
|
ok: !0,
|
|
@@ -3801,24 +4039,24 @@ function ca({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
|
|
|
3801
4039
|
} finally {
|
|
3802
4040
|
E(null);
|
|
3803
4041
|
}
|
|
3804
|
-
}, [
|
|
4042
|
+
}, [F]), se = /* @__PURE__ */ $("div", {
|
|
3805
4043
|
className: "space-y-3",
|
|
3806
4044
|
children: [
|
|
3807
4045
|
/* @__PURE__ */ $("div", {
|
|
3808
4046
|
className: "flex items-center justify-between gap-2",
|
|
3809
|
-
children: [/* @__PURE__ */ Q(
|
|
4047
|
+
children: [/* @__PURE__ */ Q(U, {
|
|
3810
4048
|
value: l,
|
|
3811
4049
|
onValueChange: (e) => u(e),
|
|
3812
|
-
children: /* @__PURE__ */ $(
|
|
3813
|
-
/* @__PURE__ */ Q(
|
|
4050
|
+
children: /* @__PURE__ */ $(W, { children: [
|
|
4051
|
+
/* @__PURE__ */ Q(G, {
|
|
3814
4052
|
value: "pending",
|
|
3815
4053
|
children: "Pending"
|
|
3816
4054
|
}),
|
|
3817
|
-
/* @__PURE__ */ Q(
|
|
4055
|
+
/* @__PURE__ */ Q(G, {
|
|
3818
4056
|
value: "decided",
|
|
3819
4057
|
children: "Decided"
|
|
3820
4058
|
}),
|
|
3821
|
-
/* @__PURE__ */ Q(
|
|
4059
|
+
/* @__PURE__ */ Q(G, {
|
|
3822
4060
|
value: "all",
|
|
3823
4061
|
children: "All"
|
|
3824
4062
|
})
|
|
@@ -3826,7 +4064,7 @@ function ca({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
|
|
|
3826
4064
|
}), /* @__PURE__ */ $(v, {
|
|
3827
4065
|
variant: "outline",
|
|
3828
4066
|
size: "sm",
|
|
3829
|
-
onClick: () => void
|
|
4067
|
+
onClick: () => void P(),
|
|
3830
4068
|
disabled: M,
|
|
3831
4069
|
"data-testid": "ai-inbox-refresh",
|
|
3832
4070
|
children: [/* @__PURE__ */ Q(st, { className: `h-3.5 w-3.5 mr-1.5 ${M ? "animate-spin" : ""}` }), "Refresh"]
|
|
@@ -3834,15 +4072,15 @@ function ca({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
|
|
|
3834
4072
|
}),
|
|
3835
4073
|
N ? /* @__PURE__ */ $(f, {
|
|
3836
4074
|
variant: "destructive",
|
|
3837
|
-
children: [/* @__PURE__ */ Q(
|
|
4075
|
+
children: [/* @__PURE__ */ Q(ke, { className: "h-4 w-4" }), /* @__PURE__ */ Q(p, { children: N.message })]
|
|
3838
4076
|
}) : null,
|
|
3839
4077
|
D ? /* @__PURE__ */ $(f, {
|
|
3840
4078
|
variant: "destructive",
|
|
3841
|
-
children: [/* @__PURE__ */ Q(
|
|
4079
|
+
children: [/* @__PURE__ */ Q(ke, { className: "h-4 w-4" }), /* @__PURE__ */ Q(p, { children: D })]
|
|
3842
4080
|
}) : null,
|
|
3843
4081
|
k && !D ? /* @__PURE__ */ $(f, {
|
|
3844
4082
|
variant: k.ok ? "default" : "destructive",
|
|
3845
|
-
children: [k.ok ? /* @__PURE__ */ Q(
|
|
4083
|
+
children: [k.ok ? /* @__PURE__ */ Q(J, { className: "h-4 w-4" }) : /* @__PURE__ */ Q(X, { className: "h-4 w-4" }), /* @__PURE__ */ $(p, { children: [
|
|
3846
4084
|
k.kind === "approve" ? "Approve" : "Reject",
|
|
3847
4085
|
" for",
|
|
3848
4086
|
" ",
|
|
@@ -3855,72 +4093,72 @@ function ca({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
|
|
|
3855
4093
|
k.message ?? (k.ok ? "OK" : "Failed")
|
|
3856
4094
|
] })]
|
|
3857
4095
|
}) : null,
|
|
3858
|
-
M &&
|
|
4096
|
+
M && I.length === 0 ? /* @__PURE__ */ $("div", {
|
|
3859
4097
|
className: "space-y-2",
|
|
3860
4098
|
children: [
|
|
3861
|
-
/* @__PURE__ */ Q(
|
|
3862
|
-
/* @__PURE__ */ Q(
|
|
3863
|
-
/* @__PURE__ */ Q(
|
|
4099
|
+
/* @__PURE__ */ Q(xe, { className: "h-10 w-full" }),
|
|
4100
|
+
/* @__PURE__ */ Q(xe, { className: "h-10 w-full" }),
|
|
4101
|
+
/* @__PURE__ */ Q(xe, { className: "h-10 w-full" })
|
|
3864
4102
|
]
|
|
3865
|
-
}) :
|
|
3866
|
-
/* @__PURE__ */ Q(
|
|
3867
|
-
/* @__PURE__ */ Q(
|
|
3868
|
-
/* @__PURE__ */ Q(
|
|
4103
|
+
}) : I.length === 0 ? /* @__PURE__ */ Q(te, { children: /* @__PURE__ */ $(L, { children: [
|
|
4104
|
+
/* @__PURE__ */ Q(re, { children: /* @__PURE__ */ Q($e, { className: "h-8 w-8 text-muted-foreground" }) }),
|
|
4105
|
+
/* @__PURE__ */ Q(ie, { children: "No actions waiting" }),
|
|
4106
|
+
/* @__PURE__ */ Q(ne, { children: "When the AI proposes a sensitive action it will appear here for review." })
|
|
3869
4107
|
] }) }) : /* @__PURE__ */ Q("div", {
|
|
3870
4108
|
className: "rounded-md border",
|
|
3871
|
-
children: /* @__PURE__ */ $(
|
|
3872
|
-
/* @__PURE__ */ Q(
|
|
4109
|
+
children: /* @__PURE__ */ $(B, { children: [/* @__PURE__ */ Q(Ce, { children: /* @__PURE__ */ $(we, { children: [
|
|
4110
|
+
/* @__PURE__ */ Q(H, {
|
|
3873
4111
|
className: "w-[140px]",
|
|
3874
4112
|
children: "Tool"
|
|
3875
4113
|
}),
|
|
3876
|
-
/* @__PURE__ */ Q(
|
|
4114
|
+
/* @__PURE__ */ Q(H, {
|
|
3877
4115
|
className: "w-[140px]",
|
|
3878
4116
|
children: "Action"
|
|
3879
4117
|
}),
|
|
3880
|
-
/* @__PURE__ */ Q(
|
|
4118
|
+
/* @__PURE__ */ Q(H, {
|
|
3881
4119
|
className: "w-[120px]",
|
|
3882
4120
|
children: "Object"
|
|
3883
4121
|
}),
|
|
3884
|
-
/* @__PURE__ */ Q(
|
|
4122
|
+
/* @__PURE__ */ Q(H, {
|
|
3885
4123
|
className: "w-[110px]",
|
|
3886
4124
|
children: "Status"
|
|
3887
4125
|
}),
|
|
3888
|
-
/* @__PURE__ */ Q(
|
|
4126
|
+
/* @__PURE__ */ Q(H, {
|
|
3889
4127
|
className: "w-[110px]",
|
|
3890
4128
|
children: "Proposed"
|
|
3891
4129
|
}),
|
|
3892
|
-
/* @__PURE__ */ Q(
|
|
4130
|
+
/* @__PURE__ */ Q(H, {
|
|
3893
4131
|
className: "w-[260px] text-right",
|
|
3894
4132
|
children: "Decision"
|
|
3895
4133
|
})
|
|
3896
|
-
] }) }), /* @__PURE__ */ Q(
|
|
4134
|
+
] }) }), /* @__PURE__ */ Q(Se, { children: I.map((e) => {
|
|
3897
4135
|
let t = e.status === "pending", n = T === e.id;
|
|
3898
|
-
return /* @__PURE__ */ $(
|
|
3899
|
-
/* @__PURE__ */ Q(
|
|
4136
|
+
return /* @__PURE__ */ $(we, { children: [
|
|
4137
|
+
/* @__PURE__ */ Q(V, {
|
|
3900
4138
|
className: "font-mono text-xs",
|
|
3901
4139
|
children: e.tool_name
|
|
3902
4140
|
}),
|
|
3903
|
-
/* @__PURE__ */ Q(
|
|
4141
|
+
/* @__PURE__ */ Q(V, {
|
|
3904
4142
|
className: "text-sm",
|
|
3905
4143
|
children: e.action_name
|
|
3906
4144
|
}),
|
|
3907
|
-
/* @__PURE__ */ Q(
|
|
4145
|
+
/* @__PURE__ */ Q(V, {
|
|
3908
4146
|
className: "text-sm",
|
|
3909
4147
|
children: e.object_name
|
|
3910
4148
|
}),
|
|
3911
|
-
/* @__PURE__ */ Q(
|
|
3912
|
-
/* @__PURE__ */ Q(
|
|
4149
|
+
/* @__PURE__ */ Q(V, { children: /* @__PURE__ */ Q(ua, { status: e.status }) }),
|
|
4150
|
+
/* @__PURE__ */ Q(V, {
|
|
3913
4151
|
className: "text-xs text-muted-foreground",
|
|
3914
4152
|
children: /* @__PURE__ */ $("span", {
|
|
3915
4153
|
className: "inline-flex items-center gap-1",
|
|
3916
4154
|
children: [
|
|
3917
4155
|
/* @__PURE__ */ Q(He, { className: "h-3 w-3" }),
|
|
3918
4156
|
" ",
|
|
3919
|
-
|
|
4157
|
+
da(e.proposed_at)
|
|
3920
4158
|
]
|
|
3921
4159
|
})
|
|
3922
4160
|
}),
|
|
3923
|
-
/* @__PURE__ */ Q(
|
|
4161
|
+
/* @__PURE__ */ Q(V, {
|
|
3924
4162
|
className: "text-right",
|
|
3925
4163
|
children: /* @__PURE__ */ $("div", {
|
|
3926
4164
|
className: "inline-flex gap-1.5",
|
|
@@ -3934,9 +4172,9 @@ function ca({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
|
|
|
3934
4172
|
size: "sm",
|
|
3935
4173
|
variant: "default",
|
|
3936
4174
|
disabled: n,
|
|
3937
|
-
onClick: () => void
|
|
4175
|
+
onClick: () => void ae(e.id),
|
|
3938
4176
|
"data-testid": `ai-inbox-approve-${e.id}`,
|
|
3939
|
-
children: [/* @__PURE__ */ Q(
|
|
4177
|
+
children: [/* @__PURE__ */ Q(J, { className: "h-3.5 w-3.5 mr-1" }), n ? "Working…" : "Approve"]
|
|
3940
4178
|
}), /* @__PURE__ */ $(v, {
|
|
3941
4179
|
size: "sm",
|
|
3942
4180
|
variant: "destructive",
|
|
@@ -3962,127 +4200,127 @@ function ca({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
|
|
|
3962
4200
|
children: [/* @__PURE__ */ $(C, {
|
|
3963
4201
|
className: "flex items-center gap-2",
|
|
3964
4202
|
children: [
|
|
3965
|
-
/* @__PURE__ */ Q(
|
|
4203
|
+
/* @__PURE__ */ Q(Ne, { className: "h-4 w-4" }),
|
|
3966
4204
|
" ",
|
|
3967
4205
|
o
|
|
3968
4206
|
]
|
|
3969
4207
|
}), s ? /* @__PURE__ */ Q(x, { children: s }) : null]
|
|
3970
|
-
}), /* @__PURE__ */ Q(b, { children:
|
|
4208
|
+
}), /* @__PURE__ */ Q(b, { children: se })]
|
|
3971
4209
|
}) : /* @__PURE__ */ Q("div", {
|
|
3972
4210
|
className: c,
|
|
3973
|
-
children:
|
|
4211
|
+
children: se
|
|
3974
4212
|
}),
|
|
3975
|
-
/* @__PURE__ */ Q(
|
|
4213
|
+
/* @__PURE__ */ Q(ge, {
|
|
3976
4214
|
open: !!d,
|
|
3977
4215
|
onOpenChange: (e) => {
|
|
3978
4216
|
e || m(null);
|
|
3979
4217
|
},
|
|
3980
|
-
children: /* @__PURE__ */ $(
|
|
4218
|
+
children: /* @__PURE__ */ $(_e, {
|
|
3981
4219
|
className: "sm:max-w-[560px] overflow-y-auto",
|
|
3982
|
-
children: [/* @__PURE__ */ $(
|
|
4220
|
+
children: [/* @__PURE__ */ $(ye, { children: [/* @__PURE__ */ $(be, {
|
|
3983
4221
|
className: "flex items-center gap-2",
|
|
3984
|
-
children: [/* @__PURE__ */ Q(
|
|
3985
|
-
}), /* @__PURE__ */ Q(
|
|
4222
|
+
children: [/* @__PURE__ */ Q(Ne, { className: "h-4 w-4" }), R ? R.action_name : "Pending action"]
|
|
4223
|
+
}), /* @__PURE__ */ Q(ve, { children: R ? /* @__PURE__ */ $(Z, { children: [
|
|
3986
4224
|
"Tool ",
|
|
3987
4225
|
/* @__PURE__ */ Q("code", {
|
|
3988
4226
|
className: "text-xs",
|
|
3989
|
-
children:
|
|
4227
|
+
children: R.tool_name
|
|
3990
4228
|
}),
|
|
3991
4229
|
" on",
|
|
3992
4230
|
" ",
|
|
3993
4231
|
/* @__PURE__ */ Q("code", {
|
|
3994
4232
|
className: "text-xs",
|
|
3995
|
-
children:
|
|
4233
|
+
children: R.object_name
|
|
3996
4234
|
})
|
|
3997
|
-
] }) : "Loading…" })] }),
|
|
4235
|
+
] }) : "Loading…" })] }), R ? /* @__PURE__ */ $("div", {
|
|
3998
4236
|
className: "px-4 space-y-4 mt-4",
|
|
3999
4237
|
children: [
|
|
4000
4238
|
/* @__PURE__ */ $("div", {
|
|
4001
4239
|
className: "grid grid-cols-2 gap-3 text-sm",
|
|
4002
4240
|
children: [
|
|
4003
|
-
/* @__PURE__ */ $("div", { children: [/* @__PURE__ */ Q(
|
|
4241
|
+
/* @__PURE__ */ $("div", { children: [/* @__PURE__ */ Q(z, {
|
|
4004
4242
|
className: "text-xs text-muted-foreground",
|
|
4005
4243
|
children: "Status"
|
|
4006
4244
|
}), /* @__PURE__ */ Q("div", {
|
|
4007
4245
|
className: "mt-1",
|
|
4008
|
-
children: /* @__PURE__ */ Q(
|
|
4246
|
+
children: /* @__PURE__ */ Q(ua, { status: R.status })
|
|
4009
4247
|
})] }),
|
|
4010
|
-
/* @__PURE__ */ $("div", { children: [/* @__PURE__ */ Q(
|
|
4248
|
+
/* @__PURE__ */ $("div", { children: [/* @__PURE__ */ Q(z, {
|
|
4011
4249
|
className: "text-xs text-muted-foreground",
|
|
4012
4250
|
children: "Proposed"
|
|
4013
4251
|
}), /* @__PURE__ */ Q("div", {
|
|
4014
4252
|
className: "mt-1 text-xs",
|
|
4015
|
-
children:
|
|
4253
|
+
children: da(R.proposed_at)
|
|
4016
4254
|
})] }),
|
|
4017
|
-
/* @__PURE__ */ $("div", { children: [/* @__PURE__ */ Q(
|
|
4255
|
+
/* @__PURE__ */ $("div", { children: [/* @__PURE__ */ Q(z, {
|
|
4018
4256
|
className: "text-xs text-muted-foreground",
|
|
4019
4257
|
children: "Proposed by"
|
|
4020
4258
|
}), /* @__PURE__ */ Q("div", {
|
|
4021
4259
|
className: "mt-1 text-xs font-mono break-all",
|
|
4022
|
-
children:
|
|
4260
|
+
children: R.proposed_by ?? "—"
|
|
4023
4261
|
})] }),
|
|
4024
|
-
/* @__PURE__ */ $("div", { children: [/* @__PURE__ */ Q(
|
|
4262
|
+
/* @__PURE__ */ $("div", { children: [/* @__PURE__ */ Q(z, {
|
|
4025
4263
|
className: "text-xs text-muted-foreground",
|
|
4026
4264
|
children: "Decided by"
|
|
4027
4265
|
}), /* @__PURE__ */ Q("div", {
|
|
4028
4266
|
className: "mt-1 text-xs font-mono break-all",
|
|
4029
|
-
children:
|
|
4267
|
+
children: R.decided_by ?? "—"
|
|
4030
4268
|
})] }),
|
|
4031
|
-
|
|
4269
|
+
R.conversation_id ? /* @__PURE__ */ $("div", {
|
|
4032
4270
|
className: "col-span-2",
|
|
4033
|
-
children: [/* @__PURE__ */ Q(
|
|
4271
|
+
children: [/* @__PURE__ */ Q(z, {
|
|
4034
4272
|
className: "text-xs text-muted-foreground",
|
|
4035
4273
|
children: "Conversation"
|
|
4036
4274
|
}), /* @__PURE__ */ Q("div", {
|
|
4037
4275
|
className: "mt-1 text-xs font-mono break-all",
|
|
4038
|
-
children:
|
|
4276
|
+
children: R.conversation_id
|
|
4039
4277
|
})]
|
|
4040
4278
|
}) : null
|
|
4041
4279
|
]
|
|
4042
4280
|
}),
|
|
4043
|
-
/* @__PURE__ */ Q(
|
|
4044
|
-
/* @__PURE__ */ $("div", { children: [/* @__PURE__ */ Q(
|
|
4281
|
+
/* @__PURE__ */ Q(he, {}),
|
|
4282
|
+
/* @__PURE__ */ $("div", { children: [/* @__PURE__ */ Q(z, {
|
|
4045
4283
|
className: "text-xs",
|
|
4046
4284
|
children: "Tool input"
|
|
4047
4285
|
}), /* @__PURE__ */ Q("div", {
|
|
4048
4286
|
className: "mt-1.5",
|
|
4049
|
-
children: /* @__PURE__ */ Q(
|
|
4287
|
+
children: /* @__PURE__ */ Q(pa, { value: fa(R.tool_input) })
|
|
4050
4288
|
})] }),
|
|
4051
|
-
|
|
4289
|
+
R.result ? /* @__PURE__ */ $("div", { children: [/* @__PURE__ */ Q(z, {
|
|
4052
4290
|
className: "text-xs",
|
|
4053
4291
|
children: "Result"
|
|
4054
4292
|
}), /* @__PURE__ */ Q("div", {
|
|
4055
4293
|
className: "mt-1.5",
|
|
4056
|
-
children: /* @__PURE__ */ Q(
|
|
4294
|
+
children: /* @__PURE__ */ Q(pa, { value: fa(R.result) })
|
|
4057
4295
|
})] }) : null,
|
|
4058
|
-
|
|
4296
|
+
R.error ? /* @__PURE__ */ $("div", { children: [/* @__PURE__ */ Q(z, {
|
|
4059
4297
|
className: "text-xs text-destructive",
|
|
4060
4298
|
children: "Error"
|
|
4061
4299
|
}), /* @__PURE__ */ Q("div", {
|
|
4062
4300
|
className: "mt-1.5",
|
|
4063
|
-
children: /* @__PURE__ */ Q(
|
|
4301
|
+
children: /* @__PURE__ */ Q(pa, { value: R.error })
|
|
4064
4302
|
})] }) : null,
|
|
4065
|
-
|
|
4303
|
+
R.rejection_reason ? /* @__PURE__ */ $("div", { children: [/* @__PURE__ */ Q(z, {
|
|
4066
4304
|
className: "text-xs",
|
|
4067
4305
|
children: "Rejection reason"
|
|
4068
4306
|
}), /* @__PURE__ */ Q("div", {
|
|
4069
4307
|
className: "mt-1.5 text-sm",
|
|
4070
|
-
children:
|
|
4308
|
+
children: R.rejection_reason
|
|
4071
4309
|
})] }) : null,
|
|
4072
|
-
|
|
4310
|
+
R.status === "pending" ? /* @__PURE__ */ $("div", {
|
|
4073
4311
|
className: "pt-2 flex gap-2",
|
|
4074
4312
|
children: [/* @__PURE__ */ $(v, {
|
|
4075
4313
|
size: "sm",
|
|
4076
|
-
onClick: () => void R
|
|
4077
|
-
disabled: T ===
|
|
4078
|
-
children: [/* @__PURE__ */ Q(
|
|
4314
|
+
onClick: () => void ae(R.id),
|
|
4315
|
+
disabled: T === R.id,
|
|
4316
|
+
children: [/* @__PURE__ */ Q(J, { className: "h-3.5 w-3.5 mr-1" }), "Approve & Execute"]
|
|
4079
4317
|
}), /* @__PURE__ */ $(v, {
|
|
4080
4318
|
size: "sm",
|
|
4081
4319
|
variant: "destructive",
|
|
4082
4320
|
onClick: () => {
|
|
4083
|
-
g(
|
|
4321
|
+
g(R.id), w("");
|
|
4084
4322
|
},
|
|
4085
|
-
disabled: T ===
|
|
4323
|
+
disabled: T === R.id,
|
|
4086
4324
|
children: [/* @__PURE__ */ Q(X, { className: "h-3.5 w-3.5 mr-1" }), "Reject"]
|
|
4087
4325
|
})]
|
|
4088
4326
|
}) : null
|
|
@@ -4090,17 +4328,17 @@ function ca({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
|
|
|
4090
4328
|
}) : null]
|
|
4091
4329
|
})
|
|
4092
4330
|
}),
|
|
4093
|
-
/* @__PURE__ */ Q(
|
|
4331
|
+
/* @__PURE__ */ Q(ge, {
|
|
4094
4332
|
open: !!h,
|
|
4095
4333
|
onOpenChange: (e) => {
|
|
4096
4334
|
e || (g(null), w(""));
|
|
4097
4335
|
},
|
|
4098
|
-
children: /* @__PURE__ */ $(
|
|
4336
|
+
children: /* @__PURE__ */ $(_e, {
|
|
4099
4337
|
side: "bottom",
|
|
4100
4338
|
className: "max-h-[40vh]",
|
|
4101
|
-
children: [/* @__PURE__ */ $(
|
|
4339
|
+
children: [/* @__PURE__ */ $(ye, { children: [/* @__PURE__ */ Q(be, { children: "Reject this action?" }), /* @__PURE__ */ Q(ve, { children: "The reason is shown back to the AI so it can adjust its next response." })] }), /* @__PURE__ */ $("div", {
|
|
4102
4340
|
className: "px-4 mt-3 space-y-3",
|
|
4103
|
-
children: [/* @__PURE__ */ Q(
|
|
4341
|
+
children: [/* @__PURE__ */ Q(Te, {
|
|
4104
4342
|
value: _,
|
|
4105
4343
|
onChange: (e) => w(e.target.value),
|
|
4106
4344
|
placeholder: "Optional reason (e.g. 'Wrong record id — please confirm with the user first.')",
|
|
@@ -4118,7 +4356,7 @@ function ca({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
|
|
|
4118
4356
|
}), /* @__PURE__ */ $(v, {
|
|
4119
4357
|
variant: "destructive",
|
|
4120
4358
|
size: "sm",
|
|
4121
|
-
onClick: () => h && void
|
|
4359
|
+
onClick: () => h && void oe(h, _),
|
|
4122
4360
|
disabled: !h || T === h,
|
|
4123
4361
|
"data-testid": "ai-inbox-reject-confirm",
|
|
4124
4362
|
children: [/* @__PURE__ */ Q(X, { className: "h-3.5 w-3.5 mr-1" }), "Reject"]
|
|
@@ -4131,14 +4369,14 @@ function ca({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
|
|
|
4131
4369
|
}
|
|
4132
4370
|
//#endregion
|
|
4133
4371
|
//#region src/useHitlInChat.ts
|
|
4134
|
-
function
|
|
4372
|
+
function ga(e) {
|
|
4135
4373
|
return !e || e.length === 0 ? "/api/v1/ai" : e.endsWith("/") ? e.slice(0, -1) : e;
|
|
4136
4374
|
}
|
|
4137
|
-
function
|
|
4375
|
+
function _a(e, t) {
|
|
4138
4376
|
let n = { ...e ?? {} };
|
|
4139
4377
|
return t && (n["Content-Type"] = "application/json"), n;
|
|
4140
4378
|
}
|
|
4141
|
-
async function
|
|
4379
|
+
async function va(e) {
|
|
4142
4380
|
let t = await e.text();
|
|
4143
4381
|
if (!t) return null;
|
|
4144
4382
|
try {
|
|
@@ -4147,8 +4385,8 @@ async function da(e) {
|
|
|
4147
4385
|
return { raw: t };
|
|
4148
4386
|
}
|
|
4149
4387
|
}
|
|
4150
|
-
function
|
|
4151
|
-
let { messages: n, apiBase: r, headers: i, onDecided: a, continueConversation: o } = t, s =
|
|
4388
|
+
function ya(t) {
|
|
4389
|
+
let { messages: n, apiBase: r, headers: i, onDecided: a, continueConversation: o } = t, s = ga(r), c = e.useMemo(() => {
|
|
4152
4390
|
let e = /* @__PURE__ */ new Map();
|
|
4153
4391
|
for (let t of n) {
|
|
4154
4392
|
let n = t.toolInvocations ?? [];
|
|
@@ -4191,9 +4429,9 @@ function fa(t) {
|
|
|
4191
4429
|
let r = `${s}/pending-actions/${encodeURIComponent(l)}/${t ? "approve" : "reject"}`, c = t ? "{}" : JSON.stringify({ reason: n ?? "" }), d = await fetch(r, {
|
|
4192
4430
|
method: "POST",
|
|
4193
4431
|
credentials: "include",
|
|
4194
|
-
headers:
|
|
4432
|
+
headers: _a(i, !0),
|
|
4195
4433
|
body: c
|
|
4196
|
-
}), f = await
|
|
4434
|
+
}), f = await va(d) ?? {};
|
|
4197
4435
|
if (!d.ok) {
|
|
4198
4436
|
let t = typeof f.error == "string" ? f.error : `Approval failed: HTTP ${d.status}`;
|
|
4199
4437
|
m(e, {
|
|
@@ -4220,7 +4458,7 @@ function fa(t) {
|
|
|
4220
4458
|
state: "success",
|
|
4221
4459
|
message: `Status: ${p}`
|
|
4222
4460
|
}), h = !0), a?.(e, f), h && o) {
|
|
4223
|
-
let r =
|
|
4461
|
+
let r = ba({
|
|
4224
4462
|
approved: t,
|
|
4225
4463
|
status: p,
|
|
4226
4464
|
toolName: u,
|
|
@@ -4255,24 +4493,24 @@ function fa(t) {
|
|
|
4255
4493
|
isDeciding: f
|
|
4256
4494
|
};
|
|
4257
4495
|
}
|
|
4258
|
-
function
|
|
4496
|
+
function ba(e) {
|
|
4259
4497
|
let { approved: t, status: n, toolName: r, pendingActionId: i, outcome: a, reason: o } = e, s = `[HITL ${i}]`;
|
|
4260
4498
|
if (t && n === "executed") {
|
|
4261
4499
|
let e = a.result;
|
|
4262
|
-
return `${s} The operator approved the \`${r}\` call. It executed successfully with result: ${e == null ? "(no payload)" : typeof e == "string" ? e :
|
|
4500
|
+
return `${s} The operator approved the \`${r}\` call. It executed successfully with result: ${e == null ? "(no payload)" : typeof e == "string" ? e : xa(JSON.stringify(e), 800)}. Acknowledge the outcome concisely and continue the user's task.`;
|
|
4263
4501
|
}
|
|
4264
4502
|
if (!t && n === "rejected") return `${s} The operator rejected the \`${r}\` call.${o && o.trim().length > 0 ? ` Reason: ${o}.` : ""} Acknowledge the rejection and ask whether to try a different approach.`;
|
|
4265
4503
|
if (n === "failed") {
|
|
4266
4504
|
let e = a.error;
|
|
4267
|
-
return `${s} The \`${r}\` call was approved but execution failed: ${typeof e == "string" ? e :
|
|
4505
|
+
return `${s} The \`${r}\` call was approved but execution failed: ${typeof e == "string" ? e : xa(JSON.stringify(e ?? {}), 400)}. Apologize concisely and offer alternatives.`;
|
|
4268
4506
|
}
|
|
4269
4507
|
}
|
|
4270
|
-
function
|
|
4508
|
+
function xa(e, t) {
|
|
4271
4509
|
return e.length <= t ? e : `${e.slice(0, t - 1)}…`;
|
|
4272
4510
|
}
|
|
4273
4511
|
//#endregion
|
|
4274
4512
|
//#region src/index.tsx
|
|
4275
|
-
var
|
|
4513
|
+
var Sa = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type your message...", onSendMessage: i, disabled: a = !1, showTimestamp: o = !1, userAvatarUrl: s, userAvatarFallback: c = "You", assistantAvatarUrl: l, assistantAvatarFallback: u = "AI", maxHeight: d = "500px", ...f }, p) => {
|
|
4276
4514
|
let [m, h] = e.useState(""), g = e.useRef(null), _ = e.useRef(null);
|
|
4277
4515
|
e.useEffect(() => {
|
|
4278
4516
|
if (g.current) {
|
|
@@ -4287,10 +4525,10 @@ var ha = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
4287
4525
|
};
|
|
4288
4526
|
return /* @__PURE__ */ $("div", {
|
|
4289
4527
|
ref: p,
|
|
4290
|
-
className:
|
|
4528
|
+
className: q("flex flex-col border rounded-lg bg-background overflow-hidden", t),
|
|
4291
4529
|
style: { maxHeight: d },
|
|
4292
4530
|
...f,
|
|
4293
|
-
children: [/* @__PURE__ */ Q(
|
|
4531
|
+
children: [/* @__PURE__ */ Q(ce, {
|
|
4294
4532
|
ref: g,
|
|
4295
4533
|
className: "flex-1 p-4",
|
|
4296
4534
|
children: /* @__PURE__ */ Q("div", {
|
|
@@ -4298,7 +4536,7 @@ var ha = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
4298
4536
|
children: n.length === 0 ? /* @__PURE__ */ Q("div", {
|
|
4299
4537
|
className: "flex items-center justify-center h-32 text-muted-foreground text-sm",
|
|
4300
4538
|
children: "No messages yet. Start a conversation!"
|
|
4301
|
-
}) : n.map((e) => /* @__PURE__ */ Q(
|
|
4539
|
+
}) : n.map((e) => /* @__PURE__ */ Q(Ca, {
|
|
4302
4540
|
message: e,
|
|
4303
4541
|
showTimestamp: o,
|
|
4304
4542
|
userAvatarUrl: s,
|
|
@@ -4311,7 +4549,7 @@ var ha = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
4311
4549
|
className: "border-t p-4",
|
|
4312
4550
|
children: /* @__PURE__ */ $("div", {
|
|
4313
4551
|
className: "flex gap-2",
|
|
4314
|
-
children: [/* @__PURE__ */ Q(
|
|
4552
|
+
children: [/* @__PURE__ */ Q(se, {
|
|
4315
4553
|
ref: _,
|
|
4316
4554
|
value: m,
|
|
4317
4555
|
onChange: (e) => h(e.target.value),
|
|
@@ -4329,8 +4567,8 @@ var ha = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
4329
4567
|
})]
|
|
4330
4568
|
});
|
|
4331
4569
|
});
|
|
4332
|
-
|
|
4333
|
-
var
|
|
4570
|
+
Sa.displayName = "Chatbot";
|
|
4571
|
+
var Ca = ({ message: e, showTimestamp: t, userAvatarUrl: n, userAvatarFallback: r, assistantAvatarUrl: i, assistantAvatarFallback: a }) => {
|
|
4334
4572
|
let o = e.role === "user";
|
|
4335
4573
|
if (e.role === "system") return /* @__PURE__ */ Q("div", {
|
|
4336
4574
|
className: "flex justify-center",
|
|
@@ -4341,7 +4579,7 @@ var ga = ({ message: e, showTimestamp: t, userAvatarUrl: n, userAvatarFallback:
|
|
|
4341
4579
|
});
|
|
4342
4580
|
let s = o ? e.avatar || n : e.avatar || i, c = o ? e.avatarFallback || r : e.avatarFallback || a;
|
|
4343
4581
|
return /* @__PURE__ */ $("div", {
|
|
4344
|
-
className:
|
|
4582
|
+
className: q("flex gap-3", o ? "flex-row-reverse" : "flex-row"),
|
|
4345
4583
|
children: [/* @__PURE__ */ $(m, {
|
|
4346
4584
|
className: "h-8 w-8",
|
|
4347
4585
|
children: [/* @__PURE__ */ Q(g, { src: s }), /* @__PURE__ */ Q(h, {
|
|
@@ -4349,9 +4587,9 @@ var ga = ({ message: e, showTimestamp: t, userAvatarUrl: n, userAvatarFallback:
|
|
|
4349
4587
|
children: c
|
|
4350
4588
|
})]
|
|
4351
4589
|
}), /* @__PURE__ */ $("div", {
|
|
4352
|
-
className:
|
|
4590
|
+
className: q("flex flex-col gap-1", o ? "items-end" : "items-start"),
|
|
4353
4591
|
children: [/* @__PURE__ */ Q("div", {
|
|
4354
|
-
className:
|
|
4592
|
+
className: q("rounded-lg px-4 py-2 max-w-[70%] break-words", o ? "bg-primary text-primary-foreground" : "bg-muted"),
|
|
4355
4593
|
children: /* @__PURE__ */ Q("p", {
|
|
4356
4594
|
className: "text-sm whitespace-pre-wrap",
|
|
4357
4595
|
children: e.content
|
|
@@ -4362,9 +4600,9 @@ var ga = ({ message: e, showTimestamp: t, userAvatarUrl: n, userAvatarFallback:
|
|
|
4362
4600
|
})]
|
|
4363
4601
|
})]
|
|
4364
4602
|
});
|
|
4365
|
-
},
|
|
4603
|
+
}, wa = e.forwardRef(({ className: e, avatarSrc: t, avatarFallback: n = "AI", ...r }, i) => /* @__PURE__ */ $("div", {
|
|
4366
4604
|
ref: i,
|
|
4367
|
-
className:
|
|
4605
|
+
className: q("flex gap-3", e),
|
|
4368
4606
|
...r,
|
|
4369
4607
|
children: [/* @__PURE__ */ $(m, {
|
|
4370
4608
|
className: "h-8 w-8",
|
|
@@ -4384,6 +4622,6 @@ var ga = ({ message: e, showTimestamp: t, userAvatarUrl: n, userAvatarFallback:
|
|
|
4384
4622
|
})
|
|
4385
4623
|
})]
|
|
4386
4624
|
}));
|
|
4387
|
-
|
|
4625
|
+
wa.displayName = "TypingIndicator";
|
|
4388
4626
|
//#endregion
|
|
4389
|
-
export {
|
|
4627
|
+
export { nn as AGENT_ALIAS_GROUPS, ia as AIElements, ha as AiPendingActionsInbox, Sa as Chatbot, Li as ChatbotEnhanced, ta as FloatingChatbot, kn as FloatingChatbotPanel, _n as FloatingChatbotProvider, Cn as FloatingChatbotTrigger, un as PLATFORM_DEFAULT_AGENT, wa as TypingIndicator, rn as agentAliasGroup, an as agentRouteName, Kt as buildProgressFromDraftReview, Wt as detectDraftResult, Ht as detectProposedPlan, jn as humanizeToolName, ln as isAskAgent, cn as isBuildAgent, sn as isBuiltinAgentName, Oi as publishHealthFromResponse, on as resolveAgentParam, dn as resolveDefaultAgentName, Nn as summarizeChatError, Zt as uiMessageToChatMessage, Qt as uiMessagesToChatMessages, Mn as unwrapToolResult, pn as useAgents, hn as useAiModels, vn as useFloatingChatbot, ya as useHitlInChat, tn as useObjectChat, ca as usePendingActions };
|