@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.js
CHANGED
|
@@ -1442,10 +1442,15 @@ function Table({ widget, onAction }) {
|
|
|
1442
1442
|
|
|
1443
1443
|
function Form({ widget, onAction }) {
|
|
1444
1444
|
const { title, fields } = widget.props;
|
|
1445
|
+
const fileInputRefs = _react.useRef.call(void 0, {});
|
|
1445
1446
|
const [formData, setFormData] = _react.useState.call(void 0, () => {
|
|
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] = _nullishCoalesce(field.defaultValue, () => ( (field.type === "checkbox" ? false : "")));
|
|
1453
|
+
}
|
|
1449
1454
|
});
|
|
1450
1455
|
return initial;
|
|
1451
1456
|
});
|
|
@@ -1524,11 +1529,75 @@ function Form({ widget, onAction }) {
|
|
|
1524
1529
|
),
|
|
1525
1530
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "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__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-2", children: [
|
|
1535
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1536
|
+
"input",
|
|
1537
|
+
{
|
|
1538
|
+
ref: (el) => {
|
|
1539
|
+
fileInputRefs.current[field.name] = el;
|
|
1540
|
+
},
|
|
1541
|
+
type: "file",
|
|
1542
|
+
name: field.name,
|
|
1543
|
+
multiple: _nullishCoalesce(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__ */ _jsxruntime.jsx.call(void 0,
|
|
1560
|
+
"button",
|
|
1561
|
+
{
|
|
1562
|
+
type: "button",
|
|
1563
|
+
onClick: () => _optionalChain([fileInputRefs, 'access', _23 => _23.current, 'access', _24 => _24[field.name], 'optionalAccess', _25 => _25.click, 'call', _26 => _26()]),
|
|
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__ */ _jsxruntime.jsx.call(void 0, "ul", { className: "space-y-1", children: files.map((file, idx) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
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__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "!text-neutral-700 dark:!text-neutral-300 truncate mr-2", children: [
|
|
1574
|
+
file.name,
|
|
1575
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "!text-neutral-400 ml-1", children: [
|
|
1576
|
+
"(",
|
|
1577
|
+
(file.size / 1024).toFixed(0),
|
|
1578
|
+
" KB)"
|
|
1579
|
+
] })
|
|
1580
|
+
] }),
|
|
1581
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
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
|
}
|
|
1530
1599
|
};
|
|
1531
|
-
const submitAction = _optionalChain([widget, 'access',
|
|
1600
|
+
const submitAction = _optionalChain([widget, 'access', _27 => _27.actions, 'optionalAccess', _28 => _28.find, 'call', _29 => _29((a) => a.type === "submit")]) || _optionalChain([widget, 'access', _30 => _30.actions, 'optionalAccess', _31 => _31[0]]);
|
|
1532
1601
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "form", { onSubmit: handleSubmit, className: "border border-neutral-200 dark:border-neutral-700 rounded-xl bg-white dark:bg-neutral-900 overflow-hidden", children: [
|
|
1533
1602
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "p-4", children: [
|
|
1534
1603
|
title && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h3", { className: "!text-lg font-semibold !text-neutral-900 dark:!text-white mb-4", children: title }),
|
|
@@ -1588,7 +1657,7 @@ function StepIcon({ type, status }) {
|
|
|
1588
1657
|
if (type === "recurring" || type === "repeat") {
|
|
1589
1658
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "svg", { className: iconClass, fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, 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" }) });
|
|
1590
1659
|
}
|
|
1591
|
-
if (type === "agent" || _optionalChain([type, 'optionalAccess',
|
|
1660
|
+
if (type === "agent" || _optionalChain([type, 'optionalAccess', _32 => _32.startsWith, 'call', _33 => _33("@")])) {
|
|
1592
1661
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "svg", { className: iconClass, fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M17 20h5v-2a3 3 0 00-5.356-1.857M17 20H7m10 0v-2c0-.656-.126-1.283-.356-1.857M7 20H2v-2a3 3 0 015.356-1.857M7 20v-2c0-.656.126-1.283.356-1.857m0 0a5.002 5.002 0 019.288 0M15 7a3 3 0 11-6 0 3 3 0 016 0z" }) });
|
|
1593
1662
|
}
|
|
1594
1663
|
if (type === "email" || type === "mail") {
|
|
@@ -1684,7 +1753,7 @@ function getStepColorClass(step, stepType) {
|
|
|
1684
1753
|
if (stepType === "time" || stepType === "schedule" || stepType === "clock") {
|
|
1685
1754
|
return STEP_COLOR_CLASSES.blue;
|
|
1686
1755
|
}
|
|
1687
|
-
if (stepType === "agent" || _optionalChain([stepType, 'optionalAccess',
|
|
1756
|
+
if (stepType === "agent" || _optionalChain([stepType, 'optionalAccess', _34 => _34.startsWith, 'call', _35 => _35("@")])) {
|
|
1688
1757
|
return STEP_COLOR_CLASSES.purple;
|
|
1689
1758
|
}
|
|
1690
1759
|
if (stepType === "email" || stepType === "slack" || stepType === "message" || stepType === "notification") {
|
|
@@ -1800,7 +1869,7 @@ function Kpi({ widget, onAction }) {
|
|
|
1800
1869
|
widget.actions && widget.actions.length > 0 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "flex gap-2 mt-3 pt-3 border-t border-neutral-200 dark:border-neutral-700", children: widget.actions.map((action, idx) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1801
1870
|
"button",
|
|
1802
1871
|
{
|
|
1803
|
-
onClick: () => _optionalChain([onAction, 'optionalCall',
|
|
1872
|
+
onClick: () => _optionalChain([onAction, 'optionalCall', _36 => _36({
|
|
1804
1873
|
type: action.type,
|
|
1805
1874
|
payload: action.payload,
|
|
1806
1875
|
widgetId: widget.id,
|
|
@@ -1912,6 +1981,121 @@ function Spacer({ widget }) {
|
|
|
1912
1981
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: heightClasses[height] || heightClasses.md });
|
|
1913
1982
|
}
|
|
1914
1983
|
|
|
1984
|
+
// src/components/Widgets/widget-library/LiveView.tsx
|
|
1985
|
+
|
|
1986
|
+
|
|
1987
|
+
function LiveView({ widget }) {
|
|
1988
|
+
const { src, title, height, aspectRatio = "16/9", allowFullscreen = true, sandbox, allow, refreshInterval, showToolbar = true } = widget.props;
|
|
1989
|
+
const iframeRef = _react.useRef.call(void 0, null);
|
|
1990
|
+
const [isLoading, setIsLoading] = _react.useState.call(void 0, true);
|
|
1991
|
+
const [hasError, setHasError] = _react.useState.call(void 0, false);
|
|
1992
|
+
const [refreshKey, setRefreshKey] = _react.useState.call(void 0, 0);
|
|
1993
|
+
const handleRefresh = _react.useCallback.call(void 0, () => {
|
|
1994
|
+
setIsLoading(true);
|
|
1995
|
+
setHasError(false);
|
|
1996
|
+
setRefreshKey((k) => k + 1);
|
|
1997
|
+
}, []);
|
|
1998
|
+
const handleFullscreen = _react.useCallback.call(void 0, () => {
|
|
1999
|
+
_optionalChain([iframeRef, 'access', _37 => _37.current, 'optionalAccess', _38 => _38.requestFullscreen, 'optionalCall', _39 => _39()]);
|
|
2000
|
+
}, []);
|
|
2001
|
+
const handleOpenExternal = _react.useCallback.call(void 0, () => {
|
|
2002
|
+
window.open(src, "_blank", "noopener,noreferrer");
|
|
2003
|
+
}, [src]);
|
|
2004
|
+
_react.useEffect.call(void 0, () => {
|
|
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__ */ _jsxruntime.jsxs.call(void 0, "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__ */ _jsxruntime.jsxs.call(void 0, "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__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-2 min-w-0", children: [
|
|
2014
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "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__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-sm font-medium text-neutral-700 dark:text-neutral-300 truncate", children: title || "Live View" })
|
|
2019
|
+
] }),
|
|
2020
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-1 flex-shrink-0", children: [
|
|
2021
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
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__ */ _jsxruntime.jsx.call(void 0, "svg", { className: "w-3.5 h-3.5", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", strokeWidth: 2, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "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__ */ _jsxruntime.jsx.call(void 0,
|
|
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__ */ _jsxruntime.jsx.call(void 0, "svg", { className: "w-3.5 h-3.5", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", strokeWidth: 2, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "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__ */ _jsxruntime.jsx.call(void 0,
|
|
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__ */ _jsxruntime.jsx.call(void 0, "svg", { className: "w-3.5 h-3.5", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", strokeWidth: 2, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "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__ */ _jsxruntime.jsxs.call(void 0,
|
|
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__ */ _jsxruntime.jsx.call(void 0, "div", { className: "absolute inset-0 flex items-center justify-center bg-neutral-100 dark:bg-neutral-900 z-10", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-col items-center gap-2", children: [
|
|
2057
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "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__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-xs text-neutral-500", children: "Loading..." })
|
|
2059
|
+
] }) }),
|
|
2060
|
+
hasError && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "absolute inset-0 flex items-center justify-center bg-neutral-100 dark:bg-neutral-900 z-10", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-col items-center gap-2 text-center px-4", children: [
|
|
2061
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "svg", { className: "w-8 h-8 text-neutral-400", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", strokeWidth: 1.5, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "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__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-sm text-neutral-500", children: "Failed to load" }),
|
|
2063
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
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__ */ _jsxruntime.jsx.call(void 0,
|
|
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
|
+
|
|
1915
2099
|
// src/components/Widgets/WidgetRenderer.tsx
|
|
1916
2100
|
|
|
1917
2101
|
function WidgetRenderer({ widget, onAction }) {
|
|
@@ -1939,6 +2123,8 @@ function WidgetRenderer({ widget, onAction }) {
|
|
|
1939
2123
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TextBlock, { widget });
|
|
1940
2124
|
case "spacer":
|
|
1941
2125
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Spacer, { widget });
|
|
2126
|
+
case "live_view":
|
|
2127
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, LiveView, { widget });
|
|
1942
2128
|
default:
|
|
1943
2129
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "p-4 border border-yellow-300 bg-yellow-50 rounded-lg", children: [
|
|
1944
2130
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "p", { className: "text-sm text-yellow-800", children: [
|
|
@@ -1965,7 +2151,7 @@ function Widgets({
|
|
|
1965
2151
|
}) {
|
|
1966
2152
|
_react.useEffect.call(void 0, () => {
|
|
1967
2153
|
widgets.forEach((widget) => {
|
|
1968
|
-
_optionalChain([onWidgetMount, 'optionalCall',
|
|
2154
|
+
_optionalChain([onWidgetMount, 'optionalCall', _40 => _40(widget.id)]);
|
|
1969
2155
|
});
|
|
1970
2156
|
}, [widgets, onWidgetMount]);
|
|
1971
2157
|
const layoutClasses = {
|
|
@@ -2239,7 +2425,21 @@ function MarkdownContent({ content, className = "" }) {
|
|
|
2239
2425
|
|
|
2240
2426
|
// src/components/Chat/ToolCall.tsx
|
|
2241
2427
|
|
|
2242
|
-
function ToolCall({ name, status, isReceiving = false, inputLength = 0, streamOutput }) {
|
|
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__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "apteva-tool-inline", children: [
|
|
2432
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "apteva-tool-inline-line" }),
|
|
2433
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "apteva-tool-inline-content", children: [
|
|
2434
|
+
status === "running" || status === "preparing" ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "svg", { className: "apteva-tool-inline-icon apteva-tool-icon-spin", width: "14", height: "14", fill: "none", viewBox: "0 0 24 24", children: [
|
|
2435
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "circle", { className: "apteva-tool-spinner-track", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }),
|
|
2436
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", { className: "apteva-tool-spinner-fill", fill: "currentColor", d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z" })
|
|
2437
|
+
] }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "svg", { className: "apteva-tool-inline-icon", width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", { d: "M13 2L3 14h9l-1 8 10-12h-9l1-8z", fill: "currentColor" }) }),
|
|
2438
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "apteva-tool-inline-text", children: statusText })
|
|
2439
|
+
] }),
|
|
2440
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "apteva-tool-inline-line" })
|
|
2441
|
+
] });
|
|
2442
|
+
}
|
|
2243
2443
|
if (status === "preparing") {
|
|
2244
2444
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "apteva-tool-card apteva-tool-card-preparing", children: [
|
|
2245
2445
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "svg", { className: "apteva-tool-icon apteva-tool-icon-spin", fill: "none", viewBox: "0 0 24 24", children: [
|
|
@@ -2287,12 +2487,82 @@ function ToolCall({ name, status, isReceiving = false, inputLength = 0, streamOu
|
|
|
2287
2487
|
] });
|
|
2288
2488
|
}
|
|
2289
2489
|
|
|
2490
|
+
// src/components/Chat/ToolCallGroup.tsx
|
|
2491
|
+
|
|
2492
|
+
|
|
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] = _react.useState.call(void 0, 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__ */ _jsxruntime.jsxs.call(void 0, "div", { className: cardClass, children: [
|
|
2506
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
2507
|
+
"button",
|
|
2508
|
+
{
|
|
2509
|
+
className: "apteva-tool-group-header",
|
|
2510
|
+
onClick: () => setExpanded(!expanded),
|
|
2511
|
+
children: [
|
|
2512
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "apteva-tool-group-header-left", children: [
|
|
2513
|
+
allDone ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "svg", { className: "apteva-tool-group-icon", width: "14", height: "14", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M5 13l4 4L19 7" }) }) : /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "svg", { className: "apteva-tool-group-icon apteva-tool-icon-spin", width: "14", height: "14", fill: "none", viewBox: "0 0 24 24", children: [
|
|
2514
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "circle", { className: "apteva-tool-spinner-track", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }),
|
|
2515
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "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__ */ _jsxruntime.jsx.call(void 0, "span", { className: "apteva-tool-group-status", children: statusText })
|
|
2518
|
+
] }),
|
|
2519
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
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__ */ _jsxruntime.jsx.call(void 0, "path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M19 9l-7 7-7-7" })
|
|
2529
|
+
}
|
|
2530
|
+
)
|
|
2531
|
+
]
|
|
2532
|
+
}
|
|
2533
|
+
),
|
|
2534
|
+
!isExpanded && activeStreamTool && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "apteva-tool-group-stream", children: [
|
|
2535
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "apteva-tool-group-stream-name", children: [
|
|
2536
|
+
activeStreamTool.name,
|
|
2537
|
+
":"
|
|
2538
|
+
] }),
|
|
2539
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "apteva-tool-group-stream-text", children: activeStreamTool.streamOutput })
|
|
2540
|
+
] }),
|
|
2541
|
+
isExpanded && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "apteva-tool-group-list", children: tools.map((tool) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "apteva-tool-group-item", children: [
|
|
2542
|
+
tool.status === "completed" ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "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__ */ _jsxruntime.jsx.call(void 0, "path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 3, d: "M5 13l4 4L19 7" }) }) : tool.status === "error" ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "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__ */ _jsxruntime.jsx.call(void 0, "path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 3, d: "M6 18L18 6M6 6l12 12" }) }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "apteva-tool-group-item-icon apteva-tool-group-item-spinner" }),
|
|
2543
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "apteva-tool-group-item-name", children: tool.name }),
|
|
2544
|
+
tool.streamOutput && tool.status === "running" && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "apteva-tool-group-item-stream", children: tool.streamOutput })
|
|
2545
|
+
] }, tool.id)) })
|
|
2546
|
+
] });
|
|
2547
|
+
}
|
|
2548
|
+
|
|
2549
|
+
// src/components/Chat/PersistentWidgetRef.tsx
|
|
2550
|
+
|
|
2551
|
+
function PersistentWidgetRef({ widget }) {
|
|
2552
|
+
const title = widget.props.title || widget.type.replace(/_/g, " ");
|
|
2553
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "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__ */ _jsxruntime.jsx.call(void 0, "div", { className: "w-2 h-2 rounded-full bg-emerald-500 animate-pulse flex-shrink-0" }),
|
|
2555
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-neutral-600 dark:text-neutral-400 capitalize", children: title }),
|
|
2556
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "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
2561
|
|
|
2292
|
-
function Message({ message, onAction, enableWidgets, onWidgetRender }) {
|
|
2562
|
+
function Message({ message, onAction, enableWidgets, onWidgetRender, persistentWidgetIds, toolCallStyle = "card" }) {
|
|
2293
2563
|
const isUser = message.role === "user";
|
|
2294
|
-
const contentSegments = _optionalChain([message, 'access',
|
|
2295
|
-
const isStreaming = _optionalChain([message, 'access',
|
|
2564
|
+
const contentSegments = _optionalChain([message, 'access', _41 => _41.metadata, 'optionalAccess', _42 => _42.content_segments]);
|
|
2565
|
+
const isStreaming = _optionalChain([message, 'access', _43 => _43.metadata, 'optionalAccess', _44 => _44.isStreaming]) === true;
|
|
2296
2566
|
const hasContent = message.content || contentSegments && contentSegments.length > 0;
|
|
2297
2567
|
const reportedWidgetsRef = _react.useRef.call(void 0, /* @__PURE__ */ new Set());
|
|
2298
2568
|
const parsedWidgets = _react.useMemo.call(void 0, () => {
|
|
@@ -2372,7 +2642,7 @@ function Message({ message, onAction, enableWidgets, onWidgetRender }) {
|
|
|
2372
2642
|
}
|
|
2373
2643
|
return elements.length > 0 ? elements : null;
|
|
2374
2644
|
};
|
|
2375
|
-
const attachments = _optionalChain([message, 'access',
|
|
2645
|
+
const attachments = _optionalChain([message, 'access', _45 => _45.metadata, 'optionalAccess', _46 => _46.attachments]) || [];
|
|
2376
2646
|
const hasAttachments = attachments.length > 0;
|
|
2377
2647
|
const renderAttachments = () => {
|
|
2378
2648
|
if (!hasAttachments) return null;
|
|
@@ -2468,36 +2738,102 @@ 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__ */ _jsxruntime.jsx.call(void 0, "div", { className: "apteva-tool-call-standalone", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
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__ */ _jsxruntime.jsx.call(void 0, "div", { className: "apteva-tool-call-standalone", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ToolCallGroup, { tools: toolData }) }, `tool-group-${groupIndex}`)
|
|
2801
|
+
);
|
|
2802
|
+
} else {
|
|
2803
|
+
group.tools.forEach((segment) => {
|
|
2804
|
+
if (segment.type === "tool") {
|
|
2805
|
+
elements.push(
|
|
2806
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "apteva-tool-call-standalone", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
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) => !_optionalChain([persistentWidgetIds, 'optionalAccess', _47 => _47.has, 'call', _48 => _48(w.id)]));
|
|
2827
|
+
const persistentRefs = message.widgets.filter((w) => _optionalChain([persistentWidgetIds, 'optionalAccess', _49 => _49.has, 'call', _50 => _50(w.id)]));
|
|
2828
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
2829
|
+
persistentRefs.map((w) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "apteva-widget-standalone", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, PersistentWidgetRef, { widget: w }) }, `ref-${w.id}`)),
|
|
2830
|
+
inlineWidgets.length > 0 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "apteva-widget-standalone", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Widgets, { widgets: inlineWidgets, onAction, layout: "stack" }) })
|
|
2831
|
+
] });
|
|
2832
|
+
};
|
|
2497
2833
|
if (!isUser && (contentSegments && contentSegments.length > 0)) {
|
|
2498
2834
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "apteva-message-segmented", children: [
|
|
2499
2835
|
renderSegmentedContent(),
|
|
2500
|
-
|
|
2836
|
+
renderMessageWidgets(),
|
|
2501
2837
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "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
|
}
|
|
@@ -2505,7 +2841,7 @@ function Message({ message, onAction, enableWidgets, onWidgetRender }) {
|
|
|
2505
2841
|
if (!isUser && enableWidgets && widgetContent) {
|
|
2506
2842
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "apteva-message-segmented", children: [
|
|
2507
2843
|
widgetContent,
|
|
2508
|
-
|
|
2844
|
+
renderMessageWidgets(),
|
|
2509
2845
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "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
|
}
|
|
@@ -2525,7 +2861,7 @@ function Message({ message, onAction, enableWidgets, onWidgetRender }) {
|
|
|
2525
2861
|
),
|
|
2526
2862
|
children: [
|
|
2527
2863
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: isUser ? "apteva-message-content-user" : "apteva-message-content-assistant", children: renderContent() }),
|
|
2528
|
-
|
|
2864
|
+
renderMessageWidgets(),
|
|
2529
2865
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "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
|
}
|
|
@@ -2687,7 +3023,9 @@ function MessageList({
|
|
|
2687
3023
|
chatVariant,
|
|
2688
3024
|
onPromptClick,
|
|
2689
3025
|
enableWidgets,
|
|
2690
|
-
onWidgetRender
|
|
3026
|
+
onWidgetRender,
|
|
3027
|
+
persistentWidgetIds,
|
|
3028
|
+
toolCallStyle
|
|
2691
3029
|
}) {
|
|
2692
3030
|
const listRef = _react.useRef.call(void 0, null);
|
|
2693
3031
|
const isNearBottomRef = _react.useRef.call(void 0, true);
|
|
@@ -2719,7 +3057,7 @@ function MessageList({
|
|
|
2719
3057
|
onPromptClick: onPromptClick || (() => {
|
|
2720
3058
|
})
|
|
2721
3059
|
}
|
|
2722
|
-
) : messages.map((message) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: message.role === "user" ? "apteva-message-row-user" : "apteva-message-row-assistant", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Message, { message, onAction, enableWidgets, onWidgetRender }) }, message.id)) });
|
|
3060
|
+
) : messages.map((message) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: message.role === "user" ? "apteva-message-row-user" : "apteva-message-row-assistant", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Message, { message, onAction, enableWidgets, onWidgetRender, persistentWidgetIds, toolCallStyle }) }, message.id)) });
|
|
2723
3061
|
}
|
|
2724
3062
|
|
|
2725
3063
|
// src/components/Chat/Composer.tsx
|
|
@@ -2793,7 +3131,7 @@ function Composer({ onSendMessage, placeholder = "Type a message...", disabled =
|
|
|
2793
3131
|
setFileError(errors.join(", "));
|
|
2794
3132
|
setTimeout(() => setFileError(null), 5e3);
|
|
2795
3133
|
}
|
|
2796
|
-
_optionalChain([onFileUpload, 'optionalCall',
|
|
3134
|
+
_optionalChain([onFileUpload, 'optionalCall', _51 => _51(e.target.files)]);
|
|
2797
3135
|
setShowMenu(false);
|
|
2798
3136
|
e.target.value = "";
|
|
2799
3137
|
}
|
|
@@ -2865,15 +3203,15 @@ function Composer({ onSendMessage, placeholder = "Type a message...", disabled =
|
|
|
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]",
|
|
2867
3205
|
style: {
|
|
2868
|
-
left: _nullishCoalesce(_optionalChain([menuButtonRef, 'access',
|
|
2869
|
-
bottom: window.innerHeight - (_nullishCoalesce(_optionalChain([menuButtonRef, 'access',
|
|
3206
|
+
left: _nullishCoalesce(_optionalChain([menuButtonRef, 'access', _52 => _52.current, 'optionalAccess', _53 => _53.getBoundingClientRect, 'call', _54 => _54(), 'access', _55 => _55.left]), () => ( 0)),
|
|
3207
|
+
bottom: window.innerHeight - (_nullishCoalesce(_optionalChain([menuButtonRef, 'access', _56 => _56.current, 'optionalAccess', _57 => _57.getBoundingClientRect, 'call', _58 => _58(), 'access', _59 => _59.top]), () => ( 0))) + 8
|
|
2870
3208
|
},
|
|
2871
3209
|
children: [
|
|
2872
3210
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
2873
3211
|
"button",
|
|
2874
3212
|
{
|
|
2875
3213
|
onClick: () => {
|
|
2876
|
-
_optionalChain([fileInputRef, 'access',
|
|
3214
|
+
_optionalChain([fileInputRef, 'access', _60 => _60.current, 'optionalAccess', _61 => _61.click, 'call', _62 => _62()]);
|
|
2877
3215
|
setShowMenu(false);
|
|
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",
|
|
@@ -2994,8 +3332,8 @@ function CommandComposer({
|
|
|
2994
3332
|
}
|
|
2995
3333
|
};
|
|
2996
3334
|
const handleNewCommand = () => {
|
|
2997
|
-
_optionalChain([onReset, 'optionalCall',
|
|
2998
|
-
_optionalChain([inputRef, 'access',
|
|
3335
|
+
_optionalChain([onReset, 'optionalCall', _63 => _63()]);
|
|
3336
|
+
_optionalChain([inputRef, 'access', _64 => _64.current, 'optionalAccess', _65 => _65.focus, 'call', _66 => _66()]);
|
|
2999
3337
|
};
|
|
3000
3338
|
const handleInputChange = (value) => {
|
|
3001
3339
|
setInput(value);
|
|
@@ -3109,15 +3447,15 @@ function CommandComposer({
|
|
|
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]",
|
|
3111
3449
|
style: {
|
|
3112
|
-
left: _nullishCoalesce(_optionalChain([menuButtonRef, 'access',
|
|
3113
|
-
top: (_nullishCoalesce(_optionalChain([menuButtonRef, 'access',
|
|
3450
|
+
left: _nullishCoalesce(_optionalChain([menuButtonRef, 'access', _67 => _67.current, 'optionalAccess', _68 => _68.getBoundingClientRect, 'call', _69 => _69(), 'access', _70 => _70.left]), () => ( 0)),
|
|
3451
|
+
top: (_nullishCoalesce(_optionalChain([menuButtonRef, 'access', _71 => _71.current, 'optionalAccess', _72 => _72.getBoundingClientRect, 'call', _73 => _73(), 'access', _74 => _74.bottom]), () => ( 0))) + 8
|
|
3114
3452
|
},
|
|
3115
3453
|
children: [
|
|
3116
3454
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
3117
3455
|
"button",
|
|
3118
3456
|
{
|
|
3119
3457
|
onClick: () => {
|
|
3120
|
-
_optionalChain([fileInputRef, 'access',
|
|
3458
|
+
_optionalChain([fileInputRef, 'access', _75 => _75.current, 'optionalAccess', _76 => _76.click, 'call', _77 => _77()]);
|
|
3121
3459
|
setShowMenu(false);
|
|
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",
|
|
@@ -3270,8 +3608,8 @@ var AptevaClient = class {
|
|
|
3270
3608
|
constructor(config) {
|
|
3271
3609
|
__publicField(this, "config");
|
|
3272
3610
|
this.config = {
|
|
3273
|
-
apiUrl: _nullishCoalesce(_optionalChain([config, 'optionalAccess',
|
|
3274
|
-
apiKey: _nullishCoalesce(_optionalChain([config, 'optionalAccess',
|
|
3611
|
+
apiUrl: _nullishCoalesce(_optionalChain([config, 'optionalAccess', _78 => _78.apiUrl]), () => ( "")),
|
|
3612
|
+
apiKey: _nullishCoalesce(_optionalChain([config, 'optionalAccess', _79 => _79.apiKey]), () => ( ""))
|
|
3275
3613
|
};
|
|
3276
3614
|
}
|
|
3277
3615
|
/**
|
|
@@ -3348,7 +3686,7 @@ var AptevaClient = class {
|
|
|
3348
3686
|
const error = await response.json().catch(() => ({ error: "Request failed" }));
|
|
3349
3687
|
throw new Error(error.error || `Request failed with status ${response.status}`);
|
|
3350
3688
|
}
|
|
3351
|
-
const reader = _optionalChain([response, 'access',
|
|
3689
|
+
const reader = _optionalChain([response, 'access', _80 => _80.body, 'optionalAccess', _81 => _81.getReader, 'call', _82 => _82()]);
|
|
3352
3690
|
if (!reader) {
|
|
3353
3691
|
throw new Error("Response body is not readable");
|
|
3354
3692
|
}
|
|
@@ -3366,7 +3704,7 @@ var AptevaClient = class {
|
|
|
3366
3704
|
if (line.startsWith("data: ")) {
|
|
3367
3705
|
const data = line.slice(6);
|
|
3368
3706
|
if (data === "[DONE]") {
|
|
3369
|
-
_optionalChain([onComplete, 'optionalCall',
|
|
3707
|
+
_optionalChain([onComplete, 'optionalCall', _83 => _83(threadId)]);
|
|
3370
3708
|
return;
|
|
3371
3709
|
}
|
|
3372
3710
|
try {
|
|
@@ -3381,10 +3719,10 @@ var AptevaClient = class {
|
|
|
3381
3719
|
}
|
|
3382
3720
|
}
|
|
3383
3721
|
}
|
|
3384
|
-
_optionalChain([onComplete, 'optionalCall',
|
|
3722
|
+
_optionalChain([onComplete, 'optionalCall', _84 => _84(threadId)]);
|
|
3385
3723
|
} catch (error) {
|
|
3386
3724
|
const err = error instanceof Error ? error : new Error("Unknown error");
|
|
3387
|
-
_optionalChain([onError, 'optionalCall',
|
|
3725
|
+
_optionalChain([onError, 'optionalCall', _85 => _85(err)]);
|
|
3388
3726
|
throw err;
|
|
3389
3727
|
}
|
|
3390
3728
|
}
|
|
@@ -3448,6 +3786,41 @@ var AptevaClient = class {
|
|
|
3448
3786
|
};
|
|
3449
3787
|
var aptevaClient = new AptevaClient();
|
|
3450
3788
|
|
|
3789
|
+
// src/components/Chat/PersistentWidgetPanel.tsx
|
|
3790
|
+
|
|
3791
|
+
|
|
3792
|
+
function PersistentWidgetPanel({ widgets, onAction }) {
|
|
3793
|
+
const [collapsed, setCollapsed] = _react.useState.call(void 0, false);
|
|
3794
|
+
if (widgets.length === 0) return null;
|
|
3795
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "apteva-persistent-panel border-b border-neutral-200 dark:border-neutral-700 bg-neutral-50 dark:bg-neutral-900", children: [
|
|
3796
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center justify-between px-3 py-1.5", children: [
|
|
3797
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-2", children: [
|
|
3798
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "w-1.5 h-1.5 rounded-full bg-emerald-500 animate-pulse" }),
|
|
3799
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-xs font-medium text-neutral-500 dark:text-neutral-400 uppercase tracking-wider", children: "Live" })
|
|
3800
|
+
] }),
|
|
3801
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
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__ */ _jsxruntime.jsx.call(void 0,
|
|
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__ */ _jsxruntime.jsx.call(void 0, "path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M19 9l-7 7-7-7" })
|
|
3815
|
+
}
|
|
3816
|
+
)
|
|
3817
|
+
}
|
|
3818
|
+
)
|
|
3819
|
+
] }),
|
|
3820
|
+
!collapsed && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "px-3 pb-3 flex flex-col gap-3", children: widgets.map((widget) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, WidgetRenderer, { widget, onAction }, widget.id)) })
|
|
3821
|
+
] });
|
|
3822
|
+
}
|
|
3823
|
+
|
|
3451
3824
|
// src/components/Chat/Chat.tsx
|
|
3452
3825
|
|
|
3453
3826
|
var Chat = _react.forwardRef.call(void 0, function Chat2({
|
|
@@ -3490,6 +3863,8 @@ var Chat = _react.forwardRef.call(void 0, 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,
|
|
@@ -3515,6 +3890,30 @@ var Chat = _react.forwardRef.call(void 0, function Chat2({
|
|
|
3515
3890
|
const [internalPlanMode, setInternalPlanMode] = _react.useState.call(void 0, planMode);
|
|
3516
3891
|
const [showSettingsMenu, setShowSettingsMenu] = _react.useState.call(void 0, false);
|
|
3517
3892
|
const fileInputRef = _react.useRef.call(void 0, null);
|
|
3893
|
+
const [persistentWidgets, setPersistentWidgets] = _react.useState.call(void 0, /* @__PURE__ */ new Map());
|
|
3894
|
+
const updatePersistentWidgets = _react.useCallback.call(void 0, (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
|
+
_react.useEffect.call(void 0, () => {
|
|
3913
|
+
updatePersistentWidgets(messages);
|
|
3914
|
+
}, [messages, updatePersistentWidgets]);
|
|
3915
|
+
const persistentWidgetList = _react.useMemo.call(void 0, () => Array.from(persistentWidgets.values()), [persistentWidgets]);
|
|
3916
|
+
const persistentWidgetIds = _react.useMemo.call(void 0, () => new Set(persistentWidgets.keys()), [persistentWidgets]);
|
|
3518
3917
|
const handleSendMessageRef = _react.useRef.call(void 0, null);
|
|
3519
3918
|
_react.useImperativeHandle.call(void 0, ref, () => ({
|
|
3520
3919
|
sendMessage: async (text) => {
|
|
@@ -3546,7 +3945,7 @@ ${widgetContext}` : widgetContext;
|
|
|
3546
3945
|
}, [apiUrl, apiKey]);
|
|
3547
3946
|
_react.useEffect.call(void 0, () => {
|
|
3548
3947
|
if (threadId) {
|
|
3549
|
-
_optionalChain([onThreadChange, 'optionalCall',
|
|
3948
|
+
_optionalChain([onThreadChange, 'optionalCall', _86 => _86(threadId)]);
|
|
3550
3949
|
}
|
|
3551
3950
|
}, [threadId, onThreadChange]);
|
|
3552
3951
|
_react.useEffect.call(void 0, () => {
|
|
@@ -3564,7 +3963,7 @@ ${widgetContext}` : widgetContext;
|
|
|
3564
3963
|
}, [showSettingsMenu]);
|
|
3565
3964
|
const handleModeChange = (newMode) => {
|
|
3566
3965
|
setMode(newMode);
|
|
3567
|
-
_optionalChain([onModeChange, 'optionalCall',
|
|
3966
|
+
_optionalChain([onModeChange, 'optionalCall', _87 => _87(newMode)]);
|
|
3568
3967
|
if (newMode === "command") {
|
|
3569
3968
|
setCommandState("idle");
|
|
3570
3969
|
setCommandResult(null);
|
|
@@ -3589,7 +3988,7 @@ ${widgetContext}` : widgetContext;
|
|
|
3589
3988
|
metadata: hasFiles ? { attachments } : void 0
|
|
3590
3989
|
};
|
|
3591
3990
|
setMessages((prev) => [...prev, userMessage]);
|
|
3592
|
-
_optionalChain([onMessageSent, 'optionalCall',
|
|
3991
|
+
_optionalChain([onMessageSent, 'optionalCall', _88 => _88(userMessage)]);
|
|
3593
3992
|
}
|
|
3594
3993
|
setIsLoading(true);
|
|
3595
3994
|
try {
|
|
@@ -3657,7 +4056,7 @@ ${widgetContext}` : widgetContext;
|
|
|
3657
4056
|
responseThreadId = chunk.thread_id;
|
|
3658
4057
|
if (!currentThreadId) {
|
|
3659
4058
|
setCurrentThreadId(chunk.thread_id);
|
|
3660
|
-
_optionalChain([onThreadChange, 'optionalCall',
|
|
4059
|
+
_optionalChain([onThreadChange, 'optionalCall', _89 => _89(chunk.thread_id)]);
|
|
3661
4060
|
}
|
|
3662
4061
|
}
|
|
3663
4062
|
break;
|
|
@@ -3689,7 +4088,7 @@ ${widgetContext}` : widgetContext;
|
|
|
3689
4088
|
contentSegments.push({ type: "tool", id: chunk.tool_id, name: displayName, status: "preparing" });
|
|
3690
4089
|
toolInputBuffers[chunk.tool_id] = "";
|
|
3691
4090
|
setChatToolName(displayName);
|
|
3692
|
-
_optionalChain([onToolCall, 'optionalCall',
|
|
4091
|
+
_optionalChain([onToolCall, 'optionalCall', _90 => _90(chunk.tool_name, chunk.tool_id)]);
|
|
3693
4092
|
updateMessage();
|
|
3694
4093
|
}
|
|
3695
4094
|
break;
|
|
@@ -3749,7 +4148,7 @@ ${widgetContext}` : widgetContext;
|
|
|
3749
4148
|
toolSegment.result = chunk.content;
|
|
3750
4149
|
toolSegment.status = "completed";
|
|
3751
4150
|
toolSegment.isReceiving = false;
|
|
3752
|
-
_optionalChain([onToolResult, 'optionalCall',
|
|
4151
|
+
_optionalChain([onToolResult, 'optionalCall', _91 => _91(toolSegment.name, chunk.content)]);
|
|
3753
4152
|
}
|
|
3754
4153
|
setChatToolName(null);
|
|
3755
4154
|
updateMessage();
|
|
@@ -3793,7 +4192,7 @@ ${widgetContext}` : widgetContext;
|
|
|
3793
4192
|
});
|
|
3794
4193
|
if (threadId2 && threadId2 !== currentThreadId) {
|
|
3795
4194
|
setCurrentThreadId(threadId2);
|
|
3796
|
-
_optionalChain([onThreadChange, 'optionalCall',
|
|
4195
|
+
_optionalChain([onThreadChange, 'optionalCall', _92 => _92(threadId2)]);
|
|
3797
4196
|
}
|
|
3798
4197
|
setIsLoading(false);
|
|
3799
4198
|
setCurrentRequestId(null);
|
|
@@ -3817,7 +4216,7 @@ ${widgetContext}` : widgetContext;
|
|
|
3817
4216
|
setIsLoading(false);
|
|
3818
4217
|
setCurrentRequestId(null);
|
|
3819
4218
|
setChatToolName(null);
|
|
3820
|
-
_optionalChain([onError, 'optionalCall',
|
|
4219
|
+
_optionalChain([onError, 'optionalCall', _93 => _93(error)]);
|
|
3821
4220
|
}
|
|
3822
4221
|
);
|
|
3823
4222
|
}
|
|
@@ -3830,7 +4229,7 @@ ${widgetContext}` : widgetContext;
|
|
|
3830
4229
|
metadata: { error: true }
|
|
3831
4230
|
};
|
|
3832
4231
|
setMessages((prev) => [...prev, errorMessage]);
|
|
3833
|
-
_optionalChain([onError, 'optionalCall',
|
|
4232
|
+
_optionalChain([onError, 'optionalCall', _94 => _94(error instanceof Error ? error : new Error("Unknown error"))]);
|
|
3834
4233
|
} finally {
|
|
3835
4234
|
setIsLoading(false);
|
|
3836
4235
|
}
|
|
@@ -3876,7 +4275,7 @@ ${planningInstruction}` : planningInstruction;
|
|
|
3876
4275
|
const error = err instanceof Error ? err : new Error("Failed to generate plan");
|
|
3877
4276
|
setCommandError(error);
|
|
3878
4277
|
setCommandState("error");
|
|
3879
|
-
_optionalChain([onError, 'optionalCall',
|
|
4278
|
+
_optionalChain([onError, 'optionalCall', _95 => _95(error)]);
|
|
3880
4279
|
}
|
|
3881
4280
|
}
|
|
3882
4281
|
return;
|
|
@@ -3909,12 +4308,12 @@ ${planningInstruction}` : planningInstruction;
|
|
|
3909
4308
|
setCommandResult(result);
|
|
3910
4309
|
setCommandState("success");
|
|
3911
4310
|
setProgress(100);
|
|
3912
|
-
_optionalChain([onComplete, 'optionalCall',
|
|
4311
|
+
_optionalChain([onComplete, 'optionalCall', _96 => _96(result)]);
|
|
3913
4312
|
},
|
|
3914
4313
|
(error) => {
|
|
3915
4314
|
setCommandError(error);
|
|
3916
4315
|
setCommandState("error");
|
|
3917
|
-
_optionalChain([onError, 'optionalCall',
|
|
4316
|
+
_optionalChain([onError, 'optionalCall', _97 => _97(error)]);
|
|
3918
4317
|
}
|
|
3919
4318
|
);
|
|
3920
4319
|
} else {
|
|
@@ -3927,7 +4326,7 @@ ${planningInstruction}` : planningInstruction;
|
|
|
3927
4326
|
setCommandResult(result);
|
|
3928
4327
|
setCommandState("success");
|
|
3929
4328
|
setProgress(100);
|
|
3930
|
-
_optionalChain([onComplete, 'optionalCall',
|
|
4329
|
+
_optionalChain([onComplete, 'optionalCall', _98 => _98(result)]);
|
|
3931
4330
|
}
|
|
3932
4331
|
} else {
|
|
3933
4332
|
const commandInstruction = `CRITICAL COMMAND MODE: Maximum 10 words per response. Execute the command immediately. Make reasonable assumptions based on context. Use sensible defaults for missing details. DO NOT ask questions unless something is truly impossible without user input (e.g., missing required password). State what you're doing or the result. Examples: "Analyzing customer data from last quarter..." or "Created 5 new database entries successfully" or "Search complete: found 12 matching results". NO greetings, NO filler words, NO clarification requests. Action/result only.`;
|
|
@@ -3957,16 +4356,16 @@ ${commandInstruction}` : commandInstruction;
|
|
|
3957
4356
|
const displayName = chunk.tool_display_name || chunk.tool_name;
|
|
3958
4357
|
lastToolName = chunk.tool_name;
|
|
3959
4358
|
setCurrentToolName(displayName);
|
|
3960
|
-
_optionalChain([onToolCall, 'optionalCall',
|
|
4359
|
+
_optionalChain([onToolCall, 'optionalCall', _99 => _99(chunk.tool_name, chunk.tool_id || "")]);
|
|
3961
4360
|
accumulatedContent = "";
|
|
3962
4361
|
setStreamedContent("");
|
|
3963
4362
|
} else if (chunk.type === "tool_result") {
|
|
3964
|
-
_optionalChain([onToolResult, 'optionalCall',
|
|
4363
|
+
_optionalChain([onToolResult, 'optionalCall', _100 => _100(lastToolName, chunk.content)]);
|
|
3965
4364
|
setCurrentToolName(null);
|
|
3966
4365
|
} else if (chunk.type === "thread_id" && chunk.thread_id) {
|
|
3967
4366
|
if (!currentThreadId) {
|
|
3968
4367
|
setCurrentThreadId(chunk.thread_id);
|
|
3969
|
-
_optionalChain([onThreadChange, 'optionalCall',
|
|
4368
|
+
_optionalChain([onThreadChange, 'optionalCall', _101 => _101(chunk.thread_id)]);
|
|
3970
4369
|
}
|
|
3971
4370
|
} else if (chunk.type === "request_id" && chunk.request_id) {
|
|
3972
4371
|
setCurrentRequestId(chunk.request_id);
|
|
@@ -3982,13 +4381,13 @@ ${commandInstruction}` : commandInstruction;
|
|
|
3982
4381
|
setCommandState("success");
|
|
3983
4382
|
setProgress(100);
|
|
3984
4383
|
setCurrentRequestId(null);
|
|
3985
|
-
_optionalChain([onComplete, 'optionalCall',
|
|
4384
|
+
_optionalChain([onComplete, 'optionalCall', _102 => _102(result)]);
|
|
3986
4385
|
},
|
|
3987
4386
|
(error) => {
|
|
3988
4387
|
setCommandError(error);
|
|
3989
4388
|
setCommandState("error");
|
|
3990
4389
|
setCurrentRequestId(null);
|
|
3991
|
-
_optionalChain([onError, 'optionalCall',
|
|
4390
|
+
_optionalChain([onError, 'optionalCall', _103 => _103(error)]);
|
|
3992
4391
|
}
|
|
3993
4392
|
);
|
|
3994
4393
|
} else {
|
|
@@ -4008,14 +4407,14 @@ ${commandInstruction}` : commandInstruction;
|
|
|
4008
4407
|
setCommandResult(result);
|
|
4009
4408
|
setCommandState("success");
|
|
4010
4409
|
setProgress(100);
|
|
4011
|
-
_optionalChain([onComplete, 'optionalCall',
|
|
4410
|
+
_optionalChain([onComplete, 'optionalCall', _104 => _104(result)]);
|
|
4012
4411
|
}
|
|
4013
4412
|
}
|
|
4014
4413
|
} catch (err) {
|
|
4015
4414
|
const error = err instanceof Error ? err : new Error("Unknown error");
|
|
4016
4415
|
setCommandError(error);
|
|
4017
4416
|
setCommandState("error");
|
|
4018
|
-
_optionalChain([onError, 'optionalCall',
|
|
4417
|
+
_optionalChain([onError, 'optionalCall', _105 => _105(error)]);
|
|
4019
4418
|
}
|
|
4020
4419
|
};
|
|
4021
4420
|
const resetCommand = () => {
|
|
@@ -4074,6 +4473,7 @@ ${planToExecute}`;
|
|
|
4074
4473
|
] })
|
|
4075
4474
|
] }) }),
|
|
4076
4475
|
mode === "chat" && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
4476
|
+
persistentWidgetList.length > 0 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, PersistentWidgetPanel, { widgets: persistentWidgetList, onAction }),
|
|
4077
4477
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4078
4478
|
MessageList,
|
|
4079
4479
|
{
|
|
@@ -4087,7 +4487,9 @@ ${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
4495
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
@@ -4111,8 +4513,8 @@ ${planToExecute}`;
|
|
|
4111
4513
|
executeCommand(text, files);
|
|
4112
4514
|
},
|
|
4113
4515
|
state: commandState,
|
|
4114
|
-
response: _optionalChain([commandResult, 'optionalAccess',
|
|
4115
|
-
error: _optionalChain([commandError, 'optionalAccess',
|
|
4516
|
+
response: _optionalChain([commandResult, 'optionalAccess', _106 => _106.data, 'optionalAccess', _107 => _107.summary]) || _optionalChain([commandResult, 'optionalAccess', _108 => _108.message]),
|
|
4517
|
+
error: _optionalChain([commandError, 'optionalAccess', _109 => _109.message]),
|
|
4116
4518
|
plan,
|
|
4117
4519
|
streamedContent,
|
|
4118
4520
|
toolName: currentToolName,
|
|
@@ -4280,13 +4682,13 @@ ${planningInstruction}` : planningInstruction;
|
|
|
4280
4682
|
const error2 = err instanceof Error ? err : new Error("Failed to generate plan");
|
|
4281
4683
|
setError(error2);
|
|
4282
4684
|
setState("error");
|
|
4283
|
-
_optionalChain([onError, 'optionalCall',
|
|
4685
|
+
_optionalChain([onError, 'optionalCall', _110 => _110(error2)]);
|
|
4284
4686
|
});
|
|
4285
4687
|
} catch (err) {
|
|
4286
4688
|
const error2 = err instanceof Error ? err : new Error("Failed to generate plan");
|
|
4287
4689
|
setError(error2);
|
|
4288
4690
|
setState("error");
|
|
4289
|
-
_optionalChain([onError, 'optionalCall',
|
|
4691
|
+
_optionalChain([onError, 'optionalCall', _111 => _111(error2)]);
|
|
4290
4692
|
}
|
|
4291
4693
|
}
|
|
4292
4694
|
return;
|
|
@@ -4297,7 +4699,7 @@ ${planningInstruction}` : planningInstruction;
|
|
|
4297
4699
|
setStreamedContent("");
|
|
4298
4700
|
setCommand("");
|
|
4299
4701
|
setUploadedFiles([]);
|
|
4300
|
-
_optionalChain([onStart, 'optionalCall',
|
|
4702
|
+
_optionalChain([onStart, 'optionalCall', _112 => _112()]);
|
|
4301
4703
|
try {
|
|
4302
4704
|
if (useMock) {
|
|
4303
4705
|
if (enableStreaming) {
|
|
@@ -4308,16 +4710,16 @@ ${planningInstruction}` : planningInstruction;
|
|
|
4308
4710
|
if (chunk.type === "token" && chunk.content) {
|
|
4309
4711
|
accumulatedContent += chunk.content;
|
|
4310
4712
|
setStreamedContent(accumulatedContent);
|
|
4311
|
-
_optionalChain([onChunk, 'optionalCall',
|
|
4713
|
+
_optionalChain([onChunk, 'optionalCall', _113 => _113(chunk.content)]);
|
|
4312
4714
|
const estimatedProgress = Math.min(Math.round(accumulatedContent.length / 10), 90);
|
|
4313
4715
|
setProgress(estimatedProgress);
|
|
4314
|
-
_optionalChain([onProgress, 'optionalCall',
|
|
4716
|
+
_optionalChain([onProgress, 'optionalCall', _114 => _114(estimatedProgress)]);
|
|
4315
4717
|
} else if (chunk.type === "widget" && chunk.widget) {
|
|
4316
4718
|
const widget = chunk.widget;
|
|
4317
4719
|
setResult((prev) => ({
|
|
4318
4720
|
success: true,
|
|
4319
|
-
data: _optionalChain([prev, 'optionalAccess',
|
|
4320
|
-
widgets: [..._optionalChain([prev, 'optionalAccess',
|
|
4721
|
+
data: _optionalChain([prev, 'optionalAccess', _115 => _115.data]) || {},
|
|
4722
|
+
widgets: [..._optionalChain([prev, 'optionalAccess', _116 => _116.widgets]) || [], widget],
|
|
4321
4723
|
message: accumulatedContent || "Command executed successfully"
|
|
4322
4724
|
}));
|
|
4323
4725
|
}
|
|
@@ -4337,19 +4739,19 @@ ${planningInstruction}` : planningInstruction;
|
|
|
4337
4739
|
setResult(result2);
|
|
4338
4740
|
setState("success");
|
|
4339
4741
|
setProgress(100);
|
|
4340
|
-
_optionalChain([onComplete, 'optionalCall',
|
|
4742
|
+
_optionalChain([onComplete, 'optionalCall', _117 => _117(result2)]);
|
|
4341
4743
|
},
|
|
4342
4744
|
(error2) => {
|
|
4343
4745
|
setError(error2);
|
|
4344
4746
|
setState("error");
|
|
4345
|
-
_optionalChain([onError, 'optionalCall',
|
|
4747
|
+
_optionalChain([onError, 'optionalCall', _118 => _118(error2)]);
|
|
4346
4748
|
}
|
|
4347
4749
|
);
|
|
4348
4750
|
} else {
|
|
4349
4751
|
const progressInterval = setInterval(() => {
|
|
4350
4752
|
setProgress((prev) => {
|
|
4351
4753
|
const next = Math.min(prev + 10, 90);
|
|
4352
|
-
_optionalChain([onProgress, 'optionalCall',
|
|
4754
|
+
_optionalChain([onProgress, 'optionalCall', _119 => _119(next)]);
|
|
4353
4755
|
return next;
|
|
4354
4756
|
});
|
|
4355
4757
|
}, 200);
|
|
@@ -4373,7 +4775,7 @@ ${planningInstruction}` : planningInstruction;
|
|
|
4373
4775
|
setResult(result2);
|
|
4374
4776
|
setState("success");
|
|
4375
4777
|
setProgress(100);
|
|
4376
|
-
_optionalChain([onComplete, 'optionalCall',
|
|
4778
|
+
_optionalChain([onComplete, 'optionalCall', _120 => _120(result2)]);
|
|
4377
4779
|
}
|
|
4378
4780
|
} else {
|
|
4379
4781
|
if (enableStreaming) {
|
|
@@ -4419,16 +4821,16 @@ ${commandInstruction}` : commandInstruction;
|
|
|
4419
4821
|
if (chunk.type === "token" && chunk.content) {
|
|
4420
4822
|
accumulatedContent += chunk.content;
|
|
4421
4823
|
setStreamedContent(accumulatedContent);
|
|
4422
|
-
_optionalChain([onChunk, 'optionalCall',
|
|
4824
|
+
_optionalChain([onChunk, 'optionalCall', _121 => _121(chunk.content)]);
|
|
4423
4825
|
const estimatedProgress = Math.min(Math.round(accumulatedContent.length / 10), 90);
|
|
4424
4826
|
setProgress(estimatedProgress);
|
|
4425
|
-
_optionalChain([onProgress, 'optionalCall',
|
|
4827
|
+
_optionalChain([onProgress, 'optionalCall', _122 => _122(estimatedProgress)]);
|
|
4426
4828
|
} else if (chunk.type === "widget" && chunk.widget) {
|
|
4427
4829
|
const widget = chunk.widget;
|
|
4428
4830
|
setResult((prev) => ({
|
|
4429
4831
|
success: true,
|
|
4430
|
-
data: _optionalChain([prev, 'optionalAccess',
|
|
4431
|
-
widgets: [..._optionalChain([prev, 'optionalAccess',
|
|
4832
|
+
data: _optionalChain([prev, 'optionalAccess', _123 => _123.data]) || {},
|
|
4833
|
+
widgets: [..._optionalChain([prev, 'optionalAccess', _124 => _124.widgets]) || [], widget],
|
|
4432
4834
|
message: accumulatedContent || "Command executed successfully"
|
|
4433
4835
|
}));
|
|
4434
4836
|
}
|
|
@@ -4448,20 +4850,20 @@ ${commandInstruction}` : commandInstruction;
|
|
|
4448
4850
|
setResult(result2);
|
|
4449
4851
|
setState("success");
|
|
4450
4852
|
setProgress(100);
|
|
4451
|
-
_optionalChain([onComplete, 'optionalCall',
|
|
4853
|
+
_optionalChain([onComplete, 'optionalCall', _125 => _125(result2)]);
|
|
4452
4854
|
},
|
|
4453
4855
|
(error2) => {
|
|
4454
4856
|
const err = error2 instanceof Error ? error2 : new Error("Unknown error");
|
|
4455
4857
|
setError(err);
|
|
4456
4858
|
setState("error");
|
|
4457
|
-
_optionalChain([onError, 'optionalCall',
|
|
4859
|
+
_optionalChain([onError, 'optionalCall', _126 => _126(err)]);
|
|
4458
4860
|
}
|
|
4459
4861
|
);
|
|
4460
4862
|
} else {
|
|
4461
4863
|
const progressInterval = setInterval(() => {
|
|
4462
4864
|
setProgress((prev) => {
|
|
4463
4865
|
const next = Math.min(prev + 10, 90);
|
|
4464
|
-
_optionalChain([onProgress, 'optionalCall',
|
|
4866
|
+
_optionalChain([onProgress, 'optionalCall', _127 => _127(next)]);
|
|
4465
4867
|
return next;
|
|
4466
4868
|
});
|
|
4467
4869
|
}, 200);
|
|
@@ -4517,14 +4919,14 @@ ${commandInstruction}` : commandInstruction;
|
|
|
4517
4919
|
setResult(result2);
|
|
4518
4920
|
setState("success");
|
|
4519
4921
|
setProgress(100);
|
|
4520
|
-
_optionalChain([onComplete, 'optionalCall',
|
|
4922
|
+
_optionalChain([onComplete, 'optionalCall', _128 => _128(result2)]);
|
|
4521
4923
|
}
|
|
4522
4924
|
}
|
|
4523
4925
|
} catch (err) {
|
|
4524
4926
|
const error2 = err instanceof Error ? err : new Error("Unknown error");
|
|
4525
4927
|
setError(error2);
|
|
4526
4928
|
setState("error");
|
|
4527
|
-
_optionalChain([onError, 'optionalCall',
|
|
4929
|
+
_optionalChain([onError, 'optionalCall', _129 => _129(error2)]);
|
|
4528
4930
|
}
|
|
4529
4931
|
};
|
|
4530
4932
|
const resetCommand = () => {
|
|
@@ -4557,14 +4959,14 @@ ${planToExecute}`;
|
|
|
4557
4959
|
};
|
|
4558
4960
|
const handleFileSelect = async (e) => {
|
|
4559
4961
|
if (e.target.files && e.target.files.length > 0) {
|
|
4560
|
-
_optionalChain([onFileUpload, 'optionalCall',
|
|
4962
|
+
_optionalChain([onFileUpload, 'optionalCall', _130 => _130(e.target.files)]);
|
|
4561
4963
|
const files = [];
|
|
4562
4964
|
for (let i = 0; i < e.target.files.length; i++) {
|
|
4563
4965
|
const file = e.target.files[i];
|
|
4564
4966
|
const reader = new FileReader();
|
|
4565
4967
|
await new Promise((resolve) => {
|
|
4566
4968
|
reader.onload = (event) => {
|
|
4567
|
-
if (_optionalChain([event, 'access',
|
|
4969
|
+
if (_optionalChain([event, 'access', _131 => _131.target, 'optionalAccess', _132 => _132.result])) {
|
|
4568
4970
|
const fullDataUrl = event.target.result;
|
|
4569
4971
|
const base64Data = fullDataUrl.split(",")[1];
|
|
4570
4972
|
if (file.type.startsWith("image/")) {
|
|
@@ -4658,7 +5060,7 @@ ${planToExecute}`;
|
|
|
4658
5060
|
enableFileUpload && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4659
5061
|
"button",
|
|
4660
5062
|
{
|
|
4661
|
-
onClick: () => _optionalChain([fileInputRef, 'access',
|
|
5063
|
+
onClick: () => _optionalChain([fileInputRef, 'access', _133 => _133.current, 'optionalAccess', _134 => _134.click, 'call', _135 => _135()]),
|
|
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
5066
|
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "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)" }) })
|
|
@@ -4877,7 +5279,7 @@ ${planToExecute}`;
|
|
|
4877
5279
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "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__ */ _jsxruntime.jsx.call(void 0, "path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" }) }),
|
|
4878
5280
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { children: [
|
|
4879
5281
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h3", { className: "text-sm font-semibold text-red-800 dark:text-red-400", children: "Error" }),
|
|
4880
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-red-700 dark:text-red-300 text-sm mt-1", children: _optionalChain([error, 'optionalAccess',
|
|
5282
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-red-700 dark:text-red-300 text-sm mt-1", children: _optionalChain([error, 'optionalAccess', _136 => _136.message]) })
|
|
4881
5283
|
] })
|
|
4882
5284
|
] }) }),
|
|
4883
5285
|
allowInput && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
@@ -4905,7 +5307,7 @@ ${planToExecute}`;
|
|
|
4905
5307
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-green-700 dark:text-green-300 text-sm", children: "Command executed successfully" })
|
|
4906
5308
|
] })
|
|
4907
5309
|
] }),
|
|
4908
|
-
_optionalChain([result, 'access',
|
|
5310
|
+
_optionalChain([result, 'access', _137 => _137.data, 'optionalAccess', _138 => _138.summary]) && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "text-neutral-700 dark:text-neutral-300 text-sm leading-relaxed whitespace-pre-line", children: result.data.summary }),
|
|
4909
5311
|
result.widgets && result.widgets.length > 0 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "space-y-3", children: result.widgets.map((widget) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4910
5312
|
WidgetRenderer,
|
|
4911
5313
|
{
|
|
@@ -4956,7 +5358,7 @@ ${planToExecute}`;
|
|
|
4956
5358
|
enableFileUpload && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4957
5359
|
"button",
|
|
4958
5360
|
{
|
|
4959
|
-
onClick: () => _optionalChain([fileInputRef, 'access',
|
|
5361
|
+
onClick: () => _optionalChain([fileInputRef, 'access', _139 => _139.current, 'optionalAccess', _140 => _140.click, 'call', _141 => _141()]),
|
|
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
5364
|
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "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)" }) })
|
|
@@ -5142,25 +5544,25 @@ function Prompt({
|
|
|
5142
5544
|
const newValue = e.target.value;
|
|
5143
5545
|
if (!maxLength || newValue.length <= maxLength) {
|
|
5144
5546
|
setValue(newValue);
|
|
5145
|
-
_optionalChain([onChange, 'optionalCall',
|
|
5547
|
+
_optionalChain([onChange, 'optionalCall', _142 => _142(newValue)]);
|
|
5146
5548
|
}
|
|
5147
5549
|
};
|
|
5148
5550
|
const handleSubmit = async () => {
|
|
5149
5551
|
if (value.length < minLength) return;
|
|
5150
|
-
_optionalChain([onSubmit, 'optionalCall',
|
|
5552
|
+
_optionalChain([onSubmit, 'optionalCall', _143 => _143(value)]);
|
|
5151
5553
|
setIsLoading(true);
|
|
5152
5554
|
try {
|
|
5153
5555
|
if (useMock) {
|
|
5154
5556
|
await new Promise((resolve) => setTimeout(resolve, 1500));
|
|
5155
5557
|
const mockResult = `Enhanced version: ${value} [AI-generated content]`;
|
|
5156
|
-
_optionalChain([onResult, 'optionalCall',
|
|
5558
|
+
_optionalChain([onResult, 'optionalCall', _144 => _144(mockResult)]);
|
|
5157
5559
|
setValue("");
|
|
5158
5560
|
} else {
|
|
5159
5561
|
const response = await aptevaClient.chat({
|
|
5160
5562
|
agent_id: agentId,
|
|
5161
5563
|
message: value
|
|
5162
5564
|
});
|
|
5163
|
-
_optionalChain([onResult, 'optionalCall',
|
|
5565
|
+
_optionalChain([onResult, 'optionalCall', _145 => _145(response.message)]);
|
|
5164
5566
|
setValue("");
|
|
5165
5567
|
}
|
|
5166
5568
|
} catch (error) {
|
|
@@ -5255,7 +5657,7 @@ function Stream({
|
|
|
5255
5657
|
}, [autoStart]);
|
|
5256
5658
|
const startStreaming = async () => {
|
|
5257
5659
|
setIsStreaming(true);
|
|
5258
|
-
_optionalChain([onStart, 'optionalCall',
|
|
5660
|
+
_optionalChain([onStart, 'optionalCall', _146 => _146()]);
|
|
5259
5661
|
try {
|
|
5260
5662
|
if (useMock) {
|
|
5261
5663
|
const mockText = "This is a simulated streaming response from the AI agent. In a real implementation, this would stream data from your backend API. The text appears word by word to simulate the streaming effect. You can customize the typing speed and styling based on your needs.";
|
|
@@ -5263,13 +5665,13 @@ function Stream({
|
|
|
5263
5665
|
mockText,
|
|
5264
5666
|
(chunk) => {
|
|
5265
5667
|
setText((prev) => prev + chunk);
|
|
5266
|
-
_optionalChain([onChunk, 'optionalCall',
|
|
5668
|
+
_optionalChain([onChunk, 'optionalCall', _147 => _147(chunk)]);
|
|
5267
5669
|
},
|
|
5268
5670
|
typingSpeed
|
|
5269
5671
|
);
|
|
5270
5672
|
setIsComplete(true);
|
|
5271
5673
|
setIsStreaming(false);
|
|
5272
|
-
_optionalChain([onComplete, 'optionalCall',
|
|
5674
|
+
_optionalChain([onComplete, 'optionalCall', _148 => _148(text + mockText)]);
|
|
5273
5675
|
} else {
|
|
5274
5676
|
let accumulatedText = "";
|
|
5275
5677
|
await aptevaClient.chatStream(
|
|
@@ -5282,24 +5684,24 @@ function Stream({
|
|
|
5282
5684
|
if (chunk.type === "token" && chunk.content) {
|
|
5283
5685
|
accumulatedText += chunk.content;
|
|
5284
5686
|
setText(accumulatedText);
|
|
5285
|
-
_optionalChain([onChunk, 'optionalCall',
|
|
5687
|
+
_optionalChain([onChunk, 'optionalCall', _149 => _149(chunk.content)]);
|
|
5286
5688
|
}
|
|
5287
5689
|
},
|
|
5288
5690
|
() => {
|
|
5289
5691
|
setIsComplete(true);
|
|
5290
5692
|
setIsStreaming(false);
|
|
5291
|
-
_optionalChain([onComplete, 'optionalCall',
|
|
5693
|
+
_optionalChain([onComplete, 'optionalCall', _150 => _150(accumulatedText)]);
|
|
5292
5694
|
},
|
|
5293
5695
|
(error) => {
|
|
5294
5696
|
const err = error instanceof Error ? error : new Error("Streaming error");
|
|
5295
|
-
_optionalChain([onError, 'optionalCall',
|
|
5697
|
+
_optionalChain([onError, 'optionalCall', _151 => _151(err)]);
|
|
5296
5698
|
setIsStreaming(false);
|
|
5297
5699
|
}
|
|
5298
5700
|
);
|
|
5299
5701
|
}
|
|
5300
5702
|
} catch (error) {
|
|
5301
5703
|
const err = error instanceof Error ? error : new Error("Streaming error");
|
|
5302
|
-
_optionalChain([onError, 'optionalCall',
|
|
5704
|
+
_optionalChain([onError, 'optionalCall', _152 => _152(err)]);
|
|
5303
5705
|
setIsStreaming(false);
|
|
5304
5706
|
}
|
|
5305
5707
|
};
|
|
@@ -5391,7 +5793,7 @@ function ThreadList({
|
|
|
5391
5793
|
}) {
|
|
5392
5794
|
const [searchQuery, setSearchQuery] = _react.useState.call(void 0, "");
|
|
5393
5795
|
const filteredThreads = threads.filter(
|
|
5394
|
-
(thread) => thread.title.toLowerCase().includes(searchQuery.toLowerCase()) || _optionalChain([thread, 'access',
|
|
5796
|
+
(thread) => thread.title.toLowerCase().includes(searchQuery.toLowerCase()) || _optionalChain([thread, 'access', _153 => _153.preview, 'optionalAccess', _154 => _154.toLowerCase, 'call', _155 => _155(), 'access', _156 => _156.includes, 'call', _157 => _157(searchQuery.toLowerCase())])
|
|
5395
5797
|
);
|
|
5396
5798
|
const groupedThreads = groupBy === "date" ? groupThreadsByDate(filteredThreads) : { All: filteredThreads };
|
|
5397
5799
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-col h-full", children: [
|
|
@@ -5413,8 +5815,8 @@ function ThreadList({
|
|
|
5413
5815
|
{
|
|
5414
5816
|
thread,
|
|
5415
5817
|
isActive: thread.id === currentThreadId,
|
|
5416
|
-
onSelect: () => _optionalChain([onThreadSelect, 'optionalCall',
|
|
5417
|
-
onDelete: () => _optionalChain([onThreadDelete, 'optionalCall',
|
|
5818
|
+
onSelect: () => _optionalChain([onThreadSelect, 'optionalCall', _158 => _158(thread.id)]),
|
|
5819
|
+
onDelete: () => _optionalChain([onThreadDelete, 'optionalCall', _159 => _159(thread.id)])
|
|
5418
5820
|
},
|
|
5419
5821
|
thread.id
|
|
5420
5822
|
))
|
|
@@ -5476,7 +5878,7 @@ function Threads({
|
|
|
5476
5878
|
threads.slice(0, 5).map((thread) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
5477
5879
|
"button",
|
|
5478
5880
|
{
|
|
5479
|
-
onClick: () => _optionalChain([onThreadSelect, 'optionalCall',
|
|
5881
|
+
onClick: () => _optionalChain([onThreadSelect, 'optionalCall', _160 => _160(thread.id)]),
|
|
5480
5882
|
className: cn(
|
|
5481
5883
|
"px-4 py-2 whitespace-nowrap font-medium transition-colors",
|
|
5482
5884
|
thread.id === currentThreadId ? "border-b-2 border-apteva-500 text-apteva-500" : "text-neutral-600 hover:text-neutral-900"
|
|
@@ -5661,7 +6063,7 @@ function TabsLayout({ node, renderNode }) {
|
|
|
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 };
|
|
5664
|
-
if (node.type === "widget" && _optionalChain([node, 'access',
|
|
6066
|
+
if (node.type === "widget" && _optionalChain([node, 'access', _161 => _161.props, 'optionalAccess', _162 => _162.widget])) {
|
|
5665
6067
|
node.type = node.props.widget;
|
|
5666
6068
|
const { widget: _, ...rest } = node.props;
|
|
5667
6069
|
node.props = rest;
|
|
@@ -5799,10 +6201,10 @@ function AutoInterface({
|
|
|
5799
6201
|
].filter(Boolean).join("\n\n");
|
|
5800
6202
|
const updateInterface = _react.useCallback.call(void 0, (newSpec) => {
|
|
5801
6203
|
setInterfaceSpec(newSpec);
|
|
5802
|
-
_optionalChain([onInterfaceChange, 'optionalCall',
|
|
6204
|
+
_optionalChain([onInterfaceChange, 'optionalCall', _163 => _163(newSpec)]);
|
|
5803
6205
|
}, [onInterfaceChange]);
|
|
5804
6206
|
const handleAction = _react.useCallback.call(void 0, (action) => {
|
|
5805
|
-
_optionalChain([onAction, 'optionalCall',
|
|
6207
|
+
_optionalChain([onAction, 'optionalCall', _164 => _164(action)]);
|
|
5806
6208
|
if (chatRef.current) {
|
|
5807
6209
|
chatRef.current.sendMessage(
|
|
5808
6210
|
`[Action: ${action.type} on widget ${action.widgetId || "unknown"}. Payload: ${JSON.stringify(action.payload)}]`
|
|
@@ -5810,7 +6212,7 @@ function AutoInterface({
|
|
|
5810
6212
|
}
|
|
5811
6213
|
}, [onAction]);
|
|
5812
6214
|
const handleMessageComplete = _react.useCallback.call(void 0, (result) => {
|
|
5813
|
-
if (!_optionalChain([result, 'optionalAccess',
|
|
6215
|
+
if (!_optionalChain([result, 'optionalAccess', _165 => _165.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));
|
|
5816
6218
|
const parsed = parseInterfaceFromText(text);
|
|
@@ -5850,7 +6252,7 @@ function AutoInterface({
|
|
|
5850
6252
|
}).catch((err) => {
|
|
5851
6253
|
if (cancelled) return;
|
|
5852
6254
|
console.error("[AutoInterface] Initial generation failed:", err);
|
|
5853
|
-
_optionalChain([onError, 'optionalCall',
|
|
6255
|
+
_optionalChain([onError, 'optionalCall', _166 => _166(err instanceof Error ? err : new Error(String(err)))]);
|
|
5854
6256
|
setIsGenerating(false);
|
|
5855
6257
|
});
|
|
5856
6258
|
return () => {
|
|
@@ -6016,7 +6418,7 @@ function useInterfaceAI({
|
|
|
6016
6418
|
}
|
|
6017
6419
|
const sendMessage = _react.useCallback.call(void 0, async (message) => {
|
|
6018
6420
|
accumulatedTextRef.current = "";
|
|
6019
|
-
_optionalChain([onStreamStart, 'optionalCall',
|
|
6421
|
+
_optionalChain([onStreamStart, 'optionalCall', _167 => _167()]);
|
|
6020
6422
|
const systemPrompt = [
|
|
6021
6423
|
generateInterfaceContext(),
|
|
6022
6424
|
context || ""
|
|
@@ -6039,27 +6441,27 @@ function useInterfaceAI({
|
|
|
6039
6441
|
accumulatedTextRef.current += chunk.content || "";
|
|
6040
6442
|
const parsed = parseInterfaceFromText(accumulatedTextRef.current);
|
|
6041
6443
|
if (parsed) {
|
|
6042
|
-
_optionalChain([onInterface, 'optionalCall',
|
|
6444
|
+
_optionalChain([onInterface, 'optionalCall', _168 => _168(parsed)]);
|
|
6043
6445
|
}
|
|
6044
6446
|
const updates = parseUpdatesFromText(accumulatedTextRef.current);
|
|
6045
6447
|
if (updates.length > 0) {
|
|
6046
|
-
_optionalChain([onUpdates, 'optionalCall',
|
|
6448
|
+
_optionalChain([onUpdates, 'optionalCall', _169 => _169(updates)]);
|
|
6047
6449
|
}
|
|
6048
6450
|
}
|
|
6049
6451
|
},
|
|
6050
6452
|
// onComplete
|
|
6051
6453
|
() => {
|
|
6052
|
-
_optionalChain([onStreamEnd, 'optionalCall',
|
|
6454
|
+
_optionalChain([onStreamEnd, 'optionalCall', _170 => _170()]);
|
|
6053
6455
|
},
|
|
6054
6456
|
// onError
|
|
6055
6457
|
(error) => {
|
|
6056
|
-
_optionalChain([onError, 'optionalCall',
|
|
6057
|
-
_optionalChain([onStreamEnd, 'optionalCall',
|
|
6458
|
+
_optionalChain([onError, 'optionalCall', _171 => _171(error)]);
|
|
6459
|
+
_optionalChain([onStreamEnd, 'optionalCall', _172 => _172()]);
|
|
6058
6460
|
}
|
|
6059
6461
|
);
|
|
6060
6462
|
} catch (error) {
|
|
6061
|
-
_optionalChain([onError, 'optionalCall',
|
|
6062
|
-
_optionalChain([onStreamEnd, 'optionalCall',
|
|
6463
|
+
_optionalChain([onError, 'optionalCall', _173 => _173(error instanceof Error ? error : new Error("Unknown error"))]);
|
|
6464
|
+
_optionalChain([onStreamEnd, 'optionalCall', _174 => _174()]);
|
|
6063
6465
|
}
|
|
6064
6466
|
}, [agentId, context, onInterface, onUpdates, onError, onStreamStart, onStreamEnd]);
|
|
6065
6467
|
return {
|
|
@@ -6103,5 +6505,7 @@ function useInterfaceAI({
|
|
|
6103
6505
|
|
|
6104
6506
|
|
|
6105
6507
|
|
|
6106
|
-
|
|
6508
|
+
|
|
6509
|
+
|
|
6510
|
+
exports.AptevaClient = AptevaClient; exports.AutoInterface = AutoInterface; exports.Button = Button; exports.Card = Card; exports.Chat = Chat; exports.Command = Command; exports.InterfaceRenderer = InterfaceRenderer; exports.InterfaceSkeleton = InterfaceSkeleton; exports.Kpi = Kpi; exports.LayoutRenderer = LayoutRenderer; exports.List = List; exports.LiveView = LiveView; exports.PersistentWidgetPanel = PersistentWidgetPanel; exports.Prompt = Prompt; exports.Spacer = Spacer; exports.Stream = Stream; exports.TextBlock = TextBlock; exports.Threads = Threads; exports.Widgets = Widgets; exports.applyUpdate = applyUpdate; exports.applyUpdates = applyUpdates; exports.aptevaClient = aptevaClient; exports.cn = cn; exports.containsInterface = containsInterface; exports.convertApiMessages = convertApiMessages; exports.findNode = findNode; exports.generateCompactInterfaceContext = generateCompactInterfaceContext; exports.generateInterfaceContext = generateInterfaceContext; exports.getThemeScript = getThemeScript; exports.mockMessages = mockMessages; exports.mockThreads = mockThreads; exports.mockWidgets = mockWidgets; exports.parseInterfaceFromText = parseInterfaceFromText; exports.parseUpdatesFromText = parseUpdatesFromText; exports.stripInterface = stripInterface; exports.useInterfaceAI = useInterfaceAI; exports.useInterfaceState = useInterfaceState;
|
|
6107
6511
|
//# sourceMappingURL=index.js.map
|