ai 6.0.214 → 6.0.216

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
@@ -1171,7 +1171,7 @@ import {
1171
1171
  } from "@ai-sdk/provider-utils";
1172
1172
 
1173
1173
  // src/version.ts
1174
- var VERSION = true ? "6.0.214" : "0.0.0-test";
1174
+ var VERSION = true ? "6.0.216" : "0.0.0-test";
1175
1175
 
1176
1176
  // src/util/download/download.ts
1177
1177
  var download = async ({
@@ -11693,29 +11693,44 @@ function pruneMessages({
11693
11693
  }
11694
11694
  }
11695
11695
  }
11696
+ const toolCallIdToToolName = /* @__PURE__ */ new Map();
11697
+ for (const message of messages) {
11698
+ if ((message.role === "assistant" || message.role === "tool") && typeof message.content !== "string") {
11699
+ for (const part of message.content) {
11700
+ if (part.type === "tool-call" || part.type === "tool-result") {
11701
+ toolCallIdToToolName.set(part.toolCallId, part.toolName);
11702
+ }
11703
+ }
11704
+ }
11705
+ }
11706
+ const approvalIdToToolName = /* @__PURE__ */ new Map();
11707
+ for (const message of messages) {
11708
+ if ((message.role === "assistant" || message.role === "tool") && typeof message.content !== "string") {
11709
+ for (const part of message.content) {
11710
+ if (part.type === "tool-approval-request") {
11711
+ const toolName = toolCallIdToToolName.get(part.toolCallId);
11712
+ if (toolName != null) {
11713
+ approvalIdToToolName.set(part.approvalId, toolName);
11714
+ }
11715
+ }
11716
+ }
11717
+ }
11718
+ }
11696
11719
  messages = messages.map((message, messageIndex) => {
11697
11720
  if (message.role !== "assistant" && message.role !== "tool" || typeof message.content === "string" || keepLastMessagesCount && messageIndex >= messages.length - keepLastMessagesCount) {
11698
11721
  return message;
11699
11722
  }
11700
- const toolCallIdToToolName = {};
11701
- const approvalIdToToolName = {};
11702
11723
  return {
11703
11724
  ...message,
11704
11725
  content: message.content.filter((part) => {
11705
11726
  if (part.type !== "tool-call" && part.type !== "tool-result" && part.type !== "tool-approval-request" && part.type !== "tool-approval-response") {
11706
11727
  return true;
11707
11728
  }
11708
- if (part.type === "tool-call") {
11709
- toolCallIdToToolName[part.toolCallId] = part.toolName;
11710
- } else if (part.type === "tool-approval-request") {
11711
- approvalIdToToolName[part.approvalId] = toolCallIdToToolName[part.toolCallId];
11712
- }
11713
11729
  if ((part.type === "tool-call" || part.type === "tool-result") && keptToolCallIds.has(part.toolCallId) || (part.type === "tool-approval-request" || part.type === "tool-approval-response") && keptApprovalIds.has(part.approvalId)) {
11714
11730
  return true;
11715
11731
  }
11716
- return toolCall.tools != null && !toolCall.tools.includes(
11717
- part.type === "tool-call" || part.type === "tool-result" ? part.toolName : approvalIdToToolName[part.approvalId]
11718
- );
11732
+ const partToolName = part.type === "tool-call" || part.type === "tool-result" ? part.toolName : approvalIdToToolName.get(part.approvalId);
11733
+ return toolCall.tools != null && partToolName != null && !toolCall.tools.includes(partToolName);
11719
11734
  })
11720
11735
  };
11721
11736
  });