@apteva/apteva-kit 0.1.59 → 0.1.60
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 +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +200 -79
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +594 -473
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -913,6 +913,125 @@ function Table({ widget, onAction }) {
|
|
|
913
913
|
] }) }) });
|
|
914
914
|
}
|
|
915
915
|
|
|
916
|
+
// src/components/Widgets/widget-library/Form.tsx
|
|
917
|
+
|
|
918
|
+
|
|
919
|
+
function Form({ widget, onAction }) {
|
|
920
|
+
const { title, fields } = widget.props;
|
|
921
|
+
const [formData, setFormData] = _react.useState.call(void 0, () => {
|
|
922
|
+
const initial = {};
|
|
923
|
+
fields.forEach((field) => {
|
|
924
|
+
initial[field.name] = _nullishCoalesce(field.defaultValue, () => ( (field.type === "checkbox" ? false : "")));
|
|
925
|
+
});
|
|
926
|
+
return initial;
|
|
927
|
+
});
|
|
928
|
+
const handleChange = (name, value) => {
|
|
929
|
+
setFormData((prev) => ({ ...prev, [name]: value }));
|
|
930
|
+
};
|
|
931
|
+
const handleSubmit = (e) => {
|
|
932
|
+
e.preventDefault();
|
|
933
|
+
if (_optionalChain([widget, 'access', _18 => _18.actions, 'optionalAccess', _19 => _19[0]]) && onAction) {
|
|
934
|
+
onAction({
|
|
935
|
+
type: widget.actions[0].type,
|
|
936
|
+
payload: { ...widget.actions[0].payload, formData },
|
|
937
|
+
widgetId: widget.id,
|
|
938
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
939
|
+
});
|
|
940
|
+
}
|
|
941
|
+
};
|
|
942
|
+
const renderField = (field) => {
|
|
943
|
+
const baseInputClass = cn(
|
|
944
|
+
"w-full px-3 py-2 rounded-lg border transition-colors",
|
|
945
|
+
"border-neutral-300 dark:border-neutral-600",
|
|
946
|
+
"bg-white dark:bg-neutral-800",
|
|
947
|
+
"text-neutral-900 dark:text-neutral-100",
|
|
948
|
+
"placeholder-neutral-400 dark:placeholder-neutral-500",
|
|
949
|
+
"focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent"
|
|
950
|
+
);
|
|
951
|
+
switch (field.type) {
|
|
952
|
+
case "text":
|
|
953
|
+
case "password":
|
|
954
|
+
case "number":
|
|
955
|
+
case "date":
|
|
956
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
957
|
+
"input",
|
|
958
|
+
{
|
|
959
|
+
type: field.type,
|
|
960
|
+
name: field.name,
|
|
961
|
+
value: formData[field.name] || "",
|
|
962
|
+
onChange: (e) => handleChange(field.name, field.type === "number" ? Number(e.target.value) : e.target.value),
|
|
963
|
+
placeholder: field.placeholder,
|
|
964
|
+
required: field.required,
|
|
965
|
+
className: baseInputClass
|
|
966
|
+
}
|
|
967
|
+
);
|
|
968
|
+
case "textarea":
|
|
969
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
970
|
+
"textarea",
|
|
971
|
+
{
|
|
972
|
+
name: field.name,
|
|
973
|
+
value: formData[field.name] || "",
|
|
974
|
+
onChange: (e) => handleChange(field.name, e.target.value),
|
|
975
|
+
placeholder: field.placeholder,
|
|
976
|
+
required: field.required,
|
|
977
|
+
rows: 3,
|
|
978
|
+
className: baseInputClass
|
|
979
|
+
}
|
|
980
|
+
);
|
|
981
|
+
case "select":
|
|
982
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
983
|
+
"select",
|
|
984
|
+
{
|
|
985
|
+
name: field.name,
|
|
986
|
+
value: formData[field.name] || "",
|
|
987
|
+
onChange: (e) => handleChange(field.name, e.target.value),
|
|
988
|
+
required: field.required,
|
|
989
|
+
className: baseInputClass,
|
|
990
|
+
children: [
|
|
991
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "option", { value: "", children: field.placeholder || "Select..." }),
|
|
992
|
+
_optionalChain([field, 'access', _20 => _20.options, 'optionalAccess', _21 => _21.map, 'call', _22 => _22((opt) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "option", { value: opt.value, children: opt.label }, opt.value))])
|
|
993
|
+
]
|
|
994
|
+
}
|
|
995
|
+
);
|
|
996
|
+
case "checkbox":
|
|
997
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "label", { className: "flex items-center gap-2 cursor-pointer", children: [
|
|
998
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
999
|
+
"input",
|
|
1000
|
+
{
|
|
1001
|
+
type: "checkbox",
|
|
1002
|
+
name: field.name,
|
|
1003
|
+
checked: formData[field.name] || false,
|
|
1004
|
+
onChange: (e) => handleChange(field.name, e.target.checked),
|
|
1005
|
+
className: "w-4 h-4 rounded border-neutral-300 dark:border-neutral-600 text-blue-500 focus:ring-blue-500"
|
|
1006
|
+
}
|
|
1007
|
+
),
|
|
1008
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-neutral-700 dark:text-neutral-300", children: field.label })
|
|
1009
|
+
] });
|
|
1010
|
+
default:
|
|
1011
|
+
return null;
|
|
1012
|
+
}
|
|
1013
|
+
};
|
|
1014
|
+
const submitAction = _optionalChain([widget, 'access', _23 => _23.actions, 'optionalAccess', _24 => _24.find, 'call', _25 => _25((a) => a.type === "submit")]) || _optionalChain([widget, 'access', _26 => _26.actions, 'optionalAccess', _27 => _27[0]]);
|
|
1015
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "form", { onSubmit: handleSubmit, className: "apteva-form rounded-lg border border-neutral-200 dark:border-neutral-700 p-4 bg-white dark:bg-neutral-800", children: [
|
|
1016
|
+
title && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h3", { className: "text-base font-semibold text-neutral-900 dark:text-neutral-100 mb-4", children: title }),
|
|
1017
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "space-y-4", children: fields.map((field) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: field.type === "checkbox" ? "" : "space-y-1", children: [
|
|
1018
|
+
field.type !== "checkbox" && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "label", { className: "block text-sm font-medium text-neutral-700 dark:text-neutral-300", children: [
|
|
1019
|
+
field.label,
|
|
1020
|
+
field.required && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-red-500 ml-1", children: "*" })
|
|
1021
|
+
] }),
|
|
1022
|
+
renderField(field)
|
|
1023
|
+
] }, field.name)) }),
|
|
1024
|
+
submitAction && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "mt-4", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1025
|
+
"button",
|
|
1026
|
+
{
|
|
1027
|
+
type: "submit",
|
|
1028
|
+
className: "px-4 py-2 rounded-lg font-medium transition-colors bg-blue-500 text-white hover:bg-blue-600",
|
|
1029
|
+
children: submitAction.label || "Submit"
|
|
1030
|
+
}
|
|
1031
|
+
) })
|
|
1032
|
+
] });
|
|
1033
|
+
}
|
|
1034
|
+
|
|
916
1035
|
// src/components/Widgets/WidgetRenderer.tsx
|
|
917
1036
|
|
|
918
1037
|
function WidgetRenderer({ widget, onAction }) {
|
|
@@ -928,6 +1047,8 @@ function WidgetRenderer({ widget, onAction }) {
|
|
|
928
1047
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ButtonGroup, { widget, onAction });
|
|
929
1048
|
case "table":
|
|
930
1049
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Table, { widget, onAction });
|
|
1050
|
+
case "form":
|
|
1051
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Form, { widget, onAction });
|
|
931
1052
|
default:
|
|
932
1053
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "p-4 border border-yellow-300 bg-yellow-50 rounded-lg", children: [
|
|
933
1054
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "p", { className: "text-sm text-yellow-800", children: [
|
|
@@ -954,7 +1075,7 @@ function Widgets({
|
|
|
954
1075
|
}) {
|
|
955
1076
|
_react.useEffect.call(void 0, () => {
|
|
956
1077
|
widgets.forEach((widget) => {
|
|
957
|
-
_optionalChain([onWidgetMount, 'optionalCall',
|
|
1078
|
+
_optionalChain([onWidgetMount, 'optionalCall', _28 => _28(widget.id)]);
|
|
958
1079
|
});
|
|
959
1080
|
}, [widgets, onWidgetMount]);
|
|
960
1081
|
const layoutClasses = {
|
|
@@ -1257,8 +1378,8 @@ function ToolCall({ name, status }) {
|
|
|
1257
1378
|
|
|
1258
1379
|
function Message({ message, onAction, enableWidgets, onWidgetRender }) {
|
|
1259
1380
|
const isUser = message.role === "user";
|
|
1260
|
-
const contentSegments = _optionalChain([message, 'access',
|
|
1261
|
-
const isStreaming = _optionalChain([message, 'access',
|
|
1381
|
+
const contentSegments = _optionalChain([message, 'access', _29 => _29.metadata, 'optionalAccess', _30 => _30.content_segments]);
|
|
1382
|
+
const isStreaming = _optionalChain([message, 'access', _31 => _31.metadata, 'optionalAccess', _32 => _32.isStreaming]) === true;
|
|
1262
1383
|
const hasContent = message.content || contentSegments && contentSegments.length > 0;
|
|
1263
1384
|
const reportedWidgetsRef = _react.useRef.call(void 0, /* @__PURE__ */ new Set());
|
|
1264
1385
|
const parsedWidgets = _react.useMemo.call(void 0, () => {
|
|
@@ -1698,7 +1819,7 @@ function Composer({ onSendMessage, placeholder = "Type a message...", disabled =
|
|
|
1698
1819
|
setFileError(errors.join(", "));
|
|
1699
1820
|
setTimeout(() => setFileError(null), 5e3);
|
|
1700
1821
|
}
|
|
1701
|
-
_optionalChain([onFileUpload, 'optionalCall',
|
|
1822
|
+
_optionalChain([onFileUpload, 'optionalCall', _33 => _33(e.target.files)]);
|
|
1702
1823
|
setShowMenu(false);
|
|
1703
1824
|
e.target.value = "";
|
|
1704
1825
|
}
|
|
@@ -1768,15 +1889,15 @@ function Composer({ onSendMessage, placeholder = "Type a message...", disabled =
|
|
|
1768
1889
|
{
|
|
1769
1890
|
className: "apteva-composer-menu fixed bg-neutral-800 dark:bg-neutral-800 rounded-xl shadow-lg overflow-hidden z-[9999] min-w-[200px]",
|
|
1770
1891
|
style: {
|
|
1771
|
-
left: _nullishCoalesce(_optionalChain([menuButtonRef, 'access',
|
|
1772
|
-
top: (_nullishCoalesce(_optionalChain([menuButtonRef, 'access',
|
|
1892
|
+
left: _nullishCoalesce(_optionalChain([menuButtonRef, 'access', _34 => _34.current, 'optionalAccess', _35 => _35.getBoundingClientRect, 'call', _36 => _36(), 'access', _37 => _37.left]), () => ( 0)),
|
|
1893
|
+
top: (_nullishCoalesce(_optionalChain([menuButtonRef, 'access', _38 => _38.current, 'optionalAccess', _39 => _39.getBoundingClientRect, 'call', _40 => _40(), 'access', _41 => _41.bottom]), () => ( 0))) + 8
|
|
1773
1894
|
},
|
|
1774
1895
|
children: [
|
|
1775
1896
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1776
1897
|
"button",
|
|
1777
1898
|
{
|
|
1778
1899
|
onClick: () => {
|
|
1779
|
-
_optionalChain([fileInputRef, 'access',
|
|
1900
|
+
_optionalChain([fileInputRef, 'access', _42 => _42.current, 'optionalAccess', _43 => _43.click, 'call', _44 => _44()]);
|
|
1780
1901
|
setShowMenu(false);
|
|
1781
1902
|
},
|
|
1782
1903
|
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",
|
|
@@ -1895,8 +2016,8 @@ function CommandComposer({
|
|
|
1895
2016
|
}
|
|
1896
2017
|
};
|
|
1897
2018
|
const handleNewCommand = () => {
|
|
1898
|
-
_optionalChain([onReset, 'optionalCall',
|
|
1899
|
-
_optionalChain([inputRef, 'access',
|
|
2019
|
+
_optionalChain([onReset, 'optionalCall', _45 => _45()]);
|
|
2020
|
+
_optionalChain([inputRef, 'access', _46 => _46.current, 'optionalAccess', _47 => _47.focus, 'call', _48 => _48()]);
|
|
1900
2021
|
};
|
|
1901
2022
|
const handleInputChange = (value) => {
|
|
1902
2023
|
setInput(value);
|
|
@@ -2010,15 +2131,15 @@ function CommandComposer({
|
|
|
2010
2131
|
{
|
|
2011
2132
|
className: "apteva-composer-menu fixed bg-neutral-800 dark:bg-neutral-800 rounded-xl shadow-lg overflow-hidden z-[9999] min-w-[200px]",
|
|
2012
2133
|
style: {
|
|
2013
|
-
left: _nullishCoalesce(_optionalChain([menuButtonRef, 'access',
|
|
2014
|
-
top: (_nullishCoalesce(_optionalChain([menuButtonRef, 'access',
|
|
2134
|
+
left: _nullishCoalesce(_optionalChain([menuButtonRef, 'access', _49 => _49.current, 'optionalAccess', _50 => _50.getBoundingClientRect, 'call', _51 => _51(), 'access', _52 => _52.left]), () => ( 0)),
|
|
2135
|
+
top: (_nullishCoalesce(_optionalChain([menuButtonRef, 'access', _53 => _53.current, 'optionalAccess', _54 => _54.getBoundingClientRect, 'call', _55 => _55(), 'access', _56 => _56.bottom]), () => ( 0))) + 8
|
|
2015
2136
|
},
|
|
2016
2137
|
children: [
|
|
2017
2138
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
2018
2139
|
"button",
|
|
2019
2140
|
{
|
|
2020
2141
|
onClick: () => {
|
|
2021
|
-
_optionalChain([fileInputRef, 'access',
|
|
2142
|
+
_optionalChain([fileInputRef, 'access', _57 => _57.current, 'optionalAccess', _58 => _58.click, 'call', _59 => _59()]);
|
|
2022
2143
|
setShowMenu(false);
|
|
2023
2144
|
},
|
|
2024
2145
|
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",
|
|
@@ -2259,7 +2380,7 @@ var AptevaClient = class {
|
|
|
2259
2380
|
const error = await response.json().catch(() => ({ error: "Request failed" }));
|
|
2260
2381
|
throw new Error(error.error || `Request failed with status ${response.status}`);
|
|
2261
2382
|
}
|
|
2262
|
-
const reader = _optionalChain([response, 'access',
|
|
2383
|
+
const reader = _optionalChain([response, 'access', _60 => _60.body, 'optionalAccess', _61 => _61.getReader, 'call', _62 => _62()]);
|
|
2263
2384
|
if (!reader) {
|
|
2264
2385
|
throw new Error("Response body is not readable");
|
|
2265
2386
|
}
|
|
@@ -2277,7 +2398,7 @@ var AptevaClient = class {
|
|
|
2277
2398
|
if (line.startsWith("data: ")) {
|
|
2278
2399
|
const data = line.slice(6);
|
|
2279
2400
|
if (data === "[DONE]") {
|
|
2280
|
-
_optionalChain([onComplete, 'optionalCall',
|
|
2401
|
+
_optionalChain([onComplete, 'optionalCall', _63 => _63(threadId)]);
|
|
2281
2402
|
return;
|
|
2282
2403
|
}
|
|
2283
2404
|
try {
|
|
@@ -2292,10 +2413,10 @@ var AptevaClient = class {
|
|
|
2292
2413
|
}
|
|
2293
2414
|
}
|
|
2294
2415
|
}
|
|
2295
|
-
_optionalChain([onComplete, 'optionalCall',
|
|
2416
|
+
_optionalChain([onComplete, 'optionalCall', _64 => _64(threadId)]);
|
|
2296
2417
|
} catch (error) {
|
|
2297
2418
|
const err = error instanceof Error ? error : new Error("Unknown error");
|
|
2298
|
-
_optionalChain([onError, 'optionalCall',
|
|
2419
|
+
_optionalChain([onError, 'optionalCall', _65 => _65(err)]);
|
|
2299
2420
|
throw err;
|
|
2300
2421
|
}
|
|
2301
2422
|
}
|
|
@@ -2455,7 +2576,7 @@ ${widgetContext}` : widgetContext;
|
|
|
2455
2576
|
}, [apiUrl, apiKey]);
|
|
2456
2577
|
_react.useEffect.call(void 0, () => {
|
|
2457
2578
|
if (threadId) {
|
|
2458
|
-
_optionalChain([onThreadChange, 'optionalCall',
|
|
2579
|
+
_optionalChain([onThreadChange, 'optionalCall', _66 => _66(threadId)]);
|
|
2459
2580
|
}
|
|
2460
2581
|
}, [threadId, onThreadChange]);
|
|
2461
2582
|
_react.useEffect.call(void 0, () => {
|
|
@@ -2473,7 +2594,7 @@ ${widgetContext}` : widgetContext;
|
|
|
2473
2594
|
}, [showSettingsMenu]);
|
|
2474
2595
|
const handleModeChange = (newMode) => {
|
|
2475
2596
|
setMode(newMode);
|
|
2476
|
-
_optionalChain([onModeChange, 'optionalCall',
|
|
2597
|
+
_optionalChain([onModeChange, 'optionalCall', _67 => _67(newMode)]);
|
|
2477
2598
|
if (newMode === "command") {
|
|
2478
2599
|
setCommandState("idle");
|
|
2479
2600
|
setCommandResult(null);
|
|
@@ -2494,7 +2615,7 @@ ${widgetContext}` : widgetContext;
|
|
|
2494
2615
|
metadata: hasFiles ? { attachments: fileNames } : void 0
|
|
2495
2616
|
};
|
|
2496
2617
|
setMessages((prev) => [...prev, userMessage]);
|
|
2497
|
-
_optionalChain([onMessageSent, 'optionalCall',
|
|
2618
|
+
_optionalChain([onMessageSent, 'optionalCall', _68 => _68(userMessage)]);
|
|
2498
2619
|
}
|
|
2499
2620
|
setIsLoading(true);
|
|
2500
2621
|
try {
|
|
@@ -2561,7 +2682,7 @@ ${widgetContext}` : widgetContext;
|
|
|
2561
2682
|
responseThreadId = chunk.thread_id;
|
|
2562
2683
|
if (!currentThreadId) {
|
|
2563
2684
|
setCurrentThreadId(chunk.thread_id);
|
|
2564
|
-
_optionalChain([onThreadChange, 'optionalCall',
|
|
2685
|
+
_optionalChain([onThreadChange, 'optionalCall', _69 => _69(chunk.thread_id)]);
|
|
2565
2686
|
}
|
|
2566
2687
|
}
|
|
2567
2688
|
break;
|
|
@@ -2586,7 +2707,7 @@ ${widgetContext}` : widgetContext;
|
|
|
2586
2707
|
contentSegments.push({ type: "tool", id: chunk.tool_id, name: chunk.tool_name });
|
|
2587
2708
|
toolInputBuffer = "";
|
|
2588
2709
|
setChatToolName(chunk.tool_name);
|
|
2589
|
-
_optionalChain([onToolCall, 'optionalCall',
|
|
2710
|
+
_optionalChain([onToolCall, 'optionalCall', _70 => _70(chunk.tool_name, chunk.tool_id)]);
|
|
2590
2711
|
updateMessage();
|
|
2591
2712
|
}
|
|
2592
2713
|
break;
|
|
@@ -2600,7 +2721,7 @@ ${widgetContext}` : widgetContext;
|
|
|
2600
2721
|
const toolSegment = contentSegments.find((s) => s.type === "tool" && s.id === chunk.tool_id);
|
|
2601
2722
|
if (toolSegment) {
|
|
2602
2723
|
toolSegment.result = chunk.content;
|
|
2603
|
-
_optionalChain([onToolResult, 'optionalCall',
|
|
2724
|
+
_optionalChain([onToolResult, 'optionalCall', _71 => _71(toolSegment.name, chunk.content)]);
|
|
2604
2725
|
}
|
|
2605
2726
|
setChatToolName(null);
|
|
2606
2727
|
updateMessage();
|
|
@@ -2643,7 +2764,7 @@ ${widgetContext}` : widgetContext;
|
|
|
2643
2764
|
});
|
|
2644
2765
|
if (threadId2 && threadId2 !== currentThreadId) {
|
|
2645
2766
|
setCurrentThreadId(threadId2);
|
|
2646
|
-
_optionalChain([onThreadChange, 'optionalCall',
|
|
2767
|
+
_optionalChain([onThreadChange, 'optionalCall', _72 => _72(threadId2)]);
|
|
2647
2768
|
}
|
|
2648
2769
|
setIsLoading(false);
|
|
2649
2770
|
setCurrentRequestId(null);
|
|
@@ -2667,7 +2788,7 @@ ${widgetContext}` : widgetContext;
|
|
|
2667
2788
|
setIsLoading(false);
|
|
2668
2789
|
setCurrentRequestId(null);
|
|
2669
2790
|
setChatToolName(null);
|
|
2670
|
-
_optionalChain([onError, 'optionalCall',
|
|
2791
|
+
_optionalChain([onError, 'optionalCall', _73 => _73(error)]);
|
|
2671
2792
|
}
|
|
2672
2793
|
);
|
|
2673
2794
|
}
|
|
@@ -2680,7 +2801,7 @@ ${widgetContext}` : widgetContext;
|
|
|
2680
2801
|
metadata: { error: true }
|
|
2681
2802
|
};
|
|
2682
2803
|
setMessages((prev) => [...prev, errorMessage]);
|
|
2683
|
-
_optionalChain([onError, 'optionalCall',
|
|
2804
|
+
_optionalChain([onError, 'optionalCall', _74 => _74(error instanceof Error ? error : new Error("Unknown error"))]);
|
|
2684
2805
|
} finally {
|
|
2685
2806
|
setIsLoading(false);
|
|
2686
2807
|
}
|
|
@@ -2726,7 +2847,7 @@ ${planningInstruction}` : planningInstruction;
|
|
|
2726
2847
|
const error = err instanceof Error ? err : new Error("Failed to generate plan");
|
|
2727
2848
|
setCommandError(error);
|
|
2728
2849
|
setCommandState("error");
|
|
2729
|
-
_optionalChain([onError, 'optionalCall',
|
|
2850
|
+
_optionalChain([onError, 'optionalCall', _75 => _75(error)]);
|
|
2730
2851
|
}
|
|
2731
2852
|
}
|
|
2732
2853
|
return;
|
|
@@ -2759,12 +2880,12 @@ ${planningInstruction}` : planningInstruction;
|
|
|
2759
2880
|
setCommandResult(result);
|
|
2760
2881
|
setCommandState("success");
|
|
2761
2882
|
setProgress(100);
|
|
2762
|
-
_optionalChain([onComplete, 'optionalCall',
|
|
2883
|
+
_optionalChain([onComplete, 'optionalCall', _76 => _76(result)]);
|
|
2763
2884
|
},
|
|
2764
2885
|
(error) => {
|
|
2765
2886
|
setCommandError(error);
|
|
2766
2887
|
setCommandState("error");
|
|
2767
|
-
_optionalChain([onError, 'optionalCall',
|
|
2888
|
+
_optionalChain([onError, 'optionalCall', _77 => _77(error)]);
|
|
2768
2889
|
}
|
|
2769
2890
|
);
|
|
2770
2891
|
} else {
|
|
@@ -2777,7 +2898,7 @@ ${planningInstruction}` : planningInstruction;
|
|
|
2777
2898
|
setCommandResult(result);
|
|
2778
2899
|
setCommandState("success");
|
|
2779
2900
|
setProgress(100);
|
|
2780
|
-
_optionalChain([onComplete, 'optionalCall',
|
|
2901
|
+
_optionalChain([onComplete, 'optionalCall', _78 => _78(result)]);
|
|
2781
2902
|
}
|
|
2782
2903
|
} else {
|
|
2783
2904
|
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.`;
|
|
@@ -2806,16 +2927,16 @@ ${commandInstruction}` : commandInstruction;
|
|
|
2806
2927
|
} else if (chunk.type === "tool_call" && chunk.tool_name) {
|
|
2807
2928
|
lastToolName = chunk.tool_name;
|
|
2808
2929
|
setCurrentToolName(chunk.tool_name);
|
|
2809
|
-
_optionalChain([onToolCall, 'optionalCall',
|
|
2930
|
+
_optionalChain([onToolCall, 'optionalCall', _79 => _79(chunk.tool_name, chunk.tool_id || "")]);
|
|
2810
2931
|
accumulatedContent = "";
|
|
2811
2932
|
setStreamedContent("");
|
|
2812
2933
|
} else if (chunk.type === "tool_result") {
|
|
2813
|
-
_optionalChain([onToolResult, 'optionalCall',
|
|
2934
|
+
_optionalChain([onToolResult, 'optionalCall', _80 => _80(lastToolName, chunk.content)]);
|
|
2814
2935
|
setCurrentToolName(null);
|
|
2815
2936
|
} else if (chunk.type === "thread_id" && chunk.thread_id) {
|
|
2816
2937
|
if (!currentThreadId) {
|
|
2817
2938
|
setCurrentThreadId(chunk.thread_id);
|
|
2818
|
-
_optionalChain([onThreadChange, 'optionalCall',
|
|
2939
|
+
_optionalChain([onThreadChange, 'optionalCall', _81 => _81(chunk.thread_id)]);
|
|
2819
2940
|
}
|
|
2820
2941
|
} else if (chunk.type === "request_id" && chunk.request_id) {
|
|
2821
2942
|
setCurrentRequestId(chunk.request_id);
|
|
@@ -2831,13 +2952,13 @@ ${commandInstruction}` : commandInstruction;
|
|
|
2831
2952
|
setCommandState("success");
|
|
2832
2953
|
setProgress(100);
|
|
2833
2954
|
setCurrentRequestId(null);
|
|
2834
|
-
_optionalChain([onComplete, 'optionalCall',
|
|
2955
|
+
_optionalChain([onComplete, 'optionalCall', _82 => _82(result)]);
|
|
2835
2956
|
},
|
|
2836
2957
|
(error) => {
|
|
2837
2958
|
setCommandError(error);
|
|
2838
2959
|
setCommandState("error");
|
|
2839
2960
|
setCurrentRequestId(null);
|
|
2840
|
-
_optionalChain([onError, 'optionalCall',
|
|
2961
|
+
_optionalChain([onError, 'optionalCall', _83 => _83(error)]);
|
|
2841
2962
|
}
|
|
2842
2963
|
);
|
|
2843
2964
|
} else {
|
|
@@ -2857,14 +2978,14 @@ ${commandInstruction}` : commandInstruction;
|
|
|
2857
2978
|
setCommandResult(result);
|
|
2858
2979
|
setCommandState("success");
|
|
2859
2980
|
setProgress(100);
|
|
2860
|
-
_optionalChain([onComplete, 'optionalCall',
|
|
2981
|
+
_optionalChain([onComplete, 'optionalCall', _84 => _84(result)]);
|
|
2861
2982
|
}
|
|
2862
2983
|
}
|
|
2863
2984
|
} catch (err) {
|
|
2864
2985
|
const error = err instanceof Error ? err : new Error("Unknown error");
|
|
2865
2986
|
setCommandError(error);
|
|
2866
2987
|
setCommandState("error");
|
|
2867
|
-
_optionalChain([onError, 'optionalCall',
|
|
2988
|
+
_optionalChain([onError, 'optionalCall', _85 => _85(error)]);
|
|
2868
2989
|
}
|
|
2869
2990
|
};
|
|
2870
2991
|
const resetCommand = () => {
|
|
@@ -2956,8 +3077,8 @@ ${planToExecute}`;
|
|
|
2956
3077
|
executeCommand(text, files);
|
|
2957
3078
|
},
|
|
2958
3079
|
state: commandState,
|
|
2959
|
-
response: _optionalChain([commandResult, 'optionalAccess',
|
|
2960
|
-
error: _optionalChain([commandError, 'optionalAccess',
|
|
3080
|
+
response: _optionalChain([commandResult, 'optionalAccess', _86 => _86.data, 'optionalAccess', _87 => _87.summary]) || _optionalChain([commandResult, 'optionalAccess', _88 => _88.message]),
|
|
3081
|
+
error: _optionalChain([commandError, 'optionalAccess', _89 => _89.message]),
|
|
2961
3082
|
plan,
|
|
2962
3083
|
streamedContent,
|
|
2963
3084
|
toolName: currentToolName,
|
|
@@ -3125,13 +3246,13 @@ ${planningInstruction}` : planningInstruction;
|
|
|
3125
3246
|
const error2 = err instanceof Error ? err : new Error("Failed to generate plan");
|
|
3126
3247
|
setError(error2);
|
|
3127
3248
|
setState("error");
|
|
3128
|
-
_optionalChain([onError, 'optionalCall',
|
|
3249
|
+
_optionalChain([onError, 'optionalCall', _90 => _90(error2)]);
|
|
3129
3250
|
});
|
|
3130
3251
|
} catch (err) {
|
|
3131
3252
|
const error2 = err instanceof Error ? err : new Error("Failed to generate plan");
|
|
3132
3253
|
setError(error2);
|
|
3133
3254
|
setState("error");
|
|
3134
|
-
_optionalChain([onError, 'optionalCall',
|
|
3255
|
+
_optionalChain([onError, 'optionalCall', _91 => _91(error2)]);
|
|
3135
3256
|
}
|
|
3136
3257
|
}
|
|
3137
3258
|
return;
|
|
@@ -3142,7 +3263,7 @@ ${planningInstruction}` : planningInstruction;
|
|
|
3142
3263
|
setStreamedContent("");
|
|
3143
3264
|
setCommand("");
|
|
3144
3265
|
setUploadedFiles([]);
|
|
3145
|
-
_optionalChain([onStart, 'optionalCall',
|
|
3266
|
+
_optionalChain([onStart, 'optionalCall', _92 => _92()]);
|
|
3146
3267
|
try {
|
|
3147
3268
|
if (useMock) {
|
|
3148
3269
|
if (enableStreaming) {
|
|
@@ -3153,16 +3274,16 @@ ${planningInstruction}` : planningInstruction;
|
|
|
3153
3274
|
if (chunk.type === "token" && chunk.content) {
|
|
3154
3275
|
accumulatedContent += chunk.content;
|
|
3155
3276
|
setStreamedContent(accumulatedContent);
|
|
3156
|
-
_optionalChain([onChunk, 'optionalCall',
|
|
3277
|
+
_optionalChain([onChunk, 'optionalCall', _93 => _93(chunk.content)]);
|
|
3157
3278
|
const estimatedProgress = Math.min(Math.round(accumulatedContent.length / 10), 90);
|
|
3158
3279
|
setProgress(estimatedProgress);
|
|
3159
|
-
_optionalChain([onProgress, 'optionalCall',
|
|
3280
|
+
_optionalChain([onProgress, 'optionalCall', _94 => _94(estimatedProgress)]);
|
|
3160
3281
|
} else if (chunk.type === "widget" && chunk.widget) {
|
|
3161
3282
|
const widget = chunk.widget;
|
|
3162
3283
|
setResult((prev) => ({
|
|
3163
3284
|
success: true,
|
|
3164
|
-
data: _optionalChain([prev, 'optionalAccess',
|
|
3165
|
-
widgets: [..._optionalChain([prev, 'optionalAccess',
|
|
3285
|
+
data: _optionalChain([prev, 'optionalAccess', _95 => _95.data]) || {},
|
|
3286
|
+
widgets: [..._optionalChain([prev, 'optionalAccess', _96 => _96.widgets]) || [], widget],
|
|
3166
3287
|
message: accumulatedContent || "Command executed successfully"
|
|
3167
3288
|
}));
|
|
3168
3289
|
}
|
|
@@ -3182,19 +3303,19 @@ ${planningInstruction}` : planningInstruction;
|
|
|
3182
3303
|
setResult(result2);
|
|
3183
3304
|
setState("success");
|
|
3184
3305
|
setProgress(100);
|
|
3185
|
-
_optionalChain([onComplete, 'optionalCall',
|
|
3306
|
+
_optionalChain([onComplete, 'optionalCall', _97 => _97(result2)]);
|
|
3186
3307
|
},
|
|
3187
3308
|
(error2) => {
|
|
3188
3309
|
setError(error2);
|
|
3189
3310
|
setState("error");
|
|
3190
|
-
_optionalChain([onError, 'optionalCall',
|
|
3311
|
+
_optionalChain([onError, 'optionalCall', _98 => _98(error2)]);
|
|
3191
3312
|
}
|
|
3192
3313
|
);
|
|
3193
3314
|
} else {
|
|
3194
3315
|
const progressInterval = setInterval(() => {
|
|
3195
3316
|
setProgress((prev) => {
|
|
3196
3317
|
const next = Math.min(prev + 10, 90);
|
|
3197
|
-
_optionalChain([onProgress, 'optionalCall',
|
|
3318
|
+
_optionalChain([onProgress, 'optionalCall', _99 => _99(next)]);
|
|
3198
3319
|
return next;
|
|
3199
3320
|
});
|
|
3200
3321
|
}, 200);
|
|
@@ -3218,7 +3339,7 @@ ${planningInstruction}` : planningInstruction;
|
|
|
3218
3339
|
setResult(result2);
|
|
3219
3340
|
setState("success");
|
|
3220
3341
|
setProgress(100);
|
|
3221
|
-
_optionalChain([onComplete, 'optionalCall',
|
|
3342
|
+
_optionalChain([onComplete, 'optionalCall', _100 => _100(result2)]);
|
|
3222
3343
|
}
|
|
3223
3344
|
} else {
|
|
3224
3345
|
if (enableStreaming) {
|
|
@@ -3264,16 +3385,16 @@ ${commandInstruction}` : commandInstruction;
|
|
|
3264
3385
|
if (chunk.type === "token" && chunk.content) {
|
|
3265
3386
|
accumulatedContent += chunk.content;
|
|
3266
3387
|
setStreamedContent(accumulatedContent);
|
|
3267
|
-
_optionalChain([onChunk, 'optionalCall',
|
|
3388
|
+
_optionalChain([onChunk, 'optionalCall', _101 => _101(chunk.content)]);
|
|
3268
3389
|
const estimatedProgress = Math.min(Math.round(accumulatedContent.length / 10), 90);
|
|
3269
3390
|
setProgress(estimatedProgress);
|
|
3270
|
-
_optionalChain([onProgress, 'optionalCall',
|
|
3391
|
+
_optionalChain([onProgress, 'optionalCall', _102 => _102(estimatedProgress)]);
|
|
3271
3392
|
} else if (chunk.type === "widget" && chunk.widget) {
|
|
3272
3393
|
const widget = chunk.widget;
|
|
3273
3394
|
setResult((prev) => ({
|
|
3274
3395
|
success: true,
|
|
3275
|
-
data: _optionalChain([prev, 'optionalAccess',
|
|
3276
|
-
widgets: [..._optionalChain([prev, 'optionalAccess',
|
|
3396
|
+
data: _optionalChain([prev, 'optionalAccess', _103 => _103.data]) || {},
|
|
3397
|
+
widgets: [..._optionalChain([prev, 'optionalAccess', _104 => _104.widgets]) || [], widget],
|
|
3277
3398
|
message: accumulatedContent || "Command executed successfully"
|
|
3278
3399
|
}));
|
|
3279
3400
|
}
|
|
@@ -3293,20 +3414,20 @@ ${commandInstruction}` : commandInstruction;
|
|
|
3293
3414
|
setResult(result2);
|
|
3294
3415
|
setState("success");
|
|
3295
3416
|
setProgress(100);
|
|
3296
|
-
_optionalChain([onComplete, 'optionalCall',
|
|
3417
|
+
_optionalChain([onComplete, 'optionalCall', _105 => _105(result2)]);
|
|
3297
3418
|
},
|
|
3298
3419
|
(error2) => {
|
|
3299
3420
|
const err = error2 instanceof Error ? error2 : new Error("Unknown error");
|
|
3300
3421
|
setError(err);
|
|
3301
3422
|
setState("error");
|
|
3302
|
-
_optionalChain([onError, 'optionalCall',
|
|
3423
|
+
_optionalChain([onError, 'optionalCall', _106 => _106(err)]);
|
|
3303
3424
|
}
|
|
3304
3425
|
);
|
|
3305
3426
|
} else {
|
|
3306
3427
|
const progressInterval = setInterval(() => {
|
|
3307
3428
|
setProgress((prev) => {
|
|
3308
3429
|
const next = Math.min(prev + 10, 90);
|
|
3309
|
-
_optionalChain([onProgress, 'optionalCall',
|
|
3430
|
+
_optionalChain([onProgress, 'optionalCall', _107 => _107(next)]);
|
|
3310
3431
|
return next;
|
|
3311
3432
|
});
|
|
3312
3433
|
}, 200);
|
|
@@ -3362,14 +3483,14 @@ ${commandInstruction}` : commandInstruction;
|
|
|
3362
3483
|
setResult(result2);
|
|
3363
3484
|
setState("success");
|
|
3364
3485
|
setProgress(100);
|
|
3365
|
-
_optionalChain([onComplete, 'optionalCall',
|
|
3486
|
+
_optionalChain([onComplete, 'optionalCall', _108 => _108(result2)]);
|
|
3366
3487
|
}
|
|
3367
3488
|
}
|
|
3368
3489
|
} catch (err) {
|
|
3369
3490
|
const error2 = err instanceof Error ? err : new Error("Unknown error");
|
|
3370
3491
|
setError(error2);
|
|
3371
3492
|
setState("error");
|
|
3372
|
-
_optionalChain([onError, 'optionalCall',
|
|
3493
|
+
_optionalChain([onError, 'optionalCall', _109 => _109(error2)]);
|
|
3373
3494
|
}
|
|
3374
3495
|
};
|
|
3375
3496
|
const resetCommand = () => {
|
|
@@ -3402,14 +3523,14 @@ ${planToExecute}`;
|
|
|
3402
3523
|
};
|
|
3403
3524
|
const handleFileSelect = async (e) => {
|
|
3404
3525
|
if (e.target.files && e.target.files.length > 0) {
|
|
3405
|
-
_optionalChain([onFileUpload, 'optionalCall',
|
|
3526
|
+
_optionalChain([onFileUpload, 'optionalCall', _110 => _110(e.target.files)]);
|
|
3406
3527
|
const files = [];
|
|
3407
3528
|
for (let i = 0; i < e.target.files.length; i++) {
|
|
3408
3529
|
const file = e.target.files[i];
|
|
3409
3530
|
const reader = new FileReader();
|
|
3410
3531
|
await new Promise((resolve) => {
|
|
3411
3532
|
reader.onload = (event) => {
|
|
3412
|
-
if (_optionalChain([event, 'access',
|
|
3533
|
+
if (_optionalChain([event, 'access', _111 => _111.target, 'optionalAccess', _112 => _112.result])) {
|
|
3413
3534
|
const fullDataUrl = event.target.result;
|
|
3414
3535
|
const base64Data = fullDataUrl.split(",")[1];
|
|
3415
3536
|
if (file.type.startsWith("image/")) {
|
|
@@ -3503,7 +3624,7 @@ ${planToExecute}`;
|
|
|
3503
3624
|
enableFileUpload && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3504
3625
|
"button",
|
|
3505
3626
|
{
|
|
3506
|
-
onClick: () => _optionalChain([fileInputRef, 'access',
|
|
3627
|
+
onClick: () => _optionalChain([fileInputRef, 'access', _113 => _113.current, 'optionalAccess', _114 => _114.click, 'call', _115 => _115()]),
|
|
3507
3628
|
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",
|
|
3508
3629
|
title: "Attach file",
|
|
3509
3630
|
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)" }) })
|
|
@@ -3722,7 +3843,7 @@ ${planToExecute}`;
|
|
|
3722
3843
|
/* @__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" }) }),
|
|
3723
3844
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { children: [
|
|
3724
3845
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h3", { className: "text-sm font-semibold text-red-800 dark:text-red-400", children: "Error" }),
|
|
3725
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-red-700 dark:text-red-300 text-sm mt-1", children: _optionalChain([error, 'optionalAccess',
|
|
3846
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-red-700 dark:text-red-300 text-sm mt-1", children: _optionalChain([error, 'optionalAccess', _116 => _116.message]) })
|
|
3726
3847
|
] })
|
|
3727
3848
|
] }) }),
|
|
3728
3849
|
allowInput && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
@@ -3750,7 +3871,7 @@ ${planToExecute}`;
|
|
|
3750
3871
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-green-700 dark:text-green-300 text-sm", children: "Command executed successfully" })
|
|
3751
3872
|
] })
|
|
3752
3873
|
] }),
|
|
3753
|
-
_optionalChain([result, 'access',
|
|
3874
|
+
_optionalChain([result, 'access', _117 => _117.data, 'optionalAccess', _118 => _118.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 }),
|
|
3754
3875
|
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,
|
|
3755
3876
|
WidgetRenderer,
|
|
3756
3877
|
{
|
|
@@ -3801,7 +3922,7 @@ ${planToExecute}`;
|
|
|
3801
3922
|
enableFileUpload && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3802
3923
|
"button",
|
|
3803
3924
|
{
|
|
3804
|
-
onClick: () => _optionalChain([fileInputRef, 'access',
|
|
3925
|
+
onClick: () => _optionalChain([fileInputRef, 'access', _119 => _119.current, 'optionalAccess', _120 => _120.click, 'call', _121 => _121()]),
|
|
3805
3926
|
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",
|
|
3806
3927
|
title: "Attach file",
|
|
3807
3928
|
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)" }) })
|
|
@@ -3987,25 +4108,25 @@ function Prompt({
|
|
|
3987
4108
|
const newValue = e.target.value;
|
|
3988
4109
|
if (!maxLength || newValue.length <= maxLength) {
|
|
3989
4110
|
setValue(newValue);
|
|
3990
|
-
_optionalChain([onChange, 'optionalCall',
|
|
4111
|
+
_optionalChain([onChange, 'optionalCall', _122 => _122(newValue)]);
|
|
3991
4112
|
}
|
|
3992
4113
|
};
|
|
3993
4114
|
const handleSubmit = async () => {
|
|
3994
4115
|
if (value.length < minLength) return;
|
|
3995
|
-
_optionalChain([onSubmit, 'optionalCall',
|
|
4116
|
+
_optionalChain([onSubmit, 'optionalCall', _123 => _123(value)]);
|
|
3996
4117
|
setIsLoading(true);
|
|
3997
4118
|
try {
|
|
3998
4119
|
if (useMock) {
|
|
3999
4120
|
await new Promise((resolve) => setTimeout(resolve, 1500));
|
|
4000
4121
|
const mockResult = `Enhanced version: ${value} [AI-generated content]`;
|
|
4001
|
-
_optionalChain([onResult, 'optionalCall',
|
|
4122
|
+
_optionalChain([onResult, 'optionalCall', _124 => _124(mockResult)]);
|
|
4002
4123
|
setValue("");
|
|
4003
4124
|
} else {
|
|
4004
4125
|
const response = await aptevaClient.chat({
|
|
4005
4126
|
agent_id: agentId,
|
|
4006
4127
|
message: value
|
|
4007
4128
|
});
|
|
4008
|
-
_optionalChain([onResult, 'optionalCall',
|
|
4129
|
+
_optionalChain([onResult, 'optionalCall', _125 => _125(response.message)]);
|
|
4009
4130
|
setValue("");
|
|
4010
4131
|
}
|
|
4011
4132
|
} catch (error) {
|
|
@@ -4100,7 +4221,7 @@ function Stream({
|
|
|
4100
4221
|
}, [autoStart]);
|
|
4101
4222
|
const startStreaming = async () => {
|
|
4102
4223
|
setIsStreaming(true);
|
|
4103
|
-
_optionalChain([onStart, 'optionalCall',
|
|
4224
|
+
_optionalChain([onStart, 'optionalCall', _126 => _126()]);
|
|
4104
4225
|
try {
|
|
4105
4226
|
if (useMock) {
|
|
4106
4227
|
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.";
|
|
@@ -4108,13 +4229,13 @@ function Stream({
|
|
|
4108
4229
|
mockText,
|
|
4109
4230
|
(chunk) => {
|
|
4110
4231
|
setText((prev) => prev + chunk);
|
|
4111
|
-
_optionalChain([onChunk, 'optionalCall',
|
|
4232
|
+
_optionalChain([onChunk, 'optionalCall', _127 => _127(chunk)]);
|
|
4112
4233
|
},
|
|
4113
4234
|
typingSpeed
|
|
4114
4235
|
);
|
|
4115
4236
|
setIsComplete(true);
|
|
4116
4237
|
setIsStreaming(false);
|
|
4117
|
-
_optionalChain([onComplete, 'optionalCall',
|
|
4238
|
+
_optionalChain([onComplete, 'optionalCall', _128 => _128(text + mockText)]);
|
|
4118
4239
|
} else {
|
|
4119
4240
|
let accumulatedText = "";
|
|
4120
4241
|
await aptevaClient.chatStream(
|
|
@@ -4127,24 +4248,24 @@ function Stream({
|
|
|
4127
4248
|
if (chunk.type === "token" && chunk.content) {
|
|
4128
4249
|
accumulatedText += chunk.content;
|
|
4129
4250
|
setText(accumulatedText);
|
|
4130
|
-
_optionalChain([onChunk, 'optionalCall',
|
|
4251
|
+
_optionalChain([onChunk, 'optionalCall', _129 => _129(chunk.content)]);
|
|
4131
4252
|
}
|
|
4132
4253
|
},
|
|
4133
4254
|
() => {
|
|
4134
4255
|
setIsComplete(true);
|
|
4135
4256
|
setIsStreaming(false);
|
|
4136
|
-
_optionalChain([onComplete, 'optionalCall',
|
|
4257
|
+
_optionalChain([onComplete, 'optionalCall', _130 => _130(accumulatedText)]);
|
|
4137
4258
|
},
|
|
4138
4259
|
(error) => {
|
|
4139
4260
|
const err = error instanceof Error ? error : new Error("Streaming error");
|
|
4140
|
-
_optionalChain([onError, 'optionalCall',
|
|
4261
|
+
_optionalChain([onError, 'optionalCall', _131 => _131(err)]);
|
|
4141
4262
|
setIsStreaming(false);
|
|
4142
4263
|
}
|
|
4143
4264
|
);
|
|
4144
4265
|
}
|
|
4145
4266
|
} catch (error) {
|
|
4146
4267
|
const err = error instanceof Error ? error : new Error("Streaming error");
|
|
4147
|
-
_optionalChain([onError, 'optionalCall',
|
|
4268
|
+
_optionalChain([onError, 'optionalCall', _132 => _132(err)]);
|
|
4148
4269
|
setIsStreaming(false);
|
|
4149
4270
|
}
|
|
4150
4271
|
};
|
|
@@ -4236,7 +4357,7 @@ function ThreadList({
|
|
|
4236
4357
|
}) {
|
|
4237
4358
|
const [searchQuery, setSearchQuery] = _react.useState.call(void 0, "");
|
|
4238
4359
|
const filteredThreads = threads.filter(
|
|
4239
|
-
(thread) => thread.title.toLowerCase().includes(searchQuery.toLowerCase()) || _optionalChain([thread, 'access',
|
|
4360
|
+
(thread) => thread.title.toLowerCase().includes(searchQuery.toLowerCase()) || _optionalChain([thread, 'access', _133 => _133.preview, 'optionalAccess', _134 => _134.toLowerCase, 'call', _135 => _135(), 'access', _136 => _136.includes, 'call', _137 => _137(searchQuery.toLowerCase())])
|
|
4240
4361
|
);
|
|
4241
4362
|
const groupedThreads = groupBy === "date" ? groupThreadsByDate(filteredThreads) : { All: filteredThreads };
|
|
4242
4363
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-col h-full", children: [
|
|
@@ -4258,8 +4379,8 @@ function ThreadList({
|
|
|
4258
4379
|
{
|
|
4259
4380
|
thread,
|
|
4260
4381
|
isActive: thread.id === currentThreadId,
|
|
4261
|
-
onSelect: () => _optionalChain([onThreadSelect, 'optionalCall',
|
|
4262
|
-
onDelete: () => _optionalChain([onThreadDelete, 'optionalCall',
|
|
4382
|
+
onSelect: () => _optionalChain([onThreadSelect, 'optionalCall', _138 => _138(thread.id)]),
|
|
4383
|
+
onDelete: () => _optionalChain([onThreadDelete, 'optionalCall', _139 => _139(thread.id)])
|
|
4263
4384
|
},
|
|
4264
4385
|
thread.id
|
|
4265
4386
|
))
|
|
@@ -4321,7 +4442,7 @@ function Threads({
|
|
|
4321
4442
|
threads.slice(0, 5).map((thread) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4322
4443
|
"button",
|
|
4323
4444
|
{
|
|
4324
|
-
onClick: () => _optionalChain([onThreadSelect, 'optionalCall',
|
|
4445
|
+
onClick: () => _optionalChain([onThreadSelect, 'optionalCall', _140 => _140(thread.id)]),
|
|
4325
4446
|
className: cn(
|
|
4326
4447
|
"px-4 py-2 whitespace-nowrap font-medium transition-colors",
|
|
4327
4448
|
thread.id === currentThreadId ? "border-b-2 border-apteva-500 text-apteva-500" : "text-neutral-600 hover:text-neutral-900"
|