@object-ui/plugin-chatbot 17.5.0 → 17.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +101 -0
- package/dist/ChatbotEnhanced.d.ts +29 -0
- package/dist/ChatbotEnhanced.d.ts.map +1 -1
- package/dist/chatMessageAdapter.d.ts +1 -1
- package/dist/chatMessageAdapter.d.ts.map +1 -1
- package/dist/elements/prompt-input.d.ts.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1185 -1031
- package/dist/index.umd.cjs +3 -1
- package/dist/mapMessages.d.ts +53 -0
- package/dist/mapMessages.d.ts.map +1 -1
- package/dist/useObjectChat.d.ts +10 -1
- package/dist/useObjectChat.d.ts.map +1 -1
- package/package.json +10 -10
package/dist/index.js
CHANGED
|
@@ -1,46 +1,46 @@
|
|
|
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 ee, DropdownMenuContent as P, 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 z, Label as B, ScrollArea 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 ee, DropdownMenuContent as P, 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 z, Label as B, ScrollArea as se, ScrollBar as V, Select as ce, SelectContent as le, SelectItem as ue, SelectTrigger as de, SelectValue as fe, Separator as pe, Sheet as me, SheetContent as he, SheetDescription as ge, SheetHeader as _e, SheetTitle as ve, Skeleton as ye, Table as be, TableBody as xe, TableCell as H, TableHead as U, TableHeader as Se, TableRow as Ce, Tabs as we, TabsList as Te, TabsTrigger as Ee, Textarea as De, Tooltip as Oe, TooltipContent as ke, TooltipProvider as Ae, TooltipTrigger as je, cn as W } from "@object-ui/components";
|
|
4
|
+
import { AlertCircle as Me, ArrowDownIcon as Ne, ArrowRight as Pe, BookIcon as Fe, Bot as Ie, BrainIcon as Le, Check as Re, CheckCircle2 as G, CheckCircleIcon as ze, CheckIcon as Be, ChevronDownIcon as Ve, ChevronLeftIcon as He, ChevronRightIcon as Ue, CircleIcon as K, ClipboardList as We, Clock as Ge, Clock3 as Ke, ClockIcon as qe, Copy as Je, CopyIcon as Ye, CornerDownLeft as Xe, CornerDownLeftIcon as Ze, Eye as Qe, GitCompareArrows as $e, HelpCircle as et, Hourglass as tt, ImageIcon as nt, Inbox as rt, Loader2 as it, Loader2Icon as at, Maximize2 as ot, MicIcon as st, Minimize2 as q, PaperclipIcon as ct, PlusIcon as lt, RefreshCw as ut, Rocket as dt, Send as ft, ShieldCheck as pt, Sparkles as mt, SquareIcon as ht, Table2 as gt, TriangleAlert as _t, WifiOff as vt, WrenchIcon as yt, X as bt, XCircle as J, XCircleIcon as xt, XIcon as Y } from "lucide-react";
|
|
5
5
|
import { Fragment as X, jsx as Z, jsxs as Q } from "react/jsx-runtime";
|
|
6
6
|
import { useChat as St } from "@ai-sdk/react";
|
|
7
7
|
import { DefaultChatTransport as Ct } from "ai";
|
|
8
8
|
import * as wt from "react-dom";
|
|
9
|
-
import { SchemaRenderer as Tt, useObjectTranslation as
|
|
10
|
-
import { useObjectTranslation as
|
|
11
|
-
import { StickToBottom as
|
|
12
|
-
import { cva as
|
|
13
|
-
import { Slot as
|
|
14
|
-
import { Streamdown as
|
|
15
|
-
import { nanoid as
|
|
16
|
-
import { codeToHtml as
|
|
17
|
-
import { useControllableState as
|
|
18
|
-
import { motion as
|
|
19
|
-
import { ComponentRegistry as
|
|
9
|
+
import { SchemaRenderer as Tt, useObjectTranslation as Et } from "@object-ui/react";
|
|
10
|
+
import { useObjectTranslation as Dt, useSafeTranslate as Ot } from "@object-ui/i18n";
|
|
11
|
+
import { StickToBottom as kt, useStickToBottomContext as At } from "use-stick-to-bottom";
|
|
12
|
+
import { cva as jt } from "class-variance-authority";
|
|
13
|
+
import { Slot as Mt } from "@radix-ui/react-slot";
|
|
14
|
+
import { Streamdown as Nt } from "streamdown";
|
|
15
|
+
import { nanoid as Pt } from "nanoid";
|
|
16
|
+
import { codeToHtml as Ft } from "shiki";
|
|
17
|
+
import { useControllableState as It } from "@radix-ui/react-use-controllable-state";
|
|
18
|
+
import { motion as Lt } from "motion/react";
|
|
19
|
+
import { ComponentRegistry as Rt, toDomProps as zt } from "@object-ui/core";
|
|
20
20
|
//#region \0rolldown/runtime.js
|
|
21
|
-
var
|
|
21
|
+
var Bt = Object.defineProperty, Vt = (e, t) => {
|
|
22
22
|
let n = {};
|
|
23
|
-
for (var r in e)
|
|
23
|
+
for (var r in e) Bt(n, r, {
|
|
24
24
|
get: e[r],
|
|
25
25
|
enumerable: !0
|
|
26
26
|
});
|
|
27
|
-
return t ||
|
|
27
|
+
return t || Bt(n, Symbol.toStringTag, { value: "Module" }), n;
|
|
28
28
|
};
|
|
29
29
|
//#endregion
|
|
30
30
|
//#region src/utils.ts
|
|
31
|
-
function
|
|
31
|
+
function Ht(e = "msg") {
|
|
32
32
|
return typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID() : `${e}-${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
|
33
33
|
}
|
|
34
34
|
//#endregion
|
|
35
35
|
//#region src/mapMessages.ts
|
|
36
|
-
function
|
|
36
|
+
function Ut(e, t) {
|
|
37
37
|
return typeof e.content == "string" ? e.content : t.filter((e) => e.type === "text").map((e) => e.text ?? "").join("");
|
|
38
38
|
}
|
|
39
|
-
function
|
|
39
|
+
function Wt(e) {
|
|
40
40
|
let t = e.filter((e) => e.type === "reasoning" || e.type === "reasoning-delta").map((e) => e.text ?? "").join("\n").trim();
|
|
41
41
|
return t.length > 0 ? t : void 0;
|
|
42
42
|
}
|
|
43
|
-
function
|
|
43
|
+
function $(e) {
|
|
44
44
|
let t = (e) => {
|
|
45
45
|
if (e && typeof e == "object") return e;
|
|
46
46
|
if (typeof e != "string") return;
|
|
@@ -53,18 +53,18 @@ function Wt(e) {
|
|
|
53
53
|
}
|
|
54
54
|
}, n = [e];
|
|
55
55
|
e && typeof e == "object" && "value" in e && n.push(e.value);
|
|
56
|
-
let r;
|
|
56
|
+
let r, i;
|
|
57
57
|
for (let e of n) {
|
|
58
58
|
let n = t(e);
|
|
59
59
|
if (n) {
|
|
60
60
|
if (typeof n.status == "string") return n;
|
|
61
|
-
r ??= n;
|
|
61
|
+
n.type === "text" && "value" in n ? i ??= n : r ??= n;
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
|
-
return r;
|
|
64
|
+
return r ?? i;
|
|
65
65
|
}
|
|
66
66
|
function Gt(e) {
|
|
67
|
-
let t =
|
|
67
|
+
let t = $(e);
|
|
68
68
|
if (!t) return;
|
|
69
69
|
let n = t.pendingActionId;
|
|
70
70
|
if (t.status === "pending_approval" && typeof n == "string" && n.length > 0) return {
|
|
@@ -76,7 +76,7 @@ function Kt(e) {
|
|
|
76
76
|
return Array.isArray(e) ? e.filter((e) => typeof e == "string" && e.trim().length > 0) : [];
|
|
77
77
|
}
|
|
78
78
|
function qt(e) {
|
|
79
|
-
let t =
|
|
79
|
+
let t = $(e);
|
|
80
80
|
if (!t || t.status !== "blueprint_proposed") return;
|
|
81
81
|
let n = t.blueprint, r = n && typeof n == "object" ? n : {}, i = (Array.isArray(r.objects) ? r.objects : []).flatMap((e) => {
|
|
82
82
|
let t = e;
|
|
@@ -112,7 +112,7 @@ function qt(e) {
|
|
|
112
112
|
};
|
|
113
113
|
}
|
|
114
114
|
function Jt(e) {
|
|
115
|
-
let t =
|
|
115
|
+
let t = $(e);
|
|
116
116
|
if (!t || t.status !== "build_handoff") return;
|
|
117
117
|
let n = typeof t.prompt == "string" ? t.prompt.trim() : "";
|
|
118
118
|
if (!n) return;
|
|
@@ -123,7 +123,7 @@ function Jt(e) {
|
|
|
123
123
|
};
|
|
124
124
|
}
|
|
125
125
|
function Yt(e) {
|
|
126
|
-
let t =
|
|
126
|
+
let t = $(e);
|
|
127
127
|
if (!t || t.status !== "changes_proposed") return;
|
|
128
128
|
let n = (e) => typeof e == "string" && e ? e : void 0, r = t.changes, i = (Array.isArray(r) ? r : []).flatMap((e) => {
|
|
129
129
|
let t = e;
|
|
@@ -141,8 +141,57 @@ function Yt(e) {
|
|
|
141
141
|
changes: i
|
|
142
142
|
};
|
|
143
143
|
}
|
|
144
|
-
function Xt(e) {
|
|
145
|
-
|
|
144
|
+
function Xt(e, t) {
|
|
145
|
+
if (!e || !e.startsWith("replay_")) return;
|
|
146
|
+
let n = $(t);
|
|
147
|
+
if (!n) return;
|
|
148
|
+
if (n.status === "published") return { kind: "published" };
|
|
149
|
+
let r = n.error;
|
|
150
|
+
if (typeof r == "string" && r.trim() && n.status === void 0) return {
|
|
151
|
+
kind: "failed",
|
|
152
|
+
dispatchError: !0,
|
|
153
|
+
error: r.trim().split("\n")[0]
|
|
154
|
+
};
|
|
155
|
+
if (n.status !== "drafted") return;
|
|
156
|
+
let i = n.packageId, a = typeof i == "string" && i ? { packageId: i } : {};
|
|
157
|
+
if (n.publishFailed === !0) {
|
|
158
|
+
let e = n.publishError, t = typeof e == "string" && e.trim() ? e.trim().split("\n")[0] : void 0, r = n.publishOutcome;
|
|
159
|
+
return {
|
|
160
|
+
kind: "failed",
|
|
161
|
+
...typeof r == "string" && r ? { outcome: r } : {},
|
|
162
|
+
...t ? { error: t } : {},
|
|
163
|
+
...a
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
return {
|
|
167
|
+
kind: "drafted",
|
|
168
|
+
...a
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
function Zt(e) {
|
|
172
|
+
let t = $(e);
|
|
173
|
+
if (!t) return;
|
|
174
|
+
if (t.status === "published") return { kind: "published" };
|
|
175
|
+
if (t.status !== "drafted") return;
|
|
176
|
+
let n = t.packageId, r = typeof n == "string" && n ? { packageId: n } : {};
|
|
177
|
+
return t.publishFailed === !0 ? {
|
|
178
|
+
kind: "failed",
|
|
179
|
+
...r
|
|
180
|
+
} : {
|
|
181
|
+
kind: "drafted",
|
|
182
|
+
...r
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
function Qt(e) {
|
|
186
|
+
let t = $(e);
|
|
187
|
+
if (!t || t.status !== "drafted" && t.status !== "published") return;
|
|
188
|
+
let n = t.packageId;
|
|
189
|
+
if (typeof n != "string" || !n) return;
|
|
190
|
+
let r = t.drafted;
|
|
191
|
+
return Array.isArray(r) && r.some((e) => e && typeof e == "object" && e.type === "app") ? n : void 0;
|
|
192
|
+
}
|
|
193
|
+
function $t(e) {
|
|
194
|
+
let t = $(e);
|
|
146
195
|
if (!t || t.status !== "drafted") return;
|
|
147
196
|
let n = [];
|
|
148
197
|
if (Array.isArray(t.drafted)) {
|
|
@@ -182,39 +231,40 @@ function Xt(e) {
|
|
|
182
231
|
...s.length ? { issues: s } : {}
|
|
183
232
|
};
|
|
184
233
|
}
|
|
185
|
-
function
|
|
234
|
+
function en(e) {
|
|
186
235
|
return e.replace(/[._-]+/g, " ").replace(/\s+/g, " ").trim().replace(/\b\w/g, (e) => e.toUpperCase());
|
|
187
236
|
}
|
|
188
|
-
function
|
|
237
|
+
function tn(e) {
|
|
189
238
|
if (!e || !Array.isArray(e.items) || e.items.length === 0) return;
|
|
190
239
|
let t = e.items.find((e) => e.type === "app");
|
|
191
240
|
if (t) return {
|
|
192
241
|
phase: "done",
|
|
193
|
-
appLabel:
|
|
242
|
+
appLabel: en(t.name),
|
|
194
243
|
items: e.items,
|
|
195
244
|
done: e.items.length,
|
|
196
245
|
total: e.items.length
|
|
197
246
|
};
|
|
198
247
|
}
|
|
199
|
-
function
|
|
248
|
+
function nn(e, t = {}) {
|
|
200
249
|
return e.filter((e) => e.type === "dynamic-tool" || typeof e.type == "string" && e.type.startsWith("tool-")).map((e) => {
|
|
201
|
-
let n = e.type === "dynamic-tool" ? e.toolName ?? "tool" : typeof e.type == "string" ? e.type.replace(/^tool-/, "") : "tool", r = e.output ?? e.result,
|
|
250
|
+
let n = e.type === "dynamic-tool" ? e.toolName ?? "tool" : typeof e.type == "string" ? e.type.replace(/^tool-/, "") : "tool", r = e.toolCallId ?? e.id ?? `${e.type ?? "tool"}-${Math.random().toString(36).slice(2, 8)}`, i = e.output ?? e.result, a = Gt(i), o = Xt(r, i), s = o ? void 0 : $t(i), c = qt(i), l = Yt(i), u = Jt(i), d = e.state, f = (d === "input-available" || d === "input-streaming") && (i !== void 0 || !t.liveTail) ? "output-available" : d, p = a && f !== "output-error" ? "approval-requested" : f;
|
|
202
251
|
return {
|
|
203
|
-
toolCallId:
|
|
252
|
+
toolCallId: r,
|
|
204
253
|
toolName: n,
|
|
205
254
|
args: e.input ?? e.args,
|
|
206
|
-
result:
|
|
255
|
+
result: i,
|
|
207
256
|
errorText: e.errorText,
|
|
208
|
-
state:
|
|
209
|
-
pendingActionId:
|
|
210
|
-
draftReview:
|
|
211
|
-
proposedPlan:
|
|
212
|
-
proposedChanges:
|
|
213
|
-
builderHandoff:
|
|
257
|
+
state: p,
|
|
258
|
+
pendingActionId: a?.pendingActionId,
|
|
259
|
+
draftReview: s,
|
|
260
|
+
proposedPlan: c,
|
|
261
|
+
proposedChanges: l,
|
|
262
|
+
builderHandoff: u,
|
|
263
|
+
replayOutcome: o
|
|
214
264
|
};
|
|
215
265
|
});
|
|
216
266
|
}
|
|
217
|
-
function
|
|
267
|
+
function rn(e) {
|
|
218
268
|
let t = e.filter((e) => e.type === "source-url" || e.type === "source").map((e) => ({
|
|
219
269
|
id: e.id,
|
|
220
270
|
title: e.title,
|
|
@@ -222,7 +272,7 @@ function en(e) {
|
|
|
222
272
|
})).filter((e) => !!e.url);
|
|
223
273
|
return t.length > 0 ? t : void 0;
|
|
224
274
|
}
|
|
225
|
-
function
|
|
275
|
+
function an(e) {
|
|
226
276
|
let t = e.filter((e) => e.type === "data-build-progress").pop()?.data;
|
|
227
277
|
if (!t || typeof t != "object") return;
|
|
228
278
|
let n = t, r = Array.isArray(n.items) ? n.items.filter((e) => typeof e?.type == "string" && typeof e?.name == "string").map((e) => ({
|
|
@@ -238,7 +288,7 @@ function tn(e) {
|
|
|
238
288
|
...typeof n.seq == "number" ? { seq: n.seq } : {}
|
|
239
289
|
};
|
|
240
290
|
}
|
|
241
|
-
function
|
|
291
|
+
function on(e) {
|
|
242
292
|
let t = e.filter((e) => e.type === "data-blueprint-progress").pop()?.data;
|
|
243
293
|
if (!t || typeof t != "object") return;
|
|
244
294
|
let n = t, r = Array.isArray(n.objects) ? n.objects.filter((e) => typeof e?.name == "string").map((e) => ({
|
|
@@ -260,7 +310,7 @@ function nn(e) {
|
|
|
260
310
|
...typeof n.seq == "number" ? { seq: n.seq } : {}
|
|
261
311
|
};
|
|
262
312
|
}
|
|
263
|
-
function
|
|
313
|
+
function sn(e) {
|
|
264
314
|
let t = [];
|
|
265
315
|
for (let n of e) {
|
|
266
316
|
if (n.type !== "data-chart") continue;
|
|
@@ -280,35 +330,35 @@ function rn(e) {
|
|
|
280
330
|
}
|
|
281
331
|
return t.length > 0 ? t : void 0;
|
|
282
332
|
}
|
|
283
|
-
function
|
|
284
|
-
let n = Array.isArray(e.parts) ? e.parts : [], r =
|
|
333
|
+
function cn(e, t = {}) {
|
|
334
|
+
let n = Array.isArray(e.parts) ? e.parts : [], r = nn(n, { liveTail: t.streaming }), i = Array.isArray(e.toolInvocations) ? e.toolInvocations : [], a = r.length > 0 ? r : i, o = an(n) ?? a.map((e) => tn(e.draftReview)).find((e) => !!e);
|
|
285
335
|
return {
|
|
286
336
|
id: e.id ?? `msg-${Math.random().toString(36).slice(2, 8)}`,
|
|
287
337
|
role: e.role ?? "assistant",
|
|
288
|
-
content:
|
|
289
|
-
reasoning:
|
|
338
|
+
content: Ut(e, n),
|
|
339
|
+
reasoning: Wt(n),
|
|
290
340
|
toolInvocations: a,
|
|
291
|
-
sources:
|
|
341
|
+
sources: rn(n),
|
|
292
342
|
buildProgress: o,
|
|
293
|
-
blueprintProgress:
|
|
294
|
-
charts:
|
|
343
|
+
blueprintProgress: on(n),
|
|
344
|
+
charts: sn(n),
|
|
295
345
|
streaming: t.streaming
|
|
296
346
|
};
|
|
297
347
|
}
|
|
298
|
-
function
|
|
348
|
+
function ln(e, t = {}) {
|
|
299
349
|
if (!Array.isArray(e) || e.length === 0) return [];
|
|
300
350
|
let n = e.length - 1;
|
|
301
|
-
return e.map((e, r) =>
|
|
351
|
+
return e.map((e, r) => cn(e, { streaming: !!t.isStreaming && r === n && e.role === "assistant" }));
|
|
302
352
|
}
|
|
303
353
|
//#endregion
|
|
304
354
|
//#region src/chatMessageAdapter.ts
|
|
305
|
-
function
|
|
355
|
+
function un(e) {
|
|
306
356
|
return typeof e == "string" ? e : e instanceof Date ? e.toISOString() : void 0;
|
|
307
357
|
}
|
|
308
|
-
function
|
|
358
|
+
function dn(e) {
|
|
309
359
|
return e === "tool" ? "assistant" : e;
|
|
310
360
|
}
|
|
311
|
-
function
|
|
361
|
+
function fn(e) {
|
|
312
362
|
switch (e) {
|
|
313
363
|
case "partial-call": return "input-streaming";
|
|
314
364
|
case "call": return "input-available";
|
|
@@ -316,34 +366,34 @@ function ln(e) {
|
|
|
316
366
|
default: return e;
|
|
317
367
|
}
|
|
318
368
|
}
|
|
319
|
-
function
|
|
369
|
+
function pn(e) {
|
|
320
370
|
let { state: t, ...n } = e;
|
|
321
371
|
return {
|
|
322
372
|
...n,
|
|
323
|
-
state:
|
|
373
|
+
state: fn(t)
|
|
324
374
|
};
|
|
325
375
|
}
|
|
326
|
-
function
|
|
376
|
+
function mn(e) {
|
|
327
377
|
let { role: t, timestamp: n, toolInvocations: r, ...i } = e;
|
|
328
378
|
return {
|
|
329
379
|
...i,
|
|
330
|
-
role:
|
|
331
|
-
timestamp:
|
|
332
|
-
toolInvocations: r?.map(
|
|
380
|
+
role: dn(t),
|
|
381
|
+
timestamp: un(n),
|
|
382
|
+
toolInvocations: r?.map(pn)
|
|
333
383
|
};
|
|
334
384
|
}
|
|
335
|
-
function
|
|
336
|
-
return (e ?? []).map(
|
|
385
|
+
function hn(e) {
|
|
386
|
+
return (e ?? []).map(mn);
|
|
337
387
|
}
|
|
338
388
|
//#endregion
|
|
339
389
|
//#region src/useObjectChat.ts
|
|
340
|
-
var
|
|
341
|
-
function
|
|
390
|
+
var gn = "objectui:ai-usage-refresh";
|
|
391
|
+
function _n() {
|
|
342
392
|
if (!(typeof window > "u" || typeof window.dispatchEvent != "function")) try {
|
|
343
|
-
window.dispatchEvent(new CustomEvent(
|
|
393
|
+
window.dispatchEvent(new CustomEvent(gn));
|
|
344
394
|
} catch {}
|
|
345
395
|
}
|
|
346
|
-
async function
|
|
396
|
+
async function vn(e, t) {
|
|
347
397
|
let n;
|
|
348
398
|
try {
|
|
349
399
|
n = await fetch(e, t);
|
|
@@ -361,7 +411,7 @@ async function hn(e, t) {
|
|
|
361
411
|
}
|
|
362
412
|
return n;
|
|
363
413
|
}
|
|
364
|
-
function
|
|
414
|
+
function yn(e) {
|
|
365
415
|
let t = [...e.messages].reverse().find((e) => e.role === "user");
|
|
366
416
|
return { body: {
|
|
367
417
|
...e.body ?? {},
|
|
@@ -372,7 +422,7 @@ function gn(e) {
|
|
|
372
422
|
...t ? { turnId: t.id } : {}
|
|
373
423
|
} };
|
|
374
424
|
}
|
|
375
|
-
function
|
|
425
|
+
function bn(e, t) {
|
|
376
426
|
let n = e.context ?? {};
|
|
377
427
|
return {
|
|
378
428
|
...e,
|
|
@@ -382,25 +432,33 @@ function _n(e, t) {
|
|
|
382
432
|
}
|
|
383
433
|
};
|
|
384
434
|
}
|
|
385
|
-
|
|
435
|
+
var xn = /* @__PURE__ */ new Set();
|
|
436
|
+
function Sn() {
|
|
437
|
+
xn.has("maxToolRoundtrips") || (xn.add("maxToolRoundtrips"), console.warn("[@object-ui/plugin-chatbot] `maxToolRoundtrips` is deprecated and has no effect: the installed chat runtime exposes no client-side round-trip cap (`useChat` dropped the numeric knob, and the surviving `stopWhen` / `stepCountIs` step cap is server-side only). Cap tool-calling loops on the agent instead — `planning.maxIterations`. This key is inert and is slated for removal in a future major (objectui#5605)."));
|
|
438
|
+
}
|
|
439
|
+
function Cn(e) {
|
|
386
440
|
return (e ?? []).map((e, t) => ({
|
|
387
441
|
id: e.id || `msg-${t}`,
|
|
388
442
|
role: e.role || "user",
|
|
389
443
|
content: e.content || "",
|
|
390
|
-
timestamp:
|
|
444
|
+
timestamp: un(e.timestamp),
|
|
391
445
|
metadata: e.metadata,
|
|
392
446
|
streaming: e.streaming,
|
|
393
447
|
toolInvocations: e.toolInvocations
|
|
394
448
|
}));
|
|
395
449
|
}
|
|
396
|
-
function
|
|
397
|
-
let { api: t, initialMessages: n, conversationId: r, parentConversationId: i, systemPrompt: a, model: s, streamingEnabled: f = !0, headers: p, body: m, maxToolRoundtrips: h
|
|
450
|
+
function wn(e = {}) {
|
|
451
|
+
let { api: t, initialMessages: n, conversationId: r, parentConversationId: i, systemPrompt: a, model: s, streamingEnabled: f = !0, headers: p, body: m, maxToolRoundtrips: h, onError: g, showTimestamp: _, autoResponse: v, autoResponseText: y, autoResponseDelay: b = 1e3, onSend: x } = e;
|
|
452
|
+
c(() => {
|
|
453
|
+
h !== void 0 && Sn();
|
|
454
|
+
}, [h]);
|
|
455
|
+
let S = u(t ? "api" : "local").current === "api", C = l(() => (n ?? []).map((e, t) => {
|
|
398
456
|
if (Array.isArray(e.parts) && e.parts.length > 0) return {
|
|
399
457
|
id: e.id || `msg-${t}`,
|
|
400
458
|
role: e.role || "user",
|
|
401
459
|
parts: e.parts
|
|
402
460
|
};
|
|
403
|
-
let n =
|
|
461
|
+
let n = Cn([e])[0], r = [];
|
|
404
462
|
n.content && r.push({
|
|
405
463
|
type: "text",
|
|
406
464
|
text: n.content
|
|
@@ -432,100 +490,108 @@ function yn(e = {}) {
|
|
|
432
490
|
let e = E.current;
|
|
433
491
|
E.current = i, i && !e && (T.current = i);
|
|
434
492
|
}, [i]);
|
|
435
|
-
let D =
|
|
493
|
+
let D = u(m);
|
|
494
|
+
D.current = m;
|
|
495
|
+
let O = u(p);
|
|
496
|
+
O.current = p;
|
|
497
|
+
let k = l(() => {
|
|
436
498
|
if (S) return new Ct({
|
|
437
499
|
api: t,
|
|
438
|
-
fetch:
|
|
439
|
-
headers: { ...p },
|
|
500
|
+
fetch: vn,
|
|
440
501
|
body: {
|
|
441
|
-
...m,
|
|
442
502
|
...r ? { conversationId: r } : {},
|
|
443
503
|
...s ? { model: s } : {},
|
|
444
504
|
...a ? { systemPrompt: a } : {},
|
|
445
505
|
...f === void 0 ? {} : { stream: f }
|
|
446
506
|
},
|
|
447
|
-
prepareSendMessagesRequest: ({ id: e, body: t, messages: n, trigger: r, messageId: i }) => {
|
|
448
|
-
let
|
|
507
|
+
prepareSendMessagesRequest: ({ id: e, body: t, messages: n, trigger: r, messageId: i, headers: a }) => {
|
|
508
|
+
let o = yn({
|
|
449
509
|
id: e,
|
|
450
|
-
body:
|
|
510
|
+
body: {
|
|
511
|
+
...D.current,
|
|
512
|
+
...t
|
|
513
|
+
},
|
|
451
514
|
messages: n,
|
|
452
515
|
trigger: r,
|
|
453
516
|
messageId: i
|
|
454
517
|
});
|
|
455
|
-
|
|
518
|
+
w.current && (o.body.model = w.current), T.current &&= (o.body = bn(o.body, T.current), void 0);
|
|
519
|
+
let s = new Headers(O.current ?? {});
|
|
520
|
+
return new Headers(a ?? {}).forEach((e, t) => s.set(t, e)), {
|
|
521
|
+
...o,
|
|
522
|
+
headers: s
|
|
523
|
+
};
|
|
456
524
|
}
|
|
457
525
|
});
|
|
458
526
|
}, [
|
|
459
527
|
S,
|
|
460
528
|
t,
|
|
461
|
-
p,
|
|
462
|
-
m,
|
|
463
529
|
s,
|
|
464
530
|
a,
|
|
465
531
|
f,
|
|
466
532
|
r
|
|
467
|
-
]),
|
|
468
|
-
transport:
|
|
533
|
+
]), A = u(null), j = St({
|
|
534
|
+
transport: k,
|
|
469
535
|
messages: S && C.length > 0 ? C : void 0,
|
|
470
536
|
onError: S ? (e) => {
|
|
471
537
|
if (e.notSent) {
|
|
472
|
-
let e =
|
|
473
|
-
e?.setMessages && t && t.length > 0 && t[t.length - 1]?.role === "user" && e.setMessages(t.slice(0, -1)),
|
|
538
|
+
let e = A.current, t = e?.messages;
|
|
539
|
+
e?.setMessages && t && t.length > 0 && t[t.length - 1]?.role === "user" && e.setMessages(t.slice(0, -1)), _n();
|
|
474
540
|
}
|
|
475
541
|
g?.(e);
|
|
476
542
|
} : void 0
|
|
477
543
|
});
|
|
478
|
-
|
|
479
|
-
let
|
|
544
|
+
A.current = j;
|
|
545
|
+
let M = u(void 0), N = j?.status;
|
|
480
546
|
c(() => {
|
|
481
|
-
let e =
|
|
482
|
-
|
|
483
|
-
}, [
|
|
484
|
-
let [
|
|
547
|
+
let e = M.current;
|
|
548
|
+
M.current = N, (e === "streaming" || e === "submitted") && N === "ready" && _n();
|
|
549
|
+
}, [N]);
|
|
550
|
+
let [ee, P] = d(() => Cn(n)), [F, I] = d(!1), [te, ne] = d(""), [L, re] = d(""), ie = u(null);
|
|
485
551
|
c(() => () => {
|
|
486
|
-
|
|
552
|
+
ie.current &&= (clearTimeout(ie.current), null);
|
|
487
553
|
}, []);
|
|
488
|
-
let { messages:
|
|
554
|
+
let { messages: R, status: ae, error: oe, sendMessage: z, regenerate: B, stop: se, setMessages: V } = j, ce = ae === "submitted" || ae === "streaming", le = ln(R, { isStreaming: ce }).map((e, t) => ({
|
|
489
555
|
...e,
|
|
490
|
-
metadata:
|
|
491
|
-
})),
|
|
556
|
+
metadata: R[t]?.metadata
|
|
557
|
+
})), ue = o((e) => {
|
|
492
558
|
let t = e.trim();
|
|
493
559
|
if (!t) return;
|
|
494
|
-
let n = [...
|
|
495
|
-
id:
|
|
560
|
+
let n = [...le, {
|
|
561
|
+
id: Ht("msg"),
|
|
496
562
|
role: "user",
|
|
497
563
|
content: t
|
|
498
564
|
}];
|
|
499
|
-
|
|
565
|
+
z({ text: t }), re(""), x?.(t, n);
|
|
500
566
|
}, [
|
|
501
|
-
|
|
567
|
+
z,
|
|
502
568
|
x,
|
|
503
|
-
|
|
504
|
-
]),
|
|
505
|
-
|
|
506
|
-
}, [
|
|
507
|
-
|
|
508
|
-
}, []),
|
|
509
|
-
|
|
510
|
-
}, []),
|
|
569
|
+
le
|
|
570
|
+
]), de = o(() => {
|
|
571
|
+
V([]);
|
|
572
|
+
}, [V]), fe = o((e) => {
|
|
573
|
+
re(e.target.value);
|
|
574
|
+
}, []), pe = o(() => {
|
|
575
|
+
ie.current &&= (clearTimeout(ie.current), null), I(!1);
|
|
576
|
+
}, []), me = o((e) => {
|
|
511
577
|
if (!e.trim()) return;
|
|
512
578
|
let t = {
|
|
513
|
-
id:
|
|
579
|
+
id: Ht("msg"),
|
|
514
580
|
role: "user",
|
|
515
581
|
content: e.trim(),
|
|
516
582
|
timestamp: _ ? (/* @__PURE__ */ new Date()).toLocaleTimeString() : void 0
|
|
517
583
|
};
|
|
518
|
-
|
|
584
|
+
P((n) => {
|
|
519
585
|
let r = [...n, t];
|
|
520
586
|
return x?.(e.trim(), r), r;
|
|
521
|
-
}),
|
|
587
|
+
}), ne(""), v && (I(!0), ie.current = setTimeout(() => {
|
|
522
588
|
let e = {
|
|
523
|
-
id:
|
|
589
|
+
id: Ht("msg"),
|
|
524
590
|
role: "assistant",
|
|
525
591
|
content: y || "Thank you for your message!",
|
|
526
592
|
timestamp: _ ? (/* @__PURE__ */ new Date()).toLocaleTimeString() : void 0
|
|
527
593
|
};
|
|
528
|
-
|
|
594
|
+
P((t) => [...t, e]), I(!1);
|
|
529
595
|
}, b));
|
|
530
596
|
}, [
|
|
531
597
|
_,
|
|
@@ -533,65 +599,65 @@ function yn(e = {}) {
|
|
|
533
599
|
y,
|
|
534
600
|
b,
|
|
535
601
|
x
|
|
536
|
-
]),
|
|
537
|
-
|
|
538
|
-
}, [
|
|
539
|
-
|
|
602
|
+
]), he = o(() => {}, []), ge = o(() => {
|
|
603
|
+
pe(), P([]);
|
|
604
|
+
}, [pe]), _e = o((e) => {
|
|
605
|
+
ne(e.target.value);
|
|
540
606
|
}, []);
|
|
541
607
|
return S ? {
|
|
542
|
-
messages:
|
|
543
|
-
isLoading:
|
|
544
|
-
error:
|
|
545
|
-
sendMessage:
|
|
546
|
-
stop:
|
|
547
|
-
reload:
|
|
548
|
-
clear:
|
|
549
|
-
setMessages:
|
|
608
|
+
messages: le,
|
|
609
|
+
isLoading: ce,
|
|
610
|
+
error: oe,
|
|
611
|
+
sendMessage: ue,
|
|
612
|
+
stop: se,
|
|
613
|
+
reload: B,
|
|
614
|
+
clear: de,
|
|
615
|
+
setMessages: V,
|
|
550
616
|
isApiMode: !0,
|
|
551
|
-
input:
|
|
552
|
-
setInput:
|
|
553
|
-
handleInputChange:
|
|
617
|
+
input: L,
|
|
618
|
+
setInput: re,
|
|
619
|
+
handleInputChange: fe
|
|
554
620
|
} : {
|
|
555
|
-
messages:
|
|
556
|
-
isLoading:
|
|
621
|
+
messages: ee,
|
|
622
|
+
isLoading: F,
|
|
557
623
|
error: void 0,
|
|
558
|
-
sendMessage:
|
|
559
|
-
stop:
|
|
560
|
-
reload:
|
|
561
|
-
clear:
|
|
624
|
+
sendMessage: me,
|
|
625
|
+
stop: pe,
|
|
626
|
+
reload: he,
|
|
627
|
+
clear: ge,
|
|
562
628
|
isApiMode: !1,
|
|
563
|
-
input:
|
|
564
|
-
setInput:
|
|
565
|
-
handleInputChange:
|
|
629
|
+
input: te,
|
|
630
|
+
setInput: ne,
|
|
631
|
+
handleInputChange: _e
|
|
566
632
|
};
|
|
567
633
|
}
|
|
568
634
|
//#endregion
|
|
569
635
|
//#region src/agentAliases.ts
|
|
570
|
-
var
|
|
571
|
-
function
|
|
572
|
-
return
|
|
636
|
+
var Tn = [["build", "metadata_assistant"], ["ask", "data_chat"]];
|
|
637
|
+
function En(e) {
|
|
638
|
+
return Tn.find((t) => t.includes(e)) ?? [e];
|
|
573
639
|
}
|
|
574
|
-
function
|
|
575
|
-
return
|
|
640
|
+
function Dn(e) {
|
|
641
|
+
return En(e)[0];
|
|
576
642
|
}
|
|
577
|
-
function
|
|
643
|
+
function On(e, t) {
|
|
578
644
|
if (e) {
|
|
579
645
|
if (t.includes(e)) return e;
|
|
580
|
-
for (let n of
|
|
646
|
+
for (let n of En(e)) if (t.includes(n)) return n;
|
|
581
647
|
}
|
|
582
648
|
}
|
|
583
|
-
function
|
|
584
|
-
return e != null &&
|
|
649
|
+
function kn(e) {
|
|
650
|
+
return e != null && Tn.some((t) => t.includes(e));
|
|
585
651
|
}
|
|
586
|
-
function
|
|
587
|
-
return e != null &&
|
|
652
|
+
function An(e) {
|
|
653
|
+
return e != null && Dn(e) === "build";
|
|
588
654
|
}
|
|
589
|
-
function
|
|
590
|
-
return e != null &&
|
|
655
|
+
function jn(e) {
|
|
656
|
+
return e != null && Dn(e) === "ask";
|
|
591
657
|
}
|
|
592
658
|
//#endregion
|
|
593
659
|
//#region src/useAgents.ts
|
|
594
|
-
function
|
|
660
|
+
function Mn(e) {
|
|
595
661
|
if (!(!e || typeof e != "object")) return {
|
|
596
662
|
authoring: e.authoring === !0,
|
|
597
663
|
canvas: e.canvas === !0,
|
|
@@ -599,45 +665,45 @@ function Dn(e) {
|
|
|
599
665
|
resume: e.resume === !0
|
|
600
666
|
};
|
|
601
667
|
}
|
|
602
|
-
function
|
|
668
|
+
function Nn(e, t, n) {
|
|
603
669
|
if (!t) return !1;
|
|
604
670
|
let r = e.find((e) => e.name === t);
|
|
605
|
-
return r?.capabilities ? r.capabilities[n] :
|
|
671
|
+
return r?.capabilities ? r.capabilities[n] : An(t);
|
|
606
672
|
}
|
|
607
|
-
var
|
|
608
|
-
function
|
|
673
|
+
var Pn = "ask";
|
|
674
|
+
function Fn(e, t) {
|
|
609
675
|
if (e.length === 0) return;
|
|
610
676
|
let n = e.map((e) => e.name);
|
|
611
677
|
if (t) {
|
|
612
|
-
let e =
|
|
678
|
+
let e = On(t, n);
|
|
613
679
|
if (e) return e;
|
|
614
680
|
}
|
|
615
|
-
return
|
|
681
|
+
return On("ask", n) || e[0].name;
|
|
616
682
|
}
|
|
617
|
-
function
|
|
683
|
+
function In(e) {
|
|
618
684
|
let t = e && typeof e == "object" && !Array.isArray(e) && typeof e.success == "boolean" ? e.data : e;
|
|
619
685
|
if (Array.isArray(t)) return t;
|
|
620
686
|
let n = t?.agents;
|
|
621
687
|
return Array.isArray(n) ? n : [];
|
|
622
688
|
}
|
|
623
|
-
function
|
|
689
|
+
function Ln(e) {
|
|
624
690
|
return e.filter((e) => typeof e?.name == "string" && e.name.length > 0).map((e) => ({
|
|
625
691
|
name: e.name,
|
|
626
692
|
label: e.label || e.name,
|
|
627
693
|
description: e.description,
|
|
628
694
|
role: e.role,
|
|
629
695
|
active: e.active !== !1,
|
|
630
|
-
capabilities:
|
|
696
|
+
capabilities: Mn(e.capabilities)
|
|
631
697
|
}));
|
|
632
698
|
}
|
|
633
|
-
var
|
|
634
|
-
function
|
|
635
|
-
if (n)
|
|
699
|
+
var Rn = 3e4, zn = /* @__PURE__ */ new Map(), Bn = /* @__PURE__ */ new Map();
|
|
700
|
+
function Vn(e, t, n) {
|
|
701
|
+
if (n) zn.delete(e);
|
|
636
702
|
else {
|
|
637
|
-
let t =
|
|
638
|
-
if (t && Date.now() - t.timestamp <
|
|
703
|
+
let t = zn.get(e);
|
|
704
|
+
if (t && Date.now() - t.timestamp < Rn) return Promise.resolve(t.data);
|
|
639
705
|
}
|
|
640
|
-
let r =
|
|
706
|
+
let r = Bn.get(e);
|
|
641
707
|
if (r && !n) return r;
|
|
642
708
|
let i = `${e.replace(/\/$/, "")}/agents`, a = fetch(i, {
|
|
643
709
|
method: "GET",
|
|
@@ -648,21 +714,21 @@ function In(e, t, n) {
|
|
|
648
714
|
credentials: "include"
|
|
649
715
|
}).then(async (e) => {
|
|
650
716
|
if (!e.ok) throw Error(`Failed to load agents (${e.status})`);
|
|
651
|
-
return
|
|
652
|
-
}).then((t) => (
|
|
717
|
+
return Ln(In(await e.json()));
|
|
718
|
+
}).then((t) => (zn.set(e, {
|
|
653
719
|
data: t,
|
|
654
720
|
timestamp: Date.now()
|
|
655
721
|
}), t)).finally(() => {
|
|
656
|
-
|
|
722
|
+
Bn.delete(e);
|
|
657
723
|
});
|
|
658
|
-
return
|
|
724
|
+
return Bn.set(e, a), a;
|
|
659
725
|
}
|
|
660
|
-
function
|
|
726
|
+
function Hn(e = {}) {
|
|
661
727
|
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);
|
|
662
728
|
return _.current = n, c(() => {
|
|
663
729
|
if (!r || !t) return;
|
|
664
730
|
let e = !1;
|
|
665
|
-
return f(!0), m(void 0),
|
|
731
|
+
return f(!0), m(void 0), Vn(t, _.current, h > 0).then((t) => {
|
|
666
732
|
e || s(t.length > 0 ? t : i);
|
|
667
733
|
}).catch((t) => {
|
|
668
734
|
e || (m(t), s(i));
|
|
@@ -684,13 +750,13 @@ function Ln(e = {}) {
|
|
|
684
750
|
}
|
|
685
751
|
//#endregion
|
|
686
752
|
//#region src/useAiModels.ts
|
|
687
|
-
function
|
|
753
|
+
function Un(e) {
|
|
688
754
|
return e.filter((e) => typeof e?.id == "string" && e.id.length > 0).map((e) => ({
|
|
689
755
|
id: e.id,
|
|
690
756
|
label: e.label || e.id
|
|
691
757
|
}));
|
|
692
758
|
}
|
|
693
|
-
function
|
|
759
|
+
function Wn(e = {}) {
|
|
694
760
|
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);
|
|
695
761
|
return v.current = n, c(() => {
|
|
696
762
|
if (!r || !t) return;
|
|
@@ -710,7 +776,7 @@ function zn(e = {}) {
|
|
|
710
776
|
if (!t.ok) throw Error(`Failed to load AI models (${t.status})`);
|
|
711
777
|
let r = await t.json();
|
|
712
778
|
if (n) return;
|
|
713
|
-
let c = Array.isArray(r) ? r : r?.models ?? [], u = Array.isArray(r) ? void 0 : r?.defaultModel, d =
|
|
779
|
+
let c = Array.isArray(r) ? r : r?.models ?? [], u = Array.isArray(r) ? void 0 : r?.defaultModel, d = Un(c);
|
|
714
780
|
a(d), l(u ?? c.find((e) => e?.default)?.id ?? c[0]?.id), p(!1), d.length === 0 && o < 5 && !n && (o += 1, setTimeout(() => {
|
|
715
781
|
s();
|
|
716
782
|
}, 1200));
|
|
@@ -739,8 +805,8 @@ function zn(e = {}) {
|
|
|
739
805
|
}
|
|
740
806
|
//#endregion
|
|
741
807
|
//#region src/FloatingChatbotProvider.tsx
|
|
742
|
-
var
|
|
743
|
-
function
|
|
808
|
+
var Gn = e.createContext(null);
|
|
809
|
+
function Kn({ defaultOpen: t = !1, children: n }) {
|
|
744
810
|
let [r, i] = e.useState(t), [a, o] = e.useState(!1), s = e.useMemo(() => ({
|
|
745
811
|
isOpen: r,
|
|
746
812
|
isFullscreen: a,
|
|
@@ -751,26 +817,26 @@ function Vn({ defaultOpen: t = !1, children: n }) {
|
|
|
751
817
|
toggle: () => i((e) => !e),
|
|
752
818
|
toggleFullscreen: () => o((e) => !e)
|
|
753
819
|
}), [r, a]);
|
|
754
|
-
return /* @__PURE__ */ Z(
|
|
820
|
+
return /* @__PURE__ */ Z(Gn.Provider, {
|
|
755
821
|
value: s,
|
|
756
822
|
children: n
|
|
757
823
|
});
|
|
758
824
|
}
|
|
759
|
-
function
|
|
760
|
-
let t = e.useContext(
|
|
825
|
+
function qn() {
|
|
826
|
+
let t = e.useContext(Gn);
|
|
761
827
|
if (!t) throw Error("useFloatingChatbot must be used within a <FloatingChatbotProvider>");
|
|
762
828
|
return t;
|
|
763
829
|
}
|
|
764
830
|
//#endregion
|
|
765
831
|
//#region src/FloatingChatbotTrigger.tsx
|
|
766
|
-
function
|
|
767
|
-
let { t: e } =
|
|
832
|
+
function Jn() {
|
|
833
|
+
let { t: e } = Et();
|
|
768
834
|
return (t, n) => {
|
|
769
835
|
let r = e(`common.${t}`);
|
|
770
836
|
return !r || r === `common.${t}` ? n : r;
|
|
771
837
|
};
|
|
772
838
|
}
|
|
773
|
-
var
|
|
839
|
+
var Yn = {
|
|
774
840
|
32: "size-8",
|
|
775
841
|
36: "size-9",
|
|
776
842
|
40: "size-10",
|
|
@@ -783,26 +849,26 @@ var Wn = {
|
|
|
783
849
|
72: "size-[72px]",
|
|
784
850
|
80: "size-20"
|
|
785
851
|
};
|
|
786
|
-
function
|
|
852
|
+
function Xn(e, t) {
|
|
787
853
|
return t.reduce((t, n) => Math.abs(n - e) < Math.abs(t - e) ? n : t);
|
|
788
854
|
}
|
|
789
|
-
function
|
|
790
|
-
return
|
|
855
|
+
function Zn(e) {
|
|
856
|
+
return Yn[e] ?? Yn[Xn(e, Object.keys(Yn).map(Number))];
|
|
791
857
|
}
|
|
792
|
-
function
|
|
793
|
-
let { isOpen: r, toggle: i } =
|
|
858
|
+
function Qn({ position: e = "bottom-right", size: t = 56, className: n }) {
|
|
859
|
+
let { isOpen: r, toggle: i } = qn(), a = Jn();
|
|
794
860
|
return /* @__PURE__ */ Z(v, {
|
|
795
861
|
onClick: i,
|
|
796
|
-
className:
|
|
862
|
+
className: W("fixed z-50 rounded-full shadow-lg transition-transform hover:scale-105", Zn(t), r && "hidden", e === "bottom-right" ? "right-6 bottom-20 sm:bottom-6" : "left-6 bottom-20 sm:bottom-6", n),
|
|
797
863
|
size: "icon",
|
|
798
864
|
"aria-label": r ? a("closeChat", "Close chat") : a("openChat", "Open chat"),
|
|
799
865
|
"data-testid": "floating-chatbot-trigger",
|
|
800
|
-
children: Z(r ?
|
|
866
|
+
children: Z(r ? bt : Ie, { className: "h-6 w-6" })
|
|
801
867
|
});
|
|
802
868
|
}
|
|
803
869
|
//#endregion
|
|
804
870
|
//#region src/FloatingChatbotPanel.tsx
|
|
805
|
-
var
|
|
871
|
+
var $n = {
|
|
806
872
|
300: "sm:w-[300px]",
|
|
807
873
|
320: "sm:w-[320px]",
|
|
808
874
|
340: "sm:w-[340px]",
|
|
@@ -821,7 +887,7 @@ var Jn = {
|
|
|
821
887
|
640: "sm:w-[640px]",
|
|
822
888
|
720: "sm:w-[720px]",
|
|
823
889
|
800: "sm:w-[800px]"
|
|
824
|
-
},
|
|
890
|
+
}, er = {
|
|
825
891
|
360: "h-[min(360px,calc(100svh_-_6rem_-_env(safe-area-inset-bottom)))] sm:h-[360px]",
|
|
826
892
|
400: "h-[min(400px,calc(100svh_-_6rem_-_env(safe-area-inset-bottom)))] sm:h-[400px]",
|
|
827
893
|
420: "h-[min(420px,calc(100svh_-_6rem_-_env(safe-area-inset-bottom)))] sm:h-[420px]",
|
|
@@ -835,19 +901,19 @@ var Jn = {
|
|
|
835
901
|
720: "h-[min(720px,calc(100svh_-_6rem_-_env(safe-area-inset-bottom)))] sm:h-[720px]",
|
|
836
902
|
800: "h-[min(800px,calc(100svh_-_6rem_-_env(safe-area-inset-bottom)))] sm:h-[800px]"
|
|
837
903
|
};
|
|
838
|
-
function
|
|
904
|
+
function tr(e, t) {
|
|
839
905
|
return t.reduce((t, n) => Math.abs(n - e) < Math.abs(t - e) ? n : t);
|
|
840
906
|
}
|
|
841
|
-
function
|
|
842
|
-
return
|
|
907
|
+
function nr(e) {
|
|
908
|
+
return $n[e] ?? $n[tr(e, Object.keys($n).map(Number))];
|
|
843
909
|
}
|
|
844
|
-
function
|
|
845
|
-
return
|
|
910
|
+
function rr(e) {
|
|
911
|
+
return er[e] ?? er[tr(e, Object.keys(er).map(Number))];
|
|
846
912
|
}
|
|
847
|
-
function
|
|
848
|
-
let { isOpen: c, isFullscreen: l, close: u, toggleFullscreen: d } =
|
|
913
|
+
function ir({ title: e = "Chat", position: t = "bottom-right", width: n = 400, height: r = 520, children: i, className: a, headerExtra: o, headerActions: s }) {
|
|
914
|
+
let { isOpen: c, isFullscreen: l, close: u, toggleFullscreen: d } = qn();
|
|
849
915
|
return c ? /* @__PURE__ */ Q("div", {
|
|
850
|
-
className:
|
|
916
|
+
className: W("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" ? W("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)]", nr(n), rr(r)) : W("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)]", nr(n), rr(r)), a),
|
|
851
917
|
role: "dialog",
|
|
852
918
|
"aria-label": e,
|
|
853
919
|
"data-testid": "floating-chatbot-panel",
|
|
@@ -874,7 +940,7 @@ function $n({ title: e = "Chat", position: t = "bottom-right", width: n = 400, h
|
|
|
874
940
|
onClick: d,
|
|
875
941
|
"aria-label": l ? "Exit fullscreen" : "Fullscreen",
|
|
876
942
|
"data-testid": "floating-chatbot-fullscreen",
|
|
877
|
-
children: Z(l ?
|
|
943
|
+
children: Z(l ? q : ot, { className: "h-4 w-4" })
|
|
878
944
|
}),
|
|
879
945
|
/* @__PURE__ */ Z(v, {
|
|
880
946
|
variant: "ghost",
|
|
@@ -883,7 +949,7 @@ function $n({ title: e = "Chat", position: t = "bottom-right", width: n = 400, h
|
|
|
883
949
|
onClick: u,
|
|
884
950
|
"aria-label": "Close chat",
|
|
885
951
|
"data-testid": "floating-chatbot-close",
|
|
886
|
-
children: /* @__PURE__ */ Z(
|
|
952
|
+
children: /* @__PURE__ */ Z(bt, { className: "h-4 w-4" })
|
|
887
953
|
})
|
|
888
954
|
]
|
|
889
955
|
})
|
|
@@ -896,7 +962,7 @@ function $n({ title: e = "Chat", position: t = "bottom-right", width: n = 400, h
|
|
|
896
962
|
}
|
|
897
963
|
//#endregion
|
|
898
964
|
//#region src/tool-display.ts
|
|
899
|
-
var
|
|
965
|
+
var ar = {
|
|
900
966
|
ai: "AI",
|
|
901
967
|
api: "API",
|
|
902
968
|
crm: "CRM",
|
|
@@ -908,17 +974,17 @@ var er = {
|
|
|
908
974
|
url: "URL",
|
|
909
975
|
utc: "UTC"
|
|
910
976
|
};
|
|
911
|
-
function
|
|
977
|
+
function or(e) {
|
|
912
978
|
if (!e) return "";
|
|
913
979
|
let t = String(e).trim();
|
|
914
980
|
if (!t) return "";
|
|
915
981
|
let n = t.replace(/[_-]+/g, " ").replace(/([a-z])([A-Z])/g, "$1 $2").split(/\s+/).filter(Boolean);
|
|
916
982
|
return n.length === 0 ? t : n.map((e, t) => {
|
|
917
983
|
let n = e.toLowerCase();
|
|
918
|
-
return
|
|
984
|
+
return ar[n] ? ar[n] : t === 0 ? n.charAt(0).toUpperCase() + n.slice(1) : n;
|
|
919
985
|
}).join(" ");
|
|
920
986
|
}
|
|
921
|
-
function
|
|
987
|
+
function sr(e) {
|
|
922
988
|
if (e == null) return e;
|
|
923
989
|
let t = e;
|
|
924
990
|
for (let e = 0; e < 2; e++) {
|
|
@@ -936,7 +1002,7 @@ function nr(e) {
|
|
|
936
1002
|
}
|
|
937
1003
|
return t;
|
|
938
1004
|
}
|
|
939
|
-
function
|
|
1005
|
+
function cr(e) {
|
|
940
1006
|
let t = (e instanceof Error ? e.message : String(e ?? "")).replace(/\s+/g, " ").trim();
|
|
941
1007
|
if (!t) return { summary: "Something went wrong. Please try again." };
|
|
942
1008
|
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);
|
|
@@ -945,18 +1011,18 @@ function rr(e) {
|
|
|
945
1011
|
details: n.length > i.length ? n : void 0
|
|
946
1012
|
};
|
|
947
1013
|
}
|
|
948
|
-
var
|
|
1014
|
+
var lr = /* @__PURE__ */ new Set([
|
|
949
1015
|
"ai_design_quota_exhausted",
|
|
950
1016
|
"ai_data_chat_trial_exhausted",
|
|
951
1017
|
"ai_allowance_exhausted"
|
|
952
1018
|
]);
|
|
953
|
-
function
|
|
954
|
-
return typeof e == "string" &&
|
|
1019
|
+
function ur(e) {
|
|
1020
|
+
return typeof e == "string" && lr.has(e) ? e : void 0;
|
|
955
1021
|
}
|
|
956
|
-
function
|
|
1022
|
+
function dr(e) {
|
|
957
1023
|
return typeof e == "string" && e.trim() ? e : void 0;
|
|
958
1024
|
}
|
|
959
|
-
function
|
|
1025
|
+
function fr(e) {
|
|
960
1026
|
let t = e instanceof Error ? e.message : String(e ?? "");
|
|
961
1027
|
if (!t) return null;
|
|
962
1028
|
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("}");
|
|
@@ -968,40 +1034,40 @@ function sr(e) {
|
|
|
968
1034
|
return null;
|
|
969
1035
|
}
|
|
970
1036
|
if (!a || typeof a != "object") return null;
|
|
971
|
-
let o = a.error && typeof a.error == "object" ? a.error : void 0, s =
|
|
1037
|
+
let o = a.error && typeof a.error == "object" ? a.error : void 0, s = ur(a.error), c = ur(o?.code) ?? s ?? ur(a.code);
|
|
972
1038
|
return c ? {
|
|
973
1039
|
code: c,
|
|
974
|
-
message:
|
|
975
|
-
messageEn:
|
|
1040
|
+
message: dr(o?.message) ?? dr(a.message) ?? (s ? void 0 : dr(a.error)) ?? "",
|
|
1041
|
+
messageEn: dr(a.messageEn),
|
|
976
1042
|
upgrade: a.upgrade === !0,
|
|
977
1043
|
topUp: a.topUp === !0
|
|
978
1044
|
} : null;
|
|
979
1045
|
}
|
|
980
|
-
function
|
|
1046
|
+
function pr(e) {
|
|
981
1047
|
return !!(e && typeof e == "object" && e.notSent === !0);
|
|
982
1048
|
}
|
|
983
|
-
function
|
|
1049
|
+
function mr(e) {
|
|
984
1050
|
let t = e && typeof e == "object" ? e.status : void 0;
|
|
985
1051
|
return typeof t == "number" ? t : void 0;
|
|
986
1052
|
}
|
|
987
|
-
function
|
|
988
|
-
if (
|
|
1053
|
+
function hr(e) {
|
|
1054
|
+
if (mr(e) === 429) return !0;
|
|
989
1055
|
let t = e instanceof Error ? e.message : typeof e == "string" ? e : "";
|
|
990
1056
|
return /\b429\b|too many requests|rate[\s_-]?limit/i.test(t);
|
|
991
1057
|
}
|
|
992
1058
|
//#endregion
|
|
993
1059
|
//#region src/elements/conversation.tsx
|
|
994
|
-
var
|
|
995
|
-
className:
|
|
1060
|
+
var gr = ({ className: e, ...t }) => /* @__PURE__ */ Z(kt, {
|
|
1061
|
+
className: W("relative flex-1 overflow-y-hidden", e),
|
|
996
1062
|
initial: "smooth",
|
|
997
1063
|
resize: "smooth",
|
|
998
1064
|
role: "log",
|
|
999
1065
|
...t
|
|
1000
|
-
}),
|
|
1001
|
-
className:
|
|
1066
|
+
}), _r = ({ className: e, ...t }) => /* @__PURE__ */ Z(kt.Content, {
|
|
1067
|
+
className: W("flex flex-col gap-8 p-4", e),
|
|
1002
1068
|
...t
|
|
1003
|
-
}),
|
|
1004
|
-
className:
|
|
1069
|
+
}), vr = ({ className: e, title: t = "No messages yet", description: n = "Start a conversation to see messages here", icon: r, children: i, ...a }) => /* @__PURE__ */ Z("div", {
|
|
1070
|
+
className: W("flex size-full flex-col items-center justify-center gap-3 p-8 text-center", e),
|
|
1005
1071
|
...a,
|
|
1006
1072
|
children: i ?? /* @__PURE__ */ Q(X, { children: [r && /* @__PURE__ */ Z("div", {
|
|
1007
1073
|
className: "text-muted-foreground",
|
|
@@ -1016,55 +1082,55 @@ var dr = ({ className: e, ...t }) => /* @__PURE__ */ Z(Ot, {
|
|
|
1016
1082
|
children: n
|
|
1017
1083
|
})]
|
|
1018
1084
|
})] })
|
|
1019
|
-
}),
|
|
1020
|
-
let { isAtBottom: n, scrollToBottom: r } =
|
|
1085
|
+
}), yr = ({ className: e, ...t }) => {
|
|
1086
|
+
let { isAtBottom: n, scrollToBottom: r } = At(), i = o(() => {
|
|
1021
1087
|
r();
|
|
1022
1088
|
}, [r]);
|
|
1023
1089
|
return !n && /* @__PURE__ */ Z(v, {
|
|
1024
|
-
className:
|
|
1090
|
+
className: W("absolute bottom-4 left-[50%] translate-x-[-50%] rounded-full", e),
|
|
1025
1091
|
onClick: i,
|
|
1026
1092
|
size: "icon",
|
|
1027
1093
|
type: "button",
|
|
1028
1094
|
variant: "outline",
|
|
1029
1095
|
...t,
|
|
1030
|
-
children: /* @__PURE__ */ Z(
|
|
1096
|
+
children: /* @__PURE__ */ Z(Ne, { className: "size-4" })
|
|
1031
1097
|
});
|
|
1032
|
-
},
|
|
1098
|
+
}, br = jt("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", {
|
|
1033
1099
|
variants: { orientation: {
|
|
1034
1100
|
horizontal: "[&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0 [&>*:not(:last-child)]:rounded-r-none",
|
|
1035
1101
|
vertical: "flex-col [&>*:not(:first-child)]:rounded-t-none [&>*:not(:first-child)]:border-t-0 [&>*:not(:last-child)]:rounded-b-none"
|
|
1036
1102
|
} },
|
|
1037
1103
|
defaultVariants: { orientation: "horizontal" }
|
|
1038
1104
|
});
|
|
1039
|
-
function
|
|
1105
|
+
function xr({ className: e, orientation: t, ...n }) {
|
|
1040
1106
|
return /* @__PURE__ */ Z("div", {
|
|
1041
1107
|
role: "group",
|
|
1042
1108
|
"data-slot": "button-group",
|
|
1043
1109
|
"data-orientation": t,
|
|
1044
|
-
className:
|
|
1110
|
+
className: W(br({ orientation: t }), e),
|
|
1045
1111
|
...n
|
|
1046
1112
|
});
|
|
1047
1113
|
}
|
|
1048
|
-
function
|
|
1049
|
-
return /* @__PURE__ */ Z(t ?
|
|
1050
|
-
className:
|
|
1114
|
+
function Sr({ className: e, asChild: t = !1, ...n }) {
|
|
1115
|
+
return /* @__PURE__ */ Z(t ? Mt : "div", {
|
|
1116
|
+
className: W("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),
|
|
1051
1117
|
...n
|
|
1052
1118
|
});
|
|
1053
1119
|
}
|
|
1054
1120
|
//#endregion
|
|
1055
1121
|
//#region src/elements/message.tsx
|
|
1056
|
-
var
|
|
1057
|
-
className:
|
|
1122
|
+
var Cr = ({ className: e, from: t, ...n }) => /* @__PURE__ */ Z("div", {
|
|
1123
|
+
className: W("group flex w-full max-w-[95%] flex-col gap-2", t === "user" ? "is-user ml-auto justify-end" : "is-assistant", e),
|
|
1058
1124
|
...n
|
|
1059
|
-
}),
|
|
1060
|
-
className:
|
|
1125
|
+
}), wr = ({ children: e, className: t, ...n }) => /* @__PURE__ */ Z("div", {
|
|
1126
|
+
className: W("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),
|
|
1061
1127
|
...n,
|
|
1062
1128
|
children: e
|
|
1063
|
-
}),
|
|
1064
|
-
className:
|
|
1129
|
+
}), Tr = ({ className: e, children: t, ...n }) => /* @__PURE__ */ Z("div", {
|
|
1130
|
+
className: W("flex items-center gap-1", e),
|
|
1065
1131
|
...n,
|
|
1066
1132
|
children: t
|
|
1067
|
-
}),
|
|
1133
|
+
}), Er = ({ tooltip: e, children: t, label: n, variant: r = "ghost", size: i = "icon", ...a }) => {
|
|
1068
1134
|
let o = /* @__PURE__ */ Q(v, {
|
|
1069
1135
|
size: i,
|
|
1070
1136
|
type: "button",
|
|
@@ -1075,15 +1141,15 @@ var vr = ({ className: e, from: t, ...n }) => /* @__PURE__ */ Z("div", {
|
|
|
1075
1141
|
children: n || e
|
|
1076
1142
|
})]
|
|
1077
1143
|
});
|
|
1078
|
-
return e ? /* @__PURE__ */ Z(
|
|
1144
|
+
return e ? /* @__PURE__ */ Z(Ae, { children: /* @__PURE__ */ Q(Oe, { children: [/* @__PURE__ */ Z(je, {
|
|
1079
1145
|
asChild: !0,
|
|
1080
1146
|
children: o
|
|
1081
|
-
}), /* @__PURE__ */ Z(
|
|
1082
|
-
},
|
|
1083
|
-
let e = s(
|
|
1147
|
+
}), /* @__PURE__ */ Z(ke, { children: /* @__PURE__ */ Z("p", { children: e }) })] }) }) : o;
|
|
1148
|
+
}, Dr = r(null), Or = () => {
|
|
1149
|
+
let e = s(Dr);
|
|
1084
1150
|
if (!e) throw Error("MessageBranch components must be used within MessageBranch");
|
|
1085
1151
|
return e;
|
|
1086
|
-
},
|
|
1152
|
+
}, kr = ({ defaultBranch: e = 0, onBranchChange: t, className: n, ...r }) => {
|
|
1087
1153
|
let [i, a] = d(e), [o, s] = d([]), c = (e) => {
|
|
1088
1154
|
a(e), t?.(e);
|
|
1089
1155
|
}, l = {
|
|
@@ -1100,15 +1166,15 @@ var vr = ({ className: e, from: t, ...n }) => /* @__PURE__ */ Z("div", {
|
|
|
1100
1166
|
branches: o,
|
|
1101
1167
|
setBranches: s
|
|
1102
1168
|
};
|
|
1103
|
-
return /* @__PURE__ */ Z(
|
|
1169
|
+
return /* @__PURE__ */ Z(Dr.Provider, {
|
|
1104
1170
|
value: l,
|
|
1105
1171
|
children: /* @__PURE__ */ Z("div", {
|
|
1106
|
-
className:
|
|
1172
|
+
className: W("grid w-full gap-2 [&>div]:pb-0", n),
|
|
1107
1173
|
...r
|
|
1108
1174
|
})
|
|
1109
1175
|
});
|
|
1110
|
-
},
|
|
1111
|
-
let { currentBranch: n, setBranches: r, branches: i } =
|
|
1176
|
+
}, Ar = ({ children: e, ...t }) => {
|
|
1177
|
+
let { currentBranch: n, setBranches: r, branches: i } = Or(), a = Array.isArray(e) ? e : [e];
|
|
1112
1178
|
return c(() => {
|
|
1113
1179
|
i.length !== a.length && r(a);
|
|
1114
1180
|
}, [
|
|
@@ -1116,19 +1182,19 @@ var vr = ({ className: e, from: t, ...n }) => /* @__PURE__ */ Z("div", {
|
|
|
1116
1182
|
i,
|
|
1117
1183
|
r
|
|
1118
1184
|
]), a.map((e, r) => /* @__PURE__ */ Z("div", {
|
|
1119
|
-
className:
|
|
1185
|
+
className: W("grid gap-2 overflow-hidden [&>div]:pb-0", r === n ? "block" : "hidden"),
|
|
1120
1186
|
...t,
|
|
1121
1187
|
children: e
|
|
1122
1188
|
}, e.key));
|
|
1123
|
-
},
|
|
1124
|
-
let { totalBranches: r } =
|
|
1125
|
-
return r <= 1 ? null : /* @__PURE__ */ Z(
|
|
1189
|
+
}, jr = ({ className: e, from: t, ...n }) => {
|
|
1190
|
+
let { totalBranches: r } = Or();
|
|
1191
|
+
return r <= 1 ? null : /* @__PURE__ */ Z(xr, {
|
|
1126
1192
|
className: "[&>*:not(:first-child)]:rounded-l-md [&>*:not(:last-child)]:rounded-r-md",
|
|
1127
1193
|
orientation: "horizontal",
|
|
1128
1194
|
...n
|
|
1129
1195
|
});
|
|
1130
|
-
},
|
|
1131
|
-
let { goToPrevious: n, totalBranches: r } =
|
|
1196
|
+
}, Mr = ({ children: e, ...t }) => {
|
|
1197
|
+
let { goToPrevious: n, totalBranches: r } = Or();
|
|
1132
1198
|
return /* @__PURE__ */ Z(v, {
|
|
1133
1199
|
"aria-label": "Previous branch",
|
|
1134
1200
|
disabled: r <= 1,
|
|
@@ -1137,10 +1203,10 @@ var vr = ({ className: e, from: t, ...n }) => /* @__PURE__ */ Z("div", {
|
|
|
1137
1203
|
type: "button",
|
|
1138
1204
|
variant: "ghost",
|
|
1139
1205
|
...t,
|
|
1140
|
-
children: e ?? /* @__PURE__ */ Z(
|
|
1206
|
+
children: e ?? /* @__PURE__ */ Z(He, { size: 14 })
|
|
1141
1207
|
});
|
|
1142
|
-
},
|
|
1143
|
-
let { goToNext: r, totalBranches: i } =
|
|
1208
|
+
}, Nr = ({ children: e, className: t, ...n }) => {
|
|
1209
|
+
let { goToNext: r, totalBranches: i } = Or();
|
|
1144
1210
|
return /* @__PURE__ */ Z(v, {
|
|
1145
1211
|
"aria-label": "Next branch",
|
|
1146
1212
|
disabled: i <= 1,
|
|
@@ -1149,12 +1215,12 @@ var vr = ({ className: e, from: t, ...n }) => /* @__PURE__ */ Z("div", {
|
|
|
1149
1215
|
type: "button",
|
|
1150
1216
|
variant: "ghost",
|
|
1151
1217
|
...n,
|
|
1152
|
-
children: e ?? /* @__PURE__ */ Z(
|
|
1218
|
+
children: e ?? /* @__PURE__ */ Z(Ue, { size: 14 })
|
|
1153
1219
|
});
|
|
1154
|
-
},
|
|
1155
|
-
let { currentBranch: n, totalBranches: r } =
|
|
1156
|
-
return /* @__PURE__ */ Q(
|
|
1157
|
-
className:
|
|
1220
|
+
}, Pr = ({ className: e, ...t }) => {
|
|
1221
|
+
let { currentBranch: n, totalBranches: r } = Or();
|
|
1222
|
+
return /* @__PURE__ */ Q(Sr, {
|
|
1223
|
+
className: W("border-none bg-transparent text-muted-foreground shadow-none", e),
|
|
1158
1224
|
...t,
|
|
1159
1225
|
children: [
|
|
1160
1226
|
n + 1,
|
|
@@ -1162,15 +1228,15 @@ var vr = ({ className: e, from: t, ...n }) => /* @__PURE__ */ Z("div", {
|
|
|
1162
1228
|
r
|
|
1163
1229
|
]
|
|
1164
1230
|
});
|
|
1165
|
-
},
|
|
1166
|
-
className:
|
|
1231
|
+
}, Fr = a(({ className: e, ...t }) => /* @__PURE__ */ Z(Nt, {
|
|
1232
|
+
className: W("size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0", e),
|
|
1167
1233
|
...t
|
|
1168
1234
|
}), (e, t) => e.children === t.children);
|
|
1169
|
-
|
|
1170
|
-
function
|
|
1235
|
+
Fr.displayName = "MessageResponse";
|
|
1236
|
+
function Ir({ data: e, className: t, onRemove: n, ...r }) {
|
|
1171
1237
|
let i = e.filename || "", a = (e.mediaType?.startsWith("image/") && e.url ? "image" : "file") == "image", o = i || (a ? "Image" : "Attachment");
|
|
1172
1238
|
return /* @__PURE__ */ Z("div", {
|
|
1173
|
-
className:
|
|
1239
|
+
className: W("group relative size-24 overflow-hidden rounded-lg", t),
|
|
1174
1240
|
...r,
|
|
1175
1241
|
children: a ? /* @__PURE__ */ Q(X, { children: [/* @__PURE__ */ Z("img", {
|
|
1176
1242
|
alt: i || "attachment",
|
|
@@ -1186,17 +1252,17 @@ function jr({ data: e, className: t, onRemove: n, ...r }) {
|
|
|
1186
1252
|
},
|
|
1187
1253
|
type: "button",
|
|
1188
1254
|
variant: "ghost",
|
|
1189
|
-
children: [/* @__PURE__ */ Z(
|
|
1255
|
+
children: [/* @__PURE__ */ Z(Y, {}), /* @__PURE__ */ Z("span", {
|
|
1190
1256
|
className: "sr-only",
|
|
1191
1257
|
children: "Remove"
|
|
1192
1258
|
})]
|
|
1193
|
-
})] }) : /* @__PURE__ */ Q(X, { children: [/* @__PURE__ */ Q(
|
|
1259
|
+
})] }) : /* @__PURE__ */ Q(X, { children: [/* @__PURE__ */ Q(Oe, { children: [/* @__PURE__ */ Z(je, {
|
|
1194
1260
|
asChild: !0,
|
|
1195
1261
|
children: /* @__PURE__ */ Z("div", {
|
|
1196
1262
|
className: "flex size-full shrink-0 items-center justify-center rounded-lg bg-muted text-muted-foreground",
|
|
1197
|
-
children: /* @__PURE__ */ Z(
|
|
1263
|
+
children: /* @__PURE__ */ Z(ct, { className: "size-4" })
|
|
1198
1264
|
})
|
|
1199
|
-
}), /* @__PURE__ */ Z(
|
|
1265
|
+
}), /* @__PURE__ */ Z(ke, { children: /* @__PURE__ */ Z("p", { children: o }) })] }), n && /* @__PURE__ */ Q(v, {
|
|
1200
1266
|
"aria-label": "Remove attachment",
|
|
1201
1267
|
className: "size-6 shrink-0 rounded-full p-0 opacity-0 transition-opacity hover:bg-accent group-hover:opacity-100 [&>svg]:size-3",
|
|
1202
1268
|
onClick: (e) => {
|
|
@@ -1204,36 +1270,36 @@ function jr({ data: e, className: t, onRemove: n, ...r }) {
|
|
|
1204
1270
|
},
|
|
1205
1271
|
type: "button",
|
|
1206
1272
|
variant: "ghost",
|
|
1207
|
-
children: [/* @__PURE__ */ Z(
|
|
1273
|
+
children: [/* @__PURE__ */ Z(Y, {}), /* @__PURE__ */ Z("span", {
|
|
1208
1274
|
className: "sr-only",
|
|
1209
1275
|
children: "Remove"
|
|
1210
1276
|
})]
|
|
1211
1277
|
})] })
|
|
1212
1278
|
});
|
|
1213
1279
|
}
|
|
1214
|
-
function
|
|
1280
|
+
function Lr({ children: e, className: t, ...n }) {
|
|
1215
1281
|
return e ? /* @__PURE__ */ Z("div", {
|
|
1216
|
-
className:
|
|
1282
|
+
className: W("ml-auto flex w-fit flex-wrap items-start gap-2", t),
|
|
1217
1283
|
...n,
|
|
1218
1284
|
children: e
|
|
1219
1285
|
}) : null;
|
|
1220
1286
|
}
|
|
1221
|
-
var
|
|
1222
|
-
className:
|
|
1287
|
+
var Rr = ({ className: e, children: t, ...n }) => /* @__PURE__ */ Z("div", {
|
|
1288
|
+
className: W("mt-4 flex w-full items-center justify-between gap-4", e),
|
|
1223
1289
|
...n,
|
|
1224
1290
|
children: t
|
|
1225
1291
|
});
|
|
1226
1292
|
//#endregion
|
|
1227
1293
|
//#region src/elements/ui/input-group.tsx
|
|
1228
|
-
function
|
|
1294
|
+
function zr({ className: e, ...t }) {
|
|
1229
1295
|
return /* @__PURE__ */ Z("div", {
|
|
1230
1296
|
"data-slot": "input-group",
|
|
1231
1297
|
role: "group",
|
|
1232
|
-
className:
|
|
1298
|
+
className: W("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),
|
|
1233
1299
|
...t
|
|
1234
1300
|
});
|
|
1235
1301
|
}
|
|
1236
|
-
var
|
|
1302
|
+
var Br = jt("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", {
|
|
1237
1303
|
variants: { align: {
|
|
1238
1304
|
"inline-start": "order-first pl-3 has-[>button]:ml-[-0.45rem] has-[>kbd]:ml-[-0.35rem]",
|
|
1239
1305
|
"inline-end": "order-last pr-3 has-[>button]:mr-[-0.45rem] has-[>kbd]:mr-[-0.35rem]",
|
|
@@ -1242,19 +1308,19 @@ var Fr = At("flex h-auto cursor-text items-center justify-center gap-2 py-1.5 te
|
|
|
1242
1308
|
} },
|
|
1243
1309
|
defaultVariants: { align: "inline-start" }
|
|
1244
1310
|
});
|
|
1245
|
-
function
|
|
1311
|
+
function Vr({ className: e, align: t = "inline-start", ...n }) {
|
|
1246
1312
|
return /* @__PURE__ */ Z("div", {
|
|
1247
1313
|
role: "group",
|
|
1248
1314
|
"data-slot": "input-group-addon",
|
|
1249
1315
|
"data-align": t,
|
|
1250
|
-
className:
|
|
1316
|
+
className: W(Br({ align: t }), e),
|
|
1251
1317
|
onClick: (e) => {
|
|
1252
1318
|
e.target.closest("button") || e.currentTarget.parentElement?.querySelector("input")?.focus();
|
|
1253
1319
|
},
|
|
1254
1320
|
...n
|
|
1255
1321
|
});
|
|
1256
1322
|
}
|
|
1257
|
-
var
|
|
1323
|
+
var Hr = jt("flex items-center gap-2 text-sm shadow-none", {
|
|
1258
1324
|
variants: { size: {
|
|
1259
1325
|
xs: "h-6 gap-1 rounded-[calc(var(--radius)-5px)] px-2 has-[>svg]:px-2 [&>svg:not([class*='size-'])]:size-3.5",
|
|
1260
1326
|
sm: "h-8 gap-1.5 rounded-md px-2.5 has-[>svg]:px-2.5",
|
|
@@ -1263,38 +1329,38 @@ var Lr = At("flex items-center gap-2 text-sm shadow-none", {
|
|
|
1263
1329
|
} },
|
|
1264
1330
|
defaultVariants: { size: "xs" }
|
|
1265
1331
|
});
|
|
1266
|
-
function
|
|
1332
|
+
function Ur({ className: e, type: t = "button", variant: n = "ghost", size: r = "xs", ...i }) {
|
|
1267
1333
|
return /* @__PURE__ */ Z(v, {
|
|
1268
1334
|
type: t,
|
|
1269
1335
|
"data-size": r,
|
|
1270
1336
|
variant: n,
|
|
1271
|
-
className:
|
|
1337
|
+
className: W(Hr({ size: r }), e),
|
|
1272
1338
|
...i
|
|
1273
1339
|
});
|
|
1274
1340
|
}
|
|
1275
|
-
function
|
|
1276
|
-
return /* @__PURE__ */ Z(
|
|
1341
|
+
function Wr({ className: e, ...t }) {
|
|
1342
|
+
return /* @__PURE__ */ Z(De, {
|
|
1277
1343
|
"data-slot": "input-group-control",
|
|
1278
|
-
className:
|
|
1344
|
+
className: W("flex-1 resize-none rounded-none border-0 bg-transparent py-3 shadow-none focus-visible:ring-0 dark:bg-transparent", e),
|
|
1279
1345
|
...t
|
|
1280
1346
|
});
|
|
1281
1347
|
}
|
|
1282
1348
|
//#endregion
|
|
1283
1349
|
//#region src/elements/prompt-input.tsx
|
|
1284
|
-
var
|
|
1285
|
-
let e = s(
|
|
1350
|
+
var Gr = r(null), Kr = r(null), qr = () => {
|
|
1351
|
+
let e = s(Gr);
|
|
1286
1352
|
if (!e) throw Error("Wrap your component inside <PromptInputProvider> to use usePromptInputController().");
|
|
1287
1353
|
return e;
|
|
1288
|
-
},
|
|
1289
|
-
let e = s(
|
|
1354
|
+
}, Jr = () => s(Gr), Yr = () => {
|
|
1355
|
+
let e = s(Kr);
|
|
1290
1356
|
if (!e) throw Error("Wrap your component inside <PromptInputProvider> to use useProviderAttachments().");
|
|
1291
1357
|
return e;
|
|
1292
|
-
},
|
|
1293
|
-
function
|
|
1358
|
+
}, Xr = () => s(Kr);
|
|
1359
|
+
function Zr({ initialInput: e = "", children: t }) {
|
|
1294
1360
|
let [n, r] = d(e), i = o(() => r(""), []), [a, s] = d([]), f = u(null), p = u(() => {}), m = o((e) => {
|
|
1295
1361
|
let t = Array.from(e);
|
|
1296
1362
|
t.length !== 0 && s((e) => e.concat(t.map((e) => ({
|
|
1297
|
-
id:
|
|
1363
|
+
id: Pt(),
|
|
1298
1364
|
type: "file",
|
|
1299
1365
|
url: URL.createObjectURL(e),
|
|
1300
1366
|
mediaType: e.type,
|
|
@@ -1346,25 +1412,25 @@ function Kr({ initialInput: e = "", children: t }) {
|
|
|
1346
1412
|
y,
|
|
1347
1413
|
b
|
|
1348
1414
|
]);
|
|
1349
|
-
return /* @__PURE__ */ Z(
|
|
1415
|
+
return /* @__PURE__ */ Z(Gr.Provider, {
|
|
1350
1416
|
value: x,
|
|
1351
|
-
children: /* @__PURE__ */ Z(
|
|
1417
|
+
children: /* @__PURE__ */ Z(Kr.Provider, {
|
|
1352
1418
|
value: y,
|
|
1353
1419
|
children: t
|
|
1354
1420
|
})
|
|
1355
1421
|
});
|
|
1356
1422
|
}
|
|
1357
|
-
var
|
|
1358
|
-
let e =
|
|
1423
|
+
var Qr = r(null), $r = () => {
|
|
1424
|
+
let e = Xr(), t = s(Qr), n = e ?? t;
|
|
1359
1425
|
if (!n) throw Error("usePromptInputAttachments must be used within a PromptInput or PromptInputProvider");
|
|
1360
1426
|
return n;
|
|
1361
1427
|
};
|
|
1362
|
-
function
|
|
1363
|
-
let r =
|
|
1364
|
-
return /* @__PURE__ */ Q(
|
|
1428
|
+
function ei({ data: e, className: t, ...n }) {
|
|
1429
|
+
let r = $r(), i = e.filename || "", a = (e.mediaType?.startsWith("image/") && e.url ? "image" : "file") == "image", o = i || (a ? "Image" : "Attachment");
|
|
1430
|
+
return /* @__PURE__ */ Q(xi, { children: [/* @__PURE__ */ Z(oe, {
|
|
1365
1431
|
asChild: !0,
|
|
1366
1432
|
children: /* @__PURE__ */ Q("div", {
|
|
1367
|
-
className:
|
|
1433
|
+
className: W("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),
|
|
1368
1434
|
...n,
|
|
1369
1435
|
children: [/* @__PURE__ */ Q("div", {
|
|
1370
1436
|
className: "relative size-5 shrink-0",
|
|
@@ -1378,7 +1444,7 @@ function Yr({ data: e, className: t, ...n }) {
|
|
|
1378
1444
|
width: 20
|
|
1379
1445
|
}) : /* @__PURE__ */ Z("div", {
|
|
1380
1446
|
className: "flex size-5 items-center justify-center text-muted-foreground",
|
|
1381
|
-
children: /* @__PURE__ */ Z(
|
|
1447
|
+
children: /* @__PURE__ */ Z(ct, { className: "size-3" })
|
|
1382
1448
|
})
|
|
1383
1449
|
}), /* @__PURE__ */ Q(v, {
|
|
1384
1450
|
"aria-label": "Remove attachment",
|
|
@@ -1388,7 +1454,7 @@ function Yr({ data: e, className: t, ...n }) {
|
|
|
1388
1454
|
},
|
|
1389
1455
|
type: "button",
|
|
1390
1456
|
variant: "ghost",
|
|
1391
|
-
children: [/* @__PURE__ */ Z(
|
|
1457
|
+
children: [/* @__PURE__ */ Z(Y, {}), /* @__PURE__ */ Z("span", {
|
|
1392
1458
|
className: "sr-only",
|
|
1393
1459
|
children: "Remove"
|
|
1394
1460
|
})]
|
|
@@ -1398,7 +1464,7 @@ function Yr({ data: e, className: t, ...n }) {
|
|
|
1398
1464
|
children: o
|
|
1399
1465
|
})]
|
|
1400
1466
|
}, e.id)
|
|
1401
|
-
}), /* @__PURE__ */ Z(
|
|
1467
|
+
}), /* @__PURE__ */ Z(Ci, {
|
|
1402
1468
|
className: "w-auto p-2",
|
|
1403
1469
|
children: /* @__PURE__ */ Q("div", {
|
|
1404
1470
|
className: "w-auto space-y-3",
|
|
@@ -1427,29 +1493,29 @@ function Yr({ data: e, className: t, ...n }) {
|
|
|
1427
1493
|
})
|
|
1428
1494
|
})] });
|
|
1429
1495
|
}
|
|
1430
|
-
function
|
|
1431
|
-
let i =
|
|
1496
|
+
function ti({ children: e, className: t, ...r }) {
|
|
1497
|
+
let i = $r();
|
|
1432
1498
|
return i.files.length ? /* @__PURE__ */ Z("div", {
|
|
1433
|
-
className:
|
|
1499
|
+
className: W("flex flex-wrap items-center gap-2 p-3 w-full", t),
|
|
1434
1500
|
...r,
|
|
1435
1501
|
children: i.files.map((t) => /* @__PURE__ */ Z(n, { children: e(t) }, t.id))
|
|
1436
1502
|
}) : null;
|
|
1437
1503
|
}
|
|
1438
|
-
var
|
|
1439
|
-
let n =
|
|
1504
|
+
var ni = ({ label: e = "Add photos or files", ...t }) => {
|
|
1505
|
+
let n = $r();
|
|
1440
1506
|
return /* @__PURE__ */ Q(F, {
|
|
1441
1507
|
...t,
|
|
1442
1508
|
onSelect: (e) => {
|
|
1443
1509
|
e.preventDefault(), n.openFileDialog();
|
|
1444
1510
|
},
|
|
1445
1511
|
children: [
|
|
1446
|
-
/* @__PURE__ */ Z(
|
|
1512
|
+
/* @__PURE__ */ Z(nt, { className: "mr-2 size-4" }),
|
|
1447
1513
|
" ",
|
|
1448
1514
|
e
|
|
1449
1515
|
]
|
|
1450
1516
|
});
|
|
1451
|
-
},
|
|
1452
|
-
let _ =
|
|
1517
|
+
}, ri = ({ 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 }) => {
|
|
1518
|
+
let _ = Jr(), v = !!_, y = u(null), b = u(null), [x, S] = d([]), C = v ? _.attachments.files : x, w = u(C);
|
|
1453
1519
|
w.current = C;
|
|
1454
1520
|
let T = o(() => {
|
|
1455
1521
|
y.current?.click();
|
|
@@ -1484,7 +1550,7 @@ var Zr = ({ label: e = "Add photos or files", ...t }) => {
|
|
|
1484
1550
|
});
|
|
1485
1551
|
let i = [];
|
|
1486
1552
|
for (let e of n) i.push({
|
|
1487
|
-
id:
|
|
1553
|
+
id: Pt(),
|
|
1488
1554
|
type: "file",
|
|
1489
1555
|
url: URL.createObjectURL(e),
|
|
1490
1556
|
mediaType: e.type,
|
|
@@ -1571,7 +1637,7 @@ var Zr = ({ label: e = "Add photos or files", ...t }) => {
|
|
|
1571
1637
|
title: r,
|
|
1572
1638
|
type: "file"
|
|
1573
1639
|
}), /* @__PURE__ */ Z("form", {
|
|
1574
|
-
className:
|
|
1640
|
+
className: W("w-full", e),
|
|
1575
1641
|
onSubmit: (e) => {
|
|
1576
1642
|
e.preventDefault();
|
|
1577
1643
|
let t = e.currentTarget, n = v ? _.textInput.value : new FormData(t).get("message") || "";
|
|
@@ -1598,20 +1664,20 @@ var Zr = ({ label: e = "Add photos or files", ...t }) => {
|
|
|
1598
1664
|
},
|
|
1599
1665
|
ref: b,
|
|
1600
1666
|
...g,
|
|
1601
|
-
children: /* @__PURE__ */ Z(
|
|
1667
|
+
children: /* @__PURE__ */ Z(zr, {
|
|
1602
1668
|
className: "overflow-hidden",
|
|
1603
1669
|
children: h
|
|
1604
1670
|
})
|
|
1605
1671
|
})] });
|
|
1606
|
-
return v ? I : /* @__PURE__ */ Z(
|
|
1672
|
+
return v ? I : /* @__PURE__ */ Z(Qr.Provider, {
|
|
1607
1673
|
value: F,
|
|
1608
1674
|
children: I
|
|
1609
1675
|
});
|
|
1610
|
-
},
|
|
1611
|
-
className:
|
|
1676
|
+
}, ii = ({ className: e, ...t }) => /* @__PURE__ */ Z("div", {
|
|
1677
|
+
className: W("contents", e),
|
|
1612
1678
|
...t
|
|
1613
|
-
}),
|
|
1614
|
-
let i =
|
|
1679
|
+
}), ai = ({ onChange: e, className: t, placeholder: n = "What would you like to know?", ...r }) => {
|
|
1680
|
+
let i = Jr(), a = $r(), [o, s] = d(!1), c = (e) => {
|
|
1615
1681
|
if (e.key === "Enter") {
|
|
1616
1682
|
if (o || e.nativeEvent.isComposing || e.shiftKey) return;
|
|
1617
1683
|
e.preventDefault();
|
|
@@ -1639,8 +1705,8 @@ var Zr = ({ label: e = "Add photos or files", ...t }) => {
|
|
|
1639
1705
|
i.textInput.setInput(t.currentTarget.value), e?.(t);
|
|
1640
1706
|
}
|
|
1641
1707
|
} : { onChange: e };
|
|
1642
|
-
return /* @__PURE__ */ Z(
|
|
1643
|
-
className:
|
|
1708
|
+
return /* @__PURE__ */ Z(Wr, {
|
|
1709
|
+
className: W("field-sizing-content max-h-48 min-h-16", t),
|
|
1644
1710
|
name: "message",
|
|
1645
1711
|
onCompositionEnd: () => s(!1),
|
|
1646
1712
|
onCompositionStart: () => s(!0),
|
|
@@ -1650,52 +1716,52 @@ var Zr = ({ label: e = "Add photos or files", ...t }) => {
|
|
|
1650
1716
|
...r,
|
|
1651
1717
|
...u
|
|
1652
1718
|
});
|
|
1653
|
-
},
|
|
1719
|
+
}, oi = ({ className: e, ...t }) => /* @__PURE__ */ Z(Vr, {
|
|
1654
1720
|
align: "block-end",
|
|
1655
|
-
className:
|
|
1721
|
+
className: W("order-first flex-wrap gap-1", e),
|
|
1656
1722
|
...t
|
|
1657
|
-
}),
|
|
1723
|
+
}), si = ({ className: e, ...t }) => /* @__PURE__ */ Z(Vr, {
|
|
1658
1724
|
align: "block-end",
|
|
1659
|
-
className:
|
|
1725
|
+
className: W("justify-between gap-1", e),
|
|
1660
1726
|
...t
|
|
1661
|
-
}),
|
|
1662
|
-
className:
|
|
1727
|
+
}), ci = ({ className: e, ...t }) => /* @__PURE__ */ Z("div", {
|
|
1728
|
+
className: W("flex items-center gap-1", e),
|
|
1663
1729
|
...t
|
|
1664
|
-
}),
|
|
1730
|
+
}), li = ({ variant: e = "ghost", className: n, size: r, ...i }) => {
|
|
1665
1731
|
let a = r ?? (t.count(i.children) > 1 ? "sm" : "icon-sm");
|
|
1666
|
-
return /* @__PURE__ */ Z(
|
|
1667
|
-
className:
|
|
1732
|
+
return /* @__PURE__ */ Z(Ur, {
|
|
1733
|
+
className: W(n),
|
|
1668
1734
|
size: a,
|
|
1669
1735
|
type: "button",
|
|
1670
1736
|
variant: e,
|
|
1671
1737
|
...i
|
|
1672
1738
|
});
|
|
1673
|
-
},
|
|
1739
|
+
}, ui = (e) => /* @__PURE__ */ Z(ee, { ...e }), di = ({ className: e, children: t, ...n }) => /* @__PURE__ */ Z(I, {
|
|
1674
1740
|
asChild: !0,
|
|
1675
|
-
children: /* @__PURE__ */ Z(
|
|
1741
|
+
children: /* @__PURE__ */ Z(li, {
|
|
1676
1742
|
className: e,
|
|
1677
1743
|
...n,
|
|
1678
|
-
children: t ?? /* @__PURE__ */ Z(
|
|
1744
|
+
children: t ?? /* @__PURE__ */ Z(lt, { className: "size-4" })
|
|
1679
1745
|
})
|
|
1680
|
-
}),
|
|
1746
|
+
}), fi = ({ className: e, ...t }) => /* @__PURE__ */ Z(P, {
|
|
1681
1747
|
align: "start",
|
|
1682
|
-
className:
|
|
1748
|
+
className: W(e),
|
|
1683
1749
|
...t
|
|
1684
|
-
}),
|
|
1685
|
-
className:
|
|
1750
|
+
}), pi = ({ className: e, ...t }) => /* @__PURE__ */ Z(F, {
|
|
1751
|
+
className: W(e),
|
|
1686
1752
|
...t
|
|
1687
|
-
}),
|
|
1688
|
-
let o = /* @__PURE__ */ Z(
|
|
1689
|
-
return r === "submitted" ? o = /* @__PURE__ */ Z(
|
|
1753
|
+
}), mi = ({ className: e, variant: t = "default", size: n = "icon-sm", status: r, children: i, ...a }) => {
|
|
1754
|
+
let o = /* @__PURE__ */ Z(Ze, { className: "size-4" });
|
|
1755
|
+
return r === "submitted" ? o = /* @__PURE__ */ Z(at, { className: "size-4 animate-spin" }) : r === "streaming" ? o = /* @__PURE__ */ Z(ht, { className: "size-4" }) : r === "error" && (o = /* @__PURE__ */ Z(Y, { className: "size-4" })), /* @__PURE__ */ Z(Ur, {
|
|
1690
1756
|
"aria-label": "Submit",
|
|
1691
|
-
className:
|
|
1757
|
+
className: W(e),
|
|
1692
1758
|
size: n,
|
|
1693
1759
|
type: "submit",
|
|
1694
1760
|
variant: t,
|
|
1695
1761
|
...a,
|
|
1696
1762
|
children: i ?? o
|
|
1697
1763
|
});
|
|
1698
|
-
},
|
|
1764
|
+
}, hi = ({ className: e, textareaRef: t, onTranscriptionChange: n, ...r }) => {
|
|
1699
1765
|
let [i, a] = d(!1), [s, l] = d(null), f = u(null);
|
|
1700
1766
|
c(() => {
|
|
1701
1767
|
if (typeof window < "u" && ("SpeechRecognition" in window || "webkitSpeechRecognition" in window)) {
|
|
@@ -1725,80 +1791,80 @@ var Zr = ({ label: e = "Add photos or files", ...t }) => {
|
|
|
1725
1791
|
let p = o(() => {
|
|
1726
1792
|
s && (i ? s.stop() : s.start());
|
|
1727
1793
|
}, [s, i]);
|
|
1728
|
-
return /* @__PURE__ */ Z(
|
|
1729
|
-
className:
|
|
1794
|
+
return /* @__PURE__ */ Z(li, {
|
|
1795
|
+
className: W("relative transition-all duration-200", i && "animate-pulse bg-accent text-accent-foreground", e),
|
|
1730
1796
|
disabled: !s,
|
|
1731
1797
|
onClick: p,
|
|
1732
1798
|
...r,
|
|
1733
|
-
children: /* @__PURE__ */ Z(
|
|
1799
|
+
children: /* @__PURE__ */ Z(st, { className: "size-4" })
|
|
1734
1800
|
});
|
|
1735
|
-
},
|
|
1736
|
-
className:
|
|
1801
|
+
}, gi = (e) => /* @__PURE__ */ Z(ce, { ...e }), _i = ({ className: e, ...t }) => /* @__PURE__ */ Z(de, {
|
|
1802
|
+
className: W("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),
|
|
1737
1803
|
...t
|
|
1738
|
-
}),
|
|
1739
|
-
className:
|
|
1804
|
+
}), vi = ({ className: e, ...t }) => /* @__PURE__ */ Z(le, {
|
|
1805
|
+
className: W(e),
|
|
1740
1806
|
...t
|
|
1741
|
-
}),
|
|
1742
|
-
className:
|
|
1807
|
+
}), yi = ({ className: e, ...t }) => /* @__PURE__ */ Z(ue, {
|
|
1808
|
+
className: W(e),
|
|
1743
1809
|
...t
|
|
1744
|
-
}),
|
|
1745
|
-
className:
|
|
1810
|
+
}), bi = ({ className: e, ...t }) => /* @__PURE__ */ Z(fe, {
|
|
1811
|
+
className: W(e),
|
|
1746
1812
|
...t
|
|
1747
|
-
}),
|
|
1813
|
+
}), xi = ({ openDelay: e = 0, closeDelay: t = 0, ...n }) => /* @__PURE__ */ Z(R, {
|
|
1748
1814
|
closeDelay: t,
|
|
1749
1815
|
openDelay: e,
|
|
1750
1816
|
...n
|
|
1751
|
-
}),
|
|
1817
|
+
}), Si = (e) => /* @__PURE__ */ Z(oe, { ...e }), Ci = ({ align: e = "start", ...t }) => /* @__PURE__ */ Z(ae, {
|
|
1752
1818
|
align: e,
|
|
1753
1819
|
...t
|
|
1754
|
-
}),
|
|
1755
|
-
className:
|
|
1820
|
+
}), wi = ({ className: e, ...t }) => /* @__PURE__ */ Z("div", {
|
|
1821
|
+
className: W(e),
|
|
1756
1822
|
...t
|
|
1757
|
-
}),
|
|
1758
|
-
className:
|
|
1823
|
+
}), Ti = ({ className: e, ...t }) => /* @__PURE__ */ Z("div", {
|
|
1824
|
+
className: W(e),
|
|
1759
1825
|
...t
|
|
1760
|
-
}),
|
|
1761
|
-
className:
|
|
1826
|
+
}), Ei = ({ className: e, ...t }) => /* @__PURE__ */ Z("h3", {
|
|
1827
|
+
className: W("mb-2 px-3 font-medium text-muted-foreground text-xs", e),
|
|
1762
1828
|
...t
|
|
1763
|
-
}),
|
|
1764
|
-
className:
|
|
1829
|
+
}), Di = ({ className: e, ...t }) => /* @__PURE__ */ Z("div", {
|
|
1830
|
+
className: W("space-y-1", e),
|
|
1765
1831
|
...t
|
|
1766
|
-
}),
|
|
1767
|
-
className:
|
|
1832
|
+
}), Oi = ({ className: e, ...t }) => /* @__PURE__ */ Z("div", {
|
|
1833
|
+
className: W("flex items-center gap-2 px-3 py-2 text-xs hover:bg-accent", e),
|
|
1768
1834
|
...t
|
|
1769
|
-
}),
|
|
1770
|
-
className:
|
|
1835
|
+
}), ki = ({ className: e, ...t }) => /* @__PURE__ */ Z(D, {
|
|
1836
|
+
className: W(e),
|
|
1771
1837
|
...t
|
|
1772
|
-
}),
|
|
1773
|
-
className:
|
|
1838
|
+
}), Ai = ({ className: e, ...t }) => /* @__PURE__ */ Z(A, {
|
|
1839
|
+
className: W(e),
|
|
1774
1840
|
...t
|
|
1775
|
-
}),
|
|
1776
|
-
className:
|
|
1841
|
+
}), ji = ({ className: e, ...t }) => /* @__PURE__ */ Z(M, {
|
|
1842
|
+
className: W(e),
|
|
1777
1843
|
...t
|
|
1778
|
-
}),
|
|
1779
|
-
className:
|
|
1844
|
+
}), Mi = ({ className: e, ...t }) => /* @__PURE__ */ Z(O, {
|
|
1845
|
+
className: W(e),
|
|
1780
1846
|
...t
|
|
1781
|
-
}),
|
|
1782
|
-
className:
|
|
1847
|
+
}), Ni = ({ className: e, ...t }) => /* @__PURE__ */ Z(k, {
|
|
1848
|
+
className: W(e),
|
|
1783
1849
|
...t
|
|
1784
|
-
}),
|
|
1785
|
-
className:
|
|
1850
|
+
}), Pi = ({ className: e, ...t }) => /* @__PURE__ */ Z(j, {
|
|
1851
|
+
className: W(e),
|
|
1786
1852
|
...t
|
|
1787
|
-
}),
|
|
1788
|
-
className:
|
|
1853
|
+
}), Fi = ({ className: e, ...t }) => /* @__PURE__ */ Z(N, {
|
|
1854
|
+
className: W(e),
|
|
1789
1855
|
...t
|
|
1790
|
-
}),
|
|
1856
|
+
}), Ii = ({ className: e, children: t, ...n }) => /* @__PURE__ */ Q(se, {
|
|
1791
1857
|
className: "w-full overflow-x-auto whitespace-nowrap",
|
|
1792
1858
|
...n,
|
|
1793
1859
|
children: [/* @__PURE__ */ Z("div", {
|
|
1794
|
-
className:
|
|
1860
|
+
className: W("flex w-max flex-nowrap items-center gap-2", e),
|
|
1795
1861
|
children: t
|
|
1796
|
-
}), /* @__PURE__ */ Z(
|
|
1862
|
+
}), /* @__PURE__ */ Z(V, {
|
|
1797
1863
|
className: "hidden",
|
|
1798
1864
|
orientation: "horizontal"
|
|
1799
1865
|
})]
|
|
1800
|
-
}),
|
|
1801
|
-
className:
|
|
1866
|
+
}), Li = ({ suggestion: e, onClick: t, className: n, variant: r = "outline", size: i = "sm", children: a, ...o }) => /* @__PURE__ */ Z(v, {
|
|
1867
|
+
className: W("cursor-pointer rounded-full px-4", n),
|
|
1802
1868
|
onClick: () => {
|
|
1803
1869
|
t?.(e);
|
|
1804
1870
|
},
|
|
@@ -1807,7 +1873,7 @@ var Zr = ({ label: e = "Add photos or files", ...t }) => {
|
|
|
1807
1873
|
variant: r,
|
|
1808
1874
|
...o,
|
|
1809
1875
|
children: a || e
|
|
1810
|
-
}),
|
|
1876
|
+
}), Ri = r({ code: "" }), zi = {
|
|
1811
1877
|
name: "line-numbers",
|
|
1812
1878
|
line(e, t) {
|
|
1813
1879
|
e.children.unshift({
|
|
@@ -1828,21 +1894,21 @@ var Zr = ({ label: e = "Add photos or files", ...t }) => {
|
|
|
1828
1894
|
});
|
|
1829
1895
|
}
|
|
1830
1896
|
};
|
|
1831
|
-
async function
|
|
1832
|
-
let r = n ? [
|
|
1833
|
-
return await Promise.all([
|
|
1897
|
+
async function Bi(e, t, n = !1) {
|
|
1898
|
+
let r = n ? [zi] : [];
|
|
1899
|
+
return await Promise.all([Ft(e, {
|
|
1834
1900
|
lang: t,
|
|
1835
1901
|
theme: "one-light",
|
|
1836
1902
|
transformers: r
|
|
1837
|
-
}),
|
|
1903
|
+
}), Ft(e, {
|
|
1838
1904
|
lang: t,
|
|
1839
1905
|
theme: "one-dark-pro",
|
|
1840
1906
|
transformers: r
|
|
1841
1907
|
})]);
|
|
1842
1908
|
}
|
|
1843
|
-
var
|
|
1909
|
+
var Vi = ({ code: e, language: t, showLineNumbers: n = !1, className: r, children: i, ...a }) => {
|
|
1844
1910
|
let [o, s] = d(""), [l, f] = d(""), p = u(!1);
|
|
1845
|
-
return c(() => (
|
|
1911
|
+
return c(() => (Bi(e, t, n).then(([e, t]) => {
|
|
1846
1912
|
p.current ||= (s(e), f(t), !0);
|
|
1847
1913
|
}), () => {
|
|
1848
1914
|
p.current = !1;
|
|
@@ -1850,10 +1916,10 @@ var Ii = ({ code: e, language: t, showLineNumbers: n = !1, className: r, childre
|
|
|
1850
1916
|
e,
|
|
1851
1917
|
t,
|
|
1852
1918
|
n
|
|
1853
|
-
]), /* @__PURE__ */ Z(
|
|
1919
|
+
]), /* @__PURE__ */ Z(Ri.Provider, {
|
|
1854
1920
|
value: { code: e },
|
|
1855
1921
|
children: /* @__PURE__ */ Z("div", {
|
|
1856
|
-
className:
|
|
1922
|
+
className: W("group relative w-full overflow-hidden rounded-md border bg-background text-foreground", r),
|
|
1857
1923
|
...a,
|
|
1858
1924
|
children: /* @__PURE__ */ Q("div", {
|
|
1859
1925
|
className: "relative",
|
|
@@ -1874,8 +1940,8 @@ var Ii = ({ code: e, language: t, showLineNumbers: n = !1, className: r, childre
|
|
|
1874
1940
|
})
|
|
1875
1941
|
})
|
|
1876
1942
|
});
|
|
1877
|
-
},
|
|
1878
|
-
let [o, c] = d(!1), { code: l } = s(
|
|
1943
|
+
}, Hi = ({ onCopy: e, onError: t, timeout: n = 2e3, children: r, className: i, ...a }) => {
|
|
1944
|
+
let [o, c] = d(!1), { code: l } = s(Ri), u = async () => {
|
|
1879
1945
|
if (typeof window > "u" || !navigator?.clipboard?.writeText) {
|
|
1880
1946
|
t?.(/* @__PURE__ */ Error("Clipboard API not available"));
|
|
1881
1947
|
return;
|
|
@@ -1885,29 +1951,29 @@ var Ii = ({ code: e, language: t, showLineNumbers: n = !1, className: r, childre
|
|
|
1885
1951
|
} catch (e) {
|
|
1886
1952
|
t?.(e);
|
|
1887
1953
|
}
|
|
1888
|
-
}, f = o ?
|
|
1954
|
+
}, f = o ? Be : Ye;
|
|
1889
1955
|
return /* @__PURE__ */ Z(v, {
|
|
1890
|
-
className:
|
|
1956
|
+
className: W("shrink-0", i),
|
|
1891
1957
|
onClick: u,
|
|
1892
1958
|
size: "icon",
|
|
1893
1959
|
variant: "ghost",
|
|
1894
1960
|
...a,
|
|
1895
1961
|
children: r ?? /* @__PURE__ */ Z(f, { size: 14 })
|
|
1896
1962
|
});
|
|
1897
|
-
},
|
|
1898
|
-
className:
|
|
1963
|
+
}, Ui = ({ className: e, ...t }) => /* @__PURE__ */ Z(w, {
|
|
1964
|
+
className: W("not-prose mb-4 w-full rounded-md border", e),
|
|
1899
1965
|
...t
|
|
1900
|
-
}),
|
|
1966
|
+
}), Wi = (e) => /* @__PURE__ */ Q(_, {
|
|
1901
1967
|
className: "gap-1.5 rounded-full text-xs",
|
|
1902
1968
|
variant: "secondary",
|
|
1903
1969
|
children: [{
|
|
1904
|
-
"input-streaming": /* @__PURE__ */ Z(
|
|
1905
|
-
"input-available": /* @__PURE__ */ Z(
|
|
1906
|
-
"approval-requested": /* @__PURE__ */ Z(
|
|
1907
|
-
"approval-responded": /* @__PURE__ */ Z(
|
|
1908
|
-
"output-available": /* @__PURE__ */ Z(
|
|
1909
|
-
"output-error": /* @__PURE__ */ Z(
|
|
1910
|
-
"output-denied": /* @__PURE__ */ Z(
|
|
1970
|
+
"input-streaming": /* @__PURE__ */ Z(K, { className: "size-4" }),
|
|
1971
|
+
"input-available": /* @__PURE__ */ Z(qe, { className: "size-4 animate-pulse" }),
|
|
1972
|
+
"approval-requested": /* @__PURE__ */ Z(qe, { className: "size-4 text-yellow-600" }),
|
|
1973
|
+
"approval-responded": /* @__PURE__ */ Z(ze, { className: "size-4 text-blue-600" }),
|
|
1974
|
+
"output-available": /* @__PURE__ */ Z(ze, { className: "size-4 text-green-600" }),
|
|
1975
|
+
"output-error": /* @__PURE__ */ Z(xt, { className: "size-4 text-red-600" }),
|
|
1976
|
+
"output-denied": /* @__PURE__ */ Z(xt, { className: "size-4 text-orange-600" })
|
|
1911
1977
|
}[e], {
|
|
1912
1978
|
"input-streaming": "Pending",
|
|
1913
1979
|
"input-available": "Running",
|
|
@@ -1917,61 +1983,61 @@ var Ii = ({ code: e, language: t, showLineNumbers: n = !1, className: r, childre
|
|
|
1917
1983
|
"output-error": "Error",
|
|
1918
1984
|
"output-denied": "Denied"
|
|
1919
1985
|
}[e]]
|
|
1920
|
-
}),
|
|
1921
|
-
className:
|
|
1986
|
+
}), Gi = ({ className: e, title: t, type: n, state: r, ...i }) => /* @__PURE__ */ Q(E, {
|
|
1987
|
+
className: W("flex w-full items-center justify-between gap-4 p-3", e),
|
|
1922
1988
|
...i,
|
|
1923
1989
|
children: [/* @__PURE__ */ Q("div", {
|
|
1924
1990
|
className: "flex items-center gap-2",
|
|
1925
1991
|
children: [
|
|
1926
|
-
/* @__PURE__ */ Z(
|
|
1992
|
+
/* @__PURE__ */ Z(yt, { className: "size-4 text-muted-foreground" }),
|
|
1927
1993
|
/* @__PURE__ */ Z("span", {
|
|
1928
1994
|
className: "font-medium text-sm",
|
|
1929
1995
|
children: t ?? n.split("-").slice(1).join("-")
|
|
1930
1996
|
}),
|
|
1931
|
-
|
|
1997
|
+
Wi(r)
|
|
1932
1998
|
]
|
|
1933
|
-
}), /* @__PURE__ */ Z(
|
|
1934
|
-
}),
|
|
1935
|
-
className:
|
|
1999
|
+
}), /* @__PURE__ */ Z(Ve, { className: "size-4 text-muted-foreground transition-transform group-data-[state=open]:rotate-180" })]
|
|
2000
|
+
}), Ki = ({ className: e, ...t }) => /* @__PURE__ */ Z(T, {
|
|
2001
|
+
className: W("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),
|
|
1936
2002
|
...t
|
|
1937
|
-
}),
|
|
1938
|
-
className:
|
|
2003
|
+
}), qi = ({ className: e, input: t, ...n }) => /* @__PURE__ */ Q("div", {
|
|
2004
|
+
className: W("space-y-2 overflow-hidden p-4", e),
|
|
1939
2005
|
...n,
|
|
1940
2006
|
children: [/* @__PURE__ */ Z("h4", {
|
|
1941
2007
|
className: "font-medium text-muted-foreground text-xs uppercase tracking-wide",
|
|
1942
2008
|
children: "Parameters"
|
|
1943
2009
|
}), /* @__PURE__ */ Z("div", {
|
|
1944
2010
|
className: "rounded-md bg-muted/50",
|
|
1945
|
-
children: /* @__PURE__ */ Z(
|
|
2011
|
+
children: /* @__PURE__ */ Z(Vi, {
|
|
1946
2012
|
code: JSON.stringify(t, null, 2),
|
|
1947
2013
|
language: "json"
|
|
1948
2014
|
})
|
|
1949
2015
|
})]
|
|
1950
|
-
}),
|
|
2016
|
+
}), Ji = ({ className: e, output: t, errorText: n, ...r }) => {
|
|
1951
2017
|
if (!(t || n)) return null;
|
|
1952
2018
|
let a = /* @__PURE__ */ Z("div", { children: t });
|
|
1953
|
-
return typeof t == "object" && !i(t) ? a = /* @__PURE__ */ Z(
|
|
2019
|
+
return typeof t == "object" && !i(t) ? a = /* @__PURE__ */ Z(Vi, {
|
|
1954
2020
|
code: JSON.stringify(t, null, 2),
|
|
1955
2021
|
language: "json"
|
|
1956
|
-
}) : typeof t == "string" && (a = /* @__PURE__ */ Z(
|
|
2022
|
+
}) : typeof t == "string" && (a = /* @__PURE__ */ Z(Vi, {
|
|
1957
2023
|
code: t,
|
|
1958
2024
|
language: "json"
|
|
1959
2025
|
})), /* @__PURE__ */ Q("div", {
|
|
1960
|
-
className:
|
|
2026
|
+
className: W("space-y-2 p-4", e),
|
|
1961
2027
|
...r,
|
|
1962
2028
|
children: [/* @__PURE__ */ Z("h4", {
|
|
1963
2029
|
className: "font-medium text-muted-foreground text-xs uppercase tracking-wide",
|
|
1964
2030
|
children: n ? "Error" : "Result"
|
|
1965
2031
|
}), /* @__PURE__ */ Q("div", {
|
|
1966
|
-
className:
|
|
2032
|
+
className: W("overflow-x-auto rounded-md text-xs [&_table]:w-full", n ? "bg-destructive/10 text-destructive" : "bg-muted/50 text-foreground"),
|
|
1967
2033
|
children: [n && /* @__PURE__ */ Z("div", { children: n }), a]
|
|
1968
2034
|
})]
|
|
1969
2035
|
});
|
|
1970
|
-
},
|
|
1971
|
-
let a = l(() =>
|
|
2036
|
+
}, Yi = a(({ children: e, as: t = "p", className: n, duration: r = 2, spread: i = 2 }) => {
|
|
2037
|
+
let a = l(() => Lt.create(t), [t]), o = l(() => (e?.length ?? 0) * i, [e, i]);
|
|
1972
2038
|
return /* @__PURE__ */ Z(a, {
|
|
1973
2039
|
animate: { backgroundPosition: "0% center" },
|
|
1974
|
-
className:
|
|
2040
|
+
className: W("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),
|
|
1975
2041
|
initial: { backgroundPosition: "100% center" },
|
|
1976
2042
|
style: {
|
|
1977
2043
|
"--spread": `${o}px`,
|
|
@@ -1984,21 +2050,21 @@ var Ii = ({ code: e, language: t, showLineNumbers: n = !1, className: r, childre
|
|
|
1984
2050
|
},
|
|
1985
2051
|
children: e
|
|
1986
2052
|
});
|
|
1987
|
-
}),
|
|
1988
|
-
let e = s(
|
|
2053
|
+
}), Xi = r(null), Zi = () => {
|
|
2054
|
+
let e = s(Xi);
|
|
1989
2055
|
if (!e) throw Error("Reasoning components must be used within Reasoning");
|
|
1990
2056
|
return e;
|
|
1991
|
-
},
|
|
1992
|
-
let [l, u] =
|
|
2057
|
+
}, Qi = 1e3, $i = 1e3, ea = a(({ className: e, isStreaming: t = !1, open: n, defaultOpen: r = !0, onOpenChange: i, duration: a, children: o, ...s }) => {
|
|
2058
|
+
let [l, u] = It({
|
|
1993
2059
|
prop: n,
|
|
1994
2060
|
defaultProp: r,
|
|
1995
2061
|
onChange: i
|
|
1996
|
-
}), [f, p] =
|
|
2062
|
+
}), [f, p] = It({
|
|
1997
2063
|
prop: a,
|
|
1998
2064
|
defaultProp: void 0
|
|
1999
2065
|
}), [m, h] = d(!1), [g, _] = d(null);
|
|
2000
2066
|
return c(() => {
|
|
2001
|
-
t ? g === null && _(Date.now()) : g !== null && (p(Math.ceil((Date.now() - g) /
|
|
2067
|
+
t ? g === null && _(Date.now()) : g !== null && (p(Math.ceil((Date.now() - g) / $i)), _(null));
|
|
2002
2068
|
}, [
|
|
2003
2069
|
t,
|
|
2004
2070
|
g,
|
|
@@ -2007,7 +2073,7 @@ var Ii = ({ code: e, language: t, showLineNumbers: n = !1, className: r, childre
|
|
|
2007
2073
|
if (r && !t && l && !m) {
|
|
2008
2074
|
let e = setTimeout(() => {
|
|
2009
2075
|
u(!1), h(!0);
|
|
2010
|
-
},
|
|
2076
|
+
}, Qi);
|
|
2011
2077
|
return () => clearTimeout(e);
|
|
2012
2078
|
}
|
|
2013
2079
|
}, [
|
|
@@ -2016,7 +2082,7 @@ var Ii = ({ code: e, language: t, showLineNumbers: n = !1, className: r, childre
|
|
|
2016
2082
|
r,
|
|
2017
2083
|
u,
|
|
2018
2084
|
m
|
|
2019
|
-
]), /* @__PURE__ */ Z(
|
|
2085
|
+
]), /* @__PURE__ */ Z(Xi.Provider, {
|
|
2020
2086
|
value: {
|
|
2021
2087
|
isStreaming: t,
|
|
2022
2088
|
isOpen: l,
|
|
@@ -2024,7 +2090,7 @@ var Ii = ({ code: e, language: t, showLineNumbers: n = !1, className: r, childre
|
|
|
2024
2090
|
duration: f
|
|
2025
2091
|
},
|
|
2026
2092
|
children: /* @__PURE__ */ Z(w, {
|
|
2027
|
-
className:
|
|
2093
|
+
className: W("not-prose mb-4", e),
|
|
2028
2094
|
onOpenChange: (e) => {
|
|
2029
2095
|
u(e);
|
|
2030
2096
|
},
|
|
@@ -2033,37 +2099,37 @@ var Ii = ({ code: e, language: t, showLineNumbers: n = !1, className: r, childre
|
|
|
2033
2099
|
children: o
|
|
2034
2100
|
})
|
|
2035
2101
|
});
|
|
2036
|
-
}),
|
|
2102
|
+
}), ta = (e, t) => e || t === 0 ? /* @__PURE__ */ Z(Yi, {
|
|
2037
2103
|
duration: 1,
|
|
2038
2104
|
children: "Thinking..."
|
|
2039
2105
|
}) : t === void 0 ? /* @__PURE__ */ Z("p", { children: "Thought for a few seconds" }) : /* @__PURE__ */ Q("p", { children: [
|
|
2040
2106
|
"Thought for ",
|
|
2041
2107
|
t,
|
|
2042
2108
|
" seconds"
|
|
2043
|
-
] }),
|
|
2044
|
-
let { isStreaming: i, isOpen: a, duration: o } =
|
|
2109
|
+
] }), na = a(({ className: e, children: t, getThinkingMessage: n = ta, ...r }) => {
|
|
2110
|
+
let { isStreaming: i, isOpen: a, duration: o } = Zi();
|
|
2045
2111
|
return /* @__PURE__ */ Z(E, {
|
|
2046
|
-
className:
|
|
2112
|
+
className: W("flex w-full items-center gap-2 text-muted-foreground text-sm transition-colors hover:text-foreground", e),
|
|
2047
2113
|
...r,
|
|
2048
2114
|
children: t ?? /* @__PURE__ */ Q(X, { children: [
|
|
2049
|
-
/* @__PURE__ */ Z(
|
|
2115
|
+
/* @__PURE__ */ Z(Le, { className: "size-4" }),
|
|
2050
2116
|
n(i, o),
|
|
2051
|
-
/* @__PURE__ */ Z(
|
|
2117
|
+
/* @__PURE__ */ Z(Ve, { className: W("size-4 transition-transform", a ? "rotate-180" : "rotate-0") })
|
|
2052
2118
|
] })
|
|
2053
2119
|
});
|
|
2054
|
-
}),
|
|
2055
|
-
className:
|
|
2120
|
+
}), ra = a(({ className: e, children: t, ...n }) => /* @__PURE__ */ Z(T, {
|
|
2121
|
+
className: W("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),
|
|
2056
2122
|
...n,
|
|
2057
|
-
children: /* @__PURE__ */ Z(
|
|
2123
|
+
children: /* @__PURE__ */ Z(Nt, { children: t })
|
|
2058
2124
|
}));
|
|
2059
|
-
|
|
2125
|
+
ea.displayName = "Reasoning", na.displayName = "ReasoningTrigger", ra.displayName = "ReasoningContent";
|
|
2060
2126
|
//#endregion
|
|
2061
2127
|
//#region src/elements/sources.tsx
|
|
2062
|
-
var
|
|
2063
|
-
className:
|
|
2128
|
+
var ia = ({ className: e, ...t }) => /* @__PURE__ */ Z(w, {
|
|
2129
|
+
className: W("not-prose mb-4 text-primary text-xs", e),
|
|
2064
2130
|
...t
|
|
2065
|
-
}),
|
|
2066
|
-
className:
|
|
2131
|
+
}), aa = ({ className: e, count: t, children: n, ...r }) => /* @__PURE__ */ Z(E, {
|
|
2132
|
+
className: W("flex items-center gap-2", e),
|
|
2067
2133
|
...r,
|
|
2068
2134
|
children: n ?? /* @__PURE__ */ Q(X, { children: [/* @__PURE__ */ Q("p", {
|
|
2069
2135
|
className: "font-medium",
|
|
@@ -2072,24 +2138,24 @@ var $i = ({ className: e, ...t }) => /* @__PURE__ */ Z(w, {
|
|
|
2072
2138
|
t,
|
|
2073
2139
|
" sources"
|
|
2074
2140
|
]
|
|
2075
|
-
}), /* @__PURE__ */ Z(
|
|
2076
|
-
}),
|
|
2077
|
-
className:
|
|
2141
|
+
}), /* @__PURE__ */ Z(Ve, { className: "h-4 w-4" })] })
|
|
2142
|
+
}), oa = ({ className: e, ...t }) => /* @__PURE__ */ Z(T, {
|
|
2143
|
+
className: W("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),
|
|
2078
2144
|
...t
|
|
2079
|
-
}),
|
|
2145
|
+
}), sa = ({ href: e, title: t, children: n, ...r }) => /* @__PURE__ */ Z("a", {
|
|
2080
2146
|
className: "flex items-center gap-2",
|
|
2081
2147
|
href: e,
|
|
2082
2148
|
rel: "noreferrer",
|
|
2083
2149
|
target: "_blank",
|
|
2084
2150
|
...r,
|
|
2085
|
-
children: n ?? /* @__PURE__ */ Q(X, { children: [/* @__PURE__ */ Z(
|
|
2151
|
+
children: n ?? /* @__PURE__ */ Q(X, { children: [/* @__PURE__ */ Z(Fe, { className: "h-4 w-4" }), /* @__PURE__ */ Z("span", {
|
|
2086
2152
|
className: "block font-medium",
|
|
2087
2153
|
children: t
|
|
2088
2154
|
})] })
|
|
2089
2155
|
});
|
|
2090
2156
|
//#endregion
|
|
2091
2157
|
//#region src/ChatbotEnhanced.tsx
|
|
2092
|
-
function
|
|
2158
|
+
function ca(e) {
|
|
2093
2159
|
let t = e ?? {}, n = t.data && typeof t.data == "object" ? t.data : t, r = n.seedApplied, i = n.probes;
|
|
2094
2160
|
if (!r && !i) return;
|
|
2095
2161
|
let a = {};
|
|
@@ -2103,10 +2169,10 @@ function ra(e) {
|
|
|
2103
2169
|
message: String(e.message)
|
|
2104
2170
|
}))), a;
|
|
2105
2171
|
}
|
|
2106
|
-
function
|
|
2172
|
+
function la(e) {
|
|
2107
2173
|
return e === "user" ? "user" : "assistant";
|
|
2108
2174
|
}
|
|
2109
|
-
function
|
|
2175
|
+
function ua(e) {
|
|
2110
2176
|
let t = e.trim();
|
|
2111
2177
|
if (t.length < 2 || !(t.startsWith("{") || t.startsWith("[")) || !(t.endsWith("}") || t.endsWith("]"))) return !1;
|
|
2112
2178
|
try {
|
|
@@ -2115,15 +2181,15 @@ function aa(e) {
|
|
|
2115
2181
|
return !1;
|
|
2116
2182
|
}
|
|
2117
2183
|
}
|
|
2118
|
-
function
|
|
2119
|
-
let t =
|
|
2184
|
+
function da(e) {
|
|
2185
|
+
let t = $(e)?.status;
|
|
2120
2186
|
return t === "changes_proposed" || t === "blueprint_proposed" || t === "awaiting_confirmation";
|
|
2121
2187
|
}
|
|
2122
|
-
function
|
|
2188
|
+
function fa(e) {
|
|
2123
2189
|
let t = e.state ?? (e.errorText ? "output-error" : e.result === void 0 ? "input-available" : "output-available");
|
|
2124
|
-
return t === "output-error" || t === "output-denied" ? "failed" : t === "approval-requested" || t === "approval-responded" ? "awaiting" : t === "output-available" ?
|
|
2190
|
+
return t === "output-error" || t === "output-denied" ? "failed" : t === "approval-requested" || t === "approval-responded" ? "awaiting" : t === "output-available" ? da(e.result) ? "awaiting" : "completed" : "running";
|
|
2125
2191
|
}
|
|
2126
|
-
var
|
|
2192
|
+
var pa = {
|
|
2127
2193
|
create_object: "Create object",
|
|
2128
2194
|
add_field: "Add field",
|
|
2129
2195
|
modify_field: "Modify field",
|
|
@@ -2133,20 +2199,20 @@ var ca = {
|
|
|
2133
2199
|
create_seed: "Generate sample data",
|
|
2134
2200
|
create_package: "Create app package"
|
|
2135
2201
|
};
|
|
2136
|
-
function
|
|
2202
|
+
function ma(e, t = pa) {
|
|
2137
2203
|
return [
|
|
2138
|
-
t[e.verb] ??
|
|
2204
|
+
t[e.verb] ?? pa[e.verb] ?? e.verb,
|
|
2139
2205
|
`${e.field ? `${e.object ? `${e.object}.` : ""}${e.field}` : e.object ?? e.name ?? ""}${e.type ? ` (${e.type})` : ""}`,
|
|
2140
2206
|
e.details
|
|
2141
2207
|
].filter(Boolean).join(" ");
|
|
2142
2208
|
}
|
|
2143
|
-
function
|
|
2209
|
+
function ha(e) {
|
|
2144
2210
|
return e.toolName === "propose_blueprint";
|
|
2145
2211
|
}
|
|
2146
|
-
function
|
|
2147
|
-
return
|
|
2212
|
+
function ga(e) {
|
|
2213
|
+
return ha(e) && fa(e) === "completed" && !e.proposedPlan && !e.proposedChanges && !e.draftReview?.items.length;
|
|
2148
2214
|
}
|
|
2149
|
-
var
|
|
2215
|
+
var _a = [
|
|
2150
2216
|
"待补",
|
|
2151
2217
|
"后续",
|
|
2152
2218
|
"将在",
|
|
@@ -2172,25 +2238,25 @@ var fa = [
|
|
|
2172
2238
|
"coming soon",
|
|
2173
2239
|
"tbd"
|
|
2174
2240
|
];
|
|
2175
|
-
function
|
|
2241
|
+
function va(e) {
|
|
2176
2242
|
let t = [], n = [];
|
|
2177
2243
|
for (let r of e) {
|
|
2178
2244
|
if (typeof r != "string") continue;
|
|
2179
2245
|
let e = r.trim();
|
|
2180
2246
|
if (!e) continue;
|
|
2181
2247
|
let i = e.toLowerCase();
|
|
2182
|
-
|
|
2248
|
+
_a.some((e) => i.includes(e)) ? n.push(e) : t.push(e);
|
|
2183
2249
|
}
|
|
2184
2250
|
return {
|
|
2185
2251
|
designNotes: t,
|
|
2186
2252
|
deferred: n
|
|
2187
2253
|
};
|
|
2188
2254
|
}
|
|
2189
|
-
function
|
|
2190
|
-
let t =
|
|
2191
|
-
return t === "awaiting" || t === "failed" || !!e.pendingActionId || !!e.draftReview?.items.length || !!e.proposedPlan || !!e.proposedChanges || !!e.builderHandoff ||
|
|
2255
|
+
function ya(e) {
|
|
2256
|
+
let t = fa(e);
|
|
2257
|
+
return t === "awaiting" || t === "failed" || !!e.pendingActionId || !!e.draftReview?.items.length || !!e.proposedPlan || !!e.proposedChanges || !!e.builderHandoff || ga(e);
|
|
2192
2258
|
}
|
|
2193
|
-
function
|
|
2259
|
+
function ba(e) {
|
|
2194
2260
|
switch (e) {
|
|
2195
2261
|
case "failed": return 4;
|
|
2196
2262
|
case "awaiting": return 3;
|
|
@@ -2198,20 +2264,20 @@ function ha(e) {
|
|
|
2198
2264
|
case "completed": return 1;
|
|
2199
2265
|
}
|
|
2200
2266
|
}
|
|
2201
|
-
function
|
|
2267
|
+
function xa(e) {
|
|
2202
2268
|
return /^\((?:called [^)]*|tool call|no content)\)$/.test(e.trim());
|
|
2203
2269
|
}
|
|
2204
|
-
function
|
|
2270
|
+
function Sa(e) {
|
|
2205
2271
|
let t = /* @__PURE__ */ new Map();
|
|
2206
2272
|
for (let n of e) {
|
|
2207
|
-
let e =
|
|
2273
|
+
let e = fa(n), r = `${n.toolName}:${e}`, i = t.get(r);
|
|
2208
2274
|
if (i) {
|
|
2209
2275
|
i.count += 1, i.errorText = i.errorText ?? n.errorText;
|
|
2210
2276
|
continue;
|
|
2211
2277
|
}
|
|
2212
2278
|
t.set(r, {
|
|
2213
2279
|
key: r,
|
|
2214
|
-
title:
|
|
2280
|
+
title: or(n.toolName) || n.toolName,
|
|
2215
2281
|
rawName: n.toolName,
|
|
2216
2282
|
count: 1,
|
|
2217
2283
|
state: e,
|
|
@@ -2219,11 +2285,11 @@ function _a(e) {
|
|
|
2219
2285
|
});
|
|
2220
2286
|
}
|
|
2221
2287
|
return Array.from(t.values()).sort((e, t) => {
|
|
2222
|
-
let n =
|
|
2288
|
+
let n = ba(t.state) - ba(e.state);
|
|
2223
2289
|
return n === 0 ? e.title.localeCompare(t.title) : n;
|
|
2224
2290
|
});
|
|
2225
2291
|
}
|
|
2226
|
-
function
|
|
2292
|
+
function Ca({ health: e }) {
|
|
2227
2293
|
if (!e) return null;
|
|
2228
2294
|
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 = [];
|
|
2229
2295
|
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) {
|
|
@@ -2236,25 +2302,25 @@ function va({ health: e }) {
|
|
|
2236
2302
|
children: [
|
|
2237
2303
|
o.length > 0 ? /* @__PURE__ */ Q("div", {
|
|
2238
2304
|
className: "flex items-center gap-1.5 text-xs text-emerald-700",
|
|
2239
|
-
children: [/* @__PURE__ */ Z(
|
|
2305
|
+
children: [/* @__PURE__ */ Z(G, { className: "size-3.5 shrink-0" }), /* @__PURE__ */ Z("span", { children: o.join(" · ") })]
|
|
2240
2306
|
}) : null,
|
|
2241
2307
|
e.seedError ? /* @__PURE__ */ Q("div", {
|
|
2242
2308
|
className: "flex items-start gap-1.5 text-xs text-red-600",
|
|
2243
|
-
children: [/* @__PURE__ */ Z(
|
|
2309
|
+
children: [/* @__PURE__ */ Z(J, { className: "mt-0.5 size-3.5 shrink-0" }), /* @__PURE__ */ Z("span", { children: e.seedError })]
|
|
2244
2310
|
}) : null,
|
|
2245
2311
|
n.map((e, t) => /* @__PURE__ */ Q("div", {
|
|
2246
2312
|
className: "flex items-start gap-1.5 text-xs text-red-600",
|
|
2247
|
-
children: [/* @__PURE__ */ Z(
|
|
2313
|
+
children: [/* @__PURE__ */ Z(J, { className: "mt-0.5 size-3.5 shrink-0" }), /* @__PURE__ */ Z("span", { children: e.message })]
|
|
2248
2314
|
}, `e${t}`)),
|
|
2249
2315
|
r.map((e, t) => /* @__PURE__ */ Q("div", {
|
|
2250
2316
|
className: "flex items-start gap-1.5 text-xs text-amber-600",
|
|
2251
|
-
children: [/* @__PURE__ */ Z(
|
|
2317
|
+
children: [/* @__PURE__ */ Z(Me, { className: "mt-0.5 size-3.5 shrink-0" }), /* @__PURE__ */ Z("span", { children: e.message })]
|
|
2252
2318
|
}, `w${t}`))
|
|
2253
2319
|
]
|
|
2254
2320
|
});
|
|
2255
2321
|
}
|
|
2256
|
-
var
|
|
2257
|
-
let
|
|
2322
|
+
var wa = 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,.csv,.tsv,.xlsx,.xlsm", maxFileSize: w = 10485760, suggestions: T, labels: E, models: D, selectedModelId: O, onModelChange: k, headerSlot: A, promptOverlaySlot: j, onInputChange: M, onToolApprove: N, toolApproveLabel: ee = "Approve", toolDenyLabel: P = "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", onDesignBuiltApp: R, designBuiltAppLabel: ae = "Design in Studio", getArtifactAction: oe, onPreviewDraftApp: z, previewDraftLabel: B = "Preview", onDraftArtifacts: se, onBuildMaterialized: V, publishDraftsLabel: ce = "Publish", publishedLabel: le = "Published", verifiedLabel: ue = "Verified", nextStepsLabel: de = "What's next", planTitleLabel: fe = "Proposed plan", builderHandoffTitleLabel: pe = "Build this in the Builder", builderHandoffOpenLabel: me = "Open in Builder →", builderHandoffSupersededTitle: he = "A newer request is available", onOpenBuilder: ge, planExtendLabel: _e = "Adding to existing app", planQuestionsLabel: ve = "Confirm before building", planAssumptionsLabel: ye = "Assumptions", planDeferredLabel: be = "Not yet built", planApproveHintLabel: xe = "Reply to approve or adjust this plan.", planApproveLabel: H = "Build it", planAdjustLabel: U = "Adjust", planBuiltLabel: Se = "Built", planBuildingLabel: Ce = "Building…", planReadyLabel: we = "The plan is ready. Build it now, or tell me what to adjust.", planApproveMessage: Te = "Looks good — build it as proposed.", planApproveDefaultsMessage: Ee = "Build it with your best assumptions; use sensible defaults for the open questions.", planAnswerMessage: De = (e, t) => `For "${e}", go with: ${t}.`, changesTitleLabel: Oe = "Confirm changes", changesConfirmedLabel: ke = "Confirmed", changesConfirmLabel: Ae = "Confirm", changesConfirmHintLabel: je = "Reply to confirm or adjust this change.", changesConfirmMessage: Ne = "Confirm — apply the change you just proposed.", changeVerbLabels: Pe = pa, changesApplyingLabel: Fe = "Applying…", changesAppliedLabel: Le = "Applied", changesDraftedLabel: ze = "Saved as draft", changesFailedLabel: Be = "Not applied", surfaceContextLabel: Ve, fetchPendingDraftCount: He, autoPublishDrafts: Ue = !1, processVisibility: K = "summary", surface: Ge = "card", ...qe }, Ye) => {
|
|
2323
|
+
let Ze = d ? "streaming" : "ready", nt = Ge === "plain", [rt, at] = e.useState(null), ot = e.useRef(""), st = e.useRef(null), q = e.useMemo(() => ({
|
|
2258
2324
|
emptyTitle: E?.emptyTitle ?? "Start a conversation",
|
|
2259
2325
|
emptyDescription: E?.emptyDescription ?? "Ask anything — the assistant has access to your current app context.",
|
|
2260
2326
|
clear: E?.clear ?? "Clear",
|
|
@@ -2280,55 +2346,55 @@ var ya = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2280
2346
|
connectionStalledLabel: E?.connectionStalledLabel ?? "Still working…",
|
|
2281
2347
|
connectionOfflineLabel: E?.connectionOfflineLabel ?? "Connection lost — reconnecting…",
|
|
2282
2348
|
designingPlanLabel: E?.designingPlanLabel ?? "Designing your app…",
|
|
2283
|
-
designingPlanHints: E?.designingPlanHints ??
|
|
2284
|
-
}), [E]), [
|
|
2285
|
-
if (
|
|
2286
|
-
let t = await
|
|
2287
|
-
|
|
2349
|
+
designingPlanHints: E?.designingPlanHints ?? Na
|
|
2350
|
+
}), [E]), [ct, lt] = e.useState(() => /* @__PURE__ */ new Set()), [ft, ht] = e.useState(() => /* @__PURE__ */ new Map()), [vt, yt] = e.useState(() => /* @__PURE__ */ new Map()), bt = e.useRef(/* @__PURE__ */ new Set()), xt = e.useCallback(async (e) => {
|
|
2351
|
+
if (He) try {
|
|
2352
|
+
let t = await He(e);
|
|
2353
|
+
yt((n) => {
|
|
2288
2354
|
if (n.get(e) === t) return n;
|
|
2289
2355
|
let r = new Map(n);
|
|
2290
2356
|
return r.set(e, t), r;
|
|
2291
2357
|
});
|
|
2292
2358
|
} catch {}
|
|
2293
|
-
}, [
|
|
2359
|
+
}, [He]);
|
|
2294
2360
|
e.useEffect(() => {
|
|
2295
|
-
if (!
|
|
2361
|
+
if (!He || d) return;
|
|
2296
2362
|
let e = /* @__PURE__ */ new Set();
|
|
2297
2363
|
for (let t of n) for (let n of t.toolInvocations ?? []) {
|
|
2298
2364
|
let t = n.draftReview?.packageId, r = n.toolCallId;
|
|
2299
|
-
t && r && !
|
|
2365
|
+
t && r && !bt.current.has(r) && (bt.current.add(r), e.add(t));
|
|
2300
2366
|
}
|
|
2301
|
-
for (let t of e)
|
|
2367
|
+
for (let t of e) xt(t);
|
|
2302
2368
|
}, [
|
|
2303
2369
|
n,
|
|
2304
2370
|
d,
|
|
2305
|
-
|
|
2306
|
-
|
|
2371
|
+
He,
|
|
2372
|
+
xt
|
|
2307
2373
|
]);
|
|
2308
|
-
let
|
|
2374
|
+
let Y = e.useCallback(async (e) => {
|
|
2309
2375
|
if (!L) return;
|
|
2310
2376
|
let t = [];
|
|
2311
2377
|
for (let r of n) for (let n of r.toolInvocations ?? []) n.draftReview?.packageId === e && n.toolCallId && t.push(n.toolCallId);
|
|
2312
2378
|
let r = await L(e), i = r && typeof r == "object" ? r : void 0;
|
|
2313
2379
|
if ((i ? i.ok !== !1 : r !== !1) && t.length > 0) {
|
|
2314
|
-
|
|
2380
|
+
lt((e) => {
|
|
2315
2381
|
let n = new Set(e);
|
|
2316
2382
|
for (let e of t) n.add(e);
|
|
2317
2383
|
return n;
|
|
2318
2384
|
});
|
|
2319
2385
|
let e = i?.health;
|
|
2320
|
-
e &&
|
|
2386
|
+
e && ht((n) => {
|
|
2321
2387
|
let r = new Map(n);
|
|
2322
2388
|
for (let n of t) r.set(n, e);
|
|
2323
2389
|
return r;
|
|
2324
2390
|
});
|
|
2325
2391
|
}
|
|
2326
|
-
|
|
2392
|
+
xt(e);
|
|
2327
2393
|
}, [
|
|
2328
2394
|
L,
|
|
2329
2395
|
n,
|
|
2330
|
-
|
|
2331
|
-
]),
|
|
2396
|
+
xt
|
|
2397
|
+
]), St = e.useRef(/* @__PURE__ */ new Set()), Ct = e.useRef(!1);
|
|
2332
2398
|
e.useEffect(() => {
|
|
2333
2399
|
let e = [];
|
|
2334
2400
|
for (let t of n) for (let n of t.toolInvocations ?? []) {
|
|
@@ -2338,27 +2404,27 @@ var ya = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2338
2404
|
packageId: t.packageId
|
|
2339
2405
|
});
|
|
2340
2406
|
}
|
|
2341
|
-
if (!
|
|
2342
|
-
|
|
2343
|
-
for (let t of e)
|
|
2407
|
+
if (!Ct.current) {
|
|
2408
|
+
Ct.current = !0;
|
|
2409
|
+
for (let t of e) St.current.add(t.key);
|
|
2344
2410
|
return;
|
|
2345
2411
|
}
|
|
2346
|
-
if (!
|
|
2347
|
-
let t = e.filter((e) => !
|
|
2412
|
+
if (!Ue || !L || d) return;
|
|
2413
|
+
let t = e.filter((e) => !St.current.has(e.key));
|
|
2348
2414
|
if (t.length !== 0) {
|
|
2349
|
-
for (let e of t)
|
|
2350
|
-
for (let e of [...new Set(t.map((e) => e.packageId))])
|
|
2415
|
+
for (let e of t) St.current.add(e.key);
|
|
2416
|
+
for (let e of [...new Set(t.map((e) => e.packageId))]) Y(e);
|
|
2351
2417
|
}
|
|
2352
2418
|
}, [
|
|
2353
2419
|
n,
|
|
2354
2420
|
d,
|
|
2355
|
-
|
|
2421
|
+
Ue,
|
|
2356
2422
|
L,
|
|
2357
|
-
|
|
2423
|
+
Y
|
|
2358
2424
|
]);
|
|
2359
|
-
let
|
|
2425
|
+
let wt = e.useRef(/* @__PURE__ */ new Set());
|
|
2360
2426
|
e.useEffect(() => {
|
|
2361
|
-
if (!
|
|
2427
|
+
if (!se) return;
|
|
2362
2428
|
let e = /* @__PURE__ */ new Map(), t;
|
|
2363
2429
|
for (let r of n) {
|
|
2364
2430
|
for (let t of r.buildProgress?.items ?? []) t?.type && t?.name && e.set(`${t.type}:${t.name}`, t);
|
|
@@ -2368,69 +2434,82 @@ var ya = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2368
2434
|
r?.packageId && r.items?.some((e) => e.type === "app") && (t = r.packageId);
|
|
2369
2435
|
}
|
|
2370
2436
|
}
|
|
2371
|
-
let r =
|
|
2437
|
+
let r = wt.current, i = !1;
|
|
2372
2438
|
for (let t of e.keys()) r.has(t) || (r.add(t), i = !0);
|
|
2373
|
-
i &&
|
|
2374
|
-
}, [n,
|
|
2375
|
-
let
|
|
2439
|
+
i && se([...e.values()], t);
|
|
2440
|
+
}, [n, se]);
|
|
2441
|
+
let Et = e.useRef(/* @__PURE__ */ new Set());
|
|
2376
2442
|
e.useEffect(() => {
|
|
2377
|
-
if (
|
|
2443
|
+
if (V) for (let e of n) for (let t of e.toolInvocations ?? []) {
|
|
2378
2444
|
let e = t.draftReview;
|
|
2379
2445
|
if (!e?.materialized || !t.toolCallId) continue;
|
|
2380
2446
|
let n = e.items.find((e) => e.type === "app");
|
|
2381
|
-
!n ||
|
|
2447
|
+
!n || Et.current.has(t.toolCallId) || (Et.current.add(t.toolCallId), V(n.name));
|
|
2382
2448
|
}
|
|
2383
|
-
}, [n,
|
|
2384
|
-
let
|
|
2449
|
+
}, [n, V]);
|
|
2450
|
+
let Dt = e.useCallback((e) => {
|
|
2385
2451
|
let t = !!e.text?.trim(), n = e.files?.map((e) => e.file).filter(Boolean), r = !!(n && n.length > 0);
|
|
2386
2452
|
if (!(t || r)) return;
|
|
2387
2453
|
let a = e.text?.trim() ?? "";
|
|
2388
|
-
|
|
2389
|
-
}, [i]),
|
|
2390
|
-
|
|
2391
|
-
}, [i]),
|
|
2392
|
-
t && (
|
|
2454
|
+
ot.current = a, st.current = null, Mt.current = null, i?.(a, n);
|
|
2455
|
+
}, [i]), Ot = e.useCallback((e) => {
|
|
2456
|
+
Mt.current = null, i?.(e);
|
|
2457
|
+
}, [i]), kt = e.useRef(null), [At, jt] = e.useState(() => /* @__PURE__ */ new Set()), Mt = e.useRef(null), Nt = e.useCallback((e, t) => {
|
|
2458
|
+
t && (Mt.current = t, jt((e) => {
|
|
2393
2459
|
let n = new Set(e);
|
|
2394
2460
|
return n.add(t), n;
|
|
2395
|
-
})), i?.(e ?
|
|
2461
|
+
})), i?.(e ? Ee : Te);
|
|
2396
2462
|
}, [
|
|
2397
2463
|
i,
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
]),
|
|
2401
|
-
|
|
2464
|
+
Te,
|
|
2465
|
+
Ee
|
|
2466
|
+
]), [Pt, Ft] = e.useState(() => /* @__PURE__ */ new Set()), It = e.useRef(null), Lt = e.useCallback((e) => {
|
|
2467
|
+
e && (It.current = e, Ft((t) => {
|
|
2468
|
+
let n = new Set(t);
|
|
2469
|
+
return n.add(e), n;
|
|
2470
|
+
})), i?.(Ne);
|
|
2471
|
+
}, [i, Ne]), Rt = e.useCallback(() => {
|
|
2472
|
+
let e = kt.current?.querySelector("textarea");
|
|
2402
2473
|
e && (e.focus(), e.scrollIntoView({ block: "nearest" }));
|
|
2403
2474
|
}, []);
|
|
2404
2475
|
e.useEffect(() => {
|
|
2405
|
-
if (!f || !
|
|
2406
|
-
if (
|
|
2407
|
-
let e =
|
|
2408
|
-
|
|
2476
|
+
if (!f || !pr(f) || st.current === f) return;
|
|
2477
|
+
if (st.current = f, Mt.current) {
|
|
2478
|
+
let e = Mt.current;
|
|
2479
|
+
Mt.current = null, jt((t) => {
|
|
2409
2480
|
if (!t.has(e)) return t;
|
|
2410
2481
|
let n = new Set(t);
|
|
2411
2482
|
return n.delete(e), n;
|
|
2412
2483
|
});
|
|
2413
2484
|
}
|
|
2414
|
-
|
|
2485
|
+
if (It.current) {
|
|
2486
|
+
let e = It.current;
|
|
2487
|
+
It.current = null, Ft((t) => {
|
|
2488
|
+
if (!t.has(e)) return t;
|
|
2489
|
+
let n = new Set(t);
|
|
2490
|
+
return n.delete(e), n;
|
|
2491
|
+
});
|
|
2492
|
+
}
|
|
2493
|
+
let e = ot.current;
|
|
2415
2494
|
if (!e) return;
|
|
2416
|
-
let t =
|
|
2495
|
+
let t = kt.current?.querySelector("textarea");
|
|
2417
2496
|
t && t.value.trim() === "" && (t.value = e, t.dispatchEvent(new Event("input", { bubbles: !0 })), t.focus());
|
|
2418
2497
|
}, [f]);
|
|
2419
|
-
let
|
|
2420
|
-
navigator.clipboard?.writeText(e.content),
|
|
2421
|
-
}, []),
|
|
2498
|
+
let zt = e.useCallback((e) => {
|
|
2499
|
+
navigator.clipboard?.writeText(e.content), at(e.id), window.setTimeout(() => at((t) => t === e.id ? null : t), 1500);
|
|
2500
|
+
}, []), Bt = e.useMemo(() => {
|
|
2422
2501
|
let e = /* @__PURE__ */ new Set(), t = [], r = -1, i = 0;
|
|
2423
|
-
for (let e of n) for (let n of e.toolInvocations ?? []) (n.proposedPlan ||
|
|
2502
|
+
for (let e of n) for (let n of e.toolInvocations ?? []) (n.proposedPlan || ga(n)) && n.toolCallId && t.push({
|
|
2424
2503
|
id: n.toolCallId,
|
|
2425
2504
|
order: i
|
|
2426
2505
|
}), n.toolName === "apply_blueprint" && (r = i), i += 1;
|
|
2427
2506
|
for (let n of t) n.order < r && e.add(n.id);
|
|
2428
2507
|
return e;
|
|
2429
|
-
}, [n]),
|
|
2508
|
+
}, [n]), Vt = e.useMemo(() => {
|
|
2430
2509
|
let e;
|
|
2431
2510
|
for (let t of n) for (let n of t.toolInvocations ?? []) n.builderHandoff && n.toolCallId && (e = n.toolCallId);
|
|
2432
2511
|
return e;
|
|
2433
|
-
}, [n]),
|
|
2512
|
+
}, [n]), Ht = e.useMemo(() => {
|
|
2434
2513
|
let e = /* @__PURE__ */ new Set(), t = [], r = /* @__PURE__ */ new Map(), i = 0;
|
|
2435
2514
|
for (let e of n) for (let n of e.toolInvocations ?? []) n.proposedChanges && n.toolCallId ? t.push({
|
|
2436
2515
|
id: n.toolCallId,
|
|
@@ -2442,8 +2521,27 @@ var ya = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2442
2521
|
t !== void 0 && t > n.order && e.add(n.id);
|
|
2443
2522
|
}
|
|
2444
2523
|
return e;
|
|
2445
|
-
}, [n]),
|
|
2446
|
-
let
|
|
2524
|
+
}, [n]), Ut = e.useMemo(() => {
|
|
2525
|
+
let e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Map(), r = [], i = 0;
|
|
2526
|
+
for (let a of n) for (let n of a.toolInvocations ?? []) {
|
|
2527
|
+
if (n.proposedChanges && n.toolCallId) r.push({
|
|
2528
|
+
id: n.toolCallId,
|
|
2529
|
+
toolName: n.toolName ?? "",
|
|
2530
|
+
order: i
|
|
2531
|
+
}), t.delete(n.toolCallId);
|
|
2532
|
+
else if (n.toolCallId?.startsWith("replay_")) {
|
|
2533
|
+
let a;
|
|
2534
|
+
for (let e of r) e.order < i && e.toolName === (n.toolName ?? "") && (a = e);
|
|
2535
|
+
a && (n.replayOutcome ? (e.set(a.id, n.replayOutcome), n.replayOutcome.dispatchError ? t.set(a.id, i) : t.delete(a.id)) : n.result === void 0 && !n.errorText && e.set(a.id, { kind: "applying" }));
|
|
2536
|
+
} else if (n.result !== void 0 && t.size > 0) {
|
|
2537
|
+
let r = Zt(n.result);
|
|
2538
|
+
if (r) for (let [n, a] of t) i > a && e.set(n, r);
|
|
2539
|
+
}
|
|
2540
|
+
i += 1;
|
|
2541
|
+
}
|
|
2542
|
+
return e;
|
|
2543
|
+
}, [n]), Wt = (e) => {
|
|
2544
|
+
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 = or(e.toolName), c = sr(e.result), l = K === "debug" && s && s.toLowerCase() !== e.toolName.toLowerCase(), u = K === "debug" || a, d = e.draftReview?.packageId, f = d === void 0 ? void 0 : vt.get(d), p = f === void 0 ? ct.has(e.toolCallId) : f === 0, m = t === "input-streaming" || t === "input-available", h = t === "output-available" && da(e.result) ? "approval-requested" : t, g = /* @__PURE__ */ Q("span", {
|
|
2447
2545
|
className: "inline-flex min-w-0 items-center gap-2",
|
|
2448
2546
|
children: [
|
|
2449
2547
|
/* @__PURE__ */ Z("span", { children: s || e.toolName }),
|
|
@@ -2451,22 +2549,22 @@ var ya = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2451
2549
|
className: "rounded bg-muted px-1 py-px text-[10px] font-mono text-muted-foreground",
|
|
2452
2550
|
children: e.toolName
|
|
2453
2551
|
}) : null,
|
|
2454
|
-
m ?
|
|
2455
|
-
label:
|
|
2456
|
-
hints:
|
|
2457
|
-
offlineLabel:
|
|
2458
|
-
}) : /* @__PURE__ */ Z(
|
|
2552
|
+
m ? ha(e) ? /* @__PURE__ */ Z(Ia, {
|
|
2553
|
+
label: q.designingPlanLabel,
|
|
2554
|
+
hints: q.designingPlanHints,
|
|
2555
|
+
offlineLabel: q.connectionOfflineLabel
|
|
2556
|
+
}) : /* @__PURE__ */ Z(La, { offlineLabel: q.connectionOfflineLabel }) : null
|
|
2459
2557
|
]
|
|
2460
2558
|
});
|
|
2461
|
-
return /* @__PURE__ */ Q(
|
|
2462
|
-
defaultOpen: t === "output-error" || t === "approval-requested" || !!(e.draftReview && e.draftReview.items.length > 0) || !!e.proposedPlan || !!e.proposedChanges || !!e.builderHandoff ||
|
|
2463
|
-
children: [/* @__PURE__ */ Z(
|
|
2559
|
+
return /* @__PURE__ */ Q(Ui, {
|
|
2560
|
+
defaultOpen: t === "output-error" || t === "approval-requested" || !!(e.draftReview && e.draftReview.items.length > 0) || !!e.proposedPlan || !!e.proposedChanges || !!e.builderHandoff || ga(e),
|
|
2561
|
+
children: [/* @__PURE__ */ Z(Gi, {
|
|
2464
2562
|
type: n,
|
|
2465
2563
|
state: h,
|
|
2466
2564
|
title: g
|
|
2467
|
-
}), /* @__PURE__ */ Q(
|
|
2468
|
-
u && e.args !== void 0 ? /* @__PURE__ */ Z(
|
|
2469
|
-
o ? null : u || t === "output-error" ? /* @__PURE__ */ Z(
|
|
2565
|
+
}), /* @__PURE__ */ Q(Ki, { children: [
|
|
2566
|
+
u && e.args !== void 0 ? /* @__PURE__ */ Z(qi, { input: e.args }) : null,
|
|
2567
|
+
o ? null : u || t === "output-error" ? /* @__PURE__ */ Z(qa, {
|
|
2470
2568
|
output: c,
|
|
2471
2569
|
errorText: e.errorText
|
|
2472
2570
|
}) : null,
|
|
@@ -2498,18 +2596,18 @@ var ya = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2498
2596
|
L && e.draftReview.packageId ? p ? /* @__PURE__ */ Q("span", {
|
|
2499
2597
|
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",
|
|
2500
2598
|
children: [
|
|
2501
|
-
/* @__PURE__ */ Z(
|
|
2502
|
-
|
|
2599
|
+
/* @__PURE__ */ Z(G, { className: "size-3.5" }),
|
|
2600
|
+
le,
|
|
2503
2601
|
e.draftReview.failedCount ? ` · ${e.draftReview.failedCount} need${e.draftReview.failedCount === 1 ? "s" : ""} attention` : ""
|
|
2504
2602
|
]
|
|
2505
2603
|
}) : /* @__PURE__ */ Q("button", {
|
|
2506
2604
|
type: "button",
|
|
2507
|
-
onClick: () => void
|
|
2605
|
+
onClick: () => void Y(e.draftReview.packageId),
|
|
2508
2606
|
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",
|
|
2509
2607
|
"data-testid": "draft-publish",
|
|
2510
2608
|
children: [
|
|
2511
|
-
/* @__PURE__ */ Z(
|
|
2512
|
-
|
|
2609
|
+
/* @__PURE__ */ Z(dt, { className: "size-3.5" }),
|
|
2610
|
+
ce,
|
|
2513
2611
|
typeof f == "number" && f > 0 ? ` (${f})` : ""
|
|
2514
2612
|
]
|
|
2515
2613
|
}) : null,
|
|
@@ -2517,7 +2615,7 @@ var ya = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2517
2615
|
type: "button",
|
|
2518
2616
|
onClick: () => te(e.draftReview.items),
|
|
2519
2617
|
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",
|
|
2520
|
-
children: [/* @__PURE__ */ Z(
|
|
2618
|
+
children: [/* @__PURE__ */ Z($e, { className: "size-3.5" }), ne(e.draftReview.items.length)]
|
|
2521
2619
|
}) : null,
|
|
2522
2620
|
z && !p ? (() => {
|
|
2523
2621
|
let t = e.draftReview.items.find((e) => e.type === "app");
|
|
@@ -2529,17 +2627,17 @@ var ya = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2529
2627
|
}),
|
|
2530
2628
|
className: "inline-flex h-7 items-center gap-1.5 rounded-md border px-3 text-xs font-medium hover:bg-muted",
|
|
2531
2629
|
"data-testid": "draft-preview-app",
|
|
2532
|
-
children: [/* @__PURE__ */ Z(
|
|
2630
|
+
children: [/* @__PURE__ */ Z(Qe, { className: "size-3.5" }), B]
|
|
2533
2631
|
}) : null;
|
|
2534
2632
|
})() : null,
|
|
2535
2633
|
e.draftReview.verification ? e.draftReview.verification.errors > 0 ? /* @__PURE__ */ Q("span", {
|
|
2536
2634
|
className: "inline-flex h-7 shrink-0 items-center gap-1.5 rounded-md border border-amber-200 bg-amber-50 px-2.5 text-xs font-medium text-amber-700",
|
|
2537
2635
|
"data-testid": "draft-verification-chip",
|
|
2538
|
-
children: [/* @__PURE__ */ Z(
|
|
2636
|
+
children: [/* @__PURE__ */ Z(_t, { className: "size-3.5" }), `${e.draftReview.verification.errors} issue${e.draftReview.verification.errors === 1 ? "" : "s"}`]
|
|
2539
2637
|
}) : /* @__PURE__ */ Q("span", {
|
|
2540
2638
|
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",
|
|
2541
2639
|
"data-testid": "draft-verification-chip",
|
|
2542
|
-
children: [/* @__PURE__ */ Z(
|
|
2640
|
+
children: [/* @__PURE__ */ Z(pt, { className: "size-3.5" }), ue]
|
|
2543
2641
|
}) : null,
|
|
2544
2642
|
e.draftReview.summary ? /* @__PURE__ */ Z("span", {
|
|
2545
2643
|
className: "min-w-0 flex-1 truncate text-xs text-muted-foreground",
|
|
@@ -2552,19 +2650,19 @@ var ya = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2552
2650
|
"data-testid": "draft-issues",
|
|
2553
2651
|
children: [e.draftReview.issues.filter((e) => e.severity === "error").map((e, t) => /* @__PURE__ */ Q("div", {
|
|
2554
2652
|
className: "flex items-start gap-1.5 text-xs text-red-600",
|
|
2555
|
-
children: [/* @__PURE__ */ Z(
|
|
2653
|
+
children: [/* @__PURE__ */ Z(J, { className: "mt-0.5 size-3.5 shrink-0" }), /* @__PURE__ */ Z("span", { children: e.fix ? `${e.message} — ${e.fix}` : e.message })]
|
|
2556
2654
|
}, `e${t}`)), e.draftReview.issues.filter((e) => e.severity !== "error").map((e, t) => /* @__PURE__ */ Q("div", {
|
|
2557
2655
|
className: "flex items-start gap-1.5 text-xs text-amber-600",
|
|
2558
|
-
children: [/* @__PURE__ */ Z(
|
|
2656
|
+
children: [/* @__PURE__ */ Z(Me, { className: "mt-0.5 size-3.5 shrink-0" }), /* @__PURE__ */ Z("span", { children: e.message })]
|
|
2559
2657
|
}, `w${t}`))]
|
|
2560
2658
|
}) : null,
|
|
2561
|
-
|
|
2659
|
+
ct.has(e.toolCallId) ? /* @__PURE__ */ Z(Ca, { health: ft.get(e.toolCallId) }) : null,
|
|
2562
2660
|
e.draftReview.nextSteps && e.draftReview.nextSteps.length > 0 ? /* @__PURE__ */ Q("div", {
|
|
2563
2661
|
className: "flex flex-col gap-1 border-t bg-muted/20 px-3 py-2",
|
|
2564
2662
|
"data-testid": "draft-next-steps",
|
|
2565
2663
|
children: [/* @__PURE__ */ Z("span", {
|
|
2566
2664
|
className: "text-xs font-medium text-foreground/80",
|
|
2567
|
-
children:
|
|
2665
|
+
children: de
|
|
2568
2666
|
}), e.draftReview.nextSteps.map((e, t) => /* @__PURE__ */ Q("div", {
|
|
2569
2667
|
className: "flex items-start gap-1.5 text-xs text-muted-foreground",
|
|
2570
2668
|
children: [/* @__PURE__ */ Z("span", {
|
|
@@ -2580,22 +2678,22 @@ var ya = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2580
2678
|
children: [
|
|
2581
2679
|
/* @__PURE__ */ Q("span", {
|
|
2582
2680
|
className: "inline-flex items-center gap-1.5 text-xs font-medium text-foreground/80",
|
|
2583
|
-
children: [/* @__PURE__ */ Z(
|
|
2681
|
+
children: [/* @__PURE__ */ Z(mt, { className: "size-3.5" }), pe]
|
|
2584
2682
|
}),
|
|
2585
2683
|
/* @__PURE__ */ Z("p", {
|
|
2586
2684
|
className: "text-xs text-muted-foreground",
|
|
2587
2685
|
children: e.builderHandoff.prompt
|
|
2588
2686
|
}),
|
|
2589
2687
|
(() => {
|
|
2590
|
-
let t = !!
|
|
2688
|
+
let t = !!Vt && e.toolCallId !== Vt;
|
|
2591
2689
|
return /* @__PURE__ */ Z("button", {
|
|
2592
2690
|
type: "button",
|
|
2593
|
-
onClick: () =>
|
|
2594
|
-
disabled: !
|
|
2691
|
+
onClick: () => ge?.(e.builderHandoff),
|
|
2692
|
+
disabled: !ge || t,
|
|
2595
2693
|
"data-testid": t ? "builder-handoff-superseded" : "builder-handoff-open",
|
|
2596
|
-
title: t ?
|
|
2694
|
+
title: t ? he : void 0,
|
|
2597
2695
|
className: "inline-flex w-fit items-center gap-1 rounded-md bg-primary px-2.5 py-1 text-xs font-medium text-primary-foreground transition-colors hover:bg-primary/90 disabled:cursor-not-allowed disabled:opacity-50",
|
|
2598
|
-
children:
|
|
2696
|
+
children: me
|
|
2599
2697
|
});
|
|
2600
2698
|
})()
|
|
2601
2699
|
]
|
|
@@ -2606,14 +2704,14 @@ var ya = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2606
2704
|
children: [
|
|
2607
2705
|
/* @__PURE__ */ Q("span", {
|
|
2608
2706
|
className: "inline-flex items-center gap-1.5 text-xs font-medium text-foreground/80",
|
|
2609
|
-
children: [/* @__PURE__ */ Z(
|
|
2707
|
+
children: [/* @__PURE__ */ Z(We, { className: "size-3.5" }), fe]
|
|
2610
2708
|
}),
|
|
2611
2709
|
e.proposedPlan.targetApp ? /* @__PURE__ */ Q("span", {
|
|
2612
2710
|
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",
|
|
2613
2711
|
"data-testid": "proposed-plan-extend",
|
|
2614
2712
|
children: [
|
|
2615
2713
|
"+ ",
|
|
2616
|
-
|
|
2714
|
+
_e,
|
|
2617
2715
|
" \"",
|
|
2618
2716
|
e.proposedPlan.targetApp,
|
|
2619
2717
|
"\""
|
|
@@ -2629,7 +2727,7 @@ var ya = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2629
2727
|
className: "inline-flex items-center gap-1 rounded-md border bg-background px-1.5 py-0.5 text-[11px] text-foreground/80",
|
|
2630
2728
|
title: e.name,
|
|
2631
2729
|
children: [
|
|
2632
|
-
/* @__PURE__ */ Z(
|
|
2730
|
+
/* @__PURE__ */ Z(gt, { className: "size-3 text-foreground/40" }),
|
|
2633
2731
|
e.label || e.name,
|
|
2634
2732
|
e.fieldCount > 0 ? /* @__PURE__ */ Q("span", {
|
|
2635
2733
|
className: "text-foreground/40",
|
|
@@ -2646,13 +2744,13 @@ var ya = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2646
2744
|
}) : null;
|
|
2647
2745
|
})(),
|
|
2648
2746
|
(() => {
|
|
2649
|
-
let { designNotes: t, deferred: n } =
|
|
2747
|
+
let { designNotes: t, deferred: n } = va(e.proposedPlan.assumptions);
|
|
2650
2748
|
return /* @__PURE__ */ Q(X, { children: [t.length > 0 ? /* @__PURE__ */ Q("div", {
|
|
2651
2749
|
className: "flex flex-col gap-0.5",
|
|
2652
2750
|
"data-testid": "proposed-plan-assumptions",
|
|
2653
2751
|
children: [/* @__PURE__ */ Z("span", {
|
|
2654
2752
|
className: "text-[11px] font-medium text-foreground/70",
|
|
2655
|
-
children:
|
|
2753
|
+
children: ye
|
|
2656
2754
|
}), t.map((e, t) => /* @__PURE__ */ Q("div", {
|
|
2657
2755
|
className: "flex items-start gap-1.5 text-[11px] text-muted-foreground",
|
|
2658
2756
|
children: [/* @__PURE__ */ Z("span", {
|
|
@@ -2665,7 +2763,7 @@ var ya = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2665
2763
|
"data-testid": "proposed-plan-deferred",
|
|
2666
2764
|
children: [/* @__PURE__ */ Q("span", {
|
|
2667
2765
|
className: "inline-flex items-center gap-1.5 text-[11px] font-medium text-amber-800 dark:text-amber-300",
|
|
2668
|
-
children: [/* @__PURE__ */ Z(
|
|
2766
|
+
children: [/* @__PURE__ */ Z(tt, { className: "size-3.5" }), be]
|
|
2669
2767
|
}), n.map((e, t) => /* @__PURE__ */ Q("div", {
|
|
2670
2768
|
className: "flex items-start gap-1.5 text-[11px] text-amber-900/90 dark:text-amber-200/90",
|
|
2671
2769
|
children: [/* @__PURE__ */ Z("span", {
|
|
@@ -2680,7 +2778,7 @@ var ya = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2680
2778
|
"data-testid": "proposed-plan-questions",
|
|
2681
2779
|
children: [/* @__PURE__ */ Q("span", {
|
|
2682
2780
|
className: "inline-flex items-center gap-1.5 text-[11px] font-medium text-amber-800 dark:text-amber-300",
|
|
2683
|
-
children: [/* @__PURE__ */ Z(
|
|
2781
|
+
children: [/* @__PURE__ */ Z(et, { className: "size-3.5" }), ve]
|
|
2684
2782
|
}), e.proposedPlan.questions.map((t, n) => {
|
|
2685
2783
|
let r = e.proposedPlan.questionChoices?.find((e) => e.text === t);
|
|
2686
2784
|
return /* @__PURE__ */ Q("div", {
|
|
@@ -2696,7 +2794,7 @@ var ya = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2696
2794
|
"data-testid": "proposed-plan-choice",
|
|
2697
2795
|
children: r.options.map((e, n) => /* @__PURE__ */ Z("button", {
|
|
2698
2796
|
type: "button",
|
|
2699
|
-
onClick: () => i(
|
|
2797
|
+
onClick: () => i(De(t, e)),
|
|
2700
2798
|
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",
|
|
2701
2799
|
children: e
|
|
2702
2800
|
}, n))
|
|
@@ -2704,91 +2802,91 @@ var ya = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2704
2802
|
}, n);
|
|
2705
2803
|
})]
|
|
2706
2804
|
}) : null,
|
|
2707
|
-
i ?
|
|
2805
|
+
i ? Bt.has(e.toolCallId) ? /* @__PURE__ */ Z("div", {
|
|
2708
2806
|
className: "flex flex-wrap items-center gap-1.5 pt-0.5",
|
|
2709
2807
|
"data-testid": "proposed-plan-actions",
|
|
2710
2808
|
children: /* @__PURE__ */ Q("span", {
|
|
2711
2809
|
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",
|
|
2712
2810
|
"data-testid": "proposed-plan-built",
|
|
2713
|
-
children: [/* @__PURE__ */ Z(
|
|
2811
|
+
children: [/* @__PURE__ */ Z(G, { className: "size-3.5" }), Se]
|
|
2714
2812
|
})
|
|
2715
|
-
}) :
|
|
2813
|
+
}) : At.has(e.toolCallId) ? /* @__PURE__ */ Z("div", {
|
|
2716
2814
|
className: "flex flex-wrap items-center gap-1.5 pt-0.5",
|
|
2717
2815
|
"data-testid": "proposed-plan-actions",
|
|
2718
2816
|
children: /* @__PURE__ */ Q("span", {
|
|
2719
2817
|
className: "inline-flex h-7 items-center gap-1.5 rounded-md border bg-muted/40 px-3 text-xs font-medium text-muted-foreground",
|
|
2720
2818
|
"data-testid": "proposed-plan-building",
|
|
2721
|
-
children: [/* @__PURE__ */ Z(
|
|
2819
|
+
children: [/* @__PURE__ */ Z(it, { className: "size-3.5 animate-spin" }), Ce]
|
|
2722
2820
|
})
|
|
2723
2821
|
}) : /* @__PURE__ */ Q("div", {
|
|
2724
2822
|
className: "flex flex-wrap items-center gap-1.5 pt-0.5",
|
|
2725
2823
|
"data-testid": "proposed-plan-actions",
|
|
2726
2824
|
children: [/* @__PURE__ */ Q("button", {
|
|
2727
2825
|
type: "button",
|
|
2728
|
-
onClick: () =>
|
|
2826
|
+
onClick: () => Nt(e.proposedPlan.questions.length > 0, e.toolCallId),
|
|
2729
2827
|
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",
|
|
2730
2828
|
"data-testid": "proposed-plan-approve",
|
|
2731
|
-
children: [/* @__PURE__ */ Z(
|
|
2829
|
+
children: [/* @__PURE__ */ Z(dt, { className: "size-3.5" }), H]
|
|
2732
2830
|
}), /* @__PURE__ */ Z("button", {
|
|
2733
2831
|
type: "button",
|
|
2734
|
-
onClick:
|
|
2832
|
+
onClick: Rt,
|
|
2735
2833
|
className: "inline-flex h-7 items-center rounded-md border bg-background px-3 text-xs font-medium hover:bg-accent",
|
|
2736
2834
|
"data-testid": "proposed-plan-adjust",
|
|
2737
|
-
children:
|
|
2835
|
+
children: U
|
|
2738
2836
|
})]
|
|
2739
2837
|
}) : /* @__PURE__ */ Z("span", {
|
|
2740
2838
|
className: "text-[11px] italic text-muted-foreground/80",
|
|
2741
|
-
children:
|
|
2839
|
+
children: xe
|
|
2742
2840
|
})
|
|
2743
2841
|
]
|
|
2744
2842
|
}) : null,
|
|
2745
|
-
|
|
2843
|
+
ga(e) ? /* @__PURE__ */ Q("div", {
|
|
2746
2844
|
className: "flex flex-col gap-2 border-t bg-muted/20 px-3 py-2.5",
|
|
2747
2845
|
"data-testid": "proposed-plan-fallback",
|
|
2748
2846
|
children: [
|
|
2749
2847
|
/* @__PURE__ */ Q("span", {
|
|
2750
2848
|
className: "inline-flex items-center gap-1.5 text-xs font-medium text-foreground/80",
|
|
2751
|
-
children: [/* @__PURE__ */ Z(
|
|
2849
|
+
children: [/* @__PURE__ */ Z(We, { className: "size-3.5" }), fe]
|
|
2752
2850
|
}),
|
|
2753
2851
|
/* @__PURE__ */ Z("p", {
|
|
2754
2852
|
className: "text-xs text-muted-foreground",
|
|
2755
|
-
children:
|
|
2853
|
+
children: we
|
|
2756
2854
|
}),
|
|
2757
|
-
i ?
|
|
2855
|
+
i ? Bt.has(e.toolCallId) ? /* @__PURE__ */ Z("div", {
|
|
2758
2856
|
className: "flex flex-wrap items-center gap-1.5 pt-0.5",
|
|
2759
2857
|
"data-testid": "proposed-plan-actions",
|
|
2760
2858
|
children: /* @__PURE__ */ Q("span", {
|
|
2761
2859
|
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",
|
|
2762
2860
|
"data-testid": "proposed-plan-built",
|
|
2763
|
-
children: [/* @__PURE__ */ Z(
|
|
2861
|
+
children: [/* @__PURE__ */ Z(G, { className: "size-3.5" }), Se]
|
|
2764
2862
|
})
|
|
2765
|
-
}) :
|
|
2863
|
+
}) : At.has(e.toolCallId) ? /* @__PURE__ */ Z("div", {
|
|
2766
2864
|
className: "flex flex-wrap items-center gap-1.5 pt-0.5",
|
|
2767
2865
|
"data-testid": "proposed-plan-actions",
|
|
2768
2866
|
children: /* @__PURE__ */ Q("span", {
|
|
2769
2867
|
className: "inline-flex h-7 items-center gap-1.5 rounded-md border bg-muted/40 px-3 text-xs font-medium text-muted-foreground",
|
|
2770
2868
|
"data-testid": "proposed-plan-building",
|
|
2771
|
-
children: [/* @__PURE__ */ Z(
|
|
2869
|
+
children: [/* @__PURE__ */ Z(it, { className: "size-3.5 animate-spin" }), Ce]
|
|
2772
2870
|
})
|
|
2773
2871
|
}) : /* @__PURE__ */ Q("div", {
|
|
2774
2872
|
className: "flex flex-wrap items-center gap-1.5 pt-0.5",
|
|
2775
2873
|
"data-testid": "proposed-plan-actions",
|
|
2776
2874
|
children: [/* @__PURE__ */ Q("button", {
|
|
2777
2875
|
type: "button",
|
|
2778
|
-
onClick: () =>
|
|
2876
|
+
onClick: () => Nt(!1, e.toolCallId),
|
|
2779
2877
|
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",
|
|
2780
2878
|
"data-testid": "proposed-plan-approve",
|
|
2781
|
-
children: [/* @__PURE__ */ Z(
|
|
2879
|
+
children: [/* @__PURE__ */ Z(dt, { className: "size-3.5" }), H]
|
|
2782
2880
|
}), /* @__PURE__ */ Z("button", {
|
|
2783
2881
|
type: "button",
|
|
2784
|
-
onClick:
|
|
2882
|
+
onClick: Rt,
|
|
2785
2883
|
className: "inline-flex h-7 items-center rounded-md border bg-background px-3 text-xs font-medium hover:bg-accent",
|
|
2786
2884
|
"data-testid": "proposed-plan-adjust",
|
|
2787
|
-
children:
|
|
2885
|
+
children: U
|
|
2788
2886
|
})]
|
|
2789
2887
|
}) : /* @__PURE__ */ Z("span", {
|
|
2790
2888
|
className: "text-[11px] italic text-muted-foreground/80",
|
|
2791
|
-
children:
|
|
2889
|
+
children: xe
|
|
2792
2890
|
})
|
|
2793
2891
|
]
|
|
2794
2892
|
}) : null,
|
|
@@ -2798,7 +2896,7 @@ var ya = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2798
2896
|
children: [
|
|
2799
2897
|
/* @__PURE__ */ Q("span", {
|
|
2800
2898
|
className: "inline-flex items-center gap-1.5 text-xs font-medium text-foreground/80",
|
|
2801
|
-
children: [/* @__PURE__ */ Z(
|
|
2899
|
+
children: [/* @__PURE__ */ Z(We, { className: "size-3.5" }), Oe]
|
|
2802
2900
|
}),
|
|
2803
2901
|
e.proposedChanges.summary ? /* @__PURE__ */ Z("p", {
|
|
2804
2902
|
className: "text-xs text-muted-foreground",
|
|
@@ -2808,66 +2906,111 @@ var ya = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2808
2906
|
className: "flex flex-col gap-1",
|
|
2809
2907
|
children: e.proposedChanges.changes.map((e, t) => /* @__PURE__ */ Q("div", {
|
|
2810
2908
|
className: "flex items-start gap-1.5 rounded-md border bg-background px-2 py-1 text-[11px] text-foreground/80",
|
|
2811
|
-
children: [/* @__PURE__ */ Z(
|
|
2909
|
+
children: [/* @__PURE__ */ Z(gt, { className: "mt-px size-3 shrink-0 text-foreground/40" }), /* @__PURE__ */ Z("span", { children: ma(e, Pe) })]
|
|
2812
2910
|
}, t))
|
|
2813
2911
|
}),
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
"
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
|
|
2820
|
-
|
|
2821
|
-
|
|
2822
|
-
|
|
2823
|
-
|
|
2824
|
-
"
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
|
|
2912
|
+
(() => {
|
|
2913
|
+
let t = Ut.get(e.toolCallId);
|
|
2914
|
+
return t?.kind === "published" ? /* @__PURE__ */ Z("div", {
|
|
2915
|
+
className: "flex flex-wrap items-center gap-1.5 pt-0.5",
|
|
2916
|
+
"data-testid": "proposed-changes-actions",
|
|
2917
|
+
children: /* @__PURE__ */ Q("span", {
|
|
2918
|
+
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",
|
|
2919
|
+
"data-testid": "proposed-changes-applied",
|
|
2920
|
+
children: [/* @__PURE__ */ Z(G, { className: "size-3.5" }), Le]
|
|
2921
|
+
})
|
|
2922
|
+
}) : t?.kind === "failed" ? /* @__PURE__ */ Q("div", {
|
|
2923
|
+
className: "flex flex-col gap-1 pt-0.5",
|
|
2924
|
+
"data-testid": "proposed-changes-actions",
|
|
2925
|
+
children: [/* @__PURE__ */ Q("span", {
|
|
2926
|
+
className: "inline-flex h-7 w-fit items-center gap-1.5 rounded-md border border-red-200 bg-red-50 px-3 text-xs font-medium text-red-700 dark:border-red-900/50 dark:bg-red-950/30 dark:text-red-300",
|
|
2927
|
+
"data-testid": "proposed-changes-failed",
|
|
2928
|
+
children: [/* @__PURE__ */ Z(J, { className: "size-3.5" }), Be]
|
|
2929
|
+
}), t.error ? /* @__PURE__ */ Z("span", {
|
|
2930
|
+
className: "text-[11px] text-red-700/80 dark:text-red-300/80",
|
|
2931
|
+
"data-testid": "proposed-changes-failed-reason",
|
|
2932
|
+
children: t.error
|
|
2933
|
+
}) : null]
|
|
2934
|
+
}) : t?.kind === "drafted" ? /* @__PURE__ */ Q("div", {
|
|
2935
|
+
className: "flex flex-wrap items-center gap-1.5 pt-0.5",
|
|
2936
|
+
"data-testid": "proposed-changes-actions",
|
|
2937
|
+
children: [/* @__PURE__ */ Q("span", {
|
|
2938
|
+
className: "inline-flex h-7 items-center gap-1.5 rounded-md border border-amber-200 bg-amber-50 px-3 text-xs font-medium text-amber-800 dark:border-amber-900/50 dark:bg-amber-950/30 dark:text-amber-300",
|
|
2939
|
+
"data-testid": "proposed-changes-drafted",
|
|
2940
|
+
children: [/* @__PURE__ */ Z(Ke, { className: "size-3.5" }), ze]
|
|
2941
|
+
}), L && t.packageId ? /* @__PURE__ */ Q("button", {
|
|
2942
|
+
type: "button",
|
|
2943
|
+
onClick: () => void Y(t.packageId),
|
|
2944
|
+
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",
|
|
2945
|
+
"data-testid": "proposed-changes-publish",
|
|
2946
|
+
children: [/* @__PURE__ */ Z(dt, { className: "size-3.5" }), ce]
|
|
2947
|
+
}) : null]
|
|
2948
|
+
}) : t?.kind === "applying" || Pt.has(e.toolCallId) ? /* @__PURE__ */ Z("div", {
|
|
2949
|
+
className: "flex flex-wrap items-center gap-1.5 pt-0.5",
|
|
2950
|
+
"data-testid": "proposed-changes-actions",
|
|
2951
|
+
children: /* @__PURE__ */ Q("span", {
|
|
2952
|
+
className: "inline-flex h-7 items-center gap-1.5 rounded-md border bg-muted/40 px-3 text-xs font-medium text-foreground/70",
|
|
2953
|
+
"data-testid": "proposed-changes-applying",
|
|
2954
|
+
children: [/* @__PURE__ */ Z(it, { className: "size-3.5 animate-spin" }), Fe]
|
|
2955
|
+
})
|
|
2956
|
+
}) : i ? Ht.has(e.toolCallId) ? /* @__PURE__ */ Z("div", {
|
|
2957
|
+
className: "flex flex-wrap items-center gap-1.5 pt-0.5",
|
|
2958
|
+
"data-testid": "proposed-changes-actions",
|
|
2959
|
+
children: /* @__PURE__ */ Q("span", {
|
|
2960
|
+
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",
|
|
2961
|
+
"data-testid": "proposed-changes-confirmed",
|
|
2962
|
+
children: [/* @__PURE__ */ Z(G, { className: "size-3.5" }), ke]
|
|
2963
|
+
})
|
|
2964
|
+
}) : /* @__PURE__ */ Q("div", {
|
|
2965
|
+
className: "flex flex-wrap items-center gap-1.5 pt-0.5",
|
|
2966
|
+
"data-testid": "proposed-changes-actions",
|
|
2967
|
+
children: [/* @__PURE__ */ Q("button", {
|
|
2968
|
+
type: "button",
|
|
2969
|
+
onClick: () => Lt(e.toolCallId),
|
|
2970
|
+
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",
|
|
2971
|
+
"data-testid": "proposed-changes-confirm",
|
|
2972
|
+
children: [/* @__PURE__ */ Z(G, { className: "size-3.5" }), Ae]
|
|
2973
|
+
}), /* @__PURE__ */ Z("button", {
|
|
2974
|
+
type: "button",
|
|
2975
|
+
onClick: Rt,
|
|
2976
|
+
className: "inline-flex h-7 items-center rounded-md border bg-background px-3 text-xs font-medium hover:bg-accent",
|
|
2977
|
+
"data-testid": "proposed-changes-adjust",
|
|
2978
|
+
children: U
|
|
2979
|
+
})]
|
|
2980
|
+
}) : /* @__PURE__ */ Z("span", {
|
|
2981
|
+
className: "text-[11px] italic text-muted-foreground/80",
|
|
2982
|
+
children: je
|
|
2983
|
+
});
|
|
2984
|
+
})()
|
|
2842
2985
|
]
|
|
2843
2986
|
}) : null
|
|
2844
2987
|
] })]
|
|
2845
2988
|
}, e.toolCallId);
|
|
2846
2989
|
};
|
|
2847
2990
|
return /* @__PURE__ */ Q("div", {
|
|
2848
|
-
ref:
|
|
2849
|
-
className:
|
|
2991
|
+
ref: Ye,
|
|
2992
|
+
className: W(nt ? "flex min-h-0 flex-col overflow-hidden bg-background" : "flex min-h-0 flex-col overflow-hidden rounded-lg border bg-background", t),
|
|
2850
2993
|
style: { maxHeight: b },
|
|
2851
|
-
...
|
|
2994
|
+
...qe,
|
|
2852
2995
|
children: [
|
|
2853
2996
|
a && !y && n.length > 0 && /* @__PURE__ */ Z("div", {
|
|
2854
|
-
className:
|
|
2997
|
+
className: W("flex items-center justify-end px-4 py-2", nt ? "bg-background" : "border-b bg-muted/30"),
|
|
2855
2998
|
children: /* @__PURE__ */ Z("button", {
|
|
2856
2999
|
type: "button",
|
|
2857
3000
|
onClick: a,
|
|
2858
3001
|
className: "text-xs text-muted-foreground hover:text-foreground transition-colors",
|
|
2859
|
-
children:
|
|
3002
|
+
children: q.clear
|
|
2860
3003
|
})
|
|
2861
3004
|
}),
|
|
2862
3005
|
A ? /* @__PURE__ */ Z("div", {
|
|
2863
|
-
className:
|
|
3006
|
+
className: W("shrink-0", !nt && "border-b bg-background/50"),
|
|
2864
3007
|
children: A
|
|
2865
3008
|
}) : null,
|
|
2866
|
-
/* @__PURE__ */ Q(
|
|
3009
|
+
/* @__PURE__ */ Q(gr, {
|
|
2867
3010
|
className: "flex-1 min-h-0",
|
|
2868
|
-
children: [/* @__PURE__ */ Q(
|
|
2869
|
-
className:
|
|
2870
|
-
children: [n.length === 0 ? /* @__PURE__ */ Q(
|
|
3011
|
+
children: [/* @__PURE__ */ Q(_r, {
|
|
3012
|
+
className: W("space-y-4", nt ? "mx-auto w-full max-w-2xl px-4 py-8 sm:px-0" : "px-4 py-3"),
|
|
3013
|
+
children: [n.length === 0 ? /* @__PURE__ */ Q(vr, {
|
|
2871
3014
|
className: "gap-3 px-0 py-8",
|
|
2872
3015
|
children: [
|
|
2873
3016
|
/* @__PURE__ */ Z("div", {
|
|
@@ -2876,49 +3019,49 @@ var ya = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2876
3019
|
src: _,
|
|
2877
3020
|
alt: "",
|
|
2878
3021
|
className: "size-full rounded-md object-cover"
|
|
2879
|
-
}) : /* @__PURE__ */ Z(
|
|
3022
|
+
}) : /* @__PURE__ */ Z(Ie, { className: "size-4" })
|
|
2880
3023
|
}),
|
|
2881
3024
|
/* @__PURE__ */ Q("div", {
|
|
2882
3025
|
className: "w-full max-w-full space-y-1",
|
|
2883
3026
|
children: [/* @__PURE__ */ Z("h3", {
|
|
2884
3027
|
className: "text-sm font-medium text-foreground/90 break-words",
|
|
2885
|
-
children:
|
|
3028
|
+
children: q.emptyTitle
|
|
2886
3029
|
}), /* @__PURE__ */ Z("p", {
|
|
2887
3030
|
className: "text-sm text-muted-foreground break-words",
|
|
2888
|
-
children:
|
|
3031
|
+
children: q.emptyDescription
|
|
2889
3032
|
})]
|
|
2890
3033
|
}),
|
|
2891
3034
|
T && T.length > 0 ? /* @__PURE__ */ Z("div", {
|
|
2892
3035
|
className: "flex w-full max-w-full flex-wrap justify-center gap-2",
|
|
2893
|
-
children: T.map((e) => /* @__PURE__ */ Z(
|
|
3036
|
+
children: T.map((e) => /* @__PURE__ */ Z(Li, {
|
|
2894
3037
|
className: "h-auto min-h-8 min-w-0 max-w-full whitespace-normal break-words rounded-full border-border/60 bg-background/80 px-3 py-1 text-left text-xs font-medium text-foreground/90 shadow-none hover:bg-muted/60",
|
|
2895
3038
|
suggestion: e,
|
|
2896
|
-
onClick:
|
|
3039
|
+
onClick: Ot
|
|
2897
3040
|
}, e))
|
|
2898
3041
|
}) : null
|
|
2899
3042
|
]
|
|
2900
3043
|
}) : n.map((e) => {
|
|
2901
|
-
let t = e.role === "user", n = e.toolInvocations ?? [], r = e.reasoning?.trim(), i = e.sources ?? [], a = t ? void 0 : e.buildProgress, o = !t && !n.some((e) => !!e.proposedPlan) ? e.blueprintProgress : void 0, c = !t &&
|
|
2902
|
-
return /* @__PURE__ */ Z(
|
|
2903
|
-
from:
|
|
3044
|
+
let t = e.role === "user", n = e.toolInvocations ?? [], r = e.reasoning?.trim(), i = e.sources ?? [], a = t ? void 0 : e.buildProgress, o = !t && !n.some((e) => !!e.proposedPlan) ? e.blueprintProgress : void 0, c = !t && K === "summary" ? n.filter((e) => !ya(e) && !(o && e.toolName === "propose_blueprint")) : [], l = !t && K === "debug" ? n : !t && K !== "debug" ? n.filter(ya) : [], u = !t && e.content.trim().length > 0 && !xa(e.content), d = K === "debug" && !!r, f = !t && !!e.streaming && !u && c.length === 0 && l.length === 0 && !d && !a && !o;
|
|
3045
|
+
return /* @__PURE__ */ Z(Cr, {
|
|
3046
|
+
from: la(e.role),
|
|
2904
3047
|
children: /* @__PURE__ */ Q("div", {
|
|
2905
|
-
className:
|
|
2906
|
-
children: [m ? /* @__PURE__ */ Z(
|
|
3048
|
+
className: W("flex w-full gap-2.5", m ? t ? "flex-row-reverse items-start" : "flex-row items-start" : "flex-col"),
|
|
3049
|
+
children: [m ? /* @__PURE__ */ Z(Ta, {
|
|
2907
3050
|
isUser: t,
|
|
2908
3051
|
url: t ? h : _,
|
|
2909
3052
|
fallback: t ? g : v
|
|
2910
3053
|
}) : null, /* @__PURE__ */ Q("div", {
|
|
2911
|
-
className:
|
|
2912
|
-
children: [/* @__PURE__ */ Q(
|
|
2913
|
-
o ? /* @__PURE__ */ Z(
|
|
3054
|
+
className: W("flex min-w-0 flex-col gap-2", m && !t && "flex-1"),
|
|
3055
|
+
children: [/* @__PURE__ */ Q(wr, { children: [
|
|
3056
|
+
o ? /* @__PURE__ */ Z(Ba, {
|
|
2914
3057
|
progress: o,
|
|
2915
|
-
designingLabel:
|
|
2916
|
-
extendLabel:
|
|
2917
|
-
waitingLabel:
|
|
2918
|
-
stalledLabel:
|
|
2919
|
-
offlineLabel:
|
|
3058
|
+
designingLabel: q.designingPlanLabel,
|
|
3059
|
+
extendLabel: _e,
|
|
3060
|
+
waitingLabel: q.connectionWaiting,
|
|
3061
|
+
stalledLabel: q.connectionStalledLabel,
|
|
3062
|
+
offlineLabel: q.connectionOfflineLabel
|
|
2920
3063
|
}) : null,
|
|
2921
|
-
a ? /* @__PURE__ */ Z(
|
|
3064
|
+
a ? /* @__PURE__ */ Z(Va, {
|
|
2922
3065
|
progress: a,
|
|
2923
3066
|
appSegment: e.toolInvocations?.map((e) => e.draftReview).find((e) => e?.packageId && e.items?.some((e) => e.type === "app"))?.packageId,
|
|
2924
3067
|
onOpenBuiltApp: re,
|
|
@@ -2928,27 +3071,27 @@ var ya = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2928
3071
|
getArtifactAction: oe,
|
|
2929
3072
|
onPreviewDraftApp: z,
|
|
2930
3073
|
previewDraftLabel: B,
|
|
2931
|
-
waitingLabel:
|
|
2932
|
-
stalledLabel:
|
|
2933
|
-
offlineLabel:
|
|
3074
|
+
waitingLabel: q.connectionWaiting,
|
|
3075
|
+
stalledLabel: q.connectionStalledLabel,
|
|
3076
|
+
offlineLabel: q.connectionOfflineLabel
|
|
2934
3077
|
}) : null,
|
|
2935
|
-
!t &&
|
|
3078
|
+
!t && K === "debug" && r ? /* @__PURE__ */ Q(ea, {
|
|
2936
3079
|
isStreaming: !!e.streaming && !e.content,
|
|
2937
3080
|
className: "mb-2",
|
|
2938
|
-
children: [/* @__PURE__ */ Z(
|
|
3081
|
+
children: [/* @__PURE__ */ Z(na, {}), /* @__PURE__ */ Z(ra, { children: r })]
|
|
2939
3082
|
}) : null,
|
|
2940
|
-
!t &&
|
|
2941
|
-
groups:
|
|
2942
|
-
labels:
|
|
3083
|
+
!t && K === "summary" && c.length > 0 ? /* @__PURE__ */ Z(Ha, {
|
|
3084
|
+
groups: Sa(c),
|
|
3085
|
+
labels: q
|
|
2943
3086
|
}) : null,
|
|
2944
|
-
!t && l.length > 0 ? l.map(
|
|
3087
|
+
!t && l.length > 0 ? l.map(Wt) : null,
|
|
2945
3088
|
t ? e.content ? /* @__PURE__ */ Z("div", {
|
|
2946
3089
|
className: "whitespace-pre-wrap break-words",
|
|
2947
3090
|
children: e.content
|
|
2948
|
-
}) : null : f ? /* @__PURE__ */ Z(
|
|
3091
|
+
}) : null : f ? /* @__PURE__ */ Z(Da, {}) : u ? /* @__PURE__ */ Z(Fr, { children: e.content }) : !e.streaming && xa(e.content) ? /* @__PURE__ */ Z("span", {
|
|
2949
3092
|
className: "text-xs italic text-muted-foreground/70",
|
|
2950
3093
|
title: e.content,
|
|
2951
|
-
children:
|
|
3094
|
+
children: q.agentActivity
|
|
2952
3095
|
}) : null,
|
|
2953
3096
|
e.streaming && u ? /* @__PURE__ */ Z("span", {
|
|
2954
3097
|
"aria-hidden": !0,
|
|
@@ -2973,7 +3116,7 @@ var ya = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2973
3116
|
} })]
|
|
2974
3117
|
}, t))
|
|
2975
3118
|
}) : null,
|
|
2976
|
-
!t && i.length > 0 ? /* @__PURE__ */ Q(
|
|
3119
|
+
!t && i.length > 0 ? /* @__PURE__ */ Q(ia, { children: [/* @__PURE__ */ Z(aa, { count: i.length }), /* @__PURE__ */ Z(oa, { children: i.map((e, t) => /* @__PURE__ */ Z(sa, {
|
|
2977
3120
|
href: e.url,
|
|
2978
3121
|
title: e.title ?? e.url
|
|
2979
3122
|
}, e.id ?? e.url ?? t)) })] }) : null,
|
|
@@ -2981,133 +3124,144 @@ var ya = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2981
3124
|
className: "text-[10px] opacity-70 mt-1",
|
|
2982
3125
|
children: e.timestamp
|
|
2983
3126
|
}) : null
|
|
2984
|
-
] }), !t && !f ? /* @__PURE__ */ Q(
|
|
3127
|
+
] }), !t && !f ? /* @__PURE__ */ Q(Tr, {
|
|
2985
3128
|
className: "opacity-0 transition-opacity group-focus-within:opacity-100 group-hover:opacity-100",
|
|
2986
3129
|
children: [
|
|
2987
|
-
/* @__PURE__ */ Z(
|
|
2988
|
-
label:
|
|
2989
|
-
tooltip:
|
|
2990
|
-
onClick: () =>
|
|
2991
|
-
children:
|
|
3130
|
+
/* @__PURE__ */ Z(Er, {
|
|
3131
|
+
label: rt === e.id ? q.copied : q.copy,
|
|
3132
|
+
tooltip: rt === e.id ? q.copied : q.copy,
|
|
3133
|
+
onClick: () => zt(e),
|
|
3134
|
+
children: rt === e.id ? /* @__PURE__ */ Z(Re, { className: "size-3.5" }) : /* @__PURE__ */ Z(Je, { className: "size-3.5" })
|
|
2992
3135
|
}),
|
|
2993
|
-
s ? /* @__PURE__ */ Z(
|
|
2994
|
-
label:
|
|
2995
|
-
tooltip:
|
|
3136
|
+
s ? /* @__PURE__ */ Z(Er, {
|
|
3137
|
+
label: q.regenerate,
|
|
3138
|
+
tooltip: q.regenerate,
|
|
2996
3139
|
onClick: s,
|
|
2997
|
-
children: /* @__PURE__ */ Z(
|
|
3140
|
+
children: /* @__PURE__ */ Z(ut, { className: "size-3.5" })
|
|
2998
3141
|
}) : null,
|
|
2999
|
-
|
|
3142
|
+
K === "debug" && e.traceId ? /* @__PURE__ */ Z("a", {
|
|
3000
3143
|
href: `#trace/${e.traceId}`,
|
|
3001
3144
|
"data-trace-id": e.traceId,
|
|
3002
3145
|
className: "text-[10px] text-muted-foreground hover:text-foreground ml-1 underline",
|
|
3003
|
-
title:
|
|
3004
|
-
children:
|
|
3146
|
+
title: q.viewTrace,
|
|
3147
|
+
children: q.trace
|
|
3005
3148
|
}) : null
|
|
3006
3149
|
]
|
|
3007
3150
|
}) : null]
|
|
3008
3151
|
})]
|
|
3009
3152
|
})
|
|
3010
3153
|
}, e.id);
|
|
3011
|
-
}), d && !n.some((e) => e.streaming) ? /* @__PURE__ */ Z(
|
|
3154
|
+
}), d && !n.some((e) => e.streaming) ? /* @__PURE__ */ Z(Ea, {
|
|
3012
3155
|
showAvatar: m,
|
|
3013
3156
|
assistantAvatarUrl: _,
|
|
3014
3157
|
assistantAvatarFallback: v,
|
|
3015
|
-
waitingLabel:
|
|
3016
|
-
stalledLabel:
|
|
3017
|
-
offlineLabel:
|
|
3158
|
+
waitingLabel: q.connectionWaiting,
|
|
3159
|
+
stalledLabel: q.connectionStalledLabel,
|
|
3160
|
+
offlineLabel: q.connectionOfflineLabel
|
|
3018
3161
|
}) : null]
|
|
3019
|
-
}), /* @__PURE__ */ Z(
|
|
3162
|
+
}), /* @__PURE__ */ Z(yr, {})]
|
|
3020
3163
|
}),
|
|
3021
|
-
f ?
|
|
3164
|
+
f ? pr(f) && !fr(f) ? /* @__PURE__ */ Z(Ga, {
|
|
3022
3165
|
error: f,
|
|
3023
|
-
rateLimitedLabel:
|
|
3024
|
-
genericLabel:
|
|
3025
|
-
}) : /* @__PURE__ */ Z(
|
|
3166
|
+
rateLimitedLabel: q.sendFailedRateLimited,
|
|
3167
|
+
genericLabel: q.sendFailedGeneric
|
|
3168
|
+
}) : /* @__PURE__ */ Z(Ka, {
|
|
3026
3169
|
error: f,
|
|
3027
3170
|
onReload: s,
|
|
3028
3171
|
onUpgrade: c
|
|
3029
3172
|
}) : null,
|
|
3030
3173
|
u ? null : /* @__PURE__ */ Q("div", {
|
|
3031
|
-
ref:
|
|
3032
|
-
className:
|
|
3033
|
-
children: [
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
|
|
3037
|
-
|
|
3038
|
-
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
|
|
3043
|
-
|
|
3044
|
-
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
|
|
3052
|
-
|
|
3053
|
-
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
|
|
3057
|
-
|
|
3058
|
-
|
|
3059
|
-
|
|
3060
|
-
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
|
|
3064
|
-
|
|
3065
|
-
|
|
3066
|
-
|
|
3067
|
-
className: "
|
|
3068
|
-
children:
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
|
|
3073
|
-
|
|
3074
|
-
|
|
3075
|
-
|
|
3076
|
-
|
|
3077
|
-
|
|
3078
|
-
|
|
3079
|
-
|
|
3174
|
+
ref: kt,
|
|
3175
|
+
className: W("relative", nt && "mx-auto w-full max-w-2xl px-4 pb-4 sm:px-0"),
|
|
3176
|
+
children: [
|
|
3177
|
+
Ve ? /* @__PURE__ */ Z("div", {
|
|
3178
|
+
className: "mb-1 flex",
|
|
3179
|
+
"data-testid": "surface-context-chip",
|
|
3180
|
+
children: /* @__PURE__ */ Z("span", {
|
|
3181
|
+
className: "inline-flex items-center gap-1 rounded-full border bg-muted/40 px-2 py-0.5 text-[11px] text-muted-foreground",
|
|
3182
|
+
children: Ve
|
|
3183
|
+
})
|
|
3184
|
+
}) : null,
|
|
3185
|
+
j ? /* @__PURE__ */ Z("div", {
|
|
3186
|
+
className: "absolute bottom-full left-0 right-0 z-10 px-3 pb-1",
|
|
3187
|
+
children: j
|
|
3188
|
+
}) : null,
|
|
3189
|
+
/* @__PURE__ */ Q(ri, {
|
|
3190
|
+
accept: C,
|
|
3191
|
+
fileInputLabel: q.uploadFiles,
|
|
3192
|
+
maxFileSize: w,
|
|
3193
|
+
onSubmit: Dt,
|
|
3194
|
+
onError: (e) => {
|
|
3195
|
+
console.warn("[plugin-chatbot] prompt-input error", e);
|
|
3196
|
+
},
|
|
3197
|
+
children: [
|
|
3198
|
+
S ? /* @__PURE__ */ Z(ii, { children: /* @__PURE__ */ Z(ti, { children: (e) => /* @__PURE__ */ Z(ei, { data: e }) }) }) : null,
|
|
3199
|
+
/* @__PURE__ */ Z(ai, {
|
|
3200
|
+
placeholder: r,
|
|
3201
|
+
disabled: l || Ze === "streaming",
|
|
3202
|
+
onChange: M ? (e) => M(e.currentTarget.value) : void 0
|
|
3203
|
+
}),
|
|
3204
|
+
/* @__PURE__ */ Q(si, { children: [/* @__PURE__ */ Q(ci, { children: [
|
|
3205
|
+
S ? /* @__PURE__ */ Q(ui, { children: [/* @__PURE__ */ Z(di, {}), /* @__PURE__ */ Z(fi, { children: /* @__PURE__ */ Z(ni, {}) })] }) : null,
|
|
3206
|
+
D && D.length > 1 ? /* @__PURE__ */ Z("select", {
|
|
3207
|
+
"aria-label": q.model,
|
|
3208
|
+
value: O ?? D[0].id,
|
|
3209
|
+
onChange: (e) => k?.(e.target.value),
|
|
3210
|
+
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",
|
|
3211
|
+
children: D.map((e) => /* @__PURE__ */ Q("option", {
|
|
3212
|
+
value: e.id,
|
|
3213
|
+
children: [e.label ?? e.id, e.provider ? ` · ${e.provider}` : ""]
|
|
3214
|
+
}, e.id))
|
|
3215
|
+
}) : null,
|
|
3216
|
+
/* @__PURE__ */ Q("span", {
|
|
3217
|
+
className: "hidden items-center gap-1 text-[10px] text-muted-foreground sm:inline-flex",
|
|
3218
|
+
"aria-hidden": "true",
|
|
3219
|
+
children: [/* @__PURE__ */ Z(Xe, { className: "h-3 w-3" }), /* @__PURE__ */ Z("span", {
|
|
3220
|
+
className: "opacity-70",
|
|
3221
|
+
children: q.sendHint
|
|
3222
|
+
})]
|
|
3223
|
+
})
|
|
3224
|
+
] }), /* @__PURE__ */ Z(mi, {
|
|
3225
|
+
"aria-label": Ze === "streaming" ? q.stopResponse : q.submit,
|
|
3226
|
+
status: Ze,
|
|
3227
|
+
disabled: l,
|
|
3228
|
+
onClick: Ze === "streaming" ? o : void 0,
|
|
3229
|
+
type: Ze === "streaming" ? "button" : "submit"
|
|
3230
|
+
})] })
|
|
3231
|
+
]
|
|
3232
|
+
})
|
|
3233
|
+
]
|
|
3080
3234
|
})
|
|
3081
3235
|
]
|
|
3082
3236
|
});
|
|
3083
3237
|
});
|
|
3084
|
-
|
|
3085
|
-
function
|
|
3238
|
+
wa.displayName = "ChatbotEnhanced";
|
|
3239
|
+
function Ta({ isUser: e, url: t, fallback: n }) {
|
|
3086
3240
|
return /* @__PURE__ */ Z("div", {
|
|
3087
|
-
className:
|
|
3241
|
+
className: W("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"),
|
|
3088
3242
|
"aria-hidden": "true",
|
|
3089
3243
|
children: t ? /* @__PURE__ */ Z("img", {
|
|
3090
3244
|
src: t,
|
|
3091
3245
|
alt: "",
|
|
3092
3246
|
className: "size-full object-cover"
|
|
3093
|
-
}) : e ? n?.trim()?.charAt(0)?.toUpperCase() || "U" : /* @__PURE__ */ Z(
|
|
3247
|
+
}) : e ? n?.trim()?.charAt(0)?.toUpperCase() || "U" : /* @__PURE__ */ Z(Ie, { className: "size-4" })
|
|
3094
3248
|
});
|
|
3095
3249
|
}
|
|
3096
|
-
function
|
|
3097
|
-
return /* @__PURE__ */ Z(
|
|
3250
|
+
function Ea({ showAvatar: e, assistantAvatarUrl: t, assistantAvatarFallback: n, waitingLabel: r, stalledLabel: i, offlineLabel: a }) {
|
|
3251
|
+
return /* @__PURE__ */ Z(Cr, {
|
|
3098
3252
|
from: "assistant",
|
|
3099
3253
|
"aria-live": "polite",
|
|
3100
3254
|
children: /* @__PURE__ */ Q("div", {
|
|
3101
|
-
className:
|
|
3102
|
-
children: [e ? /* @__PURE__ */ Z(
|
|
3255
|
+
className: W("flex w-full gap-2.5", e ? "flex-row items-start" : "flex-col"),
|
|
3256
|
+
children: [e ? /* @__PURE__ */ Z(Ta, {
|
|
3103
3257
|
isUser: !1,
|
|
3104
3258
|
url: t,
|
|
3105
3259
|
fallback: n
|
|
3106
|
-
}) : null, /* @__PURE__ */ Z(
|
|
3260
|
+
}) : null, /* @__PURE__ */ Z(wr, {
|
|
3107
3261
|
className: "rounded-lg border bg-muted/30 px-3 py-2 text-muted-foreground",
|
|
3108
3262
|
children: /* @__PURE__ */ Q("span", {
|
|
3109
3263
|
className: "inline-flex items-center gap-2",
|
|
3110
|
-
children: [/* @__PURE__ */ Z(
|
|
3264
|
+
children: [/* @__PURE__ */ Z(Da, {}), /* @__PURE__ */ Z(Ma, {
|
|
3111
3265
|
active: !0,
|
|
3112
3266
|
pending: !0,
|
|
3113
3267
|
activityKey: 0,
|
|
@@ -3120,7 +3274,7 @@ function xa({ showAvatar: e, assistantAvatarUrl: t, assistantAvatarFallback: n,
|
|
|
3120
3274
|
})
|
|
3121
3275
|
});
|
|
3122
3276
|
}
|
|
3123
|
-
function
|
|
3277
|
+
function Da() {
|
|
3124
3278
|
return /* @__PURE__ */ Q(X, { children: [/* @__PURE__ */ Z("span", {
|
|
3125
3279
|
className: "sr-only",
|
|
3126
3280
|
children: "Assistant is responding"
|
|
@@ -3134,12 +3288,12 @@ function Sa() {
|
|
|
3134
3288
|
]
|
|
3135
3289
|
})] });
|
|
3136
3290
|
}
|
|
3137
|
-
function
|
|
3291
|
+
function Oa(e) {
|
|
3138
3292
|
let t = Math.floor(e / 60), n = e % 60;
|
|
3139
3293
|
return `${t}:${String(n).padStart(2, "0")}`;
|
|
3140
3294
|
}
|
|
3141
|
-
var
|
|
3142
|
-
function
|
|
3295
|
+
var ka = 6;
|
|
3296
|
+
function Aa(t, n) {
|
|
3143
3297
|
let r = e.useRef(0), i = e.useRef(0), [a, o] = e.useState({
|
|
3144
3298
|
elapsed: 0,
|
|
3145
3299
|
quiet: 0
|
|
@@ -3168,10 +3322,10 @@ function Ta(t, n) {
|
|
|
3168
3322
|
}, [t]), {
|
|
3169
3323
|
elapsedSeconds: a.elapsed,
|
|
3170
3324
|
quietSeconds: a.quiet,
|
|
3171
|
-
live: a.quiet <
|
|
3325
|
+
live: a.quiet < ka
|
|
3172
3326
|
};
|
|
3173
3327
|
}
|
|
3174
|
-
function
|
|
3328
|
+
function ja() {
|
|
3175
3329
|
let [t, n] = e.useState(() => typeof navigator < "u" && navigator.onLine === !1);
|
|
3176
3330
|
return e.useEffect(() => {
|
|
3177
3331
|
if (typeof window > "u") return;
|
|
@@ -3181,22 +3335,22 @@ function Ea() {
|
|
|
3181
3335
|
};
|
|
3182
3336
|
}, []), t;
|
|
3183
3337
|
}
|
|
3184
|
-
function
|
|
3185
|
-
let { elapsedSeconds: o, quietSeconds: s, live: c } =
|
|
3338
|
+
function Ma({ active: e, activityKey: t, pending: n = !1, waitingLabel: r, stalledLabel: i = "Still working…", offlineLabel: a = "Connection lost — reconnecting…" }) {
|
|
3339
|
+
let { elapsedSeconds: o, quietSeconds: s, live: c } = Aa(e, t), l = ja() ? "offline" : c ? n ? "waiting" : "receiving" : "stalled", u = Oa(o);
|
|
3186
3340
|
return /* @__PURE__ */ Q("span", {
|
|
3187
|
-
className:
|
|
3341
|
+
className: W("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"),
|
|
3188
3342
|
"aria-live": "polite",
|
|
3189
3343
|
"data-liveness-tier": l,
|
|
3190
3344
|
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`,
|
|
3191
3345
|
children: [
|
|
3192
|
-
l === "offline" ? /* @__PURE__ */ Z(
|
|
3346
|
+
l === "offline" ? /* @__PURE__ */ Z(vt, {
|
|
3193
3347
|
className: "size-3 shrink-0",
|
|
3194
3348
|
"aria-hidden": !0
|
|
3195
3349
|
}) : /* @__PURE__ */ Z("span", {
|
|
3196
3350
|
"aria-hidden": !0,
|
|
3197
|
-
className:
|
|
3351
|
+
className: W("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")
|
|
3198
3352
|
}),
|
|
3199
|
-
/* @__PURE__ */ Z(
|
|
3353
|
+
/* @__PURE__ */ Z(Ke, {
|
|
3200
3354
|
className: "size-3 shrink-0",
|
|
3201
3355
|
"aria-hidden": !0
|
|
3202
3356
|
}),
|
|
@@ -3205,7 +3359,7 @@ function Da({ active: e, activityKey: t, pending: n = !1, waitingLabel: r, stall
|
|
|
3205
3359
|
]
|
|
3206
3360
|
});
|
|
3207
3361
|
}
|
|
3208
|
-
var
|
|
3362
|
+
var Na = [
|
|
3209
3363
|
"Mapping out the data you’ll track…",
|
|
3210
3364
|
"Shaping objects and their fields…",
|
|
3211
3365
|
"Connecting related records…",
|
|
@@ -3216,27 +3370,27 @@ var Oa = [
|
|
|
3216
3370
|
"Sketching a dashboard to track it…",
|
|
3217
3371
|
"Double-checking the structure hangs together…",
|
|
3218
3372
|
"Pulling the plan together…"
|
|
3219
|
-
],
|
|
3220
|
-
function
|
|
3373
|
+
], Pa = 3500;
|
|
3374
|
+
function Fa(e, t, n = Pa) {
|
|
3221
3375
|
if (t <= 0) return -1;
|
|
3222
3376
|
if (t === 1) return 0;
|
|
3223
|
-
let r = Math.floor((Number.isFinite(e) && e > 0 ? e : 0) / (n > 0 ? n :
|
|
3377
|
+
let r = Math.floor((Number.isFinite(e) && e > 0 ? e : 0) / (n > 0 ? n : Pa));
|
|
3224
3378
|
return Math.min(r, t - 1);
|
|
3225
3379
|
}
|
|
3226
|
-
function
|
|
3380
|
+
function Ia({ label: t, hints: n, offlineLabel: r }) {
|
|
3227
3381
|
let [i, a] = e.useState(0);
|
|
3228
3382
|
e.useEffect(() => {
|
|
3229
3383
|
if (n.length <= 1) return;
|
|
3230
|
-
let e = Date.now(), t = setInterval(() => a(Date.now() - e),
|
|
3384
|
+
let e = Date.now(), t = setInterval(() => a(Date.now() - e), Pa);
|
|
3231
3385
|
return () => clearInterval(t);
|
|
3232
3386
|
}, [n.length]);
|
|
3233
|
-
let o =
|
|
3387
|
+
let o = Fa(i, n.length), s = o >= 0 ? n[o] : void 0, c = n.length > 1 && n.length <= 12;
|
|
3234
3388
|
return /* @__PURE__ */ Q("span", {
|
|
3235
3389
|
className: "inline-flex min-w-0 items-center gap-1.5 text-xs text-muted-foreground",
|
|
3236
3390
|
"data-testid": "build-proposal-progress",
|
|
3237
3391
|
"aria-live": "polite",
|
|
3238
3392
|
children: [
|
|
3239
|
-
/* @__PURE__ */ Z(
|
|
3393
|
+
/* @__PURE__ */ Z(mt, {
|
|
3240
3394
|
className: "size-3 shrink-0 animate-pulse text-primary",
|
|
3241
3395
|
"aria-hidden": !0
|
|
3242
3396
|
}),
|
|
@@ -3252,45 +3406,45 @@ function ja({ label: t, hints: n, offlineLabel: r }) {
|
|
|
3252
3406
|
className: "hidden shrink-0 items-center gap-0.5 sm:inline-flex",
|
|
3253
3407
|
"data-testid": "build-proposal-progress-dots",
|
|
3254
3408
|
"aria-hidden": !0,
|
|
3255
|
-
children: n.map((e, t) => /* @__PURE__ */ Z("span", { className:
|
|
3409
|
+
children: n.map((e, t) => /* @__PURE__ */ Z("span", { className: W("size-1 rounded-full transition-colors", t <= o ? "bg-primary/70" : "bg-muted-foreground/25") }, t))
|
|
3256
3410
|
}) : null,
|
|
3257
|
-
/* @__PURE__ */ Z(
|
|
3411
|
+
/* @__PURE__ */ Z(La, { offlineLabel: r })
|
|
3258
3412
|
]
|
|
3259
3413
|
});
|
|
3260
3414
|
}
|
|
3261
|
-
function
|
|
3262
|
-
let [n, r] = e.useState(0), i =
|
|
3415
|
+
function La({ offlineLabel: t }) {
|
|
3416
|
+
let [n, r] = e.useState(0), i = ja();
|
|
3263
3417
|
return e.useEffect(() => {
|
|
3264
3418
|
let e = Date.now(), t = setInterval(() => r(Math.floor((Date.now() - e) / 1e3)), 1e3);
|
|
3265
3419
|
return () => clearInterval(t);
|
|
3266
3420
|
}, []), /* @__PURE__ */ Q("span", {
|
|
3267
|
-
className:
|
|
3421
|
+
className: W("inline-flex items-center gap-1 text-xs tabular-nums", i ? "text-red-600 font-medium" : "text-muted-foreground"),
|
|
3268
3422
|
"aria-live": "polite",
|
|
3269
3423
|
"data-tool-running-timer": !0,
|
|
3270
3424
|
children: [
|
|
3271
|
-
Z(i ?
|
|
3425
|
+
Z(i ? vt : Ke, {
|
|
3272
3426
|
className: "size-3 shrink-0",
|
|
3273
3427
|
"aria-hidden": !0
|
|
3274
3428
|
}),
|
|
3275
|
-
/* @__PURE__ */ Z("span", { children:
|
|
3429
|
+
/* @__PURE__ */ Z("span", { children: Oa(n) }),
|
|
3276
3430
|
i ? /* @__PURE__ */ Q("span", { children: ["· ", t] }) : null
|
|
3277
3431
|
]
|
|
3278
3432
|
});
|
|
3279
3433
|
}
|
|
3280
|
-
var
|
|
3434
|
+
var Ra = [
|
|
3281
3435
|
"object",
|
|
3282
3436
|
"view",
|
|
3283
3437
|
"dashboard",
|
|
3284
3438
|
"app",
|
|
3285
3439
|
"seed"
|
|
3286
|
-
],
|
|
3440
|
+
], za = {
|
|
3287
3441
|
object: "Objects",
|
|
3288
3442
|
view: "Views",
|
|
3289
3443
|
dashboard: "Dashboards",
|
|
3290
3444
|
app: "App",
|
|
3291
3445
|
seed: "Sample data"
|
|
3292
3446
|
};
|
|
3293
|
-
function
|
|
3447
|
+
function Ba({ progress: e, designingLabel: t = "Designing your app…", extendLabel: n = "Adding to existing app", waitingLabel: r = "Waiting for server…", stalledLabel: i = "Still working…", offlineLabel: a = "Connection lost — reconnecting…" }) {
|
|
3294
3448
|
let { phase: o, summary: s, appLabel: c, targetApp: l, objects: u, counts: d, seq: f } = e, p = o === "done", m = f ?? `${o}:${u.length}`, h = p && (s || c) || t, g = [];
|
|
3295
3449
|
return d?.objects && g.push(`${d.objects} object${d.objects === 1 ? "" : "s"}`), d?.views && g.push(`${d.views} view${d.views === 1 ? "" : "s"}`), d?.dashboards && g.push(`${d.dashboards} dashboard${d.dashboards === 1 ? "" : "s"}`), /* @__PURE__ */ Q("div", {
|
|
3296
3450
|
className: "rounded-lg border bg-muted/30 p-3 text-sm",
|
|
@@ -3299,7 +3453,7 @@ function Fa({ progress: e, designingLabel: t = "Designing your app…", extendLa
|
|
|
3299
3453
|
/* @__PURE__ */ Q("div", {
|
|
3300
3454
|
className: "mb-2 flex items-center gap-2 font-medium",
|
|
3301
3455
|
children: [
|
|
3302
|
-
p ? /* @__PURE__ */ Z(
|
|
3456
|
+
p ? /* @__PURE__ */ Z(G, { className: "size-4 shrink-0 text-emerald-600" }) : /* @__PURE__ */ Z(it, { className: "size-4 shrink-0 animate-spin text-primary" }),
|
|
3303
3457
|
/* @__PURE__ */ Z("span", {
|
|
3304
3458
|
className: "min-w-0 truncate",
|
|
3305
3459
|
children: h
|
|
@@ -3317,7 +3471,7 @@ function Fa({ progress: e, designingLabel: t = "Designing your app…", extendLa
|
|
|
3317
3471
|
}) : null,
|
|
3318
3472
|
p ? null : /* @__PURE__ */ Z("span", {
|
|
3319
3473
|
className: "ml-auto shrink-0",
|
|
3320
|
-
children: /* @__PURE__ */ Z(
|
|
3474
|
+
children: /* @__PURE__ */ Z(Ma, {
|
|
3321
3475
|
active: !0,
|
|
3322
3476
|
activityKey: m,
|
|
3323
3477
|
waitingLabel: r,
|
|
@@ -3338,7 +3492,7 @@ function Fa({ progress: e, designingLabel: t = "Designing your app…", extendLa
|
|
|
3338
3492
|
className: "inline-flex animate-in fade-in items-center gap-1 rounded-md border bg-background px-1.5 py-0.5 text-[11px] text-foreground/80 duration-500",
|
|
3339
3493
|
title: e.name,
|
|
3340
3494
|
children: [
|
|
3341
|
-
/* @__PURE__ */ Z(
|
|
3495
|
+
/* @__PURE__ */ Z(gt, { className: "size-3 text-foreground/40" }),
|
|
3342
3496
|
e.label || e.name,
|
|
3343
3497
|
e.fields ? /* @__PURE__ */ Q("span", {
|
|
3344
3498
|
className: "text-foreground/40",
|
|
@@ -3354,7 +3508,7 @@ function Fa({ progress: e, designingLabel: t = "Designing your app…", extendLa
|
|
|
3354
3508
|
]
|
|
3355
3509
|
});
|
|
3356
3510
|
}
|
|
3357
|
-
function
|
|
3511
|
+
function Va({ progress: t, appSegment: n, onOpenBuiltApp: r, openBuiltAppLabel: i = "Open app", onDesignBuiltApp: a, designBuiltAppLabel: o = "Design in Studio", getArtifactAction: s, onPreviewDraftApp: c, previewDraftLabel: l = "Preview", waitingLabel: u = "Waiting for server…", stalledLabel: d = "Still working…", offlineLabel: f = "Connection lost — reconnecting…" }) {
|
|
3358
3512
|
let { phase: p, appLabel: m, items: h, done: g, total: _, seq: v } = t, y = p === "done", b = v ?? `${p}:${g}:${h.length}`, x = h.find((e) => e.type === "app"), S = _ > 0 ? Math.min(100, Math.round(g / _ * 100)) : y ? 100 : 6, C = /* @__PURE__ */ new Map();
|
|
3359
3513
|
for (let e of h) {
|
|
3360
3514
|
let t = C.get(e.type) ?? [];
|
|
@@ -3363,7 +3517,7 @@ function Ia({ progress: t, appSegment: n, onOpenBuiltApp: r, openBuiltAppLabel:
|
|
|
3363
3517
|
display: e.name.replace(/_sample$/, "")
|
|
3364
3518
|
}), C.set(e.type, t);
|
|
3365
3519
|
}
|
|
3366
|
-
let w = [...
|
|
3520
|
+
let w = [...Ra.filter((e) => C.has(e)), ...[...C.keys()].filter((e) => !Ra.includes(e))];
|
|
3367
3521
|
return /* @__PURE__ */ Q("div", {
|
|
3368
3522
|
className: "rounded-lg border bg-muted/30 p-3 text-sm",
|
|
3369
3523
|
"data-testid": "build-progress",
|
|
@@ -3371,7 +3525,7 @@ function Ia({ progress: t, appSegment: n, onOpenBuiltApp: r, openBuiltAppLabel:
|
|
|
3371
3525
|
/* @__PURE__ */ Q("div", {
|
|
3372
3526
|
className: "mb-2 flex items-center gap-2 font-medium",
|
|
3373
3527
|
children: [
|
|
3374
|
-
y ? /* @__PURE__ */ Z(
|
|
3528
|
+
y ? /* @__PURE__ */ Z(G, { className: "size-4 shrink-0 text-emerald-600" }) : /* @__PURE__ */ Z(it, { className: "size-4 shrink-0 animate-spin text-primary" }),
|
|
3375
3529
|
/* @__PURE__ */ Z("span", { children: y ? `Built ${m ?? "your app"}` : `Building ${m ?? "your app"}…` }),
|
|
3376
3530
|
!y && p === "data" ? /* @__PURE__ */ Z("span", {
|
|
3377
3531
|
className: "text-xs font-normal text-muted-foreground",
|
|
@@ -3379,7 +3533,7 @@ function Ia({ progress: t, appSegment: n, onOpenBuiltApp: r, openBuiltAppLabel:
|
|
|
3379
3533
|
}) : null,
|
|
3380
3534
|
y ? null : /* @__PURE__ */ Z("span", {
|
|
3381
3535
|
className: "ml-auto",
|
|
3382
|
-
children: /* @__PURE__ */ Z(
|
|
3536
|
+
children: /* @__PURE__ */ Z(Ma, {
|
|
3383
3537
|
active: !0,
|
|
3384
3538
|
activityKey: b,
|
|
3385
3539
|
waitingLabel: u,
|
|
@@ -3392,7 +3546,7 @@ function Ia({ progress: t, appSegment: n, onOpenBuiltApp: r, openBuiltAppLabel:
|
|
|
3392
3546
|
/* @__PURE__ */ Z("div", {
|
|
3393
3547
|
className: "mb-2 h-1.5 w-full overflow-hidden rounded-full bg-muted",
|
|
3394
3548
|
children: /* @__PURE__ */ Z("div", {
|
|
3395
|
-
className:
|
|
3549
|
+
className: W("h-full rounded-full transition-all duration-500", y ? "bg-emerald-500" : "bg-primary"),
|
|
3396
3550
|
style: { width: `${S}%` }
|
|
3397
3551
|
})
|
|
3398
3552
|
}),
|
|
@@ -3402,12 +3556,12 @@ function Ia({ progress: t, appSegment: n, onOpenBuiltApp: r, openBuiltAppLabel:
|
|
|
3402
3556
|
let r = C.get(t);
|
|
3403
3557
|
return /* @__PURE__ */ Q("li", {
|
|
3404
3558
|
className: "flex items-start gap-2",
|
|
3405
|
-
children: [/* @__PURE__ */ Z(
|
|
3559
|
+
children: [/* @__PURE__ */ Z(G, { className: "mt-0.5 size-3.5 shrink-0 text-emerald-600" }), /* @__PURE__ */ Q("span", {
|
|
3406
3560
|
className: "min-w-0 text-muted-foreground",
|
|
3407
3561
|
children: [
|
|
3408
3562
|
/* @__PURE__ */ Z("span", {
|
|
3409
3563
|
className: "font-medium text-foreground",
|
|
3410
|
-
children:
|
|
3564
|
+
children: za[t] ?? t
|
|
3411
3565
|
}),
|
|
3412
3566
|
" ",
|
|
3413
3567
|
r.slice(0, 6).map((r, i) => {
|
|
@@ -3437,28 +3591,28 @@ function Ia({ progress: t, appSegment: n, onOpenBuiltApp: r, openBuiltAppLabel:
|
|
|
3437
3591
|
onClick: () => a(x.name, n),
|
|
3438
3592
|
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",
|
|
3439
3593
|
"data-testid": "build-progress-design-app",
|
|
3440
|
-
children: [o, /* @__PURE__ */ Z(
|
|
3594
|
+
children: [o, /* @__PURE__ */ Z(Pe, { className: "size-3.5" })]
|
|
3441
3595
|
}) : null,
|
|
3442
3596
|
r ? /* @__PURE__ */ Q("button", {
|
|
3443
3597
|
type: "button",
|
|
3444
3598
|
onClick: () => r(x.name),
|
|
3445
|
-
className:
|
|
3599
|
+
className: W("inline-flex h-7 items-center gap-1.5 rounded-md px-3 text-xs font-medium", a ? "border hover:bg-muted" : "bg-primary text-primary-foreground hover:bg-primary/90"),
|
|
3446
3600
|
"data-testid": "build-progress-open-app",
|
|
3447
|
-
children: [i, /* @__PURE__ */ Z(
|
|
3601
|
+
children: [i, /* @__PURE__ */ Z(Pe, { className: "size-3.5" })]
|
|
3448
3602
|
}) : null,
|
|
3449
3603
|
c ? /* @__PURE__ */ Q("button", {
|
|
3450
3604
|
type: "button",
|
|
3451
3605
|
onClick: () => c(x.name),
|
|
3452
3606
|
className: "inline-flex h-7 items-center gap-1.5 rounded-md border px-3 text-xs font-medium hover:bg-muted",
|
|
3453
3607
|
"data-testid": "build-progress-preview-app",
|
|
3454
|
-
children: [/* @__PURE__ */ Z(
|
|
3608
|
+
children: [/* @__PURE__ */ Z(Qe, { className: "size-3.5" }), l]
|
|
3455
3609
|
}) : null
|
|
3456
3610
|
]
|
|
3457
3611
|
}) : null
|
|
3458
3612
|
]
|
|
3459
3613
|
});
|
|
3460
3614
|
}
|
|
3461
|
-
function
|
|
3615
|
+
function Ha({ groups: e, labels: t }) {
|
|
3462
3616
|
return e.length === 0 ? null : /* @__PURE__ */ Z("div", {
|
|
3463
3617
|
className: "not-prose mb-2 border-l border-border/70 pl-3",
|
|
3464
3618
|
children: /* @__PURE__ */ Z("div", {
|
|
@@ -3468,7 +3622,7 @@ function La({ groups: e, labels: t }) {
|
|
|
3468
3622
|
children: [/* @__PURE__ */ Q("div", {
|
|
3469
3623
|
className: "flex min-w-0 items-center gap-2",
|
|
3470
3624
|
children: [
|
|
3471
|
-
/* @__PURE__ */ Z(
|
|
3625
|
+
/* @__PURE__ */ Z(Ua, { state: e.state }),
|
|
3472
3626
|
/* @__PURE__ */ Z("span", {
|
|
3473
3627
|
className: "truncate font-medium text-foreground",
|
|
3474
3628
|
children: e.title
|
|
@@ -3478,22 +3632,22 @@ function La({ groups: e, labels: t }) {
|
|
|
3478
3632
|
children: ["x", e.count]
|
|
3479
3633
|
}) : null
|
|
3480
3634
|
]
|
|
3481
|
-
}), e.state === "running" ? e.rawName === "propose_blueprint" ? /* @__PURE__ */ Z(
|
|
3635
|
+
}), e.state === "running" ? e.rawName === "propose_blueprint" ? /* @__PURE__ */ Z(Ia, {
|
|
3482
3636
|
label: t.designingPlanLabel,
|
|
3483
3637
|
hints: t.designingPlanHints,
|
|
3484
3638
|
offlineLabel: t.connectionOfflineLabel
|
|
3485
|
-
}) : /* @__PURE__ */ Z(
|
|
3486
|
-
className:
|
|
3487
|
-
children:
|
|
3639
|
+
}) : /* @__PURE__ */ Z(La, { offlineLabel: t.connectionOfflineLabel }) : /* @__PURE__ */ Z("span", {
|
|
3640
|
+
className: W("shrink-0 text-[10px] font-medium", e.state === "failed" ? "text-destructive" : e.state === "completed" ? "text-emerald-700 dark:text-emerald-400" : "text-muted-foreground"),
|
|
3641
|
+
children: Wa(e.state, t)
|
|
3488
3642
|
})]
|
|
3489
3643
|
}, e.key))
|
|
3490
3644
|
})
|
|
3491
3645
|
});
|
|
3492
3646
|
}
|
|
3493
|
-
function
|
|
3494
|
-
return e === "failed" ? /* @__PURE__ */ Z(
|
|
3647
|
+
function Ua({ state: e }) {
|
|
3648
|
+
return e === "failed" ? /* @__PURE__ */ Z(J, { className: "size-3.5 shrink-0 text-destructive" }) : e === "completed" ? /* @__PURE__ */ Z(G, { className: "size-3.5 shrink-0 text-emerald-600" }) : /* @__PURE__ */ Z(Ke, { className: "size-3.5 shrink-0 text-muted-foreground" });
|
|
3495
3649
|
}
|
|
3496
|
-
function
|
|
3650
|
+
function Wa(e, t) {
|
|
3497
3651
|
switch (e) {
|
|
3498
3652
|
case "failed": return t.toolFailed;
|
|
3499
3653
|
case "awaiting": return t.toolAwaitingApproval;
|
|
@@ -3501,8 +3655,8 @@ function za(e, t) {
|
|
|
3501
3655
|
case "completed": return t.toolCompleted;
|
|
3502
3656
|
}
|
|
3503
3657
|
}
|
|
3504
|
-
function
|
|
3505
|
-
let i = e.useMemo(() =>
|
|
3658
|
+
function Ga({ error: t, rateLimitedLabel: n, genericLabel: r }) {
|
|
3659
|
+
let i = e.useMemo(() => hr(t) ? n : r, [
|
|
3506
3660
|
t,
|
|
3507
3661
|
n,
|
|
3508
3662
|
r
|
|
@@ -3515,7 +3669,7 @@ function Ba({ error: t, rateLimitedLabel: n, genericLabel: r }) {
|
|
|
3515
3669
|
className: "rounded-md border border-amber-300/40 bg-amber-50/60 px-3 py-2 text-foreground dark:bg-amber-950/20",
|
|
3516
3670
|
children: /* @__PURE__ */ Q("div", {
|
|
3517
3671
|
className: "flex items-start gap-2",
|
|
3518
|
-
children: [/* @__PURE__ */ Z(
|
|
3672
|
+
children: [/* @__PURE__ */ Z(_t, { className: "mt-0.5 h-4 w-4 shrink-0 text-amber-600" }), /* @__PURE__ */ Z("div", {
|
|
3519
3673
|
className: "min-w-0 flex-1 break-words leading-snug",
|
|
3520
3674
|
children: i
|
|
3521
3675
|
})]
|
|
@@ -3523,8 +3677,8 @@ function Ba({ error: t, rateLimitedLabel: n, genericLabel: r }) {
|
|
|
3523
3677
|
})
|
|
3524
3678
|
});
|
|
3525
3679
|
}
|
|
3526
|
-
function
|
|
3527
|
-
let { language: i } =
|
|
3680
|
+
function Ka({ error: t, onReload: n, onUpgrade: r }) {
|
|
3681
|
+
let { language: i } = Dt(), a = Ot(), o = e.useMemo(() => fr(t), [t]), { summary: s, details: c } = e.useMemo(() => cr(t), [t]), [l, u] = e.useState(!1);
|
|
3528
3682
|
if (o) {
|
|
3529
3683
|
let e = (i.toLowerCase().startsWith("zh") ? o.message : o.messageEn ?? o.message) || a("chatbotQuota.fallbackMessage", "You have reached your AI quota."), t = o.topUp ? a("chatbotQuota.buyCredits", "Buy a credit pack") : a("chatbotQuota.upgradePlan", "Upgrade plan"), n = a("chatbotQuota.title", "Upgrade needed");
|
|
3530
3684
|
return /* @__PURE__ */ Z("div", {
|
|
@@ -3561,7 +3715,7 @@ function Va({ error: t, onReload: n, onUpgrade: r }) {
|
|
|
3561
3715
|
children: [/* @__PURE__ */ Q("div", {
|
|
3562
3716
|
className: "flex items-start gap-2",
|
|
3563
3717
|
children: [
|
|
3564
|
-
/* @__PURE__ */ Z(
|
|
3718
|
+
/* @__PURE__ */ Z(Me, { className: "mt-0.5 h-4 w-4 shrink-0 text-destructive" }),
|
|
3565
3719
|
/* @__PURE__ */ Q("div", {
|
|
3566
3720
|
className: "min-w-0 flex-1",
|
|
3567
3721
|
children: [/* @__PURE__ */ Z("div", {
|
|
@@ -3584,7 +3738,7 @@ function Va({ error: t, onReload: n, onUpgrade: r }) {
|
|
|
3584
3738
|
type: "button",
|
|
3585
3739
|
onClick: n,
|
|
3586
3740
|
className: "inline-flex h-7 items-center rounded-md border border-destructive/30 bg-background px-2 text-xs font-medium text-destructive hover:bg-destructive/10",
|
|
3587
|
-
children: [/* @__PURE__ */ Z(
|
|
3741
|
+
children: [/* @__PURE__ */ Z(ut, { className: "mr-1 h-3 w-3" }), a("chatbotError.retry", "Retry")]
|
|
3588
3742
|
}) : null]
|
|
3589
3743
|
})
|
|
3590
3744
|
]
|
|
@@ -3595,27 +3749,27 @@ function Va({ error: t, onReload: n, onUpgrade: r }) {
|
|
|
3595
3749
|
})
|
|
3596
3750
|
});
|
|
3597
3751
|
}
|
|
3598
|
-
function
|
|
3599
|
-
return t ? /* @__PURE__ */ Z(
|
|
3752
|
+
function qa({ output: e, errorText: t }) {
|
|
3753
|
+
return t ? /* @__PURE__ */ Z(Ji, {
|
|
3600
3754
|
output: void 0,
|
|
3601
3755
|
errorText: t
|
|
3602
|
-
}) : e == null || e === "" ? null : typeof e == "string" && !
|
|
3756
|
+
}) : e == null || e === "" ? null : typeof e == "string" && !ua(e) ? /* @__PURE__ */ Q("div", {
|
|
3603
3757
|
className: "space-y-2 p-4",
|
|
3604
3758
|
children: [/* @__PURE__ */ Z("h4", {
|
|
3605
3759
|
className: "font-medium text-muted-foreground text-xs uppercase tracking-wide",
|
|
3606
3760
|
children: "Result"
|
|
3607
3761
|
}), /* @__PURE__ */ Z("div", {
|
|
3608
3762
|
className: "overflow-x-auto rounded-md bg-muted/40 px-3 py-2 text-sm text-foreground",
|
|
3609
|
-
children: /* @__PURE__ */ Z(
|
|
3763
|
+
children: /* @__PURE__ */ Z(Fr, { children: e })
|
|
3610
3764
|
})]
|
|
3611
|
-
}) : /* @__PURE__ */ Z(
|
|
3765
|
+
}) : /* @__PURE__ */ Z(Ji, {
|
|
3612
3766
|
output: e,
|
|
3613
3767
|
errorText: void 0
|
|
3614
3768
|
});
|
|
3615
3769
|
}
|
|
3616
3770
|
//#endregion
|
|
3617
3771
|
//#region src/FloatingChatbot.tsx
|
|
3618
|
-
function
|
|
3772
|
+
function Ja({ floatingConfig: t, headerExtra: n, headerActions: r, ...i }) {
|
|
3619
3773
|
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);
|
|
3620
3774
|
e.useEffect(() => {
|
|
3621
3775
|
let e = document.getElementById("floating-chatbot-portal");
|
|
@@ -3623,19 +3777,19 @@ function Ua({ floatingConfig: t, headerExtra: n, headerActions: r, ...i }) {
|
|
|
3623
3777
|
e && e.parentNode && !e.hasChildNodes() && e.parentNode.removeChild(e);
|
|
3624
3778
|
};
|
|
3625
3779
|
}, []);
|
|
3626
|
-
let p = /* @__PURE__ */ Q(
|
|
3780
|
+
let p = /* @__PURE__ */ Q(Kn, {
|
|
3627
3781
|
defaultOpen: o,
|
|
3628
|
-
children: [/* @__PURE__ */ Z(
|
|
3782
|
+
children: [/* @__PURE__ */ Z(Qn, {
|
|
3629
3783
|
position: a,
|
|
3630
3784
|
size: u
|
|
3631
|
-
}), /* @__PURE__ */ Z(
|
|
3785
|
+
}), /* @__PURE__ */ Z(ir, {
|
|
3632
3786
|
title: l,
|
|
3633
3787
|
position: a,
|
|
3634
3788
|
width: s,
|
|
3635
3789
|
height: c,
|
|
3636
3790
|
headerExtra: n,
|
|
3637
3791
|
headerActions: r,
|
|
3638
|
-
children: /* @__PURE__ */ Z(
|
|
3792
|
+
children: /* @__PURE__ */ Z(wa, {
|
|
3639
3793
|
...i,
|
|
3640
3794
|
maxHeight: "100%",
|
|
3641
3795
|
className: "h-full border-0 rounded-none"
|
|
@@ -3644,8 +3798,8 @@ function Ua({ floatingConfig: t, headerExtra: n, headerActions: r, ...i }) {
|
|
|
3644
3798
|
});
|
|
3645
3799
|
return d ? wt.createPortal(p, d) : p;
|
|
3646
3800
|
}
|
|
3647
|
-
|
|
3648
|
-
let { messages: i, isLoading: a, sendMessage: o } =
|
|
3801
|
+
Rt.register("chatbot", ({ schema: e, className: t, disabled: n, ...r }) => {
|
|
3802
|
+
let { messages: i, isLoading: a, sendMessage: o } = wn({
|
|
3649
3803
|
api: e.api,
|
|
3650
3804
|
initialMessages: e.messages,
|
|
3651
3805
|
conversationId: e.conversationId,
|
|
@@ -3663,9 +3817,9 @@ Lt.register("chatbot", ({ schema: e, className: t, disabled: n, ...r }) => {
|
|
|
3663
3817
|
onSend: e.onSend
|
|
3664
3818
|
}), s = (e) => {
|
|
3665
3819
|
o(e);
|
|
3666
|
-
}, c = l(() =>
|
|
3667
|
-
return /* @__PURE__ */ Z(
|
|
3668
|
-
...
|
|
3820
|
+
}, c = l(() => hn(i), [i]);
|
|
3821
|
+
return /* @__PURE__ */ Z(go, {
|
|
3822
|
+
...zt(r),
|
|
3669
3823
|
messages: c,
|
|
3670
3824
|
placeholder: e.placeholder,
|
|
3671
3825
|
onSendMessage: s,
|
|
@@ -3810,8 +3964,8 @@ Lt.register("chatbot", ({ schema: e, className: t, disabled: n, ...r }) => {
|
|
|
3810
3964
|
autoResponseDelay: 1e3,
|
|
3811
3965
|
className: "w-full max-w-2xl"
|
|
3812
3966
|
}
|
|
3813
|
-
}),
|
|
3814
|
-
let { messages: i, isLoading: a, error: o, sendMessage: s, stop: c, reload: u, clear: d, isApiMode: f } =
|
|
3967
|
+
}), Rt.register("chatbot-enhanced", ({ schema: e, className: t, disabled: n, ...r }) => {
|
|
3968
|
+
let { messages: i, isLoading: a, error: o, sendMessage: s, stop: c, reload: u, clear: d, isApiMode: f } = wn({
|
|
3815
3969
|
api: e.api,
|
|
3816
3970
|
initialMessages: e.messages,
|
|
3817
3971
|
conversationId: e.conversationId,
|
|
@@ -3831,9 +3985,9 @@ Lt.register("chatbot", ({ schema: e, className: t, disabled: n, ...r }) => {
|
|
|
3831
3985
|
s(e, t);
|
|
3832
3986
|
}, m = () => {
|
|
3833
3987
|
d(), e.onClear?.();
|
|
3834
|
-
}, h = l(() =>
|
|
3835
|
-
return /* @__PURE__ */ Z(
|
|
3836
|
-
...
|
|
3988
|
+
}, h = l(() => hn(i), [i]);
|
|
3989
|
+
return /* @__PURE__ */ Z(wa, {
|
|
3990
|
+
...zt(r),
|
|
3837
3991
|
messages: h,
|
|
3838
3992
|
placeholder: e.placeholder,
|
|
3839
3993
|
onSendMessage: p,
|
|
@@ -3997,8 +4151,8 @@ Lt.register("chatbot", ({ schema: e, className: t, disabled: n, ...r }) => {
|
|
|
3997
4151
|
autoResponseDelay: 1e3,
|
|
3998
4152
|
className: "w-full max-w-2xl"
|
|
3999
4153
|
}
|
|
4000
|
-
}),
|
|
4001
|
-
let { messages: r, isLoading: i, error: a, sendMessage: o, stop: s, reload: c, clear: u, isApiMode: d } =
|
|
4154
|
+
}), Rt.register("chatbot-floating", ({ schema: e, className: t, ...n }) => {
|
|
4155
|
+
let { messages: r, isLoading: i, error: a, sendMessage: o, stop: s, reload: c, clear: u, isApiMode: d } = wn({
|
|
4002
4156
|
api: e.api,
|
|
4003
4157
|
initialMessages: e.messages,
|
|
4004
4158
|
conversationId: e.conversationId,
|
|
@@ -4018,8 +4172,8 @@ Lt.register("chatbot", ({ schema: e, className: t, disabled: n, ...r }) => {
|
|
|
4018
4172
|
o(e, t);
|
|
4019
4173
|
}, p = () => {
|
|
4020
4174
|
u(), e.onClear?.();
|
|
4021
|
-
}, m = l(() =>
|
|
4022
|
-
return /* @__PURE__ */ Z(
|
|
4175
|
+
}, m = l(() => hn(r), [r]);
|
|
4176
|
+
return /* @__PURE__ */ Z(Ja, {
|
|
4023
4177
|
floatingConfig: e.floatingConfig,
|
|
4024
4178
|
messages: m,
|
|
4025
4179
|
placeholder: e.placeholder,
|
|
@@ -4187,7 +4341,7 @@ Lt.register("chatbot", ({ schema: e, className: t, disabled: n, ...r }) => {
|
|
|
4187
4341
|
});
|
|
4188
4342
|
//#endregion
|
|
4189
4343
|
//#region src/elements/loader.tsx
|
|
4190
|
-
var
|
|
4344
|
+
var Ya = ({ size: e = 16 }) => /* @__PURE__ */ Q("svg", {
|
|
4191
4345
|
height: e,
|
|
4192
4346
|
strokeLinejoin: "round",
|
|
4193
4347
|
style: { color: "currentcolor" },
|
|
@@ -4268,97 +4422,97 @@ var Wa = ({ size: e = 16 }) => /* @__PURE__ */ Q("svg", {
|
|
|
4268
4422
|
})
|
|
4269
4423
|
}) })
|
|
4270
4424
|
]
|
|
4271
|
-
}),
|
|
4272
|
-
className:
|
|
4425
|
+
}), Xa = ({ className: e, size: t = 16, ...n }) => /* @__PURE__ */ Z("div", {
|
|
4426
|
+
className: W("inline-flex animate-spin items-center justify-center", e),
|
|
4273
4427
|
...n,
|
|
4274
|
-
children: /* @__PURE__ */ Z(
|
|
4275
|
-
}),
|
|
4276
|
-
CodeBlock: () =>
|
|
4277
|
-
CodeBlockCopyButton: () =>
|
|
4278
|
-
Conversation: () =>
|
|
4279
|
-
ConversationContent: () =>
|
|
4280
|
-
ConversationEmptyState: () =>
|
|
4281
|
-
ConversationScrollButton: () =>
|
|
4282
|
-
Loader: () =>
|
|
4283
|
-
Message: () =>
|
|
4284
|
-
MessageAction: () =>
|
|
4285
|
-
MessageActions: () =>
|
|
4286
|
-
MessageAttachment: () =>
|
|
4287
|
-
MessageAttachments: () =>
|
|
4288
|
-
MessageBranch: () =>
|
|
4289
|
-
MessageBranchContent: () =>
|
|
4290
|
-
MessageBranchNext: () =>
|
|
4291
|
-
MessageBranchPage: () =>
|
|
4292
|
-
MessageBranchPrevious: () =>
|
|
4293
|
-
MessageBranchSelector: () =>
|
|
4294
|
-
MessageContent: () =>
|
|
4295
|
-
MessageResponse: () =>
|
|
4296
|
-
MessageToolbar: () =>
|
|
4297
|
-
PromptInput: () =>
|
|
4298
|
-
PromptInputActionAddAttachments: () =>
|
|
4299
|
-
PromptInputActionMenu: () =>
|
|
4300
|
-
PromptInputActionMenuContent: () =>
|
|
4301
|
-
PromptInputActionMenuItem: () =>
|
|
4302
|
-
PromptInputActionMenuTrigger: () =>
|
|
4303
|
-
PromptInputAttachment: () =>
|
|
4304
|
-
PromptInputAttachments: () =>
|
|
4305
|
-
PromptInputBody: () =>
|
|
4306
|
-
PromptInputButton: () =>
|
|
4307
|
-
PromptInputCommand: () =>
|
|
4308
|
-
PromptInputCommandEmpty: () =>
|
|
4309
|
-
PromptInputCommandGroup: () =>
|
|
4310
|
-
PromptInputCommandInput: () =>
|
|
4311
|
-
PromptInputCommandItem: () =>
|
|
4312
|
-
PromptInputCommandList: () =>
|
|
4313
|
-
PromptInputCommandSeparator: () =>
|
|
4314
|
-
PromptInputFooter: () =>
|
|
4315
|
-
PromptInputHeader: () =>
|
|
4316
|
-
PromptInputHoverCard: () =>
|
|
4317
|
-
PromptInputHoverCardContent: () =>
|
|
4318
|
-
PromptInputHoverCardTrigger: () =>
|
|
4319
|
-
PromptInputProvider: () =>
|
|
4320
|
-
PromptInputSelect: () =>
|
|
4321
|
-
PromptInputSelectContent: () =>
|
|
4322
|
-
PromptInputSelectItem: () =>
|
|
4323
|
-
PromptInputSelectTrigger: () =>
|
|
4324
|
-
PromptInputSelectValue: () =>
|
|
4325
|
-
PromptInputSpeechButton: () =>
|
|
4326
|
-
PromptInputSubmit: () =>
|
|
4327
|
-
PromptInputTab: () =>
|
|
4328
|
-
PromptInputTabBody: () =>
|
|
4329
|
-
PromptInputTabItem: () =>
|
|
4330
|
-
PromptInputTabLabel: () =>
|
|
4331
|
-
PromptInputTabsList: () =>
|
|
4332
|
-
PromptInputTextarea: () =>
|
|
4333
|
-
PromptInputTools: () =>
|
|
4334
|
-
Reasoning: () =>
|
|
4335
|
-
ReasoningContent: () =>
|
|
4336
|
-
ReasoningTrigger: () =>
|
|
4337
|
-
Shimmer: () =>
|
|
4338
|
-
Source: () =>
|
|
4339
|
-
Sources: () =>
|
|
4340
|
-
SourcesContent: () =>
|
|
4341
|
-
SourcesTrigger: () =>
|
|
4342
|
-
Suggestion: () =>
|
|
4343
|
-
Suggestions: () =>
|
|
4344
|
-
Tool: () =>
|
|
4345
|
-
ToolContent: () =>
|
|
4346
|
-
ToolHeader: () =>
|
|
4347
|
-
ToolInput: () =>
|
|
4348
|
-
ToolOutput: () =>
|
|
4349
|
-
highlightCode: () =>
|
|
4350
|
-
usePromptInputAttachments: () =>
|
|
4351
|
-
usePromptInputController: () =>
|
|
4352
|
-
useProviderAttachments: () =>
|
|
4353
|
-
useReasoning: () =>
|
|
4354
|
-
}),
|
|
4355
|
-
function
|
|
4428
|
+
children: /* @__PURE__ */ Z(Ya, { size: t })
|
|
4429
|
+
}), Za = /* @__PURE__ */ Vt({
|
|
4430
|
+
CodeBlock: () => Vi,
|
|
4431
|
+
CodeBlockCopyButton: () => Hi,
|
|
4432
|
+
Conversation: () => gr,
|
|
4433
|
+
ConversationContent: () => _r,
|
|
4434
|
+
ConversationEmptyState: () => vr,
|
|
4435
|
+
ConversationScrollButton: () => yr,
|
|
4436
|
+
Loader: () => Xa,
|
|
4437
|
+
Message: () => Cr,
|
|
4438
|
+
MessageAction: () => Er,
|
|
4439
|
+
MessageActions: () => Tr,
|
|
4440
|
+
MessageAttachment: () => Ir,
|
|
4441
|
+
MessageAttachments: () => Lr,
|
|
4442
|
+
MessageBranch: () => kr,
|
|
4443
|
+
MessageBranchContent: () => Ar,
|
|
4444
|
+
MessageBranchNext: () => Nr,
|
|
4445
|
+
MessageBranchPage: () => Pr,
|
|
4446
|
+
MessageBranchPrevious: () => Mr,
|
|
4447
|
+
MessageBranchSelector: () => jr,
|
|
4448
|
+
MessageContent: () => wr,
|
|
4449
|
+
MessageResponse: () => Fr,
|
|
4450
|
+
MessageToolbar: () => Rr,
|
|
4451
|
+
PromptInput: () => ri,
|
|
4452
|
+
PromptInputActionAddAttachments: () => ni,
|
|
4453
|
+
PromptInputActionMenu: () => ui,
|
|
4454
|
+
PromptInputActionMenuContent: () => fi,
|
|
4455
|
+
PromptInputActionMenuItem: () => pi,
|
|
4456
|
+
PromptInputActionMenuTrigger: () => di,
|
|
4457
|
+
PromptInputAttachment: () => ei,
|
|
4458
|
+
PromptInputAttachments: () => ti,
|
|
4459
|
+
PromptInputBody: () => ii,
|
|
4460
|
+
PromptInputButton: () => li,
|
|
4461
|
+
PromptInputCommand: () => ki,
|
|
4462
|
+
PromptInputCommandEmpty: () => Mi,
|
|
4463
|
+
PromptInputCommandGroup: () => Ni,
|
|
4464
|
+
PromptInputCommandInput: () => Ai,
|
|
4465
|
+
PromptInputCommandItem: () => Pi,
|
|
4466
|
+
PromptInputCommandList: () => ji,
|
|
4467
|
+
PromptInputCommandSeparator: () => Fi,
|
|
4468
|
+
PromptInputFooter: () => si,
|
|
4469
|
+
PromptInputHeader: () => oi,
|
|
4470
|
+
PromptInputHoverCard: () => xi,
|
|
4471
|
+
PromptInputHoverCardContent: () => Ci,
|
|
4472
|
+
PromptInputHoverCardTrigger: () => Si,
|
|
4473
|
+
PromptInputProvider: () => Zr,
|
|
4474
|
+
PromptInputSelect: () => gi,
|
|
4475
|
+
PromptInputSelectContent: () => vi,
|
|
4476
|
+
PromptInputSelectItem: () => yi,
|
|
4477
|
+
PromptInputSelectTrigger: () => _i,
|
|
4478
|
+
PromptInputSelectValue: () => bi,
|
|
4479
|
+
PromptInputSpeechButton: () => hi,
|
|
4480
|
+
PromptInputSubmit: () => mi,
|
|
4481
|
+
PromptInputTab: () => Ti,
|
|
4482
|
+
PromptInputTabBody: () => Di,
|
|
4483
|
+
PromptInputTabItem: () => Oi,
|
|
4484
|
+
PromptInputTabLabel: () => Ei,
|
|
4485
|
+
PromptInputTabsList: () => wi,
|
|
4486
|
+
PromptInputTextarea: () => ai,
|
|
4487
|
+
PromptInputTools: () => ci,
|
|
4488
|
+
Reasoning: () => ea,
|
|
4489
|
+
ReasoningContent: () => ra,
|
|
4490
|
+
ReasoningTrigger: () => na,
|
|
4491
|
+
Shimmer: () => Yi,
|
|
4492
|
+
Source: () => sa,
|
|
4493
|
+
Sources: () => ia,
|
|
4494
|
+
SourcesContent: () => oa,
|
|
4495
|
+
SourcesTrigger: () => aa,
|
|
4496
|
+
Suggestion: () => Li,
|
|
4497
|
+
Suggestions: () => Ii,
|
|
4498
|
+
Tool: () => Ui,
|
|
4499
|
+
ToolContent: () => Ki,
|
|
4500
|
+
ToolHeader: () => Gi,
|
|
4501
|
+
ToolInput: () => qi,
|
|
4502
|
+
ToolOutput: () => Ji,
|
|
4503
|
+
highlightCode: () => Bi,
|
|
4504
|
+
usePromptInputAttachments: () => $r,
|
|
4505
|
+
usePromptInputController: () => qr,
|
|
4506
|
+
useProviderAttachments: () => Yr,
|
|
4507
|
+
useReasoning: () => Zi
|
|
4508
|
+
}), Qa = "/api/v1/ai";
|
|
4509
|
+
function $a(e, t, n) {
|
|
4356
4510
|
let r = e.replace(/\/$/, ""), i = new URLSearchParams();
|
|
4357
4511
|
if (n) for (let [e, t] of Object.entries(n)) t != null && t !== "" && i.set(e, String(t));
|
|
4358
4512
|
let a = i.toString();
|
|
4359
4513
|
return `${r}${t}${a ? `?${a}` : ""}`;
|
|
4360
4514
|
}
|
|
4361
|
-
async function
|
|
4515
|
+
async function eo(e, t, n) {
|
|
4362
4516
|
let r = await fetch(e, {
|
|
4363
4517
|
credentials: "include",
|
|
4364
4518
|
...t,
|
|
@@ -4378,8 +4532,8 @@ async function Ya(e, t, n) {
|
|
|
4378
4532
|
}
|
|
4379
4533
|
return i;
|
|
4380
4534
|
}
|
|
4381
|
-
function
|
|
4382
|
-
let { apiBase: n =
|
|
4535
|
+
function to(t = {}) {
|
|
4536
|
+
let { apiBase: n = Qa, 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({
|
|
4383
4537
|
apiBase: n,
|
|
4384
4538
|
status: r,
|
|
4385
4539
|
conversationId: i,
|
|
@@ -4397,7 +4551,7 @@ function Xa(t = {}) {
|
|
|
4397
4551
|
let { apiBase: e, status: t, conversationId: n, limit: r, headers: i } = _.current;
|
|
4398
4552
|
m(!0), g(void 0);
|
|
4399
4553
|
try {
|
|
4400
|
-
let a = await
|
|
4554
|
+
let a = await eo($a(e, "/pending-actions", {
|
|
4401
4555
|
status: t && t !== "all" ? t : void 0,
|
|
4402
4556
|
conversationId: n,
|
|
4403
4557
|
limit: r
|
|
@@ -4409,9 +4563,9 @@ function Xa(t = {}) {
|
|
|
4409
4563
|
m(!1);
|
|
4410
4564
|
}
|
|
4411
4565
|
}, []), y = e.useCallback(async (e) => {
|
|
4412
|
-
let { apiBase: t, headers: n } = _.current, r =
|
|
4566
|
+
let { apiBase: t, headers: n } = _.current, r = $a(t, `/pending-actions/${encodeURIComponent(e)}/approve`);
|
|
4413
4567
|
try {
|
|
4414
|
-
return await
|
|
4568
|
+
return await eo(r, {
|
|
4415
4569
|
method: "POST",
|
|
4416
4570
|
body: "{}"
|
|
4417
4571
|
}, n);
|
|
@@ -4419,9 +4573,9 @@ function Xa(t = {}) {
|
|
|
4419
4573
|
v();
|
|
4420
4574
|
}
|
|
4421
4575
|
}, [v]), b = e.useCallback(async (e, t) => {
|
|
4422
|
-
let { apiBase: n, headers: r } = _.current, i =
|
|
4576
|
+
let { apiBase: n, headers: r } = _.current, i = $a(n, `/pending-actions/${encodeURIComponent(e)}/reject`);
|
|
4423
4577
|
try {
|
|
4424
|
-
return await
|
|
4578
|
+
return await eo(i, {
|
|
4425
4579
|
method: "POST",
|
|
4426
4580
|
body: JSON.stringify(t ? { reason: t } : {})
|
|
4427
4581
|
}, r);
|
|
@@ -4455,7 +4609,7 @@ function Xa(t = {}) {
|
|
|
4455
4609
|
}
|
|
4456
4610
|
//#endregion
|
|
4457
4611
|
//#region src/AiPendingActionsInbox.tsx
|
|
4458
|
-
var
|
|
4612
|
+
var no = {
|
|
4459
4613
|
pending: {
|
|
4460
4614
|
variant: "secondary",
|
|
4461
4615
|
label: "Pending"
|
|
@@ -4477,8 +4631,8 @@ var Za = {
|
|
|
4477
4631
|
label: "Rejected"
|
|
4478
4632
|
}
|
|
4479
4633
|
};
|
|
4480
|
-
function
|
|
4481
|
-
let t =
|
|
4634
|
+
function ro({ status: e }) {
|
|
4635
|
+
let t = no[e] ?? {
|
|
4482
4636
|
variant: "outline",
|
|
4483
4637
|
label: e
|
|
4484
4638
|
};
|
|
@@ -4487,7 +4641,7 @@ function Qa({ status: e }) {
|
|
|
4487
4641
|
children: t.label
|
|
4488
4642
|
});
|
|
4489
4643
|
}
|
|
4490
|
-
function
|
|
4644
|
+
function io(e) {
|
|
4491
4645
|
if (!e) return "—";
|
|
4492
4646
|
let t = Date.parse(e);
|
|
4493
4647
|
if (Number.isNaN(t)) return e;
|
|
@@ -4505,7 +4659,7 @@ function $a(e) {
|
|
|
4505
4659
|
return e;
|
|
4506
4660
|
}
|
|
4507
4661
|
}
|
|
4508
|
-
function
|
|
4662
|
+
function ao(e) {
|
|
4509
4663
|
if (!e) return null;
|
|
4510
4664
|
try {
|
|
4511
4665
|
return JSON.parse(e);
|
|
@@ -4513,7 +4667,7 @@ function eo(e) {
|
|
|
4513
4667
|
return e;
|
|
4514
4668
|
}
|
|
4515
4669
|
}
|
|
4516
|
-
function
|
|
4670
|
+
function oo({ value: e, max: t = 320 }) {
|
|
4517
4671
|
let n = typeof e == "string" ? e : JSON.stringify(e, null, 2);
|
|
4518
4672
|
return n == null || n === "" ? /* @__PURE__ */ Z("span", {
|
|
4519
4673
|
className: "text-muted-foreground text-xs",
|
|
@@ -4524,20 +4678,20 @@ function to({ value: e, max: t = 320 }) {
|
|
|
4524
4678
|
children: n
|
|
4525
4679
|
});
|
|
4526
4680
|
}
|
|
4527
|
-
function
|
|
4681
|
+
function so(e) {
|
|
4528
4682
|
switch (e) {
|
|
4529
4683
|
case "pending": return "pending";
|
|
4530
4684
|
case "all": return "all";
|
|
4531
4685
|
case "decided": return "all";
|
|
4532
4686
|
}
|
|
4533
4687
|
}
|
|
4534
|
-
function
|
|
4535
|
-
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: ee, approve: P, reject: F } =
|
|
4688
|
+
function co({ 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 }) {
|
|
4689
|
+
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: ee, approve: P, reject: F } = to({
|
|
4536
4690
|
apiBase: t,
|
|
4537
4691
|
headers: n,
|
|
4538
4692
|
pollInterval: r,
|
|
4539
4693
|
conversationId: i,
|
|
4540
|
-
status:
|
|
4694
|
+
status: so(l)
|
|
4541
4695
|
}), 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) => {
|
|
4542
4696
|
E(e), O(null);
|
|
4543
4697
|
try {
|
|
@@ -4584,19 +4738,19 @@ function ro({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
|
|
|
4584
4738
|
children: [
|
|
4585
4739
|
/* @__PURE__ */ Q("div", {
|
|
4586
4740
|
className: "flex items-center justify-between gap-2",
|
|
4587
|
-
children: [/* @__PURE__ */ Z(
|
|
4741
|
+
children: [/* @__PURE__ */ Z(we, {
|
|
4588
4742
|
value: l,
|
|
4589
4743
|
onValueChange: (e) => u(e),
|
|
4590
|
-
children: /* @__PURE__ */ Q(
|
|
4591
|
-
/* @__PURE__ */ Z(
|
|
4744
|
+
children: /* @__PURE__ */ Q(Te, { children: [
|
|
4745
|
+
/* @__PURE__ */ Z(Ee, {
|
|
4592
4746
|
value: "pending",
|
|
4593
4747
|
children: "Pending"
|
|
4594
4748
|
}),
|
|
4595
|
-
/* @__PURE__ */ Z(
|
|
4749
|
+
/* @__PURE__ */ Z(Ee, {
|
|
4596
4750
|
value: "decided",
|
|
4597
4751
|
children: "Decided"
|
|
4598
4752
|
}),
|
|
4599
|
-
/* @__PURE__ */ Z(
|
|
4753
|
+
/* @__PURE__ */ Z(Ee, {
|
|
4600
4754
|
value: "all",
|
|
4601
4755
|
children: "All"
|
|
4602
4756
|
})
|
|
@@ -4607,20 +4761,20 @@ function ro({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
|
|
|
4607
4761
|
onClick: () => void ee(),
|
|
4608
4762
|
disabled: M,
|
|
4609
4763
|
"data-testid": "ai-inbox-refresh",
|
|
4610
|
-
children: [/* @__PURE__ */ Z(
|
|
4764
|
+
children: [/* @__PURE__ */ Z(ut, { className: `h-3.5 w-3.5 mr-1.5 ${M ? "animate-spin" : ""}` }), "Refresh"]
|
|
4611
4765
|
})]
|
|
4612
4766
|
}),
|
|
4613
4767
|
N ? /* @__PURE__ */ Q(f, {
|
|
4614
4768
|
variant: "destructive",
|
|
4615
|
-
children: [/* @__PURE__ */ Z(
|
|
4769
|
+
children: [/* @__PURE__ */ Z(Me, { className: "h-4 w-4" }), /* @__PURE__ */ Z(p, { children: N.message })]
|
|
4616
4770
|
}) : null,
|
|
4617
4771
|
D ? /* @__PURE__ */ Q(f, {
|
|
4618
4772
|
variant: "destructive",
|
|
4619
|
-
children: [/* @__PURE__ */ Z(
|
|
4773
|
+
children: [/* @__PURE__ */ Z(Me, { className: "h-4 w-4" }), /* @__PURE__ */ Z(p, { children: D })]
|
|
4620
4774
|
}) : null,
|
|
4621
4775
|
k && !D ? /* @__PURE__ */ Q(f, {
|
|
4622
4776
|
variant: k.ok ? "default" : "destructive",
|
|
4623
|
-
children: [k.ok ? /* @__PURE__ */ Z(
|
|
4777
|
+
children: [k.ok ? /* @__PURE__ */ Z(G, { className: "h-4 w-4" }) : /* @__PURE__ */ Z(J, { className: "h-4 w-4" }), /* @__PURE__ */ Q(p, { children: [
|
|
4624
4778
|
k.kind === "approve" ? "Approve" : "Reject",
|
|
4625
4779
|
" for",
|
|
4626
4780
|
" ",
|
|
@@ -4636,69 +4790,69 @@ function ro({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
|
|
|
4636
4790
|
M && I.length === 0 ? /* @__PURE__ */ Q("div", {
|
|
4637
4791
|
className: "space-y-2",
|
|
4638
4792
|
children: [
|
|
4639
|
-
/* @__PURE__ */ Z(
|
|
4640
|
-
/* @__PURE__ */ Z(
|
|
4641
|
-
/* @__PURE__ */ Z(
|
|
4793
|
+
/* @__PURE__ */ Z(ye, { className: "h-10 w-full" }),
|
|
4794
|
+
/* @__PURE__ */ Z(ye, { className: "h-10 w-full" }),
|
|
4795
|
+
/* @__PURE__ */ Z(ye, { className: "h-10 w-full" })
|
|
4642
4796
|
]
|
|
4643
4797
|
}) : I.length === 0 ? /* @__PURE__ */ Z(te, { children: /* @__PURE__ */ Q(L, { children: [
|
|
4644
|
-
/* @__PURE__ */ Z(re, { children: /* @__PURE__ */ Z(
|
|
4798
|
+
/* @__PURE__ */ Z(re, { children: /* @__PURE__ */ Z(rt, { className: "h-8 w-8 text-muted-foreground" }) }),
|
|
4645
4799
|
/* @__PURE__ */ Z(ie, { children: "No actions waiting" }),
|
|
4646
4800
|
/* @__PURE__ */ Z(ne, { children: "When the AI proposes a sensitive action it will appear here for review." })
|
|
4647
4801
|
] }) }) : /* @__PURE__ */ Z("div", {
|
|
4648
4802
|
className: "rounded-md border",
|
|
4649
|
-
children: /* @__PURE__ */ Q(
|
|
4650
|
-
/* @__PURE__ */ Z(
|
|
4803
|
+
children: /* @__PURE__ */ Q(be, { children: [/* @__PURE__ */ Z(Se, { children: /* @__PURE__ */ Q(Ce, { children: [
|
|
4804
|
+
/* @__PURE__ */ Z(U, {
|
|
4651
4805
|
className: "w-[140px]",
|
|
4652
4806
|
children: "Tool"
|
|
4653
4807
|
}),
|
|
4654
|
-
/* @__PURE__ */ Z(
|
|
4808
|
+
/* @__PURE__ */ Z(U, {
|
|
4655
4809
|
className: "w-[140px]",
|
|
4656
4810
|
children: "Action"
|
|
4657
4811
|
}),
|
|
4658
|
-
/* @__PURE__ */ Z(
|
|
4812
|
+
/* @__PURE__ */ Z(U, {
|
|
4659
4813
|
className: "w-[120px]",
|
|
4660
4814
|
children: "Object"
|
|
4661
4815
|
}),
|
|
4662
|
-
/* @__PURE__ */ Z(
|
|
4816
|
+
/* @__PURE__ */ Z(U, {
|
|
4663
4817
|
className: "w-[110px]",
|
|
4664
4818
|
children: "Status"
|
|
4665
4819
|
}),
|
|
4666
|
-
/* @__PURE__ */ Z(
|
|
4820
|
+
/* @__PURE__ */ Z(U, {
|
|
4667
4821
|
className: "w-[110px]",
|
|
4668
4822
|
children: "Proposed"
|
|
4669
4823
|
}),
|
|
4670
|
-
/* @__PURE__ */ Z(
|
|
4824
|
+
/* @__PURE__ */ Z(U, {
|
|
4671
4825
|
className: "w-[260px] text-right",
|
|
4672
4826
|
children: "Decision"
|
|
4673
4827
|
})
|
|
4674
|
-
] }) }), /* @__PURE__ */ Z(
|
|
4828
|
+
] }) }), /* @__PURE__ */ Z(xe, { children: I.map((e) => {
|
|
4675
4829
|
let t = e.status === "pending", n = T === e.id;
|
|
4676
|
-
return /* @__PURE__ */ Q(
|
|
4677
|
-
/* @__PURE__ */ Z(
|
|
4830
|
+
return /* @__PURE__ */ Q(Ce, { children: [
|
|
4831
|
+
/* @__PURE__ */ Z(H, {
|
|
4678
4832
|
className: "font-mono text-xs",
|
|
4679
4833
|
children: e.tool_name
|
|
4680
4834
|
}),
|
|
4681
|
-
/* @__PURE__ */ Z(
|
|
4835
|
+
/* @__PURE__ */ Z(H, {
|
|
4682
4836
|
className: "text-sm",
|
|
4683
4837
|
children: e.action_name
|
|
4684
4838
|
}),
|
|
4685
|
-
/* @__PURE__ */ Z(
|
|
4839
|
+
/* @__PURE__ */ Z(H, {
|
|
4686
4840
|
className: "text-sm",
|
|
4687
4841
|
children: e.object_name
|
|
4688
4842
|
}),
|
|
4689
|
-
/* @__PURE__ */ Z(
|
|
4690
|
-
/* @__PURE__ */ Z(
|
|
4843
|
+
/* @__PURE__ */ Z(H, { children: /* @__PURE__ */ Z(ro, { status: e.status }) }),
|
|
4844
|
+
/* @__PURE__ */ Z(H, {
|
|
4691
4845
|
className: "text-xs text-muted-foreground",
|
|
4692
4846
|
children: /* @__PURE__ */ Q("span", {
|
|
4693
4847
|
className: "inline-flex items-center gap-1",
|
|
4694
4848
|
children: [
|
|
4695
|
-
/* @__PURE__ */ Z(
|
|
4849
|
+
/* @__PURE__ */ Z(Ge, { className: "h-3 w-3" }),
|
|
4696
4850
|
" ",
|
|
4697
|
-
|
|
4851
|
+
io(e.proposed_at)
|
|
4698
4852
|
]
|
|
4699
4853
|
})
|
|
4700
4854
|
}),
|
|
4701
|
-
/* @__PURE__ */ Z(
|
|
4855
|
+
/* @__PURE__ */ Z(H, {
|
|
4702
4856
|
className: "text-right",
|
|
4703
4857
|
children: /* @__PURE__ */ Q("div", {
|
|
4704
4858
|
className: "inline-flex gap-1.5",
|
|
@@ -4707,14 +4861,14 @@ function ro({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
|
|
|
4707
4861
|
variant: "ghost",
|
|
4708
4862
|
onClick: () => m(e.id),
|
|
4709
4863
|
"data-testid": `ai-inbox-view-${e.id}`,
|
|
4710
|
-
children: [/* @__PURE__ */ Z(
|
|
4864
|
+
children: [/* @__PURE__ */ Z(Qe, { className: "h-3.5 w-3.5 mr-1" }), " View"]
|
|
4711
4865
|
}), t ? /* @__PURE__ */ Q(X, { children: [/* @__PURE__ */ Q(v, {
|
|
4712
4866
|
size: "sm",
|
|
4713
4867
|
variant: "default",
|
|
4714
4868
|
disabled: n,
|
|
4715
4869
|
onClick: () => void ae(e.id),
|
|
4716
4870
|
"data-testid": `ai-inbox-approve-${e.id}`,
|
|
4717
|
-
children: [/* @__PURE__ */ Z(
|
|
4871
|
+
children: [/* @__PURE__ */ Z(G, { className: "h-3.5 w-3.5 mr-1" }), n ? "Working…" : "Approve"]
|
|
4718
4872
|
}), /* @__PURE__ */ Q(v, {
|
|
4719
4873
|
size: "sm",
|
|
4720
4874
|
variant: "destructive",
|
|
@@ -4723,7 +4877,7 @@ function ro({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
|
|
|
4723
4877
|
g(e.id), w("");
|
|
4724
4878
|
},
|
|
4725
4879
|
"data-testid": `ai-inbox-reject-${e.id}`,
|
|
4726
|
-
children: [/* @__PURE__ */ Z(
|
|
4880
|
+
children: [/* @__PURE__ */ Z(J, { className: "h-3.5 w-3.5 mr-1" }), "Reject"]
|
|
4727
4881
|
})] }) : null]
|
|
4728
4882
|
})
|
|
4729
4883
|
})
|
|
@@ -4740,7 +4894,7 @@ function ro({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
|
|
|
4740
4894
|
children: [/* @__PURE__ */ Q(C, {
|
|
4741
4895
|
className: "flex items-center gap-2",
|
|
4742
4896
|
children: [
|
|
4743
|
-
/* @__PURE__ */ Z(
|
|
4897
|
+
/* @__PURE__ */ Z(Ie, { className: "h-4 w-4" }),
|
|
4744
4898
|
" ",
|
|
4745
4899
|
o
|
|
4746
4900
|
]
|
|
@@ -4750,17 +4904,17 @@ function ro({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
|
|
|
4750
4904
|
className: c,
|
|
4751
4905
|
children: z
|
|
4752
4906
|
}),
|
|
4753
|
-
/* @__PURE__ */ Z(
|
|
4907
|
+
/* @__PURE__ */ Z(me, {
|
|
4754
4908
|
open: !!d,
|
|
4755
4909
|
onOpenChange: (e) => {
|
|
4756
4910
|
e || m(null);
|
|
4757
4911
|
},
|
|
4758
|
-
children: /* @__PURE__ */ Q(
|
|
4912
|
+
children: /* @__PURE__ */ Q(he, {
|
|
4759
4913
|
className: "sm:max-w-[560px] overflow-y-auto",
|
|
4760
|
-
children: [/* @__PURE__ */ Q(
|
|
4914
|
+
children: [/* @__PURE__ */ Q(_e, { children: [/* @__PURE__ */ Q(ve, {
|
|
4761
4915
|
className: "flex items-center gap-2",
|
|
4762
|
-
children: [/* @__PURE__ */ Z(
|
|
4763
|
-
}), /* @__PURE__ */ Z(
|
|
4916
|
+
children: [/* @__PURE__ */ Z(Ie, { className: "h-4 w-4" }), R ? R.action_name : "Pending action"]
|
|
4917
|
+
}), /* @__PURE__ */ Z(ge, { children: R ? /* @__PURE__ */ Q(X, { children: [
|
|
4764
4918
|
"Tool ",
|
|
4765
4919
|
/* @__PURE__ */ Z("code", {
|
|
4766
4920
|
className: "text-xs",
|
|
@@ -4783,14 +4937,14 @@ function ro({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
|
|
|
4783
4937
|
children: "Status"
|
|
4784
4938
|
}), /* @__PURE__ */ Z("div", {
|
|
4785
4939
|
className: "mt-1",
|
|
4786
|
-
children: /* @__PURE__ */ Z(
|
|
4940
|
+
children: /* @__PURE__ */ Z(ro, { status: R.status })
|
|
4787
4941
|
})] }),
|
|
4788
4942
|
/* @__PURE__ */ Q("div", { children: [/* @__PURE__ */ Z(B, {
|
|
4789
4943
|
className: "text-xs text-muted-foreground",
|
|
4790
4944
|
children: "Proposed"
|
|
4791
4945
|
}), /* @__PURE__ */ Z("div", {
|
|
4792
4946
|
className: "mt-1 text-xs",
|
|
4793
|
-
children:
|
|
4947
|
+
children: io(R.proposed_at)
|
|
4794
4948
|
})] }),
|
|
4795
4949
|
/* @__PURE__ */ Q("div", { children: [/* @__PURE__ */ Z(B, {
|
|
4796
4950
|
className: "text-xs text-muted-foreground",
|
|
@@ -4818,27 +4972,27 @@ function ro({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
|
|
|
4818
4972
|
}) : null
|
|
4819
4973
|
]
|
|
4820
4974
|
}),
|
|
4821
|
-
/* @__PURE__ */ Z(
|
|
4975
|
+
/* @__PURE__ */ Z(pe, {}),
|
|
4822
4976
|
/* @__PURE__ */ Q("div", { children: [/* @__PURE__ */ Z(B, {
|
|
4823
4977
|
className: "text-xs",
|
|
4824
4978
|
children: "Tool input"
|
|
4825
4979
|
}), /* @__PURE__ */ Z("div", {
|
|
4826
4980
|
className: "mt-1.5",
|
|
4827
|
-
children: /* @__PURE__ */ Z(
|
|
4981
|
+
children: /* @__PURE__ */ Z(oo, { value: ao(R.tool_input) })
|
|
4828
4982
|
})] }),
|
|
4829
4983
|
R.result ? /* @__PURE__ */ Q("div", { children: [/* @__PURE__ */ Z(B, {
|
|
4830
4984
|
className: "text-xs",
|
|
4831
4985
|
children: "Result"
|
|
4832
4986
|
}), /* @__PURE__ */ Z("div", {
|
|
4833
4987
|
className: "mt-1.5",
|
|
4834
|
-
children: /* @__PURE__ */ Z(
|
|
4988
|
+
children: /* @__PURE__ */ Z(oo, { value: ao(R.result) })
|
|
4835
4989
|
})] }) : null,
|
|
4836
4990
|
R.error ? /* @__PURE__ */ Q("div", { children: [/* @__PURE__ */ Z(B, {
|
|
4837
4991
|
className: "text-xs text-destructive",
|
|
4838
4992
|
children: "Error"
|
|
4839
4993
|
}), /* @__PURE__ */ Z("div", {
|
|
4840
4994
|
className: "mt-1.5",
|
|
4841
|
-
children: /* @__PURE__ */ Z(
|
|
4995
|
+
children: /* @__PURE__ */ Z(oo, { value: R.error })
|
|
4842
4996
|
})] }) : null,
|
|
4843
4997
|
R.rejection_reason ? /* @__PURE__ */ Q("div", { children: [/* @__PURE__ */ Z(B, {
|
|
4844
4998
|
className: "text-xs",
|
|
@@ -4853,7 +5007,7 @@ function ro({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
|
|
|
4853
5007
|
size: "sm",
|
|
4854
5008
|
onClick: () => void ae(R.id),
|
|
4855
5009
|
disabled: T === R.id,
|
|
4856
|
-
children: [/* @__PURE__ */ Z(
|
|
5010
|
+
children: [/* @__PURE__ */ Z(G, { className: "h-3.5 w-3.5 mr-1" }), "Approve & Execute"]
|
|
4857
5011
|
}), /* @__PURE__ */ Q(v, {
|
|
4858
5012
|
size: "sm",
|
|
4859
5013
|
variant: "destructive",
|
|
@@ -4861,24 +5015,24 @@ function ro({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
|
|
|
4861
5015
|
g(R.id), w("");
|
|
4862
5016
|
},
|
|
4863
5017
|
disabled: T === R.id,
|
|
4864
|
-
children: [/* @__PURE__ */ Z(
|
|
5018
|
+
children: [/* @__PURE__ */ Z(J, { className: "h-3.5 w-3.5 mr-1" }), "Reject"]
|
|
4865
5019
|
})]
|
|
4866
5020
|
}) : null
|
|
4867
5021
|
]
|
|
4868
5022
|
}) : null]
|
|
4869
5023
|
})
|
|
4870
5024
|
}),
|
|
4871
|
-
/* @__PURE__ */ Z(
|
|
5025
|
+
/* @__PURE__ */ Z(me, {
|
|
4872
5026
|
open: !!h,
|
|
4873
5027
|
onOpenChange: (e) => {
|
|
4874
5028
|
e || (g(null), w(""));
|
|
4875
5029
|
},
|
|
4876
|
-
children: /* @__PURE__ */ Q(
|
|
5030
|
+
children: /* @__PURE__ */ Q(he, {
|
|
4877
5031
|
side: "bottom",
|
|
4878
5032
|
className: "max-h-[40vh]",
|
|
4879
|
-
children: [/* @__PURE__ */ Q(
|
|
5033
|
+
children: [/* @__PURE__ */ Q(_e, { children: [/* @__PURE__ */ Z(ve, { children: "Reject this action?" }), /* @__PURE__ */ Z(ge, { children: "The reason is shown back to the AI so it can adjust its next response." })] }), /* @__PURE__ */ Q("div", {
|
|
4880
5034
|
className: "px-4 mt-3 space-y-3",
|
|
4881
|
-
children: [/* @__PURE__ */ Z(
|
|
5035
|
+
children: [/* @__PURE__ */ Z(De, {
|
|
4882
5036
|
value: _,
|
|
4883
5037
|
onChange: (e) => w(e.target.value),
|
|
4884
5038
|
placeholder: "Optional reason (e.g. 'Wrong record id — please confirm with the user first.')",
|
|
@@ -4899,7 +5053,7 @@ function ro({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
|
|
|
4899
5053
|
onClick: () => h && void oe(h, _),
|
|
4900
5054
|
disabled: !h || T === h,
|
|
4901
5055
|
"data-testid": "ai-inbox-reject-confirm",
|
|
4902
|
-
children: [/* @__PURE__ */ Z(
|
|
5056
|
+
children: [/* @__PURE__ */ Z(J, { className: "h-3.5 w-3.5 mr-1" }), "Reject"]
|
|
4903
5057
|
})]
|
|
4904
5058
|
})]
|
|
4905
5059
|
})]
|
|
@@ -4909,14 +5063,14 @@ function ro({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
|
|
|
4909
5063
|
}
|
|
4910
5064
|
//#endregion
|
|
4911
5065
|
//#region src/useHitlInChat.ts
|
|
4912
|
-
function
|
|
5066
|
+
function lo(e) {
|
|
4913
5067
|
return !e || e.length === 0 ? "/api/v1/ai" : e.endsWith("/") ? e.slice(0, -1) : e;
|
|
4914
5068
|
}
|
|
4915
|
-
function
|
|
5069
|
+
function uo(e, t) {
|
|
4916
5070
|
let n = { ...e ?? {} };
|
|
4917
5071
|
return t && (n["Content-Type"] = "application/json"), n;
|
|
4918
5072
|
}
|
|
4919
|
-
async function
|
|
5073
|
+
async function fo(e) {
|
|
4920
5074
|
let t = await e.text();
|
|
4921
5075
|
if (!t) return null;
|
|
4922
5076
|
try {
|
|
@@ -4925,8 +5079,8 @@ async function oo(e) {
|
|
|
4925
5079
|
return { raw: t };
|
|
4926
5080
|
}
|
|
4927
5081
|
}
|
|
4928
|
-
function
|
|
4929
|
-
let { messages: n, apiBase: r, headers: i, onDecided: a, continueConversation: o } = t, s =
|
|
5082
|
+
function po(t) {
|
|
5083
|
+
let { messages: n, apiBase: r, headers: i, onDecided: a, continueConversation: o } = t, s = lo(r), c = e.useMemo(() => {
|
|
4930
5084
|
let e = /* @__PURE__ */ new Map();
|
|
4931
5085
|
for (let t of n) {
|
|
4932
5086
|
let n = t.toolInvocations ?? [];
|
|
@@ -4969,9 +5123,9 @@ function so(t) {
|
|
|
4969
5123
|
let r = `${s}/pending-actions/${encodeURIComponent(l)}/${t ? "approve" : "reject"}`, c = t ? "{}" : JSON.stringify({ reason: n ?? "" }), d = await fetch(r, {
|
|
4970
5124
|
method: "POST",
|
|
4971
5125
|
credentials: "include",
|
|
4972
|
-
headers:
|
|
5126
|
+
headers: uo(i, !0),
|
|
4973
5127
|
body: c
|
|
4974
|
-
}), f = await
|
|
5128
|
+
}), f = await fo(d) ?? {};
|
|
4975
5129
|
if (!d.ok) {
|
|
4976
5130
|
let t = typeof f.error == "string" ? f.error : `Approval failed: HTTP ${d.status}`;
|
|
4977
5131
|
m(e, {
|
|
@@ -5004,7 +5158,7 @@ function so(t) {
|
|
|
5004
5158
|
message: `Status: ${p}`
|
|
5005
5159
|
}), h = !0;
|
|
5006
5160
|
if (a?.(e, f), h && o) {
|
|
5007
|
-
let r =
|
|
5161
|
+
let r = mo({
|
|
5008
5162
|
approved: t,
|
|
5009
5163
|
status: p,
|
|
5010
5164
|
toolName: u,
|
|
@@ -5040,24 +5194,24 @@ function so(t) {
|
|
|
5040
5194
|
isDeciding: f
|
|
5041
5195
|
};
|
|
5042
5196
|
}
|
|
5043
|
-
function
|
|
5197
|
+
function mo(e) {
|
|
5044
5198
|
let { approved: t, status: n, toolName: r, pendingActionId: i, outcome: a, reason: o } = e, s = `[HITL ${i}]`;
|
|
5045
5199
|
if (t && n === "executed") {
|
|
5046
5200
|
let e = a.result;
|
|
5047
|
-
return `${s} The operator approved the \`${r}\` call. It executed successfully with result: ${e == null ? "(no payload)" : typeof e == "string" ? e :
|
|
5201
|
+
return `${s} The operator approved the \`${r}\` call. It executed successfully with result: ${e == null ? "(no payload)" : typeof e == "string" ? e : ho(JSON.stringify(e), 800)}. Acknowledge the outcome concisely and continue the user's task.`;
|
|
5048
5202
|
}
|
|
5049
5203
|
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.`;
|
|
5050
5204
|
if (n === "failed") {
|
|
5051
5205
|
let e = a.error;
|
|
5052
|
-
return `${s} The \`${r}\` call was approved but execution failed: ${typeof e == "string" ? e :
|
|
5206
|
+
return `${s} The \`${r}\` call was approved but execution failed: ${typeof e == "string" ? e : ho(JSON.stringify(e ?? {}), 400)}. Apologize concisely and offer alternatives.`;
|
|
5053
5207
|
}
|
|
5054
5208
|
}
|
|
5055
|
-
function
|
|
5209
|
+
function ho(e, t) {
|
|
5056
5210
|
return e.length <= t ? e : `${e.slice(0, t - 1)}…`;
|
|
5057
5211
|
}
|
|
5058
5212
|
//#endregion
|
|
5059
5213
|
//#region src/index.tsx
|
|
5060
|
-
var
|
|
5214
|
+
var go = 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) => {
|
|
5061
5215
|
let [m, h] = e.useState(""), g = e.useRef(null), _ = e.useRef(null);
|
|
5062
5216
|
e.useEffect(() => {
|
|
5063
5217
|
if (g.current) {
|
|
@@ -5072,10 +5226,10 @@ var uo = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
5072
5226
|
};
|
|
5073
5227
|
return /* @__PURE__ */ Q("div", {
|
|
5074
5228
|
ref: p,
|
|
5075
|
-
className:
|
|
5229
|
+
className: W("flex flex-col border rounded-lg bg-background overflow-hidden", t),
|
|
5076
5230
|
style: { maxHeight: d },
|
|
5077
5231
|
...f,
|
|
5078
|
-
children: [/* @__PURE__ */ Z(
|
|
5232
|
+
children: [/* @__PURE__ */ Z(se, {
|
|
5079
5233
|
ref: g,
|
|
5080
5234
|
className: "flex-1 p-4",
|
|
5081
5235
|
children: /* @__PURE__ */ Z("div", {
|
|
@@ -5083,7 +5237,7 @@ var uo = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
5083
5237
|
children: n.length === 0 ? /* @__PURE__ */ Z("div", {
|
|
5084
5238
|
className: "flex items-center justify-center h-32 text-muted-foreground text-sm",
|
|
5085
5239
|
children: "No messages yet. Start a conversation!"
|
|
5086
|
-
}) : n.map((e) => /* @__PURE__ */ Z(
|
|
5240
|
+
}) : n.map((e) => /* @__PURE__ */ Z(_o, {
|
|
5087
5241
|
message: e,
|
|
5088
5242
|
showTimestamp: o,
|
|
5089
5243
|
userAvatarUrl: s,
|
|
@@ -5108,14 +5262,14 @@ var uo = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
5108
5262
|
onClick: y,
|
|
5109
5263
|
disabled: a || !m.trim(),
|
|
5110
5264
|
size: "icon",
|
|
5111
|
-
children: /* @__PURE__ */ Z(
|
|
5265
|
+
children: /* @__PURE__ */ Z(ft, { className: "h-4 w-4" })
|
|
5112
5266
|
})]
|
|
5113
5267
|
})
|
|
5114
5268
|
})]
|
|
5115
5269
|
});
|
|
5116
5270
|
});
|
|
5117
|
-
|
|
5118
|
-
var
|
|
5271
|
+
go.displayName = "Chatbot";
|
|
5272
|
+
var _o = ({ message: e, showTimestamp: t, userAvatarUrl: n, userAvatarFallback: r, assistantAvatarUrl: i, assistantAvatarFallback: a }) => {
|
|
5119
5273
|
let o = e.role === "user";
|
|
5120
5274
|
if (e.role === "system") return /* @__PURE__ */ Z("div", {
|
|
5121
5275
|
className: "flex justify-center",
|
|
@@ -5126,7 +5280,7 @@ var fo = ({ message: e, showTimestamp: t, userAvatarUrl: n, userAvatarFallback:
|
|
|
5126
5280
|
});
|
|
5127
5281
|
let s = o ? e.avatar || n : e.avatar || i, c = o ? e.avatarFallback || r : e.avatarFallback || a;
|
|
5128
5282
|
return /* @__PURE__ */ Q("div", {
|
|
5129
|
-
className:
|
|
5283
|
+
className: W("flex gap-3", o ? "flex-row-reverse" : "flex-row"),
|
|
5130
5284
|
children: [/* @__PURE__ */ Q(m, {
|
|
5131
5285
|
className: "h-8 w-8",
|
|
5132
5286
|
children: [/* @__PURE__ */ Z(g, { src: s }), /* @__PURE__ */ Z(h, {
|
|
@@ -5134,9 +5288,9 @@ var fo = ({ message: e, showTimestamp: t, userAvatarUrl: n, userAvatarFallback:
|
|
|
5134
5288
|
children: c
|
|
5135
5289
|
})]
|
|
5136
5290
|
}), /* @__PURE__ */ Q("div", {
|
|
5137
|
-
className:
|
|
5291
|
+
className: W("flex flex-col gap-1", o ? "items-end" : "items-start"),
|
|
5138
5292
|
children: [/* @__PURE__ */ Z("div", {
|
|
5139
|
-
className:
|
|
5293
|
+
className: W("rounded-lg px-4 py-2 max-w-[70%] break-words", o ? "bg-primary text-primary-foreground" : "bg-muted"),
|
|
5140
5294
|
children: /* @__PURE__ */ Z("p", {
|
|
5141
5295
|
className: "text-sm whitespace-pre-wrap",
|
|
5142
5296
|
children: e.content
|
|
@@ -5147,9 +5301,9 @@ var fo = ({ message: e, showTimestamp: t, userAvatarUrl: n, userAvatarFallback:
|
|
|
5147
5301
|
})]
|
|
5148
5302
|
})]
|
|
5149
5303
|
});
|
|
5150
|
-
},
|
|
5304
|
+
}, vo = e.forwardRef(({ className: e, avatarSrc: t, avatarFallback: n = "AI", ...r }, i) => /* @__PURE__ */ Q("div", {
|
|
5151
5305
|
ref: i,
|
|
5152
|
-
className:
|
|
5306
|
+
className: W("flex gap-3", e),
|
|
5153
5307
|
...r,
|
|
5154
5308
|
children: [/* @__PURE__ */ Q(m, {
|
|
5155
5309
|
className: "h-8 w-8",
|
|
@@ -5169,6 +5323,6 @@ var fo = ({ message: e, showTimestamp: t, userAvatarUrl: n, userAvatarFallback:
|
|
|
5169
5323
|
})
|
|
5170
5324
|
})]
|
|
5171
5325
|
}));
|
|
5172
|
-
|
|
5326
|
+
vo.displayName = "TypingIndicator";
|
|
5173
5327
|
//#endregion
|
|
5174
|
-
export {
|
|
5328
|
+
export { Tn as AGENT_ALIAS_GROUPS, Za as AIElements, gn as AI_USAGE_REFRESH_EVENT, co as AiPendingActionsInbox, go as Chatbot, wa as ChatbotEnhanced, Ja as FloatingChatbot, ir as FloatingChatbotPanel, Kn as FloatingChatbotProvider, Qn as FloatingChatbotTrigger, Pn as PLATFORM_DEFAULT_AGENT, vo as TypingIndicator, En as agentAliasGroup, Nn as agentHasCapability, Dn as agentRouteName, mn as authoredToRuntimeMessage, tn as buildProgressFromDraftReview, Zt as detectAuthoringVerdict, Jt as detectBuilderHandoff, Qt as detectBuiltAppPackage, $t as detectDraftResult, Yt as detectProposedChanges, qt as detectProposedPlan, Xt as detectReplayOutcome, _n as emitAiUsageRefresh, or as humanizeToolName, jn as isAskAgent, An as isBuildAgent, kn as isBuiltinAgentName, ca as publishHealthFromResponse, On as resolveAgentParam, Fn as resolveDefaultAgentName, cr as summarizeChatError, hn as toRuntimeMessages, dn as toRuntimeRole, un as toRuntimeTimestamp, pn as toRuntimeToolInvocation, fn as toRuntimeToolState, cn as uiMessageToChatMessage, ln as uiMessagesToChatMessages, sr as unwrapToolResult, Hn as useAgents, Wn as useAiModels, qn as useFloatingChatbot, po as useHitlInChat, wn as useObjectChat, to as usePendingActions };
|