@ai-sdk/google 2.0.104 → 2.0.106

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.
@@ -170,6 +170,11 @@ function convertJSONSchemaDefinition(jsonSchema, isRoot, referenceContext) {
170
170
  const nonNullTypes = type.filter((t) => t !== "null");
171
171
  if (nonNullTypes.length === 0) {
172
172
  result.type = "null";
173
+ } else if (nonNullTypes.length === 1) {
174
+ result.type = nonNullTypes[0];
175
+ if (hasNull) {
176
+ result.nullable = true;
177
+ }
173
178
  } else {
174
179
  result.anyOf = nonNullTypes.map((t) => ({ type: t }));
175
180
  if (hasNull) {
@@ -1986,13 +1991,13 @@ var getSafetyRatingSchema = () => z3.object({
1986
1991
  severityScore: z3.number().nullish(),
1987
1992
  blocked: z3.boolean().nullish()
1988
1993
  });
1989
- var tokenDetailsSchema = z3.array(
1994
+ var tokenDetailsSchema = () => z3.array(
1990
1995
  z3.object({
1991
1996
  modality: z3.string(),
1992
1997
  tokenCount: z3.number()
1993
1998
  })
1994
1999
  ).nullish();
1995
- var usageSchema = z3.object({
2000
+ var usageSchema = () => z3.object({
1996
2001
  cachedContentTokenCount: z3.number().nullish(),
1997
2002
  thoughtsTokenCount: z3.number().nullish(),
1998
2003
  promptTokenCount: z3.number().nullish(),
@@ -2001,8 +2006,8 @@ var usageSchema = z3.object({
2001
2006
  // https://cloud.google.com/vertex-ai/generative-ai/docs/reference/rest/v1/GenerateContentResponse#TrafficType
2002
2007
  trafficType: z3.string().nullish(),
2003
2008
  // https://ai.google.dev/api/generate-content#Modality
2004
- promptTokensDetails: tokenDetailsSchema,
2005
- candidatesTokensDetails: tokenDetailsSchema
2009
+ promptTokensDetails: tokenDetailsSchema(),
2010
+ candidatesTokensDetails: tokenDetailsSchema()
2006
2011
  });
2007
2012
  var getUrlContextMetadataSchema = () => z3.object({
2008
2013
  urlMetadata: z3.array(
@@ -2025,7 +2030,7 @@ var responseSchema = lazySchema3(
2025
2030
  urlContextMetadata: getUrlContextMetadataSchema().nullish()
2026
2031
  })
2027
2032
  ).nullish(),
2028
- usageMetadata: usageSchema.nullish(),
2033
+ usageMetadata: usageSchema().nullish(),
2029
2034
  promptFeedback: z3.object({
2030
2035
  blockReason: z3.string().nullish(),
2031
2036
  safetyRatings: z3.array(getSafetyRatingSchema()).nullish()
@@ -2047,7 +2052,7 @@ var chunkSchema = lazySchema3(
2047
2052
  urlContextMetadata: getUrlContextMetadataSchema().nullish()
2048
2053
  })
2049
2054
  ).nullish(),
2050
- usageMetadata: usageSchema.nullish(),
2055
+ usageMetadata: usageSchema().nullish(),
2051
2056
  promptFeedback: z3.object({
2052
2057
  blockReason: z3.string().nullish(),
2053
2058
  safetyRatings: z3.array(getSafetyRatingSchema()).nullish()
@@ -2093,7 +2098,7 @@ import {
2093
2098
  zodSchema as zodSchema5
2094
2099
  } from "@ai-sdk/provider-utils";
2095
2100
  import { z as z6 } from "zod/v4";
2096
- var fileSearchArgsBaseSchema = z6.object({
2101
+ var fileSearchArgsBaseSchema = () => z6.object({
2097
2102
  /** The names of the file_search_stores to retrieve from.
2098
2103
  * Example: `fileSearchStores/my-file-search-store-123`
2099
2104
  */
@@ -2110,7 +2115,7 @@ var fileSearchArgsBaseSchema = z6.object({
2110
2115
  ).optional()
2111
2116
  }).passthrough();
2112
2117
  var fileSearchArgsSchema = lazySchema5(
2113
- () => zodSchema5(fileSearchArgsBaseSchema)
2118
+ () => zodSchema5(fileSearchArgsBaseSchema())
2114
2119
  );
2115
2120
  var fileSearch = createProviderDefinedToolFactory2({
2116
2121
  id: "google.file_search",
@@ -2138,7 +2143,7 @@ import {
2138
2143
  zodSchema as zodSchema7
2139
2144
  } from "@ai-sdk/provider-utils";
2140
2145
  import { z as z8 } from "zod/v4";
2141
- var googleSearchToolArgsBaseSchema = z8.object({
2146
+ var googleSearchToolArgsBaseSchema = () => z8.object({
2142
2147
  searchTypes: z8.object({
2143
2148
  webSearch: z8.object({}).optional(),
2144
2149
  imageSearch: z8.object({}).optional()
@@ -2149,7 +2154,7 @@ var googleSearchToolArgsBaseSchema = z8.object({
2149
2154
  }).optional()
2150
2155
  }).passthrough();
2151
2156
  var googleSearchToolArgsSchema = lazySchema7(
2152
- () => zodSchema7(googleSearchToolArgsBaseSchema)
2157
+ () => zodSchema7(googleSearchToolArgsBaseSchema())
2153
2158
  );
2154
2159
  var googleSearch = createProviderDefinedToolFactory4({
2155
2160
  id: "google.google_search",