@apteva/apteva-kit 0.1.104 → 0.1.106
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.d.mts +34 -2
- package/dist/index.d.ts +34 -2
- package/dist/index.js +538 -127
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1039 -628
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -4,13 +4,13 @@ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { en
|
|
|
4
4
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
5
|
|
|
6
6
|
// src/components/Chat/Chat.tsx
|
|
7
|
-
import { useState as
|
|
7
|
+
import { useState as useState9, useEffect as useEffect7, useRef as useRef9, useMemo as useMemo2, useCallback as useCallback2, forwardRef, useImperativeHandle } from "react";
|
|
8
8
|
|
|
9
9
|
// src/components/Chat/MessageList.tsx
|
|
10
|
-
import { useEffect as
|
|
10
|
+
import { useEffect as useEffect6, useRef as useRef6 } from "react";
|
|
11
11
|
|
|
12
12
|
// src/components/Chat/Message.tsx
|
|
13
|
-
import { useEffect as
|
|
13
|
+
import { useEffect as useEffect5, useRef as useRef5, useMemo } from "react";
|
|
14
14
|
|
|
15
15
|
// src/utils/cn.ts
|
|
16
16
|
import { clsx } from "clsx";
|
|
@@ -1139,7 +1139,7 @@ function convertApiMessages(apiMessages) {
|
|
|
1139
1139
|
}
|
|
1140
1140
|
|
|
1141
1141
|
// src/components/Widgets/Widgets.tsx
|
|
1142
|
-
import { useEffect as
|
|
1142
|
+
import { useEffect as useEffect4 } from "react";
|
|
1143
1143
|
|
|
1144
1144
|
// src/components/Widgets/widget-library/Card.tsx
|
|
1145
1145
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -1438,14 +1438,19 @@ function Table({ widget, onAction }) {
|
|
|
1438
1438
|
}
|
|
1439
1439
|
|
|
1440
1440
|
// src/components/Widgets/widget-library/Form.tsx
|
|
1441
|
-
import { useState as useState3 } from "react";
|
|
1441
|
+
import { useState as useState3, useRef as useRef3 } from "react";
|
|
1442
1442
|
import { jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
1443
1443
|
function Form({ widget, onAction }) {
|
|
1444
1444
|
const { title, fields } = widget.props;
|
|
1445
|
+
const fileInputRefs = useRef3({});
|
|
1445
1446
|
const [formData, setFormData] = useState3(() => {
|
|
1446
1447
|
const initial = {};
|
|
1447
1448
|
fields.forEach((field) => {
|
|
1448
|
-
|
|
1449
|
+
if (field.type === "file") {
|
|
1450
|
+
initial[field.name] = [];
|
|
1451
|
+
} else {
|
|
1452
|
+
initial[field.name] = field.defaultValue ?? (field.type === "checkbox" ? false : "");
|
|
1453
|
+
}
|
|
1449
1454
|
});
|
|
1450
1455
|
return initial;
|
|
1451
1456
|
});
|
|
@@ -1524,6 +1529,70 @@ function Form({ widget, onAction }) {
|
|
|
1524
1529
|
),
|
|
1525
1530
|
/* @__PURE__ */ jsx6("span", { className: "!text-neutral-700 dark:!text-neutral-300", children: field.label })
|
|
1526
1531
|
] });
|
|
1532
|
+
case "file": {
|
|
1533
|
+
const files = formData[field.name] || [];
|
|
1534
|
+
return /* @__PURE__ */ jsxs4("div", { className: "space-y-2", children: [
|
|
1535
|
+
/* @__PURE__ */ jsx6(
|
|
1536
|
+
"input",
|
|
1537
|
+
{
|
|
1538
|
+
ref: (el) => {
|
|
1539
|
+
fileInputRefs.current[field.name] = el;
|
|
1540
|
+
},
|
|
1541
|
+
type: "file",
|
|
1542
|
+
name: field.name,
|
|
1543
|
+
multiple: field.multiple ?? true,
|
|
1544
|
+
accept: field.accept,
|
|
1545
|
+
onChange: (e) => {
|
|
1546
|
+
const newFiles = Array.from(e.target.files || []);
|
|
1547
|
+
if (field.multiple !== false) {
|
|
1548
|
+
handleChange(field.name, [...files, ...newFiles]);
|
|
1549
|
+
} else {
|
|
1550
|
+
handleChange(field.name, newFiles);
|
|
1551
|
+
}
|
|
1552
|
+
if (fileInputRefs.current[field.name]) {
|
|
1553
|
+
fileInputRefs.current[field.name].value = "";
|
|
1554
|
+
}
|
|
1555
|
+
},
|
|
1556
|
+
className: "hidden"
|
|
1557
|
+
}
|
|
1558
|
+
),
|
|
1559
|
+
/* @__PURE__ */ jsx6(
|
|
1560
|
+
"button",
|
|
1561
|
+
{
|
|
1562
|
+
type: "button",
|
|
1563
|
+
onClick: () => fileInputRefs.current[field.name]?.click(),
|
|
1564
|
+
className: "w-full px-3 py-3 rounded-lg border-2 border-dashed transition-colors cursor-pointer border-neutral-300 dark:border-neutral-600 bg-neutral-50 dark:bg-neutral-800 !text-neutral-500 dark:!text-neutral-400 hover:border-blue-400 hover:!text-blue-500 !text-sm",
|
|
1565
|
+
children: field.placeholder || "Click to add files"
|
|
1566
|
+
}
|
|
1567
|
+
),
|
|
1568
|
+
files.length > 0 && /* @__PURE__ */ jsx6("ul", { className: "space-y-1", children: files.map((file, idx) => /* @__PURE__ */ jsxs4(
|
|
1569
|
+
"li",
|
|
1570
|
+
{
|
|
1571
|
+
className: "flex items-center justify-between px-2 py-1.5 rounded-lg bg-neutral-50 dark:bg-neutral-800 !text-sm",
|
|
1572
|
+
children: [
|
|
1573
|
+
/* @__PURE__ */ jsxs4("span", { className: "!text-neutral-700 dark:!text-neutral-300 truncate mr-2", children: [
|
|
1574
|
+
file.name,
|
|
1575
|
+
/* @__PURE__ */ jsxs4("span", { className: "!text-neutral-400 ml-1", children: [
|
|
1576
|
+
"(",
|
|
1577
|
+
(file.size / 1024).toFixed(0),
|
|
1578
|
+
" KB)"
|
|
1579
|
+
] })
|
|
1580
|
+
] }),
|
|
1581
|
+
/* @__PURE__ */ jsx6(
|
|
1582
|
+
"button",
|
|
1583
|
+
{
|
|
1584
|
+
type: "button",
|
|
1585
|
+
onClick: () => handleChange(field.name, files.filter((_, i) => i !== idx)),
|
|
1586
|
+
className: "!text-neutral-400 hover:!text-red-500 transition-colors flex-shrink-0",
|
|
1587
|
+
children: "\u2715"
|
|
1588
|
+
}
|
|
1589
|
+
)
|
|
1590
|
+
]
|
|
1591
|
+
},
|
|
1592
|
+
`${file.name}-${idx}`
|
|
1593
|
+
)) })
|
|
1594
|
+
] });
|
|
1595
|
+
}
|
|
1527
1596
|
default:
|
|
1528
1597
|
return null;
|
|
1529
1598
|
}
|
|
@@ -1912,48 +1981,165 @@ function Spacer({ widget }) {
|
|
|
1912
1981
|
return /* @__PURE__ */ jsx11("div", { className: heightClasses[height] || heightClasses.md });
|
|
1913
1982
|
}
|
|
1914
1983
|
|
|
1915
|
-
// src/components/Widgets/
|
|
1984
|
+
// src/components/Widgets/widget-library/LiveView.tsx
|
|
1985
|
+
import { useState as useState4, useCallback, useRef as useRef4, useEffect as useEffect3 } from "react";
|
|
1916
1986
|
import { jsx as jsx12, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
1987
|
+
function LiveView({ widget }) {
|
|
1988
|
+
const { src, title, height, aspectRatio = "16/9", allowFullscreen = true, sandbox, allow, refreshInterval, showToolbar = true } = widget.props;
|
|
1989
|
+
const iframeRef = useRef4(null);
|
|
1990
|
+
const [isLoading, setIsLoading] = useState4(true);
|
|
1991
|
+
const [hasError, setHasError] = useState4(false);
|
|
1992
|
+
const [refreshKey, setRefreshKey] = useState4(0);
|
|
1993
|
+
const handleRefresh = useCallback(() => {
|
|
1994
|
+
setIsLoading(true);
|
|
1995
|
+
setHasError(false);
|
|
1996
|
+
setRefreshKey((k) => k + 1);
|
|
1997
|
+
}, []);
|
|
1998
|
+
const handleFullscreen = useCallback(() => {
|
|
1999
|
+
iframeRef.current?.requestFullscreen?.();
|
|
2000
|
+
}, []);
|
|
2001
|
+
const handleOpenExternal = useCallback(() => {
|
|
2002
|
+
window.open(src, "_blank", "noopener,noreferrer");
|
|
2003
|
+
}, [src]);
|
|
2004
|
+
useEffect3(() => {
|
|
2005
|
+
if (!refreshInterval || refreshInterval <= 0) return;
|
|
2006
|
+
const interval = setInterval(handleRefresh, refreshInterval * 1e3);
|
|
2007
|
+
return () => clearInterval(interval);
|
|
2008
|
+
}, [refreshInterval, handleRefresh]);
|
|
2009
|
+
const aspectMap = { "16/9": "56.25%", "4/3": "75%", "1/1": "100%" };
|
|
2010
|
+
const useFixedHeight = !!height;
|
|
2011
|
+
return /* @__PURE__ */ jsxs8("div", { className: "rounded-xl overflow-hidden border border-neutral-200 dark:border-neutral-700 bg-neutral-50 dark:bg-neutral-900", children: [
|
|
2012
|
+
showToolbar && /* @__PURE__ */ jsxs8("div", { className: "flex items-center justify-between px-3 py-2 bg-neutral-100 dark:bg-neutral-800 border-b border-neutral-200 dark:border-neutral-700", children: [
|
|
2013
|
+
/* @__PURE__ */ jsxs8("div", { className: "flex items-center gap-2 min-w-0", children: [
|
|
2014
|
+
/* @__PURE__ */ jsx12("div", { className: cn(
|
|
2015
|
+
"w-2 h-2 rounded-full flex-shrink-0",
|
|
2016
|
+
hasError ? "bg-red-500" : isLoading ? "bg-amber-500 animate-pulse" : "bg-emerald-500"
|
|
2017
|
+
) }),
|
|
2018
|
+
/* @__PURE__ */ jsx12("span", { className: "text-sm font-medium text-neutral-700 dark:text-neutral-300 truncate", children: title || "Live View" })
|
|
2019
|
+
] }),
|
|
2020
|
+
/* @__PURE__ */ jsxs8("div", { className: "flex items-center gap-1 flex-shrink-0", children: [
|
|
2021
|
+
/* @__PURE__ */ jsx12(
|
|
2022
|
+
"button",
|
|
2023
|
+
{
|
|
2024
|
+
onClick: handleRefresh,
|
|
2025
|
+
className: "p-1.5 rounded-md text-neutral-500 hover:text-neutral-700 dark:hover:text-neutral-300 hover:bg-neutral-200 dark:hover:bg-neutral-700 transition-colors",
|
|
2026
|
+
title: "Refresh",
|
|
2027
|
+
children: /* @__PURE__ */ jsx12("svg", { className: "w-3.5 h-3.5", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", strokeWidth: 2, children: /* @__PURE__ */ jsx12("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15" }) })
|
|
2028
|
+
}
|
|
2029
|
+
),
|
|
2030
|
+
/* @__PURE__ */ jsx12(
|
|
2031
|
+
"button",
|
|
2032
|
+
{
|
|
2033
|
+
onClick: handleOpenExternal,
|
|
2034
|
+
className: "p-1.5 rounded-md text-neutral-500 hover:text-neutral-700 dark:hover:text-neutral-300 hover:bg-neutral-200 dark:hover:bg-neutral-700 transition-colors",
|
|
2035
|
+
title: "Open in new tab",
|
|
2036
|
+
children: /* @__PURE__ */ jsx12("svg", { className: "w-3.5 h-3.5", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", strokeWidth: 2, children: /* @__PURE__ */ jsx12("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14" }) })
|
|
2037
|
+
}
|
|
2038
|
+
),
|
|
2039
|
+
allowFullscreen && /* @__PURE__ */ jsx12(
|
|
2040
|
+
"button",
|
|
2041
|
+
{
|
|
2042
|
+
onClick: handleFullscreen,
|
|
2043
|
+
className: "p-1.5 rounded-md text-neutral-500 hover:text-neutral-700 dark:hover:text-neutral-300 hover:bg-neutral-200 dark:hover:bg-neutral-700 transition-colors",
|
|
2044
|
+
title: "Fullscreen",
|
|
2045
|
+
children: /* @__PURE__ */ jsx12("svg", { className: "w-3.5 h-3.5", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", strokeWidth: 2, children: /* @__PURE__ */ jsx12("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5v-4m0 4h-4m4 0l-5-5" }) })
|
|
2046
|
+
}
|
|
2047
|
+
)
|
|
2048
|
+
] })
|
|
2049
|
+
] }),
|
|
2050
|
+
/* @__PURE__ */ jsxs8(
|
|
2051
|
+
"div",
|
|
2052
|
+
{
|
|
2053
|
+
className: "relative bg-white dark:bg-neutral-950",
|
|
2054
|
+
style: useFixedHeight ? { height } : { paddingBottom: aspectMap[aspectRatio] || aspectMap["16/9"] },
|
|
2055
|
+
children: [
|
|
2056
|
+
isLoading && /* @__PURE__ */ jsx12("div", { className: "absolute inset-0 flex items-center justify-center bg-neutral-100 dark:bg-neutral-900 z-10", children: /* @__PURE__ */ jsxs8("div", { className: "flex flex-col items-center gap-2", children: [
|
|
2057
|
+
/* @__PURE__ */ jsx12("div", { className: "w-6 h-6 border-2 border-neutral-300 dark:border-neutral-600 border-t-blue-500 rounded-full animate-spin" }),
|
|
2058
|
+
/* @__PURE__ */ jsx12("span", { className: "text-xs text-neutral-500", children: "Loading..." })
|
|
2059
|
+
] }) }),
|
|
2060
|
+
hasError && /* @__PURE__ */ jsx12("div", { className: "absolute inset-0 flex items-center justify-center bg-neutral-100 dark:bg-neutral-900 z-10", children: /* @__PURE__ */ jsxs8("div", { className: "flex flex-col items-center gap-2 text-center px-4", children: [
|
|
2061
|
+
/* @__PURE__ */ jsx12("svg", { className: "w-8 h-8 text-neutral-400", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", strokeWidth: 1.5, children: /* @__PURE__ */ jsx12("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M12 9v3.75m9-.75a9 9 0 11-18 0 9 9 0 0118 0zm-9 3.75h.008v.008H12v-.008z" }) }),
|
|
2062
|
+
/* @__PURE__ */ jsx12("span", { className: "text-sm text-neutral-500", children: "Failed to load" }),
|
|
2063
|
+
/* @__PURE__ */ jsx12(
|
|
2064
|
+
"button",
|
|
2065
|
+
{
|
|
2066
|
+
onClick: handleRefresh,
|
|
2067
|
+
className: "text-xs text-blue-500 hover:text-blue-600 underline",
|
|
2068
|
+
children: "Try again"
|
|
2069
|
+
}
|
|
2070
|
+
)
|
|
2071
|
+
] }) }),
|
|
2072
|
+
/* @__PURE__ */ jsx12(
|
|
2073
|
+
"iframe",
|
|
2074
|
+
{
|
|
2075
|
+
ref: iframeRef,
|
|
2076
|
+
src,
|
|
2077
|
+
title: title || "Live View",
|
|
2078
|
+
className: cn(
|
|
2079
|
+
"border-0 bg-white dark:bg-neutral-950",
|
|
2080
|
+
useFixedHeight ? "w-full h-full" : "absolute inset-0 w-full h-full"
|
|
2081
|
+
),
|
|
2082
|
+
allowFullScreen: allowFullscreen,
|
|
2083
|
+
sandbox,
|
|
2084
|
+
allow,
|
|
2085
|
+
onLoad: () => setIsLoading(false),
|
|
2086
|
+
onError: () => {
|
|
2087
|
+
setIsLoading(false);
|
|
2088
|
+
setHasError(true);
|
|
2089
|
+
}
|
|
2090
|
+
},
|
|
2091
|
+
refreshKey
|
|
2092
|
+
)
|
|
2093
|
+
]
|
|
2094
|
+
}
|
|
2095
|
+
)
|
|
2096
|
+
] });
|
|
2097
|
+
}
|
|
2098
|
+
|
|
2099
|
+
// src/components/Widgets/WidgetRenderer.tsx
|
|
2100
|
+
import { jsx as jsx13, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
1917
2101
|
function WidgetRenderer({ widget, onAction }) {
|
|
1918
2102
|
const renderWidget = () => {
|
|
1919
2103
|
switch (widget.type) {
|
|
1920
2104
|
case "card":
|
|
1921
|
-
return /* @__PURE__ */
|
|
2105
|
+
return /* @__PURE__ */ jsx13(Card, { widget, onAction });
|
|
1922
2106
|
case "list":
|
|
1923
|
-
return /* @__PURE__ */
|
|
2107
|
+
return /* @__PURE__ */ jsx13(List, { widget, onAction });
|
|
1924
2108
|
case "button":
|
|
1925
|
-
return /* @__PURE__ */
|
|
2109
|
+
return /* @__PURE__ */ jsx13(Button, { widget, onAction });
|
|
1926
2110
|
case "button_group":
|
|
1927
|
-
return /* @__PURE__ */
|
|
2111
|
+
return /* @__PURE__ */ jsx13(ButtonGroup, { widget, onAction });
|
|
1928
2112
|
case "table":
|
|
1929
|
-
return /* @__PURE__ */
|
|
2113
|
+
return /* @__PURE__ */ jsx13(Table, { widget, onAction });
|
|
1930
2114
|
case "form":
|
|
1931
|
-
return /* @__PURE__ */
|
|
2115
|
+
return /* @__PURE__ */ jsx13(Form, { widget, onAction });
|
|
1932
2116
|
case "image":
|
|
1933
|
-
return /* @__PURE__ */
|
|
2117
|
+
return /* @__PURE__ */ jsx13(Image, { widget });
|
|
1934
2118
|
case "flow":
|
|
1935
|
-
return /* @__PURE__ */
|
|
2119
|
+
return /* @__PURE__ */ jsx13(Flow, { widget });
|
|
1936
2120
|
case "kpi":
|
|
1937
|
-
return /* @__PURE__ */
|
|
2121
|
+
return /* @__PURE__ */ jsx13(Kpi, { widget, onAction });
|
|
1938
2122
|
case "text_block":
|
|
1939
|
-
return /* @__PURE__ */
|
|
2123
|
+
return /* @__PURE__ */ jsx13(TextBlock, { widget });
|
|
1940
2124
|
case "spacer":
|
|
1941
|
-
return /* @__PURE__ */
|
|
2125
|
+
return /* @__PURE__ */ jsx13(Spacer, { widget });
|
|
2126
|
+
case "live_view":
|
|
2127
|
+
return /* @__PURE__ */ jsx13(LiveView, { widget });
|
|
1942
2128
|
default:
|
|
1943
|
-
return /* @__PURE__ */
|
|
1944
|
-
/* @__PURE__ */
|
|
2129
|
+
return /* @__PURE__ */ jsxs9("div", { className: "p-4 border border-yellow-300 bg-yellow-50 rounded-lg", children: [
|
|
2130
|
+
/* @__PURE__ */ jsxs9("p", { className: "text-sm text-yellow-800", children: [
|
|
1945
2131
|
"Unknown widget type: ",
|
|
1946
2132
|
widget.type
|
|
1947
2133
|
] }),
|
|
1948
|
-
/* @__PURE__ */
|
|
2134
|
+
/* @__PURE__ */ jsx13("pre", { className: "text-xs mt-2 overflow-auto", children: JSON.stringify(widget, null, 2) })
|
|
1949
2135
|
] });
|
|
1950
2136
|
}
|
|
1951
2137
|
};
|
|
1952
|
-
return /* @__PURE__ */
|
|
2138
|
+
return /* @__PURE__ */ jsx13("div", { className: "apteva-widget", children: renderWidget() });
|
|
1953
2139
|
}
|
|
1954
2140
|
|
|
1955
2141
|
// src/components/Widgets/Widgets.tsx
|
|
1956
|
-
import { jsx as
|
|
2142
|
+
import { jsx as jsx14 } from "react/jsx-runtime";
|
|
1957
2143
|
function Widgets({
|
|
1958
2144
|
widgets,
|
|
1959
2145
|
onAction,
|
|
@@ -1963,7 +2149,7 @@ function Widgets({
|
|
|
1963
2149
|
columns = 3,
|
|
1964
2150
|
className
|
|
1965
2151
|
}) {
|
|
1966
|
-
|
|
2152
|
+
useEffect4(() => {
|
|
1967
2153
|
widgets.forEach((widget) => {
|
|
1968
2154
|
onWidgetMount?.(widget.id);
|
|
1969
2155
|
});
|
|
@@ -1978,85 +2164,85 @@ function Widgets({
|
|
|
1978
2164
|
normal: "gap-4",
|
|
1979
2165
|
loose: "gap-6"
|
|
1980
2166
|
};
|
|
1981
|
-
return /* @__PURE__ */
|
|
2167
|
+
return /* @__PURE__ */ jsx14("div", { className: cn(layoutClasses[layout], spacingClasses[spacing], className), children: widgets.map((widget) => /* @__PURE__ */ jsx14(WidgetRenderer, { widget, onAction }, widget.id)) });
|
|
1982
2168
|
}
|
|
1983
2169
|
|
|
1984
2170
|
// src/components/Widgets/WidgetSkeleton.tsx
|
|
1985
|
-
import { jsx as
|
|
2171
|
+
import { jsx as jsx15, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
1986
2172
|
function WidgetSkeleton({ type, className }) {
|
|
1987
2173
|
switch (type) {
|
|
1988
2174
|
case "card":
|
|
1989
|
-
return /* @__PURE__ */
|
|
1990
|
-
/* @__PURE__ */
|
|
1991
|
-
/* @__PURE__ */
|
|
1992
|
-
/* @__PURE__ */
|
|
2175
|
+
return /* @__PURE__ */ jsx15("div", { className: cn("apteva-widget-skeleton animate-pulse rounded-lg border border-neutral-200 dark:border-neutral-800 overflow-hidden", className), children: /* @__PURE__ */ jsxs10("div", { className: "p-4 space-y-3", children: [
|
|
2176
|
+
/* @__PURE__ */ jsx15("div", { className: "h-4 bg-neutral-200 dark:bg-neutral-700 rounded w-3/4" }),
|
|
2177
|
+
/* @__PURE__ */ jsx15("div", { className: "h-3 bg-neutral-200 dark:bg-neutral-700 rounded w-full" }),
|
|
2178
|
+
/* @__PURE__ */ jsx15("div", { className: "h-3 bg-neutral-200 dark:bg-neutral-700 rounded w-5/6" })
|
|
1993
2179
|
] }) });
|
|
1994
2180
|
case "list":
|
|
1995
|
-
return /* @__PURE__ */
|
|
1996
|
-
/* @__PURE__ */
|
|
1997
|
-
/* @__PURE__ */
|
|
1998
|
-
/* @__PURE__ */
|
|
1999
|
-
/* @__PURE__ */
|
|
2181
|
+
return /* @__PURE__ */ jsx15("div", { className: cn("apteva-widget-skeleton animate-pulse space-y-2", className), children: [1, 2, 3].map((i) => /* @__PURE__ */ jsxs10("div", { className: "flex items-center gap-3 p-3 rounded-lg border border-neutral-200 dark:border-neutral-800", children: [
|
|
2182
|
+
/* @__PURE__ */ jsx15("div", { className: "w-10 h-10 bg-neutral-200 dark:bg-neutral-700 rounded-full flex-shrink-0" }),
|
|
2183
|
+
/* @__PURE__ */ jsxs10("div", { className: "flex-1 space-y-2", children: [
|
|
2184
|
+
/* @__PURE__ */ jsx15("div", { className: "h-3 bg-neutral-200 dark:bg-neutral-700 rounded w-1/2" }),
|
|
2185
|
+
/* @__PURE__ */ jsx15("div", { className: "h-2 bg-neutral-200 dark:bg-neutral-700 rounded w-3/4" })
|
|
2000
2186
|
] })
|
|
2001
2187
|
] }, i)) });
|
|
2002
2188
|
case "button_group":
|
|
2003
|
-
return /* @__PURE__ */
|
|
2004
|
-
/* @__PURE__ */
|
|
2005
|
-
/* @__PURE__ */
|
|
2006
|
-
/* @__PURE__ */
|
|
2189
|
+
return /* @__PURE__ */ jsxs10("div", { className: cn("apteva-widget-skeleton animate-pulse flex gap-2", className), children: [
|
|
2190
|
+
/* @__PURE__ */ jsx15("div", { className: "h-9 bg-neutral-200 dark:bg-neutral-700 rounded-lg w-20" }),
|
|
2191
|
+
/* @__PURE__ */ jsx15("div", { className: "h-9 bg-neutral-200 dark:bg-neutral-700 rounded-lg w-20" }),
|
|
2192
|
+
/* @__PURE__ */ jsx15("div", { className: "h-9 bg-neutral-200 dark:bg-neutral-700 rounded-lg w-20" })
|
|
2007
2193
|
] });
|
|
2008
2194
|
case "form":
|
|
2009
|
-
return /* @__PURE__ */
|
|
2010
|
-
/* @__PURE__ */
|
|
2011
|
-
/* @__PURE__ */
|
|
2012
|
-
/* @__PURE__ */
|
|
2013
|
-
/* @__PURE__ */
|
|
2195
|
+
return /* @__PURE__ */ jsxs10("div", { className: cn("apteva-widget-skeleton animate-pulse rounded-lg border border-neutral-200 dark:border-neutral-800 p-4 space-y-4", className), children: [
|
|
2196
|
+
/* @__PURE__ */ jsx15("div", { className: "h-4 bg-neutral-200 dark:bg-neutral-700 rounded w-1/3" }),
|
|
2197
|
+
/* @__PURE__ */ jsxs10("div", { className: "space-y-3", children: [
|
|
2198
|
+
/* @__PURE__ */ jsx15("div", { className: "h-10 bg-neutral-200 dark:bg-neutral-700 rounded" }),
|
|
2199
|
+
/* @__PURE__ */ jsx15("div", { className: "h-10 bg-neutral-200 dark:bg-neutral-700 rounded" })
|
|
2014
2200
|
] }),
|
|
2015
|
-
/* @__PURE__ */
|
|
2201
|
+
/* @__PURE__ */ jsx15("div", { className: "h-9 bg-neutral-200 dark:bg-neutral-700 rounded w-24" })
|
|
2016
2202
|
] });
|
|
2017
2203
|
case "chart":
|
|
2018
|
-
return /* @__PURE__ */
|
|
2019
|
-
/* @__PURE__ */
|
|
2020
|
-
/* @__PURE__ */
|
|
2021
|
-
/* @__PURE__ */
|
|
2022
|
-
/* @__PURE__ */
|
|
2023
|
-
/* @__PURE__ */
|
|
2024
|
-
/* @__PURE__ */
|
|
2025
|
-
/* @__PURE__ */
|
|
2204
|
+
return /* @__PURE__ */ jsxs10("div", { className: cn("apteva-widget-skeleton animate-pulse rounded-lg border border-neutral-200 dark:border-neutral-800 p-4", className), children: [
|
|
2205
|
+
/* @__PURE__ */ jsx15("div", { className: "h-4 bg-neutral-200 dark:bg-neutral-700 rounded w-1/4 mb-4" }),
|
|
2206
|
+
/* @__PURE__ */ jsxs10("div", { className: "flex items-end gap-2 h-32", children: [
|
|
2207
|
+
/* @__PURE__ */ jsx15("div", { className: "flex-1 bg-neutral-200 dark:bg-neutral-700 rounded-t h-1/2" }),
|
|
2208
|
+
/* @__PURE__ */ jsx15("div", { className: "flex-1 bg-neutral-200 dark:bg-neutral-700 rounded-t h-3/4" }),
|
|
2209
|
+
/* @__PURE__ */ jsx15("div", { className: "flex-1 bg-neutral-200 dark:bg-neutral-700 rounded-t h-1/3" }),
|
|
2210
|
+
/* @__PURE__ */ jsx15("div", { className: "flex-1 bg-neutral-200 dark:bg-neutral-700 rounded-t h-full" }),
|
|
2211
|
+
/* @__PURE__ */ jsx15("div", { className: "flex-1 bg-neutral-200 dark:bg-neutral-700 rounded-t h-2/3" })
|
|
2026
2212
|
] })
|
|
2027
2213
|
] });
|
|
2028
2214
|
case "image":
|
|
2029
|
-
return /* @__PURE__ */
|
|
2215
|
+
return /* @__PURE__ */ jsx15("div", { className: cn("apteva-widget-skeleton animate-pulse", className), children: /* @__PURE__ */ jsx15("div", { className: "aspect-video bg-neutral-200 dark:bg-neutral-700 rounded-lg" }) });
|
|
2030
2216
|
case "gallery":
|
|
2031
|
-
return /* @__PURE__ */
|
|
2217
|
+
return /* @__PURE__ */ jsx15("div", { className: cn("apteva-widget-skeleton animate-pulse grid grid-cols-3 gap-2", className), children: [1, 2, 3].map((i) => /* @__PURE__ */ jsx15("div", { className: "aspect-square bg-neutral-200 dark:bg-neutral-700 rounded-lg" }, i)) });
|
|
2032
2218
|
case "map":
|
|
2033
|
-
return /* @__PURE__ */
|
|
2034
|
-
/* @__PURE__ */
|
|
2035
|
-
/* @__PURE__ */
|
|
2219
|
+
return /* @__PURE__ */ jsx15("div", { className: cn("apteva-widget-skeleton animate-pulse", className), children: /* @__PURE__ */ jsx15("div", { className: "h-48 bg-neutral-200 dark:bg-neutral-700 rounded-lg flex items-center justify-center", children: /* @__PURE__ */ jsxs10("svg", { className: "w-8 h-8 text-neutral-400 dark:text-neutral-500", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: [
|
|
2220
|
+
/* @__PURE__ */ jsx15("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 1.5, d: "M17.657 16.657L13.414 20.9a1.998 1.998 0 01-2.827 0l-4.244-4.243a8 8 0 1111.314 0z" }),
|
|
2221
|
+
/* @__PURE__ */ jsx15("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 1.5, d: "M15 11a3 3 0 11-6 0 3 3 0 016 0z" })
|
|
2036
2222
|
] }) }) });
|
|
2037
2223
|
case "table":
|
|
2038
|
-
return /* @__PURE__ */
|
|
2039
|
-
/* @__PURE__ */
|
|
2040
|
-
/* @__PURE__ */
|
|
2041
|
-
/* @__PURE__ */
|
|
2042
|
-
/* @__PURE__ */
|
|
2224
|
+
return /* @__PURE__ */ jsxs10("div", { className: cn("apteva-widget-skeleton animate-pulse rounded-lg border border-neutral-200 dark:border-neutral-800 overflow-hidden", className), children: [
|
|
2225
|
+
/* @__PURE__ */ jsxs10("div", { className: "flex bg-neutral-100 dark:bg-neutral-800 border-b border-neutral-200 dark:border-neutral-700", children: [
|
|
2226
|
+
/* @__PURE__ */ jsx15("div", { className: "flex-1 px-4 py-3", children: /* @__PURE__ */ jsx15("div", { className: "h-3 bg-neutral-300 dark:bg-neutral-600 rounded w-16" }) }),
|
|
2227
|
+
/* @__PURE__ */ jsx15("div", { className: "flex-1 px-4 py-3", children: /* @__PURE__ */ jsx15("div", { className: "h-3 bg-neutral-300 dark:bg-neutral-600 rounded w-20" }) }),
|
|
2228
|
+
/* @__PURE__ */ jsx15("div", { className: "flex-1 px-4 py-3", children: /* @__PURE__ */ jsx15("div", { className: "h-3 bg-neutral-300 dark:bg-neutral-600 rounded w-14" }) })
|
|
2043
2229
|
] }),
|
|
2044
|
-
[1, 2, 3].map((i) => /* @__PURE__ */
|
|
2045
|
-
/* @__PURE__ */
|
|
2046
|
-
/* @__PURE__ */
|
|
2047
|
-
/* @__PURE__ */
|
|
2230
|
+
[1, 2, 3].map((i) => /* @__PURE__ */ jsxs10("div", { className: "flex border-b border-neutral-200 dark:border-neutral-800 last:border-b-0", children: [
|
|
2231
|
+
/* @__PURE__ */ jsx15("div", { className: "flex-1 px-4 py-3", children: /* @__PURE__ */ jsx15("div", { className: "h-3 bg-neutral-200 dark:bg-neutral-700 rounded w-24" }) }),
|
|
2232
|
+
/* @__PURE__ */ jsx15("div", { className: "flex-1 px-4 py-3", children: /* @__PURE__ */ jsx15("div", { className: "h-3 bg-neutral-200 dark:bg-neutral-700 rounded w-16" }) }),
|
|
2233
|
+
/* @__PURE__ */ jsx15("div", { className: "flex-1 px-4 py-3", children: /* @__PURE__ */ jsx15("div", { className: "h-3 bg-neutral-200 dark:bg-neutral-700 rounded w-20" }) })
|
|
2048
2234
|
] }, i))
|
|
2049
2235
|
] });
|
|
2050
2236
|
default:
|
|
2051
|
-
return /* @__PURE__ */
|
|
2052
|
-
/* @__PURE__ */
|
|
2053
|
-
/* @__PURE__ */
|
|
2237
|
+
return /* @__PURE__ */ jsxs10("div", { className: cn("apteva-widget-skeleton animate-pulse rounded-lg border border-neutral-200 dark:border-neutral-800 p-4", className), children: [
|
|
2238
|
+
/* @__PURE__ */ jsx15("div", { className: "h-4 bg-neutral-200 dark:bg-neutral-700 rounded w-1/2 mb-2" }),
|
|
2239
|
+
/* @__PURE__ */ jsx15("div", { className: "h-3 bg-neutral-200 dark:bg-neutral-700 rounded w-full" })
|
|
2054
2240
|
] });
|
|
2055
2241
|
}
|
|
2056
2242
|
}
|
|
2057
2243
|
|
|
2058
2244
|
// src/components/Chat/MarkdownContent.tsx
|
|
2059
|
-
import { jsx as
|
|
2245
|
+
import { jsx as jsx16, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
2060
2246
|
function isImageUrl(url) {
|
|
2061
2247
|
const imageExtensions = /\.(jpg|jpeg|png|gif|webp|svg|bmp|ico)(\?.*)?$/i;
|
|
2062
2248
|
return imageExtensions.test(url);
|
|
@@ -2075,7 +2261,7 @@ function parseInlineMarkdown(text, keyPrefix = "") {
|
|
|
2075
2261
|
const alt = match[1] || "";
|
|
2076
2262
|
const src = match[2];
|
|
2077
2263
|
result.push(
|
|
2078
|
-
/* @__PURE__ */
|
|
2264
|
+
/* @__PURE__ */ jsx16(
|
|
2079
2265
|
"img",
|
|
2080
2266
|
{
|
|
2081
2267
|
src,
|
|
@@ -2090,7 +2276,7 @@ function parseInlineMarkdown(text, keyPrefix = "") {
|
|
|
2090
2276
|
const href = match[4];
|
|
2091
2277
|
if (isImageUrl(href)) {
|
|
2092
2278
|
result.push(
|
|
2093
|
-
/* @__PURE__ */
|
|
2279
|
+
/* @__PURE__ */ jsx16(
|
|
2094
2280
|
"img",
|
|
2095
2281
|
{
|
|
2096
2282
|
src: href,
|
|
@@ -2102,7 +2288,7 @@ function parseInlineMarkdown(text, keyPrefix = "") {
|
|
|
2102
2288
|
);
|
|
2103
2289
|
} else {
|
|
2104
2290
|
result.push(
|
|
2105
|
-
/* @__PURE__ */
|
|
2291
|
+
/* @__PURE__ */ jsx16(
|
|
2106
2292
|
"a",
|
|
2107
2293
|
{
|
|
2108
2294
|
href,
|
|
@@ -2116,10 +2302,10 @@ function parseInlineMarkdown(text, keyPrefix = "") {
|
|
|
2116
2302
|
);
|
|
2117
2303
|
}
|
|
2118
2304
|
} else if (match[5] !== void 0) {
|
|
2119
|
-
result.push(/* @__PURE__ */
|
|
2305
|
+
result.push(/* @__PURE__ */ jsx16("strong", { children: match[6] }, `${keyPrefix}b${key++}`));
|
|
2120
2306
|
} else if (match[7] !== void 0) {
|
|
2121
2307
|
result.push(
|
|
2122
|
-
/* @__PURE__ */
|
|
2308
|
+
/* @__PURE__ */ jsx16("code", { className: "apteva-md-inline-code", children: match[7] }, `${keyPrefix}code${key++}`)
|
|
2123
2309
|
);
|
|
2124
2310
|
}
|
|
2125
2311
|
lastIndex = match.index + match[0].length;
|
|
@@ -2139,7 +2325,7 @@ function parseMarkdown(content) {
|
|
|
2139
2325
|
const h2Match = line.match(/^##\s+(.*)$/);
|
|
2140
2326
|
if (h2Match) {
|
|
2141
2327
|
result.push(
|
|
2142
|
-
/* @__PURE__ */
|
|
2328
|
+
/* @__PURE__ */ jsx16("h2", { className: "apteva-md-h2", children: parseInlineMarkdown(h2Match[1], `${key}`) }, `h2${key++}`)
|
|
2143
2329
|
);
|
|
2144
2330
|
i++;
|
|
2145
2331
|
continue;
|
|
@@ -2147,7 +2333,7 @@ function parseMarkdown(content) {
|
|
|
2147
2333
|
const h3Match = line.match(/^###\s+(.*)$/);
|
|
2148
2334
|
if (h3Match) {
|
|
2149
2335
|
result.push(
|
|
2150
|
-
/* @__PURE__ */
|
|
2336
|
+
/* @__PURE__ */ jsx16("h3", { className: "apteva-md-h3", children: parseInlineMarkdown(h3Match[1], `${key}`) }, `h3${key++}`)
|
|
2151
2337
|
);
|
|
2152
2338
|
i++;
|
|
2153
2339
|
continue;
|
|
@@ -2160,7 +2346,7 @@ function parseMarkdown(content) {
|
|
|
2160
2346
|
const itemMatch = lines[i].match(/^(\s*)([-*+])\s+(.*)$/);
|
|
2161
2347
|
if (itemMatch && itemMatch[1].length === indent) {
|
|
2162
2348
|
listItems.push(
|
|
2163
|
-
/* @__PURE__ */
|
|
2349
|
+
/* @__PURE__ */ jsx16("li", { className: "apteva-md-li", children: parseInlineMarkdown(itemMatch[3], `${key}`) }, `li${key++}`)
|
|
2164
2350
|
);
|
|
2165
2351
|
i++;
|
|
2166
2352
|
} else {
|
|
@@ -2168,7 +2354,7 @@ function parseMarkdown(content) {
|
|
|
2168
2354
|
}
|
|
2169
2355
|
}
|
|
2170
2356
|
result.push(
|
|
2171
|
-
/* @__PURE__ */
|
|
2357
|
+
/* @__PURE__ */ jsx16("ul", { className: "apteva-md-ul", children: listItems }, `ul${key++}`)
|
|
2172
2358
|
);
|
|
2173
2359
|
continue;
|
|
2174
2360
|
}
|
|
@@ -2180,7 +2366,7 @@ function parseMarkdown(content) {
|
|
|
2180
2366
|
const itemMatch = lines[i].match(/^(\s*)(\d+)\.\s+(.*)$/);
|
|
2181
2367
|
if (itemMatch && itemMatch[1].length === indent) {
|
|
2182
2368
|
listItems.push(
|
|
2183
|
-
/* @__PURE__ */
|
|
2369
|
+
/* @__PURE__ */ jsx16("li", { className: "apteva-md-li", children: parseInlineMarkdown(itemMatch[3], `${key}`) }, `li${key++}`)
|
|
2184
2370
|
);
|
|
2185
2371
|
i++;
|
|
2186
2372
|
} else {
|
|
@@ -2188,7 +2374,7 @@ function parseMarkdown(content) {
|
|
|
2188
2374
|
}
|
|
2189
2375
|
}
|
|
2190
2376
|
result.push(
|
|
2191
|
-
/* @__PURE__ */
|
|
2377
|
+
/* @__PURE__ */ jsx16("ol", { className: "apteva-md-ol", children: listItems }, `ol${key++}`)
|
|
2192
2378
|
);
|
|
2193
2379
|
continue;
|
|
2194
2380
|
}
|
|
@@ -2211,19 +2397,19 @@ function parseMarkdown(content) {
|
|
|
2211
2397
|
}
|
|
2212
2398
|
}
|
|
2213
2399
|
result.push(
|
|
2214
|
-
/* @__PURE__ */
|
|
2215
|
-
/* @__PURE__ */
|
|
2216
|
-
/* @__PURE__ */
|
|
2400
|
+
/* @__PURE__ */ jsx16("div", { className: "apteva-md-table-wrapper", children: /* @__PURE__ */ jsxs11("table", { className: "apteva-md-table", children: [
|
|
2401
|
+
/* @__PURE__ */ jsx16("thead", { children: /* @__PURE__ */ jsx16("tr", { children: headerCells.map((cell, idx) => /* @__PURE__ */ jsx16("th", { className: "apteva-md-th", children: parseInlineMarkdown(cell, `th${key}${idx}`) }, `th${idx}`)) }) }),
|
|
2402
|
+
/* @__PURE__ */ jsx16("tbody", { children: bodyRows.map((row, rowIdx) => /* @__PURE__ */ jsx16("tr", { children: row.map((cell, cellIdx) => /* @__PURE__ */ jsx16("td", { className: "apteva-md-td", children: parseInlineMarkdown(cell, `td${key}${rowIdx}${cellIdx}`) }, `td${cellIdx}`)) }, `tr${rowIdx}`)) })
|
|
2217
2403
|
] }) }, `table-wrapper${key++}`)
|
|
2218
2404
|
);
|
|
2219
2405
|
continue;
|
|
2220
2406
|
}
|
|
2221
2407
|
}
|
|
2222
2408
|
if (line === "") {
|
|
2223
|
-
result.push(/* @__PURE__ */
|
|
2409
|
+
result.push(/* @__PURE__ */ jsx16("br", {}, `br${key++}`));
|
|
2224
2410
|
} else {
|
|
2225
2411
|
result.push(
|
|
2226
|
-
/* @__PURE__ */
|
|
2412
|
+
/* @__PURE__ */ jsxs11("span", { children: [
|
|
2227
2413
|
parseInlineMarkdown(line, `${key}`),
|
|
2228
2414
|
i < lines.length - 1 ? "\n" : ""
|
|
2229
2415
|
] }, `p${key++}`)
|
|
@@ -2234,67 +2420,151 @@ function parseMarkdown(content) {
|
|
|
2234
2420
|
return result;
|
|
2235
2421
|
}
|
|
2236
2422
|
function MarkdownContent({ content, className = "" }) {
|
|
2237
|
-
return /* @__PURE__ */
|
|
2423
|
+
return /* @__PURE__ */ jsx16("div", { className: `apteva-md ${className}`, children: parseMarkdown(content) });
|
|
2238
2424
|
}
|
|
2239
2425
|
|
|
2240
2426
|
// src/components/Chat/ToolCall.tsx
|
|
2241
|
-
import { Fragment as Fragment2, jsx as
|
|
2242
|
-
function ToolCall({ name, status, isReceiving = false, inputLength = 0, streamOutput }) {
|
|
2427
|
+
import { Fragment as Fragment2, jsx as jsx17, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
2428
|
+
function ToolCall({ name, status, isReceiving = false, inputLength = 0, streamOutput, variant = "card" }) {
|
|
2429
|
+
if (variant === "inline") {
|
|
2430
|
+
const statusText = status === "preparing" ? `${name} preparing...` : status === "running" ? streamOutput ? `${name} \xB7 ${streamOutput}` : `${name}...` : status === "error" ? `${name} failed` : name;
|
|
2431
|
+
return /* @__PURE__ */ jsxs12("div", { className: "apteva-tool-inline", children: [
|
|
2432
|
+
/* @__PURE__ */ jsx17("div", { className: "apteva-tool-inline-line" }),
|
|
2433
|
+
/* @__PURE__ */ jsxs12("div", { className: "apteva-tool-inline-content", children: [
|
|
2434
|
+
status === "running" || status === "preparing" ? /* @__PURE__ */ jsxs12("svg", { className: "apteva-tool-inline-icon apteva-tool-icon-spin", width: "14", height: "14", fill: "none", viewBox: "0 0 24 24", children: [
|
|
2435
|
+
/* @__PURE__ */ jsx17("circle", { className: "apteva-tool-spinner-track", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }),
|
|
2436
|
+
/* @__PURE__ */ jsx17("path", { className: "apteva-tool-spinner-fill", fill: "currentColor", d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z" })
|
|
2437
|
+
] }) : /* @__PURE__ */ jsx17("svg", { className: "apteva-tool-inline-icon", width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ jsx17("path", { d: "M13 2L3 14h9l-1 8 10-12h-9l1-8z", fill: "currentColor" }) }),
|
|
2438
|
+
/* @__PURE__ */ jsx17("span", { className: "apteva-tool-inline-text", children: statusText })
|
|
2439
|
+
] }),
|
|
2440
|
+
/* @__PURE__ */ jsx17("div", { className: "apteva-tool-inline-line" })
|
|
2441
|
+
] });
|
|
2442
|
+
}
|
|
2243
2443
|
if (status === "preparing") {
|
|
2244
|
-
return /* @__PURE__ */
|
|
2245
|
-
/* @__PURE__ */
|
|
2246
|
-
/* @__PURE__ */
|
|
2247
|
-
/* @__PURE__ */
|
|
2444
|
+
return /* @__PURE__ */ jsxs12("div", { className: "apteva-tool-card apteva-tool-card-preparing", children: [
|
|
2445
|
+
/* @__PURE__ */ jsxs12("svg", { className: "apteva-tool-icon apteva-tool-icon-spin", fill: "none", viewBox: "0 0 24 24", children: [
|
|
2446
|
+
/* @__PURE__ */ jsx17("circle", { className: "apteva-tool-spinner-track", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }),
|
|
2447
|
+
/* @__PURE__ */ jsx17("path", { className: "apteva-tool-spinner-fill", fill: "currentColor", d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z" })
|
|
2248
2448
|
] }),
|
|
2249
|
-
/* @__PURE__ */
|
|
2250
|
-
/* @__PURE__ */
|
|
2251
|
-
/* @__PURE__ */
|
|
2449
|
+
/* @__PURE__ */ jsxs12("span", { className: "apteva-tool-label", children: [
|
|
2450
|
+
/* @__PURE__ */ jsx17("strong", { children: name }),
|
|
2451
|
+
/* @__PURE__ */ jsx17("span", { className: "apteva-tool-status-text", children: " preparing..." })
|
|
2252
2452
|
] })
|
|
2253
2453
|
] });
|
|
2254
2454
|
}
|
|
2255
2455
|
if (status === "running") {
|
|
2256
|
-
return /* @__PURE__ */
|
|
2257
|
-
/* @__PURE__ */
|
|
2258
|
-
/* @__PURE__ */
|
|
2259
|
-
/* @__PURE__ */
|
|
2456
|
+
return /* @__PURE__ */ jsxs12("div", { className: "apteva-tool-card apteva-tool-card-running", children: [
|
|
2457
|
+
/* @__PURE__ */ jsxs12("svg", { className: "apteva-tool-icon apteva-tool-icon-spin", fill: "none", viewBox: "0 0 24 24", children: [
|
|
2458
|
+
/* @__PURE__ */ jsx17("circle", { className: "apteva-tool-spinner-track", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }),
|
|
2459
|
+
/* @__PURE__ */ jsx17("path", { className: "apteva-tool-spinner-fill", fill: "currentColor", d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z" })
|
|
2260
2460
|
] }),
|
|
2261
|
-
/* @__PURE__ */
|
|
2262
|
-
/* @__PURE__ */
|
|
2263
|
-
streamOutput ? /* @__PURE__ */
|
|
2264
|
-
streamOutput ? /* @__PURE__ */
|
|
2265
|
-
/* @__PURE__ */
|
|
2266
|
-
/* @__PURE__ */
|
|
2267
|
-
/* @__PURE__ */
|
|
2268
|
-
/* @__PURE__ */
|
|
2269
|
-
/* @__PURE__ */
|
|
2461
|
+
/* @__PURE__ */ jsxs12("span", { className: "apteva-tool-label", children: [
|
|
2462
|
+
/* @__PURE__ */ jsx17("strong", { children: name }),
|
|
2463
|
+
streamOutput ? /* @__PURE__ */ jsx17("span", { className: "apteva-tool-stream-separator", children: " \xB7 " }) : null,
|
|
2464
|
+
streamOutput ? /* @__PURE__ */ jsx17("span", { className: "apteva-tool-stream-output", children: streamOutput }) : /* @__PURE__ */ jsxs12(Fragment2, { children: [
|
|
2465
|
+
/* @__PURE__ */ jsx17("span", { className: "apteva-tool-status-text", children: " running" }),
|
|
2466
|
+
/* @__PURE__ */ jsxs12("span", { className: "apteva-tool-dots", children: [
|
|
2467
|
+
/* @__PURE__ */ jsx17("span", { children: "." }),
|
|
2468
|
+
/* @__PURE__ */ jsx17("span", { children: "." }),
|
|
2469
|
+
/* @__PURE__ */ jsx17("span", { children: "." })
|
|
2270
2470
|
] })
|
|
2271
2471
|
] })
|
|
2272
2472
|
] })
|
|
2273
2473
|
] });
|
|
2274
2474
|
}
|
|
2275
2475
|
if (status === "completed") {
|
|
2276
|
-
return /* @__PURE__ */
|
|
2277
|
-
/* @__PURE__ */
|
|
2278
|
-
/* @__PURE__ */
|
|
2476
|
+
return /* @__PURE__ */ jsxs12("div", { className: "apteva-tool-card apteva-tool-card-completed", children: [
|
|
2477
|
+
/* @__PURE__ */ jsx17("svg", { className: "apteva-tool-icon", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx17("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M5 13l4 4L19 7" }) }),
|
|
2478
|
+
/* @__PURE__ */ jsx17("span", { className: "apteva-tool-label", children: name })
|
|
2279
2479
|
] });
|
|
2280
2480
|
}
|
|
2281
|
-
return /* @__PURE__ */
|
|
2282
|
-
/* @__PURE__ */
|
|
2283
|
-
/* @__PURE__ */
|
|
2481
|
+
return /* @__PURE__ */ jsxs12("div", { className: "apteva-tool-card apteva-tool-card-error", children: [
|
|
2482
|
+
/* @__PURE__ */ jsx17("svg", { className: "apteva-tool-icon", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx17("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M6 18L18 6M6 6l12 12" }) }),
|
|
2483
|
+
/* @__PURE__ */ jsxs12("span", { className: "apteva-tool-label", children: [
|
|
2284
2484
|
name,
|
|
2285
2485
|
" failed"
|
|
2286
2486
|
] })
|
|
2287
2487
|
] });
|
|
2288
2488
|
}
|
|
2289
2489
|
|
|
2490
|
+
// src/components/Chat/ToolCallGroup.tsx
|
|
2491
|
+
import { useState as useState5 } from "react";
|
|
2492
|
+
import { jsx as jsx18, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
2493
|
+
function ToolCallGroup({ tools }) {
|
|
2494
|
+
const completed = tools.filter((t) => t.status === "completed").length;
|
|
2495
|
+
const errored = tools.filter((t) => t.status === "error").length;
|
|
2496
|
+
const running = tools.filter((t) => t.status === "running").length;
|
|
2497
|
+
const preparing = tools.filter((t) => t.status === "preparing").length;
|
|
2498
|
+
const total = tools.length;
|
|
2499
|
+
const allDone = completed + errored === total;
|
|
2500
|
+
const [expanded, setExpanded] = useState5(false);
|
|
2501
|
+
const isExpanded = allDone ? expanded : true;
|
|
2502
|
+
const activeStreamTool = tools.find((t) => t.status === "running" && t.streamOutput);
|
|
2503
|
+
const statusText = allDone ? `Used ${total} tools` : `Using ${total} tools${completed > 0 ? ` \xB7 ${completed}/${total} done` : ""}`;
|
|
2504
|
+
const cardClass = allDone ? errored > 0 ? "apteva-tool-group apteva-tool-group-error" : "apteva-tool-group apteva-tool-group-completed" : "apteva-tool-group apteva-tool-group-running";
|
|
2505
|
+
return /* @__PURE__ */ jsxs13("div", { className: cardClass, children: [
|
|
2506
|
+
/* @__PURE__ */ jsxs13(
|
|
2507
|
+
"button",
|
|
2508
|
+
{
|
|
2509
|
+
className: "apteva-tool-group-header",
|
|
2510
|
+
onClick: () => setExpanded(!expanded),
|
|
2511
|
+
children: [
|
|
2512
|
+
/* @__PURE__ */ jsxs13("div", { className: "apteva-tool-group-header-left", children: [
|
|
2513
|
+
allDone ? /* @__PURE__ */ jsx18("svg", { className: "apteva-tool-group-icon", width: "14", height: "14", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx18("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M5 13l4 4L19 7" }) }) : /* @__PURE__ */ jsxs13("svg", { className: "apteva-tool-group-icon apteva-tool-icon-spin", width: "14", height: "14", fill: "none", viewBox: "0 0 24 24", children: [
|
|
2514
|
+
/* @__PURE__ */ jsx18("circle", { className: "apteva-tool-spinner-track", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }),
|
|
2515
|
+
/* @__PURE__ */ jsx18("path", { className: "apteva-tool-spinner-fill", fill: "currentColor", d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z" })
|
|
2516
|
+
] }),
|
|
2517
|
+
/* @__PURE__ */ jsx18("span", { className: "apteva-tool-group-status", children: statusText })
|
|
2518
|
+
] }),
|
|
2519
|
+
/* @__PURE__ */ jsx18(
|
|
2520
|
+
"svg",
|
|
2521
|
+
{
|
|
2522
|
+
className: `apteva-tool-group-chevron ${isExpanded ? "apteva-tool-group-chevron-open" : ""}`,
|
|
2523
|
+
width: "14",
|
|
2524
|
+
height: "14",
|
|
2525
|
+
fill: "none",
|
|
2526
|
+
stroke: "currentColor",
|
|
2527
|
+
viewBox: "0 0 24 24",
|
|
2528
|
+
children: /* @__PURE__ */ jsx18("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M19 9l-7 7-7-7" })
|
|
2529
|
+
}
|
|
2530
|
+
)
|
|
2531
|
+
]
|
|
2532
|
+
}
|
|
2533
|
+
),
|
|
2534
|
+
!isExpanded && activeStreamTool && /* @__PURE__ */ jsxs13("div", { className: "apteva-tool-group-stream", children: [
|
|
2535
|
+
/* @__PURE__ */ jsxs13("span", { className: "apteva-tool-group-stream-name", children: [
|
|
2536
|
+
activeStreamTool.name,
|
|
2537
|
+
":"
|
|
2538
|
+
] }),
|
|
2539
|
+
/* @__PURE__ */ jsx18("span", { className: "apteva-tool-group-stream-text", children: activeStreamTool.streamOutput })
|
|
2540
|
+
] }),
|
|
2541
|
+
isExpanded && /* @__PURE__ */ jsx18("div", { className: "apteva-tool-group-list", children: tools.map((tool) => /* @__PURE__ */ jsxs13("div", { className: "apteva-tool-group-item", children: [
|
|
2542
|
+
tool.status === "completed" ? /* @__PURE__ */ jsx18("svg", { className: "apteva-tool-group-item-icon apteva-tool-group-item-done", width: "12", height: "12", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx18("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 3, d: "M5 13l4 4L19 7" }) }) : tool.status === "error" ? /* @__PURE__ */ jsx18("svg", { className: "apteva-tool-group-item-icon apteva-tool-group-item-error", width: "12", height: "12", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx18("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 3, d: "M6 18L18 6M6 6l12 12" }) }) : /* @__PURE__ */ jsx18("div", { className: "apteva-tool-group-item-icon apteva-tool-group-item-spinner" }),
|
|
2543
|
+
/* @__PURE__ */ jsx18("span", { className: "apteva-tool-group-item-name", children: tool.name }),
|
|
2544
|
+
tool.streamOutput && tool.status === "running" && /* @__PURE__ */ jsx18("span", { className: "apteva-tool-group-item-stream", children: tool.streamOutput })
|
|
2545
|
+
] }, tool.id)) })
|
|
2546
|
+
] });
|
|
2547
|
+
}
|
|
2548
|
+
|
|
2549
|
+
// src/components/Chat/PersistentWidgetRef.tsx
|
|
2550
|
+
import { jsx as jsx19, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
2551
|
+
function PersistentWidgetRef({ widget }) {
|
|
2552
|
+
const title = widget.props.title || widget.type.replace(/_/g, " ");
|
|
2553
|
+
return /* @__PURE__ */ jsxs14("div", { className: "flex items-center gap-2 px-3 py-2 rounded-lg bg-neutral-100 dark:bg-neutral-800 border border-neutral-200 dark:border-neutral-700 text-sm", children: [
|
|
2554
|
+
/* @__PURE__ */ jsx19("div", { className: "w-2 h-2 rounded-full bg-emerald-500 animate-pulse flex-shrink-0" }),
|
|
2555
|
+
/* @__PURE__ */ jsx19("span", { className: "text-neutral-600 dark:text-neutral-400 capitalize", children: title }),
|
|
2556
|
+
/* @__PURE__ */ jsx19("span", { className: "text-neutral-400 dark:text-neutral-500 text-xs ml-auto", children: "pinned above" })
|
|
2557
|
+
] });
|
|
2558
|
+
}
|
|
2559
|
+
|
|
2290
2560
|
// src/components/Chat/Message.tsx
|
|
2291
|
-
import { jsx as
|
|
2292
|
-
function Message({ message, onAction, enableWidgets, onWidgetRender }) {
|
|
2561
|
+
import { Fragment as Fragment3, jsx as jsx20, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
2562
|
+
function Message({ message, onAction, enableWidgets, onWidgetRender, persistentWidgetIds, toolCallStyle = "card" }) {
|
|
2293
2563
|
const isUser = message.role === "user";
|
|
2294
2564
|
const contentSegments = message.metadata?.content_segments;
|
|
2295
2565
|
const isStreaming = message.metadata?.isStreaming === true;
|
|
2296
2566
|
const hasContent = message.content || contentSegments && contentSegments.length > 0;
|
|
2297
|
-
const reportedWidgetsRef =
|
|
2567
|
+
const reportedWidgetsRef = useRef5(/* @__PURE__ */ new Set());
|
|
2298
2568
|
const parsedWidgets = useMemo(() => {
|
|
2299
2569
|
if (!enableWidgets || isUser || !message.content) {
|
|
2300
2570
|
return [];
|
|
@@ -2302,7 +2572,7 @@ function Message({ message, onAction, enableWidgets, onWidgetRender }) {
|
|
|
2302
2572
|
const parsed = parseWidgetsFromText(message.content);
|
|
2303
2573
|
return parsed.segments.filter((seg) => seg.type === "widget" && !!seg.widget).map((seg) => seg.widget);
|
|
2304
2574
|
}, [enableWidgets, isUser, message.content]);
|
|
2305
|
-
|
|
2575
|
+
useEffect5(() => {
|
|
2306
2576
|
if (onWidgetRender && message.widgets) {
|
|
2307
2577
|
for (const widget of message.widgets) {
|
|
2308
2578
|
if (!reportedWidgetsRef.current.has(widget.id)) {
|
|
@@ -2312,7 +2582,7 @@ function Message({ message, onAction, enableWidgets, onWidgetRender }) {
|
|
|
2312
2582
|
}
|
|
2313
2583
|
}
|
|
2314
2584
|
}, [message.widgets, onWidgetRender]);
|
|
2315
|
-
|
|
2585
|
+
useEffect5(() => {
|
|
2316
2586
|
if (onWidgetRender && parsedWidgets.length > 0) {
|
|
2317
2587
|
for (const widget of parsedWidgets) {
|
|
2318
2588
|
if (!reportedWidgetsRef.current.has(widget.id)) {
|
|
@@ -2324,14 +2594,14 @@ function Message({ message, onAction, enableWidgets, onWidgetRender }) {
|
|
|
2324
2594
|
}, [parsedWidgets, onWidgetRender]);
|
|
2325
2595
|
const renderTextContent = (text) => {
|
|
2326
2596
|
if (!enableWidgets || isUser) {
|
|
2327
|
-
return /* @__PURE__ */
|
|
2597
|
+
return /* @__PURE__ */ jsx20(MarkdownContent, { content: text });
|
|
2328
2598
|
}
|
|
2329
2599
|
const parsed = parseWidgetsFromText(text);
|
|
2330
2600
|
const cleanedText = parsed.segments.filter((seg) => seg.type === "text" && seg.content).map((seg) => seg.content).join("");
|
|
2331
2601
|
if (!cleanedText.trim()) {
|
|
2332
2602
|
return null;
|
|
2333
2603
|
}
|
|
2334
|
-
return /* @__PURE__ */
|
|
2604
|
+
return /* @__PURE__ */ jsx20(MarkdownContent, { content: cleanedText });
|
|
2335
2605
|
};
|
|
2336
2606
|
const renderContentWithWidgets = () => {
|
|
2337
2607
|
if (!enableWidgets || isUser || !message.content) {
|
|
@@ -2346,28 +2616,28 @@ function Message({ message, onAction, enableWidgets, onWidgetRender }) {
|
|
|
2346
2616
|
} else if (segment.type === "widget" && segment.widget) {
|
|
2347
2617
|
if (textBuffer.trim()) {
|
|
2348
2618
|
elements.push(
|
|
2349
|
-
/* @__PURE__ */
|
|
2619
|
+
/* @__PURE__ */ jsx20("div", { className: "apteva-message-bubble apteva-message-assistant", children: /* @__PURE__ */ jsx20("div", { className: "apteva-message-content-assistant", children: /* @__PURE__ */ jsx20(MarkdownContent, { content: textBuffer }) }) }, `text-${index}`)
|
|
2350
2620
|
);
|
|
2351
2621
|
textBuffer = "";
|
|
2352
2622
|
}
|
|
2353
2623
|
elements.push(
|
|
2354
|
-
/* @__PURE__ */
|
|
2624
|
+
/* @__PURE__ */ jsx20("div", { className: "apteva-widget-standalone", children: /* @__PURE__ */ jsx20(WidgetRenderer, { widget: segment.widget, onAction }) }, `widget-${index}`)
|
|
2355
2625
|
);
|
|
2356
2626
|
} else if (segment.type === "widget_pending" && segment.pendingType) {
|
|
2357
2627
|
if (textBuffer.trim()) {
|
|
2358
2628
|
elements.push(
|
|
2359
|
-
/* @__PURE__ */
|
|
2629
|
+
/* @__PURE__ */ jsx20("div", { className: "apteva-message-bubble apteva-message-assistant", children: /* @__PURE__ */ jsx20("div", { className: "apteva-message-content-assistant", children: /* @__PURE__ */ jsx20(MarkdownContent, { content: textBuffer }) }) }, `text-${index}`)
|
|
2360
2630
|
);
|
|
2361
2631
|
textBuffer = "";
|
|
2362
2632
|
}
|
|
2363
2633
|
elements.push(
|
|
2364
|
-
/* @__PURE__ */
|
|
2634
|
+
/* @__PURE__ */ jsx20("div", { className: "apteva-widget-standalone", children: /* @__PURE__ */ jsx20(WidgetSkeleton, { type: segment.pendingType }) }, `pending-${index}`)
|
|
2365
2635
|
);
|
|
2366
2636
|
}
|
|
2367
2637
|
});
|
|
2368
2638
|
if (textBuffer.trim()) {
|
|
2369
2639
|
elements.push(
|
|
2370
|
-
/* @__PURE__ */
|
|
2640
|
+
/* @__PURE__ */ jsx20("div", { className: "apteva-message-bubble apteva-message-assistant", children: /* @__PURE__ */ jsx20("div", { className: "apteva-message-content-assistant", children: /* @__PURE__ */ jsx20(MarkdownContent, { content: textBuffer }) }) }, "text-final")
|
|
2371
2641
|
);
|
|
2372
2642
|
}
|
|
2373
2643
|
return elements.length > 0 ? elements : null;
|
|
@@ -2376,11 +2646,11 @@ function Message({ message, onAction, enableWidgets, onWidgetRender }) {
|
|
|
2376
2646
|
const hasAttachments = attachments.length > 0;
|
|
2377
2647
|
const renderAttachments = () => {
|
|
2378
2648
|
if (!hasAttachments) return null;
|
|
2379
|
-
return /* @__PURE__ */
|
|
2649
|
+
return /* @__PURE__ */ jsx20("div", { className: "apteva-message-attachments flex flex-wrap gap-2 mb-2 justify-end", children: attachments.map((att, index) => {
|
|
2380
2650
|
const isImage = att.type.startsWith("image/");
|
|
2381
2651
|
const isPdf = att.type === "application/pdf";
|
|
2382
2652
|
if (isImage && att.preview) {
|
|
2383
|
-
return /* @__PURE__ */
|
|
2653
|
+
return /* @__PURE__ */ jsx20("div", { className: "apteva-attachment-image relative rounded-lg overflow-hidden shadow-sm", children: /* @__PURE__ */ jsx20(
|
|
2384
2654
|
"img",
|
|
2385
2655
|
{
|
|
2386
2656
|
src: att.preview,
|
|
@@ -2389,15 +2659,15 @@ function Message({ message, onAction, enableWidgets, onWidgetRender }) {
|
|
|
2389
2659
|
}
|
|
2390
2660
|
) }, index);
|
|
2391
2661
|
}
|
|
2392
|
-
return /* @__PURE__ */
|
|
2662
|
+
return /* @__PURE__ */ jsxs15(
|
|
2393
2663
|
"div",
|
|
2394
2664
|
{
|
|
2395
2665
|
className: "apteva-attachment-doc flex items-center gap-3 px-4 py-3 bg-neutral-100 dark:bg-neutral-800 border border-neutral-200 dark:border-neutral-700 rounded-xl shadow-sm",
|
|
2396
2666
|
children: [
|
|
2397
|
-
/* @__PURE__ */
|
|
2398
|
-
/* @__PURE__ */
|
|
2399
|
-
/* @__PURE__ */
|
|
2400
|
-
/* @__PURE__ */
|
|
2667
|
+
/* @__PURE__ */ jsx20("div", { className: "w-10 h-10 flex items-center justify-center bg-red-100 dark:bg-red-900/30 rounded-lg text-red-600 dark:text-red-400", children: isPdf ? /* @__PURE__ */ jsx20("svg", { className: "w-5 h-5", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx20("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z" }) }) : /* @__PURE__ */ jsx20("svg", { className: "w-5 h-5", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx20("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z" }) }) }),
|
|
2668
|
+
/* @__PURE__ */ jsxs15("div", { className: "flex flex-col min-w-0", children: [
|
|
2669
|
+
/* @__PURE__ */ jsx20("span", { className: "text-sm font-medium text-neutral-800 dark:text-neutral-200 truncate max-w-[180px]", children: att.name }),
|
|
2670
|
+
/* @__PURE__ */ jsxs15("span", { className: "text-xs text-neutral-500 dark:text-neutral-400", children: [
|
|
2401
2671
|
isPdf ? "PDF" : "Document",
|
|
2402
2672
|
" \xB7 ",
|
|
2403
2673
|
formatFileSize(att.size)
|
|
@@ -2411,13 +2681,13 @@ function Message({ message, onAction, enableWidgets, onWidgetRender }) {
|
|
|
2411
2681
|
};
|
|
2412
2682
|
const renderContent = () => {
|
|
2413
2683
|
if (isUser) {
|
|
2414
|
-
return /* @__PURE__ */
|
|
2684
|
+
return /* @__PURE__ */ jsx20("div", { className: "apteva-message-text", children: message.content });
|
|
2415
2685
|
}
|
|
2416
2686
|
if (isStreaming && !hasContent) {
|
|
2417
|
-
return /* @__PURE__ */
|
|
2418
|
-
/* @__PURE__ */
|
|
2419
|
-
/* @__PURE__ */
|
|
2420
|
-
/* @__PURE__ */
|
|
2687
|
+
return /* @__PURE__ */ jsxs15("div", { className: "apteva-typing-indicator", children: [
|
|
2688
|
+
/* @__PURE__ */ jsx20("span", {}),
|
|
2689
|
+
/* @__PURE__ */ jsx20("span", {}),
|
|
2690
|
+
/* @__PURE__ */ jsx20("span", {})
|
|
2421
2691
|
] });
|
|
2422
2692
|
}
|
|
2423
2693
|
if (contentSegments && contentSegments.length > 0) {
|
|
@@ -2427,7 +2697,7 @@ function Message({ message, onAction, enableWidgets, onWidgetRender }) {
|
|
|
2427
2697
|
};
|
|
2428
2698
|
const renderTextSegmentWithWidgets = (text, keyPrefix) => {
|
|
2429
2699
|
if (!enableWidgets) {
|
|
2430
|
-
return /* @__PURE__ */
|
|
2700
|
+
return /* @__PURE__ */ jsx20("div", { className: "apteva-message-bubble apteva-message-assistant", children: /* @__PURE__ */ jsx20("div", { className: "apteva-message-content-assistant", children: /* @__PURE__ */ jsx20(MarkdownContent, { content: text }) }) }, keyPrefix);
|
|
2431
2701
|
}
|
|
2432
2702
|
const parsed = parseWidgetsFromText(text);
|
|
2433
2703
|
const elements = [];
|
|
@@ -2438,28 +2708,28 @@ function Message({ message, onAction, enableWidgets, onWidgetRender }) {
|
|
|
2438
2708
|
} else if (seg.type === "widget" && seg.widget) {
|
|
2439
2709
|
if (textBuffer.trim()) {
|
|
2440
2710
|
elements.push(
|
|
2441
|
-
/* @__PURE__ */
|
|
2711
|
+
/* @__PURE__ */ jsx20("div", { className: "apteva-message-bubble apteva-message-assistant", children: /* @__PURE__ */ jsx20("div", { className: "apteva-message-content-assistant", children: /* @__PURE__ */ jsx20(MarkdownContent, { content: textBuffer }) }) }, `${keyPrefix}-text-${idx}`)
|
|
2442
2712
|
);
|
|
2443
2713
|
textBuffer = "";
|
|
2444
2714
|
}
|
|
2445
2715
|
elements.push(
|
|
2446
|
-
/* @__PURE__ */
|
|
2716
|
+
/* @__PURE__ */ jsx20("div", { className: "apteva-widget-standalone", children: /* @__PURE__ */ jsx20(WidgetRenderer, { widget: seg.widget, onAction }) }, `${keyPrefix}-widget-${idx}`)
|
|
2447
2717
|
);
|
|
2448
2718
|
} else if (seg.type === "widget_pending" && seg.pendingType) {
|
|
2449
2719
|
if (textBuffer.trim()) {
|
|
2450
2720
|
elements.push(
|
|
2451
|
-
/* @__PURE__ */
|
|
2721
|
+
/* @__PURE__ */ jsx20("div", { className: "apteva-message-bubble apteva-message-assistant", children: /* @__PURE__ */ jsx20("div", { className: "apteva-message-content-assistant", children: /* @__PURE__ */ jsx20(MarkdownContent, { content: textBuffer }) }) }, `${keyPrefix}-text-${idx}`)
|
|
2452
2722
|
);
|
|
2453
2723
|
textBuffer = "";
|
|
2454
2724
|
}
|
|
2455
2725
|
elements.push(
|
|
2456
|
-
/* @__PURE__ */
|
|
2726
|
+
/* @__PURE__ */ jsx20("div", { className: "apteva-widget-standalone", children: /* @__PURE__ */ jsx20(WidgetSkeleton, { type: seg.pendingType }) }, `${keyPrefix}-pending-${idx}`)
|
|
2457
2727
|
);
|
|
2458
2728
|
}
|
|
2459
2729
|
});
|
|
2460
2730
|
if (textBuffer.trim()) {
|
|
2461
2731
|
elements.push(
|
|
2462
|
-
/* @__PURE__ */
|
|
2732
|
+
/* @__PURE__ */ jsx20("div", { className: "apteva-message-bubble apteva-message-assistant", children: /* @__PURE__ */ jsx20("div", { className: "apteva-message-content-assistant", children: /* @__PURE__ */ jsx20(MarkdownContent, { content: textBuffer }) }) }, `${keyPrefix}-text-final`)
|
|
2463
2733
|
);
|
|
2464
2734
|
}
|
|
2465
2735
|
return elements;
|
|
@@ -2468,55 +2738,121 @@ function Message({ message, onAction, enableWidgets, onWidgetRender }) {
|
|
|
2468
2738
|
if (!contentSegments || contentSegments.length === 0) {
|
|
2469
2739
|
return null;
|
|
2470
2740
|
}
|
|
2471
|
-
const
|
|
2741
|
+
const groups = [];
|
|
2742
|
+
let currentToolRun = [];
|
|
2743
|
+
const flushToolRun = () => {
|
|
2744
|
+
if (currentToolRun.length > 0) {
|
|
2745
|
+
groups.push({ type: "tools", tools: [...currentToolRun] });
|
|
2746
|
+
currentToolRun = [];
|
|
2747
|
+
}
|
|
2748
|
+
};
|
|
2472
2749
|
contentSegments.forEach((segment, index) => {
|
|
2473
|
-
if (segment.type === "
|
|
2474
|
-
|
|
2750
|
+
if (segment.type === "tool") {
|
|
2751
|
+
currentToolRun.push(segment);
|
|
2752
|
+
} else {
|
|
2753
|
+
flushToolRun();
|
|
2754
|
+
if (segment.type === "text" && segment.content) {
|
|
2755
|
+
groups.push({ type: "text", content: segment.content, index });
|
|
2756
|
+
}
|
|
2757
|
+
}
|
|
2758
|
+
});
|
|
2759
|
+
flushToolRun();
|
|
2760
|
+
const elements = [];
|
|
2761
|
+
groups.forEach((group, groupIndex) => {
|
|
2762
|
+
if (group.type === "text") {
|
|
2763
|
+
const textElements = renderTextSegmentWithWidgets(group.content, `seg-${group.index}`);
|
|
2475
2764
|
if (Array.isArray(textElements)) {
|
|
2476
2765
|
elements.push(...textElements);
|
|
2477
2766
|
} else {
|
|
2478
2767
|
elements.push(textElements);
|
|
2479
2768
|
}
|
|
2480
|
-
} else if (
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2769
|
+
} else if (group.type === "tools") {
|
|
2770
|
+
if (toolCallStyle === "inline") {
|
|
2771
|
+
group.tools.forEach((segment) => {
|
|
2772
|
+
if (segment.type === "tool") {
|
|
2773
|
+
elements.push(
|
|
2774
|
+
/* @__PURE__ */ jsx20("div", { className: "apteva-tool-call-standalone", children: /* @__PURE__ */ jsx20(
|
|
2775
|
+
ToolCall,
|
|
2776
|
+
{
|
|
2777
|
+
name: segment.name,
|
|
2778
|
+
status: segment.status || (segment.result !== void 0 ? "completed" : "running"),
|
|
2779
|
+
isReceiving: segment.isReceiving,
|
|
2780
|
+
inputLength: segment.inputLength,
|
|
2781
|
+
streamOutput: segment.streamOutput,
|
|
2782
|
+
variant: "inline"
|
|
2783
|
+
}
|
|
2784
|
+
) }, segment.id)
|
|
2785
|
+
);
|
|
2490
2786
|
}
|
|
2491
|
-
|
|
2492
|
-
)
|
|
2787
|
+
});
|
|
2788
|
+
} else if (group.tools.length >= 3) {
|
|
2789
|
+
const toolData = group.tools.map((t) => {
|
|
2790
|
+
const tool = t;
|
|
2791
|
+
return {
|
|
2792
|
+
id: tool.id,
|
|
2793
|
+
name: tool.name,
|
|
2794
|
+
status: tool.status || (tool.result !== void 0 ? "completed" : "running"),
|
|
2795
|
+
isReceiving: tool.isReceiving,
|
|
2796
|
+
streamOutput: tool.streamOutput
|
|
2797
|
+
};
|
|
2798
|
+
});
|
|
2799
|
+
elements.push(
|
|
2800
|
+
/* @__PURE__ */ jsx20("div", { className: "apteva-tool-call-standalone", children: /* @__PURE__ */ jsx20(ToolCallGroup, { tools: toolData }) }, `tool-group-${groupIndex}`)
|
|
2801
|
+
);
|
|
2802
|
+
} else {
|
|
2803
|
+
group.tools.forEach((segment) => {
|
|
2804
|
+
if (segment.type === "tool") {
|
|
2805
|
+
elements.push(
|
|
2806
|
+
/* @__PURE__ */ jsx20("div", { className: "apteva-tool-call-standalone", children: /* @__PURE__ */ jsx20(
|
|
2807
|
+
ToolCall,
|
|
2808
|
+
{
|
|
2809
|
+
name: segment.name,
|
|
2810
|
+
status: segment.status || (segment.result !== void 0 ? "completed" : "running"),
|
|
2811
|
+
isReceiving: segment.isReceiving,
|
|
2812
|
+
inputLength: segment.inputLength,
|
|
2813
|
+
streamOutput: segment.streamOutput
|
|
2814
|
+
}
|
|
2815
|
+
) }, segment.id)
|
|
2816
|
+
);
|
|
2817
|
+
}
|
|
2818
|
+
});
|
|
2819
|
+
}
|
|
2493
2820
|
}
|
|
2494
2821
|
});
|
|
2495
2822
|
return elements;
|
|
2496
2823
|
};
|
|
2824
|
+
const renderMessageWidgets = () => {
|
|
2825
|
+
if (!message.widgets || message.widgets.length === 0) return null;
|
|
2826
|
+
const inlineWidgets = message.widgets.filter((w) => !persistentWidgetIds?.has(w.id));
|
|
2827
|
+
const persistentRefs = message.widgets.filter((w) => persistentWidgetIds?.has(w.id));
|
|
2828
|
+
return /* @__PURE__ */ jsxs15(Fragment3, { children: [
|
|
2829
|
+
persistentRefs.map((w) => /* @__PURE__ */ jsx20("div", { className: "apteva-widget-standalone", children: /* @__PURE__ */ jsx20(PersistentWidgetRef, { widget: w }) }, `ref-${w.id}`)),
|
|
2830
|
+
inlineWidgets.length > 0 && /* @__PURE__ */ jsx20("div", { className: "apteva-widget-standalone", children: /* @__PURE__ */ jsx20(Widgets, { widgets: inlineWidgets, onAction, layout: "stack" }) })
|
|
2831
|
+
] });
|
|
2832
|
+
};
|
|
2497
2833
|
if (!isUser && (contentSegments && contentSegments.length > 0)) {
|
|
2498
|
-
return /* @__PURE__ */
|
|
2834
|
+
return /* @__PURE__ */ jsxs15("div", { className: "apteva-message-segmented", children: [
|
|
2499
2835
|
renderSegmentedContent(),
|
|
2500
|
-
|
|
2501
|
-
/* @__PURE__ */
|
|
2836
|
+
renderMessageWidgets(),
|
|
2837
|
+
/* @__PURE__ */ jsx20("div", { className: "apteva-message-timestamp apteva-message-timestamp-assistant", suppressHydrationWarning: true, children: message.timestamp.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" }) })
|
|
2502
2838
|
] });
|
|
2503
2839
|
}
|
|
2504
2840
|
const widgetContent = renderContentWithWidgets();
|
|
2505
2841
|
if (!isUser && enableWidgets && widgetContent) {
|
|
2506
|
-
return /* @__PURE__ */
|
|
2842
|
+
return /* @__PURE__ */ jsxs15("div", { className: "apteva-message-segmented", children: [
|
|
2507
2843
|
widgetContent,
|
|
2508
|
-
|
|
2509
|
-
/* @__PURE__ */
|
|
2844
|
+
renderMessageWidgets(),
|
|
2845
|
+
/* @__PURE__ */ jsx20("div", { className: "apteva-message-timestamp apteva-message-timestamp-assistant", suppressHydrationWarning: true, children: message.timestamp.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" }) })
|
|
2510
2846
|
] });
|
|
2511
2847
|
}
|
|
2512
2848
|
if (isUser && hasAttachments) {
|
|
2513
|
-
return /* @__PURE__ */
|
|
2849
|
+
return /* @__PURE__ */ jsxs15("div", { className: "apteva-message-segmented apteva-message-user-with-attachments flex flex-col items-end", children: [
|
|
2514
2850
|
renderAttachments(),
|
|
2515
|
-
message.content && /* @__PURE__ */
|
|
2516
|
-
/* @__PURE__ */
|
|
2851
|
+
message.content && /* @__PURE__ */ jsx20("div", { className: "apteva-message-bubble apteva-message-user", children: /* @__PURE__ */ jsx20("div", { className: "apteva-message-content-user", children: /* @__PURE__ */ jsx20("div", { className: "apteva-message-text", children: message.content }) }) }),
|
|
2852
|
+
/* @__PURE__ */ jsx20("div", { className: "apteva-message-timestamp apteva-message-timestamp-user", suppressHydrationWarning: true, children: message.timestamp.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" }) })
|
|
2517
2853
|
] });
|
|
2518
2854
|
}
|
|
2519
|
-
return /* @__PURE__ */
|
|
2855
|
+
return /* @__PURE__ */ jsxs15(
|
|
2520
2856
|
"div",
|
|
2521
2857
|
{
|
|
2522
2858
|
className: cn(
|
|
@@ -2524,17 +2860,17 @@ function Message({ message, onAction, enableWidgets, onWidgetRender }) {
|
|
|
2524
2860
|
isUser ? "apteva-message-user" : "apteva-message-assistant"
|
|
2525
2861
|
),
|
|
2526
2862
|
children: [
|
|
2527
|
-
/* @__PURE__ */
|
|
2528
|
-
|
|
2529
|
-
/* @__PURE__ */
|
|
2863
|
+
/* @__PURE__ */ jsx20("div", { className: isUser ? "apteva-message-content-user" : "apteva-message-content-assistant", children: renderContent() }),
|
|
2864
|
+
renderMessageWidgets(),
|
|
2865
|
+
/* @__PURE__ */ jsx20("div", { className: cn("apteva-message-timestamp", isUser ? "apteva-message-timestamp-user" : "apteva-message-timestamp-assistant"), suppressHydrationWarning: true, children: message.timestamp.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" }) })
|
|
2530
2866
|
]
|
|
2531
2867
|
}
|
|
2532
2868
|
);
|
|
2533
2869
|
}
|
|
2534
2870
|
|
|
2535
2871
|
// src/components/Chat/WelcomeScreen.tsx
|
|
2536
|
-
import { jsx as
|
|
2537
|
-
var DefaultIcon = () => /* @__PURE__ */
|
|
2872
|
+
import { jsx as jsx21, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
2873
|
+
var DefaultIcon = () => /* @__PURE__ */ jsx21("svg", { className: "w-12 h-12 sm:w-16 sm:h-16", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx21(
|
|
2538
2874
|
"path",
|
|
2539
2875
|
{
|
|
2540
2876
|
strokeLinecap: "round",
|
|
@@ -2543,7 +2879,7 @@ var DefaultIcon = () => /* @__PURE__ */ jsx18("svg", { className: "w-12 h-12 sm:
|
|
|
2543
2879
|
d: "M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"
|
|
2544
2880
|
}
|
|
2545
2881
|
) });
|
|
2546
|
-
var ArrowIcon = () => /* @__PURE__ */
|
|
2882
|
+
var ArrowIcon = () => /* @__PURE__ */ jsx21("svg", { className: "w-4 h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx21("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M13 7l5 5m0 0l-5 5m5-5H6" }) });
|
|
2547
2883
|
function WelcomeScreen({
|
|
2548
2884
|
title,
|
|
2549
2885
|
subtitle,
|
|
@@ -2559,18 +2895,18 @@ function WelcomeScreen({
|
|
|
2559
2895
|
const hasPrompts = normalizedPrompts.length > 0;
|
|
2560
2896
|
const hasHeader = title || subtitle || icon;
|
|
2561
2897
|
if (!hasHeader && !hasPrompts) {
|
|
2562
|
-
return /* @__PURE__ */
|
|
2563
|
-
/* @__PURE__ */
|
|
2564
|
-
/* @__PURE__ */
|
|
2898
|
+
return /* @__PURE__ */ jsx21("div", { className: "flex items-center justify-center h-full !text-neutral-500 dark:!text-neutral-400", children: /* @__PURE__ */ jsxs16("div", { className: "text-center space-y-2", children: [
|
|
2899
|
+
/* @__PURE__ */ jsx21("div", { className: "flex justify-center", children: /* @__PURE__ */ jsx21(DefaultIcon, {}) }),
|
|
2900
|
+
/* @__PURE__ */ jsx21("p", { className: "text-sm", children: "No messages yet. Start a conversation!" })
|
|
2565
2901
|
] }) });
|
|
2566
2902
|
}
|
|
2567
2903
|
if (variant === "minimal") {
|
|
2568
|
-
return /* @__PURE__ */
|
|
2569
|
-
hasHeader && /* @__PURE__ */
|
|
2570
|
-
title && /* @__PURE__ */
|
|
2571
|
-
subtitle && /* @__PURE__ */
|
|
2904
|
+
return /* @__PURE__ */ jsxs16("div", { className: "flex flex-col h-full px-4 py-4", children: [
|
|
2905
|
+
hasHeader && /* @__PURE__ */ jsxs16("div", { className: "mb-4", children: [
|
|
2906
|
+
title && /* @__PURE__ */ jsx21("h2", { className: "text-lg font-semibold !text-neutral-900 dark:!text-white", children: title }),
|
|
2907
|
+
subtitle && /* @__PURE__ */ jsx21("p", { className: "text-sm !text-neutral-500 dark:!text-neutral-400 mt-1", children: subtitle })
|
|
2572
2908
|
] }),
|
|
2573
|
-
hasPrompts && /* @__PURE__ */
|
|
2909
|
+
hasPrompts && /* @__PURE__ */ jsx21("div", { className: "flex-1 space-y-2", children: normalizedPrompts.map((prompt, index) => /* @__PURE__ */ jsx21(
|
|
2574
2910
|
"button",
|
|
2575
2911
|
{
|
|
2576
2912
|
onClick: () => onPromptClick(prompt.text),
|
|
@@ -2583,11 +2919,11 @@ function WelcomeScreen({
|
|
|
2583
2919
|
"transition-all duration-200",
|
|
2584
2920
|
"group"
|
|
2585
2921
|
),
|
|
2586
|
-
children: /* @__PURE__ */
|
|
2587
|
-
/* @__PURE__ */
|
|
2588
|
-
/* @__PURE__ */
|
|
2589
|
-
/* @__PURE__ */
|
|
2590
|
-
prompt.description && /* @__PURE__ */
|
|
2922
|
+
children: /* @__PURE__ */ jsxs16("div", { className: "flex items-center gap-3", children: [
|
|
2923
|
+
/* @__PURE__ */ jsx21("div", { className: "flex-shrink-0 !text-neutral-400 dark:!text-neutral-500 group-hover:!text-blue-500 dark:group-hover:!text-blue-400 transition-colors", children: prompt.icon || /* @__PURE__ */ jsx21(ArrowIcon, {}) }),
|
|
2924
|
+
/* @__PURE__ */ jsxs16("div", { className: "flex-1 min-w-0", children: [
|
|
2925
|
+
/* @__PURE__ */ jsx21("p", { className: "text-sm font-medium !text-neutral-900 dark:!text-white truncate", children: prompt.text }),
|
|
2926
|
+
prompt.description && /* @__PURE__ */ jsx21("p", { className: "text-xs !text-neutral-500 dark:!text-neutral-400 mt-0.5 truncate", children: prompt.description })
|
|
2591
2927
|
] })
|
|
2592
2928
|
] })
|
|
2593
2929
|
},
|
|
@@ -2595,14 +2931,14 @@ function WelcomeScreen({
|
|
|
2595
2931
|
)) })
|
|
2596
2932
|
] });
|
|
2597
2933
|
}
|
|
2598
|
-
return /* @__PURE__ */
|
|
2599
|
-
/* @__PURE__ */
|
|
2600
|
-
/* @__PURE__ */
|
|
2601
|
-
title && /* @__PURE__ */
|
|
2602
|
-
subtitle && /* @__PURE__ */
|
|
2934
|
+
return /* @__PURE__ */ jsxs16("div", { className: "flex flex-col items-center justify-center h-full px-4 py-6 sm:py-8", children: [
|
|
2935
|
+
/* @__PURE__ */ jsxs16("div", { className: "text-center mb-6 sm:mb-8 max-w-md", children: [
|
|
2936
|
+
/* @__PURE__ */ jsx21("div", { className: "mb-4 !text-neutral-400 dark:!text-neutral-500 flex justify-center", children: icon || /* @__PURE__ */ jsx21(DefaultIcon, {}) }),
|
|
2937
|
+
title && /* @__PURE__ */ jsx21("h1", { className: "text-xl sm:text-2xl font-semibold !text-neutral-900 dark:!text-white mb-2", children: title }),
|
|
2938
|
+
subtitle && /* @__PURE__ */ jsx21("p", { className: "text-sm sm:text-base !text-neutral-500 dark:!text-neutral-400", children: subtitle })
|
|
2603
2939
|
] }),
|
|
2604
|
-
hasPrompts && /* @__PURE__ */
|
|
2605
|
-
/* @__PURE__ */
|
|
2940
|
+
hasPrompts && /* @__PURE__ */ jsxs16("div", { className: "w-full max-w-2xl", children: [
|
|
2941
|
+
/* @__PURE__ */ jsx21("div", { className: "sm:hidden space-y-2", children: normalizedPrompts.map((prompt, index) => /* @__PURE__ */ jsx21(
|
|
2606
2942
|
"button",
|
|
2607
2943
|
{
|
|
2608
2944
|
onClick: () => onPromptClick(prompt.text),
|
|
@@ -2617,20 +2953,20 @@ function WelcomeScreen({
|
|
|
2617
2953
|
"shadow-sm hover:shadow",
|
|
2618
2954
|
"group"
|
|
2619
2955
|
),
|
|
2620
|
-
children: /* @__PURE__ */
|
|
2621
|
-
/* @__PURE__ */
|
|
2622
|
-
/* @__PURE__ */
|
|
2623
|
-
/* @__PURE__ */
|
|
2624
|
-
prompt.description && /* @__PURE__ */
|
|
2956
|
+
children: /* @__PURE__ */ jsxs16("div", { className: "flex items-center gap-3", children: [
|
|
2957
|
+
/* @__PURE__ */ jsx21("div", { className: "flex-shrink-0 w-8 h-8 rounded-lg bg-neutral-100 dark:bg-neutral-700 flex items-center justify-center !text-neutral-500 dark:!text-neutral-400 group-hover:bg-blue-100 dark:group-hover:bg-blue-900/30 group-hover:!text-blue-600 dark:group-hover:!text-blue-400 transition-colors", children: prompt.icon || /* @__PURE__ */ jsx21(ArrowIcon, {}) }),
|
|
2958
|
+
/* @__PURE__ */ jsxs16("div", { className: "flex-1 min-w-0", children: [
|
|
2959
|
+
/* @__PURE__ */ jsx21("p", { className: "text-sm font-medium !text-neutral-900 dark:!text-white", children: prompt.text }),
|
|
2960
|
+
prompt.description && /* @__PURE__ */ jsx21("p", { className: "text-xs !text-neutral-500 dark:!text-neutral-400 mt-0.5 line-clamp-1", children: prompt.description })
|
|
2625
2961
|
] }),
|
|
2626
|
-
/* @__PURE__ */
|
|
2962
|
+
/* @__PURE__ */ jsx21(
|
|
2627
2963
|
"svg",
|
|
2628
2964
|
{
|
|
2629
2965
|
className: "w-4 h-4 !text-neutral-400 group-hover:!text-blue-500 transition-colors flex-shrink-0",
|
|
2630
2966
|
fill: "none",
|
|
2631
2967
|
stroke: "currentColor",
|
|
2632
2968
|
viewBox: "0 0 24 24",
|
|
2633
|
-
children: /* @__PURE__ */
|
|
2969
|
+
children: /* @__PURE__ */ jsx21(
|
|
2634
2970
|
"path",
|
|
2635
2971
|
{
|
|
2636
2972
|
strokeLinecap: "round",
|
|
@@ -2645,7 +2981,7 @@ function WelcomeScreen({
|
|
|
2645
2981
|
},
|
|
2646
2982
|
index
|
|
2647
2983
|
)) }),
|
|
2648
|
-
/* @__PURE__ */
|
|
2984
|
+
/* @__PURE__ */ jsx21("div", { className: "hidden sm:grid sm:grid-cols-2 gap-3", children: normalizedPrompts.map((prompt, index) => /* @__PURE__ */ jsx21(
|
|
2649
2985
|
"button",
|
|
2650
2986
|
{
|
|
2651
2987
|
onClick: () => onPromptClick(prompt.text),
|
|
@@ -2660,11 +2996,11 @@ function WelcomeScreen({
|
|
|
2660
2996
|
"transition-all duration-200",
|
|
2661
2997
|
"group"
|
|
2662
2998
|
),
|
|
2663
|
-
children: /* @__PURE__ */
|
|
2664
|
-
/* @__PURE__ */
|
|
2665
|
-
/* @__PURE__ */
|
|
2666
|
-
/* @__PURE__ */
|
|
2667
|
-
prompt.description && /* @__PURE__ */
|
|
2999
|
+
children: /* @__PURE__ */ jsxs16("div", { className: "flex items-start gap-3", children: [
|
|
3000
|
+
/* @__PURE__ */ jsx21("div", { className: "flex-shrink-0 w-9 h-9 rounded-lg bg-neutral-100 dark:bg-neutral-700 flex items-center justify-center !text-neutral-500 dark:!text-neutral-400 group-hover:bg-blue-100 dark:group-hover:bg-blue-900/30 group-hover:!text-blue-600 dark:group-hover:!text-blue-400 transition-colors", children: prompt.icon || /* @__PURE__ */ jsx21(ArrowIcon, {}) }),
|
|
3001
|
+
/* @__PURE__ */ jsxs16("div", { className: "flex-1 min-w-0", children: [
|
|
3002
|
+
/* @__PURE__ */ jsx21("p", { className: "text-sm font-medium !text-neutral-900 dark:!text-white leading-snug", children: prompt.text }),
|
|
3003
|
+
prompt.description && /* @__PURE__ */ jsx21("p", { className: "text-xs !text-neutral-500 dark:!text-neutral-400 mt-1 line-clamp-2", children: prompt.description })
|
|
2668
3004
|
] })
|
|
2669
3005
|
] })
|
|
2670
3006
|
},
|
|
@@ -2675,7 +3011,7 @@ function WelcomeScreen({
|
|
|
2675
3011
|
}
|
|
2676
3012
|
|
|
2677
3013
|
// src/components/Chat/MessageList.tsx
|
|
2678
|
-
import { jsx as
|
|
3014
|
+
import { jsx as jsx22 } from "react/jsx-runtime";
|
|
2679
3015
|
function MessageList({
|
|
2680
3016
|
messages,
|
|
2681
3017
|
onAction,
|
|
@@ -2687,18 +3023,20 @@ function MessageList({
|
|
|
2687
3023
|
chatVariant,
|
|
2688
3024
|
onPromptClick,
|
|
2689
3025
|
enableWidgets,
|
|
2690
|
-
onWidgetRender
|
|
3026
|
+
onWidgetRender,
|
|
3027
|
+
persistentWidgetIds,
|
|
3028
|
+
toolCallStyle
|
|
2691
3029
|
}) {
|
|
2692
|
-
const listRef =
|
|
2693
|
-
const isNearBottomRef =
|
|
2694
|
-
const lastScrollHeightRef =
|
|
3030
|
+
const listRef = useRef6(null);
|
|
3031
|
+
const isNearBottomRef = useRef6(true);
|
|
3032
|
+
const lastScrollHeightRef = useRef6(0);
|
|
2695
3033
|
const handleScroll = () => {
|
|
2696
3034
|
if (listRef.current) {
|
|
2697
3035
|
const { scrollTop, scrollHeight, clientHeight } = listRef.current;
|
|
2698
3036
|
isNearBottomRef.current = scrollHeight - scrollTop - clientHeight < 100;
|
|
2699
3037
|
}
|
|
2700
3038
|
};
|
|
2701
|
-
|
|
3039
|
+
useEffect6(() => {
|
|
2702
3040
|
if (listRef.current && isNearBottomRef.current) {
|
|
2703
3041
|
const currentScrollHeight = listRef.current.scrollHeight;
|
|
2704
3042
|
if (currentScrollHeight !== lastScrollHeightRef.current) {
|
|
@@ -2707,7 +3045,7 @@ function MessageList({
|
|
|
2707
3045
|
}
|
|
2708
3046
|
}
|
|
2709
3047
|
}, [messages]);
|
|
2710
|
-
return /* @__PURE__ */
|
|
3048
|
+
return /* @__PURE__ */ jsx22("div", { ref: listRef, className: "apteva-message-list apteva-scrollbar-hidden", onScroll: handleScroll, children: messages.length === 0 ? /* @__PURE__ */ jsx22(
|
|
2711
3049
|
WelcomeScreen,
|
|
2712
3050
|
{
|
|
2713
3051
|
title: welcomeTitle,
|
|
@@ -2719,21 +3057,21 @@ function MessageList({
|
|
|
2719
3057
|
onPromptClick: onPromptClick || (() => {
|
|
2720
3058
|
})
|
|
2721
3059
|
}
|
|
2722
|
-
) : messages.map((message) => /* @__PURE__ */
|
|
3060
|
+
) : messages.map((message) => /* @__PURE__ */ jsx22("div", { className: message.role === "user" ? "apteva-message-row-user" : "apteva-message-row-assistant", children: /* @__PURE__ */ jsx22(Message, { message, onAction, enableWidgets, onWidgetRender, persistentWidgetIds, toolCallStyle }) }, message.id)) });
|
|
2723
3061
|
}
|
|
2724
3062
|
|
|
2725
3063
|
// src/components/Chat/Composer.tsx
|
|
2726
|
-
import { useState as
|
|
2727
|
-
import { Fragment as
|
|
3064
|
+
import { useState as useState6, useRef as useRef7 } from "react";
|
|
3065
|
+
import { Fragment as Fragment4, jsx as jsx23, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
2728
3066
|
function Composer({ onSendMessage, placeholder = "Type a message...", disabled = false, isLoading = false, onStop, onFileUpload, onSwitchMode }) {
|
|
2729
|
-
const [text, setText] =
|
|
2730
|
-
const [showMenu, setShowMenu] =
|
|
2731
|
-
const [pendingFiles, setPendingFiles] =
|
|
2732
|
-
const [fileError, setFileError] =
|
|
2733
|
-
const [isMultiLine, setIsMultiLine] =
|
|
2734
|
-
const textareaRef =
|
|
2735
|
-
const fileInputRef =
|
|
2736
|
-
const menuButtonRef =
|
|
3067
|
+
const [text, setText] = useState6("");
|
|
3068
|
+
const [showMenu, setShowMenu] = useState6(false);
|
|
3069
|
+
const [pendingFiles, setPendingFiles] = useState6([]);
|
|
3070
|
+
const [fileError, setFileError] = useState6(null);
|
|
3071
|
+
const [isMultiLine, setIsMultiLine] = useState6(false);
|
|
3072
|
+
const textareaRef = useRef7(null);
|
|
3073
|
+
const fileInputRef = useRef7(null);
|
|
3074
|
+
const menuButtonRef = useRef7(null);
|
|
2737
3075
|
const handleKeyDown = (e) => {
|
|
2738
3076
|
if (e.key === "Enter" && !e.shiftKey) {
|
|
2739
3077
|
e.preventDefault();
|
|
@@ -2809,35 +3147,35 @@ function Composer({ onSendMessage, placeholder = "Type a message...", disabled =
|
|
|
2809
3147
|
};
|
|
2810
3148
|
const getFileIcon = (mimeType) => {
|
|
2811
3149
|
if (mimeType.startsWith("image/")) {
|
|
2812
|
-
return /* @__PURE__ */
|
|
3150
|
+
return /* @__PURE__ */ jsx23("svg", { className: "w-4 h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx23("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z" }) });
|
|
2813
3151
|
}
|
|
2814
3152
|
if (mimeType === "application/pdf") {
|
|
2815
|
-
return /* @__PURE__ */
|
|
3153
|
+
return /* @__PURE__ */ jsx23("svg", { className: "w-4 h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx23("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z" }) });
|
|
2816
3154
|
}
|
|
2817
|
-
return /* @__PURE__ */
|
|
3155
|
+
return /* @__PURE__ */ jsx23("svg", { className: "w-4 h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx23("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z" }) });
|
|
2818
3156
|
};
|
|
2819
|
-
return /* @__PURE__ */
|
|
2820
|
-
fileError && /* @__PURE__ */
|
|
2821
|
-
/* @__PURE__ */
|
|
2822
|
-
/* @__PURE__ */
|
|
3157
|
+
return /* @__PURE__ */ jsxs17("div", { className: "px-4 py-3 relative", children: [
|
|
3158
|
+
fileError && /* @__PURE__ */ jsx23("div", { className: "apteva-file-error", children: /* @__PURE__ */ jsxs17("div", { className: "apteva-file-error-content", children: [
|
|
3159
|
+
/* @__PURE__ */ jsx23("svg", { fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx23("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" }) }),
|
|
3160
|
+
/* @__PURE__ */ jsx23("span", { children: fileError })
|
|
2823
3161
|
] }) }),
|
|
2824
|
-
pendingFiles.length > 0 && /* @__PURE__ */
|
|
2825
|
-
pf.preview ? /* @__PURE__ */
|
|
2826
|
-
/* @__PURE__ */
|
|
2827
|
-
/* @__PURE__ */
|
|
2828
|
-
/* @__PURE__ */
|
|
3162
|
+
pendingFiles.length > 0 && /* @__PURE__ */ jsx23("div", { className: "apteva-file-preview", children: pendingFiles.map((pf, index) => /* @__PURE__ */ jsxs17("div", { className: "apteva-file-item", children: [
|
|
3163
|
+
pf.preview ? /* @__PURE__ */ jsx23("img", { src: pf.preview, alt: pf.file.name, className: "apteva-file-thumb" }) : /* @__PURE__ */ jsx23("div", { className: "apteva-file-icon", children: getFileIcon(pf.file.type) }),
|
|
3164
|
+
/* @__PURE__ */ jsxs17("div", { className: "apteva-file-info", children: [
|
|
3165
|
+
/* @__PURE__ */ jsx23("span", { className: "apteva-file-name", children: pf.file.name }),
|
|
3166
|
+
/* @__PURE__ */ jsx23("span", { className: "apteva-file-size", children: formatFileSize(pf.file.size) })
|
|
2829
3167
|
] }),
|
|
2830
|
-
/* @__PURE__ */
|
|
3168
|
+
/* @__PURE__ */ jsx23(
|
|
2831
3169
|
"button",
|
|
2832
3170
|
{
|
|
2833
3171
|
onClick: () => removeFile(index),
|
|
2834
3172
|
className: "apteva-file-remove",
|
|
2835
3173
|
title: "Remove file",
|
|
2836
|
-
children: /* @__PURE__ */
|
|
3174
|
+
children: /* @__PURE__ */ jsx23("svg", { fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx23("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M6 18L18 6M6 6l12 12" }) })
|
|
2837
3175
|
}
|
|
2838
3176
|
)
|
|
2839
3177
|
] }, index)) }),
|
|
2840
|
-
/* @__PURE__ */
|
|
3178
|
+
/* @__PURE__ */ jsxs17(
|
|
2841
3179
|
"div",
|
|
2842
3180
|
{
|
|
2843
3181
|
className: "apteva-composer",
|
|
@@ -2847,20 +3185,20 @@ function Composer({ onSendMessage, placeholder = "Type a message...", disabled =
|
|
|
2847
3185
|
alignItems: "end"
|
|
2848
3186
|
},
|
|
2849
3187
|
children: [
|
|
2850
|
-
/* @__PURE__ */
|
|
2851
|
-
/* @__PURE__ */
|
|
3188
|
+
/* @__PURE__ */ jsxs17("div", { className: "relative flex-shrink-0 self-end", style: { gridArea: "plus" }, children: [
|
|
3189
|
+
/* @__PURE__ */ jsx23(
|
|
2852
3190
|
"button",
|
|
2853
3191
|
{
|
|
2854
3192
|
ref: menuButtonRef,
|
|
2855
3193
|
onClick: () => setShowMenu(!showMenu),
|
|
2856
3194
|
className: "apteva-composer-menu-btn w-8 h-8 rounded-lg flex items-center justify-center transition-all !text-neutral-700 dark:!text-neutral-300 hover:bg-neutral-100 dark:hover:bg-neutral-800",
|
|
2857
3195
|
title: "More options",
|
|
2858
|
-
children: /* @__PURE__ */
|
|
3196
|
+
children: /* @__PURE__ */ jsx23("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsx23("path", { d: "M10 5v10M5 10h10", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) })
|
|
2859
3197
|
}
|
|
2860
3198
|
),
|
|
2861
|
-
showMenu && /* @__PURE__ */
|
|
2862
|
-
/* @__PURE__ */
|
|
2863
|
-
/* @__PURE__ */
|
|
3199
|
+
showMenu && /* @__PURE__ */ jsxs17(Fragment4, { children: [
|
|
3200
|
+
/* @__PURE__ */ jsx23("div", { className: "fixed inset-0 z-[9998]", onClick: () => setShowMenu(false) }),
|
|
3201
|
+
/* @__PURE__ */ jsxs17(
|
|
2864
3202
|
"div",
|
|
2865
3203
|
{
|
|
2866
3204
|
className: "apteva-composer-menu fixed bg-neutral-800 dark:bg-neutral-800 rounded-xl shadow-lg overflow-hidden z-[9999] min-w-[200px]",
|
|
@@ -2869,7 +3207,7 @@ function Composer({ onSendMessage, placeholder = "Type a message...", disabled =
|
|
|
2869
3207
|
bottom: window.innerHeight - (menuButtonRef.current?.getBoundingClientRect().top ?? 0) + 8
|
|
2870
3208
|
},
|
|
2871
3209
|
children: [
|
|
2872
|
-
/* @__PURE__ */
|
|
3210
|
+
/* @__PURE__ */ jsxs17(
|
|
2873
3211
|
"button",
|
|
2874
3212
|
{
|
|
2875
3213
|
onClick: () => {
|
|
@@ -2878,12 +3216,12 @@ function Composer({ onSendMessage, placeholder = "Type a message...", disabled =
|
|
|
2878
3216
|
},
|
|
2879
3217
|
className: "w-full flex items-center gap-3 px-4 py-3 hover:bg-neutral-700 dark:hover:bg-neutral-700 transition-colors !text-white text-left",
|
|
2880
3218
|
children: [
|
|
2881
|
-
/* @__PURE__ */
|
|
2882
|
-
/* @__PURE__ */
|
|
3219
|
+
/* @__PURE__ */ jsx23("svg", { width: "18", height: "18", viewBox: "0 0 20 20", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsx23("path", { d: "M10.5 3.5L5.5 8.5C4.67157 9.32843 4.67157 10.6716 5.5 11.5C6.32843 12.3284 7.67157 12.3284 8.5 11.5L14.5 5.5C15.8807 4.11929 15.8807 1.88071 14.5 0.5C13.1193 -0.880711 10.8807 -0.880711 9.5 0.5L3.5 6.5C1.56846 8.43154 1.56846 11.5685 3.5 13.5C5.43154 15.4315 8.56846 15.4315 10.5 13.5L15.5 8.5", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round", transform: "translate(2, 3)" }) }),
|
|
3220
|
+
/* @__PURE__ */ jsx23("span", { className: "!text-sm font-medium", children: "Add photos & files" })
|
|
2883
3221
|
]
|
|
2884
3222
|
}
|
|
2885
3223
|
),
|
|
2886
|
-
onSwitchMode && /* @__PURE__ */
|
|
3224
|
+
onSwitchMode && /* @__PURE__ */ jsxs17(
|
|
2887
3225
|
"button",
|
|
2888
3226
|
{
|
|
2889
3227
|
onClick: () => {
|
|
@@ -2892,8 +3230,8 @@ function Composer({ onSendMessage, placeholder = "Type a message...", disabled =
|
|
|
2892
3230
|
},
|
|
2893
3231
|
className: "w-full flex items-center gap-3 px-4 py-3 hover:bg-neutral-700 dark:hover:bg-neutral-700 transition-colors !text-white text-left border-t border-neutral-700 dark:border-neutral-700",
|
|
2894
3232
|
children: [
|
|
2895
|
-
/* @__PURE__ */
|
|
2896
|
-
/* @__PURE__ */
|
|
3233
|
+
/* @__PURE__ */ jsx23("svg", { className: "w-4.5 h-4.5", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx23("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M13 10V3L4 14h7v7l9-11h-7z" }) }),
|
|
3234
|
+
/* @__PURE__ */ jsx23("span", { className: "!text-sm font-medium", children: "Switch to command mode" })
|
|
2897
3235
|
]
|
|
2898
3236
|
}
|
|
2899
3237
|
)
|
|
@@ -2902,7 +3240,7 @@ function Composer({ onSendMessage, placeholder = "Type a message...", disabled =
|
|
|
2902
3240
|
)
|
|
2903
3241
|
] })
|
|
2904
3242
|
] }),
|
|
2905
|
-
/* @__PURE__ */
|
|
3243
|
+
/* @__PURE__ */ jsx23(
|
|
2906
3244
|
"textarea",
|
|
2907
3245
|
{
|
|
2908
3246
|
ref: textareaRef,
|
|
@@ -2916,28 +3254,28 @@ function Composer({ onSendMessage, placeholder = "Type a message...", disabled =
|
|
|
2916
3254
|
rows: 1
|
|
2917
3255
|
}
|
|
2918
3256
|
),
|
|
2919
|
-
/* @__PURE__ */
|
|
3257
|
+
/* @__PURE__ */ jsx23("div", { className: "self-end", style: { gridArea: "send" }, children: isLoading && onStop ? /* @__PURE__ */ jsx23(
|
|
2920
3258
|
"button",
|
|
2921
3259
|
{
|
|
2922
3260
|
onClick: onStop,
|
|
2923
3261
|
className: "apteva-composer-stop-btn",
|
|
2924
3262
|
title: "Stop generation",
|
|
2925
|
-
children: /* @__PURE__ */
|
|
3263
|
+
children: /* @__PURE__ */ jsx23("svg", { width: "14", height: "14", viewBox: "0 0 14 14", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsx23("rect", { x: "2", y: "2", width: "10", height: "10", rx: "1", fill: "currentColor" }) })
|
|
2926
3264
|
}
|
|
2927
|
-
) : /* @__PURE__ */
|
|
3265
|
+
) : /* @__PURE__ */ jsx23(
|
|
2928
3266
|
"button",
|
|
2929
3267
|
{
|
|
2930
3268
|
onClick: handleSend,
|
|
2931
3269
|
disabled: !text.trim() && pendingFiles.length === 0 || disabled,
|
|
2932
3270
|
className: "apteva-composer-send-btn w-8 h-8 rounded-lg flex items-center justify-center font-bold transition-all flex-shrink-0 border border-neutral-300 dark:border-neutral-600 bg-white dark:bg-neutral-800 !text-neutral-700 dark:!text-neutral-300 hover:bg-neutral-50 dark:hover:bg-neutral-700 disabled:opacity-30 disabled:cursor-not-allowed !text-lg",
|
|
2933
3271
|
title: "Send message",
|
|
2934
|
-
children: /* @__PURE__ */
|
|
3272
|
+
children: /* @__PURE__ */ jsx23("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsx23("path", { d: "M8 3L8 13M8 3L4 7M8 3L12 7", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) })
|
|
2935
3273
|
}
|
|
2936
3274
|
) })
|
|
2937
3275
|
]
|
|
2938
3276
|
}
|
|
2939
3277
|
),
|
|
2940
|
-
/* @__PURE__ */
|
|
3278
|
+
/* @__PURE__ */ jsx23(
|
|
2941
3279
|
"input",
|
|
2942
3280
|
{
|
|
2943
3281
|
ref: fileInputRef,
|
|
@@ -2952,8 +3290,8 @@ function Composer({ onSendMessage, placeholder = "Type a message...", disabled =
|
|
|
2952
3290
|
}
|
|
2953
3291
|
|
|
2954
3292
|
// src/components/Chat/CommandComposer.tsx
|
|
2955
|
-
import { useState as
|
|
2956
|
-
import { Fragment as
|
|
3293
|
+
import { useState as useState7, useRef as useRef8 } from "react";
|
|
3294
|
+
import { Fragment as Fragment5, jsx as jsx24, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
2957
3295
|
function CommandComposer({
|
|
2958
3296
|
onExecute,
|
|
2959
3297
|
state,
|
|
@@ -2970,13 +3308,13 @@ function CommandComposer({
|
|
|
2970
3308
|
placeholder = "Enter your command...",
|
|
2971
3309
|
disabled = false
|
|
2972
3310
|
}) {
|
|
2973
|
-
const [input, setInput] =
|
|
2974
|
-
const [pendingFiles, setPendingFiles] =
|
|
2975
|
-
const [fileError, setFileError] =
|
|
2976
|
-
const [showMenu, setShowMenu] =
|
|
2977
|
-
const inputRef =
|
|
2978
|
-
const fileInputRef =
|
|
2979
|
-
const menuButtonRef =
|
|
3311
|
+
const [input, setInput] = useState7("");
|
|
3312
|
+
const [pendingFiles, setPendingFiles] = useState7([]);
|
|
3313
|
+
const [fileError, setFileError] = useState7(null);
|
|
3314
|
+
const [showMenu, setShowMenu] = useState7(false);
|
|
3315
|
+
const inputRef = useRef8(null);
|
|
3316
|
+
const fileInputRef = useRef8(null);
|
|
3317
|
+
const menuButtonRef = useRef8(null);
|
|
2980
3318
|
const handleSubmit = () => {
|
|
2981
3319
|
const hasText = input.trim();
|
|
2982
3320
|
const hasFiles = pendingFiles.length > 0;
|
|
@@ -3043,12 +3381,12 @@ function CommandComposer({
|
|
|
3043
3381
|
};
|
|
3044
3382
|
const getFileIcon = (mimeType) => {
|
|
3045
3383
|
if (mimeType.startsWith("image/")) {
|
|
3046
|
-
return /* @__PURE__ */
|
|
3384
|
+
return /* @__PURE__ */ jsx24("svg", { className: "w-4 h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx24("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z" }) });
|
|
3047
3385
|
}
|
|
3048
3386
|
if (mimeType === "application/pdf") {
|
|
3049
|
-
return /* @__PURE__ */
|
|
3387
|
+
return /* @__PURE__ */ jsx24("svg", { className: "w-4 h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx24("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z" }) });
|
|
3050
3388
|
}
|
|
3051
|
-
return /* @__PURE__ */
|
|
3389
|
+
return /* @__PURE__ */ jsx24("svg", { className: "w-4 h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx24("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z" }) });
|
|
3052
3390
|
};
|
|
3053
3391
|
const getDisplayContent = () => {
|
|
3054
3392
|
if (state === "loading") {
|
|
@@ -3073,12 +3411,12 @@ function CommandComposer({
|
|
|
3073
3411
|
};
|
|
3074
3412
|
const isShowingResult = state !== "idle";
|
|
3075
3413
|
const { text: displayContent, isToolCall } = getDisplayContent();
|
|
3076
|
-
return /* @__PURE__ */
|
|
3077
|
-
fileError && /* @__PURE__ */
|
|
3078
|
-
/* @__PURE__ */
|
|
3079
|
-
/* @__PURE__ */
|
|
3414
|
+
return /* @__PURE__ */ jsxs18("div", { className: "w-full relative", children: [
|
|
3415
|
+
fileError && /* @__PURE__ */ jsx24("div", { className: "apteva-file-error", style: { top: "-3rem", bottom: "auto" }, children: /* @__PURE__ */ jsxs18("div", { className: "apteva-file-error-content", children: [
|
|
3416
|
+
/* @__PURE__ */ jsx24("svg", { fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx24("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" }) }),
|
|
3417
|
+
/* @__PURE__ */ jsx24("span", { children: fileError })
|
|
3080
3418
|
] }) }),
|
|
3081
|
-
/* @__PURE__ */
|
|
3419
|
+
/* @__PURE__ */ jsxs18(
|
|
3082
3420
|
"div",
|
|
3083
3421
|
{
|
|
3084
3422
|
className: cn(
|
|
@@ -3090,21 +3428,21 @@ function CommandComposer({
|
|
|
3090
3428
|
state === "error" && "border-red-400 dark:border-red-500"
|
|
3091
3429
|
),
|
|
3092
3430
|
children: [
|
|
3093
|
-
/* @__PURE__ */
|
|
3094
|
-
state === "idle" && /* @__PURE__ */
|
|
3095
|
-
/* @__PURE__ */
|
|
3431
|
+
/* @__PURE__ */ jsxs18("div", { className: "w-8 h-8 flex items-center justify-center flex-shrink-0", children: [
|
|
3432
|
+
state === "idle" && /* @__PURE__ */ jsxs18("div", { className: "relative", children: [
|
|
3433
|
+
/* @__PURE__ */ jsx24(
|
|
3096
3434
|
"button",
|
|
3097
3435
|
{
|
|
3098
3436
|
ref: menuButtonRef,
|
|
3099
3437
|
onClick: () => setShowMenu(!showMenu),
|
|
3100
3438
|
className: "apteva-composer-menu-btn w-8 h-8 rounded-lg flex items-center justify-center transition-all !text-neutral-500 dark:!text-neutral-400 hover:!text-neutral-700 dark:hover:!text-neutral-200 hover:bg-neutral-100 dark:hover:bg-neutral-800",
|
|
3101
3439
|
title: "More options",
|
|
3102
|
-
children: /* @__PURE__ */
|
|
3440
|
+
children: /* @__PURE__ */ jsx24("svg", { width: "18", height: "18", viewBox: "0 0 20 20", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsx24("path", { d: "M10 5v10M5 10h10", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) })
|
|
3103
3441
|
}
|
|
3104
3442
|
),
|
|
3105
|
-
showMenu && /* @__PURE__ */
|
|
3106
|
-
/* @__PURE__ */
|
|
3107
|
-
/* @__PURE__ */
|
|
3443
|
+
showMenu && /* @__PURE__ */ jsxs18(Fragment5, { children: [
|
|
3444
|
+
/* @__PURE__ */ jsx24("div", { className: "fixed inset-0 z-[9998]", onClick: () => setShowMenu(false) }),
|
|
3445
|
+
/* @__PURE__ */ jsxs18(
|
|
3108
3446
|
"div",
|
|
3109
3447
|
{
|
|
3110
3448
|
className: "apteva-composer-menu fixed bg-neutral-800 dark:bg-neutral-800 rounded-xl shadow-lg overflow-hidden z-[9999] min-w-[200px]",
|
|
@@ -3113,7 +3451,7 @@ function CommandComposer({
|
|
|
3113
3451
|
top: (menuButtonRef.current?.getBoundingClientRect().bottom ?? 0) + 8
|
|
3114
3452
|
},
|
|
3115
3453
|
children: [
|
|
3116
|
-
/* @__PURE__ */
|
|
3454
|
+
/* @__PURE__ */ jsxs18(
|
|
3117
3455
|
"button",
|
|
3118
3456
|
{
|
|
3119
3457
|
onClick: () => {
|
|
@@ -3122,12 +3460,12 @@ function CommandComposer({
|
|
|
3122
3460
|
},
|
|
3123
3461
|
className: "w-full flex items-center gap-3 px-4 py-3 hover:bg-neutral-700 dark:hover:bg-neutral-700 transition-colors !text-white text-left",
|
|
3124
3462
|
children: [
|
|
3125
|
-
/* @__PURE__ */
|
|
3126
|
-
/* @__PURE__ */
|
|
3463
|
+
/* @__PURE__ */ jsx24("svg", { width: "18", height: "18", viewBox: "0 0 20 20", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsx24("path", { d: "M10.5 3.5L5.5 8.5C4.67157 9.32843 4.67157 10.6716 5.5 11.5C6.32843 12.3284 7.67157 12.3284 8.5 11.5L14.5 5.5C15.8807 4.11929 15.8807 1.88071 14.5 0.5C13.1193 -0.880711 10.8807 -0.880711 9.5 0.5L3.5 6.5C1.56846 8.43154 1.56846 11.5685 3.5 13.5C5.43154 15.4315 8.56846 15.4315 10.5 13.5L15.5 8.5", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round", transform: "translate(2, 3)" }) }),
|
|
3464
|
+
/* @__PURE__ */ jsx24("span", { className: "!text-sm font-medium", children: "Add photos & files" })
|
|
3127
3465
|
]
|
|
3128
3466
|
}
|
|
3129
3467
|
),
|
|
3130
|
-
onExpand && /* @__PURE__ */
|
|
3468
|
+
onExpand && /* @__PURE__ */ jsxs18(
|
|
3131
3469
|
"button",
|
|
3132
3470
|
{
|
|
3133
3471
|
onClick: () => {
|
|
@@ -3136,8 +3474,8 @@ function CommandComposer({
|
|
|
3136
3474
|
},
|
|
3137
3475
|
className: "w-full flex items-center gap-3 px-4 py-3 hover:bg-neutral-700 dark:hover:bg-neutral-700 transition-colors !text-white text-left border-t border-neutral-700 dark:border-neutral-700",
|
|
3138
3476
|
children: [
|
|
3139
|
-
/* @__PURE__ */
|
|
3140
|
-
/* @__PURE__ */
|
|
3477
|
+
/* @__PURE__ */ jsx24("svg", { className: "w-4.5 h-4.5", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx24("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z" }) }),
|
|
3478
|
+
/* @__PURE__ */ jsx24("span", { className: "!text-sm font-medium", children: "Expand to chat" })
|
|
3141
3479
|
]
|
|
3142
3480
|
}
|
|
3143
3481
|
)
|
|
@@ -3146,22 +3484,22 @@ function CommandComposer({
|
|
|
3146
3484
|
)
|
|
3147
3485
|
] })
|
|
3148
3486
|
] }),
|
|
3149
|
-
state === "loading" && !toolName && /* @__PURE__ */
|
|
3150
|
-
state === "loading" && toolName && /* @__PURE__ */
|
|
3487
|
+
state === "loading" && !toolName && /* @__PURE__ */ jsx24("div", { className: "w-4 h-4 border-2 border-blue-200 border-t-blue-500 rounded-full animate-spin" }),
|
|
3488
|
+
state === "loading" && toolName && /* @__PURE__ */ jsx24("div", { className: "w-2 h-2 rounded-full bg-blue-500 animate-pulse" })
|
|
3151
3489
|
] }),
|
|
3152
|
-
pendingFiles.length > 0 && state === "idle" && /* @__PURE__ */
|
|
3153
|
-
pf.preview ? /* @__PURE__ */
|
|
3154
|
-
/* @__PURE__ */
|
|
3490
|
+
pendingFiles.length > 0 && state === "idle" && /* @__PURE__ */ jsx24("div", { className: "apteva-file-badges", children: pendingFiles.map((pf, index) => /* @__PURE__ */ jsxs18("div", { className: "apteva-file-badge", title: pf.file.name, children: [
|
|
3491
|
+
pf.preview ? /* @__PURE__ */ jsx24("img", { src: pf.preview, alt: pf.file.name, className: "apteva-file-badge-img" }) : /* @__PURE__ */ jsx24("span", { className: "apteva-file-badge-icon", children: getFileIcon(pf.file.type) }),
|
|
3492
|
+
/* @__PURE__ */ jsx24(
|
|
3155
3493
|
"button",
|
|
3156
3494
|
{
|
|
3157
3495
|
onClick: () => removeFile(index),
|
|
3158
3496
|
className: "apteva-file-badge-remove",
|
|
3159
3497
|
title: "Remove",
|
|
3160
|
-
children: /* @__PURE__ */
|
|
3498
|
+
children: /* @__PURE__ */ jsx24("svg", { fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx24("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M6 18L18 6M6 6l12 12" }) })
|
|
3161
3499
|
}
|
|
3162
3500
|
)
|
|
3163
3501
|
] }, index)) }),
|
|
3164
|
-
state === "idle" ? /* @__PURE__ */
|
|
3502
|
+
state === "idle" ? /* @__PURE__ */ jsx24(
|
|
3165
3503
|
"textarea",
|
|
3166
3504
|
{
|
|
3167
3505
|
ref: inputRef,
|
|
@@ -3179,7 +3517,7 @@ function CommandComposer({
|
|
|
3179
3517
|
),
|
|
3180
3518
|
style: { minHeight: "24px", maxHeight: "120px" }
|
|
3181
3519
|
}
|
|
3182
|
-
) : /* @__PURE__ */
|
|
3520
|
+
) : /* @__PURE__ */ jsx24(
|
|
3183
3521
|
"div",
|
|
3184
3522
|
{
|
|
3185
3523
|
className: cn(
|
|
@@ -3190,14 +3528,14 @@ function CommandComposer({
|
|
|
3190
3528
|
state === "error" && "!text-red-600 dark:!text-red-400",
|
|
3191
3529
|
state === "plan-pending" && "!text-amber-700 dark:!text-amber-300"
|
|
3192
3530
|
),
|
|
3193
|
-
children: isToolCall ? /* @__PURE__ */
|
|
3194
|
-
/* @__PURE__ */
|
|
3195
|
-
/* @__PURE__ */
|
|
3531
|
+
children: isToolCall ? /* @__PURE__ */ jsxs18(Fragment5, { children: [
|
|
3532
|
+
/* @__PURE__ */ jsx24("span", { className: "font-mono", children: displayContent }),
|
|
3533
|
+
/* @__PURE__ */ jsx24("span", { className: "text-neutral-400 dark:text-neutral-500", children: "Running..." })
|
|
3196
3534
|
] }) : displayContent
|
|
3197
3535
|
}
|
|
3198
3536
|
),
|
|
3199
|
-
/* @__PURE__ */
|
|
3200
|
-
/* @__PURE__ */
|
|
3537
|
+
/* @__PURE__ */ jsx24("div", { className: "w-8 h-8 flex items-center justify-center flex-shrink-0", children: state === "plan-pending" ? /* @__PURE__ */ jsxs18("div", { className: "flex items-center gap-1", children: [
|
|
3538
|
+
/* @__PURE__ */ jsx24(
|
|
3201
3539
|
"button",
|
|
3202
3540
|
{
|
|
3203
3541
|
onClick: onApprove,
|
|
@@ -3205,7 +3543,7 @@ function CommandComposer({
|
|
|
3205
3543
|
children: "Approve"
|
|
3206
3544
|
}
|
|
3207
3545
|
),
|
|
3208
|
-
/* @__PURE__ */
|
|
3546
|
+
/* @__PURE__ */ jsx24(
|
|
3209
3547
|
"button",
|
|
3210
3548
|
{
|
|
3211
3549
|
onClick: onReject,
|
|
@@ -3213,26 +3551,26 @@ function CommandComposer({
|
|
|
3213
3551
|
children: "Modify"
|
|
3214
3552
|
}
|
|
3215
3553
|
)
|
|
3216
|
-
] }) : /* @__PURE__ */
|
|
3217
|
-
state === "loading" && onStop && /* @__PURE__ */
|
|
3554
|
+
] }) : /* @__PURE__ */ jsxs18(Fragment5, { children: [
|
|
3555
|
+
state === "loading" && onStop && /* @__PURE__ */ jsx24(
|
|
3218
3556
|
"button",
|
|
3219
3557
|
{
|
|
3220
3558
|
onClick: onStop,
|
|
3221
3559
|
className: "apteva-composer-stop-btn",
|
|
3222
3560
|
title: "Stop generation",
|
|
3223
|
-
children: /* @__PURE__ */
|
|
3561
|
+
children: /* @__PURE__ */ jsx24("svg", { width: "14", height: "14", viewBox: "0 0 14 14", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsx24("rect", { x: "2", y: "2", width: "10", height: "10", rx: "1", fill: "currentColor" }) })
|
|
3224
3562
|
}
|
|
3225
3563
|
),
|
|
3226
|
-
(state === "success" || state === "error") && /* @__PURE__ */
|
|
3564
|
+
(state === "success" || state === "error") && /* @__PURE__ */ jsx24(
|
|
3227
3565
|
"button",
|
|
3228
3566
|
{
|
|
3229
3567
|
onClick: handleNewCommand,
|
|
3230
3568
|
className: "w-8 h-8 rounded-lg flex items-center justify-center !text-neutral-400 hover:!text-neutral-600 dark:hover:!text-neutral-300 hover:bg-neutral-100 dark:hover:bg-neutral-800 transition-colors",
|
|
3231
3569
|
title: "New command",
|
|
3232
|
-
children: /* @__PURE__ */
|
|
3570
|
+
children: /* @__PURE__ */ jsx24("svg", { className: "w-4 h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx24("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M6 18L18 6M6 6l12 12" }) })
|
|
3233
3571
|
}
|
|
3234
3572
|
),
|
|
3235
|
-
state === "idle" && /* @__PURE__ */
|
|
3573
|
+
state === "idle" && /* @__PURE__ */ jsx24(
|
|
3236
3574
|
"button",
|
|
3237
3575
|
{
|
|
3238
3576
|
onClick: handleSubmit,
|
|
@@ -3244,14 +3582,14 @@ function CommandComposer({
|
|
|
3244
3582
|
input.trim() || pendingFiles.length > 0 ? "bg-neutral-900 dark:bg-white !text-white dark:!text-neutral-900 border-neutral-900 dark:border-white" : "bg-white dark:bg-neutral-800 !text-neutral-400"
|
|
3245
3583
|
),
|
|
3246
3584
|
title: "Execute command",
|
|
3247
|
-
children: /* @__PURE__ */
|
|
3585
|
+
children: /* @__PURE__ */ jsx24("svg", { className: "w-4 h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx24("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M5 12h14M12 5l7 7-7 7" }) })
|
|
3248
3586
|
}
|
|
3249
3587
|
)
|
|
3250
3588
|
] }) })
|
|
3251
3589
|
]
|
|
3252
3590
|
}
|
|
3253
3591
|
),
|
|
3254
|
-
/* @__PURE__ */
|
|
3592
|
+
/* @__PURE__ */ jsx24(
|
|
3255
3593
|
"input",
|
|
3256
3594
|
{
|
|
3257
3595
|
ref: fileInputRef,
|
|
@@ -3448,8 +3786,43 @@ var AptevaClient = class {
|
|
|
3448
3786
|
};
|
|
3449
3787
|
var aptevaClient = new AptevaClient();
|
|
3450
3788
|
|
|
3789
|
+
// src/components/Chat/PersistentWidgetPanel.tsx
|
|
3790
|
+
import { useState as useState8 } from "react";
|
|
3791
|
+
import { jsx as jsx25, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
3792
|
+
function PersistentWidgetPanel({ widgets, onAction }) {
|
|
3793
|
+
const [collapsed, setCollapsed] = useState8(false);
|
|
3794
|
+
if (widgets.length === 0) return null;
|
|
3795
|
+
return /* @__PURE__ */ jsxs19("div", { className: "apteva-persistent-panel border-b border-neutral-200 dark:border-neutral-700 bg-neutral-50 dark:bg-neutral-900", children: [
|
|
3796
|
+
/* @__PURE__ */ jsxs19("div", { className: "flex items-center justify-between px-3 py-1.5", children: [
|
|
3797
|
+
/* @__PURE__ */ jsxs19("div", { className: "flex items-center gap-2", children: [
|
|
3798
|
+
/* @__PURE__ */ jsx25("div", { className: "w-1.5 h-1.5 rounded-full bg-emerald-500 animate-pulse" }),
|
|
3799
|
+
/* @__PURE__ */ jsx25("span", { className: "text-xs font-medium text-neutral-500 dark:text-neutral-400 uppercase tracking-wider", children: "Live" })
|
|
3800
|
+
] }),
|
|
3801
|
+
/* @__PURE__ */ jsx25(
|
|
3802
|
+
"button",
|
|
3803
|
+
{
|
|
3804
|
+
onClick: () => setCollapsed((c) => !c),
|
|
3805
|
+
className: "p-1 rounded text-neutral-400 hover:text-neutral-600 dark:hover:text-neutral-300 hover:bg-neutral-200 dark:hover:bg-neutral-700 transition-colors",
|
|
3806
|
+
children: /* @__PURE__ */ jsx25(
|
|
3807
|
+
"svg",
|
|
3808
|
+
{
|
|
3809
|
+
className: cn("w-3.5 h-3.5 transition-transform", collapsed && "rotate-180"),
|
|
3810
|
+
fill: "none",
|
|
3811
|
+
viewBox: "0 0 24 24",
|
|
3812
|
+
stroke: "currentColor",
|
|
3813
|
+
strokeWidth: 2,
|
|
3814
|
+
children: /* @__PURE__ */ jsx25("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M19 9l-7 7-7-7" })
|
|
3815
|
+
}
|
|
3816
|
+
)
|
|
3817
|
+
}
|
|
3818
|
+
)
|
|
3819
|
+
] }),
|
|
3820
|
+
!collapsed && /* @__PURE__ */ jsx25("div", { className: "px-3 pb-3 flex flex-col gap-3", children: widgets.map((widget) => /* @__PURE__ */ jsx25(WidgetRenderer, { widget, onAction }, widget.id)) })
|
|
3821
|
+
] });
|
|
3822
|
+
}
|
|
3823
|
+
|
|
3451
3824
|
// src/components/Chat/Chat.tsx
|
|
3452
|
-
import { Fragment as
|
|
3825
|
+
import { Fragment as Fragment6, jsx as jsx26, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
3453
3826
|
var Chat = forwardRef(function Chat2({
|
|
3454
3827
|
agentId,
|
|
3455
3828
|
threadId,
|
|
@@ -3490,6 +3863,8 @@ var Chat = forwardRef(function Chat2({
|
|
|
3490
3863
|
showHeader = true,
|
|
3491
3864
|
headerTitle = "Chat",
|
|
3492
3865
|
onHeaderBack,
|
|
3866
|
+
// Tool call display
|
|
3867
|
+
toolCallStyle = "card",
|
|
3493
3868
|
// Widget detection
|
|
3494
3869
|
enableWidgets = false,
|
|
3495
3870
|
availableWidgets,
|
|
@@ -3497,25 +3872,49 @@ var Chat = forwardRef(function Chat2({
|
|
|
3497
3872
|
onWidgetRender,
|
|
3498
3873
|
className
|
|
3499
3874
|
}, ref) {
|
|
3500
|
-
const [messages, setMessages] =
|
|
3501
|
-
const [isLoading, setIsLoading] =
|
|
3502
|
-
const [currentThreadId, setCurrentThreadId] =
|
|
3503
|
-
const [mode, setMode] =
|
|
3504
|
-
const [chatToolName, setChatToolName] =
|
|
3505
|
-
const [commandState, setCommandState] =
|
|
3506
|
-
const [commandResult, setCommandResult] =
|
|
3507
|
-
const [commandError, setCommandError] =
|
|
3508
|
-
const [progress, setProgress] =
|
|
3509
|
-
const [commandInput, setCommandInput] =
|
|
3510
|
-
const [streamedContent, setStreamedContent] =
|
|
3511
|
-
const [currentToolName, setCurrentToolName] =
|
|
3512
|
-
const [currentRequestId, setCurrentRequestId] =
|
|
3513
|
-
const [plan, setPlan] =
|
|
3514
|
-
const [pendingCommand, setPendingCommand] =
|
|
3515
|
-
const [internalPlanMode, setInternalPlanMode] =
|
|
3516
|
-
const [showSettingsMenu, setShowSettingsMenu] =
|
|
3517
|
-
const fileInputRef =
|
|
3518
|
-
const
|
|
3875
|
+
const [messages, setMessages] = useState9(initialMessages);
|
|
3876
|
+
const [isLoading, setIsLoading] = useState9(false);
|
|
3877
|
+
const [currentThreadId, setCurrentThreadId] = useState9(threadId || null);
|
|
3878
|
+
const [mode, setMode] = useState9(initialMode);
|
|
3879
|
+
const [chatToolName, setChatToolName] = useState9(null);
|
|
3880
|
+
const [commandState, setCommandState] = useState9("idle");
|
|
3881
|
+
const [commandResult, setCommandResult] = useState9(null);
|
|
3882
|
+
const [commandError, setCommandError] = useState9(null);
|
|
3883
|
+
const [progress, setProgress] = useState9(0);
|
|
3884
|
+
const [commandInput, setCommandInput] = useState9("");
|
|
3885
|
+
const [streamedContent, setStreamedContent] = useState9("");
|
|
3886
|
+
const [currentToolName, setCurrentToolName] = useState9(null);
|
|
3887
|
+
const [currentRequestId, setCurrentRequestId] = useState9(null);
|
|
3888
|
+
const [plan, setPlan] = useState9("");
|
|
3889
|
+
const [pendingCommand, setPendingCommand] = useState9("");
|
|
3890
|
+
const [internalPlanMode, setInternalPlanMode] = useState9(planMode);
|
|
3891
|
+
const [showSettingsMenu, setShowSettingsMenu] = useState9(false);
|
|
3892
|
+
const fileInputRef = useRef9(null);
|
|
3893
|
+
const [persistentWidgets, setPersistentWidgets] = useState9(/* @__PURE__ */ new Map());
|
|
3894
|
+
const updatePersistentWidgets = useCallback2((msgs) => {
|
|
3895
|
+
setPersistentWidgets((prev) => {
|
|
3896
|
+
const next = new Map(prev);
|
|
3897
|
+
let changed = false;
|
|
3898
|
+
for (const msg of msgs) {
|
|
3899
|
+
if (!msg.widgets) continue;
|
|
3900
|
+
for (const w of msg.widgets) {
|
|
3901
|
+
if (!w.persistent) continue;
|
|
3902
|
+
const existing = next.get(w.id);
|
|
3903
|
+
if (!existing || existing !== w) {
|
|
3904
|
+
next.set(w.id, w);
|
|
3905
|
+
changed = true;
|
|
3906
|
+
}
|
|
3907
|
+
}
|
|
3908
|
+
}
|
|
3909
|
+
return changed ? next : prev;
|
|
3910
|
+
});
|
|
3911
|
+
}, []);
|
|
3912
|
+
useEffect7(() => {
|
|
3913
|
+
updatePersistentWidgets(messages);
|
|
3914
|
+
}, [messages, updatePersistentWidgets]);
|
|
3915
|
+
const persistentWidgetList = useMemo2(() => Array.from(persistentWidgets.values()), [persistentWidgets]);
|
|
3916
|
+
const persistentWidgetIds = useMemo2(() => new Set(persistentWidgets.keys()), [persistentWidgets]);
|
|
3917
|
+
const handleSendMessageRef = useRef9(null);
|
|
3519
3918
|
useImperativeHandle(ref, () => ({
|
|
3520
3919
|
sendMessage: async (text) => {
|
|
3521
3920
|
if (handleSendMessageRef.current) {
|
|
@@ -3536,7 +3935,7 @@ var Chat = forwardRef(function Chat2({
|
|
|
3536
3935
|
return context ? `${context}
|
|
3537
3936
|
${widgetContext}` : widgetContext;
|
|
3538
3937
|
}, [context, enableWidgets, availableWidgets, compactWidgetContext]);
|
|
3539
|
-
|
|
3938
|
+
useEffect7(() => {
|
|
3540
3939
|
if (apiUrl || apiKey) {
|
|
3541
3940
|
aptevaClient.configure({
|
|
3542
3941
|
...apiUrl && { apiUrl },
|
|
@@ -3544,15 +3943,15 @@ ${widgetContext}` : widgetContext;
|
|
|
3544
3943
|
});
|
|
3545
3944
|
}
|
|
3546
3945
|
}, [apiUrl, apiKey]);
|
|
3547
|
-
|
|
3946
|
+
useEffect7(() => {
|
|
3548
3947
|
if (threadId) {
|
|
3549
3948
|
onThreadChange?.(threadId);
|
|
3550
3949
|
}
|
|
3551
3950
|
}, [threadId, onThreadChange]);
|
|
3552
|
-
|
|
3951
|
+
useEffect7(() => {
|
|
3553
3952
|
setInternalPlanMode(planMode);
|
|
3554
3953
|
}, [planMode]);
|
|
3555
|
-
|
|
3954
|
+
useEffect7(() => {
|
|
3556
3955
|
const handleClickOutside = (event) => {
|
|
3557
3956
|
const target = event.target;
|
|
3558
3957
|
if (showSettingsMenu && !target.closest(".settings-menu-container")) {
|
|
@@ -3669,15 +4068,21 @@ ${widgetContext}` : widgetContext;
|
|
|
3669
4068
|
case "content":
|
|
3670
4069
|
case "token":
|
|
3671
4070
|
if (chunk.content) {
|
|
3672
|
-
currentTextBuffer
|
|
3673
|
-
|
|
4071
|
+
if (!currentTextBuffer) {
|
|
4072
|
+
currentTextBuffer = chunk.content.trimStart();
|
|
4073
|
+
} else {
|
|
4074
|
+
currentTextBuffer += chunk.content;
|
|
4075
|
+
}
|
|
4076
|
+
if (currentTextBuffer) {
|
|
4077
|
+
updateMessage();
|
|
4078
|
+
}
|
|
3674
4079
|
}
|
|
3675
4080
|
break;
|
|
3676
4081
|
case "tool_call":
|
|
3677
4082
|
if (chunk.tool_id && chunk.tool_name) {
|
|
3678
4083
|
const displayName = chunk.tool_display_name || chunk.tool_name;
|
|
3679
4084
|
if (currentTextBuffer) {
|
|
3680
|
-
contentSegments.push({ type: "text", content: currentTextBuffer });
|
|
4085
|
+
contentSegments.push({ type: "text", content: currentTextBuffer.trimEnd() });
|
|
3681
4086
|
currentTextBuffer = "";
|
|
3682
4087
|
}
|
|
3683
4088
|
contentSegments.push({ type: "tool", id: chunk.tool_id, name: displayName, status: "preparing" });
|
|
@@ -3760,6 +4165,7 @@ ${widgetContext}` : widgetContext;
|
|
|
3760
4165
|
}
|
|
3761
4166
|
},
|
|
3762
4167
|
(threadId2) => {
|
|
4168
|
+
currentTextBuffer = currentTextBuffer.trimEnd();
|
|
3763
4169
|
if (currentTextBuffer) {
|
|
3764
4170
|
const lastSegment = contentSegments[contentSegments.length - 1];
|
|
3765
4171
|
if (lastSegment && lastSegment.type === "text") {
|
|
@@ -4055,19 +4461,20 @@ ${planToExecute}`;
|
|
|
4055
4461
|
setCurrentRequestId(null);
|
|
4056
4462
|
};
|
|
4057
4463
|
const isCompact = commandVariant === "compact";
|
|
4058
|
-
return /* @__PURE__ */
|
|
4059
|
-
showHeader && mode === "chat" && /* @__PURE__ */
|
|
4060
|
-
onHeaderBack && /* @__PURE__ */
|
|
4061
|
-
/* @__PURE__ */
|
|
4062
|
-
/* @__PURE__ */
|
|
4063
|
-
/* @__PURE__ */
|
|
4464
|
+
return /* @__PURE__ */ jsxs20("div", { className: cn("apteva-chat flex flex-col h-full", variant !== "default" && `apteva-chat-${variant}`, className), children: [
|
|
4465
|
+
showHeader && mode === "chat" && /* @__PURE__ */ jsx26("div", { className: "apteva-chat-header px-4 py-3", children: /* @__PURE__ */ jsxs20("div", { style: { display: "flex", alignItems: "center", gap: "0.5rem" }, children: [
|
|
4466
|
+
onHeaderBack && /* @__PURE__ */ jsx26("button", { onClick: onHeaderBack, className: "apteva-chat-back", style: { flexShrink: 0 }, children: /* @__PURE__ */ jsx26("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ jsx26("path", { d: "M10 12L6 8l4-4" }) }) }),
|
|
4467
|
+
/* @__PURE__ */ jsxs20("div", { children: [
|
|
4468
|
+
/* @__PURE__ */ jsx26("div", { className: "apteva-chat-title", children: headerTitle }),
|
|
4469
|
+
/* @__PURE__ */ jsx26("div", { className: cn(
|
|
4064
4470
|
"apteva-chat-status",
|
|
4065
4471
|
isLoading ? chatToolName ? "apteva-chat-status-tool" : "apteva-chat-status-thinking" : "apteva-chat-status-ready"
|
|
4066
4472
|
), children: isLoading ? chatToolName ? `Using ${chatToolName}...` : "Thinking..." : "Ready" })
|
|
4067
4473
|
] })
|
|
4068
4474
|
] }) }),
|
|
4069
|
-
mode === "chat" && /* @__PURE__ */
|
|
4070
|
-
/* @__PURE__ */
|
|
4475
|
+
mode === "chat" && /* @__PURE__ */ jsxs20(Fragment6, { children: [
|
|
4476
|
+
persistentWidgetList.length > 0 && /* @__PURE__ */ jsx26(PersistentWidgetPanel, { widgets: persistentWidgetList, onAction }),
|
|
4477
|
+
/* @__PURE__ */ jsx26(
|
|
4071
4478
|
MessageList,
|
|
4072
4479
|
{
|
|
4073
4480
|
messages,
|
|
@@ -4080,10 +4487,12 @@ ${planToExecute}`;
|
|
|
4080
4487
|
chatVariant: variant,
|
|
4081
4488
|
onPromptClick: (prompt) => handleSendMessage(prompt),
|
|
4082
4489
|
enableWidgets,
|
|
4083
|
-
onWidgetRender
|
|
4490
|
+
onWidgetRender,
|
|
4491
|
+
persistentWidgetIds,
|
|
4492
|
+
toolCallStyle
|
|
4084
4493
|
}
|
|
4085
4494
|
),
|
|
4086
|
-
/* @__PURE__ */
|
|
4495
|
+
/* @__PURE__ */ jsx26(
|
|
4087
4496
|
Composer,
|
|
4088
4497
|
{
|
|
4089
4498
|
onSendMessage: handleSendMessage,
|
|
@@ -4096,7 +4505,7 @@ ${planToExecute}`;
|
|
|
4096
4505
|
}
|
|
4097
4506
|
)
|
|
4098
4507
|
] }),
|
|
4099
|
-
mode === "command" && /* @__PURE__ */
|
|
4508
|
+
mode === "command" && /* @__PURE__ */ jsx26("div", { className: "w-full", children: /* @__PURE__ */ jsx26(
|
|
4100
4509
|
CommandComposer,
|
|
4101
4510
|
{
|
|
4102
4511
|
onExecute: (text, files) => {
|
|
@@ -4117,7 +4526,7 @@ ${planToExecute}`;
|
|
|
4117
4526
|
placeholder: placeholder || "Enter your command..."
|
|
4118
4527
|
}
|
|
4119
4528
|
) }),
|
|
4120
|
-
/* @__PURE__ */
|
|
4529
|
+
/* @__PURE__ */ jsx26("style", { dangerouslySetInnerHTML: {
|
|
4121
4530
|
__html: `
|
|
4122
4531
|
@keyframes pulse-border {
|
|
4123
4532
|
0%, 100% { border-color: rgb(59, 130, 246); }
|
|
@@ -4135,12 +4544,12 @@ ${planToExecute}`;
|
|
|
4135
4544
|
});
|
|
4136
4545
|
|
|
4137
4546
|
// src/components/Chat/CommandOutput.tsx
|
|
4138
|
-
import { useState as
|
|
4139
|
-
import { jsx as
|
|
4547
|
+
import { useState as useState10 } from "react";
|
|
4548
|
+
import { jsx as jsx27, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
4140
4549
|
|
|
4141
4550
|
// src/components/Command/Command.tsx
|
|
4142
|
-
import React, { useState as
|
|
4143
|
-
import { Fragment as
|
|
4551
|
+
import React, { useState as useState11, useEffect as useEffect8 } from "react";
|
|
4552
|
+
import { Fragment as Fragment7, jsx as jsx28, jsxs as jsxs22 } from "react/jsx-runtime";
|
|
4144
4553
|
function Command({
|
|
4145
4554
|
agentId,
|
|
4146
4555
|
command: initialCommand,
|
|
@@ -4167,28 +4576,28 @@ function Command({
|
|
|
4167
4576
|
resultRenderer,
|
|
4168
4577
|
className
|
|
4169
4578
|
}) {
|
|
4170
|
-
const [state, setState] =
|
|
4171
|
-
const [result, setResult] =
|
|
4172
|
-
const [error, setError] =
|
|
4173
|
-
const [progress, setProgress] =
|
|
4174
|
-
const [command, setCommand] =
|
|
4175
|
-
const [streamedContent, setStreamedContent] =
|
|
4176
|
-
const [plan, setPlan] =
|
|
4177
|
-
const [pendingCommand, setPendingCommand] =
|
|
4178
|
-
const [showPlanDetails, setShowPlanDetails] =
|
|
4179
|
-
const [uploadedFiles, setUploadedFiles] =
|
|
4180
|
-
const [showSettingsMenu, setShowSettingsMenu] =
|
|
4181
|
-
const [internalPlanMode, setInternalPlanMode] =
|
|
4579
|
+
const [state, setState] = useState11("idle");
|
|
4580
|
+
const [result, setResult] = useState11(null);
|
|
4581
|
+
const [error, setError] = useState11(null);
|
|
4582
|
+
const [progress, setProgress] = useState11(0);
|
|
4583
|
+
const [command, setCommand] = useState11(initialCommand || "");
|
|
4584
|
+
const [streamedContent, setStreamedContent] = useState11("");
|
|
4585
|
+
const [plan, setPlan] = useState11("");
|
|
4586
|
+
const [pendingCommand, setPendingCommand] = useState11("");
|
|
4587
|
+
const [showPlanDetails, setShowPlanDetails] = useState11(false);
|
|
4588
|
+
const [uploadedFiles, setUploadedFiles] = useState11([]);
|
|
4589
|
+
const [showSettingsMenu, setShowSettingsMenu] = useState11(false);
|
|
4590
|
+
const [internalPlanMode, setInternalPlanMode] = useState11(planMode);
|
|
4182
4591
|
const fileInputRef = React.useRef(null);
|
|
4183
|
-
|
|
4592
|
+
useEffect8(() => {
|
|
4184
4593
|
if (autoExecute && state === "idle" && command) {
|
|
4185
4594
|
executeCommand();
|
|
4186
4595
|
}
|
|
4187
4596
|
}, [autoExecute]);
|
|
4188
|
-
|
|
4597
|
+
useEffect8(() => {
|
|
4189
4598
|
setInternalPlanMode(planMode);
|
|
4190
4599
|
}, [planMode]);
|
|
4191
|
-
|
|
4600
|
+
useEffect8(() => {
|
|
4192
4601
|
const handleClickOutside = (event) => {
|
|
4193
4602
|
const target = event.target;
|
|
4194
4603
|
if (showSettingsMenu && !target.closest(".settings-menu-container")) {
|
|
@@ -4590,7 +4999,7 @@ ${planToExecute}`;
|
|
|
4590
4999
|
setUploadedFiles((prev) => prev.filter((_, i) => i !== index));
|
|
4591
5000
|
};
|
|
4592
5001
|
const isCompact = variant === "compact";
|
|
4593
|
-
return /* @__PURE__ */
|
|
5002
|
+
return /* @__PURE__ */ jsxs22(
|
|
4594
5003
|
"div",
|
|
4595
5004
|
{
|
|
4596
5005
|
className: cn(
|
|
@@ -4605,9 +5014,9 @@ ${planToExecute}`;
|
|
|
4605
5014
|
),
|
|
4606
5015
|
style: { minHeight: isCompact ? "auto" : "180px" },
|
|
4607
5016
|
children: [
|
|
4608
|
-
/* @__PURE__ */
|
|
4609
|
-
state === "idle" && allowInput && !isCompact && /* @__PURE__ */
|
|
4610
|
-
/* @__PURE__ */
|
|
5017
|
+
/* @__PURE__ */ jsxs22("div", { className: cn("flex-1 flex", isCompact ? "flex-row items-center p-3 gap-3" : "flex-col p-4"), children: [
|
|
5018
|
+
state === "idle" && allowInput && !isCompact && /* @__PURE__ */ jsxs22(Fragment7, { children: [
|
|
5019
|
+
/* @__PURE__ */ jsx28(
|
|
4611
5020
|
"textarea",
|
|
4612
5021
|
{
|
|
4613
5022
|
value: command,
|
|
@@ -4623,42 +5032,42 @@ ${planToExecute}`;
|
|
|
4623
5032
|
rows: 6
|
|
4624
5033
|
}
|
|
4625
5034
|
),
|
|
4626
|
-
uploadedFiles.length > 0 && /* @__PURE__ */
|
|
4627
|
-
file.type === "image" ? /* @__PURE__ */
|
|
5035
|
+
uploadedFiles.length > 0 && /* @__PURE__ */ jsx28("div", { className: "flex flex-wrap gap-2 mt-2", children: uploadedFiles.map((file, index) => /* @__PURE__ */ jsxs22("div", { className: "relative group", children: [
|
|
5036
|
+
file.type === "image" ? /* @__PURE__ */ jsx28(
|
|
4628
5037
|
"img",
|
|
4629
5038
|
{
|
|
4630
5039
|
src: file.preview,
|
|
4631
5040
|
alt: file.name,
|
|
4632
5041
|
className: "w-20 h-20 object-cover rounded-lg border-2 border-neutral-300 dark:border-neutral-600"
|
|
4633
5042
|
}
|
|
4634
|
-
) : /* @__PURE__ */
|
|
4635
|
-
/* @__PURE__ */
|
|
4636
|
-
/* @__PURE__ */
|
|
5043
|
+
) : /* @__PURE__ */ jsxs22("div", { className: "w-20 h-20 flex flex-col items-center justify-center rounded-lg border-2 border-neutral-300 dark:border-neutral-600 bg-neutral-50 dark:bg-neutral-800", children: [
|
|
5044
|
+
/* @__PURE__ */ jsx28("svg", { className: "w-8 h-8 text-neutral-500 dark:text-neutral-400", fill: "currentColor", viewBox: "0 0 20 20", children: /* @__PURE__ */ jsx28("path", { fillRule: "evenodd", d: "M4 4a2 2 0 012-2h4.586A2 2 0 0112 2.586L15.414 6A2 2 0 0116 7.414V16a2 2 0 01-2 2H6a2 2 0 01-2-2V4zm2 6a1 1 0 011-1h6a1 1 0 110 2H7a1 1 0 01-1-1zm1 3a1 1 0 100 2h6a1 1 0 100-2H7z", clipRule: "evenodd" }) }),
|
|
5045
|
+
/* @__PURE__ */ jsx28("span", { className: "text-[8px] text-neutral-500 dark:text-neutral-400 mt-1 px-1 truncate max-w-full", children: file.name.length > 12 ? file.name.slice(0, 12) + "..." : file.name })
|
|
4637
5046
|
] }),
|
|
4638
|
-
/* @__PURE__ */
|
|
5047
|
+
/* @__PURE__ */ jsx28(
|
|
4639
5048
|
"button",
|
|
4640
5049
|
{
|
|
4641
5050
|
onClick: () => removeFile(index),
|
|
4642
5051
|
className: "absolute -top-2 -right-2 w-6 h-6 bg-red-500 hover:bg-red-600 text-white rounded-full flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity",
|
|
4643
5052
|
title: `Remove ${file.type}`,
|
|
4644
|
-
children: /* @__PURE__ */
|
|
5053
|
+
children: /* @__PURE__ */ jsx28("svg", { className: "w-4 h-4", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ jsx28("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M6 18L18 6M6 6l12 12" }) })
|
|
4645
5054
|
}
|
|
4646
5055
|
)
|
|
4647
5056
|
] }, index)) })
|
|
4648
5057
|
] }),
|
|
4649
|
-
state === "idle" && allowInput && isCompact && /* @__PURE__ */
|
|
4650
|
-
/* @__PURE__ */
|
|
4651
|
-
enableFileUpload && /* @__PURE__ */
|
|
5058
|
+
state === "idle" && allowInput && isCompact && /* @__PURE__ */ jsxs22(Fragment7, { children: [
|
|
5059
|
+
/* @__PURE__ */ jsxs22("div", { className: "flex items-center gap-0.5 flex-shrink-0", children: [
|
|
5060
|
+
enableFileUpload && /* @__PURE__ */ jsx28(
|
|
4652
5061
|
"button",
|
|
4653
5062
|
{
|
|
4654
5063
|
onClick: () => fileInputRef.current?.click(),
|
|
4655
5064
|
className: "w-8 h-8 rounded-lg flex items-center justify-center transition-all flex-shrink-0 !text-neutral-500 dark:!text-neutral-500 hover:bg-neutral-100 dark:hover:bg-neutral-800",
|
|
4656
5065
|
title: "Attach file",
|
|
4657
|
-
children: /* @__PURE__ */
|
|
5066
|
+
children: /* @__PURE__ */ jsx28("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsx28("path", { d: "M8.4 2.8L4.4 6.8C3.736 7.464 3.736 8.536 4.4 9.2C5.064 9.864 6.136 9.864 6.8 9.2L11.6 4.4C12.704 3.296 12.704 1.504 11.6 0.4C10.496 -0.704 8.704 -0.704 7.6 0.4L2.8 5.2C1.256 6.744 1.256 9.256 2.8 10.8C4.344 12.344 6.856 12.344 8.4 10.8L12.4 6.8", stroke: "currentColor", strokeWidth: "1.2", strokeLinecap: "round", strokeLinejoin: "round", transform: "translate(1.6, 2.4)" }) })
|
|
4658
5067
|
}
|
|
4659
5068
|
),
|
|
4660
|
-
planMode && /* @__PURE__ */
|
|
4661
|
-
/* @__PURE__ */
|
|
5069
|
+
planMode && /* @__PURE__ */ jsxs22("div", { className: "relative settings-menu-container", children: [
|
|
5070
|
+
/* @__PURE__ */ jsx28(
|
|
4662
5071
|
"button",
|
|
4663
5072
|
{
|
|
4664
5073
|
onClick: () => setShowSettingsMenu(!showSettingsMenu),
|
|
@@ -4667,28 +5076,28 @@ ${planToExecute}`;
|
|
|
4667
5076
|
internalPlanMode ? "!text-blue-600 dark:!text-blue-400" : "!text-neutral-500 dark:!text-neutral-500"
|
|
4668
5077
|
),
|
|
4669
5078
|
title: "Settings",
|
|
4670
|
-
children: /* @__PURE__ */
|
|
4671
|
-
/* @__PURE__ */
|
|
4672
|
-
/* @__PURE__ */
|
|
4673
|
-
/* @__PURE__ */
|
|
4674
|
-
/* @__PURE__ */
|
|
4675
|
-
/* @__PURE__ */
|
|
4676
|
-
/* @__PURE__ */
|
|
4677
|
-
/* @__PURE__ */
|
|
4678
|
-
/* @__PURE__ */
|
|
4679
|
-
/* @__PURE__ */
|
|
5079
|
+
children: /* @__PURE__ */ jsxs22("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
5080
|
+
/* @__PURE__ */ jsx28("line", { x1: "4", y1: "21", x2: "4", y2: "14" }),
|
|
5081
|
+
/* @__PURE__ */ jsx28("line", { x1: "4", y1: "10", x2: "4", y2: "3" }),
|
|
5082
|
+
/* @__PURE__ */ jsx28("line", { x1: "12", y1: "21", x2: "12", y2: "12" }),
|
|
5083
|
+
/* @__PURE__ */ jsx28("line", { x1: "12", y1: "8", x2: "12", y2: "3" }),
|
|
5084
|
+
/* @__PURE__ */ jsx28("line", { x1: "20", y1: "21", x2: "20", y2: "16" }),
|
|
5085
|
+
/* @__PURE__ */ jsx28("line", { x1: "20", y1: "12", x2: "20", y2: "3" }),
|
|
5086
|
+
/* @__PURE__ */ jsx28("line", { x1: "1", y1: "14", x2: "7", y2: "14" }),
|
|
5087
|
+
/* @__PURE__ */ jsx28("line", { x1: "9", y1: "8", x2: "15", y2: "8" }),
|
|
5088
|
+
/* @__PURE__ */ jsx28("line", { x1: "17", y1: "16", x2: "23", y2: "16" })
|
|
4680
5089
|
] })
|
|
4681
5090
|
}
|
|
4682
5091
|
),
|
|
4683
|
-
showSettingsMenu && /* @__PURE__ */
|
|
4684
|
-
/* @__PURE__ */
|
|
4685
|
-
/* @__PURE__ */
|
|
4686
|
-
/* @__PURE__ */
|
|
4687
|
-
/* @__PURE__ */
|
|
4688
|
-
/* @__PURE__ */
|
|
5092
|
+
showSettingsMenu && /* @__PURE__ */ jsx28("div", { className: "absolute top-10 left-0 z-50 w-56 bg-white dark:bg-neutral-800 border border-neutral-200 dark:border-neutral-700 rounded-lg shadow-lg p-2.5 settings-menu-container", children: /* @__PURE__ */ jsxs22("label", { className: "flex items-center justify-between cursor-pointer group", children: [
|
|
5093
|
+
/* @__PURE__ */ jsxs22("div", { className: "flex items-center gap-2", children: [
|
|
5094
|
+
/* @__PURE__ */ jsx28("svg", { className: "w-3.5 h-3.5 text-neutral-500 dark:text-neutral-400", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ jsx28("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-3 7h3m-3 4h3m-6-4h.01M9 16h.01" }) }),
|
|
5095
|
+
/* @__PURE__ */ jsxs22("div", { children: [
|
|
5096
|
+
/* @__PURE__ */ jsx28("div", { className: "text-xs font-medium text-neutral-700 dark:text-neutral-300", children: "Plan Mode" }),
|
|
5097
|
+
/* @__PURE__ */ jsx28("div", { className: "text-[10px] text-neutral-500 dark:text-neutral-400", children: "Review first" })
|
|
4689
5098
|
] })
|
|
4690
5099
|
] }),
|
|
4691
|
-
/* @__PURE__ */
|
|
5100
|
+
/* @__PURE__ */ jsx28(
|
|
4692
5101
|
"button",
|
|
4693
5102
|
{
|
|
4694
5103
|
onClick: (e) => {
|
|
@@ -4700,7 +5109,7 @@ ${planToExecute}`;
|
|
|
4700
5109
|
internalPlanMode ? "bg-blue-600" : "bg-neutral-300 dark:bg-neutral-600"
|
|
4701
5110
|
),
|
|
4702
5111
|
type: "button",
|
|
4703
|
-
children: /* @__PURE__ */
|
|
5112
|
+
children: /* @__PURE__ */ jsx28(
|
|
4704
5113
|
"span",
|
|
4705
5114
|
{
|
|
4706
5115
|
className: cn(
|
|
@@ -4714,26 +5123,26 @@ ${planToExecute}`;
|
|
|
4714
5123
|
] }) })
|
|
4715
5124
|
] })
|
|
4716
5125
|
] }),
|
|
4717
|
-
uploadedFiles.length > 0 && /* @__PURE__ */
|
|
4718
|
-
file.type === "image" ? /* @__PURE__ */
|
|
5126
|
+
uploadedFiles.length > 0 && /* @__PURE__ */ jsx28("div", { className: "flex gap-1 flex-shrink-0", children: uploadedFiles.map((file, index) => /* @__PURE__ */ jsxs22("div", { className: "relative group", children: [
|
|
5127
|
+
file.type === "image" ? /* @__PURE__ */ jsx28(
|
|
4719
5128
|
"img",
|
|
4720
5129
|
{
|
|
4721
5130
|
src: file.preview,
|
|
4722
5131
|
alt: file.name,
|
|
4723
5132
|
className: "w-8 h-8 object-cover rounded border border-neutral-300 dark:border-neutral-600"
|
|
4724
5133
|
}
|
|
4725
|
-
) : /* @__PURE__ */
|
|
4726
|
-
/* @__PURE__ */
|
|
5134
|
+
) : /* @__PURE__ */ jsx28("div", { className: "w-8 h-8 flex items-center justify-center rounded border border-neutral-300 dark:border-neutral-600 bg-neutral-50 dark:bg-neutral-800", title: file.name, children: /* @__PURE__ */ jsx28("svg", { className: "w-4 h-4 text-neutral-500 dark:text-neutral-400", fill: "currentColor", viewBox: "0 0 20 20", children: /* @__PURE__ */ jsx28("path", { fillRule: "evenodd", d: "M4 4a2 2 0 012-2h4.586A2 2 0 0112 2.586L15.414 6A2 2 0 0116 7.414V16a2 2 0 01-2 2H6a2 2 0 01-2-2V4zm2 6a1 1 0 011-1h6a1 1 0 110 2H7a1 1 0 01-1-1zm1 3a1 1 0 100 2h6a1 1 0 100-2H7z", clipRule: "evenodd" }) }) }),
|
|
5135
|
+
/* @__PURE__ */ jsx28(
|
|
4727
5136
|
"button",
|
|
4728
5137
|
{
|
|
4729
5138
|
onClick: () => removeFile(index),
|
|
4730
5139
|
className: "absolute -top-1 -right-1 w-4 h-4 bg-red-500 hover:bg-red-600 text-white rounded-full flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity",
|
|
4731
5140
|
title: "Remove",
|
|
4732
|
-
children: /* @__PURE__ */
|
|
5141
|
+
children: /* @__PURE__ */ jsx28("svg", { className: "w-2.5 h-2.5", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", strokeWidth: 3, children: /* @__PURE__ */ jsx28("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M6 18L18 6M6 6l12 12" }) })
|
|
4733
5142
|
}
|
|
4734
5143
|
)
|
|
4735
5144
|
] }, index)) }),
|
|
4736
|
-
/* @__PURE__ */
|
|
5145
|
+
/* @__PURE__ */ jsx28(
|
|
4737
5146
|
"input",
|
|
4738
5147
|
{
|
|
4739
5148
|
type: "text",
|
|
@@ -4749,7 +5158,7 @@ ${planToExecute}`;
|
|
|
4749
5158
|
className: "flex-1 bg-transparent border-none focus:outline-none !text-neutral-900 dark:!text-neutral-100 placeholder-neutral-400 dark:placeholder-neutral-500 py-1"
|
|
4750
5159
|
}
|
|
4751
5160
|
),
|
|
4752
|
-
/* @__PURE__ */
|
|
5161
|
+
/* @__PURE__ */ jsx28(
|
|
4753
5162
|
"button",
|
|
4754
5163
|
{
|
|
4755
5164
|
onClick: () => executeCommand(),
|
|
@@ -4765,33 +5174,33 @@ ${planToExecute}`;
|
|
|
4765
5174
|
!command.trim() && "border-neutral-200 dark:border-neutral-700 !text-neutral-400 dark:!text-neutral-600"
|
|
4766
5175
|
),
|
|
4767
5176
|
title: "Execute",
|
|
4768
|
-
children: /* @__PURE__ */
|
|
5177
|
+
children: /* @__PURE__ */ jsx28("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsx28("path", { d: "M8 3L8 13M8 3L4 7M8 3L12 7", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) })
|
|
4769
5178
|
}
|
|
4770
5179
|
)
|
|
4771
5180
|
] }),
|
|
4772
|
-
state === "loading" && !isCompact && /* @__PURE__ */
|
|
4773
|
-
/* @__PURE__ */
|
|
4774
|
-
/* @__PURE__ */
|
|
4775
|
-
showProgress && /* @__PURE__ */
|
|
4776
|
-
/* @__PURE__ */
|
|
5181
|
+
state === "loading" && !isCompact && /* @__PURE__ */ jsxs22("div", { className: "flex-1 flex flex-col items-center justify-center space-y-4 py-8", children: [
|
|
5182
|
+
/* @__PURE__ */ jsx28("div", { className: "w-6 h-6 border-2 border-neutral-300 border-t-blue-500 rounded-full animate-spin" }),
|
|
5183
|
+
/* @__PURE__ */ jsx28("div", { className: "text-neutral-600 dark:text-neutral-400 text-sm text-center max-w-md", children: enableStreaming && streamedContent ? streamedContent : loadingText }),
|
|
5184
|
+
showProgress && /* @__PURE__ */ jsxs22("div", { className: "w-full max-w-sm", children: [
|
|
5185
|
+
/* @__PURE__ */ jsx28("div", { className: "w-full bg-neutral-200 dark:bg-neutral-700 rounded-full h-1.5", children: /* @__PURE__ */ jsx28(
|
|
4777
5186
|
"div",
|
|
4778
5187
|
{
|
|
4779
5188
|
className: "bg-blue-500 h-1.5 rounded-full transition-all duration-300",
|
|
4780
5189
|
style: { width: `${progress}%` }
|
|
4781
5190
|
}
|
|
4782
5191
|
) }),
|
|
4783
|
-
/* @__PURE__ */
|
|
5192
|
+
/* @__PURE__ */ jsxs22("p", { className: "text-xs text-neutral-500 mt-2 text-center", children: [
|
|
4784
5193
|
progress,
|
|
4785
5194
|
"%"
|
|
4786
5195
|
] })
|
|
4787
5196
|
] })
|
|
4788
5197
|
] }),
|
|
4789
|
-
state === "loading" && isCompact && /* @__PURE__ */
|
|
4790
|
-
/* @__PURE__ */
|
|
4791
|
-
/* @__PURE__ */
|
|
4792
|
-
/* @__PURE__ */
|
|
5198
|
+
state === "loading" && isCompact && /* @__PURE__ */ jsxs22(Fragment7, { children: [
|
|
5199
|
+
/* @__PURE__ */ jsxs22("div", { className: "flex-1 flex items-center gap-3 py-1", children: [
|
|
5200
|
+
/* @__PURE__ */ jsx28("div", { className: "w-4 h-4 border-2 border-neutral-300 border-t-blue-500 rounded-full animate-spin" }),
|
|
5201
|
+
/* @__PURE__ */ jsx28("div", { className: "text-neutral-600 dark:text-neutral-400 text-sm truncate", children: enableStreaming && streamedContent ? streamedContent : loadingText })
|
|
4793
5202
|
] }),
|
|
4794
|
-
/* @__PURE__ */
|
|
5203
|
+
/* @__PURE__ */ jsx28(
|
|
4795
5204
|
"button",
|
|
4796
5205
|
{
|
|
4797
5206
|
disabled: true,
|
|
@@ -4803,20 +5212,20 @@ ${planToExecute}`;
|
|
|
4803
5212
|
"!text-lg",
|
|
4804
5213
|
"opacity-30 cursor-not-allowed"
|
|
4805
5214
|
),
|
|
4806
|
-
children: /* @__PURE__ */
|
|
5215
|
+
children: /* @__PURE__ */ jsx28("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsx28("path", { d: "M8 3L8 13M8 3L4 7M8 3L12 7", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) })
|
|
4807
5216
|
}
|
|
4808
5217
|
)
|
|
4809
5218
|
] }),
|
|
4810
|
-
state === "plan-pending" && !isCompact && /* @__PURE__ */
|
|
4811
|
-
/* @__PURE__ */
|
|
4812
|
-
/* @__PURE__ */
|
|
4813
|
-
/* @__PURE__ */
|
|
4814
|
-
/* @__PURE__ */
|
|
4815
|
-
/* @__PURE__ */
|
|
5219
|
+
state === "plan-pending" && !isCompact && /* @__PURE__ */ jsx28("div", { className: "flex-1 flex flex-col", children: /* @__PURE__ */ jsxs22("div", { className: "mb-4 p-4 bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg", children: [
|
|
5220
|
+
/* @__PURE__ */ jsxs22("div", { className: "flex items-start gap-2 mb-3", children: [
|
|
5221
|
+
/* @__PURE__ */ jsx28("svg", { className: "w-5 h-5 text-blue-600 dark:text-blue-400 mt-0.5 flex-shrink-0", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ jsx28("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-3 7h3m-3 4h3m-6-4h.01M9 16h.01" }) }),
|
|
5222
|
+
/* @__PURE__ */ jsxs22("div", { className: "flex-1", children: [
|
|
5223
|
+
/* @__PURE__ */ jsx28("h3", { className: "text-sm font-semibold text-blue-800 dark:text-blue-300 mb-1", children: "Proposed Plan" }),
|
|
5224
|
+
/* @__PURE__ */ jsx28("div", { className: "text-blue-700 dark:text-blue-300 text-sm whitespace-pre-line leading-relaxed", children: plan })
|
|
4816
5225
|
] })
|
|
4817
5226
|
] }),
|
|
4818
|
-
/* @__PURE__ */
|
|
4819
|
-
/* @__PURE__ */
|
|
5227
|
+
/* @__PURE__ */ jsxs22("div", { className: "flex gap-2 mt-4", children: [
|
|
5228
|
+
/* @__PURE__ */ jsx28(
|
|
4820
5229
|
"button",
|
|
4821
5230
|
{
|
|
4822
5231
|
onClick: approvePlan,
|
|
@@ -4824,7 +5233,7 @@ ${planToExecute}`;
|
|
|
4824
5233
|
children: "Approve & Execute"
|
|
4825
5234
|
}
|
|
4826
5235
|
),
|
|
4827
|
-
/* @__PURE__ */
|
|
5236
|
+
/* @__PURE__ */ jsx28(
|
|
4828
5237
|
"button",
|
|
4829
5238
|
{
|
|
4830
5239
|
onClick: rejectPlan,
|
|
@@ -4834,20 +5243,20 @@ ${planToExecute}`;
|
|
|
4834
5243
|
)
|
|
4835
5244
|
] })
|
|
4836
5245
|
] }) }),
|
|
4837
|
-
state === "plan-pending" && isCompact && /* @__PURE__ */
|
|
4838
|
-
/* @__PURE__ */
|
|
5246
|
+
state === "plan-pending" && isCompact && /* @__PURE__ */ jsxs22(Fragment7, { children: [
|
|
5247
|
+
/* @__PURE__ */ jsxs22(
|
|
4839
5248
|
"button",
|
|
4840
5249
|
{
|
|
4841
5250
|
onClick: () => setShowPlanDetails(true),
|
|
4842
5251
|
className: "flex-1 flex items-center gap-2 px-3 py-2 bg-blue-50 dark:bg-blue-900/30 hover:bg-blue-100 dark:hover:bg-blue-900/40 border border-blue-200 dark:border-blue-800 rounded-lg transition-colors",
|
|
4843
5252
|
children: [
|
|
4844
|
-
/* @__PURE__ */
|
|
4845
|
-
/* @__PURE__ */
|
|
5253
|
+
/* @__PURE__ */ jsx28("svg", { className: "w-4 h-4 text-blue-600 dark:text-blue-400 flex-shrink-0", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ jsx28("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-3 7h3m-3 4h3m-6-4h.01M9 16h.01" }) }),
|
|
5254
|
+
/* @__PURE__ */ jsx28("span", { className: "text-sm font-medium text-blue-700 dark:text-blue-300 truncate flex-1", children: "View Execution Plan" })
|
|
4846
5255
|
]
|
|
4847
5256
|
}
|
|
4848
5257
|
),
|
|
4849
|
-
/* @__PURE__ */
|
|
4850
|
-
/* @__PURE__ */
|
|
5258
|
+
/* @__PURE__ */ jsxs22("div", { className: "flex gap-2 flex-shrink-0", children: [
|
|
5259
|
+
/* @__PURE__ */ jsx28(
|
|
4851
5260
|
"button",
|
|
4852
5261
|
{
|
|
4853
5262
|
onClick: approvePlan,
|
|
@@ -4855,7 +5264,7 @@ ${planToExecute}`;
|
|
|
4855
5264
|
children: "Approve"
|
|
4856
5265
|
}
|
|
4857
5266
|
),
|
|
4858
|
-
/* @__PURE__ */
|
|
5267
|
+
/* @__PURE__ */ jsx28(
|
|
4859
5268
|
"button",
|
|
4860
5269
|
{
|
|
4861
5270
|
onClick: rejectPlan,
|
|
@@ -4865,15 +5274,15 @@ ${planToExecute}`;
|
|
|
4865
5274
|
)
|
|
4866
5275
|
] })
|
|
4867
5276
|
] }),
|
|
4868
|
-
state === "error" && /* @__PURE__ */
|
|
4869
|
-
/* @__PURE__ */
|
|
4870
|
-
/* @__PURE__ */
|
|
4871
|
-
/* @__PURE__ */
|
|
4872
|
-
/* @__PURE__ */
|
|
4873
|
-
/* @__PURE__ */
|
|
5277
|
+
state === "error" && /* @__PURE__ */ jsxs22("div", { className: "flex-1 flex flex-col", children: [
|
|
5278
|
+
/* @__PURE__ */ jsx28("div", { className: "mb-4 p-3 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg", children: /* @__PURE__ */ jsxs22("div", { className: "flex items-start gap-2", children: [
|
|
5279
|
+
/* @__PURE__ */ jsx28("svg", { className: "w-5 h-5 text-red-600 mt-0.5 flex-shrink-0", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ jsx28("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" }) }),
|
|
5280
|
+
/* @__PURE__ */ jsxs22("div", { children: [
|
|
5281
|
+
/* @__PURE__ */ jsx28("h3", { className: "text-sm font-semibold text-red-800 dark:text-red-400", children: "Error" }),
|
|
5282
|
+
/* @__PURE__ */ jsx28("p", { className: "text-red-700 dark:text-red-300 text-sm mt-1", children: error?.message })
|
|
4874
5283
|
] })
|
|
4875
5284
|
] }) }),
|
|
4876
|
-
allowInput && /* @__PURE__ */
|
|
5285
|
+
allowInput && /* @__PURE__ */ jsx28(
|
|
4877
5286
|
"textarea",
|
|
4878
5287
|
{
|
|
4879
5288
|
value: command,
|
|
@@ -4890,16 +5299,16 @@ ${planToExecute}`;
|
|
|
4890
5299
|
}
|
|
4891
5300
|
)
|
|
4892
5301
|
] }),
|
|
4893
|
-
state === "success" && result && !isCompact && /* @__PURE__ */
|
|
4894
|
-
/* @__PURE__ */
|
|
4895
|
-
/* @__PURE__ */
|
|
4896
|
-
/* @__PURE__ */
|
|
4897
|
-
/* @__PURE__ */
|
|
4898
|
-
/* @__PURE__ */
|
|
5302
|
+
state === "success" && result && !isCompact && /* @__PURE__ */ jsx28("div", { className: "flex-1 overflow-auto", children: resultRenderer ? resultRenderer(result.data) : /* @__PURE__ */ jsxs22("div", { className: "space-y-4", children: [
|
|
5303
|
+
/* @__PURE__ */ jsxs22("div", { className: "flex items-start gap-3 p-3 bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 rounded-lg", children: [
|
|
5304
|
+
/* @__PURE__ */ jsx28("svg", { className: "w-5 h-5 text-green-600 mt-0.5 flex-shrink-0", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ jsx28("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z" }) }),
|
|
5305
|
+
/* @__PURE__ */ jsxs22("div", { className: "flex-1", children: [
|
|
5306
|
+
/* @__PURE__ */ jsx28("h3", { className: "text-sm font-semibold text-green-800 dark:text-green-400 mb-1", children: "Success" }),
|
|
5307
|
+
/* @__PURE__ */ jsx28("p", { className: "text-green-700 dark:text-green-300 text-sm", children: "Command executed successfully" })
|
|
4899
5308
|
] })
|
|
4900
5309
|
] }),
|
|
4901
|
-
result.data?.summary && /* @__PURE__ */
|
|
4902
|
-
result.widgets && result.widgets.length > 0 && /* @__PURE__ */
|
|
5310
|
+
result.data?.summary && /* @__PURE__ */ jsx28("div", { className: "text-neutral-700 dark:text-neutral-300 text-sm leading-relaxed whitespace-pre-line", children: result.data.summary }),
|
|
5311
|
+
result.widgets && result.widgets.length > 0 && /* @__PURE__ */ jsx28("div", { className: "space-y-3", children: result.widgets.map((widget) => /* @__PURE__ */ jsx28(
|
|
4903
5312
|
WidgetRenderer,
|
|
4904
5313
|
{
|
|
4905
5314
|
widget,
|
|
@@ -4908,8 +5317,8 @@ ${planToExecute}`;
|
|
|
4908
5317
|
widget.id
|
|
4909
5318
|
)) })
|
|
4910
5319
|
] }) }),
|
|
4911
|
-
state === "success" && result && isCompact && /* @__PURE__ */
|
|
4912
|
-
/* @__PURE__ */
|
|
5320
|
+
state === "success" && result && isCompact && /* @__PURE__ */ jsxs22(Fragment7, { children: [
|
|
5321
|
+
/* @__PURE__ */ jsxs22(
|
|
4913
5322
|
"div",
|
|
4914
5323
|
{
|
|
4915
5324
|
className: "flex-1 flex items-center gap-2 py-1 cursor-text min-w-0",
|
|
@@ -4918,12 +5327,12 @@ ${planToExecute}`;
|
|
|
4918
5327
|
setResult(null);
|
|
4919
5328
|
},
|
|
4920
5329
|
children: [
|
|
4921
|
-
/* @__PURE__ */
|
|
4922
|
-
/* @__PURE__ */
|
|
5330
|
+
/* @__PURE__ */ jsx28("svg", { className: "w-4 h-4 text-green-600 flex-shrink-0", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ jsx28("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z" }) }),
|
|
5331
|
+
/* @__PURE__ */ jsx28("div", { className: "text-green-700 dark:text-green-300 text-sm truncate flex-1 min-w-0", children: resultRenderer ? resultRenderer(result.data) : result.message || "Command executed successfully" })
|
|
4923
5332
|
]
|
|
4924
5333
|
}
|
|
4925
5334
|
),
|
|
4926
|
-
/* @__PURE__ */
|
|
5335
|
+
/* @__PURE__ */ jsx28(
|
|
4927
5336
|
"button",
|
|
4928
5337
|
{
|
|
4929
5338
|
onClick: () => {
|
|
@@ -4939,24 +5348,24 @@ ${planToExecute}`;
|
|
|
4939
5348
|
"!text-lg"
|
|
4940
5349
|
),
|
|
4941
5350
|
title: "New command",
|
|
4942
|
-
children: /* @__PURE__ */
|
|
5351
|
+
children: /* @__PURE__ */ jsx28("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsx28("path", { d: "M8 3L8 13M8 3L4 7M8 3L12 7", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) })
|
|
4943
5352
|
}
|
|
4944
5353
|
)
|
|
4945
5354
|
] })
|
|
4946
5355
|
] }),
|
|
4947
|
-
!isCompact && /* @__PURE__ */
|
|
4948
|
-
/* @__PURE__ */
|
|
4949
|
-
enableFileUpload && /* @__PURE__ */
|
|
5356
|
+
!isCompact && /* @__PURE__ */ jsxs22("div", { className: "p-3 flex items-center justify-between gap-2", children: [
|
|
5357
|
+
/* @__PURE__ */ jsx28("div", { className: "flex items-center gap-1", children: state === "idle" && allowInput && /* @__PURE__ */ jsxs22(Fragment7, { children: [
|
|
5358
|
+
enableFileUpload && /* @__PURE__ */ jsx28(
|
|
4950
5359
|
"button",
|
|
4951
5360
|
{
|
|
4952
5361
|
onClick: () => fileInputRef.current?.click(),
|
|
4953
5362
|
className: "w-8 h-8 rounded-lg flex items-center justify-center transition-all flex-shrink-0 !text-neutral-500 dark:!text-neutral-500 hover:bg-neutral-100 dark:hover:bg-neutral-800",
|
|
4954
5363
|
title: "Attach file",
|
|
4955
|
-
children: /* @__PURE__ */
|
|
5364
|
+
children: /* @__PURE__ */ jsx28("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsx28("path", { d: "M8.4 2.8L4.4 6.8C3.736 7.464 3.736 8.536 4.4 9.2C5.064 9.864 6.136 9.864 6.8 9.2L11.6 4.4C12.704 3.296 12.704 1.504 11.6 0.4C10.496 -0.704 8.704 -0.704 7.6 0.4L2.8 5.2C1.256 6.744 1.256 9.256 2.8 10.8C4.344 12.344 6.856 12.344 8.4 10.8L12.4 6.8", stroke: "currentColor", strokeWidth: "1.2", strokeLinecap: "round", strokeLinejoin: "round", transform: "translate(1.6, 2.4)" }) })
|
|
4956
5365
|
}
|
|
4957
5366
|
),
|
|
4958
|
-
planMode && /* @__PURE__ */
|
|
4959
|
-
/* @__PURE__ */
|
|
5367
|
+
planMode && /* @__PURE__ */ jsxs22("div", { className: "relative settings-menu-container", children: [
|
|
5368
|
+
/* @__PURE__ */ jsx28(
|
|
4960
5369
|
"button",
|
|
4961
5370
|
{
|
|
4962
5371
|
onClick: () => setShowSettingsMenu(!showSettingsMenu),
|
|
@@ -4965,28 +5374,28 @@ ${planToExecute}`;
|
|
|
4965
5374
|
internalPlanMode ? "!text-blue-600 dark:!text-blue-400" : "!text-neutral-500 dark:!text-neutral-500"
|
|
4966
5375
|
),
|
|
4967
5376
|
title: "Settings",
|
|
4968
|
-
children: /* @__PURE__ */
|
|
4969
|
-
/* @__PURE__ */
|
|
4970
|
-
/* @__PURE__ */
|
|
4971
|
-
/* @__PURE__ */
|
|
4972
|
-
/* @__PURE__ */
|
|
4973
|
-
/* @__PURE__ */
|
|
4974
|
-
/* @__PURE__ */
|
|
4975
|
-
/* @__PURE__ */
|
|
4976
|
-
/* @__PURE__ */
|
|
4977
|
-
/* @__PURE__ */
|
|
5377
|
+
children: /* @__PURE__ */ jsxs22("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
5378
|
+
/* @__PURE__ */ jsx28("line", { x1: "4", y1: "21", x2: "4", y2: "14" }),
|
|
5379
|
+
/* @__PURE__ */ jsx28("line", { x1: "4", y1: "10", x2: "4", y2: "3" }),
|
|
5380
|
+
/* @__PURE__ */ jsx28("line", { x1: "12", y1: "21", x2: "12", y2: "12" }),
|
|
5381
|
+
/* @__PURE__ */ jsx28("line", { x1: "12", y1: "8", x2: "12", y2: "3" }),
|
|
5382
|
+
/* @__PURE__ */ jsx28("line", { x1: "20", y1: "21", x2: "20", y2: "16" }),
|
|
5383
|
+
/* @__PURE__ */ jsx28("line", { x1: "20", y1: "12", x2: "20", y2: "3" }),
|
|
5384
|
+
/* @__PURE__ */ jsx28("line", { x1: "1", y1: "14", x2: "7", y2: "14" }),
|
|
5385
|
+
/* @__PURE__ */ jsx28("line", { x1: "9", y1: "8", x2: "15", y2: "8" }),
|
|
5386
|
+
/* @__PURE__ */ jsx28("line", { x1: "17", y1: "16", x2: "23", y2: "16" })
|
|
4978
5387
|
] })
|
|
4979
5388
|
}
|
|
4980
5389
|
),
|
|
4981
|
-
showSettingsMenu && /* @__PURE__ */
|
|
4982
|
-
/* @__PURE__ */
|
|
4983
|
-
/* @__PURE__ */
|
|
4984
|
-
/* @__PURE__ */
|
|
4985
|
-
/* @__PURE__ */
|
|
4986
|
-
/* @__PURE__ */
|
|
5390
|
+
showSettingsMenu && /* @__PURE__ */ jsx28("div", { className: "absolute top-10 left-0 z-50 w-64 bg-white dark:bg-neutral-800 border border-neutral-200 dark:border-neutral-700 rounded-lg shadow-lg p-3 settings-menu-container", children: /* @__PURE__ */ jsxs22("label", { className: "flex items-center justify-between cursor-pointer group", children: [
|
|
5391
|
+
/* @__PURE__ */ jsxs22("div", { className: "flex items-center gap-2", children: [
|
|
5392
|
+
/* @__PURE__ */ jsx28("svg", { className: "w-4 h-4 text-neutral-500 dark:text-neutral-400", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ jsx28("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-3 7h3m-3 4h3m-6-4h.01M9 16h.01" }) }),
|
|
5393
|
+
/* @__PURE__ */ jsxs22("div", { children: [
|
|
5394
|
+
/* @__PURE__ */ jsx28("div", { className: "text-sm font-medium text-neutral-700 dark:text-neutral-300", children: "Plan Mode" }),
|
|
5395
|
+
/* @__PURE__ */ jsx28("div", { className: "text-xs text-neutral-500 dark:text-neutral-400", children: "Review before executing" })
|
|
4987
5396
|
] })
|
|
4988
5397
|
] }),
|
|
4989
|
-
/* @__PURE__ */
|
|
5398
|
+
/* @__PURE__ */ jsx28(
|
|
4990
5399
|
"button",
|
|
4991
5400
|
{
|
|
4992
5401
|
onClick: (e) => {
|
|
@@ -4998,7 +5407,7 @@ ${planToExecute}`;
|
|
|
4998
5407
|
internalPlanMode ? "bg-blue-600" : "bg-neutral-300 dark:bg-neutral-600"
|
|
4999
5408
|
),
|
|
5000
5409
|
type: "button",
|
|
5001
|
-
children: /* @__PURE__ */
|
|
5410
|
+
children: /* @__PURE__ */ jsx28(
|
|
5002
5411
|
"span",
|
|
5003
5412
|
{
|
|
5004
5413
|
className: cn(
|
|
@@ -5012,9 +5421,9 @@ ${planToExecute}`;
|
|
|
5012
5421
|
] }) })
|
|
5013
5422
|
] })
|
|
5014
5423
|
] }) }),
|
|
5015
|
-
!(state === "idle" && allowInput) && /* @__PURE__ */
|
|
5016
|
-
/* @__PURE__ */
|
|
5017
|
-
(state === "success" || state === "error") && allowInput && /* @__PURE__ */
|
|
5424
|
+
!(state === "idle" && allowInput) && /* @__PURE__ */ jsx28("div", {}),
|
|
5425
|
+
/* @__PURE__ */ jsxs22("div", { className: "flex items-center gap-2", children: [
|
|
5426
|
+
(state === "success" || state === "error") && allowInput && /* @__PURE__ */ jsx28(
|
|
5018
5427
|
"button",
|
|
5019
5428
|
{
|
|
5020
5429
|
onClick: resetCommand,
|
|
@@ -5022,7 +5431,7 @@ ${planToExecute}`;
|
|
|
5022
5431
|
children: "Reset"
|
|
5023
5432
|
}
|
|
5024
5433
|
),
|
|
5025
|
-
(state === "idle" || state === "error") && /* @__PURE__ */
|
|
5434
|
+
(state === "idle" || state === "error") && /* @__PURE__ */ jsx28(
|
|
5026
5435
|
"button",
|
|
5027
5436
|
{
|
|
5028
5437
|
onClick: () => executeCommand(),
|
|
@@ -5038,29 +5447,29 @@ ${planToExecute}`;
|
|
|
5038
5447
|
!command.trim() && "border-neutral-200 dark:border-neutral-700 !text-neutral-400 dark:!text-neutral-600"
|
|
5039
5448
|
),
|
|
5040
5449
|
title: state === "error" ? "Retry" : "Execute",
|
|
5041
|
-
children: state === "error" ? /* @__PURE__ */
|
|
5450
|
+
children: state === "error" ? /* @__PURE__ */ jsx28("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsx28("path", { d: "M13 8C13 10.7614 10.7614 13 8 13C5.23858 13 3 10.7614 3 8C3 5.23858 5.23858 3 8 3C9.65685 3 11.1257 3.82818 12 5.09091M12 3V5.09091M12 5.09091H9.81818", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) }) : /* @__PURE__ */ jsx28("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsx28("path", { d: "M8 3L8 13M8 3L4 7M8 3L12 7", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) })
|
|
5042
5451
|
}
|
|
5043
5452
|
)
|
|
5044
5453
|
] })
|
|
5045
5454
|
] }),
|
|
5046
|
-
showPlanDetails && isCompact && state === "plan-pending" && /* @__PURE__ */
|
|
5047
|
-
/* @__PURE__ */
|
|
5048
|
-
/* @__PURE__ */
|
|
5049
|
-
/* @__PURE__ */
|
|
5050
|
-
/* @__PURE__ */
|
|
5455
|
+
showPlanDetails && isCompact && state === "plan-pending" && /* @__PURE__ */ jsx28("div", { className: "fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4", onClick: () => setShowPlanDetails(false), children: /* @__PURE__ */ jsxs22("div", { className: "bg-white dark:bg-neutral-900 rounded-2xl shadow-2xl max-w-2xl w-full max-h-[80vh] overflow-hidden", onClick: (e) => e.stopPropagation(), children: [
|
|
5456
|
+
/* @__PURE__ */ jsxs22("div", { className: "flex items-center justify-between p-6 border-b border-neutral-200 dark:border-neutral-700", children: [
|
|
5457
|
+
/* @__PURE__ */ jsxs22("div", { className: "flex items-center gap-3", children: [
|
|
5458
|
+
/* @__PURE__ */ jsx28("svg", { className: "w-6 h-6 text-blue-600 dark:text-blue-400", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ jsx28("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-3 7h3m-3 4h3m-6-4h.01M9 16h.01" }) }),
|
|
5459
|
+
/* @__PURE__ */ jsx28("h2", { className: "text-xl font-semibold text-neutral-900 dark:text-white", children: "Proposed Execution Plan" })
|
|
5051
5460
|
] }),
|
|
5052
|
-
/* @__PURE__ */
|
|
5461
|
+
/* @__PURE__ */ jsx28(
|
|
5053
5462
|
"button",
|
|
5054
5463
|
{
|
|
5055
5464
|
onClick: () => setShowPlanDetails(false),
|
|
5056
5465
|
className: "text-neutral-400 hover:text-neutral-600 dark:hover:text-neutral-300 transition-colors",
|
|
5057
|
-
children: /* @__PURE__ */
|
|
5466
|
+
children: /* @__PURE__ */ jsx28("svg", { className: "w-6 h-6", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ jsx28("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M6 18L18 6M6 6l12 12" }) })
|
|
5058
5467
|
}
|
|
5059
5468
|
)
|
|
5060
5469
|
] }),
|
|
5061
|
-
/* @__PURE__ */
|
|
5062
|
-
/* @__PURE__ */
|
|
5063
|
-
/* @__PURE__ */
|
|
5470
|
+
/* @__PURE__ */ jsx28("div", { className: "p-6 overflow-y-auto max-h-[calc(80vh-180px)]", children: /* @__PURE__ */ jsx28("div", { className: "prose prose-sm dark:prose-invert max-w-none", children: /* @__PURE__ */ jsx28("div", { className: "text-neutral-700 dark:text-neutral-300 whitespace-pre-line leading-relaxed", children: plan }) }) }),
|
|
5471
|
+
/* @__PURE__ */ jsxs22("div", { className: "flex items-center justify-end gap-3 p-6 border-t border-neutral-200 dark:border-neutral-700 bg-neutral-50 dark:bg-neutral-800/50", children: [
|
|
5472
|
+
/* @__PURE__ */ jsx28(
|
|
5064
5473
|
"button",
|
|
5065
5474
|
{
|
|
5066
5475
|
onClick: rejectPlan,
|
|
@@ -5068,7 +5477,7 @@ ${planToExecute}`;
|
|
|
5068
5477
|
children: "Modify Command"
|
|
5069
5478
|
}
|
|
5070
5479
|
),
|
|
5071
|
-
/* @__PURE__ */
|
|
5480
|
+
/* @__PURE__ */ jsx28(
|
|
5072
5481
|
"button",
|
|
5073
5482
|
{
|
|
5074
5483
|
onClick: approvePlan,
|
|
@@ -5078,7 +5487,7 @@ ${planToExecute}`;
|
|
|
5078
5487
|
)
|
|
5079
5488
|
] })
|
|
5080
5489
|
] }) }),
|
|
5081
|
-
/* @__PURE__ */
|
|
5490
|
+
/* @__PURE__ */ jsx28(
|
|
5082
5491
|
"input",
|
|
5083
5492
|
{
|
|
5084
5493
|
ref: fileInputRef,
|
|
@@ -5089,7 +5498,7 @@ ${planToExecute}`;
|
|
|
5089
5498
|
accept: "image/*,application/pdf,.doc,.docx,.txt"
|
|
5090
5499
|
}
|
|
5091
5500
|
),
|
|
5092
|
-
/* @__PURE__ */
|
|
5501
|
+
/* @__PURE__ */ jsx28("style", { dangerouslySetInnerHTML: {
|
|
5093
5502
|
__html: `
|
|
5094
5503
|
@keyframes pulse-border {
|
|
5095
5504
|
0%, 100% {
|
|
@@ -5110,8 +5519,8 @@ ${planToExecute}`;
|
|
|
5110
5519
|
}
|
|
5111
5520
|
|
|
5112
5521
|
// src/components/Prompt/Prompt.tsx
|
|
5113
|
-
import { useState as
|
|
5114
|
-
import { jsx as
|
|
5522
|
+
import { useState as useState12 } from "react";
|
|
5523
|
+
import { jsx as jsx29, jsxs as jsxs23 } from "react/jsx-runtime";
|
|
5115
5524
|
function Prompt({
|
|
5116
5525
|
agentId,
|
|
5117
5526
|
placeholder = "Enter your prompt...",
|
|
@@ -5128,9 +5537,9 @@ function Prompt({
|
|
|
5128
5537
|
showSuggestions = false,
|
|
5129
5538
|
className
|
|
5130
5539
|
}) {
|
|
5131
|
-
const [value, setValue] =
|
|
5132
|
-
const [isLoading, setIsLoading] =
|
|
5133
|
-
const [suggestions] =
|
|
5540
|
+
const [value, setValue] = useState12(initialValue);
|
|
5541
|
+
const [isLoading, setIsLoading] = useState12(false);
|
|
5542
|
+
const [suggestions] = useState12(["Plan a trip", "Write a description", "Analyze data"]);
|
|
5134
5543
|
const handleChange = (e) => {
|
|
5135
5544
|
const newValue = e.target.value;
|
|
5136
5545
|
if (!maxLength || newValue.length <= maxLength) {
|
|
@@ -5173,9 +5582,9 @@ function Prompt({
|
|
|
5173
5582
|
handleSubmit();
|
|
5174
5583
|
}
|
|
5175
5584
|
};
|
|
5176
|
-
return /* @__PURE__ */
|
|
5177
|
-
/* @__PURE__ */
|
|
5178
|
-
/* @__PURE__ */
|
|
5585
|
+
return /* @__PURE__ */ jsxs23("div", { className: cn("space-y-2", className), children: [
|
|
5586
|
+
/* @__PURE__ */ jsxs23("div", { className: "flex gap-2", children: [
|
|
5587
|
+
/* @__PURE__ */ jsx29(
|
|
5179
5588
|
"input",
|
|
5180
5589
|
{
|
|
5181
5590
|
type: "text",
|
|
@@ -5188,7 +5597,7 @@ function Prompt({
|
|
|
5188
5597
|
className: "flex-1 px-4 py-2 border border-neutral-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-apteva-500 dark:bg-neutral-800 dark:border-neutral-600 dark:text-white"
|
|
5189
5598
|
}
|
|
5190
5599
|
),
|
|
5191
|
-
submitOn === "button" && /* @__PURE__ */
|
|
5600
|
+
submitOn === "button" && /* @__PURE__ */ jsx29(
|
|
5192
5601
|
"button",
|
|
5193
5602
|
{
|
|
5194
5603
|
onClick: handleSubmit,
|
|
@@ -5198,13 +5607,13 @@ function Prompt({
|
|
|
5198
5607
|
}
|
|
5199
5608
|
)
|
|
5200
5609
|
] }),
|
|
5201
|
-
maxLength && /* @__PURE__ */
|
|
5610
|
+
maxLength && /* @__PURE__ */ jsxs23("p", { className: "text-xs text-neutral-500", children: [
|
|
5202
5611
|
value.length,
|
|
5203
5612
|
" / ",
|
|
5204
5613
|
maxLength,
|
|
5205
5614
|
" characters"
|
|
5206
5615
|
] }),
|
|
5207
|
-
showSuggestions && !value && /* @__PURE__ */
|
|
5616
|
+
showSuggestions && !value && /* @__PURE__ */ jsx29("div", { className: "flex flex-wrap gap-2", children: suggestions.map((suggestion, idx) => /* @__PURE__ */ jsx29(
|
|
5208
5617
|
"button",
|
|
5209
5618
|
{
|
|
5210
5619
|
onClick: () => setValue(suggestion),
|
|
@@ -5213,16 +5622,16 @@ function Prompt({
|
|
|
5213
5622
|
},
|
|
5214
5623
|
idx
|
|
5215
5624
|
)) }),
|
|
5216
|
-
isLoading && /* @__PURE__ */
|
|
5217
|
-
/* @__PURE__ */
|
|
5218
|
-
/* @__PURE__ */
|
|
5625
|
+
isLoading && /* @__PURE__ */ jsxs23("div", { className: "flex items-center gap-2 text-sm text-neutral-500", children: [
|
|
5626
|
+
/* @__PURE__ */ jsx29("div", { className: "w-4 h-4 border-2 border-apteva-500 border-t-transparent rounded-full animate-spin" }),
|
|
5627
|
+
/* @__PURE__ */ jsx29("span", { children: "AI is processing your request..." })
|
|
5219
5628
|
] })
|
|
5220
5629
|
] });
|
|
5221
5630
|
}
|
|
5222
5631
|
|
|
5223
5632
|
// src/components/Stream/Stream.tsx
|
|
5224
|
-
import { useState as
|
|
5225
|
-
import { jsx as
|
|
5633
|
+
import { useState as useState13, useEffect as useEffect9 } from "react";
|
|
5634
|
+
import { jsx as jsx30, jsxs as jsxs24 } from "react/jsx-runtime";
|
|
5226
5635
|
function Stream({
|
|
5227
5636
|
agentId,
|
|
5228
5637
|
prompt,
|
|
@@ -5238,10 +5647,10 @@ function Stream({
|
|
|
5238
5647
|
typingSpeed = 30,
|
|
5239
5648
|
className
|
|
5240
5649
|
}) {
|
|
5241
|
-
const [text, setText] =
|
|
5242
|
-
const [isStreaming, setIsStreaming] =
|
|
5243
|
-
const [isComplete, setIsComplete] =
|
|
5244
|
-
|
|
5650
|
+
const [text, setText] = useState13("");
|
|
5651
|
+
const [isStreaming, setIsStreaming] = useState13(false);
|
|
5652
|
+
const [isComplete, setIsComplete] = useState13(false);
|
|
5653
|
+
useEffect9(() => {
|
|
5245
5654
|
if (autoStart && !isStreaming && !isComplete) {
|
|
5246
5655
|
startStreaming();
|
|
5247
5656
|
}
|
|
@@ -5302,7 +5711,7 @@ function Stream({
|
|
|
5302
5711
|
plain: "text-neutral-900 dark:text-neutral-100"
|
|
5303
5712
|
};
|
|
5304
5713
|
if (!isStreaming && !isComplete) {
|
|
5305
|
-
return /* @__PURE__ */
|
|
5714
|
+
return /* @__PURE__ */ jsx30("div", { className: cn("p-4", className), children: /* @__PURE__ */ jsx30(
|
|
5306
5715
|
"button",
|
|
5307
5716
|
{
|
|
5308
5717
|
onClick: startStreaming,
|
|
@@ -5311,19 +5720,19 @@ function Stream({
|
|
|
5311
5720
|
}
|
|
5312
5721
|
) });
|
|
5313
5722
|
}
|
|
5314
|
-
return /* @__PURE__ */
|
|
5723
|
+
return /* @__PURE__ */ jsxs24("div", { className: cn(variantClasses[variant], className), children: [
|
|
5315
5724
|
text,
|
|
5316
|
-
isStreaming && showCursor && /* @__PURE__ */
|
|
5725
|
+
isStreaming && showCursor && /* @__PURE__ */ jsx30("span", { className: "apteva-stream-cursor" })
|
|
5317
5726
|
] });
|
|
5318
5727
|
}
|
|
5319
5728
|
|
|
5320
5729
|
// src/components/Threads/ThreadList.tsx
|
|
5321
|
-
import { useState as
|
|
5730
|
+
import { useState as useState14 } from "react";
|
|
5322
5731
|
|
|
5323
5732
|
// src/components/Threads/ThreadItem.tsx
|
|
5324
|
-
import { jsx as
|
|
5733
|
+
import { jsx as jsx31, jsxs as jsxs25 } from "react/jsx-runtime";
|
|
5325
5734
|
function ThreadItem({ thread, isActive = false, onSelect, onDelete }) {
|
|
5326
|
-
return /* @__PURE__ */
|
|
5735
|
+
return /* @__PURE__ */ jsxs25(
|
|
5327
5736
|
"div",
|
|
5328
5737
|
{
|
|
5329
5738
|
className: cn("apteva-thread-item", {
|
|
@@ -5331,19 +5740,19 @@ function ThreadItem({ thread, isActive = false, onSelect, onDelete }) {
|
|
|
5331
5740
|
}),
|
|
5332
5741
|
onClick: onSelect,
|
|
5333
5742
|
children: [
|
|
5334
|
-
/* @__PURE__ */
|
|
5335
|
-
/* @__PURE__ */
|
|
5336
|
-
thread.preview && /* @__PURE__ */
|
|
5337
|
-
/* @__PURE__ */
|
|
5338
|
-
/* @__PURE__ */
|
|
5743
|
+
/* @__PURE__ */ jsxs25("div", { className: "flex-1 min-w-0", children: [
|
|
5744
|
+
/* @__PURE__ */ jsx31("h4", { className: "font-semibold text-neutral-900 dark:text-white truncate", children: thread.title }),
|
|
5745
|
+
thread.preview && /* @__PURE__ */ jsx31("p", { className: "text-sm text-neutral-600 dark:text-neutral-400 truncate", children: thread.preview }),
|
|
5746
|
+
/* @__PURE__ */ jsxs25("div", { className: "flex items-center gap-2 mt-1 text-xs text-neutral-500", children: [
|
|
5747
|
+
/* @__PURE__ */ jsxs25("span", { children: [
|
|
5339
5748
|
thread.messageCount,
|
|
5340
5749
|
" messages"
|
|
5341
5750
|
] }),
|
|
5342
|
-
/* @__PURE__ */
|
|
5343
|
-
/* @__PURE__ */
|
|
5751
|
+
/* @__PURE__ */ jsx31("span", { children: "\u2022" }),
|
|
5752
|
+
/* @__PURE__ */ jsx31("span", { children: formatRelativeTime(thread.updatedAt) })
|
|
5344
5753
|
] })
|
|
5345
5754
|
] }),
|
|
5346
|
-
onDelete && /* @__PURE__ */
|
|
5755
|
+
onDelete && /* @__PURE__ */ jsx31(
|
|
5347
5756
|
"button",
|
|
5348
5757
|
{
|
|
5349
5758
|
onClick: (e) => {
|
|
@@ -5373,7 +5782,7 @@ function formatRelativeTime(date) {
|
|
|
5373
5782
|
}
|
|
5374
5783
|
|
|
5375
5784
|
// src/components/Threads/ThreadList.tsx
|
|
5376
|
-
import { jsx as
|
|
5785
|
+
import { jsx as jsx32, jsxs as jsxs26 } from "react/jsx-runtime";
|
|
5377
5786
|
function ThreadList({
|
|
5378
5787
|
threads,
|
|
5379
5788
|
currentThreadId,
|
|
@@ -5382,13 +5791,13 @@ function ThreadList({
|
|
|
5382
5791
|
showSearch = false,
|
|
5383
5792
|
groupBy = "none"
|
|
5384
5793
|
}) {
|
|
5385
|
-
const [searchQuery, setSearchQuery] =
|
|
5794
|
+
const [searchQuery, setSearchQuery] = useState14("");
|
|
5386
5795
|
const filteredThreads = threads.filter(
|
|
5387
5796
|
(thread) => thread.title.toLowerCase().includes(searchQuery.toLowerCase()) || thread.preview?.toLowerCase().includes(searchQuery.toLowerCase())
|
|
5388
5797
|
);
|
|
5389
5798
|
const groupedThreads = groupBy === "date" ? groupThreadsByDate(filteredThreads) : { All: filteredThreads };
|
|
5390
|
-
return /* @__PURE__ */
|
|
5391
|
-
showSearch && /* @__PURE__ */
|
|
5799
|
+
return /* @__PURE__ */ jsxs26("div", { className: "flex flex-col h-full", children: [
|
|
5800
|
+
showSearch && /* @__PURE__ */ jsx32("div", { className: "p-3 border-b border-neutral-200 dark:border-neutral-700", children: /* @__PURE__ */ jsx32(
|
|
5392
5801
|
"input",
|
|
5393
5802
|
{
|
|
5394
5803
|
type: "text",
|
|
@@ -5398,10 +5807,10 @@ function ThreadList({
|
|
|
5398
5807
|
className: "w-full px-3 py-2 text-sm border border-neutral-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-apteva-500 dark:bg-neutral-800 dark:border-neutral-600 dark:text-white"
|
|
5399
5808
|
}
|
|
5400
5809
|
) }),
|
|
5401
|
-
/* @__PURE__ */
|
|
5402
|
-
Object.entries(groupedThreads).map(([group, groupThreads]) => /* @__PURE__ */
|
|
5403
|
-
groupBy !== "none" && /* @__PURE__ */
|
|
5404
|
-
groupThreads.map((thread) => /* @__PURE__ */
|
|
5810
|
+
/* @__PURE__ */ jsxs26("div", { className: "flex-1 overflow-y-auto", children: [
|
|
5811
|
+
Object.entries(groupedThreads).map(([group, groupThreads]) => /* @__PURE__ */ jsxs26("div", { children: [
|
|
5812
|
+
groupBy !== "none" && /* @__PURE__ */ jsx32("div", { className: "px-3 py-2 text-xs font-semibold text-neutral-500 uppercase", children: group }),
|
|
5813
|
+
groupThreads.map((thread) => /* @__PURE__ */ jsx32(
|
|
5405
5814
|
ThreadItem,
|
|
5406
5815
|
{
|
|
5407
5816
|
thread,
|
|
@@ -5412,9 +5821,9 @@ function ThreadList({
|
|
|
5412
5821
|
thread.id
|
|
5413
5822
|
))
|
|
5414
5823
|
] }, group)),
|
|
5415
|
-
filteredThreads.length === 0 && /* @__PURE__ */
|
|
5416
|
-
/* @__PURE__ */
|
|
5417
|
-
/* @__PURE__ */
|
|
5824
|
+
filteredThreads.length === 0 && /* @__PURE__ */ jsxs26("div", { className: "p-8 text-center text-neutral-500", children: [
|
|
5825
|
+
/* @__PURE__ */ jsx32("svg", { className: "w-10 h-10 mx-auto mb-2 opacity-50", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx32("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 1.5, d: "M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z" }) }),
|
|
5826
|
+
/* @__PURE__ */ jsx32("p", { children: "No conversations found" })
|
|
5418
5827
|
] })
|
|
5419
5828
|
] })
|
|
5420
5829
|
] });
|
|
@@ -5446,7 +5855,7 @@ function groupThreadsByDate(threads) {
|
|
|
5446
5855
|
}
|
|
5447
5856
|
|
|
5448
5857
|
// src/components/Threads/Threads.tsx
|
|
5449
|
-
import { jsx as
|
|
5858
|
+
import { jsx as jsx33, jsxs as jsxs27 } from "react/jsx-runtime";
|
|
5450
5859
|
function Threads({
|
|
5451
5860
|
threads,
|
|
5452
5861
|
currentThreadId,
|
|
@@ -5465,8 +5874,8 @@ function Threads({
|
|
|
5465
5874
|
tabs: "flex gap-2 border-b border-neutral-200 dark:border-neutral-700 overflow-x-auto"
|
|
5466
5875
|
};
|
|
5467
5876
|
if (variant === "tabs") {
|
|
5468
|
-
return /* @__PURE__ */
|
|
5469
|
-
threads.slice(0, 5).map((thread) => /* @__PURE__ */
|
|
5877
|
+
return /* @__PURE__ */ jsxs27("div", { className: cn(variantClasses[variant], className), children: [
|
|
5878
|
+
threads.slice(0, 5).map((thread) => /* @__PURE__ */ jsx33(
|
|
5470
5879
|
"button",
|
|
5471
5880
|
{
|
|
5472
5881
|
onClick: () => onThreadSelect?.(thread.id),
|
|
@@ -5478,7 +5887,7 @@ function Threads({
|
|
|
5478
5887
|
},
|
|
5479
5888
|
thread.id
|
|
5480
5889
|
)),
|
|
5481
|
-
showNewButton && onNewThread && /* @__PURE__ */
|
|
5890
|
+
showNewButton && onNewThread && /* @__PURE__ */ jsx33(
|
|
5482
5891
|
"button",
|
|
5483
5892
|
{
|
|
5484
5893
|
onClick: onNewThread,
|
|
@@ -5488,8 +5897,8 @@ function Threads({
|
|
|
5488
5897
|
)
|
|
5489
5898
|
] });
|
|
5490
5899
|
}
|
|
5491
|
-
return /* @__PURE__ */
|
|
5492
|
-
showNewButton && onNewThread && /* @__PURE__ */
|
|
5900
|
+
return /* @__PURE__ */ jsxs27("div", { className: cn(variantClasses[variant], "flex flex-col", className), children: [
|
|
5901
|
+
showNewButton && onNewThread && /* @__PURE__ */ jsx33("div", { className: "p-3 border-b border-neutral-200 dark:border-neutral-700", children: /* @__PURE__ */ jsx33(
|
|
5493
5902
|
"button",
|
|
5494
5903
|
{
|
|
5495
5904
|
onClick: onNewThread,
|
|
@@ -5497,7 +5906,7 @@ function Threads({
|
|
|
5497
5906
|
children: "+ New Conversation"
|
|
5498
5907
|
}
|
|
5499
5908
|
) }),
|
|
5500
|
-
/* @__PURE__ */
|
|
5909
|
+
/* @__PURE__ */ jsx33(
|
|
5501
5910
|
ThreadList,
|
|
5502
5911
|
{
|
|
5503
5912
|
threads,
|
|
@@ -5512,11 +5921,11 @@ function Threads({
|
|
|
5512
5921
|
}
|
|
5513
5922
|
|
|
5514
5923
|
// src/components/AutoInterface/AutoInterface.tsx
|
|
5515
|
-
import { useState as
|
|
5924
|
+
import { useState as useState16, useRef as useRef10, useCallback as useCallback3, useEffect as useEffect10 } from "react";
|
|
5516
5925
|
|
|
5517
5926
|
// src/components/AutoInterface/LayoutRenderer.tsx
|
|
5518
|
-
import { useState as
|
|
5519
|
-
import { Fragment as
|
|
5927
|
+
import { useState as useState15 } from "react";
|
|
5928
|
+
import { Fragment as Fragment8, jsx as jsx34, jsxs as jsxs28 } from "react/jsx-runtime";
|
|
5520
5929
|
var gapClasses = {
|
|
5521
5930
|
none: "gap-0",
|
|
5522
5931
|
sm: "gap-2",
|
|
@@ -5540,27 +5949,27 @@ function LayoutRenderer({ node, onAction, renderNode }) {
|
|
|
5540
5949
|
const children = node.children || [];
|
|
5541
5950
|
switch (node.layout) {
|
|
5542
5951
|
case "page":
|
|
5543
|
-
return /* @__PURE__ */
|
|
5952
|
+
return /* @__PURE__ */ jsx34(PageLayout, { node, renderNode });
|
|
5544
5953
|
case "row":
|
|
5545
|
-
return /* @__PURE__ */
|
|
5954
|
+
return /* @__PURE__ */ jsx34(RowLayout, { node, renderNode });
|
|
5546
5955
|
case "columns":
|
|
5547
|
-
return /* @__PURE__ */
|
|
5956
|
+
return /* @__PURE__ */ jsx34(ColumnsLayout, { node, renderNode });
|
|
5548
5957
|
case "stack":
|
|
5549
|
-
return /* @__PURE__ */
|
|
5958
|
+
return /* @__PURE__ */ jsx34(StackLayout, { node, renderNode });
|
|
5550
5959
|
case "sidebar":
|
|
5551
|
-
return /* @__PURE__ */
|
|
5960
|
+
return /* @__PURE__ */ jsx34(SidebarLayout, { node, renderNode });
|
|
5552
5961
|
case "tabs":
|
|
5553
|
-
return /* @__PURE__ */
|
|
5962
|
+
return /* @__PURE__ */ jsx34(TabsLayout, { node, renderNode });
|
|
5554
5963
|
default:
|
|
5555
|
-
return /* @__PURE__ */
|
|
5964
|
+
return /* @__PURE__ */ jsx34("div", { className: "space-y-4", children: children.map((child) => /* @__PURE__ */ jsx34("div", { children: renderNode(child) }, child.id)) });
|
|
5556
5965
|
}
|
|
5557
5966
|
}
|
|
5558
5967
|
function PageLayout({ node, renderNode }) {
|
|
5559
5968
|
const { title, padding = "md", maxWidth = "xl" } = node.props || {};
|
|
5560
5969
|
const children = node.children || [];
|
|
5561
|
-
return /* @__PURE__ */
|
|
5562
|
-
title && /* @__PURE__ */
|
|
5563
|
-
/* @__PURE__ */
|
|
5970
|
+
return /* @__PURE__ */ jsxs28("div", { className: cn("w-full mx-auto", paddingClasses[padding], maxWidthClasses[maxWidth]), children: [
|
|
5971
|
+
title && /* @__PURE__ */ jsx34("h1", { className: "!text-2xl font-bold !text-neutral-900 dark:!text-white mb-6", children: title }),
|
|
5972
|
+
/* @__PURE__ */ jsx34("div", { className: "space-y-6", children: children.map((child) => /* @__PURE__ */ jsx34("div", { children: renderNode(child) }, child.id)) })
|
|
5564
5973
|
] });
|
|
5565
5974
|
}
|
|
5566
5975
|
function RowLayout({ node, renderNode }) {
|
|
@@ -5573,12 +5982,12 @@ function RowLayout({ node, renderNode }) {
|
|
|
5573
5982
|
end: "items-end",
|
|
5574
5983
|
stretch: "items-stretch"
|
|
5575
5984
|
};
|
|
5576
|
-
return /* @__PURE__ */
|
|
5985
|
+
return /* @__PURE__ */ jsx34(
|
|
5577
5986
|
"div",
|
|
5578
5987
|
{
|
|
5579
5988
|
className: cn("grid", gapClasses[gap], alignClasses[align]),
|
|
5580
5989
|
style: { gridTemplateColumns: templateColumns },
|
|
5581
|
-
children: children.map((child) => /* @__PURE__ */
|
|
5990
|
+
children: children.map((child) => /* @__PURE__ */ jsx34("div", { children: renderNode(child) }, child.id))
|
|
5582
5991
|
}
|
|
5583
5992
|
);
|
|
5584
5993
|
}
|
|
@@ -5586,12 +5995,12 @@ function ColumnsLayout({ node, renderNode }) {
|
|
|
5586
5995
|
const { count, gap = "md" } = node.props || {};
|
|
5587
5996
|
const children = node.children || [];
|
|
5588
5997
|
const colCount = count || children.length;
|
|
5589
|
-
return /* @__PURE__ */
|
|
5998
|
+
return /* @__PURE__ */ jsx34(
|
|
5590
5999
|
"div",
|
|
5591
6000
|
{
|
|
5592
6001
|
className: cn("grid", gapClasses[gap]),
|
|
5593
6002
|
style: { gridTemplateColumns: `repeat(${colCount}, 1fr)` },
|
|
5594
|
-
children: children.map((child) => /* @__PURE__ */
|
|
6003
|
+
children: children.map((child) => /* @__PURE__ */ jsx34("div", { children: renderNode(child) }, child.id))
|
|
5595
6004
|
}
|
|
5596
6005
|
);
|
|
5597
6006
|
}
|
|
@@ -5604,14 +6013,14 @@ function StackLayout({ node, renderNode }) {
|
|
|
5604
6013
|
right: "items-end",
|
|
5605
6014
|
stretch: "items-stretch"
|
|
5606
6015
|
};
|
|
5607
|
-
return /* @__PURE__ */
|
|
6016
|
+
return /* @__PURE__ */ jsx34("div", { className: cn("flex flex-col", gapClasses[gap], alignClasses[align]), children: children.map((child) => /* @__PURE__ */ jsx34("div", { children: renderNode(child) }, child.id)) });
|
|
5608
6017
|
}
|
|
5609
6018
|
function SidebarLayout({ node, renderNode }) {
|
|
5610
6019
|
const { side = "left", width = "280px" } = node.props || {};
|
|
5611
6020
|
const children = node.children || [];
|
|
5612
6021
|
const [sidebarChild, ...mainChildren] = side === "left" ? children : [...children].reverse();
|
|
5613
6022
|
if (!sidebarChild) return null;
|
|
5614
|
-
const sidebar = /* @__PURE__ */
|
|
6023
|
+
const sidebar = /* @__PURE__ */ jsx34(
|
|
5615
6024
|
"div",
|
|
5616
6025
|
{
|
|
5617
6026
|
className: "flex-shrink-0 overflow-y-auto border-neutral-200 dark:border-neutral-700",
|
|
@@ -5619,11 +6028,11 @@ function SidebarLayout({ node, renderNode }) {
|
|
|
5619
6028
|
children: renderNode(sidebarChild)
|
|
5620
6029
|
}
|
|
5621
6030
|
);
|
|
5622
|
-
const main = /* @__PURE__ */
|
|
5623
|
-
return /* @__PURE__ */
|
|
6031
|
+
const main = /* @__PURE__ */ jsx34("div", { className: "flex-1 overflow-y-auto min-w-0", children: mainChildren.map((child) => /* @__PURE__ */ jsx34("div", { children: renderNode(child) }, child.id)) });
|
|
6032
|
+
return /* @__PURE__ */ jsx34("div", { className: "flex h-full gap-4", children: side === "left" ? /* @__PURE__ */ jsxs28(Fragment8, { children: [
|
|
5624
6033
|
sidebar,
|
|
5625
6034
|
main
|
|
5626
|
-
] }) : /* @__PURE__ */
|
|
6035
|
+
] }) : /* @__PURE__ */ jsxs28(Fragment8, { children: [
|
|
5627
6036
|
main,
|
|
5628
6037
|
sidebar
|
|
5629
6038
|
] }) });
|
|
@@ -5631,9 +6040,9 @@ function SidebarLayout({ node, renderNode }) {
|
|
|
5631
6040
|
function TabsLayout({ node, renderNode }) {
|
|
5632
6041
|
const { labels = [], defaultTab = 0 } = node.props || {};
|
|
5633
6042
|
const children = node.children || [];
|
|
5634
|
-
const [activeTab, setActiveTab] =
|
|
5635
|
-
return /* @__PURE__ */
|
|
5636
|
-
/* @__PURE__ */
|
|
6043
|
+
const [activeTab, setActiveTab] = useState15(defaultTab);
|
|
6044
|
+
return /* @__PURE__ */ jsxs28("div", { children: [
|
|
6045
|
+
/* @__PURE__ */ jsx34("div", { className: "flex border-b border-neutral-200 dark:border-neutral-700 mb-4", children: labels.map((label, idx) => /* @__PURE__ */ jsx34(
|
|
5637
6046
|
"button",
|
|
5638
6047
|
{
|
|
5639
6048
|
onClick: () => setActiveTab(idx),
|
|
@@ -5650,7 +6059,7 @@ function TabsLayout({ node, renderNode }) {
|
|
|
5650
6059
|
}
|
|
5651
6060
|
|
|
5652
6061
|
// src/components/AutoInterface/InterfaceRenderer.tsx
|
|
5653
|
-
import { Fragment as
|
|
6062
|
+
import { Fragment as Fragment9, jsx as jsx35 } from "react/jsx-runtime";
|
|
5654
6063
|
var STRUCTURAL_KEYS = /* @__PURE__ */ new Set(["type", "id", "layout", "props", "children", "actions", "metadata", "isStreaming"]);
|
|
5655
6064
|
function normalizeNode(n) {
|
|
5656
6065
|
let node = { ...n };
|
|
@@ -5680,7 +6089,7 @@ function InterfaceRenderer({ node, onAction }) {
|
|
|
5680
6089
|
const renderNode = (rawNode) => {
|
|
5681
6090
|
const n = normalizeNode(rawNode);
|
|
5682
6091
|
if (n.type === "layout" && n.layout) {
|
|
5683
|
-
return /* @__PURE__ */
|
|
6092
|
+
return /* @__PURE__ */ jsx35(
|
|
5684
6093
|
LayoutRenderer,
|
|
5685
6094
|
{
|
|
5686
6095
|
node: n,
|
|
@@ -5690,7 +6099,7 @@ function InterfaceRenderer({ node, onAction }) {
|
|
|
5690
6099
|
n.id
|
|
5691
6100
|
);
|
|
5692
6101
|
}
|
|
5693
|
-
return /* @__PURE__ */
|
|
6102
|
+
return /* @__PURE__ */ jsx35(
|
|
5694
6103
|
WidgetRenderer,
|
|
5695
6104
|
{
|
|
5696
6105
|
widget: {
|
|
@@ -5706,33 +6115,33 @@ function InterfaceRenderer({ node, onAction }) {
|
|
|
5706
6115
|
n.id
|
|
5707
6116
|
);
|
|
5708
6117
|
};
|
|
5709
|
-
return /* @__PURE__ */
|
|
6118
|
+
return /* @__PURE__ */ jsx35(Fragment9, { children: renderNode(node) });
|
|
5710
6119
|
}
|
|
5711
6120
|
|
|
5712
6121
|
// src/components/AutoInterface/InterfaceSkeleton.tsx
|
|
5713
|
-
import { jsx as
|
|
6122
|
+
import { jsx as jsx36, jsxs as jsxs29 } from "react/jsx-runtime";
|
|
5714
6123
|
function InterfaceSkeleton({ className }) {
|
|
5715
|
-
return /* @__PURE__ */
|
|
5716
|
-
/* @__PURE__ */
|
|
5717
|
-
/* @__PURE__ */
|
|
5718
|
-
/* @__PURE__ */
|
|
5719
|
-
/* @__PURE__ */
|
|
6124
|
+
return /* @__PURE__ */ jsxs29("div", { className: cn("animate-pulse space-y-6 p-6", className), children: [
|
|
6125
|
+
/* @__PURE__ */ jsx36("div", { className: "h-7 bg-neutral-200 dark:bg-neutral-700 rounded w-1/3" }),
|
|
6126
|
+
/* @__PURE__ */ jsx36("div", { className: "grid grid-cols-4 gap-4", children: [1, 2, 3, 4].map((i) => /* @__PURE__ */ jsxs29("div", { className: "border border-neutral-200 dark:border-neutral-700 rounded-xl p-5 space-y-2", children: [
|
|
6127
|
+
/* @__PURE__ */ jsx36("div", { className: "h-4 bg-neutral-200 dark:bg-neutral-700 rounded w-2/3" }),
|
|
6128
|
+
/* @__PURE__ */ jsx36("div", { className: "h-8 bg-neutral-200 dark:bg-neutral-700 rounded w-1/2" })
|
|
5720
6129
|
] }, i)) }),
|
|
5721
|
-
/* @__PURE__ */
|
|
5722
|
-
/* @__PURE__ */
|
|
5723
|
-
/* @__PURE__ */
|
|
5724
|
-
/* @__PURE__ */
|
|
6130
|
+
/* @__PURE__ */ jsxs29("div", { className: "grid grid-cols-3 gap-4", children: [
|
|
6131
|
+
/* @__PURE__ */ jsxs29("div", { className: "col-span-2 border border-neutral-200 dark:border-neutral-700 rounded-xl p-5 space-y-3", children: [
|
|
6132
|
+
/* @__PURE__ */ jsx36("div", { className: "h-4 bg-neutral-200 dark:bg-neutral-700 rounded w-1/4" }),
|
|
6133
|
+
/* @__PURE__ */ jsx36("div", { className: "h-40 bg-neutral-200 dark:bg-neutral-700 rounded" })
|
|
5725
6134
|
] }),
|
|
5726
|
-
/* @__PURE__ */
|
|
5727
|
-
/* @__PURE__ */
|
|
5728
|
-
[1, 2, 3].map((i) => /* @__PURE__ */
|
|
6135
|
+
/* @__PURE__ */ jsxs29("div", { className: "border border-neutral-200 dark:border-neutral-700 rounded-xl p-5 space-y-3", children: [
|
|
6136
|
+
/* @__PURE__ */ jsx36("div", { className: "h-4 bg-neutral-200 dark:bg-neutral-700 rounded w-1/2" }),
|
|
6137
|
+
[1, 2, 3].map((i) => /* @__PURE__ */ jsx36("div", { className: "h-10 bg-neutral-200 dark:bg-neutral-700 rounded" }, i))
|
|
5729
6138
|
] })
|
|
5730
6139
|
] })
|
|
5731
6140
|
] });
|
|
5732
6141
|
}
|
|
5733
6142
|
|
|
5734
6143
|
// src/components/AutoInterface/AutoInterface.tsx
|
|
5735
|
-
import { jsx as
|
|
6144
|
+
import { jsx as jsx37, jsxs as jsxs30 } from "react/jsx-runtime";
|
|
5736
6145
|
async function generateInitialInterface(apiUrl, apiKey, agentId, prompt) {
|
|
5737
6146
|
const systemContext = generateCompactInterfaceContext();
|
|
5738
6147
|
const message = `${systemContext}
|
|
@@ -5782,19 +6191,19 @@ function AutoInterface({
|
|
|
5782
6191
|
theme,
|
|
5783
6192
|
className
|
|
5784
6193
|
}) {
|
|
5785
|
-
const [interfaceSpec, setInterfaceSpec] =
|
|
5786
|
-
const [isGenerating, setIsGenerating] =
|
|
5787
|
-
const [chatCollapsed, setChatCollapsed] =
|
|
5788
|
-
const chatRef =
|
|
6194
|
+
const [interfaceSpec, setInterfaceSpec] = useState16(initialInterface || null);
|
|
6195
|
+
const [isGenerating, setIsGenerating] = useState16(false);
|
|
6196
|
+
const [chatCollapsed, setChatCollapsed] = useState16(false);
|
|
6197
|
+
const chatRef = useRef10(null);
|
|
5789
6198
|
const systemContext = [
|
|
5790
6199
|
generateInterfaceContext(),
|
|
5791
6200
|
context || ""
|
|
5792
6201
|
].filter(Boolean).join("\n\n");
|
|
5793
|
-
const updateInterface =
|
|
6202
|
+
const updateInterface = useCallback3((newSpec) => {
|
|
5794
6203
|
setInterfaceSpec(newSpec);
|
|
5795
6204
|
onInterfaceChange?.(newSpec);
|
|
5796
6205
|
}, [onInterfaceChange]);
|
|
5797
|
-
const handleAction =
|
|
6206
|
+
const handleAction = useCallback3((action) => {
|
|
5798
6207
|
onAction?.(action);
|
|
5799
6208
|
if (chatRef.current) {
|
|
5800
6209
|
chatRef.current.sendMessage(
|
|
@@ -5802,7 +6211,7 @@ function AutoInterface({
|
|
|
5802
6211
|
);
|
|
5803
6212
|
}
|
|
5804
6213
|
}, [onAction]);
|
|
5805
|
-
const handleMessageComplete =
|
|
6214
|
+
const handleMessageComplete = useCallback3((result) => {
|
|
5806
6215
|
if (!result?.data) return;
|
|
5807
6216
|
const text = typeof result.data === "string" ? result.data : result.data.message || "";
|
|
5808
6217
|
console.log("[AutoInterface] Chat message complete, text (" + text.length + " chars):", text.substring(0, 300));
|
|
@@ -5823,7 +6232,7 @@ function AutoInterface({
|
|
|
5823
6232
|
}
|
|
5824
6233
|
setIsGenerating(false);
|
|
5825
6234
|
}, [interfaceSpec, updateInterface]);
|
|
5826
|
-
|
|
6235
|
+
useEffect10(() => {
|
|
5827
6236
|
if (!initialPrompt || initialInterface || useMock) return;
|
|
5828
6237
|
if (!apiUrl) return;
|
|
5829
6238
|
let cancelled = false;
|
|
@@ -5852,17 +6261,17 @@ function AutoInterface({
|
|
|
5852
6261
|
}, [initialPrompt]);
|
|
5853
6262
|
const hasInterface = interfaceSpec !== null;
|
|
5854
6263
|
const showSkeleton = isGenerating && !hasInterface;
|
|
5855
|
-
return /* @__PURE__ */
|
|
6264
|
+
return /* @__PURE__ */ jsxs30("div", { className: cn(
|
|
5856
6265
|
"flex h-full bg-neutral-50 dark:bg-black",
|
|
5857
6266
|
chatPosition === "bottom" ? "flex-col" : "flex-row",
|
|
5858
6267
|
className
|
|
5859
6268
|
), children: [
|
|
5860
|
-
/* @__PURE__ */
|
|
6269
|
+
/* @__PURE__ */ jsxs30("div", { className: cn(
|
|
5861
6270
|
"flex-1 overflow-y-auto min-w-0",
|
|
5862
6271
|
hasInterface || showSkeleton ? "" : "hidden"
|
|
5863
6272
|
), children: [
|
|
5864
|
-
showSkeleton && /* @__PURE__ */
|
|
5865
|
-
hasInterface && interfaceSpec && /* @__PURE__ */
|
|
6273
|
+
showSkeleton && /* @__PURE__ */ jsx37(InterfaceSkeleton, {}),
|
|
6274
|
+
hasInterface && interfaceSpec && /* @__PURE__ */ jsx37("div", { className: "p-4", children: /* @__PURE__ */ jsx37(
|
|
5866
6275
|
InterfaceRenderer,
|
|
5867
6276
|
{
|
|
5868
6277
|
node: interfaceSpec.root,
|
|
@@ -5870,16 +6279,16 @@ function AutoInterface({
|
|
|
5870
6279
|
}
|
|
5871
6280
|
) })
|
|
5872
6281
|
] }),
|
|
5873
|
-
chatCollapsible && hasInterface && chatPosition === "right" && /* @__PURE__ */
|
|
6282
|
+
chatCollapsible && hasInterface && chatPosition === "right" && /* @__PURE__ */ jsx37(
|
|
5874
6283
|
"button",
|
|
5875
6284
|
{
|
|
5876
6285
|
onClick: () => setChatCollapsed(!chatCollapsed),
|
|
5877
6286
|
className: "flex-shrink-0 w-6 flex items-center justify-center border-l border-neutral-200 dark:border-neutral-700 bg-neutral-100 dark:bg-neutral-800 hover:bg-neutral-200 dark:hover:bg-neutral-700 transition-colors",
|
|
5878
6287
|
title: chatCollapsed ? "Show chat" : "Hide chat",
|
|
5879
|
-
children: /* @__PURE__ */
|
|
6288
|
+
children: /* @__PURE__ */ jsx37("span", { className: "!text-xs !text-neutral-500 dark:!text-neutral-400", children: chatCollapsed ? "\u25C0" : "\u25B6" })
|
|
5880
6289
|
}
|
|
5881
6290
|
),
|
|
5882
|
-
/* @__PURE__ */
|
|
6291
|
+
/* @__PURE__ */ jsx37(
|
|
5883
6292
|
"div",
|
|
5884
6293
|
{
|
|
5885
6294
|
className: cn(
|
|
@@ -5890,7 +6299,7 @@ function AutoInterface({
|
|
|
5890
6299
|
!hasInterface && !showSkeleton && "flex-1"
|
|
5891
6300
|
),
|
|
5892
6301
|
style: hasInterface || showSkeleton ? chatPosition === "right" ? { width: chatWidth } : { height: "300px" } : void 0,
|
|
5893
|
-
children: /* @__PURE__ */
|
|
6302
|
+
children: /* @__PURE__ */ jsx37(
|
|
5894
6303
|
Chat,
|
|
5895
6304
|
{
|
|
5896
6305
|
ref: chatRef,
|
|
@@ -5948,29 +6357,29 @@ function getThemeScript() {
|
|
|
5948
6357
|
}
|
|
5949
6358
|
|
|
5950
6359
|
// src/hooks/useInterfaceState.ts
|
|
5951
|
-
import { useState as
|
|
6360
|
+
import { useState as useState17, useCallback as useCallback4 } from "react";
|
|
5952
6361
|
function useInterfaceState(initialSpec) {
|
|
5953
|
-
const [spec, setSpec] =
|
|
5954
|
-
const [isStreaming, setIsStreaming] =
|
|
5955
|
-
const setInterface =
|
|
6362
|
+
const [spec, setSpec] = useState17(initialSpec || null);
|
|
6363
|
+
const [isStreaming, setIsStreaming] = useState17(false);
|
|
6364
|
+
const setInterface = useCallback4((newSpec) => {
|
|
5956
6365
|
setSpec(newSpec);
|
|
5957
6366
|
}, []);
|
|
5958
|
-
const clearInterface =
|
|
6367
|
+
const clearInterface = useCallback4(() => {
|
|
5959
6368
|
setSpec(null);
|
|
5960
6369
|
}, []);
|
|
5961
|
-
const applyInterfaceUpdate =
|
|
6370
|
+
const applyInterfaceUpdate = useCallback4((update) => {
|
|
5962
6371
|
setSpec((prev) => {
|
|
5963
6372
|
if (!prev) return prev;
|
|
5964
6373
|
return applyUpdate(prev, update);
|
|
5965
6374
|
});
|
|
5966
6375
|
}, []);
|
|
5967
|
-
const applyInterfaceUpdates =
|
|
6376
|
+
const applyInterfaceUpdates = useCallback4((updates) => {
|
|
5968
6377
|
setSpec((prev) => {
|
|
5969
6378
|
if (!prev) return prev;
|
|
5970
6379
|
return applyUpdates(prev, updates);
|
|
5971
6380
|
});
|
|
5972
6381
|
}, []);
|
|
5973
|
-
const getNode =
|
|
6382
|
+
const getNode = useCallback4((id) => {
|
|
5974
6383
|
if (!spec) return null;
|
|
5975
6384
|
return findNode(spec.root, id);
|
|
5976
6385
|
}, [spec]);
|
|
@@ -5987,7 +6396,7 @@ function useInterfaceState(initialSpec) {
|
|
|
5987
6396
|
}
|
|
5988
6397
|
|
|
5989
6398
|
// src/hooks/useInterfaceAI.ts
|
|
5990
|
-
import { useCallback as
|
|
6399
|
+
import { useCallback as useCallback5, useRef as useRef11 } from "react";
|
|
5991
6400
|
function useInterfaceAI({
|
|
5992
6401
|
agentId,
|
|
5993
6402
|
apiUrl,
|
|
@@ -5999,15 +6408,15 @@ function useInterfaceAI({
|
|
|
5999
6408
|
onStreamStart,
|
|
6000
6409
|
onStreamEnd
|
|
6001
6410
|
}) {
|
|
6002
|
-
const threadIdRef =
|
|
6003
|
-
const accumulatedTextRef =
|
|
6411
|
+
const threadIdRef = useRef11(null);
|
|
6412
|
+
const accumulatedTextRef = useRef11("");
|
|
6004
6413
|
if (apiUrl || apiKey) {
|
|
6005
6414
|
aptevaClient.configure({
|
|
6006
6415
|
...apiUrl && { apiUrl },
|
|
6007
6416
|
...apiKey && { apiKey }
|
|
6008
6417
|
});
|
|
6009
6418
|
}
|
|
6010
|
-
const sendMessage =
|
|
6419
|
+
const sendMessage = useCallback5(async (message) => {
|
|
6011
6420
|
accumulatedTextRef.current = "";
|
|
6012
6421
|
onStreamStart?.();
|
|
6013
6422
|
const systemPrompt = [
|
|
@@ -6072,6 +6481,8 @@ export {
|
|
|
6072
6481
|
Kpi,
|
|
6073
6482
|
LayoutRenderer,
|
|
6074
6483
|
List,
|
|
6484
|
+
LiveView,
|
|
6485
|
+
PersistentWidgetPanel,
|
|
6075
6486
|
Prompt,
|
|
6076
6487
|
Spacer,
|
|
6077
6488
|
Stream,
|