@apteva/apteva-kit 0.1.16 → 0.1.17

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 CHANGED
@@ -195,6 +195,7 @@ interface ChatProps {
195
195
  onFileUpload?: (files: FileList) => void;
196
196
  onComplete?: (result: CommandResult) => void;
197
197
  onError?: (error: Error) => void;
198
+ onToolResult?: (toolName: string, result?: any) => void;
198
199
  theme?: 'light' | 'dark' | 'auto';
199
200
  placeholder?: string;
200
201
  showHeader?: boolean;
@@ -223,6 +224,7 @@ interface CommandProps {
223
224
  onError?: (error: Error) => void;
224
225
  onFileUpload?: (files: FileList) => void;
225
226
  onAction?: (action: ActionEvent) => void;
227
+ onToolResult?: (toolName: string, result?: any) => void;
226
228
  loadingText?: string;
227
229
  showProgress?: boolean;
228
230
  enableStreaming?: boolean;
@@ -304,7 +306,7 @@ interface UseAptevaKitReturn {
304
306
  error: Error | null;
305
307
  }
306
308
 
307
- declare function Chat({ agentId, threadId, initialMessages, context, apiUrl, apiKey, useMock, initialMode, showModeToggle, onModeChange, commandVariant, planMode, onPlanModeChange, enableStreaming, showProgress, loadingText, welcomeTitle, welcomeSubtitle, welcomeIcon, suggestedPrompts, welcomeVariant, onThreadChange, onMessageSent, onAction, onFileUpload, onComplete, onError, placeholder, showHeader, headerTitle, className, }: ChatProps): react_jsx_runtime.JSX.Element;
309
+ declare function Chat({ agentId, threadId, initialMessages, context, apiUrl, apiKey, useMock, initialMode, showModeToggle, onModeChange, commandVariant, planMode, onPlanModeChange, enableStreaming, showProgress, loadingText, welcomeTitle, welcomeSubtitle, welcomeIcon, suggestedPrompts, welcomeVariant, onThreadChange, onMessageSent, onAction, onFileUpload, onComplete, onError, onToolResult, placeholder, showHeader, headerTitle, className, }: ChatProps): react_jsx_runtime.JSX.Element;
308
310
 
309
311
  declare function Command({ agentId, command: initialCommand, context, autoExecute, allowInput, placeholder, submitButtonText, variant, useMock, planMode, onPlanModeChange, enableFileUpload, onStart, onProgress, onChunk, onComplete, onError, onFileUpload, onAction, loadingText, showProgress, enableStreaming, resultRenderer, className, }: CommandProps): react_jsx_runtime.JSX.Element;
310
312
 
package/dist/index.d.ts CHANGED
@@ -195,6 +195,7 @@ interface ChatProps {
195
195
  onFileUpload?: (files: FileList) => void;
196
196
  onComplete?: (result: CommandResult) => void;
197
197
  onError?: (error: Error) => void;
198
+ onToolResult?: (toolName: string, result?: any) => void;
198
199
  theme?: 'light' | 'dark' | 'auto';
199
200
  placeholder?: string;
200
201
  showHeader?: boolean;
@@ -223,6 +224,7 @@ interface CommandProps {
223
224
  onError?: (error: Error) => void;
224
225
  onFileUpload?: (files: FileList) => void;
225
226
  onAction?: (action: ActionEvent) => void;
227
+ onToolResult?: (toolName: string, result?: any) => void;
226
228
  loadingText?: string;
227
229
  showProgress?: boolean;
228
230
  enableStreaming?: boolean;
@@ -304,7 +306,7 @@ interface UseAptevaKitReturn {
304
306
  error: Error | null;
305
307
  }
306
308
 
307
- declare function Chat({ agentId, threadId, initialMessages, context, apiUrl, apiKey, useMock, initialMode, showModeToggle, onModeChange, commandVariant, planMode, onPlanModeChange, enableStreaming, showProgress, loadingText, welcomeTitle, welcomeSubtitle, welcomeIcon, suggestedPrompts, welcomeVariant, onThreadChange, onMessageSent, onAction, onFileUpload, onComplete, onError, placeholder, showHeader, headerTitle, className, }: ChatProps): react_jsx_runtime.JSX.Element;
309
+ declare function Chat({ agentId, threadId, initialMessages, context, apiUrl, apiKey, useMock, initialMode, showModeToggle, onModeChange, commandVariant, planMode, onPlanModeChange, enableStreaming, showProgress, loadingText, welcomeTitle, welcomeSubtitle, welcomeIcon, suggestedPrompts, welcomeVariant, onThreadChange, onMessageSent, onAction, onFileUpload, onComplete, onError, onToolResult, placeholder, showHeader, headerTitle, className, }: ChatProps): react_jsx_runtime.JSX.Element;
308
310
 
309
311
  declare function Command({ agentId, command: initialCommand, context, autoExecute, allowInput, placeholder, submitButtonText, variant, useMock, planMode, onPlanModeChange, enableFileUpload, onStart, onProgress, onChunk, onComplete, onError, onFileUpload, onAction, loadingText, showProgress, enableStreaming, resultRenderer, className, }: CommandProps): react_jsx_runtime.JSX.Element;
310
312
 
package/dist/index.js CHANGED
@@ -1384,26 +1384,6 @@ function CommandComposer({
1384
1384
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "svg", { className: "w-3 h-3 flex-shrink-0", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", 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" }) }),
1385
1385
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: fileError })
1386
1386
  ] }) }),
1387
- pendingFiles.length > 0 && state === "idle" && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "mb-2 flex flex-wrap gap-2", children: pendingFiles.map((pf, index) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
1388
- "div",
1389
- {
1390
- className: "relative group flex items-center gap-2 px-2 py-1.5 bg-gray-100 dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg",
1391
- children: [
1392
- pf.preview ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "img", { src: pf.preview, alt: pf.file.name, className: "w-6 h-6 object-cover rounded" }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "w-6 h-6 flex items-center justify-center bg-gray-200 dark:bg-gray-700 rounded !text-gray-500 dark:!text-gray-400", children: getFileIcon(pf.file.type) }),
1393
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-xs font-medium !text-gray-700 dark:!text-gray-300 truncate max-w-[100px]", children: pf.file.name }),
1394
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1395
- "button",
1396
- {
1397
- onClick: () => removeFile(index),
1398
- className: "w-4 h-4 bg-gray-500 hover:bg-red-500 text-white rounded-full flex items-center justify-center",
1399
- title: "Remove file",
1400
- children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "svg", { className: "w-2.5 h-2.5", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M6 18L18 6M6 6l12 12" }) })
1401
- }
1402
- )
1403
- ]
1404
- },
1405
- index
1406
- )) }),
1407
1387
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
1408
1388
  "div",
1409
1389
  {
@@ -1475,6 +1455,26 @@ function CommandComposer({
1475
1455
  state === "loading" && !toolName && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "w-4 h-4 border-2 border-blue-200 border-t-blue-500 rounded-full animate-spin" }),
1476
1456
  state === "loading" && toolName && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "w-2 h-2 rounded-full bg-blue-500 animate-pulse" })
1477
1457
  ] }),
1458
+ pendingFiles.length > 0 && state === "idle" && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "flex items-center gap-1 flex-shrink-0", children: pendingFiles.map((pf, index) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
1459
+ "div",
1460
+ {
1461
+ className: "relative group flex items-center justify-center w-6 h-6 bg-gray-100 dark:bg-gray-800 rounded overflow-hidden",
1462
+ title: pf.file.name,
1463
+ children: [
1464
+ pf.preview ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "img", { src: pf.preview, alt: pf.file.name, className: "w-6 h-6 object-cover" }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-xs !text-gray-500 dark:!text-gray-400", children: getFileIcon(pf.file.type) }),
1465
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1466
+ "button",
1467
+ {
1468
+ onClick: () => removeFile(index),
1469
+ className: "absolute inset-0 bg-black/50 opacity-0 group-hover:opacity-100 flex items-center justify-center transition-opacity",
1470
+ title: "Remove",
1471
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "svg", { className: "w-3 h-3 text-white", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M6 18L18 6M6 6l12 12" }) })
1472
+ }
1473
+ )
1474
+ ]
1475
+ },
1476
+ index
1477
+ )) }),
1478
1478
  state === "idle" ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1479
1479
  "textarea",
1480
1480
  {
@@ -1482,7 +1482,7 @@ function CommandComposer({
1482
1482
  value: input,
1483
1483
  onChange: (e) => handleInputChange(e.target.value),
1484
1484
  onKeyDown: handleKeyDown,
1485
- placeholder,
1485
+ placeholder: pendingFiles.length > 0 ? "Add a message..." : placeholder,
1486
1486
  disabled,
1487
1487
  rows: 1,
1488
1488
  className: cn(
@@ -1768,6 +1768,7 @@ function Chat({
1768
1768
  onFileUpload,
1769
1769
  onComplete,
1770
1770
  onError,
1771
+ onToolResult,
1771
1772
  // UI
1772
1773
  placeholder,
1773
1774
  showHeader = true,
@@ -1935,6 +1936,7 @@ function Chat({
1935
1936
  const toolSegment = contentSegments.find((s) => s.type === "tool" && s.id === chunk.tool_id);
1936
1937
  if (toolSegment) {
1937
1938
  toolSegment.result = chunk.content;
1939
+ _optionalChain([onToolResult, 'optionalCall', _55 => _55(toolSegment.name, chunk.content)]);
1938
1940
  }
1939
1941
  updateMessage();
1940
1942
  }
@@ -1976,7 +1978,7 @@ function Chat({
1976
1978
  });
1977
1979
  if (threadId2 && threadId2 !== currentThreadId) {
1978
1980
  setCurrentThreadId(threadId2);
1979
- _optionalChain([onThreadChange, 'optionalCall', _55 => _55(threadId2)]);
1981
+ _optionalChain([onThreadChange, 'optionalCall', _56 => _56(threadId2)]);
1980
1982
  }
1981
1983
  setIsLoading(false);
1982
1984
  },
@@ -1996,7 +1998,7 @@ function Chat({
1996
1998
  return [...prev, errorMessage];
1997
1999
  });
1998
2000
  setIsLoading(false);
1999
- _optionalChain([onError, 'optionalCall', _56 => _56(error)]);
2001
+ _optionalChain([onError, 'optionalCall', _57 => _57(error)]);
2000
2002
  }
2001
2003
  );
2002
2004
  }
@@ -2009,7 +2011,7 @@ function Chat({
2009
2011
  metadata: { error: true }
2010
2012
  };
2011
2013
  setMessages((prev) => [...prev, errorMessage]);
2012
- _optionalChain([onError, 'optionalCall', _57 => _57(error instanceof Error ? error : new Error("Unknown error"))]);
2014
+ _optionalChain([onError, 'optionalCall', _58 => _58(error instanceof Error ? error : new Error("Unknown error"))]);
2013
2015
  } finally {
2014
2016
  setIsLoading(false);
2015
2017
  }
@@ -2054,7 +2056,7 @@ ${planningInstruction}` : planningInstruction;
2054
2056
  const error = err instanceof Error ? err : new Error("Failed to generate plan");
2055
2057
  setCommandError(error);
2056
2058
  setCommandState("error");
2057
- _optionalChain([onError, 'optionalCall', _58 => _58(error)]);
2059
+ _optionalChain([onError, 'optionalCall', _59 => _59(error)]);
2058
2060
  }
2059
2061
  }
2060
2062
  return;
@@ -2087,12 +2089,12 @@ ${planningInstruction}` : planningInstruction;
2087
2089
  setCommandResult(result);
2088
2090
  setCommandState("success");
2089
2091
  setProgress(100);
2090
- _optionalChain([onComplete, 'optionalCall', _59 => _59(result)]);
2092
+ _optionalChain([onComplete, 'optionalCall', _60 => _60(result)]);
2091
2093
  },
2092
2094
  (error) => {
2093
2095
  setCommandError(error);
2094
2096
  setCommandState("error");
2095
- _optionalChain([onError, 'optionalCall', _60 => _60(error)]);
2097
+ _optionalChain([onError, 'optionalCall', _61 => _61(error)]);
2096
2098
  }
2097
2099
  );
2098
2100
  } else {
@@ -2105,7 +2107,7 @@ ${planningInstruction}` : planningInstruction;
2105
2107
  setCommandResult(result);
2106
2108
  setCommandState("success");
2107
2109
  setProgress(100);
2108
- _optionalChain([onComplete, 'optionalCall', _61 => _61(result)]);
2110
+ _optionalChain([onComplete, 'optionalCall', _62 => _62(result)]);
2109
2111
  }
2110
2112
  } else {
2111
2113
  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.`;
@@ -2115,6 +2117,7 @@ ${commandInstruction}` : commandInstruction;
2115
2117
  const messagePayload = files && files.length > 0 ? await buildMessageWithAttachments(currentCommand, files) : currentCommand;
2116
2118
  if (enableStreaming) {
2117
2119
  let accumulatedContent = "";
2120
+ let lastToolName = "";
2118
2121
  await aptevaClient.chatStream(
2119
2122
  {
2120
2123
  agent_id: agentId,
@@ -2131,15 +2134,17 @@ ${commandInstruction}` : commandInstruction;
2131
2134
  const estimatedProgress = Math.min(Math.round(accumulatedContent.length / 10), 90);
2132
2135
  setProgress(estimatedProgress);
2133
2136
  } else if (chunk.type === "tool_call" && chunk.tool_name) {
2137
+ lastToolName = chunk.tool_name;
2134
2138
  setCurrentToolName(chunk.tool_name);
2135
2139
  accumulatedContent = "";
2136
2140
  setStreamedContent("");
2137
2141
  } else if (chunk.type === "tool_result") {
2142
+ _optionalChain([onToolResult, 'optionalCall', _63 => _63(lastToolName, chunk.content)]);
2138
2143
  setCurrentToolName(null);
2139
2144
  } else if (chunk.type === "thread_id" && chunk.thread_id) {
2140
2145
  if (!currentThreadId) {
2141
2146
  setCurrentThreadId(chunk.thread_id);
2142
- _optionalChain([onThreadChange, 'optionalCall', _62 => _62(chunk.thread_id)]);
2147
+ _optionalChain([onThreadChange, 'optionalCall', _64 => _64(chunk.thread_id)]);
2143
2148
  }
2144
2149
  }
2145
2150
  },
@@ -2152,12 +2157,12 @@ ${commandInstruction}` : commandInstruction;
2152
2157
  setCommandResult(result);
2153
2158
  setCommandState("success");
2154
2159
  setProgress(100);
2155
- _optionalChain([onComplete, 'optionalCall', _63 => _63(result)]);
2160
+ _optionalChain([onComplete, 'optionalCall', _65 => _65(result)]);
2156
2161
  },
2157
2162
  (error) => {
2158
2163
  setCommandError(error);
2159
2164
  setCommandState("error");
2160
- _optionalChain([onError, 'optionalCall', _64 => _64(error)]);
2165
+ _optionalChain([onError, 'optionalCall', _66 => _66(error)]);
2161
2166
  }
2162
2167
  );
2163
2168
  } else {
@@ -2177,14 +2182,14 @@ ${commandInstruction}` : commandInstruction;
2177
2182
  setCommandResult(result);
2178
2183
  setCommandState("success");
2179
2184
  setProgress(100);
2180
- _optionalChain([onComplete, 'optionalCall', _65 => _65(result)]);
2185
+ _optionalChain([onComplete, 'optionalCall', _67 => _67(result)]);
2181
2186
  }
2182
2187
  }
2183
2188
  } catch (err) {
2184
2189
  const error = err instanceof Error ? err : new Error("Unknown error");
2185
2190
  setCommandError(error);
2186
2191
  setCommandState("error");
2187
- _optionalChain([onError, 'optionalCall', _66 => _66(error)]);
2192
+ _optionalChain([onError, 'optionalCall', _68 => _68(error)]);
2188
2193
  }
2189
2194
  };
2190
2195
  const resetCommand = () => {
@@ -2250,8 +2255,8 @@ ${planToExecute}`;
2250
2255
  executeCommand(text, files);
2251
2256
  },
2252
2257
  state: commandState,
2253
- response: _optionalChain([commandResult, 'optionalAccess', _67 => _67.data, 'optionalAccess', _68 => _68.summary]) || _optionalChain([commandResult, 'optionalAccess', _69 => _69.message]),
2254
- error: _optionalChain([commandError, 'optionalAccess', _70 => _70.message]),
2258
+ response: _optionalChain([commandResult, 'optionalAccess', _69 => _69.data, 'optionalAccess', _70 => _70.summary]) || _optionalChain([commandResult, 'optionalAccess', _71 => _71.message]),
2259
+ error: _optionalChain([commandError, 'optionalAccess', _72 => _72.message]),
2255
2260
  plan,
2256
2261
  streamedContent,
2257
2262
  toolName: currentToolName,
@@ -2418,13 +2423,13 @@ ${planningInstruction}` : planningInstruction;
2418
2423
  const error2 = err instanceof Error ? err : new Error("Failed to generate plan");
2419
2424
  setError(error2);
2420
2425
  setState("error");
2421
- _optionalChain([onError, 'optionalCall', _71 => _71(error2)]);
2426
+ _optionalChain([onError, 'optionalCall', _73 => _73(error2)]);
2422
2427
  });
2423
2428
  } catch (err) {
2424
2429
  const error2 = err instanceof Error ? err : new Error("Failed to generate plan");
2425
2430
  setError(error2);
2426
2431
  setState("error");
2427
- _optionalChain([onError, 'optionalCall', _72 => _72(error2)]);
2432
+ _optionalChain([onError, 'optionalCall', _74 => _74(error2)]);
2428
2433
  }
2429
2434
  }
2430
2435
  return;
@@ -2435,7 +2440,7 @@ ${planningInstruction}` : planningInstruction;
2435
2440
  setStreamedContent("");
2436
2441
  setCommand("");
2437
2442
  setUploadedFiles([]);
2438
- _optionalChain([onStart, 'optionalCall', _73 => _73()]);
2443
+ _optionalChain([onStart, 'optionalCall', _75 => _75()]);
2439
2444
  try {
2440
2445
  if (useMock) {
2441
2446
  if (enableStreaming) {
@@ -2446,16 +2451,16 @@ ${planningInstruction}` : planningInstruction;
2446
2451
  if (chunk.type === "token" && chunk.content) {
2447
2452
  accumulatedContent += chunk.content;
2448
2453
  setStreamedContent(accumulatedContent);
2449
- _optionalChain([onChunk, 'optionalCall', _74 => _74(chunk.content)]);
2454
+ _optionalChain([onChunk, 'optionalCall', _76 => _76(chunk.content)]);
2450
2455
  const estimatedProgress = Math.min(Math.round(accumulatedContent.length / 10), 90);
2451
2456
  setProgress(estimatedProgress);
2452
- _optionalChain([onProgress, 'optionalCall', _75 => _75(estimatedProgress)]);
2457
+ _optionalChain([onProgress, 'optionalCall', _77 => _77(estimatedProgress)]);
2453
2458
  } else if (chunk.type === "widget" && chunk.widget) {
2454
2459
  const widget = chunk.widget;
2455
2460
  setResult((prev) => ({
2456
2461
  success: true,
2457
- data: _optionalChain([prev, 'optionalAccess', _76 => _76.data]) || {},
2458
- widgets: [..._optionalChain([prev, 'optionalAccess', _77 => _77.widgets]) || [], widget],
2462
+ data: _optionalChain([prev, 'optionalAccess', _78 => _78.data]) || {},
2463
+ widgets: [..._optionalChain([prev, 'optionalAccess', _79 => _79.widgets]) || [], widget],
2459
2464
  message: accumulatedContent || "Command executed successfully"
2460
2465
  }));
2461
2466
  }
@@ -2475,19 +2480,19 @@ ${planningInstruction}` : planningInstruction;
2475
2480
  setResult(result2);
2476
2481
  setState("success");
2477
2482
  setProgress(100);
2478
- _optionalChain([onComplete, 'optionalCall', _78 => _78(result2)]);
2483
+ _optionalChain([onComplete, 'optionalCall', _80 => _80(result2)]);
2479
2484
  },
2480
2485
  (error2) => {
2481
2486
  setError(error2);
2482
2487
  setState("error");
2483
- _optionalChain([onError, 'optionalCall', _79 => _79(error2)]);
2488
+ _optionalChain([onError, 'optionalCall', _81 => _81(error2)]);
2484
2489
  }
2485
2490
  );
2486
2491
  } else {
2487
2492
  const progressInterval = setInterval(() => {
2488
2493
  setProgress((prev) => {
2489
2494
  const next = Math.min(prev + 10, 90);
2490
- _optionalChain([onProgress, 'optionalCall', _80 => _80(next)]);
2495
+ _optionalChain([onProgress, 'optionalCall', _82 => _82(next)]);
2491
2496
  return next;
2492
2497
  });
2493
2498
  }, 200);
@@ -2511,7 +2516,7 @@ ${planningInstruction}` : planningInstruction;
2511
2516
  setResult(result2);
2512
2517
  setState("success");
2513
2518
  setProgress(100);
2514
- _optionalChain([onComplete, 'optionalCall', _81 => _81(result2)]);
2519
+ _optionalChain([onComplete, 'optionalCall', _83 => _83(result2)]);
2515
2520
  }
2516
2521
  } else {
2517
2522
  if (enableStreaming) {
@@ -2557,16 +2562,16 @@ ${commandInstruction}` : commandInstruction;
2557
2562
  if (chunk.type === "token" && chunk.content) {
2558
2563
  accumulatedContent += chunk.content;
2559
2564
  setStreamedContent(accumulatedContent);
2560
- _optionalChain([onChunk, 'optionalCall', _82 => _82(chunk.content)]);
2565
+ _optionalChain([onChunk, 'optionalCall', _84 => _84(chunk.content)]);
2561
2566
  const estimatedProgress = Math.min(Math.round(accumulatedContent.length / 10), 90);
2562
2567
  setProgress(estimatedProgress);
2563
- _optionalChain([onProgress, 'optionalCall', _83 => _83(estimatedProgress)]);
2568
+ _optionalChain([onProgress, 'optionalCall', _85 => _85(estimatedProgress)]);
2564
2569
  } else if (chunk.type === "widget" && chunk.widget) {
2565
2570
  const widget = chunk.widget;
2566
2571
  setResult((prev) => ({
2567
2572
  success: true,
2568
- data: _optionalChain([prev, 'optionalAccess', _84 => _84.data]) || {},
2569
- widgets: [..._optionalChain([prev, 'optionalAccess', _85 => _85.widgets]) || [], widget],
2573
+ data: _optionalChain([prev, 'optionalAccess', _86 => _86.data]) || {},
2574
+ widgets: [..._optionalChain([prev, 'optionalAccess', _87 => _87.widgets]) || [], widget],
2570
2575
  message: accumulatedContent || "Command executed successfully"
2571
2576
  }));
2572
2577
  }
@@ -2586,20 +2591,20 @@ ${commandInstruction}` : commandInstruction;
2586
2591
  setResult(result2);
2587
2592
  setState("success");
2588
2593
  setProgress(100);
2589
- _optionalChain([onComplete, 'optionalCall', _86 => _86(result2)]);
2594
+ _optionalChain([onComplete, 'optionalCall', _88 => _88(result2)]);
2590
2595
  },
2591
2596
  (error2) => {
2592
2597
  const err = error2 instanceof Error ? error2 : new Error("Unknown error");
2593
2598
  setError(err);
2594
2599
  setState("error");
2595
- _optionalChain([onError, 'optionalCall', _87 => _87(err)]);
2600
+ _optionalChain([onError, 'optionalCall', _89 => _89(err)]);
2596
2601
  }
2597
2602
  );
2598
2603
  } else {
2599
2604
  const progressInterval = setInterval(() => {
2600
2605
  setProgress((prev) => {
2601
2606
  const next = Math.min(prev + 10, 90);
2602
- _optionalChain([onProgress, 'optionalCall', _88 => _88(next)]);
2607
+ _optionalChain([onProgress, 'optionalCall', _90 => _90(next)]);
2603
2608
  return next;
2604
2609
  });
2605
2610
  }, 200);
@@ -2655,14 +2660,14 @@ ${commandInstruction}` : commandInstruction;
2655
2660
  setResult(result2);
2656
2661
  setState("success");
2657
2662
  setProgress(100);
2658
- _optionalChain([onComplete, 'optionalCall', _89 => _89(result2)]);
2663
+ _optionalChain([onComplete, 'optionalCall', _91 => _91(result2)]);
2659
2664
  }
2660
2665
  }
2661
2666
  } catch (err) {
2662
2667
  const error2 = err instanceof Error ? err : new Error("Unknown error");
2663
2668
  setError(error2);
2664
2669
  setState("error");
2665
- _optionalChain([onError, 'optionalCall', _90 => _90(error2)]);
2670
+ _optionalChain([onError, 'optionalCall', _92 => _92(error2)]);
2666
2671
  }
2667
2672
  };
2668
2673
  const resetCommand = () => {
@@ -2695,14 +2700,14 @@ ${planToExecute}`;
2695
2700
  };
2696
2701
  const handleFileSelect = async (e) => {
2697
2702
  if (e.target.files && e.target.files.length > 0) {
2698
- _optionalChain([onFileUpload, 'optionalCall', _91 => _91(e.target.files)]);
2703
+ _optionalChain([onFileUpload, 'optionalCall', _93 => _93(e.target.files)]);
2699
2704
  const files = [];
2700
2705
  for (let i = 0; i < e.target.files.length; i++) {
2701
2706
  const file = e.target.files[i];
2702
2707
  const reader = new FileReader();
2703
2708
  await new Promise((resolve) => {
2704
2709
  reader.onload = (event) => {
2705
- if (_optionalChain([event, 'access', _92 => _92.target, 'optionalAccess', _93 => _93.result])) {
2710
+ if (_optionalChain([event, 'access', _94 => _94.target, 'optionalAccess', _95 => _95.result])) {
2706
2711
  const fullDataUrl = event.target.result;
2707
2712
  const base64Data = fullDataUrl.split(",")[1];
2708
2713
  if (file.type.startsWith("image/")) {
@@ -2796,7 +2801,7 @@ ${planToExecute}`;
2796
2801
  enableFileUpload && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
2797
2802
  "button",
2798
2803
  {
2799
- onClick: () => _optionalChain([fileInputRef, 'access', _94 => _94.current, 'optionalAccess', _95 => _95.click, 'call', _96 => _96()]),
2804
+ onClick: () => _optionalChain([fileInputRef, 'access', _96 => _96.current, 'optionalAccess', _97 => _97.click, 'call', _98 => _98()]),
2800
2805
  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",
2801
2806
  title: "Attach file",
2802
2807
  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)" }) })
@@ -3015,7 +3020,7 @@ ${planToExecute}`;
3015
3020
  /* @__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" }) }),
3016
3021
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { children: [
3017
3022
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h3", { className: "text-sm font-semibold text-red-800 dark:text-red-400", children: "Error" }),
3018
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-red-700 dark:text-red-300 text-sm mt-1", children: _optionalChain([error, 'optionalAccess', _97 => _97.message]) })
3023
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-red-700 dark:text-red-300 text-sm mt-1", children: _optionalChain([error, 'optionalAccess', _99 => _99.message]) })
3019
3024
  ] })
3020
3025
  ] }) }),
3021
3026
  allowInput && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
@@ -3043,7 +3048,7 @@ ${planToExecute}`;
3043
3048
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-green-700 dark:text-green-300 text-sm", children: "Command executed successfully" })
3044
3049
  ] })
3045
3050
  ] }),
3046
- _optionalChain([result, 'access', _98 => _98.data, 'optionalAccess', _99 => _99.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 }),
3051
+ _optionalChain([result, 'access', _100 => _100.data, 'optionalAccess', _101 => _101.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 }),
3047
3052
  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,
3048
3053
  WidgetRenderer,
3049
3054
  {
@@ -3094,7 +3099,7 @@ ${planToExecute}`;
3094
3099
  enableFileUpload && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
3095
3100
  "button",
3096
3101
  {
3097
- onClick: () => _optionalChain([fileInputRef, 'access', _100 => _100.current, 'optionalAccess', _101 => _101.click, 'call', _102 => _102()]),
3102
+ onClick: () => _optionalChain([fileInputRef, 'access', _102 => _102.current, 'optionalAccess', _103 => _103.click, 'call', _104 => _104()]),
3098
3103
  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",
3099
3104
  title: "Attach file",
3100
3105
  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)" }) })
@@ -3280,25 +3285,25 @@ function Prompt({
3280
3285
  const newValue = e.target.value;
3281
3286
  if (!maxLength || newValue.length <= maxLength) {
3282
3287
  setValue(newValue);
3283
- _optionalChain([onChange, 'optionalCall', _103 => _103(newValue)]);
3288
+ _optionalChain([onChange, 'optionalCall', _105 => _105(newValue)]);
3284
3289
  }
3285
3290
  };
3286
3291
  const handleSubmit = async () => {
3287
3292
  if (value.length < minLength) return;
3288
- _optionalChain([onSubmit, 'optionalCall', _104 => _104(value)]);
3293
+ _optionalChain([onSubmit, 'optionalCall', _106 => _106(value)]);
3289
3294
  setIsLoading(true);
3290
3295
  try {
3291
3296
  if (useMock) {
3292
3297
  await new Promise((resolve) => setTimeout(resolve, 1500));
3293
3298
  const mockResult = `Enhanced version: ${value} [AI-generated content]`;
3294
- _optionalChain([onResult, 'optionalCall', _105 => _105(mockResult)]);
3299
+ _optionalChain([onResult, 'optionalCall', _107 => _107(mockResult)]);
3295
3300
  setValue("");
3296
3301
  } else {
3297
3302
  const response = await aptevaClient.chat({
3298
3303
  agent_id: agentId,
3299
3304
  message: value
3300
3305
  });
3301
- _optionalChain([onResult, 'optionalCall', _106 => _106(response.message)]);
3306
+ _optionalChain([onResult, 'optionalCall', _108 => _108(response.message)]);
3302
3307
  setValue("");
3303
3308
  }
3304
3309
  } catch (error) {
@@ -3393,7 +3398,7 @@ function Stream({
3393
3398
  }, [autoStart]);
3394
3399
  const startStreaming = async () => {
3395
3400
  setIsStreaming(true);
3396
- _optionalChain([onStart, 'optionalCall', _107 => _107()]);
3401
+ _optionalChain([onStart, 'optionalCall', _109 => _109()]);
3397
3402
  try {
3398
3403
  if (useMock) {
3399
3404
  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.";
@@ -3401,13 +3406,13 @@ function Stream({
3401
3406
  mockText,
3402
3407
  (chunk) => {
3403
3408
  setText((prev) => prev + chunk);
3404
- _optionalChain([onChunk, 'optionalCall', _108 => _108(chunk)]);
3409
+ _optionalChain([onChunk, 'optionalCall', _110 => _110(chunk)]);
3405
3410
  },
3406
3411
  typingSpeed
3407
3412
  );
3408
3413
  setIsComplete(true);
3409
3414
  setIsStreaming(false);
3410
- _optionalChain([onComplete, 'optionalCall', _109 => _109(text + mockText)]);
3415
+ _optionalChain([onComplete, 'optionalCall', _111 => _111(text + mockText)]);
3411
3416
  } else {
3412
3417
  let accumulatedText = "";
3413
3418
  await aptevaClient.chatStream(
@@ -3420,24 +3425,24 @@ function Stream({
3420
3425
  if (chunk.type === "token" && chunk.content) {
3421
3426
  accumulatedText += chunk.content;
3422
3427
  setText(accumulatedText);
3423
- _optionalChain([onChunk, 'optionalCall', _110 => _110(chunk.content)]);
3428
+ _optionalChain([onChunk, 'optionalCall', _112 => _112(chunk.content)]);
3424
3429
  }
3425
3430
  },
3426
3431
  () => {
3427
3432
  setIsComplete(true);
3428
3433
  setIsStreaming(false);
3429
- _optionalChain([onComplete, 'optionalCall', _111 => _111(accumulatedText)]);
3434
+ _optionalChain([onComplete, 'optionalCall', _113 => _113(accumulatedText)]);
3430
3435
  },
3431
3436
  (error) => {
3432
3437
  const err = error instanceof Error ? error : new Error("Streaming error");
3433
- _optionalChain([onError, 'optionalCall', _112 => _112(err)]);
3438
+ _optionalChain([onError, 'optionalCall', _114 => _114(err)]);
3434
3439
  setIsStreaming(false);
3435
3440
  }
3436
3441
  );
3437
3442
  }
3438
3443
  } catch (error) {
3439
3444
  const err = error instanceof Error ? error : new Error("Streaming error");
3440
- _optionalChain([onError, 'optionalCall', _113 => _113(err)]);
3445
+ _optionalChain([onError, 'optionalCall', _115 => _115(err)]);
3441
3446
  setIsStreaming(false);
3442
3447
  }
3443
3448
  };
@@ -3529,7 +3534,7 @@ function ThreadList({
3529
3534
  }) {
3530
3535
  const [searchQuery, setSearchQuery] = _react.useState.call(void 0, "");
3531
3536
  const filteredThreads = threads.filter(
3532
- (thread) => thread.title.toLowerCase().includes(searchQuery.toLowerCase()) || _optionalChain([thread, 'access', _114 => _114.preview, 'optionalAccess', _115 => _115.toLowerCase, 'call', _116 => _116(), 'access', _117 => _117.includes, 'call', _118 => _118(searchQuery.toLowerCase())])
3537
+ (thread) => thread.title.toLowerCase().includes(searchQuery.toLowerCase()) || _optionalChain([thread, 'access', _116 => _116.preview, 'optionalAccess', _117 => _117.toLowerCase, 'call', _118 => _118(), 'access', _119 => _119.includes, 'call', _120 => _120(searchQuery.toLowerCase())])
3533
3538
  );
3534
3539
  const groupedThreads = groupBy === "date" ? groupThreadsByDate(filteredThreads) : { All: filteredThreads };
3535
3540
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-col h-full", children: [
@@ -3551,8 +3556,8 @@ function ThreadList({
3551
3556
  {
3552
3557
  thread,
3553
3558
  isActive: thread.id === currentThreadId,
3554
- onSelect: () => _optionalChain([onThreadSelect, 'optionalCall', _119 => _119(thread.id)]),
3555
- onDelete: () => _optionalChain([onThreadDelete, 'optionalCall', _120 => _120(thread.id)])
3559
+ onSelect: () => _optionalChain([onThreadSelect, 'optionalCall', _121 => _121(thread.id)]),
3560
+ onDelete: () => _optionalChain([onThreadDelete, 'optionalCall', _122 => _122(thread.id)])
3556
3561
  },
3557
3562
  thread.id
3558
3563
  ))
@@ -3614,7 +3619,7 @@ function Threads({
3614
3619
  threads.slice(0, 5).map((thread) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
3615
3620
  "button",
3616
3621
  {
3617
- onClick: () => _optionalChain([onThreadSelect, 'optionalCall', _121 => _121(thread.id)]),
3622
+ onClick: () => _optionalChain([onThreadSelect, 'optionalCall', _123 => _123(thread.id)]),
3618
3623
  className: cn(
3619
3624
  "px-4 py-2 whitespace-nowrap font-medium transition-colors",
3620
3625
  thread.id === currentThreadId ? "border-b-2 border-apteva-500 text-apteva-500" : "text-gray-600 hover:text-gray-900"