@apteva/apteva-kit 0.1.105 → 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 +528 -124
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1029 -625
- 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")) {
|
|
@@ -4062,19 +4461,20 @@ ${planToExecute}`;
|
|
|
4062
4461
|
setCurrentRequestId(null);
|
|
4063
4462
|
};
|
|
4064
4463
|
const isCompact = commandVariant === "compact";
|
|
4065
|
-
return /* @__PURE__ */
|
|
4066
|
-
showHeader && mode === "chat" && /* @__PURE__ */
|
|
4067
|
-
onHeaderBack && /* @__PURE__ */
|
|
4068
|
-
/* @__PURE__ */
|
|
4069
|
-
/* @__PURE__ */
|
|
4070
|
-
/* @__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(
|
|
4071
4470
|
"apteva-chat-status",
|
|
4072
4471
|
isLoading ? chatToolName ? "apteva-chat-status-tool" : "apteva-chat-status-thinking" : "apteva-chat-status-ready"
|
|
4073
4472
|
), children: isLoading ? chatToolName ? `Using ${chatToolName}...` : "Thinking..." : "Ready" })
|
|
4074
4473
|
] })
|
|
4075
4474
|
] }) }),
|
|
4076
|
-
mode === "chat" && /* @__PURE__ */
|
|
4077
|
-
/* @__PURE__ */
|
|
4475
|
+
mode === "chat" && /* @__PURE__ */ jsxs20(Fragment6, { children: [
|
|
4476
|
+
persistentWidgetList.length > 0 && /* @__PURE__ */ jsx26(PersistentWidgetPanel, { widgets: persistentWidgetList, onAction }),
|
|
4477
|
+
/* @__PURE__ */ jsx26(
|
|
4078
4478
|
MessageList,
|
|
4079
4479
|
{
|
|
4080
4480
|
messages,
|
|
@@ -4087,10 +4487,12 @@ ${planToExecute}`;
|
|
|
4087
4487
|
chatVariant: variant,
|
|
4088
4488
|
onPromptClick: (prompt) => handleSendMessage(prompt),
|
|
4089
4489
|
enableWidgets,
|
|
4090
|
-
onWidgetRender
|
|
4490
|
+
onWidgetRender,
|
|
4491
|
+
persistentWidgetIds,
|
|
4492
|
+
toolCallStyle
|
|
4091
4493
|
}
|
|
4092
4494
|
),
|
|
4093
|
-
/* @__PURE__ */
|
|
4495
|
+
/* @__PURE__ */ jsx26(
|
|
4094
4496
|
Composer,
|
|
4095
4497
|
{
|
|
4096
4498
|
onSendMessage: handleSendMessage,
|
|
@@ -4103,7 +4505,7 @@ ${planToExecute}`;
|
|
|
4103
4505
|
}
|
|
4104
4506
|
)
|
|
4105
4507
|
] }),
|
|
4106
|
-
mode === "command" && /* @__PURE__ */
|
|
4508
|
+
mode === "command" && /* @__PURE__ */ jsx26("div", { className: "w-full", children: /* @__PURE__ */ jsx26(
|
|
4107
4509
|
CommandComposer,
|
|
4108
4510
|
{
|
|
4109
4511
|
onExecute: (text, files) => {
|
|
@@ -4124,7 +4526,7 @@ ${planToExecute}`;
|
|
|
4124
4526
|
placeholder: placeholder || "Enter your command..."
|
|
4125
4527
|
}
|
|
4126
4528
|
) }),
|
|
4127
|
-
/* @__PURE__ */
|
|
4529
|
+
/* @__PURE__ */ jsx26("style", { dangerouslySetInnerHTML: {
|
|
4128
4530
|
__html: `
|
|
4129
4531
|
@keyframes pulse-border {
|
|
4130
4532
|
0%, 100% { border-color: rgb(59, 130, 246); }
|
|
@@ -4142,12 +4544,12 @@ ${planToExecute}`;
|
|
|
4142
4544
|
});
|
|
4143
4545
|
|
|
4144
4546
|
// src/components/Chat/CommandOutput.tsx
|
|
4145
|
-
import { useState as
|
|
4146
|
-
import { jsx as
|
|
4547
|
+
import { useState as useState10 } from "react";
|
|
4548
|
+
import { jsx as jsx27, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
4147
4549
|
|
|
4148
4550
|
// src/components/Command/Command.tsx
|
|
4149
|
-
import React, { useState as
|
|
4150
|
-
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";
|
|
4151
4553
|
function Command({
|
|
4152
4554
|
agentId,
|
|
4153
4555
|
command: initialCommand,
|
|
@@ -4174,28 +4576,28 @@ function Command({
|
|
|
4174
4576
|
resultRenderer,
|
|
4175
4577
|
className
|
|
4176
4578
|
}) {
|
|
4177
|
-
const [state, setState] =
|
|
4178
|
-
const [result, setResult] =
|
|
4179
|
-
const [error, setError] =
|
|
4180
|
-
const [progress, setProgress] =
|
|
4181
|
-
const [command, setCommand] =
|
|
4182
|
-
const [streamedContent, setStreamedContent] =
|
|
4183
|
-
const [plan, setPlan] =
|
|
4184
|
-
const [pendingCommand, setPendingCommand] =
|
|
4185
|
-
const [showPlanDetails, setShowPlanDetails] =
|
|
4186
|
-
const [uploadedFiles, setUploadedFiles] =
|
|
4187
|
-
const [showSettingsMenu, setShowSettingsMenu] =
|
|
4188
|
-
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);
|
|
4189
4591
|
const fileInputRef = React.useRef(null);
|
|
4190
|
-
|
|
4592
|
+
useEffect8(() => {
|
|
4191
4593
|
if (autoExecute && state === "idle" && command) {
|
|
4192
4594
|
executeCommand();
|
|
4193
4595
|
}
|
|
4194
4596
|
}, [autoExecute]);
|
|
4195
|
-
|
|
4597
|
+
useEffect8(() => {
|
|
4196
4598
|
setInternalPlanMode(planMode);
|
|
4197
4599
|
}, [planMode]);
|
|
4198
|
-
|
|
4600
|
+
useEffect8(() => {
|
|
4199
4601
|
const handleClickOutside = (event) => {
|
|
4200
4602
|
const target = event.target;
|
|
4201
4603
|
if (showSettingsMenu && !target.closest(".settings-menu-container")) {
|
|
@@ -4597,7 +4999,7 @@ ${planToExecute}`;
|
|
|
4597
4999
|
setUploadedFiles((prev) => prev.filter((_, i) => i !== index));
|
|
4598
5000
|
};
|
|
4599
5001
|
const isCompact = variant === "compact";
|
|
4600
|
-
return /* @__PURE__ */
|
|
5002
|
+
return /* @__PURE__ */ jsxs22(
|
|
4601
5003
|
"div",
|
|
4602
5004
|
{
|
|
4603
5005
|
className: cn(
|
|
@@ -4612,9 +5014,9 @@ ${planToExecute}`;
|
|
|
4612
5014
|
),
|
|
4613
5015
|
style: { minHeight: isCompact ? "auto" : "180px" },
|
|
4614
5016
|
children: [
|
|
4615
|
-
/* @__PURE__ */
|
|
4616
|
-
state === "idle" && allowInput && !isCompact && /* @__PURE__ */
|
|
4617
|
-
/* @__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(
|
|
4618
5020
|
"textarea",
|
|
4619
5021
|
{
|
|
4620
5022
|
value: command,
|
|
@@ -4630,42 +5032,42 @@ ${planToExecute}`;
|
|
|
4630
5032
|
rows: 6
|
|
4631
5033
|
}
|
|
4632
5034
|
),
|
|
4633
|
-
uploadedFiles.length > 0 && /* @__PURE__ */
|
|
4634
|
-
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(
|
|
4635
5037
|
"img",
|
|
4636
5038
|
{
|
|
4637
5039
|
src: file.preview,
|
|
4638
5040
|
alt: file.name,
|
|
4639
5041
|
className: "w-20 h-20 object-cover rounded-lg border-2 border-neutral-300 dark:border-neutral-600"
|
|
4640
5042
|
}
|
|
4641
|
-
) : /* @__PURE__ */
|
|
4642
|
-
/* @__PURE__ */
|
|
4643
|
-
/* @__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 })
|
|
4644
5046
|
] }),
|
|
4645
|
-
/* @__PURE__ */
|
|
5047
|
+
/* @__PURE__ */ jsx28(
|
|
4646
5048
|
"button",
|
|
4647
5049
|
{
|
|
4648
5050
|
onClick: () => removeFile(index),
|
|
4649
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",
|
|
4650
5052
|
title: `Remove ${file.type}`,
|
|
4651
|
-
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" }) })
|
|
4652
5054
|
}
|
|
4653
5055
|
)
|
|
4654
5056
|
] }, index)) })
|
|
4655
5057
|
] }),
|
|
4656
|
-
state === "idle" && allowInput && isCompact && /* @__PURE__ */
|
|
4657
|
-
/* @__PURE__ */
|
|
4658
|
-
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(
|
|
4659
5061
|
"button",
|
|
4660
5062
|
{
|
|
4661
5063
|
onClick: () => fileInputRef.current?.click(),
|
|
4662
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",
|
|
4663
5065
|
title: "Attach file",
|
|
4664
|
-
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)" }) })
|
|
4665
5067
|
}
|
|
4666
5068
|
),
|
|
4667
|
-
planMode && /* @__PURE__ */
|
|
4668
|
-
/* @__PURE__ */
|
|
5069
|
+
planMode && /* @__PURE__ */ jsxs22("div", { className: "relative settings-menu-container", children: [
|
|
5070
|
+
/* @__PURE__ */ jsx28(
|
|
4669
5071
|
"button",
|
|
4670
5072
|
{
|
|
4671
5073
|
onClick: () => setShowSettingsMenu(!showSettingsMenu),
|
|
@@ -4674,28 +5076,28 @@ ${planToExecute}`;
|
|
|
4674
5076
|
internalPlanMode ? "!text-blue-600 dark:!text-blue-400" : "!text-neutral-500 dark:!text-neutral-500"
|
|
4675
5077
|
),
|
|
4676
5078
|
title: "Settings",
|
|
4677
|
-
children: /* @__PURE__ */
|
|
4678
|
-
/* @__PURE__ */
|
|
4679
|
-
/* @__PURE__ */
|
|
4680
|
-
/* @__PURE__ */
|
|
4681
|
-
/* @__PURE__ */
|
|
4682
|
-
/* @__PURE__ */
|
|
4683
|
-
/* @__PURE__ */
|
|
4684
|
-
/* @__PURE__ */
|
|
4685
|
-
/* @__PURE__ */
|
|
4686
|
-
/* @__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" })
|
|
4687
5089
|
] })
|
|
4688
5090
|
}
|
|
4689
5091
|
),
|
|
4690
|
-
showSettingsMenu && /* @__PURE__ */
|
|
4691
|
-
/* @__PURE__ */
|
|
4692
|
-
/* @__PURE__ */
|
|
4693
|
-
/* @__PURE__ */
|
|
4694
|
-
/* @__PURE__ */
|
|
4695
|
-
/* @__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" })
|
|
4696
5098
|
] })
|
|
4697
5099
|
] }),
|
|
4698
|
-
/* @__PURE__ */
|
|
5100
|
+
/* @__PURE__ */ jsx28(
|
|
4699
5101
|
"button",
|
|
4700
5102
|
{
|
|
4701
5103
|
onClick: (e) => {
|
|
@@ -4707,7 +5109,7 @@ ${planToExecute}`;
|
|
|
4707
5109
|
internalPlanMode ? "bg-blue-600" : "bg-neutral-300 dark:bg-neutral-600"
|
|
4708
5110
|
),
|
|
4709
5111
|
type: "button",
|
|
4710
|
-
children: /* @__PURE__ */
|
|
5112
|
+
children: /* @__PURE__ */ jsx28(
|
|
4711
5113
|
"span",
|
|
4712
5114
|
{
|
|
4713
5115
|
className: cn(
|
|
@@ -4721,26 +5123,26 @@ ${planToExecute}`;
|
|
|
4721
5123
|
] }) })
|
|
4722
5124
|
] })
|
|
4723
5125
|
] }),
|
|
4724
|
-
uploadedFiles.length > 0 && /* @__PURE__ */
|
|
4725
|
-
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(
|
|
4726
5128
|
"img",
|
|
4727
5129
|
{
|
|
4728
5130
|
src: file.preview,
|
|
4729
5131
|
alt: file.name,
|
|
4730
5132
|
className: "w-8 h-8 object-cover rounded border border-neutral-300 dark:border-neutral-600"
|
|
4731
5133
|
}
|
|
4732
|
-
) : /* @__PURE__ */
|
|
4733
|
-
/* @__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(
|
|
4734
5136
|
"button",
|
|
4735
5137
|
{
|
|
4736
5138
|
onClick: () => removeFile(index),
|
|
4737
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",
|
|
4738
5140
|
title: "Remove",
|
|
4739
|
-
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" }) })
|
|
4740
5142
|
}
|
|
4741
5143
|
)
|
|
4742
5144
|
] }, index)) }),
|
|
4743
|
-
/* @__PURE__ */
|
|
5145
|
+
/* @__PURE__ */ jsx28(
|
|
4744
5146
|
"input",
|
|
4745
5147
|
{
|
|
4746
5148
|
type: "text",
|
|
@@ -4756,7 +5158,7 @@ ${planToExecute}`;
|
|
|
4756
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"
|
|
4757
5159
|
}
|
|
4758
5160
|
),
|
|
4759
|
-
/* @__PURE__ */
|
|
5161
|
+
/* @__PURE__ */ jsx28(
|
|
4760
5162
|
"button",
|
|
4761
5163
|
{
|
|
4762
5164
|
onClick: () => executeCommand(),
|
|
@@ -4772,33 +5174,33 @@ ${planToExecute}`;
|
|
|
4772
5174
|
!command.trim() && "border-neutral-200 dark:border-neutral-700 !text-neutral-400 dark:!text-neutral-600"
|
|
4773
5175
|
),
|
|
4774
5176
|
title: "Execute",
|
|
4775
|
-
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" }) })
|
|
4776
5178
|
}
|
|
4777
5179
|
)
|
|
4778
5180
|
] }),
|
|
4779
|
-
state === "loading" && !isCompact && /* @__PURE__ */
|
|
4780
|
-
/* @__PURE__ */
|
|
4781
|
-
/* @__PURE__ */
|
|
4782
|
-
showProgress && /* @__PURE__ */
|
|
4783
|
-
/* @__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(
|
|
4784
5186
|
"div",
|
|
4785
5187
|
{
|
|
4786
5188
|
className: "bg-blue-500 h-1.5 rounded-full transition-all duration-300",
|
|
4787
5189
|
style: { width: `${progress}%` }
|
|
4788
5190
|
}
|
|
4789
5191
|
) }),
|
|
4790
|
-
/* @__PURE__ */
|
|
5192
|
+
/* @__PURE__ */ jsxs22("p", { className: "text-xs text-neutral-500 mt-2 text-center", children: [
|
|
4791
5193
|
progress,
|
|
4792
5194
|
"%"
|
|
4793
5195
|
] })
|
|
4794
5196
|
] })
|
|
4795
5197
|
] }),
|
|
4796
|
-
state === "loading" && isCompact && /* @__PURE__ */
|
|
4797
|
-
/* @__PURE__ */
|
|
4798
|
-
/* @__PURE__ */
|
|
4799
|
-
/* @__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 })
|
|
4800
5202
|
] }),
|
|
4801
|
-
/* @__PURE__ */
|
|
5203
|
+
/* @__PURE__ */ jsx28(
|
|
4802
5204
|
"button",
|
|
4803
5205
|
{
|
|
4804
5206
|
disabled: true,
|
|
@@ -4810,20 +5212,20 @@ ${planToExecute}`;
|
|
|
4810
5212
|
"!text-lg",
|
|
4811
5213
|
"opacity-30 cursor-not-allowed"
|
|
4812
5214
|
),
|
|
4813
|
-
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" }) })
|
|
4814
5216
|
}
|
|
4815
5217
|
)
|
|
4816
5218
|
] }),
|
|
4817
|
-
state === "plan-pending" && !isCompact && /* @__PURE__ */
|
|
4818
|
-
/* @__PURE__ */
|
|
4819
|
-
/* @__PURE__ */
|
|
4820
|
-
/* @__PURE__ */
|
|
4821
|
-
/* @__PURE__ */
|
|
4822
|
-
/* @__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 })
|
|
4823
5225
|
] })
|
|
4824
5226
|
] }),
|
|
4825
|
-
/* @__PURE__ */
|
|
4826
|
-
/* @__PURE__ */
|
|
5227
|
+
/* @__PURE__ */ jsxs22("div", { className: "flex gap-2 mt-4", children: [
|
|
5228
|
+
/* @__PURE__ */ jsx28(
|
|
4827
5229
|
"button",
|
|
4828
5230
|
{
|
|
4829
5231
|
onClick: approvePlan,
|
|
@@ -4831,7 +5233,7 @@ ${planToExecute}`;
|
|
|
4831
5233
|
children: "Approve & Execute"
|
|
4832
5234
|
}
|
|
4833
5235
|
),
|
|
4834
|
-
/* @__PURE__ */
|
|
5236
|
+
/* @__PURE__ */ jsx28(
|
|
4835
5237
|
"button",
|
|
4836
5238
|
{
|
|
4837
5239
|
onClick: rejectPlan,
|
|
@@ -4841,20 +5243,20 @@ ${planToExecute}`;
|
|
|
4841
5243
|
)
|
|
4842
5244
|
] })
|
|
4843
5245
|
] }) }),
|
|
4844
|
-
state === "plan-pending" && isCompact && /* @__PURE__ */
|
|
4845
|
-
/* @__PURE__ */
|
|
5246
|
+
state === "plan-pending" && isCompact && /* @__PURE__ */ jsxs22(Fragment7, { children: [
|
|
5247
|
+
/* @__PURE__ */ jsxs22(
|
|
4846
5248
|
"button",
|
|
4847
5249
|
{
|
|
4848
5250
|
onClick: () => setShowPlanDetails(true),
|
|
4849
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",
|
|
4850
5252
|
children: [
|
|
4851
|
-
/* @__PURE__ */
|
|
4852
|
-
/* @__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" })
|
|
4853
5255
|
]
|
|
4854
5256
|
}
|
|
4855
5257
|
),
|
|
4856
|
-
/* @__PURE__ */
|
|
4857
|
-
/* @__PURE__ */
|
|
5258
|
+
/* @__PURE__ */ jsxs22("div", { className: "flex gap-2 flex-shrink-0", children: [
|
|
5259
|
+
/* @__PURE__ */ jsx28(
|
|
4858
5260
|
"button",
|
|
4859
5261
|
{
|
|
4860
5262
|
onClick: approvePlan,
|
|
@@ -4862,7 +5264,7 @@ ${planToExecute}`;
|
|
|
4862
5264
|
children: "Approve"
|
|
4863
5265
|
}
|
|
4864
5266
|
),
|
|
4865
|
-
/* @__PURE__ */
|
|
5267
|
+
/* @__PURE__ */ jsx28(
|
|
4866
5268
|
"button",
|
|
4867
5269
|
{
|
|
4868
5270
|
onClick: rejectPlan,
|
|
@@ -4872,15 +5274,15 @@ ${planToExecute}`;
|
|
|
4872
5274
|
)
|
|
4873
5275
|
] })
|
|
4874
5276
|
] }),
|
|
4875
|
-
state === "error" && /* @__PURE__ */
|
|
4876
|
-
/* @__PURE__ */
|
|
4877
|
-
/* @__PURE__ */
|
|
4878
|
-
/* @__PURE__ */
|
|
4879
|
-
/* @__PURE__ */
|
|
4880
|
-
/* @__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 })
|
|
4881
5283
|
] })
|
|
4882
5284
|
] }) }),
|
|
4883
|
-
allowInput && /* @__PURE__ */
|
|
5285
|
+
allowInput && /* @__PURE__ */ jsx28(
|
|
4884
5286
|
"textarea",
|
|
4885
5287
|
{
|
|
4886
5288
|
value: command,
|
|
@@ -4897,16 +5299,16 @@ ${planToExecute}`;
|
|
|
4897
5299
|
}
|
|
4898
5300
|
)
|
|
4899
5301
|
] }),
|
|
4900
|
-
state === "success" && result && !isCompact && /* @__PURE__ */
|
|
4901
|
-
/* @__PURE__ */
|
|
4902
|
-
/* @__PURE__ */
|
|
4903
|
-
/* @__PURE__ */
|
|
4904
|
-
/* @__PURE__ */
|
|
4905
|
-
/* @__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" })
|
|
4906
5308
|
] })
|
|
4907
5309
|
] }),
|
|
4908
|
-
result.data?.summary && /* @__PURE__ */
|
|
4909
|
-
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(
|
|
4910
5312
|
WidgetRenderer,
|
|
4911
5313
|
{
|
|
4912
5314
|
widget,
|
|
@@ -4915,8 +5317,8 @@ ${planToExecute}`;
|
|
|
4915
5317
|
widget.id
|
|
4916
5318
|
)) })
|
|
4917
5319
|
] }) }),
|
|
4918
|
-
state === "success" && result && isCompact && /* @__PURE__ */
|
|
4919
|
-
/* @__PURE__ */
|
|
5320
|
+
state === "success" && result && isCompact && /* @__PURE__ */ jsxs22(Fragment7, { children: [
|
|
5321
|
+
/* @__PURE__ */ jsxs22(
|
|
4920
5322
|
"div",
|
|
4921
5323
|
{
|
|
4922
5324
|
className: "flex-1 flex items-center gap-2 py-1 cursor-text min-w-0",
|
|
@@ -4925,12 +5327,12 @@ ${planToExecute}`;
|
|
|
4925
5327
|
setResult(null);
|
|
4926
5328
|
},
|
|
4927
5329
|
children: [
|
|
4928
|
-
/* @__PURE__ */
|
|
4929
|
-
/* @__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" })
|
|
4930
5332
|
]
|
|
4931
5333
|
}
|
|
4932
5334
|
),
|
|
4933
|
-
/* @__PURE__ */
|
|
5335
|
+
/* @__PURE__ */ jsx28(
|
|
4934
5336
|
"button",
|
|
4935
5337
|
{
|
|
4936
5338
|
onClick: () => {
|
|
@@ -4946,24 +5348,24 @@ ${planToExecute}`;
|
|
|
4946
5348
|
"!text-lg"
|
|
4947
5349
|
),
|
|
4948
5350
|
title: "New command",
|
|
4949
|
-
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" }) })
|
|
4950
5352
|
}
|
|
4951
5353
|
)
|
|
4952
5354
|
] })
|
|
4953
5355
|
] }),
|
|
4954
|
-
!isCompact && /* @__PURE__ */
|
|
4955
|
-
/* @__PURE__ */
|
|
4956
|
-
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(
|
|
4957
5359
|
"button",
|
|
4958
5360
|
{
|
|
4959
5361
|
onClick: () => fileInputRef.current?.click(),
|
|
4960
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",
|
|
4961
5363
|
title: "Attach file",
|
|
4962
|
-
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)" }) })
|
|
4963
5365
|
}
|
|
4964
5366
|
),
|
|
4965
|
-
planMode && /* @__PURE__ */
|
|
4966
|
-
/* @__PURE__ */
|
|
5367
|
+
planMode && /* @__PURE__ */ jsxs22("div", { className: "relative settings-menu-container", children: [
|
|
5368
|
+
/* @__PURE__ */ jsx28(
|
|
4967
5369
|
"button",
|
|
4968
5370
|
{
|
|
4969
5371
|
onClick: () => setShowSettingsMenu(!showSettingsMenu),
|
|
@@ -4972,28 +5374,28 @@ ${planToExecute}`;
|
|
|
4972
5374
|
internalPlanMode ? "!text-blue-600 dark:!text-blue-400" : "!text-neutral-500 dark:!text-neutral-500"
|
|
4973
5375
|
),
|
|
4974
5376
|
title: "Settings",
|
|
4975
|
-
children: /* @__PURE__ */
|
|
4976
|
-
/* @__PURE__ */
|
|
4977
|
-
/* @__PURE__ */
|
|
4978
|
-
/* @__PURE__ */
|
|
4979
|
-
/* @__PURE__ */
|
|
4980
|
-
/* @__PURE__ */
|
|
4981
|
-
/* @__PURE__ */
|
|
4982
|
-
/* @__PURE__ */
|
|
4983
|
-
/* @__PURE__ */
|
|
4984
|
-
/* @__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" })
|
|
4985
5387
|
] })
|
|
4986
5388
|
}
|
|
4987
5389
|
),
|
|
4988
|
-
showSettingsMenu && /* @__PURE__ */
|
|
4989
|
-
/* @__PURE__ */
|
|
4990
|
-
/* @__PURE__ */
|
|
4991
|
-
/* @__PURE__ */
|
|
4992
|
-
/* @__PURE__ */
|
|
4993
|
-
/* @__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" })
|
|
4994
5396
|
] })
|
|
4995
5397
|
] }),
|
|
4996
|
-
/* @__PURE__ */
|
|
5398
|
+
/* @__PURE__ */ jsx28(
|
|
4997
5399
|
"button",
|
|
4998
5400
|
{
|
|
4999
5401
|
onClick: (e) => {
|
|
@@ -5005,7 +5407,7 @@ ${planToExecute}`;
|
|
|
5005
5407
|
internalPlanMode ? "bg-blue-600" : "bg-neutral-300 dark:bg-neutral-600"
|
|
5006
5408
|
),
|
|
5007
5409
|
type: "button",
|
|
5008
|
-
children: /* @__PURE__ */
|
|
5410
|
+
children: /* @__PURE__ */ jsx28(
|
|
5009
5411
|
"span",
|
|
5010
5412
|
{
|
|
5011
5413
|
className: cn(
|
|
@@ -5019,9 +5421,9 @@ ${planToExecute}`;
|
|
|
5019
5421
|
] }) })
|
|
5020
5422
|
] })
|
|
5021
5423
|
] }) }),
|
|
5022
|
-
!(state === "idle" && allowInput) && /* @__PURE__ */
|
|
5023
|
-
/* @__PURE__ */
|
|
5024
|
-
(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(
|
|
5025
5427
|
"button",
|
|
5026
5428
|
{
|
|
5027
5429
|
onClick: resetCommand,
|
|
@@ -5029,7 +5431,7 @@ ${planToExecute}`;
|
|
|
5029
5431
|
children: "Reset"
|
|
5030
5432
|
}
|
|
5031
5433
|
),
|
|
5032
|
-
(state === "idle" || state === "error") && /* @__PURE__ */
|
|
5434
|
+
(state === "idle" || state === "error") && /* @__PURE__ */ jsx28(
|
|
5033
5435
|
"button",
|
|
5034
5436
|
{
|
|
5035
5437
|
onClick: () => executeCommand(),
|
|
@@ -5045,29 +5447,29 @@ ${planToExecute}`;
|
|
|
5045
5447
|
!command.trim() && "border-neutral-200 dark:border-neutral-700 !text-neutral-400 dark:!text-neutral-600"
|
|
5046
5448
|
),
|
|
5047
5449
|
title: state === "error" ? "Retry" : "Execute",
|
|
5048
|
-
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" }) })
|
|
5049
5451
|
}
|
|
5050
5452
|
)
|
|
5051
5453
|
] })
|
|
5052
5454
|
] }),
|
|
5053
|
-
showPlanDetails && isCompact && state === "plan-pending" && /* @__PURE__ */
|
|
5054
|
-
/* @__PURE__ */
|
|
5055
|
-
/* @__PURE__ */
|
|
5056
|
-
/* @__PURE__ */
|
|
5057
|
-
/* @__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" })
|
|
5058
5460
|
] }),
|
|
5059
|
-
/* @__PURE__ */
|
|
5461
|
+
/* @__PURE__ */ jsx28(
|
|
5060
5462
|
"button",
|
|
5061
5463
|
{
|
|
5062
5464
|
onClick: () => setShowPlanDetails(false),
|
|
5063
5465
|
className: "text-neutral-400 hover:text-neutral-600 dark:hover:text-neutral-300 transition-colors",
|
|
5064
|
-
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" }) })
|
|
5065
5467
|
}
|
|
5066
5468
|
)
|
|
5067
5469
|
] }),
|
|
5068
|
-
/* @__PURE__ */
|
|
5069
|
-
/* @__PURE__ */
|
|
5070
|
-
/* @__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(
|
|
5071
5473
|
"button",
|
|
5072
5474
|
{
|
|
5073
5475
|
onClick: rejectPlan,
|
|
@@ -5075,7 +5477,7 @@ ${planToExecute}`;
|
|
|
5075
5477
|
children: "Modify Command"
|
|
5076
5478
|
}
|
|
5077
5479
|
),
|
|
5078
|
-
/* @__PURE__ */
|
|
5480
|
+
/* @__PURE__ */ jsx28(
|
|
5079
5481
|
"button",
|
|
5080
5482
|
{
|
|
5081
5483
|
onClick: approvePlan,
|
|
@@ -5085,7 +5487,7 @@ ${planToExecute}`;
|
|
|
5085
5487
|
)
|
|
5086
5488
|
] })
|
|
5087
5489
|
] }) }),
|
|
5088
|
-
/* @__PURE__ */
|
|
5490
|
+
/* @__PURE__ */ jsx28(
|
|
5089
5491
|
"input",
|
|
5090
5492
|
{
|
|
5091
5493
|
ref: fileInputRef,
|
|
@@ -5096,7 +5498,7 @@ ${planToExecute}`;
|
|
|
5096
5498
|
accept: "image/*,application/pdf,.doc,.docx,.txt"
|
|
5097
5499
|
}
|
|
5098
5500
|
),
|
|
5099
|
-
/* @__PURE__ */
|
|
5501
|
+
/* @__PURE__ */ jsx28("style", { dangerouslySetInnerHTML: {
|
|
5100
5502
|
__html: `
|
|
5101
5503
|
@keyframes pulse-border {
|
|
5102
5504
|
0%, 100% {
|
|
@@ -5117,8 +5519,8 @@ ${planToExecute}`;
|
|
|
5117
5519
|
}
|
|
5118
5520
|
|
|
5119
5521
|
// src/components/Prompt/Prompt.tsx
|
|
5120
|
-
import { useState as
|
|
5121
|
-
import { jsx as
|
|
5522
|
+
import { useState as useState12 } from "react";
|
|
5523
|
+
import { jsx as jsx29, jsxs as jsxs23 } from "react/jsx-runtime";
|
|
5122
5524
|
function Prompt({
|
|
5123
5525
|
agentId,
|
|
5124
5526
|
placeholder = "Enter your prompt...",
|
|
@@ -5135,9 +5537,9 @@ function Prompt({
|
|
|
5135
5537
|
showSuggestions = false,
|
|
5136
5538
|
className
|
|
5137
5539
|
}) {
|
|
5138
|
-
const [value, setValue] =
|
|
5139
|
-
const [isLoading, setIsLoading] =
|
|
5140
|
-
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"]);
|
|
5141
5543
|
const handleChange = (e) => {
|
|
5142
5544
|
const newValue = e.target.value;
|
|
5143
5545
|
if (!maxLength || newValue.length <= maxLength) {
|
|
@@ -5180,9 +5582,9 @@ function Prompt({
|
|
|
5180
5582
|
handleSubmit();
|
|
5181
5583
|
}
|
|
5182
5584
|
};
|
|
5183
|
-
return /* @__PURE__ */
|
|
5184
|
-
/* @__PURE__ */
|
|
5185
|
-
/* @__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(
|
|
5186
5588
|
"input",
|
|
5187
5589
|
{
|
|
5188
5590
|
type: "text",
|
|
@@ -5195,7 +5597,7 @@ function Prompt({
|
|
|
5195
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"
|
|
5196
5598
|
}
|
|
5197
5599
|
),
|
|
5198
|
-
submitOn === "button" && /* @__PURE__ */
|
|
5600
|
+
submitOn === "button" && /* @__PURE__ */ jsx29(
|
|
5199
5601
|
"button",
|
|
5200
5602
|
{
|
|
5201
5603
|
onClick: handleSubmit,
|
|
@@ -5205,13 +5607,13 @@ function Prompt({
|
|
|
5205
5607
|
}
|
|
5206
5608
|
)
|
|
5207
5609
|
] }),
|
|
5208
|
-
maxLength && /* @__PURE__ */
|
|
5610
|
+
maxLength && /* @__PURE__ */ jsxs23("p", { className: "text-xs text-neutral-500", children: [
|
|
5209
5611
|
value.length,
|
|
5210
5612
|
" / ",
|
|
5211
5613
|
maxLength,
|
|
5212
5614
|
" characters"
|
|
5213
5615
|
] }),
|
|
5214
|
-
showSuggestions && !value && /* @__PURE__ */
|
|
5616
|
+
showSuggestions && !value && /* @__PURE__ */ jsx29("div", { className: "flex flex-wrap gap-2", children: suggestions.map((suggestion, idx) => /* @__PURE__ */ jsx29(
|
|
5215
5617
|
"button",
|
|
5216
5618
|
{
|
|
5217
5619
|
onClick: () => setValue(suggestion),
|
|
@@ -5220,16 +5622,16 @@ function Prompt({
|
|
|
5220
5622
|
},
|
|
5221
5623
|
idx
|
|
5222
5624
|
)) }),
|
|
5223
|
-
isLoading && /* @__PURE__ */
|
|
5224
|
-
/* @__PURE__ */
|
|
5225
|
-
/* @__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..." })
|
|
5226
5628
|
] })
|
|
5227
5629
|
] });
|
|
5228
5630
|
}
|
|
5229
5631
|
|
|
5230
5632
|
// src/components/Stream/Stream.tsx
|
|
5231
|
-
import { useState as
|
|
5232
|
-
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";
|
|
5233
5635
|
function Stream({
|
|
5234
5636
|
agentId,
|
|
5235
5637
|
prompt,
|
|
@@ -5245,10 +5647,10 @@ function Stream({
|
|
|
5245
5647
|
typingSpeed = 30,
|
|
5246
5648
|
className
|
|
5247
5649
|
}) {
|
|
5248
|
-
const [text, setText] =
|
|
5249
|
-
const [isStreaming, setIsStreaming] =
|
|
5250
|
-
const [isComplete, setIsComplete] =
|
|
5251
|
-
|
|
5650
|
+
const [text, setText] = useState13("");
|
|
5651
|
+
const [isStreaming, setIsStreaming] = useState13(false);
|
|
5652
|
+
const [isComplete, setIsComplete] = useState13(false);
|
|
5653
|
+
useEffect9(() => {
|
|
5252
5654
|
if (autoStart && !isStreaming && !isComplete) {
|
|
5253
5655
|
startStreaming();
|
|
5254
5656
|
}
|
|
@@ -5309,7 +5711,7 @@ function Stream({
|
|
|
5309
5711
|
plain: "text-neutral-900 dark:text-neutral-100"
|
|
5310
5712
|
};
|
|
5311
5713
|
if (!isStreaming && !isComplete) {
|
|
5312
|
-
return /* @__PURE__ */
|
|
5714
|
+
return /* @__PURE__ */ jsx30("div", { className: cn("p-4", className), children: /* @__PURE__ */ jsx30(
|
|
5313
5715
|
"button",
|
|
5314
5716
|
{
|
|
5315
5717
|
onClick: startStreaming,
|
|
@@ -5318,19 +5720,19 @@ function Stream({
|
|
|
5318
5720
|
}
|
|
5319
5721
|
) });
|
|
5320
5722
|
}
|
|
5321
|
-
return /* @__PURE__ */
|
|
5723
|
+
return /* @__PURE__ */ jsxs24("div", { className: cn(variantClasses[variant], className), children: [
|
|
5322
5724
|
text,
|
|
5323
|
-
isStreaming && showCursor && /* @__PURE__ */
|
|
5725
|
+
isStreaming && showCursor && /* @__PURE__ */ jsx30("span", { className: "apteva-stream-cursor" })
|
|
5324
5726
|
] });
|
|
5325
5727
|
}
|
|
5326
5728
|
|
|
5327
5729
|
// src/components/Threads/ThreadList.tsx
|
|
5328
|
-
import { useState as
|
|
5730
|
+
import { useState as useState14 } from "react";
|
|
5329
5731
|
|
|
5330
5732
|
// src/components/Threads/ThreadItem.tsx
|
|
5331
|
-
import { jsx as
|
|
5733
|
+
import { jsx as jsx31, jsxs as jsxs25 } from "react/jsx-runtime";
|
|
5332
5734
|
function ThreadItem({ thread, isActive = false, onSelect, onDelete }) {
|
|
5333
|
-
return /* @__PURE__ */
|
|
5735
|
+
return /* @__PURE__ */ jsxs25(
|
|
5334
5736
|
"div",
|
|
5335
5737
|
{
|
|
5336
5738
|
className: cn("apteva-thread-item", {
|
|
@@ -5338,19 +5740,19 @@ function ThreadItem({ thread, isActive = false, onSelect, onDelete }) {
|
|
|
5338
5740
|
}),
|
|
5339
5741
|
onClick: onSelect,
|
|
5340
5742
|
children: [
|
|
5341
|
-
/* @__PURE__ */
|
|
5342
|
-
/* @__PURE__ */
|
|
5343
|
-
thread.preview && /* @__PURE__ */
|
|
5344
|
-
/* @__PURE__ */
|
|
5345
|
-
/* @__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: [
|
|
5346
5748
|
thread.messageCount,
|
|
5347
5749
|
" messages"
|
|
5348
5750
|
] }),
|
|
5349
|
-
/* @__PURE__ */
|
|
5350
|
-
/* @__PURE__ */
|
|
5751
|
+
/* @__PURE__ */ jsx31("span", { children: "\u2022" }),
|
|
5752
|
+
/* @__PURE__ */ jsx31("span", { children: formatRelativeTime(thread.updatedAt) })
|
|
5351
5753
|
] })
|
|
5352
5754
|
] }),
|
|
5353
|
-
onDelete && /* @__PURE__ */
|
|
5755
|
+
onDelete && /* @__PURE__ */ jsx31(
|
|
5354
5756
|
"button",
|
|
5355
5757
|
{
|
|
5356
5758
|
onClick: (e) => {
|
|
@@ -5380,7 +5782,7 @@ function formatRelativeTime(date) {
|
|
|
5380
5782
|
}
|
|
5381
5783
|
|
|
5382
5784
|
// src/components/Threads/ThreadList.tsx
|
|
5383
|
-
import { jsx as
|
|
5785
|
+
import { jsx as jsx32, jsxs as jsxs26 } from "react/jsx-runtime";
|
|
5384
5786
|
function ThreadList({
|
|
5385
5787
|
threads,
|
|
5386
5788
|
currentThreadId,
|
|
@@ -5389,13 +5791,13 @@ function ThreadList({
|
|
|
5389
5791
|
showSearch = false,
|
|
5390
5792
|
groupBy = "none"
|
|
5391
5793
|
}) {
|
|
5392
|
-
const [searchQuery, setSearchQuery] =
|
|
5794
|
+
const [searchQuery, setSearchQuery] = useState14("");
|
|
5393
5795
|
const filteredThreads = threads.filter(
|
|
5394
5796
|
(thread) => thread.title.toLowerCase().includes(searchQuery.toLowerCase()) || thread.preview?.toLowerCase().includes(searchQuery.toLowerCase())
|
|
5395
5797
|
);
|
|
5396
5798
|
const groupedThreads = groupBy === "date" ? groupThreadsByDate(filteredThreads) : { All: filteredThreads };
|
|
5397
|
-
return /* @__PURE__ */
|
|
5398
|
-
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(
|
|
5399
5801
|
"input",
|
|
5400
5802
|
{
|
|
5401
5803
|
type: "text",
|
|
@@ -5405,10 +5807,10 @@ function ThreadList({
|
|
|
5405
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"
|
|
5406
5808
|
}
|
|
5407
5809
|
) }),
|
|
5408
|
-
/* @__PURE__ */
|
|
5409
|
-
Object.entries(groupedThreads).map(([group, groupThreads]) => /* @__PURE__ */
|
|
5410
|
-
groupBy !== "none" && /* @__PURE__ */
|
|
5411
|
-
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(
|
|
5412
5814
|
ThreadItem,
|
|
5413
5815
|
{
|
|
5414
5816
|
thread,
|
|
@@ -5419,9 +5821,9 @@ function ThreadList({
|
|
|
5419
5821
|
thread.id
|
|
5420
5822
|
))
|
|
5421
5823
|
] }, group)),
|
|
5422
|
-
filteredThreads.length === 0 && /* @__PURE__ */
|
|
5423
|
-
/* @__PURE__ */
|
|
5424
|
-
/* @__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" })
|
|
5425
5827
|
] })
|
|
5426
5828
|
] })
|
|
5427
5829
|
] });
|
|
@@ -5453,7 +5855,7 @@ function groupThreadsByDate(threads) {
|
|
|
5453
5855
|
}
|
|
5454
5856
|
|
|
5455
5857
|
// src/components/Threads/Threads.tsx
|
|
5456
|
-
import { jsx as
|
|
5858
|
+
import { jsx as jsx33, jsxs as jsxs27 } from "react/jsx-runtime";
|
|
5457
5859
|
function Threads({
|
|
5458
5860
|
threads,
|
|
5459
5861
|
currentThreadId,
|
|
@@ -5472,8 +5874,8 @@ function Threads({
|
|
|
5472
5874
|
tabs: "flex gap-2 border-b border-neutral-200 dark:border-neutral-700 overflow-x-auto"
|
|
5473
5875
|
};
|
|
5474
5876
|
if (variant === "tabs") {
|
|
5475
|
-
return /* @__PURE__ */
|
|
5476
|
-
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(
|
|
5477
5879
|
"button",
|
|
5478
5880
|
{
|
|
5479
5881
|
onClick: () => onThreadSelect?.(thread.id),
|
|
@@ -5485,7 +5887,7 @@ function Threads({
|
|
|
5485
5887
|
},
|
|
5486
5888
|
thread.id
|
|
5487
5889
|
)),
|
|
5488
|
-
showNewButton && onNewThread && /* @__PURE__ */
|
|
5890
|
+
showNewButton && onNewThread && /* @__PURE__ */ jsx33(
|
|
5489
5891
|
"button",
|
|
5490
5892
|
{
|
|
5491
5893
|
onClick: onNewThread,
|
|
@@ -5495,8 +5897,8 @@ function Threads({
|
|
|
5495
5897
|
)
|
|
5496
5898
|
] });
|
|
5497
5899
|
}
|
|
5498
|
-
return /* @__PURE__ */
|
|
5499
|
-
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(
|
|
5500
5902
|
"button",
|
|
5501
5903
|
{
|
|
5502
5904
|
onClick: onNewThread,
|
|
@@ -5504,7 +5906,7 @@ function Threads({
|
|
|
5504
5906
|
children: "+ New Conversation"
|
|
5505
5907
|
}
|
|
5506
5908
|
) }),
|
|
5507
|
-
/* @__PURE__ */
|
|
5909
|
+
/* @__PURE__ */ jsx33(
|
|
5508
5910
|
ThreadList,
|
|
5509
5911
|
{
|
|
5510
5912
|
threads,
|
|
@@ -5519,11 +5921,11 @@ function Threads({
|
|
|
5519
5921
|
}
|
|
5520
5922
|
|
|
5521
5923
|
// src/components/AutoInterface/AutoInterface.tsx
|
|
5522
|
-
import { useState as
|
|
5924
|
+
import { useState as useState16, useRef as useRef10, useCallback as useCallback3, useEffect as useEffect10 } from "react";
|
|
5523
5925
|
|
|
5524
5926
|
// src/components/AutoInterface/LayoutRenderer.tsx
|
|
5525
|
-
import { useState as
|
|
5526
|
-
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";
|
|
5527
5929
|
var gapClasses = {
|
|
5528
5930
|
none: "gap-0",
|
|
5529
5931
|
sm: "gap-2",
|
|
@@ -5547,27 +5949,27 @@ function LayoutRenderer({ node, onAction, renderNode }) {
|
|
|
5547
5949
|
const children = node.children || [];
|
|
5548
5950
|
switch (node.layout) {
|
|
5549
5951
|
case "page":
|
|
5550
|
-
return /* @__PURE__ */
|
|
5952
|
+
return /* @__PURE__ */ jsx34(PageLayout, { node, renderNode });
|
|
5551
5953
|
case "row":
|
|
5552
|
-
return /* @__PURE__ */
|
|
5954
|
+
return /* @__PURE__ */ jsx34(RowLayout, { node, renderNode });
|
|
5553
5955
|
case "columns":
|
|
5554
|
-
return /* @__PURE__ */
|
|
5956
|
+
return /* @__PURE__ */ jsx34(ColumnsLayout, { node, renderNode });
|
|
5555
5957
|
case "stack":
|
|
5556
|
-
return /* @__PURE__ */
|
|
5958
|
+
return /* @__PURE__ */ jsx34(StackLayout, { node, renderNode });
|
|
5557
5959
|
case "sidebar":
|
|
5558
|
-
return /* @__PURE__ */
|
|
5960
|
+
return /* @__PURE__ */ jsx34(SidebarLayout, { node, renderNode });
|
|
5559
5961
|
case "tabs":
|
|
5560
|
-
return /* @__PURE__ */
|
|
5962
|
+
return /* @__PURE__ */ jsx34(TabsLayout, { node, renderNode });
|
|
5561
5963
|
default:
|
|
5562
|
-
return /* @__PURE__ */
|
|
5964
|
+
return /* @__PURE__ */ jsx34("div", { className: "space-y-4", children: children.map((child) => /* @__PURE__ */ jsx34("div", { children: renderNode(child) }, child.id)) });
|
|
5563
5965
|
}
|
|
5564
5966
|
}
|
|
5565
5967
|
function PageLayout({ node, renderNode }) {
|
|
5566
5968
|
const { title, padding = "md", maxWidth = "xl" } = node.props || {};
|
|
5567
5969
|
const children = node.children || [];
|
|
5568
|
-
return /* @__PURE__ */
|
|
5569
|
-
title && /* @__PURE__ */
|
|
5570
|
-
/* @__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)) })
|
|
5571
5973
|
] });
|
|
5572
5974
|
}
|
|
5573
5975
|
function RowLayout({ node, renderNode }) {
|
|
@@ -5580,12 +5982,12 @@ function RowLayout({ node, renderNode }) {
|
|
|
5580
5982
|
end: "items-end",
|
|
5581
5983
|
stretch: "items-stretch"
|
|
5582
5984
|
};
|
|
5583
|
-
return /* @__PURE__ */
|
|
5985
|
+
return /* @__PURE__ */ jsx34(
|
|
5584
5986
|
"div",
|
|
5585
5987
|
{
|
|
5586
5988
|
className: cn("grid", gapClasses[gap], alignClasses[align]),
|
|
5587
5989
|
style: { gridTemplateColumns: templateColumns },
|
|
5588
|
-
children: children.map((child) => /* @__PURE__ */
|
|
5990
|
+
children: children.map((child) => /* @__PURE__ */ jsx34("div", { children: renderNode(child) }, child.id))
|
|
5589
5991
|
}
|
|
5590
5992
|
);
|
|
5591
5993
|
}
|
|
@@ -5593,12 +5995,12 @@ function ColumnsLayout({ node, renderNode }) {
|
|
|
5593
5995
|
const { count, gap = "md" } = node.props || {};
|
|
5594
5996
|
const children = node.children || [];
|
|
5595
5997
|
const colCount = count || children.length;
|
|
5596
|
-
return /* @__PURE__ */
|
|
5998
|
+
return /* @__PURE__ */ jsx34(
|
|
5597
5999
|
"div",
|
|
5598
6000
|
{
|
|
5599
6001
|
className: cn("grid", gapClasses[gap]),
|
|
5600
6002
|
style: { gridTemplateColumns: `repeat(${colCount}, 1fr)` },
|
|
5601
|
-
children: children.map((child) => /* @__PURE__ */
|
|
6003
|
+
children: children.map((child) => /* @__PURE__ */ jsx34("div", { children: renderNode(child) }, child.id))
|
|
5602
6004
|
}
|
|
5603
6005
|
);
|
|
5604
6006
|
}
|
|
@@ -5611,14 +6013,14 @@ function StackLayout({ node, renderNode }) {
|
|
|
5611
6013
|
right: "items-end",
|
|
5612
6014
|
stretch: "items-stretch"
|
|
5613
6015
|
};
|
|
5614
|
-
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)) });
|
|
5615
6017
|
}
|
|
5616
6018
|
function SidebarLayout({ node, renderNode }) {
|
|
5617
6019
|
const { side = "left", width = "280px" } = node.props || {};
|
|
5618
6020
|
const children = node.children || [];
|
|
5619
6021
|
const [sidebarChild, ...mainChildren] = side === "left" ? children : [...children].reverse();
|
|
5620
6022
|
if (!sidebarChild) return null;
|
|
5621
|
-
const sidebar = /* @__PURE__ */
|
|
6023
|
+
const sidebar = /* @__PURE__ */ jsx34(
|
|
5622
6024
|
"div",
|
|
5623
6025
|
{
|
|
5624
6026
|
className: "flex-shrink-0 overflow-y-auto border-neutral-200 dark:border-neutral-700",
|
|
@@ -5626,11 +6028,11 @@ function SidebarLayout({ node, renderNode }) {
|
|
|
5626
6028
|
children: renderNode(sidebarChild)
|
|
5627
6029
|
}
|
|
5628
6030
|
);
|
|
5629
|
-
const main = /* @__PURE__ */
|
|
5630
|
-
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: [
|
|
5631
6033
|
sidebar,
|
|
5632
6034
|
main
|
|
5633
|
-
] }) : /* @__PURE__ */
|
|
6035
|
+
] }) : /* @__PURE__ */ jsxs28(Fragment8, { children: [
|
|
5634
6036
|
main,
|
|
5635
6037
|
sidebar
|
|
5636
6038
|
] }) });
|
|
@@ -5638,9 +6040,9 @@ function SidebarLayout({ node, renderNode }) {
|
|
|
5638
6040
|
function TabsLayout({ node, renderNode }) {
|
|
5639
6041
|
const { labels = [], defaultTab = 0 } = node.props || {};
|
|
5640
6042
|
const children = node.children || [];
|
|
5641
|
-
const [activeTab, setActiveTab] =
|
|
5642
|
-
return /* @__PURE__ */
|
|
5643
|
-
/* @__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(
|
|
5644
6046
|
"button",
|
|
5645
6047
|
{
|
|
5646
6048
|
onClick: () => setActiveTab(idx),
|
|
@@ -5657,7 +6059,7 @@ function TabsLayout({ node, renderNode }) {
|
|
|
5657
6059
|
}
|
|
5658
6060
|
|
|
5659
6061
|
// src/components/AutoInterface/InterfaceRenderer.tsx
|
|
5660
|
-
import { Fragment as
|
|
6062
|
+
import { Fragment as Fragment9, jsx as jsx35 } from "react/jsx-runtime";
|
|
5661
6063
|
var STRUCTURAL_KEYS = /* @__PURE__ */ new Set(["type", "id", "layout", "props", "children", "actions", "metadata", "isStreaming"]);
|
|
5662
6064
|
function normalizeNode(n) {
|
|
5663
6065
|
let node = { ...n };
|
|
@@ -5687,7 +6089,7 @@ function InterfaceRenderer({ node, onAction }) {
|
|
|
5687
6089
|
const renderNode = (rawNode) => {
|
|
5688
6090
|
const n = normalizeNode(rawNode);
|
|
5689
6091
|
if (n.type === "layout" && n.layout) {
|
|
5690
|
-
return /* @__PURE__ */
|
|
6092
|
+
return /* @__PURE__ */ jsx35(
|
|
5691
6093
|
LayoutRenderer,
|
|
5692
6094
|
{
|
|
5693
6095
|
node: n,
|
|
@@ -5697,7 +6099,7 @@ function InterfaceRenderer({ node, onAction }) {
|
|
|
5697
6099
|
n.id
|
|
5698
6100
|
);
|
|
5699
6101
|
}
|
|
5700
|
-
return /* @__PURE__ */
|
|
6102
|
+
return /* @__PURE__ */ jsx35(
|
|
5701
6103
|
WidgetRenderer,
|
|
5702
6104
|
{
|
|
5703
6105
|
widget: {
|
|
@@ -5713,33 +6115,33 @@ function InterfaceRenderer({ node, onAction }) {
|
|
|
5713
6115
|
n.id
|
|
5714
6116
|
);
|
|
5715
6117
|
};
|
|
5716
|
-
return /* @__PURE__ */
|
|
6118
|
+
return /* @__PURE__ */ jsx35(Fragment9, { children: renderNode(node) });
|
|
5717
6119
|
}
|
|
5718
6120
|
|
|
5719
6121
|
// src/components/AutoInterface/InterfaceSkeleton.tsx
|
|
5720
|
-
import { jsx as
|
|
6122
|
+
import { jsx as jsx36, jsxs as jsxs29 } from "react/jsx-runtime";
|
|
5721
6123
|
function InterfaceSkeleton({ className }) {
|
|
5722
|
-
return /* @__PURE__ */
|
|
5723
|
-
/* @__PURE__ */
|
|
5724
|
-
/* @__PURE__ */
|
|
5725
|
-
/* @__PURE__ */
|
|
5726
|
-
/* @__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" })
|
|
5727
6129
|
] }, i)) }),
|
|
5728
|
-
/* @__PURE__ */
|
|
5729
|
-
/* @__PURE__ */
|
|
5730
|
-
/* @__PURE__ */
|
|
5731
|
-
/* @__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" })
|
|
5732
6134
|
] }),
|
|
5733
|
-
/* @__PURE__ */
|
|
5734
|
-
/* @__PURE__ */
|
|
5735
|
-
[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))
|
|
5736
6138
|
] })
|
|
5737
6139
|
] })
|
|
5738
6140
|
] });
|
|
5739
6141
|
}
|
|
5740
6142
|
|
|
5741
6143
|
// src/components/AutoInterface/AutoInterface.tsx
|
|
5742
|
-
import { jsx as
|
|
6144
|
+
import { jsx as jsx37, jsxs as jsxs30 } from "react/jsx-runtime";
|
|
5743
6145
|
async function generateInitialInterface(apiUrl, apiKey, agentId, prompt) {
|
|
5744
6146
|
const systemContext = generateCompactInterfaceContext();
|
|
5745
6147
|
const message = `${systemContext}
|
|
@@ -5789,19 +6191,19 @@ function AutoInterface({
|
|
|
5789
6191
|
theme,
|
|
5790
6192
|
className
|
|
5791
6193
|
}) {
|
|
5792
|
-
const [interfaceSpec, setInterfaceSpec] =
|
|
5793
|
-
const [isGenerating, setIsGenerating] =
|
|
5794
|
-
const [chatCollapsed, setChatCollapsed] =
|
|
5795
|
-
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);
|
|
5796
6198
|
const systemContext = [
|
|
5797
6199
|
generateInterfaceContext(),
|
|
5798
6200
|
context || ""
|
|
5799
6201
|
].filter(Boolean).join("\n\n");
|
|
5800
|
-
const updateInterface =
|
|
6202
|
+
const updateInterface = useCallback3((newSpec) => {
|
|
5801
6203
|
setInterfaceSpec(newSpec);
|
|
5802
6204
|
onInterfaceChange?.(newSpec);
|
|
5803
6205
|
}, [onInterfaceChange]);
|
|
5804
|
-
const handleAction =
|
|
6206
|
+
const handleAction = useCallback3((action) => {
|
|
5805
6207
|
onAction?.(action);
|
|
5806
6208
|
if (chatRef.current) {
|
|
5807
6209
|
chatRef.current.sendMessage(
|
|
@@ -5809,7 +6211,7 @@ function AutoInterface({
|
|
|
5809
6211
|
);
|
|
5810
6212
|
}
|
|
5811
6213
|
}, [onAction]);
|
|
5812
|
-
const handleMessageComplete =
|
|
6214
|
+
const handleMessageComplete = useCallback3((result) => {
|
|
5813
6215
|
if (!result?.data) return;
|
|
5814
6216
|
const text = typeof result.data === "string" ? result.data : result.data.message || "";
|
|
5815
6217
|
console.log("[AutoInterface] Chat message complete, text (" + text.length + " chars):", text.substring(0, 300));
|
|
@@ -5830,7 +6232,7 @@ function AutoInterface({
|
|
|
5830
6232
|
}
|
|
5831
6233
|
setIsGenerating(false);
|
|
5832
6234
|
}, [interfaceSpec, updateInterface]);
|
|
5833
|
-
|
|
6235
|
+
useEffect10(() => {
|
|
5834
6236
|
if (!initialPrompt || initialInterface || useMock) return;
|
|
5835
6237
|
if (!apiUrl) return;
|
|
5836
6238
|
let cancelled = false;
|
|
@@ -5859,17 +6261,17 @@ function AutoInterface({
|
|
|
5859
6261
|
}, [initialPrompt]);
|
|
5860
6262
|
const hasInterface = interfaceSpec !== null;
|
|
5861
6263
|
const showSkeleton = isGenerating && !hasInterface;
|
|
5862
|
-
return /* @__PURE__ */
|
|
6264
|
+
return /* @__PURE__ */ jsxs30("div", { className: cn(
|
|
5863
6265
|
"flex h-full bg-neutral-50 dark:bg-black",
|
|
5864
6266
|
chatPosition === "bottom" ? "flex-col" : "flex-row",
|
|
5865
6267
|
className
|
|
5866
6268
|
), children: [
|
|
5867
|
-
/* @__PURE__ */
|
|
6269
|
+
/* @__PURE__ */ jsxs30("div", { className: cn(
|
|
5868
6270
|
"flex-1 overflow-y-auto min-w-0",
|
|
5869
6271
|
hasInterface || showSkeleton ? "" : "hidden"
|
|
5870
6272
|
), children: [
|
|
5871
|
-
showSkeleton && /* @__PURE__ */
|
|
5872
|
-
hasInterface && interfaceSpec && /* @__PURE__ */
|
|
6273
|
+
showSkeleton && /* @__PURE__ */ jsx37(InterfaceSkeleton, {}),
|
|
6274
|
+
hasInterface && interfaceSpec && /* @__PURE__ */ jsx37("div", { className: "p-4", children: /* @__PURE__ */ jsx37(
|
|
5873
6275
|
InterfaceRenderer,
|
|
5874
6276
|
{
|
|
5875
6277
|
node: interfaceSpec.root,
|
|
@@ -5877,16 +6279,16 @@ function AutoInterface({
|
|
|
5877
6279
|
}
|
|
5878
6280
|
) })
|
|
5879
6281
|
] }),
|
|
5880
|
-
chatCollapsible && hasInterface && chatPosition === "right" && /* @__PURE__ */
|
|
6282
|
+
chatCollapsible && hasInterface && chatPosition === "right" && /* @__PURE__ */ jsx37(
|
|
5881
6283
|
"button",
|
|
5882
6284
|
{
|
|
5883
6285
|
onClick: () => setChatCollapsed(!chatCollapsed),
|
|
5884
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",
|
|
5885
6287
|
title: chatCollapsed ? "Show chat" : "Hide chat",
|
|
5886
|
-
children: /* @__PURE__ */
|
|
6288
|
+
children: /* @__PURE__ */ jsx37("span", { className: "!text-xs !text-neutral-500 dark:!text-neutral-400", children: chatCollapsed ? "\u25C0" : "\u25B6" })
|
|
5887
6289
|
}
|
|
5888
6290
|
),
|
|
5889
|
-
/* @__PURE__ */
|
|
6291
|
+
/* @__PURE__ */ jsx37(
|
|
5890
6292
|
"div",
|
|
5891
6293
|
{
|
|
5892
6294
|
className: cn(
|
|
@@ -5897,7 +6299,7 @@ function AutoInterface({
|
|
|
5897
6299
|
!hasInterface && !showSkeleton && "flex-1"
|
|
5898
6300
|
),
|
|
5899
6301
|
style: hasInterface || showSkeleton ? chatPosition === "right" ? { width: chatWidth } : { height: "300px" } : void 0,
|
|
5900
|
-
children: /* @__PURE__ */
|
|
6302
|
+
children: /* @__PURE__ */ jsx37(
|
|
5901
6303
|
Chat,
|
|
5902
6304
|
{
|
|
5903
6305
|
ref: chatRef,
|
|
@@ -5955,29 +6357,29 @@ function getThemeScript() {
|
|
|
5955
6357
|
}
|
|
5956
6358
|
|
|
5957
6359
|
// src/hooks/useInterfaceState.ts
|
|
5958
|
-
import { useState as
|
|
6360
|
+
import { useState as useState17, useCallback as useCallback4 } from "react";
|
|
5959
6361
|
function useInterfaceState(initialSpec) {
|
|
5960
|
-
const [spec, setSpec] =
|
|
5961
|
-
const [isStreaming, setIsStreaming] =
|
|
5962
|
-
const setInterface =
|
|
6362
|
+
const [spec, setSpec] = useState17(initialSpec || null);
|
|
6363
|
+
const [isStreaming, setIsStreaming] = useState17(false);
|
|
6364
|
+
const setInterface = useCallback4((newSpec) => {
|
|
5963
6365
|
setSpec(newSpec);
|
|
5964
6366
|
}, []);
|
|
5965
|
-
const clearInterface =
|
|
6367
|
+
const clearInterface = useCallback4(() => {
|
|
5966
6368
|
setSpec(null);
|
|
5967
6369
|
}, []);
|
|
5968
|
-
const applyInterfaceUpdate =
|
|
6370
|
+
const applyInterfaceUpdate = useCallback4((update) => {
|
|
5969
6371
|
setSpec((prev) => {
|
|
5970
6372
|
if (!prev) return prev;
|
|
5971
6373
|
return applyUpdate(prev, update);
|
|
5972
6374
|
});
|
|
5973
6375
|
}, []);
|
|
5974
|
-
const applyInterfaceUpdates =
|
|
6376
|
+
const applyInterfaceUpdates = useCallback4((updates) => {
|
|
5975
6377
|
setSpec((prev) => {
|
|
5976
6378
|
if (!prev) return prev;
|
|
5977
6379
|
return applyUpdates(prev, updates);
|
|
5978
6380
|
});
|
|
5979
6381
|
}, []);
|
|
5980
|
-
const getNode =
|
|
6382
|
+
const getNode = useCallback4((id) => {
|
|
5981
6383
|
if (!spec) return null;
|
|
5982
6384
|
return findNode(spec.root, id);
|
|
5983
6385
|
}, [spec]);
|
|
@@ -5994,7 +6396,7 @@ function useInterfaceState(initialSpec) {
|
|
|
5994
6396
|
}
|
|
5995
6397
|
|
|
5996
6398
|
// src/hooks/useInterfaceAI.ts
|
|
5997
|
-
import { useCallback as
|
|
6399
|
+
import { useCallback as useCallback5, useRef as useRef11 } from "react";
|
|
5998
6400
|
function useInterfaceAI({
|
|
5999
6401
|
agentId,
|
|
6000
6402
|
apiUrl,
|
|
@@ -6006,15 +6408,15 @@ function useInterfaceAI({
|
|
|
6006
6408
|
onStreamStart,
|
|
6007
6409
|
onStreamEnd
|
|
6008
6410
|
}) {
|
|
6009
|
-
const threadIdRef =
|
|
6010
|
-
const accumulatedTextRef =
|
|
6411
|
+
const threadIdRef = useRef11(null);
|
|
6412
|
+
const accumulatedTextRef = useRef11("");
|
|
6011
6413
|
if (apiUrl || apiKey) {
|
|
6012
6414
|
aptevaClient.configure({
|
|
6013
6415
|
...apiUrl && { apiUrl },
|
|
6014
6416
|
...apiKey && { apiKey }
|
|
6015
6417
|
});
|
|
6016
6418
|
}
|
|
6017
|
-
const sendMessage =
|
|
6419
|
+
const sendMessage = useCallback5(async (message) => {
|
|
6018
6420
|
accumulatedTextRef.current = "";
|
|
6019
6421
|
onStreamStart?.();
|
|
6020
6422
|
const systemPrompt = [
|
|
@@ -6079,6 +6481,8 @@ export {
|
|
|
6079
6481
|
Kpi,
|
|
6080
6482
|
LayoutRenderer,
|
|
6081
6483
|
List,
|
|
6484
|
+
LiveView,
|
|
6485
|
+
PersistentWidgetPanel,
|
|
6082
6486
|
Prompt,
|
|
6083
6487
|
Spacer,
|
|
6084
6488
|
Stream,
|