@apteva/apteva-kit 0.1.105 → 0.1.107
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 +35 -2
- package/dist/index.d.ts +35 -2
- package/dist/index.js +530 -125
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1031 -626
- 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") {
|
|
@@ -1785,9 +1854,10 @@ var trendIcons = {
|
|
|
1785
1854
|
flat: { symbol: "\u2192", color: "text-neutral-400" }
|
|
1786
1855
|
};
|
|
1787
1856
|
function Kpi({ widget, onAction }) {
|
|
1788
|
-
const { label = "", value = "", change, trend } = widget.props || {};
|
|
1857
|
+
const { title, label = "", value = "", change, trend } = widget.props || {};
|
|
1789
1858
|
const trendInfo = trend ? trendIcons[trend] : null;
|
|
1790
1859
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "border border-neutral-200 dark:border-neutral-700 rounded-xl bg-white dark:bg-neutral-900 p-5", children: [
|
|
1860
|
+
title && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h3", { className: "!text-base font-semibold !text-neutral-900 dark:!text-white mb-3", children: title }),
|
|
1791
1861
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "!text-sm font-medium !text-neutral-500 dark:!text-neutral-400 mb-1", children: label }),
|
|
1792
1862
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-end gap-2", children: [
|
|
1793
1863
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "!text-2xl font-bold !text-neutral-900 dark:!text-white", children: value }),
|
|
@@ -1800,7 +1870,7 @@ function Kpi({ widget, onAction }) {
|
|
|
1800
1870
|
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
1871
|
"button",
|
|
1802
1872
|
{
|
|
1803
|
-
onClick: () => _optionalChain([onAction, 'optionalCall',
|
|
1873
|
+
onClick: () => _optionalChain([onAction, 'optionalCall', _36 => _36({
|
|
1804
1874
|
type: action.type,
|
|
1805
1875
|
payload: action.payload,
|
|
1806
1876
|
widgetId: widget.id,
|
|
@@ -1912,6 +1982,121 @@ function Spacer({ widget }) {
|
|
|
1912
1982
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: heightClasses[height] || heightClasses.md });
|
|
1913
1983
|
}
|
|
1914
1984
|
|
|
1985
|
+
// src/components/Widgets/widget-library/LiveView.tsx
|
|
1986
|
+
|
|
1987
|
+
|
|
1988
|
+
function LiveView({ widget }) {
|
|
1989
|
+
const { src, title, height, aspectRatio = "16/9", allowFullscreen = true, sandbox, allow, refreshInterval, showToolbar = true } = widget.props;
|
|
1990
|
+
const iframeRef = _react.useRef.call(void 0, null);
|
|
1991
|
+
const [isLoading, setIsLoading] = _react.useState.call(void 0, true);
|
|
1992
|
+
const [hasError, setHasError] = _react.useState.call(void 0, false);
|
|
1993
|
+
const [refreshKey, setRefreshKey] = _react.useState.call(void 0, 0);
|
|
1994
|
+
const handleRefresh = _react.useCallback.call(void 0, () => {
|
|
1995
|
+
setIsLoading(true);
|
|
1996
|
+
setHasError(false);
|
|
1997
|
+
setRefreshKey((k) => k + 1);
|
|
1998
|
+
}, []);
|
|
1999
|
+
const handleFullscreen = _react.useCallback.call(void 0, () => {
|
|
2000
|
+
_optionalChain([iframeRef, 'access', _37 => _37.current, 'optionalAccess', _38 => _38.requestFullscreen, 'optionalCall', _39 => _39()]);
|
|
2001
|
+
}, []);
|
|
2002
|
+
const handleOpenExternal = _react.useCallback.call(void 0, () => {
|
|
2003
|
+
window.open(src, "_blank", "noopener,noreferrer");
|
|
2004
|
+
}, [src]);
|
|
2005
|
+
_react.useEffect.call(void 0, () => {
|
|
2006
|
+
if (!refreshInterval || refreshInterval <= 0) return;
|
|
2007
|
+
const interval = setInterval(handleRefresh, refreshInterval * 1e3);
|
|
2008
|
+
return () => clearInterval(interval);
|
|
2009
|
+
}, [refreshInterval, handleRefresh]);
|
|
2010
|
+
const aspectMap = { "16/9": "56.25%", "4/3": "75%", "1/1": "100%" };
|
|
2011
|
+
const useFixedHeight = !!height;
|
|
2012
|
+
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: [
|
|
2013
|
+
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: [
|
|
2014
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-2 min-w-0", children: [
|
|
2015
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: cn(
|
|
2016
|
+
"w-2 h-2 rounded-full flex-shrink-0",
|
|
2017
|
+
hasError ? "bg-red-500" : isLoading ? "bg-amber-500 animate-pulse" : "bg-emerald-500"
|
|
2018
|
+
) }),
|
|
2019
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-sm font-medium text-neutral-700 dark:text-neutral-300 truncate", children: title || "Live View" })
|
|
2020
|
+
] }),
|
|
2021
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-1 flex-shrink-0", children: [
|
|
2022
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2023
|
+
"button",
|
|
2024
|
+
{
|
|
2025
|
+
onClick: handleRefresh,
|
|
2026
|
+
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",
|
|
2027
|
+
title: "Refresh",
|
|
2028
|
+
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" }) })
|
|
2029
|
+
}
|
|
2030
|
+
),
|
|
2031
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2032
|
+
"button",
|
|
2033
|
+
{
|
|
2034
|
+
onClick: handleOpenExternal,
|
|
2035
|
+
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",
|
|
2036
|
+
title: "Open in new tab",
|
|
2037
|
+
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" }) })
|
|
2038
|
+
}
|
|
2039
|
+
),
|
|
2040
|
+
allowFullscreen && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2041
|
+
"button",
|
|
2042
|
+
{
|
|
2043
|
+
onClick: handleFullscreen,
|
|
2044
|
+
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",
|
|
2045
|
+
title: "Fullscreen",
|
|
2046
|
+
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" }) })
|
|
2047
|
+
}
|
|
2048
|
+
)
|
|
2049
|
+
] })
|
|
2050
|
+
] }),
|
|
2051
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
2052
|
+
"div",
|
|
2053
|
+
{
|
|
2054
|
+
className: "relative bg-white dark:bg-neutral-950",
|
|
2055
|
+
style: useFixedHeight ? { height } : { paddingBottom: aspectMap[aspectRatio] || aspectMap["16/9"] },
|
|
2056
|
+
children: [
|
|
2057
|
+
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: [
|
|
2058
|
+
/* @__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" }),
|
|
2059
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-xs text-neutral-500", children: "Loading..." })
|
|
2060
|
+
] }) }),
|
|
2061
|
+
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: [
|
|
2062
|
+
/* @__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" }) }),
|
|
2063
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-sm text-neutral-500", children: "Failed to load" }),
|
|
2064
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2065
|
+
"button",
|
|
2066
|
+
{
|
|
2067
|
+
onClick: handleRefresh,
|
|
2068
|
+
className: "text-xs text-blue-500 hover:text-blue-600 underline",
|
|
2069
|
+
children: "Try again"
|
|
2070
|
+
}
|
|
2071
|
+
)
|
|
2072
|
+
] }) }),
|
|
2073
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2074
|
+
"iframe",
|
|
2075
|
+
{
|
|
2076
|
+
ref: iframeRef,
|
|
2077
|
+
src,
|
|
2078
|
+
title: title || "Live View",
|
|
2079
|
+
className: cn(
|
|
2080
|
+
"border-0 bg-white dark:bg-neutral-950",
|
|
2081
|
+
useFixedHeight ? "w-full h-full" : "absolute inset-0 w-full h-full"
|
|
2082
|
+
),
|
|
2083
|
+
allowFullScreen: allowFullscreen,
|
|
2084
|
+
sandbox,
|
|
2085
|
+
allow,
|
|
2086
|
+
onLoad: () => setIsLoading(false),
|
|
2087
|
+
onError: () => {
|
|
2088
|
+
setIsLoading(false);
|
|
2089
|
+
setHasError(true);
|
|
2090
|
+
}
|
|
2091
|
+
},
|
|
2092
|
+
refreshKey
|
|
2093
|
+
)
|
|
2094
|
+
]
|
|
2095
|
+
}
|
|
2096
|
+
)
|
|
2097
|
+
] });
|
|
2098
|
+
}
|
|
2099
|
+
|
|
1915
2100
|
// src/components/Widgets/WidgetRenderer.tsx
|
|
1916
2101
|
|
|
1917
2102
|
function WidgetRenderer({ widget, onAction }) {
|
|
@@ -1939,6 +2124,8 @@ function WidgetRenderer({ widget, onAction }) {
|
|
|
1939
2124
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TextBlock, { widget });
|
|
1940
2125
|
case "spacer":
|
|
1941
2126
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Spacer, { widget });
|
|
2127
|
+
case "live_view":
|
|
2128
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, LiveView, { widget });
|
|
1942
2129
|
default:
|
|
1943
2130
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "p-4 border border-yellow-300 bg-yellow-50 rounded-lg", children: [
|
|
1944
2131
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "p", { className: "text-sm text-yellow-800", children: [
|
|
@@ -1965,7 +2152,7 @@ function Widgets({
|
|
|
1965
2152
|
}) {
|
|
1966
2153
|
_react.useEffect.call(void 0, () => {
|
|
1967
2154
|
widgets.forEach((widget) => {
|
|
1968
|
-
_optionalChain([onWidgetMount, 'optionalCall',
|
|
2155
|
+
_optionalChain([onWidgetMount, 'optionalCall', _40 => _40(widget.id)]);
|
|
1969
2156
|
});
|
|
1970
2157
|
}, [widgets, onWidgetMount]);
|
|
1971
2158
|
const layoutClasses = {
|
|
@@ -2239,7 +2426,21 @@ function MarkdownContent({ content, className = "" }) {
|
|
|
2239
2426
|
|
|
2240
2427
|
// src/components/Chat/ToolCall.tsx
|
|
2241
2428
|
|
|
2242
|
-
function ToolCall({ name, status, isReceiving = false, inputLength = 0, streamOutput }) {
|
|
2429
|
+
function ToolCall({ name, status, isReceiving = false, inputLength = 0, streamOutput, variant = "card" }) {
|
|
2430
|
+
if (variant === "inline") {
|
|
2431
|
+
const statusText = status === "preparing" ? `${name} preparing...` : status === "running" ? streamOutput ? `${name} \xB7 ${streamOutput}` : `${name}...` : status === "error" ? `${name} failed` : name;
|
|
2432
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "apteva-tool-inline", children: [
|
|
2433
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "apteva-tool-inline-line" }),
|
|
2434
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "apteva-tool-inline-content", children: [
|
|
2435
|
+
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: [
|
|
2436
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "circle", { className: "apteva-tool-spinner-track", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }),
|
|
2437
|
+
/* @__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" })
|
|
2438
|
+
] }) : /* @__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" }) }),
|
|
2439
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "apteva-tool-inline-text", children: statusText })
|
|
2440
|
+
] }),
|
|
2441
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "apteva-tool-inline-line" })
|
|
2442
|
+
] });
|
|
2443
|
+
}
|
|
2243
2444
|
if (status === "preparing") {
|
|
2244
2445
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "apteva-tool-card apteva-tool-card-preparing", children: [
|
|
2245
2446
|
/* @__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 +2488,82 @@ function ToolCall({ name, status, isReceiving = false, inputLength = 0, streamOu
|
|
|
2287
2488
|
] });
|
|
2288
2489
|
}
|
|
2289
2490
|
|
|
2491
|
+
// src/components/Chat/ToolCallGroup.tsx
|
|
2492
|
+
|
|
2493
|
+
|
|
2494
|
+
function ToolCallGroup({ tools }) {
|
|
2495
|
+
const completed = tools.filter((t) => t.status === "completed").length;
|
|
2496
|
+
const errored = tools.filter((t) => t.status === "error").length;
|
|
2497
|
+
const running = tools.filter((t) => t.status === "running").length;
|
|
2498
|
+
const preparing = tools.filter((t) => t.status === "preparing").length;
|
|
2499
|
+
const total = tools.length;
|
|
2500
|
+
const allDone = completed + errored === total;
|
|
2501
|
+
const [expanded, setExpanded] = _react.useState.call(void 0, false);
|
|
2502
|
+
const isExpanded = allDone ? expanded : true;
|
|
2503
|
+
const activeStreamTool = tools.find((t) => t.status === "running" && t.streamOutput);
|
|
2504
|
+
const statusText = allDone ? `Used ${total} tools` : `Using ${total} tools${completed > 0 ? ` \xB7 ${completed}/${total} done` : ""}`;
|
|
2505
|
+
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";
|
|
2506
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: cardClass, children: [
|
|
2507
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
2508
|
+
"button",
|
|
2509
|
+
{
|
|
2510
|
+
className: "apteva-tool-group-header",
|
|
2511
|
+
onClick: () => setExpanded(!expanded),
|
|
2512
|
+
children: [
|
|
2513
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "apteva-tool-group-header-left", children: [
|
|
2514
|
+
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: [
|
|
2515
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "circle", { className: "apteva-tool-spinner-track", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }),
|
|
2516
|
+
/* @__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" })
|
|
2517
|
+
] }),
|
|
2518
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "apteva-tool-group-status", children: statusText })
|
|
2519
|
+
] }),
|
|
2520
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2521
|
+
"svg",
|
|
2522
|
+
{
|
|
2523
|
+
className: `apteva-tool-group-chevron ${isExpanded ? "apteva-tool-group-chevron-open" : ""}`,
|
|
2524
|
+
width: "14",
|
|
2525
|
+
height: "14",
|
|
2526
|
+
fill: "none",
|
|
2527
|
+
stroke: "currentColor",
|
|
2528
|
+
viewBox: "0 0 24 24",
|
|
2529
|
+
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M19 9l-7 7-7-7" })
|
|
2530
|
+
}
|
|
2531
|
+
)
|
|
2532
|
+
]
|
|
2533
|
+
}
|
|
2534
|
+
),
|
|
2535
|
+
!isExpanded && activeStreamTool && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "apteva-tool-group-stream", children: [
|
|
2536
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "apteva-tool-group-stream-name", children: [
|
|
2537
|
+
activeStreamTool.name,
|
|
2538
|
+
":"
|
|
2539
|
+
] }),
|
|
2540
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "apteva-tool-group-stream-text", children: activeStreamTool.streamOutput })
|
|
2541
|
+
] }),
|
|
2542
|
+
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: [
|
|
2543
|
+
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" }),
|
|
2544
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "apteva-tool-group-item-name", children: tool.name }),
|
|
2545
|
+
tool.streamOutput && tool.status === "running" && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "apteva-tool-group-item-stream", children: tool.streamOutput })
|
|
2546
|
+
] }, tool.id)) })
|
|
2547
|
+
] });
|
|
2548
|
+
}
|
|
2549
|
+
|
|
2550
|
+
// src/components/Chat/PersistentWidgetRef.tsx
|
|
2551
|
+
|
|
2552
|
+
function PersistentWidgetRef({ widget }) {
|
|
2553
|
+
const title = widget.props.title || widget.type.replace(/_/g, " ");
|
|
2554
|
+
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: [
|
|
2555
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "w-2 h-2 rounded-full bg-emerald-500 animate-pulse flex-shrink-0" }),
|
|
2556
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-neutral-600 dark:text-neutral-400 capitalize", children: title }),
|
|
2557
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-neutral-400 dark:text-neutral-500 text-xs ml-auto", children: "pinned above" })
|
|
2558
|
+
] });
|
|
2559
|
+
}
|
|
2560
|
+
|
|
2290
2561
|
// src/components/Chat/Message.tsx
|
|
2291
2562
|
|
|
2292
|
-
function Message({ message, onAction, enableWidgets, onWidgetRender }) {
|
|
2563
|
+
function Message({ message, onAction, enableWidgets, onWidgetRender, persistentWidgetIds, toolCallStyle = "card" }) {
|
|
2293
2564
|
const isUser = message.role === "user";
|
|
2294
|
-
const contentSegments = _optionalChain([message, 'access',
|
|
2295
|
-
const isStreaming = _optionalChain([message, 'access',
|
|
2565
|
+
const contentSegments = _optionalChain([message, 'access', _41 => _41.metadata, 'optionalAccess', _42 => _42.content_segments]);
|
|
2566
|
+
const isStreaming = _optionalChain([message, 'access', _43 => _43.metadata, 'optionalAccess', _44 => _44.isStreaming]) === true;
|
|
2296
2567
|
const hasContent = message.content || contentSegments && contentSegments.length > 0;
|
|
2297
2568
|
const reportedWidgetsRef = _react.useRef.call(void 0, /* @__PURE__ */ new Set());
|
|
2298
2569
|
const parsedWidgets = _react.useMemo.call(void 0, () => {
|
|
@@ -2372,7 +2643,7 @@ function Message({ message, onAction, enableWidgets, onWidgetRender }) {
|
|
|
2372
2643
|
}
|
|
2373
2644
|
return elements.length > 0 ? elements : null;
|
|
2374
2645
|
};
|
|
2375
|
-
const attachments = _optionalChain([message, 'access',
|
|
2646
|
+
const attachments = _optionalChain([message, 'access', _45 => _45.metadata, 'optionalAccess', _46 => _46.attachments]) || [];
|
|
2376
2647
|
const hasAttachments = attachments.length > 0;
|
|
2377
2648
|
const renderAttachments = () => {
|
|
2378
2649
|
if (!hasAttachments) return null;
|
|
@@ -2468,36 +2739,102 @@ function Message({ message, onAction, enableWidgets, onWidgetRender }) {
|
|
|
2468
2739
|
if (!contentSegments || contentSegments.length === 0) {
|
|
2469
2740
|
return null;
|
|
2470
2741
|
}
|
|
2471
|
-
const
|
|
2742
|
+
const groups = [];
|
|
2743
|
+
let currentToolRun = [];
|
|
2744
|
+
const flushToolRun = () => {
|
|
2745
|
+
if (currentToolRun.length > 0) {
|
|
2746
|
+
groups.push({ type: "tools", tools: [...currentToolRun] });
|
|
2747
|
+
currentToolRun = [];
|
|
2748
|
+
}
|
|
2749
|
+
};
|
|
2472
2750
|
contentSegments.forEach((segment, index) => {
|
|
2473
|
-
if (segment.type === "
|
|
2474
|
-
|
|
2751
|
+
if (segment.type === "tool") {
|
|
2752
|
+
currentToolRun.push(segment);
|
|
2753
|
+
} else {
|
|
2754
|
+
flushToolRun();
|
|
2755
|
+
if (segment.type === "text" && segment.content) {
|
|
2756
|
+
groups.push({ type: "text", content: segment.content, index });
|
|
2757
|
+
}
|
|
2758
|
+
}
|
|
2759
|
+
});
|
|
2760
|
+
flushToolRun();
|
|
2761
|
+
const elements = [];
|
|
2762
|
+
groups.forEach((group, groupIndex) => {
|
|
2763
|
+
if (group.type === "text") {
|
|
2764
|
+
const textElements = renderTextSegmentWithWidgets(group.content, `seg-${group.index}`);
|
|
2475
2765
|
if (Array.isArray(textElements)) {
|
|
2476
2766
|
elements.push(...textElements);
|
|
2477
2767
|
} else {
|
|
2478
2768
|
elements.push(textElements);
|
|
2479
2769
|
}
|
|
2480
|
-
} else if (
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2770
|
+
} else if (group.type === "tools") {
|
|
2771
|
+
if (toolCallStyle === "inline") {
|
|
2772
|
+
group.tools.forEach((segment) => {
|
|
2773
|
+
if (segment.type === "tool") {
|
|
2774
|
+
elements.push(
|
|
2775
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "apteva-tool-call-standalone", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2776
|
+
ToolCall,
|
|
2777
|
+
{
|
|
2778
|
+
name: segment.name,
|
|
2779
|
+
status: segment.status || (segment.result !== void 0 ? "completed" : "running"),
|
|
2780
|
+
isReceiving: segment.isReceiving,
|
|
2781
|
+
inputLength: segment.inputLength,
|
|
2782
|
+
streamOutput: segment.streamOutput,
|
|
2783
|
+
variant: "inline"
|
|
2784
|
+
}
|
|
2785
|
+
) }, segment.id)
|
|
2786
|
+
);
|
|
2490
2787
|
}
|
|
2491
|
-
|
|
2492
|
-
)
|
|
2788
|
+
});
|
|
2789
|
+
} else if (group.tools.length >= 3) {
|
|
2790
|
+
const toolData = group.tools.map((t) => {
|
|
2791
|
+
const tool = t;
|
|
2792
|
+
return {
|
|
2793
|
+
id: tool.id,
|
|
2794
|
+
name: tool.name,
|
|
2795
|
+
status: tool.status || (tool.result !== void 0 ? "completed" : "running"),
|
|
2796
|
+
isReceiving: tool.isReceiving,
|
|
2797
|
+
streamOutput: tool.streamOutput
|
|
2798
|
+
};
|
|
2799
|
+
});
|
|
2800
|
+
elements.push(
|
|
2801
|
+
/* @__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}`)
|
|
2802
|
+
);
|
|
2803
|
+
} else {
|
|
2804
|
+
group.tools.forEach((segment) => {
|
|
2805
|
+
if (segment.type === "tool") {
|
|
2806
|
+
elements.push(
|
|
2807
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "apteva-tool-call-standalone", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2808
|
+
ToolCall,
|
|
2809
|
+
{
|
|
2810
|
+
name: segment.name,
|
|
2811
|
+
status: segment.status || (segment.result !== void 0 ? "completed" : "running"),
|
|
2812
|
+
isReceiving: segment.isReceiving,
|
|
2813
|
+
inputLength: segment.inputLength,
|
|
2814
|
+
streamOutput: segment.streamOutput
|
|
2815
|
+
}
|
|
2816
|
+
) }, segment.id)
|
|
2817
|
+
);
|
|
2818
|
+
}
|
|
2819
|
+
});
|
|
2820
|
+
}
|
|
2493
2821
|
}
|
|
2494
2822
|
});
|
|
2495
2823
|
return elements;
|
|
2496
2824
|
};
|
|
2825
|
+
const renderMessageWidgets = () => {
|
|
2826
|
+
if (!message.widgets || message.widgets.length === 0) return null;
|
|
2827
|
+
const inlineWidgets = message.widgets.filter((w) => !_optionalChain([persistentWidgetIds, 'optionalAccess', _47 => _47.has, 'call', _48 => _48(w.id)]));
|
|
2828
|
+
const persistentRefs = message.widgets.filter((w) => _optionalChain([persistentWidgetIds, 'optionalAccess', _49 => _49.has, 'call', _50 => _50(w.id)]));
|
|
2829
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
2830
|
+
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}`)),
|
|
2831
|
+
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" }) })
|
|
2832
|
+
] });
|
|
2833
|
+
};
|
|
2497
2834
|
if (!isUser && (contentSegments && contentSegments.length > 0)) {
|
|
2498
2835
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "apteva-message-segmented", children: [
|
|
2499
2836
|
renderSegmentedContent(),
|
|
2500
|
-
|
|
2837
|
+
renderMessageWidgets(),
|
|
2501
2838
|
/* @__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
2839
|
] });
|
|
2503
2840
|
}
|
|
@@ -2505,7 +2842,7 @@ function Message({ message, onAction, enableWidgets, onWidgetRender }) {
|
|
|
2505
2842
|
if (!isUser && enableWidgets && widgetContent) {
|
|
2506
2843
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "apteva-message-segmented", children: [
|
|
2507
2844
|
widgetContent,
|
|
2508
|
-
|
|
2845
|
+
renderMessageWidgets(),
|
|
2509
2846
|
/* @__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
2847
|
] });
|
|
2511
2848
|
}
|
|
@@ -2525,7 +2862,7 @@ function Message({ message, onAction, enableWidgets, onWidgetRender }) {
|
|
|
2525
2862
|
),
|
|
2526
2863
|
children: [
|
|
2527
2864
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: isUser ? "apteva-message-content-user" : "apteva-message-content-assistant", children: renderContent() }),
|
|
2528
|
-
|
|
2865
|
+
renderMessageWidgets(),
|
|
2529
2866
|
/* @__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
2867
|
]
|
|
2531
2868
|
}
|
|
@@ -2687,7 +3024,9 @@ function MessageList({
|
|
|
2687
3024
|
chatVariant,
|
|
2688
3025
|
onPromptClick,
|
|
2689
3026
|
enableWidgets,
|
|
2690
|
-
onWidgetRender
|
|
3027
|
+
onWidgetRender,
|
|
3028
|
+
persistentWidgetIds,
|
|
3029
|
+
toolCallStyle
|
|
2691
3030
|
}) {
|
|
2692
3031
|
const listRef = _react.useRef.call(void 0, null);
|
|
2693
3032
|
const isNearBottomRef = _react.useRef.call(void 0, true);
|
|
@@ -2719,7 +3058,7 @@ function MessageList({
|
|
|
2719
3058
|
onPromptClick: onPromptClick || (() => {
|
|
2720
3059
|
})
|
|
2721
3060
|
}
|
|
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)) });
|
|
3061
|
+
) : 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
3062
|
}
|
|
2724
3063
|
|
|
2725
3064
|
// src/components/Chat/Composer.tsx
|
|
@@ -2793,7 +3132,7 @@ function Composer({ onSendMessage, placeholder = "Type a message...", disabled =
|
|
|
2793
3132
|
setFileError(errors.join(", "));
|
|
2794
3133
|
setTimeout(() => setFileError(null), 5e3);
|
|
2795
3134
|
}
|
|
2796
|
-
_optionalChain([onFileUpload, 'optionalCall',
|
|
3135
|
+
_optionalChain([onFileUpload, 'optionalCall', _51 => _51(e.target.files)]);
|
|
2797
3136
|
setShowMenu(false);
|
|
2798
3137
|
e.target.value = "";
|
|
2799
3138
|
}
|
|
@@ -2865,15 +3204,15 @@ function Composer({ onSendMessage, placeholder = "Type a message...", disabled =
|
|
|
2865
3204
|
{
|
|
2866
3205
|
className: "apteva-composer-menu fixed bg-neutral-800 dark:bg-neutral-800 rounded-xl shadow-lg overflow-hidden z-[9999] min-w-[200px]",
|
|
2867
3206
|
style: {
|
|
2868
|
-
left: _nullishCoalesce(_optionalChain([menuButtonRef, 'access',
|
|
2869
|
-
bottom: window.innerHeight - (_nullishCoalesce(_optionalChain([menuButtonRef, 'access',
|
|
3207
|
+
left: _nullishCoalesce(_optionalChain([menuButtonRef, 'access', _52 => _52.current, 'optionalAccess', _53 => _53.getBoundingClientRect, 'call', _54 => _54(), 'access', _55 => _55.left]), () => ( 0)),
|
|
3208
|
+
bottom: window.innerHeight - (_nullishCoalesce(_optionalChain([menuButtonRef, 'access', _56 => _56.current, 'optionalAccess', _57 => _57.getBoundingClientRect, 'call', _58 => _58(), 'access', _59 => _59.top]), () => ( 0))) + 8
|
|
2870
3209
|
},
|
|
2871
3210
|
children: [
|
|
2872
3211
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
2873
3212
|
"button",
|
|
2874
3213
|
{
|
|
2875
3214
|
onClick: () => {
|
|
2876
|
-
_optionalChain([fileInputRef, 'access',
|
|
3215
|
+
_optionalChain([fileInputRef, 'access', _60 => _60.current, 'optionalAccess', _61 => _61.click, 'call', _62 => _62()]);
|
|
2877
3216
|
setShowMenu(false);
|
|
2878
3217
|
},
|
|
2879
3218
|
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 +3333,8 @@ function CommandComposer({
|
|
|
2994
3333
|
}
|
|
2995
3334
|
};
|
|
2996
3335
|
const handleNewCommand = () => {
|
|
2997
|
-
_optionalChain([onReset, 'optionalCall',
|
|
2998
|
-
_optionalChain([inputRef, 'access',
|
|
3336
|
+
_optionalChain([onReset, 'optionalCall', _63 => _63()]);
|
|
3337
|
+
_optionalChain([inputRef, 'access', _64 => _64.current, 'optionalAccess', _65 => _65.focus, 'call', _66 => _66()]);
|
|
2999
3338
|
};
|
|
3000
3339
|
const handleInputChange = (value) => {
|
|
3001
3340
|
setInput(value);
|
|
@@ -3109,15 +3448,15 @@ function CommandComposer({
|
|
|
3109
3448
|
{
|
|
3110
3449
|
className: "apteva-composer-menu fixed bg-neutral-800 dark:bg-neutral-800 rounded-xl shadow-lg overflow-hidden z-[9999] min-w-[200px]",
|
|
3111
3450
|
style: {
|
|
3112
|
-
left: _nullishCoalesce(_optionalChain([menuButtonRef, 'access',
|
|
3113
|
-
top: (_nullishCoalesce(_optionalChain([menuButtonRef, 'access',
|
|
3451
|
+
left: _nullishCoalesce(_optionalChain([menuButtonRef, 'access', _67 => _67.current, 'optionalAccess', _68 => _68.getBoundingClientRect, 'call', _69 => _69(), 'access', _70 => _70.left]), () => ( 0)),
|
|
3452
|
+
top: (_nullishCoalesce(_optionalChain([menuButtonRef, 'access', _71 => _71.current, 'optionalAccess', _72 => _72.getBoundingClientRect, 'call', _73 => _73(), 'access', _74 => _74.bottom]), () => ( 0))) + 8
|
|
3114
3453
|
},
|
|
3115
3454
|
children: [
|
|
3116
3455
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
3117
3456
|
"button",
|
|
3118
3457
|
{
|
|
3119
3458
|
onClick: () => {
|
|
3120
|
-
_optionalChain([fileInputRef, 'access',
|
|
3459
|
+
_optionalChain([fileInputRef, 'access', _75 => _75.current, 'optionalAccess', _76 => _76.click, 'call', _77 => _77()]);
|
|
3121
3460
|
setShowMenu(false);
|
|
3122
3461
|
},
|
|
3123
3462
|
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 +3609,8 @@ var AptevaClient = class {
|
|
|
3270
3609
|
constructor(config) {
|
|
3271
3610
|
__publicField(this, "config");
|
|
3272
3611
|
this.config = {
|
|
3273
|
-
apiUrl: _nullishCoalesce(_optionalChain([config, 'optionalAccess',
|
|
3274
|
-
apiKey: _nullishCoalesce(_optionalChain([config, 'optionalAccess',
|
|
3612
|
+
apiUrl: _nullishCoalesce(_optionalChain([config, 'optionalAccess', _78 => _78.apiUrl]), () => ( "")),
|
|
3613
|
+
apiKey: _nullishCoalesce(_optionalChain([config, 'optionalAccess', _79 => _79.apiKey]), () => ( ""))
|
|
3275
3614
|
};
|
|
3276
3615
|
}
|
|
3277
3616
|
/**
|
|
@@ -3348,7 +3687,7 @@ var AptevaClient = class {
|
|
|
3348
3687
|
const error = await response.json().catch(() => ({ error: "Request failed" }));
|
|
3349
3688
|
throw new Error(error.error || `Request failed with status ${response.status}`);
|
|
3350
3689
|
}
|
|
3351
|
-
const reader = _optionalChain([response, 'access',
|
|
3690
|
+
const reader = _optionalChain([response, 'access', _80 => _80.body, 'optionalAccess', _81 => _81.getReader, 'call', _82 => _82()]);
|
|
3352
3691
|
if (!reader) {
|
|
3353
3692
|
throw new Error("Response body is not readable");
|
|
3354
3693
|
}
|
|
@@ -3366,7 +3705,7 @@ var AptevaClient = class {
|
|
|
3366
3705
|
if (line.startsWith("data: ")) {
|
|
3367
3706
|
const data = line.slice(6);
|
|
3368
3707
|
if (data === "[DONE]") {
|
|
3369
|
-
_optionalChain([onComplete, 'optionalCall',
|
|
3708
|
+
_optionalChain([onComplete, 'optionalCall', _83 => _83(threadId)]);
|
|
3370
3709
|
return;
|
|
3371
3710
|
}
|
|
3372
3711
|
try {
|
|
@@ -3381,10 +3720,10 @@ var AptevaClient = class {
|
|
|
3381
3720
|
}
|
|
3382
3721
|
}
|
|
3383
3722
|
}
|
|
3384
|
-
_optionalChain([onComplete, 'optionalCall',
|
|
3723
|
+
_optionalChain([onComplete, 'optionalCall', _84 => _84(threadId)]);
|
|
3385
3724
|
} catch (error) {
|
|
3386
3725
|
const err = error instanceof Error ? error : new Error("Unknown error");
|
|
3387
|
-
_optionalChain([onError, 'optionalCall',
|
|
3726
|
+
_optionalChain([onError, 'optionalCall', _85 => _85(err)]);
|
|
3388
3727
|
throw err;
|
|
3389
3728
|
}
|
|
3390
3729
|
}
|
|
@@ -3448,6 +3787,41 @@ var AptevaClient = class {
|
|
|
3448
3787
|
};
|
|
3449
3788
|
var aptevaClient = new AptevaClient();
|
|
3450
3789
|
|
|
3790
|
+
// src/components/Chat/PersistentWidgetPanel.tsx
|
|
3791
|
+
|
|
3792
|
+
|
|
3793
|
+
function PersistentWidgetPanel({ widgets, onAction }) {
|
|
3794
|
+
const [collapsed, setCollapsed] = _react.useState.call(void 0, false);
|
|
3795
|
+
if (widgets.length === 0) return null;
|
|
3796
|
+
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: [
|
|
3797
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center justify-between px-3 py-1.5", children: [
|
|
3798
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-2", children: [
|
|
3799
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "w-1.5 h-1.5 rounded-full bg-emerald-500 animate-pulse" }),
|
|
3800
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-xs font-medium text-neutral-500 dark:text-neutral-400 uppercase tracking-wider", children: "Live" })
|
|
3801
|
+
] }),
|
|
3802
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3803
|
+
"button",
|
|
3804
|
+
{
|
|
3805
|
+
onClick: () => setCollapsed((c) => !c),
|
|
3806
|
+
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",
|
|
3807
|
+
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3808
|
+
"svg",
|
|
3809
|
+
{
|
|
3810
|
+
className: cn("w-3.5 h-3.5 transition-transform", collapsed && "rotate-180"),
|
|
3811
|
+
fill: "none",
|
|
3812
|
+
viewBox: "0 0 24 24",
|
|
3813
|
+
stroke: "currentColor",
|
|
3814
|
+
strokeWidth: 2,
|
|
3815
|
+
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M19 9l-7 7-7-7" })
|
|
3816
|
+
}
|
|
3817
|
+
)
|
|
3818
|
+
}
|
|
3819
|
+
)
|
|
3820
|
+
] }),
|
|
3821
|
+
!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)) })
|
|
3822
|
+
] });
|
|
3823
|
+
}
|
|
3824
|
+
|
|
3451
3825
|
// src/components/Chat/Chat.tsx
|
|
3452
3826
|
|
|
3453
3827
|
var Chat = _react.forwardRef.call(void 0, function Chat2({
|
|
@@ -3490,6 +3864,8 @@ var Chat = _react.forwardRef.call(void 0, function Chat2({
|
|
|
3490
3864
|
showHeader = true,
|
|
3491
3865
|
headerTitle = "Chat",
|
|
3492
3866
|
onHeaderBack,
|
|
3867
|
+
// Tool call display
|
|
3868
|
+
toolCallStyle = "card",
|
|
3493
3869
|
// Widget detection
|
|
3494
3870
|
enableWidgets = false,
|
|
3495
3871
|
availableWidgets,
|
|
@@ -3515,6 +3891,30 @@ var Chat = _react.forwardRef.call(void 0, function Chat2({
|
|
|
3515
3891
|
const [internalPlanMode, setInternalPlanMode] = _react.useState.call(void 0, planMode);
|
|
3516
3892
|
const [showSettingsMenu, setShowSettingsMenu] = _react.useState.call(void 0, false);
|
|
3517
3893
|
const fileInputRef = _react.useRef.call(void 0, null);
|
|
3894
|
+
const [persistentWidgets, setPersistentWidgets] = _react.useState.call(void 0, /* @__PURE__ */ new Map());
|
|
3895
|
+
const updatePersistentWidgets = _react.useCallback.call(void 0, (msgs) => {
|
|
3896
|
+
setPersistentWidgets((prev) => {
|
|
3897
|
+
const next = new Map(prev);
|
|
3898
|
+
let changed = false;
|
|
3899
|
+
for (const msg of msgs) {
|
|
3900
|
+
if (!msg.widgets) continue;
|
|
3901
|
+
for (const w of msg.widgets) {
|
|
3902
|
+
if (!w.persistent) continue;
|
|
3903
|
+
const existing = next.get(w.id);
|
|
3904
|
+
if (!existing || existing !== w) {
|
|
3905
|
+
next.set(w.id, w);
|
|
3906
|
+
changed = true;
|
|
3907
|
+
}
|
|
3908
|
+
}
|
|
3909
|
+
}
|
|
3910
|
+
return changed ? next : prev;
|
|
3911
|
+
});
|
|
3912
|
+
}, []);
|
|
3913
|
+
_react.useEffect.call(void 0, () => {
|
|
3914
|
+
updatePersistentWidgets(messages);
|
|
3915
|
+
}, [messages, updatePersistentWidgets]);
|
|
3916
|
+
const persistentWidgetList = _react.useMemo.call(void 0, () => Array.from(persistentWidgets.values()), [persistentWidgets]);
|
|
3917
|
+
const persistentWidgetIds = _react.useMemo.call(void 0, () => new Set(persistentWidgets.keys()), [persistentWidgets]);
|
|
3518
3918
|
const handleSendMessageRef = _react.useRef.call(void 0, null);
|
|
3519
3919
|
_react.useImperativeHandle.call(void 0, ref, () => ({
|
|
3520
3920
|
sendMessage: async (text) => {
|
|
@@ -3546,7 +3946,7 @@ ${widgetContext}` : widgetContext;
|
|
|
3546
3946
|
}, [apiUrl, apiKey]);
|
|
3547
3947
|
_react.useEffect.call(void 0, () => {
|
|
3548
3948
|
if (threadId) {
|
|
3549
|
-
_optionalChain([onThreadChange, 'optionalCall',
|
|
3949
|
+
_optionalChain([onThreadChange, 'optionalCall', _86 => _86(threadId)]);
|
|
3550
3950
|
}
|
|
3551
3951
|
}, [threadId, onThreadChange]);
|
|
3552
3952
|
_react.useEffect.call(void 0, () => {
|
|
@@ -3564,7 +3964,7 @@ ${widgetContext}` : widgetContext;
|
|
|
3564
3964
|
}, [showSettingsMenu]);
|
|
3565
3965
|
const handleModeChange = (newMode) => {
|
|
3566
3966
|
setMode(newMode);
|
|
3567
|
-
_optionalChain([onModeChange, 'optionalCall',
|
|
3967
|
+
_optionalChain([onModeChange, 'optionalCall', _87 => _87(newMode)]);
|
|
3568
3968
|
if (newMode === "command") {
|
|
3569
3969
|
setCommandState("idle");
|
|
3570
3970
|
setCommandResult(null);
|
|
@@ -3589,7 +3989,7 @@ ${widgetContext}` : widgetContext;
|
|
|
3589
3989
|
metadata: hasFiles ? { attachments } : void 0
|
|
3590
3990
|
};
|
|
3591
3991
|
setMessages((prev) => [...prev, userMessage]);
|
|
3592
|
-
_optionalChain([onMessageSent, 'optionalCall',
|
|
3992
|
+
_optionalChain([onMessageSent, 'optionalCall', _88 => _88(userMessage)]);
|
|
3593
3993
|
}
|
|
3594
3994
|
setIsLoading(true);
|
|
3595
3995
|
try {
|
|
@@ -3657,7 +4057,7 @@ ${widgetContext}` : widgetContext;
|
|
|
3657
4057
|
responseThreadId = chunk.thread_id;
|
|
3658
4058
|
if (!currentThreadId) {
|
|
3659
4059
|
setCurrentThreadId(chunk.thread_id);
|
|
3660
|
-
_optionalChain([onThreadChange, 'optionalCall',
|
|
4060
|
+
_optionalChain([onThreadChange, 'optionalCall', _89 => _89(chunk.thread_id)]);
|
|
3661
4061
|
}
|
|
3662
4062
|
}
|
|
3663
4063
|
break;
|
|
@@ -3689,7 +4089,7 @@ ${widgetContext}` : widgetContext;
|
|
|
3689
4089
|
contentSegments.push({ type: "tool", id: chunk.tool_id, name: displayName, status: "preparing" });
|
|
3690
4090
|
toolInputBuffers[chunk.tool_id] = "";
|
|
3691
4091
|
setChatToolName(displayName);
|
|
3692
|
-
_optionalChain([onToolCall, 'optionalCall',
|
|
4092
|
+
_optionalChain([onToolCall, 'optionalCall', _90 => _90(chunk.tool_name, chunk.tool_id)]);
|
|
3693
4093
|
updateMessage();
|
|
3694
4094
|
}
|
|
3695
4095
|
break;
|
|
@@ -3749,7 +4149,7 @@ ${widgetContext}` : widgetContext;
|
|
|
3749
4149
|
toolSegment.result = chunk.content;
|
|
3750
4150
|
toolSegment.status = "completed";
|
|
3751
4151
|
toolSegment.isReceiving = false;
|
|
3752
|
-
_optionalChain([onToolResult, 'optionalCall',
|
|
4152
|
+
_optionalChain([onToolResult, 'optionalCall', _91 => _91(toolSegment.name, chunk.content)]);
|
|
3753
4153
|
}
|
|
3754
4154
|
setChatToolName(null);
|
|
3755
4155
|
updateMessage();
|
|
@@ -3793,7 +4193,7 @@ ${widgetContext}` : widgetContext;
|
|
|
3793
4193
|
});
|
|
3794
4194
|
if (threadId2 && threadId2 !== currentThreadId) {
|
|
3795
4195
|
setCurrentThreadId(threadId2);
|
|
3796
|
-
_optionalChain([onThreadChange, 'optionalCall',
|
|
4196
|
+
_optionalChain([onThreadChange, 'optionalCall', _92 => _92(threadId2)]);
|
|
3797
4197
|
}
|
|
3798
4198
|
setIsLoading(false);
|
|
3799
4199
|
setCurrentRequestId(null);
|
|
@@ -3817,7 +4217,7 @@ ${widgetContext}` : widgetContext;
|
|
|
3817
4217
|
setIsLoading(false);
|
|
3818
4218
|
setCurrentRequestId(null);
|
|
3819
4219
|
setChatToolName(null);
|
|
3820
|
-
_optionalChain([onError, 'optionalCall',
|
|
4220
|
+
_optionalChain([onError, 'optionalCall', _93 => _93(error)]);
|
|
3821
4221
|
}
|
|
3822
4222
|
);
|
|
3823
4223
|
}
|
|
@@ -3830,7 +4230,7 @@ ${widgetContext}` : widgetContext;
|
|
|
3830
4230
|
metadata: { error: true }
|
|
3831
4231
|
};
|
|
3832
4232
|
setMessages((prev) => [...prev, errorMessage]);
|
|
3833
|
-
_optionalChain([onError, 'optionalCall',
|
|
4233
|
+
_optionalChain([onError, 'optionalCall', _94 => _94(error instanceof Error ? error : new Error("Unknown error"))]);
|
|
3834
4234
|
} finally {
|
|
3835
4235
|
setIsLoading(false);
|
|
3836
4236
|
}
|
|
@@ -3876,7 +4276,7 @@ ${planningInstruction}` : planningInstruction;
|
|
|
3876
4276
|
const error = err instanceof Error ? err : new Error("Failed to generate plan");
|
|
3877
4277
|
setCommandError(error);
|
|
3878
4278
|
setCommandState("error");
|
|
3879
|
-
_optionalChain([onError, 'optionalCall',
|
|
4279
|
+
_optionalChain([onError, 'optionalCall', _95 => _95(error)]);
|
|
3880
4280
|
}
|
|
3881
4281
|
}
|
|
3882
4282
|
return;
|
|
@@ -3909,12 +4309,12 @@ ${planningInstruction}` : planningInstruction;
|
|
|
3909
4309
|
setCommandResult(result);
|
|
3910
4310
|
setCommandState("success");
|
|
3911
4311
|
setProgress(100);
|
|
3912
|
-
_optionalChain([onComplete, 'optionalCall',
|
|
4312
|
+
_optionalChain([onComplete, 'optionalCall', _96 => _96(result)]);
|
|
3913
4313
|
},
|
|
3914
4314
|
(error) => {
|
|
3915
4315
|
setCommandError(error);
|
|
3916
4316
|
setCommandState("error");
|
|
3917
|
-
_optionalChain([onError, 'optionalCall',
|
|
4317
|
+
_optionalChain([onError, 'optionalCall', _97 => _97(error)]);
|
|
3918
4318
|
}
|
|
3919
4319
|
);
|
|
3920
4320
|
} else {
|
|
@@ -3927,7 +4327,7 @@ ${planningInstruction}` : planningInstruction;
|
|
|
3927
4327
|
setCommandResult(result);
|
|
3928
4328
|
setCommandState("success");
|
|
3929
4329
|
setProgress(100);
|
|
3930
|
-
_optionalChain([onComplete, 'optionalCall',
|
|
4330
|
+
_optionalChain([onComplete, 'optionalCall', _98 => _98(result)]);
|
|
3931
4331
|
}
|
|
3932
4332
|
} else {
|
|
3933
4333
|
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 +4357,16 @@ ${commandInstruction}` : commandInstruction;
|
|
|
3957
4357
|
const displayName = chunk.tool_display_name || chunk.tool_name;
|
|
3958
4358
|
lastToolName = chunk.tool_name;
|
|
3959
4359
|
setCurrentToolName(displayName);
|
|
3960
|
-
_optionalChain([onToolCall, 'optionalCall',
|
|
4360
|
+
_optionalChain([onToolCall, 'optionalCall', _99 => _99(chunk.tool_name, chunk.tool_id || "")]);
|
|
3961
4361
|
accumulatedContent = "";
|
|
3962
4362
|
setStreamedContent("");
|
|
3963
4363
|
} else if (chunk.type === "tool_result") {
|
|
3964
|
-
_optionalChain([onToolResult, 'optionalCall',
|
|
4364
|
+
_optionalChain([onToolResult, 'optionalCall', _100 => _100(lastToolName, chunk.content)]);
|
|
3965
4365
|
setCurrentToolName(null);
|
|
3966
4366
|
} else if (chunk.type === "thread_id" && chunk.thread_id) {
|
|
3967
4367
|
if (!currentThreadId) {
|
|
3968
4368
|
setCurrentThreadId(chunk.thread_id);
|
|
3969
|
-
_optionalChain([onThreadChange, 'optionalCall',
|
|
4369
|
+
_optionalChain([onThreadChange, 'optionalCall', _101 => _101(chunk.thread_id)]);
|
|
3970
4370
|
}
|
|
3971
4371
|
} else if (chunk.type === "request_id" && chunk.request_id) {
|
|
3972
4372
|
setCurrentRequestId(chunk.request_id);
|
|
@@ -3982,13 +4382,13 @@ ${commandInstruction}` : commandInstruction;
|
|
|
3982
4382
|
setCommandState("success");
|
|
3983
4383
|
setProgress(100);
|
|
3984
4384
|
setCurrentRequestId(null);
|
|
3985
|
-
_optionalChain([onComplete, 'optionalCall',
|
|
4385
|
+
_optionalChain([onComplete, 'optionalCall', _102 => _102(result)]);
|
|
3986
4386
|
},
|
|
3987
4387
|
(error) => {
|
|
3988
4388
|
setCommandError(error);
|
|
3989
4389
|
setCommandState("error");
|
|
3990
4390
|
setCurrentRequestId(null);
|
|
3991
|
-
_optionalChain([onError, 'optionalCall',
|
|
4391
|
+
_optionalChain([onError, 'optionalCall', _103 => _103(error)]);
|
|
3992
4392
|
}
|
|
3993
4393
|
);
|
|
3994
4394
|
} else {
|
|
@@ -4008,14 +4408,14 @@ ${commandInstruction}` : commandInstruction;
|
|
|
4008
4408
|
setCommandResult(result);
|
|
4009
4409
|
setCommandState("success");
|
|
4010
4410
|
setProgress(100);
|
|
4011
|
-
_optionalChain([onComplete, 'optionalCall',
|
|
4411
|
+
_optionalChain([onComplete, 'optionalCall', _104 => _104(result)]);
|
|
4012
4412
|
}
|
|
4013
4413
|
}
|
|
4014
4414
|
} catch (err) {
|
|
4015
4415
|
const error = err instanceof Error ? err : new Error("Unknown error");
|
|
4016
4416
|
setCommandError(error);
|
|
4017
4417
|
setCommandState("error");
|
|
4018
|
-
_optionalChain([onError, 'optionalCall',
|
|
4418
|
+
_optionalChain([onError, 'optionalCall', _105 => _105(error)]);
|
|
4019
4419
|
}
|
|
4020
4420
|
};
|
|
4021
4421
|
const resetCommand = () => {
|
|
@@ -4074,6 +4474,7 @@ ${planToExecute}`;
|
|
|
4074
4474
|
] })
|
|
4075
4475
|
] }) }),
|
|
4076
4476
|
mode === "chat" && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
4477
|
+
persistentWidgetList.length > 0 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, PersistentWidgetPanel, { widgets: persistentWidgetList, onAction }),
|
|
4077
4478
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4078
4479
|
MessageList,
|
|
4079
4480
|
{
|
|
@@ -4087,7 +4488,9 @@ ${planToExecute}`;
|
|
|
4087
4488
|
chatVariant: variant,
|
|
4088
4489
|
onPromptClick: (prompt) => handleSendMessage(prompt),
|
|
4089
4490
|
enableWidgets,
|
|
4090
|
-
onWidgetRender
|
|
4491
|
+
onWidgetRender,
|
|
4492
|
+
persistentWidgetIds,
|
|
4493
|
+
toolCallStyle
|
|
4091
4494
|
}
|
|
4092
4495
|
),
|
|
4093
4496
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
@@ -4111,8 +4514,8 @@ ${planToExecute}`;
|
|
|
4111
4514
|
executeCommand(text, files);
|
|
4112
4515
|
},
|
|
4113
4516
|
state: commandState,
|
|
4114
|
-
response: _optionalChain([commandResult, 'optionalAccess',
|
|
4115
|
-
error: _optionalChain([commandError, 'optionalAccess',
|
|
4517
|
+
response: _optionalChain([commandResult, 'optionalAccess', _106 => _106.data, 'optionalAccess', _107 => _107.summary]) || _optionalChain([commandResult, 'optionalAccess', _108 => _108.message]),
|
|
4518
|
+
error: _optionalChain([commandError, 'optionalAccess', _109 => _109.message]),
|
|
4116
4519
|
plan,
|
|
4117
4520
|
streamedContent,
|
|
4118
4521
|
toolName: currentToolName,
|
|
@@ -4280,13 +4683,13 @@ ${planningInstruction}` : planningInstruction;
|
|
|
4280
4683
|
const error2 = err instanceof Error ? err : new Error("Failed to generate plan");
|
|
4281
4684
|
setError(error2);
|
|
4282
4685
|
setState("error");
|
|
4283
|
-
_optionalChain([onError, 'optionalCall',
|
|
4686
|
+
_optionalChain([onError, 'optionalCall', _110 => _110(error2)]);
|
|
4284
4687
|
});
|
|
4285
4688
|
} catch (err) {
|
|
4286
4689
|
const error2 = err instanceof Error ? err : new Error("Failed to generate plan");
|
|
4287
4690
|
setError(error2);
|
|
4288
4691
|
setState("error");
|
|
4289
|
-
_optionalChain([onError, 'optionalCall',
|
|
4692
|
+
_optionalChain([onError, 'optionalCall', _111 => _111(error2)]);
|
|
4290
4693
|
}
|
|
4291
4694
|
}
|
|
4292
4695
|
return;
|
|
@@ -4297,7 +4700,7 @@ ${planningInstruction}` : planningInstruction;
|
|
|
4297
4700
|
setStreamedContent("");
|
|
4298
4701
|
setCommand("");
|
|
4299
4702
|
setUploadedFiles([]);
|
|
4300
|
-
_optionalChain([onStart, 'optionalCall',
|
|
4703
|
+
_optionalChain([onStart, 'optionalCall', _112 => _112()]);
|
|
4301
4704
|
try {
|
|
4302
4705
|
if (useMock) {
|
|
4303
4706
|
if (enableStreaming) {
|
|
@@ -4308,16 +4711,16 @@ ${planningInstruction}` : planningInstruction;
|
|
|
4308
4711
|
if (chunk.type === "token" && chunk.content) {
|
|
4309
4712
|
accumulatedContent += chunk.content;
|
|
4310
4713
|
setStreamedContent(accumulatedContent);
|
|
4311
|
-
_optionalChain([onChunk, 'optionalCall',
|
|
4714
|
+
_optionalChain([onChunk, 'optionalCall', _113 => _113(chunk.content)]);
|
|
4312
4715
|
const estimatedProgress = Math.min(Math.round(accumulatedContent.length / 10), 90);
|
|
4313
4716
|
setProgress(estimatedProgress);
|
|
4314
|
-
_optionalChain([onProgress, 'optionalCall',
|
|
4717
|
+
_optionalChain([onProgress, 'optionalCall', _114 => _114(estimatedProgress)]);
|
|
4315
4718
|
} else if (chunk.type === "widget" && chunk.widget) {
|
|
4316
4719
|
const widget = chunk.widget;
|
|
4317
4720
|
setResult((prev) => ({
|
|
4318
4721
|
success: true,
|
|
4319
|
-
data: _optionalChain([prev, 'optionalAccess',
|
|
4320
|
-
widgets: [..._optionalChain([prev, 'optionalAccess',
|
|
4722
|
+
data: _optionalChain([prev, 'optionalAccess', _115 => _115.data]) || {},
|
|
4723
|
+
widgets: [..._optionalChain([prev, 'optionalAccess', _116 => _116.widgets]) || [], widget],
|
|
4321
4724
|
message: accumulatedContent || "Command executed successfully"
|
|
4322
4725
|
}));
|
|
4323
4726
|
}
|
|
@@ -4337,19 +4740,19 @@ ${planningInstruction}` : planningInstruction;
|
|
|
4337
4740
|
setResult(result2);
|
|
4338
4741
|
setState("success");
|
|
4339
4742
|
setProgress(100);
|
|
4340
|
-
_optionalChain([onComplete, 'optionalCall',
|
|
4743
|
+
_optionalChain([onComplete, 'optionalCall', _117 => _117(result2)]);
|
|
4341
4744
|
},
|
|
4342
4745
|
(error2) => {
|
|
4343
4746
|
setError(error2);
|
|
4344
4747
|
setState("error");
|
|
4345
|
-
_optionalChain([onError, 'optionalCall',
|
|
4748
|
+
_optionalChain([onError, 'optionalCall', _118 => _118(error2)]);
|
|
4346
4749
|
}
|
|
4347
4750
|
);
|
|
4348
4751
|
} else {
|
|
4349
4752
|
const progressInterval = setInterval(() => {
|
|
4350
4753
|
setProgress((prev) => {
|
|
4351
4754
|
const next = Math.min(prev + 10, 90);
|
|
4352
|
-
_optionalChain([onProgress, 'optionalCall',
|
|
4755
|
+
_optionalChain([onProgress, 'optionalCall', _119 => _119(next)]);
|
|
4353
4756
|
return next;
|
|
4354
4757
|
});
|
|
4355
4758
|
}, 200);
|
|
@@ -4373,7 +4776,7 @@ ${planningInstruction}` : planningInstruction;
|
|
|
4373
4776
|
setResult(result2);
|
|
4374
4777
|
setState("success");
|
|
4375
4778
|
setProgress(100);
|
|
4376
|
-
_optionalChain([onComplete, 'optionalCall',
|
|
4779
|
+
_optionalChain([onComplete, 'optionalCall', _120 => _120(result2)]);
|
|
4377
4780
|
}
|
|
4378
4781
|
} else {
|
|
4379
4782
|
if (enableStreaming) {
|
|
@@ -4419,16 +4822,16 @@ ${commandInstruction}` : commandInstruction;
|
|
|
4419
4822
|
if (chunk.type === "token" && chunk.content) {
|
|
4420
4823
|
accumulatedContent += chunk.content;
|
|
4421
4824
|
setStreamedContent(accumulatedContent);
|
|
4422
|
-
_optionalChain([onChunk, 'optionalCall',
|
|
4825
|
+
_optionalChain([onChunk, 'optionalCall', _121 => _121(chunk.content)]);
|
|
4423
4826
|
const estimatedProgress = Math.min(Math.round(accumulatedContent.length / 10), 90);
|
|
4424
4827
|
setProgress(estimatedProgress);
|
|
4425
|
-
_optionalChain([onProgress, 'optionalCall',
|
|
4828
|
+
_optionalChain([onProgress, 'optionalCall', _122 => _122(estimatedProgress)]);
|
|
4426
4829
|
} else if (chunk.type === "widget" && chunk.widget) {
|
|
4427
4830
|
const widget = chunk.widget;
|
|
4428
4831
|
setResult((prev) => ({
|
|
4429
4832
|
success: true,
|
|
4430
|
-
data: _optionalChain([prev, 'optionalAccess',
|
|
4431
|
-
widgets: [..._optionalChain([prev, 'optionalAccess',
|
|
4833
|
+
data: _optionalChain([prev, 'optionalAccess', _123 => _123.data]) || {},
|
|
4834
|
+
widgets: [..._optionalChain([prev, 'optionalAccess', _124 => _124.widgets]) || [], widget],
|
|
4432
4835
|
message: accumulatedContent || "Command executed successfully"
|
|
4433
4836
|
}));
|
|
4434
4837
|
}
|
|
@@ -4448,20 +4851,20 @@ ${commandInstruction}` : commandInstruction;
|
|
|
4448
4851
|
setResult(result2);
|
|
4449
4852
|
setState("success");
|
|
4450
4853
|
setProgress(100);
|
|
4451
|
-
_optionalChain([onComplete, 'optionalCall',
|
|
4854
|
+
_optionalChain([onComplete, 'optionalCall', _125 => _125(result2)]);
|
|
4452
4855
|
},
|
|
4453
4856
|
(error2) => {
|
|
4454
4857
|
const err = error2 instanceof Error ? error2 : new Error("Unknown error");
|
|
4455
4858
|
setError(err);
|
|
4456
4859
|
setState("error");
|
|
4457
|
-
_optionalChain([onError, 'optionalCall',
|
|
4860
|
+
_optionalChain([onError, 'optionalCall', _126 => _126(err)]);
|
|
4458
4861
|
}
|
|
4459
4862
|
);
|
|
4460
4863
|
} else {
|
|
4461
4864
|
const progressInterval = setInterval(() => {
|
|
4462
4865
|
setProgress((prev) => {
|
|
4463
4866
|
const next = Math.min(prev + 10, 90);
|
|
4464
|
-
_optionalChain([onProgress, 'optionalCall',
|
|
4867
|
+
_optionalChain([onProgress, 'optionalCall', _127 => _127(next)]);
|
|
4465
4868
|
return next;
|
|
4466
4869
|
});
|
|
4467
4870
|
}, 200);
|
|
@@ -4517,14 +4920,14 @@ ${commandInstruction}` : commandInstruction;
|
|
|
4517
4920
|
setResult(result2);
|
|
4518
4921
|
setState("success");
|
|
4519
4922
|
setProgress(100);
|
|
4520
|
-
_optionalChain([onComplete, 'optionalCall',
|
|
4923
|
+
_optionalChain([onComplete, 'optionalCall', _128 => _128(result2)]);
|
|
4521
4924
|
}
|
|
4522
4925
|
}
|
|
4523
4926
|
} catch (err) {
|
|
4524
4927
|
const error2 = err instanceof Error ? err : new Error("Unknown error");
|
|
4525
4928
|
setError(error2);
|
|
4526
4929
|
setState("error");
|
|
4527
|
-
_optionalChain([onError, 'optionalCall',
|
|
4930
|
+
_optionalChain([onError, 'optionalCall', _129 => _129(error2)]);
|
|
4528
4931
|
}
|
|
4529
4932
|
};
|
|
4530
4933
|
const resetCommand = () => {
|
|
@@ -4557,14 +4960,14 @@ ${planToExecute}`;
|
|
|
4557
4960
|
};
|
|
4558
4961
|
const handleFileSelect = async (e) => {
|
|
4559
4962
|
if (e.target.files && e.target.files.length > 0) {
|
|
4560
|
-
_optionalChain([onFileUpload, 'optionalCall',
|
|
4963
|
+
_optionalChain([onFileUpload, 'optionalCall', _130 => _130(e.target.files)]);
|
|
4561
4964
|
const files = [];
|
|
4562
4965
|
for (let i = 0; i < e.target.files.length; i++) {
|
|
4563
4966
|
const file = e.target.files[i];
|
|
4564
4967
|
const reader = new FileReader();
|
|
4565
4968
|
await new Promise((resolve) => {
|
|
4566
4969
|
reader.onload = (event) => {
|
|
4567
|
-
if (_optionalChain([event, 'access',
|
|
4970
|
+
if (_optionalChain([event, 'access', _131 => _131.target, 'optionalAccess', _132 => _132.result])) {
|
|
4568
4971
|
const fullDataUrl = event.target.result;
|
|
4569
4972
|
const base64Data = fullDataUrl.split(",")[1];
|
|
4570
4973
|
if (file.type.startsWith("image/")) {
|
|
@@ -4658,7 +5061,7 @@ ${planToExecute}`;
|
|
|
4658
5061
|
enableFileUpload && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4659
5062
|
"button",
|
|
4660
5063
|
{
|
|
4661
|
-
onClick: () => _optionalChain([fileInputRef, 'access',
|
|
5064
|
+
onClick: () => _optionalChain([fileInputRef, 'access', _133 => _133.current, 'optionalAccess', _134 => _134.click, 'call', _135 => _135()]),
|
|
4662
5065
|
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
5066
|
title: "Attach file",
|
|
4664
5067
|
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 +5280,7 @@ ${planToExecute}`;
|
|
|
4877
5280
|
/* @__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
5281
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { children: [
|
|
4879
5282
|
/* @__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',
|
|
5283
|
+
/* @__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
5284
|
] })
|
|
4882
5285
|
] }) }),
|
|
4883
5286
|
allowInput && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
@@ -4905,7 +5308,7 @@ ${planToExecute}`;
|
|
|
4905
5308
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-green-700 dark:text-green-300 text-sm", children: "Command executed successfully" })
|
|
4906
5309
|
] })
|
|
4907
5310
|
] }),
|
|
4908
|
-
_optionalChain([result, 'access',
|
|
5311
|
+
_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
5312
|
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
5313
|
WidgetRenderer,
|
|
4911
5314
|
{
|
|
@@ -4956,7 +5359,7 @@ ${planToExecute}`;
|
|
|
4956
5359
|
enableFileUpload && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4957
5360
|
"button",
|
|
4958
5361
|
{
|
|
4959
|
-
onClick: () => _optionalChain([fileInputRef, 'access',
|
|
5362
|
+
onClick: () => _optionalChain([fileInputRef, 'access', _139 => _139.current, 'optionalAccess', _140 => _140.click, 'call', _141 => _141()]),
|
|
4960
5363
|
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
5364
|
title: "Attach file",
|
|
4962
5365
|
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 +5545,25 @@ function Prompt({
|
|
|
5142
5545
|
const newValue = e.target.value;
|
|
5143
5546
|
if (!maxLength || newValue.length <= maxLength) {
|
|
5144
5547
|
setValue(newValue);
|
|
5145
|
-
_optionalChain([onChange, 'optionalCall',
|
|
5548
|
+
_optionalChain([onChange, 'optionalCall', _142 => _142(newValue)]);
|
|
5146
5549
|
}
|
|
5147
5550
|
};
|
|
5148
5551
|
const handleSubmit = async () => {
|
|
5149
5552
|
if (value.length < minLength) return;
|
|
5150
|
-
_optionalChain([onSubmit, 'optionalCall',
|
|
5553
|
+
_optionalChain([onSubmit, 'optionalCall', _143 => _143(value)]);
|
|
5151
5554
|
setIsLoading(true);
|
|
5152
5555
|
try {
|
|
5153
5556
|
if (useMock) {
|
|
5154
5557
|
await new Promise((resolve) => setTimeout(resolve, 1500));
|
|
5155
5558
|
const mockResult = `Enhanced version: ${value} [AI-generated content]`;
|
|
5156
|
-
_optionalChain([onResult, 'optionalCall',
|
|
5559
|
+
_optionalChain([onResult, 'optionalCall', _144 => _144(mockResult)]);
|
|
5157
5560
|
setValue("");
|
|
5158
5561
|
} else {
|
|
5159
5562
|
const response = await aptevaClient.chat({
|
|
5160
5563
|
agent_id: agentId,
|
|
5161
5564
|
message: value
|
|
5162
5565
|
});
|
|
5163
|
-
_optionalChain([onResult, 'optionalCall',
|
|
5566
|
+
_optionalChain([onResult, 'optionalCall', _145 => _145(response.message)]);
|
|
5164
5567
|
setValue("");
|
|
5165
5568
|
}
|
|
5166
5569
|
} catch (error) {
|
|
@@ -5255,7 +5658,7 @@ function Stream({
|
|
|
5255
5658
|
}, [autoStart]);
|
|
5256
5659
|
const startStreaming = async () => {
|
|
5257
5660
|
setIsStreaming(true);
|
|
5258
|
-
_optionalChain([onStart, 'optionalCall',
|
|
5661
|
+
_optionalChain([onStart, 'optionalCall', _146 => _146()]);
|
|
5259
5662
|
try {
|
|
5260
5663
|
if (useMock) {
|
|
5261
5664
|
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 +5666,13 @@ function Stream({
|
|
|
5263
5666
|
mockText,
|
|
5264
5667
|
(chunk) => {
|
|
5265
5668
|
setText((prev) => prev + chunk);
|
|
5266
|
-
_optionalChain([onChunk, 'optionalCall',
|
|
5669
|
+
_optionalChain([onChunk, 'optionalCall', _147 => _147(chunk)]);
|
|
5267
5670
|
},
|
|
5268
5671
|
typingSpeed
|
|
5269
5672
|
);
|
|
5270
5673
|
setIsComplete(true);
|
|
5271
5674
|
setIsStreaming(false);
|
|
5272
|
-
_optionalChain([onComplete, 'optionalCall',
|
|
5675
|
+
_optionalChain([onComplete, 'optionalCall', _148 => _148(text + mockText)]);
|
|
5273
5676
|
} else {
|
|
5274
5677
|
let accumulatedText = "";
|
|
5275
5678
|
await aptevaClient.chatStream(
|
|
@@ -5282,24 +5685,24 @@ function Stream({
|
|
|
5282
5685
|
if (chunk.type === "token" && chunk.content) {
|
|
5283
5686
|
accumulatedText += chunk.content;
|
|
5284
5687
|
setText(accumulatedText);
|
|
5285
|
-
_optionalChain([onChunk, 'optionalCall',
|
|
5688
|
+
_optionalChain([onChunk, 'optionalCall', _149 => _149(chunk.content)]);
|
|
5286
5689
|
}
|
|
5287
5690
|
},
|
|
5288
5691
|
() => {
|
|
5289
5692
|
setIsComplete(true);
|
|
5290
5693
|
setIsStreaming(false);
|
|
5291
|
-
_optionalChain([onComplete, 'optionalCall',
|
|
5694
|
+
_optionalChain([onComplete, 'optionalCall', _150 => _150(accumulatedText)]);
|
|
5292
5695
|
},
|
|
5293
5696
|
(error) => {
|
|
5294
5697
|
const err = error instanceof Error ? error : new Error("Streaming error");
|
|
5295
|
-
_optionalChain([onError, 'optionalCall',
|
|
5698
|
+
_optionalChain([onError, 'optionalCall', _151 => _151(err)]);
|
|
5296
5699
|
setIsStreaming(false);
|
|
5297
5700
|
}
|
|
5298
5701
|
);
|
|
5299
5702
|
}
|
|
5300
5703
|
} catch (error) {
|
|
5301
5704
|
const err = error instanceof Error ? error : new Error("Streaming error");
|
|
5302
|
-
_optionalChain([onError, 'optionalCall',
|
|
5705
|
+
_optionalChain([onError, 'optionalCall', _152 => _152(err)]);
|
|
5303
5706
|
setIsStreaming(false);
|
|
5304
5707
|
}
|
|
5305
5708
|
};
|
|
@@ -5391,7 +5794,7 @@ function ThreadList({
|
|
|
5391
5794
|
}) {
|
|
5392
5795
|
const [searchQuery, setSearchQuery] = _react.useState.call(void 0, "");
|
|
5393
5796
|
const filteredThreads = threads.filter(
|
|
5394
|
-
(thread) => thread.title.toLowerCase().includes(searchQuery.toLowerCase()) || _optionalChain([thread, 'access',
|
|
5797
|
+
(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
5798
|
);
|
|
5396
5799
|
const groupedThreads = groupBy === "date" ? groupThreadsByDate(filteredThreads) : { All: filteredThreads };
|
|
5397
5800
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-col h-full", children: [
|
|
@@ -5413,8 +5816,8 @@ function ThreadList({
|
|
|
5413
5816
|
{
|
|
5414
5817
|
thread,
|
|
5415
5818
|
isActive: thread.id === currentThreadId,
|
|
5416
|
-
onSelect: () => _optionalChain([onThreadSelect, 'optionalCall',
|
|
5417
|
-
onDelete: () => _optionalChain([onThreadDelete, 'optionalCall',
|
|
5819
|
+
onSelect: () => _optionalChain([onThreadSelect, 'optionalCall', _158 => _158(thread.id)]),
|
|
5820
|
+
onDelete: () => _optionalChain([onThreadDelete, 'optionalCall', _159 => _159(thread.id)])
|
|
5418
5821
|
},
|
|
5419
5822
|
thread.id
|
|
5420
5823
|
))
|
|
@@ -5476,7 +5879,7 @@ function Threads({
|
|
|
5476
5879
|
threads.slice(0, 5).map((thread) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
5477
5880
|
"button",
|
|
5478
5881
|
{
|
|
5479
|
-
onClick: () => _optionalChain([onThreadSelect, 'optionalCall',
|
|
5882
|
+
onClick: () => _optionalChain([onThreadSelect, 'optionalCall', _160 => _160(thread.id)]),
|
|
5480
5883
|
className: cn(
|
|
5481
5884
|
"px-4 py-2 whitespace-nowrap font-medium transition-colors",
|
|
5482
5885
|
thread.id === currentThreadId ? "border-b-2 border-apteva-500 text-apteva-500" : "text-neutral-600 hover:text-neutral-900"
|
|
@@ -5661,7 +6064,7 @@ function TabsLayout({ node, renderNode }) {
|
|
|
5661
6064
|
var STRUCTURAL_KEYS = /* @__PURE__ */ new Set(["type", "id", "layout", "props", "children", "actions", "metadata", "isStreaming"]);
|
|
5662
6065
|
function normalizeNode(n) {
|
|
5663
6066
|
let node = { ...n };
|
|
5664
|
-
if (node.type === "widget" && _optionalChain([node, 'access',
|
|
6067
|
+
if (node.type === "widget" && _optionalChain([node, 'access', _161 => _161.props, 'optionalAccess', _162 => _162.widget])) {
|
|
5665
6068
|
node.type = node.props.widget;
|
|
5666
6069
|
const { widget: _, ...rest } = node.props;
|
|
5667
6070
|
node.props = rest;
|
|
@@ -5799,10 +6202,10 @@ function AutoInterface({
|
|
|
5799
6202
|
].filter(Boolean).join("\n\n");
|
|
5800
6203
|
const updateInterface = _react.useCallback.call(void 0, (newSpec) => {
|
|
5801
6204
|
setInterfaceSpec(newSpec);
|
|
5802
|
-
_optionalChain([onInterfaceChange, 'optionalCall',
|
|
6205
|
+
_optionalChain([onInterfaceChange, 'optionalCall', _163 => _163(newSpec)]);
|
|
5803
6206
|
}, [onInterfaceChange]);
|
|
5804
6207
|
const handleAction = _react.useCallback.call(void 0, (action) => {
|
|
5805
|
-
_optionalChain([onAction, 'optionalCall',
|
|
6208
|
+
_optionalChain([onAction, 'optionalCall', _164 => _164(action)]);
|
|
5806
6209
|
if (chatRef.current) {
|
|
5807
6210
|
chatRef.current.sendMessage(
|
|
5808
6211
|
`[Action: ${action.type} on widget ${action.widgetId || "unknown"}. Payload: ${JSON.stringify(action.payload)}]`
|
|
@@ -5810,7 +6213,7 @@ function AutoInterface({
|
|
|
5810
6213
|
}
|
|
5811
6214
|
}, [onAction]);
|
|
5812
6215
|
const handleMessageComplete = _react.useCallback.call(void 0, (result) => {
|
|
5813
|
-
if (!_optionalChain([result, 'optionalAccess',
|
|
6216
|
+
if (!_optionalChain([result, 'optionalAccess', _165 => _165.data])) return;
|
|
5814
6217
|
const text = typeof result.data === "string" ? result.data : result.data.message || "";
|
|
5815
6218
|
console.log("[AutoInterface] Chat message complete, text (" + text.length + " chars):", text.substring(0, 300));
|
|
5816
6219
|
const parsed = parseInterfaceFromText(text);
|
|
@@ -5850,7 +6253,7 @@ function AutoInterface({
|
|
|
5850
6253
|
}).catch((err) => {
|
|
5851
6254
|
if (cancelled) return;
|
|
5852
6255
|
console.error("[AutoInterface] Initial generation failed:", err);
|
|
5853
|
-
_optionalChain([onError, 'optionalCall',
|
|
6256
|
+
_optionalChain([onError, 'optionalCall', _166 => _166(err instanceof Error ? err : new Error(String(err)))]);
|
|
5854
6257
|
setIsGenerating(false);
|
|
5855
6258
|
});
|
|
5856
6259
|
return () => {
|
|
@@ -6016,7 +6419,7 @@ function useInterfaceAI({
|
|
|
6016
6419
|
}
|
|
6017
6420
|
const sendMessage = _react.useCallback.call(void 0, async (message) => {
|
|
6018
6421
|
accumulatedTextRef.current = "";
|
|
6019
|
-
_optionalChain([onStreamStart, 'optionalCall',
|
|
6422
|
+
_optionalChain([onStreamStart, 'optionalCall', _167 => _167()]);
|
|
6020
6423
|
const systemPrompt = [
|
|
6021
6424
|
generateInterfaceContext(),
|
|
6022
6425
|
context || ""
|
|
@@ -6039,27 +6442,27 @@ function useInterfaceAI({
|
|
|
6039
6442
|
accumulatedTextRef.current += chunk.content || "";
|
|
6040
6443
|
const parsed = parseInterfaceFromText(accumulatedTextRef.current);
|
|
6041
6444
|
if (parsed) {
|
|
6042
|
-
_optionalChain([onInterface, 'optionalCall',
|
|
6445
|
+
_optionalChain([onInterface, 'optionalCall', _168 => _168(parsed)]);
|
|
6043
6446
|
}
|
|
6044
6447
|
const updates = parseUpdatesFromText(accumulatedTextRef.current);
|
|
6045
6448
|
if (updates.length > 0) {
|
|
6046
|
-
_optionalChain([onUpdates, 'optionalCall',
|
|
6449
|
+
_optionalChain([onUpdates, 'optionalCall', _169 => _169(updates)]);
|
|
6047
6450
|
}
|
|
6048
6451
|
}
|
|
6049
6452
|
},
|
|
6050
6453
|
// onComplete
|
|
6051
6454
|
() => {
|
|
6052
|
-
_optionalChain([onStreamEnd, 'optionalCall',
|
|
6455
|
+
_optionalChain([onStreamEnd, 'optionalCall', _170 => _170()]);
|
|
6053
6456
|
},
|
|
6054
6457
|
// onError
|
|
6055
6458
|
(error) => {
|
|
6056
|
-
_optionalChain([onError, 'optionalCall',
|
|
6057
|
-
_optionalChain([onStreamEnd, 'optionalCall',
|
|
6459
|
+
_optionalChain([onError, 'optionalCall', _171 => _171(error)]);
|
|
6460
|
+
_optionalChain([onStreamEnd, 'optionalCall', _172 => _172()]);
|
|
6058
6461
|
}
|
|
6059
6462
|
);
|
|
6060
6463
|
} catch (error) {
|
|
6061
|
-
_optionalChain([onError, 'optionalCall',
|
|
6062
|
-
_optionalChain([onStreamEnd, 'optionalCall',
|
|
6464
|
+
_optionalChain([onError, 'optionalCall', _173 => _173(error instanceof Error ? error : new Error("Unknown error"))]);
|
|
6465
|
+
_optionalChain([onStreamEnd, 'optionalCall', _174 => _174()]);
|
|
6063
6466
|
}
|
|
6064
6467
|
}, [agentId, context, onInterface, onUpdates, onError, onStreamStart, onStreamEnd]);
|
|
6065
6468
|
return {
|
|
@@ -6103,5 +6506,7 @@ function useInterfaceAI({
|
|
|
6103
6506
|
|
|
6104
6507
|
|
|
6105
6508
|
|
|
6106
|
-
|
|
6509
|
+
|
|
6510
|
+
|
|
6511
|
+
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
6512
|
//# sourceMappingURL=index.js.map
|