@object-ui/plugin-chatbot 6.1.0 → 6.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +44 -0
- package/dist/index.js +783 -691
- package/dist/index.umd.cjs +1 -1
- package/dist/packages/plugin-chatbot/src/ChatbotEnhanced.d.ts.map +1 -1
- package/dist/packages/plugin-chatbot/src/elements/tool.d.ts +2 -2
- package/dist/packages/plugin-chatbot/src/elements/tool.d.ts.map +1 -1
- package/dist/packages/plugin-chatbot/src/index.d.ts +1 -0
- package/dist/packages/plugin-chatbot/src/index.d.ts.map +1 -1
- package/dist/packages/plugin-chatbot/src/tool-display.d.ts +41 -0
- package/dist/packages/plugin-chatbot/src/tool-display.d.ts.map +1 -0
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
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 P, DropdownMenuContent as F, DropdownMenuItem as I, DropdownMenuTrigger as L, Empty as ee, EmptyDescription as te, EmptyHeader as ne, EmptyMedia as re, EmptyTitle as ie, HoverCard as R, HoverCardContent as ae, HoverCardTrigger 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 P, DropdownMenuContent as F, DropdownMenuItem as I, DropdownMenuTrigger as L, Empty as ee, EmptyDescription as te, EmptyHeader as ne, EmptyMedia as re, EmptyTitle as ie, HoverCard as R, HoverCardContent as ae, HoverCardTrigger as oe, Input as se, Label as z, ScrollArea as ce, ScrollBar as le, Select as ue, SelectContent as de, SelectItem as fe, SelectTrigger as pe, SelectValue as me, Separator as he, Sheet as ge, SheetContent as _e, SheetDescription as ve, SheetHeader as ye, SheetTitle as be, Skeleton as xe, Table as Se, TableBody as Ce, TableCell as B, TableHead as V, TableHeader as we, TableRow as Te, Tabs as Ee, TabsList as De, TabsTrigger as Oe, Textarea as ke, Tooltip as Ae, TooltipContent as je, TooltipProvider as Me, TooltipTrigger as Ne, cn as H } from "@object-ui/components";
|
|
4
|
+
import { AlertCircle as Pe, ArrowDownIcon as Fe, BookIcon as Ie, Bot as Le, BrainIcon as Re, Check as ze, CheckCircle2 as Be, CheckCircleIcon as Ve, CheckIcon as He, ChevronDownIcon as Ue, ChevronLeftIcon as We, ChevronRightIcon as Ge, CircleIcon as Ke, Clock as qe, ClockIcon as Je, Copy as Ye, CopyIcon as Xe, CornerDownLeft as Ze, CornerDownLeftIcon as Qe, Eye as $e, ImageIcon as et, Inbox as tt, Loader2Icon as nt, Maximize2 as rt, MicIcon as it, Minimize2 as at, PaperclipIcon as ot, PlusIcon as st, RefreshCw as ct, Send as lt, SquareIcon as ut, WrenchIcon as dt, X as ft, XCircle as U, XCircleIcon as pt, XIcon as W } from "lucide-react";
|
|
5
|
+
import { Fragment as G, jsx as K, jsxs as q } from "react/jsx-runtime";
|
|
6
|
+
import { useChat as mt } from "@ai-sdk/react";
|
|
7
|
+
import { DefaultChatTransport as ht } from "ai";
|
|
8
|
+
import * as gt from "react-dom";
|
|
9
|
+
import { useObjectTranslation as _t } from "@object-ui/react";
|
|
10
|
+
import { StickToBottom as vt, useStickToBottomContext as yt } from "use-stick-to-bottom";
|
|
11
|
+
import { cva as bt } from "class-variance-authority";
|
|
12
|
+
import { Slot as xt } from "@radix-ui/react-slot";
|
|
13
|
+
import { Streamdown as St } from "streamdown";
|
|
14
|
+
import { nanoid as Ct } from "nanoid";
|
|
15
|
+
import { codeToHtml as wt } from "shiki";
|
|
16
|
+
import { useControllableState as Tt } from "@radix-ui/react-use-controllable-state";
|
|
17
|
+
import { motion as Et } from "motion/react";
|
|
18
|
+
import { ComponentRegistry as J } from "@object-ui/core";
|
|
19
19
|
//#region \0rolldown/runtime.js
|
|
20
20
|
var Dt = Object.defineProperty, Ot = (e, t) => {
|
|
21
21
|
let n = {};
|
|
@@ -122,9 +122,9 @@ function Y(e = {}) {
|
|
|
122
122
|
type: "text",
|
|
123
123
|
text: e.content ?? ""
|
|
124
124
|
}]
|
|
125
|
-
})), []), C =
|
|
125
|
+
})), []), C = mt({
|
|
126
126
|
transport: l(() => {
|
|
127
|
-
if (x) return new
|
|
127
|
+
if (x) return new ht({
|
|
128
128
|
api: t,
|
|
129
129
|
headers: { ...f },
|
|
130
130
|
body: {
|
|
@@ -300,7 +300,7 @@ function Vt({ defaultOpen: t = !1, children: n }) {
|
|
|
300
300
|
toggle: () => i((e) => !e),
|
|
301
301
|
toggleFullscreen: () => o((e) => !e)
|
|
302
302
|
}), [r, a]);
|
|
303
|
-
return /* @__PURE__ */
|
|
303
|
+
return /* @__PURE__ */ K(Bt.Provider, {
|
|
304
304
|
value: s,
|
|
305
305
|
children: n
|
|
306
306
|
});
|
|
@@ -314,7 +314,7 @@ function Ht() {
|
|
|
314
314
|
//#region src/FloatingChatbotTrigger.tsx
|
|
315
315
|
function Ut() {
|
|
316
316
|
try {
|
|
317
|
-
let { t: e } =
|
|
317
|
+
let { t: e } = _t();
|
|
318
318
|
return (t, n) => {
|
|
319
319
|
let r = e(`common.${t}`);
|
|
320
320
|
return !r || r === `common.${t}` ? n : r;
|
|
@@ -325,9 +325,9 @@ function Ut() {
|
|
|
325
325
|
}
|
|
326
326
|
function Wt({ position: e = "bottom-right", size: t = 56, className: n }) {
|
|
327
327
|
let { isOpen: r, toggle: i } = Ht(), a = Ut();
|
|
328
|
-
return /* @__PURE__ */
|
|
328
|
+
return /* @__PURE__ */ K(v, {
|
|
329
329
|
onClick: i,
|
|
330
|
-
className:
|
|
330
|
+
className: H("fixed z-50 rounded-full shadow-lg transition-transform hover:scale-105", e === "bottom-right" ? "right-6 bottom-20 sm:bottom-6" : "left-6 bottom-20 sm:bottom-6", n),
|
|
331
331
|
style: {
|
|
332
332
|
width: t,
|
|
333
333
|
height: t
|
|
@@ -335,7 +335,7 @@ function Wt({ position: e = "bottom-right", size: t = 56, className: n }) {
|
|
|
335
335
|
size: "icon",
|
|
336
336
|
"aria-label": r ? a("closeChat", "Close chat") : a("openChat", "Open chat"),
|
|
337
337
|
"data-testid": "floating-chatbot-trigger",
|
|
338
|
-
children:
|
|
338
|
+
children: K(r ? ft : Le, { className: "h-6 w-6" })
|
|
339
339
|
});
|
|
340
340
|
}
|
|
341
341
|
//#endregion
|
|
@@ -352,146 +352,197 @@ function Gt({ title: e = "Chat", position: t = "bottom-right", width: n = 400, h
|
|
|
352
352
|
height: r,
|
|
353
353
|
maxHeight: "calc(100vh - 100px)"
|
|
354
354
|
};
|
|
355
|
-
return /* @__PURE__ */
|
|
356
|
-
className:
|
|
355
|
+
return /* @__PURE__ */ q("div", {
|
|
356
|
+
className: H("fixed z-50 flex flex-col rounded-lg border bg-background shadow-xl overflow-hidden transition-all", c ? "inset-0 rounded-none" : t === "bottom-right" ? "right-6 bottom-20" : "left-6 bottom-20", a),
|
|
357
357
|
style: d,
|
|
358
358
|
role: "dialog",
|
|
359
359
|
"aria-label": e,
|
|
360
360
|
"data-testid": "floating-chatbot-panel",
|
|
361
|
-
children: [/* @__PURE__ */
|
|
361
|
+
children: [/* @__PURE__ */ q("div", {
|
|
362
362
|
className: "flex items-center justify-between gap-2 px-4 py-2 border-b bg-muted/40",
|
|
363
363
|
children: [
|
|
364
|
-
/* @__PURE__ */
|
|
364
|
+
/* @__PURE__ */ K("span", {
|
|
365
365
|
className: "text-sm font-medium truncate shrink-0",
|
|
366
366
|
children: e
|
|
367
367
|
}),
|
|
368
|
-
o ? /* @__PURE__ */
|
|
368
|
+
o ? /* @__PURE__ */ K("div", {
|
|
369
369
|
className: "flex-1 min-w-0 flex items-center justify-end mr-1",
|
|
370
370
|
"data-testid": "floating-chatbot-header-extra",
|
|
371
371
|
children: o
|
|
372
372
|
}) : null,
|
|
373
|
-
/* @__PURE__ */
|
|
373
|
+
/* @__PURE__ */ q("div", {
|
|
374
374
|
className: "flex items-center gap-1 shrink-0",
|
|
375
|
-
children: [/* @__PURE__ */
|
|
375
|
+
children: [/* @__PURE__ */ K(v, {
|
|
376
376
|
variant: "ghost",
|
|
377
377
|
size: "icon",
|
|
378
378
|
className: "h-7 w-7",
|
|
379
379
|
onClick: u,
|
|
380
380
|
"aria-label": c ? "Exit fullscreen" : "Fullscreen",
|
|
381
381
|
"data-testid": "floating-chatbot-fullscreen",
|
|
382
|
-
children:
|
|
383
|
-
}), /* @__PURE__ */
|
|
382
|
+
children: K(c ? at : rt, { className: "h-4 w-4" })
|
|
383
|
+
}), /* @__PURE__ */ K(v, {
|
|
384
384
|
variant: "ghost",
|
|
385
385
|
size: "icon",
|
|
386
386
|
className: "h-7 w-7",
|
|
387
387
|
onClick: l,
|
|
388
388
|
"aria-label": "Close chat",
|
|
389
389
|
"data-testid": "floating-chatbot-close",
|
|
390
|
-
children: /* @__PURE__ */
|
|
390
|
+
children: /* @__PURE__ */ K(ft, { className: "h-4 w-4" })
|
|
391
391
|
})]
|
|
392
392
|
})
|
|
393
393
|
]
|
|
394
|
-
}), /* @__PURE__ */
|
|
394
|
+
}), /* @__PURE__ */ K("div", {
|
|
395
395
|
className: "flex-1 overflow-hidden",
|
|
396
396
|
children: i
|
|
397
397
|
})]
|
|
398
398
|
});
|
|
399
399
|
}
|
|
400
400
|
//#endregion
|
|
401
|
+
//#region src/tool-display.ts
|
|
402
|
+
var Kt = {
|
|
403
|
+
ai: "AI",
|
|
404
|
+
api: "API",
|
|
405
|
+
crm: "CRM",
|
|
406
|
+
hitl: "HITL",
|
|
407
|
+
id: "ID",
|
|
408
|
+
ids: "IDs",
|
|
409
|
+
rag: "RAG",
|
|
410
|
+
sql: "SQL",
|
|
411
|
+
url: "URL",
|
|
412
|
+
utc: "UTC"
|
|
413
|
+
};
|
|
414
|
+
function qt(e) {
|
|
415
|
+
if (!e) return "";
|
|
416
|
+
let t = String(e).trim();
|
|
417
|
+
if (!t) return "";
|
|
418
|
+
let n = t.replace(/[_-]+/g, " ").replace(/([a-z])([A-Z])/g, "$1 $2").split(/\s+/).filter(Boolean);
|
|
419
|
+
return n.length === 0 ? t : n.map((e, t) => {
|
|
420
|
+
let n = e.toLowerCase();
|
|
421
|
+
return Kt[n] ? Kt[n] : t === 0 ? n.charAt(0).toUpperCase() + n.slice(1) : n;
|
|
422
|
+
}).join(" ");
|
|
423
|
+
}
|
|
424
|
+
function Jt(e) {
|
|
425
|
+
if (e == null) return e;
|
|
426
|
+
let t = e;
|
|
427
|
+
for (let e = 0; e < 2; e++) {
|
|
428
|
+
if (typeof t == "object" && t && !Array.isArray(t) && t.type === "text" && typeof t.value == "string") {
|
|
429
|
+
t = t.value;
|
|
430
|
+
continue;
|
|
431
|
+
}
|
|
432
|
+
break;
|
|
433
|
+
}
|
|
434
|
+
if (typeof t == "string") {
|
|
435
|
+
let e = t.trim();
|
|
436
|
+
if (e.startsWith("{") && e.endsWith("}") || e.startsWith("[") && e.endsWith("]")) try {
|
|
437
|
+
return JSON.parse(e);
|
|
438
|
+
} catch {}
|
|
439
|
+
}
|
|
440
|
+
return t;
|
|
441
|
+
}
|
|
442
|
+
function Yt(e) {
|
|
443
|
+
let t = (e instanceof Error ? e.message : String(e ?? "")).replace(/\s+/g, " ").trim();
|
|
444
|
+
if (!t) return { summary: "Something went wrong. Please try again." };
|
|
445
|
+
let n = t.replace(/^Failed after \d+ attempts?\.\s*Last error:\s*/i, ""), r = n.match(/^([^.;:]+[.;:!?])\s/)?.[1]?.trim() ?? (n.length > 140 ? `${n.slice(0, 137).trimEnd()}…` : n);
|
|
446
|
+
return {
|
|
447
|
+
summary: r,
|
|
448
|
+
details: n.length > r.length ? n : void 0
|
|
449
|
+
};
|
|
450
|
+
}
|
|
451
|
+
//#endregion
|
|
401
452
|
//#region src/elements/conversation.tsx
|
|
402
|
-
var
|
|
403
|
-
className:
|
|
453
|
+
var Xt = ({ className: e, ...t }) => /* @__PURE__ */ K(vt, {
|
|
454
|
+
className: H("relative flex-1 overflow-y-hidden", e),
|
|
404
455
|
initial: "smooth",
|
|
405
456
|
resize: "smooth",
|
|
406
457
|
role: "log",
|
|
407
458
|
...t
|
|
408
|
-
}),
|
|
409
|
-
className:
|
|
459
|
+
}), Zt = ({ className: e, ...t }) => /* @__PURE__ */ K(vt.Content, {
|
|
460
|
+
className: H("flex flex-col gap-8 p-4", e),
|
|
410
461
|
...t
|
|
411
|
-
}),
|
|
412
|
-
className:
|
|
462
|
+
}), Qt = ({ className: e, title: t = "No messages yet", description: n = "Start a conversation to see messages here", icon: r, children: i, ...a }) => /* @__PURE__ */ K("div", {
|
|
463
|
+
className: H("flex size-full flex-col items-center justify-center gap-3 p-8 text-center", e),
|
|
413
464
|
...a,
|
|
414
|
-
children: i ?? /* @__PURE__ */
|
|
465
|
+
children: i ?? /* @__PURE__ */ q(G, { children: [r && /* @__PURE__ */ K("div", {
|
|
415
466
|
className: "text-muted-foreground",
|
|
416
467
|
children: r
|
|
417
|
-
}), /* @__PURE__ */
|
|
468
|
+
}), /* @__PURE__ */ q("div", {
|
|
418
469
|
className: "space-y-1",
|
|
419
|
-
children: [/* @__PURE__ */
|
|
470
|
+
children: [/* @__PURE__ */ K("h3", {
|
|
420
471
|
className: "font-medium text-sm",
|
|
421
472
|
children: t
|
|
422
|
-
}), n && /* @__PURE__ */
|
|
473
|
+
}), n && /* @__PURE__ */ K("p", {
|
|
423
474
|
className: "text-muted-foreground text-sm",
|
|
424
475
|
children: n
|
|
425
476
|
})]
|
|
426
477
|
})] })
|
|
427
|
-
}),
|
|
428
|
-
let { isAtBottom: n, scrollToBottom: r } =
|
|
478
|
+
}), $t = ({ className: e, ...t }) => {
|
|
479
|
+
let { isAtBottom: n, scrollToBottom: r } = yt(), i = o(() => {
|
|
429
480
|
r();
|
|
430
481
|
}, [r]);
|
|
431
|
-
return !n && /* @__PURE__ */
|
|
432
|
-
className:
|
|
482
|
+
return !n && /* @__PURE__ */ K(v, {
|
|
483
|
+
className: H("absolute bottom-4 left-[50%] translate-x-[-50%] rounded-full", e),
|
|
433
484
|
onClick: i,
|
|
434
485
|
size: "icon",
|
|
435
486
|
type: "button",
|
|
436
487
|
variant: "outline",
|
|
437
488
|
...t,
|
|
438
|
-
children: /* @__PURE__ */
|
|
489
|
+
children: /* @__PURE__ */ K(Fe, { className: "size-4" })
|
|
439
490
|
});
|
|
440
|
-
},
|
|
491
|
+
}, en = bt("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", {
|
|
441
492
|
variants: { orientation: {
|
|
442
493
|
horizontal: "[&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0 [&>*:not(:last-child)]:rounded-r-none",
|
|
443
494
|
vertical: "flex-col [&>*:not(:first-child)]:rounded-t-none [&>*:not(:first-child)]:border-t-0 [&>*:not(:last-child)]:rounded-b-none"
|
|
444
495
|
} },
|
|
445
496
|
defaultVariants: { orientation: "horizontal" }
|
|
446
497
|
});
|
|
447
|
-
function
|
|
448
|
-
return /* @__PURE__ */
|
|
498
|
+
function tn({ className: e, orientation: t, ...n }) {
|
|
499
|
+
return /* @__PURE__ */ K("div", {
|
|
449
500
|
role: "group",
|
|
450
501
|
"data-slot": "button-group",
|
|
451
502
|
"data-orientation": t,
|
|
452
|
-
className:
|
|
503
|
+
className: H(en({ orientation: t }), e),
|
|
453
504
|
...n
|
|
454
505
|
});
|
|
455
506
|
}
|
|
456
|
-
function
|
|
457
|
-
return /* @__PURE__ */
|
|
458
|
-
className:
|
|
507
|
+
function nn({ className: e, asChild: t = !1, ...n }) {
|
|
508
|
+
return /* @__PURE__ */ K(t ? xt : "div", {
|
|
509
|
+
className: H("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),
|
|
459
510
|
...n
|
|
460
511
|
});
|
|
461
512
|
}
|
|
462
513
|
//#endregion
|
|
463
514
|
//#region src/elements/message.tsx
|
|
464
|
-
var
|
|
465
|
-
className:
|
|
515
|
+
var rn = ({ className: e, from: t, ...n }) => /* @__PURE__ */ K("div", {
|
|
516
|
+
className: H("group flex w-full max-w-[95%] flex-col gap-2", t === "user" ? "is-user ml-auto justify-end" : "is-assistant", e),
|
|
466
517
|
...n
|
|
467
|
-
}),
|
|
468
|
-
className:
|
|
518
|
+
}), an = ({ children: e, className: t, ...n }) => /* @__PURE__ */ K("div", {
|
|
519
|
+
className: H("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),
|
|
469
520
|
...n,
|
|
470
521
|
children: e
|
|
471
|
-
}),
|
|
472
|
-
className:
|
|
522
|
+
}), on = ({ className: e, children: t, ...n }) => /* @__PURE__ */ K("div", {
|
|
523
|
+
className: H("flex items-center gap-1", e),
|
|
473
524
|
...n,
|
|
474
525
|
children: t
|
|
475
|
-
}),
|
|
476
|
-
let o = /* @__PURE__ */
|
|
526
|
+
}), sn = ({ tooltip: e, children: t, label: n, variant: r = "ghost", size: i = "icon", ...a }) => {
|
|
527
|
+
let o = /* @__PURE__ */ q(v, {
|
|
477
528
|
size: i,
|
|
478
529
|
type: "button",
|
|
479
530
|
variant: r,
|
|
480
531
|
...a,
|
|
481
|
-
children: [t, /* @__PURE__ */
|
|
532
|
+
children: [t, /* @__PURE__ */ K("span", {
|
|
482
533
|
className: "sr-only",
|
|
483
534
|
children: n || e
|
|
484
535
|
})]
|
|
485
536
|
});
|
|
486
|
-
return e ? /* @__PURE__ */
|
|
537
|
+
return e ? /* @__PURE__ */ K(Me, { children: /* @__PURE__ */ q(Ae, { children: [/* @__PURE__ */ K(Ne, {
|
|
487
538
|
asChild: !0,
|
|
488
539
|
children: o
|
|
489
|
-
}), /* @__PURE__ */
|
|
490
|
-
},
|
|
491
|
-
let e = s(
|
|
540
|
+
}), /* @__PURE__ */ K(je, { children: /* @__PURE__ */ K("p", { children: e }) })] }) }) : o;
|
|
541
|
+
}, cn = r(null), X = () => {
|
|
542
|
+
let e = s(cn);
|
|
492
543
|
if (!e) throw Error("MessageBranch components must be used within MessageBranch");
|
|
493
544
|
return e;
|
|
494
|
-
},
|
|
545
|
+
}, ln = ({ defaultBranch: e = 0, onBranchChange: t, className: n, ...r }) => {
|
|
495
546
|
let [i, a] = d(e), [o, s] = d([]), c = (e) => {
|
|
496
547
|
a(e), t?.(e);
|
|
497
548
|
}, l = {
|
|
@@ -506,14 +557,14 @@ var $t = ({ className: e, from: t, ...n }) => /* @__PURE__ */ q("div", {
|
|
|
506
557
|
branches: o,
|
|
507
558
|
setBranches: s
|
|
508
559
|
};
|
|
509
|
-
return /* @__PURE__ */
|
|
560
|
+
return /* @__PURE__ */ K(cn.Provider, {
|
|
510
561
|
value: l,
|
|
511
|
-
children: /* @__PURE__ */
|
|
512
|
-
className:
|
|
562
|
+
children: /* @__PURE__ */ K("div", {
|
|
563
|
+
className: H("grid w-full gap-2 [&>div]:pb-0", n),
|
|
513
564
|
...r
|
|
514
565
|
})
|
|
515
566
|
});
|
|
516
|
-
},
|
|
567
|
+
}, un = ({ children: e, ...t }) => {
|
|
517
568
|
let { currentBranch: n, setBranches: r, branches: i } = X(), a = Array.isArray(e) ? e : [e];
|
|
518
569
|
return c(() => {
|
|
519
570
|
i.length !== a.length && r(a);
|
|
@@ -521,21 +572,21 @@ var $t = ({ className: e, from: t, ...n }) => /* @__PURE__ */ q("div", {
|
|
|
521
572
|
a,
|
|
522
573
|
i,
|
|
523
574
|
r
|
|
524
|
-
]), a.map((e, r) => /* @__PURE__ */
|
|
525
|
-
className:
|
|
575
|
+
]), a.map((e, r) => /* @__PURE__ */ K("div", {
|
|
576
|
+
className: H("grid gap-2 overflow-hidden [&>div]:pb-0", r === n ? "block" : "hidden"),
|
|
526
577
|
...t,
|
|
527
578
|
children: e
|
|
528
579
|
}, e.key));
|
|
529
|
-
},
|
|
580
|
+
}, dn = ({ className: e, from: t, ...n }) => {
|
|
530
581
|
let { totalBranches: r } = X();
|
|
531
|
-
return r <= 1 ? null : /* @__PURE__ */
|
|
582
|
+
return r <= 1 ? null : /* @__PURE__ */ K(tn, {
|
|
532
583
|
className: "[&>*:not(:first-child)]:rounded-l-md [&>*:not(:last-child)]:rounded-r-md",
|
|
533
584
|
orientation: "horizontal",
|
|
534
585
|
...n
|
|
535
586
|
});
|
|
536
|
-
},
|
|
587
|
+
}, fn = ({ children: e, ...t }) => {
|
|
537
588
|
let { goToPrevious: n, totalBranches: r } = X();
|
|
538
|
-
return /* @__PURE__ */
|
|
589
|
+
return /* @__PURE__ */ K(v, {
|
|
539
590
|
"aria-label": "Previous branch",
|
|
540
591
|
disabled: r <= 1,
|
|
541
592
|
onClick: n,
|
|
@@ -543,11 +594,11 @@ var $t = ({ className: e, from: t, ...n }) => /* @__PURE__ */ q("div", {
|
|
|
543
594
|
type: "button",
|
|
544
595
|
variant: "ghost",
|
|
545
596
|
...t,
|
|
546
|
-
children: e ?? /* @__PURE__ */
|
|
597
|
+
children: e ?? /* @__PURE__ */ K(We, { size: 14 })
|
|
547
598
|
});
|
|
548
|
-
},
|
|
599
|
+
}, pn = ({ children: e, className: t, ...n }) => {
|
|
549
600
|
let { goToNext: r, totalBranches: i } = X();
|
|
550
|
-
return /* @__PURE__ */
|
|
601
|
+
return /* @__PURE__ */ K(v, {
|
|
551
602
|
"aria-label": "Next branch",
|
|
552
603
|
disabled: i <= 1,
|
|
553
604
|
onClick: r,
|
|
@@ -555,12 +606,12 @@ var $t = ({ className: e, from: t, ...n }) => /* @__PURE__ */ q("div", {
|
|
|
555
606
|
type: "button",
|
|
556
607
|
variant: "ghost",
|
|
557
608
|
...n,
|
|
558
|
-
children: e ?? /* @__PURE__ */
|
|
609
|
+
children: e ?? /* @__PURE__ */ K(Ge, { size: 14 })
|
|
559
610
|
});
|
|
560
|
-
},
|
|
611
|
+
}, mn = ({ className: e, ...t }) => {
|
|
561
612
|
let { currentBranch: n, totalBranches: r } = X();
|
|
562
|
-
return /* @__PURE__ */
|
|
563
|
-
className:
|
|
613
|
+
return /* @__PURE__ */ q(nn, {
|
|
614
|
+
className: H("border-none bg-transparent text-muted-foreground shadow-none", e),
|
|
564
615
|
...t,
|
|
565
616
|
children: [
|
|
566
617
|
n + 1,
|
|
@@ -568,23 +619,23 @@ var $t = ({ className: e, from: t, ...n }) => /* @__PURE__ */ q("div", {
|
|
|
568
619
|
r
|
|
569
620
|
]
|
|
570
621
|
});
|
|
571
|
-
},
|
|
572
|
-
className:
|
|
622
|
+
}, hn = a(({ className: e, ...t }) => /* @__PURE__ */ K(St, {
|
|
623
|
+
className: H("size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0", e),
|
|
573
624
|
...t
|
|
574
625
|
}), (e, t) => e.children === t.children);
|
|
575
|
-
|
|
576
|
-
function
|
|
626
|
+
hn.displayName = "MessageResponse";
|
|
627
|
+
function gn({ data: e, className: t, onRemove: n, ...r }) {
|
|
577
628
|
let i = e.filename || "", a = (e.mediaType?.startsWith("image/") && e.url ? "image" : "file") == "image", o = i || (a ? "Image" : "Attachment");
|
|
578
|
-
return /* @__PURE__ */
|
|
579
|
-
className:
|
|
629
|
+
return /* @__PURE__ */ K("div", {
|
|
630
|
+
className: H("group relative size-24 overflow-hidden rounded-lg", t),
|
|
580
631
|
...r,
|
|
581
|
-
children: a ? /* @__PURE__ */
|
|
632
|
+
children: a ? /* @__PURE__ */ q(G, { children: [/* @__PURE__ */ K("img", {
|
|
582
633
|
alt: i || "attachment",
|
|
583
634
|
className: "size-full object-cover",
|
|
584
635
|
height: 100,
|
|
585
636
|
src: e.url,
|
|
586
637
|
width: 100
|
|
587
|
-
}), n && /* @__PURE__ */
|
|
638
|
+
}), n && /* @__PURE__ */ q(v, {
|
|
588
639
|
"aria-label": "Remove attachment",
|
|
589
640
|
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",
|
|
590
641
|
onClick: (e) => {
|
|
@@ -592,17 +643,17 @@ function fn({ data: e, className: t, onRemove: n, ...r }) {
|
|
|
592
643
|
},
|
|
593
644
|
type: "button",
|
|
594
645
|
variant: "ghost",
|
|
595
|
-
children: [/* @__PURE__ */
|
|
646
|
+
children: [/* @__PURE__ */ K(W, {}), /* @__PURE__ */ K("span", {
|
|
596
647
|
className: "sr-only",
|
|
597
648
|
children: "Remove"
|
|
598
649
|
})]
|
|
599
|
-
})] }) : /* @__PURE__ */
|
|
650
|
+
})] }) : /* @__PURE__ */ q(G, { children: [/* @__PURE__ */ q(Ae, { children: [/* @__PURE__ */ K(Ne, {
|
|
600
651
|
asChild: !0,
|
|
601
|
-
children: /* @__PURE__ */
|
|
652
|
+
children: /* @__PURE__ */ K("div", {
|
|
602
653
|
className: "flex size-full shrink-0 items-center justify-center rounded-lg bg-muted text-muted-foreground",
|
|
603
|
-
children: /* @__PURE__ */
|
|
654
|
+
children: /* @__PURE__ */ K(ot, { className: "size-4" })
|
|
604
655
|
})
|
|
605
|
-
}), /* @__PURE__ */
|
|
656
|
+
}), /* @__PURE__ */ K(je, { children: /* @__PURE__ */ K("p", { children: o }) })] }), n && /* @__PURE__ */ q(v, {
|
|
606
657
|
"aria-label": "Remove attachment",
|
|
607
658
|
className: "size-6 shrink-0 rounded-full p-0 opacity-0 transition-opacity hover:bg-accent group-hover:opacity-100 [&>svg]:size-3",
|
|
608
659
|
onClick: (e) => {
|
|
@@ -610,36 +661,36 @@ function fn({ data: e, className: t, onRemove: n, ...r }) {
|
|
|
610
661
|
},
|
|
611
662
|
type: "button",
|
|
612
663
|
variant: "ghost",
|
|
613
|
-
children: [/* @__PURE__ */
|
|
664
|
+
children: [/* @__PURE__ */ K(W, {}), /* @__PURE__ */ K("span", {
|
|
614
665
|
className: "sr-only",
|
|
615
666
|
children: "Remove"
|
|
616
667
|
})]
|
|
617
668
|
})] })
|
|
618
669
|
});
|
|
619
670
|
}
|
|
620
|
-
function
|
|
621
|
-
return e ? /* @__PURE__ */
|
|
622
|
-
className:
|
|
671
|
+
function _n({ children: e, className: t, ...n }) {
|
|
672
|
+
return e ? /* @__PURE__ */ K("div", {
|
|
673
|
+
className: H("ml-auto flex w-fit flex-wrap items-start gap-2", t),
|
|
623
674
|
...n,
|
|
624
675
|
children: e
|
|
625
676
|
}) : null;
|
|
626
677
|
}
|
|
627
|
-
var
|
|
628
|
-
className:
|
|
678
|
+
var vn = ({ className: e, children: t, ...n }) => /* @__PURE__ */ K("div", {
|
|
679
|
+
className: H("mt-4 flex w-full items-center justify-between gap-4", e),
|
|
629
680
|
...n,
|
|
630
681
|
children: t
|
|
631
682
|
});
|
|
632
683
|
//#endregion
|
|
633
684
|
//#region src/elements/ui/input-group.tsx
|
|
634
|
-
function
|
|
635
|
-
return /* @__PURE__ */
|
|
685
|
+
function yn({ className: e, ...t }) {
|
|
686
|
+
return /* @__PURE__ */ K("div", {
|
|
636
687
|
"data-slot": "input-group",
|
|
637
688
|
role: "group",
|
|
638
|
-
className:
|
|
689
|
+
className: H("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),
|
|
639
690
|
...t
|
|
640
691
|
});
|
|
641
692
|
}
|
|
642
|
-
var
|
|
693
|
+
var bn = bt("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", {
|
|
643
694
|
variants: { align: {
|
|
644
695
|
"inline-start": "order-first pl-3 has-[>button]:ml-[-0.45rem] has-[>kbd]:ml-[-0.35rem]",
|
|
645
696
|
"inline-end": "order-last pr-3 has-[>button]:mr-[-0.45rem] has-[>kbd]:mr-[-0.35rem]",
|
|
@@ -648,19 +699,19 @@ var gn = yt("flex h-auto cursor-text items-center justify-center gap-2 py-1.5 te
|
|
|
648
699
|
} },
|
|
649
700
|
defaultVariants: { align: "inline-start" }
|
|
650
701
|
});
|
|
651
|
-
function
|
|
652
|
-
return /* @__PURE__ */
|
|
702
|
+
function xn({ className: e, align: t = "inline-start", ...n }) {
|
|
703
|
+
return /* @__PURE__ */ K("div", {
|
|
653
704
|
role: "group",
|
|
654
705
|
"data-slot": "input-group-addon",
|
|
655
706
|
"data-align": t,
|
|
656
|
-
className:
|
|
707
|
+
className: H(bn({ align: t }), e),
|
|
657
708
|
onClick: (e) => {
|
|
658
709
|
e.target.closest("button") || e.currentTarget.parentElement?.querySelector("input")?.focus();
|
|
659
710
|
},
|
|
660
711
|
...n
|
|
661
712
|
});
|
|
662
713
|
}
|
|
663
|
-
var
|
|
714
|
+
var Sn = bt("flex items-center gap-2 text-sm shadow-none", {
|
|
664
715
|
variants: { size: {
|
|
665
716
|
xs: "h-6 gap-1 rounded-[calc(var(--radius)-5px)] px-2 has-[>svg]:px-2 [&>svg:not([class*='size-'])]:size-3.5",
|
|
666
717
|
sm: "h-8 gap-1.5 rounded-md px-2.5 has-[>svg]:px-2.5",
|
|
@@ -669,38 +720,38 @@ var vn = yt("flex items-center gap-2 text-sm shadow-none", {
|
|
|
669
720
|
} },
|
|
670
721
|
defaultVariants: { size: "xs" }
|
|
671
722
|
});
|
|
672
|
-
function
|
|
673
|
-
return /* @__PURE__ */
|
|
723
|
+
function Cn({ className: e, type: t = "button", variant: n = "ghost", size: r = "xs", ...i }) {
|
|
724
|
+
return /* @__PURE__ */ K(v, {
|
|
674
725
|
type: t,
|
|
675
726
|
"data-size": r,
|
|
676
727
|
variant: n,
|
|
677
|
-
className:
|
|
728
|
+
className: H(Sn({ size: r }), e),
|
|
678
729
|
...i
|
|
679
730
|
});
|
|
680
731
|
}
|
|
681
|
-
function
|
|
682
|
-
return /* @__PURE__ */
|
|
732
|
+
function wn({ className: e, ...t }) {
|
|
733
|
+
return /* @__PURE__ */ K(ke, {
|
|
683
734
|
"data-slot": "input-group-control",
|
|
684
|
-
className:
|
|
735
|
+
className: H("flex-1 resize-none rounded-none border-0 bg-transparent py-3 shadow-none focus-visible:ring-0 dark:bg-transparent", e),
|
|
685
736
|
...t
|
|
686
737
|
});
|
|
687
738
|
}
|
|
688
739
|
//#endregion
|
|
689
740
|
//#region src/elements/prompt-input.tsx
|
|
690
|
-
var
|
|
691
|
-
let e = s(
|
|
741
|
+
var Tn = r(null), En = r(null), Dn = () => {
|
|
742
|
+
let e = s(Tn);
|
|
692
743
|
if (!e) throw Error("Wrap your component inside <PromptInputProvider> to use usePromptInputController().");
|
|
693
744
|
return e;
|
|
694
|
-
},
|
|
695
|
-
let e = s(
|
|
745
|
+
}, On = () => s(Tn), kn = () => {
|
|
746
|
+
let e = s(En);
|
|
696
747
|
if (!e) throw Error("Wrap your component inside <PromptInputProvider> to use useProviderAttachments().");
|
|
697
748
|
return e;
|
|
698
|
-
},
|
|
699
|
-
function
|
|
749
|
+
}, An = () => s(En);
|
|
750
|
+
function jn({ initialInput: e = "", children: t }) {
|
|
700
751
|
let [n, r] = d(e), i = o(() => r(""), []), [a, s] = d([]), f = u(null), p = u(() => {}), m = o((e) => {
|
|
701
752
|
let t = Array.from(e);
|
|
702
753
|
t.length !== 0 && s((e) => e.concat(t.map((e) => ({
|
|
703
|
-
id:
|
|
754
|
+
id: Ct(),
|
|
704
755
|
type: "file",
|
|
705
756
|
url: URL.createObjectURL(e),
|
|
706
757
|
mediaType: e.type,
|
|
@@ -751,41 +802,41 @@ function Dn({ initialInput: e = "", children: t }) {
|
|
|
751
802
|
y,
|
|
752
803
|
b
|
|
753
804
|
]);
|
|
754
|
-
return /* @__PURE__ */
|
|
805
|
+
return /* @__PURE__ */ K(Tn.Provider, {
|
|
755
806
|
value: x,
|
|
756
|
-
children: /* @__PURE__ */
|
|
807
|
+
children: /* @__PURE__ */ K(En.Provider, {
|
|
757
808
|
value: y,
|
|
758
809
|
children: t
|
|
759
810
|
})
|
|
760
811
|
});
|
|
761
812
|
}
|
|
762
|
-
var
|
|
763
|
-
let e =
|
|
813
|
+
var Mn = r(null), Z = () => {
|
|
814
|
+
let e = An(), t = s(Mn), n = e ?? t;
|
|
764
815
|
if (!n) throw Error("usePromptInputAttachments must be used within a PromptInput or PromptInputProvider");
|
|
765
816
|
return n;
|
|
766
817
|
};
|
|
767
|
-
function
|
|
818
|
+
function Nn({ data: e, className: t, ...n }) {
|
|
768
819
|
let r = Z(), i = e.filename || "", a = (e.mediaType?.startsWith("image/") && e.url ? "image" : "file") == "image", o = i || (a ? "Image" : "Attachment");
|
|
769
|
-
return /* @__PURE__ */
|
|
820
|
+
return /* @__PURE__ */ q(er, { children: [/* @__PURE__ */ K(oe, {
|
|
770
821
|
asChild: !0,
|
|
771
|
-
children: /* @__PURE__ */
|
|
772
|
-
className:
|
|
822
|
+
children: /* @__PURE__ */ q("div", {
|
|
823
|
+
className: H("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),
|
|
773
824
|
...n,
|
|
774
|
-
children: [/* @__PURE__ */
|
|
825
|
+
children: [/* @__PURE__ */ q("div", {
|
|
775
826
|
className: "relative size-5 shrink-0",
|
|
776
|
-
children: [/* @__PURE__ */
|
|
827
|
+
children: [/* @__PURE__ */ K("div", {
|
|
777
828
|
className: "absolute inset-0 flex size-5 items-center justify-center overflow-hidden rounded bg-background transition-opacity group-hover:opacity-0",
|
|
778
|
-
children: a ? /* @__PURE__ */
|
|
829
|
+
children: a ? /* @__PURE__ */ K("img", {
|
|
779
830
|
alt: i || "attachment",
|
|
780
831
|
className: "size-5 object-cover",
|
|
781
832
|
height: 20,
|
|
782
833
|
src: e.url,
|
|
783
834
|
width: 20
|
|
784
|
-
}) : /* @__PURE__ */
|
|
835
|
+
}) : /* @__PURE__ */ K("div", {
|
|
785
836
|
className: "flex size-5 items-center justify-center text-muted-foreground",
|
|
786
|
-
children: /* @__PURE__ */
|
|
837
|
+
children: /* @__PURE__ */ K(ot, { className: "size-3" })
|
|
787
838
|
})
|
|
788
|
-
}), /* @__PURE__ */
|
|
839
|
+
}), /* @__PURE__ */ q(v, {
|
|
789
840
|
"aria-label": "Remove attachment",
|
|
790
841
|
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",
|
|
791
842
|
onClick: (t) => {
|
|
@@ -793,37 +844,37 @@ function kn({ data: e, className: t, ...n }) {
|
|
|
793
844
|
},
|
|
794
845
|
type: "button",
|
|
795
846
|
variant: "ghost",
|
|
796
|
-
children: [/* @__PURE__ */
|
|
847
|
+
children: [/* @__PURE__ */ K(W, {}), /* @__PURE__ */ K("span", {
|
|
797
848
|
className: "sr-only",
|
|
798
849
|
children: "Remove"
|
|
799
850
|
})]
|
|
800
851
|
})]
|
|
801
|
-
}), /* @__PURE__ */
|
|
852
|
+
}), /* @__PURE__ */ K("span", {
|
|
802
853
|
className: "flex-1 truncate",
|
|
803
854
|
children: o
|
|
804
855
|
})]
|
|
805
856
|
}, e.id)
|
|
806
|
-
}), /* @__PURE__ */
|
|
857
|
+
}), /* @__PURE__ */ K(nr, {
|
|
807
858
|
className: "w-auto p-2",
|
|
808
|
-
children: /* @__PURE__ */
|
|
859
|
+
children: /* @__PURE__ */ q("div", {
|
|
809
860
|
className: "w-auto space-y-3",
|
|
810
|
-
children: [a && /* @__PURE__ */
|
|
861
|
+
children: [a && /* @__PURE__ */ K("div", {
|
|
811
862
|
className: "flex max-h-96 w-96 items-center justify-center overflow-hidden rounded-md border",
|
|
812
|
-
children: /* @__PURE__ */
|
|
863
|
+
children: /* @__PURE__ */ K("img", {
|
|
813
864
|
alt: i || "attachment preview",
|
|
814
865
|
className: "max-h-full max-w-full object-contain",
|
|
815
866
|
height: 384,
|
|
816
867
|
src: e.url,
|
|
817
868
|
width: 448
|
|
818
869
|
})
|
|
819
|
-
}), /* @__PURE__ */
|
|
870
|
+
}), /* @__PURE__ */ K("div", {
|
|
820
871
|
className: "flex items-center gap-2.5",
|
|
821
|
-
children: /* @__PURE__ */
|
|
872
|
+
children: /* @__PURE__ */ q("div", {
|
|
822
873
|
className: "min-w-0 flex-1 space-y-1 px-0.5",
|
|
823
|
-
children: [/* @__PURE__ */
|
|
874
|
+
children: [/* @__PURE__ */ K("h4", {
|
|
824
875
|
className: "truncate font-semibold text-sm leading-none",
|
|
825
876
|
children: i || (a ? "Image" : "Attachment")
|
|
826
|
-
}), e.mediaType && /* @__PURE__ */
|
|
877
|
+
}), e.mediaType && /* @__PURE__ */ K("p", {
|
|
827
878
|
className: "truncate font-mono text-muted-foreground text-xs",
|
|
828
879
|
children: e.mediaType
|
|
829
880
|
})]
|
|
@@ -832,29 +883,29 @@ function kn({ data: e, className: t, ...n }) {
|
|
|
832
883
|
})
|
|
833
884
|
})] });
|
|
834
885
|
}
|
|
835
|
-
function
|
|
886
|
+
function Pn({ children: e, className: t, ...r }) {
|
|
836
887
|
let i = Z();
|
|
837
|
-
return i.files.length ? /* @__PURE__ */
|
|
838
|
-
className:
|
|
888
|
+
return i.files.length ? /* @__PURE__ */ K("div", {
|
|
889
|
+
className: H("flex flex-wrap items-center gap-2 p-3 w-full", t),
|
|
839
890
|
...r,
|
|
840
|
-
children: i.files.map((t) => /* @__PURE__ */
|
|
891
|
+
children: i.files.map((t) => /* @__PURE__ */ K(n, { children: e(t) }, t.id))
|
|
841
892
|
}) : null;
|
|
842
893
|
}
|
|
843
|
-
var
|
|
894
|
+
var Fn = ({ label: e = "Add photos or files", ...t }) => {
|
|
844
895
|
let n = Z();
|
|
845
|
-
return /* @__PURE__ */
|
|
896
|
+
return /* @__PURE__ */ q(I, {
|
|
846
897
|
...t,
|
|
847
898
|
onSelect: (e) => {
|
|
848
899
|
e.preventDefault(), n.openFileDialog();
|
|
849
900
|
},
|
|
850
901
|
children: [
|
|
851
|
-
/* @__PURE__ */
|
|
902
|
+
/* @__PURE__ */ K(et, { className: "mr-2 size-4" }),
|
|
852
903
|
" ",
|
|
853
904
|
e
|
|
854
905
|
]
|
|
855
906
|
});
|
|
856
|
-
},
|
|
857
|
-
let g =
|
|
907
|
+
}, In = ({ className: e, accept: t, multiple: n, globalDrop: r, syncHiddenInput: i, maxFiles: a, maxFileSize: s, onError: f, onSubmit: p, children: m, ...h }) => {
|
|
908
|
+
let g = On(), _ = !!g, v = u(null), y = u(null), [b, x] = d([]), S = _ ? g.attachments.files : b, C = u(S);
|
|
858
909
|
C.current = S;
|
|
859
910
|
let w = o(() => {
|
|
860
911
|
v.current?.click();
|
|
@@ -889,7 +940,7 @@ var jn = ({ label: e = "Add photos or files", ...t }) => {
|
|
|
889
940
|
});
|
|
890
941
|
let i = [];
|
|
891
942
|
for (let e of n) i.push({
|
|
892
|
-
id:
|
|
943
|
+
id: Ct(),
|
|
893
944
|
type: "file",
|
|
894
945
|
url: URL.createObjectURL(e),
|
|
895
946
|
mediaType: e.type,
|
|
@@ -965,7 +1016,7 @@ var jn = ({ label: e = "Add photos or files", ...t }) => {
|
|
|
965
1016
|
A,
|
|
966
1017
|
j,
|
|
967
1018
|
M
|
|
968
|
-
]), I = /* @__PURE__ */
|
|
1019
|
+
]), I = /* @__PURE__ */ q(G, { children: [/* @__PURE__ */ K("input", {
|
|
969
1020
|
accept: t,
|
|
970
1021
|
"aria-label": "Upload files",
|
|
971
1022
|
className: "hidden",
|
|
@@ -974,8 +1025,8 @@ var jn = ({ label: e = "Add photos or files", ...t }) => {
|
|
|
974
1025
|
ref: v,
|
|
975
1026
|
title: "Upload files",
|
|
976
1027
|
type: "file"
|
|
977
|
-
}), /* @__PURE__ */
|
|
978
|
-
className:
|
|
1028
|
+
}), /* @__PURE__ */ K("form", {
|
|
1029
|
+
className: H("w-full", e),
|
|
979
1030
|
onSubmit: (e) => {
|
|
980
1031
|
e.preventDefault();
|
|
981
1032
|
let t = e.currentTarget, n = _ ? g.textInput.value : new FormData(t).get("message") || "";
|
|
@@ -1002,20 +1053,20 @@ var jn = ({ label: e = "Add photos or files", ...t }) => {
|
|
|
1002
1053
|
},
|
|
1003
1054
|
ref: y,
|
|
1004
1055
|
...h,
|
|
1005
|
-
children: /* @__PURE__ */
|
|
1056
|
+
children: /* @__PURE__ */ K(yn, {
|
|
1006
1057
|
className: "overflow-hidden",
|
|
1007
1058
|
children: m
|
|
1008
1059
|
})
|
|
1009
1060
|
})] });
|
|
1010
|
-
return _ ? I : /* @__PURE__ */
|
|
1061
|
+
return _ ? I : /* @__PURE__ */ K(Mn.Provider, {
|
|
1011
1062
|
value: F,
|
|
1012
1063
|
children: I
|
|
1013
1064
|
});
|
|
1014
|
-
},
|
|
1015
|
-
className:
|
|
1065
|
+
}, Ln = ({ className: e, ...t }) => /* @__PURE__ */ K("div", {
|
|
1066
|
+
className: H("contents", e),
|
|
1016
1067
|
...t
|
|
1017
|
-
}),
|
|
1018
|
-
let i =
|
|
1068
|
+
}), Rn = ({ onChange: e, className: t, placeholder: n = "What would you like to know?", ...r }) => {
|
|
1069
|
+
let i = On(), a = Z(), [o, s] = d(!1), c = (e) => {
|
|
1019
1070
|
if (e.key === "Enter") {
|
|
1020
1071
|
if (o || e.nativeEvent.isComposing || e.shiftKey) return;
|
|
1021
1072
|
e.preventDefault();
|
|
@@ -1043,8 +1094,8 @@ var jn = ({ label: e = "Add photos or files", ...t }) => {
|
|
|
1043
1094
|
i.textInput.setInput(t.currentTarget.value), e?.(t);
|
|
1044
1095
|
}
|
|
1045
1096
|
} : { onChange: e };
|
|
1046
|
-
return /* @__PURE__ */
|
|
1047
|
-
className:
|
|
1097
|
+
return /* @__PURE__ */ K(wn, {
|
|
1098
|
+
className: H("field-sizing-content max-h-48 min-h-16", t),
|
|
1048
1099
|
name: "message",
|
|
1049
1100
|
onCompositionEnd: () => s(!1),
|
|
1050
1101
|
onCompositionStart: () => s(!0),
|
|
@@ -1054,52 +1105,52 @@ var jn = ({ label: e = "Add photos or files", ...t }) => {
|
|
|
1054
1105
|
...r,
|
|
1055
1106
|
...u
|
|
1056
1107
|
});
|
|
1057
|
-
},
|
|
1108
|
+
}, zn = ({ className: e, ...t }) => /* @__PURE__ */ K(xn, {
|
|
1058
1109
|
align: "block-end",
|
|
1059
|
-
className:
|
|
1110
|
+
className: H("order-first flex-wrap gap-1", e),
|
|
1060
1111
|
...t
|
|
1061
|
-
}),
|
|
1112
|
+
}), Bn = ({ className: e, ...t }) => /* @__PURE__ */ K(xn, {
|
|
1062
1113
|
align: "block-end",
|
|
1063
|
-
className:
|
|
1114
|
+
className: H("justify-between gap-1", e),
|
|
1064
1115
|
...t
|
|
1065
|
-
}),
|
|
1066
|
-
className:
|
|
1116
|
+
}), Vn = ({ className: e, ...t }) => /* @__PURE__ */ K("div", {
|
|
1117
|
+
className: H("flex items-center gap-1", e),
|
|
1067
1118
|
...t
|
|
1068
|
-
}),
|
|
1119
|
+
}), Hn = ({ variant: e = "ghost", className: n, size: r, ...i }) => {
|
|
1069
1120
|
let a = r ?? (t.count(i.children) > 1 ? "sm" : "icon-sm");
|
|
1070
|
-
return /* @__PURE__ */
|
|
1071
|
-
className:
|
|
1121
|
+
return /* @__PURE__ */ K(Cn, {
|
|
1122
|
+
className: H(n),
|
|
1072
1123
|
size: a,
|
|
1073
1124
|
type: "button",
|
|
1074
1125
|
variant: e,
|
|
1075
1126
|
...i
|
|
1076
1127
|
});
|
|
1077
|
-
},
|
|
1128
|
+
}, Un = (e) => /* @__PURE__ */ K(P, { ...e }), Wn = ({ className: e, children: t, ...n }) => /* @__PURE__ */ K(L, {
|
|
1078
1129
|
asChild: !0,
|
|
1079
|
-
children: /* @__PURE__ */
|
|
1130
|
+
children: /* @__PURE__ */ K(Hn, {
|
|
1080
1131
|
className: e,
|
|
1081
1132
|
...n,
|
|
1082
|
-
children: t ?? /* @__PURE__ */
|
|
1133
|
+
children: t ?? /* @__PURE__ */ K(st, { className: "size-4" })
|
|
1083
1134
|
})
|
|
1084
|
-
}),
|
|
1135
|
+
}), Gn = ({ className: e, ...t }) => /* @__PURE__ */ K(F, {
|
|
1085
1136
|
align: "start",
|
|
1086
|
-
className:
|
|
1137
|
+
className: H(e),
|
|
1087
1138
|
...t
|
|
1088
|
-
}),
|
|
1089
|
-
className:
|
|
1139
|
+
}), Kn = ({ className: e, ...t }) => /* @__PURE__ */ K(I, {
|
|
1140
|
+
className: H(e),
|
|
1090
1141
|
...t
|
|
1091
|
-
}),
|
|
1092
|
-
let o = /* @__PURE__ */
|
|
1093
|
-
return r === "submitted" ? o = /* @__PURE__ */
|
|
1142
|
+
}), qn = ({ className: e, variant: t = "default", size: n = "icon-sm", status: r, children: i, ...a }) => {
|
|
1143
|
+
let o = /* @__PURE__ */ K(Qe, { className: "size-4" });
|
|
1144
|
+
return r === "submitted" ? o = /* @__PURE__ */ K(nt, { className: "size-4 animate-spin" }) : r === "streaming" ? o = /* @__PURE__ */ K(ut, { className: "size-4" }) : r === "error" && (o = /* @__PURE__ */ K(W, { className: "size-4" })), /* @__PURE__ */ K(Cn, {
|
|
1094
1145
|
"aria-label": "Submit",
|
|
1095
|
-
className:
|
|
1146
|
+
className: H(e),
|
|
1096
1147
|
size: n,
|
|
1097
1148
|
type: "submit",
|
|
1098
1149
|
variant: t,
|
|
1099
1150
|
...a,
|
|
1100
1151
|
children: i ?? o
|
|
1101
1152
|
});
|
|
1102
|
-
},
|
|
1153
|
+
}, Jn = ({ className: e, textareaRef: t, onTranscriptionChange: n, ...r }) => {
|
|
1103
1154
|
let [i, a] = d(!1), [s, l] = d(null), f = u(null);
|
|
1104
1155
|
c(() => {
|
|
1105
1156
|
if (typeof window < "u" && ("SpeechRecognition" in window || "webkitSpeechRecognition" in window)) {
|
|
@@ -1129,80 +1180,80 @@ var jn = ({ label: e = "Add photos or files", ...t }) => {
|
|
|
1129
1180
|
let p = o(() => {
|
|
1130
1181
|
s && (i ? s.stop() : s.start());
|
|
1131
1182
|
}, [s, i]);
|
|
1132
|
-
return /* @__PURE__ */
|
|
1133
|
-
className:
|
|
1183
|
+
return /* @__PURE__ */ K(Hn, {
|
|
1184
|
+
className: H("relative transition-all duration-200", i && "animate-pulse bg-accent text-accent-foreground", e),
|
|
1134
1185
|
disabled: !s,
|
|
1135
1186
|
onClick: p,
|
|
1136
1187
|
...r,
|
|
1137
|
-
children: /* @__PURE__ */
|
|
1188
|
+
children: /* @__PURE__ */ K(it, { className: "size-4" })
|
|
1138
1189
|
});
|
|
1139
|
-
},
|
|
1140
|
-
className:
|
|
1190
|
+
}, Yn = (e) => /* @__PURE__ */ K(ue, { ...e }), Xn = ({ className: e, ...t }) => /* @__PURE__ */ K(pe, {
|
|
1191
|
+
className: H("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),
|
|
1141
1192
|
...t
|
|
1142
|
-
}),
|
|
1143
|
-
className:
|
|
1193
|
+
}), Zn = ({ className: e, ...t }) => /* @__PURE__ */ K(de, {
|
|
1194
|
+
className: H(e),
|
|
1144
1195
|
...t
|
|
1145
|
-
}),
|
|
1146
|
-
className:
|
|
1196
|
+
}), Qn = ({ className: e, ...t }) => /* @__PURE__ */ K(fe, {
|
|
1197
|
+
className: H(e),
|
|
1147
1198
|
...t
|
|
1148
|
-
}),
|
|
1149
|
-
className:
|
|
1199
|
+
}), $n = ({ className: e, ...t }) => /* @__PURE__ */ K(me, {
|
|
1200
|
+
className: H(e),
|
|
1150
1201
|
...t
|
|
1151
|
-
}),
|
|
1202
|
+
}), er = ({ openDelay: e = 0, closeDelay: t = 0, ...n }) => /* @__PURE__ */ K(R, {
|
|
1152
1203
|
closeDelay: t,
|
|
1153
1204
|
openDelay: e,
|
|
1154
1205
|
...n
|
|
1155
|
-
}),
|
|
1206
|
+
}), tr = (e) => /* @__PURE__ */ K(oe, { ...e }), nr = ({ align: e = "start", ...t }) => /* @__PURE__ */ K(ae, {
|
|
1156
1207
|
align: e,
|
|
1157
1208
|
...t
|
|
1158
|
-
}),
|
|
1159
|
-
className:
|
|
1209
|
+
}), rr = ({ className: e, ...t }) => /* @__PURE__ */ K("div", {
|
|
1210
|
+
className: H(e),
|
|
1160
1211
|
...t
|
|
1161
|
-
}),
|
|
1162
|
-
className:
|
|
1212
|
+
}), ir = ({ className: e, ...t }) => /* @__PURE__ */ K("div", {
|
|
1213
|
+
className: H(e),
|
|
1163
1214
|
...t
|
|
1164
|
-
}),
|
|
1165
|
-
className:
|
|
1215
|
+
}), ar = ({ className: e, ...t }) => /* @__PURE__ */ K("h3", {
|
|
1216
|
+
className: H("mb-2 px-3 font-medium text-muted-foreground text-xs", e),
|
|
1166
1217
|
...t
|
|
1167
|
-
}),
|
|
1168
|
-
className:
|
|
1218
|
+
}), or = ({ className: e, ...t }) => /* @__PURE__ */ K("div", {
|
|
1219
|
+
className: H("space-y-1", e),
|
|
1169
1220
|
...t
|
|
1170
|
-
}),
|
|
1171
|
-
className:
|
|
1221
|
+
}), sr = ({ className: e, ...t }) => /* @__PURE__ */ K("div", {
|
|
1222
|
+
className: H("flex items-center gap-2 px-3 py-2 text-xs hover:bg-accent", e),
|
|
1172
1223
|
...t
|
|
1173
|
-
}),
|
|
1174
|
-
className:
|
|
1224
|
+
}), cr = ({ className: e, ...t }) => /* @__PURE__ */ K(D, {
|
|
1225
|
+
className: H(e),
|
|
1175
1226
|
...t
|
|
1176
|
-
}),
|
|
1177
|
-
className:
|
|
1227
|
+
}), lr = ({ className: e, ...t }) => /* @__PURE__ */ K(A, {
|
|
1228
|
+
className: H(e),
|
|
1178
1229
|
...t
|
|
1179
|
-
}),
|
|
1180
|
-
className:
|
|
1230
|
+
}), ur = ({ className: e, ...t }) => /* @__PURE__ */ K(M, {
|
|
1231
|
+
className: H(e),
|
|
1181
1232
|
...t
|
|
1182
|
-
}),
|
|
1183
|
-
className:
|
|
1233
|
+
}), dr = ({ className: e, ...t }) => /* @__PURE__ */ K(O, {
|
|
1234
|
+
className: H(e),
|
|
1184
1235
|
...t
|
|
1185
|
-
}),
|
|
1186
|
-
className:
|
|
1236
|
+
}), fr = ({ className: e, ...t }) => /* @__PURE__ */ K(k, {
|
|
1237
|
+
className: H(e),
|
|
1187
1238
|
...t
|
|
1188
|
-
}),
|
|
1189
|
-
className:
|
|
1239
|
+
}), pr = ({ className: e, ...t }) => /* @__PURE__ */ K(j, {
|
|
1240
|
+
className: H(e),
|
|
1190
1241
|
...t
|
|
1191
|
-
}),
|
|
1192
|
-
className:
|
|
1242
|
+
}), mr = ({ className: e, ...t }) => /* @__PURE__ */ K(N, {
|
|
1243
|
+
className: H(e),
|
|
1193
1244
|
...t
|
|
1194
|
-
}),
|
|
1245
|
+
}), hr = ({ className: e, children: t, ...n }) => /* @__PURE__ */ q(ce, {
|
|
1195
1246
|
className: "w-full overflow-x-auto whitespace-nowrap",
|
|
1196
1247
|
...n,
|
|
1197
|
-
children: [/* @__PURE__ */
|
|
1198
|
-
className:
|
|
1248
|
+
children: [/* @__PURE__ */ K("div", {
|
|
1249
|
+
className: H("flex w-max flex-nowrap items-center gap-2", e),
|
|
1199
1250
|
children: t
|
|
1200
|
-
}), /* @__PURE__ */
|
|
1251
|
+
}), /* @__PURE__ */ K(le, {
|
|
1201
1252
|
className: "hidden",
|
|
1202
1253
|
orientation: "horizontal"
|
|
1203
1254
|
})]
|
|
1204
|
-
}),
|
|
1205
|
-
className:
|
|
1255
|
+
}), gr = ({ suggestion: e, onClick: t, className: n, variant: r = "outline", size: i = "sm", children: a, ...o }) => /* @__PURE__ */ K(v, {
|
|
1256
|
+
className: H("cursor-pointer rounded-full px-4", n),
|
|
1206
1257
|
onClick: () => {
|
|
1207
1258
|
t?.(e);
|
|
1208
1259
|
},
|
|
@@ -1211,7 +1262,7 @@ var jn = ({ label: e = "Add photos or files", ...t }) => {
|
|
|
1211
1262
|
variant: r,
|
|
1212
1263
|
...o,
|
|
1213
1264
|
children: a || e
|
|
1214
|
-
}),
|
|
1265
|
+
}), _r = r({ code: "" }), vr = {
|
|
1215
1266
|
name: "line-numbers",
|
|
1216
1267
|
line(e, t) {
|
|
1217
1268
|
e.children.unshift({
|
|
@@ -1232,13 +1283,13 @@ var jn = ({ label: e = "Add photos or files", ...t }) => {
|
|
|
1232
1283
|
});
|
|
1233
1284
|
}
|
|
1234
1285
|
};
|
|
1235
|
-
async function
|
|
1236
|
-
let r = n ? [
|
|
1237
|
-
return await Promise.all([
|
|
1286
|
+
async function yr(e, t, n = !1) {
|
|
1287
|
+
let r = n ? [vr] : [];
|
|
1288
|
+
return await Promise.all([wt(e, {
|
|
1238
1289
|
lang: t,
|
|
1239
1290
|
theme: "one-light",
|
|
1240
1291
|
transformers: r
|
|
1241
|
-
}),
|
|
1292
|
+
}), wt(e, {
|
|
1242
1293
|
lang: t,
|
|
1243
1294
|
theme: "one-dark-pro",
|
|
1244
1295
|
transformers: r
|
|
@@ -1246,7 +1297,7 @@ async function hr(e, t, n = !1) {
|
|
|
1246
1297
|
}
|
|
1247
1298
|
var Q = ({ code: e, language: t, showLineNumbers: n = !1, className: r, children: i, ...a }) => {
|
|
1248
1299
|
let [o, s] = d(""), [l, f] = d(""), p = u(!1);
|
|
1249
|
-
return c(() => (
|
|
1300
|
+
return c(() => (yr(e, t, n).then(([e, t]) => {
|
|
1250
1301
|
p.current ||= (s(e), f(t), !0);
|
|
1251
1302
|
}), () => {
|
|
1252
1303
|
p.current = !1;
|
|
@@ -1254,23 +1305,23 @@ var Q = ({ code: e, language: t, showLineNumbers: n = !1, className: r, children
|
|
|
1254
1305
|
e,
|
|
1255
1306
|
t,
|
|
1256
1307
|
n
|
|
1257
|
-
]), /* @__PURE__ */
|
|
1308
|
+
]), /* @__PURE__ */ K(_r.Provider, {
|
|
1258
1309
|
value: { code: e },
|
|
1259
|
-
children: /* @__PURE__ */
|
|
1260
|
-
className:
|
|
1310
|
+
children: /* @__PURE__ */ K("div", {
|
|
1311
|
+
className: H("group relative w-full overflow-hidden rounded-md border bg-background text-foreground", r),
|
|
1261
1312
|
...a,
|
|
1262
|
-
children: /* @__PURE__ */
|
|
1313
|
+
children: /* @__PURE__ */ q("div", {
|
|
1263
1314
|
className: "relative",
|
|
1264
1315
|
children: [
|
|
1265
|
-
/* @__PURE__ */
|
|
1316
|
+
/* @__PURE__ */ K("div", {
|
|
1266
1317
|
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",
|
|
1267
1318
|
dangerouslySetInnerHTML: { __html: o }
|
|
1268
1319
|
}),
|
|
1269
|
-
/* @__PURE__ */
|
|
1320
|
+
/* @__PURE__ */ K("div", {
|
|
1270
1321
|
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",
|
|
1271
1322
|
dangerouslySetInnerHTML: { __html: l }
|
|
1272
1323
|
}),
|
|
1273
|
-
i && /* @__PURE__ */
|
|
1324
|
+
i && /* @__PURE__ */ K("div", {
|
|
1274
1325
|
className: "absolute top-2 right-2 flex items-center gap-2",
|
|
1275
1326
|
children: i
|
|
1276
1327
|
})
|
|
@@ -1278,8 +1329,8 @@ var Q = ({ code: e, language: t, showLineNumbers: n = !1, className: r, children
|
|
|
1278
1329
|
})
|
|
1279
1330
|
})
|
|
1280
1331
|
});
|
|
1281
|
-
},
|
|
1282
|
-
let [o, c] = d(!1), { code: l } = s(
|
|
1332
|
+
}, br = ({ onCopy: e, onError: t, timeout: n = 2e3, children: r, className: i, ...a }) => {
|
|
1333
|
+
let [o, c] = d(!1), { code: l } = s(_r), u = async () => {
|
|
1283
1334
|
if (typeof window > "u" || !navigator?.clipboard?.writeText) {
|
|
1284
1335
|
t?.(/* @__PURE__ */ Error("Clipboard API not available"));
|
|
1285
1336
|
return;
|
|
@@ -1289,29 +1340,29 @@ var Q = ({ code: e, language: t, showLineNumbers: n = !1, className: r, children
|
|
|
1289
1340
|
} catch (e) {
|
|
1290
1341
|
t?.(e);
|
|
1291
1342
|
}
|
|
1292
|
-
}, f = o ?
|
|
1293
|
-
return /* @__PURE__ */
|
|
1294
|
-
className:
|
|
1343
|
+
}, f = o ? He : Xe;
|
|
1344
|
+
return /* @__PURE__ */ K(v, {
|
|
1345
|
+
className: H("shrink-0", i),
|
|
1295
1346
|
onClick: u,
|
|
1296
1347
|
size: "icon",
|
|
1297
1348
|
variant: "ghost",
|
|
1298
1349
|
...a,
|
|
1299
|
-
children: r ?? /* @__PURE__ */
|
|
1350
|
+
children: r ?? /* @__PURE__ */ K(f, { size: 14 })
|
|
1300
1351
|
});
|
|
1301
|
-
},
|
|
1302
|
-
className:
|
|
1352
|
+
}, xr = ({ className: e, ...t }) => /* @__PURE__ */ K(w, {
|
|
1353
|
+
className: H("not-prose mb-4 w-full rounded-md border", e),
|
|
1303
1354
|
...t
|
|
1304
|
-
}),
|
|
1355
|
+
}), Sr = (e) => /* @__PURE__ */ q(_, {
|
|
1305
1356
|
className: "gap-1.5 rounded-full text-xs",
|
|
1306
1357
|
variant: "secondary",
|
|
1307
1358
|
children: [{
|
|
1308
|
-
"input-streaming": /* @__PURE__ */
|
|
1309
|
-
"input-available": /* @__PURE__ */
|
|
1310
|
-
"approval-requested": /* @__PURE__ */
|
|
1311
|
-
"approval-responded": /* @__PURE__ */
|
|
1312
|
-
"output-available": /* @__PURE__ */
|
|
1313
|
-
"output-error": /* @__PURE__ */
|
|
1314
|
-
"output-denied": /* @__PURE__ */
|
|
1359
|
+
"input-streaming": /* @__PURE__ */ K(Ke, { className: "size-4" }),
|
|
1360
|
+
"input-available": /* @__PURE__ */ K(Je, { className: "size-4 animate-pulse" }),
|
|
1361
|
+
"approval-requested": /* @__PURE__ */ K(Je, { className: "size-4 text-yellow-600" }),
|
|
1362
|
+
"approval-responded": /* @__PURE__ */ K(Ve, { className: "size-4 text-blue-600" }),
|
|
1363
|
+
"output-available": /* @__PURE__ */ K(Ve, { className: "size-4 text-green-600" }),
|
|
1364
|
+
"output-error": /* @__PURE__ */ K(pt, { className: "size-4 text-red-600" }),
|
|
1365
|
+
"output-denied": /* @__PURE__ */ K(pt, { className: "size-4 text-orange-600" })
|
|
1315
1366
|
}[e], {
|
|
1316
1367
|
"input-streaming": "Pending",
|
|
1317
1368
|
"input-available": "Running",
|
|
@@ -1321,61 +1372,61 @@ var Q = ({ code: e, language: t, showLineNumbers: n = !1, className: r, children
|
|
|
1321
1372
|
"output-error": "Error",
|
|
1322
1373
|
"output-denied": "Denied"
|
|
1323
1374
|
}[e]]
|
|
1324
|
-
}),
|
|
1325
|
-
className:
|
|
1375
|
+
}), Cr = ({ className: e, title: t, type: n, state: r, ...i }) => /* @__PURE__ */ q(E, {
|
|
1376
|
+
className: H("flex w-full items-center justify-between gap-4 p-3", e),
|
|
1326
1377
|
...i,
|
|
1327
|
-
children: [/* @__PURE__ */
|
|
1378
|
+
children: [/* @__PURE__ */ q("div", {
|
|
1328
1379
|
className: "flex items-center gap-2",
|
|
1329
1380
|
children: [
|
|
1330
|
-
/* @__PURE__ */
|
|
1331
|
-
/* @__PURE__ */
|
|
1381
|
+
/* @__PURE__ */ K(dt, { className: "size-4 text-muted-foreground" }),
|
|
1382
|
+
/* @__PURE__ */ K("span", {
|
|
1332
1383
|
className: "font-medium text-sm",
|
|
1333
1384
|
children: t ?? n.split("-").slice(1).join("-")
|
|
1334
1385
|
}),
|
|
1335
|
-
|
|
1386
|
+
Sr(r)
|
|
1336
1387
|
]
|
|
1337
|
-
}), /* @__PURE__ */
|
|
1338
|
-
}),
|
|
1339
|
-
className:
|
|
1388
|
+
}), /* @__PURE__ */ K(Ue, { className: "size-4 text-muted-foreground transition-transform group-data-[state=open]:rotate-180" })]
|
|
1389
|
+
}), wr = ({ className: e, ...t }) => /* @__PURE__ */ K(T, {
|
|
1390
|
+
className: H("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),
|
|
1340
1391
|
...t
|
|
1341
|
-
}),
|
|
1342
|
-
className:
|
|
1392
|
+
}), Tr = ({ className: e, input: t, ...n }) => /* @__PURE__ */ q("div", {
|
|
1393
|
+
className: H("space-y-2 overflow-hidden p-4", e),
|
|
1343
1394
|
...n,
|
|
1344
|
-
children: [/* @__PURE__ */
|
|
1395
|
+
children: [/* @__PURE__ */ K("h4", {
|
|
1345
1396
|
className: "font-medium text-muted-foreground text-xs uppercase tracking-wide",
|
|
1346
1397
|
children: "Parameters"
|
|
1347
|
-
}), /* @__PURE__ */
|
|
1398
|
+
}), /* @__PURE__ */ K("div", {
|
|
1348
1399
|
className: "rounded-md bg-muted/50",
|
|
1349
|
-
children: /* @__PURE__ */
|
|
1400
|
+
children: /* @__PURE__ */ K(Q, {
|
|
1350
1401
|
code: JSON.stringify(t, null, 2),
|
|
1351
1402
|
language: "json"
|
|
1352
1403
|
})
|
|
1353
1404
|
})]
|
|
1354
|
-
}),
|
|
1405
|
+
}), Er = ({ className: e, output: t, errorText: n, ...r }) => {
|
|
1355
1406
|
if (!(t || n)) return null;
|
|
1356
|
-
let a = /* @__PURE__ */
|
|
1357
|
-
return typeof t == "object" && !i(t) ? a = /* @__PURE__ */
|
|
1407
|
+
let a = /* @__PURE__ */ K("div", { children: t });
|
|
1408
|
+
return typeof t == "object" && !i(t) ? a = /* @__PURE__ */ K(Q, {
|
|
1358
1409
|
code: JSON.stringify(t, null, 2),
|
|
1359
1410
|
language: "json"
|
|
1360
|
-
}) : typeof t == "string" && (a = /* @__PURE__ */
|
|
1411
|
+
}) : typeof t == "string" && (a = /* @__PURE__ */ K(Q, {
|
|
1361
1412
|
code: t,
|
|
1362
1413
|
language: "json"
|
|
1363
|
-
})), /* @__PURE__ */
|
|
1364
|
-
className:
|
|
1414
|
+
})), /* @__PURE__ */ q("div", {
|
|
1415
|
+
className: H("space-y-2 p-4", e),
|
|
1365
1416
|
...r,
|
|
1366
|
-
children: [/* @__PURE__ */
|
|
1417
|
+
children: [/* @__PURE__ */ K("h4", {
|
|
1367
1418
|
className: "font-medium text-muted-foreground text-xs uppercase tracking-wide",
|
|
1368
1419
|
children: n ? "Error" : "Result"
|
|
1369
|
-
}), /* @__PURE__ */
|
|
1370
|
-
className:
|
|
1371
|
-
children: [n && /* @__PURE__ */
|
|
1420
|
+
}), /* @__PURE__ */ q("div", {
|
|
1421
|
+
className: H("overflow-x-auto rounded-md text-xs [&_table]:w-full", n ? "bg-destructive/10 text-destructive" : "bg-muted/50 text-foreground"),
|
|
1422
|
+
children: [n && /* @__PURE__ */ K("div", { children: n }), a]
|
|
1372
1423
|
})]
|
|
1373
1424
|
});
|
|
1374
|
-
},
|
|
1375
|
-
let a =
|
|
1376
|
-
return /* @__PURE__ */
|
|
1425
|
+
}, Dr = a(({ children: e, as: t = "p", className: n, duration: r = 2, spread: i = 2 }) => {
|
|
1426
|
+
let a = Et.create(t), o = l(() => (e?.length ?? 0) * i, [e, i]);
|
|
1427
|
+
return /* @__PURE__ */ K(a, {
|
|
1377
1428
|
animate: { backgroundPosition: "0% center" },
|
|
1378
|
-
className:
|
|
1429
|
+
className: H("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),
|
|
1379
1430
|
initial: { backgroundPosition: "100% center" },
|
|
1380
1431
|
style: {
|
|
1381
1432
|
"--spread": `${o}px`,
|
|
@@ -1388,21 +1439,21 @@ var Q = ({ code: e, language: t, showLineNumbers: n = !1, className: r, children
|
|
|
1388
1439
|
},
|
|
1389
1440
|
children: e
|
|
1390
1441
|
});
|
|
1391
|
-
}),
|
|
1392
|
-
let e = s(
|
|
1442
|
+
}), Or = r(null), kr = () => {
|
|
1443
|
+
let e = s(Or);
|
|
1393
1444
|
if (!e) throw Error("Reasoning components must be used within Reasoning");
|
|
1394
1445
|
return e;
|
|
1395
|
-
},
|
|
1396
|
-
let [l, u] =
|
|
1446
|
+
}, Ar = 1e3, jr = 1e3, Mr = a(({ className: e, isStreaming: t = !1, open: n, defaultOpen: r = !0, onOpenChange: i, duration: a, children: o, ...s }) => {
|
|
1447
|
+
let [l, u] = Tt({
|
|
1397
1448
|
prop: n,
|
|
1398
1449
|
defaultProp: r,
|
|
1399
1450
|
onChange: i
|
|
1400
|
-
}), [f, p] =
|
|
1451
|
+
}), [f, p] = Tt({
|
|
1401
1452
|
prop: a,
|
|
1402
1453
|
defaultProp: void 0
|
|
1403
1454
|
}), [m, h] = d(!1), [g, _] = d(null);
|
|
1404
1455
|
return c(() => {
|
|
1405
|
-
t ? g === null && _(Date.now()) : g !== null && (p(Math.ceil((Date.now() - g) /
|
|
1456
|
+
t ? g === null && _(Date.now()) : g !== null && (p(Math.ceil((Date.now() - g) / jr)), _(null));
|
|
1406
1457
|
}, [
|
|
1407
1458
|
t,
|
|
1408
1459
|
g,
|
|
@@ -1411,7 +1462,7 @@ var Q = ({ code: e, language: t, showLineNumbers: n = !1, className: r, children
|
|
|
1411
1462
|
if (r && !t && l && !m) {
|
|
1412
1463
|
let e = setTimeout(() => {
|
|
1413
1464
|
u(!1), h(!0);
|
|
1414
|
-
},
|
|
1465
|
+
}, Ar);
|
|
1415
1466
|
return () => clearTimeout(e);
|
|
1416
1467
|
}
|
|
1417
1468
|
}, [
|
|
@@ -1420,15 +1471,15 @@ var Q = ({ code: e, language: t, showLineNumbers: n = !1, className: r, children
|
|
|
1420
1471
|
r,
|
|
1421
1472
|
u,
|
|
1422
1473
|
m
|
|
1423
|
-
]), /* @__PURE__ */
|
|
1474
|
+
]), /* @__PURE__ */ K(Or.Provider, {
|
|
1424
1475
|
value: {
|
|
1425
1476
|
isStreaming: t,
|
|
1426
1477
|
isOpen: l,
|
|
1427
1478
|
setIsOpen: u,
|
|
1428
1479
|
duration: f
|
|
1429
1480
|
},
|
|
1430
|
-
children: /* @__PURE__ */
|
|
1431
|
-
className:
|
|
1481
|
+
children: /* @__PURE__ */ K(w, {
|
|
1482
|
+
className: H("not-prose mb-4", e),
|
|
1432
1483
|
onOpenChange: (e) => {
|
|
1433
1484
|
u(e);
|
|
1434
1485
|
},
|
|
@@ -1437,73 +1488,70 @@ var Q = ({ code: e, language: t, showLineNumbers: n = !1, className: r, children
|
|
|
1437
1488
|
children: o
|
|
1438
1489
|
})
|
|
1439
1490
|
});
|
|
1440
|
-
}),
|
|
1491
|
+
}), Nr = (e, t) => e || t === 0 ? /* @__PURE__ */ K(Dr, {
|
|
1441
1492
|
duration: 1,
|
|
1442
1493
|
children: "Thinking..."
|
|
1443
|
-
}) : t === void 0 ? /* @__PURE__ */
|
|
1494
|
+
}) : t === void 0 ? /* @__PURE__ */ K("p", { children: "Thought for a few seconds" }) : /* @__PURE__ */ q("p", { children: [
|
|
1444
1495
|
"Thought for ",
|
|
1445
1496
|
t,
|
|
1446
1497
|
" seconds"
|
|
1447
|
-
] }),
|
|
1448
|
-
let { isStreaming: i, isOpen: a, duration: o } =
|
|
1449
|
-
return /* @__PURE__ */
|
|
1450
|
-
className:
|
|
1498
|
+
] }), Pr = a(({ className: e, children: t, getThinkingMessage: n = Nr, ...r }) => {
|
|
1499
|
+
let { isStreaming: i, isOpen: a, duration: o } = kr();
|
|
1500
|
+
return /* @__PURE__ */ K(E, {
|
|
1501
|
+
className: H("flex w-full items-center gap-2 text-muted-foreground text-sm transition-colors hover:text-foreground", e),
|
|
1451
1502
|
...r,
|
|
1452
|
-
children: t ?? /* @__PURE__ */
|
|
1453
|
-
/* @__PURE__ */
|
|
1503
|
+
children: t ?? /* @__PURE__ */ q(G, { children: [
|
|
1504
|
+
/* @__PURE__ */ K(Re, { className: "size-4" }),
|
|
1454
1505
|
n(i, o),
|
|
1455
|
-
/* @__PURE__ */
|
|
1506
|
+
/* @__PURE__ */ K(Ue, { className: H("size-4 transition-transform", a ? "rotate-180" : "rotate-0") })
|
|
1456
1507
|
] })
|
|
1457
1508
|
});
|
|
1458
|
-
}),
|
|
1459
|
-
className:
|
|
1509
|
+
}), Fr = a(({ className: e, children: t, ...n }) => /* @__PURE__ */ K(T, {
|
|
1510
|
+
className: H("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),
|
|
1460
1511
|
...n,
|
|
1461
|
-
children: /* @__PURE__ */
|
|
1462
|
-
...n,
|
|
1463
|
-
children: t
|
|
1464
|
-
})
|
|
1512
|
+
children: /* @__PURE__ */ K(St, { children: t })
|
|
1465
1513
|
}));
|
|
1466
|
-
|
|
1514
|
+
Mr.displayName = "Reasoning", Pr.displayName = "ReasoningTrigger", Fr.displayName = "ReasoningContent";
|
|
1467
1515
|
//#endregion
|
|
1468
1516
|
//#region src/elements/sources.tsx
|
|
1469
|
-
var
|
|
1470
|
-
className:
|
|
1517
|
+
var Ir = ({ className: e, ...t }) => /* @__PURE__ */ K(w, {
|
|
1518
|
+
className: H("not-prose mb-4 text-primary text-xs", e),
|
|
1471
1519
|
...t
|
|
1472
|
-
}),
|
|
1473
|
-
className:
|
|
1520
|
+
}), Lr = ({ className: e, count: t, children: n, ...r }) => /* @__PURE__ */ K(E, {
|
|
1521
|
+
className: H("flex items-center gap-2", e),
|
|
1474
1522
|
...r,
|
|
1475
|
-
children: n ?? /* @__PURE__ */
|
|
1523
|
+
children: n ?? /* @__PURE__ */ q(G, { children: [/* @__PURE__ */ q("p", {
|
|
1476
1524
|
className: "font-medium",
|
|
1477
1525
|
children: [
|
|
1478
1526
|
"Used ",
|
|
1479
1527
|
t,
|
|
1480
1528
|
" sources"
|
|
1481
1529
|
]
|
|
1482
|
-
}), /* @__PURE__ */
|
|
1483
|
-
}),
|
|
1484
|
-
className:
|
|
1530
|
+
}), /* @__PURE__ */ K(Ue, { className: "h-4 w-4" })] })
|
|
1531
|
+
}), Rr = ({ className: e, ...t }) => /* @__PURE__ */ K(T, {
|
|
1532
|
+
className: H("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),
|
|
1485
1533
|
...t
|
|
1486
|
-
}),
|
|
1534
|
+
}), zr = ({ href: e, title: t, children: n, ...r }) => /* @__PURE__ */ K("a", {
|
|
1487
1535
|
className: "flex items-center gap-2",
|
|
1488
1536
|
href: e,
|
|
1489
1537
|
rel: "noreferrer",
|
|
1490
1538
|
target: "_blank",
|
|
1491
1539
|
...r,
|
|
1492
|
-
children: n ?? /* @__PURE__ */
|
|
1540
|
+
children: n ?? /* @__PURE__ */ q(G, { children: [/* @__PURE__ */ K(Ie, { className: "h-4 w-4" }), /* @__PURE__ */ K("span", {
|
|
1493
1541
|
className: "block font-medium",
|
|
1494
1542
|
children: t
|
|
1495
1543
|
})] })
|
|
1496
1544
|
});
|
|
1497
1545
|
//#endregion
|
|
1498
1546
|
//#region src/ChatbotEnhanced.tsx
|
|
1499
|
-
function
|
|
1547
|
+
function Br(e, t) {
|
|
1500
1548
|
return t ? "error" : e ? "streaming" : "ready";
|
|
1501
1549
|
}
|
|
1502
|
-
function
|
|
1550
|
+
function Vr(e) {
|
|
1503
1551
|
return e === "user" ? "user" : "assistant";
|
|
1504
1552
|
}
|
|
1505
1553
|
var $ = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type your message...", onSendMessage: i, onClear: a, onStop: o, onReload: s, disabled: c = !1, isLoading: l = !1, error: u, showTimestamp: d = !1, userAvatarUrl: f, userAvatarFallback: p = "You", assistantAvatarUrl: m, assistantAvatarFallback: h = "AI", maxHeight: g = "500px", enableMarkdown: _ = !0, enableFileUpload: v = !1, acceptedFileTypes: y = "image/*,.pdf,.doc,.docx,.txt", maxFileSize: b = 10 * 1024 * 1024, suggestions: x, models: S, selectedModelId: C, onModelChange: w, headerSlot: T, promptOverlaySlot: E, onInputChange: D, onToolApprove: O, toolApproveLabel: k = "Approve", toolDenyLabel: A = "Deny", toolDenyReason: j = "User denied the operation", toolDecisions: M, ...N }, P) => {
|
|
1506
|
-
let F =
|
|
1554
|
+
let F = Br(l, u), [I, L] = e.useState(null), ee = e.useCallback((e) => {
|
|
1507
1555
|
let t = !!e.text?.trim(), n = e.files?.map((e) => e.file).filter(Boolean), r = !!(n && n.length > 0);
|
|
1508
1556
|
(t || r) && i?.(e.text?.trim() ?? "", n);
|
|
1509
1557
|
}, [i]), te = e.useCallback((e) => {
|
|
@@ -1511,85 +1559,91 @@ var $ = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type y
|
|
|
1511
1559
|
}, [i]), ne = e.useCallback((e) => {
|
|
1512
1560
|
navigator.clipboard?.writeText(e.content), L(e.id), window.setTimeout(() => L((t) => t === e.id ? null : t), 1500);
|
|
1513
1561
|
}, []);
|
|
1514
|
-
return /* @__PURE__ */
|
|
1562
|
+
return /* @__PURE__ */ q("div", {
|
|
1515
1563
|
ref: P,
|
|
1516
|
-
className:
|
|
1564
|
+
className: H("flex flex-col border rounded-lg bg-background overflow-hidden", t),
|
|
1517
1565
|
style: { maxHeight: g },
|
|
1518
1566
|
...N,
|
|
1519
1567
|
children: [
|
|
1520
|
-
a && n.length > 0 && /* @__PURE__ */
|
|
1568
|
+
a && n.length > 0 && /* @__PURE__ */ q("div", {
|
|
1521
1569
|
className: "flex items-center justify-between px-4 py-2 border-b bg-muted/30",
|
|
1522
|
-
children: [/* @__PURE__ */
|
|
1570
|
+
children: [/* @__PURE__ */ q("span", {
|
|
1523
1571
|
className: "text-sm text-muted-foreground",
|
|
1524
1572
|
children: [
|
|
1525
1573
|
n.length,
|
|
1526
1574
|
" message",
|
|
1527
1575
|
n.length === 1 ? "" : "s"
|
|
1528
1576
|
]
|
|
1529
|
-
}), /* @__PURE__ */
|
|
1577
|
+
}), /* @__PURE__ */ K("button", {
|
|
1530
1578
|
type: "button",
|
|
1531
1579
|
onClick: a,
|
|
1532
1580
|
className: "text-xs text-muted-foreground hover:text-foreground transition-colors",
|
|
1533
1581
|
children: "Clear"
|
|
1534
1582
|
})]
|
|
1535
1583
|
}),
|
|
1536
|
-
T ? /* @__PURE__ */
|
|
1584
|
+
T ? /* @__PURE__ */ K("div", {
|
|
1537
1585
|
className: "shrink-0 border-b bg-background/50",
|
|
1538
1586
|
children: T
|
|
1539
1587
|
}) : null,
|
|
1540
|
-
/* @__PURE__ */
|
|
1588
|
+
/* @__PURE__ */ q(Xt, {
|
|
1541
1589
|
className: "flex-1 min-h-0",
|
|
1542
|
-
children: [/* @__PURE__ */
|
|
1590
|
+
children: [/* @__PURE__ */ K(Zt, {
|
|
1543
1591
|
className: "space-y-4 px-4 py-3",
|
|
1544
|
-
children: n.length === 0 ? /* @__PURE__ */
|
|
1592
|
+
children: n.length === 0 ? /* @__PURE__ */ K(Qt, {
|
|
1545
1593
|
title: "Start a conversation",
|
|
1546
1594
|
description: "Ask anything — the assistant has access to your current app context.",
|
|
1547
|
-
children: x && x.length > 0 ? /* @__PURE__ */
|
|
1595
|
+
children: x && x.length > 0 ? /* @__PURE__ */ K(hr, {
|
|
1548
1596
|
className: "justify-center pt-2",
|
|
1549
|
-
children: x.map((e) => /* @__PURE__ */
|
|
1597
|
+
children: x.map((e) => /* @__PURE__ */ K(gr, {
|
|
1550
1598
|
suggestion: e,
|
|
1551
1599
|
onClick: te
|
|
1552
1600
|
}, e))
|
|
1553
1601
|
}) : null
|
|
1554
1602
|
}) : n.map((e) => {
|
|
1555
1603
|
let t = e.role === "user", n = e.toolInvocations ?? [], r = e.reasoning?.trim(), i = e.sources ?? [];
|
|
1556
|
-
return /* @__PURE__ */
|
|
1557
|
-
from:
|
|
1558
|
-
children: [/* @__PURE__ */
|
|
1559
|
-
!t && r ? /* @__PURE__ */
|
|
1604
|
+
return /* @__PURE__ */ q(rn, {
|
|
1605
|
+
from: Vr(e.role),
|
|
1606
|
+
children: [/* @__PURE__ */ q(an, { children: [
|
|
1607
|
+
!t && r ? /* @__PURE__ */ q(Mr, {
|
|
1560
1608
|
isStreaming: !!e.streaming && !e.content,
|
|
1561
1609
|
className: "mb-2",
|
|
1562
|
-
children: [/* @__PURE__ */
|
|
1610
|
+
children: [/* @__PURE__ */ K(Pr, {}), /* @__PURE__ */ K(Fr, { children: r })]
|
|
1563
1611
|
}) : null,
|
|
1564
1612
|
!t && n.length > 0 ? n.map((e) => {
|
|
1565
|
-
let t = e.state ?? (e.errorText ? "output-error" : e.result === void 0 ? "input-available" : "output-available"), n = `tool-${e.toolName}`, r = M?.[e.toolCallId], i = t === "approval-requested" && !!O && !r, a = t === "approval-requested" && !!e.pendingActionId
|
|
1566
|
-
|
|
1613
|
+
let t = e.state ?? (e.errorText ? "output-error" : e.result === void 0 ? "input-available" : "output-available"), n = `tool-${e.toolName}`, r = M?.[e.toolCallId], i = t === "approval-requested" && !!O && !r, a = t === "approval-requested" && !!e.pendingActionId, o = qt(e.toolName), s = Jt(e.result), c = /* @__PURE__ */ q("span", {
|
|
1614
|
+
className: "inline-flex items-center gap-2",
|
|
1615
|
+
children: [/* @__PURE__ */ K("span", { children: o || e.toolName }), o && o.toLowerCase() !== e.toolName.toLowerCase() ? /* @__PURE__ */ K("code", {
|
|
1616
|
+
className: "rounded bg-muted px-1 py-px text-[10px] font-mono text-muted-foreground",
|
|
1617
|
+
children: e.toolName
|
|
1618
|
+
}) : null]
|
|
1619
|
+
});
|
|
1620
|
+
return /* @__PURE__ */ q(xr, {
|
|
1567
1621
|
defaultOpen: t !== "output-available",
|
|
1568
|
-
children: [/* @__PURE__ */
|
|
1622
|
+
children: [/* @__PURE__ */ K(Cr, {
|
|
1569
1623
|
type: n,
|
|
1570
1624
|
state: t,
|
|
1571
|
-
title:
|
|
1572
|
-
}), /* @__PURE__ */
|
|
1573
|
-
e.args === void 0 ? null : /* @__PURE__ */
|
|
1574
|
-
a ? null : /* @__PURE__ */
|
|
1575
|
-
output:
|
|
1625
|
+
title: c
|
|
1626
|
+
}), /* @__PURE__ */ q(wr, { children: [
|
|
1627
|
+
e.args === void 0 ? null : /* @__PURE__ */ K(Tr, { input: e.args }),
|
|
1628
|
+
a ? null : /* @__PURE__ */ K(Er, {
|
|
1629
|
+
output: s,
|
|
1576
1630
|
errorText: e.errorText
|
|
1577
1631
|
}),
|
|
1578
|
-
r ? /* @__PURE__ */
|
|
1632
|
+
r ? /* @__PURE__ */ q("div", {
|
|
1579
1633
|
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"),
|
|
1580
|
-
children: [/* @__PURE__ */
|
|
1634
|
+
children: [/* @__PURE__ */ K("span", {
|
|
1581
1635
|
"aria-hidden": "true",
|
|
1582
1636
|
children: r.state === "pending" ? "⏳" : r.state === "success" ? "✓" : "✗"
|
|
1583
|
-
}), /* @__PURE__ */
|
|
1637
|
+
}), /* @__PURE__ */ K("span", { children: r.message ?? (r.state === "pending" ? "Submitting decision…" : r.state === "success" ? "Action approved and executed." : "Decision failed.") })]
|
|
1584
1638
|
}) : null,
|
|
1585
|
-
i ? /* @__PURE__ */
|
|
1639
|
+
i ? /* @__PURE__ */ q("div", {
|
|
1586
1640
|
className: "flex gap-2 p-3 border-t bg-muted/30",
|
|
1587
|
-
children: [/* @__PURE__ */
|
|
1641
|
+
children: [/* @__PURE__ */ K("button", {
|
|
1588
1642
|
type: "button",
|
|
1589
1643
|
onClick: () => O?.(e.toolCallId, !0),
|
|
1590
1644
|
className: "inline-flex h-7 items-center rounded-md bg-primary px-3 text-xs font-medium text-primary-foreground hover:bg-primary/90",
|
|
1591
1645
|
children: k
|
|
1592
|
-
}), /* @__PURE__ */
|
|
1646
|
+
}), /* @__PURE__ */ K("button", {
|
|
1593
1647
|
type: "button",
|
|
1594
1648
|
onClick: () => O?.(e.toolCallId, !1, j),
|
|
1595
1649
|
className: "inline-flex h-7 items-center rounded-md border bg-background px-3 text-xs font-medium hover:bg-accent",
|
|
@@ -1600,32 +1654,32 @@ var $ = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type y
|
|
|
1600
1654
|
}, e.toolCallId);
|
|
1601
1655
|
}) : null,
|
|
1602
1656
|
e.content,
|
|
1603
|
-
e.streaming ? /* @__PURE__ */
|
|
1657
|
+
e.streaming ? /* @__PURE__ */ K("span", {
|
|
1604
1658
|
"aria-hidden": !0,
|
|
1605
1659
|
className: "ml-0.5 inline-block w-[2px] h-4 align-middle bg-current animate-pulse"
|
|
1606
1660
|
}) : null,
|
|
1607
|
-
!t && i.length > 0 ? /* @__PURE__ */
|
|
1661
|
+
!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, {
|
|
1608
1662
|
href: e.url,
|
|
1609
1663
|
title: e.title ?? e.url
|
|
1610
1664
|
}, e.id ?? e.url ?? t)) })] }) : null,
|
|
1611
|
-
d && e.timestamp ? /* @__PURE__ */
|
|
1665
|
+
d && e.timestamp ? /* @__PURE__ */ K("div", {
|
|
1612
1666
|
className: "text-[10px] opacity-70 mt-1",
|
|
1613
1667
|
children: e.timestamp
|
|
1614
1668
|
}) : null
|
|
1615
|
-
] }), t ? null : /* @__PURE__ */
|
|
1616
|
-
/* @__PURE__ */
|
|
1669
|
+
] }), t ? null : /* @__PURE__ */ q(on, { children: [
|
|
1670
|
+
/* @__PURE__ */ K(sn, {
|
|
1617
1671
|
label: "Copy",
|
|
1618
1672
|
tooltip: "Copy",
|
|
1619
1673
|
onClick: () => ne(e),
|
|
1620
|
-
children: I === e.id ? /* @__PURE__ */
|
|
1674
|
+
children: I === e.id ? /* @__PURE__ */ K(ze, { className: "size-3.5" }) : /* @__PURE__ */ K(Ye, { className: "size-3.5" })
|
|
1621
1675
|
}),
|
|
1622
|
-
s ? /* @__PURE__ */
|
|
1676
|
+
s ? /* @__PURE__ */ K(sn, {
|
|
1623
1677
|
label: "Regenerate",
|
|
1624
1678
|
tooltip: "Regenerate",
|
|
1625
1679
|
onClick: s,
|
|
1626
|
-
children: /* @__PURE__ */
|
|
1680
|
+
children: /* @__PURE__ */ K(ct, { className: "size-3.5" })
|
|
1627
1681
|
}) : null,
|
|
1628
|
-
e.traceId ? /* @__PURE__ */
|
|
1682
|
+
e.traceId ? /* @__PURE__ */ K("a", {
|
|
1629
1683
|
href: `#trace/${e.traceId}`,
|
|
1630
1684
|
"data-trace-id": e.traceId,
|
|
1631
1685
|
className: "text-[10px] text-muted-foreground hover:text-foreground ml-1 underline",
|
|
@@ -1635,31 +1689,18 @@ var $ = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type y
|
|
|
1635
1689
|
] })]
|
|
1636
1690
|
}, e.id);
|
|
1637
1691
|
})
|
|
1638
|
-
}), /* @__PURE__ */
|
|
1692
|
+
}), /* @__PURE__ */ K($t, {})]
|
|
1639
1693
|
}),
|
|
1640
|
-
u ? /* @__PURE__ */
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
children: [
|
|
1644
|
-
/* @__PURE__ */ q(Ne, { className: "h-4 w-4 shrink-0" }),
|
|
1645
|
-
/* @__PURE__ */ q("span", {
|
|
1646
|
-
className: "flex-1 truncate",
|
|
1647
|
-
children: u.message || "An error occurred"
|
|
1648
|
-
}),
|
|
1649
|
-
s ? /* @__PURE__ */ q("button", {
|
|
1650
|
-
type: "button",
|
|
1651
|
-
onClick: s,
|
|
1652
|
-
className: "text-xs underline hover:no-underline",
|
|
1653
|
-
children: "Retry"
|
|
1654
|
-
}) : null
|
|
1655
|
-
]
|
|
1694
|
+
u ? /* @__PURE__ */ K(Hr, {
|
|
1695
|
+
error: u,
|
|
1696
|
+
onReload: s
|
|
1656
1697
|
}) : null,
|
|
1657
|
-
/* @__PURE__ */
|
|
1698
|
+
/* @__PURE__ */ q("div", {
|
|
1658
1699
|
className: "relative",
|
|
1659
|
-
children: [E ? /* @__PURE__ */
|
|
1700
|
+
children: [E ? /* @__PURE__ */ K("div", {
|
|
1660
1701
|
className: "absolute bottom-full left-0 right-0 z-10 px-3 pb-1",
|
|
1661
1702
|
children: E
|
|
1662
|
-
}) : null, /* @__PURE__ */
|
|
1703
|
+
}) : null, /* @__PURE__ */ q(In, {
|
|
1663
1704
|
accept: y,
|
|
1664
1705
|
maxFileSize: b,
|
|
1665
1706
|
onSubmit: ee,
|
|
@@ -1667,22 +1708,40 @@ var $ = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type y
|
|
|
1667
1708
|
console.warn("[plugin-chatbot] prompt-input error", e);
|
|
1668
1709
|
},
|
|
1669
1710
|
children: [
|
|
1670
|
-
v ? /* @__PURE__ */
|
|
1671
|
-
/* @__PURE__ */
|
|
1711
|
+
v ? /* @__PURE__ */ K(Ln, { children: /* @__PURE__ */ K(Pn, { children: (e) => /* @__PURE__ */ K(Nn, { data: e }) }) }) : null,
|
|
1712
|
+
/* @__PURE__ */ K(Rn, {
|
|
1672
1713
|
placeholder: r,
|
|
1673
1714
|
disabled: c || F === "streaming",
|
|
1674
1715
|
onChange: D ? (e) => D(e.currentTarget.value) : void 0
|
|
1675
1716
|
}),
|
|
1676
|
-
/* @__PURE__ */
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
children:
|
|
1684
|
-
|
|
1685
|
-
|
|
1717
|
+
/* @__PURE__ */ q(Bn, { children: [/* @__PURE__ */ q(Vn, { children: [
|
|
1718
|
+
v ? /* @__PURE__ */ q(Un, { children: [/* @__PURE__ */ K(Wn, {}), /* @__PURE__ */ K(Gn, { children: /* @__PURE__ */ K(Fn, {}) })] }) : null,
|
|
1719
|
+
S && S.length > 0 ? /* @__PURE__ */ K("select", {
|
|
1720
|
+
"aria-label": "Model",
|
|
1721
|
+
value: C ?? S[0].id,
|
|
1722
|
+
onChange: (e) => w?.(e.target.value),
|
|
1723
|
+
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",
|
|
1724
|
+
children: S.map((e) => /* @__PURE__ */ q("option", {
|
|
1725
|
+
value: e.id,
|
|
1726
|
+
children: [e.label ?? e.id, e.provider ? ` · ${e.provider}` : ""]
|
|
1727
|
+
}, e.id))
|
|
1728
|
+
}) : null,
|
|
1729
|
+
/* @__PURE__ */ q("span", {
|
|
1730
|
+
className: "hidden items-center gap-1 text-[10px] text-muted-foreground sm:inline-flex",
|
|
1731
|
+
"aria-hidden": "true",
|
|
1732
|
+
children: [
|
|
1733
|
+
/* @__PURE__ */ K("kbd", {
|
|
1734
|
+
className: "inline-flex h-4 items-center rounded border bg-muted px-1 font-mono text-[10px] leading-none",
|
|
1735
|
+
children: "⌘"
|
|
1736
|
+
}),
|
|
1737
|
+
/* @__PURE__ */ K(Ze, { className: "h-3 w-3" }),
|
|
1738
|
+
/* @__PURE__ */ K("span", {
|
|
1739
|
+
className: "opacity-70",
|
|
1740
|
+
children: "to send"
|
|
1741
|
+
})
|
|
1742
|
+
]
|
|
1743
|
+
})
|
|
1744
|
+
] }), /* @__PURE__ */ K(qn, {
|
|
1686
1745
|
status: F,
|
|
1687
1746
|
disabled: c,
|
|
1688
1747
|
onClick: F === "streaming" ? o : void 0
|
|
@@ -1690,7 +1749,7 @@ var $ = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type y
|
|
|
1690
1749
|
]
|
|
1691
1750
|
})]
|
|
1692
1751
|
}),
|
|
1693
|
-
/* @__PURE__ */
|
|
1752
|
+
/* @__PURE__ */ K("span", {
|
|
1694
1753
|
hidden: !0,
|
|
1695
1754
|
"data-avatar-user": f ?? p,
|
|
1696
1755
|
"data-avatar-assistant": m ?? h
|
|
@@ -1699,9 +1758,42 @@ var $ = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type y
|
|
|
1699
1758
|
});
|
|
1700
1759
|
});
|
|
1701
1760
|
$.displayName = "ChatbotEnhanced";
|
|
1761
|
+
function Hr({ error: t, onReload: n }) {
|
|
1762
|
+
let { summary: r, details: i } = e.useMemo(() => Yt(t), [t]), [a, o] = e.useState(!1);
|
|
1763
|
+
return /* @__PURE__ */ q("div", {
|
|
1764
|
+
className: "flex flex-col gap-1 border-t bg-destructive/10 px-4 py-2 text-destructive text-sm",
|
|
1765
|
+
role: "alert",
|
|
1766
|
+
children: [/* @__PURE__ */ q("div", {
|
|
1767
|
+
className: "flex items-center gap-2",
|
|
1768
|
+
children: [
|
|
1769
|
+
/* @__PURE__ */ K(Pe, { className: "h-4 w-4 shrink-0" }),
|
|
1770
|
+
/* @__PURE__ */ K("span", {
|
|
1771
|
+
className: "flex-1 leading-snug",
|
|
1772
|
+
children: r || "An error occurred"
|
|
1773
|
+
}),
|
|
1774
|
+
i ? /* @__PURE__ */ K("button", {
|
|
1775
|
+
type: "button",
|
|
1776
|
+
onClick: () => o((e) => !e),
|
|
1777
|
+
className: "text-xs underline hover:no-underline",
|
|
1778
|
+
"aria-expanded": a,
|
|
1779
|
+
children: a ? "Hide details" : "Details"
|
|
1780
|
+
}) : null,
|
|
1781
|
+
n ? /* @__PURE__ */ q("button", {
|
|
1782
|
+
type: "button",
|
|
1783
|
+
onClick: n,
|
|
1784
|
+
className: "inline-flex h-7 items-center rounded-md border border-destructive/30 bg-destructive/10 px-2 text-xs font-medium hover:bg-destructive/20",
|
|
1785
|
+
children: [/* @__PURE__ */ K(ct, { className: "mr-1 h-3 w-3" }), "Retry"]
|
|
1786
|
+
}) : null
|
|
1787
|
+
]
|
|
1788
|
+
}), a && i ? /* @__PURE__ */ K("pre", {
|
|
1789
|
+
className: "max-h-32 overflow-auto whitespace-pre-wrap break-words rounded bg-destructive/5 px-2 py-1 font-mono text-[11px] leading-snug text-destructive/90",
|
|
1790
|
+
children: i
|
|
1791
|
+
}) : null]
|
|
1792
|
+
});
|
|
1793
|
+
}
|
|
1702
1794
|
//#endregion
|
|
1703
1795
|
//#region src/FloatingChatbot.tsx
|
|
1704
|
-
function
|
|
1796
|
+
function Ur({ floatingConfig: t, headerExtra: n, ...r }) {
|
|
1705
1797
|
let { position: i = "bottom-right", defaultOpen: a = !1, panelWidth: o = 400, panelHeight: s = 520, title: c = "Chat", triggerSize: l = 56 } = t ?? {}, [u, d] = e.useState(null);
|
|
1706
1798
|
e.useEffect(() => {
|
|
1707
1799
|
let e = document.getElementById("floating-chatbot-portal");
|
|
@@ -1709,27 +1801,27 @@ function Rr({ floatingConfig: t, headerExtra: n, ...r }) {
|
|
|
1709
1801
|
e && e.parentNode && !e.hasChildNodes() && e.parentNode.removeChild(e);
|
|
1710
1802
|
};
|
|
1711
1803
|
}, []);
|
|
1712
|
-
let f = /* @__PURE__ */
|
|
1804
|
+
let f = /* @__PURE__ */ q(Vt, {
|
|
1713
1805
|
defaultOpen: a,
|
|
1714
|
-
children: [/* @__PURE__ */
|
|
1806
|
+
children: [/* @__PURE__ */ K(Wt, {
|
|
1715
1807
|
position: i,
|
|
1716
1808
|
size: l
|
|
1717
|
-
}), /* @__PURE__ */
|
|
1809
|
+
}), /* @__PURE__ */ K(Gt, {
|
|
1718
1810
|
title: c,
|
|
1719
1811
|
position: i,
|
|
1720
1812
|
width: o,
|
|
1721
1813
|
height: s,
|
|
1722
1814
|
headerExtra: n,
|
|
1723
|
-
children: /* @__PURE__ */
|
|
1815
|
+
children: /* @__PURE__ */ K($, {
|
|
1724
1816
|
...r,
|
|
1725
1817
|
maxHeight: "100%",
|
|
1726
1818
|
className: "h-full border-0 rounded-none"
|
|
1727
1819
|
})
|
|
1728
1820
|
})]
|
|
1729
1821
|
});
|
|
1730
|
-
return u ?
|
|
1822
|
+
return u ? gt.createPortal(f, u) : f;
|
|
1731
1823
|
}
|
|
1732
|
-
|
|
1824
|
+
J.register("chatbot", ({ schema: e, className: t, ...n }) => {
|
|
1733
1825
|
let { messages: r, isLoading: i, sendMessage: a } = Y({
|
|
1734
1826
|
api: e.api,
|
|
1735
1827
|
initialMessages: e.messages,
|
|
@@ -1747,7 +1839,7 @@ Et.register("chatbot", ({ schema: e, className: t, ...n }) => {
|
|
|
1747
1839
|
autoResponseDelay: e.autoResponseDelay,
|
|
1748
1840
|
onSend: e.onSend
|
|
1749
1841
|
});
|
|
1750
|
-
return /* @__PURE__ */
|
|
1842
|
+
return /* @__PURE__ */ K(ui, {
|
|
1751
1843
|
messages: r,
|
|
1752
1844
|
placeholder: e.placeholder,
|
|
1753
1845
|
onSendMessage: (e) => {
|
|
@@ -1895,7 +1987,7 @@ Et.register("chatbot", ({ schema: e, className: t, ...n }) => {
|
|
|
1895
1987
|
autoResponseDelay: 1e3,
|
|
1896
1988
|
className: "w-full max-w-2xl"
|
|
1897
1989
|
}
|
|
1898
|
-
}),
|
|
1990
|
+
}), J.register("chatbot-enhanced", ({ schema: e, className: t, ...n }) => {
|
|
1899
1991
|
let { messages: r, isLoading: i, error: a, sendMessage: o, stop: s, reload: c, clear: l, isApiMode: u } = Y({
|
|
1900
1992
|
api: e.api,
|
|
1901
1993
|
initialMessages: e.messages,
|
|
@@ -1913,7 +2005,7 @@ Et.register("chatbot", ({ schema: e, className: t, ...n }) => {
|
|
|
1913
2005
|
autoResponseDelay: e.autoResponseDelay,
|
|
1914
2006
|
onSend: e.onSend
|
|
1915
2007
|
});
|
|
1916
|
-
return /* @__PURE__ */
|
|
2008
|
+
return /* @__PURE__ */ K($, {
|
|
1917
2009
|
messages: r,
|
|
1918
2010
|
placeholder: e.placeholder,
|
|
1919
2011
|
onSendMessage: (e, t) => {
|
|
@@ -2075,7 +2167,7 @@ Et.register("chatbot", ({ schema: e, className: t, ...n }) => {
|
|
|
2075
2167
|
autoResponseDelay: 1e3,
|
|
2076
2168
|
className: "w-full max-w-2xl"
|
|
2077
2169
|
}
|
|
2078
|
-
}),
|
|
2170
|
+
}), J.register("chatbot-floating", ({ schema: e, className: t, ...n }) => {
|
|
2079
2171
|
let { messages: r, isLoading: i, error: a, sendMessage: o, stop: s, reload: c, clear: l, isApiMode: u } = Y({
|
|
2080
2172
|
api: e.api,
|
|
2081
2173
|
initialMessages: e.messages,
|
|
@@ -2093,7 +2185,7 @@ Et.register("chatbot", ({ schema: e, className: t, ...n }) => {
|
|
|
2093
2185
|
autoResponseDelay: e.autoResponseDelay,
|
|
2094
2186
|
onSend: e.onSend
|
|
2095
2187
|
});
|
|
2096
|
-
return /* @__PURE__ */
|
|
2188
|
+
return /* @__PURE__ */ K(Ur, {
|
|
2097
2189
|
floatingConfig: e.floatingConfig,
|
|
2098
2190
|
messages: r,
|
|
2099
2191
|
placeholder: e.placeholder,
|
|
@@ -2265,71 +2357,71 @@ Et.register("chatbot", ({ schema: e, className: t, ...n }) => {
|
|
|
2265
2357
|
});
|
|
2266
2358
|
//#endregion
|
|
2267
2359
|
//#region src/elements/loader.tsx
|
|
2268
|
-
var
|
|
2360
|
+
var Wr = ({ size: e = 16 }) => /* @__PURE__ */ q("svg", {
|
|
2269
2361
|
height: e,
|
|
2270
2362
|
strokeLinejoin: "round",
|
|
2271
2363
|
style: { color: "currentcolor" },
|
|
2272
2364
|
viewBox: "0 0 16 16",
|
|
2273
2365
|
width: e,
|
|
2274
2366
|
children: [
|
|
2275
|
-
/* @__PURE__ */
|
|
2276
|
-
/* @__PURE__ */
|
|
2367
|
+
/* @__PURE__ */ K("title", { children: "Loader" }),
|
|
2368
|
+
/* @__PURE__ */ q("g", {
|
|
2277
2369
|
clipPath: "url(#clip0_2393_1490)",
|
|
2278
2370
|
children: [
|
|
2279
|
-
/* @__PURE__ */
|
|
2371
|
+
/* @__PURE__ */ K("path", {
|
|
2280
2372
|
d: "M8 0V4",
|
|
2281
2373
|
stroke: "currentColor",
|
|
2282
2374
|
strokeWidth: "1.5"
|
|
2283
2375
|
}),
|
|
2284
|
-
/* @__PURE__ */
|
|
2376
|
+
/* @__PURE__ */ K("path", {
|
|
2285
2377
|
d: "M8 16V12",
|
|
2286
2378
|
opacity: "0.5",
|
|
2287
2379
|
stroke: "currentColor",
|
|
2288
2380
|
strokeWidth: "1.5"
|
|
2289
2381
|
}),
|
|
2290
|
-
/* @__PURE__ */
|
|
2382
|
+
/* @__PURE__ */ K("path", {
|
|
2291
2383
|
d: "M3.29773 1.52783L5.64887 4.7639",
|
|
2292
2384
|
opacity: "0.9",
|
|
2293
2385
|
stroke: "currentColor",
|
|
2294
2386
|
strokeWidth: "1.5"
|
|
2295
2387
|
}),
|
|
2296
|
-
/* @__PURE__ */
|
|
2388
|
+
/* @__PURE__ */ K("path", {
|
|
2297
2389
|
d: "M12.7023 1.52783L10.3511 4.7639",
|
|
2298
2390
|
opacity: "0.1",
|
|
2299
2391
|
stroke: "currentColor",
|
|
2300
2392
|
strokeWidth: "1.5"
|
|
2301
2393
|
}),
|
|
2302
|
-
/* @__PURE__ */
|
|
2394
|
+
/* @__PURE__ */ K("path", {
|
|
2303
2395
|
d: "M12.7023 14.472L10.3511 11.236",
|
|
2304
2396
|
opacity: "0.4",
|
|
2305
2397
|
stroke: "currentColor",
|
|
2306
2398
|
strokeWidth: "1.5"
|
|
2307
2399
|
}),
|
|
2308
|
-
/* @__PURE__ */
|
|
2400
|
+
/* @__PURE__ */ K("path", {
|
|
2309
2401
|
d: "M3.29773 14.472L5.64887 11.236",
|
|
2310
2402
|
opacity: "0.6",
|
|
2311
2403
|
stroke: "currentColor",
|
|
2312
2404
|
strokeWidth: "1.5"
|
|
2313
2405
|
}),
|
|
2314
|
-
/* @__PURE__ */
|
|
2406
|
+
/* @__PURE__ */ K("path", {
|
|
2315
2407
|
d: "M15.6085 5.52783L11.8043 6.7639",
|
|
2316
2408
|
opacity: "0.2",
|
|
2317
2409
|
stroke: "currentColor",
|
|
2318
2410
|
strokeWidth: "1.5"
|
|
2319
2411
|
}),
|
|
2320
|
-
/* @__PURE__ */
|
|
2412
|
+
/* @__PURE__ */ K("path", {
|
|
2321
2413
|
d: "M0.391602 10.472L4.19583 9.23598",
|
|
2322
2414
|
opacity: "0.7",
|
|
2323
2415
|
stroke: "currentColor",
|
|
2324
2416
|
strokeWidth: "1.5"
|
|
2325
2417
|
}),
|
|
2326
|
-
/* @__PURE__ */
|
|
2418
|
+
/* @__PURE__ */ K("path", {
|
|
2327
2419
|
d: "M15.6085 10.4722L11.8043 9.2361",
|
|
2328
2420
|
opacity: "0.3",
|
|
2329
2421
|
stroke: "currentColor",
|
|
2330
2422
|
strokeWidth: "1.5"
|
|
2331
2423
|
}),
|
|
2332
|
-
/* @__PURE__ */
|
|
2424
|
+
/* @__PURE__ */ K("path", {
|
|
2333
2425
|
d: "M0.391602 5.52783L4.19583 6.7639",
|
|
2334
2426
|
opacity: "0.8",
|
|
2335
2427
|
stroke: "currentColor",
|
|
@@ -2337,106 +2429,106 @@ var zr = ({ size: e = 16 }) => /* @__PURE__ */ J("svg", {
|
|
|
2337
2429
|
})
|
|
2338
2430
|
]
|
|
2339
2431
|
}),
|
|
2340
|
-
/* @__PURE__ */
|
|
2432
|
+
/* @__PURE__ */ K("defs", { children: /* @__PURE__ */ K("clipPath", {
|
|
2341
2433
|
id: "clip0_2393_1490",
|
|
2342
|
-
children: /* @__PURE__ */
|
|
2434
|
+
children: /* @__PURE__ */ K("rect", {
|
|
2343
2435
|
fill: "white",
|
|
2344
2436
|
height: "16",
|
|
2345
2437
|
width: "16"
|
|
2346
2438
|
})
|
|
2347
2439
|
}) })
|
|
2348
2440
|
]
|
|
2349
|
-
}),
|
|
2350
|
-
className:
|
|
2441
|
+
}), Gr = ({ className: e, size: t = 16, ...n }) => /* @__PURE__ */ K("div", {
|
|
2442
|
+
className: H("inline-flex animate-spin items-center justify-center", e),
|
|
2351
2443
|
...n,
|
|
2352
|
-
children: /* @__PURE__ */
|
|
2353
|
-
}),
|
|
2444
|
+
children: /* @__PURE__ */ K(Wr, { size: t })
|
|
2445
|
+
}), Kr = /* @__PURE__ */ Ot({
|
|
2354
2446
|
CodeBlock: () => Q,
|
|
2355
|
-
CodeBlockCopyButton: () =>
|
|
2356
|
-
Conversation: () =>
|
|
2357
|
-
ConversationContent: () =>
|
|
2358
|
-
ConversationEmptyState: () =>
|
|
2359
|
-
ConversationScrollButton: () =>
|
|
2360
|
-
Loader: () =>
|
|
2361
|
-
Message: () =>
|
|
2362
|
-
MessageAction: () =>
|
|
2363
|
-
MessageActions: () =>
|
|
2364
|
-
MessageAttachment: () =>
|
|
2365
|
-
MessageAttachments: () =>
|
|
2366
|
-
MessageBranch: () =>
|
|
2367
|
-
MessageBranchContent: () =>
|
|
2368
|
-
MessageBranchNext: () =>
|
|
2369
|
-
MessageBranchPage: () =>
|
|
2370
|
-
MessageBranchPrevious: () =>
|
|
2371
|
-
MessageBranchSelector: () =>
|
|
2372
|
-
MessageContent: () =>
|
|
2373
|
-
MessageResponse: () =>
|
|
2374
|
-
MessageToolbar: () =>
|
|
2375
|
-
PromptInput: () =>
|
|
2376
|
-
PromptInputActionAddAttachments: () =>
|
|
2377
|
-
PromptInputActionMenu: () =>
|
|
2378
|
-
PromptInputActionMenuContent: () =>
|
|
2379
|
-
PromptInputActionMenuItem: () =>
|
|
2380
|
-
PromptInputActionMenuTrigger: () =>
|
|
2381
|
-
PromptInputAttachment: () =>
|
|
2382
|
-
PromptInputAttachments: () =>
|
|
2383
|
-
PromptInputBody: () =>
|
|
2384
|
-
PromptInputButton: () =>
|
|
2385
|
-
PromptInputCommand: () =>
|
|
2386
|
-
PromptInputCommandEmpty: () =>
|
|
2387
|
-
PromptInputCommandGroup: () =>
|
|
2388
|
-
PromptInputCommandInput: () =>
|
|
2389
|
-
PromptInputCommandItem: () =>
|
|
2390
|
-
PromptInputCommandList: () =>
|
|
2391
|
-
PromptInputCommandSeparator: () =>
|
|
2392
|
-
PromptInputFooter: () =>
|
|
2393
|
-
PromptInputHeader: () =>
|
|
2394
|
-
PromptInputHoverCard: () =>
|
|
2395
|
-
PromptInputHoverCardContent: () =>
|
|
2396
|
-
PromptInputHoverCardTrigger: () =>
|
|
2397
|
-
PromptInputProvider: () =>
|
|
2398
|
-
PromptInputSelect: () =>
|
|
2399
|
-
PromptInputSelectContent: () =>
|
|
2400
|
-
PromptInputSelectItem: () =>
|
|
2401
|
-
PromptInputSelectTrigger: () =>
|
|
2402
|
-
PromptInputSelectValue: () =>
|
|
2403
|
-
PromptInputSpeechButton: () =>
|
|
2404
|
-
PromptInputSubmit: () =>
|
|
2405
|
-
PromptInputTab: () =>
|
|
2406
|
-
PromptInputTabBody: () =>
|
|
2407
|
-
PromptInputTabItem: () =>
|
|
2408
|
-
PromptInputTabLabel: () =>
|
|
2409
|
-
PromptInputTabsList: () =>
|
|
2410
|
-
PromptInputTextarea: () =>
|
|
2411
|
-
PromptInputTools: () =>
|
|
2412
|
-
Reasoning: () =>
|
|
2413
|
-
ReasoningContent: () =>
|
|
2414
|
-
ReasoningTrigger: () =>
|
|
2415
|
-
Shimmer: () =>
|
|
2416
|
-
Source: () =>
|
|
2417
|
-
Sources: () =>
|
|
2418
|
-
SourcesContent: () =>
|
|
2419
|
-
SourcesTrigger: () =>
|
|
2420
|
-
Suggestion: () =>
|
|
2421
|
-
Suggestions: () =>
|
|
2422
|
-
Tool: () =>
|
|
2423
|
-
ToolContent: () =>
|
|
2424
|
-
ToolHeader: () =>
|
|
2425
|
-
ToolInput: () =>
|
|
2426
|
-
ToolOutput: () =>
|
|
2427
|
-
highlightCode: () =>
|
|
2447
|
+
CodeBlockCopyButton: () => br,
|
|
2448
|
+
Conversation: () => Xt,
|
|
2449
|
+
ConversationContent: () => Zt,
|
|
2450
|
+
ConversationEmptyState: () => Qt,
|
|
2451
|
+
ConversationScrollButton: () => $t,
|
|
2452
|
+
Loader: () => Gr,
|
|
2453
|
+
Message: () => rn,
|
|
2454
|
+
MessageAction: () => sn,
|
|
2455
|
+
MessageActions: () => on,
|
|
2456
|
+
MessageAttachment: () => gn,
|
|
2457
|
+
MessageAttachments: () => _n,
|
|
2458
|
+
MessageBranch: () => ln,
|
|
2459
|
+
MessageBranchContent: () => un,
|
|
2460
|
+
MessageBranchNext: () => pn,
|
|
2461
|
+
MessageBranchPage: () => mn,
|
|
2462
|
+
MessageBranchPrevious: () => fn,
|
|
2463
|
+
MessageBranchSelector: () => dn,
|
|
2464
|
+
MessageContent: () => an,
|
|
2465
|
+
MessageResponse: () => hn,
|
|
2466
|
+
MessageToolbar: () => vn,
|
|
2467
|
+
PromptInput: () => In,
|
|
2468
|
+
PromptInputActionAddAttachments: () => Fn,
|
|
2469
|
+
PromptInputActionMenu: () => Un,
|
|
2470
|
+
PromptInputActionMenuContent: () => Gn,
|
|
2471
|
+
PromptInputActionMenuItem: () => Kn,
|
|
2472
|
+
PromptInputActionMenuTrigger: () => Wn,
|
|
2473
|
+
PromptInputAttachment: () => Nn,
|
|
2474
|
+
PromptInputAttachments: () => Pn,
|
|
2475
|
+
PromptInputBody: () => Ln,
|
|
2476
|
+
PromptInputButton: () => Hn,
|
|
2477
|
+
PromptInputCommand: () => cr,
|
|
2478
|
+
PromptInputCommandEmpty: () => dr,
|
|
2479
|
+
PromptInputCommandGroup: () => fr,
|
|
2480
|
+
PromptInputCommandInput: () => lr,
|
|
2481
|
+
PromptInputCommandItem: () => pr,
|
|
2482
|
+
PromptInputCommandList: () => ur,
|
|
2483
|
+
PromptInputCommandSeparator: () => mr,
|
|
2484
|
+
PromptInputFooter: () => Bn,
|
|
2485
|
+
PromptInputHeader: () => zn,
|
|
2486
|
+
PromptInputHoverCard: () => er,
|
|
2487
|
+
PromptInputHoverCardContent: () => nr,
|
|
2488
|
+
PromptInputHoverCardTrigger: () => tr,
|
|
2489
|
+
PromptInputProvider: () => jn,
|
|
2490
|
+
PromptInputSelect: () => Yn,
|
|
2491
|
+
PromptInputSelectContent: () => Zn,
|
|
2492
|
+
PromptInputSelectItem: () => Qn,
|
|
2493
|
+
PromptInputSelectTrigger: () => Xn,
|
|
2494
|
+
PromptInputSelectValue: () => $n,
|
|
2495
|
+
PromptInputSpeechButton: () => Jn,
|
|
2496
|
+
PromptInputSubmit: () => qn,
|
|
2497
|
+
PromptInputTab: () => ir,
|
|
2498
|
+
PromptInputTabBody: () => or,
|
|
2499
|
+
PromptInputTabItem: () => sr,
|
|
2500
|
+
PromptInputTabLabel: () => ar,
|
|
2501
|
+
PromptInputTabsList: () => rr,
|
|
2502
|
+
PromptInputTextarea: () => Rn,
|
|
2503
|
+
PromptInputTools: () => Vn,
|
|
2504
|
+
Reasoning: () => Mr,
|
|
2505
|
+
ReasoningContent: () => Fr,
|
|
2506
|
+
ReasoningTrigger: () => Pr,
|
|
2507
|
+
Shimmer: () => Dr,
|
|
2508
|
+
Source: () => zr,
|
|
2509
|
+
Sources: () => Ir,
|
|
2510
|
+
SourcesContent: () => Rr,
|
|
2511
|
+
SourcesTrigger: () => Lr,
|
|
2512
|
+
Suggestion: () => gr,
|
|
2513
|
+
Suggestions: () => hr,
|
|
2514
|
+
Tool: () => xr,
|
|
2515
|
+
ToolContent: () => wr,
|
|
2516
|
+
ToolHeader: () => Cr,
|
|
2517
|
+
ToolInput: () => Tr,
|
|
2518
|
+
ToolOutput: () => Er,
|
|
2519
|
+
highlightCode: () => yr,
|
|
2428
2520
|
usePromptInputAttachments: () => Z,
|
|
2429
|
-
usePromptInputController: () =>
|
|
2430
|
-
useProviderAttachments: () =>
|
|
2431
|
-
useReasoning: () =>
|
|
2432
|
-
}),
|
|
2433
|
-
function
|
|
2521
|
+
usePromptInputController: () => Dn,
|
|
2522
|
+
useProviderAttachments: () => kn,
|
|
2523
|
+
useReasoning: () => kr
|
|
2524
|
+
}), qr = "/api/v1/ai";
|
|
2525
|
+
function Jr(e, t, n) {
|
|
2434
2526
|
let r = e.replace(/\/$/, ""), i = new URLSearchParams();
|
|
2435
2527
|
if (n) for (let [e, t] of Object.entries(n)) t == null || t === "" || i.set(e, String(t));
|
|
2436
2528
|
let a = i.toString();
|
|
2437
2529
|
return `${r}${t}${a ? `?${a}` : ""}`;
|
|
2438
2530
|
}
|
|
2439
|
-
async function
|
|
2531
|
+
async function Yr(e, t, n) {
|
|
2440
2532
|
let r = await fetch(e, {
|
|
2441
2533
|
credentials: "include",
|
|
2442
2534
|
...t,
|
|
@@ -2456,8 +2548,8 @@ async function Wr(e, t, n) {
|
|
|
2456
2548
|
}
|
|
2457
2549
|
return i;
|
|
2458
2550
|
}
|
|
2459
|
-
function
|
|
2460
|
-
let { apiBase: n =
|
|
2551
|
+
function Xr(t = {}) {
|
|
2552
|
+
let { apiBase: n = qr, 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({
|
|
2461
2553
|
apiBase: n,
|
|
2462
2554
|
status: r,
|
|
2463
2555
|
conversationId: i,
|
|
@@ -2475,7 +2567,7 @@ function Gr(t = {}) {
|
|
|
2475
2567
|
let { apiBase: e, status: t, conversationId: n, limit: r, headers: i } = _.current;
|
|
2476
2568
|
m(!0), g(void 0);
|
|
2477
2569
|
try {
|
|
2478
|
-
let a = await
|
|
2570
|
+
let a = await Yr(Jr(e, "/pending-actions", {
|
|
2479
2571
|
status: t && t !== "all" ? t : void 0,
|
|
2480
2572
|
conversationId: n,
|
|
2481
2573
|
limit: r
|
|
@@ -2487,9 +2579,9 @@ function Gr(t = {}) {
|
|
|
2487
2579
|
m(!1);
|
|
2488
2580
|
}
|
|
2489
2581
|
}, []), y = e.useCallback(async (e) => {
|
|
2490
|
-
let { apiBase: t, headers: n } = _.current, r =
|
|
2582
|
+
let { apiBase: t, headers: n } = _.current, r = Jr(t, `/pending-actions/${encodeURIComponent(e)}/approve`);
|
|
2491
2583
|
try {
|
|
2492
|
-
return await
|
|
2584
|
+
return await Yr(r, {
|
|
2493
2585
|
method: "POST",
|
|
2494
2586
|
body: "{}"
|
|
2495
2587
|
}, n);
|
|
@@ -2497,9 +2589,9 @@ function Gr(t = {}) {
|
|
|
2497
2589
|
v();
|
|
2498
2590
|
}
|
|
2499
2591
|
}, [v]), b = e.useCallback(async (e, t) => {
|
|
2500
|
-
let { apiBase: n, headers: r } = _.current, i =
|
|
2592
|
+
let { apiBase: n, headers: r } = _.current, i = Jr(n, `/pending-actions/${encodeURIComponent(e)}/reject`);
|
|
2501
2593
|
try {
|
|
2502
|
-
return await
|
|
2594
|
+
return await Yr(i, {
|
|
2503
2595
|
method: "POST",
|
|
2504
2596
|
body: JSON.stringify(t ? { reason: t } : {})
|
|
2505
2597
|
}, r);
|
|
@@ -2533,7 +2625,7 @@ function Gr(t = {}) {
|
|
|
2533
2625
|
}
|
|
2534
2626
|
//#endregion
|
|
2535
2627
|
//#region src/AiPendingActionsInbox.tsx
|
|
2536
|
-
var
|
|
2628
|
+
var Zr = {
|
|
2537
2629
|
pending: {
|
|
2538
2630
|
variant: "secondary",
|
|
2539
2631
|
label: "Pending"
|
|
@@ -2555,17 +2647,17 @@ var Kr = {
|
|
|
2555
2647
|
label: "Rejected"
|
|
2556
2648
|
}
|
|
2557
2649
|
};
|
|
2558
|
-
function
|
|
2559
|
-
let t =
|
|
2650
|
+
function Qr({ status: e }) {
|
|
2651
|
+
let t = Zr[e] ?? {
|
|
2560
2652
|
variant: "outline",
|
|
2561
2653
|
label: e
|
|
2562
2654
|
};
|
|
2563
|
-
return /* @__PURE__ */
|
|
2655
|
+
return /* @__PURE__ */ K(_, {
|
|
2564
2656
|
variant: t.variant,
|
|
2565
2657
|
children: t.label
|
|
2566
2658
|
});
|
|
2567
2659
|
}
|
|
2568
|
-
function
|
|
2660
|
+
function $r(e) {
|
|
2569
2661
|
if (!e) return "—";
|
|
2570
2662
|
let t = Date.parse(e);
|
|
2571
2663
|
if (Number.isNaN(t)) return e;
|
|
@@ -2583,7 +2675,7 @@ function Jr(e) {
|
|
|
2583
2675
|
return e;
|
|
2584
2676
|
}
|
|
2585
2677
|
}
|
|
2586
|
-
function
|
|
2678
|
+
function ei(e) {
|
|
2587
2679
|
if (!e) return null;
|
|
2588
2680
|
try {
|
|
2589
2681
|
return JSON.parse(e);
|
|
@@ -2591,31 +2683,31 @@ function Yr(e) {
|
|
|
2591
2683
|
return e;
|
|
2592
2684
|
}
|
|
2593
2685
|
}
|
|
2594
|
-
function
|
|
2686
|
+
function ti({ value: e, max: t = 320 }) {
|
|
2595
2687
|
let n = typeof e == "string" ? e : JSON.stringify(e, null, 2);
|
|
2596
|
-
return n == null || n === "" ? /* @__PURE__ */
|
|
2688
|
+
return n == null || n === "" ? /* @__PURE__ */ K("span", {
|
|
2597
2689
|
className: "text-muted-foreground text-xs",
|
|
2598
2690
|
children: "—"
|
|
2599
|
-
}) : /* @__PURE__ */
|
|
2691
|
+
}) : /* @__PURE__ */ K("pre", {
|
|
2600
2692
|
className: "bg-muted/40 rounded text-xs p-2 overflow-auto whitespace-pre-wrap break-all",
|
|
2601
2693
|
style: { maxHeight: t },
|
|
2602
2694
|
children: n
|
|
2603
2695
|
});
|
|
2604
2696
|
}
|
|
2605
|
-
function
|
|
2697
|
+
function ni(e) {
|
|
2606
2698
|
switch (e) {
|
|
2607
2699
|
case "pending": return "pending";
|
|
2608
2700
|
case "all": return "all";
|
|
2609
2701
|
case "decided": return "all";
|
|
2610
2702
|
}
|
|
2611
2703
|
}
|
|
2612
|
-
function
|
|
2613
|
-
let [l, u] = e.useState("pending"), [d, m] = e.useState(null), [h, g] = e.useState(null), [_, w] = e.useState(""), [T, E] = e.useState(null), [D, O] = e.useState(null), [k, A] = e.useState(null), { items: j, isLoading: M, error: N, refresh: P, approve: F, reject: I } =
|
|
2704
|
+
function ri({ 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 }) {
|
|
2705
|
+
let [l, u] = e.useState("pending"), [d, m] = e.useState(null), [h, g] = e.useState(null), [_, w] = e.useState(""), [T, E] = e.useState(null), [D, O] = e.useState(null), [k, A] = e.useState(null), { items: j, isLoading: M, error: N, refresh: P, approve: F, reject: I } = Xr({
|
|
2614
2706
|
apiBase: t,
|
|
2615
2707
|
headers: n,
|
|
2616
2708
|
pollInterval: r,
|
|
2617
2709
|
conversationId: i,
|
|
2618
|
-
status:
|
|
2710
|
+
status: ni(l)
|
|
2619
2711
|
}), L = e.useMemo(() => l === "decided" ? j.filter((e) => e.status !== "pending") : j, [j, l]), R = e.useMemo(() => d ? j.find((e) => e.id === d) ?? null : null, [d, j]), ae = e.useCallback(async (e) => {
|
|
2620
2712
|
E(e), O(null);
|
|
2621
2713
|
try {
|
|
@@ -2637,7 +2729,7 @@ function Qr({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
|
|
|
2637
2729
|
} finally {
|
|
2638
2730
|
E(null);
|
|
2639
2731
|
}
|
|
2640
|
-
}, [F]),
|
|
2732
|
+
}, [F]), oe = e.useCallback(async (e, t) => {
|
|
2641
2733
|
E(e), O(null);
|
|
2642
2734
|
try {
|
|
2643
2735
|
await I(e, t.trim() || void 0), A({
|
|
@@ -2657,52 +2749,52 @@ function Qr({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
|
|
|
2657
2749
|
} finally {
|
|
2658
2750
|
E(null);
|
|
2659
2751
|
}
|
|
2660
|
-
}, [I]),
|
|
2752
|
+
}, [I]), se = /* @__PURE__ */ q("div", {
|
|
2661
2753
|
className: "space-y-3",
|
|
2662
2754
|
children: [
|
|
2663
|
-
/* @__PURE__ */
|
|
2755
|
+
/* @__PURE__ */ q("div", {
|
|
2664
2756
|
className: "flex items-center justify-between gap-2",
|
|
2665
|
-
children: [/* @__PURE__ */
|
|
2757
|
+
children: [/* @__PURE__ */ K(Ee, {
|
|
2666
2758
|
value: l,
|
|
2667
2759
|
onValueChange: (e) => u(e),
|
|
2668
|
-
children: /* @__PURE__ */
|
|
2669
|
-
/* @__PURE__ */
|
|
2760
|
+
children: /* @__PURE__ */ q(De, { children: [
|
|
2761
|
+
/* @__PURE__ */ K(Oe, {
|
|
2670
2762
|
value: "pending",
|
|
2671
2763
|
children: "Pending"
|
|
2672
2764
|
}),
|
|
2673
|
-
/* @__PURE__ */
|
|
2765
|
+
/* @__PURE__ */ K(Oe, {
|
|
2674
2766
|
value: "decided",
|
|
2675
2767
|
children: "Decided"
|
|
2676
2768
|
}),
|
|
2677
|
-
/* @__PURE__ */
|
|
2769
|
+
/* @__PURE__ */ K(Oe, {
|
|
2678
2770
|
value: "all",
|
|
2679
2771
|
children: "All"
|
|
2680
2772
|
})
|
|
2681
2773
|
] })
|
|
2682
|
-
}), /* @__PURE__ */
|
|
2774
|
+
}), /* @__PURE__ */ q(v, {
|
|
2683
2775
|
variant: "outline",
|
|
2684
2776
|
size: "sm",
|
|
2685
2777
|
onClick: () => void P(),
|
|
2686
2778
|
disabled: M,
|
|
2687
2779
|
"data-testid": "ai-inbox-refresh",
|
|
2688
|
-
children: [/* @__PURE__ */
|
|
2780
|
+
children: [/* @__PURE__ */ K(ct, { className: `h-3.5 w-3.5 mr-1.5 ${M ? "animate-spin" : ""}` }), "Refresh"]
|
|
2689
2781
|
})]
|
|
2690
2782
|
}),
|
|
2691
|
-
N ? /* @__PURE__ */
|
|
2783
|
+
N ? /* @__PURE__ */ q(f, {
|
|
2692
2784
|
variant: "destructive",
|
|
2693
|
-
children: [/* @__PURE__ */
|
|
2785
|
+
children: [/* @__PURE__ */ K(Pe, { className: "h-4 w-4" }), /* @__PURE__ */ K(p, { children: N.message })]
|
|
2694
2786
|
}) : null,
|
|
2695
|
-
D ? /* @__PURE__ */
|
|
2787
|
+
D ? /* @__PURE__ */ q(f, {
|
|
2696
2788
|
variant: "destructive",
|
|
2697
|
-
children: [/* @__PURE__ */
|
|
2789
|
+
children: [/* @__PURE__ */ K(Pe, { className: "h-4 w-4" }), /* @__PURE__ */ K(p, { children: D })]
|
|
2698
2790
|
}) : null,
|
|
2699
|
-
k && !D ? /* @__PURE__ */
|
|
2791
|
+
k && !D ? /* @__PURE__ */ q(f, {
|
|
2700
2792
|
variant: k.ok ? "default" : "destructive",
|
|
2701
|
-
children: [k.ok ? /* @__PURE__ */
|
|
2793
|
+
children: [k.ok ? /* @__PURE__ */ K(Be, { className: "h-4 w-4" }) : /* @__PURE__ */ K(U, { className: "h-4 w-4" }), /* @__PURE__ */ q(p, { children: [
|
|
2702
2794
|
k.kind === "approve" ? "Approve" : "Reject",
|
|
2703
2795
|
" for",
|
|
2704
2796
|
" ",
|
|
2705
|
-
/* @__PURE__ */
|
|
2797
|
+
/* @__PURE__ */ q("code", {
|
|
2706
2798
|
className: "text-xs",
|
|
2707
2799
|
children: [k.id.slice(0, 8), "…"]
|
|
2708
2800
|
}),
|
|
@@ -2711,89 +2803,89 @@ function Qr({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
|
|
|
2711
2803
|
k.message ?? (k.ok ? "OK" : "Failed")
|
|
2712
2804
|
] })]
|
|
2713
2805
|
}) : null,
|
|
2714
|
-
M && L.length === 0 ? /* @__PURE__ */
|
|
2806
|
+
M && L.length === 0 ? /* @__PURE__ */ q("div", {
|
|
2715
2807
|
className: "space-y-2",
|
|
2716
2808
|
children: [
|
|
2717
|
-
/* @__PURE__ */
|
|
2718
|
-
/* @__PURE__ */
|
|
2719
|
-
/* @__PURE__ */
|
|
2809
|
+
/* @__PURE__ */ K(xe, { className: "h-10 w-full" }),
|
|
2810
|
+
/* @__PURE__ */ K(xe, { className: "h-10 w-full" }),
|
|
2811
|
+
/* @__PURE__ */ K(xe, { className: "h-10 w-full" })
|
|
2720
2812
|
]
|
|
2721
|
-
}) : L.length === 0 ? /* @__PURE__ */
|
|
2722
|
-
/* @__PURE__ */
|
|
2723
|
-
/* @__PURE__ */
|
|
2724
|
-
/* @__PURE__ */
|
|
2725
|
-
] }) }) : /* @__PURE__ */
|
|
2813
|
+
}) : L.length === 0 ? /* @__PURE__ */ K(ee, { children: /* @__PURE__ */ q(ne, { children: [
|
|
2814
|
+
/* @__PURE__ */ K(re, { children: /* @__PURE__ */ K(tt, { className: "h-8 w-8 text-muted-foreground" }) }),
|
|
2815
|
+
/* @__PURE__ */ K(ie, { children: "No actions waiting" }),
|
|
2816
|
+
/* @__PURE__ */ K(te, { children: "When the AI proposes a sensitive action it will appear here for review." })
|
|
2817
|
+
] }) }) : /* @__PURE__ */ K("div", {
|
|
2726
2818
|
className: "rounded-md border",
|
|
2727
|
-
children: /* @__PURE__ */
|
|
2728
|
-
/* @__PURE__ */
|
|
2819
|
+
children: /* @__PURE__ */ q(Se, { children: [/* @__PURE__ */ K(we, { children: /* @__PURE__ */ q(Te, { children: [
|
|
2820
|
+
/* @__PURE__ */ K(V, {
|
|
2729
2821
|
className: "w-[140px]",
|
|
2730
2822
|
children: "Tool"
|
|
2731
2823
|
}),
|
|
2732
|
-
/* @__PURE__ */
|
|
2824
|
+
/* @__PURE__ */ K(V, {
|
|
2733
2825
|
className: "w-[140px]",
|
|
2734
2826
|
children: "Action"
|
|
2735
2827
|
}),
|
|
2736
|
-
/* @__PURE__ */
|
|
2828
|
+
/* @__PURE__ */ K(V, {
|
|
2737
2829
|
className: "w-[120px]",
|
|
2738
2830
|
children: "Object"
|
|
2739
2831
|
}),
|
|
2740
|
-
/* @__PURE__ */
|
|
2832
|
+
/* @__PURE__ */ K(V, {
|
|
2741
2833
|
className: "w-[110px]",
|
|
2742
2834
|
children: "Status"
|
|
2743
2835
|
}),
|
|
2744
|
-
/* @__PURE__ */
|
|
2836
|
+
/* @__PURE__ */ K(V, {
|
|
2745
2837
|
className: "w-[110px]",
|
|
2746
2838
|
children: "Proposed"
|
|
2747
2839
|
}),
|
|
2748
|
-
/* @__PURE__ */
|
|
2840
|
+
/* @__PURE__ */ K(V, {
|
|
2749
2841
|
className: "w-[260px] text-right",
|
|
2750
2842
|
children: "Decision"
|
|
2751
2843
|
})
|
|
2752
|
-
] }) }), /* @__PURE__ */
|
|
2844
|
+
] }) }), /* @__PURE__ */ K(Ce, { children: L.map((e) => {
|
|
2753
2845
|
let t = e.status === "pending", n = T === e.id;
|
|
2754
|
-
return /* @__PURE__ */
|
|
2755
|
-
/* @__PURE__ */
|
|
2846
|
+
return /* @__PURE__ */ q(Te, { children: [
|
|
2847
|
+
/* @__PURE__ */ K(B, {
|
|
2756
2848
|
className: "font-mono text-xs",
|
|
2757
2849
|
children: e.tool_name
|
|
2758
2850
|
}),
|
|
2759
|
-
/* @__PURE__ */
|
|
2851
|
+
/* @__PURE__ */ K(B, {
|
|
2760
2852
|
className: "text-sm",
|
|
2761
2853
|
children: e.action_name
|
|
2762
2854
|
}),
|
|
2763
|
-
/* @__PURE__ */
|
|
2855
|
+
/* @__PURE__ */ K(B, {
|
|
2764
2856
|
className: "text-sm",
|
|
2765
2857
|
children: e.object_name
|
|
2766
2858
|
}),
|
|
2767
|
-
/* @__PURE__ */
|
|
2768
|
-
/* @__PURE__ */
|
|
2859
|
+
/* @__PURE__ */ K(B, { children: /* @__PURE__ */ K(Qr, { status: e.status }) }),
|
|
2860
|
+
/* @__PURE__ */ K(B, {
|
|
2769
2861
|
className: "text-xs text-muted-foreground",
|
|
2770
|
-
children: /* @__PURE__ */
|
|
2862
|
+
children: /* @__PURE__ */ q("span", {
|
|
2771
2863
|
className: "inline-flex items-center gap-1",
|
|
2772
2864
|
children: [
|
|
2773
|
-
/* @__PURE__ */
|
|
2865
|
+
/* @__PURE__ */ K(qe, { className: "h-3 w-3" }),
|
|
2774
2866
|
" ",
|
|
2775
|
-
|
|
2867
|
+
$r(e.proposed_at)
|
|
2776
2868
|
]
|
|
2777
2869
|
})
|
|
2778
2870
|
}),
|
|
2779
|
-
/* @__PURE__ */
|
|
2871
|
+
/* @__PURE__ */ K(B, {
|
|
2780
2872
|
className: "text-right",
|
|
2781
|
-
children: /* @__PURE__ */
|
|
2873
|
+
children: /* @__PURE__ */ q("div", {
|
|
2782
2874
|
className: "inline-flex gap-1.5",
|
|
2783
|
-
children: [/* @__PURE__ */
|
|
2875
|
+
children: [/* @__PURE__ */ q(v, {
|
|
2784
2876
|
size: "sm",
|
|
2785
2877
|
variant: "ghost",
|
|
2786
2878
|
onClick: () => m(e.id),
|
|
2787
2879
|
"data-testid": `ai-inbox-view-${e.id}`,
|
|
2788
|
-
children: [/* @__PURE__ */
|
|
2789
|
-
}), t ? /* @__PURE__ */
|
|
2880
|
+
children: [/* @__PURE__ */ K($e, { className: "h-3.5 w-3.5 mr-1" }), " View"]
|
|
2881
|
+
}), t ? /* @__PURE__ */ q(G, { children: [/* @__PURE__ */ q(v, {
|
|
2790
2882
|
size: "sm",
|
|
2791
2883
|
variant: "default",
|
|
2792
2884
|
disabled: n,
|
|
2793
2885
|
onClick: () => void ae(e.id),
|
|
2794
2886
|
"data-testid": `ai-inbox-approve-${e.id}`,
|
|
2795
|
-
children: [/* @__PURE__ */
|
|
2796
|
-
}), /* @__PURE__ */
|
|
2887
|
+
children: [/* @__PURE__ */ K(Be, { className: "h-3.5 w-3.5 mr-1" }), n ? "Working…" : "Approve"]
|
|
2888
|
+
}), /* @__PURE__ */ q(v, {
|
|
2797
2889
|
size: "sm",
|
|
2798
2890
|
variant: "destructive",
|
|
2799
2891
|
disabled: n,
|
|
@@ -2801,7 +2893,7 @@ function Qr({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
|
|
|
2801
2893
|
g(e.id), w("");
|
|
2802
2894
|
},
|
|
2803
2895
|
"data-testid": `ai-inbox-reject-${e.id}`,
|
|
2804
|
-
children: [/* @__PURE__ */
|
|
2896
|
+
children: [/* @__PURE__ */ K(U, { className: "h-3.5 w-3.5 mr-1" }), "Reject"]
|
|
2805
2897
|
})] }) : null]
|
|
2806
2898
|
})
|
|
2807
2899
|
})
|
|
@@ -2810,174 +2902,174 @@ function Qr({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
|
|
|
2810
2902
|
})
|
|
2811
2903
|
]
|
|
2812
2904
|
});
|
|
2813
|
-
return /* @__PURE__ */
|
|
2814
|
-
a === "card" ? /* @__PURE__ */
|
|
2905
|
+
return /* @__PURE__ */ q(G, { children: [
|
|
2906
|
+
a === "card" ? /* @__PURE__ */ q(y, {
|
|
2815
2907
|
className: c,
|
|
2816
|
-
children: [/* @__PURE__ */
|
|
2908
|
+
children: [/* @__PURE__ */ q(S, {
|
|
2817
2909
|
className: "pb-3",
|
|
2818
|
-
children: [/* @__PURE__ */
|
|
2910
|
+
children: [/* @__PURE__ */ q(C, {
|
|
2819
2911
|
className: "flex items-center gap-2",
|
|
2820
2912
|
children: [
|
|
2821
|
-
/* @__PURE__ */
|
|
2913
|
+
/* @__PURE__ */ K(Le, { className: "h-4 w-4" }),
|
|
2822
2914
|
" ",
|
|
2823
2915
|
o
|
|
2824
2916
|
]
|
|
2825
|
-
}), s ? /* @__PURE__ */
|
|
2826
|
-
}), /* @__PURE__ */
|
|
2827
|
-
}) : /* @__PURE__ */
|
|
2917
|
+
}), s ? /* @__PURE__ */ K(x, { children: s }) : null]
|
|
2918
|
+
}), /* @__PURE__ */ K(b, { children: se })]
|
|
2919
|
+
}) : /* @__PURE__ */ K("div", {
|
|
2828
2920
|
className: c,
|
|
2829
|
-
children:
|
|
2921
|
+
children: se
|
|
2830
2922
|
}),
|
|
2831
|
-
/* @__PURE__ */
|
|
2923
|
+
/* @__PURE__ */ K(ge, {
|
|
2832
2924
|
open: !!d,
|
|
2833
2925
|
onOpenChange: (e) => {
|
|
2834
2926
|
e || m(null);
|
|
2835
2927
|
},
|
|
2836
|
-
children: /* @__PURE__ */
|
|
2928
|
+
children: /* @__PURE__ */ q(_e, {
|
|
2837
2929
|
className: "sm:max-w-[560px] overflow-y-auto",
|
|
2838
|
-
children: [/* @__PURE__ */
|
|
2930
|
+
children: [/* @__PURE__ */ q(ye, { children: [/* @__PURE__ */ q(be, {
|
|
2839
2931
|
className: "flex items-center gap-2",
|
|
2840
|
-
children: [/* @__PURE__ */
|
|
2841
|
-
}), /* @__PURE__ */
|
|
2932
|
+
children: [/* @__PURE__ */ K(Le, { className: "h-4 w-4" }), R ? R.action_name : "Pending action"]
|
|
2933
|
+
}), /* @__PURE__ */ K(ve, { children: R ? /* @__PURE__ */ q(G, { children: [
|
|
2842
2934
|
"Tool ",
|
|
2843
|
-
/* @__PURE__ */
|
|
2935
|
+
/* @__PURE__ */ K("code", {
|
|
2844
2936
|
className: "text-xs",
|
|
2845
2937
|
children: R.tool_name
|
|
2846
2938
|
}),
|
|
2847
2939
|
" on",
|
|
2848
2940
|
" ",
|
|
2849
|
-
/* @__PURE__ */
|
|
2941
|
+
/* @__PURE__ */ K("code", {
|
|
2850
2942
|
className: "text-xs",
|
|
2851
2943
|
children: R.object_name
|
|
2852
2944
|
})
|
|
2853
|
-
] }) : "Loading…" })] }), R ? /* @__PURE__ */
|
|
2945
|
+
] }) : "Loading…" })] }), R ? /* @__PURE__ */ q("div", {
|
|
2854
2946
|
className: "px-4 space-y-4 mt-4",
|
|
2855
2947
|
children: [
|
|
2856
|
-
/* @__PURE__ */
|
|
2948
|
+
/* @__PURE__ */ q("div", {
|
|
2857
2949
|
className: "grid grid-cols-2 gap-3 text-sm",
|
|
2858
2950
|
children: [
|
|
2859
|
-
/* @__PURE__ */
|
|
2951
|
+
/* @__PURE__ */ q("div", { children: [/* @__PURE__ */ K(z, {
|
|
2860
2952
|
className: "text-xs text-muted-foreground",
|
|
2861
2953
|
children: "Status"
|
|
2862
|
-
}), /* @__PURE__ */
|
|
2954
|
+
}), /* @__PURE__ */ K("div", {
|
|
2863
2955
|
className: "mt-1",
|
|
2864
|
-
children: /* @__PURE__ */
|
|
2956
|
+
children: /* @__PURE__ */ K(Qr, { status: R.status })
|
|
2865
2957
|
})] }),
|
|
2866
|
-
/* @__PURE__ */
|
|
2958
|
+
/* @__PURE__ */ q("div", { children: [/* @__PURE__ */ K(z, {
|
|
2867
2959
|
className: "text-xs text-muted-foreground",
|
|
2868
2960
|
children: "Proposed"
|
|
2869
|
-
}), /* @__PURE__ */
|
|
2961
|
+
}), /* @__PURE__ */ K("div", {
|
|
2870
2962
|
className: "mt-1 text-xs",
|
|
2871
|
-
children:
|
|
2963
|
+
children: $r(R.proposed_at)
|
|
2872
2964
|
})] }),
|
|
2873
|
-
/* @__PURE__ */
|
|
2965
|
+
/* @__PURE__ */ q("div", { children: [/* @__PURE__ */ K(z, {
|
|
2874
2966
|
className: "text-xs text-muted-foreground",
|
|
2875
2967
|
children: "Proposed by"
|
|
2876
|
-
}), /* @__PURE__ */
|
|
2968
|
+
}), /* @__PURE__ */ K("div", {
|
|
2877
2969
|
className: "mt-1 text-xs font-mono break-all",
|
|
2878
2970
|
children: R.proposed_by ?? "—"
|
|
2879
2971
|
})] }),
|
|
2880
|
-
/* @__PURE__ */
|
|
2972
|
+
/* @__PURE__ */ q("div", { children: [/* @__PURE__ */ K(z, {
|
|
2881
2973
|
className: "text-xs text-muted-foreground",
|
|
2882
2974
|
children: "Decided by"
|
|
2883
|
-
}), /* @__PURE__ */
|
|
2975
|
+
}), /* @__PURE__ */ K("div", {
|
|
2884
2976
|
className: "mt-1 text-xs font-mono break-all",
|
|
2885
2977
|
children: R.decided_by ?? "—"
|
|
2886
2978
|
})] }),
|
|
2887
|
-
R.conversation_id ? /* @__PURE__ */
|
|
2979
|
+
R.conversation_id ? /* @__PURE__ */ q("div", {
|
|
2888
2980
|
className: "col-span-2",
|
|
2889
|
-
children: [/* @__PURE__ */
|
|
2981
|
+
children: [/* @__PURE__ */ K(z, {
|
|
2890
2982
|
className: "text-xs text-muted-foreground",
|
|
2891
2983
|
children: "Conversation"
|
|
2892
|
-
}), /* @__PURE__ */
|
|
2984
|
+
}), /* @__PURE__ */ K("div", {
|
|
2893
2985
|
className: "mt-1 text-xs font-mono break-all",
|
|
2894
2986
|
children: R.conversation_id
|
|
2895
2987
|
})]
|
|
2896
2988
|
}) : null
|
|
2897
2989
|
]
|
|
2898
2990
|
}),
|
|
2899
|
-
/* @__PURE__ */
|
|
2900
|
-
/* @__PURE__ */
|
|
2991
|
+
/* @__PURE__ */ K(he, {}),
|
|
2992
|
+
/* @__PURE__ */ q("div", { children: [/* @__PURE__ */ K(z, {
|
|
2901
2993
|
className: "text-xs",
|
|
2902
2994
|
children: "Tool input"
|
|
2903
|
-
}), /* @__PURE__ */
|
|
2995
|
+
}), /* @__PURE__ */ K("div", {
|
|
2904
2996
|
className: "mt-1.5",
|
|
2905
|
-
children: /* @__PURE__ */
|
|
2997
|
+
children: /* @__PURE__ */ K(ti, { value: ei(R.tool_input) })
|
|
2906
2998
|
})] }),
|
|
2907
|
-
R.result ? /* @__PURE__ */
|
|
2999
|
+
R.result ? /* @__PURE__ */ q("div", { children: [/* @__PURE__ */ K(z, {
|
|
2908
3000
|
className: "text-xs",
|
|
2909
3001
|
children: "Result"
|
|
2910
|
-
}), /* @__PURE__ */
|
|
3002
|
+
}), /* @__PURE__ */ K("div", {
|
|
2911
3003
|
className: "mt-1.5",
|
|
2912
|
-
children: /* @__PURE__ */
|
|
3004
|
+
children: /* @__PURE__ */ K(ti, { value: ei(R.result) })
|
|
2913
3005
|
})] }) : null,
|
|
2914
|
-
R.error ? /* @__PURE__ */
|
|
3006
|
+
R.error ? /* @__PURE__ */ q("div", { children: [/* @__PURE__ */ K(z, {
|
|
2915
3007
|
className: "text-xs text-destructive",
|
|
2916
3008
|
children: "Error"
|
|
2917
|
-
}), /* @__PURE__ */
|
|
3009
|
+
}), /* @__PURE__ */ K("div", {
|
|
2918
3010
|
className: "mt-1.5",
|
|
2919
|
-
children: /* @__PURE__ */
|
|
3011
|
+
children: /* @__PURE__ */ K(ti, { value: R.error })
|
|
2920
3012
|
})] }) : null,
|
|
2921
|
-
R.rejection_reason ? /* @__PURE__ */
|
|
3013
|
+
R.rejection_reason ? /* @__PURE__ */ q("div", { children: [/* @__PURE__ */ K(z, {
|
|
2922
3014
|
className: "text-xs",
|
|
2923
3015
|
children: "Rejection reason"
|
|
2924
|
-
}), /* @__PURE__ */
|
|
3016
|
+
}), /* @__PURE__ */ K("div", {
|
|
2925
3017
|
className: "mt-1.5 text-sm",
|
|
2926
3018
|
children: R.rejection_reason
|
|
2927
3019
|
})] }) : null,
|
|
2928
|
-
R.status === "pending" ? /* @__PURE__ */
|
|
3020
|
+
R.status === "pending" ? /* @__PURE__ */ q("div", {
|
|
2929
3021
|
className: "pt-2 flex gap-2",
|
|
2930
|
-
children: [/* @__PURE__ */
|
|
3022
|
+
children: [/* @__PURE__ */ q(v, {
|
|
2931
3023
|
size: "sm",
|
|
2932
3024
|
onClick: () => void ae(R.id),
|
|
2933
3025
|
disabled: T === R.id,
|
|
2934
|
-
children: [/* @__PURE__ */
|
|
2935
|
-
}), /* @__PURE__ */
|
|
3026
|
+
children: [/* @__PURE__ */ K(Be, { className: "h-3.5 w-3.5 mr-1" }), "Approve & Execute"]
|
|
3027
|
+
}), /* @__PURE__ */ q(v, {
|
|
2936
3028
|
size: "sm",
|
|
2937
3029
|
variant: "destructive",
|
|
2938
3030
|
onClick: () => {
|
|
2939
3031
|
g(R.id), w("");
|
|
2940
3032
|
},
|
|
2941
3033
|
disabled: T === R.id,
|
|
2942
|
-
children: [/* @__PURE__ */
|
|
3034
|
+
children: [/* @__PURE__ */ K(U, { className: "h-3.5 w-3.5 mr-1" }), "Reject"]
|
|
2943
3035
|
})]
|
|
2944
3036
|
}) : null
|
|
2945
3037
|
]
|
|
2946
3038
|
}) : null]
|
|
2947
3039
|
})
|
|
2948
3040
|
}),
|
|
2949
|
-
/* @__PURE__ */
|
|
3041
|
+
/* @__PURE__ */ K(ge, {
|
|
2950
3042
|
open: !!h,
|
|
2951
3043
|
onOpenChange: (e) => {
|
|
2952
3044
|
e || (g(null), w(""));
|
|
2953
3045
|
},
|
|
2954
|
-
children: /* @__PURE__ */
|
|
3046
|
+
children: /* @__PURE__ */ q(_e, {
|
|
2955
3047
|
side: "bottom",
|
|
2956
3048
|
className: "max-h-[40vh]",
|
|
2957
|
-
children: [/* @__PURE__ */
|
|
3049
|
+
children: [/* @__PURE__ */ q(ye, { children: [/* @__PURE__ */ K(be, { children: "Reject this action?" }), /* @__PURE__ */ K(ve, { children: "The reason is shown back to the AI so it can adjust its next response." })] }), /* @__PURE__ */ q("div", {
|
|
2958
3050
|
className: "px-4 mt-3 space-y-3",
|
|
2959
|
-
children: [/* @__PURE__ */
|
|
3051
|
+
children: [/* @__PURE__ */ K(ke, {
|
|
2960
3052
|
value: _,
|
|
2961
3053
|
onChange: (e) => w(e.target.value),
|
|
2962
3054
|
placeholder: "Optional reason (e.g. 'Wrong record id — please confirm with the user first.')",
|
|
2963
3055
|
rows: 4,
|
|
2964
3056
|
"data-testid": "ai-inbox-reject-reason"
|
|
2965
|
-
}), /* @__PURE__ */
|
|
3057
|
+
}), /* @__PURE__ */ q("div", {
|
|
2966
3058
|
className: "flex justify-end gap-2",
|
|
2967
|
-
children: [/* @__PURE__ */
|
|
3059
|
+
children: [/* @__PURE__ */ K(v, {
|
|
2968
3060
|
variant: "outline",
|
|
2969
3061
|
size: "sm",
|
|
2970
3062
|
onClick: () => {
|
|
2971
3063
|
g(null), w("");
|
|
2972
3064
|
},
|
|
2973
3065
|
children: "Cancel"
|
|
2974
|
-
}), /* @__PURE__ */
|
|
3066
|
+
}), /* @__PURE__ */ q(v, {
|
|
2975
3067
|
variant: "destructive",
|
|
2976
3068
|
size: "sm",
|
|
2977
|
-
onClick: () => h && void
|
|
3069
|
+
onClick: () => h && void oe(h, _),
|
|
2978
3070
|
disabled: !h || T === h,
|
|
2979
3071
|
"data-testid": "ai-inbox-reject-confirm",
|
|
2980
|
-
children: [/* @__PURE__ */
|
|
3072
|
+
children: [/* @__PURE__ */ K(U, { className: "h-3.5 w-3.5 mr-1" }), "Reject"]
|
|
2981
3073
|
})]
|
|
2982
3074
|
})]
|
|
2983
3075
|
})]
|
|
@@ -2987,14 +3079,14 @@ function Qr({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
|
|
|
2987
3079
|
}
|
|
2988
3080
|
//#endregion
|
|
2989
3081
|
//#region src/useHitlInChat.ts
|
|
2990
|
-
function
|
|
3082
|
+
function ii(e) {
|
|
2991
3083
|
return !e || e.length === 0 ? "/api/v1/ai" : e.endsWith("/") ? e.slice(0, -1) : e;
|
|
2992
3084
|
}
|
|
2993
|
-
function
|
|
3085
|
+
function ai(e, t) {
|
|
2994
3086
|
let n = { ...e ?? {} };
|
|
2995
3087
|
return t && (n["Content-Type"] = "application/json"), n;
|
|
2996
3088
|
}
|
|
2997
|
-
async function
|
|
3089
|
+
async function oi(e) {
|
|
2998
3090
|
let t = await e.text();
|
|
2999
3091
|
if (!t) return null;
|
|
3000
3092
|
try {
|
|
@@ -3003,8 +3095,8 @@ async function ti(e) {
|
|
|
3003
3095
|
return { raw: t };
|
|
3004
3096
|
}
|
|
3005
3097
|
}
|
|
3006
|
-
function
|
|
3007
|
-
let { messages: n, apiBase: r, headers: i, onDecided: a, continueConversation: o } = t, s =
|
|
3098
|
+
function si(t) {
|
|
3099
|
+
let { messages: n, apiBase: r, headers: i, onDecided: a, continueConversation: o } = t, s = ii(r), c = e.useMemo(() => {
|
|
3008
3100
|
let e = /* @__PURE__ */ new Map();
|
|
3009
3101
|
for (let t of n) {
|
|
3010
3102
|
let n = t.toolInvocations ?? [];
|
|
@@ -3047,9 +3139,9 @@ function ni(t) {
|
|
|
3047
3139
|
let r = `${s}/pending-actions/${encodeURIComponent(l)}/${t ? "approve" : "reject"}`, c = t ? "{}" : JSON.stringify({ reason: n ?? "" }), d = await fetch(r, {
|
|
3048
3140
|
method: "POST",
|
|
3049
3141
|
credentials: "include",
|
|
3050
|
-
headers:
|
|
3142
|
+
headers: ai(i, !0),
|
|
3051
3143
|
body: c
|
|
3052
|
-
}), f = await
|
|
3144
|
+
}), f = await oi(d) ?? {};
|
|
3053
3145
|
if (!d.ok) {
|
|
3054
3146
|
let t = typeof f.error == "string" ? f.error : `Approval failed: HTTP ${d.status}`;
|
|
3055
3147
|
m(e, {
|
|
@@ -3076,7 +3168,7 @@ function ni(t) {
|
|
|
3076
3168
|
state: "success",
|
|
3077
3169
|
message: `Status: ${p}`
|
|
3078
3170
|
}), h = !0), a?.(e, f), h && o) {
|
|
3079
|
-
let r =
|
|
3171
|
+
let r = ci({
|
|
3080
3172
|
approved: t,
|
|
3081
3173
|
status: p,
|
|
3082
3174
|
toolName: u,
|
|
@@ -3111,24 +3203,24 @@ function ni(t) {
|
|
|
3111
3203
|
isDeciding: f
|
|
3112
3204
|
};
|
|
3113
3205
|
}
|
|
3114
|
-
function
|
|
3206
|
+
function ci(e) {
|
|
3115
3207
|
let { approved: t, status: n, toolName: r, pendingActionId: i, outcome: a, reason: o } = e, s = `[HITL ${i}]`;
|
|
3116
3208
|
if (t && n === "executed") {
|
|
3117
3209
|
let e = a.result;
|
|
3118
|
-
return `${s} The operator approved the \`${r}\` call. It executed successfully with result: ${e == null ? "(no payload)" : typeof e == "string" ? e :
|
|
3210
|
+
return `${s} The operator approved the \`${r}\` call. It executed successfully with result: ${e == null ? "(no payload)" : typeof e == "string" ? e : li(JSON.stringify(e), 800)}. Acknowledge the outcome concisely and continue the user's task.`;
|
|
3119
3211
|
}
|
|
3120
3212
|
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.`;
|
|
3121
3213
|
if (n === "failed") {
|
|
3122
3214
|
let e = a.error;
|
|
3123
|
-
return `${s} The \`${r}\` call was approved but execution failed: ${typeof e == "string" ? e :
|
|
3215
|
+
return `${s} The \`${r}\` call was approved but execution failed: ${typeof e == "string" ? e : li(JSON.stringify(e ?? {}), 400)}. Apologize concisely and offer alternatives.`;
|
|
3124
3216
|
}
|
|
3125
3217
|
}
|
|
3126
|
-
function
|
|
3218
|
+
function li(e, t) {
|
|
3127
3219
|
return e.length <= t ? e : `${e.slice(0, t - 1)}…`;
|
|
3128
3220
|
}
|
|
3129
3221
|
//#endregion
|
|
3130
3222
|
//#region src/index.tsx
|
|
3131
|
-
var
|
|
3223
|
+
var ui = 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) => {
|
|
3132
3224
|
let [m, h] = e.useState(""), g = e.useRef(null), _ = e.useRef(null);
|
|
3133
3225
|
e.useEffect(() => {
|
|
3134
3226
|
if (g.current) {
|
|
@@ -3141,20 +3233,20 @@ var ai = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
3141
3233
|
}, b = (e) => {
|
|
3142
3234
|
e.key === "Enter" && !e.shiftKey && (e.preventDefault(), y());
|
|
3143
3235
|
};
|
|
3144
|
-
return /* @__PURE__ */
|
|
3236
|
+
return /* @__PURE__ */ q("div", {
|
|
3145
3237
|
ref: p,
|
|
3146
|
-
className:
|
|
3238
|
+
className: H("flex flex-col border rounded-lg bg-background overflow-hidden", t),
|
|
3147
3239
|
style: { maxHeight: d },
|
|
3148
3240
|
...f,
|
|
3149
|
-
children: [/* @__PURE__ */
|
|
3241
|
+
children: [/* @__PURE__ */ K(ce, {
|
|
3150
3242
|
ref: g,
|
|
3151
3243
|
className: "flex-1 p-4",
|
|
3152
|
-
children: /* @__PURE__ */
|
|
3244
|
+
children: /* @__PURE__ */ K("div", {
|
|
3153
3245
|
className: "space-y-4",
|
|
3154
|
-
children: n.length === 0 ? /* @__PURE__ */
|
|
3246
|
+
children: n.length === 0 ? /* @__PURE__ */ K("div", {
|
|
3155
3247
|
className: "flex items-center justify-center h-32 text-muted-foreground text-sm",
|
|
3156
3248
|
children: "No messages yet. Start a conversation!"
|
|
3157
|
-
}) : n.map((e) => /* @__PURE__ */
|
|
3249
|
+
}) : n.map((e) => /* @__PURE__ */ K(di, {
|
|
3158
3250
|
message: e,
|
|
3159
3251
|
showTimestamp: o,
|
|
3160
3252
|
userAvatarUrl: s,
|
|
@@ -3163,11 +3255,11 @@ var ai = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
3163
3255
|
assistantAvatarFallback: u
|
|
3164
3256
|
}, e.id))
|
|
3165
3257
|
})
|
|
3166
|
-
}), /* @__PURE__ */
|
|
3258
|
+
}), /* @__PURE__ */ K("div", {
|
|
3167
3259
|
className: "border-t p-4",
|
|
3168
|
-
children: /* @__PURE__ */
|
|
3260
|
+
children: /* @__PURE__ */ q("div", {
|
|
3169
3261
|
className: "flex gap-2",
|
|
3170
|
-
children: [/* @__PURE__ */
|
|
3262
|
+
children: [/* @__PURE__ */ K(se, {
|
|
3171
3263
|
ref: _,
|
|
3172
3264
|
value: m,
|
|
3173
3265
|
onChange: (e) => h(e.target.value),
|
|
@@ -3175,71 +3267,71 @@ var ai = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
3175
3267
|
placeholder: r,
|
|
3176
3268
|
disabled: a,
|
|
3177
3269
|
className: "flex-1"
|
|
3178
|
-
}), /* @__PURE__ */
|
|
3270
|
+
}), /* @__PURE__ */ K(v, {
|
|
3179
3271
|
onClick: y,
|
|
3180
3272
|
disabled: a || !m.trim(),
|
|
3181
3273
|
size: "icon",
|
|
3182
|
-
children: /* @__PURE__ */
|
|
3274
|
+
children: /* @__PURE__ */ K(lt, { className: "h-4 w-4" })
|
|
3183
3275
|
})]
|
|
3184
3276
|
})
|
|
3185
3277
|
})]
|
|
3186
3278
|
});
|
|
3187
3279
|
});
|
|
3188
|
-
|
|
3189
|
-
var
|
|
3280
|
+
ui.displayName = "Chatbot";
|
|
3281
|
+
var di = ({ message: e, showTimestamp: t, userAvatarUrl: n, userAvatarFallback: r, assistantAvatarUrl: i, assistantAvatarFallback: a }) => {
|
|
3190
3282
|
let o = e.role === "user";
|
|
3191
|
-
if (e.role === "system") return /* @__PURE__ */
|
|
3283
|
+
if (e.role === "system") return /* @__PURE__ */ K("div", {
|
|
3192
3284
|
className: "flex justify-center",
|
|
3193
|
-
children: /* @__PURE__ */
|
|
3285
|
+
children: /* @__PURE__ */ K("div", {
|
|
3194
3286
|
className: "text-xs text-muted-foreground bg-muted px-3 py-1 rounded-full",
|
|
3195
3287
|
children: e.content
|
|
3196
3288
|
})
|
|
3197
3289
|
});
|
|
3198
3290
|
let s = o ? e.avatar || n : e.avatar || i, c = o ? e.avatarFallback || r : e.avatarFallback || a;
|
|
3199
|
-
return /* @__PURE__ */
|
|
3200
|
-
className:
|
|
3201
|
-
children: [/* @__PURE__ */
|
|
3291
|
+
return /* @__PURE__ */ q("div", {
|
|
3292
|
+
className: H("flex gap-3", o ? "flex-row-reverse" : "flex-row"),
|
|
3293
|
+
children: [/* @__PURE__ */ q(m, {
|
|
3202
3294
|
className: "h-8 w-8",
|
|
3203
|
-
children: [/* @__PURE__ */
|
|
3295
|
+
children: [/* @__PURE__ */ K(g, { src: s }), /* @__PURE__ */ K(h, {
|
|
3204
3296
|
className: "text-xs",
|
|
3205
3297
|
children: c
|
|
3206
3298
|
})]
|
|
3207
|
-
}), /* @__PURE__ */
|
|
3208
|
-
className:
|
|
3209
|
-
children: [/* @__PURE__ */
|
|
3210
|
-
className:
|
|
3211
|
-
children: /* @__PURE__ */
|
|
3299
|
+
}), /* @__PURE__ */ q("div", {
|
|
3300
|
+
className: H("flex flex-col gap-1", o ? "items-end" : "items-start"),
|
|
3301
|
+
children: [/* @__PURE__ */ K("div", {
|
|
3302
|
+
className: H("rounded-lg px-4 py-2 max-w-[70%] break-words", o ? "bg-primary text-primary-foreground" : "bg-muted"),
|
|
3303
|
+
children: /* @__PURE__ */ K("p", {
|
|
3212
3304
|
className: "text-sm whitespace-pre-wrap",
|
|
3213
3305
|
children: e.content
|
|
3214
3306
|
})
|
|
3215
|
-
}), t && e.timestamp && /* @__PURE__ */
|
|
3307
|
+
}), t && e.timestamp && /* @__PURE__ */ K("span", {
|
|
3216
3308
|
className: "text-xs text-muted-foreground",
|
|
3217
3309
|
children: e.timestamp
|
|
3218
3310
|
})]
|
|
3219
3311
|
})]
|
|
3220
3312
|
});
|
|
3221
|
-
},
|
|
3313
|
+
}, fi = e.forwardRef(({ className: e, avatarSrc: t, avatarFallback: n = "AI", ...r }, i) => /* @__PURE__ */ q("div", {
|
|
3222
3314
|
ref: i,
|
|
3223
|
-
className:
|
|
3315
|
+
className: H("flex gap-3", e),
|
|
3224
3316
|
...r,
|
|
3225
|
-
children: [/* @__PURE__ */
|
|
3317
|
+
children: [/* @__PURE__ */ q(m, {
|
|
3226
3318
|
className: "h-8 w-8",
|
|
3227
|
-
children: [/* @__PURE__ */
|
|
3319
|
+
children: [/* @__PURE__ */ K(g, { src: t }), /* @__PURE__ */ K(h, {
|
|
3228
3320
|
className: "text-xs",
|
|
3229
3321
|
children: n
|
|
3230
3322
|
})]
|
|
3231
|
-
}), /* @__PURE__ */
|
|
3323
|
+
}), /* @__PURE__ */ K("div", {
|
|
3232
3324
|
className: "flex items-center bg-muted rounded-lg px-4 py-2",
|
|
3233
|
-
children: /* @__PURE__ */
|
|
3325
|
+
children: /* @__PURE__ */ q("div", {
|
|
3234
3326
|
className: "flex gap-1",
|
|
3235
3327
|
children: [
|
|
3236
|
-
/* @__PURE__ */
|
|
3237
|
-
/* @__PURE__ */
|
|
3238
|
-
/* @__PURE__ */
|
|
3328
|
+
/* @__PURE__ */ K("span", { className: "w-2 h-2 bg-muted-foreground rounded-full animate-bounce [animation-delay:-0.3s]" }),
|
|
3329
|
+
/* @__PURE__ */ K("span", { className: "w-2 h-2 bg-muted-foreground rounded-full animate-bounce [animation-delay:-0.15s]" }),
|
|
3330
|
+
/* @__PURE__ */ K("span", { className: "w-2 h-2 bg-muted-foreground rounded-full animate-bounce" })
|
|
3239
3331
|
]
|
|
3240
3332
|
})
|
|
3241
3333
|
})]
|
|
3242
3334
|
}));
|
|
3243
|
-
|
|
3335
|
+
fi.displayName = "TypingIndicator";
|
|
3244
3336
|
//#endregion
|
|
3245
|
-
export {
|
|
3337
|
+
export { Kr as AIElements, ri as AiPendingActionsInbox, ui as Chatbot, $ as ChatbotEnhanced, Ur as FloatingChatbot, Gt as FloatingChatbotPanel, Vt as FloatingChatbotProvider, Wt as FloatingChatbotTrigger, fi as TypingIndicator, qt as humanizeToolName, Yt as summarizeChatError, Ft as uiMessageToChatMessage, It as uiMessagesToChatMessages, Jt as unwrapToolResult, zt as useAgents, Ht as useFloatingChatbot, si as useHitlInChat, Y as useObjectChat, Xr as usePendingActions };
|