@ai-sdk/provider-utils 4.0.0-beta.16 → 4.0.0-beta.17
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 +6 -0
- package/dist/index.d.mts +27 -19
- package/dist/index.d.ts +27 -19
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -641,6 +641,26 @@ interface ToolCallOptions {
|
|
|
641
641
|
*/
|
|
642
642
|
experimental_context?: unknown;
|
|
643
643
|
}
|
|
644
|
+
/**
|
|
645
|
+
* Function that is called to determine if the tool needs approval before it can be executed.
|
|
646
|
+
*/
|
|
647
|
+
type ToolNeedsApprovalFunction<INPUT> = (input: INPUT, options: {
|
|
648
|
+
/**
|
|
649
|
+
* The ID of the tool call. You can use it e.g. when sending tool-call related information with stream data.
|
|
650
|
+
*/
|
|
651
|
+
toolCallId: string;
|
|
652
|
+
/**
|
|
653
|
+
* Messages that were sent to the language model to initiate the response that contained the tool call.
|
|
654
|
+
* The messages **do not** include the system prompt nor the assistant response that contained the tool call.
|
|
655
|
+
*/
|
|
656
|
+
messages: ModelMessage[];
|
|
657
|
+
/**
|
|
658
|
+
* Additional context.
|
|
659
|
+
*
|
|
660
|
+
* Experimental (can break in patch releases).
|
|
661
|
+
*/
|
|
662
|
+
experimental_context?: unknown;
|
|
663
|
+
}) => boolean | PromiseLike<boolean>;
|
|
644
664
|
type ToolExecuteFunction<INPUT, OUTPUT> = (input: INPUT, options: ToolCallOptions) => AsyncIterable<OUTPUT> | PromiseLike<OUTPUT> | OUTPUT;
|
|
645
665
|
type NeverOptional<N, T> = 0 extends 1 & N ? Partial<T> : [N] extends [never] ? Partial<Record<keyof T, undefined>> : T;
|
|
646
666
|
type ToolOutputProperties<INPUT, OUTPUT> = NeverOptional<OUTPUT, {
|
|
@@ -685,23 +705,7 @@ type Tool<INPUT extends JSONValue | unknown | never = any, OUTPUT extends JSONVa
|
|
|
685
705
|
/**
|
|
686
706
|
Whether the tool needs approval before it can be executed.
|
|
687
707
|
*/
|
|
688
|
-
needsApproval?: boolean |
|
|
689
|
-
/**
|
|
690
|
-
* The ID of the tool call. You can use it e.g. when sending tool-call related information with stream data.
|
|
691
|
-
*/
|
|
692
|
-
toolCallId: string;
|
|
693
|
-
/**
|
|
694
|
-
* Messages that were sent to the language model to initiate the response that contained the tool call.
|
|
695
|
-
* The messages **do not** include the system prompt nor the assistant response that contained the tool call.
|
|
696
|
-
*/
|
|
697
|
-
messages: ModelMessage[];
|
|
698
|
-
/**
|
|
699
|
-
* Additional context.
|
|
700
|
-
*
|
|
701
|
-
* Experimental (can break in patch releases).
|
|
702
|
-
*/
|
|
703
|
-
experimental_context?: unknown;
|
|
704
|
-
}) => boolean | PromiseLike<boolean>);
|
|
708
|
+
needsApproval?: boolean | ToolNeedsApprovalFunction<[INPUT] extends [never] ? unknown : INPUT>;
|
|
705
709
|
/**
|
|
706
710
|
* Optional function that is called when the argument streaming starts.
|
|
707
711
|
* Only called when the tool is used in a streaming context.
|
|
@@ -773,7 +777,7 @@ declare function tool<INPUT>(tool: Tool<INPUT, never>): Tool<INPUT, never>;
|
|
|
773
777
|
declare function tool<OUTPUT>(tool: Tool<never, OUTPUT>): Tool<never, OUTPUT>;
|
|
774
778
|
declare function tool(tool: Tool<never, never>): Tool<never, never>;
|
|
775
779
|
/**
|
|
776
|
-
|
|
780
|
+
* Defines a dynamic tool.
|
|
777
781
|
*/
|
|
778
782
|
declare function dynamicTool(tool: {
|
|
779
783
|
description?: string;
|
|
@@ -781,6 +785,10 @@ declare function dynamicTool(tool: {
|
|
|
781
785
|
inputSchema: FlexibleSchema<unknown>;
|
|
782
786
|
execute: ToolExecuteFunction<unknown, unknown>;
|
|
783
787
|
toModelOutput?: (output: unknown) => LanguageModelV3ToolResultPart['output'];
|
|
788
|
+
/**
|
|
789
|
+
* Whether the tool needs approval before it can be executed.
|
|
790
|
+
*/
|
|
791
|
+
needsApproval?: boolean | ToolNeedsApprovalFunction<unknown>;
|
|
784
792
|
}): Tool<unknown, unknown> & {
|
|
785
793
|
type: 'dynamic';
|
|
786
794
|
};
|
|
@@ -953,4 +961,4 @@ interface ToolResult<NAME extends string, INPUT, OUTPUT> {
|
|
|
953
961
|
dynamic?: boolean;
|
|
954
962
|
}
|
|
955
963
|
|
|
956
|
-
export { type AssistantContent, type AssistantModelMessage, type DataContent, type FetchFunction, type FilePart, type FlexibleSchema, type IdGenerator, type ImagePart, type InferSchema, type InferToolInput, type InferToolOutput, type LazySchema, 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, asSchema, 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, jsonSchema, lazySchema, loadApiKey, loadOptionalSetting, loadSetting, mediaTypeToExtension, parseJSON, parseJsonEventStream, parseProviderOptions, postFormDataToApi, postJsonToApi, postToApi, removeUndefinedEntries, resolve, safeParseJSON, safeValidateTypes, tool, validateTypes, withUserAgentSuffix, withoutTrailingSlash, zodSchema };
|
|
964
|
+
export { type AssistantContent, type AssistantModelMessage, type DataContent, type FetchFunction, type FilePart, type FlexibleSchema, type IdGenerator, type ImagePart, type InferSchema, type InferToolInput, type InferToolOutput, type LazySchema, 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 ToolNeedsApprovalFunction, type ToolResult, type ToolResultPart, type UserContent, type UserModelMessage, VERSION, type ValidationResult, asSchema, 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, jsonSchema, lazySchema, loadApiKey, loadOptionalSetting, loadSetting, mediaTypeToExtension, parseJSON, parseJsonEventStream, parseProviderOptions, postFormDataToApi, postJsonToApi, postToApi, removeUndefinedEntries, resolve, safeParseJSON, safeValidateTypes, tool, validateTypes, withUserAgentSuffix, withoutTrailingSlash, zodSchema };
|
package/dist/index.d.ts
CHANGED
|
@@ -641,6 +641,26 @@ interface ToolCallOptions {
|
|
|
641
641
|
*/
|
|
642
642
|
experimental_context?: unknown;
|
|
643
643
|
}
|
|
644
|
+
/**
|
|
645
|
+
* Function that is called to determine if the tool needs approval before it can be executed.
|
|
646
|
+
*/
|
|
647
|
+
type ToolNeedsApprovalFunction<INPUT> = (input: INPUT, options: {
|
|
648
|
+
/**
|
|
649
|
+
* The ID of the tool call. You can use it e.g. when sending tool-call related information with stream data.
|
|
650
|
+
*/
|
|
651
|
+
toolCallId: string;
|
|
652
|
+
/**
|
|
653
|
+
* Messages that were sent to the language model to initiate the response that contained the tool call.
|
|
654
|
+
* The messages **do not** include the system prompt nor the assistant response that contained the tool call.
|
|
655
|
+
*/
|
|
656
|
+
messages: ModelMessage[];
|
|
657
|
+
/**
|
|
658
|
+
* Additional context.
|
|
659
|
+
*
|
|
660
|
+
* Experimental (can break in patch releases).
|
|
661
|
+
*/
|
|
662
|
+
experimental_context?: unknown;
|
|
663
|
+
}) => boolean | PromiseLike<boolean>;
|
|
644
664
|
type ToolExecuteFunction<INPUT, OUTPUT> = (input: INPUT, options: ToolCallOptions) => AsyncIterable<OUTPUT> | PromiseLike<OUTPUT> | OUTPUT;
|
|
645
665
|
type NeverOptional<N, T> = 0 extends 1 & N ? Partial<T> : [N] extends [never] ? Partial<Record<keyof T, undefined>> : T;
|
|
646
666
|
type ToolOutputProperties<INPUT, OUTPUT> = NeverOptional<OUTPUT, {
|
|
@@ -685,23 +705,7 @@ type Tool<INPUT extends JSONValue | unknown | never = any, OUTPUT extends JSONVa
|
|
|
685
705
|
/**
|
|
686
706
|
Whether the tool needs approval before it can be executed.
|
|
687
707
|
*/
|
|
688
|
-
needsApproval?: boolean |
|
|
689
|
-
/**
|
|
690
|
-
* The ID of the tool call. You can use it e.g. when sending tool-call related information with stream data.
|
|
691
|
-
*/
|
|
692
|
-
toolCallId: string;
|
|
693
|
-
/**
|
|
694
|
-
* Messages that were sent to the language model to initiate the response that contained the tool call.
|
|
695
|
-
* The messages **do not** include the system prompt nor the assistant response that contained the tool call.
|
|
696
|
-
*/
|
|
697
|
-
messages: ModelMessage[];
|
|
698
|
-
/**
|
|
699
|
-
* Additional context.
|
|
700
|
-
*
|
|
701
|
-
* Experimental (can break in patch releases).
|
|
702
|
-
*/
|
|
703
|
-
experimental_context?: unknown;
|
|
704
|
-
}) => boolean | PromiseLike<boolean>);
|
|
708
|
+
needsApproval?: boolean | ToolNeedsApprovalFunction<[INPUT] extends [never] ? unknown : INPUT>;
|
|
705
709
|
/**
|
|
706
710
|
* Optional function that is called when the argument streaming starts.
|
|
707
711
|
* Only called when the tool is used in a streaming context.
|
|
@@ -773,7 +777,7 @@ declare function tool<INPUT>(tool: Tool<INPUT, never>): Tool<INPUT, never>;
|
|
|
773
777
|
declare function tool<OUTPUT>(tool: Tool<never, OUTPUT>): Tool<never, OUTPUT>;
|
|
774
778
|
declare function tool(tool: Tool<never, never>): Tool<never, never>;
|
|
775
779
|
/**
|
|
776
|
-
|
|
780
|
+
* Defines a dynamic tool.
|
|
777
781
|
*/
|
|
778
782
|
declare function dynamicTool(tool: {
|
|
779
783
|
description?: string;
|
|
@@ -781,6 +785,10 @@ declare function dynamicTool(tool: {
|
|
|
781
785
|
inputSchema: FlexibleSchema<unknown>;
|
|
782
786
|
execute: ToolExecuteFunction<unknown, unknown>;
|
|
783
787
|
toModelOutput?: (output: unknown) => LanguageModelV3ToolResultPart['output'];
|
|
788
|
+
/**
|
|
789
|
+
* Whether the tool needs approval before it can be executed.
|
|
790
|
+
*/
|
|
791
|
+
needsApproval?: boolean | ToolNeedsApprovalFunction<unknown>;
|
|
784
792
|
}): Tool<unknown, unknown> & {
|
|
785
793
|
type: 'dynamic';
|
|
786
794
|
};
|
|
@@ -953,4 +961,4 @@ interface ToolResult<NAME extends string, INPUT, OUTPUT> {
|
|
|
953
961
|
dynamic?: boolean;
|
|
954
962
|
}
|
|
955
963
|
|
|
956
|
-
export { type AssistantContent, type AssistantModelMessage, type DataContent, type FetchFunction, type FilePart, type FlexibleSchema, type IdGenerator, type ImagePart, type InferSchema, type InferToolInput, type InferToolOutput, type LazySchema, 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, asSchema, 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, jsonSchema, lazySchema, loadApiKey, loadOptionalSetting, loadSetting, mediaTypeToExtension, parseJSON, parseJsonEventStream, parseProviderOptions, postFormDataToApi, postJsonToApi, postToApi, removeUndefinedEntries, resolve, safeParseJSON, safeValidateTypes, tool, validateTypes, withUserAgentSuffix, withoutTrailingSlash, zodSchema };
|
|
964
|
+
export { type AssistantContent, type AssistantModelMessage, type DataContent, type FetchFunction, type FilePart, type FlexibleSchema, type IdGenerator, type ImagePart, type InferSchema, type InferToolInput, type InferToolOutput, type LazySchema, 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 ToolNeedsApprovalFunction, type ToolResult, type ToolResultPart, type UserContent, type UserModelMessage, VERSION, type ValidationResult, asSchema, 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, jsonSchema, lazySchema, loadApiKey, loadOptionalSetting, loadSetting, mediaTypeToExtension, parseJSON, parseJsonEventStream, parseProviderOptions, postFormDataToApi, postJsonToApi, postToApi, removeUndefinedEntries, resolve, safeParseJSON, safeValidateTypes, tool, validateTypes, withUserAgentSuffix, withoutTrailingSlash, zodSchema };
|
package/dist/index.js
CHANGED
|
@@ -280,7 +280,7 @@ function withUserAgentSuffix(headers, ...userAgentSuffixParts) {
|
|
|
280
280
|
}
|
|
281
281
|
|
|
282
282
|
// src/version.ts
|
|
283
|
-
var VERSION = true ? "4.0.0-beta.
|
|
283
|
+
var VERSION = true ? "4.0.0-beta.17" : "0.0.0-test";
|
|
284
284
|
|
|
285
285
|
// src/get-from-api.ts
|
|
286
286
|
var getOriginalFetch = () => globalThis.fetch;
|