@ai-sdk/provider-utils 5.0.9 → 5.0.11

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
+ ## 5.0.11
4
+
5
+ ### Patch Changes
6
+
7
+ - cd06458: fix(ai): call `onInputStart` before `onInputAvailable` during non-streaming tool calls
8
+
9
+ ## 5.0.10
10
+
11
+ ### Patch Changes
12
+
13
+ - 31c7be8: Accept callable Standard Schema validators that do not provide JSON Schema conversion.
14
+
3
15
  ## 5.0.9
4
16
 
5
17
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -973,7 +973,11 @@ type Schema<OBJECT = unknown> = {
973
973
  declare function lazySchema<SCHEMA>(createSchema: () => Schema<SCHEMA>): LazySchema<SCHEMA>;
974
974
  type LazySchema<SCHEMA> = () => Schema<SCHEMA>;
975
975
  type ZodSchema<SCHEMA = any> = z3.Schema<SCHEMA, z3.ZodTypeDef, any> | z4.core.$ZodType<SCHEMA, any>;
976
- type StandardSchema<SCHEMA = any> = StandardSchemaV1<unknown, SCHEMA> & StandardJSONSchemaV1<unknown, SCHEMA>;
976
+ type StandardSchema<SCHEMA = any> = StandardSchemaV1<unknown, SCHEMA> & {
977
+ readonly '~standard': StandardSchemaV1.Props<unknown, SCHEMA> & {
978
+ readonly jsonSchema?: StandardJSONSchemaV1.Converter;
979
+ };
980
+ };
977
981
  type FlexibleSchema<SCHEMA = any> = Schema<SCHEMA> | LazySchema<SCHEMA> | ZodSchema<SCHEMA> | StandardSchema<SCHEMA>;
978
982
  type InferSchema<SCHEMA> = SCHEMA extends ZodSchema<infer T> ? T : SCHEMA extends StandardSchema<infer T> ? T : SCHEMA extends LazySchema<infer T> ? T : SCHEMA extends Schema<infer T> ? T : never;
979
983
  /**
@@ -1824,8 +1828,8 @@ type BaseTool<INPUT extends JSONValue | unknown | never = any, OUTPUT extends JS
1824
1828
  INPUT
1825
1829
  ] extends [never] ? unknown : INPUT, NoInfer<CONTEXT>>;
1826
1830
  /**
1827
- * Optional function that is called when the argument streaming starts.
1828
- * Only called when the tool is used in a streaming context.
1831
+ * Optional function that is called when the model starts generating the tool input.
1832
+ * In non-streaming contexts, it is called immediately before `onInputAvailable`.
1829
1833
  */
1830
1834
  onInputStart?: (options: ToolExecutionOptions<NoInfer<CONTEXT>>) => void | PromiseLike<void>;
1831
1835
  /**
package/dist/index.js CHANGED
@@ -1153,7 +1153,7 @@ function withUserAgentSuffix(headers, ...userAgentSuffixParts) {
1153
1153
  }
1154
1154
 
1155
1155
  // src/version.ts
1156
- var VERSION = true ? "5.0.9" : "0.0.0-test";
1156
+ var VERSION = true ? "5.0.11" : "0.0.0-test";
1157
1157
 
1158
1158
  // src/get-from-api.ts
1159
1159
  var getOriginalFetch = () => globalThis.fetch;
@@ -2793,11 +2793,18 @@ function asSchema(schema) {
2793
2793
  }
2794
2794
  function standardSchema(standardSchema2) {
2795
2795
  return jsonSchema(
2796
- () => addAdditionalPropertiesToJsonSchema(
2797
- standardSchema2["~standard"].jsonSchema.input({
2798
- target: "draft-07"
2799
- })
2800
- ),
2796
+ () => {
2797
+ if (!hasStandardJsonSchema(standardSchema2)) {
2798
+ throw new Error(
2799
+ `Standard schema vendor '${standardSchema2["~standard"].vendor}' does not support JSON Schema conversion.`
2800
+ );
2801
+ }
2802
+ return addAdditionalPropertiesToJsonSchema(
2803
+ standardSchema2["~standard"].jsonSchema.input({
2804
+ target: "draft-07"
2805
+ })
2806
+ );
2807
+ },
2801
2808
  {
2802
2809
  validate: async (value) => {
2803
2810
  const result = await standardSchema2["~standard"].validate(value);
@@ -2812,6 +2819,9 @@ function standardSchema(standardSchema2) {
2812
2819
  }
2813
2820
  );
2814
2821
  }
2822
+ function hasStandardJsonSchema(schema) {
2823
+ return schema["~standard"].jsonSchema != null;
2824
+ }
2815
2825
  function zod3Schema(zodSchema2, options) {
2816
2826
  var _a2;
2817
2827
  const useReferences = (_a2 = options == null ? void 0 : options.useReferences) != null ? _a2 : false;