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

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,13 @@
1
1
  # @ai-sdk/provider-utils
2
2
 
3
+ ## 4.0.0-beta.40
4
+
5
+ ### Patch Changes
6
+
7
+ - 544d4e8: chore(specification): rename v3 provider defined tool to provider tool
8
+ - Updated dependencies [544d4e8]
9
+ - @ai-sdk/provider@3.0.0-beta.22
10
+
3
11
  ## 4.0.0-beta.39
4
12
 
5
13
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { LanguageModelV3FunctionTool, LanguageModelV3ProviderDefinedTool, JSONSchema7, JSONParseError, TypeValidationError, JSONValue, APICallError, LanguageModelV3Prompt, SharedV3ProviderOptions } from '@ai-sdk/provider';
1
+ import { LanguageModelV3FunctionTool, LanguageModelV3ProviderTool, JSONSchema7, JSONParseError, TypeValidationError, JSONValue, APICallError, LanguageModelV3Prompt, SharedV3ProviderOptions } from '@ai-sdk/provider';
2
2
  import { StandardSchemaV1 } from '@standard-schema/spec';
3
3
  export * from '@standard-schema/spec';
4
4
  import * as z3 from 'zod/v3';
@@ -45,7 +45,7 @@ declare function createToolNameMapping({ tools, providerToolNames, }: {
45
45
  /**
46
46
  * Tools that were passed to the language model.
47
47
  */
48
- tools: Array<LanguageModelV3FunctionTool | LanguageModelV3ProviderDefinedTool> | undefined;
48
+ tools: Array<LanguageModelV3FunctionTool | LanguageModelV3ProviderTool> | undefined;
49
49
  /**
50
50
  * Maps the provider tool ids to the provider tool names.
51
51
  */
@@ -994,7 +994,7 @@ The types of input and output are not known at development time.
994
994
  /**
995
995
  Tool with provider-defined input and output schemas.
996
996
  */
997
- type: 'provider-defined';
997
+ type: 'provider';
998
998
  /**
999
999
  The ID of the tool. Must follow the format `<provider-name>.<unique-tool-name>`.
1000
1000
  */
@@ -1037,7 +1037,7 @@ declare function dynamicTool(tool: {
1037
1037
  type: 'dynamic';
1038
1038
  };
1039
1039
 
1040
- type ProviderDefinedToolFactory<INPUT, ARGS extends object> = <OUTPUT>(options: ARGS & {
1040
+ type ProviderToolFactory<INPUT, ARGS extends object> = <OUTPUT>(options: ARGS & {
1041
1041
  execute?: ToolExecuteFunction<INPUT, OUTPUT>;
1042
1042
  needsApproval?: Tool<INPUT, OUTPUT>['needsApproval'];
1043
1043
  toModelOutput?: Tool<INPUT, OUTPUT>['toModelOutput'];
@@ -1045,11 +1045,11 @@ type ProviderDefinedToolFactory<INPUT, ARGS extends object> = <OUTPUT>(options:
1045
1045
  onInputDelta?: Tool<INPUT, OUTPUT>['onInputDelta'];
1046
1046
  onInputAvailable?: Tool<INPUT, OUTPUT>['onInputAvailable'];
1047
1047
  }) => Tool<INPUT, OUTPUT>;
1048
- declare function createProviderDefinedToolFactory<INPUT, ARGS extends object>({ id, inputSchema, }: {
1048
+ declare function createProviderToolFactory<INPUT, ARGS extends object>({ id, inputSchema, }: {
1049
1049
  id: `${string}.${string}`;
1050
1050
  inputSchema: FlexibleSchema<INPUT>;
1051
- }): ProviderDefinedToolFactory<INPUT, ARGS>;
1052
- type ProviderDefinedToolFactoryWithOutputSchema<INPUT, OUTPUT, ARGS extends object> = (options: ARGS & {
1051
+ }): ProviderToolFactory<INPUT, ARGS>;
1052
+ type ProviderToolFactoryWithOutputSchema<INPUT, OUTPUT, ARGS extends object> = (options: ARGS & {
1053
1053
  execute?: ToolExecuteFunction<INPUT, OUTPUT>;
1054
1054
  needsApproval?: Tool<INPUT, OUTPUT>['needsApproval'];
1055
1055
  toModelOutput?: Tool<INPUT, OUTPUT>['toModelOutput'];
@@ -1057,11 +1057,11 @@ type ProviderDefinedToolFactoryWithOutputSchema<INPUT, OUTPUT, ARGS extends obje
1057
1057
  onInputDelta?: Tool<INPUT, OUTPUT>['onInputDelta'];
1058
1058
  onInputAvailable?: Tool<INPUT, OUTPUT>['onInputAvailable'];
1059
1059
  }) => Tool<INPUT, OUTPUT>;
1060
- declare function createProviderDefinedToolFactoryWithOutputSchema<INPUT, OUTPUT, ARGS extends object>({ id, inputSchema, outputSchema, }: {
1060
+ declare function createProviderToolFactoryWithOutputSchema<INPUT, OUTPUT, ARGS extends object>({ id, inputSchema, outputSchema, }: {
1061
1061
  id: `${string}.${string}`;
1062
1062
  inputSchema: FlexibleSchema<INPUT>;
1063
1063
  outputSchema: FlexibleSchema<OUTPUT>;
1064
- }): ProviderDefinedToolFactoryWithOutputSchema<INPUT, OUTPUT, ARGS>;
1064
+ }): ProviderToolFactoryWithOutputSchema<INPUT, OUTPUT, ARGS>;
1065
1065
 
1066
1066
  /**
1067
1067
  * Removes entries from a record where the value is null or undefined.
@@ -1203,4 +1203,4 @@ interface ToolResult<NAME extends string, INPUT, OUTPUT> {
1203
1203
  dynamic?: boolean;
1204
1204
  }
1205
1205
 
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 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 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, createProviderDefinedToolFactory, createProviderDefinedToolFactoryWithOutputSchema, 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 };
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 };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { LanguageModelV3FunctionTool, LanguageModelV3ProviderDefinedTool, JSONSchema7, JSONParseError, TypeValidationError, JSONValue, APICallError, LanguageModelV3Prompt, SharedV3ProviderOptions } from '@ai-sdk/provider';
1
+ import { LanguageModelV3FunctionTool, LanguageModelV3ProviderTool, JSONSchema7, JSONParseError, TypeValidationError, JSONValue, APICallError, LanguageModelV3Prompt, SharedV3ProviderOptions } from '@ai-sdk/provider';
2
2
  import { StandardSchemaV1 } from '@standard-schema/spec';
3
3
  export * from '@standard-schema/spec';
4
4
  import * as z3 from 'zod/v3';
@@ -45,7 +45,7 @@ declare function createToolNameMapping({ tools, providerToolNames, }: {
45
45
  /**
46
46
  * Tools that were passed to the language model.
47
47
  */
48
- tools: Array<LanguageModelV3FunctionTool | LanguageModelV3ProviderDefinedTool> | undefined;
48
+ tools: Array<LanguageModelV3FunctionTool | LanguageModelV3ProviderTool> | undefined;
49
49
  /**
50
50
  * Maps the provider tool ids to the provider tool names.
51
51
  */
@@ -994,7 +994,7 @@ The types of input and output are not known at development time.
994
994
  /**
995
995
  Tool with provider-defined input and output schemas.
996
996
  */
997
- type: 'provider-defined';
997
+ type: 'provider';
998
998
  /**
999
999
  The ID of the tool. Must follow the format `<provider-name>.<unique-tool-name>`.
1000
1000
  */
@@ -1037,7 +1037,7 @@ declare function dynamicTool(tool: {
1037
1037
  type: 'dynamic';
1038
1038
  };
1039
1039
 
1040
- type ProviderDefinedToolFactory<INPUT, ARGS extends object> = <OUTPUT>(options: ARGS & {
1040
+ type ProviderToolFactory<INPUT, ARGS extends object> = <OUTPUT>(options: ARGS & {
1041
1041
  execute?: ToolExecuteFunction<INPUT, OUTPUT>;
1042
1042
  needsApproval?: Tool<INPUT, OUTPUT>['needsApproval'];
1043
1043
  toModelOutput?: Tool<INPUT, OUTPUT>['toModelOutput'];
@@ -1045,11 +1045,11 @@ type ProviderDefinedToolFactory<INPUT, ARGS extends object> = <OUTPUT>(options:
1045
1045
  onInputDelta?: Tool<INPUT, OUTPUT>['onInputDelta'];
1046
1046
  onInputAvailable?: Tool<INPUT, OUTPUT>['onInputAvailable'];
1047
1047
  }) => Tool<INPUT, OUTPUT>;
1048
- declare function createProviderDefinedToolFactory<INPUT, ARGS extends object>({ id, inputSchema, }: {
1048
+ declare function createProviderToolFactory<INPUT, ARGS extends object>({ id, inputSchema, }: {
1049
1049
  id: `${string}.${string}`;
1050
1050
  inputSchema: FlexibleSchema<INPUT>;
1051
- }): ProviderDefinedToolFactory<INPUT, ARGS>;
1052
- type ProviderDefinedToolFactoryWithOutputSchema<INPUT, OUTPUT, ARGS extends object> = (options: ARGS & {
1051
+ }): ProviderToolFactory<INPUT, ARGS>;
1052
+ type ProviderToolFactoryWithOutputSchema<INPUT, OUTPUT, ARGS extends object> = (options: ARGS & {
1053
1053
  execute?: ToolExecuteFunction<INPUT, OUTPUT>;
1054
1054
  needsApproval?: Tool<INPUT, OUTPUT>['needsApproval'];
1055
1055
  toModelOutput?: Tool<INPUT, OUTPUT>['toModelOutput'];
@@ -1057,11 +1057,11 @@ type ProviderDefinedToolFactoryWithOutputSchema<INPUT, OUTPUT, ARGS extends obje
1057
1057
  onInputDelta?: Tool<INPUT, OUTPUT>['onInputDelta'];
1058
1058
  onInputAvailable?: Tool<INPUT, OUTPUT>['onInputAvailable'];
1059
1059
  }) => Tool<INPUT, OUTPUT>;
1060
- declare function createProviderDefinedToolFactoryWithOutputSchema<INPUT, OUTPUT, ARGS extends object>({ id, inputSchema, outputSchema, }: {
1060
+ declare function createProviderToolFactoryWithOutputSchema<INPUT, OUTPUT, ARGS extends object>({ id, inputSchema, outputSchema, }: {
1061
1061
  id: `${string}.${string}`;
1062
1062
  inputSchema: FlexibleSchema<INPUT>;
1063
1063
  outputSchema: FlexibleSchema<OUTPUT>;
1064
- }): ProviderDefinedToolFactoryWithOutputSchema<INPUT, OUTPUT, ARGS>;
1064
+ }): ProviderToolFactoryWithOutputSchema<INPUT, OUTPUT, ARGS>;
1065
1065
 
1066
1066
  /**
1067
1067
  * Removes entries from a record where the value is null or undefined.
@@ -1203,4 +1203,4 @@ interface ToolResult<NAME extends string, INPUT, OUTPUT> {
1203
1203
  dynamic?: boolean;
1204
1204
  }
1205
1205
 
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 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 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, createProviderDefinedToolFactory, createProviderDefinedToolFactoryWithOutputSchema, 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 };
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 };
package/dist/index.js CHANGED
@@ -45,8 +45,8 @@ __export(src_exports, {
45
45
  createIdGenerator: () => createIdGenerator,
46
46
  createJsonErrorResponseHandler: () => createJsonErrorResponseHandler,
47
47
  createJsonResponseHandler: () => createJsonResponseHandler,
48
- createProviderDefinedToolFactory: () => createProviderDefinedToolFactory,
49
- createProviderDefinedToolFactoryWithOutputSchema: () => createProviderDefinedToolFactoryWithOutputSchema,
48
+ createProviderToolFactory: () => createProviderToolFactory,
49
+ createProviderToolFactoryWithOutputSchema: () => createProviderToolFactoryWithOutputSchema,
50
50
  createStatusCodeErrorResponseHandler: () => createStatusCodeErrorResponseHandler,
51
51
  createToolNameMapping: () => createToolNameMapping,
52
52
  delay: () => delay,
@@ -144,7 +144,7 @@ function createToolNameMapping({
144
144
  const customToolNameToProviderToolName = {};
145
145
  const providerToolNameToCustomToolName = {};
146
146
  for (const tool2 of tools) {
147
- if (tool2.type === "provider-defined" && tool2.id in providerToolNames) {
147
+ if (tool2.type === "provider" && tool2.id in providerToolNames) {
148
148
  const providerToolName = providerToolNames[tool2.id];
149
149
  customToolNameToProviderToolName[tool2.name] = providerToolName;
150
150
  providerToolNameToCustomToolName[providerToolName] = tool2.name;
@@ -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.39" : "0.0.0-test";
381
+ var VERSION = true ? "4.0.0-beta.40" : "0.0.0-test";
382
382
 
383
383
  // src/get-from-api.ts
384
384
  var getOriginalFetch = () => globalThis.fetch;
@@ -2250,8 +2250,8 @@ function dynamicTool(tool2) {
2250
2250
  return { ...tool2, type: "dynamic" };
2251
2251
  }
2252
2252
 
2253
- // src/provider-defined-tool-factory.ts
2254
- function createProviderDefinedToolFactory({
2253
+ // src/provider-tool-factory.ts
2254
+ function createProviderToolFactory({
2255
2255
  id,
2256
2256
  inputSchema
2257
2257
  }) {
@@ -2265,7 +2265,7 @@ function createProviderDefinedToolFactory({
2265
2265
  onInputAvailable,
2266
2266
  ...args
2267
2267
  }) => tool({
2268
- type: "provider-defined",
2268
+ type: "provider",
2269
2269
  id,
2270
2270
  args,
2271
2271
  inputSchema,
@@ -2278,7 +2278,7 @@ function createProviderDefinedToolFactory({
2278
2278
  onInputAvailable
2279
2279
  });
2280
2280
  }
2281
- function createProviderDefinedToolFactoryWithOutputSchema({
2281
+ function createProviderToolFactoryWithOutputSchema({
2282
2282
  id,
2283
2283
  inputSchema,
2284
2284
  outputSchema
@@ -2292,7 +2292,7 @@ function createProviderDefinedToolFactoryWithOutputSchema({
2292
2292
  onInputAvailable,
2293
2293
  ...args
2294
2294
  }) => tool({
2295
- type: "provider-defined",
2295
+ type: "provider",
2296
2296
  id,
2297
2297
  args,
2298
2298
  inputSchema,
@@ -2526,8 +2526,8 @@ var import_stream2 = require("eventsource-parser/stream");
2526
2526
  createIdGenerator,
2527
2527
  createJsonErrorResponseHandler,
2528
2528
  createJsonResponseHandler,
2529
- createProviderDefinedToolFactory,
2530
- createProviderDefinedToolFactoryWithOutputSchema,
2529
+ createProviderToolFactory,
2530
+ createProviderToolFactoryWithOutputSchema,
2531
2531
  createStatusCodeErrorResponseHandler,
2532
2532
  createToolNameMapping,
2533
2533
  delay,