ai 7.0.29 → 7.0.31

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.
@@ -1,7 +1,7 @@
1
1
  import * as _ai_sdk_provider from '@ai-sdk/provider';
2
2
  import { EmbeddingModelV4Embedding, LanguageModelV4, LanguageModelV3, LanguageModelV2, SharedV4Warning, LanguageModelV4Source, SharedV4ProviderMetadata, LanguageModelV4Usage, JSONObject, LanguageModelV4CallOptions, LanguageModelV4Prompt, AISDKError, LanguageModelV4ToolCall, JSONSchema7, ProviderV4, ProviderV3, ProviderV2, LanguageModelV4ToolResultOutput, LanguageModelV4ToolChoice, LanguageModelV4FunctionTool, LanguageModelV4ProviderTool } from '@ai-sdk/provider';
3
3
  import { GatewayModelId } from '@ai-sdk/gateway';
4
- import { ModelMessage, AssistantModelMessage, ToolModelMessage, ProviderOptions, ToolSet, SystemModelMessage, Context, InferToolSetContext, Arrayable, InferToolInput, InferToolOutput, ReasoningPart, ReasoningFilePart, InferToolContext, ToolExecutionOptions, MaybePromiseLike, ToolResultOutput, Tool, Experimental_SandboxSession, RetryFunction, ToolApprovalRequest, ToolApprovalResponse } from '@ai-sdk/provider-utils';
4
+ import { ModelMessage, AssistantModelMessage, ToolModelMessage, ProviderOptions, ToolSet, SystemModelMessage, Context, InferToolSetContext, Arrayable, InferToolInput, InferToolOutput, ReasoningPart, ReasoningFilePart, InferToolContext, ToolExecutionOptions, MaybePromiseLike, ToolResultOutput, Tool, Experimental_SandboxSession, RetryFunction, ToolApprovalRequest, ToolApprovalResponse, ToolResultPart } from '@ai-sdk/provider-utils';
5
5
  export { convertAsyncIteratorToReadableStream } from '@ai-sdk/provider-utils';
6
6
 
7
7
  /**
@@ -2661,6 +2661,7 @@ type CollectedToolApprovals<TOOLS extends ToolSet> = {
2661
2661
  approvalRequest: ToolApprovalRequest;
2662
2662
  approvalResponse: ToolApprovalResponse;
2663
2663
  toolCall: TypedToolCall<TOOLS>;
2664
+ existingToolResult?: ToolResultPart;
2664
2665
  };
2665
2666
  /**
2666
2667
  * If the last message is a tool message, this function collects all tool approvals
@@ -85,7 +85,7 @@ import {
85
85
  } from "@ai-sdk/provider-utils";
86
86
 
87
87
  // src/version.ts
88
- var VERSION = true ? "7.0.29" : "0.0.0-test";
88
+ var VERSION = true ? "7.0.31" : "0.0.0-test";
89
89
 
90
90
  // src/util/download/download.ts
91
91
  var download = async ({
@@ -3062,9 +3062,7 @@ function collectToolApprovals({
3062
3062
  }
3063
3063
  }
3064
3064
  }
3065
- const toolResults = /* @__PURE__ */ Object.create(
3066
- null
3067
- );
3065
+ const toolResults = /* @__PURE__ */ Object.create(null);
3068
3066
  for (const part of lastMessage.content) {
3069
3067
  if (part.type === "tool-result") {
3070
3068
  toolResults[part.toolCallId] = part;
@@ -3082,7 +3080,8 @@ function collectToolApprovals({
3082
3080
  approvalId: approvalResponse.approvalId
3083
3081
  });
3084
3082
  }
3085
- if (toolResults[approvalRequest.toolCallId] != null) {
3083
+ const existingToolResult = toolResults[approvalRequest.toolCallId];
3084
+ if (existingToolResult != null && (approvalResponse.approved || existingToolResult.output.type !== "execution-denied")) {
3086
3085
  continue;
3087
3086
  }
3088
3087
  const toolCall = toolCallsByToolCallId[approvalRequest.toolCallId];
@@ -3095,7 +3094,8 @@ function collectToolApprovals({
3095
3094
  const approval = {
3096
3095
  approvalRequest,
3097
3096
  approvalResponse,
3098
- toolCall
3097
+ toolCall,
3098
+ ...existingToolResult != null ? { existingToolResult } : {}
3099
3099
  };
3100
3100
  if (approvalResponse.approved) {
3101
3101
  approvedToolApprovals.push(approval);