@object-ui/plugin-chatbot 7.0.0 → 7.1.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 +13 -0
- package/dist/ChatbotEnhanced.d.ts +25 -2
- package/dist/ChatbotEnhanced.d.ts.map +1 -1
- package/dist/index.js +764 -694
- package/dist/index.umd.cjs +1 -1
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -1,45 +1,45 @@
|
|
|
1
1
|
import * as e from "react";
|
|
2
2
|
import { Children as t, Fragment as n, createContext as r, isValidElement as i, memo as a, useCallback as o, useContext as s, useEffect as c, useMemo as l, useRef as u, useState as d } from "react";
|
|
3
|
-
import { Alert as f, AlertDescription as p, Avatar as m, AvatarFallback as h, AvatarImage as g, Badge as _, Button as v, Card as y, CardContent as b, CardDescription as x, CardHeader as S, CardTitle as C, Collapsible as w, CollapsibleContent as T, CollapsibleTrigger as E, Command as D, CommandEmpty as O, CommandGroup as k, CommandInput as A, CommandItem as j, CommandList as M, CommandSeparator as N, DropdownMenu as ee, DropdownMenuContent as te, DropdownMenuItem as P, DropdownMenuTrigger as F, Empty as ne, EmptyDescription as
|
|
4
|
-
import { AlertCircle as Oe, ArrowDownIcon as ke, ArrowRight as Ae, BookIcon as je, Bot as Me, BrainIcon as Ne, Check as Pe, CheckCircle2 as Y, CheckCircleIcon as Fe, CheckIcon as Ie, ChevronDownIcon as Le, ChevronLeftIcon as Re, ChevronRightIcon as ze, CircleIcon as Be, ClipboardList as Ve, Clock as He, Clock3 as Ue, ClockIcon as We, Copy as Ge, CopyIcon as Ke, CornerDownLeft as qe, CornerDownLeftIcon as Je, Eye as Ye, GitCompareArrows as Xe, HelpCircle as Ze, ImageIcon as Qe, Inbox as $e, Loader2 as et, Loader2Icon as tt, Maximize2 as nt, MicIcon as rt, Minimize2 as it, PaperclipIcon as at, PlusIcon as ot, RefreshCw as st, Rocket as ct, Send as lt, ShieldCheck as ut, SquareIcon as dt, Table2 as ft, TriangleAlert as pt,
|
|
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 te, DropdownMenuItem as P, DropdownMenuTrigger as F, Empty as ne, EmptyDescription as re, EmptyHeader as I, EmptyMedia as ie, EmptyTitle as ae, HoverCard as L, HoverCardContent as oe, HoverCardTrigger as R, Input as z, Label as B, ScrollArea as se, ScrollBar as ce, Select as le, SelectContent as ue, SelectItem as de, SelectTrigger as fe, SelectValue as pe, Separator as me, Sheet as he, SheetContent as ge, SheetDescription as _e, SheetHeader as ve, SheetTitle as ye, Skeleton as V, Table as be, TableBody as H, TableCell as U, TableHead as W, TableHeader as xe, TableRow as G, Tabs as K, TabsList as Se, TabsTrigger as Ce, Textarea as q, Tooltip as we, TooltipContent as Te, TooltipProvider as Ee, TooltipTrigger as De, cn as J } from "@object-ui/components";
|
|
4
|
+
import { AlertCircle as Oe, ArrowDownIcon as ke, ArrowRight as Ae, BookIcon as je, Bot as Me, BrainIcon as Ne, Check as Pe, CheckCircle2 as Y, CheckCircleIcon as Fe, CheckIcon as Ie, ChevronDownIcon as Le, ChevronLeftIcon as Re, ChevronRightIcon as ze, CircleIcon as Be, ClipboardList as Ve, Clock as He, Clock3 as Ue, ClockIcon as We, Copy as Ge, CopyIcon as Ke, CornerDownLeft as qe, CornerDownLeftIcon as Je, Eye as Ye, GitCompareArrows as Xe, HelpCircle as Ze, ImageIcon as Qe, Inbox as $e, Loader2 as et, Loader2Icon as tt, Maximize2 as nt, MicIcon as rt, Minimize2 as it, PaperclipIcon as at, PlusIcon as ot, RefreshCw as st, Rocket as ct, Send as lt, ShieldCheck as ut, SquareIcon as dt, Table2 as ft, TriangleAlert as pt, WifiOff as mt, WrenchIcon as ht, X as gt, XCircle as X, XCircleIcon as _t, XIcon as vt } from "lucide-react";
|
|
5
5
|
import { Fragment as Z, jsx as Q, jsxs as $ } from "react/jsx-runtime";
|
|
6
|
-
import { useChat as
|
|
7
|
-
import { DefaultChatTransport as
|
|
8
|
-
import * as
|
|
9
|
-
import { SchemaRenderer as
|
|
10
|
-
import { StickToBottom as
|
|
11
|
-
import { cva as
|
|
12
|
-
import { Slot as
|
|
13
|
-
import { Streamdown as
|
|
14
|
-
import { nanoid as
|
|
15
|
-
import { codeToHtml as
|
|
16
|
-
import { useControllableState as
|
|
17
|
-
import { motion as
|
|
18
|
-
import { ComponentRegistry as
|
|
6
|
+
import { useChat as yt } from "@ai-sdk/react";
|
|
7
|
+
import { DefaultChatTransport as bt } from "ai";
|
|
8
|
+
import * as xt from "react-dom";
|
|
9
|
+
import { SchemaRenderer as St, useObjectTranslation as Ct } from "@object-ui/react";
|
|
10
|
+
import { StickToBottom as wt, useStickToBottomContext as Tt } from "use-stick-to-bottom";
|
|
11
|
+
import { cva as Et } from "class-variance-authority";
|
|
12
|
+
import { Slot as Dt } from "@radix-ui/react-slot";
|
|
13
|
+
import { Streamdown as Ot } from "streamdown";
|
|
14
|
+
import { nanoid as kt } from "nanoid";
|
|
15
|
+
import { codeToHtml as At } from "shiki";
|
|
16
|
+
import { useControllableState as jt } from "@radix-ui/react-use-controllable-state";
|
|
17
|
+
import { motion as Mt } from "motion/react";
|
|
18
|
+
import { ComponentRegistry as Nt } from "@object-ui/core";
|
|
19
19
|
//#region \0rolldown/runtime.js
|
|
20
|
-
var
|
|
20
|
+
var Pt = Object.defineProperty, Ft = (e, t) => {
|
|
21
21
|
let n = {};
|
|
22
|
-
for (var r in e)
|
|
22
|
+
for (var r in e) Pt(n, r, {
|
|
23
23
|
get: e[r],
|
|
24
24
|
enumerable: !0
|
|
25
25
|
});
|
|
26
|
-
return t ||
|
|
26
|
+
return t || Pt(n, Symbol.toStringTag, { value: "Module" }), n;
|
|
27
27
|
};
|
|
28
28
|
//#endregion
|
|
29
29
|
//#region src/utils.ts
|
|
30
|
-
function
|
|
30
|
+
function It(e = "msg") {
|
|
31
31
|
return typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID() : `${e}-${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
|
32
32
|
}
|
|
33
33
|
//#endregion
|
|
34
34
|
//#region src/mapMessages.ts
|
|
35
|
-
function
|
|
35
|
+
function Lt(e, t) {
|
|
36
36
|
return typeof e.content == "string" ? e.content : t.filter((e) => e.type === "text").map((e) => e.text ?? "").join("");
|
|
37
37
|
}
|
|
38
|
-
function
|
|
38
|
+
function Rt(e) {
|
|
39
39
|
let t = e.filter((e) => e.type === "reasoning" || e.type === "reasoning-delta").map((e) => e.text ?? "").join("\n").trim();
|
|
40
40
|
return t.length > 0 ? t : void 0;
|
|
41
41
|
}
|
|
42
|
-
function
|
|
42
|
+
function zt(e) {
|
|
43
43
|
let t = (e) => {
|
|
44
44
|
if (e && typeof e == "object") return e;
|
|
45
45
|
if (typeof e != "string") return;
|
|
@@ -62,8 +62,8 @@ function Rt(e) {
|
|
|
62
62
|
}
|
|
63
63
|
return r;
|
|
64
64
|
}
|
|
65
|
-
function
|
|
66
|
-
let t =
|
|
65
|
+
function Bt(e) {
|
|
66
|
+
let t = zt(e);
|
|
67
67
|
if (!t) return;
|
|
68
68
|
let n = t.pendingActionId;
|
|
69
69
|
if (t.status === "pending_approval" && typeof n == "string" && n.length > 0) return {
|
|
@@ -71,11 +71,11 @@ function zt(e) {
|
|
|
71
71
|
raw: t
|
|
72
72
|
};
|
|
73
73
|
}
|
|
74
|
-
function
|
|
74
|
+
function Vt(e) {
|
|
75
75
|
return Array.isArray(e) ? e.filter((e) => typeof e == "string" && e.trim().length > 0) : [];
|
|
76
76
|
}
|
|
77
|
-
function
|
|
78
|
-
let t =
|
|
77
|
+
function Ht(e) {
|
|
78
|
+
let t = zt(e);
|
|
79
79
|
if (!t || t.status !== "blueprint_proposed") return;
|
|
80
80
|
let n = t.blueprint, r = n && typeof n == "object" ? n : {}, i = (Array.isArray(r.objects) ? r.objects : []).flatMap((e) => {
|
|
81
81
|
let t = e;
|
|
@@ -91,7 +91,7 @@ function Vt(e) {
|
|
|
91
91
|
views: a(o.views, Array.isArray(r.views) ? r.views.length : 0),
|
|
92
92
|
dashboards: a(o.dashboards, Array.isArray(r.dashboards) ? r.dashboards.length : 0),
|
|
93
93
|
seedData: a(o.seedData, Array.isArray(r.seedData) ? r.seedData.length : 0)
|
|
94
|
-
}, c =
|
|
94
|
+
}, c = Vt(t.questions), l = t.questionChoices, u = Array.isArray(l) ? l.flatMap((e) => {
|
|
95
95
|
let t = e;
|
|
96
96
|
if (typeof t?.text != "string" || !t.text) return [];
|
|
97
97
|
let n = Array.isArray(t.options) ? t.options.filter((e) => typeof e == "string" && e.trim().length > 0) : [];
|
|
@@ -104,14 +104,14 @@ function Vt(e) {
|
|
|
104
104
|
...d ? { summary: d } : {},
|
|
105
105
|
objects: i,
|
|
106
106
|
counts: s,
|
|
107
|
-
questions: c.length ? c :
|
|
107
|
+
questions: c.length ? c : Vt(r.questions),
|
|
108
108
|
...u.length ? { questionChoices: u } : {},
|
|
109
|
-
assumptions:
|
|
109
|
+
assumptions: Vt(r.assumptions),
|
|
110
110
|
...typeof f == "string" && f ? { targetApp: f } : {}
|
|
111
111
|
};
|
|
112
112
|
}
|
|
113
|
-
function
|
|
114
|
-
let t =
|
|
113
|
+
function Ut(e) {
|
|
114
|
+
let t = zt(e);
|
|
115
115
|
if (!t || t.status !== "drafted") return;
|
|
116
116
|
let n = [];
|
|
117
117
|
if (Array.isArray(t.drafted)) {
|
|
@@ -151,23 +151,23 @@ function Ht(e) {
|
|
|
151
151
|
...s.length ? { issues: s } : {}
|
|
152
152
|
};
|
|
153
153
|
}
|
|
154
|
-
function
|
|
154
|
+
function Wt(e) {
|
|
155
155
|
return e.replace(/[._-]+/g, " ").replace(/\s+/g, " ").trim().replace(/\b\w/g, (e) => e.toUpperCase());
|
|
156
156
|
}
|
|
157
|
-
function
|
|
157
|
+
function Gt(e) {
|
|
158
158
|
if (!e || !Array.isArray(e.items) || e.items.length === 0) return;
|
|
159
159
|
let t = e.items.find((e) => e.type === "app");
|
|
160
160
|
if (t) return {
|
|
161
161
|
phase: "done",
|
|
162
|
-
appLabel:
|
|
162
|
+
appLabel: Wt(t.name),
|
|
163
163
|
items: e.items,
|
|
164
164
|
done: e.items.length,
|
|
165
165
|
total: e.items.length
|
|
166
166
|
};
|
|
167
167
|
}
|
|
168
|
-
function
|
|
168
|
+
function Kt(e, t = {}) {
|
|
169
169
|
return e.filter((e) => e.type === "dynamic-tool" ? !0 : typeof e.type == "string" && e.type.startsWith("tool-")).map((e) => {
|
|
170
|
-
let n = e.type === "dynamic-tool" ? e.toolName ?? "tool" : typeof e.type == "string" ? e.type.replace(/^tool-/, "") : "tool", r = e.output ?? e.result, i =
|
|
170
|
+
let n = e.type === "dynamic-tool" ? e.toolName ?? "tool" : typeof e.type == "string" ? e.type.replace(/^tool-/, "") : "tool", r = e.output ?? e.result, i = Bt(r), a = Ut(r), o = Ht(r), s = e.state, c = (s === "input-available" || s === "input-streaming") && (r !== void 0 || !t.liveTail) ? "output-available" : s, l = i && c !== "output-error" ? "approval-requested" : c;
|
|
171
171
|
return {
|
|
172
172
|
toolCallId: e.toolCallId ?? e.id ?? `${e.type ?? "tool"}-${Math.random().toString(36).slice(2, 8)}`,
|
|
173
173
|
toolName: n,
|
|
@@ -181,7 +181,7 @@ function Gt(e, t = {}) {
|
|
|
181
181
|
};
|
|
182
182
|
});
|
|
183
183
|
}
|
|
184
|
-
function
|
|
184
|
+
function qt(e) {
|
|
185
185
|
let t = e.filter((e) => e.type === "source-url" || e.type === "source").map((e) => ({
|
|
186
186
|
id: e.id,
|
|
187
187
|
title: e.title,
|
|
@@ -189,7 +189,7 @@ function Kt(e) {
|
|
|
189
189
|
})).filter((e) => !!e.url);
|
|
190
190
|
return t.length > 0 ? t : void 0;
|
|
191
191
|
}
|
|
192
|
-
function
|
|
192
|
+
function Jt(e) {
|
|
193
193
|
let t = e.filter((e) => e.type === "data-build-progress").pop()?.data;
|
|
194
194
|
if (!t || typeof t != "object") return;
|
|
195
195
|
let n = t, r = Array.isArray(n.items) ? n.items.filter((e) => typeof e?.type == "string" && typeof e?.name == "string").map((e) => ({
|
|
@@ -205,7 +205,7 @@ function qt(e) {
|
|
|
205
205
|
...typeof n.seq == "number" ? { seq: n.seq } : {}
|
|
206
206
|
};
|
|
207
207
|
}
|
|
208
|
-
function
|
|
208
|
+
function Yt(e) {
|
|
209
209
|
let t = [];
|
|
210
210
|
for (let n of e) {
|
|
211
211
|
if (n.type !== "data-chart") continue;
|
|
@@ -225,28 +225,28 @@ function Jt(e) {
|
|
|
225
225
|
}
|
|
226
226
|
return t.length > 0 ? t : void 0;
|
|
227
227
|
}
|
|
228
|
-
function
|
|
229
|
-
let n = Array.isArray(e.parts) ? e.parts : [], r =
|
|
228
|
+
function Xt(e, t = {}) {
|
|
229
|
+
let n = Array.isArray(e.parts) ? e.parts : [], r = Kt(n, { liveTail: t.streaming }), i = Array.isArray(e.toolInvocations) ? e.toolInvocations : [], a = r.length > 0 ? r : i, o = Jt(n) ?? a.map((e) => Gt(e.draftReview)).find((e) => !!e);
|
|
230
230
|
return {
|
|
231
231
|
id: e.id ?? `msg-${Math.random().toString(36).slice(2, 8)}`,
|
|
232
232
|
role: e.role ?? "assistant",
|
|
233
|
-
content:
|
|
234
|
-
reasoning:
|
|
233
|
+
content: Lt(e, n),
|
|
234
|
+
reasoning: Rt(n),
|
|
235
235
|
toolInvocations: a,
|
|
236
|
-
sources:
|
|
236
|
+
sources: qt(n),
|
|
237
237
|
buildProgress: o,
|
|
238
|
-
charts:
|
|
238
|
+
charts: Yt(n),
|
|
239
239
|
streaming: t.streaming
|
|
240
240
|
};
|
|
241
241
|
}
|
|
242
|
-
function
|
|
242
|
+
function Zt(e, t = {}) {
|
|
243
243
|
if (!Array.isArray(e) || e.length === 0) return [];
|
|
244
244
|
let n = e.length - 1;
|
|
245
|
-
return e.map((e, r) =>
|
|
245
|
+
return e.map((e, r) => Xt(e, { streaming: !!t.isStreaming && r === n && e.role === "assistant" }));
|
|
246
246
|
}
|
|
247
247
|
//#endregion
|
|
248
248
|
//#region src/useObjectChat.ts
|
|
249
|
-
function
|
|
249
|
+
function Qt(e) {
|
|
250
250
|
let t = [...e.messages].reverse().find((e) => e.role === "user");
|
|
251
251
|
return { body: {
|
|
252
252
|
...e.body ?? {},
|
|
@@ -257,7 +257,7 @@ function Zt(e) {
|
|
|
257
257
|
...t ? { turnId: t.id } : {}
|
|
258
258
|
} };
|
|
259
259
|
}
|
|
260
|
-
function
|
|
260
|
+
function $t(e) {
|
|
261
261
|
return (e ?? []).map((e, t) => ({
|
|
262
262
|
id: e.id || `msg-${t}`,
|
|
263
263
|
role: e.role || "user",
|
|
@@ -268,14 +268,14 @@ function Qt(e) {
|
|
|
268
268
|
toolInvocations: e.toolInvocations
|
|
269
269
|
}));
|
|
270
270
|
}
|
|
271
|
-
function
|
|
271
|
+
function en(e = {}) {
|
|
272
272
|
let { api: t, initialMessages: n, conversationId: r, systemPrompt: i, model: a, streamingEnabled: s = !0, headers: f, body: p, maxToolRoundtrips: m = 5, onError: h, showTimestamp: g, autoResponse: _, autoResponseText: v, autoResponseDelay: y = 1e3, onSend: b } = e, x = u(t ? "api" : "local").current === "api", S = l(() => (n ?? []).map((e, t) => {
|
|
273
273
|
if (Array.isArray(e.parts) && e.parts.length > 0) return {
|
|
274
274
|
id: e.id || `msg-${t}`,
|
|
275
275
|
role: e.role || "user",
|
|
276
276
|
parts: e.parts
|
|
277
277
|
};
|
|
278
|
-
let n =
|
|
278
|
+
let n = $t([e])[0], r = [];
|
|
279
279
|
n.content && r.push({
|
|
280
280
|
type: "text",
|
|
281
281
|
text: n.content
|
|
@@ -300,9 +300,9 @@ function $t(e = {}) {
|
|
|
300
300
|
text: ""
|
|
301
301
|
}]
|
|
302
302
|
};
|
|
303
|
-
}), []), C =
|
|
303
|
+
}), []), C = yt({
|
|
304
304
|
transport: l(() => {
|
|
305
|
-
if (x) return new
|
|
305
|
+
if (x) return new bt({
|
|
306
306
|
api: t,
|
|
307
307
|
headers: { ...f },
|
|
308
308
|
body: {
|
|
@@ -312,7 +312,7 @@ function $t(e = {}) {
|
|
|
312
312
|
...i ? { systemPrompt: i } : {},
|
|
313
313
|
...s === void 0 ? {} : { stream: s }
|
|
314
314
|
},
|
|
315
|
-
prepareSendMessagesRequest: ({ id: e, body: t, messages: n, trigger: r, messageId: i }) =>
|
|
315
|
+
prepareSendMessagesRequest: ({ id: e, body: t, messages: n, trigger: r, messageId: i }) => Qt({
|
|
316
316
|
id: e,
|
|
317
317
|
body: t,
|
|
318
318
|
messages: n,
|
|
@@ -334,11 +334,11 @@ function $t(e = {}) {
|
|
|
334
334
|
onError: x ? (e) => {
|
|
335
335
|
h?.(e);
|
|
336
336
|
} : void 0
|
|
337
|
-
}), [w, T] = d(() =>
|
|
337
|
+
}), [w, T] = d(() => $t(n)), [E, D] = d(!1), [O, k] = d(""), [A, j] = d(""), M = u(null);
|
|
338
338
|
if (c(() => () => {
|
|
339
339
|
M.current &&= (clearTimeout(M.current), null);
|
|
340
340
|
}, []), x) {
|
|
341
|
-
let { messages: e, status: t, error: n, sendMessage: r, regenerate: i, stop: a, setMessages: s } = C, c = t === "submitted" || t === "streaming", l =
|
|
341
|
+
let { messages: e, status: t, error: n, sendMessage: r, regenerate: i, stop: a, setMessages: s } = C, c = t === "submitted" || t === "streaming", l = Zt(e, { isStreaming: c }).map((t, n) => ({
|
|
342
342
|
...t,
|
|
343
343
|
metadata: e[n]?.metadata
|
|
344
344
|
}));
|
|
@@ -350,7 +350,7 @@ function $t(e = {}) {
|
|
|
350
350
|
let t = e.trim();
|
|
351
351
|
if (!t) return;
|
|
352
352
|
let n = [...l, {
|
|
353
|
-
id:
|
|
353
|
+
id: It("msg"),
|
|
354
354
|
role: "user",
|
|
355
355
|
content: t
|
|
356
356
|
}];
|
|
@@ -384,7 +384,7 @@ function $t(e = {}) {
|
|
|
384
384
|
sendMessage: o((e) => {
|
|
385
385
|
if (!e.trim()) return;
|
|
386
386
|
let t = {
|
|
387
|
-
id:
|
|
387
|
+
id: It("msg"),
|
|
388
388
|
role: "user",
|
|
389
389
|
content: e.trim(),
|
|
390
390
|
timestamp: g ? (/* @__PURE__ */ new Date()).toLocaleTimeString() : void 0
|
|
@@ -394,7 +394,7 @@ function $t(e = {}) {
|
|
|
394
394
|
return b?.(e.trim(), r), r;
|
|
395
395
|
}), k(""), _ && (D(!0), M.current = setTimeout(() => {
|
|
396
396
|
let e = {
|
|
397
|
-
id:
|
|
397
|
+
id: It("msg"),
|
|
398
398
|
role: "assistant",
|
|
399
399
|
content: v || "Thank you for your message!",
|
|
400
400
|
timestamp: g ? (/* @__PURE__ */ new Date()).toLocaleTimeString() : void 0
|
|
@@ -423,41 +423,41 @@ function $t(e = {}) {
|
|
|
423
423
|
}
|
|
424
424
|
//#endregion
|
|
425
425
|
//#region src/agentAliases.ts
|
|
426
|
-
var
|
|
427
|
-
function tn(e) {
|
|
428
|
-
return en.find((t) => t.includes(e)) ?? [e];
|
|
429
|
-
}
|
|
426
|
+
var tn = [["build", "metadata_assistant"], ["ask", "data_chat"]];
|
|
430
427
|
function nn(e) {
|
|
431
|
-
return tn(e)[
|
|
428
|
+
return tn.find((t) => t.includes(e)) ?? [e];
|
|
432
429
|
}
|
|
433
|
-
function rn(e
|
|
430
|
+
function rn(e) {
|
|
431
|
+
return nn(e)[0];
|
|
432
|
+
}
|
|
433
|
+
function an(e, t) {
|
|
434
434
|
if (e) {
|
|
435
435
|
if (t.includes(e)) return e;
|
|
436
|
-
for (let n of
|
|
436
|
+
for (let n of nn(e)) if (t.includes(n)) return n;
|
|
437
437
|
}
|
|
438
438
|
}
|
|
439
|
-
function an(e) {
|
|
440
|
-
return e != null && en.some((t) => t.includes(e));
|
|
441
|
-
}
|
|
442
439
|
function on(e) {
|
|
443
|
-
return e != null &&
|
|
440
|
+
return e != null && tn.some((t) => t.includes(e));
|
|
444
441
|
}
|
|
445
442
|
function sn(e) {
|
|
446
|
-
return e != null &&
|
|
443
|
+
return e != null && rn(e) === "build";
|
|
444
|
+
}
|
|
445
|
+
function cn(e) {
|
|
446
|
+
return e != null && rn(e) === "ask";
|
|
447
447
|
}
|
|
448
448
|
//#endregion
|
|
449
449
|
//#region src/useAgents.ts
|
|
450
|
-
var
|
|
451
|
-
function
|
|
450
|
+
var ln = "ask";
|
|
451
|
+
function un(e, t) {
|
|
452
452
|
if (e.length === 0) return;
|
|
453
453
|
let n = e.map((e) => e.name);
|
|
454
454
|
if (t) {
|
|
455
|
-
let e =
|
|
455
|
+
let e = an(t, n);
|
|
456
456
|
if (e) return e;
|
|
457
457
|
}
|
|
458
|
-
return
|
|
458
|
+
return an("ask", n) || e[0].name;
|
|
459
459
|
}
|
|
460
|
-
function
|
|
460
|
+
function dn(e) {
|
|
461
461
|
return e.filter((e) => typeof e?.name == "string" && e.name.length > 0).map((e) => ({
|
|
462
462
|
name: e.name,
|
|
463
463
|
label: e.label || e.name,
|
|
@@ -466,7 +466,7 @@ function un(e) {
|
|
|
466
466
|
active: e.active !== !1
|
|
467
467
|
}));
|
|
468
468
|
}
|
|
469
|
-
function
|
|
469
|
+
function fn(e = {}) {
|
|
470
470
|
let { apiBase: t, headers: n, enabled: r = !0, fallback: i = [] } = e, [a, s] = d(i), [l, f] = d(!1), [p, m] = d(void 0), [h, g] = d(0), _ = u(n);
|
|
471
471
|
return _.current = n, c(() => {
|
|
472
472
|
if (!r || !t) return;
|
|
@@ -486,7 +486,7 @@ function dn(e = {}) {
|
|
|
486
486
|
return e.json();
|
|
487
487
|
}).then((e) => {
|
|
488
488
|
if (n) return;
|
|
489
|
-
let t =
|
|
489
|
+
let t = dn(Array.isArray(e) ? e : e?.agents ?? []);
|
|
490
490
|
s(t.length > 0 ? t : i);
|
|
491
491
|
}).catch((e) => {
|
|
492
492
|
n || e.name === "AbortError" || (m(e), s(i));
|
|
@@ -508,8 +508,8 @@ function dn(e = {}) {
|
|
|
508
508
|
}
|
|
509
509
|
//#endregion
|
|
510
510
|
//#region src/FloatingChatbotProvider.tsx
|
|
511
|
-
var
|
|
512
|
-
function
|
|
511
|
+
var pn = e.createContext(null);
|
|
512
|
+
function mn({ defaultOpen: t = !1, children: n }) {
|
|
513
513
|
let [r, i] = e.useState(t), [a, o] = e.useState(!1), s = e.useMemo(() => ({
|
|
514
514
|
isOpen: r,
|
|
515
515
|
isFullscreen: a,
|
|
@@ -520,21 +520,21 @@ function pn({ defaultOpen: t = !1, children: n }) {
|
|
|
520
520
|
toggle: () => i((e) => !e),
|
|
521
521
|
toggleFullscreen: () => o((e) => !e)
|
|
522
522
|
}), [r, a]);
|
|
523
|
-
return /* @__PURE__ */ Q(
|
|
523
|
+
return /* @__PURE__ */ Q(pn.Provider, {
|
|
524
524
|
value: s,
|
|
525
525
|
children: n
|
|
526
526
|
});
|
|
527
527
|
}
|
|
528
|
-
function
|
|
529
|
-
let t = e.useContext(
|
|
528
|
+
function hn() {
|
|
529
|
+
let t = e.useContext(pn);
|
|
530
530
|
if (!t) throw Error("useFloatingChatbot must be used within a <FloatingChatbotProvider>");
|
|
531
531
|
return t;
|
|
532
532
|
}
|
|
533
533
|
//#endregion
|
|
534
534
|
//#region src/FloatingChatbotTrigger.tsx
|
|
535
|
-
function
|
|
535
|
+
function gn() {
|
|
536
536
|
try {
|
|
537
|
-
let { t: e } =
|
|
537
|
+
let { t: e } = Ct();
|
|
538
538
|
return (t, n) => {
|
|
539
539
|
let r = e(`common.${t}`);
|
|
540
540
|
return !r || r === `common.${t}` ? n : r;
|
|
@@ -543,7 +543,7 @@ function hn() {
|
|
|
543
543
|
return (e, t) => t;
|
|
544
544
|
}
|
|
545
545
|
}
|
|
546
|
-
var
|
|
546
|
+
var _n = {
|
|
547
547
|
32: "size-8",
|
|
548
548
|
36: "size-9",
|
|
549
549
|
40: "size-10",
|
|
@@ -556,26 +556,26 @@ var gn = {
|
|
|
556
556
|
72: "size-[72px]",
|
|
557
557
|
80: "size-20"
|
|
558
558
|
};
|
|
559
|
-
function
|
|
559
|
+
function vn(e, t) {
|
|
560
560
|
return t.reduce((t, n) => Math.abs(n - e) < Math.abs(t - e) ? n : t);
|
|
561
561
|
}
|
|
562
|
-
function
|
|
563
|
-
return
|
|
562
|
+
function yn(e) {
|
|
563
|
+
return _n[e] ?? _n[vn(e, Object.keys(_n).map(Number))];
|
|
564
564
|
}
|
|
565
|
-
function
|
|
566
|
-
let { isOpen: r, toggle: i } =
|
|
565
|
+
function bn({ position: e = "bottom-right", size: t = 56, className: n }) {
|
|
566
|
+
let { isOpen: r, toggle: i } = hn(), a = gn();
|
|
567
567
|
return /* @__PURE__ */ Q(v, {
|
|
568
568
|
onClick: i,
|
|
569
|
-
className: J("fixed z-50 rounded-full shadow-lg transition-transform hover:scale-105",
|
|
569
|
+
className: J("fixed z-50 rounded-full shadow-lg transition-transform hover:scale-105", yn(t), r && "hidden", e === "bottom-right" ? "right-6 bottom-20 sm:bottom-6" : "left-6 bottom-20 sm:bottom-6", n),
|
|
570
570
|
size: "icon",
|
|
571
571
|
"aria-label": r ? a("closeChat", "Close chat") : a("openChat", "Open chat"),
|
|
572
572
|
"data-testid": "floating-chatbot-trigger",
|
|
573
|
-
children: Q(r ?
|
|
573
|
+
children: Q(r ? gt : Me, { className: "h-6 w-6" })
|
|
574
574
|
});
|
|
575
575
|
}
|
|
576
576
|
//#endregion
|
|
577
577
|
//#region src/FloatingChatbotPanel.tsx
|
|
578
|
-
var
|
|
578
|
+
var xn = {
|
|
579
579
|
300: "sm:w-[300px]",
|
|
580
580
|
320: "sm:w-[320px]",
|
|
581
581
|
340: "sm:w-[340px]",
|
|
@@ -594,7 +594,7 @@ var bn = {
|
|
|
594
594
|
640: "sm:w-[640px]",
|
|
595
595
|
720: "sm:w-[720px]",
|
|
596
596
|
800: "sm:w-[800px]"
|
|
597
|
-
},
|
|
597
|
+
}, Sn = {
|
|
598
598
|
360: "h-[min(360px,calc(100svh_-_6rem_-_env(safe-area-inset-bottom)))] sm:h-[360px]",
|
|
599
599
|
400: "h-[min(400px,calc(100svh_-_6rem_-_env(safe-area-inset-bottom)))] sm:h-[400px]",
|
|
600
600
|
420: "h-[min(420px,calc(100svh_-_6rem_-_env(safe-area-inset-bottom)))] sm:h-[420px]",
|
|
@@ -608,19 +608,19 @@ var bn = {
|
|
|
608
608
|
720: "h-[min(720px,calc(100svh_-_6rem_-_env(safe-area-inset-bottom)))] sm:h-[720px]",
|
|
609
609
|
800: "h-[min(800px,calc(100svh_-_6rem_-_env(safe-area-inset-bottom)))] sm:h-[800px]"
|
|
610
610
|
};
|
|
611
|
-
function
|
|
611
|
+
function Cn(e, t) {
|
|
612
612
|
return t.reduce((t, n) => Math.abs(n - e) < Math.abs(t - e) ? n : t);
|
|
613
613
|
}
|
|
614
|
-
function Cn(e) {
|
|
615
|
-
return bn[e] ?? bn[Sn(e, Object.keys(bn).map(Number))];
|
|
616
|
-
}
|
|
617
614
|
function wn(e) {
|
|
618
|
-
return xn[e] ?? xn[
|
|
615
|
+
return xn[e] ?? xn[Cn(e, Object.keys(xn).map(Number))];
|
|
619
616
|
}
|
|
620
|
-
function Tn(
|
|
621
|
-
|
|
617
|
+
function Tn(e) {
|
|
618
|
+
return Sn[e] ?? Sn[Cn(e, Object.keys(Sn).map(Number))];
|
|
619
|
+
}
|
|
620
|
+
function En({ title: e = "Chat", position: t = "bottom-right", width: n = 400, height: r = 520, children: i, className: a, headerExtra: o, headerActions: s }) {
|
|
621
|
+
let { isOpen: c, isFullscreen: l, close: u, toggleFullscreen: d } = hn();
|
|
622
622
|
return c ? /* @__PURE__ */ $("div", {
|
|
623
|
-
className: J("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" ? J("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)]",
|
|
623
|
+
className: J("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" ? J("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)]", wn(n), Tn(r)) : J("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)]", wn(n), Tn(r)), a),
|
|
624
624
|
role: "dialog",
|
|
625
625
|
"aria-label": e,
|
|
626
626
|
"data-testid": "floating-chatbot-panel",
|
|
@@ -656,7 +656,7 @@ function Tn({ title: e = "Chat", position: t = "bottom-right", width: n = 400, h
|
|
|
656
656
|
onClick: u,
|
|
657
657
|
"aria-label": "Close chat",
|
|
658
658
|
"data-testid": "floating-chatbot-close",
|
|
659
|
-
children: /* @__PURE__ */ Q(
|
|
659
|
+
children: /* @__PURE__ */ Q(gt, { className: "h-4 w-4" })
|
|
660
660
|
})
|
|
661
661
|
]
|
|
662
662
|
})
|
|
@@ -669,7 +669,7 @@ function Tn({ title: e = "Chat", position: t = "bottom-right", width: n = 400, h
|
|
|
669
669
|
}
|
|
670
670
|
//#endregion
|
|
671
671
|
//#region src/tool-display.ts
|
|
672
|
-
var
|
|
672
|
+
var Dn = {
|
|
673
673
|
ai: "AI",
|
|
674
674
|
api: "API",
|
|
675
675
|
crm: "CRM",
|
|
@@ -681,17 +681,17 @@ var En = {
|
|
|
681
681
|
url: "URL",
|
|
682
682
|
utc: "UTC"
|
|
683
683
|
};
|
|
684
|
-
function
|
|
684
|
+
function On(e) {
|
|
685
685
|
if (!e) return "";
|
|
686
686
|
let t = String(e).trim();
|
|
687
687
|
if (!t) return "";
|
|
688
688
|
let n = t.replace(/[_-]+/g, " ").replace(/([a-z])([A-Z])/g, "$1 $2").split(/\s+/).filter(Boolean);
|
|
689
689
|
return n.length === 0 ? t : n.map((e, t) => {
|
|
690
690
|
let n = e.toLowerCase();
|
|
691
|
-
return
|
|
691
|
+
return Dn[n] ? Dn[n] : t === 0 ? n.charAt(0).toUpperCase() + n.slice(1) : n;
|
|
692
692
|
}).join(" ");
|
|
693
693
|
}
|
|
694
|
-
function
|
|
694
|
+
function kn(e) {
|
|
695
695
|
if (e == null) return e;
|
|
696
696
|
let t = e;
|
|
697
697
|
for (let e = 0; e < 2; e++) {
|
|
@@ -709,7 +709,7 @@ function On(e) {
|
|
|
709
709
|
}
|
|
710
710
|
return t;
|
|
711
711
|
}
|
|
712
|
-
function
|
|
712
|
+
function An(e) {
|
|
713
713
|
let t = (e instanceof Error ? e.message : String(e ?? "")).replace(/\s+/g, " ").trim();
|
|
714
714
|
if (!t) return { summary: "Something went wrong. Please try again." };
|
|
715
715
|
let n = t.replace(/^Failed after \d+ attempts?\.\s*Last error:\s*/i, ""), r = n.match(/^Invalid error response format:\s*(.+)$/i)?.[1]?.trim() ?? n, i = r.match(/^([^:]{8,80}):\s+(.+)$/)?.[1]?.trim() ?? r.match(/^([^.;!?]+[.;!?])\s/)?.[1]?.trim() ?? (r.length > 140 ? `${r.slice(0, 137).trimEnd()}…` : r);
|
|
@@ -718,12 +718,12 @@ function kn(e) {
|
|
|
718
718
|
details: n.length > i.length ? n : void 0
|
|
719
719
|
};
|
|
720
720
|
}
|
|
721
|
-
var
|
|
721
|
+
var jn = new Set([
|
|
722
722
|
"ai_design_quota_exhausted",
|
|
723
723
|
"ai_data_chat_trial_exhausted",
|
|
724
724
|
"ai_allowance_exhausted"
|
|
725
725
|
]);
|
|
726
|
-
function
|
|
726
|
+
function Mn(e) {
|
|
727
727
|
let t = e instanceof Error ? e.message : String(e ?? "");
|
|
728
728
|
if (!t) return null;
|
|
729
729
|
let n = t.replace(/^Failed after \d+ attempts?\.\s*Last error:\s*/i, "").replace(/^Invalid error response format:\s*/i, "").trim(), r = n.indexOf("{"), i = n.lastIndexOf("}");
|
|
@@ -734,7 +734,7 @@ function jn(e) {
|
|
|
734
734
|
} catch {
|
|
735
735
|
return null;
|
|
736
736
|
}
|
|
737
|
-
return !a || typeof a.error != "string" || !
|
|
737
|
+
return !a || typeof a.error != "string" || !jn.has(a.error) ? null : {
|
|
738
738
|
code: a.error,
|
|
739
739
|
message: typeof a.message == "string" ? a.message : "",
|
|
740
740
|
messageEn: typeof a.messageEn == "string" ? a.messageEn : void 0,
|
|
@@ -744,16 +744,16 @@ function jn(e) {
|
|
|
744
744
|
}
|
|
745
745
|
//#endregion
|
|
746
746
|
//#region src/elements/conversation.tsx
|
|
747
|
-
var
|
|
747
|
+
var Nn = ({ className: e, ...t }) => /* @__PURE__ */ Q(wt, {
|
|
748
748
|
className: J("relative flex-1 overflow-y-hidden", e),
|
|
749
749
|
initial: "smooth",
|
|
750
750
|
resize: "smooth",
|
|
751
751
|
role: "log",
|
|
752
752
|
...t
|
|
753
|
-
}),
|
|
753
|
+
}), Pn = ({ className: e, ...t }) => /* @__PURE__ */ Q(wt.Content, {
|
|
754
754
|
className: J("flex flex-col gap-8 p-4", e),
|
|
755
755
|
...t
|
|
756
|
-
}),
|
|
756
|
+
}), Fn = ({ className: e, title: t = "No messages yet", description: n = "Start a conversation to see messages here", icon: r, children: i, ...a }) => /* @__PURE__ */ Q("div", {
|
|
757
757
|
className: J("flex size-full flex-col items-center justify-center gap-3 p-8 text-center", e),
|
|
758
758
|
...a,
|
|
759
759
|
children: i ?? /* @__PURE__ */ $(Z, { children: [r && /* @__PURE__ */ Q("div", {
|
|
@@ -769,8 +769,8 @@ var Mn = ({ className: e, ...t }) => /* @__PURE__ */ Q(Ct, {
|
|
|
769
769
|
children: n
|
|
770
770
|
})]
|
|
771
771
|
})] })
|
|
772
|
-
}),
|
|
773
|
-
let { isAtBottom: n, scrollToBottom: r } =
|
|
772
|
+
}), In = ({ className: e, ...t }) => {
|
|
773
|
+
let { isAtBottom: n, scrollToBottom: r } = Tt(), i = o(() => {
|
|
774
774
|
r();
|
|
775
775
|
}, [r]);
|
|
776
776
|
return !n && /* @__PURE__ */ Q(v, {
|
|
@@ -782,42 +782,42 @@ var Mn = ({ className: e, ...t }) => /* @__PURE__ */ Q(Ct, {
|
|
|
782
782
|
...t,
|
|
783
783
|
children: /* @__PURE__ */ Q(ke, { className: "size-4" })
|
|
784
784
|
});
|
|
785
|
-
},
|
|
785
|
+
}, Ln = Et("flex w-fit items-stretch has-[>[data-slot=button-group]]:gap-2 [&>*]:focus-visible:relative [&>*]:focus-visible:z-10 has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-r-md [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1", {
|
|
786
786
|
variants: { orientation: {
|
|
787
787
|
horizontal: "[&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0 [&>*:not(:last-child)]:rounded-r-none",
|
|
788
788
|
vertical: "flex-col [&>*:not(:first-child)]:rounded-t-none [&>*:not(:first-child)]:border-t-0 [&>*:not(:last-child)]:rounded-b-none"
|
|
789
789
|
} },
|
|
790
790
|
defaultVariants: { orientation: "horizontal" }
|
|
791
791
|
});
|
|
792
|
-
function
|
|
792
|
+
function Rn({ className: e, orientation: t, ...n }) {
|
|
793
793
|
return /* @__PURE__ */ Q("div", {
|
|
794
794
|
role: "group",
|
|
795
795
|
"data-slot": "button-group",
|
|
796
796
|
"data-orientation": t,
|
|
797
|
-
className: J(
|
|
797
|
+
className: J(Ln({ orientation: t }), e),
|
|
798
798
|
...n
|
|
799
799
|
});
|
|
800
800
|
}
|
|
801
|
-
function
|
|
802
|
-
return /* @__PURE__ */ Q(t ?
|
|
801
|
+
function zn({ className: e, asChild: t = !1, ...n }) {
|
|
802
|
+
return /* @__PURE__ */ Q(t ? Dt : "div", {
|
|
803
803
|
className: J("flex items-center gap-2 rounded-md border bg-muted px-4 text-sm font-medium shadow-xs [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4", e),
|
|
804
804
|
...n
|
|
805
805
|
});
|
|
806
806
|
}
|
|
807
807
|
//#endregion
|
|
808
808
|
//#region src/elements/message.tsx
|
|
809
|
-
var
|
|
809
|
+
var Bn = ({ className: e, from: t, ...n }) => /* @__PURE__ */ Q("div", {
|
|
810
810
|
className: J("group flex w-full max-w-[95%] flex-col gap-2", t === "user" ? "is-user ml-auto justify-end" : "is-assistant", e),
|
|
811
811
|
...n
|
|
812
|
-
}),
|
|
812
|
+
}), Vn = ({ children: e, className: t, ...n }) => /* @__PURE__ */ Q("div", {
|
|
813
813
|
className: J("is-user:dark flex w-fit max-w-full min-w-0 flex-col gap-2 overflow-hidden text-sm", "group-[.is-user]:ml-auto group-[.is-user]:rounded-lg group-[.is-user]:bg-secondary group-[.is-user]:px-4 group-[.is-user]:py-3 group-[.is-user]:text-foreground", "group-[.is-assistant]:text-foreground", t),
|
|
814
814
|
...n,
|
|
815
815
|
children: e
|
|
816
|
-
}),
|
|
816
|
+
}), Hn = ({ className: e, children: t, ...n }) => /* @__PURE__ */ Q("div", {
|
|
817
817
|
className: J("flex items-center gap-1", e),
|
|
818
818
|
...n,
|
|
819
819
|
children: t
|
|
820
|
-
}),
|
|
820
|
+
}), Un = ({ tooltip: e, children: t, label: n, variant: r = "ghost", size: i = "icon", ...a }) => {
|
|
821
821
|
let o = /* @__PURE__ */ $(v, {
|
|
822
822
|
size: i,
|
|
823
823
|
type: "button",
|
|
@@ -832,11 +832,11 @@ var zn = ({ className: e, from: t, ...n }) => /* @__PURE__ */ Q("div", {
|
|
|
832
832
|
asChild: !0,
|
|
833
833
|
children: o
|
|
834
834
|
}), /* @__PURE__ */ Q(Te, { children: /* @__PURE__ */ Q("p", { children: e }) })] }) }) : o;
|
|
835
|
-
},
|
|
836
|
-
let e = s(
|
|
835
|
+
}, Wn = r(null), Gn = () => {
|
|
836
|
+
let e = s(Wn);
|
|
837
837
|
if (!e) throw Error("MessageBranch components must be used within MessageBranch");
|
|
838
838
|
return e;
|
|
839
|
-
},
|
|
839
|
+
}, Kn = ({ defaultBranch: e = 0, onBranchChange: t, className: n, ...r }) => {
|
|
840
840
|
let [i, a] = d(e), [o, s] = d([]), c = (e) => {
|
|
841
841
|
a(e), t?.(e);
|
|
842
842
|
}, l = {
|
|
@@ -851,15 +851,15 @@ var zn = ({ className: e, from: t, ...n }) => /* @__PURE__ */ Q("div", {
|
|
|
851
851
|
branches: o,
|
|
852
852
|
setBranches: s
|
|
853
853
|
};
|
|
854
|
-
return /* @__PURE__ */ Q(
|
|
854
|
+
return /* @__PURE__ */ Q(Wn.Provider, {
|
|
855
855
|
value: l,
|
|
856
856
|
children: /* @__PURE__ */ Q("div", {
|
|
857
857
|
className: J("grid w-full gap-2 [&>div]:pb-0", n),
|
|
858
858
|
...r
|
|
859
859
|
})
|
|
860
860
|
});
|
|
861
|
-
},
|
|
862
|
-
let { currentBranch: n, setBranches: r, branches: i } =
|
|
861
|
+
}, qn = ({ children: e, ...t }) => {
|
|
862
|
+
let { currentBranch: n, setBranches: r, branches: i } = Gn(), a = Array.isArray(e) ? e : [e];
|
|
863
863
|
return c(() => {
|
|
864
864
|
i.length !== a.length && r(a);
|
|
865
865
|
}, [
|
|
@@ -871,15 +871,15 @@ var zn = ({ className: e, from: t, ...n }) => /* @__PURE__ */ Q("div", {
|
|
|
871
871
|
...t,
|
|
872
872
|
children: e
|
|
873
873
|
}, e.key));
|
|
874
|
-
},
|
|
875
|
-
let { totalBranches: r } =
|
|
876
|
-
return r <= 1 ? null : /* @__PURE__ */ Q(
|
|
874
|
+
}, Jn = ({ className: e, from: t, ...n }) => {
|
|
875
|
+
let { totalBranches: r } = Gn();
|
|
876
|
+
return r <= 1 ? null : /* @__PURE__ */ Q(Rn, {
|
|
877
877
|
className: "[&>*:not(:first-child)]:rounded-l-md [&>*:not(:last-child)]:rounded-r-md",
|
|
878
878
|
orientation: "horizontal",
|
|
879
879
|
...n
|
|
880
880
|
});
|
|
881
|
-
},
|
|
882
|
-
let { goToPrevious: n, totalBranches: r } =
|
|
881
|
+
}, Yn = ({ children: e, ...t }) => {
|
|
882
|
+
let { goToPrevious: n, totalBranches: r } = Gn();
|
|
883
883
|
return /* @__PURE__ */ Q(v, {
|
|
884
884
|
"aria-label": "Previous branch",
|
|
885
885
|
disabled: r <= 1,
|
|
@@ -890,8 +890,8 @@ var zn = ({ className: e, from: t, ...n }) => /* @__PURE__ */ Q("div", {
|
|
|
890
890
|
...t,
|
|
891
891
|
children: e ?? /* @__PURE__ */ Q(Re, { size: 14 })
|
|
892
892
|
});
|
|
893
|
-
},
|
|
894
|
-
let { goToNext: r, totalBranches: i } =
|
|
893
|
+
}, Xn = ({ children: e, className: t, ...n }) => {
|
|
894
|
+
let { goToNext: r, totalBranches: i } = Gn();
|
|
895
895
|
return /* @__PURE__ */ Q(v, {
|
|
896
896
|
"aria-label": "Next branch",
|
|
897
897
|
disabled: i <= 1,
|
|
@@ -902,9 +902,9 @@ var zn = ({ className: e, from: t, ...n }) => /* @__PURE__ */ Q("div", {
|
|
|
902
902
|
...n,
|
|
903
903
|
children: e ?? /* @__PURE__ */ Q(ze, { size: 14 })
|
|
904
904
|
});
|
|
905
|
-
},
|
|
906
|
-
let { currentBranch: n, totalBranches: r } =
|
|
907
|
-
return /* @__PURE__ */ $(
|
|
905
|
+
}, Zn = ({ className: e, ...t }) => {
|
|
906
|
+
let { currentBranch: n, totalBranches: r } = Gn();
|
|
907
|
+
return /* @__PURE__ */ $(zn, {
|
|
908
908
|
className: J("border-none bg-transparent text-muted-foreground shadow-none", e),
|
|
909
909
|
...t,
|
|
910
910
|
children: [
|
|
@@ -913,12 +913,12 @@ var zn = ({ className: e, from: t, ...n }) => /* @__PURE__ */ Q("div", {
|
|
|
913
913
|
r
|
|
914
914
|
]
|
|
915
915
|
});
|
|
916
|
-
},
|
|
916
|
+
}, Qn = a(({ className: e, ...t }) => /* @__PURE__ */ Q(Ot, {
|
|
917
917
|
className: J("size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0", e),
|
|
918
918
|
...t
|
|
919
919
|
}), (e, t) => e.children === t.children);
|
|
920
|
-
|
|
921
|
-
function
|
|
920
|
+
Qn.displayName = "MessageResponse";
|
|
921
|
+
function $n({ data: e, className: t, onRemove: n, ...r }) {
|
|
922
922
|
let i = e.filename || "", a = (e.mediaType?.startsWith("image/") && e.url ? "image" : "file") == "image", o = i || (a ? "Image" : "Attachment");
|
|
923
923
|
return /* @__PURE__ */ Q("div", {
|
|
924
924
|
className: J("group relative size-24 overflow-hidden rounded-lg", t),
|
|
@@ -937,7 +937,7 @@ function Qn({ data: e, className: t, onRemove: n, ...r }) {
|
|
|
937
937
|
},
|
|
938
938
|
type: "button",
|
|
939
939
|
variant: "ghost",
|
|
940
|
-
children: [/* @__PURE__ */ Q(
|
|
940
|
+
children: [/* @__PURE__ */ Q(vt, {}), /* @__PURE__ */ Q("span", {
|
|
941
941
|
className: "sr-only",
|
|
942
942
|
children: "Remove"
|
|
943
943
|
})]
|
|
@@ -955,28 +955,28 @@ function Qn({ data: e, className: t, onRemove: n, ...r }) {
|
|
|
955
955
|
},
|
|
956
956
|
type: "button",
|
|
957
957
|
variant: "ghost",
|
|
958
|
-
children: [/* @__PURE__ */ Q(
|
|
958
|
+
children: [/* @__PURE__ */ Q(vt, {}), /* @__PURE__ */ Q("span", {
|
|
959
959
|
className: "sr-only",
|
|
960
960
|
children: "Remove"
|
|
961
961
|
})]
|
|
962
962
|
})] })
|
|
963
963
|
});
|
|
964
964
|
}
|
|
965
|
-
function
|
|
965
|
+
function er({ children: e, className: t, ...n }) {
|
|
966
966
|
return e ? /* @__PURE__ */ Q("div", {
|
|
967
967
|
className: J("ml-auto flex w-fit flex-wrap items-start gap-2", t),
|
|
968
968
|
...n,
|
|
969
969
|
children: e
|
|
970
970
|
}) : null;
|
|
971
971
|
}
|
|
972
|
-
var
|
|
972
|
+
var tr = ({ className: e, children: t, ...n }) => /* @__PURE__ */ Q("div", {
|
|
973
973
|
className: J("mt-4 flex w-full items-center justify-between gap-4", e),
|
|
974
974
|
...n,
|
|
975
975
|
children: t
|
|
976
976
|
});
|
|
977
977
|
//#endregion
|
|
978
978
|
//#region src/elements/ui/input-group.tsx
|
|
979
|
-
function
|
|
979
|
+
function nr({ className: e, ...t }) {
|
|
980
980
|
return /* @__PURE__ */ Q("div", {
|
|
981
981
|
"data-slot": "input-group",
|
|
982
982
|
role: "group",
|
|
@@ -984,7 +984,7 @@ function tr({ className: e, ...t }) {
|
|
|
984
984
|
...t
|
|
985
985
|
});
|
|
986
986
|
}
|
|
987
|
-
var
|
|
987
|
+
var rr = Et("flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-sm font-medium text-muted-foreground select-none group-data-[disabled=true]/input-group:opacity-50 [&>kbd]:rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-4", {
|
|
988
988
|
variants: { align: {
|
|
989
989
|
"inline-start": "order-first pl-3 has-[>button]:ml-[-0.45rem] has-[>kbd]:ml-[-0.35rem]",
|
|
990
990
|
"inline-end": "order-last pr-3 has-[>button]:mr-[-0.45rem] has-[>kbd]:mr-[-0.35rem]",
|
|
@@ -993,19 +993,19 @@ var nr = Tt("flex h-auto cursor-text items-center justify-center gap-2 py-1.5 te
|
|
|
993
993
|
} },
|
|
994
994
|
defaultVariants: { align: "inline-start" }
|
|
995
995
|
});
|
|
996
|
-
function
|
|
996
|
+
function ir({ className: e, align: t = "inline-start", ...n }) {
|
|
997
997
|
return /* @__PURE__ */ Q("div", {
|
|
998
998
|
role: "group",
|
|
999
999
|
"data-slot": "input-group-addon",
|
|
1000
1000
|
"data-align": t,
|
|
1001
|
-
className: J(
|
|
1001
|
+
className: J(rr({ align: t }), e),
|
|
1002
1002
|
onClick: (e) => {
|
|
1003
1003
|
e.target.closest("button") || e.currentTarget.parentElement?.querySelector("input")?.focus();
|
|
1004
1004
|
},
|
|
1005
1005
|
...n
|
|
1006
1006
|
});
|
|
1007
1007
|
}
|
|
1008
|
-
var
|
|
1008
|
+
var ar = Et("flex items-center gap-2 text-sm shadow-none", {
|
|
1009
1009
|
variants: { size: {
|
|
1010
1010
|
xs: "h-6 gap-1 rounded-[calc(var(--radius)-5px)] px-2 has-[>svg]:px-2 [&>svg:not([class*='size-'])]:size-3.5",
|
|
1011
1011
|
sm: "h-8 gap-1.5 rounded-md px-2.5 has-[>svg]:px-2.5",
|
|
@@ -1014,17 +1014,17 @@ var ir = Tt("flex items-center gap-2 text-sm shadow-none", {
|
|
|
1014
1014
|
} },
|
|
1015
1015
|
defaultVariants: { size: "xs" }
|
|
1016
1016
|
});
|
|
1017
|
-
function
|
|
1017
|
+
function or({ className: e, type: t = "button", variant: n = "ghost", size: r = "xs", ...i }) {
|
|
1018
1018
|
return /* @__PURE__ */ Q(v, {
|
|
1019
1019
|
type: t,
|
|
1020
1020
|
"data-size": r,
|
|
1021
1021
|
variant: n,
|
|
1022
|
-
className: J(
|
|
1022
|
+
className: J(ar({ size: r }), e),
|
|
1023
1023
|
...i
|
|
1024
1024
|
});
|
|
1025
1025
|
}
|
|
1026
|
-
function
|
|
1027
|
-
return /* @__PURE__ */ Q(
|
|
1026
|
+
function sr({ className: e, ...t }) {
|
|
1027
|
+
return /* @__PURE__ */ Q(q, {
|
|
1028
1028
|
"data-slot": "input-group-control",
|
|
1029
1029
|
className: J("flex-1 resize-none rounded-none border-0 bg-transparent py-3 shadow-none focus-visible:ring-0 dark:bg-transparent", e),
|
|
1030
1030
|
...t
|
|
@@ -1032,20 +1032,20 @@ function or({ className: e, ...t }) {
|
|
|
1032
1032
|
}
|
|
1033
1033
|
//#endregion
|
|
1034
1034
|
//#region src/elements/prompt-input.tsx
|
|
1035
|
-
var
|
|
1036
|
-
let e = s(
|
|
1035
|
+
var cr = r(null), lr = r(null), ur = () => {
|
|
1036
|
+
let e = s(cr);
|
|
1037
1037
|
if (!e) throw Error("Wrap your component inside <PromptInputProvider> to use usePromptInputController().");
|
|
1038
1038
|
return e;
|
|
1039
|
-
},
|
|
1040
|
-
let e = s(
|
|
1039
|
+
}, dr = () => s(cr), fr = () => {
|
|
1040
|
+
let e = s(lr);
|
|
1041
1041
|
if (!e) throw Error("Wrap your component inside <PromptInputProvider> to use useProviderAttachments().");
|
|
1042
1042
|
return e;
|
|
1043
|
-
},
|
|
1044
|
-
function
|
|
1043
|
+
}, pr = () => s(lr);
|
|
1044
|
+
function mr({ initialInput: e = "", children: t }) {
|
|
1045
1045
|
let [n, r] = d(e), i = o(() => r(""), []), [a, s] = d([]), f = u(null), p = u(() => {}), m = o((e) => {
|
|
1046
1046
|
let t = Array.from(e);
|
|
1047
1047
|
t.length !== 0 && s((e) => e.concat(t.map((e) => ({
|
|
1048
|
-
id:
|
|
1048
|
+
id: kt(),
|
|
1049
1049
|
type: "file",
|
|
1050
1050
|
url: URL.createObjectURL(e),
|
|
1051
1051
|
mediaType: e.type,
|
|
@@ -1096,22 +1096,22 @@ function pr({ initialInput: e = "", children: t }) {
|
|
|
1096
1096
|
y,
|
|
1097
1097
|
b
|
|
1098
1098
|
]);
|
|
1099
|
-
return /* @__PURE__ */ Q(
|
|
1099
|
+
return /* @__PURE__ */ Q(cr.Provider, {
|
|
1100
1100
|
value: x,
|
|
1101
|
-
children: /* @__PURE__ */ Q(
|
|
1101
|
+
children: /* @__PURE__ */ Q(lr.Provider, {
|
|
1102
1102
|
value: y,
|
|
1103
1103
|
children: t
|
|
1104
1104
|
})
|
|
1105
1105
|
});
|
|
1106
1106
|
}
|
|
1107
|
-
var
|
|
1108
|
-
let e =
|
|
1107
|
+
var hr = r(null), gr = () => {
|
|
1108
|
+
let e = pr(), t = s(hr), n = e ?? t;
|
|
1109
1109
|
if (!n) throw Error("usePromptInputAttachments must be used within a PromptInput or PromptInputProvider");
|
|
1110
1110
|
return n;
|
|
1111
1111
|
};
|
|
1112
|
-
function
|
|
1113
|
-
let r =
|
|
1114
|
-
return /* @__PURE__ */ $(
|
|
1112
|
+
function _r({ data: e, className: t, ...n }) {
|
|
1113
|
+
let r = gr(), i = e.filename || "", a = (e.mediaType?.startsWith("image/") && e.url ? "image" : "file") == "image", o = i || (a ? "Image" : "Attachment");
|
|
1114
|
+
return /* @__PURE__ */ $(Rr, { children: [/* @__PURE__ */ Q(R, {
|
|
1115
1115
|
asChild: !0,
|
|
1116
1116
|
children: /* @__PURE__ */ $("div", {
|
|
1117
1117
|
className: J("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),
|
|
@@ -1138,7 +1138,7 @@ function gr({ data: e, className: t, ...n }) {
|
|
|
1138
1138
|
},
|
|
1139
1139
|
type: "button",
|
|
1140
1140
|
variant: "ghost",
|
|
1141
|
-
children: [/* @__PURE__ */ Q(
|
|
1141
|
+
children: [/* @__PURE__ */ Q(vt, {}), /* @__PURE__ */ Q("span", {
|
|
1142
1142
|
className: "sr-only",
|
|
1143
1143
|
children: "Remove"
|
|
1144
1144
|
})]
|
|
@@ -1148,7 +1148,7 @@ function gr({ data: e, className: t, ...n }) {
|
|
|
1148
1148
|
children: o
|
|
1149
1149
|
})]
|
|
1150
1150
|
}, e.id)
|
|
1151
|
-
}), /* @__PURE__ */ Q(
|
|
1151
|
+
}), /* @__PURE__ */ Q(Br, {
|
|
1152
1152
|
className: "w-auto p-2",
|
|
1153
1153
|
children: /* @__PURE__ */ $("div", {
|
|
1154
1154
|
className: "w-auto space-y-3",
|
|
@@ -1177,16 +1177,16 @@ function gr({ data: e, className: t, ...n }) {
|
|
|
1177
1177
|
})
|
|
1178
1178
|
})] });
|
|
1179
1179
|
}
|
|
1180
|
-
function
|
|
1181
|
-
let i =
|
|
1180
|
+
function vr({ children: e, className: t, ...r }) {
|
|
1181
|
+
let i = gr();
|
|
1182
1182
|
return i.files.length ? /* @__PURE__ */ Q("div", {
|
|
1183
1183
|
className: J("flex flex-wrap items-center gap-2 p-3 w-full", t),
|
|
1184
1184
|
...r,
|
|
1185
1185
|
children: i.files.map((t) => /* @__PURE__ */ Q(n, { children: e(t) }, t.id))
|
|
1186
1186
|
}) : null;
|
|
1187
1187
|
}
|
|
1188
|
-
var
|
|
1189
|
-
let n =
|
|
1188
|
+
var yr = ({ label: e = "Add photos or files", ...t }) => {
|
|
1189
|
+
let n = gr();
|
|
1190
1190
|
return /* @__PURE__ */ $(P, {
|
|
1191
1191
|
...t,
|
|
1192
1192
|
onSelect: (e) => {
|
|
@@ -1198,8 +1198,8 @@ var vr = ({ label: e = "Add photos or files", ...t }) => {
|
|
|
1198
1198
|
e
|
|
1199
1199
|
]
|
|
1200
1200
|
});
|
|
1201
|
-
},
|
|
1202
|
-
let _ =
|
|
1201
|
+
}, br = ({ 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 }) => {
|
|
1202
|
+
let _ = dr(), v = !!_, y = u(null), b = u(null), [x, S] = d([]), C = v ? _.attachments.files : x, w = u(C);
|
|
1203
1203
|
w.current = C;
|
|
1204
1204
|
let T = o(() => {
|
|
1205
1205
|
y.current?.click();
|
|
@@ -1234,7 +1234,7 @@ var vr = ({ label: e = "Add photos or files", ...t }) => {
|
|
|
1234
1234
|
});
|
|
1235
1235
|
let i = [];
|
|
1236
1236
|
for (let e of n) i.push({
|
|
1237
|
-
id:
|
|
1237
|
+
id: kt(),
|
|
1238
1238
|
type: "file",
|
|
1239
1239
|
url: URL.createObjectURL(e),
|
|
1240
1240
|
mediaType: e.type,
|
|
@@ -1347,20 +1347,20 @@ var vr = ({ label: e = "Add photos or files", ...t }) => {
|
|
|
1347
1347
|
},
|
|
1348
1348
|
ref: b,
|
|
1349
1349
|
...g,
|
|
1350
|
-
children: /* @__PURE__ */ Q(
|
|
1350
|
+
children: /* @__PURE__ */ Q(nr, {
|
|
1351
1351
|
className: "overflow-hidden",
|
|
1352
1352
|
children: h
|
|
1353
1353
|
})
|
|
1354
1354
|
})] });
|
|
1355
|
-
return v ? F : /* @__PURE__ */ Q(
|
|
1355
|
+
return v ? F : /* @__PURE__ */ Q(hr.Provider, {
|
|
1356
1356
|
value: P,
|
|
1357
1357
|
children: F
|
|
1358
1358
|
});
|
|
1359
|
-
},
|
|
1359
|
+
}, xr = ({ className: e, ...t }) => /* @__PURE__ */ Q("div", {
|
|
1360
1360
|
className: J("contents", e),
|
|
1361
1361
|
...t
|
|
1362
|
-
}),
|
|
1363
|
-
let i =
|
|
1362
|
+
}), Sr = ({ onChange: e, className: t, placeholder: n = "What would you like to know?", ...r }) => {
|
|
1363
|
+
let i = dr(), a = gr(), [o, s] = d(!1), c = (e) => {
|
|
1364
1364
|
if (e.key === "Enter") {
|
|
1365
1365
|
if (o || e.nativeEvent.isComposing || e.shiftKey) return;
|
|
1366
1366
|
e.preventDefault();
|
|
@@ -1388,7 +1388,7 @@ var vr = ({ label: e = "Add photos or files", ...t }) => {
|
|
|
1388
1388
|
i.textInput.setInput(t.currentTarget.value), e?.(t);
|
|
1389
1389
|
}
|
|
1390
1390
|
} : { onChange: e };
|
|
1391
|
-
return /* @__PURE__ */ Q(
|
|
1391
|
+
return /* @__PURE__ */ Q(sr, {
|
|
1392
1392
|
className: J("field-sizing-content max-h-48 min-h-16", t),
|
|
1393
1393
|
name: "message",
|
|
1394
1394
|
onCompositionEnd: () => s(!1),
|
|
@@ -1399,43 +1399,43 @@ var vr = ({ label: e = "Add photos or files", ...t }) => {
|
|
|
1399
1399
|
...r,
|
|
1400
1400
|
...u
|
|
1401
1401
|
});
|
|
1402
|
-
},
|
|
1402
|
+
}, Cr = ({ className: e, ...t }) => /* @__PURE__ */ Q(ir, {
|
|
1403
1403
|
align: "block-end",
|
|
1404
1404
|
className: J("order-first flex-wrap gap-1", e),
|
|
1405
1405
|
...t
|
|
1406
|
-
}),
|
|
1406
|
+
}), wr = ({ className: e, ...t }) => /* @__PURE__ */ Q(ir, {
|
|
1407
1407
|
align: "block-end",
|
|
1408
1408
|
className: J("justify-between gap-1", e),
|
|
1409
1409
|
...t
|
|
1410
|
-
}),
|
|
1410
|
+
}), Tr = ({ className: e, ...t }) => /* @__PURE__ */ Q("div", {
|
|
1411
1411
|
className: J("flex items-center gap-1", e),
|
|
1412
1412
|
...t
|
|
1413
|
-
}),
|
|
1413
|
+
}), Er = ({ variant: e = "ghost", className: n, size: r, ...i }) => {
|
|
1414
1414
|
let a = r ?? (t.count(i.children) > 1 ? "sm" : "icon-sm");
|
|
1415
|
-
return /* @__PURE__ */ Q(
|
|
1415
|
+
return /* @__PURE__ */ Q(or, {
|
|
1416
1416
|
className: J(n),
|
|
1417
1417
|
size: a,
|
|
1418
1418
|
type: "button",
|
|
1419
1419
|
variant: e,
|
|
1420
1420
|
...i
|
|
1421
1421
|
});
|
|
1422
|
-
},
|
|
1422
|
+
}, Dr = (e) => /* @__PURE__ */ Q(ee, { ...e }), Or = ({ className: e, children: t, ...n }) => /* @__PURE__ */ Q(F, {
|
|
1423
1423
|
asChild: !0,
|
|
1424
|
-
children: /* @__PURE__ */ Q(
|
|
1424
|
+
children: /* @__PURE__ */ Q(Er, {
|
|
1425
1425
|
className: e,
|
|
1426
1426
|
...n,
|
|
1427
1427
|
children: t ?? /* @__PURE__ */ Q(ot, { className: "size-4" })
|
|
1428
1428
|
})
|
|
1429
|
-
}),
|
|
1429
|
+
}), kr = ({ className: e, ...t }) => /* @__PURE__ */ Q(te, {
|
|
1430
1430
|
align: "start",
|
|
1431
1431
|
className: J(e),
|
|
1432
1432
|
...t
|
|
1433
|
-
}),
|
|
1433
|
+
}), Ar = ({ className: e, ...t }) => /* @__PURE__ */ Q(P, {
|
|
1434
1434
|
className: J(e),
|
|
1435
1435
|
...t
|
|
1436
|
-
}),
|
|
1436
|
+
}), jr = ({ className: e, variant: t = "default", size: n = "icon-sm", status: r, children: i, ...a }) => {
|
|
1437
1437
|
let o = /* @__PURE__ */ Q(Je, { className: "size-4" });
|
|
1438
|
-
return r === "submitted" ? o = /* @__PURE__ */ Q(tt, { className: "size-4 animate-spin" }) : r === "streaming" ? o = /* @__PURE__ */ Q(dt, { className: "size-4" }) : r === "error" && (o = /* @__PURE__ */ Q(
|
|
1438
|
+
return r === "submitted" ? o = /* @__PURE__ */ Q(tt, { className: "size-4 animate-spin" }) : r === "streaming" ? o = /* @__PURE__ */ Q(dt, { className: "size-4" }) : r === "error" && (o = /* @__PURE__ */ Q(vt, { className: "size-4" })), /* @__PURE__ */ Q(or, {
|
|
1439
1439
|
"aria-label": "Submit",
|
|
1440
1440
|
className: J(e),
|
|
1441
1441
|
size: n,
|
|
@@ -1444,7 +1444,7 @@ var vr = ({ label: e = "Add photos or files", ...t }) => {
|
|
|
1444
1444
|
...a,
|
|
1445
1445
|
children: i ?? o
|
|
1446
1446
|
});
|
|
1447
|
-
},
|
|
1447
|
+
}, Mr = ({ className: e, textareaRef: t, onTranscriptionChange: n, ...r }) => {
|
|
1448
1448
|
let [i, a] = d(!1), [s, l] = d(null), f = u(null);
|
|
1449
1449
|
c(() => {
|
|
1450
1450
|
if (typeof window < "u" && ("SpeechRecognition" in window || "webkitSpeechRecognition" in window)) {
|
|
@@ -1474,69 +1474,69 @@ var vr = ({ label: e = "Add photos or files", ...t }) => {
|
|
|
1474
1474
|
let p = o(() => {
|
|
1475
1475
|
s && (i ? s.stop() : s.start());
|
|
1476
1476
|
}, [s, i]);
|
|
1477
|
-
return /* @__PURE__ */ Q(
|
|
1477
|
+
return /* @__PURE__ */ Q(Er, {
|
|
1478
1478
|
className: J("relative transition-all duration-200", i && "animate-pulse bg-accent text-accent-foreground", e),
|
|
1479
1479
|
disabled: !s,
|
|
1480
1480
|
onClick: p,
|
|
1481
1481
|
...r,
|
|
1482
1482
|
children: /* @__PURE__ */ Q(rt, { className: "size-4" })
|
|
1483
1483
|
});
|
|
1484
|
-
},
|
|
1484
|
+
}, Nr = (e) => /* @__PURE__ */ Q(le, { ...e }), Pr = ({ className: e, ...t }) => /* @__PURE__ */ Q(fe, {
|
|
1485
1485
|
className: J("border-none bg-transparent font-medium text-muted-foreground shadow-none transition-colors", "hover:bg-accent hover:text-foreground aria-expanded:bg-accent aria-expanded:text-foreground", e),
|
|
1486
1486
|
...t
|
|
1487
|
-
}),
|
|
1487
|
+
}), Fr = ({ className: e, ...t }) => /* @__PURE__ */ Q(ue, {
|
|
1488
1488
|
className: J(e),
|
|
1489
1489
|
...t
|
|
1490
|
-
}),
|
|
1490
|
+
}), Ir = ({ className: e, ...t }) => /* @__PURE__ */ Q(de, {
|
|
1491
1491
|
className: J(e),
|
|
1492
1492
|
...t
|
|
1493
|
-
}),
|
|
1493
|
+
}), Lr = ({ className: e, ...t }) => /* @__PURE__ */ Q(pe, {
|
|
1494
1494
|
className: J(e),
|
|
1495
1495
|
...t
|
|
1496
|
-
}),
|
|
1496
|
+
}), Rr = ({ openDelay: e = 0, closeDelay: t = 0, ...n }) => /* @__PURE__ */ Q(L, {
|
|
1497
1497
|
closeDelay: t,
|
|
1498
1498
|
openDelay: e,
|
|
1499
1499
|
...n
|
|
1500
|
-
}),
|
|
1500
|
+
}), zr = (e) => /* @__PURE__ */ Q(R, { ...e }), Br = ({ align: e = "start", ...t }) => /* @__PURE__ */ Q(oe, {
|
|
1501
1501
|
align: e,
|
|
1502
1502
|
...t
|
|
1503
|
-
}),
|
|
1503
|
+
}), Vr = ({ className: e, ...t }) => /* @__PURE__ */ Q("div", {
|
|
1504
1504
|
className: J(e),
|
|
1505
1505
|
...t
|
|
1506
|
-
}),
|
|
1506
|
+
}), Hr = ({ className: e, ...t }) => /* @__PURE__ */ Q("div", {
|
|
1507
1507
|
className: J(e),
|
|
1508
1508
|
...t
|
|
1509
|
-
}),
|
|
1509
|
+
}), Ur = ({ className: e, ...t }) => /* @__PURE__ */ Q("h3", {
|
|
1510
1510
|
className: J("mb-2 px-3 font-medium text-muted-foreground text-xs", e),
|
|
1511
1511
|
...t
|
|
1512
|
-
}),
|
|
1512
|
+
}), Wr = ({ className: e, ...t }) => /* @__PURE__ */ Q("div", {
|
|
1513
1513
|
className: J("space-y-1", e),
|
|
1514
1514
|
...t
|
|
1515
|
-
}),
|
|
1515
|
+
}), Gr = ({ className: e, ...t }) => /* @__PURE__ */ Q("div", {
|
|
1516
1516
|
className: J("flex items-center gap-2 px-3 py-2 text-xs hover:bg-accent", e),
|
|
1517
1517
|
...t
|
|
1518
|
-
}),
|
|
1518
|
+
}), Kr = ({ className: e, ...t }) => /* @__PURE__ */ Q(D, {
|
|
1519
1519
|
className: J(e),
|
|
1520
1520
|
...t
|
|
1521
|
-
}),
|
|
1521
|
+
}), qr = ({ className: e, ...t }) => /* @__PURE__ */ Q(A, {
|
|
1522
1522
|
className: J(e),
|
|
1523
1523
|
...t
|
|
1524
|
-
}),
|
|
1524
|
+
}), Jr = ({ className: e, ...t }) => /* @__PURE__ */ Q(M, {
|
|
1525
1525
|
className: J(e),
|
|
1526
1526
|
...t
|
|
1527
|
-
}),
|
|
1527
|
+
}), Yr = ({ className: e, ...t }) => /* @__PURE__ */ Q(O, {
|
|
1528
1528
|
className: J(e),
|
|
1529
1529
|
...t
|
|
1530
|
-
}),
|
|
1530
|
+
}), Xr = ({ className: e, ...t }) => /* @__PURE__ */ Q(k, {
|
|
1531
1531
|
className: J(e),
|
|
1532
1532
|
...t
|
|
1533
|
-
}),
|
|
1533
|
+
}), Zr = ({ className: e, ...t }) => /* @__PURE__ */ Q(j, {
|
|
1534
1534
|
className: J(e),
|
|
1535
1535
|
...t
|
|
1536
|
-
}),
|
|
1536
|
+
}), Qr = ({ className: e, ...t }) => /* @__PURE__ */ Q(N, {
|
|
1537
1537
|
className: J(e),
|
|
1538
1538
|
...t
|
|
1539
|
-
}),
|
|
1539
|
+
}), $r = ({ className: e, children: t, ...n }) => /* @__PURE__ */ $(se, {
|
|
1540
1540
|
className: "w-full overflow-x-auto whitespace-nowrap",
|
|
1541
1541
|
...n,
|
|
1542
1542
|
children: [/* @__PURE__ */ Q("div", {
|
|
@@ -1546,7 +1546,7 @@ var vr = ({ label: e = "Add photos or files", ...t }) => {
|
|
|
1546
1546
|
className: "hidden",
|
|
1547
1547
|
orientation: "horizontal"
|
|
1548
1548
|
})]
|
|
1549
|
-
}),
|
|
1549
|
+
}), ei = ({ suggestion: e, onClick: t, className: n, variant: r = "outline", size: i = "sm", children: a, ...o }) => /* @__PURE__ */ Q(v, {
|
|
1550
1550
|
className: J("cursor-pointer rounded-full px-4", n),
|
|
1551
1551
|
onClick: () => {
|
|
1552
1552
|
t?.(e);
|
|
@@ -1556,7 +1556,7 @@ var vr = ({ label: e = "Add photos or files", ...t }) => {
|
|
|
1556
1556
|
variant: r,
|
|
1557
1557
|
...o,
|
|
1558
1558
|
children: a || e
|
|
1559
|
-
}),
|
|
1559
|
+
}), ti = r({ code: "" }), ni = {
|
|
1560
1560
|
name: "line-numbers",
|
|
1561
1561
|
line(e, t) {
|
|
1562
1562
|
e.children.unshift({
|
|
@@ -1577,21 +1577,21 @@ var vr = ({ label: e = "Add photos or files", ...t }) => {
|
|
|
1577
1577
|
});
|
|
1578
1578
|
}
|
|
1579
1579
|
};
|
|
1580
|
-
async function
|
|
1581
|
-
let r = n ? [
|
|
1582
|
-
return await Promise.all([
|
|
1580
|
+
async function ri(e, t, n = !1) {
|
|
1581
|
+
let r = n ? [ni] : [];
|
|
1582
|
+
return await Promise.all([At(e, {
|
|
1583
1583
|
lang: t,
|
|
1584
1584
|
theme: "one-light",
|
|
1585
1585
|
transformers: r
|
|
1586
|
-
}),
|
|
1586
|
+
}), At(e, {
|
|
1587
1587
|
lang: t,
|
|
1588
1588
|
theme: "one-dark-pro",
|
|
1589
1589
|
transformers: r
|
|
1590
1590
|
})]);
|
|
1591
1591
|
}
|
|
1592
|
-
var
|
|
1592
|
+
var ii = ({ code: e, language: t, showLineNumbers: n = !1, className: r, children: i, ...a }) => {
|
|
1593
1593
|
let [o, s] = d(""), [l, f] = d(""), p = u(!1);
|
|
1594
|
-
return c(() => (
|
|
1594
|
+
return c(() => (ri(e, t, n).then(([e, t]) => {
|
|
1595
1595
|
p.current ||= (s(e), f(t), !0);
|
|
1596
1596
|
}), () => {
|
|
1597
1597
|
p.current = !1;
|
|
@@ -1599,7 +1599,7 @@ var ri = ({ code: e, language: t, showLineNumbers: n = !1, className: r, childre
|
|
|
1599
1599
|
e,
|
|
1600
1600
|
t,
|
|
1601
1601
|
n
|
|
1602
|
-
]), /* @__PURE__ */ Q(
|
|
1602
|
+
]), /* @__PURE__ */ Q(ti.Provider, {
|
|
1603
1603
|
value: { code: e },
|
|
1604
1604
|
children: /* @__PURE__ */ Q("div", {
|
|
1605
1605
|
className: J("group relative w-full overflow-hidden rounded-md border bg-background text-foreground", r),
|
|
@@ -1623,8 +1623,8 @@ var ri = ({ code: e, language: t, showLineNumbers: n = !1, className: r, childre
|
|
|
1623
1623
|
})
|
|
1624
1624
|
})
|
|
1625
1625
|
});
|
|
1626
|
-
},
|
|
1627
|
-
let [o, c] = d(!1), { code: l } = s(
|
|
1626
|
+
}, ai = ({ onCopy: e, onError: t, timeout: n = 2e3, children: r, className: i, ...a }) => {
|
|
1627
|
+
let [o, c] = d(!1), { code: l } = s(ti), u = async () => {
|
|
1628
1628
|
if (typeof window > "u" || !navigator?.clipboard?.writeText) {
|
|
1629
1629
|
t?.(/* @__PURE__ */ Error("Clipboard API not available"));
|
|
1630
1630
|
return;
|
|
@@ -1643,10 +1643,10 @@ var ri = ({ code: e, language: t, showLineNumbers: n = !1, className: r, childre
|
|
|
1643
1643
|
...a,
|
|
1644
1644
|
children: r ?? /* @__PURE__ */ Q(f, { size: 14 })
|
|
1645
1645
|
});
|
|
1646
|
-
},
|
|
1646
|
+
}, oi = ({ className: e, ...t }) => /* @__PURE__ */ Q(w, {
|
|
1647
1647
|
className: J("not-prose mb-4 w-full rounded-md border", e),
|
|
1648
1648
|
...t
|
|
1649
|
-
}),
|
|
1649
|
+
}), si = (e) => /* @__PURE__ */ $(_, {
|
|
1650
1650
|
className: "gap-1.5 rounded-full text-xs",
|
|
1651
1651
|
variant: "secondary",
|
|
1652
1652
|
children: [{
|
|
@@ -1655,8 +1655,8 @@ var ri = ({ code: e, language: t, showLineNumbers: n = !1, className: r, childre
|
|
|
1655
1655
|
"approval-requested": /* @__PURE__ */ Q(We, { className: "size-4 text-yellow-600" }),
|
|
1656
1656
|
"approval-responded": /* @__PURE__ */ Q(Fe, { className: "size-4 text-blue-600" }),
|
|
1657
1657
|
"output-available": /* @__PURE__ */ Q(Fe, { className: "size-4 text-green-600" }),
|
|
1658
|
-
"output-error": /* @__PURE__ */ Q(
|
|
1659
|
-
"output-denied": /* @__PURE__ */ Q(
|
|
1658
|
+
"output-error": /* @__PURE__ */ Q(_t, { className: "size-4 text-red-600" }),
|
|
1659
|
+
"output-denied": /* @__PURE__ */ Q(_t, { className: "size-4 text-orange-600" })
|
|
1660
1660
|
}[e], {
|
|
1661
1661
|
"input-streaming": "Pending",
|
|
1662
1662
|
"input-available": "Running",
|
|
@@ -1666,24 +1666,24 @@ var ri = ({ code: e, language: t, showLineNumbers: n = !1, className: r, childre
|
|
|
1666
1666
|
"output-error": "Error",
|
|
1667
1667
|
"output-denied": "Denied"
|
|
1668
1668
|
}[e]]
|
|
1669
|
-
}),
|
|
1669
|
+
}), ci = ({ className: e, title: t, type: n, state: r, ...i }) => /* @__PURE__ */ $(E, {
|
|
1670
1670
|
className: J("flex w-full items-center justify-between gap-4 p-3", e),
|
|
1671
1671
|
...i,
|
|
1672
1672
|
children: [/* @__PURE__ */ $("div", {
|
|
1673
1673
|
className: "flex items-center gap-2",
|
|
1674
1674
|
children: [
|
|
1675
|
-
/* @__PURE__ */ Q(
|
|
1675
|
+
/* @__PURE__ */ Q(ht, { className: "size-4 text-muted-foreground" }),
|
|
1676
1676
|
/* @__PURE__ */ Q("span", {
|
|
1677
1677
|
className: "font-medium text-sm",
|
|
1678
1678
|
children: t ?? n.split("-").slice(1).join("-")
|
|
1679
1679
|
}),
|
|
1680
|
-
|
|
1680
|
+
si(r)
|
|
1681
1681
|
]
|
|
1682
1682
|
}), /* @__PURE__ */ Q(Le, { className: "size-4 text-muted-foreground transition-transform group-data-[state=open]:rotate-180" })]
|
|
1683
|
-
}),
|
|
1683
|
+
}), li = ({ className: e, ...t }) => /* @__PURE__ */ Q(T, {
|
|
1684
1684
|
className: J("data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 text-popover-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in", e),
|
|
1685
1685
|
...t
|
|
1686
|
-
}),
|
|
1686
|
+
}), ui = ({ className: e, input: t, ...n }) => /* @__PURE__ */ $("div", {
|
|
1687
1687
|
className: J("space-y-2 overflow-hidden p-4", e),
|
|
1688
1688
|
...n,
|
|
1689
1689
|
children: [/* @__PURE__ */ Q("h4", {
|
|
@@ -1691,18 +1691,18 @@ var ri = ({ code: e, language: t, showLineNumbers: n = !1, className: r, childre
|
|
|
1691
1691
|
children: "Parameters"
|
|
1692
1692
|
}), /* @__PURE__ */ Q("div", {
|
|
1693
1693
|
className: "rounded-md bg-muted/50",
|
|
1694
|
-
children: /* @__PURE__ */ Q(
|
|
1694
|
+
children: /* @__PURE__ */ Q(ii, {
|
|
1695
1695
|
code: JSON.stringify(t, null, 2),
|
|
1696
1696
|
language: "json"
|
|
1697
1697
|
})
|
|
1698
1698
|
})]
|
|
1699
|
-
}),
|
|
1699
|
+
}), di = ({ className: e, output: t, errorText: n, ...r }) => {
|
|
1700
1700
|
if (!(t || n)) return null;
|
|
1701
1701
|
let a = /* @__PURE__ */ Q("div", { children: t });
|
|
1702
|
-
return typeof t == "object" && !i(t) ? a = /* @__PURE__ */ Q(
|
|
1702
|
+
return typeof t == "object" && !i(t) ? a = /* @__PURE__ */ Q(ii, {
|
|
1703
1703
|
code: JSON.stringify(t, null, 2),
|
|
1704
1704
|
language: "json"
|
|
1705
|
-
}) : typeof t == "string" && (a = /* @__PURE__ */ Q(
|
|
1705
|
+
}) : typeof t == "string" && (a = /* @__PURE__ */ Q(ii, {
|
|
1706
1706
|
code: t,
|
|
1707
1707
|
language: "json"
|
|
1708
1708
|
})), /* @__PURE__ */ $("div", {
|
|
@@ -1716,8 +1716,8 @@ var ri = ({ code: e, language: t, showLineNumbers: n = !1, className: r, childre
|
|
|
1716
1716
|
children: [n && /* @__PURE__ */ Q("div", { children: n }), a]
|
|
1717
1717
|
})]
|
|
1718
1718
|
});
|
|
1719
|
-
},
|
|
1720
|
-
let a =
|
|
1719
|
+
}, fi = a(({ children: e, as: t = "p", className: n, duration: r = 2, spread: i = 2 }) => {
|
|
1720
|
+
let a = Mt.create(t), o = l(() => (e?.length ?? 0) * i, [e, i]);
|
|
1721
1721
|
return /* @__PURE__ */ Q(a, {
|
|
1722
1722
|
animate: { backgroundPosition: "0% center" },
|
|
1723
1723
|
className: J("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),
|
|
@@ -1733,21 +1733,21 @@ var ri = ({ code: e, language: t, showLineNumbers: n = !1, className: r, childre
|
|
|
1733
1733
|
},
|
|
1734
1734
|
children: e
|
|
1735
1735
|
});
|
|
1736
|
-
}),
|
|
1737
|
-
let e = s(
|
|
1736
|
+
}), pi = r(null), mi = () => {
|
|
1737
|
+
let e = s(pi);
|
|
1738
1738
|
if (!e) throw Error("Reasoning components must be used within Reasoning");
|
|
1739
1739
|
return e;
|
|
1740
|
-
},
|
|
1741
|
-
let [l, u] =
|
|
1740
|
+
}, hi = 1e3, gi = 1e3, _i = a(({ className: e, isStreaming: t = !1, open: n, defaultOpen: r = !0, onOpenChange: i, duration: a, children: o, ...s }) => {
|
|
1741
|
+
let [l, u] = jt({
|
|
1742
1742
|
prop: n,
|
|
1743
1743
|
defaultProp: r,
|
|
1744
1744
|
onChange: i
|
|
1745
|
-
}), [f, p] =
|
|
1745
|
+
}), [f, p] = jt({
|
|
1746
1746
|
prop: a,
|
|
1747
1747
|
defaultProp: void 0
|
|
1748
1748
|
}), [m, h] = d(!1), [g, _] = d(null);
|
|
1749
1749
|
return c(() => {
|
|
1750
|
-
t ? g === null && _(Date.now()) : g !== null && (p(Math.ceil((Date.now() - g) /
|
|
1750
|
+
t ? g === null && _(Date.now()) : g !== null && (p(Math.ceil((Date.now() - g) / gi)), _(null));
|
|
1751
1751
|
}, [
|
|
1752
1752
|
t,
|
|
1753
1753
|
g,
|
|
@@ -1756,7 +1756,7 @@ var ri = ({ code: e, language: t, showLineNumbers: n = !1, className: r, childre
|
|
|
1756
1756
|
if (r && !t && l && !m) {
|
|
1757
1757
|
let e = setTimeout(() => {
|
|
1758
1758
|
u(!1), h(!0);
|
|
1759
|
-
},
|
|
1759
|
+
}, hi);
|
|
1760
1760
|
return () => clearTimeout(e);
|
|
1761
1761
|
}
|
|
1762
1762
|
}, [
|
|
@@ -1765,7 +1765,7 @@ var ri = ({ code: e, language: t, showLineNumbers: n = !1, className: r, childre
|
|
|
1765
1765
|
r,
|
|
1766
1766
|
u,
|
|
1767
1767
|
m
|
|
1768
|
-
]), /* @__PURE__ */ Q(
|
|
1768
|
+
]), /* @__PURE__ */ Q(pi.Provider, {
|
|
1769
1769
|
value: {
|
|
1770
1770
|
isStreaming: t,
|
|
1771
1771
|
isOpen: l,
|
|
@@ -1782,15 +1782,15 @@ var ri = ({ code: e, language: t, showLineNumbers: n = !1, className: r, childre
|
|
|
1782
1782
|
children: o
|
|
1783
1783
|
})
|
|
1784
1784
|
});
|
|
1785
|
-
}),
|
|
1785
|
+
}), vi = (e, t) => e || t === 0 ? /* @__PURE__ */ Q(fi, {
|
|
1786
1786
|
duration: 1,
|
|
1787
1787
|
children: "Thinking..."
|
|
1788
1788
|
}) : t === void 0 ? /* @__PURE__ */ Q("p", { children: "Thought for a few seconds" }) : /* @__PURE__ */ $("p", { children: [
|
|
1789
1789
|
"Thought for ",
|
|
1790
1790
|
t,
|
|
1791
1791
|
" seconds"
|
|
1792
|
-
] }),
|
|
1793
|
-
let { isStreaming: i, isOpen: a, duration: o } =
|
|
1792
|
+
] }), yi = a(({ className: e, children: t, getThinkingMessage: n = vi, ...r }) => {
|
|
1793
|
+
let { isStreaming: i, isOpen: a, duration: o } = mi();
|
|
1794
1794
|
return /* @__PURE__ */ Q(E, {
|
|
1795
1795
|
className: J("flex w-full items-center gap-2 text-muted-foreground text-sm transition-colors hover:text-foreground", e),
|
|
1796
1796
|
...r,
|
|
@@ -1800,18 +1800,18 @@ var ri = ({ code: e, language: t, showLineNumbers: n = !1, className: r, childre
|
|
|
1800
1800
|
/* @__PURE__ */ Q(Le, { className: J("size-4 transition-transform", a ? "rotate-180" : "rotate-0") })
|
|
1801
1801
|
] })
|
|
1802
1802
|
});
|
|
1803
|
-
}),
|
|
1803
|
+
}), bi = a(({ className: e, children: t, ...n }) => /* @__PURE__ */ Q(T, {
|
|
1804
1804
|
className: J("mt-4 text-sm", "data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 text-muted-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in", e),
|
|
1805
1805
|
...n,
|
|
1806
|
-
children: /* @__PURE__ */ Q(
|
|
1806
|
+
children: /* @__PURE__ */ Q(Ot, { children: t })
|
|
1807
1807
|
}));
|
|
1808
|
-
|
|
1808
|
+
_i.displayName = "Reasoning", yi.displayName = "ReasoningTrigger", bi.displayName = "ReasoningContent";
|
|
1809
1809
|
//#endregion
|
|
1810
1810
|
//#region src/elements/sources.tsx
|
|
1811
|
-
var
|
|
1811
|
+
var xi = ({ className: e, ...t }) => /* @__PURE__ */ Q(w, {
|
|
1812
1812
|
className: J("not-prose mb-4 text-primary text-xs", e),
|
|
1813
1813
|
...t
|
|
1814
|
-
}),
|
|
1814
|
+
}), Si = ({ className: e, count: t, children: n, ...r }) => /* @__PURE__ */ Q(E, {
|
|
1815
1815
|
className: J("flex items-center gap-2", e),
|
|
1816
1816
|
...r,
|
|
1817
1817
|
children: n ?? /* @__PURE__ */ $(Z, { children: [/* @__PURE__ */ $("p", {
|
|
@@ -1822,10 +1822,10 @@ var bi = ({ className: e, ...t }) => /* @__PURE__ */ Q(w, {
|
|
|
1822
1822
|
" sources"
|
|
1823
1823
|
]
|
|
1824
1824
|
}), /* @__PURE__ */ Q(Le, { className: "h-4 w-4" })] })
|
|
1825
|
-
}),
|
|
1825
|
+
}), Ci = ({ className: e, ...t }) => /* @__PURE__ */ Q(T, {
|
|
1826
1826
|
className: J("mt-3 flex w-fit flex-col gap-2", "data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 outline-none data-[state=closed]:animate-out data-[state=open]:animate-in", e),
|
|
1827
1827
|
...t
|
|
1828
|
-
}),
|
|
1828
|
+
}), wi = ({ href: e, title: t, children: n, ...r }) => /* @__PURE__ */ Q("a", {
|
|
1829
1829
|
className: "flex items-center gap-2",
|
|
1830
1830
|
href: e,
|
|
1831
1831
|
rel: "noreferrer",
|
|
@@ -1838,7 +1838,7 @@ var bi = ({ className: e, ...t }) => /* @__PURE__ */ Q(w, {
|
|
|
1838
1838
|
});
|
|
1839
1839
|
//#endregion
|
|
1840
1840
|
//#region src/ChatbotEnhanced.tsx
|
|
1841
|
-
function
|
|
1841
|
+
function Ti(e) {
|
|
1842
1842
|
let t = e ?? {}, n = t.data && typeof t.data == "object" ? t.data : t, r = n.seedApplied, i = n.probes;
|
|
1843
1843
|
if (!r && !i) return;
|
|
1844
1844
|
let a = {};
|
|
@@ -1852,10 +1852,10 @@ function wi(e) {
|
|
|
1852
1852
|
message: String(e.message)
|
|
1853
1853
|
}))), a;
|
|
1854
1854
|
}
|
|
1855
|
-
function
|
|
1855
|
+
function Ei(e) {
|
|
1856
1856
|
return e === "user" ? "user" : "assistant";
|
|
1857
1857
|
}
|
|
1858
|
-
function
|
|
1858
|
+
function Di(e) {
|
|
1859
1859
|
let t = e.trim();
|
|
1860
1860
|
if (t.length < 2 || !(t.startsWith("{") || t.startsWith("[")) || !(t.endsWith("}") || t.endsWith("]"))) return !1;
|
|
1861
1861
|
try {
|
|
@@ -1864,15 +1864,15 @@ function Ei(e) {
|
|
|
1864
1864
|
return !1;
|
|
1865
1865
|
}
|
|
1866
1866
|
}
|
|
1867
|
-
function
|
|
1867
|
+
function Oi(e) {
|
|
1868
1868
|
let t = e.state ?? (e.errorText ? "output-error" : e.result === void 0 ? "input-available" : "output-available");
|
|
1869
1869
|
return t === "output-error" || t === "output-denied" ? "failed" : t === "approval-requested" || t === "approval-responded" ? "awaiting" : t === "output-available" ? "completed" : "running";
|
|
1870
1870
|
}
|
|
1871
|
-
function
|
|
1872
|
-
let t =
|
|
1871
|
+
function ki(e) {
|
|
1872
|
+
let t = Oi(e);
|
|
1873
1873
|
return t === "awaiting" || t === "failed" || !!e.pendingActionId || !!e.draftReview?.items.length || !!e.proposedPlan;
|
|
1874
1874
|
}
|
|
1875
|
-
function
|
|
1875
|
+
function Ai(e) {
|
|
1876
1876
|
switch (e) {
|
|
1877
1877
|
case "failed": return 4;
|
|
1878
1878
|
case "awaiting": return 3;
|
|
@@ -1880,17 +1880,17 @@ function ki(e) {
|
|
|
1880
1880
|
case "completed": return 1;
|
|
1881
1881
|
}
|
|
1882
1882
|
}
|
|
1883
|
-
function
|
|
1883
|
+
function ji(e) {
|
|
1884
1884
|
let t = /* @__PURE__ */ new Map();
|
|
1885
1885
|
for (let n of e) {
|
|
1886
|
-
let e =
|
|
1886
|
+
let e = Oi(n), r = `${n.toolName}:${e}`, i = t.get(r);
|
|
1887
1887
|
if (i) {
|
|
1888
1888
|
i.count += 1, i.errorText = i.errorText ?? n.errorText;
|
|
1889
1889
|
continue;
|
|
1890
1890
|
}
|
|
1891
1891
|
t.set(r, {
|
|
1892
1892
|
key: r,
|
|
1893
|
-
title:
|
|
1893
|
+
title: On(n.toolName) || n.toolName,
|
|
1894
1894
|
rawName: n.toolName,
|
|
1895
1895
|
count: 1,
|
|
1896
1896
|
state: e,
|
|
@@ -1898,11 +1898,11 @@ function Ai(e) {
|
|
|
1898
1898
|
});
|
|
1899
1899
|
}
|
|
1900
1900
|
return Array.from(t.values()).sort((e, t) => {
|
|
1901
|
-
let n =
|
|
1901
|
+
let n = Ai(t.state) - Ai(e.state);
|
|
1902
1902
|
return n === 0 ? e.title.localeCompare(t.title) : n;
|
|
1903
1903
|
});
|
|
1904
1904
|
}
|
|
1905
|
-
function
|
|
1905
|
+
function Mi({ health: e }) {
|
|
1906
1906
|
if (!e) return null;
|
|
1907
1907
|
let t = e.issues ?? [], n = t.filter((e) => e.severity === "error"), r = t.filter((e) => e.severity !== "error"), i = e.checked, a = !!i && i.seeds + i.views + i.widgets > 0, o = [];
|
|
1908
1908
|
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) {
|
|
@@ -1932,32 +1932,34 @@ function ji({ health: e }) {
|
|
|
1932
1932
|
]
|
|
1933
1933
|
});
|
|
1934
1934
|
}
|
|
1935
|
-
var
|
|
1936
|
-
let
|
|
1937
|
-
emptyTitle:
|
|
1938
|
-
emptyDescription:
|
|
1939
|
-
clear:
|
|
1940
|
-
sendHint:
|
|
1941
|
-
agentActivity:
|
|
1942
|
-
toolCompleted:
|
|
1943
|
-
toolRunning:
|
|
1944
|
-
toolAwaitingApproval:
|
|
1945
|
-
toolFailed:
|
|
1946
|
-
toolDetailsHidden:
|
|
1947
|
-
copy:
|
|
1948
|
-
copied:
|
|
1949
|
-
regenerate:
|
|
1950
|
-
model:
|
|
1951
|
-
submit:
|
|
1952
|
-
uploadFiles:
|
|
1953
|
-
stopResponse:
|
|
1954
|
-
trace:
|
|
1955
|
-
viewTrace:
|
|
1956
|
-
connectionWaiting:
|
|
1957
|
-
|
|
1935
|
+
var Ni = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type your message...", onSendMessage: i, onClear: a, onStop: o, onReload: s, onUpgrade: c, disabled: l = !1, readOnly: u = !1, isLoading: d = !1, error: f, showTimestamp: p = !1, showAvatars: m = !1, userAvatarUrl: h, userAvatarFallback: g = "You", assistantAvatarUrl: _, assistantAvatarFallback: v = "AI", hideClearBar: y = !1, maxHeight: b = "500px", enableMarkdown: x = !0, enableFileUpload: S = !1, acceptedFileTypes: C = "image/*,.pdf,.doc,.docx,.txt", maxFileSize: w = 10 * 1024 * 1024, suggestions: T, labels: E, models: D, selectedModelId: O, onModelChange: k, headerSlot: A, promptOverlaySlot: j, onInputChange: M, onToolApprove: N, toolApproveLabel: ee = "Approve", toolDenyLabel: te = "Deny", toolDenyReason: P = "User denied the operation", toolDecisions: F, onReviewDraft: ne, toolReviewLabel: re = (e) => `Review ${e} change${e === 1 ? "" : "s"}`, onPublishDrafts: I, onOpenBuiltApp: ie, openBuiltAppLabel: ae = "Open app", onPreviewDraftApp: L, previewDraftLabel: oe = "Preview", onDraftArtifacts: R, onBuildMaterialized: z, publishDraftsLabel: B = "Publish", publishedLabel: se = "Published", verifiedLabel: ce = "Verified", nextStepsLabel: le = "What's next", planTitleLabel: ue = "Proposed plan", planQuestionsLabel: de = "Confirm before building", planAssumptionsLabel: fe = "Assumptions", planApproveHintLabel: pe = "Reply to approve or adjust this plan.", planApproveLabel: me = "Build it", planAdjustLabel: he = "Adjust", planBuiltLabel: ge = "Built", planApproveMessage: _e = "Looks good — build it as proposed.", planApproveDefaultsMessage: ve = "Build it with your best assumptions; use sensible defaults for the open questions.", planAnswerMessage: ye = (e, t) => `For "${e}", go with: ${t}.`, fetchPendingDraftCount: V, autoPublishDrafts: be = !1, processVisibility: H = "summary", surface: U = "card", ...W }, xe) => {
|
|
1936
|
+
let G = d ? "streaming" : "ready", K = U === "plain", [Se, Ce] = e.useState(null), q = e.useMemo(() => ({
|
|
1937
|
+
emptyTitle: E?.emptyTitle ?? "Start a conversation",
|
|
1938
|
+
emptyDescription: E?.emptyDescription ?? "Ask anything — the assistant has access to your current app context.",
|
|
1939
|
+
clear: E?.clear ?? "Clear",
|
|
1940
|
+
sendHint: E?.sendHint ?? "to send",
|
|
1941
|
+
agentActivity: E?.agentActivity ?? "Agent activity",
|
|
1942
|
+
toolCompleted: E?.toolCompleted ?? "Completed",
|
|
1943
|
+
toolRunning: E?.toolRunning ?? "Running",
|
|
1944
|
+
toolAwaitingApproval: E?.toolAwaitingApproval ?? "Awaiting approval",
|
|
1945
|
+
toolFailed: E?.toolFailed ?? "Failed",
|
|
1946
|
+
toolDetailsHidden: E?.toolDetailsHidden ?? "Detailed tool inputs and outputs are hidden in this view.",
|
|
1947
|
+
copy: E?.copy ?? "Copy",
|
|
1948
|
+
copied: E?.copied ?? "Copied",
|
|
1949
|
+
regenerate: E?.regenerate ?? "Regenerate",
|
|
1950
|
+
model: E?.model ?? "Model",
|
|
1951
|
+
submit: E?.submit ?? "Submit",
|
|
1952
|
+
uploadFiles: E?.uploadFiles ?? "Upload files",
|
|
1953
|
+
stopResponse: E?.stopResponse ?? "Stop response",
|
|
1954
|
+
trace: E?.trace ?? "trace",
|
|
1955
|
+
viewTrace: E?.viewTrace ?? "View trace",
|
|
1956
|
+
connectionWaiting: E?.connectionWaiting ?? "Waiting for server…",
|
|
1957
|
+
connectionStalledLabel: E?.connectionStalledLabel ?? "Still working…",
|
|
1958
|
+
connectionOfflineLabel: E?.connectionOfflineLabel ?? "Connection lost — reconnecting…"
|
|
1959
|
+
}), [E]), [we, Te] = e.useState(() => /* @__PURE__ */ new Set()), [Ee, De] = e.useState(() => /* @__PURE__ */ new Map()), [ke, Ae] = e.useState(() => /* @__PURE__ */ new Map()), je = e.useRef(/* @__PURE__ */ new Set()), Ne = e.useCallback(async (e) => {
|
|
1958
1960
|
if (V) try {
|
|
1959
1961
|
let t = await V(e);
|
|
1960
|
-
|
|
1962
|
+
Ae((n) => {
|
|
1961
1963
|
if (n.get(e) === t) return n;
|
|
1962
1964
|
let r = new Map(n);
|
|
1963
1965
|
return r.set(e, t), r;
|
|
@@ -1965,43 +1967,43 @@ var Mi = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
1965
1967
|
} catch {}
|
|
1966
1968
|
}, [V]);
|
|
1967
1969
|
e.useEffect(() => {
|
|
1968
|
-
if (!V ||
|
|
1970
|
+
if (!V || d) return;
|
|
1969
1971
|
let e = /* @__PURE__ */ new Set();
|
|
1970
1972
|
for (let t of n) for (let n of t.toolInvocations ?? []) {
|
|
1971
1973
|
let t = n.draftReview?.packageId, r = n.toolCallId;
|
|
1972
|
-
t && r && !
|
|
1974
|
+
t && r && !je.current.has(r) && (je.current.add(r), e.add(t));
|
|
1973
1975
|
}
|
|
1974
|
-
for (let t of e)
|
|
1976
|
+
for (let t of e) Ne(t);
|
|
1975
1977
|
}, [
|
|
1976
1978
|
n,
|
|
1977
|
-
|
|
1979
|
+
d,
|
|
1978
1980
|
V,
|
|
1979
|
-
|
|
1981
|
+
Ne
|
|
1980
1982
|
]);
|
|
1981
|
-
let
|
|
1983
|
+
let Fe = e.useCallback(async (e) => {
|
|
1982
1984
|
if (!I) return;
|
|
1983
1985
|
let t = [];
|
|
1984
1986
|
for (let r of n) for (let n of r.toolInvocations ?? []) n.draftReview?.packageId === e && n.toolCallId && t.push(n.toolCallId);
|
|
1985
1987
|
let r = await I(e), i = r && typeof r == "object" ? r : void 0;
|
|
1986
1988
|
if ((i ? i.ok !== !1 : r !== !1) && t.length > 0) {
|
|
1987
|
-
|
|
1989
|
+
Te((e) => {
|
|
1988
1990
|
let n = new Set(e);
|
|
1989
1991
|
for (let e of t) n.add(e);
|
|
1990
1992
|
return n;
|
|
1991
1993
|
});
|
|
1992
1994
|
let e = i?.health;
|
|
1993
|
-
e &&
|
|
1995
|
+
e && De((n) => {
|
|
1994
1996
|
let r = new Map(n);
|
|
1995
1997
|
for (let n of t) r.set(n, e);
|
|
1996
1998
|
return r;
|
|
1997
1999
|
});
|
|
1998
2000
|
}
|
|
1999
|
-
|
|
2001
|
+
Ne(e);
|
|
2000
2002
|
}, [
|
|
2001
2003
|
I,
|
|
2002
2004
|
n,
|
|
2003
|
-
|
|
2004
|
-
]),
|
|
2005
|
+
Ne
|
|
2006
|
+
]), Ie = e.useRef(/* @__PURE__ */ new Set()), Le = e.useRef(!1);
|
|
2005
2007
|
e.useEffect(() => {
|
|
2006
2008
|
let e = [];
|
|
2007
2009
|
for (let t of n) for (let n of t.toolInvocations ?? []) {
|
|
@@ -2011,78 +2013,94 @@ var Mi = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2011
2013
|
packageId: t.packageId
|
|
2012
2014
|
});
|
|
2013
2015
|
}
|
|
2014
|
-
if (!
|
|
2015
|
-
|
|
2016
|
-
for (let t of e)
|
|
2016
|
+
if (!Le.current) {
|
|
2017
|
+
Le.current = !0;
|
|
2018
|
+
for (let t of e) Ie.current.add(t.key);
|
|
2017
2019
|
return;
|
|
2018
2020
|
}
|
|
2019
|
-
if (!
|
|
2020
|
-
let t = e.filter((e) => !
|
|
2021
|
+
if (!be || !I || d) return;
|
|
2022
|
+
let t = e.filter((e) => !Ie.current.has(e.key));
|
|
2021
2023
|
if (t.length !== 0) {
|
|
2022
|
-
for (let e of t)
|
|
2023
|
-
for (let e of [...new Set(t.map((e) => e.packageId))])
|
|
2024
|
+
for (let e of t) Ie.current.add(e.key);
|
|
2025
|
+
for (let e of [...new Set(t.map((e) => e.packageId))]) Fe(e);
|
|
2024
2026
|
}
|
|
2025
2027
|
}, [
|
|
2026
2028
|
n,
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
+
d,
|
|
2030
|
+
be,
|
|
2029
2031
|
I,
|
|
2030
|
-
|
|
2032
|
+
Fe
|
|
2031
2033
|
]);
|
|
2032
|
-
let
|
|
2034
|
+
let Re = e.useRef(/* @__PURE__ */ new Set());
|
|
2033
2035
|
e.useEffect(() => {
|
|
2034
2036
|
if (!R) return;
|
|
2035
|
-
let e = /* @__PURE__ */ new Map();
|
|
2036
|
-
for (let
|
|
2037
|
-
for (let
|
|
2038
|
-
for (let n of
|
|
2037
|
+
let e = /* @__PURE__ */ new Map(), t;
|
|
2038
|
+
for (let r of n) {
|
|
2039
|
+
for (let t of r.buildProgress?.items ?? []) t?.type && t?.name && e.set(`${t.type}:${t.name}`, t);
|
|
2040
|
+
for (let n of r.toolInvocations ?? []) {
|
|
2041
|
+
let r = n.draftReview;
|
|
2042
|
+
for (let t of r?.items ?? []) t?.type && t?.name && e.set(`${t.type}:${t.name}`, t);
|
|
2043
|
+
r?.packageId && r.items?.some((e) => e.type === "app") && (t = r.packageId);
|
|
2044
|
+
}
|
|
2039
2045
|
}
|
|
2040
|
-
let
|
|
2041
|
-
for (let
|
|
2042
|
-
|
|
2046
|
+
let r = Re.current, i = !1;
|
|
2047
|
+
for (let t of e.keys()) r.has(t) || (r.add(t), i = !0);
|
|
2048
|
+
i && R([...e.values()], t);
|
|
2043
2049
|
}, [n, R]);
|
|
2044
|
-
let
|
|
2050
|
+
let ze = e.useRef(/* @__PURE__ */ new Set());
|
|
2045
2051
|
e.useEffect(() => {
|
|
2046
2052
|
if (z) for (let e of n) for (let t of e.toolInvocations ?? []) {
|
|
2047
2053
|
let e = t.draftReview;
|
|
2048
2054
|
if (!e?.materialized || !t.toolCallId) continue;
|
|
2049
2055
|
let n = e.items.find((e) => e.type === "app");
|
|
2050
|
-
!n ||
|
|
2056
|
+
!n || ze.current.has(t.toolCallId) || (ze.current.add(t.toolCallId), z(n.name));
|
|
2051
2057
|
}
|
|
2052
2058
|
}, [n, z]);
|
|
2053
|
-
let
|
|
2059
|
+
let Be = e.useCallback((e) => {
|
|
2054
2060
|
let t = !!e.text?.trim(), n = e.files?.map((e) => e.file).filter(Boolean), r = !!(n && n.length > 0);
|
|
2055
2061
|
(t || r) && i?.(e.text?.trim() ?? "", n);
|
|
2056
|
-
}, [i]),
|
|
2062
|
+
}, [i]), He = e.useCallback((e) => {
|
|
2057
2063
|
i?.(e);
|
|
2058
|
-
}, [i]),
|
|
2059
|
-
i?.(e ?
|
|
2064
|
+
}, [i]), Ue = e.useRef(null), We = e.useCallback((e) => {
|
|
2065
|
+
i?.(e ? ve : _e);
|
|
2060
2066
|
}, [
|
|
2061
2067
|
i,
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
]),
|
|
2065
|
-
let e =
|
|
2068
|
+
_e,
|
|
2069
|
+
ve
|
|
2070
|
+
]), Ke = e.useCallback(() => {
|
|
2071
|
+
let e = Ue.current?.querySelector("textarea");
|
|
2066
2072
|
e && (e.focus(), e.scrollIntoView({ block: "nearest" }));
|
|
2067
|
-
}, []),
|
|
2068
|
-
navigator.clipboard?.writeText(e.content),
|
|
2069
|
-
}, []),
|
|
2070
|
-
let
|
|
2073
|
+
}, []), Je = e.useCallback((e) => {
|
|
2074
|
+
navigator.clipboard?.writeText(e.content), Ce(e.id), window.setTimeout(() => Ce((t) => t === e.id ? null : t), 1500);
|
|
2075
|
+
}, []), Qe = e.useMemo(() => {
|
|
2076
|
+
let e = /* @__PURE__ */ new Set(), t = [], r = -1, i = 0;
|
|
2077
|
+
for (let e of n) for (let n of e.toolInvocations ?? []) n.proposedPlan && n.toolCallId && t.push({
|
|
2078
|
+
id: n.toolCallId,
|
|
2079
|
+
order: i
|
|
2080
|
+
}), n.toolName === "apply_blueprint" && (r = i), i += 1;
|
|
2081
|
+
for (let n of t) n.order < r && e.add(n.id);
|
|
2082
|
+
return e;
|
|
2083
|
+
}, [n]), $e = (e) => {
|
|
2084
|
+
let t = e.state ?? (e.errorText ? "output-error" : e.result === void 0 ? "input-available" : "output-available"), n = `tool-${e.toolName}`, r = F?.[e.toolCallId], a = t === "approval-requested" && !!N && !r, o = t === "approval-requested" && !!e.pendingActionId, s = On(e.toolName), c = kn(e.result), l = H === "debug" && s && s.toLowerCase() !== e.toolName.toLowerCase(), u = H === "debug" || a, d = e.draftReview?.packageId, f = d === void 0 ? void 0 : ke.get(d), p = f === void 0 ? we.has(e.toolCallId) : f === 0, m = t === "input-streaming" || t === "input-available", h = /* @__PURE__ */ $("span", {
|
|
2071
2085
|
className: "inline-flex items-center gap-2",
|
|
2072
|
-
children: [
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2086
|
+
children: [
|
|
2087
|
+
/* @__PURE__ */ Q("span", { children: s || e.toolName }),
|
|
2088
|
+
l ? /* @__PURE__ */ Q("code", {
|
|
2089
|
+
className: "rounded bg-muted px-1 py-px text-[10px] font-mono text-muted-foreground",
|
|
2090
|
+
children: e.toolName
|
|
2091
|
+
}) : null,
|
|
2092
|
+
m ? /* @__PURE__ */ Q(Hi, { offlineLabel: q.connectionOfflineLabel }) : null
|
|
2093
|
+
]
|
|
2076
2094
|
});
|
|
2077
|
-
return /* @__PURE__ */ $(
|
|
2095
|
+
return /* @__PURE__ */ $(oi, {
|
|
2078
2096
|
defaultOpen: t === "output-error" || t === "approval-requested" || !!(e.draftReview && e.draftReview.items.length > 0) || !!e.proposedPlan,
|
|
2079
|
-
children: [/* @__PURE__ */ Q(
|
|
2097
|
+
children: [/* @__PURE__ */ Q(ci, {
|
|
2080
2098
|
type: n,
|
|
2081
2099
|
state: t,
|
|
2082
|
-
title:
|
|
2083
|
-
}), /* @__PURE__ */ $(
|
|
2084
|
-
u && e.args !== void 0 ? /* @__PURE__ */ Q(
|
|
2085
|
-
o ? null : u || t === "output-error" ? /* @__PURE__ */ Q(
|
|
2100
|
+
title: h
|
|
2101
|
+
}), /* @__PURE__ */ $(li, { children: [
|
|
2102
|
+
u && e.args !== void 0 ? /* @__PURE__ */ Q(ui, { input: e.args }) : null,
|
|
2103
|
+
o ? null : u || t === "output-error" ? /* @__PURE__ */ Q(Xi, {
|
|
2086
2104
|
output: c,
|
|
2087
2105
|
errorText: e.errorText
|
|
2088
2106
|
}) : null,
|
|
@@ -2097,17 +2115,17 @@ var Mi = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2097
2115
|
className: "flex gap-2 p-3 border-t bg-muted/30",
|
|
2098
2116
|
children: [/* @__PURE__ */ Q("button", {
|
|
2099
2117
|
type: "button",
|
|
2100
|
-
onClick: () =>
|
|
2118
|
+
onClick: () => N?.(e.toolCallId, !0),
|
|
2101
2119
|
className: "inline-flex h-7 items-center rounded-md bg-primary px-3 text-xs font-medium text-primary-foreground hover:bg-primary/90",
|
|
2102
|
-
children:
|
|
2120
|
+
children: ee
|
|
2103
2121
|
}), /* @__PURE__ */ Q("button", {
|
|
2104
2122
|
type: "button",
|
|
2105
|
-
onClick: () =>
|
|
2123
|
+
onClick: () => N?.(e.toolCallId, !1, P),
|
|
2106
2124
|
className: "inline-flex h-7 items-center rounded-md border bg-background px-3 text-xs font-medium hover:bg-accent",
|
|
2107
|
-
children:
|
|
2125
|
+
children: te
|
|
2108
2126
|
})]
|
|
2109
2127
|
}) : null,
|
|
2110
|
-
e.draftReview && e.draftReview.items.length > 0 && (
|
|
2128
|
+
e.draftReview && e.draftReview.items.length > 0 && (ne || I && e.draftReview.packageId) ? /* @__PURE__ */ $(Z, { children: [
|
|
2111
2129
|
/* @__PURE__ */ $("div", {
|
|
2112
2130
|
className: "flex items-center gap-2 p-3 border-t bg-muted/30",
|
|
2113
2131
|
children: [
|
|
@@ -2115,34 +2133,37 @@ var Mi = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2115
2133
|
className: "inline-flex h-7 items-center gap-1.5 rounded-md border border-emerald-200 bg-emerald-50 px-3 text-xs font-medium text-emerald-700",
|
|
2116
2134
|
children: [
|
|
2117
2135
|
/* @__PURE__ */ Q(Y, { className: "size-3.5" }),
|
|
2118
|
-
|
|
2136
|
+
se,
|
|
2119
2137
|
e.draftReview.failedCount ? ` · ${e.draftReview.failedCount} need${e.draftReview.failedCount === 1 ? "s" : ""} attention` : ""
|
|
2120
2138
|
]
|
|
2121
2139
|
}) : /* @__PURE__ */ $("button", {
|
|
2122
2140
|
type: "button",
|
|
2123
|
-
onClick: () => void
|
|
2141
|
+
onClick: () => void Fe(e.draftReview.packageId),
|
|
2124
2142
|
className: "inline-flex h-7 items-center gap-1.5 rounded-md bg-primary px-3 text-xs font-medium text-primary-foreground hover:bg-primary/90",
|
|
2125
2143
|
"data-testid": "draft-publish",
|
|
2126
2144
|
children: [
|
|
2127
2145
|
/* @__PURE__ */ Q(ct, { className: "size-3.5" }),
|
|
2128
|
-
|
|
2146
|
+
B,
|
|
2129
2147
|
typeof f == "number" && f > 0 ? ` (${f})` : ""
|
|
2130
2148
|
]
|
|
2131
2149
|
}) : null,
|
|
2132
|
-
|
|
2150
|
+
ne ? /* @__PURE__ */ $("button", {
|
|
2133
2151
|
type: "button",
|
|
2134
|
-
onClick: () =>
|
|
2152
|
+
onClick: () => ne(e.draftReview.items),
|
|
2135
2153
|
className: I && e.draftReview.packageId ? "inline-flex h-7 items-center gap-1.5 rounded-md border px-3 text-xs font-medium hover:bg-muted" : "inline-flex h-7 items-center gap-1.5 rounded-md bg-primary px-3 text-xs font-medium text-primary-foreground hover:bg-primary/90",
|
|
2136
|
-
children: [/* @__PURE__ */ Q(Xe, { className: "size-3.5" }),
|
|
2154
|
+
children: [/* @__PURE__ */ Q(Xe, { className: "size-3.5" }), re(e.draftReview.items.length)]
|
|
2137
2155
|
}) : null,
|
|
2138
|
-
|
|
2156
|
+
L && !p ? (() => {
|
|
2139
2157
|
let t = e.draftReview.items.find((e) => e.type === "app");
|
|
2140
2158
|
return t ? /* @__PURE__ */ $("button", {
|
|
2141
2159
|
type: "button",
|
|
2142
|
-
onClick: () =>
|
|
2160
|
+
onClick: () => L(t.name, {
|
|
2161
|
+
materialized: e.draftReview.materialized === !0,
|
|
2162
|
+
appSegment: e.draftReview.packageId
|
|
2163
|
+
}),
|
|
2143
2164
|
className: "inline-flex h-7 items-center gap-1.5 rounded-md border px-3 text-xs font-medium hover:bg-muted",
|
|
2144
2165
|
"data-testid": "draft-preview-app",
|
|
2145
|
-
children: [/* @__PURE__ */ Q(Ye, { className: "size-3.5" }),
|
|
2166
|
+
children: [/* @__PURE__ */ Q(Ye, { className: "size-3.5" }), oe]
|
|
2146
2167
|
}) : null;
|
|
2147
2168
|
})() : null,
|
|
2148
2169
|
e.draftReview.verification ? e.draftReview.verification.errors > 0 ? /* @__PURE__ */ $("span", {
|
|
@@ -2152,7 +2173,7 @@ var Mi = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2152
2173
|
}) : /* @__PURE__ */ $("span", {
|
|
2153
2174
|
className: "inline-flex h-7 shrink-0 items-center gap-1.5 rounded-md border border-emerald-200 bg-emerald-50 px-2.5 text-xs font-medium text-emerald-700",
|
|
2154
2175
|
"data-testid": "draft-verification-chip",
|
|
2155
|
-
children: [/* @__PURE__ */ Q(ut, { className: "size-3.5" }),
|
|
2176
|
+
children: [/* @__PURE__ */ Q(ut, { className: "size-3.5" }), ce]
|
|
2156
2177
|
}) : null,
|
|
2157
2178
|
e.draftReview.summary ? /* @__PURE__ */ Q("span", {
|
|
2158
2179
|
className: "truncate text-xs text-muted-foreground",
|
|
@@ -2171,13 +2192,13 @@ var Mi = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2171
2192
|
children: [/* @__PURE__ */ Q(Oe, { className: "mt-0.5 size-3.5 shrink-0" }), /* @__PURE__ */ Q("span", { children: e.message })]
|
|
2172
2193
|
}, `w${t}`))]
|
|
2173
2194
|
}) : null,
|
|
2174
|
-
|
|
2195
|
+
we.has(e.toolCallId) ? /* @__PURE__ */ Q(Mi, { health: Ee.get(e.toolCallId) }) : null,
|
|
2175
2196
|
e.draftReview.nextSteps && e.draftReview.nextSteps.length > 0 ? /* @__PURE__ */ $("div", {
|
|
2176
2197
|
className: "flex flex-col gap-1 border-t bg-muted/20 px-3 py-2",
|
|
2177
2198
|
"data-testid": "draft-next-steps",
|
|
2178
2199
|
children: [/* @__PURE__ */ Q("span", {
|
|
2179
2200
|
className: "text-xs font-medium text-foreground/80",
|
|
2180
|
-
children:
|
|
2201
|
+
children: le
|
|
2181
2202
|
}), e.draftReview.nextSteps.map((e, t) => /* @__PURE__ */ $("div", {
|
|
2182
2203
|
className: "flex items-start gap-1.5 text-xs text-muted-foreground",
|
|
2183
2204
|
children: [/* @__PURE__ */ Q("span", {
|
|
@@ -2193,7 +2214,7 @@ var Mi = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2193
2214
|
children: [
|
|
2194
2215
|
/* @__PURE__ */ $("span", {
|
|
2195
2216
|
className: "inline-flex items-center gap-1.5 text-xs font-medium text-foreground/80",
|
|
2196
|
-
children: [/* @__PURE__ */ Q(Ve, { className: "size-3.5" }),
|
|
2217
|
+
children: [/* @__PURE__ */ Q(Ve, { className: "size-3.5" }), ue]
|
|
2197
2218
|
}),
|
|
2198
2219
|
e.proposedPlan.summary ? /* @__PURE__ */ Q("p", {
|
|
2199
2220
|
className: "text-xs text-muted-foreground",
|
|
@@ -2225,7 +2246,7 @@ var Mi = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2225
2246
|
className: "flex flex-col gap-0.5",
|
|
2226
2247
|
children: [/* @__PURE__ */ Q("span", {
|
|
2227
2248
|
className: "text-[11px] font-medium text-foreground/70",
|
|
2228
|
-
children:
|
|
2249
|
+
children: fe
|
|
2229
2250
|
}), e.proposedPlan.assumptions.map((e, t) => /* @__PURE__ */ $("div", {
|
|
2230
2251
|
className: "flex items-start gap-1.5 text-[11px] text-muted-foreground",
|
|
2231
2252
|
children: [/* @__PURE__ */ Q("span", {
|
|
@@ -2239,7 +2260,7 @@ var Mi = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2239
2260
|
"data-testid": "proposed-plan-questions",
|
|
2240
2261
|
children: [/* @__PURE__ */ $("span", {
|
|
2241
2262
|
className: "inline-flex items-center gap-1.5 text-[11px] font-medium text-amber-800 dark:text-amber-300",
|
|
2242
|
-
children: [/* @__PURE__ */ Q(Ze, { className: "size-3.5" }),
|
|
2263
|
+
children: [/* @__PURE__ */ Q(Ze, { className: "size-3.5" }), de]
|
|
2243
2264
|
}), e.proposedPlan.questions.map((t, n) => {
|
|
2244
2265
|
let r = e.proposedPlan.questionChoices?.find((e) => e.text === t);
|
|
2245
2266
|
return /* @__PURE__ */ $("div", {
|
|
@@ -2255,7 +2276,7 @@ var Mi = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2255
2276
|
"data-testid": "proposed-plan-choice",
|
|
2256
2277
|
children: r.options.map((e, n) => /* @__PURE__ */ Q("button", {
|
|
2257
2278
|
type: "button",
|
|
2258
|
-
onClick: () => i(
|
|
2279
|
+
onClick: () => i(ye(t, e)),
|
|
2259
2280
|
className: "inline-flex h-6 items-center rounded-full border border-amber-300 bg-background px-2 text-[11px] font-medium text-amber-900 hover:bg-amber-100 dark:border-amber-800 dark:text-amber-200 dark:hover:bg-amber-900/40",
|
|
2260
2281
|
children: e
|
|
2261
2282
|
}, n))
|
|
@@ -2263,25 +2284,33 @@ var Mi = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2263
2284
|
}, n);
|
|
2264
2285
|
})]
|
|
2265
2286
|
}) : null,
|
|
2266
|
-
i ? /* @__PURE__ */
|
|
2287
|
+
i ? Qe.has(e.toolCallId) ? /* @__PURE__ */ Q("div", {
|
|
2288
|
+
className: "flex flex-wrap items-center gap-1.5 pt-0.5",
|
|
2289
|
+
"data-testid": "proposed-plan-actions",
|
|
2290
|
+
children: /* @__PURE__ */ $("span", {
|
|
2291
|
+
className: "inline-flex h-7 items-center gap-1.5 rounded-md border border-emerald-200 bg-emerald-50 px-3 text-xs font-medium text-emerald-700 dark:border-emerald-900/50 dark:bg-emerald-950/30 dark:text-emerald-300",
|
|
2292
|
+
"data-testid": "proposed-plan-built",
|
|
2293
|
+
children: [/* @__PURE__ */ Q(Y, { className: "size-3.5" }), ge]
|
|
2294
|
+
})
|
|
2295
|
+
}) : /* @__PURE__ */ $("div", {
|
|
2267
2296
|
className: "flex flex-wrap items-center gap-1.5 pt-0.5",
|
|
2268
2297
|
"data-testid": "proposed-plan-actions",
|
|
2269
2298
|
children: [/* @__PURE__ */ $("button", {
|
|
2270
2299
|
type: "button",
|
|
2271
|
-
onClick: () =>
|
|
2300
|
+
onClick: () => We(e.proposedPlan.questions.length > 0),
|
|
2272
2301
|
className: "inline-flex h-7 items-center gap-1.5 rounded-md bg-primary px-3 text-xs font-medium text-primary-foreground hover:bg-primary/90",
|
|
2273
2302
|
"data-testid": "proposed-plan-approve",
|
|
2274
|
-
children: [/* @__PURE__ */ Q(ct, { className: "size-3.5" }),
|
|
2303
|
+
children: [/* @__PURE__ */ Q(ct, { className: "size-3.5" }), me]
|
|
2275
2304
|
}), /* @__PURE__ */ Q("button", {
|
|
2276
2305
|
type: "button",
|
|
2277
|
-
onClick:
|
|
2306
|
+
onClick: Ke,
|
|
2278
2307
|
className: "inline-flex h-7 items-center rounded-md border bg-background px-3 text-xs font-medium hover:bg-accent",
|
|
2279
2308
|
"data-testid": "proposed-plan-adjust",
|
|
2280
|
-
children:
|
|
2309
|
+
children: he
|
|
2281
2310
|
})]
|
|
2282
2311
|
}) : /* @__PURE__ */ Q("span", {
|
|
2283
2312
|
className: "text-[11px] italic text-muted-foreground/80",
|
|
2284
|
-
children:
|
|
2313
|
+
children: pe
|
|
2285
2314
|
})
|
|
2286
2315
|
]
|
|
2287
2316
|
}) : null
|
|
@@ -2289,13 +2318,13 @@ var Mi = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2289
2318
|
}, e.toolCallId);
|
|
2290
2319
|
};
|
|
2291
2320
|
return /* @__PURE__ */ $("div", {
|
|
2292
|
-
ref:
|
|
2293
|
-
className: J(
|
|
2294
|
-
style: { maxHeight:
|
|
2295
|
-
...
|
|
2321
|
+
ref: xe,
|
|
2322
|
+
className: J(K ? "flex min-h-0 flex-col overflow-hidden bg-background" : "flex min-h-0 flex-col overflow-hidden rounded-lg border bg-background", t),
|
|
2323
|
+
style: { maxHeight: b },
|
|
2324
|
+
...W,
|
|
2296
2325
|
children: [
|
|
2297
|
-
a && !
|
|
2298
|
-
className: J("flex items-center justify-end px-4 py-2",
|
|
2326
|
+
a && !y && n.length > 0 && /* @__PURE__ */ Q("div", {
|
|
2327
|
+
className: J("flex items-center justify-end px-4 py-2", K ? "bg-background" : "border-b bg-muted/30"),
|
|
2299
2328
|
children: /* @__PURE__ */ Q("button", {
|
|
2300
2329
|
type: "button",
|
|
2301
2330
|
onClick: a,
|
|
@@ -2303,21 +2332,21 @@ var Mi = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2303
2332
|
children: q.clear
|
|
2304
2333
|
})
|
|
2305
2334
|
}),
|
|
2306
|
-
|
|
2307
|
-
className: J("shrink-0", !
|
|
2308
|
-
children:
|
|
2335
|
+
A ? /* @__PURE__ */ Q("div", {
|
|
2336
|
+
className: J("shrink-0", !K && "border-b bg-background/50"),
|
|
2337
|
+
children: A
|
|
2309
2338
|
}) : null,
|
|
2310
|
-
/* @__PURE__ */ $(
|
|
2339
|
+
/* @__PURE__ */ $(Nn, {
|
|
2311
2340
|
className: "flex-1 min-h-0",
|
|
2312
|
-
children: [/* @__PURE__ */ $(
|
|
2313
|
-
className: J("space-y-4",
|
|
2314
|
-
children: [n.length === 0 ? /* @__PURE__ */ $(
|
|
2341
|
+
children: [/* @__PURE__ */ $(Pn, {
|
|
2342
|
+
className: J("space-y-4", K ? "mx-auto w-full max-w-2xl px-4 py-8 sm:px-0" : "px-4 py-3"),
|
|
2343
|
+
children: [n.length === 0 ? /* @__PURE__ */ $(Fn, {
|
|
2315
2344
|
className: "gap-3 px-0 py-8",
|
|
2316
2345
|
children: [
|
|
2317
2346
|
/* @__PURE__ */ Q("div", {
|
|
2318
2347
|
className: "flex size-9 items-center justify-center rounded-md bg-muted/70 text-muted-foreground",
|
|
2319
|
-
children:
|
|
2320
|
-
src:
|
|
2348
|
+
children: _ ? /* @__PURE__ */ Q("img", {
|
|
2349
|
+
src: _,
|
|
2321
2350
|
alt: "",
|
|
2322
2351
|
className: "size-full rounded-md object-cover"
|
|
2323
2352
|
}) : /* @__PURE__ */ Q(Me, { className: "size-4" })
|
|
@@ -2332,50 +2361,52 @@ var Mi = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2332
2361
|
children: q.emptyDescription
|
|
2333
2362
|
})]
|
|
2334
2363
|
}),
|
|
2335
|
-
|
|
2364
|
+
T && T.length > 0 ? /* @__PURE__ */ Q($r, {
|
|
2336
2365
|
className: "justify-center gap-2",
|
|
2337
|
-
children:
|
|
2366
|
+
children: T.map((e) => /* @__PURE__ */ Q(ei, {
|
|
2338
2367
|
className: "h-8 border-border/60 bg-background/80 px-3 text-xs font-medium text-foreground/90 shadow-none hover:bg-muted/60",
|
|
2339
2368
|
suggestion: e,
|
|
2340
|
-
onClick:
|
|
2369
|
+
onClick: He
|
|
2341
2370
|
}, e))
|
|
2342
2371
|
}) : null
|
|
2343
2372
|
]
|
|
2344
2373
|
}) : n.map((e) => {
|
|
2345
|
-
let t = e.role === "user", n = e.toolInvocations ?? [], r = e.reasoning?.trim(), i = e.sources ?? [], a = t ? void 0 : e.buildProgress, o = !t && !!e.streaming && !e.content && n.length === 0 && !r && !a, c = !t && H === "summary" ? n.filter((e) => !
|
|
2346
|
-
return /* @__PURE__ */ Q(
|
|
2347
|
-
from:
|
|
2374
|
+
let t = e.role === "user", n = e.toolInvocations ?? [], r = e.reasoning?.trim(), i = e.sources ?? [], a = t ? void 0 : e.buildProgress, o = !t && !!e.streaming && !e.content && n.length === 0 && !r && !a, c = !t && H === "summary" ? n.filter((e) => !ki(e)) : [], l = !t && H === "debug" ? n : !t && H !== "debug" ? n.filter(ki) : [];
|
|
2375
|
+
return /* @__PURE__ */ Q(Bn, {
|
|
2376
|
+
from: Ei(e.role),
|
|
2348
2377
|
children: /* @__PURE__ */ $("div", {
|
|
2349
|
-
className: J("flex w-full gap-2.5",
|
|
2350
|
-
children: [
|
|
2378
|
+
className: J("flex w-full gap-2.5", m ? t ? "flex-row-reverse items-start" : "flex-row items-start" : "flex-col"),
|
|
2379
|
+
children: [m ? /* @__PURE__ */ Q(Pi, {
|
|
2351
2380
|
isUser: t,
|
|
2352
|
-
url: t ?
|
|
2353
|
-
fallback: t ?
|
|
2381
|
+
url: t ? h : _,
|
|
2382
|
+
fallback: t ? g : v
|
|
2354
2383
|
}) : null, /* @__PURE__ */ $("div", {
|
|
2355
|
-
className: J("flex min-w-0 flex-col gap-2",
|
|
2356
|
-
children: [/* @__PURE__ */ $(
|
|
2357
|
-
a ? /* @__PURE__ */ Q(
|
|
2384
|
+
className: J("flex min-w-0 flex-col gap-2", m && !t && "flex-1"),
|
|
2385
|
+
children: [/* @__PURE__ */ $(Vn, { children: [
|
|
2386
|
+
a ? /* @__PURE__ */ Q(Gi, {
|
|
2358
2387
|
progress: a,
|
|
2359
|
-
onOpenBuiltApp:
|
|
2360
|
-
openBuiltAppLabel:
|
|
2361
|
-
onPreviewDraftApp:
|
|
2362
|
-
previewDraftLabel:
|
|
2363
|
-
waitingLabel: q.connectionWaiting
|
|
2388
|
+
onOpenBuiltApp: ie,
|
|
2389
|
+
openBuiltAppLabel: ae,
|
|
2390
|
+
onPreviewDraftApp: L,
|
|
2391
|
+
previewDraftLabel: oe,
|
|
2392
|
+
waitingLabel: q.connectionWaiting,
|
|
2393
|
+
stalledLabel: q.connectionStalledLabel,
|
|
2394
|
+
offlineLabel: q.connectionOfflineLabel
|
|
2364
2395
|
}) : null,
|
|
2365
|
-
!t && H === "debug" && r ? /* @__PURE__ */ $(
|
|
2396
|
+
!t && H === "debug" && r ? /* @__PURE__ */ $(_i, {
|
|
2366
2397
|
isStreaming: !!e.streaming && !e.content,
|
|
2367
2398
|
className: "mb-2",
|
|
2368
|
-
children: [/* @__PURE__ */ Q(
|
|
2399
|
+
children: [/* @__PURE__ */ Q(yi, {}), /* @__PURE__ */ Q(bi, { children: r })]
|
|
2369
2400
|
}) : null,
|
|
2370
|
-
!t && H === "summary" && c.length > 0 ? /* @__PURE__ */ Q(
|
|
2371
|
-
groups:
|
|
2401
|
+
!t && H === "summary" && c.length > 0 ? /* @__PURE__ */ Q(Ki, {
|
|
2402
|
+
groups: ji(c),
|
|
2372
2403
|
labels: q
|
|
2373
2404
|
}) : null,
|
|
2374
|
-
!t && l.length > 0 ? l.map(
|
|
2405
|
+
!t && l.length > 0 ? l.map($e) : null,
|
|
2375
2406
|
t ? e.content ? /* @__PURE__ */ Q("div", {
|
|
2376
2407
|
className: "whitespace-pre-wrap break-words",
|
|
2377
2408
|
children: e.content
|
|
2378
|
-
}) : null : o ? /* @__PURE__ */ Q(
|
|
2409
|
+
}) : null : o ? /* @__PURE__ */ Q(Ii, {}) : e.content ? /* @__PURE__ */ Q(Qn, { children: e.content }) : null,
|
|
2379
2410
|
e.streaming && !o ? /* @__PURE__ */ Q("span", {
|
|
2380
2411
|
"aria-hidden": !0,
|
|
2381
2412
|
className: "ml-0.5 inline-block w-[2px] h-4 align-middle bg-current animate-pulse"
|
|
@@ -2390,7 +2421,7 @@ var Mi = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2390
2421
|
children: [e.title ? /* @__PURE__ */ Q("div", {
|
|
2391
2422
|
className: "mb-2 text-sm font-medium text-foreground",
|
|
2392
2423
|
children: e.title
|
|
2393
|
-
}) : null, /* @__PURE__ */ Q(
|
|
2424
|
+
}) : null, /* @__PURE__ */ Q(St, { schema: {
|
|
2394
2425
|
type: "chart",
|
|
2395
2426
|
chartType: e.chartType ?? "bar",
|
|
2396
2427
|
data: e.data,
|
|
@@ -2399,24 +2430,24 @@ var Mi = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2399
2430
|
} })]
|
|
2400
2431
|
}, t))
|
|
2401
2432
|
}) : null,
|
|
2402
|
-
!t && i.length > 0 ? /* @__PURE__ */ $(
|
|
2433
|
+
!t && i.length > 0 ? /* @__PURE__ */ $(xi, { children: [/* @__PURE__ */ Q(Si, { count: i.length }), /* @__PURE__ */ Q(Ci, { children: i.map((e, t) => /* @__PURE__ */ Q(wi, {
|
|
2403
2434
|
href: e.url,
|
|
2404
2435
|
title: e.title ?? e.url
|
|
2405
2436
|
}, e.id ?? e.url ?? t)) })] }) : null,
|
|
2406
|
-
|
|
2437
|
+
p && e.timestamp ? /* @__PURE__ */ Q("div", {
|
|
2407
2438
|
className: "text-[10px] opacity-70 mt-1",
|
|
2408
2439
|
children: e.timestamp
|
|
2409
2440
|
}) : null
|
|
2410
|
-
] }), !t && !o ? /* @__PURE__ */ $(
|
|
2441
|
+
] }), !t && !o ? /* @__PURE__ */ $(Hn, {
|
|
2411
2442
|
className: "opacity-0 transition-opacity group-focus-within:opacity-100 group-hover:opacity-100",
|
|
2412
2443
|
children: [
|
|
2413
|
-
/* @__PURE__ */ Q(
|
|
2414
|
-
label:
|
|
2415
|
-
tooltip:
|
|
2416
|
-
onClick: () =>
|
|
2417
|
-
children:
|
|
2444
|
+
/* @__PURE__ */ Q(Un, {
|
|
2445
|
+
label: Se === e.id ? q.copied : q.copy,
|
|
2446
|
+
tooltip: Se === e.id ? q.copied : q.copy,
|
|
2447
|
+
onClick: () => Je(e),
|
|
2448
|
+
children: Se === e.id ? /* @__PURE__ */ Q(Pe, { className: "size-3.5" }) : /* @__PURE__ */ Q(Ge, { className: "size-3.5" })
|
|
2418
2449
|
}),
|
|
2419
|
-
s ? /* @__PURE__ */ Q(
|
|
2450
|
+
s ? /* @__PURE__ */ Q(Un, {
|
|
2420
2451
|
label: q.regenerate,
|
|
2421
2452
|
tooltip: q.regenerate,
|
|
2422
2453
|
onClick: s,
|
|
@@ -2434,48 +2465,50 @@ var Mi = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2434
2465
|
})]
|
|
2435
2466
|
})
|
|
2436
2467
|
}, e.id);
|
|
2437
|
-
}),
|
|
2438
|
-
showAvatar:
|
|
2439
|
-
assistantAvatarUrl:
|
|
2440
|
-
assistantAvatarFallback:
|
|
2441
|
-
waitingLabel: q.connectionWaiting
|
|
2468
|
+
}), d && !n.some((e) => e.streaming) ? /* @__PURE__ */ Q(Fi, {
|
|
2469
|
+
showAvatar: m,
|
|
2470
|
+
assistantAvatarUrl: _,
|
|
2471
|
+
assistantAvatarFallback: v,
|
|
2472
|
+
waitingLabel: q.connectionWaiting,
|
|
2473
|
+
stalledLabel: q.connectionStalledLabel,
|
|
2474
|
+
offlineLabel: q.connectionOfflineLabel
|
|
2442
2475
|
}) : null]
|
|
2443
|
-
}), /* @__PURE__ */ Q(
|
|
2476
|
+
}), /* @__PURE__ */ Q(In, {})]
|
|
2444
2477
|
}),
|
|
2445
|
-
|
|
2446
|
-
error:
|
|
2478
|
+
f ? /* @__PURE__ */ Q(Yi, {
|
|
2479
|
+
error: f,
|
|
2447
2480
|
onReload: s,
|
|
2448
2481
|
onUpgrade: c
|
|
2449
2482
|
}) : null,
|
|
2450
|
-
/* @__PURE__ */ $("div", {
|
|
2451
|
-
ref:
|
|
2452
|
-
className: J("relative",
|
|
2453
|
-
children: [
|
|
2483
|
+
u ? null : /* @__PURE__ */ $("div", {
|
|
2484
|
+
ref: Ue,
|
|
2485
|
+
className: J("relative", K && "mx-auto w-full max-w-2xl px-4 pb-4 sm:px-0"),
|
|
2486
|
+
children: [j ? /* @__PURE__ */ Q("div", {
|
|
2454
2487
|
className: "absolute bottom-full left-0 right-0 z-10 px-3 pb-1",
|
|
2455
|
-
children:
|
|
2456
|
-
}) : null, /* @__PURE__ */ $(
|
|
2457
|
-
accept:
|
|
2488
|
+
children: j
|
|
2489
|
+
}) : null, /* @__PURE__ */ $(br, {
|
|
2490
|
+
accept: C,
|
|
2458
2491
|
fileInputLabel: q.uploadFiles,
|
|
2459
|
-
maxFileSize:
|
|
2460
|
-
onSubmit:
|
|
2492
|
+
maxFileSize: w,
|
|
2493
|
+
onSubmit: Be,
|
|
2461
2494
|
onError: (e) => {
|
|
2462
2495
|
console.warn("[plugin-chatbot] prompt-input error", e);
|
|
2463
2496
|
},
|
|
2464
2497
|
children: [
|
|
2465
|
-
|
|
2466
|
-
/* @__PURE__ */ Q(
|
|
2498
|
+
S ? /* @__PURE__ */ Q(xr, { children: /* @__PURE__ */ Q(vr, { children: (e) => /* @__PURE__ */ Q(_r, { data: e }) }) }) : null,
|
|
2499
|
+
/* @__PURE__ */ Q(Sr, {
|
|
2467
2500
|
placeholder: r,
|
|
2468
|
-
disabled: l ||
|
|
2469
|
-
onChange:
|
|
2501
|
+
disabled: l || G === "streaming",
|
|
2502
|
+
onChange: M ? (e) => M(e.currentTarget.value) : void 0
|
|
2470
2503
|
}),
|
|
2471
|
-
/* @__PURE__ */ $(
|
|
2472
|
-
|
|
2473
|
-
|
|
2504
|
+
/* @__PURE__ */ $(wr, { children: [/* @__PURE__ */ $(Tr, { children: [
|
|
2505
|
+
S ? /* @__PURE__ */ $(Dr, { children: [/* @__PURE__ */ Q(Or, {}), /* @__PURE__ */ Q(kr, { children: /* @__PURE__ */ Q(yr, {}) })] }) : null,
|
|
2506
|
+
D && D.length > 0 ? /* @__PURE__ */ Q("select", {
|
|
2474
2507
|
"aria-label": q.model,
|
|
2475
|
-
value:
|
|
2476
|
-
onChange: (e) =>
|
|
2508
|
+
value: O ?? D[0].id,
|
|
2509
|
+
onChange: (e) => k?.(e.target.value),
|
|
2477
2510
|
className: "h-7 rounded-md border bg-background px-2 text-xs text-muted-foreground hover:text-foreground focus:outline-none focus:ring-1 focus:ring-ring",
|
|
2478
|
-
children:
|
|
2511
|
+
children: D.map((e) => /* @__PURE__ */ $("option", {
|
|
2479
2512
|
value: e.id,
|
|
2480
2513
|
children: [e.label ?? e.id, e.provider ? ` · ${e.provider}` : ""]
|
|
2481
2514
|
}, e.id))
|
|
@@ -2495,12 +2528,12 @@ var Mi = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2495
2528
|
})
|
|
2496
2529
|
]
|
|
2497
2530
|
})
|
|
2498
|
-
] }), /* @__PURE__ */ Q(
|
|
2499
|
-
"aria-label":
|
|
2500
|
-
status:
|
|
2531
|
+
] }), /* @__PURE__ */ Q(jr, {
|
|
2532
|
+
"aria-label": G === "streaming" ? q.stopResponse : q.submit,
|
|
2533
|
+
status: G,
|
|
2501
2534
|
disabled: l,
|
|
2502
|
-
onClick:
|
|
2503
|
-
type:
|
|
2535
|
+
onClick: G === "streaming" ? o : void 0,
|
|
2536
|
+
type: G === "streaming" ? "button" : "submit"
|
|
2504
2537
|
})] })
|
|
2505
2538
|
]
|
|
2506
2539
|
})]
|
|
@@ -2508,8 +2541,8 @@ var Mi = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2508
2541
|
]
|
|
2509
2542
|
});
|
|
2510
2543
|
});
|
|
2511
|
-
|
|
2512
|
-
function
|
|
2544
|
+
Ni.displayName = "ChatbotEnhanced";
|
|
2545
|
+
function Pi({ isUser: e, url: t, fallback: n }) {
|
|
2513
2546
|
return /* @__PURE__ */ Q("div", {
|
|
2514
2547
|
className: J("mt-0.5 flex size-7 shrink-0 items-center justify-center overflow-hidden rounded-full text-[11px] font-medium", e ? "bg-secondary text-secondary-foreground" : "bg-primary/10 text-primary"),
|
|
2515
2548
|
"aria-hidden": "true",
|
|
@@ -2520,32 +2553,34 @@ function Ni({ isUser: e, url: t, fallback: n }) {
|
|
|
2520
2553
|
}) : e ? n?.trim()?.charAt(0)?.toUpperCase() || "U" : /* @__PURE__ */ Q(Me, { className: "size-4" })
|
|
2521
2554
|
});
|
|
2522
2555
|
}
|
|
2523
|
-
function
|
|
2524
|
-
return /* @__PURE__ */ Q(
|
|
2556
|
+
function Fi({ showAvatar: e, assistantAvatarUrl: t, assistantAvatarFallback: n, waitingLabel: r, stalledLabel: i, offlineLabel: a }) {
|
|
2557
|
+
return /* @__PURE__ */ Q(Bn, {
|
|
2525
2558
|
from: "assistant",
|
|
2526
2559
|
"aria-live": "polite",
|
|
2527
2560
|
children: /* @__PURE__ */ $("div", {
|
|
2528
2561
|
className: J("flex w-full gap-2.5", e ? "flex-row items-start" : "flex-col"),
|
|
2529
|
-
children: [e ? /* @__PURE__ */ Q(
|
|
2562
|
+
children: [e ? /* @__PURE__ */ Q(Pi, {
|
|
2530
2563
|
isUser: !1,
|
|
2531
2564
|
url: t,
|
|
2532
2565
|
fallback: n
|
|
2533
|
-
}) : null, /* @__PURE__ */ Q(
|
|
2566
|
+
}) : null, /* @__PURE__ */ Q(Vn, {
|
|
2534
2567
|
className: "rounded-lg border bg-muted/30 px-3 py-2 text-muted-foreground",
|
|
2535
2568
|
children: /* @__PURE__ */ $("span", {
|
|
2536
2569
|
className: "inline-flex items-center gap-2",
|
|
2537
|
-
children: [/* @__PURE__ */ Q(
|
|
2570
|
+
children: [/* @__PURE__ */ Q(Ii, {}), /* @__PURE__ */ Q(Vi, {
|
|
2538
2571
|
active: !0,
|
|
2539
2572
|
pending: !0,
|
|
2540
2573
|
activityKey: 0,
|
|
2541
|
-
waitingLabel: r
|
|
2574
|
+
waitingLabel: r,
|
|
2575
|
+
stalledLabel: i,
|
|
2576
|
+
offlineLabel: a
|
|
2542
2577
|
})]
|
|
2543
2578
|
})
|
|
2544
2579
|
})]
|
|
2545
2580
|
})
|
|
2546
2581
|
});
|
|
2547
2582
|
}
|
|
2548
|
-
function
|
|
2583
|
+
function Ii() {
|
|
2549
2584
|
return /* @__PURE__ */ $(Z, { children: [/* @__PURE__ */ Q("span", {
|
|
2550
2585
|
className: "sr-only",
|
|
2551
2586
|
children: "Assistant is responding"
|
|
@@ -2559,12 +2594,12 @@ function Fi() {
|
|
|
2559
2594
|
]
|
|
2560
2595
|
})] });
|
|
2561
2596
|
}
|
|
2562
|
-
function
|
|
2597
|
+
function Li(e) {
|
|
2563
2598
|
let t = Math.floor(e / 60), n = e % 60;
|
|
2564
2599
|
return `${t}:${String(n).padStart(2, "0")}`;
|
|
2565
2600
|
}
|
|
2566
|
-
var
|
|
2567
|
-
function
|
|
2601
|
+
var Ri = 6;
|
|
2602
|
+
function zi(t, n) {
|
|
2568
2603
|
let r = e.useRef(0), i = e.useRef(0), [a, o] = e.useState({
|
|
2569
2604
|
elapsed: 0,
|
|
2570
2605
|
quiet: 0
|
|
@@ -2593,49 +2628,82 @@ function Ri(t, n) {
|
|
|
2593
2628
|
}, [t]), {
|
|
2594
2629
|
elapsedSeconds: a.elapsed,
|
|
2595
2630
|
quietSeconds: a.quiet,
|
|
2596
|
-
live: a.quiet <
|
|
2631
|
+
live: a.quiet < Ri
|
|
2597
2632
|
};
|
|
2598
2633
|
}
|
|
2599
|
-
function
|
|
2600
|
-
let
|
|
2634
|
+
function Bi() {
|
|
2635
|
+
let [t, n] = e.useState(() => typeof navigator < "u" && navigator.onLine === !1);
|
|
2636
|
+
return e.useEffect(() => {
|
|
2637
|
+
if (typeof window > "u") return;
|
|
2638
|
+
let e = () => n(!1), t = () => n(!0);
|
|
2639
|
+
return window.addEventListener("online", e), window.addEventListener("offline", t), () => {
|
|
2640
|
+
window.removeEventListener("online", e), window.removeEventListener("offline", t);
|
|
2641
|
+
};
|
|
2642
|
+
}, []), t;
|
|
2643
|
+
}
|
|
2644
|
+
function Vi({ active: e, activityKey: t, pending: n = !1, waitingLabel: r, stalledLabel: i = "Still working…", offlineLabel: a = "Connection lost — reconnecting…" }) {
|
|
2645
|
+
let { elapsedSeconds: o, quietSeconds: s, live: c } = zi(e, t), l = Bi() ? "offline" : c ? n ? "waiting" : "receiving" : "stalled", u = Li(o);
|
|
2601
2646
|
return /* @__PURE__ */ $("span", {
|
|
2602
|
-
className: J("inline-flex items-center gap-1.5 text-xs
|
|
2647
|
+
className: J("inline-flex items-center gap-1.5 text-xs tabular-nums", l === "offline" ? "text-red-600 font-medium" : l === "stalled" ? "text-amber-600 font-medium" : "font-normal text-muted-foreground"),
|
|
2603
2648
|
"aria-live": "polite",
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
"
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2649
|
+
"data-liveness-tier": l,
|
|
2650
|
+
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`,
|
|
2651
|
+
children: [
|
|
2652
|
+
l === "offline" ? /* @__PURE__ */ Q(mt, {
|
|
2653
|
+
className: "size-3 shrink-0",
|
|
2654
|
+
"aria-hidden": !0
|
|
2655
|
+
}) : /* @__PURE__ */ Q("span", {
|
|
2656
|
+
"aria-hidden": !0,
|
|
2657
|
+
className: J("size-1.5 shrink-0 rounded-full", l === "receiving" ? "bg-emerald-500 animate-pulse" : l === "stalled" ? "bg-amber-500" : "bg-muted-foreground/50 animate-pulse")
|
|
2658
|
+
}),
|
|
2659
|
+
/* @__PURE__ */ Q(Ue, {
|
|
2660
|
+
className: "size-3 shrink-0",
|
|
2661
|
+
"aria-hidden": !0
|
|
2662
|
+
}),
|
|
2663
|
+
/* @__PURE__ */ Q("span", { children: u }),
|
|
2664
|
+
l === "receiving" ? null : /* @__PURE__ */ $("span", { children: ["· ", l === "offline" ? a : l === "stalled" ? i : r] })
|
|
2665
|
+
]
|
|
2617
2666
|
});
|
|
2618
2667
|
}
|
|
2619
|
-
|
|
2668
|
+
function Hi({ offlineLabel: t }) {
|
|
2669
|
+
let [n, r] = e.useState(0), i = Bi();
|
|
2670
|
+
return e.useEffect(() => {
|
|
2671
|
+
let e = Date.now(), t = setInterval(() => r(Math.floor((Date.now() - e) / 1e3)), 1e3);
|
|
2672
|
+
return () => clearInterval(t);
|
|
2673
|
+
}, []), /* @__PURE__ */ $("span", {
|
|
2674
|
+
className: J("inline-flex items-center gap-1 text-xs tabular-nums", i ? "text-red-600 font-medium" : "text-muted-foreground"),
|
|
2675
|
+
"aria-live": "polite",
|
|
2676
|
+
"data-tool-running-timer": !0,
|
|
2677
|
+
children: [
|
|
2678
|
+
Q(i ? mt : Ue, {
|
|
2679
|
+
className: "size-3 shrink-0",
|
|
2680
|
+
"aria-hidden": !0
|
|
2681
|
+
}),
|
|
2682
|
+
/* @__PURE__ */ Q("span", { children: Li(n) }),
|
|
2683
|
+
i ? /* @__PURE__ */ $("span", { children: ["· ", t] }) : null
|
|
2684
|
+
]
|
|
2685
|
+
});
|
|
2686
|
+
}
|
|
2687
|
+
var Ui = [
|
|
2620
2688
|
"object",
|
|
2621
2689
|
"view",
|
|
2622
2690
|
"dashboard",
|
|
2623
2691
|
"app",
|
|
2624
2692
|
"seed"
|
|
2625
|
-
],
|
|
2693
|
+
], Wi = {
|
|
2626
2694
|
object: "Objects",
|
|
2627
2695
|
view: "Views",
|
|
2628
2696
|
dashboard: "Dashboards",
|
|
2629
2697
|
app: "App",
|
|
2630
2698
|
seed: "Sample data"
|
|
2631
2699
|
};
|
|
2632
|
-
function
|
|
2633
|
-
let { phase:
|
|
2634
|
-
for (let e of
|
|
2635
|
-
let t =
|
|
2636
|
-
t.push(e.name.replace(/_sample$/, "")),
|
|
2700
|
+
function Gi({ progress: e, onOpenBuiltApp: t, openBuiltAppLabel: n = "Open app", onPreviewDraftApp: r, previewDraftLabel: i = "Preview", waitingLabel: a = "Waiting for server…", stalledLabel: o = "Still working…", offlineLabel: s = "Connection lost — reconnecting…" }) {
|
|
2701
|
+
let { phase: c, appLabel: l, items: u, done: d, total: f, seq: p } = e, m = c === "done", h = p ?? `${c}:${d}:${u.length}`, g = u.find((e) => e.type === "app"), _ = f > 0 ? Math.min(100, Math.round(d / f * 100)) : m ? 100 : 6, v = /* @__PURE__ */ new Map();
|
|
2702
|
+
for (let e of u) {
|
|
2703
|
+
let t = v.get(e.type) ?? [];
|
|
2704
|
+
t.push(e.name.replace(/_sample$/, "")), v.set(e.type, t);
|
|
2637
2705
|
}
|
|
2638
|
-
let
|
|
2706
|
+
let y = [...Ui.filter((e) => v.has(e)), ...[...v.keys()].filter((e) => !Ui.includes(e))];
|
|
2639
2707
|
return /* @__PURE__ */ $("div", {
|
|
2640
2708
|
className: "rounded-lg border bg-muted/30 p-3 text-sm",
|
|
2641
2709
|
"data-testid": "build-progress",
|
|
@@ -2643,18 +2711,20 @@ function Hi({ progress: e, onOpenBuiltApp: t, openBuiltAppLabel: n = "Open app",
|
|
|
2643
2711
|
/* @__PURE__ */ $("div", {
|
|
2644
2712
|
className: "mb-2 flex items-center gap-2 font-medium",
|
|
2645
2713
|
children: [
|
|
2646
|
-
|
|
2647
|
-
/* @__PURE__ */ Q("span", { children:
|
|
2648
|
-
!
|
|
2714
|
+
m ? /* @__PURE__ */ Q(Y, { className: "size-4 shrink-0 text-emerald-600" }) : /* @__PURE__ */ Q(et, { className: "size-4 shrink-0 animate-spin text-primary" }),
|
|
2715
|
+
/* @__PURE__ */ Q("span", { children: m ? `Built ${l ?? "your app"}` : `Building ${l ?? "your app"}…` }),
|
|
2716
|
+
!m && c === "data" ? /* @__PURE__ */ Q("span", {
|
|
2649
2717
|
className: "text-xs font-normal text-muted-foreground",
|
|
2650
2718
|
children: "adding sample data"
|
|
2651
2719
|
}) : null,
|
|
2652
|
-
|
|
2720
|
+
m ? null : /* @__PURE__ */ Q("span", {
|
|
2653
2721
|
className: "ml-auto",
|
|
2654
|
-
children: /* @__PURE__ */ Q(
|
|
2722
|
+
children: /* @__PURE__ */ Q(Vi, {
|
|
2655
2723
|
active: !0,
|
|
2656
|
-
activityKey:
|
|
2657
|
-
waitingLabel: a
|
|
2724
|
+
activityKey: h,
|
|
2725
|
+
waitingLabel: a,
|
|
2726
|
+
stalledLabel: o,
|
|
2727
|
+
offlineLabel: s
|
|
2658
2728
|
})
|
|
2659
2729
|
})
|
|
2660
2730
|
]
|
|
@@ -2662,14 +2732,14 @@ function Hi({ progress: e, onOpenBuiltApp: t, openBuiltAppLabel: n = "Open app",
|
|
|
2662
2732
|
/* @__PURE__ */ Q("div", {
|
|
2663
2733
|
className: "mb-2 h-1.5 w-full overflow-hidden rounded-full bg-muted",
|
|
2664
2734
|
children: /* @__PURE__ */ Q("div", {
|
|
2665
|
-
className: J("h-full rounded-full transition-all duration-500",
|
|
2666
|
-
style: { width: `${
|
|
2735
|
+
className: J("h-full rounded-full transition-all duration-500", m ? "bg-emerald-500" : "bg-primary"),
|
|
2736
|
+
style: { width: `${_}%` }
|
|
2667
2737
|
})
|
|
2668
2738
|
}),
|
|
2669
2739
|
/* @__PURE__ */ Q("ul", {
|
|
2670
2740
|
className: "space-y-1",
|
|
2671
|
-
children:
|
|
2672
|
-
let t =
|
|
2741
|
+
children: y.map((e) => {
|
|
2742
|
+
let t = v.get(e);
|
|
2673
2743
|
return /* @__PURE__ */ $("li", {
|
|
2674
2744
|
className: "flex items-start gap-2",
|
|
2675
2745
|
children: [/* @__PURE__ */ Q(Y, { className: "mt-0.5 size-3.5 shrink-0 text-emerald-600" }), /* @__PURE__ */ $("span", {
|
|
@@ -2677,7 +2747,7 @@ function Hi({ progress: e, onOpenBuiltApp: t, openBuiltAppLabel: n = "Open app",
|
|
|
2677
2747
|
children: [
|
|
2678
2748
|
/* @__PURE__ */ Q("span", {
|
|
2679
2749
|
className: "font-medium text-foreground",
|
|
2680
|
-
children:
|
|
2750
|
+
children: Wi[e] ?? e
|
|
2681
2751
|
}),
|
|
2682
2752
|
" ",
|
|
2683
2753
|
t.slice(0, 6).join(", "),
|
|
@@ -2687,17 +2757,17 @@ function Hi({ progress: e, onOpenBuiltApp: t, openBuiltAppLabel: n = "Open app",
|
|
|
2687
2757
|
}, e);
|
|
2688
2758
|
})
|
|
2689
2759
|
}),
|
|
2690
|
-
|
|
2760
|
+
m && g && (t || r) ? /* @__PURE__ */ $("div", {
|
|
2691
2761
|
className: "mt-3 flex items-center gap-2",
|
|
2692
2762
|
children: [t ? /* @__PURE__ */ $("button", {
|
|
2693
2763
|
type: "button",
|
|
2694
|
-
onClick: () => t(
|
|
2764
|
+
onClick: () => t(g.name),
|
|
2695
2765
|
className: "inline-flex h-7 items-center gap-1.5 rounded-md bg-primary px-3 text-xs font-medium text-primary-foreground hover:bg-primary/90",
|
|
2696
2766
|
"data-testid": "build-progress-open-app",
|
|
2697
2767
|
children: [n, /* @__PURE__ */ Q(Ae, { className: "size-3.5" })]
|
|
2698
2768
|
}) : null, r ? /* @__PURE__ */ $("button", {
|
|
2699
2769
|
type: "button",
|
|
2700
|
-
onClick: () => r(
|
|
2770
|
+
onClick: () => r(g.name),
|
|
2701
2771
|
className: "inline-flex h-7 items-center gap-1.5 rounded-md border px-3 text-xs font-medium hover:bg-muted",
|
|
2702
2772
|
"data-testid": "build-progress-preview-app",
|
|
2703
2773
|
children: [/* @__PURE__ */ Q(Ye, { className: "size-3.5" }), i]
|
|
@@ -2706,7 +2776,7 @@ function Hi({ progress: e, onOpenBuiltApp: t, openBuiltAppLabel: n = "Open app",
|
|
|
2706
2776
|
]
|
|
2707
2777
|
});
|
|
2708
2778
|
}
|
|
2709
|
-
function
|
|
2779
|
+
function Ki({ groups: e, labels: t }) {
|
|
2710
2780
|
return e.length === 0 ? null : /* @__PURE__ */ Q("div", {
|
|
2711
2781
|
className: "not-prose mb-2 border-l border-border/70 pl-3",
|
|
2712
2782
|
children: /* @__PURE__ */ Q("div", {
|
|
@@ -2716,7 +2786,7 @@ function Ui({ groups: e, labels: t }) {
|
|
|
2716
2786
|
children: [/* @__PURE__ */ $("div", {
|
|
2717
2787
|
className: "flex min-w-0 items-center gap-2",
|
|
2718
2788
|
children: [
|
|
2719
|
-
/* @__PURE__ */ Q(
|
|
2789
|
+
/* @__PURE__ */ Q(qi, { state: e.state }),
|
|
2720
2790
|
/* @__PURE__ */ Q("span", {
|
|
2721
2791
|
className: "truncate font-medium text-foreground",
|
|
2722
2792
|
children: e.title
|
|
@@ -2726,18 +2796,18 @@ function Ui({ groups: e, labels: t }) {
|
|
|
2726
2796
|
children: ["x", e.count]
|
|
2727
2797
|
}) : null
|
|
2728
2798
|
]
|
|
2729
|
-
}), /* @__PURE__ */ Q("span", {
|
|
2799
|
+
}), e.state === "running" ? /* @__PURE__ */ Q(Hi, { offlineLabel: t.connectionOfflineLabel }) : /* @__PURE__ */ Q("span", {
|
|
2730
2800
|
className: J("shrink-0 text-[10px] font-medium", e.state === "failed" ? "text-destructive" : e.state === "completed" ? "text-emerald-700 dark:text-emerald-400" : "text-muted-foreground"),
|
|
2731
|
-
children:
|
|
2801
|
+
children: Ji(e.state, t)
|
|
2732
2802
|
})]
|
|
2733
2803
|
}, e.key))
|
|
2734
2804
|
})
|
|
2735
2805
|
});
|
|
2736
2806
|
}
|
|
2737
|
-
function
|
|
2807
|
+
function qi({ state: e }) {
|
|
2738
2808
|
return e === "failed" ? /* @__PURE__ */ Q(X, { className: "size-3.5 shrink-0 text-destructive" }) : e === "completed" ? /* @__PURE__ */ Q(Y, { className: "size-3.5 shrink-0 text-emerald-600" }) : /* @__PURE__ */ Q(Ue, { className: "size-3.5 shrink-0 text-muted-foreground" });
|
|
2739
2809
|
}
|
|
2740
|
-
function
|
|
2810
|
+
function Ji(e, t) {
|
|
2741
2811
|
switch (e) {
|
|
2742
2812
|
case "failed": return t.toolFailed;
|
|
2743
2813
|
case "awaiting": return t.toolAwaitingApproval;
|
|
@@ -2745,8 +2815,8 @@ function Gi(e, t) {
|
|
|
2745
2815
|
case "completed": return t.toolCompleted;
|
|
2746
2816
|
}
|
|
2747
2817
|
}
|
|
2748
|
-
function
|
|
2749
|
-
let i = e.useMemo(() =>
|
|
2818
|
+
function Yi({ error: t, onReload: n, onUpgrade: r }) {
|
|
2819
|
+
let i = e.useMemo(() => Mn(t), [t]), { summary: a, details: o } = e.useMemo(() => An(t), [t]), [s, c] = e.useState(!1);
|
|
2750
2820
|
if (i) {
|
|
2751
2821
|
let e = typeof navigator < "u" && !!navigator.language?.toLowerCase().startsWith("zh"), t = (e ? i.message : i.messageEn ?? i.message) || (e ? "AI 额度已用完。" : "You have reached your AI quota."), n = i.topUp ? e ? "购买额度包" : "Buy a credit pack" : e ? "升级方案" : "Upgrade plan";
|
|
2752
2822
|
return /* @__PURE__ */ Q("div", {
|
|
@@ -2817,27 +2887,27 @@ function Ki({ error: t, onReload: n, onUpgrade: r }) {
|
|
|
2817
2887
|
})
|
|
2818
2888
|
});
|
|
2819
2889
|
}
|
|
2820
|
-
function
|
|
2821
|
-
return t ? /* @__PURE__ */ Q(
|
|
2890
|
+
function Xi({ output: e, errorText: t }) {
|
|
2891
|
+
return t ? /* @__PURE__ */ Q(di, {
|
|
2822
2892
|
output: void 0,
|
|
2823
2893
|
errorText: t
|
|
2824
|
-
}) : e == null || e === "" ? null : typeof e == "string" && !
|
|
2894
|
+
}) : e == null || e === "" ? null : typeof e == "string" && !Di(e) ? /* @__PURE__ */ $("div", {
|
|
2825
2895
|
className: "space-y-2 p-4",
|
|
2826
2896
|
children: [/* @__PURE__ */ Q("h4", {
|
|
2827
2897
|
className: "font-medium text-muted-foreground text-xs uppercase tracking-wide",
|
|
2828
2898
|
children: "Result"
|
|
2829
2899
|
}), /* @__PURE__ */ Q("div", {
|
|
2830
2900
|
className: "overflow-x-auto rounded-md bg-muted/40 px-3 py-2 text-sm text-foreground",
|
|
2831
|
-
children: /* @__PURE__ */ Q(
|
|
2901
|
+
children: /* @__PURE__ */ Q(Qn, { children: e })
|
|
2832
2902
|
})]
|
|
2833
|
-
}) : /* @__PURE__ */ Q(
|
|
2903
|
+
}) : /* @__PURE__ */ Q(di, {
|
|
2834
2904
|
output: e,
|
|
2835
2905
|
errorText: void 0
|
|
2836
2906
|
});
|
|
2837
2907
|
}
|
|
2838
2908
|
//#endregion
|
|
2839
2909
|
//#region src/FloatingChatbot.tsx
|
|
2840
|
-
function
|
|
2910
|
+
function Zi({ floatingConfig: t, headerExtra: n, headerActions: r, ...i }) {
|
|
2841
2911
|
let { position: a = "bottom-right", defaultOpen: o = !1, panelWidth: s = 400, panelHeight: c = 520, title: l = "Chat", triggerSize: u = 56 } = t ?? {}, [d, f] = e.useState(null);
|
|
2842
2912
|
e.useEffect(() => {
|
|
2843
2913
|
let e = document.getElementById("floating-chatbot-portal");
|
|
@@ -2845,29 +2915,29 @@ function Ji({ floatingConfig: t, headerExtra: n, headerActions: r, ...i }) {
|
|
|
2845
2915
|
e && e.parentNode && !e.hasChildNodes() && e.parentNode.removeChild(e);
|
|
2846
2916
|
};
|
|
2847
2917
|
}, []);
|
|
2848
|
-
let p = /* @__PURE__ */ $(
|
|
2918
|
+
let p = /* @__PURE__ */ $(mn, {
|
|
2849
2919
|
defaultOpen: o,
|
|
2850
|
-
children: [/* @__PURE__ */ Q(
|
|
2920
|
+
children: [/* @__PURE__ */ Q(bn, {
|
|
2851
2921
|
position: a,
|
|
2852
2922
|
size: u
|
|
2853
|
-
}), /* @__PURE__ */ Q(
|
|
2923
|
+
}), /* @__PURE__ */ Q(En, {
|
|
2854
2924
|
title: l,
|
|
2855
2925
|
position: a,
|
|
2856
2926
|
width: s,
|
|
2857
2927
|
height: c,
|
|
2858
2928
|
headerExtra: n,
|
|
2859
2929
|
headerActions: r,
|
|
2860
|
-
children: /* @__PURE__ */ Q(
|
|
2930
|
+
children: /* @__PURE__ */ Q(Ni, {
|
|
2861
2931
|
...i,
|
|
2862
2932
|
maxHeight: "100%",
|
|
2863
2933
|
className: "h-full border-0 rounded-none"
|
|
2864
2934
|
})
|
|
2865
2935
|
})]
|
|
2866
2936
|
});
|
|
2867
|
-
return d ?
|
|
2937
|
+
return d ? xt.createPortal(p, d) : p;
|
|
2868
2938
|
}
|
|
2869
|
-
|
|
2870
|
-
let { messages: r, isLoading: i, sendMessage: a } =
|
|
2939
|
+
Nt.register("chatbot", ({ schema: e, className: t, ...n }) => {
|
|
2940
|
+
let { messages: r, isLoading: i, sendMessage: a } = en({
|
|
2871
2941
|
api: e.api,
|
|
2872
2942
|
initialMessages: e.messages,
|
|
2873
2943
|
conversationId: e.conversationId,
|
|
@@ -2884,7 +2954,7 @@ Mt.register("chatbot", ({ schema: e, className: t, ...n }) => {
|
|
|
2884
2954
|
autoResponseDelay: e.autoResponseDelay,
|
|
2885
2955
|
onSend: e.onSend
|
|
2886
2956
|
});
|
|
2887
|
-
return /* @__PURE__ */ Q(
|
|
2957
|
+
return /* @__PURE__ */ Q(va, {
|
|
2888
2958
|
messages: r,
|
|
2889
2959
|
placeholder: e.placeholder,
|
|
2890
2960
|
onSendMessage: (e) => {
|
|
@@ -3032,8 +3102,8 @@ Mt.register("chatbot", ({ schema: e, className: t, ...n }) => {
|
|
|
3032
3102
|
autoResponseDelay: 1e3,
|
|
3033
3103
|
className: "w-full max-w-2xl"
|
|
3034
3104
|
}
|
|
3035
|
-
}),
|
|
3036
|
-
let { messages: r, isLoading: i, error: a, sendMessage: o, stop: s, reload: c, clear: l, isApiMode: u } =
|
|
3105
|
+
}), Nt.register("chatbot-enhanced", ({ schema: e, className: t, ...n }) => {
|
|
3106
|
+
let { messages: r, isLoading: i, error: a, sendMessage: o, stop: s, reload: c, clear: l, isApiMode: u } = en({
|
|
3037
3107
|
api: e.api,
|
|
3038
3108
|
initialMessages: e.messages,
|
|
3039
3109
|
conversationId: e.conversationId,
|
|
@@ -3050,7 +3120,7 @@ Mt.register("chatbot", ({ schema: e, className: t, ...n }) => {
|
|
|
3050
3120
|
autoResponseDelay: e.autoResponseDelay,
|
|
3051
3121
|
onSend: e.onSend
|
|
3052
3122
|
});
|
|
3053
|
-
return /* @__PURE__ */ Q(
|
|
3123
|
+
return /* @__PURE__ */ Q(Ni, {
|
|
3054
3124
|
messages: r,
|
|
3055
3125
|
placeholder: e.placeholder,
|
|
3056
3126
|
onSendMessage: (e, t) => {
|
|
@@ -3219,8 +3289,8 @@ Mt.register("chatbot", ({ schema: e, className: t, ...n }) => {
|
|
|
3219
3289
|
autoResponseDelay: 1e3,
|
|
3220
3290
|
className: "w-full max-w-2xl"
|
|
3221
3291
|
}
|
|
3222
|
-
}),
|
|
3223
|
-
let { messages: r, isLoading: i, error: a, sendMessage: o, stop: s, reload: c, clear: l, isApiMode: u } =
|
|
3292
|
+
}), Nt.register("chatbot-floating", ({ schema: e, className: t, ...n }) => {
|
|
3293
|
+
let { messages: r, isLoading: i, error: a, sendMessage: o, stop: s, reload: c, clear: l, isApiMode: u } = en({
|
|
3224
3294
|
api: e.api,
|
|
3225
3295
|
initialMessages: e.messages,
|
|
3226
3296
|
conversationId: e.conversationId,
|
|
@@ -3237,7 +3307,7 @@ Mt.register("chatbot", ({ schema: e, className: t, ...n }) => {
|
|
|
3237
3307
|
autoResponseDelay: e.autoResponseDelay,
|
|
3238
3308
|
onSend: e.onSend
|
|
3239
3309
|
});
|
|
3240
|
-
return /* @__PURE__ */ Q(
|
|
3310
|
+
return /* @__PURE__ */ Q(Zi, {
|
|
3241
3311
|
floatingConfig: e.floatingConfig,
|
|
3242
3312
|
messages: r,
|
|
3243
3313
|
placeholder: e.placeholder,
|
|
@@ -3409,7 +3479,7 @@ Mt.register("chatbot", ({ schema: e, className: t, ...n }) => {
|
|
|
3409
3479
|
});
|
|
3410
3480
|
//#endregion
|
|
3411
3481
|
//#region src/elements/loader.tsx
|
|
3412
|
-
var
|
|
3482
|
+
var Qi = ({ size: e = 16 }) => /* @__PURE__ */ $("svg", {
|
|
3413
3483
|
height: e,
|
|
3414
3484
|
strokeLinejoin: "round",
|
|
3415
3485
|
style: { color: "currentcolor" },
|
|
@@ -3490,97 +3560,97 @@ var Yi = ({ size: e = 16 }) => /* @__PURE__ */ $("svg", {
|
|
|
3490
3560
|
})
|
|
3491
3561
|
}) })
|
|
3492
3562
|
]
|
|
3493
|
-
}),
|
|
3563
|
+
}), $i = ({ className: e, size: t = 16, ...n }) => /* @__PURE__ */ Q("div", {
|
|
3494
3564
|
className: J("inline-flex animate-spin items-center justify-center", e),
|
|
3495
3565
|
...n,
|
|
3496
|
-
children: /* @__PURE__ */ Q(
|
|
3497
|
-
}),
|
|
3498
|
-
CodeBlock: () =>
|
|
3499
|
-
CodeBlockCopyButton: () =>
|
|
3500
|
-
Conversation: () =>
|
|
3501
|
-
ConversationContent: () =>
|
|
3502
|
-
ConversationEmptyState: () =>
|
|
3503
|
-
ConversationScrollButton: () =>
|
|
3504
|
-
Loader: () =>
|
|
3505
|
-
Message: () =>
|
|
3506
|
-
MessageAction: () =>
|
|
3507
|
-
MessageActions: () =>
|
|
3508
|
-
MessageAttachment: () =>
|
|
3509
|
-
MessageAttachments: () =>
|
|
3510
|
-
MessageBranch: () =>
|
|
3511
|
-
MessageBranchContent: () =>
|
|
3512
|
-
MessageBranchNext: () =>
|
|
3513
|
-
MessageBranchPage: () =>
|
|
3514
|
-
MessageBranchPrevious: () =>
|
|
3515
|
-
MessageBranchSelector: () =>
|
|
3516
|
-
MessageContent: () =>
|
|
3517
|
-
MessageResponse: () =>
|
|
3518
|
-
MessageToolbar: () =>
|
|
3519
|
-
PromptInput: () =>
|
|
3520
|
-
PromptInputActionAddAttachments: () =>
|
|
3521
|
-
PromptInputActionMenu: () =>
|
|
3522
|
-
PromptInputActionMenuContent: () =>
|
|
3523
|
-
PromptInputActionMenuItem: () =>
|
|
3524
|
-
PromptInputActionMenuTrigger: () =>
|
|
3525
|
-
PromptInputAttachment: () =>
|
|
3526
|
-
PromptInputAttachments: () =>
|
|
3527
|
-
PromptInputBody: () =>
|
|
3528
|
-
PromptInputButton: () =>
|
|
3529
|
-
PromptInputCommand: () =>
|
|
3530
|
-
PromptInputCommandEmpty: () =>
|
|
3531
|
-
PromptInputCommandGroup: () =>
|
|
3532
|
-
PromptInputCommandInput: () =>
|
|
3533
|
-
PromptInputCommandItem: () =>
|
|
3534
|
-
PromptInputCommandList: () =>
|
|
3535
|
-
PromptInputCommandSeparator: () =>
|
|
3536
|
-
PromptInputFooter: () =>
|
|
3537
|
-
PromptInputHeader: () =>
|
|
3538
|
-
PromptInputHoverCard: () =>
|
|
3539
|
-
PromptInputHoverCardContent: () =>
|
|
3540
|
-
PromptInputHoverCardTrigger: () =>
|
|
3541
|
-
PromptInputProvider: () =>
|
|
3542
|
-
PromptInputSelect: () =>
|
|
3543
|
-
PromptInputSelectContent: () =>
|
|
3544
|
-
PromptInputSelectItem: () =>
|
|
3545
|
-
PromptInputSelectTrigger: () =>
|
|
3546
|
-
PromptInputSelectValue: () =>
|
|
3547
|
-
PromptInputSpeechButton: () =>
|
|
3548
|
-
PromptInputSubmit: () =>
|
|
3549
|
-
PromptInputTab: () =>
|
|
3550
|
-
PromptInputTabBody: () =>
|
|
3551
|
-
PromptInputTabItem: () =>
|
|
3552
|
-
PromptInputTabLabel: () =>
|
|
3553
|
-
PromptInputTabsList: () =>
|
|
3554
|
-
PromptInputTextarea: () =>
|
|
3555
|
-
PromptInputTools: () =>
|
|
3556
|
-
Reasoning: () =>
|
|
3557
|
-
ReasoningContent: () =>
|
|
3558
|
-
ReasoningTrigger: () =>
|
|
3559
|
-
Shimmer: () =>
|
|
3560
|
-
Source: () =>
|
|
3561
|
-
Sources: () =>
|
|
3562
|
-
SourcesContent: () =>
|
|
3563
|
-
SourcesTrigger: () =>
|
|
3564
|
-
Suggestion: () =>
|
|
3565
|
-
Suggestions: () =>
|
|
3566
|
-
Tool: () =>
|
|
3567
|
-
ToolContent: () =>
|
|
3568
|
-
ToolHeader: () =>
|
|
3569
|
-
ToolInput: () =>
|
|
3570
|
-
ToolOutput: () =>
|
|
3571
|
-
highlightCode: () =>
|
|
3572
|
-
usePromptInputAttachments: () =>
|
|
3573
|
-
usePromptInputController: () =>
|
|
3574
|
-
useProviderAttachments: () =>
|
|
3575
|
-
useReasoning: () =>
|
|
3576
|
-
}),
|
|
3577
|
-
function
|
|
3566
|
+
children: /* @__PURE__ */ Q(Qi, { size: t })
|
|
3567
|
+
}), ea = /* @__PURE__ */ Ft({
|
|
3568
|
+
CodeBlock: () => ii,
|
|
3569
|
+
CodeBlockCopyButton: () => ai,
|
|
3570
|
+
Conversation: () => Nn,
|
|
3571
|
+
ConversationContent: () => Pn,
|
|
3572
|
+
ConversationEmptyState: () => Fn,
|
|
3573
|
+
ConversationScrollButton: () => In,
|
|
3574
|
+
Loader: () => $i,
|
|
3575
|
+
Message: () => Bn,
|
|
3576
|
+
MessageAction: () => Un,
|
|
3577
|
+
MessageActions: () => Hn,
|
|
3578
|
+
MessageAttachment: () => $n,
|
|
3579
|
+
MessageAttachments: () => er,
|
|
3580
|
+
MessageBranch: () => Kn,
|
|
3581
|
+
MessageBranchContent: () => qn,
|
|
3582
|
+
MessageBranchNext: () => Xn,
|
|
3583
|
+
MessageBranchPage: () => Zn,
|
|
3584
|
+
MessageBranchPrevious: () => Yn,
|
|
3585
|
+
MessageBranchSelector: () => Jn,
|
|
3586
|
+
MessageContent: () => Vn,
|
|
3587
|
+
MessageResponse: () => Qn,
|
|
3588
|
+
MessageToolbar: () => tr,
|
|
3589
|
+
PromptInput: () => br,
|
|
3590
|
+
PromptInputActionAddAttachments: () => yr,
|
|
3591
|
+
PromptInputActionMenu: () => Dr,
|
|
3592
|
+
PromptInputActionMenuContent: () => kr,
|
|
3593
|
+
PromptInputActionMenuItem: () => Ar,
|
|
3594
|
+
PromptInputActionMenuTrigger: () => Or,
|
|
3595
|
+
PromptInputAttachment: () => _r,
|
|
3596
|
+
PromptInputAttachments: () => vr,
|
|
3597
|
+
PromptInputBody: () => xr,
|
|
3598
|
+
PromptInputButton: () => Er,
|
|
3599
|
+
PromptInputCommand: () => Kr,
|
|
3600
|
+
PromptInputCommandEmpty: () => Yr,
|
|
3601
|
+
PromptInputCommandGroup: () => Xr,
|
|
3602
|
+
PromptInputCommandInput: () => qr,
|
|
3603
|
+
PromptInputCommandItem: () => Zr,
|
|
3604
|
+
PromptInputCommandList: () => Jr,
|
|
3605
|
+
PromptInputCommandSeparator: () => Qr,
|
|
3606
|
+
PromptInputFooter: () => wr,
|
|
3607
|
+
PromptInputHeader: () => Cr,
|
|
3608
|
+
PromptInputHoverCard: () => Rr,
|
|
3609
|
+
PromptInputHoverCardContent: () => Br,
|
|
3610
|
+
PromptInputHoverCardTrigger: () => zr,
|
|
3611
|
+
PromptInputProvider: () => mr,
|
|
3612
|
+
PromptInputSelect: () => Nr,
|
|
3613
|
+
PromptInputSelectContent: () => Fr,
|
|
3614
|
+
PromptInputSelectItem: () => Ir,
|
|
3615
|
+
PromptInputSelectTrigger: () => Pr,
|
|
3616
|
+
PromptInputSelectValue: () => Lr,
|
|
3617
|
+
PromptInputSpeechButton: () => Mr,
|
|
3618
|
+
PromptInputSubmit: () => jr,
|
|
3619
|
+
PromptInputTab: () => Hr,
|
|
3620
|
+
PromptInputTabBody: () => Wr,
|
|
3621
|
+
PromptInputTabItem: () => Gr,
|
|
3622
|
+
PromptInputTabLabel: () => Ur,
|
|
3623
|
+
PromptInputTabsList: () => Vr,
|
|
3624
|
+
PromptInputTextarea: () => Sr,
|
|
3625
|
+
PromptInputTools: () => Tr,
|
|
3626
|
+
Reasoning: () => _i,
|
|
3627
|
+
ReasoningContent: () => bi,
|
|
3628
|
+
ReasoningTrigger: () => yi,
|
|
3629
|
+
Shimmer: () => fi,
|
|
3630
|
+
Source: () => wi,
|
|
3631
|
+
Sources: () => xi,
|
|
3632
|
+
SourcesContent: () => Ci,
|
|
3633
|
+
SourcesTrigger: () => Si,
|
|
3634
|
+
Suggestion: () => ei,
|
|
3635
|
+
Suggestions: () => $r,
|
|
3636
|
+
Tool: () => oi,
|
|
3637
|
+
ToolContent: () => li,
|
|
3638
|
+
ToolHeader: () => ci,
|
|
3639
|
+
ToolInput: () => ui,
|
|
3640
|
+
ToolOutput: () => di,
|
|
3641
|
+
highlightCode: () => ri,
|
|
3642
|
+
usePromptInputAttachments: () => gr,
|
|
3643
|
+
usePromptInputController: () => ur,
|
|
3644
|
+
useProviderAttachments: () => fr,
|
|
3645
|
+
useReasoning: () => mi
|
|
3646
|
+
}), ta = "/api/v1/ai";
|
|
3647
|
+
function na(e, t, n) {
|
|
3578
3648
|
let r = e.replace(/\/$/, ""), i = new URLSearchParams();
|
|
3579
3649
|
if (n) for (let [e, t] of Object.entries(n)) t == null || t === "" || i.set(e, String(t));
|
|
3580
3650
|
let a = i.toString();
|
|
3581
3651
|
return `${r}${t}${a ? `?${a}` : ""}`;
|
|
3582
3652
|
}
|
|
3583
|
-
async function
|
|
3653
|
+
async function ra(e, t, n) {
|
|
3584
3654
|
let r = await fetch(e, {
|
|
3585
3655
|
credentials: "include",
|
|
3586
3656
|
...t,
|
|
@@ -3600,8 +3670,8 @@ async function ea(e, t, n) {
|
|
|
3600
3670
|
}
|
|
3601
3671
|
return i;
|
|
3602
3672
|
}
|
|
3603
|
-
function
|
|
3604
|
-
let { apiBase: n =
|
|
3673
|
+
function ia(t = {}) {
|
|
3674
|
+
let { apiBase: n = ta, status: r = "pending", conversationId: i, limit: a, headers: o, pollInterval: s = 5e3, enabled: c = !0 } = t, [l, u] = e.useState([]), [d, f] = e.useState(0), [p, m] = e.useState(!1), [h, g] = e.useState(void 0), _ = e.useRef({
|
|
3605
3675
|
apiBase: n,
|
|
3606
3676
|
status: r,
|
|
3607
3677
|
conversationId: i,
|
|
@@ -3619,7 +3689,7 @@ function ta(t = {}) {
|
|
|
3619
3689
|
let { apiBase: e, status: t, conversationId: n, limit: r, headers: i } = _.current;
|
|
3620
3690
|
m(!0), g(void 0);
|
|
3621
3691
|
try {
|
|
3622
|
-
let a = await
|
|
3692
|
+
let a = await ra(na(e, "/pending-actions", {
|
|
3623
3693
|
status: t && t !== "all" ? t : void 0,
|
|
3624
3694
|
conversationId: n,
|
|
3625
3695
|
limit: r
|
|
@@ -3631,9 +3701,9 @@ function ta(t = {}) {
|
|
|
3631
3701
|
m(!1);
|
|
3632
3702
|
}
|
|
3633
3703
|
}, []), y = e.useCallback(async (e) => {
|
|
3634
|
-
let { apiBase: t, headers: n } = _.current, r =
|
|
3704
|
+
let { apiBase: t, headers: n } = _.current, r = na(t, `/pending-actions/${encodeURIComponent(e)}/approve`);
|
|
3635
3705
|
try {
|
|
3636
|
-
return await
|
|
3706
|
+
return await ra(r, {
|
|
3637
3707
|
method: "POST",
|
|
3638
3708
|
body: "{}"
|
|
3639
3709
|
}, n);
|
|
@@ -3641,9 +3711,9 @@ function ta(t = {}) {
|
|
|
3641
3711
|
v();
|
|
3642
3712
|
}
|
|
3643
3713
|
}, [v]), b = e.useCallback(async (e, t) => {
|
|
3644
|
-
let { apiBase: n, headers: r } = _.current, i =
|
|
3714
|
+
let { apiBase: n, headers: r } = _.current, i = na(n, `/pending-actions/${encodeURIComponent(e)}/reject`);
|
|
3645
3715
|
try {
|
|
3646
|
-
return await
|
|
3716
|
+
return await ra(i, {
|
|
3647
3717
|
method: "POST",
|
|
3648
3718
|
body: JSON.stringify(t ? { reason: t } : {})
|
|
3649
3719
|
}, r);
|
|
@@ -3677,7 +3747,7 @@ function ta(t = {}) {
|
|
|
3677
3747
|
}
|
|
3678
3748
|
//#endregion
|
|
3679
3749
|
//#region src/AiPendingActionsInbox.tsx
|
|
3680
|
-
var
|
|
3750
|
+
var aa = {
|
|
3681
3751
|
pending: {
|
|
3682
3752
|
variant: "secondary",
|
|
3683
3753
|
label: "Pending"
|
|
@@ -3699,8 +3769,8 @@ var na = {
|
|
|
3699
3769
|
label: "Rejected"
|
|
3700
3770
|
}
|
|
3701
3771
|
};
|
|
3702
|
-
function
|
|
3703
|
-
let t =
|
|
3772
|
+
function oa({ status: e }) {
|
|
3773
|
+
let t = aa[e] ?? {
|
|
3704
3774
|
variant: "outline",
|
|
3705
3775
|
label: e
|
|
3706
3776
|
};
|
|
@@ -3709,7 +3779,7 @@ function ra({ status: e }) {
|
|
|
3709
3779
|
children: t.label
|
|
3710
3780
|
});
|
|
3711
3781
|
}
|
|
3712
|
-
function
|
|
3782
|
+
function sa(e) {
|
|
3713
3783
|
if (!e) return "—";
|
|
3714
3784
|
let t = Date.parse(e);
|
|
3715
3785
|
if (Number.isNaN(t)) return e;
|
|
@@ -3727,7 +3797,7 @@ function ia(e) {
|
|
|
3727
3797
|
return e;
|
|
3728
3798
|
}
|
|
3729
3799
|
}
|
|
3730
|
-
function
|
|
3800
|
+
function ca(e) {
|
|
3731
3801
|
if (!e) return null;
|
|
3732
3802
|
try {
|
|
3733
3803
|
return JSON.parse(e);
|
|
@@ -3735,7 +3805,7 @@ function aa(e) {
|
|
|
3735
3805
|
return e;
|
|
3736
3806
|
}
|
|
3737
3807
|
}
|
|
3738
|
-
function
|
|
3808
|
+
function la({ value: e, max: t = 320 }) {
|
|
3739
3809
|
let n = typeof e == "string" ? e : JSON.stringify(e, null, 2);
|
|
3740
3810
|
return n == null || n === "" ? /* @__PURE__ */ Q("span", {
|
|
3741
3811
|
className: "text-muted-foreground text-xs",
|
|
@@ -3746,21 +3816,21 @@ function oa({ value: e, max: t = 320 }) {
|
|
|
3746
3816
|
children: n
|
|
3747
3817
|
});
|
|
3748
3818
|
}
|
|
3749
|
-
function
|
|
3819
|
+
function ua(e) {
|
|
3750
3820
|
switch (e) {
|
|
3751
3821
|
case "pending": return "pending";
|
|
3752
3822
|
case "all": return "all";
|
|
3753
3823
|
case "decided": return "all";
|
|
3754
3824
|
}
|
|
3755
3825
|
}
|
|
3756
|
-
function
|
|
3757
|
-
let [l, u] = e.useState("pending"), [d, m] = e.useState(null), [h, g] = e.useState(null), [_, w] = e.useState(""), [T, E] = e.useState(null), [D, O] = e.useState(null), [k, A] = e.useState(null), { items: j, isLoading: M, error: N, refresh: ee, approve: te, reject: P } =
|
|
3826
|
+
function da({ 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 }) {
|
|
3827
|
+
let [l, u] = e.useState("pending"), [d, m] = e.useState(null), [h, g] = e.useState(null), [_, w] = e.useState(""), [T, E] = e.useState(null), [D, O] = e.useState(null), [k, A] = e.useState(null), { items: j, isLoading: M, error: N, refresh: ee, approve: te, reject: P } = ia({
|
|
3758
3828
|
apiBase: t,
|
|
3759
3829
|
headers: n,
|
|
3760
3830
|
pollInterval: r,
|
|
3761
3831
|
conversationId: i,
|
|
3762
|
-
status:
|
|
3763
|
-
}), F = e.useMemo(() => l === "decided" ? j.filter((e) => e.status !== "pending") : j, [j, l]), L = e.useMemo(() => d ? j.find((e) => e.id === d) ?? null : null, [d, j]),
|
|
3832
|
+
status: ua(l)
|
|
3833
|
+
}), F = e.useMemo(() => l === "decided" ? j.filter((e) => e.status !== "pending") : j, [j, l]), L = e.useMemo(() => d ? j.find((e) => e.id === d) ?? null : null, [d, j]), oe = e.useCallback(async (e) => {
|
|
3764
3834
|
E(e), O(null);
|
|
3765
3835
|
try {
|
|
3766
3836
|
let t = await te(e), n = t.status === "executed";
|
|
@@ -3781,7 +3851,7 @@ function ca({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
|
|
|
3781
3851
|
} finally {
|
|
3782
3852
|
E(null);
|
|
3783
3853
|
}
|
|
3784
|
-
}, [te]),
|
|
3854
|
+
}, [te]), R = e.useCallback(async (e, t) => {
|
|
3785
3855
|
E(e), O(null);
|
|
3786
3856
|
try {
|
|
3787
3857
|
await P(e, t.trim() || void 0), A({
|
|
@@ -3801,24 +3871,24 @@ function ca({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
|
|
|
3801
3871
|
} finally {
|
|
3802
3872
|
E(null);
|
|
3803
3873
|
}
|
|
3804
|
-
}, [P]),
|
|
3874
|
+
}, [P]), z = /* @__PURE__ */ $("div", {
|
|
3805
3875
|
className: "space-y-3",
|
|
3806
3876
|
children: [
|
|
3807
3877
|
/* @__PURE__ */ $("div", {
|
|
3808
3878
|
className: "flex items-center justify-between gap-2",
|
|
3809
|
-
children: [/* @__PURE__ */ Q(
|
|
3879
|
+
children: [/* @__PURE__ */ Q(K, {
|
|
3810
3880
|
value: l,
|
|
3811
3881
|
onValueChange: (e) => u(e),
|
|
3812
|
-
children: /* @__PURE__ */ $(
|
|
3813
|
-
/* @__PURE__ */ Q(
|
|
3882
|
+
children: /* @__PURE__ */ $(Se, { children: [
|
|
3883
|
+
/* @__PURE__ */ Q(Ce, {
|
|
3814
3884
|
value: "pending",
|
|
3815
3885
|
children: "Pending"
|
|
3816
3886
|
}),
|
|
3817
|
-
/* @__PURE__ */ Q(
|
|
3887
|
+
/* @__PURE__ */ Q(Ce, {
|
|
3818
3888
|
value: "decided",
|
|
3819
3889
|
children: "Decided"
|
|
3820
3890
|
}),
|
|
3821
|
-
/* @__PURE__ */ Q(
|
|
3891
|
+
/* @__PURE__ */ Q(Ce, {
|
|
3822
3892
|
value: "all",
|
|
3823
3893
|
children: "All"
|
|
3824
3894
|
})
|
|
@@ -3858,17 +3928,17 @@ function ca({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
|
|
|
3858
3928
|
M && F.length === 0 ? /* @__PURE__ */ $("div", {
|
|
3859
3929
|
className: "space-y-2",
|
|
3860
3930
|
children: [
|
|
3861
|
-
/* @__PURE__ */ Q(
|
|
3862
|
-
/* @__PURE__ */ Q(
|
|
3863
|
-
/* @__PURE__ */ Q(
|
|
3931
|
+
/* @__PURE__ */ Q(V, { className: "h-10 w-full" }),
|
|
3932
|
+
/* @__PURE__ */ Q(V, { className: "h-10 w-full" }),
|
|
3933
|
+
/* @__PURE__ */ Q(V, { className: "h-10 w-full" })
|
|
3864
3934
|
]
|
|
3865
|
-
}) : F.length === 0 ? /* @__PURE__ */ Q(ne, { children: /* @__PURE__ */ $(
|
|
3935
|
+
}) : F.length === 0 ? /* @__PURE__ */ Q(ne, { children: /* @__PURE__ */ $(I, { children: [
|
|
3866
3936
|
/* @__PURE__ */ Q(ie, { children: /* @__PURE__ */ Q($e, { className: "h-8 w-8 text-muted-foreground" }) }),
|
|
3867
3937
|
/* @__PURE__ */ Q(ae, { children: "No actions waiting" }),
|
|
3868
|
-
/* @__PURE__ */ Q(
|
|
3938
|
+
/* @__PURE__ */ Q(re, { children: "When the AI proposes a sensitive action it will appear here for review." })
|
|
3869
3939
|
] }) }) : /* @__PURE__ */ Q("div", {
|
|
3870
3940
|
className: "rounded-md border",
|
|
3871
|
-
children: /* @__PURE__ */ $(
|
|
3941
|
+
children: /* @__PURE__ */ $(be, { children: [/* @__PURE__ */ Q(xe, { children: /* @__PURE__ */ $(G, { children: [
|
|
3872
3942
|
/* @__PURE__ */ Q(W, {
|
|
3873
3943
|
className: "w-[140px]",
|
|
3874
3944
|
children: "Tool"
|
|
@@ -3893,9 +3963,9 @@ function ca({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
|
|
|
3893
3963
|
className: "w-[260px] text-right",
|
|
3894
3964
|
children: "Decision"
|
|
3895
3965
|
})
|
|
3896
|
-
] }) }), /* @__PURE__ */ Q(
|
|
3966
|
+
] }) }), /* @__PURE__ */ Q(H, { children: F.map((e) => {
|
|
3897
3967
|
let t = e.status === "pending", n = T === e.id;
|
|
3898
|
-
return /* @__PURE__ */ $(
|
|
3968
|
+
return /* @__PURE__ */ $(G, { children: [
|
|
3899
3969
|
/* @__PURE__ */ Q(U, {
|
|
3900
3970
|
className: "font-mono text-xs",
|
|
3901
3971
|
children: e.tool_name
|
|
@@ -3908,7 +3978,7 @@ function ca({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
|
|
|
3908
3978
|
className: "text-sm",
|
|
3909
3979
|
children: e.object_name
|
|
3910
3980
|
}),
|
|
3911
|
-
/* @__PURE__ */ Q(U, { children: /* @__PURE__ */ Q(
|
|
3981
|
+
/* @__PURE__ */ Q(U, { children: /* @__PURE__ */ Q(oa, { status: e.status }) }),
|
|
3912
3982
|
/* @__PURE__ */ Q(U, {
|
|
3913
3983
|
className: "text-xs text-muted-foreground",
|
|
3914
3984
|
children: /* @__PURE__ */ $("span", {
|
|
@@ -3916,7 +3986,7 @@ function ca({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
|
|
|
3916
3986
|
children: [
|
|
3917
3987
|
/* @__PURE__ */ Q(He, { className: "h-3 w-3" }),
|
|
3918
3988
|
" ",
|
|
3919
|
-
|
|
3989
|
+
sa(e.proposed_at)
|
|
3920
3990
|
]
|
|
3921
3991
|
})
|
|
3922
3992
|
}),
|
|
@@ -3934,7 +4004,7 @@ function ca({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
|
|
|
3934
4004
|
size: "sm",
|
|
3935
4005
|
variant: "default",
|
|
3936
4006
|
disabled: n,
|
|
3937
|
-
onClick: () => void
|
|
4007
|
+
onClick: () => void oe(e.id),
|
|
3938
4008
|
"data-testid": `ai-inbox-approve-${e.id}`,
|
|
3939
4009
|
children: [/* @__PURE__ */ Q(Y, { className: "h-3.5 w-3.5 mr-1" }), n ? "Working…" : "Approve"]
|
|
3940
4010
|
}), /* @__PURE__ */ $(v, {
|
|
@@ -3967,10 +4037,10 @@ function ca({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
|
|
|
3967
4037
|
o
|
|
3968
4038
|
]
|
|
3969
4039
|
}), s ? /* @__PURE__ */ Q(x, { children: s }) : null]
|
|
3970
|
-
}), /* @__PURE__ */ Q(b, { children:
|
|
4040
|
+
}), /* @__PURE__ */ Q(b, { children: z })]
|
|
3971
4041
|
}) : /* @__PURE__ */ Q("div", {
|
|
3972
4042
|
className: c,
|
|
3973
|
-
children:
|
|
4043
|
+
children: z
|
|
3974
4044
|
}),
|
|
3975
4045
|
/* @__PURE__ */ Q(he, {
|
|
3976
4046
|
open: !!d,
|
|
@@ -3979,7 +4049,7 @@ function ca({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
|
|
|
3979
4049
|
},
|
|
3980
4050
|
children: /* @__PURE__ */ $(ge, {
|
|
3981
4051
|
className: "sm:max-w-[560px] overflow-y-auto",
|
|
3982
|
-
children: [/* @__PURE__ */ $(
|
|
4052
|
+
children: [/* @__PURE__ */ $(ve, { children: [/* @__PURE__ */ $(ye, {
|
|
3983
4053
|
className: "flex items-center gap-2",
|
|
3984
4054
|
children: [/* @__PURE__ */ Q(Me, { className: "h-4 w-4" }), L ? L.action_name : "Pending action"]
|
|
3985
4055
|
}), /* @__PURE__ */ Q(_e, { children: L ? /* @__PURE__ */ $(Z, { children: [
|
|
@@ -4005,14 +4075,14 @@ function ca({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
|
|
|
4005
4075
|
children: "Status"
|
|
4006
4076
|
}), /* @__PURE__ */ Q("div", {
|
|
4007
4077
|
className: "mt-1",
|
|
4008
|
-
children: /* @__PURE__ */ Q(
|
|
4078
|
+
children: /* @__PURE__ */ Q(oa, { status: L.status })
|
|
4009
4079
|
})] }),
|
|
4010
4080
|
/* @__PURE__ */ $("div", { children: [/* @__PURE__ */ Q(B, {
|
|
4011
4081
|
className: "text-xs text-muted-foreground",
|
|
4012
4082
|
children: "Proposed"
|
|
4013
4083
|
}), /* @__PURE__ */ Q("div", {
|
|
4014
4084
|
className: "mt-1 text-xs",
|
|
4015
|
-
children:
|
|
4085
|
+
children: sa(L.proposed_at)
|
|
4016
4086
|
})] }),
|
|
4017
4087
|
/* @__PURE__ */ $("div", { children: [/* @__PURE__ */ Q(B, {
|
|
4018
4088
|
className: "text-xs text-muted-foreground",
|
|
@@ -4046,21 +4116,21 @@ function ca({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
|
|
|
4046
4116
|
children: "Tool input"
|
|
4047
4117
|
}), /* @__PURE__ */ Q("div", {
|
|
4048
4118
|
className: "mt-1.5",
|
|
4049
|
-
children: /* @__PURE__ */ Q(
|
|
4119
|
+
children: /* @__PURE__ */ Q(la, { value: ca(L.tool_input) })
|
|
4050
4120
|
})] }),
|
|
4051
4121
|
L.result ? /* @__PURE__ */ $("div", { children: [/* @__PURE__ */ Q(B, {
|
|
4052
4122
|
className: "text-xs",
|
|
4053
4123
|
children: "Result"
|
|
4054
4124
|
}), /* @__PURE__ */ Q("div", {
|
|
4055
4125
|
className: "mt-1.5",
|
|
4056
|
-
children: /* @__PURE__ */ Q(
|
|
4126
|
+
children: /* @__PURE__ */ Q(la, { value: ca(L.result) })
|
|
4057
4127
|
})] }) : null,
|
|
4058
4128
|
L.error ? /* @__PURE__ */ $("div", { children: [/* @__PURE__ */ Q(B, {
|
|
4059
4129
|
className: "text-xs text-destructive",
|
|
4060
4130
|
children: "Error"
|
|
4061
4131
|
}), /* @__PURE__ */ Q("div", {
|
|
4062
4132
|
className: "mt-1.5",
|
|
4063
|
-
children: /* @__PURE__ */ Q(
|
|
4133
|
+
children: /* @__PURE__ */ Q(la, { value: L.error })
|
|
4064
4134
|
})] }) : null,
|
|
4065
4135
|
L.rejection_reason ? /* @__PURE__ */ $("div", { children: [/* @__PURE__ */ Q(B, {
|
|
4066
4136
|
className: "text-xs",
|
|
@@ -4073,7 +4143,7 @@ function ca({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
|
|
|
4073
4143
|
className: "pt-2 flex gap-2",
|
|
4074
4144
|
children: [/* @__PURE__ */ $(v, {
|
|
4075
4145
|
size: "sm",
|
|
4076
|
-
onClick: () => void
|
|
4146
|
+
onClick: () => void oe(L.id),
|
|
4077
4147
|
disabled: T === L.id,
|
|
4078
4148
|
children: [/* @__PURE__ */ Q(Y, { className: "h-3.5 w-3.5 mr-1" }), "Approve & Execute"]
|
|
4079
4149
|
}), /* @__PURE__ */ $(v, {
|
|
@@ -4098,9 +4168,9 @@ function ca({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
|
|
|
4098
4168
|
children: /* @__PURE__ */ $(ge, {
|
|
4099
4169
|
side: "bottom",
|
|
4100
4170
|
className: "max-h-[40vh]",
|
|
4101
|
-
children: [/* @__PURE__ */ $(
|
|
4171
|
+
children: [/* @__PURE__ */ $(ve, { children: [/* @__PURE__ */ Q(ye, { children: "Reject this action?" }), /* @__PURE__ */ Q(_e, { children: "The reason is shown back to the AI so it can adjust its next response." })] }), /* @__PURE__ */ $("div", {
|
|
4102
4172
|
className: "px-4 mt-3 space-y-3",
|
|
4103
|
-
children: [/* @__PURE__ */ Q(
|
|
4173
|
+
children: [/* @__PURE__ */ Q(q, {
|
|
4104
4174
|
value: _,
|
|
4105
4175
|
onChange: (e) => w(e.target.value),
|
|
4106
4176
|
placeholder: "Optional reason (e.g. 'Wrong record id — please confirm with the user first.')",
|
|
@@ -4118,7 +4188,7 @@ function ca({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
|
|
|
4118
4188
|
}), /* @__PURE__ */ $(v, {
|
|
4119
4189
|
variant: "destructive",
|
|
4120
4190
|
size: "sm",
|
|
4121
|
-
onClick: () => h && void
|
|
4191
|
+
onClick: () => h && void R(h, _),
|
|
4122
4192
|
disabled: !h || T === h,
|
|
4123
4193
|
"data-testid": "ai-inbox-reject-confirm",
|
|
4124
4194
|
children: [/* @__PURE__ */ Q(X, { className: "h-3.5 w-3.5 mr-1" }), "Reject"]
|
|
@@ -4131,14 +4201,14 @@ function ca({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
|
|
|
4131
4201
|
}
|
|
4132
4202
|
//#endregion
|
|
4133
4203
|
//#region src/useHitlInChat.ts
|
|
4134
|
-
function
|
|
4204
|
+
function fa(e) {
|
|
4135
4205
|
return !e || e.length === 0 ? "/api/v1/ai" : e.endsWith("/") ? e.slice(0, -1) : e;
|
|
4136
4206
|
}
|
|
4137
|
-
function
|
|
4207
|
+
function pa(e, t) {
|
|
4138
4208
|
let n = { ...e ?? {} };
|
|
4139
4209
|
return t && (n["Content-Type"] = "application/json"), n;
|
|
4140
4210
|
}
|
|
4141
|
-
async function
|
|
4211
|
+
async function ma(e) {
|
|
4142
4212
|
let t = await e.text();
|
|
4143
4213
|
if (!t) return null;
|
|
4144
4214
|
try {
|
|
@@ -4147,8 +4217,8 @@ async function da(e) {
|
|
|
4147
4217
|
return { raw: t };
|
|
4148
4218
|
}
|
|
4149
4219
|
}
|
|
4150
|
-
function
|
|
4151
|
-
let { messages: n, apiBase: r, headers: i, onDecided: a, continueConversation: o } = t, s =
|
|
4220
|
+
function ha(t) {
|
|
4221
|
+
let { messages: n, apiBase: r, headers: i, onDecided: a, continueConversation: o } = t, s = fa(r), c = e.useMemo(() => {
|
|
4152
4222
|
let e = /* @__PURE__ */ new Map();
|
|
4153
4223
|
for (let t of n) {
|
|
4154
4224
|
let n = t.toolInvocations ?? [];
|
|
@@ -4191,9 +4261,9 @@ function fa(t) {
|
|
|
4191
4261
|
let r = `${s}/pending-actions/${encodeURIComponent(l)}/${t ? "approve" : "reject"}`, c = t ? "{}" : JSON.stringify({ reason: n ?? "" }), d = await fetch(r, {
|
|
4192
4262
|
method: "POST",
|
|
4193
4263
|
credentials: "include",
|
|
4194
|
-
headers:
|
|
4264
|
+
headers: pa(i, !0),
|
|
4195
4265
|
body: c
|
|
4196
|
-
}), f = await
|
|
4266
|
+
}), f = await ma(d) ?? {};
|
|
4197
4267
|
if (!d.ok) {
|
|
4198
4268
|
let t = typeof f.error == "string" ? f.error : `Approval failed: HTTP ${d.status}`;
|
|
4199
4269
|
m(e, {
|
|
@@ -4220,7 +4290,7 @@ function fa(t) {
|
|
|
4220
4290
|
state: "success",
|
|
4221
4291
|
message: `Status: ${p}`
|
|
4222
4292
|
}), h = !0), a?.(e, f), h && o) {
|
|
4223
|
-
let r =
|
|
4293
|
+
let r = ga({
|
|
4224
4294
|
approved: t,
|
|
4225
4295
|
status: p,
|
|
4226
4296
|
toolName: u,
|
|
@@ -4255,24 +4325,24 @@ function fa(t) {
|
|
|
4255
4325
|
isDeciding: f
|
|
4256
4326
|
};
|
|
4257
4327
|
}
|
|
4258
|
-
function
|
|
4328
|
+
function ga(e) {
|
|
4259
4329
|
let { approved: t, status: n, toolName: r, pendingActionId: i, outcome: a, reason: o } = e, s = `[HITL ${i}]`;
|
|
4260
4330
|
if (t && n === "executed") {
|
|
4261
4331
|
let e = a.result;
|
|
4262
|
-
return `${s} The operator approved the \`${r}\` call. It executed successfully with result: ${e == null ? "(no payload)" : typeof e == "string" ? e :
|
|
4332
|
+
return `${s} The operator approved the \`${r}\` call. It executed successfully with result: ${e == null ? "(no payload)" : typeof e == "string" ? e : _a(JSON.stringify(e), 800)}. Acknowledge the outcome concisely and continue the user's task.`;
|
|
4263
4333
|
}
|
|
4264
4334
|
if (!t && n === "rejected") return `${s} The operator rejected the \`${r}\` call.${o && o.trim().length > 0 ? ` Reason: ${o}.` : ""} Acknowledge the rejection and ask whether to try a different approach.`;
|
|
4265
4335
|
if (n === "failed") {
|
|
4266
4336
|
let e = a.error;
|
|
4267
|
-
return `${s} The \`${r}\` call was approved but execution failed: ${typeof e == "string" ? e :
|
|
4337
|
+
return `${s} The \`${r}\` call was approved but execution failed: ${typeof e == "string" ? e : _a(JSON.stringify(e ?? {}), 400)}. Apologize concisely and offer alternatives.`;
|
|
4268
4338
|
}
|
|
4269
4339
|
}
|
|
4270
|
-
function
|
|
4340
|
+
function _a(e, t) {
|
|
4271
4341
|
return e.length <= t ? e : `${e.slice(0, t - 1)}…`;
|
|
4272
4342
|
}
|
|
4273
4343
|
//#endregion
|
|
4274
4344
|
//#region src/index.tsx
|
|
4275
|
-
var
|
|
4345
|
+
var va = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type your message...", onSendMessage: i, disabled: a = !1, showTimestamp: o = !1, userAvatarUrl: s, userAvatarFallback: c = "You", assistantAvatarUrl: l, assistantAvatarFallback: u = "AI", maxHeight: d = "500px", ...f }, p) => {
|
|
4276
4346
|
let [m, h] = e.useState(""), g = e.useRef(null), _ = e.useRef(null);
|
|
4277
4347
|
e.useEffect(() => {
|
|
4278
4348
|
if (g.current) {
|
|
@@ -4298,7 +4368,7 @@ var ha = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
4298
4368
|
children: n.length === 0 ? /* @__PURE__ */ Q("div", {
|
|
4299
4369
|
className: "flex items-center justify-center h-32 text-muted-foreground text-sm",
|
|
4300
4370
|
children: "No messages yet. Start a conversation!"
|
|
4301
|
-
}) : n.map((e) => /* @__PURE__ */ Q(
|
|
4371
|
+
}) : n.map((e) => /* @__PURE__ */ Q(ya, {
|
|
4302
4372
|
message: e,
|
|
4303
4373
|
showTimestamp: o,
|
|
4304
4374
|
userAvatarUrl: s,
|
|
@@ -4311,7 +4381,7 @@ var ha = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
4311
4381
|
className: "border-t p-4",
|
|
4312
4382
|
children: /* @__PURE__ */ $("div", {
|
|
4313
4383
|
className: "flex gap-2",
|
|
4314
|
-
children: [/* @__PURE__ */ Q(
|
|
4384
|
+
children: [/* @__PURE__ */ Q(z, {
|
|
4315
4385
|
ref: _,
|
|
4316
4386
|
value: m,
|
|
4317
4387
|
onChange: (e) => h(e.target.value),
|
|
@@ -4329,8 +4399,8 @@ var ha = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
4329
4399
|
})]
|
|
4330
4400
|
});
|
|
4331
4401
|
});
|
|
4332
|
-
|
|
4333
|
-
var
|
|
4402
|
+
va.displayName = "Chatbot";
|
|
4403
|
+
var ya = ({ message: e, showTimestamp: t, userAvatarUrl: n, userAvatarFallback: r, assistantAvatarUrl: i, assistantAvatarFallback: a }) => {
|
|
4334
4404
|
let o = e.role === "user";
|
|
4335
4405
|
if (e.role === "system") return /* @__PURE__ */ Q("div", {
|
|
4336
4406
|
className: "flex justify-center",
|
|
@@ -4362,7 +4432,7 @@ var ga = ({ message: e, showTimestamp: t, userAvatarUrl: n, userAvatarFallback:
|
|
|
4362
4432
|
})]
|
|
4363
4433
|
})]
|
|
4364
4434
|
});
|
|
4365
|
-
},
|
|
4435
|
+
}, ba = e.forwardRef(({ className: e, avatarSrc: t, avatarFallback: n = "AI", ...r }, i) => /* @__PURE__ */ $("div", {
|
|
4366
4436
|
ref: i,
|
|
4367
4437
|
className: J("flex gap-3", e),
|
|
4368
4438
|
...r,
|
|
@@ -4384,6 +4454,6 @@ var ga = ({ message: e, showTimestamp: t, userAvatarUrl: n, userAvatarFallback:
|
|
|
4384
4454
|
})
|
|
4385
4455
|
})]
|
|
4386
4456
|
}));
|
|
4387
|
-
|
|
4457
|
+
ba.displayName = "TypingIndicator";
|
|
4388
4458
|
//#endregion
|
|
4389
|
-
export {
|
|
4459
|
+
export { tn as AGENT_ALIAS_GROUPS, ea as AIElements, da as AiPendingActionsInbox, va as Chatbot, Ni as ChatbotEnhanced, Zi as FloatingChatbot, En as FloatingChatbotPanel, mn as FloatingChatbotProvider, bn as FloatingChatbotTrigger, ln as PLATFORM_DEFAULT_AGENT, ba as TypingIndicator, nn as agentAliasGroup, rn as agentRouteName, Gt as buildProgressFromDraftReview, Ut as detectDraftResult, Ht as detectProposedPlan, On as humanizeToolName, cn as isAskAgent, sn as isBuildAgent, on as isBuiltinAgentName, Ti as publishHealthFromResponse, an as resolveAgentParam, un as resolveDefaultAgentName, An as summarizeChatError, Xt as uiMessageToChatMessage, Zt as uiMessagesToChatMessages, kn as unwrapToolResult, fn as useAgents, hn as useFloatingChatbot, ha as useHitlInChat, en as useObjectChat, ia as usePendingActions };
|