@apteva/apteva-kit 0.1.104 → 0.1.105

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
@@ -3669,15 +3669,21 @@ ${widgetContext}` : widgetContext;
3669
3669
  case "content":
3670
3670
  case "token":
3671
3671
  if (chunk.content) {
3672
- currentTextBuffer += chunk.content;
3673
- updateMessage();
3672
+ if (!currentTextBuffer) {
3673
+ currentTextBuffer = chunk.content.trimStart();
3674
+ } else {
3675
+ currentTextBuffer += chunk.content;
3676
+ }
3677
+ if (currentTextBuffer) {
3678
+ updateMessage();
3679
+ }
3674
3680
  }
3675
3681
  break;
3676
3682
  case "tool_call":
3677
3683
  if (chunk.tool_id && chunk.tool_name) {
3678
3684
  const displayName = chunk.tool_display_name || chunk.tool_name;
3679
3685
  if (currentTextBuffer) {
3680
- contentSegments.push({ type: "text", content: currentTextBuffer });
3686
+ contentSegments.push({ type: "text", content: currentTextBuffer.trimEnd() });
3681
3687
  currentTextBuffer = "";
3682
3688
  }
3683
3689
  contentSegments.push({ type: "tool", id: chunk.tool_id, name: displayName, status: "preparing" });
@@ -3760,6 +3766,7 @@ ${widgetContext}` : widgetContext;
3760
3766
  }
3761
3767
  },
3762
3768
  (threadId2) => {
3769
+ currentTextBuffer = currentTextBuffer.trimEnd();
3763
3770
  if (currentTextBuffer) {
3764
3771
  const lastSegment = contentSegments[contentSegments.length - 1];
3765
3772
  if (lastSegment && lastSegment.type === "text") {