@ai-sdk/provider-utils 4.0.0-beta.39 → 4.0.0-beta.41
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 +16 -0
- package/dist/index.d.mts +18 -10
- package/dist/index.d.ts +18 -10
- package/dist/index.js +11 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +9 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @ai-sdk/provider-utils
|
|
2
2
|
|
|
3
|
+
## 4.0.0-beta.41
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 1bd7d32: feat: tool-specific strict mode
|
|
8
|
+
- Updated dependencies [1bd7d32]
|
|
9
|
+
- @ai-sdk/provider@3.0.0-beta.23
|
|
10
|
+
|
|
11
|
+
## 4.0.0-beta.40
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- 544d4e8: chore(specification): rename v3 provider defined tool to provider tool
|
|
16
|
+
- Updated dependencies [544d4e8]
|
|
17
|
+
- @ai-sdk/provider@3.0.0-beta.22
|
|
18
|
+
|
|
3
19
|
## 4.0.0-beta.39
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LanguageModelV3FunctionTool,
|
|
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 |
|
|
48
|
+
tools: Array<LanguageModelV3FunctionTool | LanguageModelV3ProviderTool> | undefined;
|
|
49
49
|
/**
|
|
50
50
|
* Maps the provider tool ids to the provider tool names.
|
|
51
51
|
*/
|
|
@@ -953,6 +953,14 @@ 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.
|
|
@@ -994,7 +1002,7 @@ The types of input and output are not known at development time.
|
|
|
994
1002
|
/**
|
|
995
1003
|
Tool with provider-defined input and output schemas.
|
|
996
1004
|
*/
|
|
997
|
-
type: 'provider
|
|
1005
|
+
type: 'provider';
|
|
998
1006
|
/**
|
|
999
1007
|
The ID of the tool. Must follow the format `<provider-name>.<unique-tool-name>`.
|
|
1000
1008
|
*/
|
|
@@ -1037,7 +1045,7 @@ declare function dynamicTool(tool: {
|
|
|
1037
1045
|
type: 'dynamic';
|
|
1038
1046
|
};
|
|
1039
1047
|
|
|
1040
|
-
type
|
|
1048
|
+
type ProviderToolFactory<INPUT, ARGS extends object> = <OUTPUT>(options: ARGS & {
|
|
1041
1049
|
execute?: ToolExecuteFunction<INPUT, OUTPUT>;
|
|
1042
1050
|
needsApproval?: Tool<INPUT, OUTPUT>['needsApproval'];
|
|
1043
1051
|
toModelOutput?: Tool<INPUT, OUTPUT>['toModelOutput'];
|
|
@@ -1045,11 +1053,11 @@ type ProviderDefinedToolFactory<INPUT, ARGS extends object> = <OUTPUT>(options:
|
|
|
1045
1053
|
onInputDelta?: Tool<INPUT, OUTPUT>['onInputDelta'];
|
|
1046
1054
|
onInputAvailable?: Tool<INPUT, OUTPUT>['onInputAvailable'];
|
|
1047
1055
|
}) => Tool<INPUT, OUTPUT>;
|
|
1048
|
-
declare function
|
|
1056
|
+
declare function createProviderToolFactory<INPUT, ARGS extends object>({ id, inputSchema, }: {
|
|
1049
1057
|
id: `${string}.${string}`;
|
|
1050
1058
|
inputSchema: FlexibleSchema<INPUT>;
|
|
1051
|
-
}):
|
|
1052
|
-
type
|
|
1059
|
+
}): ProviderToolFactory<INPUT, ARGS>;
|
|
1060
|
+
type ProviderToolFactoryWithOutputSchema<INPUT, OUTPUT, ARGS extends object> = (options: ARGS & {
|
|
1053
1061
|
execute?: ToolExecuteFunction<INPUT, OUTPUT>;
|
|
1054
1062
|
needsApproval?: Tool<INPUT, OUTPUT>['needsApproval'];
|
|
1055
1063
|
toModelOutput?: Tool<INPUT, OUTPUT>['toModelOutput'];
|
|
@@ -1057,11 +1065,11 @@ type ProviderDefinedToolFactoryWithOutputSchema<INPUT, OUTPUT, ARGS extends obje
|
|
|
1057
1065
|
onInputDelta?: Tool<INPUT, OUTPUT>['onInputDelta'];
|
|
1058
1066
|
onInputAvailable?: Tool<INPUT, OUTPUT>['onInputAvailable'];
|
|
1059
1067
|
}) => Tool<INPUT, OUTPUT>;
|
|
1060
|
-
declare function
|
|
1068
|
+
declare function createProviderToolFactoryWithOutputSchema<INPUT, OUTPUT, ARGS extends object>({ id, inputSchema, outputSchema, }: {
|
|
1061
1069
|
id: `${string}.${string}`;
|
|
1062
1070
|
inputSchema: FlexibleSchema<INPUT>;
|
|
1063
1071
|
outputSchema: FlexibleSchema<OUTPUT>;
|
|
1064
|
-
}):
|
|
1072
|
+
}): ProviderToolFactoryWithOutputSchema<INPUT, OUTPUT, ARGS>;
|
|
1065
1073
|
|
|
1066
1074
|
/**
|
|
1067
1075
|
* Removes entries from a record where the value is null or undefined.
|
|
@@ -1203,4 +1211,4 @@ 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
|
|
1214
|
+
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,
|
|
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 |
|
|
48
|
+
tools: Array<LanguageModelV3FunctionTool | LanguageModelV3ProviderTool> | undefined;
|
|
49
49
|
/**
|
|
50
50
|
* Maps the provider tool ids to the provider tool names.
|
|
51
51
|
*/
|
|
@@ -953,6 +953,14 @@ 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.
|
|
@@ -994,7 +1002,7 @@ The types of input and output are not known at development time.
|
|
|
994
1002
|
/**
|
|
995
1003
|
Tool with provider-defined input and output schemas.
|
|
996
1004
|
*/
|
|
997
|
-
type: 'provider
|
|
1005
|
+
type: 'provider';
|
|
998
1006
|
/**
|
|
999
1007
|
The ID of the tool. Must follow the format `<provider-name>.<unique-tool-name>`.
|
|
1000
1008
|
*/
|
|
@@ -1037,7 +1045,7 @@ declare function dynamicTool(tool: {
|
|
|
1037
1045
|
type: 'dynamic';
|
|
1038
1046
|
};
|
|
1039
1047
|
|
|
1040
|
-
type
|
|
1048
|
+
type ProviderToolFactory<INPUT, ARGS extends object> = <OUTPUT>(options: ARGS & {
|
|
1041
1049
|
execute?: ToolExecuteFunction<INPUT, OUTPUT>;
|
|
1042
1050
|
needsApproval?: Tool<INPUT, OUTPUT>['needsApproval'];
|
|
1043
1051
|
toModelOutput?: Tool<INPUT, OUTPUT>['toModelOutput'];
|
|
@@ -1045,11 +1053,11 @@ type ProviderDefinedToolFactory<INPUT, ARGS extends object> = <OUTPUT>(options:
|
|
|
1045
1053
|
onInputDelta?: Tool<INPUT, OUTPUT>['onInputDelta'];
|
|
1046
1054
|
onInputAvailable?: Tool<INPUT, OUTPUT>['onInputAvailable'];
|
|
1047
1055
|
}) => Tool<INPUT, OUTPUT>;
|
|
1048
|
-
declare function
|
|
1056
|
+
declare function createProviderToolFactory<INPUT, ARGS extends object>({ id, inputSchema, }: {
|
|
1049
1057
|
id: `${string}.${string}`;
|
|
1050
1058
|
inputSchema: FlexibleSchema<INPUT>;
|
|
1051
|
-
}):
|
|
1052
|
-
type
|
|
1059
|
+
}): ProviderToolFactory<INPUT, ARGS>;
|
|
1060
|
+
type ProviderToolFactoryWithOutputSchema<INPUT, OUTPUT, ARGS extends object> = (options: ARGS & {
|
|
1053
1061
|
execute?: ToolExecuteFunction<INPUT, OUTPUT>;
|
|
1054
1062
|
needsApproval?: Tool<INPUT, OUTPUT>['needsApproval'];
|
|
1055
1063
|
toModelOutput?: Tool<INPUT, OUTPUT>['toModelOutput'];
|
|
@@ -1057,11 +1065,11 @@ type ProviderDefinedToolFactoryWithOutputSchema<INPUT, OUTPUT, ARGS extends obje
|
|
|
1057
1065
|
onInputDelta?: Tool<INPUT, OUTPUT>['onInputDelta'];
|
|
1058
1066
|
onInputAvailable?: Tool<INPUT, OUTPUT>['onInputAvailable'];
|
|
1059
1067
|
}) => Tool<INPUT, OUTPUT>;
|
|
1060
|
-
declare function
|
|
1068
|
+
declare function createProviderToolFactoryWithOutputSchema<INPUT, OUTPUT, ARGS extends object>({ id, inputSchema, outputSchema, }: {
|
|
1061
1069
|
id: `${string}.${string}`;
|
|
1062
1070
|
inputSchema: FlexibleSchema<INPUT>;
|
|
1063
1071
|
outputSchema: FlexibleSchema<OUTPUT>;
|
|
1064
|
-
}):
|
|
1072
|
+
}): ProviderToolFactoryWithOutputSchema<INPUT, OUTPUT, ARGS>;
|
|
1065
1073
|
|
|
1066
1074
|
/**
|
|
1067
1075
|
* Removes entries from a record where the value is null or undefined.
|
|
@@ -1203,4 +1211,4 @@ 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
|
|
1214
|
+
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
|
-
|
|
49
|
-
|
|
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
|
|
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.
|
|
381
|
+
var VERSION = true ? "4.0.0-beta.41" : "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-
|
|
2254
|
-
function
|
|
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
|
|
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
|
|
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
|
|
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
|
-
|
|
2530
|
-
|
|
2529
|
+
createProviderToolFactory,
|
|
2530
|
+
createProviderToolFactoryWithOutputSchema,
|
|
2531
2531
|
createStatusCodeErrorResponseHandler,
|
|
2532
2532
|
createToolNameMapping,
|
|
2533
2533
|
delay,
|