ai 5.1.0-beta.27 → 5.1.0-beta.28

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
@@ -716,7 +716,7 @@ import {
716
716
  } from "@ai-sdk/provider-utils";
717
717
 
718
718
  // src/version.ts
719
- var VERSION = true ? "5.1.0-beta.27" : "0.0.0-test";
719
+ var VERSION = true ? "5.1.0-beta.28" : "0.0.0-test";
720
720
 
721
721
  // src/util/download/download.ts
722
722
  var download = async ({ url }) => {
@@ -2073,6 +2073,26 @@ var DefaultGeneratedFileWithType = class extends DefaultGeneratedFile {
2073
2073
  }
2074
2074
  };
2075
2075
 
2076
+ // src/generate-text/is-approval-needed.ts
2077
+ async function isApprovalNeeded({
2078
+ tool: tool3,
2079
+ toolCall,
2080
+ messages,
2081
+ experimental_context
2082
+ }) {
2083
+ if (tool3.needsApproval == null) {
2084
+ return false;
2085
+ }
2086
+ if (typeof tool3.needsApproval === "boolean") {
2087
+ return tool3.needsApproval;
2088
+ }
2089
+ return await tool3.needsApproval(toolCall.input, {
2090
+ toolCallId: toolCall.toolCallId,
2091
+ messages,
2092
+ experimental_context
2093
+ });
2094
+ }
2095
+
2076
2096
  // src/generate-text/parse-tool-call.ts
2077
2097
  import {
2078
2098
  asSchema as asSchema2,
@@ -2625,7 +2645,12 @@ async function generateText({
2625
2645
  experimental_context
2626
2646
  });
2627
2647
  }
2628
- if (tool3 == null ? void 0 : tool3.needsApproval) {
2648
+ if (await isApprovalNeeded({
2649
+ tool: tool3,
2650
+ toolCall,
2651
+ messages: stepInputMessages,
2652
+ experimental_context
2653
+ })) {
2629
2654
  toolApprovalRequests[toolCall.toolCallId] = {
2630
2655
  type: "tool-approval-request",
2631
2656
  approvalId: generateId2(),
@@ -4522,7 +4547,12 @@ function runToolsTransformation({
4522
4547
  experimental_context
4523
4548
  });
4524
4549
  }
4525
- if (tool3.needsApproval) {
4550
+ if (await isApprovalNeeded({
4551
+ tool: tool3,
4552
+ toolCall,
4553
+ messages,
4554
+ experimental_context
4555
+ })) {
4526
4556
  toolResultsStreamController.enqueue({
4527
4557
  type: "tool-approval-request",
4528
4558
  approvalId: generateId2(),