@apteva/apteva-kit 0.1.104 → 0.1.106
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +34 -2
- package/dist/index.d.ts +34 -2
- package/dist/index.js +538 -127
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1039 -628
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
package/dist/index.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;
|
|
@@ -3669,21 +4068,27 @@ ${widgetContext}` : widgetContext;
|
|
|
3669
4068
|
case "content":
|
|
3670
4069
|
case "token":
|
|
3671
4070
|
if (chunk.content) {
|
|
3672
|
-
currentTextBuffer
|
|
3673
|
-
|
|
4071
|
+
if (!currentTextBuffer) {
|
|
4072
|
+
currentTextBuffer = chunk.content.trimStart();
|
|
4073
|
+
} else {
|
|
4074
|
+
currentTextBuffer += chunk.content;
|
|
4075
|
+
}
|
|
4076
|
+
if (currentTextBuffer) {
|
|
4077
|
+
updateMessage();
|
|
4078
|
+
}
|
|
3674
4079
|
}
|
|
3675
4080
|
break;
|
|
3676
4081
|
case "tool_call":
|
|
3677
4082
|
if (chunk.tool_id && chunk.tool_name) {
|
|
3678
4083
|
const displayName = chunk.tool_display_name || chunk.tool_name;
|
|
3679
4084
|
if (currentTextBuffer) {
|
|
3680
|
-
contentSegments.push({ type: "text", content: currentTextBuffer });
|
|
4085
|
+
contentSegments.push({ type: "text", content: currentTextBuffer.trimEnd() });
|
|
3681
4086
|
currentTextBuffer = "";
|
|
3682
4087
|
}
|
|
3683
4088
|
contentSegments.push({ type: "tool", id: chunk.tool_id, name: displayName, status: "preparing" });
|
|
3684
4089
|
toolInputBuffers[chunk.tool_id] = "";
|
|
3685
4090
|
setChatToolName(displayName);
|
|
3686
|
-
_optionalChain([onToolCall, 'optionalCall',
|
|
4091
|
+
_optionalChain([onToolCall, 'optionalCall', _90 => _90(chunk.tool_name, chunk.tool_id)]);
|
|
3687
4092
|
updateMessage();
|
|
3688
4093
|
}
|
|
3689
4094
|
break;
|
|
@@ -3743,7 +4148,7 @@ ${widgetContext}` : widgetContext;
|
|
|
3743
4148
|
toolSegment.result = chunk.content;
|
|
3744
4149
|
toolSegment.status = "completed";
|
|
3745
4150
|
toolSegment.isReceiving = false;
|
|
3746
|
-
_optionalChain([onToolResult, 'optionalCall',
|
|
4151
|
+
_optionalChain([onToolResult, 'optionalCall', _91 => _91(toolSegment.name, chunk.content)]);
|
|
3747
4152
|
}
|
|
3748
4153
|
setChatToolName(null);
|
|
3749
4154
|
updateMessage();
|
|
@@ -3760,6 +4165,7 @@ ${widgetContext}` : widgetContext;
|
|
|
3760
4165
|
}
|
|
3761
4166
|
},
|
|
3762
4167
|
(threadId2) => {
|
|
4168
|
+
currentTextBuffer = currentTextBuffer.trimEnd();
|
|
3763
4169
|
if (currentTextBuffer) {
|
|
3764
4170
|
const lastSegment = contentSegments[contentSegments.length - 1];
|
|
3765
4171
|
if (lastSegment && lastSegment.type === "text") {
|
|
@@ -3786,7 +4192,7 @@ ${widgetContext}` : widgetContext;
|
|
|
3786
4192
|
});
|
|
3787
4193
|
if (threadId2 && threadId2 !== currentThreadId) {
|
|
3788
4194
|
setCurrentThreadId(threadId2);
|
|
3789
|
-
_optionalChain([onThreadChange, 'optionalCall',
|
|
4195
|
+
_optionalChain([onThreadChange, 'optionalCall', _92 => _92(threadId2)]);
|
|
3790
4196
|
}
|
|
3791
4197
|
setIsLoading(false);
|
|
3792
4198
|
setCurrentRequestId(null);
|
|
@@ -3810,7 +4216,7 @@ ${widgetContext}` : widgetContext;
|
|
|
3810
4216
|
setIsLoading(false);
|
|
3811
4217
|
setCurrentRequestId(null);
|
|
3812
4218
|
setChatToolName(null);
|
|
3813
|
-
_optionalChain([onError, 'optionalCall',
|
|
4219
|
+
_optionalChain([onError, 'optionalCall', _93 => _93(error)]);
|
|
3814
4220
|
}
|
|
3815
4221
|
);
|
|
3816
4222
|
}
|
|
@@ -3823,7 +4229,7 @@ ${widgetContext}` : widgetContext;
|
|
|
3823
4229
|
metadata: { error: true }
|
|
3824
4230
|
};
|
|
3825
4231
|
setMessages((prev) => [...prev, errorMessage]);
|
|
3826
|
-
_optionalChain([onError, 'optionalCall',
|
|
4232
|
+
_optionalChain([onError, 'optionalCall', _94 => _94(error instanceof Error ? error : new Error("Unknown error"))]);
|
|
3827
4233
|
} finally {
|
|
3828
4234
|
setIsLoading(false);
|
|
3829
4235
|
}
|
|
@@ -3869,7 +4275,7 @@ ${planningInstruction}` : planningInstruction;
|
|
|
3869
4275
|
const error = err instanceof Error ? err : new Error("Failed to generate plan");
|
|
3870
4276
|
setCommandError(error);
|
|
3871
4277
|
setCommandState("error");
|
|
3872
|
-
_optionalChain([onError, 'optionalCall',
|
|
4278
|
+
_optionalChain([onError, 'optionalCall', _95 => _95(error)]);
|
|
3873
4279
|
}
|
|
3874
4280
|
}
|
|
3875
4281
|
return;
|
|
@@ -3902,12 +4308,12 @@ ${planningInstruction}` : planningInstruction;
|
|
|
3902
4308
|
setCommandResult(result);
|
|
3903
4309
|
setCommandState("success");
|
|
3904
4310
|
setProgress(100);
|
|
3905
|
-
_optionalChain([onComplete, 'optionalCall',
|
|
4311
|
+
_optionalChain([onComplete, 'optionalCall', _96 => _96(result)]);
|
|
3906
4312
|
},
|
|
3907
4313
|
(error) => {
|
|
3908
4314
|
setCommandError(error);
|
|
3909
4315
|
setCommandState("error");
|
|
3910
|
-
_optionalChain([onError, 'optionalCall',
|
|
4316
|
+
_optionalChain([onError, 'optionalCall', _97 => _97(error)]);
|
|
3911
4317
|
}
|
|
3912
4318
|
);
|
|
3913
4319
|
} else {
|
|
@@ -3920,7 +4326,7 @@ ${planningInstruction}` : planningInstruction;
|
|
|
3920
4326
|
setCommandResult(result);
|
|
3921
4327
|
setCommandState("success");
|
|
3922
4328
|
setProgress(100);
|
|
3923
|
-
_optionalChain([onComplete, 'optionalCall',
|
|
4329
|
+
_optionalChain([onComplete, 'optionalCall', _98 => _98(result)]);
|
|
3924
4330
|
}
|
|
3925
4331
|
} else {
|
|
3926
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.`;
|
|
@@ -3950,16 +4356,16 @@ ${commandInstruction}` : commandInstruction;
|
|
|
3950
4356
|
const displayName = chunk.tool_display_name || chunk.tool_name;
|
|
3951
4357
|
lastToolName = chunk.tool_name;
|
|
3952
4358
|
setCurrentToolName(displayName);
|
|
3953
|
-
_optionalChain([onToolCall, 'optionalCall',
|
|
4359
|
+
_optionalChain([onToolCall, 'optionalCall', _99 => _99(chunk.tool_name, chunk.tool_id || "")]);
|
|
3954
4360
|
accumulatedContent = "";
|
|
3955
4361
|
setStreamedContent("");
|
|
3956
4362
|
} else if (chunk.type === "tool_result") {
|
|
3957
|
-
_optionalChain([onToolResult, 'optionalCall',
|
|
4363
|
+
_optionalChain([onToolResult, 'optionalCall', _100 => _100(lastToolName, chunk.content)]);
|
|
3958
4364
|
setCurrentToolName(null);
|
|
3959
4365
|
} else if (chunk.type === "thread_id" && chunk.thread_id) {
|
|
3960
4366
|
if (!currentThreadId) {
|
|
3961
4367
|
setCurrentThreadId(chunk.thread_id);
|
|
3962
|
-
_optionalChain([onThreadChange, 'optionalCall',
|
|
4368
|
+
_optionalChain([onThreadChange, 'optionalCall', _101 => _101(chunk.thread_id)]);
|
|
3963
4369
|
}
|
|
3964
4370
|
} else if (chunk.type === "request_id" && chunk.request_id) {
|
|
3965
4371
|
setCurrentRequestId(chunk.request_id);
|
|
@@ -3975,13 +4381,13 @@ ${commandInstruction}` : commandInstruction;
|
|
|
3975
4381
|
setCommandState("success");
|
|
3976
4382
|
setProgress(100);
|
|
3977
4383
|
setCurrentRequestId(null);
|
|
3978
|
-
_optionalChain([onComplete, 'optionalCall',
|
|
4384
|
+
_optionalChain([onComplete, 'optionalCall', _102 => _102(result)]);
|
|
3979
4385
|
},
|
|
3980
4386
|
(error) => {
|
|
3981
4387
|
setCommandError(error);
|
|
3982
4388
|
setCommandState("error");
|
|
3983
4389
|
setCurrentRequestId(null);
|
|
3984
|
-
_optionalChain([onError, 'optionalCall',
|
|
4390
|
+
_optionalChain([onError, 'optionalCall', _103 => _103(error)]);
|
|
3985
4391
|
}
|
|
3986
4392
|
);
|
|
3987
4393
|
} else {
|
|
@@ -4001,14 +4407,14 @@ ${commandInstruction}` : commandInstruction;
|
|
|
4001
4407
|
setCommandResult(result);
|
|
4002
4408
|
setCommandState("success");
|
|
4003
4409
|
setProgress(100);
|
|
4004
|
-
_optionalChain([onComplete, 'optionalCall',
|
|
4410
|
+
_optionalChain([onComplete, 'optionalCall', _104 => _104(result)]);
|
|
4005
4411
|
}
|
|
4006
4412
|
}
|
|
4007
4413
|
} catch (err) {
|
|
4008
4414
|
const error = err instanceof Error ? err : new Error("Unknown error");
|
|
4009
4415
|
setCommandError(error);
|
|
4010
4416
|
setCommandState("error");
|
|
4011
|
-
_optionalChain([onError, 'optionalCall',
|
|
4417
|
+
_optionalChain([onError, 'optionalCall', _105 => _105(error)]);
|
|
4012
4418
|
}
|
|
4013
4419
|
};
|
|
4014
4420
|
const resetCommand = () => {
|
|
@@ -4067,6 +4473,7 @@ ${planToExecute}`;
|
|
|
4067
4473
|
] })
|
|
4068
4474
|
] }) }),
|
|
4069
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 }),
|
|
4070
4477
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4071
4478
|
MessageList,
|
|
4072
4479
|
{
|
|
@@ -4080,7 +4487,9 @@ ${planToExecute}`;
|
|
|
4080
4487
|
chatVariant: variant,
|
|
4081
4488
|
onPromptClick: (prompt) => handleSendMessage(prompt),
|
|
4082
4489
|
enableWidgets,
|
|
4083
|
-
onWidgetRender
|
|
4490
|
+
onWidgetRender,
|
|
4491
|
+
persistentWidgetIds,
|
|
4492
|
+
toolCallStyle
|
|
4084
4493
|
}
|
|
4085
4494
|
),
|
|
4086
4495
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
@@ -4104,8 +4513,8 @@ ${planToExecute}`;
|
|
|
4104
4513
|
executeCommand(text, files);
|
|
4105
4514
|
},
|
|
4106
4515
|
state: commandState,
|
|
4107
|
-
response: _optionalChain([commandResult, 'optionalAccess',
|
|
4108
|
-
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]),
|
|
4109
4518
|
plan,
|
|
4110
4519
|
streamedContent,
|
|
4111
4520
|
toolName: currentToolName,
|
|
@@ -4273,13 +4682,13 @@ ${planningInstruction}` : planningInstruction;
|
|
|
4273
4682
|
const error2 = err instanceof Error ? err : new Error("Failed to generate plan");
|
|
4274
4683
|
setError(error2);
|
|
4275
4684
|
setState("error");
|
|
4276
|
-
_optionalChain([onError, 'optionalCall',
|
|
4685
|
+
_optionalChain([onError, 'optionalCall', _110 => _110(error2)]);
|
|
4277
4686
|
});
|
|
4278
4687
|
} catch (err) {
|
|
4279
4688
|
const error2 = err instanceof Error ? err : new Error("Failed to generate plan");
|
|
4280
4689
|
setError(error2);
|
|
4281
4690
|
setState("error");
|
|
4282
|
-
_optionalChain([onError, 'optionalCall',
|
|
4691
|
+
_optionalChain([onError, 'optionalCall', _111 => _111(error2)]);
|
|
4283
4692
|
}
|
|
4284
4693
|
}
|
|
4285
4694
|
return;
|
|
@@ -4290,7 +4699,7 @@ ${planningInstruction}` : planningInstruction;
|
|
|
4290
4699
|
setStreamedContent("");
|
|
4291
4700
|
setCommand("");
|
|
4292
4701
|
setUploadedFiles([]);
|
|
4293
|
-
_optionalChain([onStart, 'optionalCall',
|
|
4702
|
+
_optionalChain([onStart, 'optionalCall', _112 => _112()]);
|
|
4294
4703
|
try {
|
|
4295
4704
|
if (useMock) {
|
|
4296
4705
|
if (enableStreaming) {
|
|
@@ -4301,16 +4710,16 @@ ${planningInstruction}` : planningInstruction;
|
|
|
4301
4710
|
if (chunk.type === "token" && chunk.content) {
|
|
4302
4711
|
accumulatedContent += chunk.content;
|
|
4303
4712
|
setStreamedContent(accumulatedContent);
|
|
4304
|
-
_optionalChain([onChunk, 'optionalCall',
|
|
4713
|
+
_optionalChain([onChunk, 'optionalCall', _113 => _113(chunk.content)]);
|
|
4305
4714
|
const estimatedProgress = Math.min(Math.round(accumulatedContent.length / 10), 90);
|
|
4306
4715
|
setProgress(estimatedProgress);
|
|
4307
|
-
_optionalChain([onProgress, 'optionalCall',
|
|
4716
|
+
_optionalChain([onProgress, 'optionalCall', _114 => _114(estimatedProgress)]);
|
|
4308
4717
|
} else if (chunk.type === "widget" && chunk.widget) {
|
|
4309
4718
|
const widget = chunk.widget;
|
|
4310
4719
|
setResult((prev) => ({
|
|
4311
4720
|
success: true,
|
|
4312
|
-
data: _optionalChain([prev, 'optionalAccess',
|
|
4313
|
-
widgets: [..._optionalChain([prev, 'optionalAccess',
|
|
4721
|
+
data: _optionalChain([prev, 'optionalAccess', _115 => _115.data]) || {},
|
|
4722
|
+
widgets: [..._optionalChain([prev, 'optionalAccess', _116 => _116.widgets]) || [], widget],
|
|
4314
4723
|
message: accumulatedContent || "Command executed successfully"
|
|
4315
4724
|
}));
|
|
4316
4725
|
}
|
|
@@ -4330,19 +4739,19 @@ ${planningInstruction}` : planningInstruction;
|
|
|
4330
4739
|
setResult(result2);
|
|
4331
4740
|
setState("success");
|
|
4332
4741
|
setProgress(100);
|
|
4333
|
-
_optionalChain([onComplete, 'optionalCall',
|
|
4742
|
+
_optionalChain([onComplete, 'optionalCall', _117 => _117(result2)]);
|
|
4334
4743
|
},
|
|
4335
4744
|
(error2) => {
|
|
4336
4745
|
setError(error2);
|
|
4337
4746
|
setState("error");
|
|
4338
|
-
_optionalChain([onError, 'optionalCall',
|
|
4747
|
+
_optionalChain([onError, 'optionalCall', _118 => _118(error2)]);
|
|
4339
4748
|
}
|
|
4340
4749
|
);
|
|
4341
4750
|
} else {
|
|
4342
4751
|
const progressInterval = setInterval(() => {
|
|
4343
4752
|
setProgress((prev) => {
|
|
4344
4753
|
const next = Math.min(prev + 10, 90);
|
|
4345
|
-
_optionalChain([onProgress, 'optionalCall',
|
|
4754
|
+
_optionalChain([onProgress, 'optionalCall', _119 => _119(next)]);
|
|
4346
4755
|
return next;
|
|
4347
4756
|
});
|
|
4348
4757
|
}, 200);
|
|
@@ -4366,7 +4775,7 @@ ${planningInstruction}` : planningInstruction;
|
|
|
4366
4775
|
setResult(result2);
|
|
4367
4776
|
setState("success");
|
|
4368
4777
|
setProgress(100);
|
|
4369
|
-
_optionalChain([onComplete, 'optionalCall',
|
|
4778
|
+
_optionalChain([onComplete, 'optionalCall', _120 => _120(result2)]);
|
|
4370
4779
|
}
|
|
4371
4780
|
} else {
|
|
4372
4781
|
if (enableStreaming) {
|
|
@@ -4412,16 +4821,16 @@ ${commandInstruction}` : commandInstruction;
|
|
|
4412
4821
|
if (chunk.type === "token" && chunk.content) {
|
|
4413
4822
|
accumulatedContent += chunk.content;
|
|
4414
4823
|
setStreamedContent(accumulatedContent);
|
|
4415
|
-
_optionalChain([onChunk, 'optionalCall',
|
|
4824
|
+
_optionalChain([onChunk, 'optionalCall', _121 => _121(chunk.content)]);
|
|
4416
4825
|
const estimatedProgress = Math.min(Math.round(accumulatedContent.length / 10), 90);
|
|
4417
4826
|
setProgress(estimatedProgress);
|
|
4418
|
-
_optionalChain([onProgress, 'optionalCall',
|
|
4827
|
+
_optionalChain([onProgress, 'optionalCall', _122 => _122(estimatedProgress)]);
|
|
4419
4828
|
} else if (chunk.type === "widget" && chunk.widget) {
|
|
4420
4829
|
const widget = chunk.widget;
|
|
4421
4830
|
setResult((prev) => ({
|
|
4422
4831
|
success: true,
|
|
4423
|
-
data: _optionalChain([prev, 'optionalAccess',
|
|
4424
|
-
widgets: [..._optionalChain([prev, 'optionalAccess',
|
|
4832
|
+
data: _optionalChain([prev, 'optionalAccess', _123 => _123.data]) || {},
|
|
4833
|
+
widgets: [..._optionalChain([prev, 'optionalAccess', _124 => _124.widgets]) || [], widget],
|
|
4425
4834
|
message: accumulatedContent || "Command executed successfully"
|
|
4426
4835
|
}));
|
|
4427
4836
|
}
|
|
@@ -4441,20 +4850,20 @@ ${commandInstruction}` : commandInstruction;
|
|
|
4441
4850
|
setResult(result2);
|
|
4442
4851
|
setState("success");
|
|
4443
4852
|
setProgress(100);
|
|
4444
|
-
_optionalChain([onComplete, 'optionalCall',
|
|
4853
|
+
_optionalChain([onComplete, 'optionalCall', _125 => _125(result2)]);
|
|
4445
4854
|
},
|
|
4446
4855
|
(error2) => {
|
|
4447
4856
|
const err = error2 instanceof Error ? error2 : new Error("Unknown error");
|
|
4448
4857
|
setError(err);
|
|
4449
4858
|
setState("error");
|
|
4450
|
-
_optionalChain([onError, 'optionalCall',
|
|
4859
|
+
_optionalChain([onError, 'optionalCall', _126 => _126(err)]);
|
|
4451
4860
|
}
|
|
4452
4861
|
);
|
|
4453
4862
|
} else {
|
|
4454
4863
|
const progressInterval = setInterval(() => {
|
|
4455
4864
|
setProgress((prev) => {
|
|
4456
4865
|
const next = Math.min(prev + 10, 90);
|
|
4457
|
-
_optionalChain([onProgress, 'optionalCall',
|
|
4866
|
+
_optionalChain([onProgress, 'optionalCall', _127 => _127(next)]);
|
|
4458
4867
|
return next;
|
|
4459
4868
|
});
|
|
4460
4869
|
}, 200);
|
|
@@ -4510,14 +4919,14 @@ ${commandInstruction}` : commandInstruction;
|
|
|
4510
4919
|
setResult(result2);
|
|
4511
4920
|
setState("success");
|
|
4512
4921
|
setProgress(100);
|
|
4513
|
-
_optionalChain([onComplete, 'optionalCall',
|
|
4922
|
+
_optionalChain([onComplete, 'optionalCall', _128 => _128(result2)]);
|
|
4514
4923
|
}
|
|
4515
4924
|
}
|
|
4516
4925
|
} catch (err) {
|
|
4517
4926
|
const error2 = err instanceof Error ? err : new Error("Unknown error");
|
|
4518
4927
|
setError(error2);
|
|
4519
4928
|
setState("error");
|
|
4520
|
-
_optionalChain([onError, 'optionalCall',
|
|
4929
|
+
_optionalChain([onError, 'optionalCall', _129 => _129(error2)]);
|
|
4521
4930
|
}
|
|
4522
4931
|
};
|
|
4523
4932
|
const resetCommand = () => {
|
|
@@ -4550,14 +4959,14 @@ ${planToExecute}`;
|
|
|
4550
4959
|
};
|
|
4551
4960
|
const handleFileSelect = async (e) => {
|
|
4552
4961
|
if (e.target.files && e.target.files.length > 0) {
|
|
4553
|
-
_optionalChain([onFileUpload, 'optionalCall',
|
|
4962
|
+
_optionalChain([onFileUpload, 'optionalCall', _130 => _130(e.target.files)]);
|
|
4554
4963
|
const files = [];
|
|
4555
4964
|
for (let i = 0; i < e.target.files.length; i++) {
|
|
4556
4965
|
const file = e.target.files[i];
|
|
4557
4966
|
const reader = new FileReader();
|
|
4558
4967
|
await new Promise((resolve) => {
|
|
4559
4968
|
reader.onload = (event) => {
|
|
4560
|
-
if (_optionalChain([event, 'access',
|
|
4969
|
+
if (_optionalChain([event, 'access', _131 => _131.target, 'optionalAccess', _132 => _132.result])) {
|
|
4561
4970
|
const fullDataUrl = event.target.result;
|
|
4562
4971
|
const base64Data = fullDataUrl.split(",")[1];
|
|
4563
4972
|
if (file.type.startsWith("image/")) {
|
|
@@ -4651,7 +5060,7 @@ ${planToExecute}`;
|
|
|
4651
5060
|
enableFileUpload && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4652
5061
|
"button",
|
|
4653
5062
|
{
|
|
4654
|
-
onClick: () => _optionalChain([fileInputRef, 'access',
|
|
5063
|
+
onClick: () => _optionalChain([fileInputRef, 'access', _133 => _133.current, 'optionalAccess', _134 => _134.click, 'call', _135 => _135()]),
|
|
4655
5064
|
className: "w-8 h-8 rounded-lg flex items-center justify-center transition-all flex-shrink-0 !text-neutral-500 dark:!text-neutral-500 hover:bg-neutral-100 dark:hover:bg-neutral-800",
|
|
4656
5065
|
title: "Attach file",
|
|
4657
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)" }) })
|
|
@@ -4870,7 +5279,7 @@ ${planToExecute}`;
|
|
|
4870
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" }) }),
|
|
4871
5280
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { children: [
|
|
4872
5281
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h3", { className: "text-sm font-semibold text-red-800 dark:text-red-400", children: "Error" }),
|
|
4873
|
-
/* @__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]) })
|
|
4874
5283
|
] })
|
|
4875
5284
|
] }) }),
|
|
4876
5285
|
allowInput && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
@@ -4898,7 +5307,7 @@ ${planToExecute}`;
|
|
|
4898
5307
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-green-700 dark:text-green-300 text-sm", children: "Command executed successfully" })
|
|
4899
5308
|
] })
|
|
4900
5309
|
] }),
|
|
4901
|
-
_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 }),
|
|
4902
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,
|
|
4903
5312
|
WidgetRenderer,
|
|
4904
5313
|
{
|
|
@@ -4949,7 +5358,7 @@ ${planToExecute}`;
|
|
|
4949
5358
|
enableFileUpload && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4950
5359
|
"button",
|
|
4951
5360
|
{
|
|
4952
|
-
onClick: () => _optionalChain([fileInputRef, 'access',
|
|
5361
|
+
onClick: () => _optionalChain([fileInputRef, 'access', _139 => _139.current, 'optionalAccess', _140 => _140.click, 'call', _141 => _141()]),
|
|
4953
5362
|
className: "w-8 h-8 rounded-lg flex items-center justify-center transition-all flex-shrink-0 !text-neutral-500 dark:!text-neutral-500 hover:bg-neutral-100 dark:hover:bg-neutral-800",
|
|
4954
5363
|
title: "Attach file",
|
|
4955
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)" }) })
|
|
@@ -5135,25 +5544,25 @@ function Prompt({
|
|
|
5135
5544
|
const newValue = e.target.value;
|
|
5136
5545
|
if (!maxLength || newValue.length <= maxLength) {
|
|
5137
5546
|
setValue(newValue);
|
|
5138
|
-
_optionalChain([onChange, 'optionalCall',
|
|
5547
|
+
_optionalChain([onChange, 'optionalCall', _142 => _142(newValue)]);
|
|
5139
5548
|
}
|
|
5140
5549
|
};
|
|
5141
5550
|
const handleSubmit = async () => {
|
|
5142
5551
|
if (value.length < minLength) return;
|
|
5143
|
-
_optionalChain([onSubmit, 'optionalCall',
|
|
5552
|
+
_optionalChain([onSubmit, 'optionalCall', _143 => _143(value)]);
|
|
5144
5553
|
setIsLoading(true);
|
|
5145
5554
|
try {
|
|
5146
5555
|
if (useMock) {
|
|
5147
5556
|
await new Promise((resolve) => setTimeout(resolve, 1500));
|
|
5148
5557
|
const mockResult = `Enhanced version: ${value} [AI-generated content]`;
|
|
5149
|
-
_optionalChain([onResult, 'optionalCall',
|
|
5558
|
+
_optionalChain([onResult, 'optionalCall', _144 => _144(mockResult)]);
|
|
5150
5559
|
setValue("");
|
|
5151
5560
|
} else {
|
|
5152
5561
|
const response = await aptevaClient.chat({
|
|
5153
5562
|
agent_id: agentId,
|
|
5154
5563
|
message: value
|
|
5155
5564
|
});
|
|
5156
|
-
_optionalChain([onResult, 'optionalCall',
|
|
5565
|
+
_optionalChain([onResult, 'optionalCall', _145 => _145(response.message)]);
|
|
5157
5566
|
setValue("");
|
|
5158
5567
|
}
|
|
5159
5568
|
} catch (error) {
|
|
@@ -5248,7 +5657,7 @@ function Stream({
|
|
|
5248
5657
|
}, [autoStart]);
|
|
5249
5658
|
const startStreaming = async () => {
|
|
5250
5659
|
setIsStreaming(true);
|
|
5251
|
-
_optionalChain([onStart, 'optionalCall',
|
|
5660
|
+
_optionalChain([onStart, 'optionalCall', _146 => _146()]);
|
|
5252
5661
|
try {
|
|
5253
5662
|
if (useMock) {
|
|
5254
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.";
|
|
@@ -5256,13 +5665,13 @@ function Stream({
|
|
|
5256
5665
|
mockText,
|
|
5257
5666
|
(chunk) => {
|
|
5258
5667
|
setText((prev) => prev + chunk);
|
|
5259
|
-
_optionalChain([onChunk, 'optionalCall',
|
|
5668
|
+
_optionalChain([onChunk, 'optionalCall', _147 => _147(chunk)]);
|
|
5260
5669
|
},
|
|
5261
5670
|
typingSpeed
|
|
5262
5671
|
);
|
|
5263
5672
|
setIsComplete(true);
|
|
5264
5673
|
setIsStreaming(false);
|
|
5265
|
-
_optionalChain([onComplete, 'optionalCall',
|
|
5674
|
+
_optionalChain([onComplete, 'optionalCall', _148 => _148(text + mockText)]);
|
|
5266
5675
|
} else {
|
|
5267
5676
|
let accumulatedText = "";
|
|
5268
5677
|
await aptevaClient.chatStream(
|
|
@@ -5275,24 +5684,24 @@ function Stream({
|
|
|
5275
5684
|
if (chunk.type === "token" && chunk.content) {
|
|
5276
5685
|
accumulatedText += chunk.content;
|
|
5277
5686
|
setText(accumulatedText);
|
|
5278
|
-
_optionalChain([onChunk, 'optionalCall',
|
|
5687
|
+
_optionalChain([onChunk, 'optionalCall', _149 => _149(chunk.content)]);
|
|
5279
5688
|
}
|
|
5280
5689
|
},
|
|
5281
5690
|
() => {
|
|
5282
5691
|
setIsComplete(true);
|
|
5283
5692
|
setIsStreaming(false);
|
|
5284
|
-
_optionalChain([onComplete, 'optionalCall',
|
|
5693
|
+
_optionalChain([onComplete, 'optionalCall', _150 => _150(accumulatedText)]);
|
|
5285
5694
|
},
|
|
5286
5695
|
(error) => {
|
|
5287
5696
|
const err = error instanceof Error ? error : new Error("Streaming error");
|
|
5288
|
-
_optionalChain([onError, 'optionalCall',
|
|
5697
|
+
_optionalChain([onError, 'optionalCall', _151 => _151(err)]);
|
|
5289
5698
|
setIsStreaming(false);
|
|
5290
5699
|
}
|
|
5291
5700
|
);
|
|
5292
5701
|
}
|
|
5293
5702
|
} catch (error) {
|
|
5294
5703
|
const err = error instanceof Error ? error : new Error("Streaming error");
|
|
5295
|
-
_optionalChain([onError, 'optionalCall',
|
|
5704
|
+
_optionalChain([onError, 'optionalCall', _152 => _152(err)]);
|
|
5296
5705
|
setIsStreaming(false);
|
|
5297
5706
|
}
|
|
5298
5707
|
};
|
|
@@ -5384,7 +5793,7 @@ function ThreadList({
|
|
|
5384
5793
|
}) {
|
|
5385
5794
|
const [searchQuery, setSearchQuery] = _react.useState.call(void 0, "");
|
|
5386
5795
|
const filteredThreads = threads.filter(
|
|
5387
|
-
(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())])
|
|
5388
5797
|
);
|
|
5389
5798
|
const groupedThreads = groupBy === "date" ? groupThreadsByDate(filteredThreads) : { All: filteredThreads };
|
|
5390
5799
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-col h-full", children: [
|
|
@@ -5406,8 +5815,8 @@ function ThreadList({
|
|
|
5406
5815
|
{
|
|
5407
5816
|
thread,
|
|
5408
5817
|
isActive: thread.id === currentThreadId,
|
|
5409
|
-
onSelect: () => _optionalChain([onThreadSelect, 'optionalCall',
|
|
5410
|
-
onDelete: () => _optionalChain([onThreadDelete, 'optionalCall',
|
|
5818
|
+
onSelect: () => _optionalChain([onThreadSelect, 'optionalCall', _158 => _158(thread.id)]),
|
|
5819
|
+
onDelete: () => _optionalChain([onThreadDelete, 'optionalCall', _159 => _159(thread.id)])
|
|
5411
5820
|
},
|
|
5412
5821
|
thread.id
|
|
5413
5822
|
))
|
|
@@ -5469,7 +5878,7 @@ function Threads({
|
|
|
5469
5878
|
threads.slice(0, 5).map((thread) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
5470
5879
|
"button",
|
|
5471
5880
|
{
|
|
5472
|
-
onClick: () => _optionalChain([onThreadSelect, 'optionalCall',
|
|
5881
|
+
onClick: () => _optionalChain([onThreadSelect, 'optionalCall', _160 => _160(thread.id)]),
|
|
5473
5882
|
className: cn(
|
|
5474
5883
|
"px-4 py-2 whitespace-nowrap font-medium transition-colors",
|
|
5475
5884
|
thread.id === currentThreadId ? "border-b-2 border-apteva-500 text-apteva-500" : "text-neutral-600 hover:text-neutral-900"
|
|
@@ -5654,7 +6063,7 @@ function TabsLayout({ node, renderNode }) {
|
|
|
5654
6063
|
var STRUCTURAL_KEYS = /* @__PURE__ */ new Set(["type", "id", "layout", "props", "children", "actions", "metadata", "isStreaming"]);
|
|
5655
6064
|
function normalizeNode(n) {
|
|
5656
6065
|
let node = { ...n };
|
|
5657
|
-
if (node.type === "widget" && _optionalChain([node, 'access',
|
|
6066
|
+
if (node.type === "widget" && _optionalChain([node, 'access', _161 => _161.props, 'optionalAccess', _162 => _162.widget])) {
|
|
5658
6067
|
node.type = node.props.widget;
|
|
5659
6068
|
const { widget: _, ...rest } = node.props;
|
|
5660
6069
|
node.props = rest;
|
|
@@ -5792,10 +6201,10 @@ function AutoInterface({
|
|
|
5792
6201
|
].filter(Boolean).join("\n\n");
|
|
5793
6202
|
const updateInterface = _react.useCallback.call(void 0, (newSpec) => {
|
|
5794
6203
|
setInterfaceSpec(newSpec);
|
|
5795
|
-
_optionalChain([onInterfaceChange, 'optionalCall',
|
|
6204
|
+
_optionalChain([onInterfaceChange, 'optionalCall', _163 => _163(newSpec)]);
|
|
5796
6205
|
}, [onInterfaceChange]);
|
|
5797
6206
|
const handleAction = _react.useCallback.call(void 0, (action) => {
|
|
5798
|
-
_optionalChain([onAction, 'optionalCall',
|
|
6207
|
+
_optionalChain([onAction, 'optionalCall', _164 => _164(action)]);
|
|
5799
6208
|
if (chatRef.current) {
|
|
5800
6209
|
chatRef.current.sendMessage(
|
|
5801
6210
|
`[Action: ${action.type} on widget ${action.widgetId || "unknown"}. Payload: ${JSON.stringify(action.payload)}]`
|
|
@@ -5803,7 +6212,7 @@ function AutoInterface({
|
|
|
5803
6212
|
}
|
|
5804
6213
|
}, [onAction]);
|
|
5805
6214
|
const handleMessageComplete = _react.useCallback.call(void 0, (result) => {
|
|
5806
|
-
if (!_optionalChain([result, 'optionalAccess',
|
|
6215
|
+
if (!_optionalChain([result, 'optionalAccess', _165 => _165.data])) return;
|
|
5807
6216
|
const text = typeof result.data === "string" ? result.data : result.data.message || "";
|
|
5808
6217
|
console.log("[AutoInterface] Chat message complete, text (" + text.length + " chars):", text.substring(0, 300));
|
|
5809
6218
|
const parsed = parseInterfaceFromText(text);
|
|
@@ -5843,7 +6252,7 @@ function AutoInterface({
|
|
|
5843
6252
|
}).catch((err) => {
|
|
5844
6253
|
if (cancelled) return;
|
|
5845
6254
|
console.error("[AutoInterface] Initial generation failed:", err);
|
|
5846
|
-
_optionalChain([onError, 'optionalCall',
|
|
6255
|
+
_optionalChain([onError, 'optionalCall', _166 => _166(err instanceof Error ? err : new Error(String(err)))]);
|
|
5847
6256
|
setIsGenerating(false);
|
|
5848
6257
|
});
|
|
5849
6258
|
return () => {
|
|
@@ -6009,7 +6418,7 @@ function useInterfaceAI({
|
|
|
6009
6418
|
}
|
|
6010
6419
|
const sendMessage = _react.useCallback.call(void 0, async (message) => {
|
|
6011
6420
|
accumulatedTextRef.current = "";
|
|
6012
|
-
_optionalChain([onStreamStart, 'optionalCall',
|
|
6421
|
+
_optionalChain([onStreamStart, 'optionalCall', _167 => _167()]);
|
|
6013
6422
|
const systemPrompt = [
|
|
6014
6423
|
generateInterfaceContext(),
|
|
6015
6424
|
context || ""
|
|
@@ -6032,27 +6441,27 @@ function useInterfaceAI({
|
|
|
6032
6441
|
accumulatedTextRef.current += chunk.content || "";
|
|
6033
6442
|
const parsed = parseInterfaceFromText(accumulatedTextRef.current);
|
|
6034
6443
|
if (parsed) {
|
|
6035
|
-
_optionalChain([onInterface, 'optionalCall',
|
|
6444
|
+
_optionalChain([onInterface, 'optionalCall', _168 => _168(parsed)]);
|
|
6036
6445
|
}
|
|
6037
6446
|
const updates = parseUpdatesFromText(accumulatedTextRef.current);
|
|
6038
6447
|
if (updates.length > 0) {
|
|
6039
|
-
_optionalChain([onUpdates, 'optionalCall',
|
|
6448
|
+
_optionalChain([onUpdates, 'optionalCall', _169 => _169(updates)]);
|
|
6040
6449
|
}
|
|
6041
6450
|
}
|
|
6042
6451
|
},
|
|
6043
6452
|
// onComplete
|
|
6044
6453
|
() => {
|
|
6045
|
-
_optionalChain([onStreamEnd, 'optionalCall',
|
|
6454
|
+
_optionalChain([onStreamEnd, 'optionalCall', _170 => _170()]);
|
|
6046
6455
|
},
|
|
6047
6456
|
// onError
|
|
6048
6457
|
(error) => {
|
|
6049
|
-
_optionalChain([onError, 'optionalCall',
|
|
6050
|
-
_optionalChain([onStreamEnd, 'optionalCall',
|
|
6458
|
+
_optionalChain([onError, 'optionalCall', _171 => _171(error)]);
|
|
6459
|
+
_optionalChain([onStreamEnd, 'optionalCall', _172 => _172()]);
|
|
6051
6460
|
}
|
|
6052
6461
|
);
|
|
6053
6462
|
} catch (error) {
|
|
6054
|
-
_optionalChain([onError, 'optionalCall',
|
|
6055
|
-
_optionalChain([onStreamEnd, 'optionalCall',
|
|
6463
|
+
_optionalChain([onError, 'optionalCall', _173 => _173(error instanceof Error ? error : new Error("Unknown error"))]);
|
|
6464
|
+
_optionalChain([onStreamEnd, 'optionalCall', _174 => _174()]);
|
|
6056
6465
|
}
|
|
6057
6466
|
}, [agentId, context, onInterface, onUpdates, onError, onStreamStart, onStreamEnd]);
|
|
6058
6467
|
return {
|
|
@@ -6096,5 +6505,7 @@ function useInterfaceAI({
|
|
|
6096
6505
|
|
|
6097
6506
|
|
|
6098
6507
|
|
|
6099
|
-
|
|
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;
|
|
6100
6511
|
//# sourceMappingURL=index.js.map
|