@object-ui/plugin-chatbot 6.2.3 → 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 +107 -0
- package/README.md +60 -4
- package/dist/{packages/plugin-chatbot/src/AiPendingActionsInbox.d.ts → AiPendingActionsInbox.d.ts} +17 -1
- package/dist/AiPendingActionsInbox.d.ts.map +1 -0
- package/dist/ChatbotEnhanced.d.ts +591 -0
- package/dist/ChatbotEnhanced.d.ts.map +1 -0
- package/dist/{packages/plugin-chatbot/src/FloatingChatbot.d.ts → FloatingChatbot.d.ts} +1 -1
- package/dist/FloatingChatbot.d.ts.map +1 -0
- package/dist/{packages/plugin-chatbot/src/FloatingChatbotPanel.d.ts → FloatingChatbotPanel.d.ts} +1 -1
- package/dist/FloatingChatbotPanel.d.ts.map +1 -0
- package/dist/{packages/plugin-chatbot/src/FloatingChatbotProvider.d.ts → FloatingChatbotProvider.d.ts} +1 -1
- package/dist/FloatingChatbotProvider.d.ts.map +1 -0
- package/dist/{packages/plugin-chatbot/src/FloatingChatbotTrigger.d.ts → FloatingChatbotTrigger.d.ts} +2 -1
- package/dist/FloatingChatbotTrigger.d.ts.map +1 -0
- package/dist/agentAliases.d.ts +57 -0
- package/dist/agentAliases.d.ts.map +1 -0
- package/dist/{packages/plugin-chatbot/src/elements → elements}/code-block.d.ts +2 -2
- package/dist/elements/code-block.d.ts.map +1 -0
- package/dist/{packages/plugin-chatbot/src/elements → elements}/conversation.d.ts +4 -4
- package/dist/elements/conversation.d.ts.map +1 -0
- package/dist/elements/index.d.ts.map +1 -0
- package/dist/{packages/plugin-chatbot/src/elements → elements}/loader.d.ts +1 -1
- package/dist/elements/loader.d.ts.map +1 -0
- package/dist/{packages/plugin-chatbot/src/elements → elements}/message.d.ts +14 -14
- package/dist/elements/message.d.ts.map +1 -0
- package/dist/{packages/plugin-chatbot/src/elements → elements}/prompt-input.d.ts +38 -37
- package/dist/elements/prompt-input.d.ts.map +1 -0
- package/dist/{packages/plugin-chatbot/src/elements → elements}/reasoning.d.ts +3 -3
- package/dist/elements/reasoning.d.ts.map +1 -0
- package/dist/{packages/plugin-chatbot/src/elements → elements}/shimmer.d.ts +2 -2
- package/dist/elements/shimmer.d.ts.map +1 -0
- package/dist/{packages/plugin-chatbot/src/elements → elements}/sources.d.ts +4 -4
- package/dist/elements/sources.d.ts.map +1 -0
- package/dist/{packages/plugin-chatbot/src/elements → elements}/suggestion.d.ts +2 -2
- package/dist/elements/suggestion.d.ts.map +1 -0
- package/dist/{packages/plugin-chatbot/src/elements → elements}/tool.d.ts +5 -5
- package/dist/elements/tool.d.ts.map +1 -0
- package/dist/{packages/plugin-chatbot/src/elements → elements}/ui/button-group.d.ts +3 -3
- package/dist/elements/ui/button-group.d.ts.map +1 -0
- package/dist/{packages/plugin-chatbot/src/elements → elements}/ui/input-group.d.ts +6 -6
- package/dist/elements/ui/input-group.d.ts.map +1 -0
- package/dist/index.d.ts +70 -2
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2074 -987
- package/dist/index.umd.cjs +1 -1
- package/dist/mapMessages.d.ts +147 -0
- package/dist/mapMessages.d.ts.map +1 -0
- package/dist/renderer.d.ts.map +1 -0
- package/dist/{packages/plugin-chatbot/src/tool-display.d.ts → tool-display.d.ts} +23 -0
- package/dist/tool-display.d.ts.map +1 -0
- package/dist/{packages/plugin-chatbot/src/useAgents.d.ts → useAgents.d.ts} +28 -0
- package/dist/useAgents.d.ts.map +1 -0
- package/dist/useHitlInChat.d.ts.map +1 -0
- package/dist/{packages/plugin-chatbot/src/useObjectChat.d.ts → useObjectChat.d.ts} +37 -1
- package/dist/useObjectChat.d.ts.map +1 -0
- package/dist/usePendingActions.d.ts.map +1 -0
- package/dist/utils.d.ts.map +1 -0
- package/package.json +16 -16
- package/dist/packages/plugin-chatbot/src/AiPendingActionsInbox.d.ts.map +0 -1
- package/dist/packages/plugin-chatbot/src/ChatbotEnhanced.d.ts +0 -171
- package/dist/packages/plugin-chatbot/src/ChatbotEnhanced.d.ts.map +0 -1
- package/dist/packages/plugin-chatbot/src/FloatingChatbot.d.ts.map +0 -1
- package/dist/packages/plugin-chatbot/src/FloatingChatbotPanel.d.ts.map +0 -1
- package/dist/packages/plugin-chatbot/src/FloatingChatbotProvider.d.ts.map +0 -1
- package/dist/packages/plugin-chatbot/src/FloatingChatbotTrigger.d.ts.map +0 -1
- package/dist/packages/plugin-chatbot/src/elements/code-block.d.ts.map +0 -1
- package/dist/packages/plugin-chatbot/src/elements/conversation.d.ts.map +0 -1
- package/dist/packages/plugin-chatbot/src/elements/index.d.ts.map +0 -1
- package/dist/packages/plugin-chatbot/src/elements/loader.d.ts.map +0 -1
- package/dist/packages/plugin-chatbot/src/elements/message.d.ts.map +0 -1
- package/dist/packages/plugin-chatbot/src/elements/prompt-input.d.ts.map +0 -1
- package/dist/packages/plugin-chatbot/src/elements/reasoning.d.ts.map +0 -1
- package/dist/packages/plugin-chatbot/src/elements/shimmer.d.ts.map +0 -1
- package/dist/packages/plugin-chatbot/src/elements/sources.d.ts.map +0 -1
- package/dist/packages/plugin-chatbot/src/elements/suggestion.d.ts.map +0 -1
- package/dist/packages/plugin-chatbot/src/elements/tool.d.ts.map +0 -1
- package/dist/packages/plugin-chatbot/src/elements/ui/button-group.d.ts.map +0 -1
- package/dist/packages/plugin-chatbot/src/elements/ui/input-group.d.ts.map +0 -1
- package/dist/packages/plugin-chatbot/src/index.d.ts +0 -68
- package/dist/packages/plugin-chatbot/src/index.d.ts.map +0 -1
- package/dist/packages/plugin-chatbot/src/mapMessages.d.ts +0 -45
- package/dist/packages/plugin-chatbot/src/mapMessages.d.ts.map +0 -1
- package/dist/packages/plugin-chatbot/src/renderer.d.ts.map +0 -1
- package/dist/packages/plugin-chatbot/src/tool-display.d.ts.map +0 -1
- package/dist/packages/plugin-chatbot/src/useAgents.d.ts.map +0 -1
- package/dist/packages/plugin-chatbot/src/useHitlInChat.d.ts.map +0 -1
- package/dist/packages/plugin-chatbot/src/useObjectChat.d.ts.map +0 -1
- package/dist/packages/plugin-chatbot/src/usePendingActions.d.ts.map +0 -1
- package/dist/packages/plugin-chatbot/src/utils.d.ts.map +0 -1
- /package/dist/{packages/plugin-chatbot/src/elements → elements}/index.d.ts +0 -0
- /package/dist/{packages/plugin-chatbot/src/renderer.d.ts → renderer.d.ts} +0 -0
- /package/dist/{packages/plugin-chatbot/src/useHitlInChat.d.ts → useHitlInChat.d.ts} +0 -0
- /package/dist/{packages/plugin-chatbot/src/usePendingActions.d.ts → usePendingActions.d.ts} +0 -0
- /package/dist/{packages/plugin-chatbot/src/utils.d.ts → utils.d.ts} +0 -0
package/dist/index.js
CHANGED
|
@@ -1,45 +1,45 @@
|
|
|
1
1
|
import * as e from "react";
|
|
2
2
|
import { Children as t, Fragment as n, createContext as r, isValidElement as i, memo as a, useCallback as o, useContext as s, useEffect as c, useMemo as l, useRef as u, useState as d } from "react";
|
|
3
|
-
import { Alert as f, AlertDescription as p, Avatar as m, AvatarFallback as h, AvatarImage as g, Badge as _, Button as v, Card as y, CardContent as b, CardDescription as x, CardHeader as S, CardTitle as C, Collapsible as w, CollapsibleContent as T, CollapsibleTrigger as E, Command as D, CommandEmpty as O, CommandGroup as k, CommandInput as A, CommandItem as j, CommandList as M, CommandSeparator as N, DropdownMenu as
|
|
4
|
-
import { AlertCircle as
|
|
5
|
-
import { Fragment as
|
|
6
|
-
import { useChat as
|
|
7
|
-
import { DefaultChatTransport as
|
|
8
|
-
import * as
|
|
9
|
-
import { useObjectTranslation 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
|
|
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
|
+
import { Fragment as Z, jsx as Q, jsxs as $ } from "react/jsx-runtime";
|
|
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;
|
|
@@ -52,31 +52,136 @@ function Nt(e) {
|
|
|
52
52
|
}
|
|
53
53
|
}, n = [e];
|
|
54
54
|
e && typeof e == "object" && "value" in e && n.push(e.value);
|
|
55
|
+
let r;
|
|
55
56
|
for (let e of n) {
|
|
56
57
|
let n = t(e);
|
|
57
|
-
if (
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
raw: n
|
|
62
|
-
};
|
|
58
|
+
if (n) {
|
|
59
|
+
if (typeof n.status == "string") return n;
|
|
60
|
+
r ??= n;
|
|
61
|
+
}
|
|
63
62
|
}
|
|
63
|
+
return r;
|
|
64
|
+
}
|
|
65
|
+
function Bt(e) {
|
|
66
|
+
let t = zt(e);
|
|
67
|
+
if (!t) return;
|
|
68
|
+
let n = t.pendingActionId;
|
|
69
|
+
if (t.status === "pending_approval" && typeof n == "string" && n.length > 0) return {
|
|
70
|
+
pendingActionId: n,
|
|
71
|
+
raw: t
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
function Vt(e) {
|
|
75
|
+
return Array.isArray(e) ? e.filter((e) => typeof e == "string" && e.trim().length > 0) : [];
|
|
76
|
+
}
|
|
77
|
+
function Ht(e) {
|
|
78
|
+
let t = zt(e);
|
|
79
|
+
if (!t || t.status !== "blueprint_proposed") return;
|
|
80
|
+
let n = t.blueprint, r = n && typeof n == "object" ? n : {}, i = (Array.isArray(r.objects) ? r.objects : []).flatMap((e) => {
|
|
81
|
+
let t = e;
|
|
82
|
+
return typeof t?.name != "string" || !t.name ? [] : [{
|
|
83
|
+
name: t.name,
|
|
84
|
+
...typeof t.label == "string" && t.label ? { label: t.label } : {},
|
|
85
|
+
fieldCount: Array.isArray(t.fields) ? t.fields.length : 0
|
|
86
|
+
}];
|
|
87
|
+
});
|
|
88
|
+
if (i.length === 0) return;
|
|
89
|
+
let a = (e, t) => typeof e == "number" && Number.isFinite(e) ? e : t, o = t.counts ?? {}, s = {
|
|
90
|
+
objects: a(o.objects, i.length),
|
|
91
|
+
views: a(o.views, Array.isArray(r.views) ? r.views.length : 0),
|
|
92
|
+
dashboards: a(o.dashboards, Array.isArray(r.dashboards) ? r.dashboards.length : 0),
|
|
93
|
+
seedData: a(o.seedData, Array.isArray(r.seedData) ? r.seedData.length : 0)
|
|
94
|
+
}, c = Vt(t.questions), l = t.questionChoices, u = Array.isArray(l) ? l.flatMap((e) => {
|
|
95
|
+
let t = e;
|
|
96
|
+
if (typeof t?.text != "string" || !t.text) return [];
|
|
97
|
+
let n = Array.isArray(t.options) ? t.options.filter((e) => typeof e == "string" && e.trim().length > 0) : [];
|
|
98
|
+
return n.length >= 2 ? [{
|
|
99
|
+
text: t.text,
|
|
100
|
+
options: n
|
|
101
|
+
}] : [];
|
|
102
|
+
}) : [], d = typeof t.summary == "string" && t.summary ? t.summary : typeof r.summary == "string" && r.summary ? r.summary : void 0, f = t.targetApp;
|
|
103
|
+
return {
|
|
104
|
+
...d ? { summary: d } : {},
|
|
105
|
+
objects: i,
|
|
106
|
+
counts: s,
|
|
107
|
+
questions: c.length ? c : Vt(r.questions),
|
|
108
|
+
...u.length ? { questionChoices: u } : {},
|
|
109
|
+
assumptions: Vt(r.assumptions),
|
|
110
|
+
...typeof f == "string" && f ? { targetApp: f } : {}
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
function Ut(e) {
|
|
114
|
+
let t = zt(e);
|
|
115
|
+
if (!t || t.status !== "drafted") return;
|
|
116
|
+
let n = [];
|
|
117
|
+
if (Array.isArray(t.drafted)) {
|
|
118
|
+
for (let e of t.drafted) if (e && typeof e == "object") {
|
|
119
|
+
let { type: t, name: r } = e;
|
|
120
|
+
typeof t == "string" && typeof r == "string" && n.push({
|
|
121
|
+
type: t,
|
|
122
|
+
name: r
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
} else typeof t.type == "string" && typeof t.name == "string" && n.push({
|
|
126
|
+
type: t.type,
|
|
127
|
+
name: t.name
|
|
128
|
+
});
|
|
129
|
+
if (n.length === 0) return;
|
|
130
|
+
let r = Array.isArray(t.failed) ? t.failed.length : 0, i = t.verification, a = i && typeof i == "object" && typeof i.errors == "number" && typeof i.warnings == "number" ? {
|
|
131
|
+
errors: i.errors,
|
|
132
|
+
warnings: i.warnings
|
|
133
|
+
} : void 0, o = t.issues, s = Array.isArray(o) ? o.flatMap((e) => {
|
|
134
|
+
let t = e;
|
|
135
|
+
return typeof t?.message != "string" || !t.message ? [] : [{
|
|
136
|
+
severity: t.severity === "error" ? "error" : "warning",
|
|
137
|
+
code: typeof t.code == "string" ? t.code : "issue",
|
|
138
|
+
message: t.message,
|
|
139
|
+
...typeof t.fix == "string" && t.fix ? { fix: t.fix } : {}
|
|
140
|
+
}];
|
|
141
|
+
}) : [], c = t.nextSteps, l = Array.isArray(c) ? c.filter((e) => typeof e == "string" && e.trim().length > 0) : [];
|
|
142
|
+
return {
|
|
143
|
+
items: n,
|
|
144
|
+
summary: typeof t.summary == "string" ? t.summary : void 0,
|
|
145
|
+
...typeof t.packageId == "string" && t.packageId ? { packageId: t.packageId } : {},
|
|
146
|
+
...t.autoPublishable === !0 ? { autoPublishable: !0 } : {},
|
|
147
|
+
...r > 0 ? { failedCount: r } : {},
|
|
148
|
+
...l.length ? { nextSteps: l } : {},
|
|
149
|
+
...t.materialized === !0 ? { materialized: !0 } : {},
|
|
150
|
+
...a ? { verification: a } : {},
|
|
151
|
+
...s.length ? { issues: s } : {}
|
|
152
|
+
};
|
|
64
153
|
}
|
|
65
|
-
function
|
|
154
|
+
function Wt(e) {
|
|
155
|
+
return e.replace(/[._-]+/g, " ").replace(/\s+/g, " ").trim().replace(/\b\w/g, (e) => e.toUpperCase());
|
|
156
|
+
}
|
|
157
|
+
function Gt(e) {
|
|
158
|
+
if (!e || !Array.isArray(e.items) || e.items.length === 0) return;
|
|
159
|
+
let t = e.items.find((e) => e.type === "app");
|
|
160
|
+
if (t) return {
|
|
161
|
+
phase: "done",
|
|
162
|
+
appLabel: Wt(t.name),
|
|
163
|
+
items: e.items,
|
|
164
|
+
done: e.items.length,
|
|
165
|
+
total: e.items.length
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
function Kt(e, t = {}) {
|
|
66
169
|
return e.filter((e) => e.type === "dynamic-tool" ? !0 : typeof e.type == "string" && e.type.startsWith("tool-")).map((e) => {
|
|
67
|
-
let
|
|
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;
|
|
68
171
|
return {
|
|
69
172
|
toolCallId: e.toolCallId ?? e.id ?? `${e.type ?? "tool"}-${Math.random().toString(36).slice(2, 8)}`,
|
|
70
|
-
toolName:
|
|
173
|
+
toolName: n,
|
|
71
174
|
args: e.input ?? e.args,
|
|
72
|
-
result:
|
|
175
|
+
result: r,
|
|
73
176
|
errorText: e.errorText,
|
|
74
|
-
state:
|
|
75
|
-
pendingActionId:
|
|
177
|
+
state: l,
|
|
178
|
+
pendingActionId: i?.pendingActionId,
|
|
179
|
+
draftReview: a,
|
|
180
|
+
proposedPlan: o
|
|
76
181
|
};
|
|
77
182
|
});
|
|
78
183
|
}
|
|
79
|
-
function
|
|
184
|
+
function qt(e) {
|
|
80
185
|
let t = e.filter((e) => e.type === "source-url" || e.type === "source").map((e) => ({
|
|
81
186
|
id: e.id,
|
|
82
187
|
title: e.title,
|
|
@@ -84,26 +189,75 @@ function Ft(e) {
|
|
|
84
189
|
})).filter((e) => !!e.url);
|
|
85
190
|
return t.length > 0 ? t : void 0;
|
|
86
191
|
}
|
|
87
|
-
function
|
|
88
|
-
let
|
|
192
|
+
function Jt(e) {
|
|
193
|
+
let t = e.filter((e) => e.type === "data-build-progress").pop()?.data;
|
|
194
|
+
if (!t || typeof t != "object") return;
|
|
195
|
+
let n = t, r = Array.isArray(n.items) ? n.items.filter((e) => typeof e?.type == "string" && typeof e?.name == "string").map((e) => ({
|
|
196
|
+
type: e.type,
|
|
197
|
+
name: e.name
|
|
198
|
+
})) : [];
|
|
199
|
+
return {
|
|
200
|
+
phase: n.phase === "data" || n.phase === "done" ? n.phase : "structure",
|
|
201
|
+
...typeof n.appLabel == "string" ? { appLabel: n.appLabel } : {},
|
|
202
|
+
items: r,
|
|
203
|
+
done: typeof n.done == "number" ? n.done : r.length,
|
|
204
|
+
total: typeof n.total == "number" ? n.total : r.length,
|
|
205
|
+
...typeof n.seq == "number" ? { seq: n.seq } : {}
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
function Yt(e) {
|
|
209
|
+
let t = [];
|
|
210
|
+
for (let n of e) {
|
|
211
|
+
if (n.type !== "data-chart") continue;
|
|
212
|
+
let e = n.data;
|
|
213
|
+
if (!e || typeof e != "object") continue;
|
|
214
|
+
let r = e, i = Array.isArray(r.data) ? r.data : [], a = Array.isArray(r.series) ? r.series.filter((e) => e && typeof e.dataKey == "string").map((e) => ({
|
|
215
|
+
dataKey: e.dataKey,
|
|
216
|
+
...typeof e.label == "string" ? { label: e.label } : {}
|
|
217
|
+
})) : [];
|
|
218
|
+
a.length !== 0 && t.push({
|
|
219
|
+
...typeof r.chartType == "string" ? { chartType: r.chartType } : {},
|
|
220
|
+
...typeof r.title == "string" ? { title: r.title } : {},
|
|
221
|
+
data: i,
|
|
222
|
+
...typeof r.xAxisKey == "string" ? { xAxisKey: r.xAxisKey } : {},
|
|
223
|
+
series: a
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
return t.length > 0 ? t : void 0;
|
|
227
|
+
}
|
|
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);
|
|
89
230
|
return {
|
|
90
231
|
id: e.id ?? `msg-${Math.random().toString(36).slice(2, 8)}`,
|
|
91
232
|
role: e.role ?? "assistant",
|
|
92
|
-
content:
|
|
93
|
-
reasoning:
|
|
94
|
-
toolInvocations:
|
|
95
|
-
sources:
|
|
233
|
+
content: Lt(e, n),
|
|
234
|
+
reasoning: Rt(n),
|
|
235
|
+
toolInvocations: a,
|
|
236
|
+
sources: qt(n),
|
|
237
|
+
buildProgress: o,
|
|
238
|
+
charts: Yt(n),
|
|
96
239
|
streaming: t.streaming
|
|
97
240
|
};
|
|
98
241
|
}
|
|
99
|
-
function
|
|
242
|
+
function Zt(e, t = {}) {
|
|
100
243
|
if (!Array.isArray(e) || e.length === 0) return [];
|
|
101
244
|
let n = e.length - 1;
|
|
102
|
-
return e.map((e, r) =>
|
|
245
|
+
return e.map((e, r) => Xt(e, { streaming: !!t.isStreaming && r === n && e.role === "assistant" }));
|
|
103
246
|
}
|
|
104
247
|
//#endregion
|
|
105
248
|
//#region src/useObjectChat.ts
|
|
106
|
-
function
|
|
249
|
+
function Qt(e) {
|
|
250
|
+
let t = [...e.messages].reverse().find((e) => e.role === "user");
|
|
251
|
+
return { body: {
|
|
252
|
+
...e.body ?? {},
|
|
253
|
+
id: e.id,
|
|
254
|
+
messages: e.messages,
|
|
255
|
+
trigger: e.trigger,
|
|
256
|
+
messageId: e.messageId,
|
|
257
|
+
...t ? { turnId: t.id } : {}
|
|
258
|
+
} };
|
|
259
|
+
}
|
|
260
|
+
function $t(e) {
|
|
107
261
|
return (e ?? []).map((e, t) => ({
|
|
108
262
|
id: e.id || `msg-${t}`,
|
|
109
263
|
role: e.role || "user",
|
|
@@ -114,17 +268,41 @@ function Rt(e) {
|
|
|
114
268
|
toolInvocations: e.toolInvocations
|
|
115
269
|
}));
|
|
116
270
|
}
|
|
117
|
-
function
|
|
118
|
-
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(() =>
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
271
|
+
function en(e = {}) {
|
|
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
|
+
if (Array.isArray(e.parts) && e.parts.length > 0) return {
|
|
274
|
+
id: e.id || `msg-${t}`,
|
|
275
|
+
role: e.role || "user",
|
|
276
|
+
parts: e.parts
|
|
277
|
+
};
|
|
278
|
+
let n = $t([e])[0], r = [];
|
|
279
|
+
n.content && r.push({
|
|
122
280
|
type: "text",
|
|
123
|
-
text:
|
|
124
|
-
}
|
|
125
|
-
|
|
281
|
+
text: n.content
|
|
282
|
+
}), e.reasoning && r.push({
|
|
283
|
+
type: "reasoning",
|
|
284
|
+
text: e.reasoning
|
|
285
|
+
});
|
|
286
|
+
for (let e of n.toolInvocations ?? []) r.push({
|
|
287
|
+
type: `tool-${e.toolName}`,
|
|
288
|
+
toolCallId: e.toolCallId,
|
|
289
|
+
toolName: e.toolName,
|
|
290
|
+
input: e.args,
|
|
291
|
+
output: e.result,
|
|
292
|
+
errorText: e.errorText,
|
|
293
|
+
state: e.state
|
|
294
|
+
});
|
|
295
|
+
return {
|
|
296
|
+
id: n.id || `msg-${t}`,
|
|
297
|
+
role: n.role,
|
|
298
|
+
parts: r.length > 0 ? r : [{
|
|
299
|
+
type: "text",
|
|
300
|
+
text: ""
|
|
301
|
+
}]
|
|
302
|
+
};
|
|
303
|
+
}), []), C = yt({
|
|
126
304
|
transport: l(() => {
|
|
127
|
-
if (x) return new
|
|
305
|
+
if (x) return new bt({
|
|
128
306
|
api: t,
|
|
129
307
|
headers: { ...f },
|
|
130
308
|
body: {
|
|
@@ -133,7 +311,14 @@ function J(e = {}) {
|
|
|
133
311
|
...a ? { model: a } : {},
|
|
134
312
|
...i ? { systemPrompt: i } : {},
|
|
135
313
|
...s === void 0 ? {} : { stream: s }
|
|
136
|
-
}
|
|
314
|
+
},
|
|
315
|
+
prepareSendMessagesRequest: ({ id: e, body: t, messages: n, trigger: r, messageId: i }) => Qt({
|
|
316
|
+
id: e,
|
|
317
|
+
body: t,
|
|
318
|
+
messages: n,
|
|
319
|
+
trigger: r,
|
|
320
|
+
messageId: i
|
|
321
|
+
})
|
|
137
322
|
});
|
|
138
323
|
}, [
|
|
139
324
|
x,
|
|
@@ -149,11 +334,11 @@ function J(e = {}) {
|
|
|
149
334
|
onError: x ? (e) => {
|
|
150
335
|
h?.(e);
|
|
151
336
|
} : void 0
|
|
152
|
-
}), [w, T] = d(() =>
|
|
337
|
+
}), [w, T] = d(() => $t(n)), [E, D] = d(!1), [O, k] = d(""), [A, j] = d(""), M = u(null);
|
|
153
338
|
if (c(() => () => {
|
|
154
339
|
M.current &&= (clearTimeout(M.current), null);
|
|
155
340
|
}, []), x) {
|
|
156
|
-
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) => ({
|
|
157
342
|
...t,
|
|
158
343
|
metadata: e[n]?.metadata
|
|
159
344
|
}));
|
|
@@ -165,7 +350,7 @@ function J(e = {}) {
|
|
|
165
350
|
let t = e.trim();
|
|
166
351
|
if (!t) return;
|
|
167
352
|
let n = [...l, {
|
|
168
|
-
id:
|
|
353
|
+
id: It("msg"),
|
|
169
354
|
role: "user",
|
|
170
355
|
content: t
|
|
171
356
|
}];
|
|
@@ -180,6 +365,7 @@ function J(e = {}) {
|
|
|
180
365
|
clear: o(() => {
|
|
181
366
|
s([]);
|
|
182
367
|
}, [s]),
|
|
368
|
+
setMessages: s,
|
|
183
369
|
isApiMode: !0,
|
|
184
370
|
input: A,
|
|
185
371
|
setInput: j,
|
|
@@ -198,7 +384,7 @@ function J(e = {}) {
|
|
|
198
384
|
sendMessage: o((e) => {
|
|
199
385
|
if (!e.trim()) return;
|
|
200
386
|
let t = {
|
|
201
|
-
id:
|
|
387
|
+
id: It("msg"),
|
|
202
388
|
role: "user",
|
|
203
389
|
content: e.trim(),
|
|
204
390
|
timestamp: g ? (/* @__PURE__ */ new Date()).toLocaleTimeString() : void 0
|
|
@@ -208,7 +394,7 @@ function J(e = {}) {
|
|
|
208
394
|
return b?.(e.trim(), r), r;
|
|
209
395
|
}), k(""), _ && (D(!0), M.current = setTimeout(() => {
|
|
210
396
|
let e = {
|
|
211
|
-
id:
|
|
397
|
+
id: It("msg"),
|
|
212
398
|
role: "assistant",
|
|
213
399
|
content: v || "Thank you for your message!",
|
|
214
400
|
timestamp: g ? (/* @__PURE__ */ new Date()).toLocaleTimeString() : void 0
|
|
@@ -236,8 +422,42 @@ function J(e = {}) {
|
|
|
236
422
|
};
|
|
237
423
|
}
|
|
238
424
|
//#endregion
|
|
425
|
+
//#region src/agentAliases.ts
|
|
426
|
+
var tn = [["build", "metadata_assistant"], ["ask", "data_chat"]];
|
|
427
|
+
function nn(e) {
|
|
428
|
+
return tn.find((t) => t.includes(e)) ?? [e];
|
|
429
|
+
}
|
|
430
|
+
function rn(e) {
|
|
431
|
+
return nn(e)[0];
|
|
432
|
+
}
|
|
433
|
+
function an(e, t) {
|
|
434
|
+
if (e) {
|
|
435
|
+
if (t.includes(e)) return e;
|
|
436
|
+
for (let n of nn(e)) if (t.includes(n)) return n;
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
function on(e) {
|
|
440
|
+
return e != null && tn.some((t) => t.includes(e));
|
|
441
|
+
}
|
|
442
|
+
function sn(e) {
|
|
443
|
+
return e != null && rn(e) === "build";
|
|
444
|
+
}
|
|
445
|
+
function cn(e) {
|
|
446
|
+
return e != null && rn(e) === "ask";
|
|
447
|
+
}
|
|
448
|
+
//#endregion
|
|
239
449
|
//#region src/useAgents.ts
|
|
240
|
-
|
|
450
|
+
var ln = "ask";
|
|
451
|
+
function un(e, t) {
|
|
452
|
+
if (e.length === 0) return;
|
|
453
|
+
let n = e.map((e) => e.name);
|
|
454
|
+
if (t) {
|
|
455
|
+
let e = an(t, n);
|
|
456
|
+
if (e) return e;
|
|
457
|
+
}
|
|
458
|
+
return an("ask", n) || e[0].name;
|
|
459
|
+
}
|
|
460
|
+
function dn(e) {
|
|
241
461
|
return e.filter((e) => typeof e?.name == "string" && e.name.length > 0).map((e) => ({
|
|
242
462
|
name: e.name,
|
|
243
463
|
label: e.label || e.name,
|
|
@@ -246,7 +466,7 @@ function zt(e) {
|
|
|
246
466
|
active: e.active !== !1
|
|
247
467
|
}));
|
|
248
468
|
}
|
|
249
|
-
function
|
|
469
|
+
function fn(e = {}) {
|
|
250
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);
|
|
251
471
|
return _.current = n, c(() => {
|
|
252
472
|
if (!r || !t) return;
|
|
@@ -266,7 +486,7 @@ function Bt(e = {}) {
|
|
|
266
486
|
return e.json();
|
|
267
487
|
}).then((e) => {
|
|
268
488
|
if (n) return;
|
|
269
|
-
let t =
|
|
489
|
+
let t = dn(Array.isArray(e) ? e : e?.agents ?? []);
|
|
270
490
|
s(t.length > 0 ? t : i);
|
|
271
491
|
}).catch((e) => {
|
|
272
492
|
n || e.name === "AbortError" || (m(e), s(i));
|
|
@@ -288,8 +508,8 @@ function Bt(e = {}) {
|
|
|
288
508
|
}
|
|
289
509
|
//#endregion
|
|
290
510
|
//#region src/FloatingChatbotProvider.tsx
|
|
291
|
-
var
|
|
292
|
-
function
|
|
511
|
+
var pn = e.createContext(null);
|
|
512
|
+
function mn({ defaultOpen: t = !1, children: n }) {
|
|
293
513
|
let [r, i] = e.useState(t), [a, o] = e.useState(!1), s = e.useMemo(() => ({
|
|
294
514
|
isOpen: r,
|
|
295
515
|
isFullscreen: a,
|
|
@@ -300,21 +520,21 @@ function Ht({ defaultOpen: t = !1, children: n }) {
|
|
|
300
520
|
toggle: () => i((e) => !e),
|
|
301
521
|
toggleFullscreen: () => o((e) => !e)
|
|
302
522
|
}), [r, a]);
|
|
303
|
-
return /* @__PURE__ */
|
|
523
|
+
return /* @__PURE__ */ Q(pn.Provider, {
|
|
304
524
|
value: s,
|
|
305
525
|
children: n
|
|
306
526
|
});
|
|
307
527
|
}
|
|
308
|
-
function
|
|
309
|
-
let t = e.useContext(
|
|
528
|
+
function hn() {
|
|
529
|
+
let t = e.useContext(pn);
|
|
310
530
|
if (!t) throw Error("useFloatingChatbot must be used within a <FloatingChatbotProvider>");
|
|
311
531
|
return t;
|
|
312
532
|
}
|
|
313
533
|
//#endregion
|
|
314
534
|
//#region src/FloatingChatbotTrigger.tsx
|
|
315
|
-
function
|
|
535
|
+
function gn() {
|
|
316
536
|
try {
|
|
317
|
-
let { t: e } =
|
|
537
|
+
let { t: e } = Ct();
|
|
318
538
|
return (t, n) => {
|
|
319
539
|
let r = e(`common.${t}`);
|
|
320
540
|
return !r || r === `common.${t}` ? n : r;
|
|
@@ -323,87 +543,133 @@ function Wt() {
|
|
|
323
543
|
return (e, t) => t;
|
|
324
544
|
}
|
|
325
545
|
}
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
546
|
+
var _n = {
|
|
547
|
+
32: "size-8",
|
|
548
|
+
36: "size-9",
|
|
549
|
+
40: "size-10",
|
|
550
|
+
44: "size-11",
|
|
551
|
+
48: "size-12",
|
|
552
|
+
52: "size-[52px]",
|
|
553
|
+
56: "size-14",
|
|
554
|
+
60: "size-[60px]",
|
|
555
|
+
64: "size-16",
|
|
556
|
+
72: "size-[72px]",
|
|
557
|
+
80: "size-20"
|
|
558
|
+
};
|
|
559
|
+
function vn(e, t) {
|
|
560
|
+
return t.reduce((t, n) => Math.abs(n - e) < Math.abs(t - e) ? n : t);
|
|
561
|
+
}
|
|
562
|
+
function yn(e) {
|
|
563
|
+
return _n[e] ?? _n[vn(e, Object.keys(_n).map(Number))];
|
|
564
|
+
}
|
|
565
|
+
function bn({ position: e = "bottom-right", size: t = 56, className: n }) {
|
|
566
|
+
let { isOpen: r, toggle: i } = hn(), a = gn();
|
|
567
|
+
return /* @__PURE__ */ Q(v, {
|
|
329
568
|
onClick: i,
|
|
330
|
-
className:
|
|
331
|
-
style: {
|
|
332
|
-
width: t,
|
|
333
|
-
height: t
|
|
334
|
-
},
|
|
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),
|
|
335
570
|
size: "icon",
|
|
336
571
|
"aria-label": r ? a("closeChat", "Close chat") : a("openChat", "Open chat"),
|
|
337
572
|
"data-testid": "floating-chatbot-trigger",
|
|
338
|
-
children:
|
|
573
|
+
children: Q(r ? gt : Me, { className: "h-6 w-6" })
|
|
339
574
|
});
|
|
340
575
|
}
|
|
341
576
|
//#endregion
|
|
342
577
|
//#region src/FloatingChatbotPanel.tsx
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
578
|
+
var xn = {
|
|
579
|
+
300: "sm:w-[300px]",
|
|
580
|
+
320: "sm:w-[320px]",
|
|
581
|
+
340: "sm:w-[340px]",
|
|
582
|
+
360: "sm:w-[360px]",
|
|
583
|
+
380: "sm:w-[380px]",
|
|
584
|
+
400: "sm:w-[400px]",
|
|
585
|
+
420: "sm:w-[420px]",
|
|
586
|
+
440: "sm:w-[440px]",
|
|
587
|
+
450: "sm:w-[450px]",
|
|
588
|
+
460: "sm:w-[460px]",
|
|
589
|
+
480: "sm:w-[480px]",
|
|
590
|
+
500: "sm:w-[500px]",
|
|
591
|
+
520: "sm:w-[520px]",
|
|
592
|
+
560: "sm:w-[560px]",
|
|
593
|
+
600: "sm:w-[600px]",
|
|
594
|
+
640: "sm:w-[640px]",
|
|
595
|
+
720: "sm:w-[720px]",
|
|
596
|
+
800: "sm:w-[800px]"
|
|
597
|
+
}, Sn = {
|
|
598
|
+
360: "h-[min(360px,calc(100svh_-_6rem_-_env(safe-area-inset-bottom)))] sm:h-[360px]",
|
|
599
|
+
400: "h-[min(400px,calc(100svh_-_6rem_-_env(safe-area-inset-bottom)))] sm:h-[400px]",
|
|
600
|
+
420: "h-[min(420px,calc(100svh_-_6rem_-_env(safe-area-inset-bottom)))] sm:h-[420px]",
|
|
601
|
+
440: "h-[min(440px,calc(100svh_-_6rem_-_env(safe-area-inset-bottom)))] sm:h-[440px]",
|
|
602
|
+
480: "h-[min(480px,calc(100svh_-_6rem_-_env(safe-area-inset-bottom)))] sm:h-[480px]",
|
|
603
|
+
500: "h-[min(500px,calc(100svh_-_6rem_-_env(safe-area-inset-bottom)))] sm:h-[500px]",
|
|
604
|
+
520: "h-[min(520px,calc(100svh_-_6rem_-_env(safe-area-inset-bottom)))] sm:h-[520px]",
|
|
605
|
+
560: "h-[min(560px,calc(100svh_-_6rem_-_env(safe-area-inset-bottom)))] sm:h-[560px]",
|
|
606
|
+
600: "h-[min(600px,calc(100svh_-_6rem_-_env(safe-area-inset-bottom)))] sm:h-[600px]",
|
|
607
|
+
640: "h-[min(640px,calc(100svh_-_6rem_-_env(safe-area-inset-bottom)))] sm:h-[640px]",
|
|
608
|
+
720: "h-[min(720px,calc(100svh_-_6rem_-_env(safe-area-inset-bottom)))] sm:h-[720px]",
|
|
609
|
+
800: "h-[min(800px,calc(100svh_-_6rem_-_env(safe-area-inset-bottom)))] sm:h-[800px]"
|
|
610
|
+
};
|
|
611
|
+
function Cn(e, t) {
|
|
612
|
+
return t.reduce((t, n) => Math.abs(n - e) < Math.abs(t - e) ? n : t);
|
|
613
|
+
}
|
|
614
|
+
function wn(e) {
|
|
615
|
+
return xn[e] ?? xn[Cn(e, Object.keys(xn).map(Number))];
|
|
616
|
+
}
|
|
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
|
+
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)]", 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),
|
|
358
624
|
role: "dialog",
|
|
359
625
|
"aria-label": e,
|
|
360
626
|
"data-testid": "floating-chatbot-panel",
|
|
361
|
-
children: [/* @__PURE__ */
|
|
362
|
-
className: "flex items-center justify-between gap-2
|
|
627
|
+
children: [/* @__PURE__ */ $("div", {
|
|
628
|
+
className: "flex min-h-10 items-center justify-between gap-2 border-b bg-muted/40 px-4 py-2",
|
|
363
629
|
children: [
|
|
364
|
-
/* @__PURE__ */
|
|
365
|
-
className: "text-sm font-medium
|
|
630
|
+
/* @__PURE__ */ Q("span", {
|
|
631
|
+
className: "min-w-0 flex-1 truncate text-sm font-medium",
|
|
366
632
|
children: e
|
|
367
633
|
}),
|
|
368
|
-
o ? /* @__PURE__ */
|
|
369
|
-
className: "
|
|
634
|
+
o ? /* @__PURE__ */ Q("div", {
|
|
635
|
+
className: "mr-1 flex min-w-0 items-center justify-end",
|
|
370
636
|
"data-testid": "floating-chatbot-header-extra",
|
|
371
637
|
children: o
|
|
372
638
|
}) : null,
|
|
373
|
-
/* @__PURE__ */
|
|
639
|
+
/* @__PURE__ */ $("div", {
|
|
374
640
|
className: "flex items-center gap-1 shrink-0",
|
|
375
641
|
children: [
|
|
376
642
|
s,
|
|
377
|
-
/* @__PURE__ */
|
|
643
|
+
/* @__PURE__ */ Q(v, {
|
|
378
644
|
variant: "ghost",
|
|
379
645
|
size: "icon",
|
|
380
646
|
className: "h-7 w-7",
|
|
381
647
|
onClick: d,
|
|
382
648
|
"aria-label": l ? "Exit fullscreen" : "Fullscreen",
|
|
383
649
|
"data-testid": "floating-chatbot-fullscreen",
|
|
384
|
-
children:
|
|
650
|
+
children: Q(l ? it : nt, { className: "h-4 w-4" })
|
|
385
651
|
}),
|
|
386
|
-
/* @__PURE__ */
|
|
652
|
+
/* @__PURE__ */ Q(v, {
|
|
387
653
|
variant: "ghost",
|
|
388
654
|
size: "icon",
|
|
389
655
|
className: "h-7 w-7",
|
|
390
656
|
onClick: u,
|
|
391
657
|
"aria-label": "Close chat",
|
|
392
658
|
"data-testid": "floating-chatbot-close",
|
|
393
|
-
children: /* @__PURE__ */
|
|
659
|
+
children: /* @__PURE__ */ Q(gt, { className: "h-4 w-4" })
|
|
394
660
|
})
|
|
395
661
|
]
|
|
396
662
|
})
|
|
397
663
|
]
|
|
398
|
-
}), /* @__PURE__ */
|
|
399
|
-
className: "flex-1 overflow-hidden",
|
|
664
|
+
}), /* @__PURE__ */ Q("div", {
|
|
665
|
+
className: "min-h-0 flex-1 overflow-hidden",
|
|
400
666
|
children: i
|
|
401
667
|
})]
|
|
402
|
-
});
|
|
668
|
+
}) : null;
|
|
403
669
|
}
|
|
404
670
|
//#endregion
|
|
405
671
|
//#region src/tool-display.ts
|
|
406
|
-
var
|
|
672
|
+
var Dn = {
|
|
407
673
|
ai: "AI",
|
|
408
674
|
api: "API",
|
|
409
675
|
crm: "CRM",
|
|
@@ -415,17 +681,17 @@ var qt = {
|
|
|
415
681
|
url: "URL",
|
|
416
682
|
utc: "UTC"
|
|
417
683
|
};
|
|
418
|
-
function
|
|
684
|
+
function On(e) {
|
|
419
685
|
if (!e) return "";
|
|
420
686
|
let t = String(e).trim();
|
|
421
687
|
if (!t) return "";
|
|
422
688
|
let n = t.replace(/[_-]+/g, " ").replace(/([a-z])([A-Z])/g, "$1 $2").split(/\s+/).filter(Boolean);
|
|
423
689
|
return n.length === 0 ? t : n.map((e, t) => {
|
|
424
690
|
let n = e.toLowerCase();
|
|
425
|
-
return
|
|
691
|
+
return Dn[n] ? Dn[n] : t === 0 ? n.charAt(0).toUpperCase() + n.slice(1) : n;
|
|
426
692
|
}).join(" ");
|
|
427
693
|
}
|
|
428
|
-
function
|
|
694
|
+
function kn(e) {
|
|
429
695
|
if (e == null) return e;
|
|
430
696
|
let t = e;
|
|
431
697
|
for (let e = 0; e < 2; e++) {
|
|
@@ -443,110 +709,134 @@ function Yt(e) {
|
|
|
443
709
|
}
|
|
444
710
|
return t;
|
|
445
711
|
}
|
|
446
|
-
function
|
|
712
|
+
function An(e) {
|
|
447
713
|
let t = (e instanceof Error ? e.message : String(e ?? "")).replace(/\s+/g, " ").trim();
|
|
448
714
|
if (!t) return { summary: "Something went wrong. Please try again." };
|
|
449
|
-
let n = t.replace(/^Failed after \d+ attempts?\.\s*Last error:\s*/i, ""), r = n.match(/^([
|
|
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);
|
|
450
716
|
return {
|
|
451
|
-
summary:
|
|
452
|
-
details: n.length >
|
|
717
|
+
summary: i.replace(/:$/, ""),
|
|
718
|
+
details: n.length > i.length ? n : void 0
|
|
719
|
+
};
|
|
720
|
+
}
|
|
721
|
+
var jn = new Set([
|
|
722
|
+
"ai_design_quota_exhausted",
|
|
723
|
+
"ai_data_chat_trial_exhausted",
|
|
724
|
+
"ai_allowance_exhausted"
|
|
725
|
+
]);
|
|
726
|
+
function Mn(e) {
|
|
727
|
+
let t = e instanceof Error ? e.message : String(e ?? "");
|
|
728
|
+
if (!t) return null;
|
|
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("}");
|
|
730
|
+
if (r < 0 || i <= r) return null;
|
|
731
|
+
let a;
|
|
732
|
+
try {
|
|
733
|
+
a = JSON.parse(n.slice(r, i + 1));
|
|
734
|
+
} catch {
|
|
735
|
+
return null;
|
|
736
|
+
}
|
|
737
|
+
return !a || typeof a.error != "string" || !jn.has(a.error) ? null : {
|
|
738
|
+
code: a.error,
|
|
739
|
+
message: typeof a.message == "string" ? a.message : "",
|
|
740
|
+
messageEn: typeof a.messageEn == "string" ? a.messageEn : void 0,
|
|
741
|
+
upgrade: a.upgrade === !0,
|
|
742
|
+
topUp: a.topUp === !0
|
|
453
743
|
};
|
|
454
744
|
}
|
|
455
745
|
//#endregion
|
|
456
746
|
//#region src/elements/conversation.tsx
|
|
457
|
-
var
|
|
458
|
-
className:
|
|
747
|
+
var Nn = ({ className: e, ...t }) => /* @__PURE__ */ Q(wt, {
|
|
748
|
+
className: J("relative flex-1 overflow-y-hidden", e),
|
|
459
749
|
initial: "smooth",
|
|
460
750
|
resize: "smooth",
|
|
461
751
|
role: "log",
|
|
462
752
|
...t
|
|
463
|
-
}),
|
|
464
|
-
className:
|
|
753
|
+
}), Pn = ({ className: e, ...t }) => /* @__PURE__ */ Q(wt.Content, {
|
|
754
|
+
className: J("flex flex-col gap-8 p-4", e),
|
|
465
755
|
...t
|
|
466
|
-
}),
|
|
467
|
-
className:
|
|
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
|
+
className: J("flex size-full flex-col items-center justify-center gap-3 p-8 text-center", e),
|
|
468
758
|
...a,
|
|
469
|
-
children: i ?? /* @__PURE__ */
|
|
759
|
+
children: i ?? /* @__PURE__ */ $(Z, { children: [r && /* @__PURE__ */ Q("div", {
|
|
470
760
|
className: "text-muted-foreground",
|
|
471
761
|
children: r
|
|
472
|
-
}), /* @__PURE__ */
|
|
762
|
+
}), /* @__PURE__ */ $("div", {
|
|
473
763
|
className: "space-y-1",
|
|
474
|
-
children: [/* @__PURE__ */
|
|
764
|
+
children: [/* @__PURE__ */ Q("h3", {
|
|
475
765
|
className: "font-medium text-sm",
|
|
476
766
|
children: t
|
|
477
|
-
}), n && /* @__PURE__ */
|
|
767
|
+
}), n && /* @__PURE__ */ Q("p", {
|
|
478
768
|
className: "text-muted-foreground text-sm",
|
|
479
769
|
children: n
|
|
480
770
|
})]
|
|
481
771
|
})] })
|
|
482
|
-
}),
|
|
483
|
-
let { isAtBottom: n, scrollToBottom: r } =
|
|
772
|
+
}), In = ({ className: e, ...t }) => {
|
|
773
|
+
let { isAtBottom: n, scrollToBottom: r } = Tt(), i = o(() => {
|
|
484
774
|
r();
|
|
485
775
|
}, [r]);
|
|
486
|
-
return !n && /* @__PURE__ */
|
|
487
|
-
className:
|
|
776
|
+
return !n && /* @__PURE__ */ Q(v, {
|
|
777
|
+
className: J("absolute bottom-4 left-[50%] translate-x-[-50%] rounded-full", e),
|
|
488
778
|
onClick: i,
|
|
489
779
|
size: "icon",
|
|
490
780
|
type: "button",
|
|
491
781
|
variant: "outline",
|
|
492
782
|
...t,
|
|
493
|
-
children: /* @__PURE__ */
|
|
783
|
+
children: /* @__PURE__ */ Q(ke, { className: "size-4" })
|
|
494
784
|
});
|
|
495
|
-
},
|
|
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", {
|
|
496
786
|
variants: { orientation: {
|
|
497
787
|
horizontal: "[&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0 [&>*:not(:last-child)]:rounded-r-none",
|
|
498
788
|
vertical: "flex-col [&>*:not(:first-child)]:rounded-t-none [&>*:not(:first-child)]:border-t-0 [&>*:not(:last-child)]:rounded-b-none"
|
|
499
789
|
} },
|
|
500
790
|
defaultVariants: { orientation: "horizontal" }
|
|
501
791
|
});
|
|
502
|
-
function
|
|
503
|
-
return /* @__PURE__ */
|
|
792
|
+
function Rn({ className: e, orientation: t, ...n }) {
|
|
793
|
+
return /* @__PURE__ */ Q("div", {
|
|
504
794
|
role: "group",
|
|
505
795
|
"data-slot": "button-group",
|
|
506
796
|
"data-orientation": t,
|
|
507
|
-
className:
|
|
797
|
+
className: J(Ln({ orientation: t }), e),
|
|
508
798
|
...n
|
|
509
799
|
});
|
|
510
800
|
}
|
|
511
|
-
function
|
|
512
|
-
return /* @__PURE__ */
|
|
513
|
-
className:
|
|
801
|
+
function zn({ className: e, asChild: t = !1, ...n }) {
|
|
802
|
+
return /* @__PURE__ */ Q(t ? Dt : "div", {
|
|
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),
|
|
514
804
|
...n
|
|
515
805
|
});
|
|
516
806
|
}
|
|
517
807
|
//#endregion
|
|
518
808
|
//#region src/elements/message.tsx
|
|
519
|
-
var
|
|
520
|
-
className:
|
|
809
|
+
var Bn = ({ className: e, from: t, ...n }) => /* @__PURE__ */ Q("div", {
|
|
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),
|
|
521
811
|
...n
|
|
522
|
-
}),
|
|
523
|
-
className:
|
|
812
|
+
}), Vn = ({ children: e, className: t, ...n }) => /* @__PURE__ */ Q("div", {
|
|
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),
|
|
524
814
|
...n,
|
|
525
815
|
children: e
|
|
526
|
-
}),
|
|
527
|
-
className:
|
|
816
|
+
}), Hn = ({ className: e, children: t, ...n }) => /* @__PURE__ */ Q("div", {
|
|
817
|
+
className: J("flex items-center gap-1", e),
|
|
528
818
|
...n,
|
|
529
819
|
children: t
|
|
530
|
-
}),
|
|
531
|
-
let o = /* @__PURE__ */
|
|
820
|
+
}), Un = ({ tooltip: e, children: t, label: n, variant: r = "ghost", size: i = "icon", ...a }) => {
|
|
821
|
+
let o = /* @__PURE__ */ $(v, {
|
|
532
822
|
size: i,
|
|
533
823
|
type: "button",
|
|
534
824
|
variant: r,
|
|
535
825
|
...a,
|
|
536
|
-
children: [t, /* @__PURE__ */
|
|
826
|
+
children: [t, /* @__PURE__ */ Q("span", {
|
|
537
827
|
className: "sr-only",
|
|
538
828
|
children: n || e
|
|
539
829
|
})]
|
|
540
830
|
});
|
|
541
|
-
return e ? /* @__PURE__ */
|
|
831
|
+
return e ? /* @__PURE__ */ Q(Ee, { children: /* @__PURE__ */ $(we, { children: [/* @__PURE__ */ Q(De, {
|
|
542
832
|
asChild: !0,
|
|
543
833
|
children: o
|
|
544
|
-
}), /* @__PURE__ */
|
|
545
|
-
},
|
|
546
|
-
let e = s(
|
|
834
|
+
}), /* @__PURE__ */ Q(Te, { children: /* @__PURE__ */ Q("p", { children: e }) })] }) }) : o;
|
|
835
|
+
}, Wn = r(null), Gn = () => {
|
|
836
|
+
let e = s(Wn);
|
|
547
837
|
if (!e) throw Error("MessageBranch components must be used within MessageBranch");
|
|
548
838
|
return e;
|
|
549
|
-
},
|
|
839
|
+
}, Kn = ({ defaultBranch: e = 0, onBranchChange: t, className: n, ...r }) => {
|
|
550
840
|
let [i, a] = d(e), [o, s] = d([]), c = (e) => {
|
|
551
841
|
a(e), t?.(e);
|
|
552
842
|
}, l = {
|
|
@@ -561,36 +851,36 @@ var an = ({ className: e, from: t, ...n }) => /* @__PURE__ */ K("div", {
|
|
|
561
851
|
branches: o,
|
|
562
852
|
setBranches: s
|
|
563
853
|
};
|
|
564
|
-
return /* @__PURE__ */
|
|
854
|
+
return /* @__PURE__ */ Q(Wn.Provider, {
|
|
565
855
|
value: l,
|
|
566
|
-
children: /* @__PURE__ */
|
|
567
|
-
className:
|
|
856
|
+
children: /* @__PURE__ */ Q("div", {
|
|
857
|
+
className: J("grid w-full gap-2 [&>div]:pb-0", n),
|
|
568
858
|
...r
|
|
569
859
|
})
|
|
570
860
|
});
|
|
571
|
-
},
|
|
572
|
-
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];
|
|
573
863
|
return c(() => {
|
|
574
864
|
i.length !== a.length && r(a);
|
|
575
865
|
}, [
|
|
576
866
|
a,
|
|
577
867
|
i,
|
|
578
868
|
r
|
|
579
|
-
]), a.map((e, r) => /* @__PURE__ */
|
|
580
|
-
className:
|
|
869
|
+
]), a.map((e, r) => /* @__PURE__ */ Q("div", {
|
|
870
|
+
className: J("grid gap-2 overflow-hidden [&>div]:pb-0", r === n ? "block" : "hidden"),
|
|
581
871
|
...t,
|
|
582
872
|
children: e
|
|
583
873
|
}, e.key));
|
|
584
|
-
},
|
|
585
|
-
let { totalBranches: r } =
|
|
586
|
-
return r <= 1 ? null : /* @__PURE__ */
|
|
874
|
+
}, Jn = ({ className: e, from: t, ...n }) => {
|
|
875
|
+
let { totalBranches: r } = Gn();
|
|
876
|
+
return r <= 1 ? null : /* @__PURE__ */ Q(Rn, {
|
|
587
877
|
className: "[&>*:not(:first-child)]:rounded-l-md [&>*:not(:last-child)]:rounded-r-md",
|
|
588
878
|
orientation: "horizontal",
|
|
589
879
|
...n
|
|
590
880
|
});
|
|
591
|
-
},
|
|
592
|
-
let { goToPrevious: n, totalBranches: r } =
|
|
593
|
-
return /* @__PURE__ */
|
|
881
|
+
}, Yn = ({ children: e, ...t }) => {
|
|
882
|
+
let { goToPrevious: n, totalBranches: r } = Gn();
|
|
883
|
+
return /* @__PURE__ */ Q(v, {
|
|
594
884
|
"aria-label": "Previous branch",
|
|
595
885
|
disabled: r <= 1,
|
|
596
886
|
onClick: n,
|
|
@@ -598,11 +888,11 @@ var an = ({ className: e, from: t, ...n }) => /* @__PURE__ */ K("div", {
|
|
|
598
888
|
type: "button",
|
|
599
889
|
variant: "ghost",
|
|
600
890
|
...t,
|
|
601
|
-
children: e ?? /* @__PURE__ */
|
|
891
|
+
children: e ?? /* @__PURE__ */ Q(Re, { size: 14 })
|
|
602
892
|
});
|
|
603
|
-
},
|
|
604
|
-
let { goToNext: r, totalBranches: i } =
|
|
605
|
-
return /* @__PURE__ */
|
|
893
|
+
}, Xn = ({ children: e, className: t, ...n }) => {
|
|
894
|
+
let { goToNext: r, totalBranches: i } = Gn();
|
|
895
|
+
return /* @__PURE__ */ Q(v, {
|
|
606
896
|
"aria-label": "Next branch",
|
|
607
897
|
disabled: i <= 1,
|
|
608
898
|
onClick: r,
|
|
@@ -610,12 +900,12 @@ var an = ({ className: e, from: t, ...n }) => /* @__PURE__ */ K("div", {
|
|
|
610
900
|
type: "button",
|
|
611
901
|
variant: "ghost",
|
|
612
902
|
...n,
|
|
613
|
-
children: e ?? /* @__PURE__ */
|
|
903
|
+
children: e ?? /* @__PURE__ */ Q(ze, { size: 14 })
|
|
614
904
|
});
|
|
615
|
-
},
|
|
616
|
-
let { currentBranch: n, totalBranches: r } =
|
|
617
|
-
return /* @__PURE__ */
|
|
618
|
-
className:
|
|
905
|
+
}, Zn = ({ className: e, ...t }) => {
|
|
906
|
+
let { currentBranch: n, totalBranches: r } = Gn();
|
|
907
|
+
return /* @__PURE__ */ $(zn, {
|
|
908
|
+
className: J("border-none bg-transparent text-muted-foreground shadow-none", e),
|
|
619
909
|
...t,
|
|
620
910
|
children: [
|
|
621
911
|
n + 1,
|
|
@@ -623,23 +913,23 @@ var an = ({ className: e, from: t, ...n }) => /* @__PURE__ */ K("div", {
|
|
|
623
913
|
r
|
|
624
914
|
]
|
|
625
915
|
});
|
|
626
|
-
},
|
|
627
|
-
className:
|
|
916
|
+
}, Qn = a(({ className: e, ...t }) => /* @__PURE__ */ Q(Ot, {
|
|
917
|
+
className: J("size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0", e),
|
|
628
918
|
...t
|
|
629
919
|
}), (e, t) => e.children === t.children);
|
|
630
|
-
|
|
631
|
-
function
|
|
920
|
+
Qn.displayName = "MessageResponse";
|
|
921
|
+
function $n({ data: e, className: t, onRemove: n, ...r }) {
|
|
632
922
|
let i = e.filename || "", a = (e.mediaType?.startsWith("image/") && e.url ? "image" : "file") == "image", o = i || (a ? "Image" : "Attachment");
|
|
633
|
-
return /* @__PURE__ */
|
|
634
|
-
className:
|
|
923
|
+
return /* @__PURE__ */ Q("div", {
|
|
924
|
+
className: J("group relative size-24 overflow-hidden rounded-lg", t),
|
|
635
925
|
...r,
|
|
636
|
-
children: a ? /* @__PURE__ */
|
|
926
|
+
children: a ? /* @__PURE__ */ $(Z, { children: [/* @__PURE__ */ Q("img", {
|
|
637
927
|
alt: i || "attachment",
|
|
638
928
|
className: "size-full object-cover",
|
|
639
929
|
height: 100,
|
|
640
930
|
src: e.url,
|
|
641
931
|
width: 100
|
|
642
|
-
}), n && /* @__PURE__ */
|
|
932
|
+
}), n && /* @__PURE__ */ $(v, {
|
|
643
933
|
"aria-label": "Remove attachment",
|
|
644
934
|
className: "absolute top-2 right-2 size-6 rounded-full bg-background/80 p-0 opacity-0 backdrop-blur-sm transition-opacity hover:bg-background group-hover:opacity-100 [&>svg]:size-3",
|
|
645
935
|
onClick: (e) => {
|
|
@@ -647,17 +937,17 @@ function gn({ data: e, className: t, onRemove: n, ...r }) {
|
|
|
647
937
|
},
|
|
648
938
|
type: "button",
|
|
649
939
|
variant: "ghost",
|
|
650
|
-
children: [/* @__PURE__ */
|
|
940
|
+
children: [/* @__PURE__ */ Q(vt, {}), /* @__PURE__ */ Q("span", {
|
|
651
941
|
className: "sr-only",
|
|
652
942
|
children: "Remove"
|
|
653
943
|
})]
|
|
654
|
-
})] }) : /* @__PURE__ */
|
|
944
|
+
})] }) : /* @__PURE__ */ $(Z, { children: [/* @__PURE__ */ $(we, { children: [/* @__PURE__ */ Q(De, {
|
|
655
945
|
asChild: !0,
|
|
656
|
-
children: /* @__PURE__ */
|
|
946
|
+
children: /* @__PURE__ */ Q("div", {
|
|
657
947
|
className: "flex size-full shrink-0 items-center justify-center rounded-lg bg-muted text-muted-foreground",
|
|
658
|
-
children: /* @__PURE__ */
|
|
948
|
+
children: /* @__PURE__ */ Q(at, { className: "size-4" })
|
|
659
949
|
})
|
|
660
|
-
}), /* @__PURE__ */
|
|
950
|
+
}), /* @__PURE__ */ Q(Te, { children: /* @__PURE__ */ Q("p", { children: o }) })] }), n && /* @__PURE__ */ $(v, {
|
|
661
951
|
"aria-label": "Remove attachment",
|
|
662
952
|
className: "size-6 shrink-0 rounded-full p-0 opacity-0 transition-opacity hover:bg-accent group-hover:opacity-100 [&>svg]:size-3",
|
|
663
953
|
onClick: (e) => {
|
|
@@ -665,36 +955,36 @@ function gn({ data: e, className: t, onRemove: n, ...r }) {
|
|
|
665
955
|
},
|
|
666
956
|
type: "button",
|
|
667
957
|
variant: "ghost",
|
|
668
|
-
children: [/* @__PURE__ */
|
|
958
|
+
children: [/* @__PURE__ */ Q(vt, {}), /* @__PURE__ */ Q("span", {
|
|
669
959
|
className: "sr-only",
|
|
670
960
|
children: "Remove"
|
|
671
961
|
})]
|
|
672
962
|
})] })
|
|
673
963
|
});
|
|
674
964
|
}
|
|
675
|
-
function
|
|
676
|
-
return e ? /* @__PURE__ */
|
|
677
|
-
className:
|
|
965
|
+
function er({ children: e, className: t, ...n }) {
|
|
966
|
+
return e ? /* @__PURE__ */ Q("div", {
|
|
967
|
+
className: J("ml-auto flex w-fit flex-wrap items-start gap-2", t),
|
|
678
968
|
...n,
|
|
679
969
|
children: e
|
|
680
970
|
}) : null;
|
|
681
971
|
}
|
|
682
|
-
var
|
|
683
|
-
className:
|
|
972
|
+
var tr = ({ className: e, children: t, ...n }) => /* @__PURE__ */ Q("div", {
|
|
973
|
+
className: J("mt-4 flex w-full items-center justify-between gap-4", e),
|
|
684
974
|
...n,
|
|
685
975
|
children: t
|
|
686
976
|
});
|
|
687
977
|
//#endregion
|
|
688
978
|
//#region src/elements/ui/input-group.tsx
|
|
689
|
-
function
|
|
690
|
-
return /* @__PURE__ */
|
|
979
|
+
function nr({ className: e, ...t }) {
|
|
980
|
+
return /* @__PURE__ */ Q("div", {
|
|
691
981
|
"data-slot": "input-group",
|
|
692
982
|
role: "group",
|
|
693
|
-
className:
|
|
983
|
+
className: J("group/input-group relative flex w-full items-center rounded-md border border-input shadow-xs transition-[color,box-shadow] outline-none dark:bg-input/30", "h-9 min-w-0 has-[>textarea]:h-auto", "has-[>[data-align=inline-start]]:[&>input]:pl-2", "has-[>[data-align=inline-end]]:[&>input]:pr-2", "has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>[data-align=block-start]]:[&>input]:pb-3", "has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-end]]:[&>input]:pt-3", "has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-[3px] has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50", "has-[[data-slot][aria-invalid=true]]:border-destructive has-[[data-slot][aria-invalid=true]]:ring-destructive/20 dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40", e),
|
|
694
984
|
...t
|
|
695
985
|
});
|
|
696
986
|
}
|
|
697
|
-
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", {
|
|
698
988
|
variants: { align: {
|
|
699
989
|
"inline-start": "order-first pl-3 has-[>button]:ml-[-0.45rem] has-[>kbd]:ml-[-0.35rem]",
|
|
700
990
|
"inline-end": "order-last pr-3 has-[>button]:mr-[-0.45rem] has-[>kbd]:mr-[-0.35rem]",
|
|
@@ -703,19 +993,19 @@ var bn = bt("flex h-auto cursor-text items-center justify-center gap-2 py-1.5 te
|
|
|
703
993
|
} },
|
|
704
994
|
defaultVariants: { align: "inline-start" }
|
|
705
995
|
});
|
|
706
|
-
function
|
|
707
|
-
return /* @__PURE__ */
|
|
996
|
+
function ir({ className: e, align: t = "inline-start", ...n }) {
|
|
997
|
+
return /* @__PURE__ */ Q("div", {
|
|
708
998
|
role: "group",
|
|
709
999
|
"data-slot": "input-group-addon",
|
|
710
1000
|
"data-align": t,
|
|
711
|
-
className:
|
|
1001
|
+
className: J(rr({ align: t }), e),
|
|
712
1002
|
onClick: (e) => {
|
|
713
1003
|
e.target.closest("button") || e.currentTarget.parentElement?.querySelector("input")?.focus();
|
|
714
1004
|
},
|
|
715
1005
|
...n
|
|
716
1006
|
});
|
|
717
1007
|
}
|
|
718
|
-
var
|
|
1008
|
+
var ar = Et("flex items-center gap-2 text-sm shadow-none", {
|
|
719
1009
|
variants: { size: {
|
|
720
1010
|
xs: "h-6 gap-1 rounded-[calc(var(--radius)-5px)] px-2 has-[>svg]:px-2 [&>svg:not([class*='size-'])]:size-3.5",
|
|
721
1011
|
sm: "h-8 gap-1.5 rounded-md px-2.5 has-[>svg]:px-2.5",
|
|
@@ -724,38 +1014,38 @@ var Sn = bt("flex items-center gap-2 text-sm shadow-none", {
|
|
|
724
1014
|
} },
|
|
725
1015
|
defaultVariants: { size: "xs" }
|
|
726
1016
|
});
|
|
727
|
-
function
|
|
728
|
-
return /* @__PURE__ */
|
|
1017
|
+
function or({ className: e, type: t = "button", variant: n = "ghost", size: r = "xs", ...i }) {
|
|
1018
|
+
return /* @__PURE__ */ Q(v, {
|
|
729
1019
|
type: t,
|
|
730
1020
|
"data-size": r,
|
|
731
1021
|
variant: n,
|
|
732
|
-
className:
|
|
1022
|
+
className: J(ar({ size: r }), e),
|
|
733
1023
|
...i
|
|
734
1024
|
});
|
|
735
1025
|
}
|
|
736
|
-
function
|
|
737
|
-
return /* @__PURE__ */
|
|
1026
|
+
function sr({ className: e, ...t }) {
|
|
1027
|
+
return /* @__PURE__ */ Q(q, {
|
|
738
1028
|
"data-slot": "input-group-control",
|
|
739
|
-
className:
|
|
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),
|
|
740
1030
|
...t
|
|
741
1031
|
});
|
|
742
1032
|
}
|
|
743
1033
|
//#endregion
|
|
744
1034
|
//#region src/elements/prompt-input.tsx
|
|
745
|
-
var
|
|
746
|
-
let e = s(
|
|
1035
|
+
var cr = r(null), lr = r(null), ur = () => {
|
|
1036
|
+
let e = s(cr);
|
|
747
1037
|
if (!e) throw Error("Wrap your component inside <PromptInputProvider> to use usePromptInputController().");
|
|
748
1038
|
return e;
|
|
749
|
-
},
|
|
750
|
-
let e = s(
|
|
1039
|
+
}, dr = () => s(cr), fr = () => {
|
|
1040
|
+
let e = s(lr);
|
|
751
1041
|
if (!e) throw Error("Wrap your component inside <PromptInputProvider> to use useProviderAttachments().");
|
|
752
1042
|
return e;
|
|
753
|
-
},
|
|
754
|
-
function
|
|
1043
|
+
}, pr = () => s(lr);
|
|
1044
|
+
function mr({ initialInput: e = "", children: t }) {
|
|
755
1045
|
let [n, r] = d(e), i = o(() => r(""), []), [a, s] = d([]), f = u(null), p = u(() => {}), m = o((e) => {
|
|
756
1046
|
let t = Array.from(e);
|
|
757
1047
|
t.length !== 0 && s((e) => e.concat(t.map((e) => ({
|
|
758
|
-
id:
|
|
1048
|
+
id: kt(),
|
|
759
1049
|
type: "file",
|
|
760
1050
|
url: URL.createObjectURL(e),
|
|
761
1051
|
mediaType: e.type,
|
|
@@ -806,41 +1096,41 @@ function jn({ initialInput: e = "", children: t }) {
|
|
|
806
1096
|
y,
|
|
807
1097
|
b
|
|
808
1098
|
]);
|
|
809
|
-
return /* @__PURE__ */
|
|
1099
|
+
return /* @__PURE__ */ Q(cr.Provider, {
|
|
810
1100
|
value: x,
|
|
811
|
-
children: /* @__PURE__ */
|
|
1101
|
+
children: /* @__PURE__ */ Q(lr.Provider, {
|
|
812
1102
|
value: y,
|
|
813
1103
|
children: t
|
|
814
1104
|
})
|
|
815
1105
|
});
|
|
816
1106
|
}
|
|
817
|
-
var
|
|
818
|
-
let e =
|
|
1107
|
+
var hr = r(null), gr = () => {
|
|
1108
|
+
let e = pr(), t = s(hr), n = e ?? t;
|
|
819
1109
|
if (!n) throw Error("usePromptInputAttachments must be used within a PromptInput or PromptInputProvider");
|
|
820
1110
|
return n;
|
|
821
1111
|
};
|
|
822
|
-
function
|
|
823
|
-
let r =
|
|
824
|
-
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, {
|
|
825
1115
|
asChild: !0,
|
|
826
|
-
children: /* @__PURE__ */
|
|
827
|
-
className:
|
|
1116
|
+
children: /* @__PURE__ */ $("div", {
|
|
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),
|
|
828
1118
|
...n,
|
|
829
|
-
children: [/* @__PURE__ */
|
|
1119
|
+
children: [/* @__PURE__ */ $("div", {
|
|
830
1120
|
className: "relative size-5 shrink-0",
|
|
831
|
-
children: [/* @__PURE__ */
|
|
1121
|
+
children: [/* @__PURE__ */ Q("div", {
|
|
832
1122
|
className: "absolute inset-0 flex size-5 items-center justify-center overflow-hidden rounded bg-background transition-opacity group-hover:opacity-0",
|
|
833
|
-
children: a ? /* @__PURE__ */
|
|
1123
|
+
children: a ? /* @__PURE__ */ Q("img", {
|
|
834
1124
|
alt: i || "attachment",
|
|
835
1125
|
className: "size-5 object-cover",
|
|
836
1126
|
height: 20,
|
|
837
1127
|
src: e.url,
|
|
838
1128
|
width: 20
|
|
839
|
-
}) : /* @__PURE__ */
|
|
1129
|
+
}) : /* @__PURE__ */ Q("div", {
|
|
840
1130
|
className: "flex size-5 items-center justify-center text-muted-foreground",
|
|
841
|
-
children: /* @__PURE__ */
|
|
1131
|
+
children: /* @__PURE__ */ Q(at, { className: "size-3" })
|
|
842
1132
|
})
|
|
843
|
-
}), /* @__PURE__ */
|
|
1133
|
+
}), /* @__PURE__ */ $(v, {
|
|
844
1134
|
"aria-label": "Remove attachment",
|
|
845
1135
|
className: "absolute inset-0 size-5 cursor-pointer rounded p-0 opacity-0 transition-opacity group-hover:pointer-events-auto group-hover:opacity-100 [&>svg]:size-2.5",
|
|
846
1136
|
onClick: (t) => {
|
|
@@ -848,37 +1138,37 @@ function Nn({ data: e, className: t, ...n }) {
|
|
|
848
1138
|
},
|
|
849
1139
|
type: "button",
|
|
850
1140
|
variant: "ghost",
|
|
851
|
-
children: [/* @__PURE__ */
|
|
1141
|
+
children: [/* @__PURE__ */ Q(vt, {}), /* @__PURE__ */ Q("span", {
|
|
852
1142
|
className: "sr-only",
|
|
853
1143
|
children: "Remove"
|
|
854
1144
|
})]
|
|
855
1145
|
})]
|
|
856
|
-
}), /* @__PURE__ */
|
|
1146
|
+
}), /* @__PURE__ */ Q("span", {
|
|
857
1147
|
className: "flex-1 truncate",
|
|
858
1148
|
children: o
|
|
859
1149
|
})]
|
|
860
1150
|
}, e.id)
|
|
861
|
-
}), /* @__PURE__ */
|
|
1151
|
+
}), /* @__PURE__ */ Q(Br, {
|
|
862
1152
|
className: "w-auto p-2",
|
|
863
|
-
children: /* @__PURE__ */
|
|
1153
|
+
children: /* @__PURE__ */ $("div", {
|
|
864
1154
|
className: "w-auto space-y-3",
|
|
865
|
-
children: [a && /* @__PURE__ */
|
|
1155
|
+
children: [a && /* @__PURE__ */ Q("div", {
|
|
866
1156
|
className: "flex max-h-96 w-96 items-center justify-center overflow-hidden rounded-md border",
|
|
867
|
-
children: /* @__PURE__ */
|
|
1157
|
+
children: /* @__PURE__ */ Q("img", {
|
|
868
1158
|
alt: i || "attachment preview",
|
|
869
1159
|
className: "max-h-full max-w-full object-contain",
|
|
870
1160
|
height: 384,
|
|
871
1161
|
src: e.url,
|
|
872
1162
|
width: 448
|
|
873
1163
|
})
|
|
874
|
-
}), /* @__PURE__ */
|
|
1164
|
+
}), /* @__PURE__ */ Q("div", {
|
|
875
1165
|
className: "flex items-center gap-2.5",
|
|
876
|
-
children: /* @__PURE__ */
|
|
1166
|
+
children: /* @__PURE__ */ $("div", {
|
|
877
1167
|
className: "min-w-0 flex-1 space-y-1 px-0.5",
|
|
878
|
-
children: [/* @__PURE__ */
|
|
1168
|
+
children: [/* @__PURE__ */ Q("h4", {
|
|
879
1169
|
className: "truncate font-semibold text-sm leading-none",
|
|
880
1170
|
children: i || (a ? "Image" : "Attachment")
|
|
881
|
-
}), e.mediaType && /* @__PURE__ */
|
|
1171
|
+
}), e.mediaType && /* @__PURE__ */ Q("p", {
|
|
882
1172
|
className: "truncate font-mono text-muted-foreground text-xs",
|
|
883
1173
|
children: e.mediaType
|
|
884
1174
|
})]
|
|
@@ -887,64 +1177,64 @@ function Nn({ data: e, className: t, ...n }) {
|
|
|
887
1177
|
})
|
|
888
1178
|
})] });
|
|
889
1179
|
}
|
|
890
|
-
function
|
|
891
|
-
let i =
|
|
892
|
-
return i.files.length ? /* @__PURE__ */
|
|
893
|
-
className:
|
|
1180
|
+
function vr({ children: e, className: t, ...r }) {
|
|
1181
|
+
let i = gr();
|
|
1182
|
+
return i.files.length ? /* @__PURE__ */ Q("div", {
|
|
1183
|
+
className: J("flex flex-wrap items-center gap-2 p-3 w-full", t),
|
|
894
1184
|
...r,
|
|
895
|
-
children: i.files.map((t) => /* @__PURE__ */
|
|
1185
|
+
children: i.files.map((t) => /* @__PURE__ */ Q(n, { children: e(t) }, t.id))
|
|
896
1186
|
}) : null;
|
|
897
1187
|
}
|
|
898
|
-
var
|
|
899
|
-
let n =
|
|
900
|
-
return /* @__PURE__ */
|
|
1188
|
+
var yr = ({ label: e = "Add photos or files", ...t }) => {
|
|
1189
|
+
let n = gr();
|
|
1190
|
+
return /* @__PURE__ */ $(P, {
|
|
901
1191
|
...t,
|
|
902
1192
|
onSelect: (e) => {
|
|
903
1193
|
e.preventDefault(), n.openFileDialog();
|
|
904
1194
|
},
|
|
905
1195
|
children: [
|
|
906
|
-
/* @__PURE__ */
|
|
1196
|
+
/* @__PURE__ */ Q(Qe, { className: "mr-2 size-4" }),
|
|
907
1197
|
" ",
|
|
908
1198
|
e
|
|
909
1199
|
]
|
|
910
1200
|
});
|
|
911
|
-
},
|
|
912
|
-
let
|
|
913
|
-
|
|
914
|
-
let
|
|
915
|
-
|
|
916
|
-
}, []),
|
|
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
|
+
w.current = C;
|
|
1204
|
+
let T = o(() => {
|
|
1205
|
+
y.current?.click();
|
|
1206
|
+
}, []), E = o((e) => !t || t.trim() === "" ? !0 : t.split(",").map((e) => e.trim()).filter(Boolean).some((t) => {
|
|
917
1207
|
if (t.endsWith("/*")) {
|
|
918
1208
|
let n = t.slice(0, -1);
|
|
919
1209
|
return e.type.startsWith(n);
|
|
920
1210
|
}
|
|
921
1211
|
return e.type === t;
|
|
922
|
-
}), [t]),
|
|
923
|
-
let t = Array.from(e), n = t.filter((e) =>
|
|
1212
|
+
}), [t]), D = o((e) => {
|
|
1213
|
+
let t = Array.from(e), n = t.filter((e) => E(e));
|
|
924
1214
|
if (t.length && n.length === 0) {
|
|
925
|
-
|
|
1215
|
+
p?.({
|
|
926
1216
|
code: "accept",
|
|
927
1217
|
message: "No files match the accepted types."
|
|
928
1218
|
});
|
|
929
1219
|
return;
|
|
930
1220
|
}
|
|
931
|
-
let r = n.filter((e) =>
|
|
1221
|
+
let r = n.filter((e) => f ? e.size <= f : !0);
|
|
932
1222
|
if (n.length > 0 && r.length === 0) {
|
|
933
|
-
|
|
1223
|
+
p?.({
|
|
934
1224
|
code: "max_file_size",
|
|
935
1225
|
message: "All files exceed the maximum size."
|
|
936
1226
|
});
|
|
937
1227
|
return;
|
|
938
1228
|
}
|
|
939
|
-
|
|
940
|
-
let t = typeof
|
|
941
|
-
typeof t == "number" && r.length > t &&
|
|
1229
|
+
S((e) => {
|
|
1230
|
+
let t = typeof s == "number" ? Math.max(0, s - e.length) : void 0, n = typeof t == "number" ? r.slice(0, t) : r;
|
|
1231
|
+
typeof t == "number" && r.length > t && p?.({
|
|
942
1232
|
code: "max_files",
|
|
943
1233
|
message: "Too many files. Some were not added."
|
|
944
1234
|
});
|
|
945
1235
|
let i = [];
|
|
946
1236
|
for (let e of n) i.push({
|
|
947
|
-
id:
|
|
1237
|
+
id: kt(),
|
|
948
1238
|
type: "file",
|
|
949
1239
|
url: URL.createObjectURL(e),
|
|
950
1240
|
mediaType: e.type,
|
|
@@ -953,48 +1243,48 @@ var Fn = ({ label: e = "Add photos or files", ...t }) => {
|
|
|
953
1243
|
return e.concat(i);
|
|
954
1244
|
});
|
|
955
1245
|
}, [
|
|
956
|
-
|
|
957
|
-
a,
|
|
1246
|
+
E,
|
|
958
1247
|
s,
|
|
959
|
-
f
|
|
960
|
-
|
|
1248
|
+
f,
|
|
1249
|
+
p
|
|
1250
|
+
]), O = o((e) => S((t) => {
|
|
961
1251
|
let n = t.find((t) => t.id === e);
|
|
962
1252
|
return n?.url && URL.revokeObjectURL(n.url), t.filter((t) => t.id !== e);
|
|
963
|
-
}), []),
|
|
1253
|
+
}), []), k = o(() => S((e) => {
|
|
964
1254
|
for (let t of e) t.url && URL.revokeObjectURL(t.url);
|
|
965
1255
|
return [];
|
|
966
|
-
}), []),
|
|
1256
|
+
}), []), A = v ? _.attachments.add : D, j = v ? _.attachments.remove : O, M = v ? _.attachments.clear : k, N = v ? _.attachments.openFileDialog : T;
|
|
967
1257
|
c(() => {
|
|
968
|
-
|
|
969
|
-
}, [
|
|
970
|
-
|
|
971
|
-
}, [
|
|
972
|
-
let e =
|
|
973
|
-
if (!e ||
|
|
1258
|
+
v && _.__registerFileInput(y, () => y.current?.click());
|
|
1259
|
+
}, [v, _]), c(() => {
|
|
1260
|
+
a && y.current && C.length === 0 && (y.current.value = "");
|
|
1261
|
+
}, [C, a]), c(() => {
|
|
1262
|
+
let e = b.current;
|
|
1263
|
+
if (!e || i) return;
|
|
974
1264
|
let t = (e) => {
|
|
975
1265
|
e.dataTransfer?.types?.includes("Files") && e.preventDefault();
|
|
976
1266
|
}, n = (e) => {
|
|
977
|
-
e.dataTransfer?.types?.includes("Files") && e.preventDefault(), e.dataTransfer?.files && e.dataTransfer.files.length > 0 &&
|
|
1267
|
+
e.dataTransfer?.types?.includes("Files") && e.preventDefault(), e.dataTransfer?.files && e.dataTransfer.files.length > 0 && A(e.dataTransfer.files);
|
|
978
1268
|
};
|
|
979
1269
|
return e.addEventListener("dragover", t), e.addEventListener("drop", n), () => {
|
|
980
1270
|
e.removeEventListener("dragover", t), e.removeEventListener("drop", n);
|
|
981
1271
|
};
|
|
982
|
-
}, [
|
|
983
|
-
if (!
|
|
1272
|
+
}, [A, i]), c(() => {
|
|
1273
|
+
if (!i) return;
|
|
984
1274
|
let e = (e) => {
|
|
985
1275
|
e.dataTransfer?.types?.includes("Files") && e.preventDefault();
|
|
986
1276
|
}, t = (e) => {
|
|
987
|
-
e.dataTransfer?.types?.includes("Files") && e.preventDefault(), e.dataTransfer?.files && e.dataTransfer.files.length > 0 &&
|
|
1277
|
+
e.dataTransfer?.types?.includes("Files") && e.preventDefault(), e.dataTransfer?.files && e.dataTransfer.files.length > 0 && A(e.dataTransfer.files);
|
|
988
1278
|
};
|
|
989
1279
|
return document.addEventListener("dragover", e), document.addEventListener("drop", t), () => {
|
|
990
1280
|
document.removeEventListener("dragover", e), document.removeEventListener("drop", t);
|
|
991
1281
|
};
|
|
992
|
-
}, [
|
|
993
|
-
if (!
|
|
994
|
-
}, [
|
|
995
|
-
let
|
|
996
|
-
e.currentTarget.files &&
|
|
997
|
-
},
|
|
1282
|
+
}, [A, i]), c(() => () => {
|
|
1283
|
+
if (!v) for (let e of w.current) e.url && URL.revokeObjectURL(e.url);
|
|
1284
|
+
}, [v]);
|
|
1285
|
+
let ee = (e) => {
|
|
1286
|
+
e.currentTarget.files && A(e.currentTarget.files), e.currentTarget.value = "";
|
|
1287
|
+
}, te = async (e) => {
|
|
998
1288
|
try {
|
|
999
1289
|
let t = await (await fetch(e)).blob();
|
|
1000
1290
|
return new Promise((e) => {
|
|
@@ -1004,39 +1294,39 @@ var Fn = ({ label: e = "Add photos or files", ...t }) => {
|
|
|
1004
1294
|
} catch {
|
|
1005
1295
|
return null;
|
|
1006
1296
|
}
|
|
1007
|
-
},
|
|
1008
|
-
files:
|
|
1297
|
+
}, P = l(() => ({
|
|
1298
|
+
files: C.map((e) => ({
|
|
1009
1299
|
...e,
|
|
1010
1300
|
id: e.id
|
|
1011
1301
|
})),
|
|
1012
|
-
add:
|
|
1013
|
-
remove:
|
|
1014
|
-
clear:
|
|
1015
|
-
openFileDialog:
|
|
1016
|
-
fileInputRef:
|
|
1302
|
+
add: A,
|
|
1303
|
+
remove: j,
|
|
1304
|
+
clear: M,
|
|
1305
|
+
openFileDialog: N,
|
|
1306
|
+
fileInputRef: y
|
|
1017
1307
|
}), [
|
|
1018
|
-
|
|
1019
|
-
k,
|
|
1308
|
+
C,
|
|
1020
1309
|
A,
|
|
1021
1310
|
j,
|
|
1022
|
-
M
|
|
1023
|
-
|
|
1311
|
+
M,
|
|
1312
|
+
N
|
|
1313
|
+
]), F = /* @__PURE__ */ $(Z, { children: [/* @__PURE__ */ Q("input", {
|
|
1024
1314
|
accept: t,
|
|
1025
|
-
"aria-label":
|
|
1315
|
+
"aria-label": r,
|
|
1026
1316
|
className: "hidden",
|
|
1027
1317
|
multiple: n,
|
|
1028
|
-
onChange:
|
|
1029
|
-
ref:
|
|
1030
|
-
title:
|
|
1318
|
+
onChange: ee,
|
|
1319
|
+
ref: y,
|
|
1320
|
+
title: r,
|
|
1031
1321
|
type: "file"
|
|
1032
|
-
}), /* @__PURE__ */
|
|
1033
|
-
className:
|
|
1322
|
+
}), /* @__PURE__ */ Q("form", {
|
|
1323
|
+
className: J("w-full", e),
|
|
1034
1324
|
onSubmit: (e) => {
|
|
1035
1325
|
e.preventDefault();
|
|
1036
|
-
let t = e.currentTarget, n =
|
|
1037
|
-
|
|
1326
|
+
let t = e.currentTarget, n = v ? _.textInput.value : new FormData(t).get("message") || "";
|
|
1327
|
+
v || t.reset(), Promise.all(C.map(async ({ id: e, ...t }) => {
|
|
1038
1328
|
if (t.url && t.url.startsWith("blob:")) {
|
|
1039
|
-
let e = await
|
|
1329
|
+
let e = await te(t.url);
|
|
1040
1330
|
return {
|
|
1041
1331
|
...t,
|
|
1042
1332
|
url: e ?? t.url
|
|
@@ -1045,32 +1335,32 @@ var Fn = ({ label: e = "Add photos or files", ...t }) => {
|
|
|
1045
1335
|
return t;
|
|
1046
1336
|
})).then((t) => {
|
|
1047
1337
|
try {
|
|
1048
|
-
let r =
|
|
1338
|
+
let r = m({
|
|
1049
1339
|
text: n,
|
|
1050
1340
|
files: t
|
|
1051
1341
|
}, e);
|
|
1052
1342
|
r instanceof Promise ? r.then(() => {
|
|
1053
|
-
|
|
1054
|
-
}).catch(() => {}) : (
|
|
1343
|
+
M(), v && _.textInput.clear();
|
|
1344
|
+
}).catch(() => {}) : (M(), v && _.textInput.clear());
|
|
1055
1345
|
} catch {}
|
|
1056
1346
|
}).catch(() => {});
|
|
1057
1347
|
},
|
|
1058
|
-
ref:
|
|
1059
|
-
...
|
|
1060
|
-
children: /* @__PURE__ */
|
|
1348
|
+
ref: b,
|
|
1349
|
+
...g,
|
|
1350
|
+
children: /* @__PURE__ */ Q(nr, {
|
|
1061
1351
|
className: "overflow-hidden",
|
|
1062
|
-
children:
|
|
1352
|
+
children: h
|
|
1063
1353
|
})
|
|
1064
1354
|
})] });
|
|
1065
|
-
return
|
|
1066
|
-
value:
|
|
1067
|
-
children:
|
|
1355
|
+
return v ? F : /* @__PURE__ */ Q(hr.Provider, {
|
|
1356
|
+
value: P,
|
|
1357
|
+
children: F
|
|
1068
1358
|
});
|
|
1069
|
-
},
|
|
1070
|
-
className:
|
|
1359
|
+
}, xr = ({ className: e, ...t }) => /* @__PURE__ */ Q("div", {
|
|
1360
|
+
className: J("contents", e),
|
|
1071
1361
|
...t
|
|
1072
|
-
}),
|
|
1073
|
-
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) => {
|
|
1074
1364
|
if (e.key === "Enter") {
|
|
1075
1365
|
if (o || e.nativeEvent.isComposing || e.shiftKey) return;
|
|
1076
1366
|
e.preventDefault();
|
|
@@ -1098,8 +1388,8 @@ var Fn = ({ label: e = "Add photos or files", ...t }) => {
|
|
|
1098
1388
|
i.textInput.setInput(t.currentTarget.value), e?.(t);
|
|
1099
1389
|
}
|
|
1100
1390
|
} : { onChange: e };
|
|
1101
|
-
return /* @__PURE__ */
|
|
1102
|
-
className:
|
|
1391
|
+
return /* @__PURE__ */ Q(sr, {
|
|
1392
|
+
className: J("field-sizing-content max-h-48 min-h-16", t),
|
|
1103
1393
|
name: "message",
|
|
1104
1394
|
onCompositionEnd: () => s(!1),
|
|
1105
1395
|
onCompositionStart: () => s(!0),
|
|
@@ -1109,52 +1399,52 @@ var Fn = ({ label: e = "Add photos or files", ...t }) => {
|
|
|
1109
1399
|
...r,
|
|
1110
1400
|
...u
|
|
1111
1401
|
});
|
|
1112
|
-
},
|
|
1402
|
+
}, Cr = ({ className: e, ...t }) => /* @__PURE__ */ Q(ir, {
|
|
1113
1403
|
align: "block-end",
|
|
1114
|
-
className:
|
|
1404
|
+
className: J("order-first flex-wrap gap-1", e),
|
|
1115
1405
|
...t
|
|
1116
|
-
}),
|
|
1406
|
+
}), wr = ({ className: e, ...t }) => /* @__PURE__ */ Q(ir, {
|
|
1117
1407
|
align: "block-end",
|
|
1118
|
-
className:
|
|
1408
|
+
className: J("justify-between gap-1", e),
|
|
1119
1409
|
...t
|
|
1120
|
-
}),
|
|
1121
|
-
className:
|
|
1410
|
+
}), Tr = ({ className: e, ...t }) => /* @__PURE__ */ Q("div", {
|
|
1411
|
+
className: J("flex items-center gap-1", e),
|
|
1122
1412
|
...t
|
|
1123
|
-
}),
|
|
1413
|
+
}), Er = ({ variant: e = "ghost", className: n, size: r, ...i }) => {
|
|
1124
1414
|
let a = r ?? (t.count(i.children) > 1 ? "sm" : "icon-sm");
|
|
1125
|
-
return /* @__PURE__ */
|
|
1126
|
-
className:
|
|
1415
|
+
return /* @__PURE__ */ Q(or, {
|
|
1416
|
+
className: J(n),
|
|
1127
1417
|
size: a,
|
|
1128
1418
|
type: "button",
|
|
1129
1419
|
variant: e,
|
|
1130
1420
|
...i
|
|
1131
1421
|
});
|
|
1132
|
-
},
|
|
1422
|
+
}, Dr = (e) => /* @__PURE__ */ Q(ee, { ...e }), Or = ({ className: e, children: t, ...n }) => /* @__PURE__ */ Q(F, {
|
|
1133
1423
|
asChild: !0,
|
|
1134
|
-
children: /* @__PURE__ */
|
|
1424
|
+
children: /* @__PURE__ */ Q(Er, {
|
|
1135
1425
|
className: e,
|
|
1136
1426
|
...n,
|
|
1137
|
-
children: t ?? /* @__PURE__ */
|
|
1427
|
+
children: t ?? /* @__PURE__ */ Q(ot, { className: "size-4" })
|
|
1138
1428
|
})
|
|
1139
|
-
}),
|
|
1429
|
+
}), kr = ({ className: e, ...t }) => /* @__PURE__ */ Q(te, {
|
|
1140
1430
|
align: "start",
|
|
1141
|
-
className:
|
|
1431
|
+
className: J(e),
|
|
1142
1432
|
...t
|
|
1143
|
-
}),
|
|
1144
|
-
className:
|
|
1433
|
+
}), Ar = ({ className: e, ...t }) => /* @__PURE__ */ Q(P, {
|
|
1434
|
+
className: J(e),
|
|
1145
1435
|
...t
|
|
1146
|
-
}),
|
|
1147
|
-
let o = /* @__PURE__ */
|
|
1148
|
-
return r === "submitted" ? o = /* @__PURE__ */
|
|
1436
|
+
}), jr = ({ className: e, variant: t = "default", size: n = "icon-sm", status: r, children: i, ...a }) => {
|
|
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(vt, { className: "size-4" })), /* @__PURE__ */ Q(or, {
|
|
1149
1439
|
"aria-label": "Submit",
|
|
1150
|
-
className:
|
|
1440
|
+
className: J(e),
|
|
1151
1441
|
size: n,
|
|
1152
1442
|
type: "submit",
|
|
1153
1443
|
variant: t,
|
|
1154
1444
|
...a,
|
|
1155
1445
|
children: i ?? o
|
|
1156
1446
|
});
|
|
1157
|
-
},
|
|
1447
|
+
}, Mr = ({ className: e, textareaRef: t, onTranscriptionChange: n, ...r }) => {
|
|
1158
1448
|
let [i, a] = d(!1), [s, l] = d(null), f = u(null);
|
|
1159
1449
|
c(() => {
|
|
1160
1450
|
if (typeof window < "u" && ("SpeechRecognition" in window || "webkitSpeechRecognition" in window)) {
|
|
@@ -1184,80 +1474,80 @@ var Fn = ({ label: e = "Add photos or files", ...t }) => {
|
|
|
1184
1474
|
let p = o(() => {
|
|
1185
1475
|
s && (i ? s.stop() : s.start());
|
|
1186
1476
|
}, [s, i]);
|
|
1187
|
-
return /* @__PURE__ */
|
|
1188
|
-
className:
|
|
1477
|
+
return /* @__PURE__ */ Q(Er, {
|
|
1478
|
+
className: J("relative transition-all duration-200", i && "animate-pulse bg-accent text-accent-foreground", e),
|
|
1189
1479
|
disabled: !s,
|
|
1190
1480
|
onClick: p,
|
|
1191
1481
|
...r,
|
|
1192
|
-
children: /* @__PURE__ */
|
|
1482
|
+
children: /* @__PURE__ */ Q(rt, { className: "size-4" })
|
|
1193
1483
|
});
|
|
1194
|
-
},
|
|
1195
|
-
className:
|
|
1484
|
+
}, Nr = (e) => /* @__PURE__ */ Q(le, { ...e }), Pr = ({ className: e, ...t }) => /* @__PURE__ */ Q(fe, {
|
|
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),
|
|
1196
1486
|
...t
|
|
1197
|
-
}),
|
|
1198
|
-
className:
|
|
1487
|
+
}), Fr = ({ className: e, ...t }) => /* @__PURE__ */ Q(ue, {
|
|
1488
|
+
className: J(e),
|
|
1199
1489
|
...t
|
|
1200
|
-
}),
|
|
1201
|
-
className:
|
|
1490
|
+
}), Ir = ({ className: e, ...t }) => /* @__PURE__ */ Q(de, {
|
|
1491
|
+
className: J(e),
|
|
1202
1492
|
...t
|
|
1203
|
-
}),
|
|
1204
|
-
className:
|
|
1493
|
+
}), Lr = ({ className: e, ...t }) => /* @__PURE__ */ Q(pe, {
|
|
1494
|
+
className: J(e),
|
|
1205
1495
|
...t
|
|
1206
|
-
}),
|
|
1496
|
+
}), Rr = ({ openDelay: e = 0, closeDelay: t = 0, ...n }) => /* @__PURE__ */ Q(L, {
|
|
1207
1497
|
closeDelay: t,
|
|
1208
1498
|
openDelay: e,
|
|
1209
1499
|
...n
|
|
1210
|
-
}),
|
|
1500
|
+
}), zr = (e) => /* @__PURE__ */ Q(R, { ...e }), Br = ({ align: e = "start", ...t }) => /* @__PURE__ */ Q(oe, {
|
|
1211
1501
|
align: e,
|
|
1212
1502
|
...t
|
|
1213
|
-
}),
|
|
1214
|
-
className:
|
|
1503
|
+
}), Vr = ({ className: e, ...t }) => /* @__PURE__ */ Q("div", {
|
|
1504
|
+
className: J(e),
|
|
1215
1505
|
...t
|
|
1216
|
-
}),
|
|
1217
|
-
className:
|
|
1506
|
+
}), Hr = ({ className: e, ...t }) => /* @__PURE__ */ Q("div", {
|
|
1507
|
+
className: J(e),
|
|
1218
1508
|
...t
|
|
1219
|
-
}),
|
|
1220
|
-
className:
|
|
1509
|
+
}), Ur = ({ className: e, ...t }) => /* @__PURE__ */ Q("h3", {
|
|
1510
|
+
className: J("mb-2 px-3 font-medium text-muted-foreground text-xs", e),
|
|
1221
1511
|
...t
|
|
1222
|
-
}),
|
|
1223
|
-
className:
|
|
1512
|
+
}), Wr = ({ className: e, ...t }) => /* @__PURE__ */ Q("div", {
|
|
1513
|
+
className: J("space-y-1", e),
|
|
1224
1514
|
...t
|
|
1225
|
-
}),
|
|
1226
|
-
className:
|
|
1515
|
+
}), Gr = ({ className: e, ...t }) => /* @__PURE__ */ Q("div", {
|
|
1516
|
+
className: J("flex items-center gap-2 px-3 py-2 text-xs hover:bg-accent", e),
|
|
1227
1517
|
...t
|
|
1228
|
-
}),
|
|
1229
|
-
className:
|
|
1518
|
+
}), Kr = ({ className: e, ...t }) => /* @__PURE__ */ Q(D, {
|
|
1519
|
+
className: J(e),
|
|
1230
1520
|
...t
|
|
1231
|
-
}),
|
|
1232
|
-
className:
|
|
1521
|
+
}), qr = ({ className: e, ...t }) => /* @__PURE__ */ Q(A, {
|
|
1522
|
+
className: J(e),
|
|
1233
1523
|
...t
|
|
1234
|
-
}),
|
|
1235
|
-
className:
|
|
1524
|
+
}), Jr = ({ className: e, ...t }) => /* @__PURE__ */ Q(M, {
|
|
1525
|
+
className: J(e),
|
|
1236
1526
|
...t
|
|
1237
|
-
}),
|
|
1238
|
-
className:
|
|
1527
|
+
}), Yr = ({ className: e, ...t }) => /* @__PURE__ */ Q(O, {
|
|
1528
|
+
className: J(e),
|
|
1239
1529
|
...t
|
|
1240
|
-
}),
|
|
1241
|
-
className:
|
|
1530
|
+
}), Xr = ({ className: e, ...t }) => /* @__PURE__ */ Q(k, {
|
|
1531
|
+
className: J(e),
|
|
1242
1532
|
...t
|
|
1243
|
-
}),
|
|
1244
|
-
className:
|
|
1533
|
+
}), Zr = ({ className: e, ...t }) => /* @__PURE__ */ Q(j, {
|
|
1534
|
+
className: J(e),
|
|
1245
1535
|
...t
|
|
1246
|
-
}),
|
|
1247
|
-
className:
|
|
1536
|
+
}), Qr = ({ className: e, ...t }) => /* @__PURE__ */ Q(N, {
|
|
1537
|
+
className: J(e),
|
|
1248
1538
|
...t
|
|
1249
|
-
}),
|
|
1539
|
+
}), $r = ({ className: e, children: t, ...n }) => /* @__PURE__ */ $(se, {
|
|
1250
1540
|
className: "w-full overflow-x-auto whitespace-nowrap",
|
|
1251
1541
|
...n,
|
|
1252
|
-
children: [/* @__PURE__ */
|
|
1253
|
-
className:
|
|
1542
|
+
children: [/* @__PURE__ */ Q("div", {
|
|
1543
|
+
className: J("flex w-max flex-nowrap items-center gap-2", e),
|
|
1254
1544
|
children: t
|
|
1255
|
-
}), /* @__PURE__ */
|
|
1545
|
+
}), /* @__PURE__ */ Q(ce, {
|
|
1256
1546
|
className: "hidden",
|
|
1257
1547
|
orientation: "horizontal"
|
|
1258
1548
|
})]
|
|
1259
|
-
}),
|
|
1260
|
-
className:
|
|
1549
|
+
}), ei = ({ suggestion: e, onClick: t, className: n, variant: r = "outline", size: i = "sm", children: a, ...o }) => /* @__PURE__ */ Q(v, {
|
|
1550
|
+
className: J("cursor-pointer rounded-full px-4", n),
|
|
1261
1551
|
onClick: () => {
|
|
1262
1552
|
t?.(e);
|
|
1263
1553
|
},
|
|
@@ -1266,7 +1556,7 @@ var Fn = ({ label: e = "Add photos or files", ...t }) => {
|
|
|
1266
1556
|
variant: r,
|
|
1267
1557
|
...o,
|
|
1268
1558
|
children: a || e
|
|
1269
|
-
}),
|
|
1559
|
+
}), ti = r({ code: "" }), ni = {
|
|
1270
1560
|
name: "line-numbers",
|
|
1271
1561
|
line(e, t) {
|
|
1272
1562
|
e.children.unshift({
|
|
@@ -1287,21 +1577,21 @@ var Fn = ({ label: e = "Add photos or files", ...t }) => {
|
|
|
1287
1577
|
});
|
|
1288
1578
|
}
|
|
1289
1579
|
};
|
|
1290
|
-
async function
|
|
1291
|
-
let r = n ? [
|
|
1292
|
-
return await Promise.all([
|
|
1580
|
+
async function ri(e, t, n = !1) {
|
|
1581
|
+
let r = n ? [ni] : [];
|
|
1582
|
+
return await Promise.all([At(e, {
|
|
1293
1583
|
lang: t,
|
|
1294
1584
|
theme: "one-light",
|
|
1295
1585
|
transformers: r
|
|
1296
|
-
}),
|
|
1586
|
+
}), At(e, {
|
|
1297
1587
|
lang: t,
|
|
1298
1588
|
theme: "one-dark-pro",
|
|
1299
1589
|
transformers: r
|
|
1300
1590
|
})]);
|
|
1301
1591
|
}
|
|
1302
|
-
var
|
|
1592
|
+
var ii = ({ code: e, language: t, showLineNumbers: n = !1, className: r, children: i, ...a }) => {
|
|
1303
1593
|
let [o, s] = d(""), [l, f] = d(""), p = u(!1);
|
|
1304
|
-
return c(() => (
|
|
1594
|
+
return c(() => (ri(e, t, n).then(([e, t]) => {
|
|
1305
1595
|
p.current ||= (s(e), f(t), !0);
|
|
1306
1596
|
}), () => {
|
|
1307
1597
|
p.current = !1;
|
|
@@ -1309,23 +1599,23 @@ var Q = ({ code: e, language: t, showLineNumbers: n = !1, className: r, children
|
|
|
1309
1599
|
e,
|
|
1310
1600
|
t,
|
|
1311
1601
|
n
|
|
1312
|
-
]), /* @__PURE__ */
|
|
1602
|
+
]), /* @__PURE__ */ Q(ti.Provider, {
|
|
1313
1603
|
value: { code: e },
|
|
1314
|
-
children: /* @__PURE__ */
|
|
1315
|
-
className:
|
|
1604
|
+
children: /* @__PURE__ */ Q("div", {
|
|
1605
|
+
className: J("group relative w-full overflow-hidden rounded-md border bg-background text-foreground", r),
|
|
1316
1606
|
...a,
|
|
1317
|
-
children: /* @__PURE__ */
|
|
1607
|
+
children: /* @__PURE__ */ $("div", {
|
|
1318
1608
|
className: "relative",
|
|
1319
1609
|
children: [
|
|
1320
|
-
/* @__PURE__ */
|
|
1610
|
+
/* @__PURE__ */ Q("div", {
|
|
1321
1611
|
className: "overflow-auto dark:hidden [&>pre]:m-0 [&>pre]:bg-background! [&>pre]:p-4 [&>pre]:text-foreground! [&>pre]:text-sm [&_code]:font-mono [&_code]:text-sm",
|
|
1322
1612
|
dangerouslySetInnerHTML: { __html: o }
|
|
1323
1613
|
}),
|
|
1324
|
-
/* @__PURE__ */
|
|
1614
|
+
/* @__PURE__ */ Q("div", {
|
|
1325
1615
|
className: "hidden overflow-auto dark:block [&>pre]:m-0 [&>pre]:bg-background! [&>pre]:p-4 [&>pre]:text-foreground! [&>pre]:text-sm [&_code]:font-mono [&_code]:text-sm",
|
|
1326
1616
|
dangerouslySetInnerHTML: { __html: l }
|
|
1327
1617
|
}),
|
|
1328
|
-
i && /* @__PURE__ */
|
|
1618
|
+
i && /* @__PURE__ */ Q("div", {
|
|
1329
1619
|
className: "absolute top-2 right-2 flex items-center gap-2",
|
|
1330
1620
|
children: i
|
|
1331
1621
|
})
|
|
@@ -1333,8 +1623,8 @@ var Q = ({ code: e, language: t, showLineNumbers: n = !1, className: r, children
|
|
|
1333
1623
|
})
|
|
1334
1624
|
})
|
|
1335
1625
|
});
|
|
1336
|
-
},
|
|
1337
|
-
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 () => {
|
|
1338
1628
|
if (typeof window > "u" || !navigator?.clipboard?.writeText) {
|
|
1339
1629
|
t?.(/* @__PURE__ */ Error("Clipboard API not available"));
|
|
1340
1630
|
return;
|
|
@@ -1344,29 +1634,29 @@ var Q = ({ code: e, language: t, showLineNumbers: n = !1, className: r, children
|
|
|
1344
1634
|
} catch (e) {
|
|
1345
1635
|
t?.(e);
|
|
1346
1636
|
}
|
|
1347
|
-
}, f = o ?
|
|
1348
|
-
return /* @__PURE__ */
|
|
1349
|
-
className:
|
|
1637
|
+
}, f = o ? Ie : Ke;
|
|
1638
|
+
return /* @__PURE__ */ Q(v, {
|
|
1639
|
+
className: J("shrink-0", i),
|
|
1350
1640
|
onClick: u,
|
|
1351
1641
|
size: "icon",
|
|
1352
1642
|
variant: "ghost",
|
|
1353
1643
|
...a,
|
|
1354
|
-
children: r ?? /* @__PURE__ */
|
|
1644
|
+
children: r ?? /* @__PURE__ */ Q(f, { size: 14 })
|
|
1355
1645
|
});
|
|
1356
|
-
},
|
|
1357
|
-
className:
|
|
1646
|
+
}, oi = ({ className: e, ...t }) => /* @__PURE__ */ Q(w, {
|
|
1647
|
+
className: J("not-prose mb-4 w-full rounded-md border", e),
|
|
1358
1648
|
...t
|
|
1359
|
-
}),
|
|
1649
|
+
}), si = (e) => /* @__PURE__ */ $(_, {
|
|
1360
1650
|
className: "gap-1.5 rounded-full text-xs",
|
|
1361
1651
|
variant: "secondary",
|
|
1362
1652
|
children: [{
|
|
1363
|
-
"input-streaming": /* @__PURE__ */
|
|
1364
|
-
"input-available": /* @__PURE__ */
|
|
1365
|
-
"approval-requested": /* @__PURE__ */
|
|
1366
|
-
"approval-responded": /* @__PURE__ */
|
|
1367
|
-
"output-available": /* @__PURE__ */
|
|
1368
|
-
"output-error": /* @__PURE__ */
|
|
1369
|
-
"output-denied": /* @__PURE__ */
|
|
1653
|
+
"input-streaming": /* @__PURE__ */ Q(Be, { className: "size-4" }),
|
|
1654
|
+
"input-available": /* @__PURE__ */ Q(We, { className: "size-4 animate-pulse" }),
|
|
1655
|
+
"approval-requested": /* @__PURE__ */ Q(We, { className: "size-4 text-yellow-600" }),
|
|
1656
|
+
"approval-responded": /* @__PURE__ */ Q(Fe, { className: "size-4 text-blue-600" }),
|
|
1657
|
+
"output-available": /* @__PURE__ */ Q(Fe, { className: "size-4 text-green-600" }),
|
|
1658
|
+
"output-error": /* @__PURE__ */ Q(_t, { className: "size-4 text-red-600" }),
|
|
1659
|
+
"output-denied": /* @__PURE__ */ Q(_t, { className: "size-4 text-orange-600" })
|
|
1370
1660
|
}[e], {
|
|
1371
1661
|
"input-streaming": "Pending",
|
|
1372
1662
|
"input-available": "Running",
|
|
@@ -1376,61 +1666,61 @@ var Q = ({ code: e, language: t, showLineNumbers: n = !1, className: r, children
|
|
|
1376
1666
|
"output-error": "Error",
|
|
1377
1667
|
"output-denied": "Denied"
|
|
1378
1668
|
}[e]]
|
|
1379
|
-
}),
|
|
1380
|
-
className:
|
|
1669
|
+
}), ci = ({ className: e, title: t, type: n, state: r, ...i }) => /* @__PURE__ */ $(E, {
|
|
1670
|
+
className: J("flex w-full items-center justify-between gap-4 p-3", e),
|
|
1381
1671
|
...i,
|
|
1382
|
-
children: [/* @__PURE__ */
|
|
1672
|
+
children: [/* @__PURE__ */ $("div", {
|
|
1383
1673
|
className: "flex items-center gap-2",
|
|
1384
1674
|
children: [
|
|
1385
|
-
/* @__PURE__ */
|
|
1386
|
-
/* @__PURE__ */
|
|
1675
|
+
/* @__PURE__ */ Q(ht, { className: "size-4 text-muted-foreground" }),
|
|
1676
|
+
/* @__PURE__ */ Q("span", {
|
|
1387
1677
|
className: "font-medium text-sm",
|
|
1388
1678
|
children: t ?? n.split("-").slice(1).join("-")
|
|
1389
1679
|
}),
|
|
1390
|
-
|
|
1680
|
+
si(r)
|
|
1391
1681
|
]
|
|
1392
|
-
}), /* @__PURE__ */
|
|
1393
|
-
}),
|
|
1394
|
-
className:
|
|
1682
|
+
}), /* @__PURE__ */ Q(Le, { className: "size-4 text-muted-foreground transition-transform group-data-[state=open]:rotate-180" })]
|
|
1683
|
+
}), li = ({ className: e, ...t }) => /* @__PURE__ */ Q(T, {
|
|
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),
|
|
1395
1685
|
...t
|
|
1396
|
-
}),
|
|
1397
|
-
className:
|
|
1686
|
+
}), ui = ({ className: e, input: t, ...n }) => /* @__PURE__ */ $("div", {
|
|
1687
|
+
className: J("space-y-2 overflow-hidden p-4", e),
|
|
1398
1688
|
...n,
|
|
1399
|
-
children: [/* @__PURE__ */
|
|
1689
|
+
children: [/* @__PURE__ */ Q("h4", {
|
|
1400
1690
|
className: "font-medium text-muted-foreground text-xs uppercase tracking-wide",
|
|
1401
1691
|
children: "Parameters"
|
|
1402
|
-
}), /* @__PURE__ */
|
|
1692
|
+
}), /* @__PURE__ */ Q("div", {
|
|
1403
1693
|
className: "rounded-md bg-muted/50",
|
|
1404
|
-
children: /* @__PURE__ */
|
|
1694
|
+
children: /* @__PURE__ */ Q(ii, {
|
|
1405
1695
|
code: JSON.stringify(t, null, 2),
|
|
1406
1696
|
language: "json"
|
|
1407
1697
|
})
|
|
1408
1698
|
})]
|
|
1409
|
-
}),
|
|
1699
|
+
}), di = ({ className: e, output: t, errorText: n, ...r }) => {
|
|
1410
1700
|
if (!(t || n)) return null;
|
|
1411
|
-
let a = /* @__PURE__ */
|
|
1412
|
-
return typeof t == "object" && !i(t) ? a = /* @__PURE__ */
|
|
1701
|
+
let a = /* @__PURE__ */ Q("div", { children: t });
|
|
1702
|
+
return typeof t == "object" && !i(t) ? a = /* @__PURE__ */ Q(ii, {
|
|
1413
1703
|
code: JSON.stringify(t, null, 2),
|
|
1414
1704
|
language: "json"
|
|
1415
|
-
}) : typeof t == "string" && (a = /* @__PURE__ */
|
|
1705
|
+
}) : typeof t == "string" && (a = /* @__PURE__ */ Q(ii, {
|
|
1416
1706
|
code: t,
|
|
1417
1707
|
language: "json"
|
|
1418
|
-
})), /* @__PURE__ */
|
|
1419
|
-
className:
|
|
1708
|
+
})), /* @__PURE__ */ $("div", {
|
|
1709
|
+
className: J("space-y-2 p-4", e),
|
|
1420
1710
|
...r,
|
|
1421
|
-
children: [/* @__PURE__ */
|
|
1711
|
+
children: [/* @__PURE__ */ Q("h4", {
|
|
1422
1712
|
className: "font-medium text-muted-foreground text-xs uppercase tracking-wide",
|
|
1423
1713
|
children: n ? "Error" : "Result"
|
|
1424
|
-
}), /* @__PURE__ */
|
|
1425
|
-
className:
|
|
1426
|
-
children: [n && /* @__PURE__ */
|
|
1714
|
+
}), /* @__PURE__ */ $("div", {
|
|
1715
|
+
className: J("overflow-x-auto rounded-md text-xs [&_table]:w-full", n ? "bg-destructive/10 text-destructive" : "bg-muted/50 text-foreground"),
|
|
1716
|
+
children: [n && /* @__PURE__ */ Q("div", { children: n }), a]
|
|
1427
1717
|
})]
|
|
1428
1718
|
});
|
|
1429
|
-
},
|
|
1430
|
-
let a =
|
|
1431
|
-
return /* @__PURE__ */
|
|
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
|
+
return /* @__PURE__ */ Q(a, {
|
|
1432
1722
|
animate: { backgroundPosition: "0% center" },
|
|
1433
|
-
className:
|
|
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),
|
|
1434
1724
|
initial: { backgroundPosition: "100% center" },
|
|
1435
1725
|
style: {
|
|
1436
1726
|
"--spread": `${o}px`,
|
|
@@ -1443,21 +1733,21 @@ var Q = ({ code: e, language: t, showLineNumbers: n = !1, className: r, children
|
|
|
1443
1733
|
},
|
|
1444
1734
|
children: e
|
|
1445
1735
|
});
|
|
1446
|
-
}),
|
|
1447
|
-
let e = s(
|
|
1736
|
+
}), pi = r(null), mi = () => {
|
|
1737
|
+
let e = s(pi);
|
|
1448
1738
|
if (!e) throw Error("Reasoning components must be used within Reasoning");
|
|
1449
1739
|
return e;
|
|
1450
|
-
},
|
|
1451
|
-
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({
|
|
1452
1742
|
prop: n,
|
|
1453
1743
|
defaultProp: r,
|
|
1454
1744
|
onChange: i
|
|
1455
|
-
}), [f, p] =
|
|
1745
|
+
}), [f, p] = jt({
|
|
1456
1746
|
prop: a,
|
|
1457
1747
|
defaultProp: void 0
|
|
1458
1748
|
}), [m, h] = d(!1), [g, _] = d(null);
|
|
1459
1749
|
return c(() => {
|
|
1460
|
-
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));
|
|
1461
1751
|
}, [
|
|
1462
1752
|
t,
|
|
1463
1753
|
g,
|
|
@@ -1466,7 +1756,7 @@ var Q = ({ code: e, language: t, showLineNumbers: n = !1, className: r, children
|
|
|
1466
1756
|
if (r && !t && l && !m) {
|
|
1467
1757
|
let e = setTimeout(() => {
|
|
1468
1758
|
u(!1), h(!0);
|
|
1469
|
-
},
|
|
1759
|
+
}, hi);
|
|
1470
1760
|
return () => clearTimeout(e);
|
|
1471
1761
|
}
|
|
1472
1762
|
}, [
|
|
@@ -1475,15 +1765,15 @@ var Q = ({ code: e, language: t, showLineNumbers: n = !1, className: r, children
|
|
|
1475
1765
|
r,
|
|
1476
1766
|
u,
|
|
1477
1767
|
m
|
|
1478
|
-
]), /* @__PURE__ */
|
|
1768
|
+
]), /* @__PURE__ */ Q(pi.Provider, {
|
|
1479
1769
|
value: {
|
|
1480
1770
|
isStreaming: t,
|
|
1481
1771
|
isOpen: l,
|
|
1482
1772
|
setIsOpen: u,
|
|
1483
1773
|
duration: f
|
|
1484
1774
|
},
|
|
1485
|
-
children: /* @__PURE__ */
|
|
1486
|
-
className:
|
|
1775
|
+
children: /* @__PURE__ */ Q(w, {
|
|
1776
|
+
className: J("not-prose mb-4", e),
|
|
1487
1777
|
onOpenChange: (e) => {
|
|
1488
1778
|
u(e);
|
|
1489
1779
|
},
|
|
@@ -1492,69 +1782,80 @@ var Q = ({ code: e, language: t, showLineNumbers: n = !1, className: r, children
|
|
|
1492
1782
|
children: o
|
|
1493
1783
|
})
|
|
1494
1784
|
});
|
|
1495
|
-
}),
|
|
1785
|
+
}), vi = (e, t) => e || t === 0 ? /* @__PURE__ */ Q(fi, {
|
|
1496
1786
|
duration: 1,
|
|
1497
1787
|
children: "Thinking..."
|
|
1498
|
-
}) : t === void 0 ? /* @__PURE__ */
|
|
1788
|
+
}) : t === void 0 ? /* @__PURE__ */ Q("p", { children: "Thought for a few seconds" }) : /* @__PURE__ */ $("p", { children: [
|
|
1499
1789
|
"Thought for ",
|
|
1500
1790
|
t,
|
|
1501
1791
|
" seconds"
|
|
1502
|
-
] }),
|
|
1503
|
-
let { isStreaming: i, isOpen: a, duration: o } =
|
|
1504
|
-
return /* @__PURE__ */
|
|
1505
|
-
className:
|
|
1792
|
+
] }), yi = a(({ className: e, children: t, getThinkingMessage: n = vi, ...r }) => {
|
|
1793
|
+
let { isStreaming: i, isOpen: a, duration: o } = mi();
|
|
1794
|
+
return /* @__PURE__ */ Q(E, {
|
|
1795
|
+
className: J("flex w-full items-center gap-2 text-muted-foreground text-sm transition-colors hover:text-foreground", e),
|
|
1506
1796
|
...r,
|
|
1507
|
-
children: t ?? /* @__PURE__ */
|
|
1508
|
-
/* @__PURE__ */
|
|
1797
|
+
children: t ?? /* @__PURE__ */ $(Z, { children: [
|
|
1798
|
+
/* @__PURE__ */ Q(Ne, { className: "size-4" }),
|
|
1509
1799
|
n(i, o),
|
|
1510
|
-
/* @__PURE__ */
|
|
1800
|
+
/* @__PURE__ */ Q(Le, { className: J("size-4 transition-transform", a ? "rotate-180" : "rotate-0") })
|
|
1511
1801
|
] })
|
|
1512
1802
|
});
|
|
1513
|
-
}),
|
|
1514
|
-
className:
|
|
1803
|
+
}), bi = a(({ className: e, children: t, ...n }) => /* @__PURE__ */ Q(T, {
|
|
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),
|
|
1515
1805
|
...n,
|
|
1516
|
-
children: /* @__PURE__ */
|
|
1806
|
+
children: /* @__PURE__ */ Q(Ot, { children: t })
|
|
1517
1807
|
}));
|
|
1518
|
-
|
|
1808
|
+
_i.displayName = "Reasoning", yi.displayName = "ReasoningTrigger", bi.displayName = "ReasoningContent";
|
|
1519
1809
|
//#endregion
|
|
1520
1810
|
//#region src/elements/sources.tsx
|
|
1521
|
-
var
|
|
1522
|
-
className:
|
|
1811
|
+
var xi = ({ className: e, ...t }) => /* @__PURE__ */ Q(w, {
|
|
1812
|
+
className: J("not-prose mb-4 text-primary text-xs", e),
|
|
1523
1813
|
...t
|
|
1524
|
-
}),
|
|
1525
|
-
className:
|
|
1814
|
+
}), Si = ({ className: e, count: t, children: n, ...r }) => /* @__PURE__ */ Q(E, {
|
|
1815
|
+
className: J("flex items-center gap-2", e),
|
|
1526
1816
|
...r,
|
|
1527
|
-
children: n ?? /* @__PURE__ */
|
|
1817
|
+
children: n ?? /* @__PURE__ */ $(Z, { children: [/* @__PURE__ */ $("p", {
|
|
1528
1818
|
className: "font-medium",
|
|
1529
1819
|
children: [
|
|
1530
1820
|
"Used ",
|
|
1531
1821
|
t,
|
|
1532
1822
|
" sources"
|
|
1533
1823
|
]
|
|
1534
|
-
}), /* @__PURE__ */
|
|
1535
|
-
}),
|
|
1536
|
-
className:
|
|
1824
|
+
}), /* @__PURE__ */ Q(Le, { className: "h-4 w-4" })] })
|
|
1825
|
+
}), Ci = ({ className: e, ...t }) => /* @__PURE__ */ Q(T, {
|
|
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),
|
|
1537
1827
|
...t
|
|
1538
|
-
}),
|
|
1828
|
+
}), wi = ({ href: e, title: t, children: n, ...r }) => /* @__PURE__ */ Q("a", {
|
|
1539
1829
|
className: "flex items-center gap-2",
|
|
1540
1830
|
href: e,
|
|
1541
1831
|
rel: "noreferrer",
|
|
1542
1832
|
target: "_blank",
|
|
1543
1833
|
...r,
|
|
1544
|
-
children: n ?? /* @__PURE__ */
|
|
1834
|
+
children: n ?? /* @__PURE__ */ $(Z, { children: [/* @__PURE__ */ Q(je, { className: "h-4 w-4" }), /* @__PURE__ */ Q("span", {
|
|
1545
1835
|
className: "block font-medium",
|
|
1546
1836
|
children: t
|
|
1547
1837
|
})] })
|
|
1548
1838
|
});
|
|
1549
1839
|
//#endregion
|
|
1550
1840
|
//#region src/ChatbotEnhanced.tsx
|
|
1551
|
-
function
|
|
1552
|
-
|
|
1841
|
+
function Ti(e) {
|
|
1842
|
+
let t = e ?? {}, n = t.data && typeof t.data == "object" ? t.data : t, r = n.seedApplied, i = n.probes;
|
|
1843
|
+
if (!r && !i) return;
|
|
1844
|
+
let a = {};
|
|
1845
|
+
return r && (r.success === !1 ? a.seedError = r.error ?? (Array.isArray(r.errors) && r.errors.length ? String(r.errors[0]) : "Sample data failed to load.") : a.seededRows = (r.inserted ?? 0) + (r.updated ?? 0)), i && (a.checked = {
|
|
1846
|
+
seeds: i.checked?.seeds ?? 0,
|
|
1847
|
+
views: i.checked?.views ?? 0,
|
|
1848
|
+
widgets: i.checked?.widgets ?? 0
|
|
1849
|
+
}, a.issues = (i.issues ?? []).filter((e) => e && typeof e.message == "string").map((e) => ({
|
|
1850
|
+
severity: e.severity === "error" ? "error" : "warning",
|
|
1851
|
+
code: String(e.code ?? "runtime_issue"),
|
|
1852
|
+
message: String(e.message)
|
|
1853
|
+
}))), a;
|
|
1553
1854
|
}
|
|
1554
|
-
function
|
|
1855
|
+
function Ei(e) {
|
|
1555
1856
|
return e === "user" ? "user" : "assistant";
|
|
1556
1857
|
}
|
|
1557
|
-
function
|
|
1858
|
+
function Di(e) {
|
|
1558
1859
|
let t = e.trim();
|
|
1559
1860
|
if (t.length < 2 || !(t.startsWith("{") || t.startsWith("[")) || !(t.endsWith("}") || t.endsWith("]"))) return !1;
|
|
1560
1861
|
try {
|
|
@@ -1563,271 +1864,1050 @@ function Hr(e) {
|
|
|
1563
1864
|
return !1;
|
|
1564
1865
|
}
|
|
1565
1866
|
}
|
|
1566
|
-
|
|
1567
|
-
let
|
|
1867
|
+
function Oi(e) {
|
|
1868
|
+
let t = e.state ?? (e.errorText ? "output-error" : e.result === void 0 ? "input-available" : "output-available");
|
|
1869
|
+
return t === "output-error" || t === "output-denied" ? "failed" : t === "approval-requested" || t === "approval-responded" ? "awaiting" : t === "output-available" ? "completed" : "running";
|
|
1870
|
+
}
|
|
1871
|
+
function ki(e) {
|
|
1872
|
+
let t = Oi(e);
|
|
1873
|
+
return t === "awaiting" || t === "failed" || !!e.pendingActionId || !!e.draftReview?.items.length || !!e.proposedPlan;
|
|
1874
|
+
}
|
|
1875
|
+
function Ai(e) {
|
|
1876
|
+
switch (e) {
|
|
1877
|
+
case "failed": return 4;
|
|
1878
|
+
case "awaiting": return 3;
|
|
1879
|
+
case "running": return 2;
|
|
1880
|
+
case "completed": return 1;
|
|
1881
|
+
}
|
|
1882
|
+
}
|
|
1883
|
+
function ji(e) {
|
|
1884
|
+
let t = /* @__PURE__ */ new Map();
|
|
1885
|
+
for (let n of e) {
|
|
1886
|
+
let e = Oi(n), r = `${n.toolName}:${e}`, i = t.get(r);
|
|
1887
|
+
if (i) {
|
|
1888
|
+
i.count += 1, i.errorText = i.errorText ?? n.errorText;
|
|
1889
|
+
continue;
|
|
1890
|
+
}
|
|
1891
|
+
t.set(r, {
|
|
1892
|
+
key: r,
|
|
1893
|
+
title: On(n.toolName) || n.toolName,
|
|
1894
|
+
rawName: n.toolName,
|
|
1895
|
+
count: 1,
|
|
1896
|
+
state: e,
|
|
1897
|
+
errorText: n.errorText
|
|
1898
|
+
});
|
|
1899
|
+
}
|
|
1900
|
+
return Array.from(t.values()).sort((e, t) => {
|
|
1901
|
+
let n = Ai(t.state) - Ai(e.state);
|
|
1902
|
+
return n === 0 ? e.title.localeCompare(t.title) : n;
|
|
1903
|
+
});
|
|
1904
|
+
}
|
|
1905
|
+
function Mi({ health: e }) {
|
|
1906
|
+
if (!e) return null;
|
|
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
|
+
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) {
|
|
1909
|
+
let e = [];
|
|
1910
|
+
i.views > 0 && e.push(`${i.views} view${i.views === 1 ? "" : "s"}`), i.widgets > 0 && e.push(`${i.widgets} widget${i.widgets === 1 ? "" : "s"}`), i.seeds > 0 && e.push(`${i.seeds} seed${i.seeds === 1 ? "" : "s"}`), e.length && o.push(`${e.join(" · ")} verified`);
|
|
1911
|
+
}
|
|
1912
|
+
return o.length === 0 && !e.seedError && t.length === 0 ? null : /* @__PURE__ */ $("div", {
|
|
1913
|
+
className: "flex flex-col gap-1 border-t bg-muted/20 px-3 py-2",
|
|
1914
|
+
"data-testid": "publish-health",
|
|
1915
|
+
children: [
|
|
1916
|
+
o.length > 0 ? /* @__PURE__ */ $("div", {
|
|
1917
|
+
className: "flex items-center gap-1.5 text-xs text-emerald-700",
|
|
1918
|
+
children: [/* @__PURE__ */ Q(Y, { className: "size-3.5 shrink-0" }), /* @__PURE__ */ Q("span", { children: o.join(" · ") })]
|
|
1919
|
+
}) : null,
|
|
1920
|
+
e.seedError ? /* @__PURE__ */ $("div", {
|
|
1921
|
+
className: "flex items-start gap-1.5 text-xs text-red-600",
|
|
1922
|
+
children: [/* @__PURE__ */ Q(X, { className: "mt-0.5 size-3.5 shrink-0" }), /* @__PURE__ */ Q("span", { children: e.seedError })]
|
|
1923
|
+
}) : null,
|
|
1924
|
+
n.map((e, t) => /* @__PURE__ */ $("div", {
|
|
1925
|
+
className: "flex items-start gap-1.5 text-xs text-red-600",
|
|
1926
|
+
children: [/* @__PURE__ */ Q(X, { className: "mt-0.5 size-3.5 shrink-0" }), /* @__PURE__ */ Q("span", { children: e.message })]
|
|
1927
|
+
}, `e${t}`)),
|
|
1928
|
+
r.map((e, t) => /* @__PURE__ */ $("div", {
|
|
1929
|
+
className: "flex items-start gap-1.5 text-xs text-amber-600",
|
|
1930
|
+
children: [/* @__PURE__ */ Q(Oe, { className: "mt-0.5 size-3.5 shrink-0" }), /* @__PURE__ */ Q("span", { children: e.message })]
|
|
1931
|
+
}, `w${t}`))
|
|
1932
|
+
]
|
|
1933
|
+
});
|
|
1934
|
+
}
|
|
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) => {
|
|
1960
|
+
if (V) try {
|
|
1961
|
+
let t = await V(e);
|
|
1962
|
+
Ae((n) => {
|
|
1963
|
+
if (n.get(e) === t) return n;
|
|
1964
|
+
let r = new Map(n);
|
|
1965
|
+
return r.set(e, t), r;
|
|
1966
|
+
});
|
|
1967
|
+
} catch {}
|
|
1968
|
+
}, [V]);
|
|
1969
|
+
e.useEffect(() => {
|
|
1970
|
+
if (!V || d) return;
|
|
1971
|
+
let e = /* @__PURE__ */ new Set();
|
|
1972
|
+
for (let t of n) for (let n of t.toolInvocations ?? []) {
|
|
1973
|
+
let t = n.draftReview?.packageId, r = n.toolCallId;
|
|
1974
|
+
t && r && !je.current.has(r) && (je.current.add(r), e.add(t));
|
|
1975
|
+
}
|
|
1976
|
+
for (let t of e) Ne(t);
|
|
1977
|
+
}, [
|
|
1978
|
+
n,
|
|
1979
|
+
d,
|
|
1980
|
+
V,
|
|
1981
|
+
Ne
|
|
1982
|
+
]);
|
|
1983
|
+
let Fe = e.useCallback(async (e) => {
|
|
1984
|
+
if (!I) return;
|
|
1985
|
+
let t = [];
|
|
1986
|
+
for (let r of n) for (let n of r.toolInvocations ?? []) n.draftReview?.packageId === e && n.toolCallId && t.push(n.toolCallId);
|
|
1987
|
+
let r = await I(e), i = r && typeof r == "object" ? r : void 0;
|
|
1988
|
+
if ((i ? i.ok !== !1 : r !== !1) && t.length > 0) {
|
|
1989
|
+
Te((e) => {
|
|
1990
|
+
let n = new Set(e);
|
|
1991
|
+
for (let e of t) n.add(e);
|
|
1992
|
+
return n;
|
|
1993
|
+
});
|
|
1994
|
+
let e = i?.health;
|
|
1995
|
+
e && De((n) => {
|
|
1996
|
+
let r = new Map(n);
|
|
1997
|
+
for (let n of t) r.set(n, e);
|
|
1998
|
+
return r;
|
|
1999
|
+
});
|
|
2000
|
+
}
|
|
2001
|
+
Ne(e);
|
|
2002
|
+
}, [
|
|
2003
|
+
I,
|
|
2004
|
+
n,
|
|
2005
|
+
Ne
|
|
2006
|
+
]), Ie = e.useRef(/* @__PURE__ */ new Set()), Le = e.useRef(!1);
|
|
2007
|
+
e.useEffect(() => {
|
|
2008
|
+
let e = [];
|
|
2009
|
+
for (let t of n) for (let n of t.toolInvocations ?? []) {
|
|
2010
|
+
let t = n.draftReview;
|
|
2011
|
+
t?.autoPublishable && t.packageId && n.toolCallId && t.items.length > 0 && e.push({
|
|
2012
|
+
key: n.toolCallId,
|
|
2013
|
+
packageId: t.packageId
|
|
2014
|
+
});
|
|
2015
|
+
}
|
|
2016
|
+
if (!Le.current) {
|
|
2017
|
+
Le.current = !0;
|
|
2018
|
+
for (let t of e) Ie.current.add(t.key);
|
|
2019
|
+
return;
|
|
2020
|
+
}
|
|
2021
|
+
if (!be || !I || d) return;
|
|
2022
|
+
let t = e.filter((e) => !Ie.current.has(e.key));
|
|
2023
|
+
if (t.length !== 0) {
|
|
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);
|
|
2026
|
+
}
|
|
2027
|
+
}, [
|
|
2028
|
+
n,
|
|
2029
|
+
d,
|
|
2030
|
+
be,
|
|
2031
|
+
I,
|
|
2032
|
+
Fe
|
|
2033
|
+
]);
|
|
2034
|
+
let Re = e.useRef(/* @__PURE__ */ new Set());
|
|
2035
|
+
e.useEffect(() => {
|
|
2036
|
+
if (!R) return;
|
|
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
|
+
}
|
|
2045
|
+
}
|
|
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);
|
|
2049
|
+
}, [n, R]);
|
|
2050
|
+
let ze = e.useRef(/* @__PURE__ */ new Set());
|
|
2051
|
+
e.useEffect(() => {
|
|
2052
|
+
if (z) for (let e of n) for (let t of e.toolInvocations ?? []) {
|
|
2053
|
+
let e = t.draftReview;
|
|
2054
|
+
if (!e?.materialized || !t.toolCallId) continue;
|
|
2055
|
+
let n = e.items.find((e) => e.type === "app");
|
|
2056
|
+
!n || ze.current.has(t.toolCallId) || (ze.current.add(t.toolCallId), z(n.name));
|
|
2057
|
+
}
|
|
2058
|
+
}, [n, z]);
|
|
2059
|
+
let Be = e.useCallback((e) => {
|
|
1568
2060
|
let t = !!e.text?.trim(), n = e.files?.map((e) => e.file).filter(Boolean), r = !!(n && n.length > 0);
|
|
1569
2061
|
(t || r) && i?.(e.text?.trim() ?? "", n);
|
|
1570
|
-
}, [i]),
|
|
2062
|
+
}, [i]), He = e.useCallback((e) => {
|
|
1571
2063
|
i?.(e);
|
|
1572
|
-
}, [i]),
|
|
1573
|
-
|
|
1574
|
-
}, [
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
2064
|
+
}, [i]), Ue = e.useRef(null), We = e.useCallback((e) => {
|
|
2065
|
+
i?.(e ? ve : _e);
|
|
2066
|
+
}, [
|
|
2067
|
+
i,
|
|
2068
|
+
_e,
|
|
2069
|
+
ve
|
|
2070
|
+
]), Ke = e.useCallback(() => {
|
|
2071
|
+
let e = Ue.current?.querySelector("textarea");
|
|
2072
|
+
e && (e.focus(), e.scrollIntoView({ block: "nearest" }));
|
|
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", {
|
|
2085
|
+
className: "inline-flex items-center gap-2",
|
|
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
|
+
]
|
|
2094
|
+
});
|
|
2095
|
+
return /* @__PURE__ */ $(oi, {
|
|
2096
|
+
defaultOpen: t === "output-error" || t === "approval-requested" || !!(e.draftReview && e.draftReview.items.length > 0) || !!e.proposedPlan,
|
|
2097
|
+
children: [/* @__PURE__ */ Q(ci, {
|
|
2098
|
+
type: n,
|
|
2099
|
+
state: t,
|
|
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, {
|
|
2104
|
+
output: c,
|
|
2105
|
+
errorText: e.errorText
|
|
2106
|
+
}) : null,
|
|
2107
|
+
r ? /* @__PURE__ */ $("div", {
|
|
2108
|
+
className: "flex items-center gap-2 p-3 border-t text-xs " + (r.state === "error" ? "bg-destructive/10 text-destructive" : r.state === "success" ? "bg-emerald-500/10 text-emerald-700 dark:text-emerald-400" : "bg-muted/30 text-muted-foreground"),
|
|
2109
|
+
children: [/* @__PURE__ */ Q("span", {
|
|
2110
|
+
"aria-hidden": "true",
|
|
2111
|
+
children: r.state === "pending" ? "..." : r.state === "success" ? "OK" : "X"
|
|
2112
|
+
}), /* @__PURE__ */ Q("span", { children: r.message ?? (r.state === "pending" ? "Submitting decision..." : r.state === "success" ? "Action approved and executed." : "Decision failed.") })]
|
|
2113
|
+
}) : null,
|
|
2114
|
+
a ? /* @__PURE__ */ $("div", {
|
|
2115
|
+
className: "flex gap-2 p-3 border-t bg-muted/30",
|
|
2116
|
+
children: [/* @__PURE__ */ Q("button", {
|
|
2117
|
+
type: "button",
|
|
2118
|
+
onClick: () => N?.(e.toolCallId, !0),
|
|
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",
|
|
2120
|
+
children: ee
|
|
2121
|
+
}), /* @__PURE__ */ Q("button", {
|
|
2122
|
+
type: "button",
|
|
2123
|
+
onClick: () => N?.(e.toolCallId, !1, P),
|
|
2124
|
+
className: "inline-flex h-7 items-center rounded-md border bg-background px-3 text-xs font-medium hover:bg-accent",
|
|
2125
|
+
children: te
|
|
2126
|
+
})]
|
|
2127
|
+
}) : null,
|
|
2128
|
+
e.draftReview && e.draftReview.items.length > 0 && (ne || I && e.draftReview.packageId) ? /* @__PURE__ */ $(Z, { children: [
|
|
2129
|
+
/* @__PURE__ */ $("div", {
|
|
2130
|
+
className: "flex items-center gap-2 p-3 border-t bg-muted/30",
|
|
2131
|
+
children: [
|
|
2132
|
+
I && e.draftReview.packageId ? p ? /* @__PURE__ */ $("span", {
|
|
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",
|
|
2134
|
+
children: [
|
|
2135
|
+
/* @__PURE__ */ Q(Y, { className: "size-3.5" }),
|
|
2136
|
+
se,
|
|
2137
|
+
e.draftReview.failedCount ? ` · ${e.draftReview.failedCount} need${e.draftReview.failedCount === 1 ? "s" : ""} attention` : ""
|
|
2138
|
+
]
|
|
2139
|
+
}) : /* @__PURE__ */ $("button", {
|
|
2140
|
+
type: "button",
|
|
2141
|
+
onClick: () => void Fe(e.draftReview.packageId),
|
|
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",
|
|
2143
|
+
"data-testid": "draft-publish",
|
|
2144
|
+
children: [
|
|
2145
|
+
/* @__PURE__ */ Q(ct, { className: "size-3.5" }),
|
|
2146
|
+
B,
|
|
2147
|
+
typeof f == "number" && f > 0 ? ` (${f})` : ""
|
|
2148
|
+
]
|
|
2149
|
+
}) : null,
|
|
2150
|
+
ne ? /* @__PURE__ */ $("button", {
|
|
2151
|
+
type: "button",
|
|
2152
|
+
onClick: () => ne(e.draftReview.items),
|
|
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",
|
|
2154
|
+
children: [/* @__PURE__ */ Q(Xe, { className: "size-3.5" }), re(e.draftReview.items.length)]
|
|
2155
|
+
}) : null,
|
|
2156
|
+
L && !p ? (() => {
|
|
2157
|
+
let t = e.draftReview.items.find((e) => e.type === "app");
|
|
2158
|
+
return t ? /* @__PURE__ */ $("button", {
|
|
2159
|
+
type: "button",
|
|
2160
|
+
onClick: () => L(t.name, {
|
|
2161
|
+
materialized: e.draftReview.materialized === !0,
|
|
2162
|
+
appSegment: e.draftReview.packageId
|
|
2163
|
+
}),
|
|
2164
|
+
className: "inline-flex h-7 items-center gap-1.5 rounded-md border px-3 text-xs font-medium hover:bg-muted",
|
|
2165
|
+
"data-testid": "draft-preview-app",
|
|
2166
|
+
children: [/* @__PURE__ */ Q(Ye, { className: "size-3.5" }), oe]
|
|
2167
|
+
}) : null;
|
|
2168
|
+
})() : null,
|
|
2169
|
+
e.draftReview.verification ? e.draftReview.verification.errors > 0 ? /* @__PURE__ */ $("span", {
|
|
2170
|
+
className: "inline-flex h-7 shrink-0 items-center gap-1.5 rounded-md border border-amber-200 bg-amber-50 px-2.5 text-xs font-medium text-amber-700",
|
|
2171
|
+
"data-testid": "draft-verification-chip",
|
|
2172
|
+
children: [/* @__PURE__ */ Q(pt, { className: "size-3.5" }), `${e.draftReview.verification.errors} issue${e.draftReview.verification.errors === 1 ? "" : "s"}`]
|
|
2173
|
+
}) : /* @__PURE__ */ $("span", {
|
|
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",
|
|
2175
|
+
"data-testid": "draft-verification-chip",
|
|
2176
|
+
children: [/* @__PURE__ */ Q(ut, { className: "size-3.5" }), ce]
|
|
2177
|
+
}) : null,
|
|
2178
|
+
e.draftReview.summary ? /* @__PURE__ */ Q("span", {
|
|
2179
|
+
className: "truncate text-xs text-muted-foreground",
|
|
2180
|
+
children: e.draftReview.summary
|
|
2181
|
+
}) : null
|
|
2182
|
+
]
|
|
2183
|
+
}),
|
|
2184
|
+
e.draftReview.issues && e.draftReview.issues.length > 0 ? /* @__PURE__ */ $("div", {
|
|
2185
|
+
className: "flex flex-col gap-1 border-t bg-muted/20 px-3 py-2",
|
|
2186
|
+
"data-testid": "draft-issues",
|
|
2187
|
+
children: [e.draftReview.issues.filter((e) => e.severity === "error").map((e, t) => /* @__PURE__ */ $("div", {
|
|
2188
|
+
className: "flex items-start gap-1.5 text-xs text-red-600",
|
|
2189
|
+
children: [/* @__PURE__ */ Q(X, { className: "mt-0.5 size-3.5 shrink-0" }), /* @__PURE__ */ Q("span", { children: e.fix ? `${e.message} — ${e.fix}` : e.message })]
|
|
2190
|
+
}, `e${t}`)), e.draftReview.issues.filter((e) => e.severity !== "error").map((e, t) => /* @__PURE__ */ $("div", {
|
|
2191
|
+
className: "flex items-start gap-1.5 text-xs text-amber-600",
|
|
2192
|
+
children: [/* @__PURE__ */ Q(Oe, { className: "mt-0.5 size-3.5 shrink-0" }), /* @__PURE__ */ Q("span", { children: e.message })]
|
|
2193
|
+
}, `w${t}`))]
|
|
2194
|
+
}) : null,
|
|
2195
|
+
we.has(e.toolCallId) ? /* @__PURE__ */ Q(Mi, { health: Ee.get(e.toolCallId) }) : null,
|
|
2196
|
+
e.draftReview.nextSteps && e.draftReview.nextSteps.length > 0 ? /* @__PURE__ */ $("div", {
|
|
2197
|
+
className: "flex flex-col gap-1 border-t bg-muted/20 px-3 py-2",
|
|
2198
|
+
"data-testid": "draft-next-steps",
|
|
2199
|
+
children: [/* @__PURE__ */ Q("span", {
|
|
2200
|
+
className: "text-xs font-medium text-foreground/80",
|
|
2201
|
+
children: le
|
|
2202
|
+
}), e.draftReview.nextSteps.map((e, t) => /* @__PURE__ */ $("div", {
|
|
2203
|
+
className: "flex items-start gap-1.5 text-xs text-muted-foreground",
|
|
2204
|
+
children: [/* @__PURE__ */ Q("span", {
|
|
2205
|
+
className: "mt-px shrink-0 text-foreground/40",
|
|
2206
|
+
children: "→"
|
|
2207
|
+
}), /* @__PURE__ */ Q("span", { children: e })]
|
|
2208
|
+
}, t))]
|
|
2209
|
+
}) : null
|
|
2210
|
+
] }) : null,
|
|
2211
|
+
e.proposedPlan ? /* @__PURE__ */ $("div", {
|
|
2212
|
+
className: "flex flex-col gap-2 border-t bg-muted/20 px-3 py-2.5",
|
|
2213
|
+
"data-testid": "proposed-plan",
|
|
1585
2214
|
children: [
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
2215
|
+
/* @__PURE__ */ $("span", {
|
|
2216
|
+
className: "inline-flex items-center gap-1.5 text-xs font-medium text-foreground/80",
|
|
2217
|
+
children: [/* @__PURE__ */ Q(Ve, { className: "size-3.5" }), ue]
|
|
2218
|
+
}),
|
|
2219
|
+
e.proposedPlan.summary ? /* @__PURE__ */ Q("p", {
|
|
2220
|
+
className: "text-xs text-muted-foreground",
|
|
2221
|
+
children: e.proposedPlan.summary
|
|
2222
|
+
}) : null,
|
|
2223
|
+
e.proposedPlan.objects.length > 0 ? /* @__PURE__ */ Q("div", {
|
|
2224
|
+
className: "flex flex-wrap gap-1.5",
|
|
2225
|
+
children: e.proposedPlan.objects.map((e) => /* @__PURE__ */ $("span", {
|
|
2226
|
+
className: "inline-flex items-center gap-1 rounded-md border bg-background px-1.5 py-0.5 text-[11px] text-foreground/80",
|
|
2227
|
+
title: e.name,
|
|
2228
|
+
children: [
|
|
2229
|
+
/* @__PURE__ */ Q(ft, { className: "size-3 text-foreground/40" }),
|
|
2230
|
+
e.label || e.name,
|
|
2231
|
+
e.fieldCount > 0 ? /* @__PURE__ */ $("span", {
|
|
2232
|
+
className: "text-foreground/40",
|
|
2233
|
+
children: ["· ", e.fieldCount]
|
|
2234
|
+
}) : null
|
|
2235
|
+
]
|
|
2236
|
+
}, e.name))
|
|
2237
|
+
}) : null,
|
|
2238
|
+
(() => {
|
|
2239
|
+
let t = e.proposedPlan.counts, n = [];
|
|
2240
|
+
return t.objects && n.push(`${t.objects} object${t.objects === 1 ? "" : "s"}`), t.views && n.push(`${t.views} view${t.views === 1 ? "" : "s"}`), t.dashboards && n.push(`${t.dashboards} dashboard${t.dashboards === 1 ? "" : "s"}`), t.seedData && n.push("sample data"), n.length ? /* @__PURE__ */ Q("span", {
|
|
2241
|
+
className: "text-[11px] text-muted-foreground",
|
|
2242
|
+
children: n.join(" · ")
|
|
2243
|
+
}) : null;
|
|
2244
|
+
})(),
|
|
2245
|
+
e.proposedPlan.assumptions.length > 0 ? /* @__PURE__ */ $("div", {
|
|
2246
|
+
className: "flex flex-col gap-0.5",
|
|
2247
|
+
children: [/* @__PURE__ */ Q("span", {
|
|
2248
|
+
className: "text-[11px] font-medium text-foreground/70",
|
|
2249
|
+
children: fe
|
|
2250
|
+
}), e.proposedPlan.assumptions.map((e, t) => /* @__PURE__ */ $("div", {
|
|
2251
|
+
className: "flex items-start gap-1.5 text-[11px] text-muted-foreground",
|
|
2252
|
+
children: [/* @__PURE__ */ Q("span", {
|
|
2253
|
+
className: "mt-px shrink-0 text-foreground/40",
|
|
2254
|
+
children: "·"
|
|
2255
|
+
}), /* @__PURE__ */ Q("span", { children: e })]
|
|
2256
|
+
}, t))]
|
|
2257
|
+
}) : null,
|
|
2258
|
+
e.proposedPlan.questions.length > 0 ? /* @__PURE__ */ $("div", {
|
|
2259
|
+
className: "flex flex-col gap-1 rounded-md border border-amber-200 bg-amber-50 px-2 py-1.5 dark:border-amber-900/50 dark:bg-amber-950/30",
|
|
2260
|
+
"data-testid": "proposed-plan-questions",
|
|
2261
|
+
children: [/* @__PURE__ */ $("span", {
|
|
2262
|
+
className: "inline-flex items-center gap-1.5 text-[11px] font-medium text-amber-800 dark:text-amber-300",
|
|
2263
|
+
children: [/* @__PURE__ */ Q(Ze, { className: "size-3.5" }), de]
|
|
2264
|
+
}), e.proposedPlan.questions.map((t, n) => {
|
|
2265
|
+
let r = e.proposedPlan.questionChoices?.find((e) => e.text === t);
|
|
2266
|
+
return /* @__PURE__ */ $("div", {
|
|
2267
|
+
className: "flex flex-col gap-1",
|
|
2268
|
+
children: [/* @__PURE__ */ $("div", {
|
|
2269
|
+
className: "flex items-start gap-1.5 text-[11px] text-amber-900/90 dark:text-amber-200/90",
|
|
2270
|
+
children: [/* @__PURE__ */ Q("span", {
|
|
2271
|
+
className: "mt-px shrink-0",
|
|
2272
|
+
children: "?"
|
|
2273
|
+
}), /* @__PURE__ */ Q("span", { children: t })]
|
|
2274
|
+
}), i && r && r.options.length > 0 ? /* @__PURE__ */ Q("div", {
|
|
2275
|
+
className: "flex flex-wrap gap-1 pl-3.5",
|
|
2276
|
+
"data-testid": "proposed-plan-choice",
|
|
2277
|
+
children: r.options.map((e, n) => /* @__PURE__ */ Q("button", {
|
|
2278
|
+
type: "button",
|
|
2279
|
+
onClick: () => i(ye(t, e)),
|
|
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",
|
|
2281
|
+
children: e
|
|
2282
|
+
}, n))
|
|
2283
|
+
}) : null]
|
|
2284
|
+
}, n);
|
|
2285
|
+
})]
|
|
2286
|
+
}) : null,
|
|
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", {
|
|
2296
|
+
className: "flex flex-wrap items-center gap-1.5 pt-0.5",
|
|
2297
|
+
"data-testid": "proposed-plan-actions",
|
|
2298
|
+
children: [/* @__PURE__ */ $("button", {
|
|
2299
|
+
type: "button",
|
|
2300
|
+
onClick: () => We(e.proposedPlan.questions.length > 0),
|
|
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",
|
|
2302
|
+
"data-testid": "proposed-plan-approve",
|
|
2303
|
+
children: [/* @__PURE__ */ Q(ct, { className: "size-3.5" }), me]
|
|
2304
|
+
}), /* @__PURE__ */ Q("button", {
|
|
2305
|
+
type: "button",
|
|
2306
|
+
onClick: Ke,
|
|
2307
|
+
className: "inline-flex h-7 items-center rounded-md border bg-background px-3 text-xs font-medium hover:bg-accent",
|
|
2308
|
+
"data-testid": "proposed-plan-adjust",
|
|
2309
|
+
children: he
|
|
2310
|
+
})]
|
|
2311
|
+
}) : /* @__PURE__ */ Q("span", {
|
|
2312
|
+
className: "text-[11px] italic text-muted-foreground/80",
|
|
2313
|
+
children: pe
|
|
2314
|
+
})
|
|
1589
2315
|
]
|
|
1590
|
-
})
|
|
2316
|
+
}) : null
|
|
2317
|
+
] })]
|
|
2318
|
+
}, e.toolCallId);
|
|
2319
|
+
};
|
|
2320
|
+
return /* @__PURE__ */ $("div", {
|
|
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,
|
|
2325
|
+
children: [
|
|
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"),
|
|
2328
|
+
children: /* @__PURE__ */ Q("button", {
|
|
1591
2329
|
type: "button",
|
|
1592
2330
|
onClick: a,
|
|
1593
2331
|
className: "text-xs text-muted-foreground hover:text-foreground transition-colors",
|
|
1594
|
-
children:
|
|
1595
|
-
})
|
|
2332
|
+
children: q.clear
|
|
2333
|
+
})
|
|
1596
2334
|
}),
|
|
1597
|
-
|
|
1598
|
-
className: "shrink-0 border-b bg-background/50",
|
|
1599
|
-
children:
|
|
2335
|
+
A ? /* @__PURE__ */ Q("div", {
|
|
2336
|
+
className: J("shrink-0", !K && "border-b bg-background/50"),
|
|
2337
|
+
children: A
|
|
1600
2338
|
}) : null,
|
|
1601
|
-
/* @__PURE__ */
|
|
2339
|
+
/* @__PURE__ */ $(Nn, {
|
|
1602
2340
|
className: "flex-1 min-h-0",
|
|
1603
|
-
children: [/* @__PURE__ */
|
|
1604
|
-
className: "space-y-4 px-4 py-3",
|
|
1605
|
-
children: n.length === 0 ? /* @__PURE__ */
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
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, {
|
|
2344
|
+
className: "gap-3 px-0 py-8",
|
|
2345
|
+
children: [
|
|
2346
|
+
/* @__PURE__ */ Q("div", {
|
|
2347
|
+
className: "flex size-9 items-center justify-center rounded-md bg-muted/70 text-muted-foreground",
|
|
2348
|
+
children: _ ? /* @__PURE__ */ Q("img", {
|
|
2349
|
+
src: _,
|
|
2350
|
+
alt: "",
|
|
2351
|
+
className: "size-full rounded-md object-cover"
|
|
2352
|
+
}) : /* @__PURE__ */ Q(Me, { className: "size-4" })
|
|
2353
|
+
}),
|
|
2354
|
+
/* @__PURE__ */ $("div", {
|
|
2355
|
+
className: "space-y-1",
|
|
2356
|
+
children: [/* @__PURE__ */ Q("h3", {
|
|
2357
|
+
className: "text-sm font-medium text-foreground/90",
|
|
2358
|
+
children: q.emptyTitle
|
|
2359
|
+
}), /* @__PURE__ */ Q("p", {
|
|
2360
|
+
className: "text-sm text-muted-foreground",
|
|
2361
|
+
children: q.emptyDescription
|
|
2362
|
+
})]
|
|
2363
|
+
}),
|
|
2364
|
+
T && T.length > 0 ? /* @__PURE__ */ Q($r, {
|
|
2365
|
+
className: "justify-center gap-2",
|
|
2366
|
+
children: T.map((e) => /* @__PURE__ */ Q(ei, {
|
|
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",
|
|
2368
|
+
suggestion: e,
|
|
2369
|
+
onClick: He
|
|
2370
|
+
}, e))
|
|
2371
|
+
}) : null
|
|
2372
|
+
]
|
|
1615
2373
|
}) : n.map((e) => {
|
|
1616
|
-
let t = e.role === "user", n = e.toolInvocations ?? [], r = e.reasoning?.trim(), i = e.sources ?? [];
|
|
1617
|
-
return /* @__PURE__ */
|
|
1618
|
-
from:
|
|
1619
|
-
children:
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
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),
|
|
2377
|
+
children: /* @__PURE__ */ $("div", {
|
|
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, {
|
|
2380
|
+
isUser: t,
|
|
2381
|
+
url: t ? h : _,
|
|
2382
|
+
fallback: t ? g : v
|
|
2383
|
+
}) : null, /* @__PURE__ */ $("div", {
|
|
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, {
|
|
2387
|
+
progress: a,
|
|
2388
|
+
onOpenBuiltApp: ie,
|
|
2389
|
+
openBuiltAppLabel: ae,
|
|
2390
|
+
onPreviewDraftApp: L,
|
|
2391
|
+
previewDraftLabel: oe,
|
|
2392
|
+
waitingLabel: q.connectionWaiting,
|
|
2393
|
+
stalledLabel: q.connectionStalledLabel,
|
|
2394
|
+
offlineLabel: q.connectionOfflineLabel
|
|
2395
|
+
}) : null,
|
|
2396
|
+
!t && H === "debug" && r ? /* @__PURE__ */ $(_i, {
|
|
2397
|
+
isStreaming: !!e.streaming && !e.content,
|
|
2398
|
+
className: "mb-2",
|
|
2399
|
+
children: [/* @__PURE__ */ Q(yi, {}), /* @__PURE__ */ Q(bi, { children: r })]
|
|
2400
|
+
}) : null,
|
|
2401
|
+
!t && H === "summary" && c.length > 0 ? /* @__PURE__ */ Q(Ki, {
|
|
2402
|
+
groups: ji(c),
|
|
2403
|
+
labels: q
|
|
2404
|
+
}) : null,
|
|
2405
|
+
!t && l.length > 0 ? l.map($e) : null,
|
|
2406
|
+
t ? e.content ? /* @__PURE__ */ Q("div", {
|
|
2407
|
+
className: "whitespace-pre-wrap break-words",
|
|
2408
|
+
children: e.content
|
|
2409
|
+
}) : null : o ? /* @__PURE__ */ Q(Ii, {}) : e.content ? /* @__PURE__ */ Q(Qn, { children: e.content }) : null,
|
|
2410
|
+
e.streaming && !o ? /* @__PURE__ */ Q("span", {
|
|
2411
|
+
"aria-hidden": !0,
|
|
2412
|
+
className: "ml-0.5 inline-block w-[2px] h-4 align-middle bg-current animate-pulse"
|
|
2413
|
+
}) : null,
|
|
2414
|
+
!t && (e.charts?.length ?? 0) > 0 ? /* @__PURE__ */ Q("div", {
|
|
2415
|
+
className: "mt-2 flex flex-col gap-3",
|
|
2416
|
+
"data-testid": "chat-charts",
|
|
2417
|
+
children: e.charts.map((e, t) => /* @__PURE__ */ $("div", {
|
|
2418
|
+
className: "rounded-lg border bg-background p-3",
|
|
2419
|
+
style: { width: "min(520px, 80vw)" },
|
|
2420
|
+
"data-testid": "chat-chart",
|
|
2421
|
+
children: [e.title ? /* @__PURE__ */ Q("div", {
|
|
2422
|
+
className: "mb-2 text-sm font-medium text-foreground",
|
|
2423
|
+
children: e.title
|
|
2424
|
+
}) : null, /* @__PURE__ */ Q(St, { schema: {
|
|
2425
|
+
type: "chart",
|
|
2426
|
+
chartType: e.chartType ?? "bar",
|
|
2427
|
+
data: e.data,
|
|
2428
|
+
xAxisKey: e.xAxisKey,
|
|
2429
|
+
series: e.series
|
|
2430
|
+
} })]
|
|
2431
|
+
}, t))
|
|
2432
|
+
}) : null,
|
|
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, {
|
|
2434
|
+
href: e.url,
|
|
2435
|
+
title: e.title ?? e.url
|
|
2436
|
+
}, e.id ?? e.url ?? t)) })] }) : null,
|
|
2437
|
+
p && e.timestamp ? /* @__PURE__ */ Q("div", {
|
|
2438
|
+
className: "text-[10px] opacity-70 mt-1",
|
|
2439
|
+
children: e.timestamp
|
|
2440
|
+
}) : null
|
|
2441
|
+
] }), !t && !o ? /* @__PURE__ */ $(Hn, {
|
|
2442
|
+
className: "opacity-0 transition-opacity group-focus-within:opacity-100 group-hover:opacity-100",
|
|
2443
|
+
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" })
|
|
1644
2449
|
}),
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
}), /* @__PURE__ */ K("span", { children: r.message ?? (r.state === "pending" ? "Submitting decision…" : r.state === "success" ? "Action approved and executed." : "Decision failed.") })]
|
|
2450
|
+
s ? /* @__PURE__ */ Q(Un, {
|
|
2451
|
+
label: q.regenerate,
|
|
2452
|
+
tooltip: q.regenerate,
|
|
2453
|
+
onClick: s,
|
|
2454
|
+
children: /* @__PURE__ */ Q(st, { className: "size-3.5" })
|
|
1651
2455
|
}) : null,
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
children: k
|
|
1659
|
-
}), /* @__PURE__ */ K("button", {
|
|
1660
|
-
type: "button",
|
|
1661
|
-
onClick: () => O?.(e.toolCallId, !1, j),
|
|
1662
|
-
className: "inline-flex h-7 items-center rounded-md border bg-background px-3 text-xs font-medium hover:bg-accent",
|
|
1663
|
-
children: A
|
|
1664
|
-
})]
|
|
2456
|
+
H === "debug" && e.traceId ? /* @__PURE__ */ Q("a", {
|
|
2457
|
+
href: `#trace/${e.traceId}`,
|
|
2458
|
+
"data-trace-id": e.traceId,
|
|
2459
|
+
className: "text-[10px] text-muted-foreground hover:text-foreground ml-1 underline",
|
|
2460
|
+
title: q.viewTrace,
|
|
2461
|
+
children: q.trace
|
|
1665
2462
|
}) : null
|
|
1666
|
-
]
|
|
1667
|
-
}
|
|
1668
|
-
})
|
|
1669
|
-
|
|
1670
|
-
className: "whitespace-pre-wrap break-words",
|
|
1671
|
-
children: e.content
|
|
1672
|
-
}) : null : e.content ? /* @__PURE__ */ K(X, { children: e.content }) : null,
|
|
1673
|
-
e.streaming ? /* @__PURE__ */ K("span", {
|
|
1674
|
-
"aria-hidden": !0,
|
|
1675
|
-
className: "ml-0.5 inline-block w-[2px] h-4 align-middle bg-current animate-pulse"
|
|
1676
|
-
}) : null,
|
|
1677
|
-
!t && i.length > 0 ? /* @__PURE__ */ q(Ir, { children: [/* @__PURE__ */ K(Lr, { count: i.length }), /* @__PURE__ */ K(Rr, { children: i.map((e, t) => /* @__PURE__ */ K(zr, {
|
|
1678
|
-
href: e.url,
|
|
1679
|
-
title: e.title ?? e.url
|
|
1680
|
-
}, e.id ?? e.url ?? t)) })] }) : null,
|
|
1681
|
-
d && e.timestamp ? /* @__PURE__ */ K("div", {
|
|
1682
|
-
className: "text-[10px] opacity-70 mt-1",
|
|
1683
|
-
children: e.timestamp
|
|
1684
|
-
}) : null
|
|
1685
|
-
] }), t ? null : /* @__PURE__ */ q(sn, { children: [
|
|
1686
|
-
/* @__PURE__ */ K(cn, {
|
|
1687
|
-
label: "Copy",
|
|
1688
|
-
tooltip: "Copy",
|
|
1689
|
-
onClick: () => ne(e),
|
|
1690
|
-
children: I === e.id ? /* @__PURE__ */ K(ze, { className: "size-3.5" }) : /* @__PURE__ */ K(Ye, { className: "size-3.5" })
|
|
1691
|
-
}),
|
|
1692
|
-
s ? /* @__PURE__ */ K(cn, {
|
|
1693
|
-
label: "Regenerate",
|
|
1694
|
-
tooltip: "Regenerate",
|
|
1695
|
-
onClick: s,
|
|
1696
|
-
children: /* @__PURE__ */ K(ct, { className: "size-3.5" })
|
|
1697
|
-
}) : null,
|
|
1698
|
-
e.traceId ? /* @__PURE__ */ K("a", {
|
|
1699
|
-
href: `#trace/${e.traceId}`,
|
|
1700
|
-
"data-trace-id": e.traceId,
|
|
1701
|
-
className: "text-[10px] text-muted-foreground hover:text-foreground ml-1 underline",
|
|
1702
|
-
title: "View trace",
|
|
1703
|
-
children: "trace"
|
|
1704
|
-
}) : null
|
|
1705
|
-
] })]
|
|
2463
|
+
]
|
|
2464
|
+
}) : null]
|
|
2465
|
+
})]
|
|
2466
|
+
})
|
|
1706
2467
|
}, e.id);
|
|
1707
|
-
})
|
|
1708
|
-
|
|
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
|
|
2475
|
+
}) : null]
|
|
2476
|
+
}), /* @__PURE__ */ Q(In, {})]
|
|
1709
2477
|
}),
|
|
1710
|
-
|
|
1711
|
-
error:
|
|
1712
|
-
onReload: s
|
|
2478
|
+
f ? /* @__PURE__ */ Q(Yi, {
|
|
2479
|
+
error: f,
|
|
2480
|
+
onReload: s,
|
|
2481
|
+
onUpgrade: c
|
|
1713
2482
|
}) : null,
|
|
1714
|
-
/* @__PURE__ */
|
|
1715
|
-
|
|
1716
|
-
|
|
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", {
|
|
1717
2487
|
className: "absolute bottom-full left-0 right-0 z-10 px-3 pb-1",
|
|
1718
|
-
children:
|
|
1719
|
-
}) : null, /* @__PURE__ */
|
|
1720
|
-
accept:
|
|
1721
|
-
|
|
1722
|
-
|
|
2488
|
+
children: j
|
|
2489
|
+
}) : null, /* @__PURE__ */ $(br, {
|
|
2490
|
+
accept: C,
|
|
2491
|
+
fileInputLabel: q.uploadFiles,
|
|
2492
|
+
maxFileSize: w,
|
|
2493
|
+
onSubmit: Be,
|
|
1723
2494
|
onError: (e) => {
|
|
1724
2495
|
console.warn("[plugin-chatbot] prompt-input error", e);
|
|
1725
2496
|
},
|
|
1726
2497
|
children: [
|
|
1727
|
-
|
|
1728
|
-
/* @__PURE__ */
|
|
2498
|
+
S ? /* @__PURE__ */ Q(xr, { children: /* @__PURE__ */ Q(vr, { children: (e) => /* @__PURE__ */ Q(_r, { data: e }) }) }) : null,
|
|
2499
|
+
/* @__PURE__ */ Q(Sr, {
|
|
1729
2500
|
placeholder: r,
|
|
1730
|
-
disabled:
|
|
1731
|
-
onChange:
|
|
2501
|
+
disabled: l || G === "streaming",
|
|
2502
|
+
onChange: M ? (e) => M(e.currentTarget.value) : void 0
|
|
1732
2503
|
}),
|
|
1733
|
-
/* @__PURE__ */
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
"aria-label":
|
|
1737
|
-
value:
|
|
1738
|
-
onChange: (e) =>
|
|
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", {
|
|
2507
|
+
"aria-label": q.model,
|
|
2508
|
+
value: O ?? D[0].id,
|
|
2509
|
+
onChange: (e) => k?.(e.target.value),
|
|
1739
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",
|
|
1740
|
-
children:
|
|
2511
|
+
children: D.map((e) => /* @__PURE__ */ $("option", {
|
|
1741
2512
|
value: e.id,
|
|
1742
2513
|
children: [e.label ?? e.id, e.provider ? ` · ${e.provider}` : ""]
|
|
1743
2514
|
}, e.id))
|
|
1744
2515
|
}) : null,
|
|
1745
|
-
/* @__PURE__ */
|
|
2516
|
+
/* @__PURE__ */ $("span", {
|
|
1746
2517
|
className: "hidden items-center gap-1 text-[10px] text-muted-foreground sm:inline-flex",
|
|
1747
2518
|
"aria-hidden": "true",
|
|
1748
2519
|
children: [
|
|
1749
|
-
/* @__PURE__ */
|
|
2520
|
+
/* @__PURE__ */ Q("kbd", {
|
|
1750
2521
|
className: "inline-flex h-4 items-center rounded border bg-muted px-1 font-mono text-[10px] leading-none",
|
|
1751
2522
|
children: "⌘"
|
|
1752
2523
|
}),
|
|
1753
|
-
/* @__PURE__ */
|
|
1754
|
-
/* @__PURE__ */
|
|
2524
|
+
/* @__PURE__ */ Q(qe, { className: "h-3 w-3" }),
|
|
2525
|
+
/* @__PURE__ */ Q("span", {
|
|
1755
2526
|
className: "opacity-70",
|
|
1756
|
-
children:
|
|
2527
|
+
children: q.sendHint
|
|
1757
2528
|
})
|
|
1758
2529
|
]
|
|
1759
2530
|
})
|
|
1760
|
-
] }), /* @__PURE__ */
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
2531
|
+
] }), /* @__PURE__ */ Q(jr, {
|
|
2532
|
+
"aria-label": G === "streaming" ? q.stopResponse : q.submit,
|
|
2533
|
+
status: G,
|
|
2534
|
+
disabled: l,
|
|
2535
|
+
onClick: G === "streaming" ? o : void 0,
|
|
2536
|
+
type: G === "streaming" ? "button" : "submit"
|
|
1764
2537
|
})] })
|
|
1765
2538
|
]
|
|
1766
2539
|
})]
|
|
1767
|
-
}),
|
|
1768
|
-
/* @__PURE__ */ K("span", {
|
|
1769
|
-
hidden: !0,
|
|
1770
|
-
"data-avatar-user": f ?? p,
|
|
1771
|
-
"data-avatar-assistant": m ?? h
|
|
1772
2540
|
})
|
|
1773
2541
|
]
|
|
1774
2542
|
});
|
|
1775
2543
|
});
|
|
1776
|
-
|
|
1777
|
-
function
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
2544
|
+
Ni.displayName = "ChatbotEnhanced";
|
|
2545
|
+
function Pi({ isUser: e, url: t, fallback: n }) {
|
|
2546
|
+
return /* @__PURE__ */ Q("div", {
|
|
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"),
|
|
2548
|
+
"aria-hidden": "true",
|
|
2549
|
+
children: t ? /* @__PURE__ */ Q("img", {
|
|
2550
|
+
src: t,
|
|
2551
|
+
alt: "",
|
|
2552
|
+
className: "size-full object-cover"
|
|
2553
|
+
}) : e ? n?.trim()?.charAt(0)?.toUpperCase() || "U" : /* @__PURE__ */ Q(Me, { className: "size-4" })
|
|
2554
|
+
});
|
|
2555
|
+
}
|
|
2556
|
+
function Fi({ showAvatar: e, assistantAvatarUrl: t, assistantAvatarFallback: n, waitingLabel: r, stalledLabel: i, offlineLabel: a }) {
|
|
2557
|
+
return /* @__PURE__ */ Q(Bn, {
|
|
2558
|
+
from: "assistant",
|
|
2559
|
+
"aria-live": "polite",
|
|
2560
|
+
children: /* @__PURE__ */ $("div", {
|
|
2561
|
+
className: J("flex w-full gap-2.5", e ? "flex-row items-start" : "flex-col"),
|
|
2562
|
+
children: [e ? /* @__PURE__ */ Q(Pi, {
|
|
2563
|
+
isUser: !1,
|
|
2564
|
+
url: t,
|
|
2565
|
+
fallback: n
|
|
2566
|
+
}) : null, /* @__PURE__ */ Q(Vn, {
|
|
2567
|
+
className: "rounded-lg border bg-muted/30 px-3 py-2 text-muted-foreground",
|
|
2568
|
+
children: /* @__PURE__ */ $("span", {
|
|
2569
|
+
className: "inline-flex items-center gap-2",
|
|
2570
|
+
children: [/* @__PURE__ */ Q(Ii, {}), /* @__PURE__ */ Q(Vi, {
|
|
2571
|
+
active: !0,
|
|
2572
|
+
pending: !0,
|
|
2573
|
+
activityKey: 0,
|
|
2574
|
+
waitingLabel: r,
|
|
2575
|
+
stalledLabel: i,
|
|
2576
|
+
offlineLabel: a
|
|
2577
|
+
})]
|
|
2578
|
+
})
|
|
2579
|
+
})]
|
|
2580
|
+
})
|
|
2581
|
+
});
|
|
2582
|
+
}
|
|
2583
|
+
function Ii() {
|
|
2584
|
+
return /* @__PURE__ */ $(Z, { children: [/* @__PURE__ */ Q("span", {
|
|
2585
|
+
className: "sr-only",
|
|
2586
|
+
children: "Assistant is responding"
|
|
2587
|
+
}), /* @__PURE__ */ $("span", {
|
|
2588
|
+
"aria-hidden": "true",
|
|
2589
|
+
className: "inline-flex items-center gap-1",
|
|
2590
|
+
children: [
|
|
2591
|
+
/* @__PURE__ */ Q("span", { className: "size-1.5 rounded-full bg-current animate-pulse" }),
|
|
2592
|
+
/* @__PURE__ */ Q("span", { className: "size-1.5 rounded-full bg-current animate-pulse" }),
|
|
2593
|
+
/* @__PURE__ */ Q("span", { className: "size-1.5 rounded-full bg-current animate-pulse" })
|
|
2594
|
+
]
|
|
2595
|
+
})] });
|
|
2596
|
+
}
|
|
2597
|
+
function Li(e) {
|
|
2598
|
+
let t = Math.floor(e / 60), n = e % 60;
|
|
2599
|
+
return `${t}:${String(n).padStart(2, "0")}`;
|
|
2600
|
+
}
|
|
2601
|
+
var Ri = 6;
|
|
2602
|
+
function zi(t, n) {
|
|
2603
|
+
let r = e.useRef(0), i = e.useRef(0), [a, o] = e.useState({
|
|
2604
|
+
elapsed: 0,
|
|
2605
|
+
quiet: 0
|
|
2606
|
+
});
|
|
2607
|
+
return e.useEffect(() => {
|
|
2608
|
+
let e = Date.now();
|
|
2609
|
+
r.current = e, i.current = e;
|
|
2610
|
+
}, []), e.useEffect(() => {
|
|
2611
|
+
let e = Date.now();
|
|
2612
|
+
i.current = e, o({
|
|
2613
|
+
elapsed: Math.floor((e - r.current) / 1e3),
|
|
2614
|
+
quiet: 0
|
|
2615
|
+
});
|
|
2616
|
+
}, [n]), e.useEffect(() => {
|
|
2617
|
+
if (!t) return;
|
|
2618
|
+
let e = () => {
|
|
2619
|
+
let e = Date.now();
|
|
2620
|
+
o({
|
|
2621
|
+
elapsed: Math.floor((e - r.current) / 1e3),
|
|
2622
|
+
quiet: Math.floor((e - i.current) / 1e3)
|
|
2623
|
+
});
|
|
2624
|
+
};
|
|
2625
|
+
e();
|
|
2626
|
+
let n = setInterval(e, 1e3);
|
|
2627
|
+
return () => clearInterval(n);
|
|
2628
|
+
}, [t]), {
|
|
2629
|
+
elapsedSeconds: a.elapsed,
|
|
2630
|
+
quietSeconds: a.quiet,
|
|
2631
|
+
live: a.quiet < Ri
|
|
2632
|
+
};
|
|
2633
|
+
}
|
|
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);
|
|
2646
|
+
return /* @__PURE__ */ $("span", {
|
|
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"),
|
|
2648
|
+
"aria-live": "polite",
|
|
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
|
+
]
|
|
2666
|
+
});
|
|
2667
|
+
}
|
|
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 = [
|
|
2688
|
+
"object",
|
|
2689
|
+
"view",
|
|
2690
|
+
"dashboard",
|
|
2691
|
+
"app",
|
|
2692
|
+
"seed"
|
|
2693
|
+
], Wi = {
|
|
2694
|
+
object: "Objects",
|
|
2695
|
+
view: "Views",
|
|
2696
|
+
dashboard: "Dashboards",
|
|
2697
|
+
app: "App",
|
|
2698
|
+
seed: "Sample data"
|
|
2699
|
+
};
|
|
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);
|
|
2705
|
+
}
|
|
2706
|
+
let y = [...Ui.filter((e) => v.has(e)), ...[...v.keys()].filter((e) => !Ui.includes(e))];
|
|
2707
|
+
return /* @__PURE__ */ $("div", {
|
|
2708
|
+
className: "rounded-lg border bg-muted/30 p-3 text-sm",
|
|
2709
|
+
"data-testid": "build-progress",
|
|
2710
|
+
children: [
|
|
2711
|
+
/* @__PURE__ */ $("div", {
|
|
2712
|
+
className: "mb-2 flex items-center gap-2 font-medium",
|
|
2713
|
+
children: [
|
|
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", {
|
|
2717
|
+
className: "text-xs font-normal text-muted-foreground",
|
|
2718
|
+
children: "adding sample data"
|
|
2719
|
+
}) : null,
|
|
2720
|
+
m ? null : /* @__PURE__ */ Q("span", {
|
|
2721
|
+
className: "ml-auto",
|
|
2722
|
+
children: /* @__PURE__ */ Q(Vi, {
|
|
2723
|
+
active: !0,
|
|
2724
|
+
activityKey: h,
|
|
2725
|
+
waitingLabel: a,
|
|
2726
|
+
stalledLabel: o,
|
|
2727
|
+
offlineLabel: s
|
|
2728
|
+
})
|
|
2729
|
+
})
|
|
2730
|
+
]
|
|
2731
|
+
}),
|
|
2732
|
+
/* @__PURE__ */ Q("div", {
|
|
2733
|
+
className: "mb-2 h-1.5 w-full overflow-hidden rounded-full bg-muted",
|
|
2734
|
+
children: /* @__PURE__ */ Q("div", {
|
|
2735
|
+
className: J("h-full rounded-full transition-all duration-500", m ? "bg-emerald-500" : "bg-primary"),
|
|
2736
|
+
style: { width: `${_}%` }
|
|
2737
|
+
})
|
|
2738
|
+
}),
|
|
2739
|
+
/* @__PURE__ */ Q("ul", {
|
|
2740
|
+
className: "space-y-1",
|
|
2741
|
+
children: y.map((e) => {
|
|
2742
|
+
let t = v.get(e);
|
|
2743
|
+
return /* @__PURE__ */ $("li", {
|
|
2744
|
+
className: "flex items-start gap-2",
|
|
2745
|
+
children: [/* @__PURE__ */ Q(Y, { className: "mt-0.5 size-3.5 shrink-0 text-emerald-600" }), /* @__PURE__ */ $("span", {
|
|
2746
|
+
className: "min-w-0 text-muted-foreground",
|
|
2747
|
+
children: [
|
|
2748
|
+
/* @__PURE__ */ Q("span", {
|
|
2749
|
+
className: "font-medium text-foreground",
|
|
2750
|
+
children: Wi[e] ?? e
|
|
2751
|
+
}),
|
|
2752
|
+
" ",
|
|
2753
|
+
t.slice(0, 6).join(", "),
|
|
2754
|
+
t.length > 6 ? ` +${t.length - 6} more` : ""
|
|
2755
|
+
]
|
|
2756
|
+
})]
|
|
2757
|
+
}, e);
|
|
2758
|
+
})
|
|
2759
|
+
}),
|
|
2760
|
+
m && g && (t || r) ? /* @__PURE__ */ $("div", {
|
|
2761
|
+
className: "mt-3 flex items-center gap-2",
|
|
2762
|
+
children: [t ? /* @__PURE__ */ $("button", {
|
|
1791
2763
|
type: "button",
|
|
1792
|
-
onClick: () =>
|
|
1793
|
-
className: "text-xs
|
|
1794
|
-
"
|
|
1795
|
-
children:
|
|
1796
|
-
}) : null,
|
|
1797
|
-
n ? /* @__PURE__ */ q("button", {
|
|
2764
|
+
onClick: () => t(g.name),
|
|
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",
|
|
2766
|
+
"data-testid": "build-progress-open-app",
|
|
2767
|
+
children: [n, /* @__PURE__ */ Q(Ae, { className: "size-3.5" })]
|
|
2768
|
+
}) : null, r ? /* @__PURE__ */ $("button", {
|
|
1798
2769
|
type: "button",
|
|
1799
|
-
onClick:
|
|
1800
|
-
className: "inline-flex h-7 items-center rounded-md border
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
2770
|
+
onClick: () => r(g.name),
|
|
2771
|
+
className: "inline-flex h-7 items-center gap-1.5 rounded-md border px-3 text-xs font-medium hover:bg-muted",
|
|
2772
|
+
"data-testid": "build-progress-preview-app",
|
|
2773
|
+
children: [/* @__PURE__ */ Q(Ye, { className: "size-3.5" }), i]
|
|
2774
|
+
}) : null]
|
|
2775
|
+
}) : null
|
|
2776
|
+
]
|
|
2777
|
+
});
|
|
2778
|
+
}
|
|
2779
|
+
function Ki({ groups: e, labels: t }) {
|
|
2780
|
+
return e.length === 0 ? null : /* @__PURE__ */ Q("div", {
|
|
2781
|
+
className: "not-prose mb-2 border-l border-border/70 pl-3",
|
|
2782
|
+
children: /* @__PURE__ */ Q("div", {
|
|
2783
|
+
className: "space-y-1",
|
|
2784
|
+
children: e.map((e) => /* @__PURE__ */ $("div", {
|
|
2785
|
+
className: "flex min-h-6 items-center justify-between gap-3 text-xs",
|
|
2786
|
+
children: [/* @__PURE__ */ $("div", {
|
|
2787
|
+
className: "flex min-w-0 items-center gap-2",
|
|
2788
|
+
children: [
|
|
2789
|
+
/* @__PURE__ */ Q(qi, { state: e.state }),
|
|
2790
|
+
/* @__PURE__ */ Q("span", {
|
|
2791
|
+
className: "truncate font-medium text-foreground",
|
|
2792
|
+
children: e.title
|
|
2793
|
+
}),
|
|
2794
|
+
e.count > 1 ? /* @__PURE__ */ $("span", {
|
|
2795
|
+
className: "shrink-0 text-[10px] text-muted-foreground",
|
|
2796
|
+
children: ["x", e.count]
|
|
2797
|
+
}) : null
|
|
2798
|
+
]
|
|
2799
|
+
}), e.state === "running" ? /* @__PURE__ */ Q(Hi, { offlineLabel: t.connectionOfflineLabel }) : /* @__PURE__ */ Q("span", {
|
|
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"),
|
|
2801
|
+
children: Ji(e.state, t)
|
|
2802
|
+
})]
|
|
2803
|
+
}, e.key))
|
|
2804
|
+
})
|
|
2805
|
+
});
|
|
2806
|
+
}
|
|
2807
|
+
function qi({ state: e }) {
|
|
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" });
|
|
2809
|
+
}
|
|
2810
|
+
function Ji(e, t) {
|
|
2811
|
+
switch (e) {
|
|
2812
|
+
case "failed": return t.toolFailed;
|
|
2813
|
+
case "awaiting": return t.toolAwaitingApproval;
|
|
2814
|
+
case "running": return t.toolRunning;
|
|
2815
|
+
case "completed": return t.toolCompleted;
|
|
2816
|
+
}
|
|
2817
|
+
}
|
|
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);
|
|
2820
|
+
if (i) {
|
|
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";
|
|
2822
|
+
return /* @__PURE__ */ Q("div", {
|
|
2823
|
+
className: "border-t bg-background px-3 py-2 text-sm",
|
|
2824
|
+
role: "alert",
|
|
2825
|
+
children: /* @__PURE__ */ Q("div", {
|
|
2826
|
+
className: "rounded-md border border-amber-300/40 bg-amber-50/60 px-3 py-2 text-foreground dark:bg-amber-950/20",
|
|
2827
|
+
children: /* @__PURE__ */ $("div", {
|
|
2828
|
+
className: "flex items-start gap-2",
|
|
2829
|
+
children: [/* @__PURE__ */ $("div", {
|
|
2830
|
+
className: "min-w-0 flex-1",
|
|
2831
|
+
children: [/* @__PURE__ */ Q("div", {
|
|
2832
|
+
className: "font-medium leading-snug text-foreground",
|
|
2833
|
+
children: e ? "需要升级" : "Upgrade needed"
|
|
2834
|
+
}), /* @__PURE__ */ Q("div", {
|
|
2835
|
+
className: "mt-0.5 break-words leading-snug text-muted-foreground",
|
|
2836
|
+
children: t
|
|
2837
|
+
})]
|
|
2838
|
+
}), r ? /* @__PURE__ */ Q("button", {
|
|
2839
|
+
type: "button",
|
|
2840
|
+
onClick: r,
|
|
2841
|
+
className: "inline-flex h-7 shrink-0 items-center rounded-md border border-amber-400/50 bg-background px-2 text-xs font-medium text-amber-700 hover:bg-amber-100/60 dark:text-amber-300",
|
|
2842
|
+
children: n
|
|
2843
|
+
}) : null]
|
|
2844
|
+
})
|
|
2845
|
+
})
|
|
2846
|
+
});
|
|
2847
|
+
}
|
|
2848
|
+
return /* @__PURE__ */ Q("div", {
|
|
2849
|
+
className: "border-t bg-background px-3 py-2 text-sm",
|
|
2850
|
+
role: "alert",
|
|
2851
|
+
children: /* @__PURE__ */ $("div", {
|
|
2852
|
+
className: "rounded-md border border-destructive/20 bg-destructive/5 px-3 py-2 text-foreground",
|
|
2853
|
+
children: [/* @__PURE__ */ $("div", {
|
|
2854
|
+
className: "flex items-start gap-2",
|
|
2855
|
+
children: [
|
|
2856
|
+
/* @__PURE__ */ Q(Oe, { className: "mt-0.5 h-4 w-4 shrink-0 text-destructive" }),
|
|
2857
|
+
/* @__PURE__ */ $("div", {
|
|
2858
|
+
className: "min-w-0 flex-1",
|
|
2859
|
+
children: [/* @__PURE__ */ Q("div", {
|
|
2860
|
+
className: "font-medium leading-snug text-destructive",
|
|
2861
|
+
children: "Response failed"
|
|
2862
|
+
}), /* @__PURE__ */ Q("div", {
|
|
2863
|
+
className: "mt-0.5 break-words leading-snug text-muted-foreground",
|
|
2864
|
+
children: a || "Something went wrong. Please try again."
|
|
2865
|
+
})]
|
|
2866
|
+
}),
|
|
2867
|
+
/* @__PURE__ */ $("div", {
|
|
2868
|
+
className: "flex shrink-0 items-center gap-1",
|
|
2869
|
+
children: [o ? /* @__PURE__ */ Q("button", {
|
|
2870
|
+
type: "button",
|
|
2871
|
+
onClick: () => c((e) => !e),
|
|
2872
|
+
className: "inline-flex h-7 items-center rounded-md px-2 text-xs font-medium text-muted-foreground hover:bg-destructive/10 hover:text-foreground",
|
|
2873
|
+
"aria-expanded": s,
|
|
2874
|
+
children: s ? "Hide" : "Details"
|
|
2875
|
+
}) : null, n ? /* @__PURE__ */ $("button", {
|
|
2876
|
+
type: "button",
|
|
2877
|
+
onClick: n,
|
|
2878
|
+
className: "inline-flex h-7 items-center rounded-md border border-destructive/30 bg-background px-2 text-xs font-medium text-destructive hover:bg-destructive/10",
|
|
2879
|
+
children: [/* @__PURE__ */ Q(st, { className: "mr-1 h-3 w-3" }), "Retry"]
|
|
2880
|
+
}) : null]
|
|
2881
|
+
})
|
|
2882
|
+
]
|
|
2883
|
+
}), s && o ? /* @__PURE__ */ Q("pre", {
|
|
2884
|
+
className: "mt-2 max-h-28 overflow-auto whitespace-pre-wrap break-words rounded border bg-background px-2 py-1 font-mono text-[11px] leading-snug text-muted-foreground",
|
|
2885
|
+
children: o
|
|
2886
|
+
}) : null]
|
|
2887
|
+
})
|
|
1808
2888
|
});
|
|
1809
2889
|
}
|
|
1810
|
-
function
|
|
1811
|
-
return t ? /* @__PURE__ */
|
|
2890
|
+
function Xi({ output: e, errorText: t }) {
|
|
2891
|
+
return t ? /* @__PURE__ */ Q(di, {
|
|
1812
2892
|
output: void 0,
|
|
1813
2893
|
errorText: t
|
|
1814
|
-
}) : e == null || e === "" ? null : typeof e == "string" && !
|
|
2894
|
+
}) : e == null || e === "" ? null : typeof e == "string" && !Di(e) ? /* @__PURE__ */ $("div", {
|
|
1815
2895
|
className: "space-y-2 p-4",
|
|
1816
|
-
children: [/* @__PURE__ */
|
|
2896
|
+
children: [/* @__PURE__ */ Q("h4", {
|
|
1817
2897
|
className: "font-medium text-muted-foreground text-xs uppercase tracking-wide",
|
|
1818
2898
|
children: "Result"
|
|
1819
|
-
}), /* @__PURE__ */
|
|
2899
|
+
}), /* @__PURE__ */ Q("div", {
|
|
1820
2900
|
className: "overflow-x-auto rounded-md bg-muted/40 px-3 py-2 text-sm text-foreground",
|
|
1821
|
-
children: /* @__PURE__ */
|
|
2901
|
+
children: /* @__PURE__ */ Q(Qn, { children: e })
|
|
1822
2902
|
})]
|
|
1823
|
-
}) : /* @__PURE__ */
|
|
2903
|
+
}) : /* @__PURE__ */ Q(di, {
|
|
1824
2904
|
output: e,
|
|
1825
2905
|
errorText: void 0
|
|
1826
2906
|
});
|
|
1827
2907
|
}
|
|
1828
2908
|
//#endregion
|
|
1829
2909
|
//#region src/FloatingChatbot.tsx
|
|
1830
|
-
function
|
|
2910
|
+
function Zi({ floatingConfig: t, headerExtra: n, headerActions: r, ...i }) {
|
|
1831
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);
|
|
1832
2912
|
e.useEffect(() => {
|
|
1833
2913
|
let e = document.getElementById("floating-chatbot-portal");
|
|
@@ -1835,29 +2915,29 @@ function Gr({ floatingConfig: t, headerExtra: n, headerActions: r, ...i }) {
|
|
|
1835
2915
|
e && e.parentNode && !e.hasChildNodes() && e.parentNode.removeChild(e);
|
|
1836
2916
|
};
|
|
1837
2917
|
}, []);
|
|
1838
|
-
let p = /* @__PURE__ */
|
|
2918
|
+
let p = /* @__PURE__ */ $(mn, {
|
|
1839
2919
|
defaultOpen: o,
|
|
1840
|
-
children: [/* @__PURE__ */
|
|
2920
|
+
children: [/* @__PURE__ */ Q(bn, {
|
|
1841
2921
|
position: a,
|
|
1842
2922
|
size: u
|
|
1843
|
-
}), /* @__PURE__ */
|
|
2923
|
+
}), /* @__PURE__ */ Q(En, {
|
|
1844
2924
|
title: l,
|
|
1845
2925
|
position: a,
|
|
1846
2926
|
width: s,
|
|
1847
2927
|
height: c,
|
|
1848
2928
|
headerExtra: n,
|
|
1849
2929
|
headerActions: r,
|
|
1850
|
-
children: /* @__PURE__ */
|
|
2930
|
+
children: /* @__PURE__ */ Q(Ni, {
|
|
1851
2931
|
...i,
|
|
1852
2932
|
maxHeight: "100%",
|
|
1853
2933
|
className: "h-full border-0 rounded-none"
|
|
1854
2934
|
})
|
|
1855
2935
|
})]
|
|
1856
2936
|
});
|
|
1857
|
-
return d ?
|
|
2937
|
+
return d ? xt.createPortal(p, d) : p;
|
|
1858
2938
|
}
|
|
1859
|
-
|
|
1860
|
-
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({
|
|
1861
2941
|
api: e.api,
|
|
1862
2942
|
initialMessages: e.messages,
|
|
1863
2943
|
conversationId: e.conversationId,
|
|
@@ -1874,7 +2954,7 @@ Dt.register("chatbot", ({ schema: e, className: t, ...n }) => {
|
|
|
1874
2954
|
autoResponseDelay: e.autoResponseDelay,
|
|
1875
2955
|
onSend: e.onSend
|
|
1876
2956
|
});
|
|
1877
|
-
return /* @__PURE__ */
|
|
2957
|
+
return /* @__PURE__ */ Q(va, {
|
|
1878
2958
|
messages: r,
|
|
1879
2959
|
placeholder: e.placeholder,
|
|
1880
2960
|
onSendMessage: (e) => {
|
|
@@ -2022,8 +3102,8 @@ Dt.register("chatbot", ({ schema: e, className: t, ...n }) => {
|
|
|
2022
3102
|
autoResponseDelay: 1e3,
|
|
2023
3103
|
className: "w-full max-w-2xl"
|
|
2024
3104
|
}
|
|
2025
|
-
}),
|
|
2026
|
-
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({
|
|
2027
3107
|
api: e.api,
|
|
2028
3108
|
initialMessages: e.messages,
|
|
2029
3109
|
conversationId: e.conversationId,
|
|
@@ -2040,7 +3120,7 @@ Dt.register("chatbot", ({ schema: e, className: t, ...n }) => {
|
|
|
2040
3120
|
autoResponseDelay: e.autoResponseDelay,
|
|
2041
3121
|
onSend: e.onSend
|
|
2042
3122
|
});
|
|
2043
|
-
return /* @__PURE__ */
|
|
3123
|
+
return /* @__PURE__ */ Q(Ni, {
|
|
2044
3124
|
messages: r,
|
|
2045
3125
|
placeholder: e.placeholder,
|
|
2046
3126
|
onSendMessage: (e, t) => {
|
|
@@ -2062,6 +3142,7 @@ Dt.register("chatbot", ({ schema: e, className: t, ...n }) => {
|
|
|
2062
3142
|
maxHeight: e.maxHeight,
|
|
2063
3143
|
enableMarkdown: e.enableMarkdown ?? !0,
|
|
2064
3144
|
enableFileUpload: e.enableFileUpload ?? !1,
|
|
3145
|
+
processVisibility: e.processVisibility,
|
|
2065
3146
|
className: t,
|
|
2066
3147
|
...n
|
|
2067
3148
|
});
|
|
@@ -2104,6 +3185,12 @@ Dt.register("chatbot", ({ schema: e, className: t, ...n }) => {
|
|
|
2104
3185
|
label: "Enable File Upload",
|
|
2105
3186
|
defaultValue: !1
|
|
2106
3187
|
},
|
|
3188
|
+
{
|
|
3189
|
+
name: "processVisibility",
|
|
3190
|
+
type: "enum",
|
|
3191
|
+
label: "Agent Process Visibility",
|
|
3192
|
+
defaultValue: "summary"
|
|
3193
|
+
},
|
|
2107
3194
|
{
|
|
2108
3195
|
name: "userAvatarUrl",
|
|
2109
3196
|
type: "string",
|
|
@@ -2202,8 +3289,8 @@ Dt.register("chatbot", ({ schema: e, className: t, ...n }) => {
|
|
|
2202
3289
|
autoResponseDelay: 1e3,
|
|
2203
3290
|
className: "w-full max-w-2xl"
|
|
2204
3291
|
}
|
|
2205
|
-
}),
|
|
2206
|
-
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({
|
|
2207
3294
|
api: e.api,
|
|
2208
3295
|
initialMessages: e.messages,
|
|
2209
3296
|
conversationId: e.conversationId,
|
|
@@ -2220,7 +3307,7 @@ Dt.register("chatbot", ({ schema: e, className: t, ...n }) => {
|
|
|
2220
3307
|
autoResponseDelay: e.autoResponseDelay,
|
|
2221
3308
|
onSend: e.onSend
|
|
2222
3309
|
});
|
|
2223
|
-
return /* @__PURE__ */
|
|
3310
|
+
return /* @__PURE__ */ Q(Zi, {
|
|
2224
3311
|
floatingConfig: e.floatingConfig,
|
|
2225
3312
|
messages: r,
|
|
2226
3313
|
placeholder: e.placeholder,
|
|
@@ -2392,71 +3479,71 @@ Dt.register("chatbot", ({ schema: e, className: t, ...n }) => {
|
|
|
2392
3479
|
});
|
|
2393
3480
|
//#endregion
|
|
2394
3481
|
//#region src/elements/loader.tsx
|
|
2395
|
-
var
|
|
3482
|
+
var Qi = ({ size: e = 16 }) => /* @__PURE__ */ $("svg", {
|
|
2396
3483
|
height: e,
|
|
2397
3484
|
strokeLinejoin: "round",
|
|
2398
3485
|
style: { color: "currentcolor" },
|
|
2399
3486
|
viewBox: "0 0 16 16",
|
|
2400
3487
|
width: e,
|
|
2401
3488
|
children: [
|
|
2402
|
-
/* @__PURE__ */
|
|
2403
|
-
/* @__PURE__ */
|
|
3489
|
+
/* @__PURE__ */ Q("title", { children: "Loader" }),
|
|
3490
|
+
/* @__PURE__ */ $("g", {
|
|
2404
3491
|
clipPath: "url(#clip0_2393_1490)",
|
|
2405
3492
|
children: [
|
|
2406
|
-
/* @__PURE__ */
|
|
3493
|
+
/* @__PURE__ */ Q("path", {
|
|
2407
3494
|
d: "M8 0V4",
|
|
2408
3495
|
stroke: "currentColor",
|
|
2409
3496
|
strokeWidth: "1.5"
|
|
2410
3497
|
}),
|
|
2411
|
-
/* @__PURE__ */
|
|
3498
|
+
/* @__PURE__ */ Q("path", {
|
|
2412
3499
|
d: "M8 16V12",
|
|
2413
3500
|
opacity: "0.5",
|
|
2414
3501
|
stroke: "currentColor",
|
|
2415
3502
|
strokeWidth: "1.5"
|
|
2416
3503
|
}),
|
|
2417
|
-
/* @__PURE__ */
|
|
3504
|
+
/* @__PURE__ */ Q("path", {
|
|
2418
3505
|
d: "M3.29773 1.52783L5.64887 4.7639",
|
|
2419
3506
|
opacity: "0.9",
|
|
2420
3507
|
stroke: "currentColor",
|
|
2421
3508
|
strokeWidth: "1.5"
|
|
2422
3509
|
}),
|
|
2423
|
-
/* @__PURE__ */
|
|
3510
|
+
/* @__PURE__ */ Q("path", {
|
|
2424
3511
|
d: "M12.7023 1.52783L10.3511 4.7639",
|
|
2425
3512
|
opacity: "0.1",
|
|
2426
3513
|
stroke: "currentColor",
|
|
2427
3514
|
strokeWidth: "1.5"
|
|
2428
3515
|
}),
|
|
2429
|
-
/* @__PURE__ */
|
|
3516
|
+
/* @__PURE__ */ Q("path", {
|
|
2430
3517
|
d: "M12.7023 14.472L10.3511 11.236",
|
|
2431
3518
|
opacity: "0.4",
|
|
2432
3519
|
stroke: "currentColor",
|
|
2433
3520
|
strokeWidth: "1.5"
|
|
2434
3521
|
}),
|
|
2435
|
-
/* @__PURE__ */
|
|
3522
|
+
/* @__PURE__ */ Q("path", {
|
|
2436
3523
|
d: "M3.29773 14.472L5.64887 11.236",
|
|
2437
3524
|
opacity: "0.6",
|
|
2438
3525
|
stroke: "currentColor",
|
|
2439
3526
|
strokeWidth: "1.5"
|
|
2440
3527
|
}),
|
|
2441
|
-
/* @__PURE__ */
|
|
3528
|
+
/* @__PURE__ */ Q("path", {
|
|
2442
3529
|
d: "M15.6085 5.52783L11.8043 6.7639",
|
|
2443
3530
|
opacity: "0.2",
|
|
2444
3531
|
stroke: "currentColor",
|
|
2445
3532
|
strokeWidth: "1.5"
|
|
2446
3533
|
}),
|
|
2447
|
-
/* @__PURE__ */
|
|
3534
|
+
/* @__PURE__ */ Q("path", {
|
|
2448
3535
|
d: "M0.391602 10.472L4.19583 9.23598",
|
|
2449
3536
|
opacity: "0.7",
|
|
2450
3537
|
stroke: "currentColor",
|
|
2451
3538
|
strokeWidth: "1.5"
|
|
2452
3539
|
}),
|
|
2453
|
-
/* @__PURE__ */
|
|
3540
|
+
/* @__PURE__ */ Q("path", {
|
|
2454
3541
|
d: "M15.6085 10.4722L11.8043 9.2361",
|
|
2455
3542
|
opacity: "0.3",
|
|
2456
3543
|
stroke: "currentColor",
|
|
2457
3544
|
strokeWidth: "1.5"
|
|
2458
3545
|
}),
|
|
2459
|
-
/* @__PURE__ */
|
|
3546
|
+
/* @__PURE__ */ Q("path", {
|
|
2460
3547
|
d: "M0.391602 5.52783L4.19583 6.7639",
|
|
2461
3548
|
opacity: "0.8",
|
|
2462
3549
|
stroke: "currentColor",
|
|
@@ -2464,106 +3551,106 @@ var Kr = ({ size: e = 16 }) => /* @__PURE__ */ q("svg", {
|
|
|
2464
3551
|
})
|
|
2465
3552
|
]
|
|
2466
3553
|
}),
|
|
2467
|
-
/* @__PURE__ */
|
|
3554
|
+
/* @__PURE__ */ Q("defs", { children: /* @__PURE__ */ Q("clipPath", {
|
|
2468
3555
|
id: "clip0_2393_1490",
|
|
2469
|
-
children: /* @__PURE__ */
|
|
3556
|
+
children: /* @__PURE__ */ Q("rect", {
|
|
2470
3557
|
fill: "white",
|
|
2471
3558
|
height: "16",
|
|
2472
3559
|
width: "16"
|
|
2473
3560
|
})
|
|
2474
3561
|
}) })
|
|
2475
3562
|
]
|
|
2476
|
-
}),
|
|
2477
|
-
className:
|
|
3563
|
+
}), $i = ({ className: e, size: t = 16, ...n }) => /* @__PURE__ */ Q("div", {
|
|
3564
|
+
className: J("inline-flex animate-spin items-center justify-center", e),
|
|
2478
3565
|
...n,
|
|
2479
|
-
children: /* @__PURE__ */
|
|
2480
|
-
}),
|
|
2481
|
-
CodeBlock: () =>
|
|
2482
|
-
CodeBlockCopyButton: () =>
|
|
2483
|
-
Conversation: () =>
|
|
2484
|
-
ConversationContent: () =>
|
|
2485
|
-
ConversationEmptyState: () =>
|
|
2486
|
-
ConversationScrollButton: () =>
|
|
2487
|
-
Loader: () =>
|
|
2488
|
-
Message: () =>
|
|
2489
|
-
MessageAction: () =>
|
|
2490
|
-
MessageActions: () =>
|
|
2491
|
-
MessageAttachment: () =>
|
|
2492
|
-
MessageAttachments: () =>
|
|
2493
|
-
MessageBranch: () =>
|
|
2494
|
-
MessageBranchContent: () =>
|
|
2495
|
-
MessageBranchNext: () =>
|
|
2496
|
-
MessageBranchPage: () =>
|
|
2497
|
-
MessageBranchPrevious: () =>
|
|
2498
|
-
MessageBranchSelector: () =>
|
|
2499
|
-
MessageContent: () =>
|
|
2500
|
-
MessageResponse: () =>
|
|
2501
|
-
MessageToolbar: () =>
|
|
2502
|
-
PromptInput: () =>
|
|
2503
|
-
PromptInputActionAddAttachments: () =>
|
|
2504
|
-
PromptInputActionMenu: () =>
|
|
2505
|
-
PromptInputActionMenuContent: () =>
|
|
2506
|
-
PromptInputActionMenuItem: () =>
|
|
2507
|
-
PromptInputActionMenuTrigger: () =>
|
|
2508
|
-
PromptInputAttachment: () =>
|
|
2509
|
-
PromptInputAttachments: () =>
|
|
2510
|
-
PromptInputBody: () =>
|
|
2511
|
-
PromptInputButton: () =>
|
|
2512
|
-
PromptInputCommand: () =>
|
|
2513
|
-
PromptInputCommandEmpty: () =>
|
|
2514
|
-
PromptInputCommandGroup: () =>
|
|
2515
|
-
PromptInputCommandInput: () =>
|
|
2516
|
-
PromptInputCommandItem: () =>
|
|
2517
|
-
PromptInputCommandList: () =>
|
|
2518
|
-
PromptInputCommandSeparator: () =>
|
|
2519
|
-
PromptInputFooter: () =>
|
|
2520
|
-
PromptInputHeader: () =>
|
|
2521
|
-
PromptInputHoverCard: () =>
|
|
2522
|
-
PromptInputHoverCardContent: () =>
|
|
2523
|
-
PromptInputHoverCardTrigger: () =>
|
|
2524
|
-
PromptInputProvider: () =>
|
|
2525
|
-
PromptInputSelect: () =>
|
|
2526
|
-
PromptInputSelectContent: () =>
|
|
2527
|
-
PromptInputSelectItem: () =>
|
|
2528
|
-
PromptInputSelectTrigger: () =>
|
|
2529
|
-
PromptInputSelectValue: () =>
|
|
2530
|
-
PromptInputSpeechButton: () =>
|
|
2531
|
-
PromptInputSubmit: () =>
|
|
2532
|
-
PromptInputTab: () =>
|
|
2533
|
-
PromptInputTabBody: () =>
|
|
2534
|
-
PromptInputTabItem: () =>
|
|
2535
|
-
PromptInputTabLabel: () =>
|
|
2536
|
-
PromptInputTabsList: () =>
|
|
2537
|
-
PromptInputTextarea: () =>
|
|
2538
|
-
PromptInputTools: () =>
|
|
2539
|
-
Reasoning: () =>
|
|
2540
|
-
ReasoningContent: () =>
|
|
2541
|
-
ReasoningTrigger: () =>
|
|
2542
|
-
Shimmer: () =>
|
|
2543
|
-
Source: () =>
|
|
2544
|
-
Sources: () =>
|
|
2545
|
-
SourcesContent: () =>
|
|
2546
|
-
SourcesTrigger: () =>
|
|
2547
|
-
Suggestion: () =>
|
|
2548
|
-
Suggestions: () =>
|
|
2549
|
-
Tool: () =>
|
|
2550
|
-
ToolContent: () =>
|
|
2551
|
-
ToolHeader: () =>
|
|
2552
|
-
ToolInput: () =>
|
|
2553
|
-
ToolOutput: () =>
|
|
2554
|
-
highlightCode: () =>
|
|
2555
|
-
usePromptInputAttachments: () =>
|
|
2556
|
-
usePromptInputController: () =>
|
|
2557
|
-
useProviderAttachments: () =>
|
|
2558
|
-
useReasoning: () =>
|
|
2559
|
-
}),
|
|
2560
|
-
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) {
|
|
2561
3648
|
let r = e.replace(/\/$/, ""), i = new URLSearchParams();
|
|
2562
3649
|
if (n) for (let [e, t] of Object.entries(n)) t == null || t === "" || i.set(e, String(t));
|
|
2563
3650
|
let a = i.toString();
|
|
2564
3651
|
return `${r}${t}${a ? `?${a}` : ""}`;
|
|
2565
3652
|
}
|
|
2566
|
-
async function
|
|
3653
|
+
async function ra(e, t, n) {
|
|
2567
3654
|
let r = await fetch(e, {
|
|
2568
3655
|
credentials: "include",
|
|
2569
3656
|
...t,
|
|
@@ -2583,8 +3670,8 @@ async function Zr(e, t, n) {
|
|
|
2583
3670
|
}
|
|
2584
3671
|
return i;
|
|
2585
3672
|
}
|
|
2586
|
-
function
|
|
2587
|
-
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({
|
|
2588
3675
|
apiBase: n,
|
|
2589
3676
|
status: r,
|
|
2590
3677
|
conversationId: i,
|
|
@@ -2602,7 +3689,7 @@ function Qr(t = {}) {
|
|
|
2602
3689
|
let { apiBase: e, status: t, conversationId: n, limit: r, headers: i } = _.current;
|
|
2603
3690
|
m(!0), g(void 0);
|
|
2604
3691
|
try {
|
|
2605
|
-
let a = await
|
|
3692
|
+
let a = await ra(na(e, "/pending-actions", {
|
|
2606
3693
|
status: t && t !== "all" ? t : void 0,
|
|
2607
3694
|
conversationId: n,
|
|
2608
3695
|
limit: r
|
|
@@ -2614,9 +3701,9 @@ function Qr(t = {}) {
|
|
|
2614
3701
|
m(!1);
|
|
2615
3702
|
}
|
|
2616
3703
|
}, []), y = e.useCallback(async (e) => {
|
|
2617
|
-
let { apiBase: t, headers: n } = _.current, r =
|
|
3704
|
+
let { apiBase: t, headers: n } = _.current, r = na(t, `/pending-actions/${encodeURIComponent(e)}/approve`);
|
|
2618
3705
|
try {
|
|
2619
|
-
return await
|
|
3706
|
+
return await ra(r, {
|
|
2620
3707
|
method: "POST",
|
|
2621
3708
|
body: "{}"
|
|
2622
3709
|
}, n);
|
|
@@ -2624,9 +3711,9 @@ function Qr(t = {}) {
|
|
|
2624
3711
|
v();
|
|
2625
3712
|
}
|
|
2626
3713
|
}, [v]), b = e.useCallback(async (e, t) => {
|
|
2627
|
-
let { apiBase: n, headers: r } = _.current, i =
|
|
3714
|
+
let { apiBase: n, headers: r } = _.current, i = na(n, `/pending-actions/${encodeURIComponent(e)}/reject`);
|
|
2628
3715
|
try {
|
|
2629
|
-
return await
|
|
3716
|
+
return await ra(i, {
|
|
2630
3717
|
method: "POST",
|
|
2631
3718
|
body: JSON.stringify(t ? { reason: t } : {})
|
|
2632
3719
|
}, r);
|
|
@@ -2660,7 +3747,7 @@ function Qr(t = {}) {
|
|
|
2660
3747
|
}
|
|
2661
3748
|
//#endregion
|
|
2662
3749
|
//#region src/AiPendingActionsInbox.tsx
|
|
2663
|
-
var
|
|
3750
|
+
var aa = {
|
|
2664
3751
|
pending: {
|
|
2665
3752
|
variant: "secondary",
|
|
2666
3753
|
label: "Pending"
|
|
@@ -2682,17 +3769,17 @@ var $r = {
|
|
|
2682
3769
|
label: "Rejected"
|
|
2683
3770
|
}
|
|
2684
3771
|
};
|
|
2685
|
-
function
|
|
2686
|
-
let t =
|
|
3772
|
+
function oa({ status: e }) {
|
|
3773
|
+
let t = aa[e] ?? {
|
|
2687
3774
|
variant: "outline",
|
|
2688
3775
|
label: e
|
|
2689
3776
|
};
|
|
2690
|
-
return /* @__PURE__ */
|
|
3777
|
+
return /* @__PURE__ */ Q(_, {
|
|
2691
3778
|
variant: t.variant,
|
|
2692
3779
|
children: t.label
|
|
2693
3780
|
});
|
|
2694
3781
|
}
|
|
2695
|
-
function
|
|
3782
|
+
function sa(e) {
|
|
2696
3783
|
if (!e) return "—";
|
|
2697
3784
|
let t = Date.parse(e);
|
|
2698
3785
|
if (Number.isNaN(t)) return e;
|
|
@@ -2710,7 +3797,7 @@ function ti(e) {
|
|
|
2710
3797
|
return e;
|
|
2711
3798
|
}
|
|
2712
3799
|
}
|
|
2713
|
-
function
|
|
3800
|
+
function ca(e) {
|
|
2714
3801
|
if (!e) return null;
|
|
2715
3802
|
try {
|
|
2716
3803
|
return JSON.parse(e);
|
|
@@ -2718,35 +3805,35 @@ function ni(e) {
|
|
|
2718
3805
|
return e;
|
|
2719
3806
|
}
|
|
2720
3807
|
}
|
|
2721
|
-
function
|
|
3808
|
+
function la({ value: e, max: t = 320 }) {
|
|
2722
3809
|
let n = typeof e == "string" ? e : JSON.stringify(e, null, 2);
|
|
2723
|
-
return n == null || n === "" ? /* @__PURE__ */
|
|
3810
|
+
return n == null || n === "" ? /* @__PURE__ */ Q("span", {
|
|
2724
3811
|
className: "text-muted-foreground text-xs",
|
|
2725
3812
|
children: "—"
|
|
2726
|
-
}) : /* @__PURE__ */
|
|
3813
|
+
}) : /* @__PURE__ */ Q("pre", {
|
|
2727
3814
|
className: "bg-muted/40 rounded text-xs p-2 overflow-auto whitespace-pre-wrap break-all",
|
|
2728
3815
|
style: { maxHeight: t },
|
|
2729
3816
|
children: n
|
|
2730
3817
|
});
|
|
2731
3818
|
}
|
|
2732
|
-
function
|
|
3819
|
+
function ua(e) {
|
|
2733
3820
|
switch (e) {
|
|
2734
3821
|
case "pending": return "pending";
|
|
2735
3822
|
case "all": return "all";
|
|
2736
3823
|
case "decided": return "all";
|
|
2737
3824
|
}
|
|
2738
3825
|
}
|
|
2739
|
-
function
|
|
2740
|
-
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:
|
|
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({
|
|
2741
3828
|
apiBase: t,
|
|
2742
3829
|
headers: n,
|
|
2743
3830
|
pollInterval: r,
|
|
2744
3831
|
conversationId: i,
|
|
2745
|
-
status:
|
|
2746
|
-
}),
|
|
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) => {
|
|
2747
3834
|
E(e), O(null);
|
|
2748
3835
|
try {
|
|
2749
|
-
let t = await
|
|
3836
|
+
let t = await te(e), n = t.status === "executed";
|
|
2750
3837
|
A({
|
|
2751
3838
|
id: e,
|
|
2752
3839
|
kind: "approve",
|
|
@@ -2764,10 +3851,10 @@ function ai({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
|
|
|
2764
3851
|
} finally {
|
|
2765
3852
|
E(null);
|
|
2766
3853
|
}
|
|
2767
|
-
}, [
|
|
3854
|
+
}, [te]), R = e.useCallback(async (e, t) => {
|
|
2768
3855
|
E(e), O(null);
|
|
2769
3856
|
try {
|
|
2770
|
-
await
|
|
3857
|
+
await P(e, t.trim() || void 0), A({
|
|
2771
3858
|
id: e,
|
|
2772
3859
|
kind: "reject",
|
|
2773
3860
|
ok: !0,
|
|
@@ -2784,52 +3871,52 @@ function ai({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
|
|
|
2784
3871
|
} finally {
|
|
2785
3872
|
E(null);
|
|
2786
3873
|
}
|
|
2787
|
-
}, [
|
|
3874
|
+
}, [P]), z = /* @__PURE__ */ $("div", {
|
|
2788
3875
|
className: "space-y-3",
|
|
2789
3876
|
children: [
|
|
2790
|
-
/* @__PURE__ */
|
|
3877
|
+
/* @__PURE__ */ $("div", {
|
|
2791
3878
|
className: "flex items-center justify-between gap-2",
|
|
2792
|
-
children: [/* @__PURE__ */ K
|
|
3879
|
+
children: [/* @__PURE__ */ Q(K, {
|
|
2793
3880
|
value: l,
|
|
2794
3881
|
onValueChange: (e) => u(e),
|
|
2795
|
-
children: /* @__PURE__ */
|
|
2796
|
-
/* @__PURE__ */
|
|
3882
|
+
children: /* @__PURE__ */ $(Se, { children: [
|
|
3883
|
+
/* @__PURE__ */ Q(Ce, {
|
|
2797
3884
|
value: "pending",
|
|
2798
3885
|
children: "Pending"
|
|
2799
3886
|
}),
|
|
2800
|
-
/* @__PURE__ */
|
|
3887
|
+
/* @__PURE__ */ Q(Ce, {
|
|
2801
3888
|
value: "decided",
|
|
2802
3889
|
children: "Decided"
|
|
2803
3890
|
}),
|
|
2804
|
-
/* @__PURE__ */
|
|
3891
|
+
/* @__PURE__ */ Q(Ce, {
|
|
2805
3892
|
value: "all",
|
|
2806
3893
|
children: "All"
|
|
2807
3894
|
})
|
|
2808
3895
|
] })
|
|
2809
|
-
}), /* @__PURE__ */
|
|
3896
|
+
}), /* @__PURE__ */ $(v, {
|
|
2810
3897
|
variant: "outline",
|
|
2811
3898
|
size: "sm",
|
|
2812
|
-
onClick: () => void
|
|
3899
|
+
onClick: () => void ee(),
|
|
2813
3900
|
disabled: M,
|
|
2814
3901
|
"data-testid": "ai-inbox-refresh",
|
|
2815
|
-
children: [/* @__PURE__ */
|
|
3902
|
+
children: [/* @__PURE__ */ Q(st, { className: `h-3.5 w-3.5 mr-1.5 ${M ? "animate-spin" : ""}` }), "Refresh"]
|
|
2816
3903
|
})]
|
|
2817
3904
|
}),
|
|
2818
|
-
N ? /* @__PURE__ */
|
|
3905
|
+
N ? /* @__PURE__ */ $(f, {
|
|
2819
3906
|
variant: "destructive",
|
|
2820
|
-
children: [/* @__PURE__ */
|
|
3907
|
+
children: [/* @__PURE__ */ Q(Oe, { className: "h-4 w-4" }), /* @__PURE__ */ Q(p, { children: N.message })]
|
|
2821
3908
|
}) : null,
|
|
2822
|
-
D ? /* @__PURE__ */
|
|
3909
|
+
D ? /* @__PURE__ */ $(f, {
|
|
2823
3910
|
variant: "destructive",
|
|
2824
|
-
children: [/* @__PURE__ */
|
|
3911
|
+
children: [/* @__PURE__ */ Q(Oe, { className: "h-4 w-4" }), /* @__PURE__ */ Q(p, { children: D })]
|
|
2825
3912
|
}) : null,
|
|
2826
|
-
k && !D ? /* @__PURE__ */
|
|
3913
|
+
k && !D ? /* @__PURE__ */ $(f, {
|
|
2827
3914
|
variant: k.ok ? "default" : "destructive",
|
|
2828
|
-
children: [k.ok ? /* @__PURE__ */
|
|
3915
|
+
children: [k.ok ? /* @__PURE__ */ Q(Y, { className: "h-4 w-4" }) : /* @__PURE__ */ Q(X, { className: "h-4 w-4" }), /* @__PURE__ */ $(p, { children: [
|
|
2829
3916
|
k.kind === "approve" ? "Approve" : "Reject",
|
|
2830
3917
|
" for",
|
|
2831
3918
|
" ",
|
|
2832
|
-
/* @__PURE__ */
|
|
3919
|
+
/* @__PURE__ */ $("code", {
|
|
2833
3920
|
className: "text-xs",
|
|
2834
3921
|
children: [k.id.slice(0, 8), "…"]
|
|
2835
3922
|
}),
|
|
@@ -2838,89 +3925,89 @@ function ai({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
|
|
|
2838
3925
|
k.message ?? (k.ok ? "OK" : "Failed")
|
|
2839
3926
|
] })]
|
|
2840
3927
|
}) : null,
|
|
2841
|
-
M &&
|
|
3928
|
+
M && F.length === 0 ? /* @__PURE__ */ $("div", {
|
|
2842
3929
|
className: "space-y-2",
|
|
2843
3930
|
children: [
|
|
2844
|
-
/* @__PURE__ */
|
|
2845
|
-
/* @__PURE__ */
|
|
2846
|
-
/* @__PURE__ */
|
|
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" })
|
|
2847
3934
|
]
|
|
2848
|
-
}) :
|
|
2849
|
-
/* @__PURE__ */
|
|
2850
|
-
/* @__PURE__ */
|
|
2851
|
-
/* @__PURE__ */
|
|
2852
|
-
] }) }) : /* @__PURE__ */
|
|
3935
|
+
}) : F.length === 0 ? /* @__PURE__ */ Q(ne, { children: /* @__PURE__ */ $(I, { children: [
|
|
3936
|
+
/* @__PURE__ */ Q(ie, { children: /* @__PURE__ */ Q($e, { className: "h-8 w-8 text-muted-foreground" }) }),
|
|
3937
|
+
/* @__PURE__ */ Q(ae, { children: "No actions waiting" }),
|
|
3938
|
+
/* @__PURE__ */ Q(re, { children: "When the AI proposes a sensitive action it will appear here for review." })
|
|
3939
|
+
] }) }) : /* @__PURE__ */ Q("div", {
|
|
2853
3940
|
className: "rounded-md border",
|
|
2854
|
-
children: /* @__PURE__ */
|
|
2855
|
-
/* @__PURE__ */
|
|
3941
|
+
children: /* @__PURE__ */ $(be, { children: [/* @__PURE__ */ Q(xe, { children: /* @__PURE__ */ $(G, { children: [
|
|
3942
|
+
/* @__PURE__ */ Q(W, {
|
|
2856
3943
|
className: "w-[140px]",
|
|
2857
3944
|
children: "Tool"
|
|
2858
3945
|
}),
|
|
2859
|
-
/* @__PURE__ */
|
|
3946
|
+
/* @__PURE__ */ Q(W, {
|
|
2860
3947
|
className: "w-[140px]",
|
|
2861
3948
|
children: "Action"
|
|
2862
3949
|
}),
|
|
2863
|
-
/* @__PURE__ */
|
|
3950
|
+
/* @__PURE__ */ Q(W, {
|
|
2864
3951
|
className: "w-[120px]",
|
|
2865
3952
|
children: "Object"
|
|
2866
3953
|
}),
|
|
2867
|
-
/* @__PURE__ */
|
|
3954
|
+
/* @__PURE__ */ Q(W, {
|
|
2868
3955
|
className: "w-[110px]",
|
|
2869
3956
|
children: "Status"
|
|
2870
3957
|
}),
|
|
2871
|
-
/* @__PURE__ */
|
|
3958
|
+
/* @__PURE__ */ Q(W, {
|
|
2872
3959
|
className: "w-[110px]",
|
|
2873
3960
|
children: "Proposed"
|
|
2874
3961
|
}),
|
|
2875
|
-
/* @__PURE__ */
|
|
3962
|
+
/* @__PURE__ */ Q(W, {
|
|
2876
3963
|
className: "w-[260px] text-right",
|
|
2877
3964
|
children: "Decision"
|
|
2878
3965
|
})
|
|
2879
|
-
] }) }), /* @__PURE__ */
|
|
3966
|
+
] }) }), /* @__PURE__ */ Q(H, { children: F.map((e) => {
|
|
2880
3967
|
let t = e.status === "pending", n = T === e.id;
|
|
2881
|
-
return /* @__PURE__ */
|
|
2882
|
-
/* @__PURE__ */
|
|
3968
|
+
return /* @__PURE__ */ $(G, { children: [
|
|
3969
|
+
/* @__PURE__ */ Q(U, {
|
|
2883
3970
|
className: "font-mono text-xs",
|
|
2884
3971
|
children: e.tool_name
|
|
2885
3972
|
}),
|
|
2886
|
-
/* @__PURE__ */
|
|
3973
|
+
/* @__PURE__ */ Q(U, {
|
|
2887
3974
|
className: "text-sm",
|
|
2888
3975
|
children: e.action_name
|
|
2889
3976
|
}),
|
|
2890
|
-
/* @__PURE__ */
|
|
3977
|
+
/* @__PURE__ */ Q(U, {
|
|
2891
3978
|
className: "text-sm",
|
|
2892
3979
|
children: e.object_name
|
|
2893
3980
|
}),
|
|
2894
|
-
/* @__PURE__ */
|
|
2895
|
-
/* @__PURE__ */
|
|
3981
|
+
/* @__PURE__ */ Q(U, { children: /* @__PURE__ */ Q(oa, { status: e.status }) }),
|
|
3982
|
+
/* @__PURE__ */ Q(U, {
|
|
2896
3983
|
className: "text-xs text-muted-foreground",
|
|
2897
|
-
children: /* @__PURE__ */
|
|
3984
|
+
children: /* @__PURE__ */ $("span", {
|
|
2898
3985
|
className: "inline-flex items-center gap-1",
|
|
2899
3986
|
children: [
|
|
2900
|
-
/* @__PURE__ */
|
|
3987
|
+
/* @__PURE__ */ Q(He, { className: "h-3 w-3" }),
|
|
2901
3988
|
" ",
|
|
2902
|
-
|
|
3989
|
+
sa(e.proposed_at)
|
|
2903
3990
|
]
|
|
2904
3991
|
})
|
|
2905
3992
|
}),
|
|
2906
|
-
/* @__PURE__ */
|
|
3993
|
+
/* @__PURE__ */ Q(U, {
|
|
2907
3994
|
className: "text-right",
|
|
2908
|
-
children: /* @__PURE__ */
|
|
3995
|
+
children: /* @__PURE__ */ $("div", {
|
|
2909
3996
|
className: "inline-flex gap-1.5",
|
|
2910
|
-
children: [/* @__PURE__ */
|
|
3997
|
+
children: [/* @__PURE__ */ $(v, {
|
|
2911
3998
|
size: "sm",
|
|
2912
3999
|
variant: "ghost",
|
|
2913
4000
|
onClick: () => m(e.id),
|
|
2914
4001
|
"data-testid": `ai-inbox-view-${e.id}`,
|
|
2915
|
-
children: [/* @__PURE__ */
|
|
2916
|
-
}), t ? /* @__PURE__ */
|
|
4002
|
+
children: [/* @__PURE__ */ Q(Ye, { className: "h-3.5 w-3.5 mr-1" }), " View"]
|
|
4003
|
+
}), t ? /* @__PURE__ */ $(Z, { children: [/* @__PURE__ */ $(v, {
|
|
2917
4004
|
size: "sm",
|
|
2918
4005
|
variant: "default",
|
|
2919
4006
|
disabled: n,
|
|
2920
|
-
onClick: () => void
|
|
4007
|
+
onClick: () => void oe(e.id),
|
|
2921
4008
|
"data-testid": `ai-inbox-approve-${e.id}`,
|
|
2922
|
-
children: [/* @__PURE__ */
|
|
2923
|
-
}), /* @__PURE__ */
|
|
4009
|
+
children: [/* @__PURE__ */ Q(Y, { className: "h-3.5 w-3.5 mr-1" }), n ? "Working…" : "Approve"]
|
|
4010
|
+
}), /* @__PURE__ */ $(v, {
|
|
2924
4011
|
size: "sm",
|
|
2925
4012
|
variant: "destructive",
|
|
2926
4013
|
disabled: n,
|
|
@@ -2928,7 +4015,7 @@ function ai({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
|
|
|
2928
4015
|
g(e.id), w("");
|
|
2929
4016
|
},
|
|
2930
4017
|
"data-testid": `ai-inbox-reject-${e.id}`,
|
|
2931
|
-
children: [/* @__PURE__ */
|
|
4018
|
+
children: [/* @__PURE__ */ Q(X, { className: "h-3.5 w-3.5 mr-1" }), "Reject"]
|
|
2932
4019
|
})] }) : null]
|
|
2933
4020
|
})
|
|
2934
4021
|
})
|
|
@@ -2937,174 +4024,174 @@ function ai({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
|
|
|
2937
4024
|
})
|
|
2938
4025
|
]
|
|
2939
4026
|
});
|
|
2940
|
-
return /* @__PURE__ */
|
|
2941
|
-
a === "card" ? /* @__PURE__ */
|
|
4027
|
+
return /* @__PURE__ */ $(Z, { children: [
|
|
4028
|
+
a === "card" ? /* @__PURE__ */ $(y, {
|
|
2942
4029
|
className: c,
|
|
2943
|
-
children: [/* @__PURE__ */
|
|
4030
|
+
children: [/* @__PURE__ */ $(S, {
|
|
2944
4031
|
className: "pb-3",
|
|
2945
|
-
children: [/* @__PURE__ */
|
|
4032
|
+
children: [/* @__PURE__ */ $(C, {
|
|
2946
4033
|
className: "flex items-center gap-2",
|
|
2947
4034
|
children: [
|
|
2948
|
-
/* @__PURE__ */
|
|
4035
|
+
/* @__PURE__ */ Q(Me, { className: "h-4 w-4" }),
|
|
2949
4036
|
" ",
|
|
2950
4037
|
o
|
|
2951
4038
|
]
|
|
2952
|
-
}), s ? /* @__PURE__ */
|
|
2953
|
-
}), /* @__PURE__ */
|
|
2954
|
-
}) : /* @__PURE__ */
|
|
4039
|
+
}), s ? /* @__PURE__ */ Q(x, { children: s }) : null]
|
|
4040
|
+
}), /* @__PURE__ */ Q(b, { children: z })]
|
|
4041
|
+
}) : /* @__PURE__ */ Q("div", {
|
|
2955
4042
|
className: c,
|
|
2956
|
-
children:
|
|
4043
|
+
children: z
|
|
2957
4044
|
}),
|
|
2958
|
-
/* @__PURE__ */
|
|
4045
|
+
/* @__PURE__ */ Q(he, {
|
|
2959
4046
|
open: !!d,
|
|
2960
4047
|
onOpenChange: (e) => {
|
|
2961
4048
|
e || m(null);
|
|
2962
4049
|
},
|
|
2963
|
-
children: /* @__PURE__ */
|
|
4050
|
+
children: /* @__PURE__ */ $(ge, {
|
|
2964
4051
|
className: "sm:max-w-[560px] overflow-y-auto",
|
|
2965
|
-
children: [/* @__PURE__ */
|
|
4052
|
+
children: [/* @__PURE__ */ $(ve, { children: [/* @__PURE__ */ $(ye, {
|
|
2966
4053
|
className: "flex items-center gap-2",
|
|
2967
|
-
children: [/* @__PURE__ */
|
|
2968
|
-
}), /* @__PURE__ */
|
|
4054
|
+
children: [/* @__PURE__ */ Q(Me, { className: "h-4 w-4" }), L ? L.action_name : "Pending action"]
|
|
4055
|
+
}), /* @__PURE__ */ Q(_e, { children: L ? /* @__PURE__ */ $(Z, { children: [
|
|
2969
4056
|
"Tool ",
|
|
2970
|
-
/* @__PURE__ */
|
|
4057
|
+
/* @__PURE__ */ Q("code", {
|
|
2971
4058
|
className: "text-xs",
|
|
2972
|
-
children:
|
|
4059
|
+
children: L.tool_name
|
|
2973
4060
|
}),
|
|
2974
4061
|
" on",
|
|
2975
4062
|
" ",
|
|
2976
|
-
/* @__PURE__ */
|
|
4063
|
+
/* @__PURE__ */ Q("code", {
|
|
2977
4064
|
className: "text-xs",
|
|
2978
|
-
children:
|
|
4065
|
+
children: L.object_name
|
|
2979
4066
|
})
|
|
2980
|
-
] }) : "Loading…" })] }),
|
|
4067
|
+
] }) : "Loading…" })] }), L ? /* @__PURE__ */ $("div", {
|
|
2981
4068
|
className: "px-4 space-y-4 mt-4",
|
|
2982
4069
|
children: [
|
|
2983
|
-
/* @__PURE__ */
|
|
4070
|
+
/* @__PURE__ */ $("div", {
|
|
2984
4071
|
className: "grid grid-cols-2 gap-3 text-sm",
|
|
2985
4072
|
children: [
|
|
2986
|
-
/* @__PURE__ */
|
|
4073
|
+
/* @__PURE__ */ $("div", { children: [/* @__PURE__ */ Q(B, {
|
|
2987
4074
|
className: "text-xs text-muted-foreground",
|
|
2988
4075
|
children: "Status"
|
|
2989
|
-
}), /* @__PURE__ */
|
|
4076
|
+
}), /* @__PURE__ */ Q("div", {
|
|
2990
4077
|
className: "mt-1",
|
|
2991
|
-
children: /* @__PURE__ */
|
|
4078
|
+
children: /* @__PURE__ */ Q(oa, { status: L.status })
|
|
2992
4079
|
})] }),
|
|
2993
|
-
/* @__PURE__ */
|
|
4080
|
+
/* @__PURE__ */ $("div", { children: [/* @__PURE__ */ Q(B, {
|
|
2994
4081
|
className: "text-xs text-muted-foreground",
|
|
2995
4082
|
children: "Proposed"
|
|
2996
|
-
}), /* @__PURE__ */
|
|
4083
|
+
}), /* @__PURE__ */ Q("div", {
|
|
2997
4084
|
className: "mt-1 text-xs",
|
|
2998
|
-
children:
|
|
4085
|
+
children: sa(L.proposed_at)
|
|
2999
4086
|
})] }),
|
|
3000
|
-
/* @__PURE__ */
|
|
4087
|
+
/* @__PURE__ */ $("div", { children: [/* @__PURE__ */ Q(B, {
|
|
3001
4088
|
className: "text-xs text-muted-foreground",
|
|
3002
4089
|
children: "Proposed by"
|
|
3003
|
-
}), /* @__PURE__ */
|
|
4090
|
+
}), /* @__PURE__ */ Q("div", {
|
|
3004
4091
|
className: "mt-1 text-xs font-mono break-all",
|
|
3005
|
-
children:
|
|
4092
|
+
children: L.proposed_by ?? "—"
|
|
3006
4093
|
})] }),
|
|
3007
|
-
/* @__PURE__ */
|
|
4094
|
+
/* @__PURE__ */ $("div", { children: [/* @__PURE__ */ Q(B, {
|
|
3008
4095
|
className: "text-xs text-muted-foreground",
|
|
3009
4096
|
children: "Decided by"
|
|
3010
|
-
}), /* @__PURE__ */
|
|
4097
|
+
}), /* @__PURE__ */ Q("div", {
|
|
3011
4098
|
className: "mt-1 text-xs font-mono break-all",
|
|
3012
|
-
children:
|
|
4099
|
+
children: L.decided_by ?? "—"
|
|
3013
4100
|
})] }),
|
|
3014
|
-
|
|
4101
|
+
L.conversation_id ? /* @__PURE__ */ $("div", {
|
|
3015
4102
|
className: "col-span-2",
|
|
3016
|
-
children: [/* @__PURE__ */
|
|
4103
|
+
children: [/* @__PURE__ */ Q(B, {
|
|
3017
4104
|
className: "text-xs text-muted-foreground",
|
|
3018
4105
|
children: "Conversation"
|
|
3019
|
-
}), /* @__PURE__ */
|
|
4106
|
+
}), /* @__PURE__ */ Q("div", {
|
|
3020
4107
|
className: "mt-1 text-xs font-mono break-all",
|
|
3021
|
-
children:
|
|
4108
|
+
children: L.conversation_id
|
|
3022
4109
|
})]
|
|
3023
4110
|
}) : null
|
|
3024
4111
|
]
|
|
3025
4112
|
}),
|
|
3026
|
-
/* @__PURE__ */
|
|
3027
|
-
/* @__PURE__ */
|
|
4113
|
+
/* @__PURE__ */ Q(me, {}),
|
|
4114
|
+
/* @__PURE__ */ $("div", { children: [/* @__PURE__ */ Q(B, {
|
|
3028
4115
|
className: "text-xs",
|
|
3029
4116
|
children: "Tool input"
|
|
3030
|
-
}), /* @__PURE__ */
|
|
4117
|
+
}), /* @__PURE__ */ Q("div", {
|
|
3031
4118
|
className: "mt-1.5",
|
|
3032
|
-
children: /* @__PURE__ */
|
|
4119
|
+
children: /* @__PURE__ */ Q(la, { value: ca(L.tool_input) })
|
|
3033
4120
|
})] }),
|
|
3034
|
-
|
|
4121
|
+
L.result ? /* @__PURE__ */ $("div", { children: [/* @__PURE__ */ Q(B, {
|
|
3035
4122
|
className: "text-xs",
|
|
3036
4123
|
children: "Result"
|
|
3037
|
-
}), /* @__PURE__ */
|
|
4124
|
+
}), /* @__PURE__ */ Q("div", {
|
|
3038
4125
|
className: "mt-1.5",
|
|
3039
|
-
children: /* @__PURE__ */
|
|
4126
|
+
children: /* @__PURE__ */ Q(la, { value: ca(L.result) })
|
|
3040
4127
|
})] }) : null,
|
|
3041
|
-
|
|
4128
|
+
L.error ? /* @__PURE__ */ $("div", { children: [/* @__PURE__ */ Q(B, {
|
|
3042
4129
|
className: "text-xs text-destructive",
|
|
3043
4130
|
children: "Error"
|
|
3044
|
-
}), /* @__PURE__ */
|
|
4131
|
+
}), /* @__PURE__ */ Q("div", {
|
|
3045
4132
|
className: "mt-1.5",
|
|
3046
|
-
children: /* @__PURE__ */
|
|
4133
|
+
children: /* @__PURE__ */ Q(la, { value: L.error })
|
|
3047
4134
|
})] }) : null,
|
|
3048
|
-
|
|
4135
|
+
L.rejection_reason ? /* @__PURE__ */ $("div", { children: [/* @__PURE__ */ Q(B, {
|
|
3049
4136
|
className: "text-xs",
|
|
3050
4137
|
children: "Rejection reason"
|
|
3051
|
-
}), /* @__PURE__ */
|
|
4138
|
+
}), /* @__PURE__ */ Q("div", {
|
|
3052
4139
|
className: "mt-1.5 text-sm",
|
|
3053
|
-
children:
|
|
4140
|
+
children: L.rejection_reason
|
|
3054
4141
|
})] }) : null,
|
|
3055
|
-
|
|
4142
|
+
L.status === "pending" ? /* @__PURE__ */ $("div", {
|
|
3056
4143
|
className: "pt-2 flex gap-2",
|
|
3057
|
-
children: [/* @__PURE__ */
|
|
4144
|
+
children: [/* @__PURE__ */ $(v, {
|
|
3058
4145
|
size: "sm",
|
|
3059
|
-
onClick: () => void
|
|
3060
|
-
disabled: T ===
|
|
3061
|
-
children: [/* @__PURE__ */
|
|
3062
|
-
}), /* @__PURE__ */
|
|
4146
|
+
onClick: () => void oe(L.id),
|
|
4147
|
+
disabled: T === L.id,
|
|
4148
|
+
children: [/* @__PURE__ */ Q(Y, { className: "h-3.5 w-3.5 mr-1" }), "Approve & Execute"]
|
|
4149
|
+
}), /* @__PURE__ */ $(v, {
|
|
3063
4150
|
size: "sm",
|
|
3064
4151
|
variant: "destructive",
|
|
3065
4152
|
onClick: () => {
|
|
3066
|
-
g(
|
|
4153
|
+
g(L.id), w("");
|
|
3067
4154
|
},
|
|
3068
|
-
disabled: T ===
|
|
3069
|
-
children: [/* @__PURE__ */
|
|
4155
|
+
disabled: T === L.id,
|
|
4156
|
+
children: [/* @__PURE__ */ Q(X, { className: "h-3.5 w-3.5 mr-1" }), "Reject"]
|
|
3070
4157
|
})]
|
|
3071
4158
|
}) : null
|
|
3072
4159
|
]
|
|
3073
4160
|
}) : null]
|
|
3074
4161
|
})
|
|
3075
4162
|
}),
|
|
3076
|
-
/* @__PURE__ */
|
|
4163
|
+
/* @__PURE__ */ Q(he, {
|
|
3077
4164
|
open: !!h,
|
|
3078
4165
|
onOpenChange: (e) => {
|
|
3079
4166
|
e || (g(null), w(""));
|
|
3080
4167
|
},
|
|
3081
|
-
children: /* @__PURE__ */
|
|
4168
|
+
children: /* @__PURE__ */ $(ge, {
|
|
3082
4169
|
side: "bottom",
|
|
3083
4170
|
className: "max-h-[40vh]",
|
|
3084
|
-
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", {
|
|
3085
4172
|
className: "px-4 mt-3 space-y-3",
|
|
3086
|
-
children: [/* @__PURE__ */
|
|
4173
|
+
children: [/* @__PURE__ */ Q(q, {
|
|
3087
4174
|
value: _,
|
|
3088
4175
|
onChange: (e) => w(e.target.value),
|
|
3089
4176
|
placeholder: "Optional reason (e.g. 'Wrong record id — please confirm with the user first.')",
|
|
3090
4177
|
rows: 4,
|
|
3091
4178
|
"data-testid": "ai-inbox-reject-reason"
|
|
3092
|
-
}), /* @__PURE__ */
|
|
4179
|
+
}), /* @__PURE__ */ $("div", {
|
|
3093
4180
|
className: "flex justify-end gap-2",
|
|
3094
|
-
children: [/* @__PURE__ */
|
|
4181
|
+
children: [/* @__PURE__ */ Q(v, {
|
|
3095
4182
|
variant: "outline",
|
|
3096
4183
|
size: "sm",
|
|
3097
4184
|
onClick: () => {
|
|
3098
4185
|
g(null), w("");
|
|
3099
4186
|
},
|
|
3100
4187
|
children: "Cancel"
|
|
3101
|
-
}), /* @__PURE__ */
|
|
4188
|
+
}), /* @__PURE__ */ $(v, {
|
|
3102
4189
|
variant: "destructive",
|
|
3103
4190
|
size: "sm",
|
|
3104
|
-
onClick: () => h && void
|
|
4191
|
+
onClick: () => h && void R(h, _),
|
|
3105
4192
|
disabled: !h || T === h,
|
|
3106
4193
|
"data-testid": "ai-inbox-reject-confirm",
|
|
3107
|
-
children: [/* @__PURE__ */
|
|
4194
|
+
children: [/* @__PURE__ */ Q(X, { className: "h-3.5 w-3.5 mr-1" }), "Reject"]
|
|
3108
4195
|
})]
|
|
3109
4196
|
})]
|
|
3110
4197
|
})]
|
|
@@ -3114,14 +4201,14 @@ function ai({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
|
|
|
3114
4201
|
}
|
|
3115
4202
|
//#endregion
|
|
3116
4203
|
//#region src/useHitlInChat.ts
|
|
3117
|
-
function
|
|
4204
|
+
function fa(e) {
|
|
3118
4205
|
return !e || e.length === 0 ? "/api/v1/ai" : e.endsWith("/") ? e.slice(0, -1) : e;
|
|
3119
4206
|
}
|
|
3120
|
-
function
|
|
4207
|
+
function pa(e, t) {
|
|
3121
4208
|
let n = { ...e ?? {} };
|
|
3122
4209
|
return t && (n["Content-Type"] = "application/json"), n;
|
|
3123
4210
|
}
|
|
3124
|
-
async function
|
|
4211
|
+
async function ma(e) {
|
|
3125
4212
|
let t = await e.text();
|
|
3126
4213
|
if (!t) return null;
|
|
3127
4214
|
try {
|
|
@@ -3130,8 +4217,8 @@ async function ci(e) {
|
|
|
3130
4217
|
return { raw: t };
|
|
3131
4218
|
}
|
|
3132
4219
|
}
|
|
3133
|
-
function
|
|
3134
|
-
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(() => {
|
|
3135
4222
|
let e = /* @__PURE__ */ new Map();
|
|
3136
4223
|
for (let t of n) {
|
|
3137
4224
|
let n = t.toolInvocations ?? [];
|
|
@@ -3174,9 +4261,9 @@ function li(t) {
|
|
|
3174
4261
|
let r = `${s}/pending-actions/${encodeURIComponent(l)}/${t ? "approve" : "reject"}`, c = t ? "{}" : JSON.stringify({ reason: n ?? "" }), d = await fetch(r, {
|
|
3175
4262
|
method: "POST",
|
|
3176
4263
|
credentials: "include",
|
|
3177
|
-
headers:
|
|
4264
|
+
headers: pa(i, !0),
|
|
3178
4265
|
body: c
|
|
3179
|
-
}), f = await
|
|
4266
|
+
}), f = await ma(d) ?? {};
|
|
3180
4267
|
if (!d.ok) {
|
|
3181
4268
|
let t = typeof f.error == "string" ? f.error : `Approval failed: HTTP ${d.status}`;
|
|
3182
4269
|
m(e, {
|
|
@@ -3203,7 +4290,7 @@ function li(t) {
|
|
|
3203
4290
|
state: "success",
|
|
3204
4291
|
message: `Status: ${p}`
|
|
3205
4292
|
}), h = !0), a?.(e, f), h && o) {
|
|
3206
|
-
let r =
|
|
4293
|
+
let r = ga({
|
|
3207
4294
|
approved: t,
|
|
3208
4295
|
status: p,
|
|
3209
4296
|
toolName: u,
|
|
@@ -3238,24 +4325,24 @@ function li(t) {
|
|
|
3238
4325
|
isDeciding: f
|
|
3239
4326
|
};
|
|
3240
4327
|
}
|
|
3241
|
-
function
|
|
4328
|
+
function ga(e) {
|
|
3242
4329
|
let { approved: t, status: n, toolName: r, pendingActionId: i, outcome: a, reason: o } = e, s = `[HITL ${i}]`;
|
|
3243
4330
|
if (t && n === "executed") {
|
|
3244
4331
|
let e = a.result;
|
|
3245
|
-
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.`;
|
|
3246
4333
|
}
|
|
3247
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.`;
|
|
3248
4335
|
if (n === "failed") {
|
|
3249
4336
|
let e = a.error;
|
|
3250
|
-
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.`;
|
|
3251
4338
|
}
|
|
3252
4339
|
}
|
|
3253
|
-
function
|
|
4340
|
+
function _a(e, t) {
|
|
3254
4341
|
return e.length <= t ? e : `${e.slice(0, t - 1)}…`;
|
|
3255
4342
|
}
|
|
3256
4343
|
//#endregion
|
|
3257
4344
|
//#region src/index.tsx
|
|
3258
|
-
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) => {
|
|
3259
4346
|
let [m, h] = e.useState(""), g = e.useRef(null), _ = e.useRef(null);
|
|
3260
4347
|
e.useEffect(() => {
|
|
3261
4348
|
if (g.current) {
|
|
@@ -3268,20 +4355,20 @@ var fi = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
3268
4355
|
}, b = (e) => {
|
|
3269
4356
|
e.key === "Enter" && !e.shiftKey && (e.preventDefault(), y());
|
|
3270
4357
|
};
|
|
3271
|
-
return /* @__PURE__ */
|
|
4358
|
+
return /* @__PURE__ */ $("div", {
|
|
3272
4359
|
ref: p,
|
|
3273
|
-
className:
|
|
4360
|
+
className: J("flex flex-col border rounded-lg bg-background overflow-hidden", t),
|
|
3274
4361
|
style: { maxHeight: d },
|
|
3275
4362
|
...f,
|
|
3276
|
-
children: [/* @__PURE__ */
|
|
4363
|
+
children: [/* @__PURE__ */ Q(se, {
|
|
3277
4364
|
ref: g,
|
|
3278
4365
|
className: "flex-1 p-4",
|
|
3279
|
-
children: /* @__PURE__ */
|
|
4366
|
+
children: /* @__PURE__ */ Q("div", {
|
|
3280
4367
|
className: "space-y-4",
|
|
3281
|
-
children: n.length === 0 ? /* @__PURE__ */
|
|
4368
|
+
children: n.length === 0 ? /* @__PURE__ */ Q("div", {
|
|
3282
4369
|
className: "flex items-center justify-center h-32 text-muted-foreground text-sm",
|
|
3283
4370
|
children: "No messages yet. Start a conversation!"
|
|
3284
|
-
}) : n.map((e) => /* @__PURE__ */
|
|
4371
|
+
}) : n.map((e) => /* @__PURE__ */ Q(ya, {
|
|
3285
4372
|
message: e,
|
|
3286
4373
|
showTimestamp: o,
|
|
3287
4374
|
userAvatarUrl: s,
|
|
@@ -3290,11 +4377,11 @@ var fi = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
3290
4377
|
assistantAvatarFallback: u
|
|
3291
4378
|
}, e.id))
|
|
3292
4379
|
})
|
|
3293
|
-
}), /* @__PURE__ */
|
|
4380
|
+
}), /* @__PURE__ */ Q("div", {
|
|
3294
4381
|
className: "border-t p-4",
|
|
3295
|
-
children: /* @__PURE__ */
|
|
4382
|
+
children: /* @__PURE__ */ $("div", {
|
|
3296
4383
|
className: "flex gap-2",
|
|
3297
|
-
children: [/* @__PURE__ */
|
|
4384
|
+
children: [/* @__PURE__ */ Q(z, {
|
|
3298
4385
|
ref: _,
|
|
3299
4386
|
value: m,
|
|
3300
4387
|
onChange: (e) => h(e.target.value),
|
|
@@ -3302,71 +4389,71 @@ var fi = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
3302
4389
|
placeholder: r,
|
|
3303
4390
|
disabled: a,
|
|
3304
4391
|
className: "flex-1"
|
|
3305
|
-
}), /* @__PURE__ */
|
|
4392
|
+
}), /* @__PURE__ */ Q(v, {
|
|
3306
4393
|
onClick: y,
|
|
3307
4394
|
disabled: a || !m.trim(),
|
|
3308
4395
|
size: "icon",
|
|
3309
|
-
children: /* @__PURE__ */
|
|
4396
|
+
children: /* @__PURE__ */ Q(lt, { className: "h-4 w-4" })
|
|
3310
4397
|
})]
|
|
3311
4398
|
})
|
|
3312
4399
|
})]
|
|
3313
4400
|
});
|
|
3314
4401
|
});
|
|
3315
|
-
|
|
3316
|
-
var
|
|
4402
|
+
va.displayName = "Chatbot";
|
|
4403
|
+
var ya = ({ message: e, showTimestamp: t, userAvatarUrl: n, userAvatarFallback: r, assistantAvatarUrl: i, assistantAvatarFallback: a }) => {
|
|
3317
4404
|
let o = e.role === "user";
|
|
3318
|
-
if (e.role === "system") return /* @__PURE__ */
|
|
4405
|
+
if (e.role === "system") return /* @__PURE__ */ Q("div", {
|
|
3319
4406
|
className: "flex justify-center",
|
|
3320
|
-
children: /* @__PURE__ */
|
|
4407
|
+
children: /* @__PURE__ */ Q("div", {
|
|
3321
4408
|
className: "text-xs text-muted-foreground bg-muted px-3 py-1 rounded-full",
|
|
3322
4409
|
children: e.content
|
|
3323
4410
|
})
|
|
3324
4411
|
});
|
|
3325
4412
|
let s = o ? e.avatar || n : e.avatar || i, c = o ? e.avatarFallback || r : e.avatarFallback || a;
|
|
3326
|
-
return /* @__PURE__ */
|
|
3327
|
-
className:
|
|
3328
|
-
children: [/* @__PURE__ */
|
|
4413
|
+
return /* @__PURE__ */ $("div", {
|
|
4414
|
+
className: J("flex gap-3", o ? "flex-row-reverse" : "flex-row"),
|
|
4415
|
+
children: [/* @__PURE__ */ $(m, {
|
|
3329
4416
|
className: "h-8 w-8",
|
|
3330
|
-
children: [/* @__PURE__ */
|
|
4417
|
+
children: [/* @__PURE__ */ Q(g, { src: s }), /* @__PURE__ */ Q(h, {
|
|
3331
4418
|
className: "text-xs",
|
|
3332
4419
|
children: c
|
|
3333
4420
|
})]
|
|
3334
|
-
}), /* @__PURE__ */
|
|
3335
|
-
className:
|
|
3336
|
-
children: [/* @__PURE__ */
|
|
3337
|
-
className:
|
|
3338
|
-
children: /* @__PURE__ */
|
|
4421
|
+
}), /* @__PURE__ */ $("div", {
|
|
4422
|
+
className: J("flex flex-col gap-1", o ? "items-end" : "items-start"),
|
|
4423
|
+
children: [/* @__PURE__ */ Q("div", {
|
|
4424
|
+
className: J("rounded-lg px-4 py-2 max-w-[70%] break-words", o ? "bg-primary text-primary-foreground" : "bg-muted"),
|
|
4425
|
+
children: /* @__PURE__ */ Q("p", {
|
|
3339
4426
|
className: "text-sm whitespace-pre-wrap",
|
|
3340
4427
|
children: e.content
|
|
3341
4428
|
})
|
|
3342
|
-
}), t && e.timestamp && /* @__PURE__ */
|
|
4429
|
+
}), t && e.timestamp && /* @__PURE__ */ Q("span", {
|
|
3343
4430
|
className: "text-xs text-muted-foreground",
|
|
3344
4431
|
children: e.timestamp
|
|
3345
4432
|
})]
|
|
3346
4433
|
})]
|
|
3347
4434
|
});
|
|
3348
|
-
},
|
|
4435
|
+
}, ba = e.forwardRef(({ className: e, avatarSrc: t, avatarFallback: n = "AI", ...r }, i) => /* @__PURE__ */ $("div", {
|
|
3349
4436
|
ref: i,
|
|
3350
|
-
className:
|
|
4437
|
+
className: J("flex gap-3", e),
|
|
3351
4438
|
...r,
|
|
3352
|
-
children: [/* @__PURE__ */
|
|
4439
|
+
children: [/* @__PURE__ */ $(m, {
|
|
3353
4440
|
className: "h-8 w-8",
|
|
3354
|
-
children: [/* @__PURE__ */
|
|
4441
|
+
children: [/* @__PURE__ */ Q(g, { src: t }), /* @__PURE__ */ Q(h, {
|
|
3355
4442
|
className: "text-xs",
|
|
3356
4443
|
children: n
|
|
3357
4444
|
})]
|
|
3358
|
-
}), /* @__PURE__ */
|
|
4445
|
+
}), /* @__PURE__ */ Q("div", {
|
|
3359
4446
|
className: "flex items-center bg-muted rounded-lg px-4 py-2",
|
|
3360
|
-
children: /* @__PURE__ */
|
|
4447
|
+
children: /* @__PURE__ */ $("div", {
|
|
3361
4448
|
className: "flex gap-1",
|
|
3362
4449
|
children: [
|
|
3363
|
-
/* @__PURE__ */
|
|
3364
|
-
/* @__PURE__ */
|
|
3365
|
-
/* @__PURE__ */
|
|
4450
|
+
/* @__PURE__ */ Q("span", { className: "w-2 h-2 bg-muted-foreground rounded-full animate-bounce [animation-delay:-0.3s]" }),
|
|
4451
|
+
/* @__PURE__ */ Q("span", { className: "w-2 h-2 bg-muted-foreground rounded-full animate-bounce [animation-delay:-0.15s]" }),
|
|
4452
|
+
/* @__PURE__ */ Q("span", { className: "w-2 h-2 bg-muted-foreground rounded-full animate-bounce" })
|
|
3366
4453
|
]
|
|
3367
4454
|
})
|
|
3368
4455
|
})]
|
|
3369
4456
|
}));
|
|
3370
|
-
|
|
4457
|
+
ba.displayName = "TypingIndicator";
|
|
3371
4458
|
//#endregion
|
|
3372
|
-
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 };
|