@object-ui/plugin-chatbot 7.1.0 → 7.3.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 +19 -0
- package/dist/ChatbotEnhanced.d.ts +17 -0
- 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 +939 -771
- 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,7 +1,7 @@
|
|
|
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
6
|
import { useChat as yt } from "@ai-sdk/react";
|
|
7
7
|
import { DefaultChatTransport as bt } from "ai";
|
|
@@ -111,6 +111,25 @@ function Ht(e) {
|
|
|
111
111
|
};
|
|
112
112
|
}
|
|
113
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) {
|
|
114
133
|
let t = zt(e);
|
|
115
134
|
if (!t || t.status !== "drafted") return;
|
|
116
135
|
let n = [];
|
|
@@ -151,37 +170,38 @@ function Ut(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 = Bt(r), a =
|
|
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 qt(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 Jt(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 Yt(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
253
|
content: Lt(e, n),
|
|
234
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 Qt(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 $t(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,7 +320,9 @@ function en(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
327
|
if (x) return new bt({
|
|
306
328
|
api: t,
|
|
@@ -312,13 +334,16 @@ function en(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 en(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
|
}));
|
|
@@ -354,7 +379,7 @@ function en(e = {}) {
|
|
|
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,19 +392,19 @@ function en(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;
|
|
@@ -389,17 +414,17 @@ function en(e = {}) {
|
|
|
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
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 en(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 nn(e) {
|
|
428
|
-
return tn.find((t) => t.includes(e)) ?? [e];
|
|
429
|
-
}
|
|
451
|
+
var nn = [["build", "metadata_assistant"], ["ask", "data_chat"]];
|
|
430
452
|
function rn(e) {
|
|
431
|
-
return nn(e)[
|
|
453
|
+
return nn.find((t) => t.includes(e)) ?? [e];
|
|
454
|
+
}
|
|
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 on(e) {
|
|
440
|
-
return e != null && tn.some((t) => t.includes(e));
|
|
441
|
-
}
|
|
442
464
|
function sn(e) {
|
|
443
|
-
return e != null &&
|
|
465
|
+
return e != null && nn.some((t) => t.includes(e));
|
|
444
466
|
}
|
|
445
467
|
function cn(e) {
|
|
446
|
-
return e != null &&
|
|
468
|
+
return e != null && an(e) === "build";
|
|
469
|
+
}
|
|
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 dn(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 fn(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 fn(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,19 +600,19 @@ function mn({ 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
617
|
let { t: e } = Ct();
|
|
538
618
|
return (t, n) => {
|
|
@@ -543,7 +623,7 @@ function gn() {
|
|
|
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 _n = {
|
|
|
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 ? gt :
|
|
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 xn = {
|
|
|
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 xn = {
|
|
|
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",
|
|
@@ -669,7 +749,7 @@ function En({ 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 Dn = {
|
|
|
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 kn(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 An(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 Mn(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 Mn(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 Nn = ({ className: e, ...t }) => /* @__PURE__ */ Q(wt, {
|
|
|
769
849
|
children: n
|
|
770
850
|
})]
|
|
771
851
|
})] })
|
|
772
|
-
}),
|
|
852
|
+
}), zn = ({ className: e, ...t }) => {
|
|
773
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
|
|
881
|
+
function Hn({ className: e, asChild: t = !1, ...n }) {
|
|
802
882
|
return /* @__PURE__ */ Q(t ? Dt : "div", {
|
|
803
|
-
className:
|
|
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 Bn = ({ 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 Bn = ({ 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 Bn = ({ 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 Bn = ({ 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 Bn = ({ 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 Bn = ({ 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",
|
|
@@ -941,13 +1021,13 @@ function $n({ data: e, className: t, onRemove: n, ...r }) {
|
|
|
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) => {
|
|
@@ -962,29 +1042,29 @@ function $n({ data: e, className: t, onRemove: n, ...r }) {
|
|
|
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 rr = Et("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,34 +1094,34 @@ var ar = Et("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) => ({
|
|
@@ -1096,25 +1176,25 @@ function mr({ 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",
|
|
@@ -1148,7 +1228,7 @@ function _r({ 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 _r({ 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 yr = ({ 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();
|
|
@@ -1282,9 +1362,9 @@ var yr = ({ 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 yr = ({ 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 yr = ({ 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 yr = ({ 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 yr = ({ 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 yr = ({ 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(vt, { className: "size-4" })), /* @__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 yr = ({ 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 yr = ({ 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,8 +1657,8 @@ var yr = ({ label: e = "Add photos or files", ...t }) => {
|
|
|
1577
1657
|
});
|
|
1578
1658
|
}
|
|
1579
1659
|
};
|
|
1580
|
-
async function
|
|
1581
|
-
let r = n ? [
|
|
1660
|
+
async function oi(e, t, n = !1) {
|
|
1661
|
+
let r = n ? [ai] : [];
|
|
1582
1662
|
return await Promise.all([At(e, {
|
|
1583
1663
|
lang: t,
|
|
1584
1664
|
theme: "one-light",
|
|
@@ -1589,9 +1669,9 @@ async function ri(e, t, n = !1) {
|
|
|
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 ii = ({ 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 ii = ({ 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,25 +1716,25 @@ var ii = ({ 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(
|
|
1736
|
+
"approval-responded": /* @__PURE__ */ Q(Y, { className: "size-4 text-blue-600" }),
|
|
1737
|
+
"output-available": /* @__PURE__ */ Q(Y, { className: "size-4 text-green-600" }),
|
|
1658
1738
|
"output-error": /* @__PURE__ */ Q(_t, { className: "size-4 text-red-600" }),
|
|
1659
1739
|
"output-denied": /* @__PURE__ */ Q(_t, { className: "size-4 text-orange-600" })
|
|
1660
1740
|
}[e], {
|
|
@@ -1666,8 +1746,8 @@ var ii = ({ 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",
|
|
@@ -1677,50 +1757,50 @@ var ii = ({ code: e, language: t, showLineNumbers: n = !1, className: r, childre
|
|
|
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
|
-
},
|
|
1799
|
+
}, hi = a(({ children: e, as: t = "p", className: n, duration: r = 2, spread: i = 2 }) => {
|
|
1720
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,11 +1813,11 @@ var ii = ({ 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
|
-
},
|
|
1820
|
+
}, vi = 1e3, yi = 1e3, bi = a(({ className: e, isStreaming: t = !1, open: n, defaultOpen: r = !0, onOpenChange: i, duration: a, children: o, ...s }) => {
|
|
1741
1821
|
let [l, u] = jt({
|
|
1742
1822
|
prop: n,
|
|
1743
1823
|
defaultProp: r,
|
|
@@ -1747,7 +1827,7 @@ var ii = ({ code: e, language: t, showLineNumbers: n = !1, className: r, childre
|
|
|
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 ii = ({ 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 ii = ({ 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 ii = ({ 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 ii = ({ 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
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 xi = ({ 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 Ti(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 Di(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 Ai(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 ji(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 Mi({ 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,13 +2023,13 @@ function Mi({ 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
|
|
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(() => ({
|
|
1937
2033
|
emptyTitle: E?.emptyTitle ?? "Start a conversation",
|
|
1938
2034
|
emptyDescription: E?.emptyDescription ?? "Ask anything — the assistant has access to your current app context.",
|
|
1939
2035
|
clear: E?.clear ?? "Clear",
|
|
@@ -1956,54 +2052,54 @@ var Ni = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
1956
2052
|
connectionWaiting: E?.connectionWaiting ?? "Waiting for server…",
|
|
1957
2053
|
connectionStalledLabel: E?.connectionStalledLabel ?? "Still working…",
|
|
1958
2054
|
connectionOfflineLabel: E?.connectionOfflineLabel ?? "Connection lost — reconnecting…"
|
|
1959
|
-
}), [E]), [
|
|
1960
|
-
if (
|
|
1961
|
-
let t = await
|
|
1962
|
-
|
|
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) => {
|
|
1963
2059
|
if (n.get(e) === t) return n;
|
|
1964
2060
|
let r = new Map(n);
|
|
1965
2061
|
return r.set(e, t), r;
|
|
1966
2062
|
});
|
|
1967
2063
|
} catch {}
|
|
1968
|
-
}, [
|
|
2064
|
+
}, [B]);
|
|
1969
2065
|
e.useEffect(() => {
|
|
1970
|
-
if (!
|
|
2066
|
+
if (!B || d) return;
|
|
1971
2067
|
let e = /* @__PURE__ */ new Set();
|
|
1972
2068
|
for (let t of n) for (let n of t.toolInvocations ?? []) {
|
|
1973
2069
|
let t = n.draftReview?.packageId, r = n.toolCallId;
|
|
1974
|
-
t && r && !
|
|
2070
|
+
t && r && !Pe.current.has(r) && (Pe.current.add(r), e.add(t));
|
|
1975
2071
|
}
|
|
1976
|
-
for (let t of e)
|
|
2072
|
+
for (let t of e) Y(t);
|
|
1977
2073
|
}, [
|
|
1978
2074
|
n,
|
|
1979
2075
|
d,
|
|
1980
|
-
|
|
1981
|
-
|
|
2076
|
+
B,
|
|
2077
|
+
Y
|
|
1982
2078
|
]);
|
|
1983
|
-
let
|
|
1984
|
-
if (!
|
|
2079
|
+
let Ie = e.useCallback(async (e) => {
|
|
2080
|
+
if (!L) return;
|
|
1985
2081
|
let t = [];
|
|
1986
2082
|
for (let r of n) for (let n of r.toolInvocations ?? []) n.draftReview?.packageId === e && n.toolCallId && t.push(n.toolCallId);
|
|
1987
|
-
let r = await
|
|
2083
|
+
let r = await L(e), i = r && typeof r == "object" ? r : void 0;
|
|
1988
2084
|
if ((i ? i.ok !== !1 : r !== !1) && t.length > 0) {
|
|
1989
|
-
|
|
2085
|
+
De((e) => {
|
|
1990
2086
|
let n = new Set(e);
|
|
1991
2087
|
for (let e of t) n.add(e);
|
|
1992
2088
|
return n;
|
|
1993
2089
|
});
|
|
1994
2090
|
let e = i?.health;
|
|
1995
|
-
e &&
|
|
2091
|
+
e && Ae((n) => {
|
|
1996
2092
|
let r = new Map(n);
|
|
1997
2093
|
for (let n of t) r.set(n, e);
|
|
1998
2094
|
return r;
|
|
1999
2095
|
});
|
|
2000
2096
|
}
|
|
2001
|
-
|
|
2097
|
+
Y(e);
|
|
2002
2098
|
}, [
|
|
2003
|
-
|
|
2099
|
+
L,
|
|
2004
2100
|
n,
|
|
2005
|
-
|
|
2006
|
-
]),
|
|
2101
|
+
Y
|
|
2102
|
+
]), Le = e.useRef(/* @__PURE__ */ new Set()), Re = e.useRef(!1);
|
|
2007
2103
|
e.useEffect(() => {
|
|
2008
2104
|
let e = [];
|
|
2009
2105
|
for (let t of n) for (let n of t.toolInvocations ?? []) {
|
|
@@ -2013,27 +2109,27 @@ var Ni = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2013
2109
|
packageId: t.packageId
|
|
2014
2110
|
});
|
|
2015
2111
|
}
|
|
2016
|
-
if (!
|
|
2017
|
-
|
|
2018
|
-
for (let t of e)
|
|
2112
|
+
if (!Re.current) {
|
|
2113
|
+
Re.current = !0;
|
|
2114
|
+
for (let t of e) Le.current.add(t.key);
|
|
2019
2115
|
return;
|
|
2020
2116
|
}
|
|
2021
|
-
if (!
|
|
2022
|
-
let t = e.filter((e) => !
|
|
2117
|
+
if (!Se || !L || d) return;
|
|
2118
|
+
let t = e.filter((e) => !Le.current.has(e.key));
|
|
2023
2119
|
if (t.length !== 0) {
|
|
2024
|
-
for (let e of t)
|
|
2025
|
-
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);
|
|
2026
2122
|
}
|
|
2027
2123
|
}, [
|
|
2028
2124
|
n,
|
|
2029
2125
|
d,
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2126
|
+
Se,
|
|
2127
|
+
L,
|
|
2128
|
+
Ie
|
|
2033
2129
|
]);
|
|
2034
|
-
let
|
|
2130
|
+
let ze = e.useRef(/* @__PURE__ */ new Set());
|
|
2035
2131
|
e.useEffect(() => {
|
|
2036
|
-
if (!
|
|
2132
|
+
if (!oe) return;
|
|
2037
2133
|
let e = /* @__PURE__ */ new Map(), t;
|
|
2038
2134
|
for (let r of n) {
|
|
2039
2135
|
for (let t of r.buildProgress?.items ?? []) t?.type && t?.name && e.set(`${t.type}:${t.name}`, t);
|
|
@@ -2043,36 +2139,36 @@ var Ni = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2043
2139
|
r?.packageId && r.items?.some((e) => e.type === "app") && (t = r.packageId);
|
|
2044
2140
|
}
|
|
2045
2141
|
}
|
|
2046
|
-
let r =
|
|
2142
|
+
let r = ze.current, i = !1;
|
|
2047
2143
|
for (let t of e.keys()) r.has(t) || (r.add(t), i = !0);
|
|
2048
|
-
i &&
|
|
2049
|
-
}, [n,
|
|
2050
|
-
let
|
|
2144
|
+
i && oe([...e.values()], t);
|
|
2145
|
+
}, [n, oe]);
|
|
2146
|
+
let Be = e.useRef(/* @__PURE__ */ new Set());
|
|
2051
2147
|
e.useEffect(() => {
|
|
2052
|
-
if (
|
|
2148
|
+
if (se) for (let e of n) for (let t of e.toolInvocations ?? []) {
|
|
2053
2149
|
let e = t.draftReview;
|
|
2054
2150
|
if (!e?.materialized || !t.toolCallId) continue;
|
|
2055
2151
|
let n = e.items.find((e) => e.type === "app");
|
|
2056
|
-
!n ||
|
|
2152
|
+
!n || Be.current.has(t.toolCallId) || (Be.current.add(t.toolCallId), se(n.name));
|
|
2057
2153
|
}
|
|
2058
|
-
}, [n,
|
|
2059
|
-
let
|
|
2154
|
+
}, [n, se]);
|
|
2155
|
+
let He = e.useCallback((e) => {
|
|
2060
2156
|
let t = !!e.text?.trim(), n = e.files?.map((e) => e.file).filter(Boolean), r = !!(n && n.length > 0);
|
|
2061
2157
|
(t || r) && i?.(e.text?.trim() ?? "", n);
|
|
2062
|
-
}, [i]),
|
|
2158
|
+
}, [i]), Ue = e.useCallback((e) => {
|
|
2063
2159
|
i?.(e);
|
|
2064
|
-
}, [i]),
|
|
2065
|
-
i?.(e ?
|
|
2160
|
+
}, [i]), We = e.useRef(null), Ke = e.useCallback((e) => {
|
|
2161
|
+
i?.(e ? be : ye);
|
|
2066
2162
|
}, [
|
|
2067
2163
|
i,
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
]),
|
|
2071
|
-
let e =
|
|
2164
|
+
ye,
|
|
2165
|
+
be
|
|
2166
|
+
]), Je = e.useCallback(() => {
|
|
2167
|
+
let e = We.current?.querySelector("textarea");
|
|
2072
2168
|
e && (e.focus(), e.scrollIntoView({ block: "nearest" }));
|
|
2073
|
-
}, []),
|
|
2074
|
-
navigator.clipboard?.writeText(e.content),
|
|
2075
|
-
}, []),
|
|
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(() => {
|
|
2076
2172
|
let e = /* @__PURE__ */ new Set(), t = [], r = -1, i = 0;
|
|
2077
2173
|
for (let e of n) for (let n of e.toolInvocations ?? []) n.proposedPlan && n.toolCallId && t.push({
|
|
2078
2174
|
id: n.toolCallId,
|
|
@@ -2080,8 +2176,20 @@ var Ni = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2080
2176
|
}), n.toolName === "apply_blueprint" && (r = i), i += 1;
|
|
2081
2177
|
for (let n of t) n.order < r && e.add(n.id);
|
|
2082
2178
|
return e;
|
|
2083
|
-
}, [n]),
|
|
2084
|
-
let
|
|
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", {
|
|
2085
2193
|
className: "inline-flex items-center gap-2",
|
|
2086
2194
|
children: [
|
|
2087
2195
|
/* @__PURE__ */ Q("span", { children: s || e.toolName }),
|
|
@@ -2089,18 +2197,18 @@ var Ni = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2089
2197
|
className: "rounded bg-muted px-1 py-px text-[10px] font-mono text-muted-foreground",
|
|
2090
2198
|
children: e.toolName
|
|
2091
2199
|
}) : null,
|
|
2092
|
-
m ? /* @__PURE__ */ Q(
|
|
2200
|
+
m ? /* @__PURE__ */ Q(Ki, { offlineLabel: K.connectionOfflineLabel }) : null
|
|
2093
2201
|
]
|
|
2094
2202
|
});
|
|
2095
|
-
return /* @__PURE__ */ $(
|
|
2096
|
-
defaultOpen: t === "output-error" || t === "approval-requested" || !!(e.draftReview && e.draftReview.items.length > 0) || !!e.proposedPlan,
|
|
2097
|
-
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, {
|
|
2098
2206
|
type: n,
|
|
2099
2207
|
state: t,
|
|
2100
2208
|
title: h
|
|
2101
|
-
}), /* @__PURE__ */ $(
|
|
2102
|
-
u && e.args !== void 0 ? /* @__PURE__ */ Q(
|
|
2103
|
-
o ? null : u || t === "output-error" ? /* @__PURE__ */ Q(
|
|
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, {
|
|
2104
2212
|
output: c,
|
|
2105
2213
|
errorText: e.errorText
|
|
2106
2214
|
}) : null,
|
|
@@ -2117,53 +2225,53 @@ var Ni = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2117
2225
|
type: "button",
|
|
2118
2226
|
onClick: () => N?.(e.toolCallId, !0),
|
|
2119
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",
|
|
2120
|
-
children:
|
|
2228
|
+
children: P
|
|
2121
2229
|
}), /* @__PURE__ */ Q("button", {
|
|
2122
2230
|
type: "button",
|
|
2123
|
-
onClick: () => N?.(e.toolCallId, !1,
|
|
2231
|
+
onClick: () => N?.(e.toolCallId, !1, F),
|
|
2124
2232
|
className: "inline-flex h-7 items-center rounded-md border bg-background px-3 text-xs font-medium hover:bg-accent",
|
|
2125
|
-
children:
|
|
2233
|
+
children: ee
|
|
2126
2234
|
})]
|
|
2127
2235
|
}) : null,
|
|
2128
|
-
e.draftReview && e.draftReview.items.length > 0 && (
|
|
2236
|
+
e.draftReview && e.draftReview.items.length > 0 && (te || L && e.draftReview.packageId) ? /* @__PURE__ */ $(Z, { children: [
|
|
2129
2237
|
/* @__PURE__ */ $("div", {
|
|
2130
2238
|
className: "flex items-center gap-2 p-3 border-t bg-muted/30",
|
|
2131
2239
|
children: [
|
|
2132
|
-
|
|
2240
|
+
L && e.draftReview.packageId ? p ? /* @__PURE__ */ $("span", {
|
|
2133
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",
|
|
2134
2242
|
children: [
|
|
2135
|
-
/* @__PURE__ */ Q(
|
|
2136
|
-
|
|
2243
|
+
/* @__PURE__ */ Q(J, { className: "size-3.5" }),
|
|
2244
|
+
ce,
|
|
2137
2245
|
e.draftReview.failedCount ? ` · ${e.draftReview.failedCount} need${e.draftReview.failedCount === 1 ? "s" : ""} attention` : ""
|
|
2138
2246
|
]
|
|
2139
2247
|
}) : /* @__PURE__ */ $("button", {
|
|
2140
2248
|
type: "button",
|
|
2141
|
-
onClick: () => void
|
|
2249
|
+
onClick: () => void Ie(e.draftReview.packageId),
|
|
2142
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",
|
|
2143
2251
|
"data-testid": "draft-publish",
|
|
2144
2252
|
children: [
|
|
2145
2253
|
/* @__PURE__ */ Q(ct, { className: "size-3.5" }),
|
|
2146
|
-
|
|
2254
|
+
z,
|
|
2147
2255
|
typeof f == "number" && f > 0 ? ` (${f})` : ""
|
|
2148
2256
|
]
|
|
2149
2257
|
}) : null,
|
|
2150
|
-
|
|
2258
|
+
te ? /* @__PURE__ */ $("button", {
|
|
2151
2259
|
type: "button",
|
|
2152
|
-
onClick: () =>
|
|
2153
|
-
className:
|
|
2154
|
-
children: [/* @__PURE__ */ Q(Xe, { className: "size-3.5" }),
|
|
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",
|
|
2262
|
+
children: [/* @__PURE__ */ Q(Xe, { className: "size-3.5" }), ne(e.draftReview.items.length)]
|
|
2155
2263
|
}) : null,
|
|
2156
|
-
|
|
2264
|
+
R && !p ? (() => {
|
|
2157
2265
|
let t = e.draftReview.items.find((e) => e.type === "app");
|
|
2158
2266
|
return t ? /* @__PURE__ */ $("button", {
|
|
2159
2267
|
type: "button",
|
|
2160
|
-
onClick: () =>
|
|
2268
|
+
onClick: () => R(t.name, {
|
|
2161
2269
|
materialized: e.draftReview.materialized === !0,
|
|
2162
2270
|
appSegment: e.draftReview.packageId
|
|
2163
2271
|
}),
|
|
2164
2272
|
className: "inline-flex h-7 items-center gap-1.5 rounded-md border px-3 text-xs font-medium hover:bg-muted",
|
|
2165
2273
|
"data-testid": "draft-preview-app",
|
|
2166
|
-
children: [/* @__PURE__ */ Q(Ye, { className: "size-3.5" }),
|
|
2274
|
+
children: [/* @__PURE__ */ Q(Ye, { className: "size-3.5" }), ae]
|
|
2167
2275
|
}) : null;
|
|
2168
2276
|
})() : null,
|
|
2169
2277
|
e.draftReview.verification ? e.draftReview.verification.errors > 0 ? /* @__PURE__ */ $("span", {
|
|
@@ -2173,7 +2281,7 @@ var Ni = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2173
2281
|
}) : /* @__PURE__ */ $("span", {
|
|
2174
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",
|
|
2175
2283
|
"data-testid": "draft-verification-chip",
|
|
2176
|
-
children: [/* @__PURE__ */ Q(ut, { className: "size-3.5" }),
|
|
2284
|
+
children: [/* @__PURE__ */ Q(ut, { className: "size-3.5" }), le]
|
|
2177
2285
|
}) : null,
|
|
2178
2286
|
e.draftReview.summary ? /* @__PURE__ */ Q("span", {
|
|
2179
2287
|
className: "truncate text-xs text-muted-foreground",
|
|
@@ -2189,16 +2297,16 @@ var Ni = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2189
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 })]
|
|
2190
2298
|
}, `e${t}`)), e.draftReview.issues.filter((e) => e.severity !== "error").map((e, t) => /* @__PURE__ */ $("div", {
|
|
2191
2299
|
className: "flex items-start gap-1.5 text-xs text-amber-600",
|
|
2192
|
-
children: [/* @__PURE__ */ Q(
|
|
2300
|
+
children: [/* @__PURE__ */ Q(ke, { className: "mt-0.5 size-3.5 shrink-0" }), /* @__PURE__ */ Q("span", { children: e.message })]
|
|
2193
2301
|
}, `w${t}`))]
|
|
2194
2302
|
}) : null,
|
|
2195
|
-
|
|
2303
|
+
Ee.has(e.toolCallId) ? /* @__PURE__ */ Q(Ii, { health: Oe.get(e.toolCallId) }) : null,
|
|
2196
2304
|
e.draftReview.nextSteps && e.draftReview.nextSteps.length > 0 ? /* @__PURE__ */ $("div", {
|
|
2197
2305
|
className: "flex flex-col gap-1 border-t bg-muted/20 px-3 py-2",
|
|
2198
2306
|
"data-testid": "draft-next-steps",
|
|
2199
2307
|
children: [/* @__PURE__ */ Q("span", {
|
|
2200
2308
|
className: "text-xs font-medium text-foreground/80",
|
|
2201
|
-
children:
|
|
2309
|
+
children: ue
|
|
2202
2310
|
}), e.draftReview.nextSteps.map((e, t) => /* @__PURE__ */ $("div", {
|
|
2203
2311
|
className: "flex items-start gap-1.5 text-xs text-muted-foreground",
|
|
2204
2312
|
children: [/* @__PURE__ */ Q("span", {
|
|
@@ -2214,8 +2322,19 @@ var Ni = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2214
2322
|
children: [
|
|
2215
2323
|
/* @__PURE__ */ $("span", {
|
|
2216
2324
|
className: "inline-flex items-center gap-1.5 text-xs font-medium text-foreground/80",
|
|
2217
|
-
children: [/* @__PURE__ */ Q(Ve, { className: "size-3.5" }),
|
|
2325
|
+
children: [/* @__PURE__ */ Q(Ve, { className: "size-3.5" }), de]
|
|
2218
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,
|
|
2219
2338
|
e.proposedPlan.summary ? /* @__PURE__ */ Q("p", {
|
|
2220
2339
|
className: "text-xs text-muted-foreground",
|
|
2221
2340
|
children: e.proposedPlan.summary
|
|
@@ -2246,7 +2365,7 @@ var Ni = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2246
2365
|
className: "flex flex-col gap-0.5",
|
|
2247
2366
|
children: [/* @__PURE__ */ Q("span", {
|
|
2248
2367
|
className: "text-[11px] font-medium text-foreground/70",
|
|
2249
|
-
children:
|
|
2368
|
+
children: me
|
|
2250
2369
|
}), e.proposedPlan.assumptions.map((e, t) => /* @__PURE__ */ $("div", {
|
|
2251
2370
|
className: "flex items-start gap-1.5 text-[11px] text-muted-foreground",
|
|
2252
2371
|
children: [/* @__PURE__ */ Q("span", {
|
|
@@ -2260,7 +2379,7 @@ var Ni = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2260
2379
|
"data-testid": "proposed-plan-questions",
|
|
2261
2380
|
children: [/* @__PURE__ */ $("span", {
|
|
2262
2381
|
className: "inline-flex items-center gap-1.5 text-[11px] font-medium text-amber-800 dark:text-amber-300",
|
|
2263
|
-
children: [/* @__PURE__ */ Q(Ze, { className: "size-3.5" }),
|
|
2382
|
+
children: [/* @__PURE__ */ Q(Ze, { className: "size-3.5" }), pe]
|
|
2264
2383
|
}), e.proposedPlan.questions.map((t, n) => {
|
|
2265
2384
|
let r = e.proposedPlan.questionChoices?.find((e) => e.text === t);
|
|
2266
2385
|
return /* @__PURE__ */ $("div", {
|
|
@@ -2276,7 +2395,7 @@ var Ni = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2276
2395
|
"data-testid": "proposed-plan-choice",
|
|
2277
2396
|
children: r.options.map((e, n) => /* @__PURE__ */ Q("button", {
|
|
2278
2397
|
type: "button",
|
|
2279
|
-
onClick: () => i(
|
|
2398
|
+
onClick: () => i(xe(t, e)),
|
|
2280
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",
|
|
2281
2400
|
children: e
|
|
2282
2401
|
}, n))
|
|
@@ -2284,33 +2403,82 @@ var Ni = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2284
2403
|
}, n);
|
|
2285
2404
|
})]
|
|
2286
2405
|
}) : null,
|
|
2287
|
-
i ?
|
|
2406
|
+
i ? $e.has(e.toolCallId) ? /* @__PURE__ */ Q("div", {
|
|
2288
2407
|
className: "flex flex-wrap items-center gap-1.5 pt-0.5",
|
|
2289
2408
|
"data-testid": "proposed-plan-actions",
|
|
2290
2409
|
children: /* @__PURE__ */ $("span", {
|
|
2291
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",
|
|
2292
2411
|
"data-testid": "proposed-plan-built",
|
|
2293
|
-
children: [/* @__PURE__ */ Q(
|
|
2412
|
+
children: [/* @__PURE__ */ Q(J, { className: "size-3.5" }), ve]
|
|
2294
2413
|
})
|
|
2295
2414
|
}) : /* @__PURE__ */ $("div", {
|
|
2296
2415
|
className: "flex flex-wrap items-center gap-1.5 pt-0.5",
|
|
2297
2416
|
"data-testid": "proposed-plan-actions",
|
|
2298
2417
|
children: [/* @__PURE__ */ $("button", {
|
|
2299
2418
|
type: "button",
|
|
2300
|
-
onClick: () =>
|
|
2419
|
+
onClick: () => Ke(e.proposedPlan.questions.length > 0),
|
|
2301
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",
|
|
2302
2421
|
"data-testid": "proposed-plan-approve",
|
|
2303
|
-
children: [/* @__PURE__ */ Q(ct, { className: "size-3.5" }),
|
|
2422
|
+
children: [/* @__PURE__ */ Q(ct, { className: "size-3.5" }), ge]
|
|
2304
2423
|
}), /* @__PURE__ */ Q("button", {
|
|
2305
2424
|
type: "button",
|
|
2306
|
-
onClick:
|
|
2425
|
+
onClick: Je,
|
|
2307
2426
|
className: "inline-flex h-7 items-center rounded-md border bg-background px-3 text-xs font-medium hover:bg-accent",
|
|
2308
2427
|
"data-testid": "proposed-plan-adjust",
|
|
2309
|
-
children:
|
|
2428
|
+
children: _e
|
|
2310
2429
|
})]
|
|
2311
2430
|
}) : /* @__PURE__ */ Q("span", {
|
|
2312
2431
|
className: "text-[11px] italic text-muted-foreground/80",
|
|
2313
|
-
children:
|
|
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: "调整"
|
|
2478
|
+
})]
|
|
2479
|
+
}) : /* @__PURE__ */ Q("span", {
|
|
2480
|
+
className: "text-[11px] italic text-muted-foreground/80",
|
|
2481
|
+
children: "回复以确认或调整该改动。"
|
|
2314
2482
|
})
|
|
2315
2483
|
]
|
|
2316
2484
|
}) : null
|
|
@@ -2318,29 +2486,29 @@ var Ni = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2318
2486
|
}, e.toolCallId);
|
|
2319
2487
|
};
|
|
2320
2488
|
return /* @__PURE__ */ $("div", {
|
|
2321
|
-
ref:
|
|
2322
|
-
className:
|
|
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),
|
|
2323
2491
|
style: { maxHeight: b },
|
|
2324
|
-
...
|
|
2492
|
+
...Ce,
|
|
2325
2493
|
children: [
|
|
2326
2494
|
a && !y && n.length > 0 && /* @__PURE__ */ Q("div", {
|
|
2327
|
-
className:
|
|
2495
|
+
className: q("flex items-center justify-end px-4 py-2", W ? "bg-background" : "border-b bg-muted/30"),
|
|
2328
2496
|
children: /* @__PURE__ */ Q("button", {
|
|
2329
2497
|
type: "button",
|
|
2330
2498
|
onClick: a,
|
|
2331
2499
|
className: "text-xs text-muted-foreground hover:text-foreground transition-colors",
|
|
2332
|
-
children:
|
|
2500
|
+
children: K.clear
|
|
2333
2501
|
})
|
|
2334
2502
|
}),
|
|
2335
2503
|
A ? /* @__PURE__ */ Q("div", {
|
|
2336
|
-
className:
|
|
2504
|
+
className: q("shrink-0", !W && "border-b bg-background/50"),
|
|
2337
2505
|
children: A
|
|
2338
2506
|
}) : null,
|
|
2339
|
-
/* @__PURE__ */ $(
|
|
2507
|
+
/* @__PURE__ */ $(In, {
|
|
2340
2508
|
className: "flex-1 min-h-0",
|
|
2341
|
-
children: [/* @__PURE__ */ $(
|
|
2342
|
-
className:
|
|
2343
|
-
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, {
|
|
2344
2512
|
className: "gap-3 px-0 py-8",
|
|
2345
2513
|
children: [
|
|
2346
2514
|
/* @__PURE__ */ Q("div", {
|
|
@@ -2349,64 +2517,64 @@ var Ni = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2349
2517
|
src: _,
|
|
2350
2518
|
alt: "",
|
|
2351
2519
|
className: "size-full rounded-md object-cover"
|
|
2352
|
-
}) : /* @__PURE__ */ Q(
|
|
2520
|
+
}) : /* @__PURE__ */ Q(Ne, { className: "size-4" })
|
|
2353
2521
|
}),
|
|
2354
2522
|
/* @__PURE__ */ $("div", {
|
|
2355
2523
|
className: "space-y-1",
|
|
2356
2524
|
children: [/* @__PURE__ */ Q("h3", {
|
|
2357
2525
|
className: "text-sm font-medium text-foreground/90",
|
|
2358
|
-
children:
|
|
2526
|
+
children: K.emptyTitle
|
|
2359
2527
|
}), /* @__PURE__ */ Q("p", {
|
|
2360
2528
|
className: "text-sm text-muted-foreground",
|
|
2361
|
-
children:
|
|
2529
|
+
children: K.emptyDescription
|
|
2362
2530
|
})]
|
|
2363
2531
|
}),
|
|
2364
|
-
T && T.length > 0 ? /* @__PURE__ */ Q(
|
|
2532
|
+
T && T.length > 0 ? /* @__PURE__ */ Q(ni, {
|
|
2365
2533
|
className: "justify-center gap-2",
|
|
2366
|
-
children: T.map((e) => /* @__PURE__ */ Q(
|
|
2534
|
+
children: T.map((e) => /* @__PURE__ */ Q(ri, {
|
|
2367
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",
|
|
2368
2536
|
suggestion: e,
|
|
2369
|
-
onClick:
|
|
2537
|
+
onClick: Ue
|
|
2370
2538
|
}, e))
|
|
2371
2539
|
}) : null
|
|
2372
2540
|
]
|
|
2373
2541
|
}) : n.map((e) => {
|
|
2374
|
-
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 &&
|
|
2375
|
-
return /* @__PURE__ */ Q(
|
|
2376
|
-
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),
|
|
2377
2545
|
children: /* @__PURE__ */ $("div", {
|
|
2378
|
-
className:
|
|
2379
|
-
children: [m ? /* @__PURE__ */ Q(
|
|
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, {
|
|
2380
2548
|
isUser: t,
|
|
2381
2549
|
url: t ? h : _,
|
|
2382
2550
|
fallback: t ? g : v
|
|
2383
2551
|
}) : null, /* @__PURE__ */ $("div", {
|
|
2384
|
-
className:
|
|
2385
|
-
children: [/* @__PURE__ */ $(
|
|
2386
|
-
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, {
|
|
2387
2555
|
progress: a,
|
|
2388
|
-
onOpenBuiltApp:
|
|
2389
|
-
openBuiltAppLabel:
|
|
2390
|
-
onPreviewDraftApp:
|
|
2391
|
-
previewDraftLabel:
|
|
2392
|
-
waitingLabel:
|
|
2393
|
-
stalledLabel:
|
|
2394
|
-
offlineLabel:
|
|
2556
|
+
onOpenBuiltApp: re,
|
|
2557
|
+
openBuiltAppLabel: ie,
|
|
2558
|
+
onPreviewDraftApp: R,
|
|
2559
|
+
previewDraftLabel: ae,
|
|
2560
|
+
waitingLabel: K.connectionWaiting,
|
|
2561
|
+
stalledLabel: K.connectionStalledLabel,
|
|
2562
|
+
offlineLabel: K.connectionOfflineLabel
|
|
2395
2563
|
}) : null,
|
|
2396
|
-
!t &&
|
|
2564
|
+
!t && V === "debug" && r ? /* @__PURE__ */ $(bi, {
|
|
2397
2565
|
isStreaming: !!e.streaming && !e.content,
|
|
2398
2566
|
className: "mb-2",
|
|
2399
|
-
children: [/* @__PURE__ */ Q(
|
|
2567
|
+
children: [/* @__PURE__ */ Q(Si, {}), /* @__PURE__ */ Q(Ci, { children: r })]
|
|
2400
2568
|
}) : null,
|
|
2401
|
-
!t &&
|
|
2402
|
-
groups:
|
|
2403
|
-
labels:
|
|
2569
|
+
!t && V === "summary" && c.length > 0 ? /* @__PURE__ */ Q(Xi, {
|
|
2570
|
+
groups: Fi(c),
|
|
2571
|
+
labels: K
|
|
2404
2572
|
}) : null,
|
|
2405
|
-
!t && l.length > 0 ? l.map(
|
|
2573
|
+
!t && l.length > 0 ? l.map(tt) : null,
|
|
2406
2574
|
t ? e.content ? /* @__PURE__ */ Q("div", {
|
|
2407
2575
|
className: "whitespace-pre-wrap break-words",
|
|
2408
2576
|
children: e.content
|
|
2409
|
-
}) : null : o ? /* @__PURE__ */ Q(
|
|
2577
|
+
}) : null : o ? /* @__PURE__ */ Q(Bi, {}) : e.content ? /* @__PURE__ */ Q(tr, { children: e.content }) : null,
|
|
2410
2578
|
e.streaming && !o ? /* @__PURE__ */ Q("span", {
|
|
2411
2579
|
"aria-hidden": !0,
|
|
2412
2580
|
className: "ml-0.5 inline-block w-[2px] h-4 align-middle bg-current animate-pulse"
|
|
@@ -2430,7 +2598,7 @@ var Ni = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2430
2598
|
} })]
|
|
2431
2599
|
}, t))
|
|
2432
2600
|
}) : null,
|
|
2433
|
-
!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, {
|
|
2434
2602
|
href: e.url,
|
|
2435
2603
|
title: e.title ?? e.url
|
|
2436
2604
|
}, e.id ?? e.url ?? t)) })] }) : null,
|
|
@@ -2438,73 +2606,73 @@ var Ni = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2438
2606
|
className: "text-[10px] opacity-70 mt-1",
|
|
2439
2607
|
children: e.timestamp
|
|
2440
2608
|
}) : null
|
|
2441
|
-
] }), !t && !o ? /* @__PURE__ */ $(
|
|
2609
|
+
] }), !t && !o ? /* @__PURE__ */ $(Gn, {
|
|
2442
2610
|
className: "opacity-0 transition-opacity group-focus-within:opacity-100 group-hover:opacity-100",
|
|
2443
2611
|
children: [
|
|
2444
|
-
/* @__PURE__ */ Q(
|
|
2445
|
-
label:
|
|
2446
|
-
tooltip:
|
|
2447
|
-
onClick: () =>
|
|
2448
|
-
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" })
|
|
2449
2617
|
}),
|
|
2450
|
-
s ? /* @__PURE__ */ Q(
|
|
2451
|
-
label:
|
|
2452
|
-
tooltip:
|
|
2618
|
+
s ? /* @__PURE__ */ Q(Kn, {
|
|
2619
|
+
label: K.regenerate,
|
|
2620
|
+
tooltip: K.regenerate,
|
|
2453
2621
|
onClick: s,
|
|
2454
2622
|
children: /* @__PURE__ */ Q(st, { className: "size-3.5" })
|
|
2455
2623
|
}) : null,
|
|
2456
|
-
|
|
2624
|
+
V === "debug" && e.traceId ? /* @__PURE__ */ Q("a", {
|
|
2457
2625
|
href: `#trace/${e.traceId}`,
|
|
2458
2626
|
"data-trace-id": e.traceId,
|
|
2459
2627
|
className: "text-[10px] text-muted-foreground hover:text-foreground ml-1 underline",
|
|
2460
|
-
title:
|
|
2461
|
-
children:
|
|
2628
|
+
title: K.viewTrace,
|
|
2629
|
+
children: K.trace
|
|
2462
2630
|
}) : null
|
|
2463
2631
|
]
|
|
2464
2632
|
}) : null]
|
|
2465
2633
|
})]
|
|
2466
2634
|
})
|
|
2467
2635
|
}, e.id);
|
|
2468
|
-
}), d && !n.some((e) => e.streaming) ? /* @__PURE__ */ Q(
|
|
2636
|
+
}), d && !n.some((e) => e.streaming) ? /* @__PURE__ */ Q(zi, {
|
|
2469
2637
|
showAvatar: m,
|
|
2470
2638
|
assistantAvatarUrl: _,
|
|
2471
2639
|
assistantAvatarFallback: v,
|
|
2472
|
-
waitingLabel:
|
|
2473
|
-
stalledLabel:
|
|
2474
|
-
offlineLabel:
|
|
2640
|
+
waitingLabel: K.connectionWaiting,
|
|
2641
|
+
stalledLabel: K.connectionStalledLabel,
|
|
2642
|
+
offlineLabel: K.connectionOfflineLabel
|
|
2475
2643
|
}) : null]
|
|
2476
|
-
}), /* @__PURE__ */ Q(
|
|
2644
|
+
}), /* @__PURE__ */ Q(zn, {})]
|
|
2477
2645
|
}),
|
|
2478
|
-
f ? /* @__PURE__ */ Q(
|
|
2646
|
+
f ? /* @__PURE__ */ Q($i, {
|
|
2479
2647
|
error: f,
|
|
2480
2648
|
onReload: s,
|
|
2481
2649
|
onUpgrade: c
|
|
2482
2650
|
}) : null,
|
|
2483
2651
|
u ? null : /* @__PURE__ */ $("div", {
|
|
2484
|
-
ref:
|
|
2485
|
-
className:
|
|
2652
|
+
ref: We,
|
|
2653
|
+
className: q("relative", W && "mx-auto w-full max-w-2xl px-4 pb-4 sm:px-0"),
|
|
2486
2654
|
children: [j ? /* @__PURE__ */ Q("div", {
|
|
2487
2655
|
className: "absolute bottom-full left-0 right-0 z-10 px-3 pb-1",
|
|
2488
2656
|
children: j
|
|
2489
|
-
}) : null, /* @__PURE__ */ $(
|
|
2657
|
+
}) : null, /* @__PURE__ */ $(Cr, {
|
|
2490
2658
|
accept: C,
|
|
2491
|
-
fileInputLabel:
|
|
2659
|
+
fileInputLabel: K.uploadFiles,
|
|
2492
2660
|
maxFileSize: w,
|
|
2493
|
-
onSubmit:
|
|
2661
|
+
onSubmit: He,
|
|
2494
2662
|
onError: (e) => {
|
|
2495
2663
|
console.warn("[plugin-chatbot] prompt-input error", e);
|
|
2496
2664
|
},
|
|
2497
2665
|
children: [
|
|
2498
|
-
S ? /* @__PURE__ */ Q(
|
|
2499
|
-
/* @__PURE__ */ Q(
|
|
2666
|
+
S ? /* @__PURE__ */ Q(wr, { children: /* @__PURE__ */ Q(xr, { children: (e) => /* @__PURE__ */ Q(br, { data: e }) }) }) : null,
|
|
2667
|
+
/* @__PURE__ */ Q(Tr, {
|
|
2500
2668
|
placeholder: r,
|
|
2501
|
-
disabled: l ||
|
|
2669
|
+
disabled: l || U === "streaming",
|
|
2502
2670
|
onChange: M ? (e) => M(e.currentTarget.value) : void 0
|
|
2503
2671
|
}),
|
|
2504
|
-
/* @__PURE__ */ $(
|
|
2505
|
-
S ? /* @__PURE__ */ $(
|
|
2672
|
+
/* @__PURE__ */ $(Dr, { children: [/* @__PURE__ */ $(Or, { children: [
|
|
2673
|
+
S ? /* @__PURE__ */ $(Ar, { children: [/* @__PURE__ */ Q(jr, {}), /* @__PURE__ */ Q(Mr, { children: /* @__PURE__ */ Q(Sr, {}) })] }) : null,
|
|
2506
2674
|
D && D.length > 0 ? /* @__PURE__ */ Q("select", {
|
|
2507
|
-
"aria-label":
|
|
2675
|
+
"aria-label": K.model,
|
|
2508
2676
|
value: O ?? D[0].id,
|
|
2509
2677
|
onChange: (e) => k?.(e.target.value),
|
|
2510
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",
|
|
@@ -2524,16 +2692,16 @@ var Ni = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2524
2692
|
/* @__PURE__ */ Q(qe, { className: "h-3 w-3" }),
|
|
2525
2693
|
/* @__PURE__ */ Q("span", {
|
|
2526
2694
|
className: "opacity-70",
|
|
2527
|
-
children:
|
|
2695
|
+
children: K.sendHint
|
|
2528
2696
|
})
|
|
2529
2697
|
]
|
|
2530
2698
|
})
|
|
2531
|
-
] }), /* @__PURE__ */ Q(
|
|
2532
|
-
"aria-label":
|
|
2533
|
-
status:
|
|
2699
|
+
] }), /* @__PURE__ */ Q(Pr, {
|
|
2700
|
+
"aria-label": U === "streaming" ? K.stopResponse : K.submit,
|
|
2701
|
+
status: U,
|
|
2534
2702
|
disabled: l,
|
|
2535
|
-
onClick:
|
|
2536
|
-
type:
|
|
2703
|
+
onClick: U === "streaming" ? o : void 0,
|
|
2704
|
+
type: U === "streaming" ? "button" : "submit"
|
|
2537
2705
|
})] })
|
|
2538
2706
|
]
|
|
2539
2707
|
})]
|
|
@@ -2541,33 +2709,33 @@ var Ni = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2541
2709
|
]
|
|
2542
2710
|
});
|
|
2543
2711
|
});
|
|
2544
|
-
|
|
2545
|
-
function
|
|
2712
|
+
Li.displayName = "ChatbotEnhanced";
|
|
2713
|
+
function Ri({ isUser: e, url: t, fallback: n }) {
|
|
2546
2714
|
return /* @__PURE__ */ Q("div", {
|
|
2547
|
-
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"),
|
|
2548
2716
|
"aria-hidden": "true",
|
|
2549
2717
|
children: t ? /* @__PURE__ */ Q("img", {
|
|
2550
2718
|
src: t,
|
|
2551
2719
|
alt: "",
|
|
2552
2720
|
className: "size-full object-cover"
|
|
2553
|
-
}) : e ? n?.trim()?.charAt(0)?.toUpperCase() || "U" : /* @__PURE__ */ Q(
|
|
2721
|
+
}) : e ? n?.trim()?.charAt(0)?.toUpperCase() || "U" : /* @__PURE__ */ Q(Ne, { className: "size-4" })
|
|
2554
2722
|
});
|
|
2555
2723
|
}
|
|
2556
|
-
function
|
|
2557
|
-
return /* @__PURE__ */ Q(
|
|
2724
|
+
function zi({ showAvatar: e, assistantAvatarUrl: t, assistantAvatarFallback: n, waitingLabel: r, stalledLabel: i, offlineLabel: a }) {
|
|
2725
|
+
return /* @__PURE__ */ Q(Un, {
|
|
2558
2726
|
from: "assistant",
|
|
2559
2727
|
"aria-live": "polite",
|
|
2560
2728
|
children: /* @__PURE__ */ $("div", {
|
|
2561
|
-
className:
|
|
2562
|
-
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, {
|
|
2563
2731
|
isUser: !1,
|
|
2564
2732
|
url: t,
|
|
2565
2733
|
fallback: n
|
|
2566
|
-
}) : null, /* @__PURE__ */ Q(
|
|
2734
|
+
}) : null, /* @__PURE__ */ Q(Wn, {
|
|
2567
2735
|
className: "rounded-lg border bg-muted/30 px-3 py-2 text-muted-foreground",
|
|
2568
2736
|
children: /* @__PURE__ */ $("span", {
|
|
2569
2737
|
className: "inline-flex items-center gap-2",
|
|
2570
|
-
children: [/* @__PURE__ */ Q(
|
|
2738
|
+
children: [/* @__PURE__ */ Q(Bi, {}), /* @__PURE__ */ Q(Gi, {
|
|
2571
2739
|
active: !0,
|
|
2572
2740
|
pending: !0,
|
|
2573
2741
|
activityKey: 0,
|
|
@@ -2580,7 +2748,7 @@ function Fi({ showAvatar: e, assistantAvatarUrl: t, assistantAvatarFallback: n,
|
|
|
2580
2748
|
})
|
|
2581
2749
|
});
|
|
2582
2750
|
}
|
|
2583
|
-
function
|
|
2751
|
+
function Bi() {
|
|
2584
2752
|
return /* @__PURE__ */ $(Z, { children: [/* @__PURE__ */ Q("span", {
|
|
2585
2753
|
className: "sr-only",
|
|
2586
2754
|
children: "Assistant is responding"
|
|
@@ -2594,12 +2762,12 @@ function Ii() {
|
|
|
2594
2762
|
]
|
|
2595
2763
|
})] });
|
|
2596
2764
|
}
|
|
2597
|
-
function
|
|
2765
|
+
function Vi(e) {
|
|
2598
2766
|
let t = Math.floor(e / 60), n = e % 60;
|
|
2599
2767
|
return `${t}:${String(n).padStart(2, "0")}`;
|
|
2600
2768
|
}
|
|
2601
|
-
var
|
|
2602
|
-
function
|
|
2769
|
+
var Hi = 6;
|
|
2770
|
+
function Ui(t, n) {
|
|
2603
2771
|
let r = e.useRef(0), i = e.useRef(0), [a, o] = e.useState({
|
|
2604
2772
|
elapsed: 0,
|
|
2605
2773
|
quiet: 0
|
|
@@ -2628,10 +2796,10 @@ function zi(t, n) {
|
|
|
2628
2796
|
}, [t]), {
|
|
2629
2797
|
elapsedSeconds: a.elapsed,
|
|
2630
2798
|
quietSeconds: a.quiet,
|
|
2631
|
-
live: a.quiet <
|
|
2799
|
+
live: a.quiet < Hi
|
|
2632
2800
|
};
|
|
2633
2801
|
}
|
|
2634
|
-
function
|
|
2802
|
+
function Wi() {
|
|
2635
2803
|
let [t, n] = e.useState(() => typeof navigator < "u" && navigator.onLine === !1);
|
|
2636
2804
|
return e.useEffect(() => {
|
|
2637
2805
|
if (typeof window > "u") return;
|
|
@@ -2641,10 +2809,10 @@ function Bi() {
|
|
|
2641
2809
|
};
|
|
2642
2810
|
}, []), t;
|
|
2643
2811
|
}
|
|
2644
|
-
function
|
|
2645
|
-
let { elapsedSeconds: o, quietSeconds: s, live: c } =
|
|
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);
|
|
2646
2814
|
return /* @__PURE__ */ $("span", {
|
|
2647
|
-
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"),
|
|
2648
2816
|
"aria-live": "polite",
|
|
2649
2817
|
"data-liveness-tier": l,
|
|
2650
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`,
|
|
@@ -2654,7 +2822,7 @@ function Vi({ active: e, activityKey: t, pending: n = !1, waitingLabel: r, stall
|
|
|
2654
2822
|
"aria-hidden": !0
|
|
2655
2823
|
}) : /* @__PURE__ */ Q("span", {
|
|
2656
2824
|
"aria-hidden": !0,
|
|
2657
|
-
className:
|
|
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")
|
|
2658
2826
|
}),
|
|
2659
2827
|
/* @__PURE__ */ Q(Ue, {
|
|
2660
2828
|
className: "size-3 shrink-0",
|
|
@@ -2665,13 +2833,13 @@ function Vi({ active: e, activityKey: t, pending: n = !1, waitingLabel: r, stall
|
|
|
2665
2833
|
]
|
|
2666
2834
|
});
|
|
2667
2835
|
}
|
|
2668
|
-
function
|
|
2669
|
-
let [n, r] = e.useState(0), i =
|
|
2836
|
+
function Ki({ offlineLabel: t }) {
|
|
2837
|
+
let [n, r] = e.useState(0), i = Wi();
|
|
2670
2838
|
return e.useEffect(() => {
|
|
2671
2839
|
let e = Date.now(), t = setInterval(() => r(Math.floor((Date.now() - e) / 1e3)), 1e3);
|
|
2672
2840
|
return () => clearInterval(t);
|
|
2673
2841
|
}, []), /* @__PURE__ */ $("span", {
|
|
2674
|
-
className:
|
|
2842
|
+
className: q("inline-flex items-center gap-1 text-xs tabular-nums", i ? "text-red-600 font-medium" : "text-muted-foreground"),
|
|
2675
2843
|
"aria-live": "polite",
|
|
2676
2844
|
"data-tool-running-timer": !0,
|
|
2677
2845
|
children: [
|
|
@@ -2679,31 +2847,31 @@ function Hi({ offlineLabel: t }) {
|
|
|
2679
2847
|
className: "size-3 shrink-0",
|
|
2680
2848
|
"aria-hidden": !0
|
|
2681
2849
|
}),
|
|
2682
|
-
/* @__PURE__ */ Q("span", { children:
|
|
2850
|
+
/* @__PURE__ */ Q("span", { children: Vi(n) }),
|
|
2683
2851
|
i ? /* @__PURE__ */ $("span", { children: ["· ", t] }) : null
|
|
2684
2852
|
]
|
|
2685
2853
|
});
|
|
2686
2854
|
}
|
|
2687
|
-
var
|
|
2855
|
+
var qi = [
|
|
2688
2856
|
"object",
|
|
2689
2857
|
"view",
|
|
2690
2858
|
"dashboard",
|
|
2691
2859
|
"app",
|
|
2692
2860
|
"seed"
|
|
2693
|
-
],
|
|
2861
|
+
], Ji = {
|
|
2694
2862
|
object: "Objects",
|
|
2695
2863
|
view: "Views",
|
|
2696
2864
|
dashboard: "Dashboards",
|
|
2697
2865
|
app: "App",
|
|
2698
2866
|
seed: "Sample data"
|
|
2699
2867
|
};
|
|
2700
|
-
function
|
|
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…" }) {
|
|
2701
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();
|
|
2702
2870
|
for (let e of u) {
|
|
2703
2871
|
let t = v.get(e.type) ?? [];
|
|
2704
2872
|
t.push(e.name.replace(/_sample$/, "")), v.set(e.type, t);
|
|
2705
2873
|
}
|
|
2706
|
-
let y = [...
|
|
2874
|
+
let y = [...qi.filter((e) => v.has(e)), ...[...v.keys()].filter((e) => !qi.includes(e))];
|
|
2707
2875
|
return /* @__PURE__ */ $("div", {
|
|
2708
2876
|
className: "rounded-lg border bg-muted/30 p-3 text-sm",
|
|
2709
2877
|
"data-testid": "build-progress",
|
|
@@ -2711,7 +2879,7 @@ function Gi({ progress: e, onOpenBuiltApp: t, openBuiltAppLabel: n = "Open app",
|
|
|
2711
2879
|
/* @__PURE__ */ $("div", {
|
|
2712
2880
|
className: "mb-2 flex items-center gap-2 font-medium",
|
|
2713
2881
|
children: [
|
|
2714
|
-
m ? /* @__PURE__ */ Q(
|
|
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" }),
|
|
2715
2883
|
/* @__PURE__ */ Q("span", { children: m ? `Built ${l ?? "your app"}` : `Building ${l ?? "your app"}…` }),
|
|
2716
2884
|
!m && c === "data" ? /* @__PURE__ */ Q("span", {
|
|
2717
2885
|
className: "text-xs font-normal text-muted-foreground",
|
|
@@ -2719,7 +2887,7 @@ function Gi({ progress: e, onOpenBuiltApp: t, openBuiltAppLabel: n = "Open app",
|
|
|
2719
2887
|
}) : null,
|
|
2720
2888
|
m ? null : /* @__PURE__ */ Q("span", {
|
|
2721
2889
|
className: "ml-auto",
|
|
2722
|
-
children: /* @__PURE__ */ Q(
|
|
2890
|
+
children: /* @__PURE__ */ Q(Gi, {
|
|
2723
2891
|
active: !0,
|
|
2724
2892
|
activityKey: h,
|
|
2725
2893
|
waitingLabel: a,
|
|
@@ -2732,7 +2900,7 @@ function Gi({ progress: e, onOpenBuiltApp: t, openBuiltAppLabel: n = "Open app",
|
|
|
2732
2900
|
/* @__PURE__ */ Q("div", {
|
|
2733
2901
|
className: "mb-2 h-1.5 w-full overflow-hidden rounded-full bg-muted",
|
|
2734
2902
|
children: /* @__PURE__ */ Q("div", {
|
|
2735
|
-
className:
|
|
2903
|
+
className: q("h-full rounded-full transition-all duration-500", m ? "bg-emerald-500" : "bg-primary"),
|
|
2736
2904
|
style: { width: `${_}%` }
|
|
2737
2905
|
})
|
|
2738
2906
|
}),
|
|
@@ -2742,12 +2910,12 @@ function Gi({ progress: e, onOpenBuiltApp: t, openBuiltAppLabel: n = "Open app",
|
|
|
2742
2910
|
let t = v.get(e);
|
|
2743
2911
|
return /* @__PURE__ */ $("li", {
|
|
2744
2912
|
className: "flex items-start gap-2",
|
|
2745
|
-
children: [/* @__PURE__ */ Q(
|
|
2913
|
+
children: [/* @__PURE__ */ Q(J, { className: "mt-0.5 size-3.5 shrink-0 text-emerald-600" }), /* @__PURE__ */ $("span", {
|
|
2746
2914
|
className: "min-w-0 text-muted-foreground",
|
|
2747
2915
|
children: [
|
|
2748
2916
|
/* @__PURE__ */ Q("span", {
|
|
2749
2917
|
className: "font-medium text-foreground",
|
|
2750
|
-
children:
|
|
2918
|
+
children: Ji[e] ?? e
|
|
2751
2919
|
}),
|
|
2752
2920
|
" ",
|
|
2753
2921
|
t.slice(0, 6).join(", "),
|
|
@@ -2764,7 +2932,7 @@ function Gi({ progress: e, onOpenBuiltApp: t, openBuiltAppLabel: n = "Open app",
|
|
|
2764
2932
|
onClick: () => t(g.name),
|
|
2765
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",
|
|
2766
2934
|
"data-testid": "build-progress-open-app",
|
|
2767
|
-
children: [n, /* @__PURE__ */ Q(
|
|
2935
|
+
children: [n, /* @__PURE__ */ Q(je, { className: "size-3.5" })]
|
|
2768
2936
|
}) : null, r ? /* @__PURE__ */ $("button", {
|
|
2769
2937
|
type: "button",
|
|
2770
2938
|
onClick: () => r(g.name),
|
|
@@ -2776,7 +2944,7 @@ function Gi({ progress: e, onOpenBuiltApp: t, openBuiltAppLabel: n = "Open app",
|
|
|
2776
2944
|
]
|
|
2777
2945
|
});
|
|
2778
2946
|
}
|
|
2779
|
-
function
|
|
2947
|
+
function Xi({ groups: e, labels: t }) {
|
|
2780
2948
|
return e.length === 0 ? null : /* @__PURE__ */ Q("div", {
|
|
2781
2949
|
className: "not-prose mb-2 border-l border-border/70 pl-3",
|
|
2782
2950
|
children: /* @__PURE__ */ Q("div", {
|
|
@@ -2786,7 +2954,7 @@ function Ki({ groups: e, labels: t }) {
|
|
|
2786
2954
|
children: [/* @__PURE__ */ $("div", {
|
|
2787
2955
|
className: "flex min-w-0 items-center gap-2",
|
|
2788
2956
|
children: [
|
|
2789
|
-
/* @__PURE__ */ Q(
|
|
2957
|
+
/* @__PURE__ */ Q(Zi, { state: e.state }),
|
|
2790
2958
|
/* @__PURE__ */ Q("span", {
|
|
2791
2959
|
className: "truncate font-medium text-foreground",
|
|
2792
2960
|
children: e.title
|
|
@@ -2796,18 +2964,18 @@ function Ki({ groups: e, labels: t }) {
|
|
|
2796
2964
|
children: ["x", e.count]
|
|
2797
2965
|
}) : null
|
|
2798
2966
|
]
|
|
2799
|
-
}), e.state === "running" ? /* @__PURE__ */ Q(
|
|
2800
|
-
className:
|
|
2801
|
-
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)
|
|
2802
2970
|
})]
|
|
2803
2971
|
}, e.key))
|
|
2804
2972
|
})
|
|
2805
2973
|
});
|
|
2806
2974
|
}
|
|
2807
|
-
function
|
|
2808
|
-
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" });
|
|
2809
2977
|
}
|
|
2810
|
-
function
|
|
2978
|
+
function Qi(e, t) {
|
|
2811
2979
|
switch (e) {
|
|
2812
2980
|
case "failed": return t.toolFailed;
|
|
2813
2981
|
case "awaiting": return t.toolAwaitingApproval;
|
|
@@ -2815,8 +2983,8 @@ function Ji(e, t) {
|
|
|
2815
2983
|
case "completed": return t.toolCompleted;
|
|
2816
2984
|
}
|
|
2817
2985
|
}
|
|
2818
|
-
function
|
|
2819
|
-
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);
|
|
2820
2988
|
if (i) {
|
|
2821
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";
|
|
2822
2990
|
return /* @__PURE__ */ Q("div", {
|
|
@@ -2853,7 +3021,7 @@ function Yi({ error: t, onReload: n, onUpgrade: r }) {
|
|
|
2853
3021
|
children: [/* @__PURE__ */ $("div", {
|
|
2854
3022
|
className: "flex items-start gap-2",
|
|
2855
3023
|
children: [
|
|
2856
|
-
/* @__PURE__ */ Q(
|
|
3024
|
+
/* @__PURE__ */ Q(ke, { className: "mt-0.5 h-4 w-4 shrink-0 text-destructive" }),
|
|
2857
3025
|
/* @__PURE__ */ $("div", {
|
|
2858
3026
|
className: "min-w-0 flex-1",
|
|
2859
3027
|
children: [/* @__PURE__ */ Q("div", {
|
|
@@ -2887,27 +3055,27 @@ function Yi({ error: t, onReload: n, onUpgrade: r }) {
|
|
|
2887
3055
|
})
|
|
2888
3056
|
});
|
|
2889
3057
|
}
|
|
2890
|
-
function
|
|
2891
|
-
return t ? /* @__PURE__ */ Q(
|
|
3058
|
+
function ea({ output: e, errorText: t }) {
|
|
3059
|
+
return t ? /* @__PURE__ */ Q(mi, {
|
|
2892
3060
|
output: void 0,
|
|
2893
3061
|
errorText: t
|
|
2894
|
-
}) : e == null || e === "" ? null : typeof e == "string" && !
|
|
3062
|
+
}) : e == null || e === "" ? null : typeof e == "string" && !Ai(e) ? /* @__PURE__ */ $("div", {
|
|
2895
3063
|
className: "space-y-2 p-4",
|
|
2896
3064
|
children: [/* @__PURE__ */ Q("h4", {
|
|
2897
3065
|
className: "font-medium text-muted-foreground text-xs uppercase tracking-wide",
|
|
2898
3066
|
children: "Result"
|
|
2899
3067
|
}), /* @__PURE__ */ Q("div", {
|
|
2900
3068
|
className: "overflow-x-auto rounded-md bg-muted/40 px-3 py-2 text-sm text-foreground",
|
|
2901
|
-
children: /* @__PURE__ */ Q(
|
|
3069
|
+
children: /* @__PURE__ */ Q(tr, { children: e })
|
|
2902
3070
|
})]
|
|
2903
|
-
}) : /* @__PURE__ */ Q(
|
|
3071
|
+
}) : /* @__PURE__ */ Q(mi, {
|
|
2904
3072
|
output: e,
|
|
2905
3073
|
errorText: void 0
|
|
2906
3074
|
});
|
|
2907
3075
|
}
|
|
2908
3076
|
//#endregion
|
|
2909
3077
|
//#region src/FloatingChatbot.tsx
|
|
2910
|
-
function
|
|
3078
|
+
function ta({ floatingConfig: t, headerExtra: n, headerActions: r, ...i }) {
|
|
2911
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);
|
|
2912
3080
|
e.useEffect(() => {
|
|
2913
3081
|
let e = document.getElementById("floating-chatbot-portal");
|
|
@@ -2915,19 +3083,19 @@ function Zi({ floatingConfig: t, headerExtra: n, headerActions: r, ...i }) {
|
|
|
2915
3083
|
e && e.parentNode && !e.hasChildNodes() && e.parentNode.removeChild(e);
|
|
2916
3084
|
};
|
|
2917
3085
|
}, []);
|
|
2918
|
-
let p = /* @__PURE__ */ $(
|
|
3086
|
+
let p = /* @__PURE__ */ $(_n, {
|
|
2919
3087
|
defaultOpen: o,
|
|
2920
|
-
children: [/* @__PURE__ */ Q(
|
|
3088
|
+
children: [/* @__PURE__ */ Q(Cn, {
|
|
2921
3089
|
position: a,
|
|
2922
3090
|
size: u
|
|
2923
|
-
}), /* @__PURE__ */ Q(
|
|
3091
|
+
}), /* @__PURE__ */ Q(kn, {
|
|
2924
3092
|
title: l,
|
|
2925
3093
|
position: a,
|
|
2926
3094
|
width: s,
|
|
2927
3095
|
height: c,
|
|
2928
3096
|
headerExtra: n,
|
|
2929
3097
|
headerActions: r,
|
|
2930
|
-
children: /* @__PURE__ */ Q(
|
|
3098
|
+
children: /* @__PURE__ */ Q(Li, {
|
|
2931
3099
|
...i,
|
|
2932
3100
|
maxHeight: "100%",
|
|
2933
3101
|
className: "h-full border-0 rounded-none"
|
|
@@ -2937,7 +3105,7 @@ function Zi({ floatingConfig: t, headerExtra: n, headerActions: r, ...i }) {
|
|
|
2937
3105
|
return d ? xt.createPortal(p, d) : p;
|
|
2938
3106
|
}
|
|
2939
3107
|
Nt.register("chatbot", ({ schema: e, className: t, ...n }) => {
|
|
2940
|
-
let { messages: r, isLoading: i, sendMessage: a } =
|
|
3108
|
+
let { messages: r, isLoading: i, sendMessage: a } = tn({
|
|
2941
3109
|
api: e.api,
|
|
2942
3110
|
initialMessages: e.messages,
|
|
2943
3111
|
conversationId: e.conversationId,
|
|
@@ -2954,7 +3122,7 @@ Nt.register("chatbot", ({ schema: e, className: t, ...n }) => {
|
|
|
2954
3122
|
autoResponseDelay: e.autoResponseDelay,
|
|
2955
3123
|
onSend: e.onSend
|
|
2956
3124
|
});
|
|
2957
|
-
return /* @__PURE__ */ Q(
|
|
3125
|
+
return /* @__PURE__ */ Q(Sa, {
|
|
2958
3126
|
messages: r,
|
|
2959
3127
|
placeholder: e.placeholder,
|
|
2960
3128
|
onSendMessage: (e) => {
|
|
@@ -3103,7 +3271,7 @@ Nt.register("chatbot", ({ schema: e, className: t, ...n }) => {
|
|
|
3103
3271
|
className: "w-full max-w-2xl"
|
|
3104
3272
|
}
|
|
3105
3273
|
}), Nt.register("chatbot-enhanced", ({ schema: e, className: t, ...n }) => {
|
|
3106
|
-
let { messages: r, isLoading: i, error: a, sendMessage: o, stop: s, reload: c, clear: l, isApiMode: u } =
|
|
3274
|
+
let { messages: r, isLoading: i, error: a, sendMessage: o, stop: s, reload: c, clear: l, isApiMode: u } = tn({
|
|
3107
3275
|
api: e.api,
|
|
3108
3276
|
initialMessages: e.messages,
|
|
3109
3277
|
conversationId: e.conversationId,
|
|
@@ -3120,7 +3288,7 @@ Nt.register("chatbot", ({ schema: e, className: t, ...n }) => {
|
|
|
3120
3288
|
autoResponseDelay: e.autoResponseDelay,
|
|
3121
3289
|
onSend: e.onSend
|
|
3122
3290
|
});
|
|
3123
|
-
return /* @__PURE__ */ Q(
|
|
3291
|
+
return /* @__PURE__ */ Q(Li, {
|
|
3124
3292
|
messages: r,
|
|
3125
3293
|
placeholder: e.placeholder,
|
|
3126
3294
|
onSendMessage: (e, t) => {
|
|
@@ -3290,7 +3458,7 @@ Nt.register("chatbot", ({ schema: e, className: t, ...n }) => {
|
|
|
3290
3458
|
className: "w-full max-w-2xl"
|
|
3291
3459
|
}
|
|
3292
3460
|
}), Nt.register("chatbot-floating", ({ schema: e, className: t, ...n }) => {
|
|
3293
|
-
let { messages: r, isLoading: i, error: a, sendMessage: o, stop: s, reload: c, clear: l, isApiMode: u } =
|
|
3461
|
+
let { messages: r, isLoading: i, error: a, sendMessage: o, stop: s, reload: c, clear: l, isApiMode: u } = tn({
|
|
3294
3462
|
api: e.api,
|
|
3295
3463
|
initialMessages: e.messages,
|
|
3296
3464
|
conversationId: e.conversationId,
|
|
@@ -3307,7 +3475,7 @@ Nt.register("chatbot", ({ schema: e, className: t, ...n }) => {
|
|
|
3307
3475
|
autoResponseDelay: e.autoResponseDelay,
|
|
3308
3476
|
onSend: e.onSend
|
|
3309
3477
|
});
|
|
3310
|
-
return /* @__PURE__ */ Q(
|
|
3478
|
+
return /* @__PURE__ */ Q(ta, {
|
|
3311
3479
|
floatingConfig: e.floatingConfig,
|
|
3312
3480
|
messages: r,
|
|
3313
3481
|
placeholder: e.placeholder,
|
|
@@ -3479,7 +3647,7 @@ Nt.register("chatbot", ({ schema: e, className: t, ...n }) => {
|
|
|
3479
3647
|
});
|
|
3480
3648
|
//#endregion
|
|
3481
3649
|
//#region src/elements/loader.tsx
|
|
3482
|
-
var
|
|
3650
|
+
var na = ({ size: e = 16 }) => /* @__PURE__ */ $("svg", {
|
|
3483
3651
|
height: e,
|
|
3484
3652
|
strokeLinejoin: "round",
|
|
3485
3653
|
style: { color: "currentcolor" },
|
|
@@ -3560,97 +3728,97 @@ var Qi = ({ size: e = 16 }) => /* @__PURE__ */ $("svg", {
|
|
|
3560
3728
|
})
|
|
3561
3729
|
}) })
|
|
3562
3730
|
]
|
|
3563
|
-
}),
|
|
3564
|
-
className:
|
|
3731
|
+
}), ra = ({ className: e, size: t = 16, ...n }) => /* @__PURE__ */ Q("div", {
|
|
3732
|
+
className: q("inline-flex animate-spin items-center justify-center", e),
|
|
3565
3733
|
...n,
|
|
3566
|
-
children: /* @__PURE__ */ Q(
|
|
3567
|
-
}),
|
|
3568
|
-
CodeBlock: () =>
|
|
3569
|
-
CodeBlockCopyButton: () =>
|
|
3570
|
-
Conversation: () =>
|
|
3571
|
-
ConversationContent: () =>
|
|
3572
|
-
ConversationEmptyState: () =>
|
|
3573
|
-
ConversationScrollButton: () =>
|
|
3574
|
-
Loader: () =>
|
|
3575
|
-
Message: () =>
|
|
3576
|
-
MessageAction: () =>
|
|
3577
|
-
MessageActions: () =>
|
|
3578
|
-
MessageAttachment: () =>
|
|
3579
|
-
MessageAttachments: () =>
|
|
3580
|
-
MessageBranch: () =>
|
|
3581
|
-
MessageBranchContent: () =>
|
|
3582
|
-
MessageBranchNext: () =>
|
|
3583
|
-
MessageBranchPage: () =>
|
|
3584
|
-
MessageBranchPrevious: () =>
|
|
3585
|
-
MessageBranchSelector: () =>
|
|
3586
|
-
MessageContent: () =>
|
|
3587
|
-
MessageResponse: () =>
|
|
3588
|
-
MessageToolbar: () =>
|
|
3589
|
-
PromptInput: () =>
|
|
3590
|
-
PromptInputActionAddAttachments: () =>
|
|
3591
|
-
PromptInputActionMenu: () =>
|
|
3592
|
-
PromptInputActionMenuContent: () =>
|
|
3593
|
-
PromptInputActionMenuItem: () =>
|
|
3594
|
-
PromptInputActionMenuTrigger: () =>
|
|
3595
|
-
PromptInputAttachment: () =>
|
|
3596
|
-
PromptInputAttachments: () =>
|
|
3597
|
-
PromptInputBody: () =>
|
|
3598
|
-
PromptInputButton: () =>
|
|
3599
|
-
PromptInputCommand: () =>
|
|
3600
|
-
PromptInputCommandEmpty: () =>
|
|
3601
|
-
PromptInputCommandGroup: () =>
|
|
3602
|
-
PromptInputCommandInput: () =>
|
|
3603
|
-
PromptInputCommandItem: () =>
|
|
3604
|
-
PromptInputCommandList: () =>
|
|
3605
|
-
PromptInputCommandSeparator: () =>
|
|
3606
|
-
PromptInputFooter: () =>
|
|
3607
|
-
PromptInputHeader: () =>
|
|
3608
|
-
PromptInputHoverCard: () =>
|
|
3609
|
-
PromptInputHoverCardContent: () =>
|
|
3610
|
-
PromptInputHoverCardTrigger: () =>
|
|
3611
|
-
PromptInputProvider: () =>
|
|
3612
|
-
PromptInputSelect: () =>
|
|
3613
|
-
PromptInputSelectContent: () =>
|
|
3614
|
-
PromptInputSelectItem: () =>
|
|
3615
|
-
PromptInputSelectTrigger: () =>
|
|
3616
|
-
PromptInputSelectValue: () =>
|
|
3617
|
-
PromptInputSpeechButton: () =>
|
|
3618
|
-
PromptInputSubmit: () =>
|
|
3619
|
-
PromptInputTab: () =>
|
|
3620
|
-
PromptInputTabBody: () =>
|
|
3621
|
-
PromptInputTabItem: () =>
|
|
3622
|
-
PromptInputTabLabel: () =>
|
|
3623
|
-
PromptInputTabsList: () =>
|
|
3624
|
-
PromptInputTextarea: () =>
|
|
3625
|
-
PromptInputTools: () =>
|
|
3626
|
-
Reasoning: () =>
|
|
3627
|
-
ReasoningContent: () =>
|
|
3628
|
-
ReasoningTrigger: () =>
|
|
3629
|
-
Shimmer: () =>
|
|
3630
|
-
Source: () =>
|
|
3631
|
-
Sources: () =>
|
|
3632
|
-
SourcesContent: () =>
|
|
3633
|
-
SourcesTrigger: () =>
|
|
3634
|
-
Suggestion: () =>
|
|
3635
|
-
Suggestions: () =>
|
|
3636
|
-
Tool: () =>
|
|
3637
|
-
ToolContent: () =>
|
|
3638
|
-
ToolHeader: () =>
|
|
3639
|
-
ToolInput: () =>
|
|
3640
|
-
ToolOutput: () =>
|
|
3641
|
-
highlightCode: () =>
|
|
3642
|
-
usePromptInputAttachments: () =>
|
|
3643
|
-
usePromptInputController: () =>
|
|
3644
|
-
useProviderAttachments: () =>
|
|
3645
|
-
useReasoning: () =>
|
|
3646
|
-
}),
|
|
3647
|
-
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) {
|
|
3648
3816
|
let r = e.replace(/\/$/, ""), i = new URLSearchParams();
|
|
3649
3817
|
if (n) for (let [e, t] of Object.entries(n)) t == null || t === "" || i.set(e, String(t));
|
|
3650
3818
|
let a = i.toString();
|
|
3651
3819
|
return `${r}${t}${a ? `?${a}` : ""}`;
|
|
3652
3820
|
}
|
|
3653
|
-
async function
|
|
3821
|
+
async function sa(e, t, n) {
|
|
3654
3822
|
let r = await fetch(e, {
|
|
3655
3823
|
credentials: "include",
|
|
3656
3824
|
...t,
|
|
@@ -3670,8 +3838,8 @@ async function ra(e, t, n) {
|
|
|
3670
3838
|
}
|
|
3671
3839
|
return i;
|
|
3672
3840
|
}
|
|
3673
|
-
function
|
|
3674
|
-
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({
|
|
3675
3843
|
apiBase: n,
|
|
3676
3844
|
status: r,
|
|
3677
3845
|
conversationId: i,
|
|
@@ -3689,7 +3857,7 @@ function ia(t = {}) {
|
|
|
3689
3857
|
let { apiBase: e, status: t, conversationId: n, limit: r, headers: i } = _.current;
|
|
3690
3858
|
m(!0), g(void 0);
|
|
3691
3859
|
try {
|
|
3692
|
-
let a = await
|
|
3860
|
+
let a = await sa(oa(e, "/pending-actions", {
|
|
3693
3861
|
status: t && t !== "all" ? t : void 0,
|
|
3694
3862
|
conversationId: n,
|
|
3695
3863
|
limit: r
|
|
@@ -3701,9 +3869,9 @@ function ia(t = {}) {
|
|
|
3701
3869
|
m(!1);
|
|
3702
3870
|
}
|
|
3703
3871
|
}, []), y = e.useCallback(async (e) => {
|
|
3704
|
-
let { apiBase: t, headers: n } = _.current, r =
|
|
3872
|
+
let { apiBase: t, headers: n } = _.current, r = oa(t, `/pending-actions/${encodeURIComponent(e)}/approve`);
|
|
3705
3873
|
try {
|
|
3706
|
-
return await
|
|
3874
|
+
return await sa(r, {
|
|
3707
3875
|
method: "POST",
|
|
3708
3876
|
body: "{}"
|
|
3709
3877
|
}, n);
|
|
@@ -3711,9 +3879,9 @@ function ia(t = {}) {
|
|
|
3711
3879
|
v();
|
|
3712
3880
|
}
|
|
3713
3881
|
}, [v]), b = e.useCallback(async (e, t) => {
|
|
3714
|
-
let { apiBase: n, headers: r } = _.current, i =
|
|
3882
|
+
let { apiBase: n, headers: r } = _.current, i = oa(n, `/pending-actions/${encodeURIComponent(e)}/reject`);
|
|
3715
3883
|
try {
|
|
3716
|
-
return await
|
|
3884
|
+
return await sa(i, {
|
|
3717
3885
|
method: "POST",
|
|
3718
3886
|
body: JSON.stringify(t ? { reason: t } : {})
|
|
3719
3887
|
}, r);
|
|
@@ -3747,7 +3915,7 @@ function ia(t = {}) {
|
|
|
3747
3915
|
}
|
|
3748
3916
|
//#endregion
|
|
3749
3917
|
//#region src/AiPendingActionsInbox.tsx
|
|
3750
|
-
var
|
|
3918
|
+
var la = {
|
|
3751
3919
|
pending: {
|
|
3752
3920
|
variant: "secondary",
|
|
3753
3921
|
label: "Pending"
|
|
@@ -3769,8 +3937,8 @@ var aa = {
|
|
|
3769
3937
|
label: "Rejected"
|
|
3770
3938
|
}
|
|
3771
3939
|
};
|
|
3772
|
-
function
|
|
3773
|
-
let t =
|
|
3940
|
+
function ua({ status: e }) {
|
|
3941
|
+
let t = la[e] ?? {
|
|
3774
3942
|
variant: "outline",
|
|
3775
3943
|
label: e
|
|
3776
3944
|
};
|
|
@@ -3779,7 +3947,7 @@ function oa({ status: e }) {
|
|
|
3779
3947
|
children: t.label
|
|
3780
3948
|
});
|
|
3781
3949
|
}
|
|
3782
|
-
function
|
|
3950
|
+
function da(e) {
|
|
3783
3951
|
if (!e) return "—";
|
|
3784
3952
|
let t = Date.parse(e);
|
|
3785
3953
|
if (Number.isNaN(t)) return e;
|
|
@@ -3797,7 +3965,7 @@ function sa(e) {
|
|
|
3797
3965
|
return e;
|
|
3798
3966
|
}
|
|
3799
3967
|
}
|
|
3800
|
-
function
|
|
3968
|
+
function fa(e) {
|
|
3801
3969
|
if (!e) return null;
|
|
3802
3970
|
try {
|
|
3803
3971
|
return JSON.parse(e);
|
|
@@ -3805,7 +3973,7 @@ function ca(e) {
|
|
|
3805
3973
|
return e;
|
|
3806
3974
|
}
|
|
3807
3975
|
}
|
|
3808
|
-
function
|
|
3976
|
+
function pa({ value: e, max: t = 320 }) {
|
|
3809
3977
|
let n = typeof e == "string" ? e : JSON.stringify(e, null, 2);
|
|
3810
3978
|
return n == null || n === "" ? /* @__PURE__ */ Q("span", {
|
|
3811
3979
|
className: "text-muted-foreground text-xs",
|
|
@@ -3816,24 +3984,24 @@ function la({ value: e, max: t = 320 }) {
|
|
|
3816
3984
|
children: n
|
|
3817
3985
|
});
|
|
3818
3986
|
}
|
|
3819
|
-
function
|
|
3987
|
+
function ma(e) {
|
|
3820
3988
|
switch (e) {
|
|
3821
3989
|
case "pending": return "pending";
|
|
3822
3990
|
case "all": return "all";
|
|
3823
3991
|
case "decided": return "all";
|
|
3824
3992
|
}
|
|
3825
3993
|
}
|
|
3826
|
-
function
|
|
3827
|
-
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({
|
|
3828
3996
|
apiBase: t,
|
|
3829
3997
|
headers: n,
|
|
3830
3998
|
pollInterval: r,
|
|
3831
3999
|
conversationId: i,
|
|
3832
|
-
status:
|
|
3833
|
-
}),
|
|
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) => {
|
|
3834
4002
|
E(e), O(null);
|
|
3835
4003
|
try {
|
|
3836
|
-
let t = await
|
|
4004
|
+
let t = await ee(e), n = t.status === "executed";
|
|
3837
4005
|
A({
|
|
3838
4006
|
id: e,
|
|
3839
4007
|
kind: "approve",
|
|
@@ -3851,10 +4019,10 @@ function da({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
|
|
|
3851
4019
|
} finally {
|
|
3852
4020
|
E(null);
|
|
3853
4021
|
}
|
|
3854
|
-
}, [
|
|
4022
|
+
}, [ee]), oe = e.useCallback(async (e, t) => {
|
|
3855
4023
|
E(e), O(null);
|
|
3856
4024
|
try {
|
|
3857
|
-
await
|
|
4025
|
+
await F(e, t.trim() || void 0), A({
|
|
3858
4026
|
id: e,
|
|
3859
4027
|
kind: "reject",
|
|
3860
4028
|
ok: !0,
|
|
@@ -3871,24 +4039,24 @@ function da({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
|
|
|
3871
4039
|
} finally {
|
|
3872
4040
|
E(null);
|
|
3873
4041
|
}
|
|
3874
|
-
}, [
|
|
4042
|
+
}, [F]), se = /* @__PURE__ */ $("div", {
|
|
3875
4043
|
className: "space-y-3",
|
|
3876
4044
|
children: [
|
|
3877
4045
|
/* @__PURE__ */ $("div", {
|
|
3878
4046
|
className: "flex items-center justify-between gap-2",
|
|
3879
|
-
children: [/* @__PURE__ */ Q(
|
|
4047
|
+
children: [/* @__PURE__ */ Q(U, {
|
|
3880
4048
|
value: l,
|
|
3881
4049
|
onValueChange: (e) => u(e),
|
|
3882
|
-
children: /* @__PURE__ */ $(
|
|
3883
|
-
/* @__PURE__ */ Q(
|
|
4050
|
+
children: /* @__PURE__ */ $(W, { children: [
|
|
4051
|
+
/* @__PURE__ */ Q(G, {
|
|
3884
4052
|
value: "pending",
|
|
3885
4053
|
children: "Pending"
|
|
3886
4054
|
}),
|
|
3887
|
-
/* @__PURE__ */ Q(
|
|
4055
|
+
/* @__PURE__ */ Q(G, {
|
|
3888
4056
|
value: "decided",
|
|
3889
4057
|
children: "Decided"
|
|
3890
4058
|
}),
|
|
3891
|
-
/* @__PURE__ */ Q(
|
|
4059
|
+
/* @__PURE__ */ Q(G, {
|
|
3892
4060
|
value: "all",
|
|
3893
4061
|
children: "All"
|
|
3894
4062
|
})
|
|
@@ -3896,7 +4064,7 @@ function da({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
|
|
|
3896
4064
|
}), /* @__PURE__ */ $(v, {
|
|
3897
4065
|
variant: "outline",
|
|
3898
4066
|
size: "sm",
|
|
3899
|
-
onClick: () => void
|
|
4067
|
+
onClick: () => void P(),
|
|
3900
4068
|
disabled: M,
|
|
3901
4069
|
"data-testid": "ai-inbox-refresh",
|
|
3902
4070
|
children: [/* @__PURE__ */ Q(st, { className: `h-3.5 w-3.5 mr-1.5 ${M ? "animate-spin" : ""}` }), "Refresh"]
|
|
@@ -3904,15 +4072,15 @@ function da({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
|
|
|
3904
4072
|
}),
|
|
3905
4073
|
N ? /* @__PURE__ */ $(f, {
|
|
3906
4074
|
variant: "destructive",
|
|
3907
|
-
children: [/* @__PURE__ */ Q(
|
|
4075
|
+
children: [/* @__PURE__ */ Q(ke, { className: "h-4 w-4" }), /* @__PURE__ */ Q(p, { children: N.message })]
|
|
3908
4076
|
}) : null,
|
|
3909
4077
|
D ? /* @__PURE__ */ $(f, {
|
|
3910
4078
|
variant: "destructive",
|
|
3911
|
-
children: [/* @__PURE__ */ Q(
|
|
4079
|
+
children: [/* @__PURE__ */ Q(ke, { className: "h-4 w-4" }), /* @__PURE__ */ Q(p, { children: D })]
|
|
3912
4080
|
}) : null,
|
|
3913
4081
|
k && !D ? /* @__PURE__ */ $(f, {
|
|
3914
4082
|
variant: k.ok ? "default" : "destructive",
|
|
3915
|
-
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: [
|
|
3916
4084
|
k.kind === "approve" ? "Approve" : "Reject",
|
|
3917
4085
|
" for",
|
|
3918
4086
|
" ",
|
|
@@ -3925,72 +4093,72 @@ function da({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
|
|
|
3925
4093
|
k.message ?? (k.ok ? "OK" : "Failed")
|
|
3926
4094
|
] })]
|
|
3927
4095
|
}) : null,
|
|
3928
|
-
M &&
|
|
4096
|
+
M && I.length === 0 ? /* @__PURE__ */ $("div", {
|
|
3929
4097
|
className: "space-y-2",
|
|
3930
4098
|
children: [
|
|
3931
|
-
/* @__PURE__ */ Q(
|
|
3932
|
-
/* @__PURE__ */ Q(
|
|
3933
|
-
/* @__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" })
|
|
3934
4102
|
]
|
|
3935
|
-
}) :
|
|
3936
|
-
/* @__PURE__ */ Q(
|
|
3937
|
-
/* @__PURE__ */ Q(
|
|
3938
|
-
/* @__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." })
|
|
3939
4107
|
] }) }) : /* @__PURE__ */ Q("div", {
|
|
3940
4108
|
className: "rounded-md border",
|
|
3941
|
-
children: /* @__PURE__ */ $(
|
|
3942
|
-
/* @__PURE__ */ Q(
|
|
4109
|
+
children: /* @__PURE__ */ $(B, { children: [/* @__PURE__ */ Q(Ce, { children: /* @__PURE__ */ $(we, { children: [
|
|
4110
|
+
/* @__PURE__ */ Q(H, {
|
|
3943
4111
|
className: "w-[140px]",
|
|
3944
4112
|
children: "Tool"
|
|
3945
4113
|
}),
|
|
3946
|
-
/* @__PURE__ */ Q(
|
|
4114
|
+
/* @__PURE__ */ Q(H, {
|
|
3947
4115
|
className: "w-[140px]",
|
|
3948
4116
|
children: "Action"
|
|
3949
4117
|
}),
|
|
3950
|
-
/* @__PURE__ */ Q(
|
|
4118
|
+
/* @__PURE__ */ Q(H, {
|
|
3951
4119
|
className: "w-[120px]",
|
|
3952
4120
|
children: "Object"
|
|
3953
4121
|
}),
|
|
3954
|
-
/* @__PURE__ */ Q(
|
|
4122
|
+
/* @__PURE__ */ Q(H, {
|
|
3955
4123
|
className: "w-[110px]",
|
|
3956
4124
|
children: "Status"
|
|
3957
4125
|
}),
|
|
3958
|
-
/* @__PURE__ */ Q(
|
|
4126
|
+
/* @__PURE__ */ Q(H, {
|
|
3959
4127
|
className: "w-[110px]",
|
|
3960
4128
|
children: "Proposed"
|
|
3961
4129
|
}),
|
|
3962
|
-
/* @__PURE__ */ Q(
|
|
4130
|
+
/* @__PURE__ */ Q(H, {
|
|
3963
4131
|
className: "w-[260px] text-right",
|
|
3964
4132
|
children: "Decision"
|
|
3965
4133
|
})
|
|
3966
|
-
] }) }), /* @__PURE__ */ Q(
|
|
4134
|
+
] }) }), /* @__PURE__ */ Q(Se, { children: I.map((e) => {
|
|
3967
4135
|
let t = e.status === "pending", n = T === e.id;
|
|
3968
|
-
return /* @__PURE__ */ $(
|
|
3969
|
-
/* @__PURE__ */ Q(
|
|
4136
|
+
return /* @__PURE__ */ $(we, { children: [
|
|
4137
|
+
/* @__PURE__ */ Q(V, {
|
|
3970
4138
|
className: "font-mono text-xs",
|
|
3971
4139
|
children: e.tool_name
|
|
3972
4140
|
}),
|
|
3973
|
-
/* @__PURE__ */ Q(
|
|
4141
|
+
/* @__PURE__ */ Q(V, {
|
|
3974
4142
|
className: "text-sm",
|
|
3975
4143
|
children: e.action_name
|
|
3976
4144
|
}),
|
|
3977
|
-
/* @__PURE__ */ Q(
|
|
4145
|
+
/* @__PURE__ */ Q(V, {
|
|
3978
4146
|
className: "text-sm",
|
|
3979
4147
|
children: e.object_name
|
|
3980
4148
|
}),
|
|
3981
|
-
/* @__PURE__ */ Q(
|
|
3982
|
-
/* @__PURE__ */ Q(
|
|
4149
|
+
/* @__PURE__ */ Q(V, { children: /* @__PURE__ */ Q(ua, { status: e.status }) }),
|
|
4150
|
+
/* @__PURE__ */ Q(V, {
|
|
3983
4151
|
className: "text-xs text-muted-foreground",
|
|
3984
4152
|
children: /* @__PURE__ */ $("span", {
|
|
3985
4153
|
className: "inline-flex items-center gap-1",
|
|
3986
4154
|
children: [
|
|
3987
4155
|
/* @__PURE__ */ Q(He, { className: "h-3 w-3" }),
|
|
3988
4156
|
" ",
|
|
3989
|
-
|
|
4157
|
+
da(e.proposed_at)
|
|
3990
4158
|
]
|
|
3991
4159
|
})
|
|
3992
4160
|
}),
|
|
3993
|
-
/* @__PURE__ */ Q(
|
|
4161
|
+
/* @__PURE__ */ Q(V, {
|
|
3994
4162
|
className: "text-right",
|
|
3995
4163
|
children: /* @__PURE__ */ $("div", {
|
|
3996
4164
|
className: "inline-flex gap-1.5",
|
|
@@ -4004,9 +4172,9 @@ function da({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
|
|
|
4004
4172
|
size: "sm",
|
|
4005
4173
|
variant: "default",
|
|
4006
4174
|
disabled: n,
|
|
4007
|
-
onClick: () => void
|
|
4175
|
+
onClick: () => void ae(e.id),
|
|
4008
4176
|
"data-testid": `ai-inbox-approve-${e.id}`,
|
|
4009
|
-
children: [/* @__PURE__ */ Q(
|
|
4177
|
+
children: [/* @__PURE__ */ Q(J, { className: "h-3.5 w-3.5 mr-1" }), n ? "Working…" : "Approve"]
|
|
4010
4178
|
}), /* @__PURE__ */ $(v, {
|
|
4011
4179
|
size: "sm",
|
|
4012
4180
|
variant: "destructive",
|
|
@@ -4032,127 +4200,127 @@ function da({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
|
|
|
4032
4200
|
children: [/* @__PURE__ */ $(C, {
|
|
4033
4201
|
className: "flex items-center gap-2",
|
|
4034
4202
|
children: [
|
|
4035
|
-
/* @__PURE__ */ Q(
|
|
4203
|
+
/* @__PURE__ */ Q(Ne, { className: "h-4 w-4" }),
|
|
4036
4204
|
" ",
|
|
4037
4205
|
o
|
|
4038
4206
|
]
|
|
4039
4207
|
}), s ? /* @__PURE__ */ Q(x, { children: s }) : null]
|
|
4040
|
-
}), /* @__PURE__ */ Q(b, { children:
|
|
4208
|
+
}), /* @__PURE__ */ Q(b, { children: se })]
|
|
4041
4209
|
}) : /* @__PURE__ */ Q("div", {
|
|
4042
4210
|
className: c,
|
|
4043
|
-
children:
|
|
4211
|
+
children: se
|
|
4044
4212
|
}),
|
|
4045
|
-
/* @__PURE__ */ Q(
|
|
4213
|
+
/* @__PURE__ */ Q(ge, {
|
|
4046
4214
|
open: !!d,
|
|
4047
4215
|
onOpenChange: (e) => {
|
|
4048
4216
|
e || m(null);
|
|
4049
4217
|
},
|
|
4050
|
-
children: /* @__PURE__ */ $(
|
|
4218
|
+
children: /* @__PURE__ */ $(_e, {
|
|
4051
4219
|
className: "sm:max-w-[560px] overflow-y-auto",
|
|
4052
|
-
children: [/* @__PURE__ */ $(
|
|
4220
|
+
children: [/* @__PURE__ */ $(ye, { children: [/* @__PURE__ */ $(be, {
|
|
4053
4221
|
className: "flex items-center gap-2",
|
|
4054
|
-
children: [/* @__PURE__ */ Q(
|
|
4055
|
-
}), /* @__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: [
|
|
4056
4224
|
"Tool ",
|
|
4057
4225
|
/* @__PURE__ */ Q("code", {
|
|
4058
4226
|
className: "text-xs",
|
|
4059
|
-
children:
|
|
4227
|
+
children: R.tool_name
|
|
4060
4228
|
}),
|
|
4061
4229
|
" on",
|
|
4062
4230
|
" ",
|
|
4063
4231
|
/* @__PURE__ */ Q("code", {
|
|
4064
4232
|
className: "text-xs",
|
|
4065
|
-
children:
|
|
4233
|
+
children: R.object_name
|
|
4066
4234
|
})
|
|
4067
|
-
] }) : "Loading…" })] }),
|
|
4235
|
+
] }) : "Loading…" })] }), R ? /* @__PURE__ */ $("div", {
|
|
4068
4236
|
className: "px-4 space-y-4 mt-4",
|
|
4069
4237
|
children: [
|
|
4070
4238
|
/* @__PURE__ */ $("div", {
|
|
4071
4239
|
className: "grid grid-cols-2 gap-3 text-sm",
|
|
4072
4240
|
children: [
|
|
4073
|
-
/* @__PURE__ */ $("div", { children: [/* @__PURE__ */ Q(
|
|
4241
|
+
/* @__PURE__ */ $("div", { children: [/* @__PURE__ */ Q(z, {
|
|
4074
4242
|
className: "text-xs text-muted-foreground",
|
|
4075
4243
|
children: "Status"
|
|
4076
4244
|
}), /* @__PURE__ */ Q("div", {
|
|
4077
4245
|
className: "mt-1",
|
|
4078
|
-
children: /* @__PURE__ */ Q(
|
|
4246
|
+
children: /* @__PURE__ */ Q(ua, { status: R.status })
|
|
4079
4247
|
})] }),
|
|
4080
|
-
/* @__PURE__ */ $("div", { children: [/* @__PURE__ */ Q(
|
|
4248
|
+
/* @__PURE__ */ $("div", { children: [/* @__PURE__ */ Q(z, {
|
|
4081
4249
|
className: "text-xs text-muted-foreground",
|
|
4082
4250
|
children: "Proposed"
|
|
4083
4251
|
}), /* @__PURE__ */ Q("div", {
|
|
4084
4252
|
className: "mt-1 text-xs",
|
|
4085
|
-
children:
|
|
4253
|
+
children: da(R.proposed_at)
|
|
4086
4254
|
})] }),
|
|
4087
|
-
/* @__PURE__ */ $("div", { children: [/* @__PURE__ */ Q(
|
|
4255
|
+
/* @__PURE__ */ $("div", { children: [/* @__PURE__ */ Q(z, {
|
|
4088
4256
|
className: "text-xs text-muted-foreground",
|
|
4089
4257
|
children: "Proposed by"
|
|
4090
4258
|
}), /* @__PURE__ */ Q("div", {
|
|
4091
4259
|
className: "mt-1 text-xs font-mono break-all",
|
|
4092
|
-
children:
|
|
4260
|
+
children: R.proposed_by ?? "—"
|
|
4093
4261
|
})] }),
|
|
4094
|
-
/* @__PURE__ */ $("div", { children: [/* @__PURE__ */ Q(
|
|
4262
|
+
/* @__PURE__ */ $("div", { children: [/* @__PURE__ */ Q(z, {
|
|
4095
4263
|
className: "text-xs text-muted-foreground",
|
|
4096
4264
|
children: "Decided by"
|
|
4097
4265
|
}), /* @__PURE__ */ Q("div", {
|
|
4098
4266
|
className: "mt-1 text-xs font-mono break-all",
|
|
4099
|
-
children:
|
|
4267
|
+
children: R.decided_by ?? "—"
|
|
4100
4268
|
})] }),
|
|
4101
|
-
|
|
4269
|
+
R.conversation_id ? /* @__PURE__ */ $("div", {
|
|
4102
4270
|
className: "col-span-2",
|
|
4103
|
-
children: [/* @__PURE__ */ Q(
|
|
4271
|
+
children: [/* @__PURE__ */ Q(z, {
|
|
4104
4272
|
className: "text-xs text-muted-foreground",
|
|
4105
4273
|
children: "Conversation"
|
|
4106
4274
|
}), /* @__PURE__ */ Q("div", {
|
|
4107
4275
|
className: "mt-1 text-xs font-mono break-all",
|
|
4108
|
-
children:
|
|
4276
|
+
children: R.conversation_id
|
|
4109
4277
|
})]
|
|
4110
4278
|
}) : null
|
|
4111
4279
|
]
|
|
4112
4280
|
}),
|
|
4113
|
-
/* @__PURE__ */ Q(
|
|
4114
|
-
/* @__PURE__ */ $("div", { children: [/* @__PURE__ */ Q(
|
|
4281
|
+
/* @__PURE__ */ Q(he, {}),
|
|
4282
|
+
/* @__PURE__ */ $("div", { children: [/* @__PURE__ */ Q(z, {
|
|
4115
4283
|
className: "text-xs",
|
|
4116
4284
|
children: "Tool input"
|
|
4117
4285
|
}), /* @__PURE__ */ Q("div", {
|
|
4118
4286
|
className: "mt-1.5",
|
|
4119
|
-
children: /* @__PURE__ */ Q(
|
|
4287
|
+
children: /* @__PURE__ */ Q(pa, { value: fa(R.tool_input) })
|
|
4120
4288
|
})] }),
|
|
4121
|
-
|
|
4289
|
+
R.result ? /* @__PURE__ */ $("div", { children: [/* @__PURE__ */ Q(z, {
|
|
4122
4290
|
className: "text-xs",
|
|
4123
4291
|
children: "Result"
|
|
4124
4292
|
}), /* @__PURE__ */ Q("div", {
|
|
4125
4293
|
className: "mt-1.5",
|
|
4126
|
-
children: /* @__PURE__ */ Q(
|
|
4294
|
+
children: /* @__PURE__ */ Q(pa, { value: fa(R.result) })
|
|
4127
4295
|
})] }) : null,
|
|
4128
|
-
|
|
4296
|
+
R.error ? /* @__PURE__ */ $("div", { children: [/* @__PURE__ */ Q(z, {
|
|
4129
4297
|
className: "text-xs text-destructive",
|
|
4130
4298
|
children: "Error"
|
|
4131
4299
|
}), /* @__PURE__ */ Q("div", {
|
|
4132
4300
|
className: "mt-1.5",
|
|
4133
|
-
children: /* @__PURE__ */ Q(
|
|
4301
|
+
children: /* @__PURE__ */ Q(pa, { value: R.error })
|
|
4134
4302
|
})] }) : null,
|
|
4135
|
-
|
|
4303
|
+
R.rejection_reason ? /* @__PURE__ */ $("div", { children: [/* @__PURE__ */ Q(z, {
|
|
4136
4304
|
className: "text-xs",
|
|
4137
4305
|
children: "Rejection reason"
|
|
4138
4306
|
}), /* @__PURE__ */ Q("div", {
|
|
4139
4307
|
className: "mt-1.5 text-sm",
|
|
4140
|
-
children:
|
|
4308
|
+
children: R.rejection_reason
|
|
4141
4309
|
})] }) : null,
|
|
4142
|
-
|
|
4310
|
+
R.status === "pending" ? /* @__PURE__ */ $("div", {
|
|
4143
4311
|
className: "pt-2 flex gap-2",
|
|
4144
4312
|
children: [/* @__PURE__ */ $(v, {
|
|
4145
4313
|
size: "sm",
|
|
4146
|
-
onClick: () => void
|
|
4147
|
-
disabled: T ===
|
|
4148
|
-
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"]
|
|
4149
4317
|
}), /* @__PURE__ */ $(v, {
|
|
4150
4318
|
size: "sm",
|
|
4151
4319
|
variant: "destructive",
|
|
4152
4320
|
onClick: () => {
|
|
4153
|
-
g(
|
|
4321
|
+
g(R.id), w("");
|
|
4154
4322
|
},
|
|
4155
|
-
disabled: T ===
|
|
4323
|
+
disabled: T === R.id,
|
|
4156
4324
|
children: [/* @__PURE__ */ Q(X, { className: "h-3.5 w-3.5 mr-1" }), "Reject"]
|
|
4157
4325
|
})]
|
|
4158
4326
|
}) : null
|
|
@@ -4160,17 +4328,17 @@ function da({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
|
|
|
4160
4328
|
}) : null]
|
|
4161
4329
|
})
|
|
4162
4330
|
}),
|
|
4163
|
-
/* @__PURE__ */ Q(
|
|
4331
|
+
/* @__PURE__ */ Q(ge, {
|
|
4164
4332
|
open: !!h,
|
|
4165
4333
|
onOpenChange: (e) => {
|
|
4166
4334
|
e || (g(null), w(""));
|
|
4167
4335
|
},
|
|
4168
|
-
children: /* @__PURE__ */ $(
|
|
4336
|
+
children: /* @__PURE__ */ $(_e, {
|
|
4169
4337
|
side: "bottom",
|
|
4170
4338
|
className: "max-h-[40vh]",
|
|
4171
|
-
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", {
|
|
4172
4340
|
className: "px-4 mt-3 space-y-3",
|
|
4173
|
-
children: [/* @__PURE__ */ Q(
|
|
4341
|
+
children: [/* @__PURE__ */ Q(Te, {
|
|
4174
4342
|
value: _,
|
|
4175
4343
|
onChange: (e) => w(e.target.value),
|
|
4176
4344
|
placeholder: "Optional reason (e.g. 'Wrong record id — please confirm with the user first.')",
|
|
@@ -4188,7 +4356,7 @@ function da({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
|
|
|
4188
4356
|
}), /* @__PURE__ */ $(v, {
|
|
4189
4357
|
variant: "destructive",
|
|
4190
4358
|
size: "sm",
|
|
4191
|
-
onClick: () => h && void
|
|
4359
|
+
onClick: () => h && void oe(h, _),
|
|
4192
4360
|
disabled: !h || T === h,
|
|
4193
4361
|
"data-testid": "ai-inbox-reject-confirm",
|
|
4194
4362
|
children: [/* @__PURE__ */ Q(X, { className: "h-3.5 w-3.5 mr-1" }), "Reject"]
|
|
@@ -4201,14 +4369,14 @@ function da({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
|
|
|
4201
4369
|
}
|
|
4202
4370
|
//#endregion
|
|
4203
4371
|
//#region src/useHitlInChat.ts
|
|
4204
|
-
function
|
|
4372
|
+
function ga(e) {
|
|
4205
4373
|
return !e || e.length === 0 ? "/api/v1/ai" : e.endsWith("/") ? e.slice(0, -1) : e;
|
|
4206
4374
|
}
|
|
4207
|
-
function
|
|
4375
|
+
function _a(e, t) {
|
|
4208
4376
|
let n = { ...e ?? {} };
|
|
4209
4377
|
return t && (n["Content-Type"] = "application/json"), n;
|
|
4210
4378
|
}
|
|
4211
|
-
async function
|
|
4379
|
+
async function va(e) {
|
|
4212
4380
|
let t = await e.text();
|
|
4213
4381
|
if (!t) return null;
|
|
4214
4382
|
try {
|
|
@@ -4217,8 +4385,8 @@ async function ma(e) {
|
|
|
4217
4385
|
return { raw: t };
|
|
4218
4386
|
}
|
|
4219
4387
|
}
|
|
4220
|
-
function
|
|
4221
|
-
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(() => {
|
|
4222
4390
|
let e = /* @__PURE__ */ new Map();
|
|
4223
4391
|
for (let t of n) {
|
|
4224
4392
|
let n = t.toolInvocations ?? [];
|
|
@@ -4261,9 +4429,9 @@ function ha(t) {
|
|
|
4261
4429
|
let r = `${s}/pending-actions/${encodeURIComponent(l)}/${t ? "approve" : "reject"}`, c = t ? "{}" : JSON.stringify({ reason: n ?? "" }), d = await fetch(r, {
|
|
4262
4430
|
method: "POST",
|
|
4263
4431
|
credentials: "include",
|
|
4264
|
-
headers:
|
|
4432
|
+
headers: _a(i, !0),
|
|
4265
4433
|
body: c
|
|
4266
|
-
}), f = await
|
|
4434
|
+
}), f = await va(d) ?? {};
|
|
4267
4435
|
if (!d.ok) {
|
|
4268
4436
|
let t = typeof f.error == "string" ? f.error : `Approval failed: HTTP ${d.status}`;
|
|
4269
4437
|
m(e, {
|
|
@@ -4290,7 +4458,7 @@ function ha(t) {
|
|
|
4290
4458
|
state: "success",
|
|
4291
4459
|
message: `Status: ${p}`
|
|
4292
4460
|
}), h = !0), a?.(e, f), h && o) {
|
|
4293
|
-
let r =
|
|
4461
|
+
let r = ba({
|
|
4294
4462
|
approved: t,
|
|
4295
4463
|
status: p,
|
|
4296
4464
|
toolName: u,
|
|
@@ -4325,24 +4493,24 @@ function ha(t) {
|
|
|
4325
4493
|
isDeciding: f
|
|
4326
4494
|
};
|
|
4327
4495
|
}
|
|
4328
|
-
function
|
|
4496
|
+
function ba(e) {
|
|
4329
4497
|
let { approved: t, status: n, toolName: r, pendingActionId: i, outcome: a, reason: o } = e, s = `[HITL ${i}]`;
|
|
4330
4498
|
if (t && n === "executed") {
|
|
4331
4499
|
let e = a.result;
|
|
4332
|
-
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.`;
|
|
4333
4501
|
}
|
|
4334
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.`;
|
|
4335
4503
|
if (n === "failed") {
|
|
4336
4504
|
let e = a.error;
|
|
4337
|
-
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.`;
|
|
4338
4506
|
}
|
|
4339
4507
|
}
|
|
4340
|
-
function
|
|
4508
|
+
function xa(e, t) {
|
|
4341
4509
|
return e.length <= t ? e : `${e.slice(0, t - 1)}…`;
|
|
4342
4510
|
}
|
|
4343
4511
|
//#endregion
|
|
4344
4512
|
//#region src/index.tsx
|
|
4345
|
-
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) => {
|
|
4346
4514
|
let [m, h] = e.useState(""), g = e.useRef(null), _ = e.useRef(null);
|
|
4347
4515
|
e.useEffect(() => {
|
|
4348
4516
|
if (g.current) {
|
|
@@ -4357,10 +4525,10 @@ var va = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
4357
4525
|
};
|
|
4358
4526
|
return /* @__PURE__ */ $("div", {
|
|
4359
4527
|
ref: p,
|
|
4360
|
-
className:
|
|
4528
|
+
className: q("flex flex-col border rounded-lg bg-background overflow-hidden", t),
|
|
4361
4529
|
style: { maxHeight: d },
|
|
4362
4530
|
...f,
|
|
4363
|
-
children: [/* @__PURE__ */ Q(
|
|
4531
|
+
children: [/* @__PURE__ */ Q(ce, {
|
|
4364
4532
|
ref: g,
|
|
4365
4533
|
className: "flex-1 p-4",
|
|
4366
4534
|
children: /* @__PURE__ */ Q("div", {
|
|
@@ -4368,7 +4536,7 @@ var va = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
4368
4536
|
children: n.length === 0 ? /* @__PURE__ */ Q("div", {
|
|
4369
4537
|
className: "flex items-center justify-center h-32 text-muted-foreground text-sm",
|
|
4370
4538
|
children: "No messages yet. Start a conversation!"
|
|
4371
|
-
}) : n.map((e) => /* @__PURE__ */ Q(
|
|
4539
|
+
}) : n.map((e) => /* @__PURE__ */ Q(Ca, {
|
|
4372
4540
|
message: e,
|
|
4373
4541
|
showTimestamp: o,
|
|
4374
4542
|
userAvatarUrl: s,
|
|
@@ -4381,7 +4549,7 @@ var va = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
4381
4549
|
className: "border-t p-4",
|
|
4382
4550
|
children: /* @__PURE__ */ $("div", {
|
|
4383
4551
|
className: "flex gap-2",
|
|
4384
|
-
children: [/* @__PURE__ */ Q(
|
|
4552
|
+
children: [/* @__PURE__ */ Q(se, {
|
|
4385
4553
|
ref: _,
|
|
4386
4554
|
value: m,
|
|
4387
4555
|
onChange: (e) => h(e.target.value),
|
|
@@ -4399,8 +4567,8 @@ var va = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
4399
4567
|
})]
|
|
4400
4568
|
});
|
|
4401
4569
|
});
|
|
4402
|
-
|
|
4403
|
-
var
|
|
4570
|
+
Sa.displayName = "Chatbot";
|
|
4571
|
+
var Ca = ({ message: e, showTimestamp: t, userAvatarUrl: n, userAvatarFallback: r, assistantAvatarUrl: i, assistantAvatarFallback: a }) => {
|
|
4404
4572
|
let o = e.role === "user";
|
|
4405
4573
|
if (e.role === "system") return /* @__PURE__ */ Q("div", {
|
|
4406
4574
|
className: "flex justify-center",
|
|
@@ -4411,7 +4579,7 @@ var ya = ({ message: e, showTimestamp: t, userAvatarUrl: n, userAvatarFallback:
|
|
|
4411
4579
|
});
|
|
4412
4580
|
let s = o ? e.avatar || n : e.avatar || i, c = o ? e.avatarFallback || r : e.avatarFallback || a;
|
|
4413
4581
|
return /* @__PURE__ */ $("div", {
|
|
4414
|
-
className:
|
|
4582
|
+
className: q("flex gap-3", o ? "flex-row-reverse" : "flex-row"),
|
|
4415
4583
|
children: [/* @__PURE__ */ $(m, {
|
|
4416
4584
|
className: "h-8 w-8",
|
|
4417
4585
|
children: [/* @__PURE__ */ Q(g, { src: s }), /* @__PURE__ */ Q(h, {
|
|
@@ -4419,9 +4587,9 @@ var ya = ({ message: e, showTimestamp: t, userAvatarUrl: n, userAvatarFallback:
|
|
|
4419
4587
|
children: c
|
|
4420
4588
|
})]
|
|
4421
4589
|
}), /* @__PURE__ */ $("div", {
|
|
4422
|
-
className:
|
|
4590
|
+
className: q("flex flex-col gap-1", o ? "items-end" : "items-start"),
|
|
4423
4591
|
children: [/* @__PURE__ */ Q("div", {
|
|
4424
|
-
className:
|
|
4592
|
+
className: q("rounded-lg px-4 py-2 max-w-[70%] break-words", o ? "bg-primary text-primary-foreground" : "bg-muted"),
|
|
4425
4593
|
children: /* @__PURE__ */ Q("p", {
|
|
4426
4594
|
className: "text-sm whitespace-pre-wrap",
|
|
4427
4595
|
children: e.content
|
|
@@ -4432,9 +4600,9 @@ var ya = ({ message: e, showTimestamp: t, userAvatarUrl: n, userAvatarFallback:
|
|
|
4432
4600
|
})]
|
|
4433
4601
|
})]
|
|
4434
4602
|
});
|
|
4435
|
-
},
|
|
4603
|
+
}, wa = e.forwardRef(({ className: e, avatarSrc: t, avatarFallback: n = "AI", ...r }, i) => /* @__PURE__ */ $("div", {
|
|
4436
4604
|
ref: i,
|
|
4437
|
-
className:
|
|
4605
|
+
className: q("flex gap-3", e),
|
|
4438
4606
|
...r,
|
|
4439
4607
|
children: [/* @__PURE__ */ $(m, {
|
|
4440
4608
|
className: "h-8 w-8",
|
|
@@ -4454,6 +4622,6 @@ var ya = ({ message: e, showTimestamp: t, userAvatarUrl: n, userAvatarFallback:
|
|
|
4454
4622
|
})
|
|
4455
4623
|
})]
|
|
4456
4624
|
}));
|
|
4457
|
-
|
|
4625
|
+
wa.displayName = "TypingIndicator";
|
|
4458
4626
|
//#endregion
|
|
4459
|
-
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 };
|