@apteva/apteva-kit 0.1.70 → 0.1.71

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
@@ -1518,14 +1518,39 @@ function MarkdownContent({ content, className = "" }) {
1518
1518
 
1519
1519
  // src/components/Chat/ToolCall.tsx
1520
1520
 
1521
- function ToolCall({ name, status }) {
1521
+ function ToolCall({ name, status, isReceiving = false }) {
1522
+ if (status === "preparing") {
1523
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: `apteva-tool-card apteva-tool-card-preparing ${isReceiving ? "apteva-tool-receiving" : ""}`, children: [
1524
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "svg", { className: "apteva-tool-icon apteva-tool-icon-spin", fill: "none", viewBox: "0 0 24 24", children: [
1525
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "circle", { className: "apteva-tool-spinner-track", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }),
1526
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", { className: "apteva-tool-spinner-fill", fill: "currentColor", d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z" })
1527
+ ] }),
1528
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "apteva-tool-label", children: [
1529
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "strong", { children: name }),
1530
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "apteva-tool-status-text", children: " preparing" }),
1531
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "apteva-tool-dots", children: [
1532
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: "." }),
1533
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: "." }),
1534
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: "." })
1535
+ ] })
1536
+ ] })
1537
+ ] });
1538
+ }
1522
1539
  if (status === "running") {
1523
1540
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "apteva-tool-card apteva-tool-card-running", children: [
1524
1541
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "svg", { className: "apteva-tool-icon apteva-tool-icon-spin", fill: "none", viewBox: "0 0 24 24", children: [
1525
1542
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "circle", { className: "apteva-tool-spinner-track", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }),
1526
1543
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", { className: "apteva-tool-spinner-fill", fill: "currentColor", d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z" })
1527
1544
  ] }),
1528
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "apteva-tool-label", children: name })
1545
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "apteva-tool-label", children: [
1546
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "strong", { children: name }),
1547
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "apteva-tool-status-text", children: " running" }),
1548
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "apteva-tool-dots", children: [
1549
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: "." }),
1550
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: "." }),
1551
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: "." })
1552
+ ] })
1553
+ ] })
1529
1554
  ] });
1530
1555
  }
1531
1556
  if (status === "completed") {
@@ -1739,7 +1764,8 @@ function Message({ message, onAction, enableWidgets, onWidgetRender }) {
1739
1764
  ToolCall,
1740
1765
  {
1741
1766
  name: segment.name,
1742
- status: segment.result !== void 0 ? "completed" : "running"
1767
+ status: segment.status || (segment.result !== void 0 ? "completed" : "running"),
1768
+ isReceiving: segment.isReceiving
1743
1769
  }
1744
1770
  ) }, segment.id)
1745
1771
  );
@@ -2845,6 +2871,7 @@ ${widgetContext}` : widgetContext;
2845
2871
  let accumulatedWidgets = [];
2846
2872
  let responseThreadId = currentThreadId;
2847
2873
  let toolInputBuffer = "";
2874
+ let receivingTimeout = null;
2848
2875
  const streamingMessageId = `msg-${Date.now()}`;
2849
2876
  const updateMessage = () => {
2850
2877
  const segments = [...contentSegments];
@@ -2921,7 +2948,7 @@ ${widgetContext}` : widgetContext;
2921
2948
  contentSegments.push({ type: "text", content: currentTextBuffer });
2922
2949
  currentTextBuffer = "";
2923
2950
  }
2924
- contentSegments.push({ type: "tool", id: chunk.tool_id, name: displayName });
2951
+ contentSegments.push({ type: "tool", id: chunk.tool_id, name: displayName, status: "preparing" });
2925
2952
  toolInputBuffer = "";
2926
2953
  setChatToolName(displayName);
2927
2954
  _optionalChain([onToolCall, 'optionalCall', _72 => _72(chunk.tool_name, chunk.tool_id)]);
@@ -2931,6 +2958,28 @@ ${widgetContext}` : widgetContext;
2931
2958
  case "tool_input_delta":
2932
2959
  if (chunk.tool_id && chunk.content) {
2933
2960
  toolInputBuffer += chunk.content;
2961
+ const toolSegment = contentSegments.find((s) => s.type === "tool" && s.id === chunk.tool_id);
2962
+ if (toolSegment) {
2963
+ toolSegment.isReceiving = true;
2964
+ updateMessage();
2965
+ if (receivingTimeout) clearTimeout(receivingTimeout);
2966
+ receivingTimeout = setTimeout(() => {
2967
+ if (toolSegment.status === "preparing") {
2968
+ toolSegment.isReceiving = false;
2969
+ updateMessage();
2970
+ }
2971
+ }, 150);
2972
+ }
2973
+ }
2974
+ break;
2975
+ case "tool_use":
2976
+ if (chunk.tool_id) {
2977
+ const toolSegment = contentSegments.find((s) => s.type === "tool" && s.id === chunk.tool_id);
2978
+ if (toolSegment && toolSegment.status === "preparing") {
2979
+ toolSegment.status = "running";
2980
+ toolSegment.isReceiving = false;
2981
+ updateMessage();
2982
+ }
2934
2983
  }
2935
2984
  break;
2936
2985
  case "tool_result":
@@ -2938,6 +2987,8 @@ ${widgetContext}` : widgetContext;
2938
2987
  const toolSegment = contentSegments.find((s) => s.type === "tool" && s.id === chunk.tool_id);
2939
2988
  if (toolSegment) {
2940
2989
  toolSegment.result = chunk.content;
2990
+ toolSegment.status = "completed";
2991
+ toolSegment.isReceiving = false;
2941
2992
  _optionalChain([onToolResult, 'optionalCall', _73 => _73(toolSegment.name, chunk.content)]);
2942
2993
  }
2943
2994
  setChatToolName(null);