@ai-sdk/provider-utils 4.0.0-beta.40 → 4.0.0-beta.42

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,19 @@
1
1
  # @ai-sdk/provider-utils
2
2
 
3
+ ## 4.0.0-beta.42
4
+
5
+ ### Patch Changes
6
+
7
+ - 3ed5519: chore: rename ToolCallOptions to ToolExecutionOptions
8
+
9
+ ## 4.0.0-beta.41
10
+
11
+ ### Patch Changes
12
+
13
+ - 1bd7d32: feat: tool-specific strict mode
14
+ - Updated dependencies [1bd7d32]
15
+ - @ai-sdk/provider@3.0.0-beta.23
16
+
3
17
  ## 4.0.0-beta.40
4
18
 
5
19
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -863,7 +863,7 @@ type ModelMessage = SystemModelMessage | UserModelMessage | AssistantModelMessag
863
863
  /**
864
864
  * Additional options that are sent into each tool call.
865
865
  */
866
- interface ToolCallOptions {
866
+ interface ToolExecutionOptions {
867
867
  /**
868
868
  * The ID of the tool call. You can use it e.g. when sending tool-call related information with stream data.
869
869
  */
@@ -904,7 +904,7 @@ type ToolNeedsApprovalFunction<INPUT> = (input: INPUT, options: {
904
904
  */
905
905
  experimental_context?: unknown;
906
906
  }) => boolean | PromiseLike<boolean>;
907
- type ToolExecuteFunction<INPUT, OUTPUT> = (input: INPUT, options: ToolCallOptions) => AsyncIterable<OUTPUT> | PromiseLike<OUTPUT> | OUTPUT;
907
+ type ToolExecuteFunction<INPUT, OUTPUT> = (input: INPUT, options: ToolExecutionOptions) => AsyncIterable<OUTPUT> | PromiseLike<OUTPUT> | OUTPUT;
908
908
  type NeverOptional<N, T> = 0 extends 1 & N ? Partial<T> : [N] extends [never] ? Partial<Record<keyof T, undefined>> : T;
909
909
  type ToolOutputProperties<INPUT, OUTPUT> = NeverOptional<OUTPUT, {
910
910
  /**
@@ -953,25 +953,33 @@ type Tool<INPUT extends JSONValue | unknown | never = any, OUTPUT extends JSONVa
953
953
  Whether the tool needs approval before it can be executed.
954
954
  */
955
955
  needsApproval?: boolean | ToolNeedsApprovalFunction<[INPUT] extends [never] ? unknown : INPUT>;
956
+ /**
957
+ * Strict mode setting for the tool.
958
+ *
959
+ * Providers that support strict mode will use this setting to determine
960
+ * how the input should be generated. Strict mode will always produce
961
+ * valid inputs, but it might limit what input schemas are supported.
962
+ */
963
+ strict?: boolean;
956
964
  /**
957
965
  * Optional function that is called when the argument streaming starts.
958
966
  * Only called when the tool is used in a streaming context.
959
967
  */
960
- onInputStart?: (options: ToolCallOptions) => void | PromiseLike<void>;
968
+ onInputStart?: (options: ToolExecutionOptions) => void | PromiseLike<void>;
961
969
  /**
962
970
  * Optional function that is called when an argument streaming delta is available.
963
971
  * Only called when the tool is used in a streaming context.
964
972
  */
965
973
  onInputDelta?: (options: {
966
974
  inputTextDelta: string;
967
- } & ToolCallOptions) => void | PromiseLike<void>;
975
+ } & ToolExecutionOptions) => void | PromiseLike<void>;
968
976
  /**
969
977
  * Optional function that is called when a tool call can be started,
970
978
  * even if the execute function is not provided.
971
979
  */
972
980
  onInputAvailable?: (options: {
973
981
  input: [INPUT] extends [never] ? unknown : INPUT;
974
- } & ToolCallOptions) => void | PromiseLike<void>;
982
+ } & ToolExecutionOptions) => void | PromiseLike<void>;
975
983
  } & ToolOutputProperties<INPUT, OUTPUT> & {
976
984
  /**
977
985
  Optional conversion function that maps the tool result to an output that can be used by the language model.
@@ -1135,7 +1143,7 @@ declare function withoutTrailingSlash(url: string | undefined): string | undefin
1135
1143
  declare function executeTool<INPUT, OUTPUT>({ execute, input, options, }: {
1136
1144
  execute: ToolExecuteFunction<INPUT, OUTPUT>;
1137
1145
  input: INPUT;
1138
- options: ToolCallOptions;
1146
+ options: ToolExecutionOptions;
1139
1147
  }): AsyncGenerator<{
1140
1148
  type: 'preliminary';
1141
1149
  output: OUTPUT;
@@ -1203,4 +1211,9 @@ interface ToolResult<NAME extends string, INPUT, OUTPUT> {
1203
1211
  dynamic?: boolean;
1204
1212
  }
1205
1213
 
1206
- export { type AssistantContent, type AssistantModelMessage, type DataContent, DelayedPromise, type FetchFunction, type FilePart, type FlexibleSchema, type IdGenerator, type ImagePart, type InferSchema, type InferToolInput, type InferToolOutput, type LazySchema, type MaybePromiseLike, type ModelMessage, type ParseResult, type ProviderOptions, type ProviderToolFactory, type ProviderToolFactoryWithOutputSchema, 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 ToolNameMapping, type ToolNeedsApprovalFunction, type ToolResult, type ToolResultOutput, type ToolResultPart, type UserContent, type UserModelMessage, VERSION, type ValidationResult, asSchema, combineHeaders, convertAsyncIteratorToReadableStream, convertBase64ToUint8Array, convertToBase64, convertUint8ArrayToBase64, createBinaryResponseHandler, createEventSourceResponseHandler, createIdGenerator, createJsonErrorResponseHandler, createJsonResponseHandler, createProviderToolFactory, createProviderToolFactoryWithOutputSchema, createStatusCodeErrorResponseHandler, createToolNameMapping, delay, dynamicTool, executeTool, extractResponseHeaders, generateId, getErrorMessage, getFromApi, getRuntimeEnvironmentUserAgent, injectJsonInstructionIntoMessages, isAbortError, isNonNullable, isParsableJson, isUrlSupported, jsonSchema, lazySchema, loadApiKey, loadOptionalSetting, loadSetting, mediaTypeToExtension, normalizeHeaders, parseJSON, parseJsonEventStream, parseProviderOptions, postFormDataToApi, postJsonToApi, postToApi, removeUndefinedEntries, resolve, safeParseJSON, safeValidateTypes, tool, validateTypes, withUserAgentSuffix, withoutTrailingSlash, zodSchema };
1214
+ /**
1215
+ * @deprecated Use ToolExecutionOptions instead.
1216
+ */
1217
+ type ToolCallOptions = ToolExecutionOptions;
1218
+
1219
+ export { type AssistantContent, type AssistantModelMessage, type DataContent, DelayedPromise, type FetchFunction, type FilePart, type FlexibleSchema, type IdGenerator, type ImagePart, type InferSchema, type InferToolInput, type InferToolOutput, type LazySchema, type MaybePromiseLike, type ModelMessage, type ParseResult, type ProviderOptions, type ProviderToolFactory, type ProviderToolFactoryWithOutputSchema, 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 ToolExecutionOptions, type ToolModelMessage, type ToolNameMapping, type ToolNeedsApprovalFunction, type ToolResult, type ToolResultOutput, type ToolResultPart, type UserContent, type UserModelMessage, VERSION, type ValidationResult, asSchema, combineHeaders, convertAsyncIteratorToReadableStream, convertBase64ToUint8Array, convertToBase64, convertUint8ArrayToBase64, createBinaryResponseHandler, createEventSourceResponseHandler, createIdGenerator, createJsonErrorResponseHandler, createJsonResponseHandler, createProviderToolFactory, createProviderToolFactoryWithOutputSchema, createStatusCodeErrorResponseHandler, createToolNameMapping, delay, dynamicTool, executeTool, extractResponseHeaders, generateId, getErrorMessage, getFromApi, getRuntimeEnvironmentUserAgent, injectJsonInstructionIntoMessages, isAbortError, isNonNullable, isParsableJson, isUrlSupported, jsonSchema, lazySchema, loadApiKey, loadOptionalSetting, loadSetting, mediaTypeToExtension, normalizeHeaders, parseJSON, parseJsonEventStream, parseProviderOptions, postFormDataToApi, postJsonToApi, postToApi, removeUndefinedEntries, resolve, safeParseJSON, safeValidateTypes, tool, validateTypes, withUserAgentSuffix, withoutTrailingSlash, zodSchema };
package/dist/index.d.ts CHANGED
@@ -863,7 +863,7 @@ type ModelMessage = SystemModelMessage | UserModelMessage | AssistantModelMessag
863
863
  /**
864
864
  * Additional options that are sent into each tool call.
865
865
  */
866
- interface ToolCallOptions {
866
+ interface ToolExecutionOptions {
867
867
  /**
868
868
  * The ID of the tool call. You can use it e.g. when sending tool-call related information with stream data.
869
869
  */
@@ -904,7 +904,7 @@ type ToolNeedsApprovalFunction<INPUT> = (input: INPUT, options: {
904
904
  */
905
905
  experimental_context?: unknown;
906
906
  }) => boolean | PromiseLike<boolean>;
907
- type ToolExecuteFunction<INPUT, OUTPUT> = (input: INPUT, options: ToolCallOptions) => AsyncIterable<OUTPUT> | PromiseLike<OUTPUT> | OUTPUT;
907
+ type ToolExecuteFunction<INPUT, OUTPUT> = (input: INPUT, options: ToolExecutionOptions) => AsyncIterable<OUTPUT> | PromiseLike<OUTPUT> | OUTPUT;
908
908
  type NeverOptional<N, T> = 0 extends 1 & N ? Partial<T> : [N] extends [never] ? Partial<Record<keyof T, undefined>> : T;
909
909
  type ToolOutputProperties<INPUT, OUTPUT> = NeverOptional<OUTPUT, {
910
910
  /**
@@ -953,25 +953,33 @@ type Tool<INPUT extends JSONValue | unknown | never = any, OUTPUT extends JSONVa
953
953
  Whether the tool needs approval before it can be executed.
954
954
  */
955
955
  needsApproval?: boolean | ToolNeedsApprovalFunction<[INPUT] extends [never] ? unknown : INPUT>;
956
+ /**
957
+ * Strict mode setting for the tool.
958
+ *
959
+ * Providers that support strict mode will use this setting to determine
960
+ * how the input should be generated. Strict mode will always produce
961
+ * valid inputs, but it might limit what input schemas are supported.
962
+ */
963
+ strict?: boolean;
956
964
  /**
957
965
  * Optional function that is called when the argument streaming starts.
958
966
  * Only called when the tool is used in a streaming context.
959
967
  */
960
- onInputStart?: (options: ToolCallOptions) => void | PromiseLike<void>;
968
+ onInputStart?: (options: ToolExecutionOptions) => void | PromiseLike<void>;
961
969
  /**
962
970
  * Optional function that is called when an argument streaming delta is available.
963
971
  * Only called when the tool is used in a streaming context.
964
972
  */
965
973
  onInputDelta?: (options: {
966
974
  inputTextDelta: string;
967
- } & ToolCallOptions) => void | PromiseLike<void>;
975
+ } & ToolExecutionOptions) => void | PromiseLike<void>;
968
976
  /**
969
977
  * Optional function that is called when a tool call can be started,
970
978
  * even if the execute function is not provided.
971
979
  */
972
980
  onInputAvailable?: (options: {
973
981
  input: [INPUT] extends [never] ? unknown : INPUT;
974
- } & ToolCallOptions) => void | PromiseLike<void>;
982
+ } & ToolExecutionOptions) => void | PromiseLike<void>;
975
983
  } & ToolOutputProperties<INPUT, OUTPUT> & {
976
984
  /**
977
985
  Optional conversion function that maps the tool result to an output that can be used by the language model.
@@ -1135,7 +1143,7 @@ declare function withoutTrailingSlash(url: string | undefined): string | undefin
1135
1143
  declare function executeTool<INPUT, OUTPUT>({ execute, input, options, }: {
1136
1144
  execute: ToolExecuteFunction<INPUT, OUTPUT>;
1137
1145
  input: INPUT;
1138
- options: ToolCallOptions;
1146
+ options: ToolExecutionOptions;
1139
1147
  }): AsyncGenerator<{
1140
1148
  type: 'preliminary';
1141
1149
  output: OUTPUT;
@@ -1203,4 +1211,9 @@ interface ToolResult<NAME extends string, INPUT, OUTPUT> {
1203
1211
  dynamic?: boolean;
1204
1212
  }
1205
1213
 
1206
- export { type AssistantContent, type AssistantModelMessage, type DataContent, DelayedPromise, type FetchFunction, type FilePart, type FlexibleSchema, type IdGenerator, type ImagePart, type InferSchema, type InferToolInput, type InferToolOutput, type LazySchema, type MaybePromiseLike, type ModelMessage, type ParseResult, type ProviderOptions, type ProviderToolFactory, type ProviderToolFactoryWithOutputSchema, 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 ToolNameMapping, type ToolNeedsApprovalFunction, type ToolResult, type ToolResultOutput, type ToolResultPart, type UserContent, type UserModelMessage, VERSION, type ValidationResult, asSchema, combineHeaders, convertAsyncIteratorToReadableStream, convertBase64ToUint8Array, convertToBase64, convertUint8ArrayToBase64, createBinaryResponseHandler, createEventSourceResponseHandler, createIdGenerator, createJsonErrorResponseHandler, createJsonResponseHandler, createProviderToolFactory, createProviderToolFactoryWithOutputSchema, createStatusCodeErrorResponseHandler, createToolNameMapping, delay, dynamicTool, executeTool, extractResponseHeaders, generateId, getErrorMessage, getFromApi, getRuntimeEnvironmentUserAgent, injectJsonInstructionIntoMessages, isAbortError, isNonNullable, isParsableJson, isUrlSupported, jsonSchema, lazySchema, loadApiKey, loadOptionalSetting, loadSetting, mediaTypeToExtension, normalizeHeaders, parseJSON, parseJsonEventStream, parseProviderOptions, postFormDataToApi, postJsonToApi, postToApi, removeUndefinedEntries, resolve, safeParseJSON, safeValidateTypes, tool, validateTypes, withUserAgentSuffix, withoutTrailingSlash, zodSchema };
1214
+ /**
1215
+ * @deprecated Use ToolExecutionOptions instead.
1216
+ */
1217
+ type ToolCallOptions = ToolExecutionOptions;
1218
+
1219
+ export { type AssistantContent, type AssistantModelMessage, type DataContent, DelayedPromise, type FetchFunction, type FilePart, type FlexibleSchema, type IdGenerator, type ImagePart, type InferSchema, type InferToolInput, type InferToolOutput, type LazySchema, type MaybePromiseLike, type ModelMessage, type ParseResult, type ProviderOptions, type ProviderToolFactory, type ProviderToolFactoryWithOutputSchema, 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 ToolExecutionOptions, type ToolModelMessage, type ToolNameMapping, type ToolNeedsApprovalFunction, type ToolResult, type ToolResultOutput, type ToolResultPart, type UserContent, type UserModelMessage, VERSION, type ValidationResult, asSchema, combineHeaders, convertAsyncIteratorToReadableStream, convertBase64ToUint8Array, convertToBase64, convertUint8ArrayToBase64, createBinaryResponseHandler, createEventSourceResponseHandler, createIdGenerator, createJsonErrorResponseHandler, createJsonResponseHandler, createProviderToolFactory, createProviderToolFactoryWithOutputSchema, createStatusCodeErrorResponseHandler, createToolNameMapping, delay, dynamicTool, executeTool, extractResponseHeaders, generateId, getErrorMessage, getFromApi, getRuntimeEnvironmentUserAgent, injectJsonInstructionIntoMessages, isAbortError, isNonNullable, isParsableJson, isUrlSupported, jsonSchema, lazySchema, loadApiKey, loadOptionalSetting, loadSetting, mediaTypeToExtension, normalizeHeaders, parseJSON, parseJsonEventStream, parseProviderOptions, postFormDataToApi, postJsonToApi, postToApi, removeUndefinedEntries, resolve, safeParseJSON, safeValidateTypes, tool, validateTypes, withUserAgentSuffix, withoutTrailingSlash, zodSchema };
package/dist/index.js CHANGED
@@ -378,7 +378,7 @@ function withUserAgentSuffix(headers, ...userAgentSuffixParts) {
378
378
  }
379
379
 
380
380
  // src/version.ts
381
- var VERSION = true ? "4.0.0-beta.40" : "0.0.0-test";
381
+ var VERSION = true ? "4.0.0-beta.42" : "0.0.0-test";
382
382
 
383
383
  // src/get-from-api.ts
384
384
  var getOriginalFetch = () => globalThis.fetch;