@apteva/apteva-kit 0.1.71 → 0.1.76

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.mjs CHANGED
@@ -1518,21 +1518,16 @@ function MarkdownContent({ content, className = "" }) {
1518
1518
 
1519
1519
  // src/components/Chat/ToolCall.tsx
1520
1520
  import { jsx as jsx11, jsxs as jsxs8 } from "react/jsx-runtime";
1521
- function ToolCall({ name, status, isReceiving = false }) {
1521
+ function ToolCall({ name, status, isReceiving = false, inputLength = 0 }) {
1522
1522
  if (status === "preparing") {
1523
- return /* @__PURE__ */ jsxs8("div", { className: `apteva-tool-card apteva-tool-card-preparing ${isReceiving ? "apteva-tool-receiving" : ""}`, children: [
1523
+ return /* @__PURE__ */ jsxs8("div", { className: "apteva-tool-card apteva-tool-card-preparing", children: [
1524
1524
  /* @__PURE__ */ jsxs8("svg", { className: "apteva-tool-icon apteva-tool-icon-spin", fill: "none", viewBox: "0 0 24 24", children: [
1525
1525
  /* @__PURE__ */ jsx11("circle", { className: "apteva-tool-spinner-track", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }),
1526
1526
  /* @__PURE__ */ jsx11("path", { className: "apteva-tool-spinner-fill", fill: "currentColor", d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z" })
1527
1527
  ] }),
1528
1528
  /* @__PURE__ */ jsxs8("span", { className: "apteva-tool-label", children: [
1529
1529
  /* @__PURE__ */ jsx11("strong", { children: name }),
1530
- /* @__PURE__ */ jsx11("span", { className: "apteva-tool-status-text", children: " preparing" }),
1531
- /* @__PURE__ */ jsxs8("span", { className: "apteva-tool-dots", children: [
1532
- /* @__PURE__ */ jsx11("span", { children: "." }),
1533
- /* @__PURE__ */ jsx11("span", { children: "." }),
1534
- /* @__PURE__ */ jsx11("span", { children: "." })
1535
- ] })
1530
+ /* @__PURE__ */ jsx11("span", { className: "apteva-tool-status-text", children: " preparing..." })
1536
1531
  ] })
1537
1532
  ] });
1538
1533
  }
@@ -1765,7 +1760,8 @@ function Message({ message, onAction, enableWidgets, onWidgetRender }) {
1765
1760
  {
1766
1761
  name: segment.name,
1767
1762
  status: segment.status || (segment.result !== void 0 ? "completed" : "running"),
1768
- isReceiving: segment.isReceiving
1763
+ isReceiving: segment.isReceiving,
1764
+ inputLength: segment.inputLength
1769
1765
  }
1770
1766
  ) }, segment.id)
1771
1767
  );
@@ -2870,8 +2866,8 @@ ${widgetContext}` : widgetContext;
2870
2866
  let currentTextBuffer = "";
2871
2867
  let accumulatedWidgets = [];
2872
2868
  let responseThreadId = currentThreadId;
2873
- let toolInputBuffer = "";
2874
- let receivingTimeout = null;
2869
+ const toolInputBuffers = {};
2870
+ const receivingTimeouts = {};
2875
2871
  const streamingMessageId = `msg-${Date.now()}`;
2876
2872
  const updateMessage = () => {
2877
2873
  const segments = [...contentSegments];
@@ -2949,7 +2945,7 @@ ${widgetContext}` : widgetContext;
2949
2945
  currentTextBuffer = "";
2950
2946
  }
2951
2947
  contentSegments.push({ type: "tool", id: chunk.tool_id, name: displayName, status: "preparing" });
2952
- toolInputBuffer = "";
2948
+ toolInputBuffers[chunk.tool_id] = "";
2953
2949
  setChatToolName(displayName);
2954
2950
  onToolCall?.(chunk.tool_name, chunk.tool_id);
2955
2951
  updateMessage();
@@ -2957,13 +2953,18 @@ ${widgetContext}` : widgetContext;
2957
2953
  break;
2958
2954
  case "tool_input_delta":
2959
2955
  if (chunk.tool_id && chunk.content) {
2960
- toolInputBuffer += chunk.content;
2961
- const toolSegment = contentSegments.find((s) => s.type === "tool" && s.id === chunk.tool_id);
2956
+ const toolId = chunk.tool_id;
2957
+ if (toolInputBuffers[toolId] === void 0) {
2958
+ toolInputBuffers[toolId] = "";
2959
+ }
2960
+ toolInputBuffers[toolId] += chunk.content;
2961
+ const toolSegment = contentSegments.find((s) => s.type === "tool" && s.id === toolId);
2962
2962
  if (toolSegment) {
2963
2963
  toolSegment.isReceiving = true;
2964
+ toolSegment.inputLength = toolInputBuffers[toolId].length;
2964
2965
  updateMessage();
2965
- if (receivingTimeout) clearTimeout(receivingTimeout);
2966
- receivingTimeout = setTimeout(() => {
2966
+ if (receivingTimeouts[toolId]) clearTimeout(receivingTimeouts[toolId]);
2967
+ receivingTimeouts[toolId] = setTimeout(() => {
2967
2968
  if (toolSegment.status === "preparing") {
2968
2969
  toolSegment.isReceiving = false;
2969
2970
  updateMessage();