@ai-sdk/google 3.0.136 → 3.0.138

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.
@@ -237,6 +237,11 @@ function convertJSONSchemaDefinition(jsonSchema, isRoot, referenceContext) {
237
237
  const nonNullTypes = type.filter((t) => t !== "null");
238
238
  if (nonNullTypes.length === 0) {
239
239
  result.type = "null";
240
+ } else if (nonNullTypes.length === 1) {
241
+ result.type = nonNullTypes[0];
242
+ if (hasNull) {
243
+ result.nullable = true;
244
+ }
240
245
  } else {
241
246
  result.anyOf = nonNullTypes.map((t) => ({ type: t }));
242
247
  if (hasNull) {
@@ -2755,7 +2760,7 @@ var getGroundingMetadataSchema = () => import_v43.z.object({
2755
2760
  import_v43.z.object({})
2756
2761
  ]).nullish()
2757
2762
  });
2758
- var partialArgSchema = import_v43.z.object({
2763
+ var partialArgSchema = () => import_v43.z.object({
2759
2764
  jsonPath: import_v43.z.string(),
2760
2765
  stringValue: import_v43.z.string().nullish(),
2761
2766
  numberValue: import_v43.z.number().nullish(),
@@ -2772,7 +2777,7 @@ var getContentSchema = () => import_v43.z.object({
2772
2777
  id: import_v43.z.string().nullish(),
2773
2778
  name: import_v43.z.string().nullish(),
2774
2779
  args: import_v43.z.unknown().nullish(),
2775
- partialArgs: import_v43.z.array(partialArgSchema).nullish(),
2780
+ partialArgs: import_v43.z.array(partialArgSchema()).nullish(),
2776
2781
  willContinue: import_v43.z.boolean().nullish()
2777
2782
  }),
2778
2783
  thoughtSignature: import_v43.z.string().nullish()
@@ -2825,13 +2830,13 @@ var getSafetyRatingSchema = () => import_v43.z.object({
2825
2830
  severityScore: import_v43.z.number().nullish(),
2826
2831
  blocked: import_v43.z.boolean().nullish()
2827
2832
  });
2828
- var tokenDetailsSchema = import_v43.z.array(
2833
+ var tokenDetailsSchema = () => import_v43.z.array(
2829
2834
  import_v43.z.object({
2830
2835
  modality: import_v43.z.string(),
2831
2836
  tokenCount: import_v43.z.number()
2832
2837
  }).catchall(import_v43.z.json())
2833
2838
  ).nullish();
2834
- var usageSchema = import_v43.z.object({
2839
+ var usageSchema = () => import_v43.z.object({
2835
2840
  cachedContentTokenCount: import_v43.z.number().nullish(),
2836
2841
  thoughtsTokenCount: import_v43.z.number().nullish(),
2837
2842
  promptTokenCount: import_v43.z.number().nullish(),
@@ -2842,10 +2847,10 @@ var usageSchema = import_v43.z.object({
2842
2847
  trafficType: import_v43.z.string().nullish(),
2843
2848
  serviceTier: import_v43.z.string().nullish(),
2844
2849
  // https://ai.google.dev/api/generate-content#Modality
2845
- promptTokensDetails: tokenDetailsSchema,
2846
- cacheTokensDetails: tokenDetailsSchema,
2847
- candidatesTokensDetails: tokenDetailsSchema,
2848
- toolUsePromptTokensDetails: tokenDetailsSchema
2850
+ promptTokensDetails: tokenDetailsSchema(),
2851
+ cacheTokensDetails: tokenDetailsSchema(),
2852
+ candidatesTokensDetails: tokenDetailsSchema(),
2853
+ toolUsePromptTokensDetails: tokenDetailsSchema()
2849
2854
  }).catchall(import_v43.z.json());
2850
2855
  var getUrlContextMetadataSchema = () => import_v43.z.object({
2851
2856
  urlMetadata: import_v43.z.array(
@@ -2870,7 +2875,7 @@ var responseSchema = (0, import_provider_utils5.lazySchema)(
2870
2875
  urlContextMetadata: getUrlContextMetadataSchema().nullish()
2871
2876
  })
2872
2877
  ).nullish(),
2873
- usageMetadata: usageSchema.nullish(),
2878
+ usageMetadata: usageSchema().nullish(),
2874
2879
  promptFeedback: import_v43.z.object({
2875
2880
  blockReason: import_v43.z.string().nullish(),
2876
2881
  safetyRatings: import_v43.z.array(getSafetyRatingSchema()).nullish()
@@ -2893,7 +2898,7 @@ var chunkSchema = (0, import_provider_utils5.lazySchema)(
2893
2898
  urlContextMetadata: getUrlContextMetadataSchema().nullish()
2894
2899
  })
2895
2900
  ).nullish(),
2896
- usageMetadata: usageSchema.nullish(),
2901
+ usageMetadata: usageSchema().nullish(),
2897
2902
  promptFeedback: import_v43.z.object({
2898
2903
  blockReason: import_v43.z.string().nullish(),
2899
2904
  safetyRatings: import_v43.z.array(getSafetyRatingSchema()).nullish()
@@ -2931,7 +2936,7 @@ var enterpriseWebSearch = (0, import_provider_utils7.createProviderToolFactory)(
2931
2936
  // src/tool/file-search.ts
2932
2937
  var import_provider_utils8 = require("@ai-sdk/provider-utils");
2933
2938
  var import_v46 = require("zod/v4");
2934
- var fileSearchArgsBaseSchema = import_v46.z.object({
2939
+ var fileSearchArgsBaseSchema = () => import_v46.z.object({
2935
2940
  /** The names of the file_search_stores to retrieve from.
2936
2941
  * Example: `fileSearchStores/my-file-search-store-123`
2937
2942
  */
@@ -2948,7 +2953,7 @@ var fileSearchArgsBaseSchema = import_v46.z.object({
2948
2953
  ).optional()
2949
2954
  }).passthrough();
2950
2955
  var fileSearchArgsSchema = (0, import_provider_utils8.lazySchema)(
2951
- () => (0, import_provider_utils8.zodSchema)(fileSearchArgsBaseSchema)
2956
+ () => (0, import_provider_utils8.zodSchema)(fileSearchArgsBaseSchema())
2952
2957
  );
2953
2958
  var fileSearch = (0, import_provider_utils8.createProviderToolFactory)({
2954
2959
  id: "google.file_search",
@@ -2966,7 +2971,7 @@ var googleMaps = (0, import_provider_utils9.createProviderToolFactory)({
2966
2971
  // src/tool/google-search.ts
2967
2972
  var import_provider_utils10 = require("@ai-sdk/provider-utils");
2968
2973
  var import_v48 = require("zod/v4");
2969
- var googleSearchToolArgsBaseSchema = import_v48.z.object({
2974
+ var googleSearchToolArgsBaseSchema = () => import_v48.z.object({
2970
2975
  searchTypes: import_v48.z.object({
2971
2976
  webSearch: import_v48.z.object({}).optional(),
2972
2977
  imageSearch: import_v48.z.object({}).optional()
@@ -2977,7 +2982,7 @@ var googleSearchToolArgsBaseSchema = import_v48.z.object({
2977
2982
  }).optional()
2978
2983
  }).passthrough();
2979
2984
  var googleSearchToolArgsSchema = (0, import_provider_utils10.lazySchema)(
2980
- () => (0, import_provider_utils10.zodSchema)(googleSearchToolArgsBaseSchema)
2985
+ () => (0, import_provider_utils10.zodSchema)(googleSearchToolArgsBaseSchema())
2981
2986
  );
2982
2987
  var googleSearch = (0, import_provider_utils10.createProviderToolFactory)(
2983
2988
  {