@apteva/apteva-kit 0.1.65 → 0.1.66

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.js CHANGED
@@ -1455,6 +1455,43 @@ function Message({ message, onAction, enableWidgets, onWidgetRender }) {
1455
1455
  }
1456
1456
  return elements.length > 0 ? elements : null;
1457
1457
  };
1458
+ const attachments = _optionalChain([message, 'access', _33 => _33.metadata, 'optionalAccess', _34 => _34.attachments]) || [];
1459
+ const hasAttachments = attachments.length > 0;
1460
+ const renderAttachments = () => {
1461
+ if (!hasAttachments) return null;
1462
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "apteva-message-attachments flex flex-wrap gap-2 mb-2 justify-end", children: attachments.map((att, index) => {
1463
+ const isImage = att.type.startsWith("image/");
1464
+ const isPdf = att.type === "application/pdf";
1465
+ if (isImage && att.preview) {
1466
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "apteva-attachment-image relative rounded-lg overflow-hidden shadow-sm", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1467
+ "img",
1468
+ {
1469
+ src: att.preview,
1470
+ alt: att.name,
1471
+ className: "max-w-[150px] max-h-[150px] object-cover"
1472
+ }
1473
+ ) }, index);
1474
+ }
1475
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
1476
+ "div",
1477
+ {
1478
+ className: "apteva-attachment-doc flex items-center gap-3 px-4 py-3 bg-neutral-100 dark:bg-neutral-800 border border-neutral-200 dark:border-neutral-700 rounded-xl shadow-sm",
1479
+ children: [
1480
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "w-10 h-10 flex items-center justify-center bg-red-100 dark:bg-red-900/30 rounded-lg text-red-600 dark:text-red-400", children: isPdf ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "svg", { className: "w-5 h-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: "M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z" }) }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "svg", { className: "w-5 h-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: "M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z" }) }) }),
1481
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-col min-w-0", children: [
1482
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-sm font-medium text-neutral-800 dark:text-neutral-200 truncate max-w-[180px]", children: att.name }),
1483
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "text-xs text-neutral-500 dark:text-neutral-400", children: [
1484
+ isPdf ? "PDF" : "Document",
1485
+ " \xB7 ",
1486
+ formatFileSize(att.size)
1487
+ ] })
1488
+ ] })
1489
+ ]
1490
+ },
1491
+ index
1492
+ );
1493
+ }) });
1494
+ };
1458
1495
  const renderContent = () => {
1459
1496
  if (isUser) {
1460
1497
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "apteva-message-text", children: message.content });
@@ -1552,6 +1589,13 @@ function Message({ message, onAction, enableWidgets, onWidgetRender }) {
1552
1589
  /* @__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" }) })
1553
1590
  ] });
1554
1591
  }
1592
+ if (isUser && hasAttachments) {
1593
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "apteva-message-segmented apteva-message-user-with-attachments flex flex-col items-end", children: [
1594
+ renderAttachments(),
1595
+ message.content && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "apteva-message-bubble apteva-message-user", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "apteva-message-content-user", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "apteva-message-text", children: message.content }) }) }),
1596
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "apteva-message-timestamp apteva-message-timestamp-user", suppressHydrationWarning: true, children: message.timestamp.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" }) })
1597
+ ] });
1598
+ }
1555
1599
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
1556
1600
  "div",
1557
1601
  {
@@ -1815,7 +1859,7 @@ function Composer({ onSendMessage, placeholder = "Type a message...", disabled =
1815
1859
  setFileError(errors.join(", "));
1816
1860
  setTimeout(() => setFileError(null), 5e3);
1817
1861
  }
1818
- _optionalChain([onFileUpload, 'optionalCall', _33 => _33(e.target.files)]);
1862
+ _optionalChain([onFileUpload, 'optionalCall', _35 => _35(e.target.files)]);
1819
1863
  setShowMenu(false);
1820
1864
  e.target.value = "";
1821
1865
  }
@@ -1885,15 +1929,15 @@ function Composer({ onSendMessage, placeholder = "Type a message...", disabled =
1885
1929
  {
1886
1930
  className: "apteva-composer-menu fixed bg-neutral-800 dark:bg-neutral-800 rounded-xl shadow-lg overflow-hidden z-[9999] min-w-[200px]",
1887
1931
  style: {
1888
- left: _nullishCoalesce(_optionalChain([menuButtonRef, 'access', _34 => _34.current, 'optionalAccess', _35 => _35.getBoundingClientRect, 'call', _36 => _36(), 'access', _37 => _37.left]), () => ( 0)),
1889
- top: (_nullishCoalesce(_optionalChain([menuButtonRef, 'access', _38 => _38.current, 'optionalAccess', _39 => _39.getBoundingClientRect, 'call', _40 => _40(), 'access', _41 => _41.bottom]), () => ( 0))) + 8
1932
+ left: _nullishCoalesce(_optionalChain([menuButtonRef, 'access', _36 => _36.current, 'optionalAccess', _37 => _37.getBoundingClientRect, 'call', _38 => _38(), 'access', _39 => _39.left]), () => ( 0)),
1933
+ top: (_nullishCoalesce(_optionalChain([menuButtonRef, 'access', _40 => _40.current, 'optionalAccess', _41 => _41.getBoundingClientRect, 'call', _42 => _42(), 'access', _43 => _43.bottom]), () => ( 0))) + 8
1890
1934
  },
1891
1935
  children: [
1892
1936
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
1893
1937
  "button",
1894
1938
  {
1895
1939
  onClick: () => {
1896
- _optionalChain([fileInputRef, 'access', _42 => _42.current, 'optionalAccess', _43 => _43.click, 'call', _44 => _44()]);
1940
+ _optionalChain([fileInputRef, 'access', _44 => _44.current, 'optionalAccess', _45 => _45.click, 'call', _46 => _46()]);
1897
1941
  setShowMenu(false);
1898
1942
  },
1899
1943
  className: "w-full flex items-center gap-3 px-4 py-3 hover:bg-neutral-700 dark:hover:bg-neutral-700 transition-colors !text-white text-left",
@@ -2012,8 +2056,8 @@ function CommandComposer({
2012
2056
  }
2013
2057
  };
2014
2058
  const handleNewCommand = () => {
2015
- _optionalChain([onReset, 'optionalCall', _45 => _45()]);
2016
- _optionalChain([inputRef, 'access', _46 => _46.current, 'optionalAccess', _47 => _47.focus, 'call', _48 => _48()]);
2059
+ _optionalChain([onReset, 'optionalCall', _47 => _47()]);
2060
+ _optionalChain([inputRef, 'access', _48 => _48.current, 'optionalAccess', _49 => _49.focus, 'call', _50 => _50()]);
2017
2061
  };
2018
2062
  const handleInputChange = (value) => {
2019
2063
  setInput(value);
@@ -2127,15 +2171,15 @@ function CommandComposer({
2127
2171
  {
2128
2172
  className: "apteva-composer-menu fixed bg-neutral-800 dark:bg-neutral-800 rounded-xl shadow-lg overflow-hidden z-[9999] min-w-[200px]",
2129
2173
  style: {
2130
- left: _nullishCoalesce(_optionalChain([menuButtonRef, 'access', _49 => _49.current, 'optionalAccess', _50 => _50.getBoundingClientRect, 'call', _51 => _51(), 'access', _52 => _52.left]), () => ( 0)),
2131
- top: (_nullishCoalesce(_optionalChain([menuButtonRef, 'access', _53 => _53.current, 'optionalAccess', _54 => _54.getBoundingClientRect, 'call', _55 => _55(), 'access', _56 => _56.bottom]), () => ( 0))) + 8
2174
+ left: _nullishCoalesce(_optionalChain([menuButtonRef, 'access', _51 => _51.current, 'optionalAccess', _52 => _52.getBoundingClientRect, 'call', _53 => _53(), 'access', _54 => _54.left]), () => ( 0)),
2175
+ top: (_nullishCoalesce(_optionalChain([menuButtonRef, 'access', _55 => _55.current, 'optionalAccess', _56 => _56.getBoundingClientRect, 'call', _57 => _57(), 'access', _58 => _58.bottom]), () => ( 0))) + 8
2132
2176
  },
2133
2177
  children: [
2134
2178
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
2135
2179
  "button",
2136
2180
  {
2137
2181
  onClick: () => {
2138
- _optionalChain([fileInputRef, 'access', _57 => _57.current, 'optionalAccess', _58 => _58.click, 'call', _59 => _59()]);
2182
+ _optionalChain([fileInputRef, 'access', _59 => _59.current, 'optionalAccess', _60 => _60.click, 'call', _61 => _61()]);
2139
2183
  setShowMenu(false);
2140
2184
  },
2141
2185
  className: "w-full flex items-center gap-3 px-4 py-3 hover:bg-neutral-700 dark:hover:bg-neutral-700 transition-colors !text-white text-left",
@@ -2376,7 +2420,7 @@ var AptevaClient = class {
2376
2420
  const error = await response.json().catch(() => ({ error: "Request failed" }));
2377
2421
  throw new Error(error.error || `Request failed with status ${response.status}`);
2378
2422
  }
2379
- const reader = _optionalChain([response, 'access', _60 => _60.body, 'optionalAccess', _61 => _61.getReader, 'call', _62 => _62()]);
2423
+ const reader = _optionalChain([response, 'access', _62 => _62.body, 'optionalAccess', _63 => _63.getReader, 'call', _64 => _64()]);
2380
2424
  if (!reader) {
2381
2425
  throw new Error("Response body is not readable");
2382
2426
  }
@@ -2394,7 +2438,7 @@ var AptevaClient = class {
2394
2438
  if (line.startsWith("data: ")) {
2395
2439
  const data = line.slice(6);
2396
2440
  if (data === "[DONE]") {
2397
- _optionalChain([onComplete, 'optionalCall', _63 => _63(threadId)]);
2441
+ _optionalChain([onComplete, 'optionalCall', _65 => _65(threadId)]);
2398
2442
  return;
2399
2443
  }
2400
2444
  try {
@@ -2409,10 +2453,10 @@ var AptevaClient = class {
2409
2453
  }
2410
2454
  }
2411
2455
  }
2412
- _optionalChain([onComplete, 'optionalCall', _64 => _64(threadId)]);
2456
+ _optionalChain([onComplete, 'optionalCall', _66 => _66(threadId)]);
2413
2457
  } catch (error) {
2414
2458
  const err = error instanceof Error ? error : new Error("Unknown error");
2415
- _optionalChain([onError, 'optionalCall', _65 => _65(err)]);
2459
+ _optionalChain([onError, 'optionalCall', _67 => _67(err)]);
2416
2460
  throw err;
2417
2461
  }
2418
2462
  }
@@ -2572,7 +2616,7 @@ ${widgetContext}` : widgetContext;
2572
2616
  }, [apiUrl, apiKey]);
2573
2617
  _react.useEffect.call(void 0, () => {
2574
2618
  if (threadId) {
2575
- _optionalChain([onThreadChange, 'optionalCall', _66 => _66(threadId)]);
2619
+ _optionalChain([onThreadChange, 'optionalCall', _68 => _68(threadId)]);
2576
2620
  }
2577
2621
  }, [threadId, onThreadChange]);
2578
2622
  _react.useEffect.call(void 0, () => {
@@ -2590,7 +2634,7 @@ ${widgetContext}` : widgetContext;
2590
2634
  }, [showSettingsMenu]);
2591
2635
  const handleModeChange = (newMode) => {
2592
2636
  setMode(newMode);
2593
- _optionalChain([onModeChange, 'optionalCall', _67 => _67(newMode)]);
2637
+ _optionalChain([onModeChange, 'optionalCall', _69 => _69(newMode)]);
2594
2638
  if (newMode === "command") {
2595
2639
  setCommandState("idle");
2596
2640
  setCommandResult(null);
@@ -2600,18 +2644,22 @@ ${widgetContext}` : widgetContext;
2600
2644
  const defaultPlaceholder = mode === "chat" ? "Type a message..." : "Enter your command...";
2601
2645
  const handleSendMessage = async (text, files, isSystem) => {
2602
2646
  const hasFiles = files && files.length > 0;
2603
- const fileNames = hasFiles ? files.map((f) => f.name) : [];
2604
- const displayContent = hasFiles ? `${text}${text ? "\n" : ""}[Attached: ${fileNames.join(", ")}]` : text;
2647
+ const attachments = hasFiles ? files.map((f) => ({
2648
+ name: f.name,
2649
+ type: f.type,
2650
+ size: f.size,
2651
+ preview: f.type.startsWith("image/") ? URL.createObjectURL(f) : void 0
2652
+ })) : [];
2605
2653
  if (!isSystem) {
2606
2654
  const userMessage = {
2607
2655
  id: `msg-${Date.now()}`,
2608
2656
  role: "user",
2609
- content: displayContent,
2657
+ content: text,
2610
2658
  timestamp: /* @__PURE__ */ new Date(),
2611
- metadata: hasFiles ? { attachments: fileNames } : void 0
2659
+ metadata: hasFiles ? { attachments } : void 0
2612
2660
  };
2613
2661
  setMessages((prev) => [...prev, userMessage]);
2614
- _optionalChain([onMessageSent, 'optionalCall', _68 => _68(userMessage)]);
2662
+ _optionalChain([onMessageSent, 'optionalCall', _70 => _70(userMessage)]);
2615
2663
  }
2616
2664
  setIsLoading(true);
2617
2665
  try {
@@ -2678,7 +2726,7 @@ ${widgetContext}` : widgetContext;
2678
2726
  responseThreadId = chunk.thread_id;
2679
2727
  if (!currentThreadId) {
2680
2728
  setCurrentThreadId(chunk.thread_id);
2681
- _optionalChain([onThreadChange, 'optionalCall', _69 => _69(chunk.thread_id)]);
2729
+ _optionalChain([onThreadChange, 'optionalCall', _71 => _71(chunk.thread_id)]);
2682
2730
  }
2683
2731
  }
2684
2732
  break;
@@ -2704,7 +2752,7 @@ ${widgetContext}` : widgetContext;
2704
2752
  contentSegments.push({ type: "tool", id: chunk.tool_id, name: displayName });
2705
2753
  toolInputBuffer = "";
2706
2754
  setChatToolName(displayName);
2707
- _optionalChain([onToolCall, 'optionalCall', _70 => _70(chunk.tool_name, chunk.tool_id)]);
2755
+ _optionalChain([onToolCall, 'optionalCall', _72 => _72(chunk.tool_name, chunk.tool_id)]);
2708
2756
  updateMessage();
2709
2757
  }
2710
2758
  break;
@@ -2718,7 +2766,7 @@ ${widgetContext}` : widgetContext;
2718
2766
  const toolSegment = contentSegments.find((s) => s.type === "tool" && s.id === chunk.tool_id);
2719
2767
  if (toolSegment) {
2720
2768
  toolSegment.result = chunk.content;
2721
- _optionalChain([onToolResult, 'optionalCall', _71 => _71(toolSegment.name, chunk.content)]);
2769
+ _optionalChain([onToolResult, 'optionalCall', _73 => _73(toolSegment.name, chunk.content)]);
2722
2770
  }
2723
2771
  setChatToolName(null);
2724
2772
  updateMessage();
@@ -2761,7 +2809,7 @@ ${widgetContext}` : widgetContext;
2761
2809
  });
2762
2810
  if (threadId2 && threadId2 !== currentThreadId) {
2763
2811
  setCurrentThreadId(threadId2);
2764
- _optionalChain([onThreadChange, 'optionalCall', _72 => _72(threadId2)]);
2812
+ _optionalChain([onThreadChange, 'optionalCall', _74 => _74(threadId2)]);
2765
2813
  }
2766
2814
  setIsLoading(false);
2767
2815
  setCurrentRequestId(null);
@@ -2785,7 +2833,7 @@ ${widgetContext}` : widgetContext;
2785
2833
  setIsLoading(false);
2786
2834
  setCurrentRequestId(null);
2787
2835
  setChatToolName(null);
2788
- _optionalChain([onError, 'optionalCall', _73 => _73(error)]);
2836
+ _optionalChain([onError, 'optionalCall', _75 => _75(error)]);
2789
2837
  }
2790
2838
  );
2791
2839
  }
@@ -2798,7 +2846,7 @@ ${widgetContext}` : widgetContext;
2798
2846
  metadata: { error: true }
2799
2847
  };
2800
2848
  setMessages((prev) => [...prev, errorMessage]);
2801
- _optionalChain([onError, 'optionalCall', _74 => _74(error instanceof Error ? error : new Error("Unknown error"))]);
2849
+ _optionalChain([onError, 'optionalCall', _76 => _76(error instanceof Error ? error : new Error("Unknown error"))]);
2802
2850
  } finally {
2803
2851
  setIsLoading(false);
2804
2852
  }
@@ -2844,7 +2892,7 @@ ${planningInstruction}` : planningInstruction;
2844
2892
  const error = err instanceof Error ? err : new Error("Failed to generate plan");
2845
2893
  setCommandError(error);
2846
2894
  setCommandState("error");
2847
- _optionalChain([onError, 'optionalCall', _75 => _75(error)]);
2895
+ _optionalChain([onError, 'optionalCall', _77 => _77(error)]);
2848
2896
  }
2849
2897
  }
2850
2898
  return;
@@ -2877,12 +2925,12 @@ ${planningInstruction}` : planningInstruction;
2877
2925
  setCommandResult(result);
2878
2926
  setCommandState("success");
2879
2927
  setProgress(100);
2880
- _optionalChain([onComplete, 'optionalCall', _76 => _76(result)]);
2928
+ _optionalChain([onComplete, 'optionalCall', _78 => _78(result)]);
2881
2929
  },
2882
2930
  (error) => {
2883
2931
  setCommandError(error);
2884
2932
  setCommandState("error");
2885
- _optionalChain([onError, 'optionalCall', _77 => _77(error)]);
2933
+ _optionalChain([onError, 'optionalCall', _79 => _79(error)]);
2886
2934
  }
2887
2935
  );
2888
2936
  } else {
@@ -2895,7 +2943,7 @@ ${planningInstruction}` : planningInstruction;
2895
2943
  setCommandResult(result);
2896
2944
  setCommandState("success");
2897
2945
  setProgress(100);
2898
- _optionalChain([onComplete, 'optionalCall', _78 => _78(result)]);
2946
+ _optionalChain([onComplete, 'optionalCall', _80 => _80(result)]);
2899
2947
  }
2900
2948
  } else {
2901
2949
  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.`;
@@ -2925,16 +2973,16 @@ ${commandInstruction}` : commandInstruction;
2925
2973
  const displayName = chunk.tool_display_name || chunk.tool_name;
2926
2974
  lastToolName = chunk.tool_name;
2927
2975
  setCurrentToolName(displayName);
2928
- _optionalChain([onToolCall, 'optionalCall', _79 => _79(chunk.tool_name, chunk.tool_id || "")]);
2976
+ _optionalChain([onToolCall, 'optionalCall', _81 => _81(chunk.tool_name, chunk.tool_id || "")]);
2929
2977
  accumulatedContent = "";
2930
2978
  setStreamedContent("");
2931
2979
  } else if (chunk.type === "tool_result") {
2932
- _optionalChain([onToolResult, 'optionalCall', _80 => _80(lastToolName, chunk.content)]);
2980
+ _optionalChain([onToolResult, 'optionalCall', _82 => _82(lastToolName, chunk.content)]);
2933
2981
  setCurrentToolName(null);
2934
2982
  } else if (chunk.type === "thread_id" && chunk.thread_id) {
2935
2983
  if (!currentThreadId) {
2936
2984
  setCurrentThreadId(chunk.thread_id);
2937
- _optionalChain([onThreadChange, 'optionalCall', _81 => _81(chunk.thread_id)]);
2985
+ _optionalChain([onThreadChange, 'optionalCall', _83 => _83(chunk.thread_id)]);
2938
2986
  }
2939
2987
  } else if (chunk.type === "request_id" && chunk.request_id) {
2940
2988
  setCurrentRequestId(chunk.request_id);
@@ -2950,13 +2998,13 @@ ${commandInstruction}` : commandInstruction;
2950
2998
  setCommandState("success");
2951
2999
  setProgress(100);
2952
3000
  setCurrentRequestId(null);
2953
- _optionalChain([onComplete, 'optionalCall', _82 => _82(result)]);
3001
+ _optionalChain([onComplete, 'optionalCall', _84 => _84(result)]);
2954
3002
  },
2955
3003
  (error) => {
2956
3004
  setCommandError(error);
2957
3005
  setCommandState("error");
2958
3006
  setCurrentRequestId(null);
2959
- _optionalChain([onError, 'optionalCall', _83 => _83(error)]);
3007
+ _optionalChain([onError, 'optionalCall', _85 => _85(error)]);
2960
3008
  }
2961
3009
  );
2962
3010
  } else {
@@ -2976,14 +3024,14 @@ ${commandInstruction}` : commandInstruction;
2976
3024
  setCommandResult(result);
2977
3025
  setCommandState("success");
2978
3026
  setProgress(100);
2979
- _optionalChain([onComplete, 'optionalCall', _84 => _84(result)]);
3027
+ _optionalChain([onComplete, 'optionalCall', _86 => _86(result)]);
2980
3028
  }
2981
3029
  }
2982
3030
  } catch (err) {
2983
3031
  const error = err instanceof Error ? err : new Error("Unknown error");
2984
3032
  setCommandError(error);
2985
3033
  setCommandState("error");
2986
- _optionalChain([onError, 'optionalCall', _85 => _85(error)]);
3034
+ _optionalChain([onError, 'optionalCall', _87 => _87(error)]);
2987
3035
  }
2988
3036
  };
2989
3037
  const resetCommand = () => {
@@ -3075,8 +3123,8 @@ ${planToExecute}`;
3075
3123
  executeCommand(text, files);
3076
3124
  },
3077
3125
  state: commandState,
3078
- response: _optionalChain([commandResult, 'optionalAccess', _86 => _86.data, 'optionalAccess', _87 => _87.summary]) || _optionalChain([commandResult, 'optionalAccess', _88 => _88.message]),
3079
- error: _optionalChain([commandError, 'optionalAccess', _89 => _89.message]),
3126
+ response: _optionalChain([commandResult, 'optionalAccess', _88 => _88.data, 'optionalAccess', _89 => _89.summary]) || _optionalChain([commandResult, 'optionalAccess', _90 => _90.message]),
3127
+ error: _optionalChain([commandError, 'optionalAccess', _91 => _91.message]),
3080
3128
  plan,
3081
3129
  streamedContent,
3082
3130
  toolName: currentToolName,
@@ -3244,13 +3292,13 @@ ${planningInstruction}` : planningInstruction;
3244
3292
  const error2 = err instanceof Error ? err : new Error("Failed to generate plan");
3245
3293
  setError(error2);
3246
3294
  setState("error");
3247
- _optionalChain([onError, 'optionalCall', _90 => _90(error2)]);
3295
+ _optionalChain([onError, 'optionalCall', _92 => _92(error2)]);
3248
3296
  });
3249
3297
  } catch (err) {
3250
3298
  const error2 = err instanceof Error ? err : new Error("Failed to generate plan");
3251
3299
  setError(error2);
3252
3300
  setState("error");
3253
- _optionalChain([onError, 'optionalCall', _91 => _91(error2)]);
3301
+ _optionalChain([onError, 'optionalCall', _93 => _93(error2)]);
3254
3302
  }
3255
3303
  }
3256
3304
  return;
@@ -3261,7 +3309,7 @@ ${planningInstruction}` : planningInstruction;
3261
3309
  setStreamedContent("");
3262
3310
  setCommand("");
3263
3311
  setUploadedFiles([]);
3264
- _optionalChain([onStart, 'optionalCall', _92 => _92()]);
3312
+ _optionalChain([onStart, 'optionalCall', _94 => _94()]);
3265
3313
  try {
3266
3314
  if (useMock) {
3267
3315
  if (enableStreaming) {
@@ -3272,16 +3320,16 @@ ${planningInstruction}` : planningInstruction;
3272
3320
  if (chunk.type === "token" && chunk.content) {
3273
3321
  accumulatedContent += chunk.content;
3274
3322
  setStreamedContent(accumulatedContent);
3275
- _optionalChain([onChunk, 'optionalCall', _93 => _93(chunk.content)]);
3323
+ _optionalChain([onChunk, 'optionalCall', _95 => _95(chunk.content)]);
3276
3324
  const estimatedProgress = Math.min(Math.round(accumulatedContent.length / 10), 90);
3277
3325
  setProgress(estimatedProgress);
3278
- _optionalChain([onProgress, 'optionalCall', _94 => _94(estimatedProgress)]);
3326
+ _optionalChain([onProgress, 'optionalCall', _96 => _96(estimatedProgress)]);
3279
3327
  } else if (chunk.type === "widget" && chunk.widget) {
3280
3328
  const widget = chunk.widget;
3281
3329
  setResult((prev) => ({
3282
3330
  success: true,
3283
- data: _optionalChain([prev, 'optionalAccess', _95 => _95.data]) || {},
3284
- widgets: [..._optionalChain([prev, 'optionalAccess', _96 => _96.widgets]) || [], widget],
3331
+ data: _optionalChain([prev, 'optionalAccess', _97 => _97.data]) || {},
3332
+ widgets: [..._optionalChain([prev, 'optionalAccess', _98 => _98.widgets]) || [], widget],
3285
3333
  message: accumulatedContent || "Command executed successfully"
3286
3334
  }));
3287
3335
  }
@@ -3301,19 +3349,19 @@ ${planningInstruction}` : planningInstruction;
3301
3349
  setResult(result2);
3302
3350
  setState("success");
3303
3351
  setProgress(100);
3304
- _optionalChain([onComplete, 'optionalCall', _97 => _97(result2)]);
3352
+ _optionalChain([onComplete, 'optionalCall', _99 => _99(result2)]);
3305
3353
  },
3306
3354
  (error2) => {
3307
3355
  setError(error2);
3308
3356
  setState("error");
3309
- _optionalChain([onError, 'optionalCall', _98 => _98(error2)]);
3357
+ _optionalChain([onError, 'optionalCall', _100 => _100(error2)]);
3310
3358
  }
3311
3359
  );
3312
3360
  } else {
3313
3361
  const progressInterval = setInterval(() => {
3314
3362
  setProgress((prev) => {
3315
3363
  const next = Math.min(prev + 10, 90);
3316
- _optionalChain([onProgress, 'optionalCall', _99 => _99(next)]);
3364
+ _optionalChain([onProgress, 'optionalCall', _101 => _101(next)]);
3317
3365
  return next;
3318
3366
  });
3319
3367
  }, 200);
@@ -3337,7 +3385,7 @@ ${planningInstruction}` : planningInstruction;
3337
3385
  setResult(result2);
3338
3386
  setState("success");
3339
3387
  setProgress(100);
3340
- _optionalChain([onComplete, 'optionalCall', _100 => _100(result2)]);
3388
+ _optionalChain([onComplete, 'optionalCall', _102 => _102(result2)]);
3341
3389
  }
3342
3390
  } else {
3343
3391
  if (enableStreaming) {
@@ -3383,16 +3431,16 @@ ${commandInstruction}` : commandInstruction;
3383
3431
  if (chunk.type === "token" && chunk.content) {
3384
3432
  accumulatedContent += chunk.content;
3385
3433
  setStreamedContent(accumulatedContent);
3386
- _optionalChain([onChunk, 'optionalCall', _101 => _101(chunk.content)]);
3434
+ _optionalChain([onChunk, 'optionalCall', _103 => _103(chunk.content)]);
3387
3435
  const estimatedProgress = Math.min(Math.round(accumulatedContent.length / 10), 90);
3388
3436
  setProgress(estimatedProgress);
3389
- _optionalChain([onProgress, 'optionalCall', _102 => _102(estimatedProgress)]);
3437
+ _optionalChain([onProgress, 'optionalCall', _104 => _104(estimatedProgress)]);
3390
3438
  } else if (chunk.type === "widget" && chunk.widget) {
3391
3439
  const widget = chunk.widget;
3392
3440
  setResult((prev) => ({
3393
3441
  success: true,
3394
- data: _optionalChain([prev, 'optionalAccess', _103 => _103.data]) || {},
3395
- widgets: [..._optionalChain([prev, 'optionalAccess', _104 => _104.widgets]) || [], widget],
3442
+ data: _optionalChain([prev, 'optionalAccess', _105 => _105.data]) || {},
3443
+ widgets: [..._optionalChain([prev, 'optionalAccess', _106 => _106.widgets]) || [], widget],
3396
3444
  message: accumulatedContent || "Command executed successfully"
3397
3445
  }));
3398
3446
  }
@@ -3412,20 +3460,20 @@ ${commandInstruction}` : commandInstruction;
3412
3460
  setResult(result2);
3413
3461
  setState("success");
3414
3462
  setProgress(100);
3415
- _optionalChain([onComplete, 'optionalCall', _105 => _105(result2)]);
3463
+ _optionalChain([onComplete, 'optionalCall', _107 => _107(result2)]);
3416
3464
  },
3417
3465
  (error2) => {
3418
3466
  const err = error2 instanceof Error ? error2 : new Error("Unknown error");
3419
3467
  setError(err);
3420
3468
  setState("error");
3421
- _optionalChain([onError, 'optionalCall', _106 => _106(err)]);
3469
+ _optionalChain([onError, 'optionalCall', _108 => _108(err)]);
3422
3470
  }
3423
3471
  );
3424
3472
  } else {
3425
3473
  const progressInterval = setInterval(() => {
3426
3474
  setProgress((prev) => {
3427
3475
  const next = Math.min(prev + 10, 90);
3428
- _optionalChain([onProgress, 'optionalCall', _107 => _107(next)]);
3476
+ _optionalChain([onProgress, 'optionalCall', _109 => _109(next)]);
3429
3477
  return next;
3430
3478
  });
3431
3479
  }, 200);
@@ -3481,14 +3529,14 @@ ${commandInstruction}` : commandInstruction;
3481
3529
  setResult(result2);
3482
3530
  setState("success");
3483
3531
  setProgress(100);
3484
- _optionalChain([onComplete, 'optionalCall', _108 => _108(result2)]);
3532
+ _optionalChain([onComplete, 'optionalCall', _110 => _110(result2)]);
3485
3533
  }
3486
3534
  }
3487
3535
  } catch (err) {
3488
3536
  const error2 = err instanceof Error ? err : new Error("Unknown error");
3489
3537
  setError(error2);
3490
3538
  setState("error");
3491
- _optionalChain([onError, 'optionalCall', _109 => _109(error2)]);
3539
+ _optionalChain([onError, 'optionalCall', _111 => _111(error2)]);
3492
3540
  }
3493
3541
  };
3494
3542
  const resetCommand = () => {
@@ -3521,14 +3569,14 @@ ${planToExecute}`;
3521
3569
  };
3522
3570
  const handleFileSelect = async (e) => {
3523
3571
  if (e.target.files && e.target.files.length > 0) {
3524
- _optionalChain([onFileUpload, 'optionalCall', _110 => _110(e.target.files)]);
3572
+ _optionalChain([onFileUpload, 'optionalCall', _112 => _112(e.target.files)]);
3525
3573
  const files = [];
3526
3574
  for (let i = 0; i < e.target.files.length; i++) {
3527
3575
  const file = e.target.files[i];
3528
3576
  const reader = new FileReader();
3529
3577
  await new Promise((resolve) => {
3530
3578
  reader.onload = (event) => {
3531
- if (_optionalChain([event, 'access', _111 => _111.target, 'optionalAccess', _112 => _112.result])) {
3579
+ if (_optionalChain([event, 'access', _113 => _113.target, 'optionalAccess', _114 => _114.result])) {
3532
3580
  const fullDataUrl = event.target.result;
3533
3581
  const base64Data = fullDataUrl.split(",")[1];
3534
3582
  if (file.type.startsWith("image/")) {
@@ -3622,7 +3670,7 @@ ${planToExecute}`;
3622
3670
  enableFileUpload && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
3623
3671
  "button",
3624
3672
  {
3625
- onClick: () => _optionalChain([fileInputRef, 'access', _113 => _113.current, 'optionalAccess', _114 => _114.click, 'call', _115 => _115()]),
3673
+ onClick: () => _optionalChain([fileInputRef, 'access', _115 => _115.current, 'optionalAccess', _116 => _116.click, 'call', _117 => _117()]),
3626
3674
  className: "w-8 h-8 rounded-lg flex items-center justify-center transition-all flex-shrink-0 !text-neutral-500 dark:!text-neutral-500 hover:bg-neutral-100 dark:hover:bg-neutral-800",
3627
3675
  title: "Attach file",
3628
3676
  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)" }) })
@@ -3841,7 +3889,7 @@ ${planToExecute}`;
3841
3889
  /* @__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" }) }),
3842
3890
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { children: [
3843
3891
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h3", { className: "text-sm font-semibold text-red-800 dark:text-red-400", children: "Error" }),
3844
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-red-700 dark:text-red-300 text-sm mt-1", children: _optionalChain([error, 'optionalAccess', _116 => _116.message]) })
3892
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-red-700 dark:text-red-300 text-sm mt-1", children: _optionalChain([error, 'optionalAccess', _118 => _118.message]) })
3845
3893
  ] })
3846
3894
  ] }) }),
3847
3895
  allowInput && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
@@ -3869,7 +3917,7 @@ ${planToExecute}`;
3869
3917
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-green-700 dark:text-green-300 text-sm", children: "Command executed successfully" })
3870
3918
  ] })
3871
3919
  ] }),
3872
- _optionalChain([result, 'access', _117 => _117.data, 'optionalAccess', _118 => _118.summary]) && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "text-neutral-700 dark:text-neutral-300 text-sm leading-relaxed whitespace-pre-line", children: result.data.summary }),
3920
+ _optionalChain([result, 'access', _119 => _119.data, 'optionalAccess', _120 => _120.summary]) && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "text-neutral-700 dark:text-neutral-300 text-sm leading-relaxed whitespace-pre-line", children: result.data.summary }),
3873
3921
  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,
3874
3922
  WidgetRenderer,
3875
3923
  {
@@ -3920,7 +3968,7 @@ ${planToExecute}`;
3920
3968
  enableFileUpload && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
3921
3969
  "button",
3922
3970
  {
3923
- onClick: () => _optionalChain([fileInputRef, 'access', _119 => _119.current, 'optionalAccess', _120 => _120.click, 'call', _121 => _121()]),
3971
+ onClick: () => _optionalChain([fileInputRef, 'access', _121 => _121.current, 'optionalAccess', _122 => _122.click, 'call', _123 => _123()]),
3924
3972
  className: "w-8 h-8 rounded-lg flex items-center justify-center transition-all flex-shrink-0 !text-neutral-500 dark:!text-neutral-500 hover:bg-neutral-100 dark:hover:bg-neutral-800",
3925
3973
  title: "Attach file",
3926
3974
  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)" }) })
@@ -4106,25 +4154,25 @@ function Prompt({
4106
4154
  const newValue = e.target.value;
4107
4155
  if (!maxLength || newValue.length <= maxLength) {
4108
4156
  setValue(newValue);
4109
- _optionalChain([onChange, 'optionalCall', _122 => _122(newValue)]);
4157
+ _optionalChain([onChange, 'optionalCall', _124 => _124(newValue)]);
4110
4158
  }
4111
4159
  };
4112
4160
  const handleSubmit = async () => {
4113
4161
  if (value.length < minLength) return;
4114
- _optionalChain([onSubmit, 'optionalCall', _123 => _123(value)]);
4162
+ _optionalChain([onSubmit, 'optionalCall', _125 => _125(value)]);
4115
4163
  setIsLoading(true);
4116
4164
  try {
4117
4165
  if (useMock) {
4118
4166
  await new Promise((resolve) => setTimeout(resolve, 1500));
4119
4167
  const mockResult = `Enhanced version: ${value} [AI-generated content]`;
4120
- _optionalChain([onResult, 'optionalCall', _124 => _124(mockResult)]);
4168
+ _optionalChain([onResult, 'optionalCall', _126 => _126(mockResult)]);
4121
4169
  setValue("");
4122
4170
  } else {
4123
4171
  const response = await aptevaClient.chat({
4124
4172
  agent_id: agentId,
4125
4173
  message: value
4126
4174
  });
4127
- _optionalChain([onResult, 'optionalCall', _125 => _125(response.message)]);
4175
+ _optionalChain([onResult, 'optionalCall', _127 => _127(response.message)]);
4128
4176
  setValue("");
4129
4177
  }
4130
4178
  } catch (error) {
@@ -4219,7 +4267,7 @@ function Stream({
4219
4267
  }, [autoStart]);
4220
4268
  const startStreaming = async () => {
4221
4269
  setIsStreaming(true);
4222
- _optionalChain([onStart, 'optionalCall', _126 => _126()]);
4270
+ _optionalChain([onStart, 'optionalCall', _128 => _128()]);
4223
4271
  try {
4224
4272
  if (useMock) {
4225
4273
  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.";
@@ -4227,13 +4275,13 @@ function Stream({
4227
4275
  mockText,
4228
4276
  (chunk) => {
4229
4277
  setText((prev) => prev + chunk);
4230
- _optionalChain([onChunk, 'optionalCall', _127 => _127(chunk)]);
4278
+ _optionalChain([onChunk, 'optionalCall', _129 => _129(chunk)]);
4231
4279
  },
4232
4280
  typingSpeed
4233
4281
  );
4234
4282
  setIsComplete(true);
4235
4283
  setIsStreaming(false);
4236
- _optionalChain([onComplete, 'optionalCall', _128 => _128(text + mockText)]);
4284
+ _optionalChain([onComplete, 'optionalCall', _130 => _130(text + mockText)]);
4237
4285
  } else {
4238
4286
  let accumulatedText = "";
4239
4287
  await aptevaClient.chatStream(
@@ -4246,24 +4294,24 @@ function Stream({
4246
4294
  if (chunk.type === "token" && chunk.content) {
4247
4295
  accumulatedText += chunk.content;
4248
4296
  setText(accumulatedText);
4249
- _optionalChain([onChunk, 'optionalCall', _129 => _129(chunk.content)]);
4297
+ _optionalChain([onChunk, 'optionalCall', _131 => _131(chunk.content)]);
4250
4298
  }
4251
4299
  },
4252
4300
  () => {
4253
4301
  setIsComplete(true);
4254
4302
  setIsStreaming(false);
4255
- _optionalChain([onComplete, 'optionalCall', _130 => _130(accumulatedText)]);
4303
+ _optionalChain([onComplete, 'optionalCall', _132 => _132(accumulatedText)]);
4256
4304
  },
4257
4305
  (error) => {
4258
4306
  const err = error instanceof Error ? error : new Error("Streaming error");
4259
- _optionalChain([onError, 'optionalCall', _131 => _131(err)]);
4307
+ _optionalChain([onError, 'optionalCall', _133 => _133(err)]);
4260
4308
  setIsStreaming(false);
4261
4309
  }
4262
4310
  );
4263
4311
  }
4264
4312
  } catch (error) {
4265
4313
  const err = error instanceof Error ? error : new Error("Streaming error");
4266
- _optionalChain([onError, 'optionalCall', _132 => _132(err)]);
4314
+ _optionalChain([onError, 'optionalCall', _134 => _134(err)]);
4267
4315
  setIsStreaming(false);
4268
4316
  }
4269
4317
  };
@@ -4355,7 +4403,7 @@ function ThreadList({
4355
4403
  }) {
4356
4404
  const [searchQuery, setSearchQuery] = _react.useState.call(void 0, "");
4357
4405
  const filteredThreads = threads.filter(
4358
- (thread) => thread.title.toLowerCase().includes(searchQuery.toLowerCase()) || _optionalChain([thread, 'access', _133 => _133.preview, 'optionalAccess', _134 => _134.toLowerCase, 'call', _135 => _135(), 'access', _136 => _136.includes, 'call', _137 => _137(searchQuery.toLowerCase())])
4406
+ (thread) => thread.title.toLowerCase().includes(searchQuery.toLowerCase()) || _optionalChain([thread, 'access', _135 => _135.preview, 'optionalAccess', _136 => _136.toLowerCase, 'call', _137 => _137(), 'access', _138 => _138.includes, 'call', _139 => _139(searchQuery.toLowerCase())])
4359
4407
  );
4360
4408
  const groupedThreads = groupBy === "date" ? groupThreadsByDate(filteredThreads) : { All: filteredThreads };
4361
4409
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-col h-full", children: [
@@ -4377,8 +4425,8 @@ function ThreadList({
4377
4425
  {
4378
4426
  thread,
4379
4427
  isActive: thread.id === currentThreadId,
4380
- onSelect: () => _optionalChain([onThreadSelect, 'optionalCall', _138 => _138(thread.id)]),
4381
- onDelete: () => _optionalChain([onThreadDelete, 'optionalCall', _139 => _139(thread.id)])
4428
+ onSelect: () => _optionalChain([onThreadSelect, 'optionalCall', _140 => _140(thread.id)]),
4429
+ onDelete: () => _optionalChain([onThreadDelete, 'optionalCall', _141 => _141(thread.id)])
4382
4430
  },
4383
4431
  thread.id
4384
4432
  ))
@@ -4440,7 +4488,7 @@ function Threads({
4440
4488
  threads.slice(0, 5).map((thread) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
4441
4489
  "button",
4442
4490
  {
4443
- onClick: () => _optionalChain([onThreadSelect, 'optionalCall', _140 => _140(thread.id)]),
4491
+ onClick: () => _optionalChain([onThreadSelect, 'optionalCall', _142 => _142(thread.id)]),
4444
4492
  className: cn(
4445
4493
  "px-4 py-2 whitespace-nowrap font-medium transition-colors",
4446
4494
  thread.id === currentThreadId ? "border-b-2 border-apteva-500 text-apteva-500" : "text-neutral-600 hover:text-neutral-900"