@ash-cloud/ash-ai 0.1.19 → 0.1.20
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/dist/index.cjs +276 -35
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +529 -420
- package/dist/index.d.ts +529 -420
- package/dist/index.js +276 -35
- package/dist/index.js.map +1 -1
- package/dist/playground/components/NormalizedMessageList.d.ts.map +1 -1
- package/dist/playground/contexts/ThemeContext.d.ts +12 -8
- package/dist/playground/contexts/ThemeContext.d.ts.map +1 -1
- package/dist/playground/index.d.ts +1 -1
- package/dist/playground/index.d.ts.map +1 -1
- package/dist/playground.js +1004 -969
- package/package.json +2 -2
package/dist/playground.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var ct = Object.defineProperty;
|
|
2
2
|
var dt = (e, n, r) => n in e ? ct(e, n, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[n] = r;
|
|
3
3
|
var ve = (e, n, r) => dt(e, typeof n != "symbol" ? n + "" : n, r);
|
|
4
|
-
import { createContext as
|
|
4
|
+
import { createContext as ke, lazy as ut, useContext as Ne, useRef as z, useState as k, useCallback as $, useEffect as te, useLayoutEffect as ht, useMemo as mt, Suspense as ft } from "react";
|
|
5
5
|
import { jsx as t, jsxs as o, Fragment as we } from "react/jsx-runtime";
|
|
6
6
|
function De(e) {
|
|
7
7
|
if (e.startsWith("mcp__")) {
|
|
@@ -228,7 +228,7 @@ function kt(e, n, r) {
|
|
|
228
228
|
} else (a.action === "mcp_tool" || a.action === "generic_tool") && (a.result = wt(n));
|
|
229
229
|
return s.actionType = a, s;
|
|
230
230
|
}
|
|
231
|
-
function
|
|
231
|
+
function An(e) {
|
|
232
232
|
switch (e.action) {
|
|
233
233
|
case "command_run":
|
|
234
234
|
return "terminal";
|
|
@@ -258,7 +258,7 @@ function En(e) {
|
|
|
258
258
|
return "tool";
|
|
259
259
|
}
|
|
260
260
|
}
|
|
261
|
-
function
|
|
261
|
+
function Rn(e) {
|
|
262
262
|
switch (e.action) {
|
|
263
263
|
case "command_run":
|
|
264
264
|
return "Command";
|
|
@@ -303,15 +303,15 @@ function Nt(e) {
|
|
|
303
303
|
return e;
|
|
304
304
|
}
|
|
305
305
|
}
|
|
306
|
-
function
|
|
306
|
+
function jn(e, n) {
|
|
307
307
|
return e.length <= n ? e : e.substring(0, n - 3) + "...";
|
|
308
308
|
}
|
|
309
|
-
function
|
|
309
|
+
function h(...e) {
|
|
310
310
|
return e.filter(Boolean).join(" ");
|
|
311
311
|
}
|
|
312
|
-
var Be =
|
|
312
|
+
var Be = ke(null);
|
|
313
313
|
function Oe() {
|
|
314
|
-
const e =
|
|
314
|
+
const e = Ne(Be);
|
|
315
315
|
if (!e)
|
|
316
316
|
throw new Error("useConversation must be used within a Conversation");
|
|
317
317
|
return e;
|
|
@@ -326,41 +326,41 @@ function Ct({
|
|
|
326
326
|
isLoadingMore: u = !1,
|
|
327
327
|
loadMoreThreshold: d = 100
|
|
328
328
|
}) {
|
|
329
|
-
const l =
|
|
329
|
+
const l = z(null), [N, f] = k(!1), [w, I] = k(r), A = z(0), K = z(!1), J = $((U = "smooth") => {
|
|
330
330
|
l.current && l.current.scrollTo({
|
|
331
331
|
top: l.current.scrollHeight,
|
|
332
|
-
behavior:
|
|
332
|
+
behavior: U
|
|
333
333
|
});
|
|
334
|
-
}, []),
|
|
334
|
+
}, []), y = $(() => {
|
|
335
335
|
if (!l.current) return;
|
|
336
|
-
const { scrollTop:
|
|
337
|
-
|
|
338
|
-
}, [s,
|
|
339
|
-
|
|
340
|
-
u && !
|
|
336
|
+
const { scrollTop: U, scrollHeight: j, clientHeight: X } = l.current, he = j - U - X < s;
|
|
337
|
+
f(!he), he && !w && I(!0), U < d && i && !u && a && a();
|
|
338
|
+
}, [s, w, d, i, u, a]);
|
|
339
|
+
te(() => {
|
|
340
|
+
u && !K.current && l.current && (A.current = l.current.scrollHeight), K.current = u;
|
|
341
341
|
}, [u]), ht(() => {
|
|
342
|
-
if (!u &&
|
|
343
|
-
const
|
|
344
|
-
|
|
342
|
+
if (!u && A.current > 0 && l.current) {
|
|
343
|
+
const j = l.current.scrollHeight - A.current;
|
|
344
|
+
j > 0 && (l.current.scrollTop += j), A.current = 0;
|
|
345
345
|
}
|
|
346
|
-
}, [u]),
|
|
347
|
-
|
|
346
|
+
}, [u]), te(() => {
|
|
347
|
+
w && !N && J("instant");
|
|
348
348
|
});
|
|
349
|
-
const
|
|
349
|
+
const D = {
|
|
350
350
|
containerRef: l,
|
|
351
|
-
scrollToBottom:
|
|
352
|
-
isScrolledUp:
|
|
353
|
-
autoScroll:
|
|
354
|
-
setAutoScroll:
|
|
351
|
+
scrollToBottom: J,
|
|
352
|
+
isScrolledUp: N,
|
|
353
|
+
autoScroll: w,
|
|
354
|
+
setAutoScroll: I,
|
|
355
355
|
hasMore: i,
|
|
356
356
|
isLoadingMore: u
|
|
357
357
|
};
|
|
358
|
-
return /* @__PURE__ */ t(Be.Provider, { value:
|
|
358
|
+
return /* @__PURE__ */ t(Be.Provider, { value: D, children: /* @__PURE__ */ t(
|
|
359
359
|
"div",
|
|
360
360
|
{
|
|
361
361
|
ref: l,
|
|
362
|
-
onScroll:
|
|
363
|
-
className:
|
|
362
|
+
onScroll: y,
|
|
363
|
+
className: h(
|
|
364
364
|
"ash-conversation flex flex-col overflow-y-auto",
|
|
365
365
|
"ash-scrollbar",
|
|
366
366
|
n
|
|
@@ -378,7 +378,7 @@ function Tt({
|
|
|
378
378
|
return /* @__PURE__ */ t(
|
|
379
379
|
"div",
|
|
380
380
|
{
|
|
381
|
-
className:
|
|
381
|
+
className: h(
|
|
382
382
|
"ash-conversation-content flex flex-col",
|
|
383
383
|
"gap-[var(--ash-message-list-gap,0.25rem)]",
|
|
384
384
|
"p-[var(--ash-spacing-md,0.75rem)]",
|
|
@@ -388,14 +388,14 @@ function Tt({
|
|
|
388
388
|
}
|
|
389
389
|
);
|
|
390
390
|
}
|
|
391
|
-
function
|
|
391
|
+
function zn({
|
|
392
392
|
children: e,
|
|
393
393
|
className: n
|
|
394
394
|
}) {
|
|
395
395
|
return /* @__PURE__ */ t(
|
|
396
396
|
"div",
|
|
397
397
|
{
|
|
398
|
-
className:
|
|
398
|
+
className: h(
|
|
399
399
|
"ash-conversation-empty flex flex-col items-center justify-center",
|
|
400
400
|
"flex-1 min-h-[200px] text-center",
|
|
401
401
|
"text-[var(--ash-text-muted,rgba(255,255,255,0.5))]",
|
|
@@ -405,7 +405,7 @@ function Rn({
|
|
|
405
405
|
}
|
|
406
406
|
);
|
|
407
407
|
}
|
|
408
|
-
function
|
|
408
|
+
function Dn({
|
|
409
409
|
className: e,
|
|
410
410
|
label: n = "Scroll to bottom"
|
|
411
411
|
}) {
|
|
@@ -414,7 +414,7 @@ function jn({
|
|
|
414
414
|
"button",
|
|
415
415
|
{
|
|
416
416
|
onClick: () => s(),
|
|
417
|
-
className:
|
|
417
|
+
className: h(
|
|
418
418
|
"ash-conversation-scroll-btn",
|
|
419
419
|
"fixed bottom-20 left-1/2 -translate-x-1/2",
|
|
420
420
|
"px-4 py-2 rounded-full",
|
|
@@ -457,7 +457,7 @@ function _t({
|
|
|
457
457
|
return !n && !r ? null : /* @__PURE__ */ t(
|
|
458
458
|
"div",
|
|
459
459
|
{
|
|
460
|
-
className:
|
|
460
|
+
className: h(
|
|
461
461
|
"ash-conversation-load-more flex items-center justify-center py-3",
|
|
462
462
|
e
|
|
463
463
|
),
|
|
@@ -493,23 +493,23 @@ function _t({
|
|
|
493
493
|
}
|
|
494
494
|
);
|
|
495
495
|
}
|
|
496
|
-
var
|
|
496
|
+
var It = ut(() => import("./index-DJwpy-R5.js"));
|
|
497
497
|
function Ve({ children: e, fallback: n, components: r, className: s }) {
|
|
498
|
-
const [a, i] =
|
|
499
|
-
|
|
498
|
+
const [a, i] = k(!1);
|
|
499
|
+
te(() => {
|
|
500
500
|
i(!0);
|
|
501
501
|
}, []);
|
|
502
502
|
const u = mt(() => {
|
|
503
503
|
if (r)
|
|
504
504
|
return r;
|
|
505
505
|
}, [r]);
|
|
506
|
-
return a ? /* @__PURE__ */ t(ft, { fallback: /* @__PURE__ */ t("span", { className: s, children: n ?? e }), children: /* @__PURE__ */ t(
|
|
506
|
+
return a ? /* @__PURE__ */ t(ft, { fallback: /* @__PURE__ */ t("span", { className: s, children: n ?? e }), children: /* @__PURE__ */ t(It, { components: u, children: e }) }) : /* @__PURE__ */ t("span", { className: s, children: n ?? e });
|
|
507
507
|
}
|
|
508
|
-
function
|
|
508
|
+
function Mt({ name: e, color: n, url: r }) {
|
|
509
509
|
return /* @__PURE__ */ o(
|
|
510
510
|
"span",
|
|
511
511
|
{
|
|
512
|
-
className:
|
|
512
|
+
className: h(
|
|
513
513
|
"ash-mention",
|
|
514
514
|
"inline-flex items-center",
|
|
515
515
|
"px-1.5 py-0.5 rounded",
|
|
@@ -535,13 +535,13 @@ function St({ name: e, color: n, url: r }) {
|
|
|
535
535
|
}
|
|
536
536
|
);
|
|
537
537
|
}
|
|
538
|
-
function
|
|
538
|
+
function St({
|
|
539
539
|
content: e,
|
|
540
540
|
components: n,
|
|
541
541
|
className: r
|
|
542
542
|
}) {
|
|
543
|
-
const s = (n == null ? void 0 : n.mention) ||
|
|
544
|
-
return /* @__PURE__ */ t("span", { className:
|
|
543
|
+
const s = (n == null ? void 0 : n.mention) || Mt;
|
|
544
|
+
return /* @__PURE__ */ t("span", { className: h("ash-rich-content", r), children: e.map((a, i) => a.type === "text" ? /* @__PURE__ */ t(Ve, { components: n, children: a.content }, i) : a.type === "mention" ? /* @__PURE__ */ t(
|
|
545
545
|
s,
|
|
546
546
|
{
|
|
547
547
|
name: a.name,
|
|
@@ -552,14 +552,14 @@ function It({
|
|
|
552
552
|
i
|
|
553
553
|
) : null) });
|
|
554
554
|
}
|
|
555
|
-
var
|
|
556
|
-
function
|
|
557
|
-
const e =
|
|
555
|
+
var qe = ke(null);
|
|
556
|
+
function Pe() {
|
|
557
|
+
const e = Ne(qe);
|
|
558
558
|
if (!e)
|
|
559
559
|
throw new Error("useMessage must be used within a Message");
|
|
560
560
|
return e;
|
|
561
561
|
}
|
|
562
|
-
function
|
|
562
|
+
function Ce({
|
|
563
563
|
from: e,
|
|
564
564
|
children: n,
|
|
565
565
|
className: r,
|
|
@@ -576,10 +576,10 @@ function Ne({
|
|
|
576
576
|
assistant: "assistant",
|
|
577
577
|
system: "system"
|
|
578
578
|
};
|
|
579
|
-
return /* @__PURE__ */ t(
|
|
579
|
+
return /* @__PURE__ */ t(qe.Provider, { value: u, children: /* @__PURE__ */ t(
|
|
580
580
|
"div",
|
|
581
581
|
{
|
|
582
|
-
className:
|
|
582
|
+
className: h(
|
|
583
583
|
"ash-message",
|
|
584
584
|
"flex gap-[var(--ash-message-gap,0.5rem)]",
|
|
585
585
|
e === "user" && "flex-row-reverse",
|
|
@@ -591,8 +591,8 @@ function Ne({
|
|
|
591
591
|
}
|
|
592
592
|
) });
|
|
593
593
|
}
|
|
594
|
-
function
|
|
595
|
-
const { from: s } =
|
|
594
|
+
function Wn({ src: e, fallback: n, className: r }) {
|
|
595
|
+
const { from: s } = Pe(), i = n || (s === "user" ? "U" : s === "assistant" ? "A" : "S"), u = {
|
|
596
596
|
user: "var(--ash-avatar-user-bg,rgba(255,255,255,0.1))",
|
|
597
597
|
assistant: "var(--ash-avatar-assistant-bg,#10a37f)",
|
|
598
598
|
system: "var(--ash-avatar-user-bg,rgba(255,255,255,0.1))"
|
|
@@ -600,7 +600,7 @@ function zn({ src: e, fallback: n, className: r }) {
|
|
|
600
600
|
return /* @__PURE__ */ t(
|
|
601
601
|
"div",
|
|
602
602
|
{
|
|
603
|
-
className:
|
|
603
|
+
className: h(
|
|
604
604
|
"ash-message-avatar flex-shrink-0",
|
|
605
605
|
"w-[var(--ash-avatar-size,1.25rem)] h-[var(--ash-avatar-size,1.25rem)]",
|
|
606
606
|
"rounded-full flex items-center justify-center",
|
|
@@ -620,19 +620,19 @@ function zn({ src: e, fallback: n, className: r }) {
|
|
|
620
620
|
}
|
|
621
621
|
);
|
|
622
622
|
}
|
|
623
|
-
function
|
|
624
|
-
const { from: r } =
|
|
625
|
-
user:
|
|
623
|
+
function Bn({ children: e, className: n }) {
|
|
624
|
+
const { from: r } = Pe(), s = {
|
|
625
|
+
user: h(
|
|
626
626
|
"bg-[var(--ash-user-bg,#5B6EF5)]",
|
|
627
627
|
"text-[var(--ash-user-text,#ffffff)]",
|
|
628
628
|
"border-[var(--ash-user-border,transparent)]"
|
|
629
629
|
),
|
|
630
|
-
assistant:
|
|
630
|
+
assistant: h(
|
|
631
631
|
"bg-[var(--ash-assistant-bg,#1a1a1a)]",
|
|
632
632
|
"text-[var(--ash-assistant-text,rgba(255,255,255,0.9))]",
|
|
633
633
|
"border-[var(--ash-assistant-border,rgba(255,255,255,0.08))]"
|
|
634
634
|
),
|
|
635
|
-
system:
|
|
635
|
+
system: h(
|
|
636
636
|
"bg-[var(--ash-surface-elevated,#111111)]",
|
|
637
637
|
"text-[var(--ash-text-muted,rgba(255,255,255,0.5))]",
|
|
638
638
|
"border-[var(--ash-border,rgba(255,255,255,0.08))]"
|
|
@@ -641,7 +641,7 @@ function Dn({ children: e, className: n }) {
|
|
|
641
641
|
return /* @__PURE__ */ t(
|
|
642
642
|
"div",
|
|
643
643
|
{
|
|
644
|
-
className:
|
|
644
|
+
className: h(
|
|
645
645
|
"ash-message-content",
|
|
646
646
|
"flex-1 min-w-0",
|
|
647
647
|
"rounded-[var(--ash-radius-lg,0.75rem)]",
|
|
@@ -666,19 +666,19 @@ function Me({
|
|
|
666
666
|
return n && n.length > 0 ? /* @__PURE__ */ t(
|
|
667
667
|
"div",
|
|
668
668
|
{
|
|
669
|
-
className:
|
|
669
|
+
className: h(
|
|
670
670
|
"ash-message-response",
|
|
671
671
|
"font-[var(--ash-font-size-base,13px)]",
|
|
672
672
|
"leading-relaxed",
|
|
673
673
|
r && "animate-pulse",
|
|
674
674
|
s
|
|
675
675
|
),
|
|
676
|
-
children: /* @__PURE__ */ t(
|
|
676
|
+
children: /* @__PURE__ */ t(St, { content: n, components: a })
|
|
677
677
|
}
|
|
678
678
|
) : e ? /* @__PURE__ */ t(
|
|
679
679
|
"div",
|
|
680
680
|
{
|
|
681
|
-
className:
|
|
681
|
+
className: h(
|
|
682
682
|
"ash-message-response",
|
|
683
683
|
"font-[var(--ash-font-size-base,13px)]",
|
|
684
684
|
"leading-relaxed",
|
|
@@ -689,11 +689,11 @@ function Me({
|
|
|
689
689
|
}
|
|
690
690
|
) : null;
|
|
691
691
|
}
|
|
692
|
-
function
|
|
692
|
+
function On({ children: e, className: n }) {
|
|
693
693
|
return /* @__PURE__ */ t(
|
|
694
694
|
"div",
|
|
695
695
|
{
|
|
696
|
-
className:
|
|
696
|
+
className: h(
|
|
697
697
|
"ash-message-actions",
|
|
698
698
|
"flex items-center gap-1 mt-2",
|
|
699
699
|
"opacity-0 group-hover:opacity-100 transition-opacity",
|
|
@@ -703,7 +703,7 @@ function Wn({ children: e, className: n }) {
|
|
|
703
703
|
}
|
|
704
704
|
);
|
|
705
705
|
}
|
|
706
|
-
function
|
|
706
|
+
function Vn({
|
|
707
707
|
icon: e,
|
|
708
708
|
label: n,
|
|
709
709
|
onClick: r,
|
|
@@ -713,7 +713,7 @@ function Bn({
|
|
|
713
713
|
"button",
|
|
714
714
|
{
|
|
715
715
|
onClick: r,
|
|
716
|
-
className:
|
|
716
|
+
className: h(
|
|
717
717
|
"ash-message-action",
|
|
718
718
|
"p-1.5 rounded-md",
|
|
719
719
|
"text-[var(--ash-text-muted,rgba(255,255,255,0.5))]",
|
|
@@ -728,7 +728,7 @@ function Bn({
|
|
|
728
728
|
}
|
|
729
729
|
);
|
|
730
730
|
}
|
|
731
|
-
function
|
|
731
|
+
function qn({ timestamp: e, className: n }) {
|
|
732
732
|
const s = (typeof e == "string" ? new Date(e) : e).toLocaleTimeString(void 0, {
|
|
733
733
|
hour: "numeric",
|
|
734
734
|
minute: "2-digit"
|
|
@@ -736,7 +736,7 @@ function On({ timestamp: e, className: n }) {
|
|
|
736
736
|
return /* @__PURE__ */ t(
|
|
737
737
|
"span",
|
|
738
738
|
{
|
|
739
|
-
className:
|
|
739
|
+
className: h(
|
|
740
740
|
"ash-message-timestamp",
|
|
741
741
|
"text-[var(--ash-font-size-xs,10px)]",
|
|
742
742
|
"text-[var(--ash-text-faint,rgba(255,255,255,0.3))]",
|
|
@@ -760,7 +760,7 @@ function Lt({ status: e, size: n = "sm", className: r }) {
|
|
|
760
760
|
return /* @__PURE__ */ t(
|
|
761
761
|
"div",
|
|
762
762
|
{
|
|
763
|
-
className:
|
|
763
|
+
className: h(
|
|
764
764
|
"rounded-full flex-shrink-0",
|
|
765
765
|
s[n],
|
|
766
766
|
a[e],
|
|
@@ -769,7 +769,7 @@ function Lt({ status: e, size: n = "sm", className: r }) {
|
|
|
769
769
|
}
|
|
770
770
|
);
|
|
771
771
|
}
|
|
772
|
-
function
|
|
772
|
+
function Pn({ className: e }) {
|
|
773
773
|
return /* @__PURE__ */ o("svg", { className: e, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
|
|
774
774
|
/* @__PURE__ */ t("circle", { cx: "12", cy: "12", r: "5" }),
|
|
775
775
|
/* @__PURE__ */ t("line", { x1: "12", y1: "1", x2: "12", y2: "3" }),
|
|
@@ -785,16 +785,16 @@ function Vn({ className: e }) {
|
|
|
785
785
|
function Hn({ className: e }) {
|
|
786
786
|
return /* @__PURE__ */ t("svg", { className: e, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: /* @__PURE__ */ t("path", { d: "M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z" }) });
|
|
787
787
|
}
|
|
788
|
-
function
|
|
788
|
+
function He({ className: e }) {
|
|
789
789
|
return /* @__PURE__ */ t("svg", { className: e, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: /* @__PURE__ */ t("polyline", { points: "6 9 12 15 18 9" }) });
|
|
790
790
|
}
|
|
791
|
-
function
|
|
791
|
+
function Fe({ className: e }) {
|
|
792
792
|
return /* @__PURE__ */ t("svg", { className: e, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: /* @__PURE__ */ t("polyline", { points: "9 18 15 12 9 6" }) });
|
|
793
793
|
}
|
|
794
794
|
function Fn({ className: e }) {
|
|
795
795
|
return /* @__PURE__ */ t("svg", { className: e, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: /* @__PURE__ */ t("polyline", { points: "15 18 9 12 15 6" }) });
|
|
796
796
|
}
|
|
797
|
-
function
|
|
797
|
+
function Kn({ className: e }) {
|
|
798
798
|
return /* @__PURE__ */ t("svg", { className: e, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: /* @__PURE__ */ t("polyline", { points: "18 15 12 9 6 15" }) });
|
|
799
799
|
}
|
|
800
800
|
function Ke({ className: e }) {
|
|
@@ -855,7 +855,7 @@ function Dt({ className: e }) {
|
|
|
855
855
|
/* @__PURE__ */ t("line", { x1: "15", y1: "16", x2: "17", y2: "18" })
|
|
856
856
|
] });
|
|
857
857
|
}
|
|
858
|
-
function
|
|
858
|
+
function Jn({ className: e }) {
|
|
859
859
|
return /* @__PURE__ */ o("svg", { className: e, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
|
|
860
860
|
/* @__PURE__ */ t("polyline", { points: "16 18 22 12 16 6" }),
|
|
861
861
|
/* @__PURE__ */ t("polyline", { points: "8 6 2 12 8 18" })
|
|
@@ -870,13 +870,13 @@ function Wt({ className: e }) {
|
|
|
870
870
|
function Bt({ className: e }) {
|
|
871
871
|
return /* @__PURE__ */ t("svg", { className: e, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: /* @__PURE__ */ t("polyline", { points: "20 6 9 17 4 12" }) });
|
|
872
872
|
}
|
|
873
|
-
function
|
|
873
|
+
function Un({ className: e }) {
|
|
874
874
|
return /* @__PURE__ */ o("svg", { className: e, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
|
|
875
875
|
/* @__PURE__ */ t("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
|
|
876
876
|
/* @__PURE__ */ t("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
|
|
877
877
|
] });
|
|
878
878
|
}
|
|
879
|
-
function
|
|
879
|
+
function Gn({ className: e }) {
|
|
880
880
|
return /* @__PURE__ */ o("svg", { className: e, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
|
|
881
881
|
/* @__PURE__ */ t("line", { x1: "12", y1: "2", x2: "12", y2: "6" }),
|
|
882
882
|
/* @__PURE__ */ t("line", { x1: "12", y1: "18", x2: "12", y2: "22" }),
|
|
@@ -902,14 +902,14 @@ function Vt({ className: e }) {
|
|
|
902
902
|
/* @__PURE__ */ t("line", { x1: "12", y1: "17", x2: "12.01", y2: "17" })
|
|
903
903
|
] });
|
|
904
904
|
}
|
|
905
|
-
function
|
|
905
|
+
function qt({ className: e }) {
|
|
906
906
|
return /* @__PURE__ */ o("svg", { className: e, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
|
|
907
907
|
/* @__PURE__ */ t("circle", { cx: "12", cy: "12", r: "10" }),
|
|
908
908
|
/* @__PURE__ */ t("line", { x1: "12", y1: "8", x2: "12", y2: "12" }),
|
|
909
909
|
/* @__PURE__ */ t("line", { x1: "12", y1: "16", x2: "12.01", y2: "16" })
|
|
910
910
|
] });
|
|
911
911
|
}
|
|
912
|
-
function
|
|
912
|
+
function Pt({ className: e }) {
|
|
913
913
|
return /* @__PURE__ */ o("svg", { className: e, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
|
|
914
914
|
/* @__PURE__ */ t("rect", { x: "8", y: "6", width: "8", height: "14", rx: "4" }),
|
|
915
915
|
/* @__PURE__ */ t("path", { d: "M3 10h2" }),
|
|
@@ -920,51 +920,51 @@ function Ft({ className: e }) {
|
|
|
920
920
|
/* @__PURE__ */ t("path", { d: "M12 2v4" })
|
|
921
921
|
] });
|
|
922
922
|
}
|
|
923
|
-
function
|
|
923
|
+
function Zn({ className: e }) {
|
|
924
924
|
return /* @__PURE__ */ o("svg", { className: e, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
|
|
925
925
|
/* @__PURE__ */ t("circle", { cx: "12", cy: "12", r: "10" }),
|
|
926
926
|
/* @__PURE__ */ t("path", { d: "M9 12l2 2 4-4" })
|
|
927
927
|
] });
|
|
928
928
|
}
|
|
929
|
-
function
|
|
929
|
+
function Yn({ className: e }) {
|
|
930
930
|
return /* @__PURE__ */ o("svg", { className: e, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
|
|
931
931
|
/* @__PURE__ */ t("circle", { cx: "12", cy: "12", r: "10" }),
|
|
932
932
|
/* @__PURE__ */ t("line", { x1: "15", y1: "9", x2: "9", y2: "15" }),
|
|
933
933
|
/* @__PURE__ */ t("line", { x1: "9", y1: "9", x2: "15", y2: "15" })
|
|
934
934
|
] });
|
|
935
935
|
}
|
|
936
|
-
function
|
|
936
|
+
function Xn({ className: e }) {
|
|
937
937
|
return /* @__PURE__ */ o("svg", { className: e, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
|
|
938
938
|
/* @__PURE__ */ t("line", { x1: "22", y1: "2", x2: "11", y2: "13" }),
|
|
939
939
|
/* @__PURE__ */ t("polygon", { points: "22 2 15 22 11 13 2 9 22 2" })
|
|
940
940
|
] });
|
|
941
941
|
}
|
|
942
|
-
function
|
|
942
|
+
function Qn({ className: e }) {
|
|
943
943
|
return /* @__PURE__ */ t("svg", { className: e, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: /* @__PURE__ */ t("path", { d: "M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48" }) });
|
|
944
944
|
}
|
|
945
|
-
function
|
|
945
|
+
function er({ className: e }) {
|
|
946
946
|
return /* @__PURE__ */ o("svg", { className: e, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
|
|
947
947
|
/* @__PURE__ */ t("circle", { cx: "12", cy: "12", r: "10" }),
|
|
948
948
|
/* @__PURE__ */ t("rect", { x: "9", y: "9", width: "6", height: "6" })
|
|
949
949
|
] });
|
|
950
950
|
}
|
|
951
|
-
function
|
|
951
|
+
function tr({ className: e }) {
|
|
952
952
|
return /* @__PURE__ */ t("svg", { className: e, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: /* @__PURE__ */ t("path", { d: "M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z" }) });
|
|
953
953
|
}
|
|
954
|
-
function
|
|
954
|
+
function nr({ className: e }) {
|
|
955
955
|
return /* @__PURE__ */ o("svg", { className: e, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
|
|
956
956
|
/* @__PURE__ */ t("path", { d: "M12 3l1.5 4.5L18 9l-4.5 1.5L12 15l-1.5-4.5L6 9l4.5-1.5L12 3z" }),
|
|
957
957
|
/* @__PURE__ */ t("path", { d: "M5 19l.5 1.5L7 21l-1.5.5L5 23l-.5-1.5L3 21l1.5-.5L5 19z" }),
|
|
958
958
|
/* @__PURE__ */ t("path", { d: "M19 11l.5 1.5L21 13l-1.5.5L19 15l-.5-1.5L17 13l1.5-.5L19 11z" })
|
|
959
959
|
] });
|
|
960
960
|
}
|
|
961
|
-
function
|
|
961
|
+
function rr({ className: e }) {
|
|
962
962
|
return /* @__PURE__ */ o("svg", { className: e, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
|
|
963
963
|
/* @__PURE__ */ t("path", { d: "M9.5 2A2.5 2.5 0 0 1 12 4.5v15a2.5 2.5 0 0 1-4.96.44 2.5 2.5 0 0 1-2.96-3.08 3 3 0 0 1-.34-5.58 2.5 2.5 0 0 1 1.32-4.24 2.5 2.5 0 0 1 4.44-1.54" }),
|
|
964
964
|
/* @__PURE__ */ t("path", { d: "M14.5 2A2.5 2.5 0 0 0 12 4.5v15a2.5 2.5 0 0 0 4.96.44 2.5 2.5 0 0 0 2.96-3.08 3 3 0 0 0 .34-5.58 2.5 2.5 0 0 0-1.32-4.24 2.5 2.5 0 0 0-4.44-1.54" })
|
|
965
965
|
] });
|
|
966
966
|
}
|
|
967
|
-
function
|
|
967
|
+
function Ht({ className: e }) {
|
|
968
968
|
return /* @__PURE__ */ o("svg", { className: e, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
|
|
969
969
|
/* @__PURE__ */ t("path", { d: "M12 8V4H8" }),
|
|
970
970
|
/* @__PURE__ */ t("rect", { x: "5", y: "8", width: "14", height: "12", rx: "2" }),
|
|
@@ -974,7 +974,7 @@ function qt({ className: e }) {
|
|
|
974
974
|
/* @__PURE__ */ t("path", { d: "M15 13v2" })
|
|
975
975
|
] });
|
|
976
976
|
}
|
|
977
|
-
function
|
|
977
|
+
function Ft({ className: e }) {
|
|
978
978
|
return /* @__PURE__ */ o("svg", { className: e, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
|
|
979
979
|
/* @__PURE__ */ t("path", { d: "M10 6h11" }),
|
|
980
980
|
/* @__PURE__ */ t("path", { d: "M10 12h11" }),
|
|
@@ -991,21 +991,21 @@ function Je({
|
|
|
991
991
|
showLineNumbers: s = !1,
|
|
992
992
|
className: a
|
|
993
993
|
}) {
|
|
994
|
-
const [i, u] =
|
|
995
|
-
`),
|
|
994
|
+
const [i, u] = k(!1), [d, l] = k(!1), N = e.split(`
|
|
995
|
+
`), f = N.length > 10 || e.length > 500, w = $(async () => {
|
|
996
996
|
try {
|
|
997
997
|
await navigator.clipboard.writeText(e), l(!0), setTimeout(() => l(!1), 2e3);
|
|
998
|
-
} catch (
|
|
999
|
-
console.error("Failed to copy:",
|
|
998
|
+
} catch (I) {
|
|
999
|
+
console.error("Failed to copy:", I);
|
|
1000
1000
|
}
|
|
1001
1001
|
}, [e]);
|
|
1002
|
-
return /* @__PURE__ */ o("div", { className:
|
|
1002
|
+
return /* @__PURE__ */ o("div", { className: h("relative rounded-lg overflow-hidden border border-white/10", a), children: [
|
|
1003
1003
|
/* @__PURE__ */ o("div", { className: "flex items-center justify-between px-4 py-2 bg-[var(--ash-code-header-bg)] border-b border-white/10", children: [
|
|
1004
1004
|
/* @__PURE__ */ t("span", { className: "text-xs text-white/60 font-medium", children: r || "code" }),
|
|
1005
1005
|
/* @__PURE__ */ t(
|
|
1006
1006
|
"button",
|
|
1007
1007
|
{
|
|
1008
|
-
onClick:
|
|
1008
|
+
onClick: w,
|
|
1009
1009
|
className: "flex items-center gap-1.5 text-xs text-white/60 hover:text-white transition-colors",
|
|
1010
1010
|
children: d ? /* @__PURE__ */ o(we, { children: [
|
|
1011
1011
|
/* @__PURE__ */ t(Bt, { className: "w-3.5 h-3.5" }),
|
|
@@ -1020,19 +1020,19 @@ function Je({
|
|
|
1020
1020
|
/* @__PURE__ */ t(
|
|
1021
1021
|
"pre",
|
|
1022
1022
|
{
|
|
1023
|
-
className:
|
|
1023
|
+
className: h(
|
|
1024
1024
|
"text-xs font-mono text-white/90 p-4 bg-black/30 overflow-x-auto whitespace-pre-wrap break-words",
|
|
1025
|
-
!i &&
|
|
1025
|
+
!i && f && "overflow-y-hidden"
|
|
1026
1026
|
),
|
|
1027
|
-
style: !i &&
|
|
1027
|
+
style: !i && f ? { maxHeight: n } : void 0,
|
|
1028
1028
|
"data-language": r,
|
|
1029
|
-
children: s ? /* @__PURE__ */ t("code", { children:
|
|
1030
|
-
/* @__PURE__ */ t("span", { className: "inline-block w-8 text-white/30 select-none text-right pr-2", children:
|
|
1031
|
-
/* @__PURE__ */ t("span", { className: "text-white/80", children:
|
|
1032
|
-
] },
|
|
1029
|
+
children: s ? /* @__PURE__ */ t("code", { children: N.map((I, A) => /* @__PURE__ */ o("span", { className: "block", children: [
|
|
1030
|
+
/* @__PURE__ */ t("span", { className: "inline-block w-8 text-white/30 select-none text-right pr-2", children: A + 1 }),
|
|
1031
|
+
/* @__PURE__ */ t("span", { className: "text-white/80", children: I })
|
|
1032
|
+
] }, A)) }) : /* @__PURE__ */ t("code", { className: "text-white/80", children: e })
|
|
1033
1033
|
}
|
|
1034
1034
|
),
|
|
1035
|
-
|
|
1035
|
+
f && !i && /* @__PURE__ */ t("div", { className: "absolute bottom-0 left-0 right-0 h-12 ash-truncate-fade flex items-end justify-center pb-2", children: /* @__PURE__ */ t(
|
|
1036
1036
|
"button",
|
|
1037
1037
|
{
|
|
1038
1038
|
onClick: () => u(!0),
|
|
@@ -1040,7 +1040,7 @@ function Je({
|
|
|
1040
1040
|
children: "Show more"
|
|
1041
1041
|
}
|
|
1042
1042
|
) }),
|
|
1043
|
-
|
|
1043
|
+
f && i && /* @__PURE__ */ t(
|
|
1044
1044
|
"button",
|
|
1045
1045
|
{
|
|
1046
1046
|
onClick: () => u(!1),
|
|
@@ -1054,9 +1054,9 @@ function Ue({ value: e, maxHeight: n, className: r }) {
|
|
|
1054
1054
|
const s = JSON.stringify(e, null, 2);
|
|
1055
1055
|
return /* @__PURE__ */ t(Je, { maxHeight: n, className: r, children: s });
|
|
1056
1056
|
}
|
|
1057
|
-
var Ge =
|
|
1058
|
-
function
|
|
1059
|
-
const e =
|
|
1057
|
+
var Ge = ke(null);
|
|
1058
|
+
function Ee() {
|
|
1059
|
+
const e = Ne(Ge);
|
|
1060
1060
|
if (!e)
|
|
1061
1061
|
throw new Error("useTool must be used within a Tool");
|
|
1062
1062
|
return e;
|
|
@@ -1068,23 +1068,23 @@ function Ze({
|
|
|
1068
1068
|
defaultExpanded: s = !1,
|
|
1069
1069
|
variant: a = "default"
|
|
1070
1070
|
}) {
|
|
1071
|
-
const [i, u] =
|
|
1071
|
+
const [i, u] = k(s), l = {
|
|
1072
1072
|
toolInvocation: e,
|
|
1073
1073
|
isExpanded: i,
|
|
1074
|
-
toggleExpanded: () => u((
|
|
1074
|
+
toggleExpanded: () => u((w) => !w),
|
|
1075
1075
|
variant: a
|
|
1076
|
-
},
|
|
1076
|
+
}, N = e.state === "result" ? "success" : "pending", f = !!(e.result && typeof e.result == "object" && "error" in e.result);
|
|
1077
1077
|
return /* @__PURE__ */ t(Ge.Provider, { value: l, children: /* @__PURE__ */ t(
|
|
1078
1078
|
"div",
|
|
1079
1079
|
{
|
|
1080
|
-
className:
|
|
1080
|
+
className: h(
|
|
1081
1081
|
"ash-tool",
|
|
1082
1082
|
"rounded-[var(--ash-radius-md,0.5rem)]",
|
|
1083
1083
|
"border border-[var(--ash-border,rgba(255,255,255,0.08))]",
|
|
1084
1084
|
"bg-[var(--ash-tool-bg,var(--ash-surface-dark,#0a0a0a))]",
|
|
1085
1085
|
"overflow-hidden",
|
|
1086
|
-
|
|
1087
|
-
|
|
1086
|
+
N === "pending" && "ash-tool-status-pending",
|
|
1087
|
+
f && "border-red-500/30",
|
|
1088
1088
|
r
|
|
1089
1089
|
),
|
|
1090
1090
|
"data-tool-name": e.toolName,
|
|
@@ -1104,41 +1104,41 @@ function Kt({
|
|
|
1104
1104
|
icon: n,
|
|
1105
1105
|
showToggle: r = !0
|
|
1106
1106
|
}) {
|
|
1107
|
-
const { toolInvocation: s, isExpanded: a, toggleExpanded: i, variant: u } =
|
|
1107
|
+
const { toolInvocation: s, isExpanded: a, toggleExpanded: i, variant: u } = Ee(), d = u === "compact", l = s.state === "result" ? "success" : "pending", N = De(s.toolName), f = n, w = r && !d;
|
|
1108
1108
|
return /* @__PURE__ */ o(
|
|
1109
1109
|
"button",
|
|
1110
1110
|
{
|
|
1111
|
-
onClick:
|
|
1112
|
-
className:
|
|
1111
|
+
onClick: w ? i : void 0,
|
|
1112
|
+
className: h(
|
|
1113
1113
|
"ash-tool-header",
|
|
1114
1114
|
"w-full flex items-center gap-2",
|
|
1115
1115
|
d ? "px-2 py-1.5" : "px-3 py-2",
|
|
1116
1116
|
"text-left",
|
|
1117
|
-
|
|
1118
|
-
!
|
|
1117
|
+
w && "cursor-pointer hover:bg-white/[0.03] transition-colors",
|
|
1118
|
+
!w && "cursor-default",
|
|
1119
1119
|
e
|
|
1120
1120
|
),
|
|
1121
1121
|
children: [
|
|
1122
1122
|
/* @__PURE__ */ t(Lt, { status: l, size: d ? "xs" : "sm" }),
|
|
1123
|
-
|
|
1123
|
+
f ? /* @__PURE__ */ t("span", { className: "text-[var(--ash-text-muted,rgba(255,255,255,0.5))]", children: f }) : /* @__PURE__ */ t("span", { className: "text-[var(--ash-text-muted,rgba(255,255,255,0.5))]", children: /* @__PURE__ */ o("svg", { className: d ? "w-3 h-3" : "w-4 h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: [
|
|
1124
1124
|
/* @__PURE__ */ t("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z" }),
|
|
1125
1125
|
/* @__PURE__ */ t("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M15 12a3 3 0 11-6 0 3 3 0 016 0z" })
|
|
1126
1126
|
] }) }),
|
|
1127
1127
|
/* @__PURE__ */ t(
|
|
1128
1128
|
"span",
|
|
1129
1129
|
{
|
|
1130
|
-
className:
|
|
1130
|
+
className: h(
|
|
1131
1131
|
"flex-1 font-medium",
|
|
1132
1132
|
d ? "text-[var(--ash-font-size-xs,10px)]" : "text-[var(--ash-font-size-sm,12px)]",
|
|
1133
1133
|
"text-[var(--ash-text-primary,rgba(255,255,255,0.9))]"
|
|
1134
1134
|
),
|
|
1135
|
-
children:
|
|
1135
|
+
children: N
|
|
1136
1136
|
}
|
|
1137
1137
|
),
|
|
1138
1138
|
/* @__PURE__ */ t(
|
|
1139
1139
|
"span",
|
|
1140
1140
|
{
|
|
1141
|
-
className:
|
|
1141
|
+
className: h(
|
|
1142
1142
|
d ? "text-[9px]" : "text-[var(--ash-font-size-xs,10px)]",
|
|
1143
1143
|
"text-[var(--ash-text-muted,rgba(255,255,255,0.5))]",
|
|
1144
1144
|
"truncate max-w-[200px]"
|
|
@@ -1146,10 +1146,10 @@ function Kt({
|
|
|
1146
1146
|
children: Object.keys(s.args).length > 0 && `(${Object.keys(s.args).join(", ")})`
|
|
1147
1147
|
}
|
|
1148
1148
|
),
|
|
1149
|
-
|
|
1149
|
+
w && /* @__PURE__ */ t(
|
|
1150
1150
|
"svg",
|
|
1151
1151
|
{
|
|
1152
|
-
className:
|
|
1152
|
+
className: h(
|
|
1153
1153
|
"w-4 h-4 text-[var(--ash-text-muted,rgba(255,255,255,0.5))]",
|
|
1154
1154
|
"transition-transform",
|
|
1155
1155
|
a && "rotate-180"
|
|
@@ -1173,11 +1173,11 @@ function Kt({
|
|
|
1173
1173
|
);
|
|
1174
1174
|
}
|
|
1175
1175
|
function Jt({ className: e, maxHeight: n = 200 }) {
|
|
1176
|
-
const { toolInvocation: r } =
|
|
1176
|
+
const { toolInvocation: r } = Ee();
|
|
1177
1177
|
return !r.args || Object.keys(r.args).length === 0 ? null : /* @__PURE__ */ o(
|
|
1178
1178
|
"div",
|
|
1179
1179
|
{
|
|
1180
|
-
className:
|
|
1180
|
+
className: h(
|
|
1181
1181
|
"ash-tool-input",
|
|
1182
1182
|
"border-t border-[var(--ash-border-subtle,rgba(255,255,255,0.04))]",
|
|
1183
1183
|
e
|
|
@@ -1197,14 +1197,14 @@ function Jt({ className: e, maxHeight: n = 200 }) {
|
|
|
1197
1197
|
);
|
|
1198
1198
|
}
|
|
1199
1199
|
function Ut({ className: e, maxHeight: n = 300 }) {
|
|
1200
|
-
const { toolInvocation: r } =
|
|
1200
|
+
const { toolInvocation: r } = Ee();
|
|
1201
1201
|
if (r.state !== "result" || !r.result)
|
|
1202
1202
|
return null;
|
|
1203
1203
|
const s = r.result, a = typeof s == "string", i = typeof s == "object" && s !== null && "error" in s;
|
|
1204
1204
|
return /* @__PURE__ */ o(
|
|
1205
1205
|
"div",
|
|
1206
1206
|
{
|
|
1207
|
-
className:
|
|
1207
|
+
className: h(
|
|
1208
1208
|
"ash-tool-output",
|
|
1209
1209
|
"border-t border-[var(--ash-border-subtle,rgba(255,255,255,0.04))]",
|
|
1210
1210
|
i && "bg-red-500/5",
|
|
@@ -1214,7 +1214,7 @@ function Ut({ className: e, maxHeight: n = 300 }) {
|
|
|
1214
1214
|
/* @__PURE__ */ t(
|
|
1215
1215
|
"div",
|
|
1216
1216
|
{
|
|
1217
|
-
className:
|
|
1217
|
+
className: h(
|
|
1218
1218
|
"ash-tool-section-header",
|
|
1219
1219
|
i && "text-red-400"
|
|
1220
1220
|
),
|
|
@@ -1233,7 +1233,7 @@ function Ut({ className: e, maxHeight: n = 300 }) {
|
|
|
1233
1233
|
}
|
|
1234
1234
|
);
|
|
1235
1235
|
}
|
|
1236
|
-
function
|
|
1236
|
+
function sr({
|
|
1237
1237
|
toolInvocations: e,
|
|
1238
1238
|
className: n,
|
|
1239
1239
|
defaultExpanded: r = !1,
|
|
@@ -1242,7 +1242,7 @@ function nr({
|
|
|
1242
1242
|
return !e || e.length === 0 ? null : /* @__PURE__ */ t(
|
|
1243
1243
|
"div",
|
|
1244
1244
|
{
|
|
1245
|
-
className:
|
|
1245
|
+
className: h(
|
|
1246
1246
|
"ash-tool-list",
|
|
1247
1247
|
"flex flex-col",
|
|
1248
1248
|
s === "compact" ? "gap-1" : "gap-2",
|
|
@@ -1260,9 +1260,9 @@ function nr({
|
|
|
1260
1260
|
}
|
|
1261
1261
|
);
|
|
1262
1262
|
}
|
|
1263
|
-
var Ye =
|
|
1263
|
+
var Ye = ke(null);
|
|
1264
1264
|
function Xe() {
|
|
1265
|
-
const e =
|
|
1265
|
+
const e = Ne(Ye);
|
|
1266
1266
|
if (!e)
|
|
1267
1267
|
throw new Error("useReasoning must be used within a Reasoning");
|
|
1268
1268
|
return e;
|
|
@@ -1275,29 +1275,29 @@ function Gt({
|
|
|
1275
1275
|
autoCollapse: a = !0,
|
|
1276
1276
|
initialDuration: i = 0
|
|
1277
1277
|
}) {
|
|
1278
|
-
const [u, d] =
|
|
1279
|
-
|
|
1280
|
-
|
|
1278
|
+
const [u, d] = k(!1), [l, N] = k(i), f = z(null), w = z(null);
|
|
1279
|
+
te(() => (n && s && (d(!0), f.current = Date.now(), w.current = setInterval(() => {
|
|
1280
|
+
f.current && N(Math.floor((Date.now() - f.current) / 1e3));
|
|
1281
1281
|
}, 1e3)), () => {
|
|
1282
|
-
|
|
1283
|
-
}), [n, s]),
|
|
1284
|
-
if (!n && a &&
|
|
1285
|
-
const
|
|
1282
|
+
w.current && (clearInterval(w.current), w.current = null);
|
|
1283
|
+
}), [n, s]), te(() => {
|
|
1284
|
+
if (!n && a && f.current) {
|
|
1285
|
+
const A = setTimeout(() => {
|
|
1286
1286
|
d(!1);
|
|
1287
1287
|
}, 500);
|
|
1288
|
-
return
|
|
1288
|
+
return f.current = null, w.current && (clearInterval(w.current), w.current = null), () => clearTimeout(A);
|
|
1289
1289
|
}
|
|
1290
1290
|
}, [n, a]);
|
|
1291
|
-
const
|
|
1291
|
+
const I = {
|
|
1292
1292
|
isOpen: u,
|
|
1293
1293
|
setIsOpen: d,
|
|
1294
1294
|
isStreaming: n,
|
|
1295
1295
|
duration: l
|
|
1296
1296
|
};
|
|
1297
|
-
return /* @__PURE__ */ t(Ye.Provider, { value:
|
|
1297
|
+
return /* @__PURE__ */ t(Ye.Provider, { value: I, children: /* @__PURE__ */ t(
|
|
1298
1298
|
"div",
|
|
1299
1299
|
{
|
|
1300
|
-
className:
|
|
1300
|
+
className: h(
|
|
1301
1301
|
"ash-reasoning",
|
|
1302
1302
|
"rounded-[var(--ash-radius-md,0.5rem)]",
|
|
1303
1303
|
"border",
|
|
@@ -1311,21 +1311,21 @@ function Gt({
|
|
|
1311
1311
|
}
|
|
1312
1312
|
) });
|
|
1313
1313
|
}
|
|
1314
|
-
function
|
|
1314
|
+
function Zt({
|
|
1315
1315
|
className: e,
|
|
1316
1316
|
label: n = "Thinking",
|
|
1317
1317
|
showDuration: r = !0
|
|
1318
1318
|
}) {
|
|
1319
1319
|
const { isOpen: s, setIsOpen: a, isStreaming: i, duration: u } = Xe(), d = (l) => {
|
|
1320
1320
|
if (l < 60) return `${l}s`;
|
|
1321
|
-
const
|
|
1322
|
-
return `${
|
|
1321
|
+
const N = Math.floor(l / 60), f = l % 60;
|
|
1322
|
+
return `${N}m ${f}s`;
|
|
1323
1323
|
};
|
|
1324
1324
|
return /* @__PURE__ */ o(
|
|
1325
1325
|
"button",
|
|
1326
1326
|
{
|
|
1327
1327
|
onClick: () => a(!s),
|
|
1328
|
-
className:
|
|
1328
|
+
className: h(
|
|
1329
1329
|
"ash-reasoning-trigger",
|
|
1330
1330
|
"w-full flex items-center gap-2",
|
|
1331
1331
|
"px-3 py-2",
|
|
@@ -1337,7 +1337,7 @@ function rr({
|
|
|
1337
1337
|
/* @__PURE__ */ t(
|
|
1338
1338
|
"span",
|
|
1339
1339
|
{
|
|
1340
|
-
className:
|
|
1340
|
+
className: h(
|
|
1341
1341
|
"w-4 h-4 flex items-center justify-center",
|
|
1342
1342
|
i && "animate-pulse"
|
|
1343
1343
|
),
|
|
@@ -1392,7 +1392,7 @@ function rr({
|
|
|
1392
1392
|
/* @__PURE__ */ o(
|
|
1393
1393
|
"span",
|
|
1394
1394
|
{
|
|
1395
|
-
className:
|
|
1395
|
+
className: h(
|
|
1396
1396
|
"flex-1 font-medium",
|
|
1397
1397
|
"text-[var(--ash-font-size-sm,12px)]",
|
|
1398
1398
|
i ? "text-[var(--ash-thinking-text,rgb(196,181,253))]" : "text-[var(--ash-text-secondary,rgba(255,255,255,0.7))]"
|
|
@@ -1406,7 +1406,7 @@ function rr({
|
|
|
1406
1406
|
r && u > 0 && /* @__PURE__ */ t(
|
|
1407
1407
|
"span",
|
|
1408
1408
|
{
|
|
1409
|
-
className:
|
|
1409
|
+
className: h(
|
|
1410
1410
|
"text-[var(--ash-font-size-xs,10px)]",
|
|
1411
1411
|
"text-[var(--ash-text-muted,rgba(255,255,255,0.5))]"
|
|
1412
1412
|
),
|
|
@@ -1416,7 +1416,7 @@ function rr({
|
|
|
1416
1416
|
/* @__PURE__ */ t(
|
|
1417
1417
|
"svg",
|
|
1418
1418
|
{
|
|
1419
|
-
className:
|
|
1419
|
+
className: h(
|
|
1420
1420
|
"w-4 h-4 text-[var(--ash-text-muted,rgba(255,255,255,0.5))]",
|
|
1421
1421
|
"transition-transform",
|
|
1422
1422
|
s && "rotate-180"
|
|
@@ -1439,7 +1439,7 @@ function rr({
|
|
|
1439
1439
|
}
|
|
1440
1440
|
);
|
|
1441
1441
|
}
|
|
1442
|
-
function
|
|
1442
|
+
function Yt({
|
|
1443
1443
|
children: e,
|
|
1444
1444
|
className: n,
|
|
1445
1445
|
maxHeight: r = 300
|
|
@@ -1448,7 +1448,7 @@ function sr({
|
|
|
1448
1448
|
return s ? /* @__PURE__ */ t(
|
|
1449
1449
|
"div",
|
|
1450
1450
|
{
|
|
1451
|
-
className:
|
|
1451
|
+
className: h(
|
|
1452
1452
|
"ash-reasoning-content",
|
|
1453
1453
|
"border-t border-[var(--ash-border-subtle,rgba(255,255,255,0.04))]",
|
|
1454
1454
|
"ash-accordion-content",
|
|
@@ -1457,7 +1457,7 @@ function sr({
|
|
|
1457
1457
|
children: /* @__PURE__ */ t(
|
|
1458
1458
|
"div",
|
|
1459
1459
|
{
|
|
1460
|
-
className:
|
|
1460
|
+
className: h(
|
|
1461
1461
|
"p-3 overflow-auto",
|
|
1462
1462
|
"text-[var(--ash-font-size-sm,12px)]",
|
|
1463
1463
|
"text-[var(--ash-text-secondary,rgba(255,255,255,0.7))]",
|
|
@@ -1479,7 +1479,7 @@ function ar({
|
|
|
1479
1479
|
return e ? /* @__PURE__ */ o(
|
|
1480
1480
|
"div",
|
|
1481
1481
|
{
|
|
1482
|
-
className:
|
|
1482
|
+
className: h(
|
|
1483
1483
|
"ash-thinking-indicator",
|
|
1484
1484
|
"flex items-center gap-2",
|
|
1485
1485
|
"px-3 py-2",
|
|
@@ -1498,26 +1498,26 @@ function ar({
|
|
|
1498
1498
|
}
|
|
1499
1499
|
) : null;
|
|
1500
1500
|
}
|
|
1501
|
-
var Qe =
|
|
1501
|
+
var Qe = ke(null);
|
|
1502
1502
|
function et() {
|
|
1503
|
-
const e =
|
|
1503
|
+
const e = Ne(Qe);
|
|
1504
1504
|
if (!e)
|
|
1505
1505
|
throw new Error("useTask must be used within a Task");
|
|
1506
1506
|
return e;
|
|
1507
1507
|
}
|
|
1508
|
-
function
|
|
1508
|
+
function Xt({
|
|
1509
1509
|
children: e,
|
|
1510
1510
|
defaultOpen: n = !1,
|
|
1511
1511
|
className: r
|
|
1512
1512
|
}) {
|
|
1513
|
-
const [s, a] =
|
|
1513
|
+
const [s, a] = k(n), i = {
|
|
1514
1514
|
isOpen: s,
|
|
1515
1515
|
setIsOpen: a
|
|
1516
1516
|
};
|
|
1517
1517
|
return /* @__PURE__ */ t(Qe.Provider, { value: i, children: /* @__PURE__ */ t(
|
|
1518
1518
|
"div",
|
|
1519
1519
|
{
|
|
1520
|
-
className:
|
|
1520
|
+
className: h(
|
|
1521
1521
|
"ash-task",
|
|
1522
1522
|
"rounded-[var(--ash-radius-md,0.5rem)]",
|
|
1523
1523
|
"border border-[var(--ash-border,rgba(255,255,255,0.08))]",
|
|
@@ -1529,13 +1529,13 @@ function Zt({
|
|
|
1529
1529
|
}
|
|
1530
1530
|
) });
|
|
1531
1531
|
}
|
|
1532
|
-
function
|
|
1532
|
+
function Qt({ children: e, className: n }) {
|
|
1533
1533
|
const { isOpen: r, setIsOpen: s } = et();
|
|
1534
1534
|
return /* @__PURE__ */ o(
|
|
1535
1535
|
"button",
|
|
1536
1536
|
{
|
|
1537
1537
|
onClick: () => s(!r),
|
|
1538
|
-
className:
|
|
1538
|
+
className: h(
|
|
1539
1539
|
"ash-task-trigger",
|
|
1540
1540
|
"w-full flex items-center gap-2",
|
|
1541
1541
|
"px-3 py-2",
|
|
@@ -1565,7 +1565,7 @@ function Yt({ children: e, className: n }) {
|
|
|
1565
1565
|
/* @__PURE__ */ t(
|
|
1566
1566
|
"span",
|
|
1567
1567
|
{
|
|
1568
|
-
className:
|
|
1568
|
+
className: h(
|
|
1569
1569
|
"flex-1 font-medium",
|
|
1570
1570
|
"text-[var(--ash-font-size-sm,12px)]",
|
|
1571
1571
|
"text-[var(--ash-text-primary,rgba(255,255,255,0.9))]"
|
|
@@ -1576,7 +1576,7 @@ function Yt({ children: e, className: n }) {
|
|
|
1576
1576
|
/* @__PURE__ */ t(
|
|
1577
1577
|
"svg",
|
|
1578
1578
|
{
|
|
1579
|
-
className:
|
|
1579
|
+
className: h(
|
|
1580
1580
|
"w-4 h-4 text-[var(--ash-text-muted,rgba(255,255,255,0.5))]",
|
|
1581
1581
|
"transition-transform",
|
|
1582
1582
|
r && "rotate-180"
|
|
@@ -1599,12 +1599,12 @@ function Yt({ children: e, className: n }) {
|
|
|
1599
1599
|
}
|
|
1600
1600
|
);
|
|
1601
1601
|
}
|
|
1602
|
-
function
|
|
1602
|
+
function en({ children: e, className: n }) {
|
|
1603
1603
|
const { isOpen: r } = et();
|
|
1604
1604
|
return r ? /* @__PURE__ */ t(
|
|
1605
1605
|
"div",
|
|
1606
1606
|
{
|
|
1607
|
-
className:
|
|
1607
|
+
className: h(
|
|
1608
1608
|
"ash-task-content",
|
|
1609
1609
|
"border-t border-[var(--ash-border-subtle,rgba(255,255,255,0.04))]",
|
|
1610
1610
|
"ash-accordion-content",
|
|
@@ -1614,7 +1614,7 @@ function Xt({ children: e, className: n }) {
|
|
|
1614
1614
|
}
|
|
1615
1615
|
) : null;
|
|
1616
1616
|
}
|
|
1617
|
-
function
|
|
1617
|
+
function tn({
|
|
1618
1618
|
children: e,
|
|
1619
1619
|
status: n,
|
|
1620
1620
|
activeForm: r,
|
|
@@ -1686,7 +1686,7 @@ function Qt({
|
|
|
1686
1686
|
return /* @__PURE__ */ o(
|
|
1687
1687
|
"div",
|
|
1688
1688
|
{
|
|
1689
|
-
className:
|
|
1689
|
+
className: h(
|
|
1690
1690
|
"ash-task-item",
|
|
1691
1691
|
"flex items-center gap-2",
|
|
1692
1692
|
"px-2 py-1.5 rounded-md",
|
|
@@ -1699,7 +1699,7 @@ function Qt({
|
|
|
1699
1699
|
/* @__PURE__ */ t(
|
|
1700
1700
|
"span",
|
|
1701
1701
|
{
|
|
1702
|
-
className:
|
|
1702
|
+
className: h(
|
|
1703
1703
|
"flex-1",
|
|
1704
1704
|
"text-[var(--ash-font-size-sm,12px)]",
|
|
1705
1705
|
i[n]
|
|
@@ -1718,10 +1718,10 @@ function or({
|
|
|
1718
1718
|
title: s
|
|
1719
1719
|
}) {
|
|
1720
1720
|
const a = e.filter((d) => d.status === "completed").length, i = e.length, u = s || `Tasks (${a}/${i})`;
|
|
1721
|
-
return /* @__PURE__ */ o(
|
|
1722
|
-
/* @__PURE__ */ t(
|
|
1723
|
-
/* @__PURE__ */ t(
|
|
1724
|
-
|
|
1721
|
+
return /* @__PURE__ */ o(Xt, { defaultOpen: n, className: r, children: [
|
|
1722
|
+
/* @__PURE__ */ t(Qt, { children: u }),
|
|
1723
|
+
/* @__PURE__ */ t(en, { children: e.map((d, l) => /* @__PURE__ */ t(
|
|
1724
|
+
tn,
|
|
1725
1725
|
{
|
|
1726
1726
|
status: d.status,
|
|
1727
1727
|
activeForm: d.activeForm,
|
|
@@ -1731,9 +1731,9 @@ function or({
|
|
|
1731
1731
|
)) })
|
|
1732
1732
|
] });
|
|
1733
1733
|
}
|
|
1734
|
-
var tt =
|
|
1735
|
-
function
|
|
1736
|
-
const e =
|
|
1734
|
+
var tt = ke(null);
|
|
1735
|
+
function $e() {
|
|
1736
|
+
const e = Ne(tt);
|
|
1737
1737
|
if (!e)
|
|
1738
1738
|
throw new Error("useAttachment must be used within an Attachment");
|
|
1739
1739
|
return e;
|
|
@@ -1746,7 +1746,7 @@ function ir({
|
|
|
1746
1746
|
return /* @__PURE__ */ t(
|
|
1747
1747
|
"div",
|
|
1748
1748
|
{
|
|
1749
|
-
className:
|
|
1749
|
+
className: h(
|
|
1750
1750
|
"ash-attachments",
|
|
1751
1751
|
{
|
|
1752
1752
|
grid: "grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 gap-2",
|
|
@@ -1775,7 +1775,7 @@ function lr({
|
|
|
1775
1775
|
return /* @__PURE__ */ t(tt.Provider, { value: i, children: /* @__PURE__ */ t(
|
|
1776
1776
|
"div",
|
|
1777
1777
|
{
|
|
1778
|
-
className:
|
|
1778
|
+
className: h(
|
|
1779
1779
|
"ash-attachment relative group",
|
|
1780
1780
|
"rounded-[var(--ash-radius-sm,0.375rem)]",
|
|
1781
1781
|
"border border-[var(--ash-border,rgba(255,255,255,0.08))]",
|
|
@@ -1787,23 +1787,23 @@ function lr({
|
|
|
1787
1787
|
),
|
|
1788
1788
|
"data-file-type": e.type,
|
|
1789
1789
|
children: n || /* @__PURE__ */ o(we, { children: [
|
|
1790
|
-
/* @__PURE__ */ t(
|
|
1791
|
-
/* @__PURE__ */ t(
|
|
1792
|
-
r && /* @__PURE__ */ t(
|
|
1790
|
+
/* @__PURE__ */ t(nn, {}),
|
|
1791
|
+
/* @__PURE__ */ t(rn, {}),
|
|
1792
|
+
r && /* @__PURE__ */ t(sn, {})
|
|
1793
1793
|
] })
|
|
1794
1794
|
}
|
|
1795
1795
|
) });
|
|
1796
1796
|
}
|
|
1797
|
-
function
|
|
1797
|
+
function nn({
|
|
1798
1798
|
className: e,
|
|
1799
1799
|
height: n = 80
|
|
1800
1800
|
}) {
|
|
1801
|
-
const { file: r } =
|
|
1801
|
+
const { file: r } = $e(), s = r.type.startsWith("image/"), a = "url" in r ? r.url : "base64" in r ? `data:${r.type};base64,${r.base64}` : void 0;
|
|
1802
1802
|
if (s && a)
|
|
1803
1803
|
return /* @__PURE__ */ t(
|
|
1804
1804
|
"div",
|
|
1805
1805
|
{
|
|
1806
|
-
className:
|
|
1806
|
+
className: h(
|
|
1807
1807
|
"ash-attachment-preview",
|
|
1808
1808
|
"w-full bg-black/20 overflow-hidden",
|
|
1809
1809
|
e
|
|
@@ -1826,7 +1826,7 @@ function en({
|
|
|
1826
1826
|
return /* @__PURE__ */ t(
|
|
1827
1827
|
"div",
|
|
1828
1828
|
{
|
|
1829
|
-
className:
|
|
1829
|
+
className: h(
|
|
1830
1830
|
"ash-attachment-preview",
|
|
1831
1831
|
"w-full flex items-center justify-center",
|
|
1832
1832
|
"bg-[var(--ash-surface-dark,#0a0a0a)]",
|
|
@@ -1838,15 +1838,15 @@ function en({
|
|
|
1838
1838
|
}
|
|
1839
1839
|
);
|
|
1840
1840
|
}
|
|
1841
|
-
function
|
|
1841
|
+
function rn({
|
|
1842
1842
|
className: e,
|
|
1843
1843
|
showSize: n = !0
|
|
1844
1844
|
}) {
|
|
1845
|
-
const { file: r } =
|
|
1845
|
+
const { file: r } = $e();
|
|
1846
1846
|
return /* @__PURE__ */ o(
|
|
1847
1847
|
"div",
|
|
1848
1848
|
{
|
|
1849
|
-
className:
|
|
1849
|
+
className: h(
|
|
1850
1850
|
"ash-attachment-info",
|
|
1851
1851
|
"px-2 py-1.5",
|
|
1852
1852
|
"truncate",
|
|
@@ -1856,7 +1856,7 @@ function tn({
|
|
|
1856
1856
|
/* @__PURE__ */ t(
|
|
1857
1857
|
"div",
|
|
1858
1858
|
{
|
|
1859
|
-
className:
|
|
1859
|
+
className: h(
|
|
1860
1860
|
"text-[var(--ash-font-size-xs,10px)]",
|
|
1861
1861
|
"text-[var(--ash-text-primary,rgba(255,255,255,0.9))]",
|
|
1862
1862
|
"truncate font-medium"
|
|
@@ -1868,7 +1868,7 @@ function tn({
|
|
|
1868
1868
|
n && /* @__PURE__ */ t(
|
|
1869
1869
|
"div",
|
|
1870
1870
|
{
|
|
1871
|
-
className:
|
|
1871
|
+
className: h(
|
|
1872
1872
|
"text-[var(--ash-font-size-xs,10px)]",
|
|
1873
1873
|
"text-[var(--ash-text-muted,rgba(255,255,255,0.5))]"
|
|
1874
1874
|
),
|
|
@@ -1879,15 +1879,15 @@ function tn({
|
|
|
1879
1879
|
}
|
|
1880
1880
|
);
|
|
1881
1881
|
}
|
|
1882
|
-
function
|
|
1883
|
-
const { onRemove: n, removable: r } =
|
|
1882
|
+
function sn({ className: e }) {
|
|
1883
|
+
const { onRemove: n, removable: r } = $e();
|
|
1884
1884
|
return !r || !n ? null : /* @__PURE__ */ t(
|
|
1885
1885
|
"button",
|
|
1886
1886
|
{
|
|
1887
1887
|
onClick: (s) => {
|
|
1888
1888
|
s.stopPropagation(), n();
|
|
1889
1889
|
},
|
|
1890
|
-
className:
|
|
1890
|
+
className: h(
|
|
1891
1891
|
"ash-attachment-remove",
|
|
1892
1892
|
"absolute top-1 right-1",
|
|
1893
1893
|
"w-5 h-5 rounded-full",
|
|
@@ -1913,7 +1913,7 @@ function cr({
|
|
|
1913
1913
|
return /* @__PURE__ */ o(
|
|
1914
1914
|
"div",
|
|
1915
1915
|
{
|
|
1916
|
-
className:
|
|
1916
|
+
className: h(
|
|
1917
1917
|
"ash-file-badge group inline-flex items-center gap-1.5",
|
|
1918
1918
|
"px-2 py-1 rounded-md",
|
|
1919
1919
|
"bg-[var(--ash-surface-elevated,#111111)]",
|
|
@@ -1931,7 +1931,7 @@ function cr({
|
|
|
1931
1931
|
onClick: (i) => {
|
|
1932
1932
|
i.stopPropagation(), r();
|
|
1933
1933
|
},
|
|
1934
|
-
className:
|
|
1934
|
+
className: h(
|
|
1935
1935
|
"ml-0.5 text-[var(--ash-text-muted)]",
|
|
1936
1936
|
"hover:text-red-400 transition-colors",
|
|
1937
1937
|
"opacity-0 group-hover:opacity-100"
|
|
@@ -1952,7 +1952,7 @@ function dr({
|
|
|
1952
1952
|
return r ? /* @__PURE__ */ t(
|
|
1953
1953
|
"div",
|
|
1954
1954
|
{
|
|
1955
|
-
className:
|
|
1955
|
+
className: h(
|
|
1956
1956
|
"ash-shimmer",
|
|
1957
1957
|
"flex flex-col gap-2",
|
|
1958
1958
|
n
|
|
@@ -1960,14 +1960,14 @@ function dr({
|
|
|
1960
1960
|
role: "status",
|
|
1961
1961
|
"aria-label": "Loading",
|
|
1962
1962
|
children: e || /* @__PURE__ */ o(we, { children: [
|
|
1963
|
-
/* @__PURE__ */ t(
|
|
1964
|
-
/* @__PURE__ */ t(
|
|
1965
|
-
/* @__PURE__ */ t(
|
|
1963
|
+
/* @__PURE__ */ t(be, { width: "100%" }),
|
|
1964
|
+
/* @__PURE__ */ t(be, { width: "80%" }),
|
|
1965
|
+
/* @__PURE__ */ t(be, { width: "60%" })
|
|
1966
1966
|
] })
|
|
1967
1967
|
}
|
|
1968
1968
|
) : null;
|
|
1969
1969
|
}
|
|
1970
|
-
function
|
|
1970
|
+
function be({
|
|
1971
1971
|
width: e = "100%",
|
|
1972
1972
|
height: n = 16,
|
|
1973
1973
|
className: r
|
|
@@ -1975,7 +1975,7 @@ function ye({
|
|
|
1975
1975
|
return /* @__PURE__ */ t(
|
|
1976
1976
|
"div",
|
|
1977
1977
|
{
|
|
1978
|
-
className:
|
|
1978
|
+
className: h(
|
|
1979
1979
|
"ash-shimmer-line",
|
|
1980
1980
|
"rounded-md",
|
|
1981
1981
|
"bg-gradient-to-r from-white/5 via-white/10 to-white/5",
|
|
@@ -1990,7 +1990,7 @@ function ye({
|
|
|
1990
1990
|
}
|
|
1991
1991
|
);
|
|
1992
1992
|
}
|
|
1993
|
-
function
|
|
1993
|
+
function an({
|
|
1994
1994
|
width: e = "100%",
|
|
1995
1995
|
height: n = 100,
|
|
1996
1996
|
rounded: r = "md",
|
|
@@ -1999,7 +1999,7 @@ function rn({
|
|
|
1999
1999
|
return /* @__PURE__ */ t(
|
|
2000
2000
|
"div",
|
|
2001
2001
|
{
|
|
2002
|
-
className:
|
|
2002
|
+
className: h(
|
|
2003
2003
|
"ash-shimmer-block",
|
|
2004
2004
|
{
|
|
2005
2005
|
none: "rounded-none",
|
|
@@ -2027,7 +2027,7 @@ function ur({
|
|
|
2027
2027
|
return /* @__PURE__ */ t(
|
|
2028
2028
|
"span",
|
|
2029
2029
|
{
|
|
2030
|
-
className:
|
|
2030
|
+
className: h(
|
|
2031
2031
|
"ash-shimmer-text inline-block",
|
|
2032
2032
|
"rounded",
|
|
2033
2033
|
"bg-gradient-to-r from-white/5 via-white/10 to-white/5",
|
|
@@ -2043,7 +2043,7 @@ function ur({
|
|
|
2043
2043
|
}
|
|
2044
2044
|
);
|
|
2045
2045
|
}
|
|
2046
|
-
function
|
|
2046
|
+
function on({
|
|
2047
2047
|
size: e = "md",
|
|
2048
2048
|
className: n
|
|
2049
2049
|
}) {
|
|
@@ -2055,7 +2055,7 @@ function sn({
|
|
|
2055
2055
|
return /* @__PURE__ */ t(
|
|
2056
2056
|
"span",
|
|
2057
2057
|
{
|
|
2058
|
-
className:
|
|
2058
|
+
className: h(
|
|
2059
2059
|
"ash-loading-dots inline-flex items-center",
|
|
2060
2060
|
{
|
|
2061
2061
|
sm: "gap-0.5",
|
|
@@ -2069,7 +2069,7 @@ function sn({
|
|
|
2069
2069
|
children: [0, 1, 2].map((a) => /* @__PURE__ */ t(
|
|
2070
2070
|
"span",
|
|
2071
2071
|
{
|
|
2072
|
-
className:
|
|
2072
|
+
className: h(
|
|
2073
2073
|
r[e],
|
|
2074
2074
|
"rounded-full",
|
|
2075
2075
|
"bg-current",
|
|
@@ -2089,7 +2089,7 @@ function hr({
|
|
|
2089
2089
|
return /* @__PURE__ */ o(
|
|
2090
2090
|
"svg",
|
|
2091
2091
|
{
|
|
2092
|
-
className:
|
|
2092
|
+
className: h(
|
|
2093
2093
|
"ash-loading-spinner animate-spin",
|
|
2094
2094
|
{
|
|
2095
2095
|
sm: "w-4 h-4",
|
|
@@ -2133,14 +2133,14 @@ function mr({
|
|
|
2133
2133
|
return /* @__PURE__ */ o(
|
|
2134
2134
|
"div",
|
|
2135
2135
|
{
|
|
2136
|
-
className:
|
|
2136
|
+
className: h(
|
|
2137
2137
|
"ash-message-shimmer flex gap-2",
|
|
2138
2138
|
e === "user" && "flex-row-reverse",
|
|
2139
2139
|
n
|
|
2140
2140
|
),
|
|
2141
2141
|
children: [
|
|
2142
2142
|
/* @__PURE__ */ t(
|
|
2143
|
-
|
|
2143
|
+
an,
|
|
2144
2144
|
{
|
|
2145
2145
|
width: 20,
|
|
2146
2146
|
height: 20,
|
|
@@ -2148,27 +2148,27 @@ function mr({
|
|
|
2148
2148
|
}
|
|
2149
2149
|
),
|
|
2150
2150
|
/* @__PURE__ */ o("div", { className: "flex-1 space-y-2 max-w-[80%]", children: [
|
|
2151
|
-
/* @__PURE__ */ t(
|
|
2152
|
-
/* @__PURE__ */ t(
|
|
2153
|
-
/* @__PURE__ */ t(
|
|
2151
|
+
/* @__PURE__ */ t(be, { width: "100%", height: 14 }),
|
|
2152
|
+
/* @__PURE__ */ t(be, { width: "85%", height: 14 }),
|
|
2153
|
+
/* @__PURE__ */ t(be, { width: "70%", height: 14 })
|
|
2154
2154
|
] })
|
|
2155
2155
|
]
|
|
2156
2156
|
}
|
|
2157
2157
|
);
|
|
2158
2158
|
}
|
|
2159
|
-
function
|
|
2159
|
+
function ln(e) {
|
|
2160
2160
|
switch (e) {
|
|
2161
2161
|
case "info":
|
|
2162
2162
|
return /* @__PURE__ */ t(Ot, { className: "w-3.5 h-3.5" });
|
|
2163
2163
|
case "warn":
|
|
2164
2164
|
return /* @__PURE__ */ t(Vt, { className: "w-3.5 h-3.5" });
|
|
2165
2165
|
case "error":
|
|
2166
|
-
return /* @__PURE__ */ t(
|
|
2166
|
+
return /* @__PURE__ */ t(qt, { className: "w-3.5 h-3.5" });
|
|
2167
2167
|
case "debug":
|
|
2168
|
-
return /* @__PURE__ */ t(
|
|
2168
|
+
return /* @__PURE__ */ t(Pt, { className: "w-3.5 h-3.5" });
|
|
2169
2169
|
}
|
|
2170
2170
|
}
|
|
2171
|
-
function
|
|
2171
|
+
function cn(e) {
|
|
2172
2172
|
switch (e) {
|
|
2173
2173
|
case "info":
|
|
2174
2174
|
return "text-blue-400";
|
|
@@ -2180,7 +2180,7 @@ function on(e) {
|
|
|
2180
2180
|
return "text-white/50";
|
|
2181
2181
|
}
|
|
2182
2182
|
}
|
|
2183
|
-
function
|
|
2183
|
+
function dn(e) {
|
|
2184
2184
|
switch (e) {
|
|
2185
2185
|
case "info":
|
|
2186
2186
|
return "bg-blue-900/20";
|
|
@@ -2192,7 +2192,7 @@ function ln(e) {
|
|
|
2192
2192
|
return "bg-white/5";
|
|
2193
2193
|
}
|
|
2194
2194
|
}
|
|
2195
|
-
function
|
|
2195
|
+
function un(e) {
|
|
2196
2196
|
switch (e) {
|
|
2197
2197
|
case "setup":
|
|
2198
2198
|
return "Setup";
|
|
@@ -2206,26 +2206,26 @@ function cn(e) {
|
|
|
2206
2206
|
return "Startup";
|
|
2207
2207
|
}
|
|
2208
2208
|
}
|
|
2209
|
-
function
|
|
2210
|
-
const [n, r] =
|
|
2209
|
+
function hn({ log: e }) {
|
|
2210
|
+
const [n, r] = k(!1), s = e.data && Object.keys(e.data).length > 0;
|
|
2211
2211
|
return /* @__PURE__ */ o(
|
|
2212
2212
|
"div",
|
|
2213
2213
|
{
|
|
2214
|
-
className:
|
|
2214
|
+
className: h(
|
|
2215
2215
|
"px-3 py-2 border-b border-white/10 last:border-b-0",
|
|
2216
|
-
|
|
2216
|
+
dn(e.level)
|
|
2217
2217
|
),
|
|
2218
2218
|
children: [
|
|
2219
2219
|
/* @__PURE__ */ o(
|
|
2220
2220
|
"div",
|
|
2221
2221
|
{
|
|
2222
|
-
className:
|
|
2222
|
+
className: h("flex items-start gap-2", s && "cursor-pointer"),
|
|
2223
2223
|
onClick: () => s && r(!n),
|
|
2224
2224
|
children: [
|
|
2225
|
-
/* @__PURE__ */ t("div", { className: "w-4 flex-shrink-0 pt-0.5", children: s && (n ? /* @__PURE__ */ t(
|
|
2226
|
-
/* @__PURE__ */ t("div", { className:
|
|
2225
|
+
/* @__PURE__ */ t("div", { className: "w-4 flex-shrink-0 pt-0.5", children: s && (n ? /* @__PURE__ */ t(He, { className: "w-3 h-3 text-white/40" }) : /* @__PURE__ */ t(Fe, { className: "w-3 h-3 text-white/40" })) }),
|
|
2226
|
+
/* @__PURE__ */ t("div", { className: h("flex-shrink-0 pt-0.5", cn(e.level)), children: ln(e.level) }),
|
|
2227
2227
|
/* @__PURE__ */ t("span", { className: "text-xs text-white/40 font-mono flex-shrink-0 pt-0.5", children: Nt(e.timestamp) }),
|
|
2228
|
-
/* @__PURE__ */ t("span", { className: "text-xs px-1.5 py-0.5 rounded bg-white/10 text-white/70 font-medium flex-shrink-0", children:
|
|
2228
|
+
/* @__PURE__ */ t("span", { className: "text-xs px-1.5 py-0.5 rounded bg-white/10 text-white/70 font-medium flex-shrink-0", children: un(e.category) }),
|
|
2229
2229
|
/* @__PURE__ */ t("span", { className: "text-sm text-white/80 flex-1 break-words", children: e.message })
|
|
2230
2230
|
]
|
|
2231
2231
|
}
|
|
@@ -2235,7 +2235,7 @@ function dn({ log: e }) {
|
|
|
2235
2235
|
}
|
|
2236
2236
|
);
|
|
2237
2237
|
}
|
|
2238
|
-
function
|
|
2238
|
+
function mn({
|
|
2239
2239
|
logs: e,
|
|
2240
2240
|
title: n = "Logs",
|
|
2241
2241
|
isLoading: r,
|
|
@@ -2243,11 +2243,11 @@ function un({
|
|
|
2243
2243
|
maxHeight: a = 256,
|
|
2244
2244
|
className: i
|
|
2245
2245
|
}) {
|
|
2246
|
-
const [u, d] =
|
|
2246
|
+
const [u, d] = k(s), l = e.filter((f) => f.level === "error").length, N = e.filter((f) => f.level === "warn").length;
|
|
2247
2247
|
return e.length === 0 && !r ? null : /* @__PURE__ */ o(
|
|
2248
2248
|
"div",
|
|
2249
2249
|
{
|
|
2250
|
-
className:
|
|
2250
|
+
className: h(
|
|
2251
2251
|
"border-t border-white/10 bg-[var(--ash-surface-dark,#0a0a0a)]",
|
|
2252
2252
|
i
|
|
2253
2253
|
),
|
|
@@ -2271,14 +2271,14 @@ function un({
|
|
|
2271
2271
|
" error",
|
|
2272
2272
|
l > 1 ? "s" : ""
|
|
2273
2273
|
] }),
|
|
2274
|
-
|
|
2275
|
-
|
|
2274
|
+
N > 0 && /* @__PURE__ */ o("span", { className: "text-xs px-1.5 py-0.5 rounded bg-yellow-900/50 text-yellow-400 font-medium", children: [
|
|
2275
|
+
N,
|
|
2276
2276
|
" warning",
|
|
2277
|
-
|
|
2277
|
+
N > 1 ? "s" : ""
|
|
2278
2278
|
] }),
|
|
2279
2279
|
r && /* @__PURE__ */ t("span", { className: "text-xs text-white/40 animate-pulse", children: "Loading..." })
|
|
2280
2280
|
] }),
|
|
2281
|
-
u ? /* @__PURE__ */ t(
|
|
2281
|
+
u ? /* @__PURE__ */ t(Fe, { className: "w-4 h-4 text-white/40" }) : /* @__PURE__ */ t(He, { className: "w-4 h-4 text-white/40" })
|
|
2282
2282
|
]
|
|
2283
2283
|
}
|
|
2284
2284
|
),
|
|
@@ -2287,7 +2287,7 @@ function un({
|
|
|
2287
2287
|
{
|
|
2288
2288
|
className: "overflow-y-auto border-t border-white/10",
|
|
2289
2289
|
style: { maxHeight: a },
|
|
2290
|
-
children: e.length === 0 ? /* @__PURE__ */ t("div", { className: "px-4 py-6 text-center text-sm text-white/50", children: "No logs yet" }) : e.map((
|
|
2290
|
+
children: e.length === 0 ? /* @__PURE__ */ t("div", { className: "px-4 py-6 text-center text-sm text-white/50", children: "No logs yet" }) : e.map((f, w) => /* @__PURE__ */ t(hn, { log: f }, `${f.timestamp}-${w}`))
|
|
2291
2291
|
}
|
|
2292
2292
|
)
|
|
2293
2293
|
]
|
|
@@ -2302,22 +2302,22 @@ function fr({
|
|
|
2302
2302
|
label: a = "Environment Variables",
|
|
2303
2303
|
helperText: i = "These environment variables will be available in the sandbox for new sessions."
|
|
2304
2304
|
}) {
|
|
2305
|
-
const [u, d] =
|
|
2306
|
-
const
|
|
2307
|
-
|
|
2308
|
-
}, [e, l,
|
|
2309
|
-
(
|
|
2310
|
-
const
|
|
2311
|
-
delete
|
|
2305
|
+
const [u, d] = k(!r), [l, N] = k(""), [f, w] = k(""), I = Object.keys(e).length > 0, A = $(() => {
|
|
2306
|
+
const y = l.trim(), D = f.trim();
|
|
2307
|
+
y && (n({ ...e, [y]: D }), N(""), w(""));
|
|
2308
|
+
}, [e, l, f, n]), K = $(
|
|
2309
|
+
(y) => {
|
|
2310
|
+
const D = { ...e };
|
|
2311
|
+
delete D[y], n(D);
|
|
2312
2312
|
},
|
|
2313
2313
|
[e, n]
|
|
2314
|
-
),
|
|
2315
|
-
(
|
|
2316
|
-
|
|
2314
|
+
), J = $(
|
|
2315
|
+
(y) => {
|
|
2316
|
+
y.key === "Enter" && (y.preventDefault(), A());
|
|
2317
2317
|
},
|
|
2318
|
-
[
|
|
2318
|
+
[A]
|
|
2319
2319
|
);
|
|
2320
|
-
return /* @__PURE__ */ o("div", { className:
|
|
2320
|
+
return /* @__PURE__ */ o("div", { className: h("ash-env-vars-panel", s), children: [
|
|
2321
2321
|
/* @__PURE__ */ o(
|
|
2322
2322
|
"button",
|
|
2323
2323
|
{
|
|
@@ -2329,7 +2329,7 @@ function fr({
|
|
|
2329
2329
|
"svg",
|
|
2330
2330
|
{
|
|
2331
2331
|
xmlns: "http://www.w3.org/2000/svg",
|
|
2332
|
-
className:
|
|
2332
|
+
className: h("ash-env-vars-chevron", u && "ash-env-vars-chevron-expanded"),
|
|
2333
2333
|
viewBox: "0 0 20 20",
|
|
2334
2334
|
fill: "currentColor",
|
|
2335
2335
|
children: /* @__PURE__ */ t(
|
|
@@ -2343,20 +2343,20 @@ function fr({
|
|
|
2343
2343
|
}
|
|
2344
2344
|
),
|
|
2345
2345
|
/* @__PURE__ */ t("span", { className: "ash-env-vars-label", children: a }),
|
|
2346
|
-
|
|
2346
|
+
I && !u && /* @__PURE__ */ t("span", { className: "ash-env-vars-badge", children: Object.keys(e).length })
|
|
2347
2347
|
]
|
|
2348
2348
|
}
|
|
2349
2349
|
),
|
|
2350
2350
|
u && /* @__PURE__ */ o("div", { className: "ash-env-vars-content", children: [
|
|
2351
|
-
Object.entries(e).map(([
|
|
2352
|
-
/* @__PURE__ */ t("span", { className: "ash-env-vars-key", children:
|
|
2351
|
+
Object.entries(e).map(([y, D]) => /* @__PURE__ */ o("div", { className: "ash-env-vars-item", children: [
|
|
2352
|
+
/* @__PURE__ */ t("span", { className: "ash-env-vars-key", children: y }),
|
|
2353
2353
|
/* @__PURE__ */ t("span", { className: "ash-env-vars-equals", children: "=" }),
|
|
2354
|
-
/* @__PURE__ */ t("span", { className: "ash-env-vars-value", children:
|
|
2354
|
+
/* @__PURE__ */ t("span", { className: "ash-env-vars-value", children: D || "(empty)" }),
|
|
2355
2355
|
/* @__PURE__ */ t(
|
|
2356
2356
|
"button",
|
|
2357
2357
|
{
|
|
2358
2358
|
type: "button",
|
|
2359
|
-
onClick: () =>
|
|
2359
|
+
onClick: () => K(y),
|
|
2360
2360
|
className: "ash-env-vars-remove",
|
|
2361
2361
|
title: "Remove variable",
|
|
2362
2362
|
children: /* @__PURE__ */ t(
|
|
@@ -2378,15 +2378,15 @@ function fr({
|
|
|
2378
2378
|
)
|
|
2379
2379
|
}
|
|
2380
2380
|
)
|
|
2381
|
-
] },
|
|
2381
|
+
] }, y)),
|
|
2382
2382
|
/* @__PURE__ */ o("div", { className: "ash-env-vars-add", children: [
|
|
2383
2383
|
/* @__PURE__ */ t(
|
|
2384
2384
|
"input",
|
|
2385
2385
|
{
|
|
2386
2386
|
type: "text",
|
|
2387
2387
|
value: l,
|
|
2388
|
-
onChange: (
|
|
2389
|
-
onKeyDown:
|
|
2388
|
+
onChange: (y) => N(y.target.value.toUpperCase().replace(/[^A-Z0-9_]/g, "")),
|
|
2389
|
+
onKeyDown: J,
|
|
2390
2390
|
placeholder: "KEY",
|
|
2391
2391
|
className: "ash-env-vars-input ash-env-vars-input-key"
|
|
2392
2392
|
}
|
|
@@ -2396,9 +2396,9 @@ function fr({
|
|
|
2396
2396
|
"input",
|
|
2397
2397
|
{
|
|
2398
2398
|
type: "text",
|
|
2399
|
-
value:
|
|
2400
|
-
onChange: (
|
|
2401
|
-
onKeyDown:
|
|
2399
|
+
value: f,
|
|
2400
|
+
onChange: (y) => w(y.target.value),
|
|
2401
|
+
onKeyDown: J,
|
|
2402
2402
|
placeholder: "value",
|
|
2403
2403
|
className: "ash-env-vars-input ash-env-vars-input-value"
|
|
2404
2404
|
}
|
|
@@ -2407,7 +2407,7 @@ function fr({
|
|
|
2407
2407
|
"button",
|
|
2408
2408
|
{
|
|
2409
2409
|
type: "button",
|
|
2410
|
-
onClick:
|
|
2410
|
+
onClick: A,
|
|
2411
2411
|
disabled: !l.trim(),
|
|
2412
2412
|
className: "ash-env-vars-add-button",
|
|
2413
2413
|
children: "Add"
|
|
@@ -2419,13 +2419,13 @@ function fr({
|
|
|
2419
2419
|
] });
|
|
2420
2420
|
}
|
|
2421
2421
|
function pr({ options: e, onSelect: n, className: r }) {
|
|
2422
|
-
return /* @__PURE__ */ t("div", { className:
|
|
2422
|
+
return /* @__PURE__ */ t("div", { className: h("grid gap-2 mt-3", r), style: {
|
|
2423
2423
|
gridTemplateColumns: "repeat(auto-fit, minmax(200px, 1fr))"
|
|
2424
2424
|
}, children: e.map((s) => /* @__PURE__ */ o(
|
|
2425
2425
|
"button",
|
|
2426
2426
|
{
|
|
2427
2427
|
onClick: () => n(s),
|
|
2428
|
-
className:
|
|
2428
|
+
className: h(
|
|
2429
2429
|
"flex items-start gap-3 p-3 rounded-xl text-left",
|
|
2430
2430
|
"bg-white/5 border border-white/10",
|
|
2431
2431
|
"hover:bg-[var(--ash-accent)]/10 hover:border-[var(--ash-accent)]/30",
|
|
@@ -2434,7 +2434,7 @@ function pr({ options: e, onSelect: n, className: r }) {
|
|
|
2434
2434
|
"group"
|
|
2435
2435
|
),
|
|
2436
2436
|
children: [
|
|
2437
|
-
/* @__PURE__ */ t("span", { className:
|
|
2437
|
+
/* @__PURE__ */ t("span", { className: h(
|
|
2438
2438
|
"flex-shrink-0 w-6 h-6 rounded-lg",
|
|
2439
2439
|
"bg-[var(--ash-accent)]/20 text-[var(--ash-accent)]",
|
|
2440
2440
|
"flex items-center justify-center",
|
|
@@ -2449,7 +2449,7 @@ function pr({ options: e, onSelect: n, className: r }) {
|
|
|
2449
2449
|
/* @__PURE__ */ t(
|
|
2450
2450
|
"svg",
|
|
2451
2451
|
{
|
|
2452
|
-
className:
|
|
2452
|
+
className: h(
|
|
2453
2453
|
"w-4 h-4 text-white/30 flex-shrink-0 mt-0.5",
|
|
2454
2454
|
"group-hover:text-[var(--ash-accent)] group-hover:translate-x-0.5",
|
|
2455
2455
|
"transition-all duration-200"
|
|
@@ -2487,15 +2487,15 @@ function gr({ actionType: e, className: n = "w-4 h-4" }) {
|
|
|
2487
2487
|
case "mcp_tool":
|
|
2488
2488
|
return /* @__PURE__ */ t(jt, { className: n });
|
|
2489
2489
|
case "todo_write":
|
|
2490
|
-
return /* @__PURE__ */ t(
|
|
2490
|
+
return /* @__PURE__ */ t(Ft, { className: n });
|
|
2491
2491
|
case "agent_tool":
|
|
2492
|
-
return /* @__PURE__ */ t(
|
|
2492
|
+
return /* @__PURE__ */ t(Ht, { className: n });
|
|
2493
2493
|
case "generic_tool":
|
|
2494
2494
|
default:
|
|
2495
2495
|
return /* @__PURE__ */ t(zt, { className: n });
|
|
2496
2496
|
}
|
|
2497
2497
|
}
|
|
2498
|
-
var
|
|
2498
|
+
var fn = {
|
|
2499
2499
|
slideUp: `
|
|
2500
2500
|
@keyframes ash-slide-up {
|
|
2501
2501
|
from { opacity: 0; transform: translateY(20px); }
|
|
@@ -2533,7 +2533,7 @@ var hn = {
|
|
|
2533
2533
|
}
|
|
2534
2534
|
`
|
|
2535
2535
|
};
|
|
2536
|
-
Object.values(
|
|
2536
|
+
Object.values(fn).join(`
|
|
2537
2537
|
`);
|
|
2538
2538
|
function xr(e) {
|
|
2539
2539
|
return e.action === "command_run";
|
|
@@ -2565,16 +2565,16 @@ function Tr(e) {
|
|
|
2565
2565
|
function _r(e) {
|
|
2566
2566
|
return e.action === "generic_tool";
|
|
2567
2567
|
}
|
|
2568
|
-
function
|
|
2568
|
+
function Ir(e) {
|
|
2569
2569
|
return e.type === "tool_call";
|
|
2570
2570
|
}
|
|
2571
|
-
function
|
|
2571
|
+
function Mr(e) {
|
|
2572
2572
|
return e.type === "error";
|
|
2573
2573
|
}
|
|
2574
2574
|
function je(e) {
|
|
2575
2575
|
const { id: n, role: r, content: s, createdAt: a, toolInvocations: i, reasoning: u } = e, d = a == null ? void 0 : a.toISOString();
|
|
2576
2576
|
if (i && i.length > 0) {
|
|
2577
|
-
const l = i[0],
|
|
2577
|
+
const l = i[0], N = {
|
|
2578
2578
|
id: l.toolCallId,
|
|
2579
2579
|
toolName: l.toolName,
|
|
2580
2580
|
actionType: {
|
|
@@ -2591,8 +2591,8 @@ function je(e) {
|
|
|
2591
2591
|
return {
|
|
2592
2592
|
id: n,
|
|
2593
2593
|
timestamp: d,
|
|
2594
|
-
entryType: { type: "tool_call", toolCall:
|
|
2595
|
-
content:
|
|
2594
|
+
entryType: { type: "tool_call", toolCall: N },
|
|
2595
|
+
content: N.summary
|
|
2596
2596
|
};
|
|
2597
2597
|
}
|
|
2598
2598
|
if (u)
|
|
@@ -2658,7 +2658,7 @@ function je(e) {
|
|
|
2658
2658
|
content: s
|
|
2659
2659
|
};
|
|
2660
2660
|
}
|
|
2661
|
-
function
|
|
2661
|
+
function pn(e) {
|
|
2662
2662
|
var r, s;
|
|
2663
2663
|
const n = [];
|
|
2664
2664
|
for (const a of e)
|
|
@@ -2729,7 +2729,7 @@ async function st(e, n) {
|
|
|
2729
2729
|
console.error("[middleware] onComplete error:", s);
|
|
2730
2730
|
}
|
|
2731
2731
|
}
|
|
2732
|
-
async function
|
|
2732
|
+
async function Te(e, n) {
|
|
2733
2733
|
for (const r of e)
|
|
2734
2734
|
if (r.onError)
|
|
2735
2735
|
try {
|
|
@@ -2738,7 +2738,7 @@ async function Ce(e, n) {
|
|
|
2738
2738
|
console.error("[middleware] onError error:", s);
|
|
2739
2739
|
}
|
|
2740
2740
|
}
|
|
2741
|
-
function
|
|
2741
|
+
function Sr(e) {
|
|
2742
2742
|
const {
|
|
2743
2743
|
createStream: n,
|
|
2744
2744
|
subscribeToSession: r,
|
|
@@ -2748,233 +2748,249 @@ function Ir(e) {
|
|
|
2748
2748
|
onSessionEnd: u,
|
|
2749
2749
|
onError: d,
|
|
2750
2750
|
onSandboxLog: l,
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
}, [L])
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
2751
|
+
canUseTool: N,
|
|
2752
|
+
resolveToolPermission: f,
|
|
2753
|
+
onReconnect: w,
|
|
2754
|
+
maxReconnectAttempts: I = 3,
|
|
2755
|
+
reconnectBaseDelay: A = 1e3,
|
|
2756
|
+
onBeforeSend: K,
|
|
2757
|
+
onEvent: J,
|
|
2758
|
+
middleware: y
|
|
2759
|
+
} = e, [D, U] = k(a), [j, X] = k([]), [ne, he] = k(!1), [xe, H] = k(!1), [ae, Q] = k(null), [L, de] = k(s || null), Z = z(null), F = z(""), B = z(null), G = z(/* @__PURE__ */ new Map()), ge = z(!1), re = z(0), me = z(0), fe = z(L), v = z([]), W = z(0);
|
|
2760
|
+
te(() => {
|
|
2761
|
+
fe.current = L;
|
|
2762
|
+
}, [L]), te(() => {
|
|
2763
|
+
v.current = j;
|
|
2764
|
+
}, [j]);
|
|
2765
|
+
const M = [...D, ...j], S = $((m) => {
|
|
2766
|
+
X([...m]);
|
|
2767
|
+
}, []), g = $(async (m) => {
|
|
2768
|
+
if (m.type !== "tool_permission" || !N || !m.requestId || !m.sessionId || !m.toolName) return;
|
|
2769
|
+
const O = {
|
|
2770
|
+
requestId: m.requestId,
|
|
2771
|
+
sessionId: m.sessionId,
|
|
2772
|
+
toolName: m.toolName,
|
|
2773
|
+
input: m.input
|
|
2774
|
+
}, R = await N(O);
|
|
2775
|
+
if (!f) {
|
|
2776
|
+
console.warn("[useAgentChat] resolveToolPermission not provided for tool permission response");
|
|
2777
|
+
return;
|
|
2778
|
+
}
|
|
2779
|
+
await f(O, R);
|
|
2780
|
+
}, [N, f]), x = $((m, O) => ({
|
|
2781
|
+
id: m,
|
|
2767
2782
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2768
2783
|
entryType: { type: "assistant_message" },
|
|
2769
|
-
content:
|
|
2770
|
-
}), []),
|
|
2771
|
-
|
|
2772
|
-
}, []),
|
|
2773
|
-
if (
|
|
2774
|
-
const
|
|
2775
|
-
isNaN(
|
|
2784
|
+
content: O
|
|
2785
|
+
}), []), _ = $(() => {
|
|
2786
|
+
F.current = "", B.current = null, G.current.clear(), ge.current = !1, X([]);
|
|
2787
|
+
}, []), q = $((m, O) => {
|
|
2788
|
+
if (m.id) {
|
|
2789
|
+
const E = parseInt(m.id, 10);
|
|
2790
|
+
isNaN(E) || (W.current = E);
|
|
2776
2791
|
}
|
|
2777
|
-
const
|
|
2778
|
-
switch (
|
|
2792
|
+
const R = [...O];
|
|
2793
|
+
switch (m.type) {
|
|
2779
2794
|
case "session_start":
|
|
2780
|
-
|
|
2795
|
+
m.sessionId && (de(m.sessionId), i == null || i(m.sessionId));
|
|
2781
2796
|
break;
|
|
2782
2797
|
case "text_delta":
|
|
2783
|
-
if (
|
|
2784
|
-
if (
|
|
2785
|
-
|
|
2798
|
+
if (m.delta)
|
|
2799
|
+
if (ge.current && B.current && (F.current = "", B.current = null, ge.current = !1), F.current += m.delta, !B.current)
|
|
2800
|
+
B.current = `text-${Date.now()}-${Math.random().toString(36).slice(2)}`, R.push(x(B.current, F.current));
|
|
2786
2801
|
else {
|
|
2787
|
-
const
|
|
2788
|
-
|
|
2802
|
+
const E = R.findIndex((P) => P.id === B.current);
|
|
2803
|
+
E !== -1 && (R[E] = x(B.current, F.current));
|
|
2789
2804
|
}
|
|
2790
2805
|
break;
|
|
2791
2806
|
case "tool_use":
|
|
2792
|
-
if (
|
|
2793
|
-
|
|
2794
|
-
const
|
|
2795
|
-
id:
|
|
2796
|
-
name:
|
|
2797
|
-
input:
|
|
2798
|
-
}),
|
|
2799
|
-
id:
|
|
2807
|
+
if (m.toolId && m.toolName) {
|
|
2808
|
+
F.current = "", B.current = null, ge.current = !0;
|
|
2809
|
+
const E = bt({
|
|
2810
|
+
id: m.toolId,
|
|
2811
|
+
name: m.toolName,
|
|
2812
|
+
input: m.input
|
|
2813
|
+
}), P = {
|
|
2814
|
+
id: m.toolId,
|
|
2800
2815
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2801
|
-
entryType: { type: "tool_call", toolCall:
|
|
2802
|
-
content:
|
|
2803
|
-
},
|
|
2804
|
-
|
|
2816
|
+
entryType: { type: "tool_call", toolCall: E },
|
|
2817
|
+
content: E.summary
|
|
2818
|
+
}, Y = R.length;
|
|
2819
|
+
R.push(P), G.current.set(m.toolId, { entryIndex: Y, toolCall: E });
|
|
2805
2820
|
}
|
|
2806
2821
|
break;
|
|
2807
2822
|
case "tool_result":
|
|
2808
|
-
if (
|
|
2809
|
-
const
|
|
2810
|
-
if (
|
|
2811
|
-
const
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
),
|
|
2816
|
-
|
|
2817
|
-
...
|
|
2818
|
-
entryType: { type: "tool_call", toolCall:
|
|
2819
|
-
}),
|
|
2823
|
+
if (m.toolId) {
|
|
2824
|
+
const E = G.current.get(m.toolId);
|
|
2825
|
+
if (E) {
|
|
2826
|
+
const P = kt(
|
|
2827
|
+
E.toolCall,
|
|
2828
|
+
m.toolResult,
|
|
2829
|
+
m.isError
|
|
2830
|
+
), Y = R[E.entryIndex];
|
|
2831
|
+
Y && Y.entryType.type === "tool_call" && (R[E.entryIndex] = {
|
|
2832
|
+
...Y,
|
|
2833
|
+
entryType: { type: "tool_call", toolCall: P }
|
|
2834
|
+
}), G.current.delete(m.toolId);
|
|
2820
2835
|
}
|
|
2821
2836
|
}
|
|
2822
2837
|
break;
|
|
2823
2838
|
case "text":
|
|
2824
|
-
|
|
2839
|
+
m.text && !F.current && (B.current = `text-${Date.now()}-${Math.random().toString(36).slice(2)}`, F.current = m.text, R.push(x(B.current, F.current)));
|
|
2825
2840
|
break;
|
|
2826
2841
|
case "message":
|
|
2827
|
-
if (
|
|
2828
|
-
const
|
|
2829
|
-
|
|
2842
|
+
if (m.content && !F.current) {
|
|
2843
|
+
const E = m.content, P = E == null ? void 0 : E.find((Y) => Y.type === "text");
|
|
2844
|
+
P != null && P.text && (B.current = `text-${Date.now()}-${Math.random().toString(36).slice(2)}`, F.current = P.text, R.push(x(B.current, F.current)));
|
|
2830
2845
|
}
|
|
2831
2846
|
break;
|
|
2832
2847
|
case "sandbox_log":
|
|
2833
|
-
|
|
2848
|
+
m.entry && (l == null || l(m.entry));
|
|
2834
2849
|
break;
|
|
2835
2850
|
case "error":
|
|
2836
|
-
|
|
2851
|
+
m.error && (Q(m.error), d == null || d(m.error), R.push({
|
|
2837
2852
|
id: `error-${Date.now()}-${Math.random().toString(36).slice(2)}`,
|
|
2838
2853
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2839
|
-
entryType: { type: "error", message:
|
|
2840
|
-
content:
|
|
2854
|
+
entryType: { type: "error", message: m.error, code: m.code },
|
|
2855
|
+
content: m.error
|
|
2841
2856
|
}));
|
|
2842
2857
|
break;
|
|
2843
2858
|
case "session_end":
|
|
2844
|
-
u == null || u(
|
|
2859
|
+
u == null || u(m.sessionId || L || "", m.status || "completed");
|
|
2845
2860
|
break;
|
|
2846
2861
|
case "complete":
|
|
2847
|
-
return
|
|
2862
|
+
return R.length > 0 && U((E) => [...E, ...R]), _(), [];
|
|
2848
2863
|
}
|
|
2849
|
-
return
|
|
2850
|
-
}, [
|
|
2851
|
-
var
|
|
2864
|
+
return R;
|
|
2865
|
+
}, [L, i, u, d, l, x, _]), ue = $(async (m, O) => {
|
|
2866
|
+
var Y, pe;
|
|
2852
2867
|
if (!r)
|
|
2853
2868
|
return !1;
|
|
2854
|
-
const
|
|
2855
|
-
if (
|
|
2856
|
-
return console.warn(`[useAgentChat] Max reconnection attempts (${
|
|
2857
|
-
|
|
2858
|
-
const
|
|
2859
|
-
console.log(`[useAgentChat] Reconnection attempt ${
|
|
2860
|
-
const
|
|
2861
|
-
|
|
2869
|
+
const R = re.current + 1;
|
|
2870
|
+
if (R > I)
|
|
2871
|
+
return console.warn(`[useAgentChat] Max reconnection attempts (${I}) exceeded`), !1;
|
|
2872
|
+
re.current = R, H(!0), w == null || w(R, m);
|
|
2873
|
+
const E = A * Math.pow(2, R - 1);
|
|
2874
|
+
console.log(`[useAgentChat] Reconnection attempt ${R}/${I} in ${E}ms`), await new Promise((V) => setTimeout(V, E));
|
|
2875
|
+
const P = new AbortController();
|
|
2876
|
+
Z.current = P;
|
|
2862
2877
|
try {
|
|
2863
|
-
const
|
|
2864
|
-
let
|
|
2865
|
-
for await (const
|
|
2866
|
-
if (
|
|
2867
|
-
if (
|
|
2868
|
-
return
|
|
2878
|
+
const V = r(m, P.signal);
|
|
2879
|
+
let ee = [...O];
|
|
2880
|
+
for await (const c of V) {
|
|
2881
|
+
if (P.signal.aborted) break;
|
|
2882
|
+
if (me.current++, await g(c), ee = q(c, ee), S(ee), c.type === "complete" || c.type === "session_end" || c.type === "error")
|
|
2883
|
+
return re.current = 0, H(!1), c.type === "complete" && ee.length > 0 && (U((p) => [...p, ...ee]), X([])), !0;
|
|
2869
2884
|
}
|
|
2870
|
-
return
|
|
2871
|
-
} catch (
|
|
2872
|
-
if ((
|
|
2873
|
-
return console.log("[useAgentChat] Reconnection stream interrupted, will retry..."),
|
|
2874
|
-
if (
|
|
2875
|
-
const
|
|
2876
|
-
console.error("[useAgentChat] Reconnection failed:",
|
|
2885
|
+
return re.current = 0, H(!1), ee.length > 0 && (U((c) => [...c, ...ee]), X([])), !0;
|
|
2886
|
+
} catch (V) {
|
|
2887
|
+
if ((V.name === "AbortError" || ((Y = V.message) == null ? void 0 : Y.includes("aborted")) || ((pe = V.message) == null ? void 0 : pe.includes("BodyStreamBuffer"))) && !P.signal.aborted)
|
|
2888
|
+
return console.log("[useAgentChat] Reconnection stream interrupted, will retry..."), H(!1), ue(m, v.current);
|
|
2889
|
+
if (H(!1), !P.signal.aborted) {
|
|
2890
|
+
const c = V instanceof Error ? V.message : "Reconnection failed";
|
|
2891
|
+
console.error("[useAgentChat] Reconnection failed:", c);
|
|
2877
2892
|
}
|
|
2878
2893
|
return !1;
|
|
2879
2894
|
}
|
|
2880
|
-
}, [r,
|
|
2881
|
-
var
|
|
2882
|
-
if (
|
|
2883
|
-
let
|
|
2884
|
-
if (
|
|
2895
|
+
}, [r, I, A, w, q, S, g]), oe = $(async (m) => {
|
|
2896
|
+
var ee, c;
|
|
2897
|
+
if (ne) return;
|
|
2898
|
+
let O = m, R = {}, E;
|
|
2899
|
+
if (K)
|
|
2885
2900
|
try {
|
|
2886
|
-
const
|
|
2887
|
-
prompt:
|
|
2888
|
-
sessionId:
|
|
2889
|
-
entries: [...
|
|
2901
|
+
const p = await K({
|
|
2902
|
+
prompt: m,
|
|
2903
|
+
sessionId: L,
|
|
2904
|
+
entries: [...D, ...j]
|
|
2890
2905
|
});
|
|
2891
|
-
if (
|
|
2906
|
+
if (p != null && p.cancel)
|
|
2892
2907
|
return;
|
|
2893
|
-
(
|
|
2894
|
-
} catch (
|
|
2895
|
-
const
|
|
2896
|
-
|
|
2908
|
+
(p == null ? void 0 : p.prompt) !== void 0 && (O = p.prompt), p != null && p.metadata && (R = p.metadata), p != null && p.sessionContext && (E = p.sessionContext);
|
|
2909
|
+
} catch (p) {
|
|
2910
|
+
const T = p instanceof Error ? p.message : "Send cancelled";
|
|
2911
|
+
Q(T), d == null || d(T);
|
|
2897
2912
|
return;
|
|
2898
2913
|
}
|
|
2899
|
-
if (
|
|
2900
|
-
const
|
|
2901
|
-
prompt:
|
|
2902
|
-
sessionId:
|
|
2903
|
-
metadata:
|
|
2904
|
-
sessionContext:
|
|
2905
|
-
}, { request:
|
|
2906
|
-
if (
|
|
2907
|
-
|
|
2914
|
+
if (y != null && y.length) {
|
|
2915
|
+
const p = {
|
|
2916
|
+
prompt: O,
|
|
2917
|
+
sessionId: L,
|
|
2918
|
+
metadata: R,
|
|
2919
|
+
sessionContext: E
|
|
2920
|
+
}, { request: T, error: b } = await nt(y, p);
|
|
2921
|
+
if (b) {
|
|
2922
|
+
Q(b), d == null || d(b), await Te(y, b);
|
|
2908
2923
|
return;
|
|
2909
2924
|
}
|
|
2910
|
-
|
|
2925
|
+
O = T.prompt, R = T.metadata || {}, E = T.sessionContext;
|
|
2911
2926
|
}
|
|
2912
|
-
|
|
2913
|
-
const
|
|
2927
|
+
he(!0), Q(null), re.current = 0, me.current = 0;
|
|
2928
|
+
const P = {
|
|
2914
2929
|
id: `user-${Date.now()}-${Math.random().toString(36).slice(2)}`,
|
|
2915
2930
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2916
2931
|
entryType: { type: "user_message" },
|
|
2917
|
-
content:
|
|
2932
|
+
content: m
|
|
2918
2933
|
};
|
|
2919
|
-
|
|
2920
|
-
const
|
|
2921
|
-
|
|
2922
|
-
let
|
|
2934
|
+
U((p) => [...p, P]), _();
|
|
2935
|
+
const Y = new AbortController();
|
|
2936
|
+
Z.current = Y;
|
|
2937
|
+
let pe = [], V = null;
|
|
2923
2938
|
try {
|
|
2924
|
-
const
|
|
2925
|
-
signal:
|
|
2926
|
-
metadata: Object.keys(
|
|
2927
|
-
sessionContext:
|
|
2939
|
+
const p = n(O, L || void 0, {
|
|
2940
|
+
signal: Y.signal,
|
|
2941
|
+
metadata: Object.keys(R).length > 0 ? R : void 0,
|
|
2942
|
+
sessionContext: E
|
|
2928
2943
|
});
|
|
2929
|
-
for await (const
|
|
2930
|
-
if (
|
|
2931
|
-
if (
|
|
2944
|
+
for await (const T of p) {
|
|
2945
|
+
if (Y.signal.aborted) break;
|
|
2946
|
+
if (me.current++, T.type === "session_start" && T.sessionId && (V = T.sessionId), J)
|
|
2932
2947
|
try {
|
|
2933
|
-
await
|
|
2934
|
-
} catch (
|
|
2935
|
-
console.error("[useAgentChat] onEvent error:",
|
|
2948
|
+
await J(T);
|
|
2949
|
+
} catch (C) {
|
|
2950
|
+
console.error("[useAgentChat] onEvent error:", C);
|
|
2936
2951
|
}
|
|
2937
|
-
|
|
2938
|
-
|
|
2952
|
+
await g(T);
|
|
2953
|
+
let b = T;
|
|
2954
|
+
y != null && y.length && (b = await rt(y, T)), b && (pe = q(b, pe), S(pe));
|
|
2939
2955
|
}
|
|
2940
|
-
|
|
2941
|
-
} catch (
|
|
2942
|
-
const
|
|
2943
|
-
if (
|
|
2944
|
-
const
|
|
2945
|
-
if (console.log(`[useAgentChat] Stream interrupted. sessionId=${
|
|
2946
|
-
if (console.log("[useAgentChat] Attempting auto-reconnection..."), await
|
|
2956
|
+
pe.length > 0 && (U((T) => [...T, ...pe]), X([])), re.current = 0, y != null && y.length && (V || fe.current) && await st(y, V || fe.current || "");
|
|
2957
|
+
} catch (p) {
|
|
2958
|
+
const T = p.name === "AbortError" || ((ee = p.message) == null ? void 0 : ee.includes("aborted")) || ((c = p.message) == null ? void 0 : c.includes("BodyStreamBuffer"));
|
|
2959
|
+
if (T && !Y.signal.aborted) {
|
|
2960
|
+
const b = fe.current, C = me.current > 0;
|
|
2961
|
+
if (console.log(`[useAgentChat] Stream interrupted. sessionId=${b}, events=${me.current}`), b && C && r) {
|
|
2962
|
+
if (console.log("[useAgentChat] Attempting auto-reconnection..."), await ue(b, v.current))
|
|
2947
2963
|
return;
|
|
2948
|
-
const
|
|
2949
|
-
|
|
2964
|
+
const ye = "Connection lost. Please try again.";
|
|
2965
|
+
Q(ye), d == null || d(ye), y != null && y.length && await Te(y, ye);
|
|
2950
2966
|
}
|
|
2951
|
-
} else if (!
|
|
2952
|
-
const
|
|
2953
|
-
|
|
2967
|
+
} else if (!T) {
|
|
2968
|
+
const b = p instanceof Error ? p.message : "Unknown error";
|
|
2969
|
+
Q(b), d == null || d(b), y != null && y.length && await Te(y, b);
|
|
2954
2970
|
}
|
|
2955
2971
|
} finally {
|
|
2956
|
-
|
|
2972
|
+
he(!1), H(!1), Z.current = null, _();
|
|
2957
2973
|
}
|
|
2958
|
-
}, [
|
|
2959
|
-
|
|
2960
|
-
}, [
|
|
2961
|
-
|
|
2962
|
-
}, [s,
|
|
2963
|
-
|
|
2964
|
-
}, [
|
|
2965
|
-
return
|
|
2966
|
-
|
|
2974
|
+
}, [ne, L, D, j, n, r, q, S, _, d, ue, K, J, y, g]), ie = $(() => {
|
|
2975
|
+
re.current = I + 1, H(!1), Z.current && Z.current.abort();
|
|
2976
|
+
}, [I]), le = $(() => {
|
|
2977
|
+
U([]), _(), de(s || null), Q(null), H(!1), re.current = 0, me.current = 0;
|
|
2978
|
+
}, [s, _]), se = $((m) => {
|
|
2979
|
+
_(), U(m);
|
|
2980
|
+
}, [_]);
|
|
2981
|
+
return te(() => () => {
|
|
2982
|
+
Z.current && Z.current.abort();
|
|
2967
2983
|
}, []), {
|
|
2968
|
-
entries:
|
|
2969
|
-
isStreaming:
|
|
2970
|
-
isReconnecting:
|
|
2971
|
-
error:
|
|
2972
|
-
sessionId:
|
|
2973
|
-
send:
|
|
2974
|
-
stop:
|
|
2975
|
-
clear:
|
|
2976
|
-
setEntries:
|
|
2977
|
-
lastSequence:
|
|
2984
|
+
entries: M,
|
|
2985
|
+
isStreaming: ne,
|
|
2986
|
+
isReconnecting: xe,
|
|
2987
|
+
error: ae,
|
|
2988
|
+
sessionId: L,
|
|
2989
|
+
send: oe,
|
|
2990
|
+
stop: ie,
|
|
2991
|
+
clear: le,
|
|
2992
|
+
setEntries: se,
|
|
2993
|
+
lastSequence: W.current
|
|
2978
2994
|
};
|
|
2979
2995
|
}
|
|
2980
2996
|
function Se() {
|
|
@@ -2987,184 +3003,200 @@ function Lr(e) {
|
|
|
2987
3003
|
initialSessionId: r,
|
|
2988
3004
|
initialMessages: s = [],
|
|
2989
3005
|
onToolCall: a,
|
|
2990
|
-
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
|
|
3006
|
+
canUseTool: i,
|
|
3007
|
+
resolveToolPermission: u,
|
|
3008
|
+
onFinish: d,
|
|
3009
|
+
onError: l,
|
|
3010
|
+
onSessionStart: N,
|
|
3011
|
+
maxReconnectAttempts: f = 3,
|
|
2994
3012
|
// reconnectBaseDelay = 1000, // TODO: implement reconnection support
|
|
2995
|
-
middleware:
|
|
2996
|
-
} = e, [
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
}, [
|
|
3000
|
-
const
|
|
3001
|
-
if (!
|
|
3002
|
-
|
|
3003
|
-
const
|
|
3004
|
-
|
|
3005
|
-
const
|
|
3006
|
-
return
|
|
3013
|
+
middleware: w
|
|
3014
|
+
} = e, [I, A] = k(s), [K, J] = k(!1), [y, D] = k(!1), [U, j] = k(void 0), [X, ne] = k(r || null), [he, xe] = k(""), H = z(null), ae = z(null), Q = z(0), L = z(X);
|
|
3015
|
+
te(() => {
|
|
3016
|
+
L.current = X;
|
|
3017
|
+
}, [X]);
|
|
3018
|
+
const de = pn(I), Z = $((v) => {
|
|
3019
|
+
if (!ae.current) return;
|
|
3020
|
+
ae.current = v(ae.current);
|
|
3021
|
+
const W = ae.current;
|
|
3022
|
+
A((M) => {
|
|
3023
|
+
const S = M.length - 1, g = M[S];
|
|
3024
|
+
return S >= 0 && g && W && g.id === W.id ? [...M.slice(0, S), W] : M;
|
|
3007
3025
|
});
|
|
3008
|
-
}, []),
|
|
3009
|
-
|
|
3010
|
-
|
|
3026
|
+
}, []), F = $(async (v) => {
|
|
3027
|
+
if (v.type !== "tool_permission" || !i || !v.requestId || !v.sessionId || !v.toolName) return;
|
|
3028
|
+
const W = {
|
|
3029
|
+
requestId: v.requestId,
|
|
3030
|
+
sessionId: v.sessionId,
|
|
3031
|
+
toolName: v.toolName,
|
|
3032
|
+
input: v.input
|
|
3033
|
+
}, M = await i(W);
|
|
3034
|
+
if (!u) {
|
|
3035
|
+
console.warn("[useChat] resolveToolPermission not provided for tool permission response");
|
|
3036
|
+
return;
|
|
3037
|
+
}
|
|
3038
|
+
await u(W, M);
|
|
3039
|
+
}, [i, u]), B = $((v) => {
|
|
3040
|
+
var W;
|
|
3041
|
+
switch (v.type) {
|
|
3011
3042
|
case "session_start":
|
|
3012
|
-
|
|
3043
|
+
v.sessionId && (ne(v.sessionId), N == null || N(v.sessionId));
|
|
3013
3044
|
break;
|
|
3014
3045
|
case "text_delta":
|
|
3015
|
-
|
|
3046
|
+
v.delta && Z((M) => ({
|
|
3016
3047
|
...M,
|
|
3017
|
-
content: M.content +
|
|
3048
|
+
content: M.content + v.delta
|
|
3018
3049
|
}));
|
|
3019
3050
|
break;
|
|
3020
3051
|
case "tool_use":
|
|
3021
|
-
if (
|
|
3052
|
+
if (v.toolId && v.toolName) {
|
|
3022
3053
|
const M = {
|
|
3023
3054
|
state: "call",
|
|
3024
|
-
toolCallId:
|
|
3025
|
-
toolName:
|
|
3026
|
-
args:
|
|
3055
|
+
toolCallId: v.toolId,
|
|
3056
|
+
toolName: v.toolName,
|
|
3057
|
+
args: v.input || {}
|
|
3027
3058
|
};
|
|
3028
|
-
|
|
3029
|
-
...
|
|
3030
|
-
toolInvocations: [...
|
|
3059
|
+
Z((S) => ({
|
|
3060
|
+
...S,
|
|
3061
|
+
toolInvocations: [...S.toolInvocations || [], M]
|
|
3031
3062
|
})), a == null || a({ toolCall: M });
|
|
3032
3063
|
}
|
|
3033
3064
|
break;
|
|
3034
3065
|
case "tool_result":
|
|
3035
|
-
|
|
3036
|
-
var
|
|
3066
|
+
v.toolId && Z((M) => {
|
|
3067
|
+
var S;
|
|
3037
3068
|
return {
|
|
3038
3069
|
...M,
|
|
3039
|
-
toolInvocations: (
|
|
3040
|
-
(
|
|
3070
|
+
toolInvocations: (S = M.toolInvocations) == null ? void 0 : S.map(
|
|
3071
|
+
(g) => g.toolCallId === v.toolId ? { ...g, state: "result", result: v.toolResult } : g
|
|
3041
3072
|
)
|
|
3042
3073
|
};
|
|
3043
3074
|
});
|
|
3044
3075
|
break;
|
|
3045
3076
|
case "text":
|
|
3046
|
-
|
|
3077
|
+
v.text && !((W = ae.current) != null && W.content) && Z((M) => ({
|
|
3047
3078
|
...M,
|
|
3048
|
-
content:
|
|
3079
|
+
content: v.text || ""
|
|
3049
3080
|
}));
|
|
3050
3081
|
break;
|
|
3051
3082
|
case "error":
|
|
3052
|
-
if (
|
|
3053
|
-
const M = new Error(
|
|
3054
|
-
|
|
3083
|
+
if (v.error) {
|
|
3084
|
+
const M = new Error(v.error);
|
|
3085
|
+
j(M), l == null || l(M);
|
|
3055
3086
|
}
|
|
3056
3087
|
break;
|
|
3057
3088
|
case "complete":
|
|
3058
|
-
|
|
3089
|
+
ae.current && (d == null || d(ae.current));
|
|
3059
3090
|
break;
|
|
3060
3091
|
}
|
|
3061
|
-
}, [
|
|
3062
|
-
if (
|
|
3063
|
-
const M = typeof
|
|
3092
|
+
}, [Z, a, d, l, N]), G = $(async (v, W) => {
|
|
3093
|
+
if (K) return null;
|
|
3094
|
+
const M = typeof v == "string" ? {
|
|
3064
3095
|
id: Se(),
|
|
3065
3096
|
role: "user",
|
|
3066
|
-
content:
|
|
3097
|
+
content: v,
|
|
3067
3098
|
createdAt: /* @__PURE__ */ new Date()
|
|
3068
3099
|
} : {
|
|
3069
|
-
id:
|
|
3070
|
-
role:
|
|
3071
|
-
content:
|
|
3072
|
-
toolInvocations:
|
|
3073
|
-
reasoning:
|
|
3100
|
+
id: v.id || Se(),
|
|
3101
|
+
role: v.role,
|
|
3102
|
+
content: v.content,
|
|
3103
|
+
toolInvocations: v.toolInvocations,
|
|
3104
|
+
reasoning: v.reasoning,
|
|
3074
3105
|
createdAt: /* @__PURE__ */ new Date()
|
|
3075
3106
|
};
|
|
3076
|
-
|
|
3077
|
-
const
|
|
3107
|
+
A((x) => [...x, M]), J(!0), j(void 0), Q.current = 0;
|
|
3108
|
+
const S = {
|
|
3078
3109
|
id: Se(),
|
|
3079
3110
|
role: "assistant",
|
|
3080
3111
|
content: "",
|
|
3081
3112
|
createdAt: /* @__PURE__ */ new Date()
|
|
3082
3113
|
};
|
|
3083
|
-
|
|
3084
|
-
const
|
|
3085
|
-
|
|
3114
|
+
ae.current = S, A((x) => [...x, S]);
|
|
3115
|
+
const g = new AbortController();
|
|
3116
|
+
H.current = g;
|
|
3086
3117
|
try {
|
|
3087
|
-
let
|
|
3088
|
-
if (
|
|
3089
|
-
const
|
|
3090
|
-
prompt:
|
|
3091
|
-
sessionId:
|
|
3092
|
-
metadata:
|
|
3093
|
-
}, { request:
|
|
3094
|
-
if (
|
|
3095
|
-
const
|
|
3096
|
-
return
|
|
3118
|
+
let x = M.content, _ = (W == null ? void 0 : W.body) || {};
|
|
3119
|
+
if (w != null && w.length) {
|
|
3120
|
+
const oe = {
|
|
3121
|
+
prompt: x,
|
|
3122
|
+
sessionId: L.current,
|
|
3123
|
+
metadata: _
|
|
3124
|
+
}, { request: ie, error: le } = await nt(w, oe);
|
|
3125
|
+
if (le) {
|
|
3126
|
+
const se = new Error(le);
|
|
3127
|
+
return j(se), l == null || l(se), J(!1), null;
|
|
3097
3128
|
}
|
|
3098
|
-
|
|
3129
|
+
x = ie.prompt, _ = ie.metadata || {};
|
|
3099
3130
|
}
|
|
3100
|
-
const
|
|
3101
|
-
signal:
|
|
3102
|
-
metadata: Object.keys(
|
|
3103
|
-
},
|
|
3104
|
-
for await (const
|
|
3105
|
-
if (
|
|
3106
|
-
|
|
3107
|
-
|
|
3131
|
+
const q = {
|
|
3132
|
+
signal: g.signal,
|
|
3133
|
+
metadata: Object.keys(_).length > 0 ? _ : void 0
|
|
3134
|
+
}, ue = n(x, L.current || void 0, q);
|
|
3135
|
+
for await (const oe of ue) {
|
|
3136
|
+
if (g.signal.aborted) break;
|
|
3137
|
+
await F(oe);
|
|
3138
|
+
let ie = oe;
|
|
3139
|
+
w != null && w.length && (ie = await rt(w, oe)), ie && B(ie);
|
|
3108
3140
|
}
|
|
3109
|
-
return
|
|
3110
|
-
} catch (
|
|
3111
|
-
if (!(
|
|
3112
|
-
const
|
|
3113
|
-
|
|
3141
|
+
return w != null && w.length && L.current && await st(w, L.current), S.id;
|
|
3142
|
+
} catch (x) {
|
|
3143
|
+
if (!(x.name === "AbortError")) {
|
|
3144
|
+
const q = x instanceof Error ? x : new Error(String(x));
|
|
3145
|
+
j(q), l == null || l(q), w != null && w.length && await Te(w, q.message);
|
|
3114
3146
|
}
|
|
3115
3147
|
return null;
|
|
3116
3148
|
} finally {
|
|
3117
|
-
|
|
3149
|
+
J(!1), D(!1), H.current = null, ae.current = null;
|
|
3118
3150
|
}
|
|
3119
|
-
}, [
|
|
3120
|
-
|
|
3121
|
-
}, [
|
|
3151
|
+
}, [K, n, B, w, l, F]), ge = $(() => {
|
|
3152
|
+
Q.current = f + 1, D(!1), H.current && H.current.abort();
|
|
3153
|
+
}, [f]), re = $(async () => {
|
|
3122
3154
|
var M;
|
|
3123
|
-
let
|
|
3124
|
-
for (let
|
|
3125
|
-
if (((M =
|
|
3126
|
-
|
|
3155
|
+
let v = -1;
|
|
3156
|
+
for (let S = I.length - 1; S >= 0; S--)
|
|
3157
|
+
if (((M = I[S]) == null ? void 0 : M.role) === "user") {
|
|
3158
|
+
v = S;
|
|
3127
3159
|
break;
|
|
3128
3160
|
}
|
|
3129
|
-
if (
|
|
3130
|
-
const
|
|
3131
|
-
return
|
|
3132
|
-
}, [
|
|
3133
|
-
|
|
3134
|
-
}, []),
|
|
3135
|
-
if (
|
|
3136
|
-
const M =
|
|
3137
|
-
|
|
3138
|
-
}, [
|
|
3139
|
-
return
|
|
3140
|
-
|
|
3161
|
+
if (v === -1) return null;
|
|
3162
|
+
const W = I[v];
|
|
3163
|
+
return W ? (A(I.slice(0, v + 1)), G(W)) : null;
|
|
3164
|
+
}, [I, G]), me = $((v) => {
|
|
3165
|
+
xe(v.target.value);
|
|
3166
|
+
}, []), fe = $((v, W) => {
|
|
3167
|
+
if (v == null || v.preventDefault(), !he.trim()) return;
|
|
3168
|
+
const M = he;
|
|
3169
|
+
xe(""), G(M, W);
|
|
3170
|
+
}, [he, G]);
|
|
3171
|
+
return te(() => () => {
|
|
3172
|
+
H.current && H.current.abort();
|
|
3141
3173
|
}, []), {
|
|
3142
|
-
messages:
|
|
3143
|
-
isLoading:
|
|
3144
|
-
error:
|
|
3145
|
-
sessionId:
|
|
3146
|
-
append:
|
|
3147
|
-
stop:
|
|
3148
|
-
setMessages:
|
|
3149
|
-
reload:
|
|
3150
|
-
input:
|
|
3151
|
-
setInput:
|
|
3152
|
-
handleInputChange:
|
|
3153
|
-
handleSubmit:
|
|
3154
|
-
isReconnecting:
|
|
3155
|
-
entries:
|
|
3174
|
+
messages: I,
|
|
3175
|
+
isLoading: K,
|
|
3176
|
+
error: U,
|
|
3177
|
+
sessionId: X,
|
|
3178
|
+
append: G,
|
|
3179
|
+
stop: ge,
|
|
3180
|
+
setMessages: A,
|
|
3181
|
+
reload: re,
|
|
3182
|
+
input: he,
|
|
3183
|
+
setInput: xe,
|
|
3184
|
+
handleInputChange: me,
|
|
3185
|
+
handleSubmit: fe,
|
|
3186
|
+
isReconnecting: y,
|
|
3187
|
+
entries: de
|
|
3156
3188
|
};
|
|
3157
3189
|
}
|
|
3158
|
-
function
|
|
3190
|
+
function gn({
|
|
3159
3191
|
messages: e,
|
|
3160
3192
|
loading: n,
|
|
3161
3193
|
streamingContent: r
|
|
3162
3194
|
}) {
|
|
3163
|
-
const s =
|
|
3164
|
-
return
|
|
3195
|
+
const s = z(null), a = z(null);
|
|
3196
|
+
return te(() => {
|
|
3165
3197
|
a.current && a.current.scrollIntoView({ behavior: "smooth", block: "end" });
|
|
3166
3198
|
}, [e, r, n]), /* @__PURE__ */ o("div", { ref: s, className: "flex-1 overflow-y-auto p-4 space-y-4", children: [
|
|
3167
|
-
e.map((i) => /* @__PURE__ */ t(
|
|
3199
|
+
e.map((i) => /* @__PURE__ */ t(xn, { message: i }, i.id)),
|
|
3168
3200
|
r && /* @__PURE__ */ t("div", { className: "flex justify-start animate-fade-in", children: /* @__PURE__ */ o("div", { className: "max-w-[80%] card-glass rounded-2xl p-4", children: [
|
|
3169
3201
|
/* @__PURE__ */ t("div", { className: "text-xs text-[#ccff00] mb-2 font-medium", children: "Assistant" }),
|
|
3170
3202
|
/* @__PURE__ */ t("div", { className: "message-content prose prose-sm prose-invert max-w-none whitespace-pre-wrap", children: r })
|
|
@@ -3177,7 +3209,7 @@ function fn({
|
|
|
3177
3209
|
/* @__PURE__ */ t("div", { ref: a })
|
|
3178
3210
|
] });
|
|
3179
3211
|
}
|
|
3180
|
-
function
|
|
3212
|
+
function xn({ message: e }) {
|
|
3181
3213
|
const n = e.role === "user", r = e.role === "tool";
|
|
3182
3214
|
return /* @__PURE__ */ t("div", { className: `flex ${n ? "justify-end" : "justify-start"} animate-fade-in`, children: /* @__PURE__ */ o(
|
|
3183
3215
|
"div",
|
|
@@ -3191,13 +3223,13 @@ function pn({ message: e }) {
|
|
|
3191
3223
|
children: e.role.charAt(0).toUpperCase() + e.role.slice(1)
|
|
3192
3224
|
}
|
|
3193
3225
|
),
|
|
3194
|
-
/* @__PURE__ */ t("div", { className: `message-content ${n ? "" : "prose prose-sm prose-invert max-w-none"}`, children: e.content.map((a, i) => /* @__PURE__ */ t(
|
|
3226
|
+
/* @__PURE__ */ t("div", { className: `message-content ${n ? "" : "prose prose-sm prose-invert max-w-none"}`, children: e.content.map((a, i) => /* @__PURE__ */ t(vn, { block: a, isUser: n }, i)) }),
|
|
3195
3227
|
/* @__PURE__ */ t("div", { className: `text-xs mt-3 ${n ? "text-black/40" : "text-white/40"}`, children: new Date(e.createdAt).toLocaleTimeString() })
|
|
3196
3228
|
]
|
|
3197
3229
|
}
|
|
3198
3230
|
) });
|
|
3199
3231
|
}
|
|
3200
|
-
function
|
|
3232
|
+
function vn({
|
|
3201
3233
|
block: e,
|
|
3202
3234
|
isUser: n
|
|
3203
3235
|
}) {
|
|
@@ -3216,11 +3248,11 @@ function gn({
|
|
|
3216
3248
|
/* @__PURE__ */ t("pre", { className: "text-sm overflow-x-auto text-emerald-300/80 font-mono", children: typeof e.content == "string" ? e.content : JSON.stringify(e.content, null, 2) })
|
|
3217
3249
|
] }) : null;
|
|
3218
3250
|
}
|
|
3219
|
-
const
|
|
3251
|
+
const wn = 5e3;
|
|
3220
3252
|
function ze(e) {
|
|
3221
3253
|
return e < 1024 ? `${e} B` : e < 1024 * 1024 ? `${(e / 1024).toFixed(1)} KB` : `${(e / (1024 * 1024)).toFixed(1)} MB`;
|
|
3222
3254
|
}
|
|
3223
|
-
function
|
|
3255
|
+
function yn({
|
|
3224
3256
|
onSend: e,
|
|
3225
3257
|
disabled: n,
|
|
3226
3258
|
loading: r,
|
|
@@ -3230,136 +3262,136 @@ function vn({
|
|
|
3230
3262
|
sessionContext: u = "",
|
|
3231
3263
|
onSessionContextChange: d,
|
|
3232
3264
|
envVars: l = {},
|
|
3233
|
-
onEnvVarsChange:
|
|
3234
|
-
enableFileUpload:
|
|
3235
|
-
maxFileSize:
|
|
3265
|
+
onEnvVarsChange: N,
|
|
3266
|
+
enableFileUpload: f = !0,
|
|
3267
|
+
maxFileSize: w = 100 * 1024 * 1024,
|
|
3236
3268
|
// 100MB
|
|
3237
|
-
maxFiles:
|
|
3238
|
-
onStop:
|
|
3239
|
-
canStop:
|
|
3240
|
-
enableLongTextConversion:
|
|
3241
|
-
longTextThreshold:
|
|
3269
|
+
maxFiles: I = 10,
|
|
3270
|
+
onStop: A,
|
|
3271
|
+
canStop: K = !1,
|
|
3272
|
+
enableLongTextConversion: J = !0,
|
|
3273
|
+
longTextThreshold: y = wn
|
|
3242
3274
|
}) {
|
|
3243
|
-
const [
|
|
3244
|
-
const
|
|
3245
|
-
let
|
|
3246
|
-
for (let
|
|
3247
|
-
|
|
3248
|
-
return btoa(
|
|
3249
|
-
}, []),
|
|
3250
|
-
if (!
|
|
3251
|
-
const
|
|
3252
|
-
if (
|
|
3253
|
-
if (c.preventDefault(),
|
|
3254
|
-
console.warn(`Cannot convert text to attachment: maximum ${
|
|
3275
|
+
const [D, U] = k(""), [j, X] = k(!1), [ne, he] = k(!1), [xe, H] = k(""), [ae, Q] = k(""), [L, de] = k([]), [Z, F] = k(!1), [B, G] = k(null), [ge, re] = k(/* @__PURE__ */ new Map()), me = z(0), fe = z(null), v = z(null), W = z(null), M = $((c) => {
|
|
3276
|
+
const T = new TextEncoder().encode(c);
|
|
3277
|
+
let b = "";
|
|
3278
|
+
for (let C = 0; C < T.length; C++)
|
|
3279
|
+
b += String.fromCharCode(T[C]);
|
|
3280
|
+
return btoa(b);
|
|
3281
|
+
}, []), S = $((c) => {
|
|
3282
|
+
if (!J || !f) return;
|
|
3283
|
+
const p = c.clipboardData.getData("text/plain");
|
|
3284
|
+
if (p.length > y) {
|
|
3285
|
+
if (c.preventDefault(), L.length >= I) {
|
|
3286
|
+
console.warn(`Cannot convert text to attachment: maximum ${I} files reached`);
|
|
3255
3287
|
return;
|
|
3256
3288
|
}
|
|
3257
|
-
const
|
|
3289
|
+
const T = p.split(`
|
|
3258
3290
|
`).length;
|
|
3259
|
-
|
|
3260
|
-
const
|
|
3261
|
-
filename:
|
|
3262
|
-
content:
|
|
3291
|
+
me.current += 1;
|
|
3292
|
+
const b = me.current, C = `pasted-text-${b}-${Date.now()}.txt`, ce = M(p), it = new TextEncoder().encode(p).length, lt = {
|
|
3293
|
+
filename: C,
|
|
3294
|
+
content: ce,
|
|
3263
3295
|
mimeType: "text/plain",
|
|
3264
3296
|
size: it
|
|
3265
3297
|
};
|
|
3266
|
-
|
|
3267
|
-
const Ae = new Map(
|
|
3268
|
-
return Ae.set(
|
|
3269
|
-
}),
|
|
3270
|
-
originalLength:
|
|
3271
|
-
filename:
|
|
3272
|
-
preview:
|
|
3273
|
-
lineCount:
|
|
3298
|
+
re((Ie) => {
|
|
3299
|
+
const Ae = new Map(Ie);
|
|
3300
|
+
return Ae.set(C, { number: b, lineCount: T }), Ae;
|
|
3301
|
+
}), de((Ie) => [...Ie, lt]), G({
|
|
3302
|
+
originalLength: p.length,
|
|
3303
|
+
filename: C,
|
|
3304
|
+
preview: p.slice(0, 100) + (p.length > 100 ? "..." : ""),
|
|
3305
|
+
lineCount: T
|
|
3274
3306
|
}), setTimeout(() => {
|
|
3275
|
-
|
|
3307
|
+
G(null);
|
|
3276
3308
|
}, 5e3);
|
|
3277
3309
|
}
|
|
3278
|
-
}, [
|
|
3279
|
-
const c =
|
|
3280
|
-
(c ||
|
|
3281
|
-
},
|
|
3282
|
-
c.key === "Enter" && !c.shiftKey && (c.preventDefault(),
|
|
3283
|
-
},
|
|
3284
|
-
const c =
|
|
3310
|
+
}, [J, f, y, L.length, I, M]), g = () => {
|
|
3311
|
+
const c = D.trim();
|
|
3312
|
+
(c || L.length > 0) && !n && (e(c || "(files attached)", L.length > 0 ? L : void 0), U(""), de([]), re(/* @__PURE__ */ new Map()), fe.current && (fe.current.style.height = "auto"));
|
|
3313
|
+
}, x = (c) => {
|
|
3314
|
+
c.key === "Enter" && !c.shiftKey && (c.preventDefault(), g());
|
|
3315
|
+
}, _ = () => {
|
|
3316
|
+
const c = fe.current;
|
|
3285
3317
|
c && (c.style.height = "auto", c.style.height = `${Math.min(c.scrollHeight, 200)}px`);
|
|
3286
|
-
},
|
|
3318
|
+
}, q = async (c) => {
|
|
3287
3319
|
if (!c) return;
|
|
3288
|
-
const
|
|
3289
|
-
for (let
|
|
3290
|
-
const
|
|
3291
|
-
if (
|
|
3292
|
-
console.warn(`File ${
|
|
3320
|
+
const p = [], T = L.length;
|
|
3321
|
+
for (let b = 0; b < c.length && T + p.length < I; b++) {
|
|
3322
|
+
const C = c[b];
|
|
3323
|
+
if (C.size > w) {
|
|
3324
|
+
console.warn(`File ${C.name} exceeds maximum size of ${ze(w)}`);
|
|
3293
3325
|
continue;
|
|
3294
3326
|
}
|
|
3295
3327
|
try {
|
|
3296
|
-
const
|
|
3297
|
-
|
|
3298
|
-
filename:
|
|
3299
|
-
content:
|
|
3300
|
-
mimeType:
|
|
3301
|
-
size:
|
|
3328
|
+
const ce = await ue(C);
|
|
3329
|
+
p.push({
|
|
3330
|
+
filename: C.name,
|
|
3331
|
+
content: ce,
|
|
3332
|
+
mimeType: C.type || "application/octet-stream",
|
|
3333
|
+
size: C.size
|
|
3302
3334
|
});
|
|
3303
|
-
} catch (
|
|
3304
|
-
console.error(`Failed to read file ${
|
|
3335
|
+
} catch (ce) {
|
|
3336
|
+
console.error(`Failed to read file ${C.name}:`, ce);
|
|
3305
3337
|
}
|
|
3306
3338
|
}
|
|
3307
|
-
|
|
3308
|
-
},
|
|
3309
|
-
const
|
|
3310
|
-
|
|
3311
|
-
const
|
|
3312
|
-
|
|
3313
|
-
},
|
|
3314
|
-
}),
|
|
3315
|
-
|
|
3316
|
-
},
|
|
3317
|
-
c.preventDefault(),
|
|
3318
|
-
},
|
|
3319
|
-
c.preventDefault(),
|
|
3320
|
-
},
|
|
3321
|
-
c.preventDefault(),
|
|
3322
|
-
},
|
|
3323
|
-
const
|
|
3324
|
-
|
|
3325
|
-
const
|
|
3326
|
-
return
|
|
3327
|
-
}),
|
|
3328
|
-
},
|
|
3329
|
-
r ||
|
|
3330
|
-
const
|
|
3331
|
-
const c =
|
|
3332
|
-
c &&
|
|
3333
|
-
},
|
|
3334
|
-
if (
|
|
3335
|
-
const
|
|
3336
|
-
delete
|
|
3339
|
+
p.length > 0 && de((b) => [...b, ...p]);
|
|
3340
|
+
}, ue = (c) => new Promise((p, T) => {
|
|
3341
|
+
const b = new FileReader();
|
|
3342
|
+
b.onload = () => {
|
|
3343
|
+
const ce = b.result.split(",")[1];
|
|
3344
|
+
p(ce || "");
|
|
3345
|
+
}, b.onerror = () => T(b.error), b.readAsDataURL(c);
|
|
3346
|
+
}), oe = (c) => {
|
|
3347
|
+
q(c.target.files), W.current && (W.current.value = "");
|
|
3348
|
+
}, ie = (c) => {
|
|
3349
|
+
c.preventDefault(), f && !n && F(!0);
|
|
3350
|
+
}, le = (c) => {
|
|
3351
|
+
c.preventDefault(), F(!1);
|
|
3352
|
+
}, se = (c) => {
|
|
3353
|
+
c.preventDefault(), F(!1), f && !n && q(c.dataTransfer.files);
|
|
3354
|
+
}, m = (c) => {
|
|
3355
|
+
const p = L[c];
|
|
3356
|
+
p && ge.has(p.filename) && re((T) => {
|
|
3357
|
+
const b = new Map(T);
|
|
3358
|
+
return b.delete(p.filename), b;
|
|
3359
|
+
}), de((T) => T.filter((b, C) => C !== c));
|
|
3360
|
+
}, O = a.length > 0;
|
|
3361
|
+
r || O && `${a.length}`;
|
|
3362
|
+
const R = u.trim().length > 0, E = Object.keys(l).length > 0, P = !n && (D.trim() || L.length > 0), Y = () => {
|
|
3363
|
+
const c = xe.trim(), p = ae.trim();
|
|
3364
|
+
c && N && (N({ ...l, [c]: p }), H(""), Q(""));
|
|
3365
|
+
}, pe = (c) => {
|
|
3366
|
+
if (N) {
|
|
3367
|
+
const p = { ...l };
|
|
3368
|
+
delete p[c], N(p);
|
|
3337
3369
|
}
|
|
3338
|
-
},
|
|
3339
|
-
c.key === "Enter" && (c.preventDefault(),
|
|
3370
|
+
}, V = (c) => {
|
|
3371
|
+
c.key === "Enter" && (c.preventDefault(), Y());
|
|
3340
3372
|
};
|
|
3341
3373
|
return /* @__PURE__ */ o(
|
|
3342
3374
|
"div",
|
|
3343
3375
|
{
|
|
3344
|
-
className: `border-t border-white/10 p-3 sm:p-4 glass-panel relative ${
|
|
3345
|
-
onDragOver:
|
|
3346
|
-
onDragLeave:
|
|
3347
|
-
onDrop:
|
|
3376
|
+
className: `border-t border-white/10 p-3 sm:p-4 glass-panel relative ${Z ? "bg-[#ccff00]/5" : ""}`,
|
|
3377
|
+
onDragOver: ie,
|
|
3378
|
+
onDragLeave: le,
|
|
3379
|
+
onDrop: se,
|
|
3348
3380
|
children: [
|
|
3349
|
-
|
|
3381
|
+
Z && f && /* @__PURE__ */ t("div", { className: "absolute inset-0 bg-[#ccff00]/10 border-2 border-dashed border-[#ccff00]/50 rounded-xl flex items-center justify-center z-10 pointer-events-none", children: /* @__PURE__ */ t("div", { className: "text-[#ccff00] font-medium", children: "Drop files here" }) }),
|
|
3350
3382
|
d && /* @__PURE__ */ o("div", { className: "mb-3", children: [
|
|
3351
3383
|
/* @__PURE__ */ o(
|
|
3352
3384
|
"button",
|
|
3353
3385
|
{
|
|
3354
3386
|
type: "button",
|
|
3355
|
-
onClick: () =>
|
|
3387
|
+
onClick: () => X(!j),
|
|
3356
3388
|
className: "flex items-center gap-2 text-xs font-medium text-white/50 hover:text-white/80 transition-colors",
|
|
3357
3389
|
children: [
|
|
3358
3390
|
/* @__PURE__ */ t(
|
|
3359
3391
|
"svg",
|
|
3360
3392
|
{
|
|
3361
3393
|
xmlns: "http://www.w3.org/2000/svg",
|
|
3362
|
-
className: `h-3 w-3 transition-transform ${
|
|
3394
|
+
className: `h-3 w-3 transition-transform ${j ? "rotate-90" : ""}`,
|
|
3363
3395
|
viewBox: "0 0 20 20",
|
|
3364
3396
|
fill: "currentColor",
|
|
3365
3397
|
children: /* @__PURE__ */ t(
|
|
@@ -3373,19 +3405,19 @@ function vn({
|
|
|
3373
3405
|
}
|
|
3374
3406
|
),
|
|
3375
3407
|
/* @__PURE__ */ t("span", { className: "uppercase tracking-wide", children: "Session Context" }),
|
|
3376
|
-
|
|
3408
|
+
R && !j && /* @__PURE__ */ t("span", { className: "badge badge-accent", children: "Active" })
|
|
3377
3409
|
]
|
|
3378
3410
|
}
|
|
3379
3411
|
),
|
|
3380
|
-
|
|
3412
|
+
j && /* @__PURE__ */ o("div", { className: "mt-2", children: [
|
|
3381
3413
|
/* @__PURE__ */ t(
|
|
3382
3414
|
"textarea",
|
|
3383
3415
|
{
|
|
3384
|
-
ref:
|
|
3416
|
+
ref: v,
|
|
3385
3417
|
value: u,
|
|
3386
3418
|
onChange: (c) => d(c.target.value),
|
|
3387
3419
|
onInput: () => {
|
|
3388
|
-
const c =
|
|
3420
|
+
const c = v.current;
|
|
3389
3421
|
c && (c.style.height = "auto", c.style.height = `${Math.min(c.scrollHeight, 150)}px`);
|
|
3390
3422
|
},
|
|
3391
3423
|
placeholder: "Add context that will be injected into every request (e.g., current page, user selection, etc.)",
|
|
@@ -3396,19 +3428,19 @@ function vn({
|
|
|
3396
3428
|
/* @__PURE__ */ t("p", { className: "text-xs text-white/40 mt-1", children: "This context is appended to the system prompt for each message sent." })
|
|
3397
3429
|
] })
|
|
3398
3430
|
] }),
|
|
3399
|
-
|
|
3431
|
+
N && /* @__PURE__ */ o("div", { className: "mb-3", children: [
|
|
3400
3432
|
/* @__PURE__ */ o(
|
|
3401
3433
|
"button",
|
|
3402
3434
|
{
|
|
3403
3435
|
type: "button",
|
|
3404
|
-
onClick: () =>
|
|
3436
|
+
onClick: () => he(!ne),
|
|
3405
3437
|
className: "flex items-center gap-2 text-xs font-medium text-white/50 hover:text-white/80 transition-colors",
|
|
3406
3438
|
children: [
|
|
3407
3439
|
/* @__PURE__ */ t(
|
|
3408
3440
|
"svg",
|
|
3409
3441
|
{
|
|
3410
3442
|
xmlns: "http://www.w3.org/2000/svg",
|
|
3411
|
-
className: `h-3 w-3 transition-transform ${
|
|
3443
|
+
className: `h-3 w-3 transition-transform ${ne ? "rotate-90" : ""}`,
|
|
3412
3444
|
viewBox: "0 0 20 20",
|
|
3413
3445
|
fill: "currentColor",
|
|
3414
3446
|
children: /* @__PURE__ */ t(
|
|
@@ -3422,23 +3454,23 @@ function vn({
|
|
|
3422
3454
|
}
|
|
3423
3455
|
),
|
|
3424
3456
|
/* @__PURE__ */ t("span", { className: "uppercase tracking-wide", children: "Environment Variables" }),
|
|
3425
|
-
|
|
3457
|
+
E && !ne && /* @__PURE__ */ t("span", { className: "badge badge-accent", children: Object.keys(l).length })
|
|
3426
3458
|
]
|
|
3427
3459
|
}
|
|
3428
3460
|
),
|
|
3429
|
-
|
|
3430
|
-
Object.entries(l).map(([c,
|
|
3461
|
+
ne && /* @__PURE__ */ o("div", { className: "mt-2 space-y-2", children: [
|
|
3462
|
+
Object.entries(l).map(([c, p]) => /* @__PURE__ */ o(
|
|
3431
3463
|
"div",
|
|
3432
3464
|
{
|
|
3433
3465
|
className: "flex items-center gap-2 bg-white/5 border border-white/10 rounded-xl px-3 py-2 text-sm",
|
|
3434
3466
|
children: [
|
|
3435
3467
|
/* @__PURE__ */ t("span", { className: "text-[#ccff00] font-mono font-medium", children: c }),
|
|
3436
3468
|
/* @__PURE__ */ t("span", { className: "text-white/40", children: "=" }),
|
|
3437
|
-
/* @__PURE__ */ t("span", { className: "text-white/70 font-mono flex-1 truncate", children:
|
|
3469
|
+
/* @__PURE__ */ t("span", { className: "text-white/70 font-mono flex-1 truncate", children: p || "(empty)" }),
|
|
3438
3470
|
/* @__PURE__ */ t(
|
|
3439
3471
|
"button",
|
|
3440
3472
|
{
|
|
3441
|
-
onClick: () =>
|
|
3473
|
+
onClick: () => pe(c),
|
|
3442
3474
|
className: "text-white/40 hover:text-red-400 transition-colors",
|
|
3443
3475
|
title: "Remove variable",
|
|
3444
3476
|
children: /* @__PURE__ */ t(
|
|
@@ -3469,9 +3501,9 @@ function vn({
|
|
|
3469
3501
|
"input",
|
|
3470
3502
|
{
|
|
3471
3503
|
type: "text",
|
|
3472
|
-
value:
|
|
3473
|
-
onChange: (c) =>
|
|
3474
|
-
onKeyDown:
|
|
3504
|
+
value: xe,
|
|
3505
|
+
onChange: (c) => H(c.target.value.toUpperCase().replace(/[^A-Z0-9_]/g, "")),
|
|
3506
|
+
onKeyDown: V,
|
|
3475
3507
|
placeholder: "KEY",
|
|
3476
3508
|
className: "input-glass text-sm font-mono flex-1 min-w-0 py-2"
|
|
3477
3509
|
}
|
|
@@ -3481,9 +3513,9 @@ function vn({
|
|
|
3481
3513
|
"input",
|
|
3482
3514
|
{
|
|
3483
3515
|
type: "text",
|
|
3484
|
-
value:
|
|
3485
|
-
onChange: (c) =>
|
|
3486
|
-
onKeyDown:
|
|
3516
|
+
value: ae,
|
|
3517
|
+
onChange: (c) => Q(c.target.value),
|
|
3518
|
+
onKeyDown: V,
|
|
3487
3519
|
placeholder: "value",
|
|
3488
3520
|
className: "input-glass text-sm font-mono flex-[2] min-w-0 py-2"
|
|
3489
3521
|
}
|
|
@@ -3491,8 +3523,8 @@ function vn({
|
|
|
3491
3523
|
/* @__PURE__ */ t(
|
|
3492
3524
|
"button",
|
|
3493
3525
|
{
|
|
3494
|
-
onClick:
|
|
3495
|
-
disabled: !
|
|
3526
|
+
onClick: Y,
|
|
3527
|
+
disabled: !xe.trim(),
|
|
3496
3528
|
className: "px-3 py-2 text-sm bg-[#ccff00]/20 hover:bg-[#ccff00]/30 text-[#ccff00] rounded-xl transition-all duration-300 disabled:opacity-30 disabled:cursor-not-allowed",
|
|
3497
3529
|
children: "Add"
|
|
3498
3530
|
}
|
|
@@ -3501,7 +3533,7 @@ function vn({
|
|
|
3501
3533
|
/* @__PURE__ */ t("p", { className: "text-xs text-white/40", children: "These environment variables will be available in the sandbox for new sessions." })
|
|
3502
3534
|
] })
|
|
3503
3535
|
] }),
|
|
3504
|
-
|
|
3536
|
+
B && /* @__PURE__ */ t("div", { className: "mb-3 p-3 bg-blue-500/10 border border-blue-500/30 rounded-xl", children: /* @__PURE__ */ o("div", { className: "flex items-start justify-between gap-3", children: [
|
|
3505
3537
|
/* @__PURE__ */ o("div", { className: "flex items-start gap-2 min-w-0", children: [
|
|
3506
3538
|
/* @__PURE__ */ t(
|
|
3507
3539
|
"svg",
|
|
@@ -3525,18 +3557,18 @@ function vn({
|
|
|
3525
3557
|
/* @__PURE__ */ o("div", { className: "min-w-0", children: [
|
|
3526
3558
|
/* @__PURE__ */ t("p", { className: "text-sm text-blue-200 font-medium", children: "Long text converted to attachment" }),
|
|
3527
3559
|
/* @__PURE__ */ o("p", { className: "text-xs text-blue-300/70 mt-1", children: [
|
|
3528
|
-
|
|
3560
|
+
B.originalLength.toLocaleString(),
|
|
3529
3561
|
" characters (",
|
|
3530
|
-
|
|
3562
|
+
B.lineCount,
|
|
3531
3563
|
" lines) saved as text attachment"
|
|
3532
3564
|
] }),
|
|
3533
|
-
/* @__PURE__ */ t("p", { className: "text-xs text-white/50 mt-1 truncate font-mono", children:
|
|
3565
|
+
/* @__PURE__ */ t("p", { className: "text-xs text-white/50 mt-1 truncate font-mono", children: B.preview })
|
|
3534
3566
|
] })
|
|
3535
3567
|
] }),
|
|
3536
3568
|
/* @__PURE__ */ t(
|
|
3537
3569
|
"button",
|
|
3538
3570
|
{
|
|
3539
|
-
onClick: () =>
|
|
3571
|
+
onClick: () => G(null),
|
|
3540
3572
|
className: "text-blue-400/70 hover:text-blue-300 transition-colors shrink-0",
|
|
3541
3573
|
title: "Dismiss",
|
|
3542
3574
|
children: /* @__PURE__ */ t(
|
|
@@ -3559,20 +3591,20 @@ function vn({
|
|
|
3559
3591
|
}
|
|
3560
3592
|
)
|
|
3561
3593
|
] }) }),
|
|
3562
|
-
|
|
3594
|
+
L.length > 0 && /* @__PURE__ */ o("div", { className: "mb-3 space-y-2", children: [
|
|
3563
3595
|
/* @__PURE__ */ o("div", { className: "text-xs font-medium text-white/50 uppercase tracking-wide", children: [
|
|
3564
3596
|
"Attached Files (",
|
|
3565
|
-
|
|
3597
|
+
L.length,
|
|
3566
3598
|
")"
|
|
3567
3599
|
] }),
|
|
3568
|
-
/* @__PURE__ */ t("div", { className: "flex flex-wrap gap-2", children:
|
|
3569
|
-
const
|
|
3600
|
+
/* @__PURE__ */ t("div", { className: "flex flex-wrap gap-2", children: L.map((c, p) => {
|
|
3601
|
+
const T = ge.get(c.filename), b = !!T;
|
|
3570
3602
|
return /* @__PURE__ */ o(
|
|
3571
3603
|
"div",
|
|
3572
3604
|
{
|
|
3573
|
-
className: `flex items-center gap-2 rounded-xl px-3 py-1.5 text-sm ${
|
|
3605
|
+
className: `flex items-center gap-2 rounded-xl px-3 py-1.5 text-sm ${b ? "bg-purple-500/10 border border-purple-500/30" : "bg-white/5 border border-white/10"}`,
|
|
3574
3606
|
children: [
|
|
3575
|
-
|
|
3607
|
+
b ? (
|
|
3576
3608
|
// Pasted text icon (document with lines)
|
|
3577
3609
|
/* @__PURE__ */ t(
|
|
3578
3610
|
"svg",
|
|
@@ -3615,11 +3647,11 @@ function vn({
|
|
|
3615
3647
|
}
|
|
3616
3648
|
)
|
|
3617
3649
|
),
|
|
3618
|
-
|
|
3650
|
+
b ? /* @__PURE__ */ o("span", { className: "text-purple-200 font-mono", title: c.filename, children: [
|
|
3619
3651
|
"[Pasted text #",
|
|
3620
|
-
|
|
3652
|
+
T.number,
|
|
3621
3653
|
" +",
|
|
3622
|
-
|
|
3654
|
+
T.lineCount,
|
|
3623
3655
|
" lines]"
|
|
3624
3656
|
] }) : /* @__PURE__ */ o(we, { children: [
|
|
3625
3657
|
/* @__PURE__ */ t("span", { className: "text-white/80 truncate max-w-[150px]", title: c.filename, children: c.filename }),
|
|
@@ -3628,8 +3660,8 @@ function vn({
|
|
|
3628
3660
|
/* @__PURE__ */ t(
|
|
3629
3661
|
"button",
|
|
3630
3662
|
{
|
|
3631
|
-
onClick: () =>
|
|
3632
|
-
className: `hover:text-red-400 transition-colors ${
|
|
3663
|
+
onClick: () => m(p),
|
|
3664
|
+
className: `hover:text-red-400 transition-colors ${b ? "text-purple-400/70" : "text-white/40"}`,
|
|
3633
3665
|
title: "Remove file",
|
|
3634
3666
|
children: /* @__PURE__ */ t(
|
|
3635
3667
|
"svg",
|
|
@@ -3652,17 +3684,17 @@ function vn({
|
|
|
3652
3684
|
)
|
|
3653
3685
|
]
|
|
3654
3686
|
},
|
|
3655
|
-
`${c.filename}-${
|
|
3687
|
+
`${c.filename}-${p}`
|
|
3656
3688
|
);
|
|
3657
3689
|
}) })
|
|
3658
3690
|
] }),
|
|
3659
|
-
|
|
3691
|
+
O && /* @__PURE__ */ o("div", { className: "mb-3 space-y-2", children: [
|
|
3660
3692
|
/* @__PURE__ */ o("div", { className: "text-xs font-medium text-white/50 uppercase tracking-wide", children: [
|
|
3661
3693
|
"Queued Messages (",
|
|
3662
3694
|
a.length,
|
|
3663
3695
|
")"
|
|
3664
3696
|
] }),
|
|
3665
|
-
/* @__PURE__ */ t("div", { className: "max-h-32 overflow-y-auto space-y-1", children: a.map((c,
|
|
3697
|
+
/* @__PURE__ */ t("div", { className: "max-h-32 overflow-y-auto space-y-1", children: a.map((c, p) => /* @__PURE__ */ o(
|
|
3666
3698
|
"div",
|
|
3667
3699
|
{
|
|
3668
3700
|
className: "flex items-center justify-between bg-yellow-500/10 border border-yellow-500/20 rounded-xl px-3 py-2 text-sm",
|
|
@@ -3670,7 +3702,7 @@ function vn({
|
|
|
3670
3702
|
/* @__PURE__ */ o("div", { className: "flex items-center gap-2 flex-1 min-w-0", children: [
|
|
3671
3703
|
/* @__PURE__ */ o("span", { className: "text-yellow-400 font-medium shrink-0", children: [
|
|
3672
3704
|
"#",
|
|
3673
|
-
|
|
3705
|
+
p + 1
|
|
3674
3706
|
] }),
|
|
3675
3707
|
/* @__PURE__ */ t("span", { className: "text-white/80 truncate", children: c.text })
|
|
3676
3708
|
] }),
|
|
@@ -3706,16 +3738,16 @@ function vn({
|
|
|
3706
3738
|
] }),
|
|
3707
3739
|
/* @__PURE__ */ o("div", { className: "flex gap-3 items-end", children: [
|
|
3708
3740
|
/* @__PURE__ */ o("div", { className: "flex-1 flex items-end bg-[#2f2f2f] rounded-2xl border border-white/10 overflow-hidden", children: [
|
|
3709
|
-
|
|
3741
|
+
f && /* @__PURE__ */ o(we, { children: [
|
|
3710
3742
|
/* @__PURE__ */ t(
|
|
3711
3743
|
"input",
|
|
3712
3744
|
{
|
|
3713
|
-
ref:
|
|
3745
|
+
ref: W,
|
|
3714
3746
|
type: "file",
|
|
3715
3747
|
multiple: !0,
|
|
3716
|
-
onChange:
|
|
3748
|
+
onChange: oe,
|
|
3717
3749
|
className: "hidden",
|
|
3718
|
-
disabled: n ||
|
|
3750
|
+
disabled: n || L.length >= I
|
|
3719
3751
|
}
|
|
3720
3752
|
),
|
|
3721
3753
|
/* @__PURE__ */ t(
|
|
@@ -3724,11 +3756,11 @@ function vn({
|
|
|
3724
3756
|
type: "button",
|
|
3725
3757
|
onClick: () => {
|
|
3726
3758
|
var c;
|
|
3727
|
-
return (c =
|
|
3759
|
+
return (c = W.current) == null ? void 0 : c.click();
|
|
3728
3760
|
},
|
|
3729
|
-
disabled: n ||
|
|
3761
|
+
disabled: n || L.length >= I,
|
|
3730
3762
|
className: "shrink-0 p-3 text-white/50 hover:text-white transition-colors disabled:opacity-50 disabled:cursor-not-allowed",
|
|
3731
|
-
title:
|
|
3763
|
+
title: L.length >= I ? `Maximum ${I} files` : "Attach files",
|
|
3732
3764
|
children: /* @__PURE__ */ t(
|
|
3733
3765
|
"svg",
|
|
3734
3766
|
{
|
|
@@ -3754,12 +3786,12 @@ function vn({
|
|
|
3754
3786
|
/* @__PURE__ */ t(
|
|
3755
3787
|
"textarea",
|
|
3756
3788
|
{
|
|
3757
|
-
ref:
|
|
3758
|
-
value:
|
|
3759
|
-
onChange: (c) =>
|
|
3760
|
-
onKeyDown:
|
|
3761
|
-
onInput:
|
|
3762
|
-
onPaste:
|
|
3789
|
+
ref: fe,
|
|
3790
|
+
value: D,
|
|
3791
|
+
onChange: (c) => U(c.target.value),
|
|
3792
|
+
onKeyDown: x,
|
|
3793
|
+
onInput: _,
|
|
3794
|
+
onPaste: S,
|
|
3763
3795
|
placeholder: s,
|
|
3764
3796
|
disabled: n,
|
|
3765
3797
|
className: "flex-1 min-w-0 resize-none py-3 px-2 bg-transparent text-white placeholder-white/40 focus:outline-none disabled:opacity-50 disabled:cursor-not-allowed",
|
|
@@ -3798,8 +3830,8 @@ function vn({
|
|
|
3798
3830
|
"button",
|
|
3799
3831
|
{
|
|
3800
3832
|
type: "button",
|
|
3801
|
-
onClick:
|
|
3802
|
-
disabled: !
|
|
3833
|
+
onClick: g,
|
|
3834
|
+
disabled: !P,
|
|
3803
3835
|
className: "shrink-0 p-3 text-white/50 hover:text-white transition-colors disabled:opacity-30 disabled:cursor-not-allowed",
|
|
3804
3836
|
title: "Send message",
|
|
3805
3837
|
children: /* @__PURE__ */ o(
|
|
@@ -3819,10 +3851,10 @@ function vn({
|
|
|
3819
3851
|
}
|
|
3820
3852
|
)
|
|
3821
3853
|
] }),
|
|
3822
|
-
r &&
|
|
3854
|
+
r && K && A ? /* @__PURE__ */ o(
|
|
3823
3855
|
"button",
|
|
3824
3856
|
{
|
|
3825
|
-
onClick:
|
|
3857
|
+
onClick: A,
|
|
3826
3858
|
className: "shrink-0 px-4 py-3 bg-red-500/80 hover:bg-red-500 text-white rounded-2xl transition-all duration-300 flex items-center gap-2 border border-red-400/30 font-medium",
|
|
3827
3859
|
title: "Stop generation",
|
|
3828
3860
|
children: [
|
|
@@ -3833,22 +3865,22 @@ function vn({
|
|
|
3833
3865
|
) : /* @__PURE__ */ o(
|
|
3834
3866
|
"button",
|
|
3835
3867
|
{
|
|
3836
|
-
onClick:
|
|
3837
|
-
disabled: !
|
|
3838
|
-
className: `shrink-0 px-4 py-3 rounded-2xl font-medium transition-all duration-300 disabled:opacity-30 disabled:cursor-not-allowed ${
|
|
3868
|
+
onClick: g,
|
|
3869
|
+
disabled: !P,
|
|
3870
|
+
className: `shrink-0 px-4 py-3 rounded-2xl font-medium transition-all duration-300 disabled:opacity-30 disabled:cursor-not-allowed ${O ? "bg-yellow-500/80 hover:bg-yellow-500 text-black border border-yellow-400/30" : "bg-[#10a37f] hover:bg-[#0d8c6d] text-white"}`,
|
|
3839
3871
|
children: [
|
|
3840
|
-
/* @__PURE__ */ t("span", { className: "hidden sm:inline", children:
|
|
3841
|
-
/* @__PURE__ */ t("span", { className: "sm:hidden", children: r ? "..." :
|
|
3872
|
+
/* @__PURE__ */ t("span", { className: "hidden sm:inline", children: O ? `Queue (${a.length})` : "Execute" }),
|
|
3873
|
+
/* @__PURE__ */ t("span", { className: "sm:hidden", children: r ? "..." : O ? `+${a.length}` : "→" })
|
|
3842
3874
|
]
|
|
3843
3875
|
}
|
|
3844
3876
|
)
|
|
3845
3877
|
] }),
|
|
3846
3878
|
/* @__PURE__ */ o("div", { className: "text-xs text-white/40 mt-2 hidden sm:block", children: [
|
|
3847
3879
|
"Press Enter to ",
|
|
3848
|
-
r ||
|
|
3880
|
+
r || O ? "queue" : "send",
|
|
3849
3881
|
", Shift+Enter for new line",
|
|
3850
|
-
|
|
3851
|
-
|
|
3882
|
+
f && " • Drag & drop files or click the attach button",
|
|
3883
|
+
J && f && ` • Long text (>${y.toLocaleString()} chars) auto-converts to attachment`
|
|
3852
3884
|
] })
|
|
3853
3885
|
]
|
|
3854
3886
|
}
|
|
@@ -3862,204 +3894,204 @@ function Er({
|
|
|
3862
3894
|
className: a = "",
|
|
3863
3895
|
useBackendQueue: i = !1
|
|
3864
3896
|
}) {
|
|
3865
|
-
const [u, d] =
|
|
3866
|
-
|
|
3867
|
-
|
|
3868
|
-
}, [
|
|
3869
|
-
|
|
3870
|
-
}, [
|
|
3871
|
-
fetch(`${e}/agents`).then((
|
|
3872
|
-
const
|
|
3873
|
-
d(
|
|
3874
|
-
}).catch((
|
|
3875
|
-
console.error("Failed to fetch agents:",
|
|
3897
|
+
const [u, d] = k([]), [l, N] = k(n || null), [f, w] = k(r || null), [I, A] = k([]), [K, J] = k(!1), [y, D] = k(""), [U, j] = k(null), [X, ne] = k([]), [he, xe] = k([]), [H, ae] = k(""), [Q, L] = k({}), de = z(!1), Z = z(H), F = z(Q), B = z(null);
|
|
3898
|
+
te(() => {
|
|
3899
|
+
Z.current = H;
|
|
3900
|
+
}, [H]), te(() => {
|
|
3901
|
+
F.current = Q;
|
|
3902
|
+
}, [Q]), te(() => {
|
|
3903
|
+
fetch(`${e}/agents`).then((g) => g.json()).then((g) => {
|
|
3904
|
+
const x = g.agents || [];
|
|
3905
|
+
d(x), !l && x.length > 0 && N(x[0].slug || x[0].name);
|
|
3906
|
+
}).catch((g) => {
|
|
3907
|
+
console.error("Failed to fetch agents:", g), j("Failed to load agents");
|
|
3876
3908
|
});
|
|
3877
|
-
}, [e]),
|
|
3878
|
-
|
|
3879
|
-
}, [
|
|
3880
|
-
const
|
|
3909
|
+
}, [e]), te(() => {
|
|
3910
|
+
f && ge(f);
|
|
3911
|
+
}, [f]);
|
|
3912
|
+
const G = $(async () => {
|
|
3881
3913
|
if (!(!i || !l))
|
|
3882
3914
|
try {
|
|
3883
|
-
const
|
|
3884
|
-
`${e}/queue/status/${l}?sessionId=${
|
|
3915
|
+
const g = await fetch(
|
|
3916
|
+
`${e}/queue/status/${l}?sessionId=${f || ""}`
|
|
3885
3917
|
);
|
|
3886
|
-
if (!
|
|
3887
|
-
const
|
|
3888
|
-
|
|
3889
|
-
} catch (
|
|
3890
|
-
console.error("Failed to fetch queue status:",
|
|
3918
|
+
if (!g.ok) return;
|
|
3919
|
+
const x = await g.json();
|
|
3920
|
+
J(x.isProcessing), xe(x.nextItems || []), !x.isProcessing && K && (f && await ge(f), D(""));
|
|
3921
|
+
} catch (g) {
|
|
3922
|
+
console.error("Failed to fetch queue status:", g);
|
|
3891
3923
|
}
|
|
3892
|
-
}, [i, l,
|
|
3893
|
-
|
|
3924
|
+
}, [i, l, f, e, K]);
|
|
3925
|
+
te(() => {
|
|
3894
3926
|
if (i)
|
|
3895
|
-
return
|
|
3896
|
-
|
|
3927
|
+
return B.current = setInterval(G, 1e3), () => {
|
|
3928
|
+
B.current && (clearInterval(B.current), B.current = null);
|
|
3897
3929
|
};
|
|
3898
|
-
}, [i,
|
|
3899
|
-
s == null || s(
|
|
3900
|
-
}, [
|
|
3901
|
-
const
|
|
3930
|
+
}, [i, G]), te(() => {
|
|
3931
|
+
s == null || s(f);
|
|
3932
|
+
}, [f, s]);
|
|
3933
|
+
const ge = async (g) => {
|
|
3902
3934
|
try {
|
|
3903
|
-
const
|
|
3904
|
-
if (!
|
|
3905
|
-
const
|
|
3906
|
-
|
|
3907
|
-
} catch (
|
|
3908
|
-
|
|
3935
|
+
const x = await fetch(`${e}/sessions/${g}/messages`);
|
|
3936
|
+
if (!x.ok) throw new Error("Failed to fetch messages");
|
|
3937
|
+
const _ = await x.json();
|
|
3938
|
+
A(_.items || _.messages || []);
|
|
3939
|
+
} catch (x) {
|
|
3940
|
+
j(x instanceof Error ? x.message : "Failed to fetch messages");
|
|
3909
3941
|
}
|
|
3910
|
-
},
|
|
3911
|
-
var
|
|
3912
|
-
if (!l) return
|
|
3913
|
-
|
|
3914
|
-
const
|
|
3942
|
+
}, re = $(async (g, x, _) => {
|
|
3943
|
+
var oe, ie;
|
|
3944
|
+
if (!l) return x;
|
|
3945
|
+
J(!0), j(null), D("");
|
|
3946
|
+
const q = {
|
|
3915
3947
|
id: `temp-${Date.now()}`,
|
|
3916
3948
|
role: "user",
|
|
3917
|
-
content: [{ type: "text", text:
|
|
3949
|
+
content: [{ type: "text", text: g }],
|
|
3918
3950
|
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
3919
3951
|
};
|
|
3920
|
-
|
|
3921
|
-
let
|
|
3952
|
+
A((le) => [...le, q]);
|
|
3953
|
+
let ue = x;
|
|
3922
3954
|
try {
|
|
3923
|
-
const
|
|
3924
|
-
filename:
|
|
3925
|
-
content:
|
|
3926
|
-
mimeType:
|
|
3927
|
-
})),
|
|
3928
|
-
|
|
3929
|
-
const
|
|
3930
|
-
!
|
|
3931
|
-
const
|
|
3955
|
+
const le = x ? `${e}/sessions/${x}/send` : `${e}/agents/${l}/run`, se = _ == null ? void 0 : _.map((ee) => ({
|
|
3956
|
+
filename: ee.filename,
|
|
3957
|
+
content: ee.content,
|
|
3958
|
+
mimeType: ee.mimeType
|
|
3959
|
+
})), m = { prompt: g }, O = Z.current.trim();
|
|
3960
|
+
O && (m.sessionContext = O);
|
|
3961
|
+
const R = F.current;
|
|
3962
|
+
!x && Object.keys(R).length > 0 && (m.envVars = R), se && se.length > 0 && (m.files = se);
|
|
3963
|
+
const E = await fetch(le, {
|
|
3932
3964
|
method: "POST",
|
|
3933
3965
|
headers: { "Content-Type": "application/json" },
|
|
3934
|
-
body: JSON.stringify(
|
|
3966
|
+
body: JSON.stringify(m)
|
|
3935
3967
|
});
|
|
3936
|
-
if (!
|
|
3937
|
-
const
|
|
3938
|
-
let
|
|
3939
|
-
for (;
|
|
3940
|
-
const { done:
|
|
3941
|
-
if (
|
|
3942
|
-
|
|
3943
|
-
const
|
|
3968
|
+
if (!E.ok) throw new Error("Failed to send message");
|
|
3969
|
+
const P = (oe = E.body) == null ? void 0 : oe.getReader(), Y = new TextDecoder();
|
|
3970
|
+
let pe = "", V = "";
|
|
3971
|
+
for (; P; ) {
|
|
3972
|
+
const { done: ee, value: c } = await P.read();
|
|
3973
|
+
if (ee) break;
|
|
3974
|
+
pe += Y.decode(c, { stream: !0 });
|
|
3975
|
+
const p = pe.split(`
|
|
3944
3976
|
`);
|
|
3945
|
-
|
|
3946
|
-
for (const
|
|
3947
|
-
if (
|
|
3948
|
-
const
|
|
3949
|
-
if (!
|
|
3977
|
+
pe = p.pop() || "";
|
|
3978
|
+
for (const T of p)
|
|
3979
|
+
if (T.startsWith("data:")) {
|
|
3980
|
+
const b = T.slice(5).trim();
|
|
3981
|
+
if (!b) continue;
|
|
3950
3982
|
try {
|
|
3951
|
-
const
|
|
3952
|
-
if (
|
|
3953
|
-
|
|
3954
|
-
else if (
|
|
3955
|
-
|
|
3956
|
-
else if (
|
|
3957
|
-
|
|
3958
|
-
else if (
|
|
3959
|
-
const
|
|
3960
|
-
(
|
|
3983
|
+
const C = JSON.parse(b);
|
|
3984
|
+
if (C.type === "session_start" && C.sessionId)
|
|
3985
|
+
ue = C.sessionId, w(C.sessionId);
|
|
3986
|
+
else if (C.type === "text_delta" && C.delta)
|
|
3987
|
+
V += C.delta, D(V);
|
|
3988
|
+
else if (C.type === "thinking_delta" && C.delta)
|
|
3989
|
+
V += C.delta, D(V);
|
|
3990
|
+
else if (C.type === "message" && C.message) {
|
|
3991
|
+
const ce = (ie = C.message.content) == null ? void 0 : ie.find(
|
|
3992
|
+
(ye) => ye.type === "text"
|
|
3961
3993
|
);
|
|
3962
|
-
|
|
3963
|
-
} else if (
|
|
3964
|
-
|
|
3994
|
+
ce != null && ce.text && (V || (V = ce.text, D(V)));
|
|
3995
|
+
} else if (C.type === "tool_use")
|
|
3996
|
+
V += `
|
|
3965
3997
|
|
|
3966
|
-
🔧 Using tool: ${
|
|
3967
|
-
`,
|
|
3968
|
-
else if (
|
|
3969
|
-
const
|
|
3970
|
-
|
|
3971
|
-
} else
|
|
3998
|
+
🔧 Using tool: ${C.name}
|
|
3999
|
+
`, D(V);
|
|
4000
|
+
else if (C.type === "session_end") {
|
|
4001
|
+
const ce = x || C.sessionId;
|
|
4002
|
+
ce && await ge(ce), D("");
|
|
4003
|
+
} else C.type === "error" && j(C.error || "Unknown error");
|
|
3972
4004
|
} catch {
|
|
3973
4005
|
}
|
|
3974
4006
|
}
|
|
3975
4007
|
}
|
|
3976
|
-
} catch (
|
|
3977
|
-
|
|
4008
|
+
} catch (le) {
|
|
4009
|
+
j(le instanceof Error ? le.message : "Unknown error"), A((se) => se.filter((m) => m.id !== q.id));
|
|
3978
4010
|
} finally {
|
|
3979
|
-
|
|
4011
|
+
J(!1);
|
|
3980
4012
|
}
|
|
3981
|
-
return
|
|
3982
|
-
}, [e, l]),
|
|
3983
|
-
if (
|
|
3984
|
-
|
|
3985
|
-
let
|
|
4013
|
+
return ue;
|
|
4014
|
+
}, [e, l]), me = $(async () => {
|
|
4015
|
+
if (de.current) return;
|
|
4016
|
+
de.current = !0;
|
|
4017
|
+
let g = f;
|
|
3986
4018
|
for (; ; ) {
|
|
3987
|
-
let
|
|
3988
|
-
if (
|
|
3989
|
-
|
|
4019
|
+
let x;
|
|
4020
|
+
if (ne((_) => _.length === 0 ? _ : (x = _[0], _.slice(1))), await new Promise((_) => setTimeout(_, 0)), !x) break;
|
|
4021
|
+
g = await re(x.text, g, x.files);
|
|
3990
4022
|
}
|
|
3991
|
-
|
|
3992
|
-
}, [
|
|
3993
|
-
|
|
3994
|
-
|
|
3995
|
-
}, [
|
|
3996
|
-
const
|
|
4023
|
+
de.current = !1;
|
|
4024
|
+
}, [f, re]);
|
|
4025
|
+
te(() => {
|
|
4026
|
+
X.length > 0 && !de.current && me();
|
|
4027
|
+
}, [X, me]);
|
|
4028
|
+
const fe = $(async (g, x) => {
|
|
3997
4029
|
if (!l) return;
|
|
3998
|
-
const
|
|
4030
|
+
const _ = {
|
|
3999
4031
|
id: `temp-${Date.now()}`,
|
|
4000
4032
|
role: "user",
|
|
4001
|
-
content: [{ type: "text", text:
|
|
4033
|
+
content: [{ type: "text", text: g }],
|
|
4002
4034
|
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
4003
4035
|
};
|
|
4004
|
-
|
|
4036
|
+
A((q) => [...q, _]);
|
|
4005
4037
|
try {
|
|
4006
|
-
const
|
|
4007
|
-
filename:
|
|
4008
|
-
content:
|
|
4009
|
-
mimeType:
|
|
4010
|
-
})),
|
|
4038
|
+
const q = x == null ? void 0 : x.map((se) => ({
|
|
4039
|
+
filename: se.filename,
|
|
4040
|
+
content: se.content,
|
|
4041
|
+
mimeType: se.mimeType
|
|
4042
|
+
})), ue = F.current, oe = !f && Object.keys(ue).length > 0 ? ue : void 0, ie = await fetch(`${e}/queue`, {
|
|
4011
4043
|
method: "POST",
|
|
4012
4044
|
headers: { "Content-Type": "application/json" },
|
|
4013
4045
|
body: JSON.stringify({
|
|
4014
4046
|
agentName: l,
|
|
4015
|
-
sessionId:
|
|
4016
|
-
prompt:
|
|
4017
|
-
files:
|
|
4018
|
-
sessionContext:
|
|
4019
|
-
envVars:
|
|
4047
|
+
sessionId: f,
|
|
4048
|
+
prompt: g,
|
|
4049
|
+
files: q,
|
|
4050
|
+
sessionContext: Z.current.trim() || void 0,
|
|
4051
|
+
envVars: oe
|
|
4020
4052
|
})
|
|
4021
4053
|
});
|
|
4022
|
-
if (!
|
|
4054
|
+
if (!ie.ok)
|
|
4023
4055
|
throw new Error("Failed to queue message");
|
|
4024
|
-
const
|
|
4025
|
-
!
|
|
4026
|
-
const
|
|
4027
|
-
if (
|
|
4028
|
-
const
|
|
4029
|
-
|
|
4056
|
+
const le = await ie.json();
|
|
4057
|
+
!f && le.id && setTimeout(async () => {
|
|
4058
|
+
const m = await fetch(`${e}/queue/${le.id}`);
|
|
4059
|
+
if (m.ok) {
|
|
4060
|
+
const O = await m.json();
|
|
4061
|
+
O.sessionId && w(O.sessionId);
|
|
4030
4062
|
}
|
|
4031
|
-
}, 500), await
|
|
4032
|
-
} catch (
|
|
4033
|
-
q
|
|
4063
|
+
}, 500), await G();
|
|
4064
|
+
} catch (q) {
|
|
4065
|
+
j(q instanceof Error ? q.message : "Failed to queue message"), A((ue) => ue.filter((oe) => oe.id !== _.id));
|
|
4034
4066
|
}
|
|
4035
|
-
}, [l,
|
|
4067
|
+
}, [l, f, e, G]), v = $((g, x) => {
|
|
4036
4068
|
if (!l) return;
|
|
4037
4069
|
if (i) {
|
|
4038
|
-
|
|
4070
|
+
fe(g, x);
|
|
4039
4071
|
return;
|
|
4040
4072
|
}
|
|
4041
|
-
const
|
|
4073
|
+
const _ = {
|
|
4042
4074
|
id: `queue-${Date.now()}-${Math.random().toString(36).slice(2)}`,
|
|
4043
|
-
text:
|
|
4044
|
-
files:
|
|
4075
|
+
text: g,
|
|
4076
|
+
files: x
|
|
4045
4077
|
};
|
|
4046
|
-
|
|
4047
|
-
}, [l,
|
|
4078
|
+
K || de.current ? ne((q) => [...q, _]) : ne([_]);
|
|
4079
|
+
}, [l, K, i, fe]), W = $(async (g) => {
|
|
4048
4080
|
if (i) {
|
|
4049
4081
|
try {
|
|
4050
|
-
await fetch(`${e}/queue/${
|
|
4082
|
+
await fetch(`${e}/queue/${g}/cancel`, {
|
|
4051
4083
|
method: "POST"
|
|
4052
|
-
}), await
|
|
4053
|
-
} catch (
|
|
4054
|
-
console.error("Failed to cancel queue item:",
|
|
4084
|
+
}), await G();
|
|
4085
|
+
} catch (x) {
|
|
4086
|
+
console.error("Failed to cancel queue item:", x);
|
|
4055
4087
|
}
|
|
4056
4088
|
return;
|
|
4057
4089
|
}
|
|
4058
|
-
|
|
4059
|
-
}, [i, e,
|
|
4060
|
-
|
|
4061
|
-
}, []),
|
|
4062
|
-
(
|
|
4090
|
+
ne((x) => x.filter((_) => _.id !== g));
|
|
4091
|
+
}, [i, e, G]), M = $(() => {
|
|
4092
|
+
w(null), A([]), D(""), j(null), xe([]), ne([]);
|
|
4093
|
+
}, []), S = u.find(
|
|
4094
|
+
(g) => g.slug === l || g.name === l
|
|
4063
4095
|
);
|
|
4064
4096
|
return /* @__PURE__ */ o("div", { className: `harness-playground flex flex-col h-full bg-[#0a0a0a] relative overflow-hidden ${a}`, children: [
|
|
4065
4097
|
/* @__PURE__ */ t("div", { className: "ambient-glow ambient-glow-accent w-[40vw] h-[40vw] -top-[20%] -right-[10%] animate-pulse-slow" }),
|
|
@@ -4069,76 +4101,76 @@ function Er({
|
|
|
4069
4101
|
/* @__PURE__ */ o("div", { className: "sticky top-0 flex items-center justify-between p-4 border-b border-white/10 glass-panel relative z-10", children: [
|
|
4070
4102
|
/* @__PURE__ */ o("div", { children: [
|
|
4071
4103
|
/* @__PURE__ */ t("h1", { className: "text-xl font-semibold text-white", children: "Playground" }),
|
|
4072
|
-
|
|
4104
|
+
S && /* @__PURE__ */ t("p", { className: "text-sm text-white/50 mt-0.5", children: S.description || `Chat with ${S.name}` })
|
|
4073
4105
|
] }),
|
|
4074
4106
|
/* @__PURE__ */ o("div", { className: "flex items-center gap-3", children: [
|
|
4075
4107
|
/* @__PURE__ */ o(
|
|
4076
4108
|
"select",
|
|
4077
4109
|
{
|
|
4078
4110
|
value: l || "",
|
|
4079
|
-
onChange: (
|
|
4080
|
-
|
|
4111
|
+
onChange: (g) => {
|
|
4112
|
+
N(g.target.value), M();
|
|
4081
4113
|
},
|
|
4082
4114
|
className: "px-4 py-2.5 rounded-xl text-sm bg-white/5 border border-white/10 text-white focus:outline-none focus:border-[#ccff00]/50 transition-all duration-300",
|
|
4083
4115
|
children: [
|
|
4084
4116
|
u.length === 0 && /* @__PURE__ */ t("option", { value: "", children: "No agents" }),
|
|
4085
|
-
u.map((
|
|
4117
|
+
u.map((g) => /* @__PURE__ */ t("option", { value: g.slug || g.name, className: "bg-[#0a0a0a]", children: g.name }, g.slug || g.name))
|
|
4086
4118
|
]
|
|
4087
4119
|
}
|
|
4088
4120
|
),
|
|
4089
4121
|
/* @__PURE__ */ t(
|
|
4090
4122
|
"button",
|
|
4091
4123
|
{
|
|
4092
|
-
onClick:
|
|
4124
|
+
onClick: M,
|
|
4093
4125
|
className: "px-4 py-2.5 text-sm text-white/70 hover:text-white border border-white/10 rounded-xl hover:bg-white/10 hover:border-white/20 transition-all duration-300",
|
|
4094
4126
|
children: "New Chat"
|
|
4095
4127
|
}
|
|
4096
4128
|
)
|
|
4097
4129
|
] })
|
|
4098
4130
|
] }),
|
|
4099
|
-
|
|
4100
|
-
/* @__PURE__ */ t("span", { children:
|
|
4131
|
+
U && /* @__PURE__ */ o("div", { className: "bg-red-500/10 border-b border-red-500/20 px-4 py-3 text-red-400 text-sm flex items-center justify-between relative z-10", children: [
|
|
4132
|
+
/* @__PURE__ */ t("span", { children: U }),
|
|
4101
4133
|
/* @__PURE__ */ t(
|
|
4102
4134
|
"button",
|
|
4103
4135
|
{
|
|
4104
|
-
onClick: () =>
|
|
4136
|
+
onClick: () => j(null),
|
|
4105
4137
|
className: "text-red-400/70 hover:text-red-400 transition-colors",
|
|
4106
4138
|
children: /* @__PURE__ */ t("svg", { className: "w-4 h-4", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: /* @__PURE__ */ t("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M6 18L18 6M6 6l12 12" }) })
|
|
4107
4139
|
}
|
|
4108
4140
|
)
|
|
4109
4141
|
] }),
|
|
4110
|
-
/* @__PURE__ */ t("div", { className: "flex-1 overflow-hidden relative z-10", children:
|
|
4142
|
+
/* @__PURE__ */ t("div", { className: "flex-1 overflow-hidden relative z-10", children: I.length === 0 && !y ? /* @__PURE__ */ t("div", { className: "h-full flex items-center justify-center", children: /* @__PURE__ */ o("div", { className: "text-center animate-fade-in", children: [
|
|
4111
4143
|
/* @__PURE__ */ t("div", { className: "w-16 h-16 mx-auto mb-4 rounded-2xl bg-[#ccff00]/10 border border-[#ccff00]/20 flex items-center justify-center", children: /* @__PURE__ */ t("svg", { className: "w-8 h-8 text-[#ccff00]", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.5", children: /* @__PURE__ */ t("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M8.625 12a.375.375 0 1 1-.75 0 .375.375 0 0 1 .75 0Zm0 0H8.25m4.125 0a.375.375 0 1 1-.75 0 .375.375 0 0 1 .75 0Zm0 0H12m4.125 0a.375.375 0 1 1-.75 0 .375.375 0 0 1 .75 0Zm0 0h-.375M21 12c0 4.556-4.03 8.25-9 8.25a9.764 9.764 0 0 1-2.555-.337A5.972 5.972 0 0 1 5.41 20.97a5.969 5.969 0 0 1-.474-.065 4.48 4.48 0 0 0 .978-2.025c.09-.457-.133-.901-.467-1.226C3.93 16.178 3 14.189 3 12c0-4.556 4.03-8.25 9-8.25s9 3.694 9 8.25Z" }) }) }),
|
|
4112
4144
|
/* @__PURE__ */ t("p", { className: "text-lg text-white/80", children: "Start a conversation" }),
|
|
4113
|
-
/* @__PURE__ */ t("p", { className: "text-sm mt-1 text-white/40", children: l ? `Chat with ${(
|
|
4145
|
+
/* @__PURE__ */ t("p", { className: "text-sm mt-1 text-white/40", children: l ? `Chat with ${(S == null ? void 0 : S.name) || l}` : "Select an agent to begin" })
|
|
4114
4146
|
] }) }) : /* @__PURE__ */ t(
|
|
4115
|
-
|
|
4147
|
+
gn,
|
|
4116
4148
|
{
|
|
4117
|
-
messages:
|
|
4118
|
-
loading:
|
|
4119
|
-
streamingContent:
|
|
4149
|
+
messages: I,
|
|
4150
|
+
loading: K,
|
|
4151
|
+
streamingContent: y
|
|
4120
4152
|
}
|
|
4121
4153
|
) }),
|
|
4122
4154
|
/* @__PURE__ */ t("div", { className: "relative z-10", children: /* @__PURE__ */ t(
|
|
4123
|
-
|
|
4155
|
+
yn,
|
|
4124
4156
|
{
|
|
4125
|
-
onSend:
|
|
4157
|
+
onSend: v,
|
|
4126
4158
|
disabled: !l,
|
|
4127
|
-
loading:
|
|
4128
|
-
queue: i ?
|
|
4129
|
-
onCancelQueued:
|
|
4130
|
-
sessionContext:
|
|
4131
|
-
onSessionContextChange:
|
|
4132
|
-
envVars:
|
|
4133
|
-
onEnvVarsChange:
|
|
4134
|
-
placeholder: l ? `Message ${(
|
|
4159
|
+
loading: K,
|
|
4160
|
+
queue: i ? he.map((g) => ({ id: g.id, text: g.prompt })) : X,
|
|
4161
|
+
onCancelQueued: W,
|
|
4162
|
+
sessionContext: H,
|
|
4163
|
+
onSessionContextChange: ae,
|
|
4164
|
+
envVars: Q,
|
|
4165
|
+
onEnvVarsChange: L,
|
|
4166
|
+
placeholder: l ? `Message ${(S == null ? void 0 : S.name) || l}...` : "Select an agent to start chatting"
|
|
4135
4167
|
}
|
|
4136
4168
|
) }),
|
|
4137
|
-
|
|
4169
|
+
f && /* @__PURE__ */ o("div", { className: "px-4 py-2 border-t border-white/10 text-xs text-white/40 glass-panel relative z-10 flex items-center gap-2", children: [
|
|
4138
4170
|
/* @__PURE__ */ t("span", { className: "w-1.5 h-1.5 rounded-full bg-[#ccff00]" }),
|
|
4139
4171
|
/* @__PURE__ */ o("span", { className: "font-mono", children: [
|
|
4140
4172
|
"Session: ",
|
|
4141
|
-
|
|
4173
|
+
f.slice(0, 8),
|
|
4142
4174
|
"..."
|
|
4143
4175
|
] })
|
|
4144
4176
|
] })
|
|
@@ -4158,11 +4190,14 @@ function $r({
|
|
|
4158
4190
|
e.map((d) => {
|
|
4159
4191
|
switch (d.entryType.type) {
|
|
4160
4192
|
case "user_message":
|
|
4161
|
-
return /* @__PURE__ */ t(
|
|
4193
|
+
return /* @__PURE__ */ t(Ce, { from: "user", children: /* @__PURE__ */ t(Me, { content: d.content }) }, d.id);
|
|
4162
4194
|
case "assistant_message":
|
|
4163
|
-
return /* @__PURE__ */ t(
|
|
4195
|
+
return /* @__PURE__ */ t(Ce, { from: "assistant", children: /* @__PURE__ */ t(Me, { content: d.content }) }, d.id);
|
|
4164
4196
|
case "thinking":
|
|
4165
|
-
return /* @__PURE__ */
|
|
4197
|
+
return /* @__PURE__ */ o(Gt, { isStreaming: !1, autoExpand: !1, autoCollapse: !1, children: [
|
|
4198
|
+
/* @__PURE__ */ t(Zt, {}),
|
|
4199
|
+
/* @__PURE__ */ t(Yt, { children: d.content })
|
|
4200
|
+
] }, d.id);
|
|
4166
4201
|
case "tool_call": {
|
|
4167
4202
|
const l = d.entryType.toolCall;
|
|
4168
4203
|
return /* @__PURE__ */ t(
|
|
@@ -4180,18 +4215,18 @@ function $r({
|
|
|
4180
4215
|
);
|
|
4181
4216
|
}
|
|
4182
4217
|
case "error":
|
|
4183
|
-
return /* @__PURE__ */ t(
|
|
4218
|
+
return /* @__PURE__ */ t(Ce, { from: "assistant", children: /* @__PURE__ */ t("div", { className: "text-red-400 bg-red-500/10 rounded-lg px-3 py-2", children: d.content }) }, d.id);
|
|
4184
4219
|
default:
|
|
4185
4220
|
return null;
|
|
4186
4221
|
}
|
|
4187
4222
|
}),
|
|
4188
|
-
r && /* @__PURE__ */ t(
|
|
4189
|
-
n && !r && /* @__PURE__ */ t(
|
|
4223
|
+
r && /* @__PURE__ */ t(Ce, { from: "assistant", children: /* @__PURE__ */ t(Me, { content: r, isStreaming: !0 }) }),
|
|
4224
|
+
n && !r && /* @__PURE__ */ t(Ce, { from: "assistant", children: /* @__PURE__ */ t(on, {}) })
|
|
4190
4225
|
] }) });
|
|
4191
4226
|
}
|
|
4192
4227
|
function Ar({ logs: e, isLoading: n, className: r }) {
|
|
4193
4228
|
return /* @__PURE__ */ t(
|
|
4194
|
-
|
|
4229
|
+
mn,
|
|
4195
4230
|
{
|
|
4196
4231
|
logs: e,
|
|
4197
4232
|
title: "Sandbox Logs",
|
|
@@ -4200,7 +4235,7 @@ function Ar({ logs: e, isLoading: n, className: r }) {
|
|
|
4200
4235
|
}
|
|
4201
4236
|
);
|
|
4202
4237
|
}
|
|
4203
|
-
function
|
|
4238
|
+
function bn(e) {
|
|
4204
4239
|
if (e.startsWith("mcp__")) {
|
|
4205
4240
|
const n = e.split("__");
|
|
4206
4241
|
if (n.length >= 3)
|
|
@@ -4208,7 +4243,7 @@ function wn(e) {
|
|
|
4208
4243
|
}
|
|
4209
4244
|
return e;
|
|
4210
4245
|
}
|
|
4211
|
-
function
|
|
4246
|
+
function kn(e) {
|
|
4212
4247
|
if (e.startsWith("mcp__")) {
|
|
4213
4248
|
const n = e.split("__");
|
|
4214
4249
|
if (n.length >= 3 && n[1] !== void 0)
|
|
@@ -4219,7 +4254,7 @@ function yn(e) {
|
|
|
4219
4254
|
}
|
|
4220
4255
|
return null;
|
|
4221
4256
|
}
|
|
4222
|
-
function
|
|
4257
|
+
function Nn(e, n) {
|
|
4223
4258
|
const r = n || {};
|
|
4224
4259
|
switch (e) {
|
|
4225
4260
|
case "Bash":
|
|
@@ -4288,7 +4323,7 @@ function bn(e, n) {
|
|
|
4288
4323
|
};
|
|
4289
4324
|
}
|
|
4290
4325
|
default: {
|
|
4291
|
-
const s =
|
|
4326
|
+
const s = kn(e);
|
|
4292
4327
|
return s ? {
|
|
4293
4328
|
action: "mcp_tool",
|
|
4294
4329
|
serverName: s.serverName,
|
|
@@ -4296,13 +4331,13 @@ function bn(e, n) {
|
|
|
4296
4331
|
arguments: n
|
|
4297
4332
|
} : {
|
|
4298
4333
|
action: "generic_tool",
|
|
4299
|
-
toolName:
|
|
4334
|
+
toolName: bn(e),
|
|
4300
4335
|
arguments: n
|
|
4301
4336
|
};
|
|
4302
4337
|
}
|
|
4303
4338
|
}
|
|
4304
4339
|
}
|
|
4305
|
-
function
|
|
4340
|
+
function Cn(e, n, r) {
|
|
4306
4341
|
switch (r.action) {
|
|
4307
4342
|
case "command_run":
|
|
4308
4343
|
const s = r.command;
|
|
@@ -4333,11 +4368,11 @@ function kn(e, n, r) {
|
|
|
4333
4368
|
return "Unknown tool";
|
|
4334
4369
|
}
|
|
4335
4370
|
}
|
|
4336
|
-
function
|
|
4371
|
+
function Tn(e) {
|
|
4337
4372
|
return typeof e == "string" ? e : Array.isArray(e) ? e.filter((n) => typeof (n == null ? void 0 : n.text) == "string").map((n) => n.text).join(`
|
|
4338
4373
|
`) : e && typeof e == "object" && "text" in e ? String(e.text) : JSON.stringify(e, null, 2);
|
|
4339
4374
|
}
|
|
4340
|
-
function
|
|
4375
|
+
function _n(e) {
|
|
4341
4376
|
if (typeof e == "string")
|
|
4342
4377
|
try {
|
|
4343
4378
|
return { type: "json", value: JSON.parse(e) };
|
|
@@ -4361,8 +4396,8 @@ function Cn(e) {
|
|
|
4361
4396
|
}
|
|
4362
4397
|
return { type: "json", value: e };
|
|
4363
4398
|
}
|
|
4364
|
-
function
|
|
4365
|
-
const n =
|
|
4399
|
+
function In(e) {
|
|
4400
|
+
const n = Tn(e);
|
|
4366
4401
|
if (typeof e == "string")
|
|
4367
4402
|
try {
|
|
4368
4403
|
const r = JSON.parse(e);
|
|
@@ -4381,7 +4416,7 @@ function Tn(e) {
|
|
|
4381
4416
|
};
|
|
4382
4417
|
}
|
|
4383
4418
|
function at(e) {
|
|
4384
|
-
const n =
|
|
4419
|
+
const n = Nn(e.name, e.input), r = Cn(e.name, e.input, n);
|
|
4385
4420
|
return {
|
|
4386
4421
|
id: e.id,
|
|
4387
4422
|
toolName: e.name,
|
|
@@ -4394,15 +4429,15 @@ function at(e) {
|
|
|
4394
4429
|
function ot(e, n, r) {
|
|
4395
4430
|
const s = { ...e }, a = { ...e.actionType };
|
|
4396
4431
|
if (s.status = r ? "failed" : "success", s.completedAt = (/* @__PURE__ */ new Date()).toISOString(), s.isError = r, a.action === "command_run") {
|
|
4397
|
-
const i =
|
|
4432
|
+
const i = In(n);
|
|
4398
4433
|
a.result = i, i.exitCode !== void 0 && i.exitCode !== 0 && (s.status = "failed", s.isError = !0);
|
|
4399
|
-
} else (a.action === "mcp_tool" || a.action === "generic_tool") && (a.result =
|
|
4434
|
+
} else (a.action === "mcp_tool" || a.action === "generic_tool") && (a.result = _n(n));
|
|
4400
4435
|
return s.actionType = a, s;
|
|
4401
4436
|
}
|
|
4402
|
-
function
|
|
4437
|
+
function Mn(e) {
|
|
4403
4438
|
return e.type === "tool_use";
|
|
4404
4439
|
}
|
|
4405
|
-
function
|
|
4440
|
+
function Sn(e) {
|
|
4406
4441
|
return e.type === "tool_result";
|
|
4407
4442
|
}
|
|
4408
4443
|
function Rr(e) {
|
|
@@ -4419,7 +4454,7 @@ function Rr(e) {
|
|
|
4419
4454
|
},
|
|
4420
4455
|
content: u.text
|
|
4421
4456
|
});
|
|
4422
|
-
else if (
|
|
4457
|
+
else if (Mn(u)) {
|
|
4423
4458
|
const d = at(u);
|
|
4424
4459
|
r.set(u.id, d);
|
|
4425
4460
|
const l = {
|
|
@@ -4432,21 +4467,21 @@ function Rr(e) {
|
|
|
4432
4467
|
content: d.summary
|
|
4433
4468
|
};
|
|
4434
4469
|
n.push(l), s.set(u.id, l);
|
|
4435
|
-
} else if (
|
|
4470
|
+
} else if (Sn(u)) {
|
|
4436
4471
|
const d = u.toolUseId, l = r.get(d);
|
|
4437
4472
|
if (l) {
|
|
4438
|
-
const
|
|
4473
|
+
const N = ot(
|
|
4439
4474
|
l,
|
|
4440
4475
|
u.content,
|
|
4441
4476
|
u.isError
|
|
4442
|
-
),
|
|
4443
|
-
|
|
4477
|
+
), f = s.get(d);
|
|
4478
|
+
f && f.entryType.type === "tool_call" && (f.entryType.toolCall = N), r.delete(d);
|
|
4444
4479
|
}
|
|
4445
4480
|
}
|
|
4446
4481
|
}
|
|
4447
4482
|
return n;
|
|
4448
4483
|
}
|
|
4449
|
-
const
|
|
4484
|
+
const _e = class _e {
|
|
4450
4485
|
constructor() {
|
|
4451
4486
|
ve(this, "entries", []);
|
|
4452
4487
|
ve(this, "pendingToolCalls", /* @__PURE__ */ new Map());
|
|
@@ -4542,7 +4577,7 @@ const Te = class Te {
|
|
|
4542
4577
|
console.warn("[ToolCallProcessor] Skipping potential duplicate delta");
|
|
4543
4578
|
return;
|
|
4544
4579
|
}
|
|
4545
|
-
this.recentDeltas.push(s), this.recentDeltas.length >
|
|
4580
|
+
this.recentDeltas.push(s), this.recentDeltas.length > _e.MAX_RECENT_DELTAS && this.recentDeltas.shift();
|
|
4546
4581
|
}
|
|
4547
4582
|
if (this.hadToolCallSinceText && this.currentTextEntryId && (this.currentTextContent = "", this.currentTextEntryId = null, this.hadToolCallSinceText = !1), this.currentTextContent += n, !this.currentTextEntryId)
|
|
4548
4583
|
this.currentTextEntryId = `text-${Date.now()}-${Math.random().toString(36).slice(2)}`, this.entries.push({
|
|
@@ -4636,35 +4671,35 @@ const Te = class Te {
|
|
|
4636
4671
|
this.listeners.forEach((r) => r(n));
|
|
4637
4672
|
}
|
|
4638
4673
|
};
|
|
4639
|
-
ve(
|
|
4640
|
-
let
|
|
4674
|
+
ve(_e, "MAX_RECENT_DELTAS", 10);
|
|
4675
|
+
let Le = _e;
|
|
4641
4676
|
function jr() {
|
|
4642
|
-
return new
|
|
4677
|
+
return new Le();
|
|
4643
4678
|
}
|
|
4644
4679
|
export {
|
|
4645
4680
|
gr as ActionIcon,
|
|
4646
|
-
|
|
4681
|
+
qt as AlertCircleIcon,
|
|
4647
4682
|
Vt as AlertTriangleIcon,
|
|
4648
4683
|
lr as Attachment,
|
|
4649
|
-
|
|
4650
|
-
|
|
4651
|
-
|
|
4684
|
+
rn as AttachmentInfo,
|
|
4685
|
+
nn as AttachmentPreview,
|
|
4686
|
+
sn as AttachmentRemove,
|
|
4652
4687
|
ir as Attachments,
|
|
4653
|
-
|
|
4654
|
-
|
|
4655
|
-
|
|
4656
|
-
|
|
4688
|
+
rr as BrainIcon,
|
|
4689
|
+
Pt as BugIcon,
|
|
4690
|
+
yn as ChatInput,
|
|
4691
|
+
Zn as CheckCircleIcon,
|
|
4657
4692
|
Bt as CheckIcon,
|
|
4658
|
-
|
|
4693
|
+
He as ChevronDownIcon,
|
|
4659
4694
|
Fn as ChevronLeftIcon,
|
|
4660
|
-
|
|
4661
|
-
|
|
4695
|
+
Fe as ChevronRightIcon,
|
|
4696
|
+
Kn as ChevronUpIcon,
|
|
4662
4697
|
Je as CodeBlock,
|
|
4663
|
-
|
|
4698
|
+
Jn as CodeIcon,
|
|
4664
4699
|
Ct as Conversation,
|
|
4665
4700
|
Tt as ConversationContent,
|
|
4666
|
-
|
|
4667
|
-
|
|
4701
|
+
zn as ConversationEmptyState,
|
|
4702
|
+
Dn as ConversationScrollButton,
|
|
4668
4703
|
Wt as CopyIcon,
|
|
4669
4704
|
$t as EditIcon,
|
|
4670
4705
|
fr as EnvVarsPanel,
|
|
@@ -4676,56 +4711,56 @@ export {
|
|
|
4676
4711
|
Ot as InfoIcon,
|
|
4677
4712
|
Ue as JsonDisplay,
|
|
4678
4713
|
Ve as LazyMarkdown,
|
|
4679
|
-
|
|
4680
|
-
|
|
4714
|
+
Gn as LoaderIcon,
|
|
4715
|
+
on as LoadingDots,
|
|
4681
4716
|
hr as LoadingSpinner,
|
|
4682
|
-
|
|
4683
|
-
|
|
4684
|
-
|
|
4685
|
-
|
|
4686
|
-
|
|
4687
|
-
|
|
4717
|
+
mn as LogsPanel,
|
|
4718
|
+
Ce as Message,
|
|
4719
|
+
Vn as MessageAction,
|
|
4720
|
+
On as MessageActions,
|
|
4721
|
+
Wn as MessageAvatar,
|
|
4722
|
+
Bn as MessageContent,
|
|
4688
4723
|
Me as MessageResponse,
|
|
4689
4724
|
mr as MessageShimmer,
|
|
4690
|
-
|
|
4691
|
-
|
|
4725
|
+
tr as MessageSquareIcon,
|
|
4726
|
+
qn as MessageTimestamp,
|
|
4692
4727
|
Hn as MoonIcon,
|
|
4693
4728
|
$r as NormalizedMessageList,
|
|
4694
4729
|
pr as OptionCards,
|
|
4695
|
-
|
|
4730
|
+
Qn as PaperclipIcon,
|
|
4696
4731
|
Er as Playground,
|
|
4697
4732
|
jt as PlugIcon,
|
|
4698
4733
|
Gt as Reasoning,
|
|
4699
|
-
|
|
4700
|
-
|
|
4734
|
+
Yt as ReasoningContent,
|
|
4735
|
+
Zt as ReasoningTrigger,
|
|
4701
4736
|
Ar as SandboxLogsPanel,
|
|
4702
4737
|
Re as SearchIcon,
|
|
4703
|
-
|
|
4738
|
+
Xn as SendIcon,
|
|
4704
4739
|
dr as Shimmer,
|
|
4705
|
-
|
|
4706
|
-
|
|
4740
|
+
an as ShimmerBlock,
|
|
4741
|
+
be as ShimmerLine,
|
|
4707
4742
|
ur as ShimmerText,
|
|
4708
|
-
|
|
4743
|
+
nr as SparklesIcon,
|
|
4709
4744
|
Lt as StatusIndicator,
|
|
4710
|
-
|
|
4711
|
-
|
|
4712
|
-
|
|
4713
|
-
|
|
4714
|
-
|
|
4745
|
+
er as StopCircleIcon,
|
|
4746
|
+
Pn as SunIcon,
|
|
4747
|
+
Xt as Task,
|
|
4748
|
+
en as TaskContent,
|
|
4749
|
+
tn as TaskItem,
|
|
4715
4750
|
or as TaskList,
|
|
4716
|
-
|
|
4751
|
+
Qt as TaskTrigger,
|
|
4717
4752
|
Ke as TerminalIcon,
|
|
4718
4753
|
ar as ThinkingIndicator,
|
|
4719
4754
|
Ze as Tool,
|
|
4720
|
-
|
|
4755
|
+
Le as ToolCallProcessor,
|
|
4721
4756
|
Kt as ToolHeader,
|
|
4722
4757
|
zt as ToolIcon,
|
|
4723
4758
|
Jt as ToolInput,
|
|
4724
|
-
|
|
4759
|
+
sr as ToolList,
|
|
4725
4760
|
Ut as ToolOutput,
|
|
4726
|
-
|
|
4727
|
-
|
|
4728
|
-
|
|
4761
|
+
Yn as XCircleIcon,
|
|
4762
|
+
Un as XIcon,
|
|
4763
|
+
h as cn,
|
|
4729
4764
|
bt as createToolCall,
|
|
4730
4765
|
jr as createToolCallProcessor,
|
|
4731
4766
|
vt as extractTextContent,
|
|
@@ -4733,10 +4768,10 @@ export {
|
|
|
4733
4768
|
Nt as formatTimestamp,
|
|
4734
4769
|
De as formatToolName,
|
|
4735
4770
|
xt as generateToolSummary,
|
|
4736
|
-
|
|
4737
|
-
|
|
4771
|
+
An as getActionIcon,
|
|
4772
|
+
Rn as getActionLabel,
|
|
4738
4773
|
xr as isCommandRunAction,
|
|
4739
|
-
|
|
4774
|
+
Mr as isErrorEntry,
|
|
4740
4775
|
wr as isFileEditAction,
|
|
4741
4776
|
vr as isFileReadAction,
|
|
4742
4777
|
yr as isFileWriteAction,
|
|
@@ -4744,7 +4779,7 @@ export {
|
|
|
4744
4779
|
kr as isGlobAction,
|
|
4745
4780
|
Tr as isMcpToolAction,
|
|
4746
4781
|
br as isSearchAction,
|
|
4747
|
-
|
|
4782
|
+
Ir as isToolCallEntry,
|
|
4748
4783
|
Nr as isWebFetchAction,
|
|
4749
4784
|
Cr as isWebSearchAction,
|
|
4750
4785
|
gt as mapToolToActionType,
|
|
@@ -4752,14 +4787,14 @@ export {
|
|
|
4752
4787
|
wt as normalizeToolResult,
|
|
4753
4788
|
yt as parseCommandResult,
|
|
4754
4789
|
pt as parseMcpToolName,
|
|
4755
|
-
|
|
4790
|
+
jn as truncate,
|
|
4756
4791
|
kt as updateToolCallWithResult,
|
|
4757
|
-
|
|
4758
|
-
|
|
4792
|
+
Sr as useAgentChat,
|
|
4793
|
+
$e as useAttachment,
|
|
4759
4794
|
Lr as useChat,
|
|
4760
4795
|
Oe as useConversation,
|
|
4761
|
-
|
|
4796
|
+
Pe as useMessage,
|
|
4762
4797
|
Xe as useReasoning,
|
|
4763
4798
|
et as useTask,
|
|
4764
|
-
|
|
4799
|
+
Ee as useTool
|
|
4765
4800
|
};
|