@apteva/apteva-kit 0.1.33 → 0.1.34
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 +60 -57
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3 -0
- package/dist/index.mjs.map +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
|
@@ -2288,6 +2288,7 @@ var Chat = _react.forwardRef.call(void 0, function Chat2({
|
|
|
2288
2288
|
onFileUpload,
|
|
2289
2289
|
onComplete,
|
|
2290
2290
|
onError,
|
|
2291
|
+
onToolCall,
|
|
2291
2292
|
onToolResult,
|
|
2292
2293
|
// UI
|
|
2293
2294
|
placeholder,
|
|
@@ -2480,6 +2481,7 @@ ${widgetContext}` : widgetContext;
|
|
|
2480
2481
|
contentSegments.push({ type: "tool", id: chunk.tool_id, name: chunk.tool_name });
|
|
2481
2482
|
toolInputBuffer = "";
|
|
2482
2483
|
setChatToolName(chunk.tool_name);
|
|
2484
|
+
_optionalChain([onToolCall, 'optionalCall', _60 => _60(chunk.tool_name, chunk.tool_id)]);
|
|
2483
2485
|
updateMessage();
|
|
2484
2486
|
}
|
|
2485
2487
|
break;
|
|
@@ -2493,7 +2495,7 @@ ${widgetContext}` : widgetContext;
|
|
|
2493
2495
|
const toolSegment = contentSegments.find((s) => s.type === "tool" && s.id === chunk.tool_id);
|
|
2494
2496
|
if (toolSegment) {
|
|
2495
2497
|
toolSegment.result = chunk.content;
|
|
2496
|
-
_optionalChain([onToolResult, 'optionalCall',
|
|
2498
|
+
_optionalChain([onToolResult, 'optionalCall', _61 => _61(toolSegment.name, chunk.content)]);
|
|
2497
2499
|
}
|
|
2498
2500
|
setChatToolName(null);
|
|
2499
2501
|
updateMessage();
|
|
@@ -2536,7 +2538,7 @@ ${widgetContext}` : widgetContext;
|
|
|
2536
2538
|
});
|
|
2537
2539
|
if (threadId2 && threadId2 !== currentThreadId) {
|
|
2538
2540
|
setCurrentThreadId(threadId2);
|
|
2539
|
-
_optionalChain([onThreadChange, 'optionalCall',
|
|
2541
|
+
_optionalChain([onThreadChange, 'optionalCall', _62 => _62(threadId2)]);
|
|
2540
2542
|
}
|
|
2541
2543
|
setIsLoading(false);
|
|
2542
2544
|
setCurrentRequestId(null);
|
|
@@ -2560,7 +2562,7 @@ ${widgetContext}` : widgetContext;
|
|
|
2560
2562
|
setIsLoading(false);
|
|
2561
2563
|
setCurrentRequestId(null);
|
|
2562
2564
|
setChatToolName(null);
|
|
2563
|
-
_optionalChain([onError, 'optionalCall',
|
|
2565
|
+
_optionalChain([onError, 'optionalCall', _63 => _63(error)]);
|
|
2564
2566
|
}
|
|
2565
2567
|
);
|
|
2566
2568
|
}
|
|
@@ -2573,7 +2575,7 @@ ${widgetContext}` : widgetContext;
|
|
|
2573
2575
|
metadata: { error: true }
|
|
2574
2576
|
};
|
|
2575
2577
|
setMessages((prev) => [...prev, errorMessage]);
|
|
2576
|
-
_optionalChain([onError, 'optionalCall',
|
|
2578
|
+
_optionalChain([onError, 'optionalCall', _64 => _64(error instanceof Error ? error : new Error("Unknown error"))]);
|
|
2577
2579
|
} finally {
|
|
2578
2580
|
setIsLoading(false);
|
|
2579
2581
|
}
|
|
@@ -2619,7 +2621,7 @@ ${planningInstruction}` : planningInstruction;
|
|
|
2619
2621
|
const error = err instanceof Error ? err : new Error("Failed to generate plan");
|
|
2620
2622
|
setCommandError(error);
|
|
2621
2623
|
setCommandState("error");
|
|
2622
|
-
_optionalChain([onError, 'optionalCall',
|
|
2624
|
+
_optionalChain([onError, 'optionalCall', _65 => _65(error)]);
|
|
2623
2625
|
}
|
|
2624
2626
|
}
|
|
2625
2627
|
return;
|
|
@@ -2652,12 +2654,12 @@ ${planningInstruction}` : planningInstruction;
|
|
|
2652
2654
|
setCommandResult(result);
|
|
2653
2655
|
setCommandState("success");
|
|
2654
2656
|
setProgress(100);
|
|
2655
|
-
_optionalChain([onComplete, 'optionalCall',
|
|
2657
|
+
_optionalChain([onComplete, 'optionalCall', _66 => _66(result)]);
|
|
2656
2658
|
},
|
|
2657
2659
|
(error) => {
|
|
2658
2660
|
setCommandError(error);
|
|
2659
2661
|
setCommandState("error");
|
|
2660
|
-
_optionalChain([onError, 'optionalCall',
|
|
2662
|
+
_optionalChain([onError, 'optionalCall', _67 => _67(error)]);
|
|
2661
2663
|
}
|
|
2662
2664
|
);
|
|
2663
2665
|
} else {
|
|
@@ -2670,7 +2672,7 @@ ${planningInstruction}` : planningInstruction;
|
|
|
2670
2672
|
setCommandResult(result);
|
|
2671
2673
|
setCommandState("success");
|
|
2672
2674
|
setProgress(100);
|
|
2673
|
-
_optionalChain([onComplete, 'optionalCall',
|
|
2675
|
+
_optionalChain([onComplete, 'optionalCall', _68 => _68(result)]);
|
|
2674
2676
|
}
|
|
2675
2677
|
} else {
|
|
2676
2678
|
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 +2701,16 @@ ${commandInstruction}` : commandInstruction;
|
|
|
2699
2701
|
} else if (chunk.type === "tool_call" && chunk.tool_name) {
|
|
2700
2702
|
lastToolName = chunk.tool_name;
|
|
2701
2703
|
setCurrentToolName(chunk.tool_name);
|
|
2704
|
+
_optionalChain([onToolCall, 'optionalCall', _69 => _69(chunk.tool_name, chunk.tool_id || "")]);
|
|
2702
2705
|
accumulatedContent = "";
|
|
2703
2706
|
setStreamedContent("");
|
|
2704
2707
|
} else if (chunk.type === "tool_result") {
|
|
2705
|
-
_optionalChain([onToolResult, 'optionalCall',
|
|
2708
|
+
_optionalChain([onToolResult, 'optionalCall', _70 => _70(lastToolName, chunk.content)]);
|
|
2706
2709
|
setCurrentToolName(null);
|
|
2707
2710
|
} else if (chunk.type === "thread_id" && chunk.thread_id) {
|
|
2708
2711
|
if (!currentThreadId) {
|
|
2709
2712
|
setCurrentThreadId(chunk.thread_id);
|
|
2710
|
-
_optionalChain([onThreadChange, 'optionalCall',
|
|
2713
|
+
_optionalChain([onThreadChange, 'optionalCall', _71 => _71(chunk.thread_id)]);
|
|
2711
2714
|
}
|
|
2712
2715
|
} else if (chunk.type === "request_id" && chunk.request_id) {
|
|
2713
2716
|
setCurrentRequestId(chunk.request_id);
|
|
@@ -2723,13 +2726,13 @@ ${commandInstruction}` : commandInstruction;
|
|
|
2723
2726
|
setCommandState("success");
|
|
2724
2727
|
setProgress(100);
|
|
2725
2728
|
setCurrentRequestId(null);
|
|
2726
|
-
_optionalChain([onComplete, 'optionalCall',
|
|
2729
|
+
_optionalChain([onComplete, 'optionalCall', _72 => _72(result)]);
|
|
2727
2730
|
},
|
|
2728
2731
|
(error) => {
|
|
2729
2732
|
setCommandError(error);
|
|
2730
2733
|
setCommandState("error");
|
|
2731
2734
|
setCurrentRequestId(null);
|
|
2732
|
-
_optionalChain([onError, 'optionalCall',
|
|
2735
|
+
_optionalChain([onError, 'optionalCall', _73 => _73(error)]);
|
|
2733
2736
|
}
|
|
2734
2737
|
);
|
|
2735
2738
|
} else {
|
|
@@ -2749,14 +2752,14 @@ ${commandInstruction}` : commandInstruction;
|
|
|
2749
2752
|
setCommandResult(result);
|
|
2750
2753
|
setCommandState("success");
|
|
2751
2754
|
setProgress(100);
|
|
2752
|
-
_optionalChain([onComplete, 'optionalCall',
|
|
2755
|
+
_optionalChain([onComplete, 'optionalCall', _74 => _74(result)]);
|
|
2753
2756
|
}
|
|
2754
2757
|
}
|
|
2755
2758
|
} catch (err) {
|
|
2756
2759
|
const error = err instanceof Error ? err : new Error("Unknown error");
|
|
2757
2760
|
setCommandError(error);
|
|
2758
2761
|
setCommandState("error");
|
|
2759
|
-
_optionalChain([onError, 'optionalCall',
|
|
2762
|
+
_optionalChain([onError, 'optionalCall', _75 => _75(error)]);
|
|
2760
2763
|
}
|
|
2761
2764
|
};
|
|
2762
2765
|
const resetCommand = () => {
|
|
@@ -2848,8 +2851,8 @@ ${planToExecute}`;
|
|
|
2848
2851
|
executeCommand(text, files);
|
|
2849
2852
|
},
|
|
2850
2853
|
state: commandState,
|
|
2851
|
-
response: _optionalChain([commandResult, 'optionalAccess',
|
|
2852
|
-
error: _optionalChain([commandError, 'optionalAccess',
|
|
2854
|
+
response: _optionalChain([commandResult, 'optionalAccess', _76 => _76.data, 'optionalAccess', _77 => _77.summary]) || _optionalChain([commandResult, 'optionalAccess', _78 => _78.message]),
|
|
2855
|
+
error: _optionalChain([commandError, 'optionalAccess', _79 => _79.message]),
|
|
2853
2856
|
plan,
|
|
2854
2857
|
streamedContent,
|
|
2855
2858
|
toolName: currentToolName,
|
|
@@ -3017,13 +3020,13 @@ ${planningInstruction}` : planningInstruction;
|
|
|
3017
3020
|
const error2 = err instanceof Error ? err : new Error("Failed to generate plan");
|
|
3018
3021
|
setError(error2);
|
|
3019
3022
|
setState("error");
|
|
3020
|
-
_optionalChain([onError, 'optionalCall',
|
|
3023
|
+
_optionalChain([onError, 'optionalCall', _80 => _80(error2)]);
|
|
3021
3024
|
});
|
|
3022
3025
|
} catch (err) {
|
|
3023
3026
|
const error2 = err instanceof Error ? err : new Error("Failed to generate plan");
|
|
3024
3027
|
setError(error2);
|
|
3025
3028
|
setState("error");
|
|
3026
|
-
_optionalChain([onError, 'optionalCall',
|
|
3029
|
+
_optionalChain([onError, 'optionalCall', _81 => _81(error2)]);
|
|
3027
3030
|
}
|
|
3028
3031
|
}
|
|
3029
3032
|
return;
|
|
@@ -3034,7 +3037,7 @@ ${planningInstruction}` : planningInstruction;
|
|
|
3034
3037
|
setStreamedContent("");
|
|
3035
3038
|
setCommand("");
|
|
3036
3039
|
setUploadedFiles([]);
|
|
3037
|
-
_optionalChain([onStart, 'optionalCall',
|
|
3040
|
+
_optionalChain([onStart, 'optionalCall', _82 => _82()]);
|
|
3038
3041
|
try {
|
|
3039
3042
|
if (useMock) {
|
|
3040
3043
|
if (enableStreaming) {
|
|
@@ -3045,16 +3048,16 @@ ${planningInstruction}` : planningInstruction;
|
|
|
3045
3048
|
if (chunk.type === "token" && chunk.content) {
|
|
3046
3049
|
accumulatedContent += chunk.content;
|
|
3047
3050
|
setStreamedContent(accumulatedContent);
|
|
3048
|
-
_optionalChain([onChunk, 'optionalCall',
|
|
3051
|
+
_optionalChain([onChunk, 'optionalCall', _83 => _83(chunk.content)]);
|
|
3049
3052
|
const estimatedProgress = Math.min(Math.round(accumulatedContent.length / 10), 90);
|
|
3050
3053
|
setProgress(estimatedProgress);
|
|
3051
|
-
_optionalChain([onProgress, 'optionalCall',
|
|
3054
|
+
_optionalChain([onProgress, 'optionalCall', _84 => _84(estimatedProgress)]);
|
|
3052
3055
|
} else if (chunk.type === "widget" && chunk.widget) {
|
|
3053
3056
|
const widget = chunk.widget;
|
|
3054
3057
|
setResult((prev) => ({
|
|
3055
3058
|
success: true,
|
|
3056
|
-
data: _optionalChain([prev, 'optionalAccess',
|
|
3057
|
-
widgets: [..._optionalChain([prev, 'optionalAccess',
|
|
3059
|
+
data: _optionalChain([prev, 'optionalAccess', _85 => _85.data]) || {},
|
|
3060
|
+
widgets: [..._optionalChain([prev, 'optionalAccess', _86 => _86.widgets]) || [], widget],
|
|
3058
3061
|
message: accumulatedContent || "Command executed successfully"
|
|
3059
3062
|
}));
|
|
3060
3063
|
}
|
|
@@ -3074,19 +3077,19 @@ ${planningInstruction}` : planningInstruction;
|
|
|
3074
3077
|
setResult(result2);
|
|
3075
3078
|
setState("success");
|
|
3076
3079
|
setProgress(100);
|
|
3077
|
-
_optionalChain([onComplete, 'optionalCall',
|
|
3080
|
+
_optionalChain([onComplete, 'optionalCall', _87 => _87(result2)]);
|
|
3078
3081
|
},
|
|
3079
3082
|
(error2) => {
|
|
3080
3083
|
setError(error2);
|
|
3081
3084
|
setState("error");
|
|
3082
|
-
_optionalChain([onError, 'optionalCall',
|
|
3085
|
+
_optionalChain([onError, 'optionalCall', _88 => _88(error2)]);
|
|
3083
3086
|
}
|
|
3084
3087
|
);
|
|
3085
3088
|
} else {
|
|
3086
3089
|
const progressInterval = setInterval(() => {
|
|
3087
3090
|
setProgress((prev) => {
|
|
3088
3091
|
const next = Math.min(prev + 10, 90);
|
|
3089
|
-
_optionalChain([onProgress, 'optionalCall',
|
|
3092
|
+
_optionalChain([onProgress, 'optionalCall', _89 => _89(next)]);
|
|
3090
3093
|
return next;
|
|
3091
3094
|
});
|
|
3092
3095
|
}, 200);
|
|
@@ -3110,7 +3113,7 @@ ${planningInstruction}` : planningInstruction;
|
|
|
3110
3113
|
setResult(result2);
|
|
3111
3114
|
setState("success");
|
|
3112
3115
|
setProgress(100);
|
|
3113
|
-
_optionalChain([onComplete, 'optionalCall',
|
|
3116
|
+
_optionalChain([onComplete, 'optionalCall', _90 => _90(result2)]);
|
|
3114
3117
|
}
|
|
3115
3118
|
} else {
|
|
3116
3119
|
if (enableStreaming) {
|
|
@@ -3156,16 +3159,16 @@ ${commandInstruction}` : commandInstruction;
|
|
|
3156
3159
|
if (chunk.type === "token" && chunk.content) {
|
|
3157
3160
|
accumulatedContent += chunk.content;
|
|
3158
3161
|
setStreamedContent(accumulatedContent);
|
|
3159
|
-
_optionalChain([onChunk, 'optionalCall',
|
|
3162
|
+
_optionalChain([onChunk, 'optionalCall', _91 => _91(chunk.content)]);
|
|
3160
3163
|
const estimatedProgress = Math.min(Math.round(accumulatedContent.length / 10), 90);
|
|
3161
3164
|
setProgress(estimatedProgress);
|
|
3162
|
-
_optionalChain([onProgress, 'optionalCall',
|
|
3165
|
+
_optionalChain([onProgress, 'optionalCall', _92 => _92(estimatedProgress)]);
|
|
3163
3166
|
} else if (chunk.type === "widget" && chunk.widget) {
|
|
3164
3167
|
const widget = chunk.widget;
|
|
3165
3168
|
setResult((prev) => ({
|
|
3166
3169
|
success: true,
|
|
3167
|
-
data: _optionalChain([prev, 'optionalAccess',
|
|
3168
|
-
widgets: [..._optionalChain([prev, 'optionalAccess',
|
|
3170
|
+
data: _optionalChain([prev, 'optionalAccess', _93 => _93.data]) || {},
|
|
3171
|
+
widgets: [..._optionalChain([prev, 'optionalAccess', _94 => _94.widgets]) || [], widget],
|
|
3169
3172
|
message: accumulatedContent || "Command executed successfully"
|
|
3170
3173
|
}));
|
|
3171
3174
|
}
|
|
@@ -3185,20 +3188,20 @@ ${commandInstruction}` : commandInstruction;
|
|
|
3185
3188
|
setResult(result2);
|
|
3186
3189
|
setState("success");
|
|
3187
3190
|
setProgress(100);
|
|
3188
|
-
_optionalChain([onComplete, 'optionalCall',
|
|
3191
|
+
_optionalChain([onComplete, 'optionalCall', _95 => _95(result2)]);
|
|
3189
3192
|
},
|
|
3190
3193
|
(error2) => {
|
|
3191
3194
|
const err = error2 instanceof Error ? error2 : new Error("Unknown error");
|
|
3192
3195
|
setError(err);
|
|
3193
3196
|
setState("error");
|
|
3194
|
-
_optionalChain([onError, 'optionalCall',
|
|
3197
|
+
_optionalChain([onError, 'optionalCall', _96 => _96(err)]);
|
|
3195
3198
|
}
|
|
3196
3199
|
);
|
|
3197
3200
|
} else {
|
|
3198
3201
|
const progressInterval = setInterval(() => {
|
|
3199
3202
|
setProgress((prev) => {
|
|
3200
3203
|
const next = Math.min(prev + 10, 90);
|
|
3201
|
-
_optionalChain([onProgress, 'optionalCall',
|
|
3204
|
+
_optionalChain([onProgress, 'optionalCall', _97 => _97(next)]);
|
|
3202
3205
|
return next;
|
|
3203
3206
|
});
|
|
3204
3207
|
}, 200);
|
|
@@ -3254,14 +3257,14 @@ ${commandInstruction}` : commandInstruction;
|
|
|
3254
3257
|
setResult(result2);
|
|
3255
3258
|
setState("success");
|
|
3256
3259
|
setProgress(100);
|
|
3257
|
-
_optionalChain([onComplete, 'optionalCall',
|
|
3260
|
+
_optionalChain([onComplete, 'optionalCall', _98 => _98(result2)]);
|
|
3258
3261
|
}
|
|
3259
3262
|
}
|
|
3260
3263
|
} catch (err) {
|
|
3261
3264
|
const error2 = err instanceof Error ? err : new Error("Unknown error");
|
|
3262
3265
|
setError(error2);
|
|
3263
3266
|
setState("error");
|
|
3264
|
-
_optionalChain([onError, 'optionalCall',
|
|
3267
|
+
_optionalChain([onError, 'optionalCall', _99 => _99(error2)]);
|
|
3265
3268
|
}
|
|
3266
3269
|
};
|
|
3267
3270
|
const resetCommand = () => {
|
|
@@ -3294,14 +3297,14 @@ ${planToExecute}`;
|
|
|
3294
3297
|
};
|
|
3295
3298
|
const handleFileSelect = async (e) => {
|
|
3296
3299
|
if (e.target.files && e.target.files.length > 0) {
|
|
3297
|
-
_optionalChain([onFileUpload, 'optionalCall',
|
|
3300
|
+
_optionalChain([onFileUpload, 'optionalCall', _100 => _100(e.target.files)]);
|
|
3298
3301
|
const files = [];
|
|
3299
3302
|
for (let i = 0; i < e.target.files.length; i++) {
|
|
3300
3303
|
const file = e.target.files[i];
|
|
3301
3304
|
const reader = new FileReader();
|
|
3302
3305
|
await new Promise((resolve) => {
|
|
3303
3306
|
reader.onload = (event) => {
|
|
3304
|
-
if (_optionalChain([event, 'access',
|
|
3307
|
+
if (_optionalChain([event, 'access', _101 => _101.target, 'optionalAccess', _102 => _102.result])) {
|
|
3305
3308
|
const fullDataUrl = event.target.result;
|
|
3306
3309
|
const base64Data = fullDataUrl.split(",")[1];
|
|
3307
3310
|
if (file.type.startsWith("image/")) {
|
|
@@ -3395,7 +3398,7 @@ ${planToExecute}`;
|
|
|
3395
3398
|
enableFileUpload && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3396
3399
|
"button",
|
|
3397
3400
|
{
|
|
3398
|
-
onClick: () => _optionalChain([fileInputRef, 'access',
|
|
3401
|
+
onClick: () => _optionalChain([fileInputRef, 'access', _103 => _103.current, 'optionalAccess', _104 => _104.click, 'call', _105 => _105()]),
|
|
3399
3402
|
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
3403
|
title: "Attach file",
|
|
3401
3404
|
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 +3617,7 @@ ${planToExecute}`;
|
|
|
3614
3617
|
/* @__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
3618
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { children: [
|
|
3616
3619
|
/* @__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',
|
|
3620
|
+
/* @__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
3621
|
] })
|
|
3619
3622
|
] }) }),
|
|
3620
3623
|
allowInput && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
@@ -3642,7 +3645,7 @@ ${planToExecute}`;
|
|
|
3642
3645
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-green-700 dark:text-green-300 text-sm", children: "Command executed successfully" })
|
|
3643
3646
|
] })
|
|
3644
3647
|
] }),
|
|
3645
|
-
_optionalChain([result, 'access',
|
|
3648
|
+
_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
3649
|
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
3650
|
WidgetRenderer,
|
|
3648
3651
|
{
|
|
@@ -3693,7 +3696,7 @@ ${planToExecute}`;
|
|
|
3693
3696
|
enableFileUpload && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3694
3697
|
"button",
|
|
3695
3698
|
{
|
|
3696
|
-
onClick: () => _optionalChain([fileInputRef, 'access',
|
|
3699
|
+
onClick: () => _optionalChain([fileInputRef, 'access', _109 => _109.current, 'optionalAccess', _110 => _110.click, 'call', _111 => _111()]),
|
|
3697
3700
|
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
3701
|
title: "Attach file",
|
|
3699
3702
|
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 +3882,25 @@ function Prompt({
|
|
|
3879
3882
|
const newValue = e.target.value;
|
|
3880
3883
|
if (!maxLength || newValue.length <= maxLength) {
|
|
3881
3884
|
setValue(newValue);
|
|
3882
|
-
_optionalChain([onChange, 'optionalCall',
|
|
3885
|
+
_optionalChain([onChange, 'optionalCall', _112 => _112(newValue)]);
|
|
3883
3886
|
}
|
|
3884
3887
|
};
|
|
3885
3888
|
const handleSubmit = async () => {
|
|
3886
3889
|
if (value.length < minLength) return;
|
|
3887
|
-
_optionalChain([onSubmit, 'optionalCall',
|
|
3890
|
+
_optionalChain([onSubmit, 'optionalCall', _113 => _113(value)]);
|
|
3888
3891
|
setIsLoading(true);
|
|
3889
3892
|
try {
|
|
3890
3893
|
if (useMock) {
|
|
3891
3894
|
await new Promise((resolve) => setTimeout(resolve, 1500));
|
|
3892
3895
|
const mockResult = `Enhanced version: ${value} [AI-generated content]`;
|
|
3893
|
-
_optionalChain([onResult, 'optionalCall',
|
|
3896
|
+
_optionalChain([onResult, 'optionalCall', _114 => _114(mockResult)]);
|
|
3894
3897
|
setValue("");
|
|
3895
3898
|
} else {
|
|
3896
3899
|
const response = await aptevaClient.chat({
|
|
3897
3900
|
agent_id: agentId,
|
|
3898
3901
|
message: value
|
|
3899
3902
|
});
|
|
3900
|
-
_optionalChain([onResult, 'optionalCall',
|
|
3903
|
+
_optionalChain([onResult, 'optionalCall', _115 => _115(response.message)]);
|
|
3901
3904
|
setValue("");
|
|
3902
3905
|
}
|
|
3903
3906
|
} catch (error) {
|
|
@@ -3992,7 +3995,7 @@ function Stream({
|
|
|
3992
3995
|
}, [autoStart]);
|
|
3993
3996
|
const startStreaming = async () => {
|
|
3994
3997
|
setIsStreaming(true);
|
|
3995
|
-
_optionalChain([onStart, 'optionalCall',
|
|
3998
|
+
_optionalChain([onStart, 'optionalCall', _116 => _116()]);
|
|
3996
3999
|
try {
|
|
3997
4000
|
if (useMock) {
|
|
3998
4001
|
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 +4003,13 @@ function Stream({
|
|
|
4000
4003
|
mockText,
|
|
4001
4004
|
(chunk) => {
|
|
4002
4005
|
setText((prev) => prev + chunk);
|
|
4003
|
-
_optionalChain([onChunk, 'optionalCall',
|
|
4006
|
+
_optionalChain([onChunk, 'optionalCall', _117 => _117(chunk)]);
|
|
4004
4007
|
},
|
|
4005
4008
|
typingSpeed
|
|
4006
4009
|
);
|
|
4007
4010
|
setIsComplete(true);
|
|
4008
4011
|
setIsStreaming(false);
|
|
4009
|
-
_optionalChain([onComplete, 'optionalCall',
|
|
4012
|
+
_optionalChain([onComplete, 'optionalCall', _118 => _118(text + mockText)]);
|
|
4010
4013
|
} else {
|
|
4011
4014
|
let accumulatedText = "";
|
|
4012
4015
|
await aptevaClient.chatStream(
|
|
@@ -4019,24 +4022,24 @@ function Stream({
|
|
|
4019
4022
|
if (chunk.type === "token" && chunk.content) {
|
|
4020
4023
|
accumulatedText += chunk.content;
|
|
4021
4024
|
setText(accumulatedText);
|
|
4022
|
-
_optionalChain([onChunk, 'optionalCall',
|
|
4025
|
+
_optionalChain([onChunk, 'optionalCall', _119 => _119(chunk.content)]);
|
|
4023
4026
|
}
|
|
4024
4027
|
},
|
|
4025
4028
|
() => {
|
|
4026
4029
|
setIsComplete(true);
|
|
4027
4030
|
setIsStreaming(false);
|
|
4028
|
-
_optionalChain([onComplete, 'optionalCall',
|
|
4031
|
+
_optionalChain([onComplete, 'optionalCall', _120 => _120(accumulatedText)]);
|
|
4029
4032
|
},
|
|
4030
4033
|
(error) => {
|
|
4031
4034
|
const err = error instanceof Error ? error : new Error("Streaming error");
|
|
4032
|
-
_optionalChain([onError, 'optionalCall',
|
|
4035
|
+
_optionalChain([onError, 'optionalCall', _121 => _121(err)]);
|
|
4033
4036
|
setIsStreaming(false);
|
|
4034
4037
|
}
|
|
4035
4038
|
);
|
|
4036
4039
|
}
|
|
4037
4040
|
} catch (error) {
|
|
4038
4041
|
const err = error instanceof Error ? error : new Error("Streaming error");
|
|
4039
|
-
_optionalChain([onError, 'optionalCall',
|
|
4042
|
+
_optionalChain([onError, 'optionalCall', _122 => _122(err)]);
|
|
4040
4043
|
setIsStreaming(false);
|
|
4041
4044
|
}
|
|
4042
4045
|
};
|
|
@@ -4128,7 +4131,7 @@ function ThreadList({
|
|
|
4128
4131
|
}) {
|
|
4129
4132
|
const [searchQuery, setSearchQuery] = _react.useState.call(void 0, "");
|
|
4130
4133
|
const filteredThreads = threads.filter(
|
|
4131
|
-
(thread) => thread.title.toLowerCase().includes(searchQuery.toLowerCase()) || _optionalChain([thread, 'access',
|
|
4134
|
+
(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
4135
|
);
|
|
4133
4136
|
const groupedThreads = groupBy === "date" ? groupThreadsByDate(filteredThreads) : { All: filteredThreads };
|
|
4134
4137
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-col h-full", children: [
|
|
@@ -4150,8 +4153,8 @@ function ThreadList({
|
|
|
4150
4153
|
{
|
|
4151
4154
|
thread,
|
|
4152
4155
|
isActive: thread.id === currentThreadId,
|
|
4153
|
-
onSelect: () => _optionalChain([onThreadSelect, 'optionalCall',
|
|
4154
|
-
onDelete: () => _optionalChain([onThreadDelete, 'optionalCall',
|
|
4156
|
+
onSelect: () => _optionalChain([onThreadSelect, 'optionalCall', _128 => _128(thread.id)]),
|
|
4157
|
+
onDelete: () => _optionalChain([onThreadDelete, 'optionalCall', _129 => _129(thread.id)])
|
|
4155
4158
|
},
|
|
4156
4159
|
thread.id
|
|
4157
4160
|
))
|
|
@@ -4213,7 +4216,7 @@ function Threads({
|
|
|
4213
4216
|
threads.slice(0, 5).map((thread) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4214
4217
|
"button",
|
|
4215
4218
|
{
|
|
4216
|
-
onClick: () => _optionalChain([onThreadSelect, 'optionalCall',
|
|
4219
|
+
onClick: () => _optionalChain([onThreadSelect, 'optionalCall', _130 => _130(thread.id)]),
|
|
4217
4220
|
className: cn(
|
|
4218
4221
|
"px-4 py-2 whitespace-nowrap font-medium transition-colors",
|
|
4219
4222
|
thread.id === currentThreadId ? "border-b-2 border-apteva-500 text-apteva-500" : "text-gray-600 hover:text-gray-900"
|