@apteva/apteva-kit 0.1.33 → 0.1.35
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 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +96 -68
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +39 -11
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -249,6 +249,7 @@ interface ChatProps {
|
|
|
249
249
|
onFileUpload?: (files: FileList) => void;
|
|
250
250
|
onComplete?: (result: CommandResult) => void;
|
|
251
251
|
onError?: (error: Error) => void;
|
|
252
|
+
onToolCall?: (toolName: string, toolId: string) => void;
|
|
252
253
|
onToolResult?: (toolName: string, result?: any) => void;
|
|
253
254
|
theme?: 'light' | 'dark' | 'auto';
|
|
254
255
|
placeholder?: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -249,6 +249,7 @@ interface ChatProps {
|
|
|
249
249
|
onFileUpload?: (files: FileList) => void;
|
|
250
250
|
onComplete?: (result: CommandResult) => void;
|
|
251
251
|
onError?: (error: Error) => void;
|
|
252
|
+
onToolCall?: (toolName: string, toolId: string) => void;
|
|
252
253
|
onToolResult?: (toolName: string, result?: any) => void;
|
|
253
254
|
theme?: 'light' | 'dark' | 'auto';
|
|
254
255
|
placeholder?: string;
|
package/dist/index.js
CHANGED
|
@@ -1325,23 +1325,48 @@ function Message({ message, onAction, enableWidgets, onWidgetRender }) {
|
|
|
1325
1325
|
] });
|
|
1326
1326
|
}
|
|
1327
1327
|
if (contentSegments && contentSegments.length > 0) {
|
|
1328
|
-
return
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1328
|
+
return null;
|
|
1329
|
+
}
|
|
1330
|
+
return renderTextContent(message.content);
|
|
1331
|
+
};
|
|
1332
|
+
const renderSegmentedContent = () => {
|
|
1333
|
+
if (!contentSegments || contentSegments.length === 0) {
|
|
1334
|
+
return null;
|
|
1335
|
+
}
|
|
1336
|
+
const elements = [];
|
|
1337
|
+
contentSegments.forEach((segment, index) => {
|
|
1338
|
+
if (segment.type === "text" && segment.content) {
|
|
1339
|
+
elements.push(
|
|
1340
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1341
|
+
"div",
|
|
1342
|
+
{
|
|
1343
|
+
className: "apteva-message-bubble apteva-message-assistant",
|
|
1344
|
+
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "apteva-message-content-assistant", children: renderTextContent(segment.content) })
|
|
1345
|
+
},
|
|
1346
|
+
`text-${index}`
|
|
1347
|
+
)
|
|
1348
|
+
);
|
|
1349
|
+
} else if (segment.type === "tool") {
|
|
1350
|
+
elements.push(
|
|
1351
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "apteva-tool-call-standalone", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1333
1352
|
ToolCall,
|
|
1334
1353
|
{
|
|
1335
1354
|
name: segment.name,
|
|
1336
1355
|
status: segment.result !== void 0 ? "completed" : "running"
|
|
1337
1356
|
}
|
|
1338
|
-
) }, segment.id)
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
return renderTextContent(message.content);
|
|
1357
|
+
) }, segment.id)
|
|
1358
|
+
);
|
|
1359
|
+
}
|
|
1360
|
+
});
|
|
1361
|
+
return elements;
|
|
1344
1362
|
};
|
|
1363
|
+
if (!isUser && contentSegments && contentSegments.length > 0) {
|
|
1364
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "apteva-message-segmented", children: [
|
|
1365
|
+
renderSegmentedContent(),
|
|
1366
|
+
message.widgets && message.widgets.length > 0 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "apteva-message-widgets", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Widgets, { widgets: message.widgets, onAction, layout: "stack" }) }),
|
|
1367
|
+
/* @__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" }) })
|
|
1368
|
+
] });
|
|
1369
|
+
}
|
|
1345
1370
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1346
1371
|
"div",
|
|
1347
1372
|
{
|
|
@@ -2288,6 +2313,7 @@ var Chat = _react.forwardRef.call(void 0, function Chat2({
|
|
|
2288
2313
|
onFileUpload,
|
|
2289
2314
|
onComplete,
|
|
2290
2315
|
onError,
|
|
2316
|
+
onToolCall,
|
|
2291
2317
|
onToolResult,
|
|
2292
2318
|
// UI
|
|
2293
2319
|
placeholder,
|
|
@@ -2480,6 +2506,7 @@ ${widgetContext}` : widgetContext;
|
|
|
2480
2506
|
contentSegments.push({ type: "tool", id: chunk.tool_id, name: chunk.tool_name });
|
|
2481
2507
|
toolInputBuffer = "";
|
|
2482
2508
|
setChatToolName(chunk.tool_name);
|
|
2509
|
+
_optionalChain([onToolCall, 'optionalCall', _60 => _60(chunk.tool_name, chunk.tool_id)]);
|
|
2483
2510
|
updateMessage();
|
|
2484
2511
|
}
|
|
2485
2512
|
break;
|
|
@@ -2493,7 +2520,7 @@ ${widgetContext}` : widgetContext;
|
|
|
2493
2520
|
const toolSegment = contentSegments.find((s) => s.type === "tool" && s.id === chunk.tool_id);
|
|
2494
2521
|
if (toolSegment) {
|
|
2495
2522
|
toolSegment.result = chunk.content;
|
|
2496
|
-
_optionalChain([onToolResult, 'optionalCall',
|
|
2523
|
+
_optionalChain([onToolResult, 'optionalCall', _61 => _61(toolSegment.name, chunk.content)]);
|
|
2497
2524
|
}
|
|
2498
2525
|
setChatToolName(null);
|
|
2499
2526
|
updateMessage();
|
|
@@ -2536,7 +2563,7 @@ ${widgetContext}` : widgetContext;
|
|
|
2536
2563
|
});
|
|
2537
2564
|
if (threadId2 && threadId2 !== currentThreadId) {
|
|
2538
2565
|
setCurrentThreadId(threadId2);
|
|
2539
|
-
_optionalChain([onThreadChange, 'optionalCall',
|
|
2566
|
+
_optionalChain([onThreadChange, 'optionalCall', _62 => _62(threadId2)]);
|
|
2540
2567
|
}
|
|
2541
2568
|
setIsLoading(false);
|
|
2542
2569
|
setCurrentRequestId(null);
|
|
@@ -2560,7 +2587,7 @@ ${widgetContext}` : widgetContext;
|
|
|
2560
2587
|
setIsLoading(false);
|
|
2561
2588
|
setCurrentRequestId(null);
|
|
2562
2589
|
setChatToolName(null);
|
|
2563
|
-
_optionalChain([onError, 'optionalCall',
|
|
2590
|
+
_optionalChain([onError, 'optionalCall', _63 => _63(error)]);
|
|
2564
2591
|
}
|
|
2565
2592
|
);
|
|
2566
2593
|
}
|
|
@@ -2573,7 +2600,7 @@ ${widgetContext}` : widgetContext;
|
|
|
2573
2600
|
metadata: { error: true }
|
|
2574
2601
|
};
|
|
2575
2602
|
setMessages((prev) => [...prev, errorMessage]);
|
|
2576
|
-
_optionalChain([onError, 'optionalCall',
|
|
2603
|
+
_optionalChain([onError, 'optionalCall', _64 => _64(error instanceof Error ? error : new Error("Unknown error"))]);
|
|
2577
2604
|
} finally {
|
|
2578
2605
|
setIsLoading(false);
|
|
2579
2606
|
}
|
|
@@ -2619,7 +2646,7 @@ ${planningInstruction}` : planningInstruction;
|
|
|
2619
2646
|
const error = err instanceof Error ? err : new Error("Failed to generate plan");
|
|
2620
2647
|
setCommandError(error);
|
|
2621
2648
|
setCommandState("error");
|
|
2622
|
-
_optionalChain([onError, 'optionalCall',
|
|
2649
|
+
_optionalChain([onError, 'optionalCall', _65 => _65(error)]);
|
|
2623
2650
|
}
|
|
2624
2651
|
}
|
|
2625
2652
|
return;
|
|
@@ -2652,12 +2679,12 @@ ${planningInstruction}` : planningInstruction;
|
|
|
2652
2679
|
setCommandResult(result);
|
|
2653
2680
|
setCommandState("success");
|
|
2654
2681
|
setProgress(100);
|
|
2655
|
-
_optionalChain([onComplete, 'optionalCall',
|
|
2682
|
+
_optionalChain([onComplete, 'optionalCall', _66 => _66(result)]);
|
|
2656
2683
|
},
|
|
2657
2684
|
(error) => {
|
|
2658
2685
|
setCommandError(error);
|
|
2659
2686
|
setCommandState("error");
|
|
2660
|
-
_optionalChain([onError, 'optionalCall',
|
|
2687
|
+
_optionalChain([onError, 'optionalCall', _67 => _67(error)]);
|
|
2661
2688
|
}
|
|
2662
2689
|
);
|
|
2663
2690
|
} else {
|
|
@@ -2670,7 +2697,7 @@ ${planningInstruction}` : planningInstruction;
|
|
|
2670
2697
|
setCommandResult(result);
|
|
2671
2698
|
setCommandState("success");
|
|
2672
2699
|
setProgress(100);
|
|
2673
|
-
_optionalChain([onComplete, 'optionalCall',
|
|
2700
|
+
_optionalChain([onComplete, 'optionalCall', _68 => _68(result)]);
|
|
2674
2701
|
}
|
|
2675
2702
|
} else {
|
|
2676
2703
|
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.`;
|
|
@@ -2699,15 +2726,16 @@ ${commandInstruction}` : commandInstruction;
|
|
|
2699
2726
|
} else if (chunk.type === "tool_call" && chunk.tool_name) {
|
|
2700
2727
|
lastToolName = chunk.tool_name;
|
|
2701
2728
|
setCurrentToolName(chunk.tool_name);
|
|
2729
|
+
_optionalChain([onToolCall, 'optionalCall', _69 => _69(chunk.tool_name, chunk.tool_id || "")]);
|
|
2702
2730
|
accumulatedContent = "";
|
|
2703
2731
|
setStreamedContent("");
|
|
2704
2732
|
} else if (chunk.type === "tool_result") {
|
|
2705
|
-
_optionalChain([onToolResult, 'optionalCall',
|
|
2733
|
+
_optionalChain([onToolResult, 'optionalCall', _70 => _70(lastToolName, chunk.content)]);
|
|
2706
2734
|
setCurrentToolName(null);
|
|
2707
2735
|
} else if (chunk.type === "thread_id" && chunk.thread_id) {
|
|
2708
2736
|
if (!currentThreadId) {
|
|
2709
2737
|
setCurrentThreadId(chunk.thread_id);
|
|
2710
|
-
_optionalChain([onThreadChange, 'optionalCall',
|
|
2738
|
+
_optionalChain([onThreadChange, 'optionalCall', _71 => _71(chunk.thread_id)]);
|
|
2711
2739
|
}
|
|
2712
2740
|
} else if (chunk.type === "request_id" && chunk.request_id) {
|
|
2713
2741
|
setCurrentRequestId(chunk.request_id);
|
|
@@ -2723,13 +2751,13 @@ ${commandInstruction}` : commandInstruction;
|
|
|
2723
2751
|
setCommandState("success");
|
|
2724
2752
|
setProgress(100);
|
|
2725
2753
|
setCurrentRequestId(null);
|
|
2726
|
-
_optionalChain([onComplete, 'optionalCall',
|
|
2754
|
+
_optionalChain([onComplete, 'optionalCall', _72 => _72(result)]);
|
|
2727
2755
|
},
|
|
2728
2756
|
(error) => {
|
|
2729
2757
|
setCommandError(error);
|
|
2730
2758
|
setCommandState("error");
|
|
2731
2759
|
setCurrentRequestId(null);
|
|
2732
|
-
_optionalChain([onError, 'optionalCall',
|
|
2760
|
+
_optionalChain([onError, 'optionalCall', _73 => _73(error)]);
|
|
2733
2761
|
}
|
|
2734
2762
|
);
|
|
2735
2763
|
} else {
|
|
@@ -2749,14 +2777,14 @@ ${commandInstruction}` : commandInstruction;
|
|
|
2749
2777
|
setCommandResult(result);
|
|
2750
2778
|
setCommandState("success");
|
|
2751
2779
|
setProgress(100);
|
|
2752
|
-
_optionalChain([onComplete, 'optionalCall',
|
|
2780
|
+
_optionalChain([onComplete, 'optionalCall', _74 => _74(result)]);
|
|
2753
2781
|
}
|
|
2754
2782
|
}
|
|
2755
2783
|
} catch (err) {
|
|
2756
2784
|
const error = err instanceof Error ? err : new Error("Unknown error");
|
|
2757
2785
|
setCommandError(error);
|
|
2758
2786
|
setCommandState("error");
|
|
2759
|
-
_optionalChain([onError, 'optionalCall',
|
|
2787
|
+
_optionalChain([onError, 'optionalCall', _75 => _75(error)]);
|
|
2760
2788
|
}
|
|
2761
2789
|
};
|
|
2762
2790
|
const resetCommand = () => {
|
|
@@ -2848,8 +2876,8 @@ ${planToExecute}`;
|
|
|
2848
2876
|
executeCommand(text, files);
|
|
2849
2877
|
},
|
|
2850
2878
|
state: commandState,
|
|
2851
|
-
response: _optionalChain([commandResult, 'optionalAccess',
|
|
2852
|
-
error: _optionalChain([commandError, 'optionalAccess',
|
|
2879
|
+
response: _optionalChain([commandResult, 'optionalAccess', _76 => _76.data, 'optionalAccess', _77 => _77.summary]) || _optionalChain([commandResult, 'optionalAccess', _78 => _78.message]),
|
|
2880
|
+
error: _optionalChain([commandError, 'optionalAccess', _79 => _79.message]),
|
|
2853
2881
|
plan,
|
|
2854
2882
|
streamedContent,
|
|
2855
2883
|
toolName: currentToolName,
|
|
@@ -3017,13 +3045,13 @@ ${planningInstruction}` : planningInstruction;
|
|
|
3017
3045
|
const error2 = err instanceof Error ? err : new Error("Failed to generate plan");
|
|
3018
3046
|
setError(error2);
|
|
3019
3047
|
setState("error");
|
|
3020
|
-
_optionalChain([onError, 'optionalCall',
|
|
3048
|
+
_optionalChain([onError, 'optionalCall', _80 => _80(error2)]);
|
|
3021
3049
|
});
|
|
3022
3050
|
} catch (err) {
|
|
3023
3051
|
const error2 = err instanceof Error ? err : new Error("Failed to generate plan");
|
|
3024
3052
|
setError(error2);
|
|
3025
3053
|
setState("error");
|
|
3026
|
-
_optionalChain([onError, 'optionalCall',
|
|
3054
|
+
_optionalChain([onError, 'optionalCall', _81 => _81(error2)]);
|
|
3027
3055
|
}
|
|
3028
3056
|
}
|
|
3029
3057
|
return;
|
|
@@ -3034,7 +3062,7 @@ ${planningInstruction}` : planningInstruction;
|
|
|
3034
3062
|
setStreamedContent("");
|
|
3035
3063
|
setCommand("");
|
|
3036
3064
|
setUploadedFiles([]);
|
|
3037
|
-
_optionalChain([onStart, 'optionalCall',
|
|
3065
|
+
_optionalChain([onStart, 'optionalCall', _82 => _82()]);
|
|
3038
3066
|
try {
|
|
3039
3067
|
if (useMock) {
|
|
3040
3068
|
if (enableStreaming) {
|
|
@@ -3045,16 +3073,16 @@ ${planningInstruction}` : planningInstruction;
|
|
|
3045
3073
|
if (chunk.type === "token" && chunk.content) {
|
|
3046
3074
|
accumulatedContent += chunk.content;
|
|
3047
3075
|
setStreamedContent(accumulatedContent);
|
|
3048
|
-
_optionalChain([onChunk, 'optionalCall',
|
|
3076
|
+
_optionalChain([onChunk, 'optionalCall', _83 => _83(chunk.content)]);
|
|
3049
3077
|
const estimatedProgress = Math.min(Math.round(accumulatedContent.length / 10), 90);
|
|
3050
3078
|
setProgress(estimatedProgress);
|
|
3051
|
-
_optionalChain([onProgress, 'optionalCall',
|
|
3079
|
+
_optionalChain([onProgress, 'optionalCall', _84 => _84(estimatedProgress)]);
|
|
3052
3080
|
} else if (chunk.type === "widget" && chunk.widget) {
|
|
3053
3081
|
const widget = chunk.widget;
|
|
3054
3082
|
setResult((prev) => ({
|
|
3055
3083
|
success: true,
|
|
3056
|
-
data: _optionalChain([prev, 'optionalAccess',
|
|
3057
|
-
widgets: [..._optionalChain([prev, 'optionalAccess',
|
|
3084
|
+
data: _optionalChain([prev, 'optionalAccess', _85 => _85.data]) || {},
|
|
3085
|
+
widgets: [..._optionalChain([prev, 'optionalAccess', _86 => _86.widgets]) || [], widget],
|
|
3058
3086
|
message: accumulatedContent || "Command executed successfully"
|
|
3059
3087
|
}));
|
|
3060
3088
|
}
|
|
@@ -3074,19 +3102,19 @@ ${planningInstruction}` : planningInstruction;
|
|
|
3074
3102
|
setResult(result2);
|
|
3075
3103
|
setState("success");
|
|
3076
3104
|
setProgress(100);
|
|
3077
|
-
_optionalChain([onComplete, 'optionalCall',
|
|
3105
|
+
_optionalChain([onComplete, 'optionalCall', _87 => _87(result2)]);
|
|
3078
3106
|
},
|
|
3079
3107
|
(error2) => {
|
|
3080
3108
|
setError(error2);
|
|
3081
3109
|
setState("error");
|
|
3082
|
-
_optionalChain([onError, 'optionalCall',
|
|
3110
|
+
_optionalChain([onError, 'optionalCall', _88 => _88(error2)]);
|
|
3083
3111
|
}
|
|
3084
3112
|
);
|
|
3085
3113
|
} else {
|
|
3086
3114
|
const progressInterval = setInterval(() => {
|
|
3087
3115
|
setProgress((prev) => {
|
|
3088
3116
|
const next = Math.min(prev + 10, 90);
|
|
3089
|
-
_optionalChain([onProgress, 'optionalCall',
|
|
3117
|
+
_optionalChain([onProgress, 'optionalCall', _89 => _89(next)]);
|
|
3090
3118
|
return next;
|
|
3091
3119
|
});
|
|
3092
3120
|
}, 200);
|
|
@@ -3110,7 +3138,7 @@ ${planningInstruction}` : planningInstruction;
|
|
|
3110
3138
|
setResult(result2);
|
|
3111
3139
|
setState("success");
|
|
3112
3140
|
setProgress(100);
|
|
3113
|
-
_optionalChain([onComplete, 'optionalCall',
|
|
3141
|
+
_optionalChain([onComplete, 'optionalCall', _90 => _90(result2)]);
|
|
3114
3142
|
}
|
|
3115
3143
|
} else {
|
|
3116
3144
|
if (enableStreaming) {
|
|
@@ -3156,16 +3184,16 @@ ${commandInstruction}` : commandInstruction;
|
|
|
3156
3184
|
if (chunk.type === "token" && chunk.content) {
|
|
3157
3185
|
accumulatedContent += chunk.content;
|
|
3158
3186
|
setStreamedContent(accumulatedContent);
|
|
3159
|
-
_optionalChain([onChunk, 'optionalCall',
|
|
3187
|
+
_optionalChain([onChunk, 'optionalCall', _91 => _91(chunk.content)]);
|
|
3160
3188
|
const estimatedProgress = Math.min(Math.round(accumulatedContent.length / 10), 90);
|
|
3161
3189
|
setProgress(estimatedProgress);
|
|
3162
|
-
_optionalChain([onProgress, 'optionalCall',
|
|
3190
|
+
_optionalChain([onProgress, 'optionalCall', _92 => _92(estimatedProgress)]);
|
|
3163
3191
|
} else if (chunk.type === "widget" && chunk.widget) {
|
|
3164
3192
|
const widget = chunk.widget;
|
|
3165
3193
|
setResult((prev) => ({
|
|
3166
3194
|
success: true,
|
|
3167
|
-
data: _optionalChain([prev, 'optionalAccess',
|
|
3168
|
-
widgets: [..._optionalChain([prev, 'optionalAccess',
|
|
3195
|
+
data: _optionalChain([prev, 'optionalAccess', _93 => _93.data]) || {},
|
|
3196
|
+
widgets: [..._optionalChain([prev, 'optionalAccess', _94 => _94.widgets]) || [], widget],
|
|
3169
3197
|
message: accumulatedContent || "Command executed successfully"
|
|
3170
3198
|
}));
|
|
3171
3199
|
}
|
|
@@ -3185,20 +3213,20 @@ ${commandInstruction}` : commandInstruction;
|
|
|
3185
3213
|
setResult(result2);
|
|
3186
3214
|
setState("success");
|
|
3187
3215
|
setProgress(100);
|
|
3188
|
-
_optionalChain([onComplete, 'optionalCall',
|
|
3216
|
+
_optionalChain([onComplete, 'optionalCall', _95 => _95(result2)]);
|
|
3189
3217
|
},
|
|
3190
3218
|
(error2) => {
|
|
3191
3219
|
const err = error2 instanceof Error ? error2 : new Error("Unknown error");
|
|
3192
3220
|
setError(err);
|
|
3193
3221
|
setState("error");
|
|
3194
|
-
_optionalChain([onError, 'optionalCall',
|
|
3222
|
+
_optionalChain([onError, 'optionalCall', _96 => _96(err)]);
|
|
3195
3223
|
}
|
|
3196
3224
|
);
|
|
3197
3225
|
} else {
|
|
3198
3226
|
const progressInterval = setInterval(() => {
|
|
3199
3227
|
setProgress((prev) => {
|
|
3200
3228
|
const next = Math.min(prev + 10, 90);
|
|
3201
|
-
_optionalChain([onProgress, 'optionalCall',
|
|
3229
|
+
_optionalChain([onProgress, 'optionalCall', _97 => _97(next)]);
|
|
3202
3230
|
return next;
|
|
3203
3231
|
});
|
|
3204
3232
|
}, 200);
|
|
@@ -3254,14 +3282,14 @@ ${commandInstruction}` : commandInstruction;
|
|
|
3254
3282
|
setResult(result2);
|
|
3255
3283
|
setState("success");
|
|
3256
3284
|
setProgress(100);
|
|
3257
|
-
_optionalChain([onComplete, 'optionalCall',
|
|
3285
|
+
_optionalChain([onComplete, 'optionalCall', _98 => _98(result2)]);
|
|
3258
3286
|
}
|
|
3259
3287
|
}
|
|
3260
3288
|
} catch (err) {
|
|
3261
3289
|
const error2 = err instanceof Error ? err : new Error("Unknown error");
|
|
3262
3290
|
setError(error2);
|
|
3263
3291
|
setState("error");
|
|
3264
|
-
_optionalChain([onError, 'optionalCall',
|
|
3292
|
+
_optionalChain([onError, 'optionalCall', _99 => _99(error2)]);
|
|
3265
3293
|
}
|
|
3266
3294
|
};
|
|
3267
3295
|
const resetCommand = () => {
|
|
@@ -3294,14 +3322,14 @@ ${planToExecute}`;
|
|
|
3294
3322
|
};
|
|
3295
3323
|
const handleFileSelect = async (e) => {
|
|
3296
3324
|
if (e.target.files && e.target.files.length > 0) {
|
|
3297
|
-
_optionalChain([onFileUpload, 'optionalCall',
|
|
3325
|
+
_optionalChain([onFileUpload, 'optionalCall', _100 => _100(e.target.files)]);
|
|
3298
3326
|
const files = [];
|
|
3299
3327
|
for (let i = 0; i < e.target.files.length; i++) {
|
|
3300
3328
|
const file = e.target.files[i];
|
|
3301
3329
|
const reader = new FileReader();
|
|
3302
3330
|
await new Promise((resolve) => {
|
|
3303
3331
|
reader.onload = (event) => {
|
|
3304
|
-
if (_optionalChain([event, 'access',
|
|
3332
|
+
if (_optionalChain([event, 'access', _101 => _101.target, 'optionalAccess', _102 => _102.result])) {
|
|
3305
3333
|
const fullDataUrl = event.target.result;
|
|
3306
3334
|
const base64Data = fullDataUrl.split(",")[1];
|
|
3307
3335
|
if (file.type.startsWith("image/")) {
|
|
@@ -3395,7 +3423,7 @@ ${planToExecute}`;
|
|
|
3395
3423
|
enableFileUpload && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3396
3424
|
"button",
|
|
3397
3425
|
{
|
|
3398
|
-
onClick: () => _optionalChain([fileInputRef, 'access',
|
|
3426
|
+
onClick: () => _optionalChain([fileInputRef, 'access', _103 => _103.current, 'optionalAccess', _104 => _104.click, 'call', _105 => _105()]),
|
|
3399
3427
|
className: "w-8 h-8 rounded-lg flex items-center justify-center transition-all flex-shrink-0 !text-gray-500 dark:!text-gray-500 hover:bg-gray-100 dark:hover:bg-gray-800",
|
|
3400
3428
|
title: "Attach file",
|
|
3401
3429
|
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)" }) })
|
|
@@ -3614,7 +3642,7 @@ ${planToExecute}`;
|
|
|
3614
3642
|
/* @__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" }) }),
|
|
3615
3643
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { children: [
|
|
3616
3644
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h3", { className: "text-sm font-semibold text-red-800 dark:text-red-400", children: "Error" }),
|
|
3617
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-red-700 dark:text-red-300 text-sm mt-1", children: _optionalChain([error, 'optionalAccess',
|
|
3645
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-red-700 dark:text-red-300 text-sm mt-1", children: _optionalChain([error, 'optionalAccess', _106 => _106.message]) })
|
|
3618
3646
|
] })
|
|
3619
3647
|
] }) }),
|
|
3620
3648
|
allowInput && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
@@ -3642,7 +3670,7 @@ ${planToExecute}`;
|
|
|
3642
3670
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-green-700 dark:text-green-300 text-sm", children: "Command executed successfully" })
|
|
3643
3671
|
] })
|
|
3644
3672
|
] }),
|
|
3645
|
-
_optionalChain([result, 'access',
|
|
3673
|
+
_optionalChain([result, 'access', _107 => _107.data, 'optionalAccess', _108 => _108.summary]) && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "text-gray-700 dark:text-gray-300 text-sm leading-relaxed whitespace-pre-line", children: result.data.summary }),
|
|
3646
3674
|
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,
|
|
3647
3675
|
WidgetRenderer,
|
|
3648
3676
|
{
|
|
@@ -3693,7 +3721,7 @@ ${planToExecute}`;
|
|
|
3693
3721
|
enableFileUpload && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3694
3722
|
"button",
|
|
3695
3723
|
{
|
|
3696
|
-
onClick: () => _optionalChain([fileInputRef, 'access',
|
|
3724
|
+
onClick: () => _optionalChain([fileInputRef, 'access', _109 => _109.current, 'optionalAccess', _110 => _110.click, 'call', _111 => _111()]),
|
|
3697
3725
|
className: "w-8 h-8 rounded-lg flex items-center justify-center transition-all flex-shrink-0 !text-gray-500 dark:!text-gray-500 hover:bg-gray-100 dark:hover:bg-gray-800",
|
|
3698
3726
|
title: "Attach file",
|
|
3699
3727
|
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)" }) })
|
|
@@ -3879,25 +3907,25 @@ function Prompt({
|
|
|
3879
3907
|
const newValue = e.target.value;
|
|
3880
3908
|
if (!maxLength || newValue.length <= maxLength) {
|
|
3881
3909
|
setValue(newValue);
|
|
3882
|
-
_optionalChain([onChange, 'optionalCall',
|
|
3910
|
+
_optionalChain([onChange, 'optionalCall', _112 => _112(newValue)]);
|
|
3883
3911
|
}
|
|
3884
3912
|
};
|
|
3885
3913
|
const handleSubmit = async () => {
|
|
3886
3914
|
if (value.length < minLength) return;
|
|
3887
|
-
_optionalChain([onSubmit, 'optionalCall',
|
|
3915
|
+
_optionalChain([onSubmit, 'optionalCall', _113 => _113(value)]);
|
|
3888
3916
|
setIsLoading(true);
|
|
3889
3917
|
try {
|
|
3890
3918
|
if (useMock) {
|
|
3891
3919
|
await new Promise((resolve) => setTimeout(resolve, 1500));
|
|
3892
3920
|
const mockResult = `Enhanced version: ${value} [AI-generated content]`;
|
|
3893
|
-
_optionalChain([onResult, 'optionalCall',
|
|
3921
|
+
_optionalChain([onResult, 'optionalCall', _114 => _114(mockResult)]);
|
|
3894
3922
|
setValue("");
|
|
3895
3923
|
} else {
|
|
3896
3924
|
const response = await aptevaClient.chat({
|
|
3897
3925
|
agent_id: agentId,
|
|
3898
3926
|
message: value
|
|
3899
3927
|
});
|
|
3900
|
-
_optionalChain([onResult, 'optionalCall',
|
|
3928
|
+
_optionalChain([onResult, 'optionalCall', _115 => _115(response.message)]);
|
|
3901
3929
|
setValue("");
|
|
3902
3930
|
}
|
|
3903
3931
|
} catch (error) {
|
|
@@ -3992,7 +4020,7 @@ function Stream({
|
|
|
3992
4020
|
}, [autoStart]);
|
|
3993
4021
|
const startStreaming = async () => {
|
|
3994
4022
|
setIsStreaming(true);
|
|
3995
|
-
_optionalChain([onStart, 'optionalCall',
|
|
4023
|
+
_optionalChain([onStart, 'optionalCall', _116 => _116()]);
|
|
3996
4024
|
try {
|
|
3997
4025
|
if (useMock) {
|
|
3998
4026
|
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.";
|
|
@@ -4000,13 +4028,13 @@ function Stream({
|
|
|
4000
4028
|
mockText,
|
|
4001
4029
|
(chunk) => {
|
|
4002
4030
|
setText((prev) => prev + chunk);
|
|
4003
|
-
_optionalChain([onChunk, 'optionalCall',
|
|
4031
|
+
_optionalChain([onChunk, 'optionalCall', _117 => _117(chunk)]);
|
|
4004
4032
|
},
|
|
4005
4033
|
typingSpeed
|
|
4006
4034
|
);
|
|
4007
4035
|
setIsComplete(true);
|
|
4008
4036
|
setIsStreaming(false);
|
|
4009
|
-
_optionalChain([onComplete, 'optionalCall',
|
|
4037
|
+
_optionalChain([onComplete, 'optionalCall', _118 => _118(text + mockText)]);
|
|
4010
4038
|
} else {
|
|
4011
4039
|
let accumulatedText = "";
|
|
4012
4040
|
await aptevaClient.chatStream(
|
|
@@ -4019,24 +4047,24 @@ function Stream({
|
|
|
4019
4047
|
if (chunk.type === "token" && chunk.content) {
|
|
4020
4048
|
accumulatedText += chunk.content;
|
|
4021
4049
|
setText(accumulatedText);
|
|
4022
|
-
_optionalChain([onChunk, 'optionalCall',
|
|
4050
|
+
_optionalChain([onChunk, 'optionalCall', _119 => _119(chunk.content)]);
|
|
4023
4051
|
}
|
|
4024
4052
|
},
|
|
4025
4053
|
() => {
|
|
4026
4054
|
setIsComplete(true);
|
|
4027
4055
|
setIsStreaming(false);
|
|
4028
|
-
_optionalChain([onComplete, 'optionalCall',
|
|
4056
|
+
_optionalChain([onComplete, 'optionalCall', _120 => _120(accumulatedText)]);
|
|
4029
4057
|
},
|
|
4030
4058
|
(error) => {
|
|
4031
4059
|
const err = error instanceof Error ? error : new Error("Streaming error");
|
|
4032
|
-
_optionalChain([onError, 'optionalCall',
|
|
4060
|
+
_optionalChain([onError, 'optionalCall', _121 => _121(err)]);
|
|
4033
4061
|
setIsStreaming(false);
|
|
4034
4062
|
}
|
|
4035
4063
|
);
|
|
4036
4064
|
}
|
|
4037
4065
|
} catch (error) {
|
|
4038
4066
|
const err = error instanceof Error ? error : new Error("Streaming error");
|
|
4039
|
-
_optionalChain([onError, 'optionalCall',
|
|
4067
|
+
_optionalChain([onError, 'optionalCall', _122 => _122(err)]);
|
|
4040
4068
|
setIsStreaming(false);
|
|
4041
4069
|
}
|
|
4042
4070
|
};
|
|
@@ -4128,7 +4156,7 @@ function ThreadList({
|
|
|
4128
4156
|
}) {
|
|
4129
4157
|
const [searchQuery, setSearchQuery] = _react.useState.call(void 0, "");
|
|
4130
4158
|
const filteredThreads = threads.filter(
|
|
4131
|
-
(thread) => thread.title.toLowerCase().includes(searchQuery.toLowerCase()) || _optionalChain([thread, 'access',
|
|
4159
|
+
(thread) => thread.title.toLowerCase().includes(searchQuery.toLowerCase()) || _optionalChain([thread, 'access', _123 => _123.preview, 'optionalAccess', _124 => _124.toLowerCase, 'call', _125 => _125(), 'access', _126 => _126.includes, 'call', _127 => _127(searchQuery.toLowerCase())])
|
|
4132
4160
|
);
|
|
4133
4161
|
const groupedThreads = groupBy === "date" ? groupThreadsByDate(filteredThreads) : { All: filteredThreads };
|
|
4134
4162
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-col h-full", children: [
|
|
@@ -4150,8 +4178,8 @@ function ThreadList({
|
|
|
4150
4178
|
{
|
|
4151
4179
|
thread,
|
|
4152
4180
|
isActive: thread.id === currentThreadId,
|
|
4153
|
-
onSelect: () => _optionalChain([onThreadSelect, 'optionalCall',
|
|
4154
|
-
onDelete: () => _optionalChain([onThreadDelete, 'optionalCall',
|
|
4181
|
+
onSelect: () => _optionalChain([onThreadSelect, 'optionalCall', _128 => _128(thread.id)]),
|
|
4182
|
+
onDelete: () => _optionalChain([onThreadDelete, 'optionalCall', _129 => _129(thread.id)])
|
|
4155
4183
|
},
|
|
4156
4184
|
thread.id
|
|
4157
4185
|
))
|
|
@@ -4213,7 +4241,7 @@ function Threads({
|
|
|
4213
4241
|
threads.slice(0, 5).map((thread) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4214
4242
|
"button",
|
|
4215
4243
|
{
|
|
4216
|
-
onClick: () => _optionalChain([onThreadSelect, 'optionalCall',
|
|
4244
|
+
onClick: () => _optionalChain([onThreadSelect, 'optionalCall', _130 => _130(thread.id)]),
|
|
4217
4245
|
className: cn(
|
|
4218
4246
|
"px-4 py-2 whitespace-nowrap font-medium transition-colors",
|
|
4219
4247
|
thread.id === currentThreadId ? "border-b-2 border-apteva-500 text-apteva-500" : "text-gray-600 hover:text-gray-900"
|