@ai-sdk/provider-utils 4.0.0-beta.46 → 4.0.0-beta.48
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 +12 -0
- package/dist/index.d.mts +15 -6
- package/dist/index.d.ts +15 -6
- package/dist/index.js +35 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +35 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @ai-sdk/provider-utils
|
|
2
2
|
|
|
3
|
+
## 4.0.0-beta.48
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 960ec8f: chore: change argument of toModelOutput to parameter object
|
|
8
|
+
|
|
9
|
+
## 4.0.0-beta.47
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- e9e157f: fix: generate zod4 json schema from input schema
|
|
14
|
+
|
|
3
15
|
## 4.0.0-beta.46
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -998,11 +998,13 @@ type Tool<INPUT extends JSONValue | unknown | never = any, OUTPUT extends JSONVa
|
|
|
998
998
|
} & ToolExecutionOptions) => void | PromiseLike<void>;
|
|
999
999
|
} & ToolOutputProperties<INPUT, OUTPUT> & {
|
|
1000
1000
|
/**
|
|
1001
|
-
Optional conversion function that maps the tool result to an output that can be used by the language model.
|
|
1002
|
-
|
|
1003
|
-
If not provided, the tool result will be sent as a JSON object.
|
|
1004
|
-
|
|
1005
|
-
toModelOutput?: (
|
|
1001
|
+
* Optional conversion function that maps the tool result to an output that can be used by the language model.
|
|
1002
|
+
*
|
|
1003
|
+
* If not provided, the tool result will be sent as a JSON object.
|
|
1004
|
+
*/
|
|
1005
|
+
toModelOutput?: (options: {
|
|
1006
|
+
output: 0 extends 1 & OUTPUT ? any : [OUTPUT] extends [never] ? any : NoInfer<OUTPUT>;
|
|
1007
|
+
}) => ToolResultOutput;
|
|
1006
1008
|
} & ({
|
|
1007
1009
|
/**
|
|
1008
1010
|
Tool with user-defined input and output schemas.
|
|
@@ -1052,7 +1054,14 @@ declare function dynamicTool(tool: {
|
|
|
1052
1054
|
providerOptions?: ProviderOptions;
|
|
1053
1055
|
inputSchema: FlexibleSchema<unknown>;
|
|
1054
1056
|
execute: ToolExecuteFunction<unknown, unknown>;
|
|
1055
|
-
|
|
1057
|
+
/**
|
|
1058
|
+
* Optional conversion function that maps the tool result to an output that can be used by the language model.
|
|
1059
|
+
*
|
|
1060
|
+
* If not provided, the tool result will be sent as a JSON object.
|
|
1061
|
+
*/
|
|
1062
|
+
toModelOutput?: (options: {
|
|
1063
|
+
output: unknown;
|
|
1064
|
+
}) => ToolResultOutput;
|
|
1056
1065
|
/**
|
|
1057
1066
|
* Whether the tool needs approval before it can be executed.
|
|
1058
1067
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -998,11 +998,13 @@ type Tool<INPUT extends JSONValue | unknown | never = any, OUTPUT extends JSONVa
|
|
|
998
998
|
} & ToolExecutionOptions) => void | PromiseLike<void>;
|
|
999
999
|
} & ToolOutputProperties<INPUT, OUTPUT> & {
|
|
1000
1000
|
/**
|
|
1001
|
-
Optional conversion function that maps the tool result to an output that can be used by the language model.
|
|
1002
|
-
|
|
1003
|
-
If not provided, the tool result will be sent as a JSON object.
|
|
1004
|
-
|
|
1005
|
-
toModelOutput?: (
|
|
1001
|
+
* Optional conversion function that maps the tool result to an output that can be used by the language model.
|
|
1002
|
+
*
|
|
1003
|
+
* If not provided, the tool result will be sent as a JSON object.
|
|
1004
|
+
*/
|
|
1005
|
+
toModelOutput?: (options: {
|
|
1006
|
+
output: 0 extends 1 & OUTPUT ? any : [OUTPUT] extends [never] ? any : NoInfer<OUTPUT>;
|
|
1007
|
+
}) => ToolResultOutput;
|
|
1006
1008
|
} & ({
|
|
1007
1009
|
/**
|
|
1008
1010
|
Tool with user-defined input and output schemas.
|
|
@@ -1052,7 +1054,14 @@ declare function dynamicTool(tool: {
|
|
|
1052
1054
|
providerOptions?: ProviderOptions;
|
|
1053
1055
|
inputSchema: FlexibleSchema<unknown>;
|
|
1054
1056
|
execute: ToolExecuteFunction<unknown, unknown>;
|
|
1055
|
-
|
|
1057
|
+
/**
|
|
1058
|
+
* Optional conversion function that maps the tool result to an output that can be used by the language model.
|
|
1059
|
+
*
|
|
1060
|
+
* If not provided, the tool result will be sent as a JSON object.
|
|
1061
|
+
*/
|
|
1062
|
+
toModelOutput?: (options: {
|
|
1063
|
+
output: unknown;
|
|
1064
|
+
}) => ToolResultOutput;
|
|
1056
1065
|
/**
|
|
1057
1066
|
* Whether the tool needs approval before it can be executed.
|
|
1058
1067
|
*/
|
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.
|
|
381
|
+
var VERSION = true ? "4.0.0-beta.48" : "0.0.0-test";
|
|
382
382
|
|
|
383
383
|
// src/get-from-api.ts
|
|
384
384
|
var getOriginalFetch = () => globalThis.fetch;
|
|
@@ -668,6 +668,33 @@ var import_provider7 = require("@ai-sdk/provider");
|
|
|
668
668
|
var import_provider6 = require("@ai-sdk/provider");
|
|
669
669
|
var z4 = __toESM(require("zod/v4"));
|
|
670
670
|
|
|
671
|
+
// src/add-additional-properties-to-json-schema.ts
|
|
672
|
+
function addAdditionalPropertiesToJsonSchema(jsonSchema2) {
|
|
673
|
+
if (jsonSchema2.type === "object") {
|
|
674
|
+
jsonSchema2.additionalProperties = false;
|
|
675
|
+
const properties = jsonSchema2.properties;
|
|
676
|
+
if (properties != null) {
|
|
677
|
+
for (const property in properties) {
|
|
678
|
+
properties[property] = addAdditionalPropertiesToJsonSchema(
|
|
679
|
+
properties[property]
|
|
680
|
+
);
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
if (jsonSchema2.type === "array" && jsonSchema2.items != null) {
|
|
685
|
+
if (Array.isArray(jsonSchema2.items)) {
|
|
686
|
+
jsonSchema2.items = jsonSchema2.items.map(
|
|
687
|
+
(item) => addAdditionalPropertiesToJsonSchema(item)
|
|
688
|
+
);
|
|
689
|
+
} else {
|
|
690
|
+
jsonSchema2.items = addAdditionalPropertiesToJsonSchema(
|
|
691
|
+
jsonSchema2.items
|
|
692
|
+
);
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
return jsonSchema2;
|
|
696
|
+
}
|
|
697
|
+
|
|
671
698
|
// src/to-json-schema/arktype-to-json-schema.ts
|
|
672
699
|
var arktypeToJsonSchema = (schema) => () => {
|
|
673
700
|
return schema.toJsonSchema();
|
|
@@ -1977,11 +2004,13 @@ function zod4Schema(zodSchema2, options) {
|
|
|
1977
2004
|
const useReferences = (_a = options == null ? void 0 : options.useReferences) != null ? _a : false;
|
|
1978
2005
|
return jsonSchema(
|
|
1979
2006
|
// defer json schema creation to avoid unnecessary computation when only validation is needed
|
|
1980
|
-
() =>
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
2007
|
+
() => addAdditionalPropertiesToJsonSchema(
|
|
2008
|
+
z4.toJSONSchema(zodSchema2, {
|
|
2009
|
+
target: "draft-7",
|
|
2010
|
+
io: "input",
|
|
2011
|
+
reused: useReferences ? "ref" : "inline"
|
|
2012
|
+
})
|
|
2013
|
+
),
|
|
1985
2014
|
{
|
|
1986
2015
|
validate: async (value) => {
|
|
1987
2016
|
const result = await z4.safeParseAsync(zodSchema2, value);
|