@ai-sdk/provider-utils 3.1.0-beta.5 → 3.1.0-beta.7

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/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # @ai-sdk/provider-utils
2
2
 
3
+ ## 3.1.0-beta.7
4
+
5
+ ### Patch Changes
6
+
7
+ - e8109d3: feat: tool execution approval
8
+ - Updated dependencies [046aa3b]
9
+ - Updated dependencies [e8109d3]
10
+ - @ai-sdk/provider@2.1.0-beta.5
11
+
12
+ ## 3.1.0-beta.6
13
+
14
+ ### Patch Changes
15
+
16
+ - 0adc679: feat(provider): shared spec v3
17
+ - Updated dependencies [0adc679]
18
+ - Updated dependencies [2b0caef]
19
+ - @ai-sdk/provider@2.1.0-beta.4
20
+
3
21
  ## 3.1.0-beta.5
4
22
 
5
23
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { JSONParseError, TypeValidationError, JSONValue, APICallError, LanguageModelV3Prompt, JSONSchema7, SharedV2ProviderOptions, LanguageModelV3ToolResultOutput, LanguageModelV3ToolResultPart } from '@ai-sdk/provider';
1
+ import { JSONParseError, TypeValidationError, JSONValue, APICallError, LanguageModelV3Prompt, JSONSchema7, SharedV3ProviderOptions, LanguageModelV3ToolResultOutput, LanguageModelV3ToolResultPart } from '@ai-sdk/provider';
2
2
  import * as z4 from 'zod/v4';
3
3
  import { ZodType, z } from 'zod/v4';
4
4
  import * as z3 from 'zod/v3';
@@ -371,7 +371,7 @@ Additional provider-specific options.
371
371
  They are passed through to the provider from the AI SDK and enable
372
372
  provider-specific functionality that can be fully encapsulated in the provider.
373
373
  */
374
- type ProviderOptions = SharedV2ProviderOptions;
374
+ type ProviderOptions = SharedV3ProviderOptions;
375
375
 
376
376
  /**
377
377
  Data content. Can either be a base64-encoded string, a Uint8Array, an ArrayBuffer, or a Buffer.
@@ -517,6 +517,21 @@ interface ToolResultPart {
517
517
  providerOptions?: ProviderOptions;
518
518
  }
519
519
 
520
+ /**
521
+ * Tool approval request prompt part.
522
+ */
523
+ type ToolApprovalRequest = {
524
+ type: 'tool-approval-request';
525
+ /**
526
+ * ID of the tool approval.
527
+ */
528
+ approvalId: string;
529
+ /**
530
+ * ID of the tool call that the approval request is for.
531
+ */
532
+ toolCallId: string;
533
+ };
534
+
520
535
  /**
521
536
  An assistant message. It can contain text, tool calls, or a combination of text and tool calls.
522
537
  */
@@ -534,7 +549,7 @@ type AssistantModelMessage = {
534
549
  Content of an assistant message.
535
550
  It can be a string or an array of text, image, reasoning, redacted reasoning, and tool call parts.
536
551
  */
537
- type AssistantContent = string | Array<TextPart | FilePart | ReasoningPart | ToolCallPart | ToolResultPart>;
552
+ type AssistantContent = string | Array<TextPart | FilePart | ReasoningPart | ToolCallPart | ToolResultPart | ToolApprovalRequest>;
538
553
 
539
554
  /**
540
555
  A system message. It can contain system information.
@@ -554,6 +569,25 @@ type SystemModelMessage = {
554
569
  providerOptions?: ProviderOptions;
555
570
  };
556
571
 
572
+ /**
573
+ * Tool approval response prompt part.
574
+ */
575
+ type ToolApprovalResponse = {
576
+ type: 'tool-approval-response';
577
+ /**
578
+ * ID of the tool approval.
579
+ */
580
+ approvalId: string;
581
+ /**
582
+ * Flag indicating whether the approval was granted or denied.
583
+ */
584
+ approved: boolean;
585
+ /**
586
+ * Optional reason for the approval or denial.
587
+ */
588
+ reason?: string;
589
+ };
590
+
557
591
  /**
558
592
  A tool message. It contains the result of one or more tool calls.
559
593
  */
@@ -570,7 +604,7 @@ type ToolModelMessage = {
570
604
  /**
571
605
  Content of a tool message. It is an array of tool result parts.
572
606
  */
573
- type ToolContent = Array<ToolResultPart>;
607
+ type ToolContent = Array<ToolResultPart | ToolApprovalResponse>;
574
608
 
575
609
  /**
576
610
  A user message. It can contain text or a combination of text and images.
@@ -662,6 +696,10 @@ type Tool<INPUT extends JSONValue | unknown | never = any, OUTPUT extends JSONVa
662
696
  */
663
697
  inputSchema: FlexibleSchema<INPUT>;
664
698
  /**
699
+ Whether the tool needs approval before it can be executed.
700
+ */
701
+ needsApproval?: boolean;
702
+ /**
665
703
  * Optional function that is called when the argument streaming starts.
666
704
  * Only called when the tool is used in a streaming context.
667
705
  */
@@ -908,4 +946,4 @@ interface ToolResult<NAME extends string, INPUT, OUTPUT> {
908
946
 
909
947
  declare const VERSION: string;
910
948
 
911
- export { type AssistantContent, type AssistantModelMessage, type DataContent, type FetchFunction, type FilePart, type FlexibleSchema, type IdGenerator, type ImagePart, type InferSchema, type InferToolInput, type InferToolOutput, type ModelMessage, type ParseResult, type ProviderDefinedToolFactory, type ProviderDefinedToolFactoryWithOutputSchema, type ProviderOptions, type ReasoningPart, type Resolvable, type ResponseHandler, type Schema, type SystemModelMessage, type TextPart, type Tool, type ToolCall, type ToolCallOptions, type ToolCallPart, type ToolContent, type ToolExecuteFunction, type ToolModelMessage, type ToolResult, type ToolResultPart, type UserContent, type UserModelMessage, VERSION, type ValidationResult, type Validator, asSchema, asValidator, combineHeaders, convertAsyncIteratorToReadableStream, convertBase64ToUint8Array, convertToBase64, convertUint8ArrayToBase64, createBinaryResponseHandler, createEventSourceResponseHandler, createIdGenerator, createJsonErrorResponseHandler, createJsonResponseHandler, createJsonStreamResponseHandler, createProviderDefinedToolFactory, createProviderDefinedToolFactoryWithOutputSchema, createStatusCodeErrorResponseHandler, delay, dynamicTool, executeTool, extractResponseHeaders, generateId, getErrorMessage, getFromApi, getRuntimeEnvironmentUserAgent, injectJsonInstructionIntoMessages, isAbortError, isParsableJson, isUrlSupported, isValidator, jsonSchema, loadApiKey, loadOptionalSetting, loadSetting, mediaTypeToExtension, parseJSON, parseJsonEventStream, parseProviderOptions, postFormDataToApi, postJsonToApi, postToApi, removeUndefinedEntries, resolve, safeParseJSON, safeValidateTypes, standardSchemaValidator, tool, validateTypes, validator, validatorSymbol, withUserAgentSuffix, withoutTrailingSlash, zodSchema };
949
+ export { type AssistantContent, type AssistantModelMessage, type DataContent, type FetchFunction, type FilePart, type FlexibleSchema, type IdGenerator, type ImagePart, type InferSchema, type InferToolInput, type InferToolOutput, type ModelMessage, type ParseResult, type ProviderDefinedToolFactory, type ProviderDefinedToolFactoryWithOutputSchema, type ProviderOptions, type ReasoningPart, type Resolvable, type ResponseHandler, type Schema, type SystemModelMessage, type TextPart, type Tool, type ToolApprovalRequest, type ToolApprovalResponse, type ToolCall, type ToolCallOptions, type ToolCallPart, type ToolContent, type ToolExecuteFunction, type ToolModelMessage, type ToolResult, type ToolResultPart, type UserContent, type UserModelMessage, VERSION, type ValidationResult, type Validator, asSchema, asValidator, combineHeaders, convertAsyncIteratorToReadableStream, convertBase64ToUint8Array, convertToBase64, convertUint8ArrayToBase64, createBinaryResponseHandler, createEventSourceResponseHandler, createIdGenerator, createJsonErrorResponseHandler, createJsonResponseHandler, createJsonStreamResponseHandler, createProviderDefinedToolFactory, createProviderDefinedToolFactoryWithOutputSchema, createStatusCodeErrorResponseHandler, delay, dynamicTool, executeTool, extractResponseHeaders, generateId, getErrorMessage, getFromApi, getRuntimeEnvironmentUserAgent, injectJsonInstructionIntoMessages, isAbortError, isParsableJson, isUrlSupported, isValidator, jsonSchema, loadApiKey, loadOptionalSetting, loadSetting, mediaTypeToExtension, parseJSON, parseJsonEventStream, parseProviderOptions, postFormDataToApi, postJsonToApi, postToApi, removeUndefinedEntries, resolve, safeParseJSON, safeValidateTypes, standardSchemaValidator, tool, validateTypes, validator, validatorSymbol, withUserAgentSuffix, withoutTrailingSlash, zodSchema };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { JSONParseError, TypeValidationError, JSONValue, APICallError, LanguageModelV3Prompt, JSONSchema7, SharedV2ProviderOptions, LanguageModelV3ToolResultOutput, LanguageModelV3ToolResultPart } from '@ai-sdk/provider';
1
+ import { JSONParseError, TypeValidationError, JSONValue, APICallError, LanguageModelV3Prompt, JSONSchema7, SharedV3ProviderOptions, LanguageModelV3ToolResultOutput, LanguageModelV3ToolResultPart } from '@ai-sdk/provider';
2
2
  import * as z4 from 'zod/v4';
3
3
  import { ZodType, z } from 'zod/v4';
4
4
  import * as z3 from 'zod/v3';
@@ -371,7 +371,7 @@ Additional provider-specific options.
371
371
  They are passed through to the provider from the AI SDK and enable
372
372
  provider-specific functionality that can be fully encapsulated in the provider.
373
373
  */
374
- type ProviderOptions = SharedV2ProviderOptions;
374
+ type ProviderOptions = SharedV3ProviderOptions;
375
375
 
376
376
  /**
377
377
  Data content. Can either be a base64-encoded string, a Uint8Array, an ArrayBuffer, or a Buffer.
@@ -517,6 +517,21 @@ interface ToolResultPart {
517
517
  providerOptions?: ProviderOptions;
518
518
  }
519
519
 
520
+ /**
521
+ * Tool approval request prompt part.
522
+ */
523
+ type ToolApprovalRequest = {
524
+ type: 'tool-approval-request';
525
+ /**
526
+ * ID of the tool approval.
527
+ */
528
+ approvalId: string;
529
+ /**
530
+ * ID of the tool call that the approval request is for.
531
+ */
532
+ toolCallId: string;
533
+ };
534
+
520
535
  /**
521
536
  An assistant message. It can contain text, tool calls, or a combination of text and tool calls.
522
537
  */
@@ -534,7 +549,7 @@ type AssistantModelMessage = {
534
549
  Content of an assistant message.
535
550
  It can be a string or an array of text, image, reasoning, redacted reasoning, and tool call parts.
536
551
  */
537
- type AssistantContent = string | Array<TextPart | FilePart | ReasoningPart | ToolCallPart | ToolResultPart>;
552
+ type AssistantContent = string | Array<TextPart | FilePart | ReasoningPart | ToolCallPart | ToolResultPart | ToolApprovalRequest>;
538
553
 
539
554
  /**
540
555
  A system message. It can contain system information.
@@ -554,6 +569,25 @@ type SystemModelMessage = {
554
569
  providerOptions?: ProviderOptions;
555
570
  };
556
571
 
572
+ /**
573
+ * Tool approval response prompt part.
574
+ */
575
+ type ToolApprovalResponse = {
576
+ type: 'tool-approval-response';
577
+ /**
578
+ * ID of the tool approval.
579
+ */
580
+ approvalId: string;
581
+ /**
582
+ * Flag indicating whether the approval was granted or denied.
583
+ */
584
+ approved: boolean;
585
+ /**
586
+ * Optional reason for the approval or denial.
587
+ */
588
+ reason?: string;
589
+ };
590
+
557
591
  /**
558
592
  A tool message. It contains the result of one or more tool calls.
559
593
  */
@@ -570,7 +604,7 @@ type ToolModelMessage = {
570
604
  /**
571
605
  Content of a tool message. It is an array of tool result parts.
572
606
  */
573
- type ToolContent = Array<ToolResultPart>;
607
+ type ToolContent = Array<ToolResultPart | ToolApprovalResponse>;
574
608
 
575
609
  /**
576
610
  A user message. It can contain text or a combination of text and images.
@@ -662,6 +696,10 @@ type Tool<INPUT extends JSONValue | unknown | never = any, OUTPUT extends JSONVa
662
696
  */
663
697
  inputSchema: FlexibleSchema<INPUT>;
664
698
  /**
699
+ Whether the tool needs approval before it can be executed.
700
+ */
701
+ needsApproval?: boolean;
702
+ /**
665
703
  * Optional function that is called when the argument streaming starts.
666
704
  * Only called when the tool is used in a streaming context.
667
705
  */
@@ -908,4 +946,4 @@ interface ToolResult<NAME extends string, INPUT, OUTPUT> {
908
946
 
909
947
  declare const VERSION: string;
910
948
 
911
- export { type AssistantContent, type AssistantModelMessage, type DataContent, type FetchFunction, type FilePart, type FlexibleSchema, type IdGenerator, type ImagePart, type InferSchema, type InferToolInput, type InferToolOutput, type ModelMessage, type ParseResult, type ProviderDefinedToolFactory, type ProviderDefinedToolFactoryWithOutputSchema, type ProviderOptions, type ReasoningPart, type Resolvable, type ResponseHandler, type Schema, type SystemModelMessage, type TextPart, type Tool, type ToolCall, type ToolCallOptions, type ToolCallPart, type ToolContent, type ToolExecuteFunction, type ToolModelMessage, type ToolResult, type ToolResultPart, type UserContent, type UserModelMessage, VERSION, type ValidationResult, type Validator, asSchema, asValidator, combineHeaders, convertAsyncIteratorToReadableStream, convertBase64ToUint8Array, convertToBase64, convertUint8ArrayToBase64, createBinaryResponseHandler, createEventSourceResponseHandler, createIdGenerator, createJsonErrorResponseHandler, createJsonResponseHandler, createJsonStreamResponseHandler, createProviderDefinedToolFactory, createProviderDefinedToolFactoryWithOutputSchema, createStatusCodeErrorResponseHandler, delay, dynamicTool, executeTool, extractResponseHeaders, generateId, getErrorMessage, getFromApi, getRuntimeEnvironmentUserAgent, injectJsonInstructionIntoMessages, isAbortError, isParsableJson, isUrlSupported, isValidator, jsonSchema, loadApiKey, loadOptionalSetting, loadSetting, mediaTypeToExtension, parseJSON, parseJsonEventStream, parseProviderOptions, postFormDataToApi, postJsonToApi, postToApi, removeUndefinedEntries, resolve, safeParseJSON, safeValidateTypes, standardSchemaValidator, tool, validateTypes, validator, validatorSymbol, withUserAgentSuffix, withoutTrailingSlash, zodSchema };
949
+ export { type AssistantContent, type AssistantModelMessage, type DataContent, type FetchFunction, type FilePart, type FlexibleSchema, type IdGenerator, type ImagePart, type InferSchema, type InferToolInput, type InferToolOutput, type ModelMessage, type ParseResult, type ProviderDefinedToolFactory, type ProviderDefinedToolFactoryWithOutputSchema, type ProviderOptions, type ReasoningPart, type Resolvable, type ResponseHandler, type Schema, type SystemModelMessage, type TextPart, type Tool, type ToolApprovalRequest, type ToolApprovalResponse, type ToolCall, type ToolCallOptions, type ToolCallPart, type ToolContent, type ToolExecuteFunction, type ToolModelMessage, type ToolResult, type ToolResultPart, type UserContent, type UserModelMessage, VERSION, type ValidationResult, type Validator, asSchema, asValidator, combineHeaders, convertAsyncIteratorToReadableStream, convertBase64ToUint8Array, convertToBase64, convertUint8ArrayToBase64, createBinaryResponseHandler, createEventSourceResponseHandler, createIdGenerator, createJsonErrorResponseHandler, createJsonResponseHandler, createJsonStreamResponseHandler, createProviderDefinedToolFactory, createProviderDefinedToolFactoryWithOutputSchema, createStatusCodeErrorResponseHandler, delay, dynamicTool, executeTool, extractResponseHeaders, generateId, getErrorMessage, getFromApi, getRuntimeEnvironmentUserAgent, injectJsonInstructionIntoMessages, isAbortError, isParsableJson, isUrlSupported, isValidator, jsonSchema, loadApiKey, loadOptionalSetting, loadSetting, mediaTypeToExtension, parseJSON, parseJsonEventStream, parseProviderOptions, postFormDataToApi, postJsonToApi, postToApi, removeUndefinedEntries, resolve, safeParseJSON, safeValidateTypes, standardSchemaValidator, tool, validateTypes, validator, validatorSymbol, withUserAgentSuffix, withoutTrailingSlash, zodSchema };
package/dist/index.js CHANGED
@@ -284,7 +284,7 @@ function handleFetchError({
284
284
  }
285
285
 
286
286
  // src/version.ts
287
- var VERSION = true ? "3.1.0-beta.5" : "0.0.0-test";
287
+ var VERSION = true ? "3.1.0-beta.7" : "0.0.0-test";
288
288
 
289
289
  // src/get-from-api.ts
290
290
  var getOriginalFetch = () => globalThis.fetch;