@ai-sdk/provider-utils 4.0.0-beta.45 → 4.0.0-beta.47

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,17 @@
1
1
  # @ai-sdk/provider-utils
2
2
 
3
+ ## 4.0.0-beta.47
4
+
5
+ ### Patch Changes
6
+
7
+ - e9e157f: fix: generate zod4 json schema from input schema
8
+
9
+ ## 4.0.0-beta.46
10
+
11
+ ### Patch Changes
12
+
13
+ - 81e29ab: chore: update docs
14
+
3
15
  ## 4.0.0-beta.45
4
16
 
5
17
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -878,7 +878,14 @@ interface ToolExecutionOptions {
878
878
  */
879
879
  abortSignal?: AbortSignal;
880
880
  /**
881
- * Additional context.
881
+ * User-defined context.
882
+ *
883
+ * Treat the context object as immutable inside tools.
884
+ * Mutating the context object can lead to race conditions and unexpected results
885
+ * when tools are called in parallel.
886
+ *
887
+ * If you need to mutate the context, analyze the tool calls and results
888
+ * in `prepareStep` and update it there.
882
889
  *
883
890
  * Experimental (can break in patch releases).
884
891
  */
package/dist/index.d.ts CHANGED
@@ -878,7 +878,14 @@ interface ToolExecutionOptions {
878
878
  */
879
879
  abortSignal?: AbortSignal;
880
880
  /**
881
- * Additional context.
881
+ * User-defined context.
882
+ *
883
+ * Treat the context object as immutable inside tools.
884
+ * Mutating the context object can lead to race conditions and unexpected results
885
+ * when tools are called in parallel.
886
+ *
887
+ * If you need to mutate the context, analyze the tool calls and results
888
+ * in `prepareStep` and update it there.
882
889
  *
883
890
  * Experimental (can break in patch releases).
884
891
  */
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.45" : "0.0.0-test";
381
+ var VERSION = true ? "4.0.0-beta.47" : "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
- () => z4.toJSONSchema(zodSchema2, {
1981
- target: "draft-7",
1982
- io: "output",
1983
- reused: useReferences ? "ref" : "inline"
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);