@ai-sdk/google 2.0.19 → 2.0.20

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.
@@ -1,9 +1,7 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
2
  var __defProp = Object.defineProperty;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
6
  var __export = (target, all) => {
9
7
  for (var name in all)
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
17
15
  }
18
16
  return to;
19
17
  };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
19
 
30
20
  // src/internal/index.ts
@@ -39,7 +29,7 @@ module.exports = __toCommonJS(internal_exports);
39
29
 
40
30
  // src/google-generative-ai-language-model.ts
41
31
  var import_provider_utils4 = require("@ai-sdk/provider-utils");
42
- var z3 = __toESM(require("zod/v4"));
32
+ var import_v43 = require("zod/v4");
43
33
 
44
34
  // src/convert-json-schema-to-openapi-schema.ts
45
35
  function convertJSONSchemaToOpenAPISchema(jsonSchema) {
@@ -312,14 +302,14 @@ function getModelPath(modelId) {
312
302
 
313
303
  // src/google-error.ts
314
304
  var import_provider_utils2 = require("@ai-sdk/provider-utils");
315
- var z = __toESM(require("zod/v4"));
305
+ var import_v4 = require("zod/v4");
316
306
  var googleErrorDataSchema = (0, import_provider_utils2.lazySchema)(
317
307
  () => (0, import_provider_utils2.zodSchema)(
318
- z.object({
319
- error: z.object({
320
- code: z.number().nullable(),
321
- message: z.string(),
322
- status: z.string()
308
+ import_v4.z.object({
309
+ error: import_v4.z.object({
310
+ code: import_v4.z.number().nullable(),
311
+ message: import_v4.z.string(),
312
+ status: import_v4.z.string()
323
313
  })
324
314
  })
325
315
  )
@@ -331,21 +321,21 @@ var googleFailedResponseHandler = (0, import_provider_utils2.createJsonErrorResp
331
321
 
332
322
  // src/google-generative-ai-options.ts
333
323
  var import_provider_utils3 = require("@ai-sdk/provider-utils");
334
- var z2 = __toESM(require("zod/v4"));
324
+ var import_v42 = require("zod/v4");
335
325
  var googleGenerativeAIProviderOptions = (0, import_provider_utils3.lazySchema)(
336
326
  () => (0, import_provider_utils3.zodSchema)(
337
- z2.object({
338
- responseModalities: z2.array(z2.enum(["TEXT", "IMAGE"])).optional(),
339
- thinkingConfig: z2.object({
340
- thinkingBudget: z2.number().optional(),
341
- includeThoughts: z2.boolean().optional()
327
+ import_v42.z.object({
328
+ responseModalities: import_v42.z.array(import_v42.z.enum(["TEXT", "IMAGE"])).optional(),
329
+ thinkingConfig: import_v42.z.object({
330
+ thinkingBudget: import_v42.z.number().optional(),
331
+ includeThoughts: import_v42.z.boolean().optional()
342
332
  }).optional(),
343
333
  /**
344
334
  * Optional.
345
335
  * The name of the cached content used as context to serve the prediction.
346
336
  * Format: cachedContents/{cachedContent}
347
337
  */
348
- cachedContent: z2.string().optional(),
338
+ cachedContent: import_v42.z.string().optional(),
349
339
  /**
350
340
  * Optional. Enable structured output. Default is true.
351
341
  *
@@ -354,13 +344,13 @@ var googleGenerativeAIProviderOptions = (0, import_provider_utils3.lazySchema)(
354
344
  * Google Generative AI uses. You can use this to disable
355
345
  * structured outputs if you need to.
356
346
  */
357
- structuredOutputs: z2.boolean().optional(),
347
+ structuredOutputs: import_v42.z.boolean().optional(),
358
348
  /**
359
349
  * Optional. A list of unique safety settings for blocking unsafe content.
360
350
  */
361
- safetySettings: z2.array(
362
- z2.object({
363
- category: z2.enum([
351
+ safetySettings: import_v42.z.array(
352
+ import_v42.z.object({
353
+ category: import_v42.z.enum([
364
354
  "HARM_CATEGORY_UNSPECIFIED",
365
355
  "HARM_CATEGORY_HATE_SPEECH",
366
356
  "HARM_CATEGORY_DANGEROUS_CONTENT",
@@ -368,7 +358,7 @@ var googleGenerativeAIProviderOptions = (0, import_provider_utils3.lazySchema)(
368
358
  "HARM_CATEGORY_SEXUALLY_EXPLICIT",
369
359
  "HARM_CATEGORY_CIVIC_INTEGRITY"
370
360
  ]),
371
- threshold: z2.enum([
361
+ threshold: import_v42.z.enum([
372
362
  "HARM_BLOCK_THRESHOLD_UNSPECIFIED",
373
363
  "BLOCK_LOW_AND_ABOVE",
374
364
  "BLOCK_MEDIUM_AND_ABOVE",
@@ -378,7 +368,7 @@ var googleGenerativeAIProviderOptions = (0, import_provider_utils3.lazySchema)(
378
368
  ])
379
369
  })
380
370
  ).optional(),
381
- threshold: z2.enum([
371
+ threshold: import_v42.z.enum([
382
372
  "HARM_BLOCK_THRESHOLD_UNSPECIFIED",
383
373
  "BLOCK_LOW_AND_ABOVE",
384
374
  "BLOCK_MEDIUM_AND_ABOVE",
@@ -391,19 +381,19 @@ var googleGenerativeAIProviderOptions = (0, import_provider_utils3.lazySchema)(
391
381
  *
392
382
  * https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/audio-understanding
393
383
  */
394
- audioTimestamp: z2.boolean().optional(),
384
+ audioTimestamp: import_v42.z.boolean().optional(),
395
385
  /**
396
386
  * Optional. Defines labels used in billing reports. Available on Vertex AI only.
397
387
  *
398
388
  * https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/add-labels-to-api-calls
399
389
  */
400
- labels: z2.record(z2.string(), z2.string()).optional(),
390
+ labels: import_v42.z.record(import_v42.z.string(), import_v42.z.string()).optional(),
401
391
  /**
402
392
  * Optional. If specified, the media resolution specified will be used.
403
393
  *
404
394
  * https://ai.google.dev/api/generate-content#MediaResolution
405
395
  */
406
- mediaResolution: z2.enum([
396
+ mediaResolution: import_v42.z.enum([
407
397
  "MEDIA_RESOLUTION_UNSPECIFIED",
408
398
  "MEDIA_RESOLUTION_LOW",
409
399
  "MEDIA_RESOLUTION_MEDIUM",
@@ -1074,129 +1064,129 @@ function extractSources({
1074
1064
  title: chunk.web.title
1075
1065
  }));
1076
1066
  }
1077
- var getGroundingMetadataSchema = () => z3.object({
1078
- webSearchQueries: z3.array(z3.string()).nullish(),
1079
- retrievalQueries: z3.array(z3.string()).nullish(),
1080
- searchEntryPoint: z3.object({ renderedContent: z3.string() }).nullish(),
1081
- groundingChunks: z3.array(
1082
- z3.object({
1083
- web: z3.object({ uri: z3.string(), title: z3.string() }).nullish(),
1084
- retrievedContext: z3.object({ uri: z3.string(), title: z3.string() }).nullish()
1067
+ var getGroundingMetadataSchema = () => import_v43.z.object({
1068
+ webSearchQueries: import_v43.z.array(import_v43.z.string()).nullish(),
1069
+ retrievalQueries: import_v43.z.array(import_v43.z.string()).nullish(),
1070
+ searchEntryPoint: import_v43.z.object({ renderedContent: import_v43.z.string() }).nullish(),
1071
+ groundingChunks: import_v43.z.array(
1072
+ import_v43.z.object({
1073
+ web: import_v43.z.object({ uri: import_v43.z.string(), title: import_v43.z.string() }).nullish(),
1074
+ retrievedContext: import_v43.z.object({ uri: import_v43.z.string(), title: import_v43.z.string() }).nullish()
1085
1075
  })
1086
1076
  ).nullish(),
1087
- groundingSupports: z3.array(
1088
- z3.object({
1089
- segment: z3.object({
1090
- startIndex: z3.number().nullish(),
1091
- endIndex: z3.number().nullish(),
1092
- text: z3.string().nullish()
1077
+ groundingSupports: import_v43.z.array(
1078
+ import_v43.z.object({
1079
+ segment: import_v43.z.object({
1080
+ startIndex: import_v43.z.number().nullish(),
1081
+ endIndex: import_v43.z.number().nullish(),
1082
+ text: import_v43.z.string().nullish()
1093
1083
  }),
1094
- segment_text: z3.string().nullish(),
1095
- groundingChunkIndices: z3.array(z3.number()).nullish(),
1096
- supportChunkIndices: z3.array(z3.number()).nullish(),
1097
- confidenceScores: z3.array(z3.number()).nullish(),
1098
- confidenceScore: z3.array(z3.number()).nullish()
1084
+ segment_text: import_v43.z.string().nullish(),
1085
+ groundingChunkIndices: import_v43.z.array(import_v43.z.number()).nullish(),
1086
+ supportChunkIndices: import_v43.z.array(import_v43.z.number()).nullish(),
1087
+ confidenceScores: import_v43.z.array(import_v43.z.number()).nullish(),
1088
+ confidenceScore: import_v43.z.array(import_v43.z.number()).nullish()
1099
1089
  })
1100
1090
  ).nullish(),
1101
- retrievalMetadata: z3.union([
1102
- z3.object({
1103
- webDynamicRetrievalScore: z3.number()
1091
+ retrievalMetadata: import_v43.z.union([
1092
+ import_v43.z.object({
1093
+ webDynamicRetrievalScore: import_v43.z.number()
1104
1094
  }),
1105
- z3.object({})
1095
+ import_v43.z.object({})
1106
1096
  ]).nullish()
1107
1097
  });
1108
- var getContentSchema = () => z3.object({
1109
- parts: z3.array(
1110
- z3.union([
1098
+ var getContentSchema = () => import_v43.z.object({
1099
+ parts: import_v43.z.array(
1100
+ import_v43.z.union([
1111
1101
  // note: order matters since text can be fully empty
1112
- z3.object({
1113
- functionCall: z3.object({
1114
- name: z3.string(),
1115
- args: z3.unknown()
1102
+ import_v43.z.object({
1103
+ functionCall: import_v43.z.object({
1104
+ name: import_v43.z.string(),
1105
+ args: import_v43.z.unknown()
1116
1106
  }),
1117
- thoughtSignature: z3.string().nullish()
1107
+ thoughtSignature: import_v43.z.string().nullish()
1118
1108
  }),
1119
- z3.object({
1120
- inlineData: z3.object({
1121
- mimeType: z3.string(),
1122
- data: z3.string()
1109
+ import_v43.z.object({
1110
+ inlineData: import_v43.z.object({
1111
+ mimeType: import_v43.z.string(),
1112
+ data: import_v43.z.string()
1123
1113
  })
1124
1114
  }),
1125
- z3.object({
1126
- executableCode: z3.object({
1127
- language: z3.string(),
1128
- code: z3.string()
1115
+ import_v43.z.object({
1116
+ executableCode: import_v43.z.object({
1117
+ language: import_v43.z.string(),
1118
+ code: import_v43.z.string()
1129
1119
  }).nullish(),
1130
- codeExecutionResult: z3.object({
1131
- outcome: z3.string(),
1132
- output: z3.string()
1120
+ codeExecutionResult: import_v43.z.object({
1121
+ outcome: import_v43.z.string(),
1122
+ output: import_v43.z.string()
1133
1123
  }).nullish(),
1134
- text: z3.string().nullish(),
1135
- thought: z3.boolean().nullish(),
1136
- thoughtSignature: z3.string().nullish()
1124
+ text: import_v43.z.string().nullish(),
1125
+ thought: import_v43.z.boolean().nullish(),
1126
+ thoughtSignature: import_v43.z.string().nullish()
1137
1127
  })
1138
1128
  ])
1139
1129
  ).nullish()
1140
1130
  });
1141
- var getSafetyRatingSchema = () => z3.object({
1142
- category: z3.string().nullish(),
1143
- probability: z3.string().nullish(),
1144
- probabilityScore: z3.number().nullish(),
1145
- severity: z3.string().nullish(),
1146
- severityScore: z3.number().nullish(),
1147
- blocked: z3.boolean().nullish()
1131
+ var getSafetyRatingSchema = () => import_v43.z.object({
1132
+ category: import_v43.z.string().nullish(),
1133
+ probability: import_v43.z.string().nullish(),
1134
+ probabilityScore: import_v43.z.number().nullish(),
1135
+ severity: import_v43.z.string().nullish(),
1136
+ severityScore: import_v43.z.number().nullish(),
1137
+ blocked: import_v43.z.boolean().nullish()
1148
1138
  });
1149
- var usageSchema = z3.object({
1150
- cachedContentTokenCount: z3.number().nullish(),
1151
- thoughtsTokenCount: z3.number().nullish(),
1152
- promptTokenCount: z3.number().nullish(),
1153
- candidatesTokenCount: z3.number().nullish(),
1154
- totalTokenCount: z3.number().nullish()
1139
+ var usageSchema = import_v43.z.object({
1140
+ cachedContentTokenCount: import_v43.z.number().nullish(),
1141
+ thoughtsTokenCount: import_v43.z.number().nullish(),
1142
+ promptTokenCount: import_v43.z.number().nullish(),
1143
+ candidatesTokenCount: import_v43.z.number().nullish(),
1144
+ totalTokenCount: import_v43.z.number().nullish()
1155
1145
  });
1156
- var getUrlContextMetadataSchema = () => z3.object({
1157
- urlMetadata: z3.array(
1158
- z3.object({
1159
- retrievedUrl: z3.string(),
1160
- urlRetrievalStatus: z3.string()
1146
+ var getUrlContextMetadataSchema = () => import_v43.z.object({
1147
+ urlMetadata: import_v43.z.array(
1148
+ import_v43.z.object({
1149
+ retrievedUrl: import_v43.z.string(),
1150
+ urlRetrievalStatus: import_v43.z.string()
1161
1151
  })
1162
1152
  )
1163
1153
  });
1164
1154
  var responseSchema = (0, import_provider_utils4.lazySchema)(
1165
1155
  () => (0, import_provider_utils4.zodSchema)(
1166
- z3.object({
1167
- candidates: z3.array(
1168
- z3.object({
1169
- content: getContentSchema().nullish().or(z3.object({}).strict()),
1170
- finishReason: z3.string().nullish(),
1171
- safetyRatings: z3.array(getSafetyRatingSchema()).nullish(),
1156
+ import_v43.z.object({
1157
+ candidates: import_v43.z.array(
1158
+ import_v43.z.object({
1159
+ content: getContentSchema().nullish().or(import_v43.z.object({}).strict()),
1160
+ finishReason: import_v43.z.string().nullish(),
1161
+ safetyRatings: import_v43.z.array(getSafetyRatingSchema()).nullish(),
1172
1162
  groundingMetadata: getGroundingMetadataSchema().nullish(),
1173
1163
  urlContextMetadata: getUrlContextMetadataSchema().nullish()
1174
1164
  })
1175
1165
  ),
1176
1166
  usageMetadata: usageSchema.nullish(),
1177
- promptFeedback: z3.object({
1178
- blockReason: z3.string().nullish(),
1179
- safetyRatings: z3.array(getSafetyRatingSchema()).nullish()
1167
+ promptFeedback: import_v43.z.object({
1168
+ blockReason: import_v43.z.string().nullish(),
1169
+ safetyRatings: import_v43.z.array(getSafetyRatingSchema()).nullish()
1180
1170
  }).nullish()
1181
1171
  })
1182
1172
  )
1183
1173
  );
1184
1174
  var chunkSchema = (0, import_provider_utils4.lazySchema)(
1185
1175
  () => (0, import_provider_utils4.zodSchema)(
1186
- z3.object({
1187
- candidates: z3.array(
1188
- z3.object({
1176
+ import_v43.z.object({
1177
+ candidates: import_v43.z.array(
1178
+ import_v43.z.object({
1189
1179
  content: getContentSchema().nullish(),
1190
- finishReason: z3.string().nullish(),
1191
- safetyRatings: z3.array(getSafetyRatingSchema()).nullish(),
1180
+ finishReason: import_v43.z.string().nullish(),
1181
+ safetyRatings: import_v43.z.array(getSafetyRatingSchema()).nullish(),
1192
1182
  groundingMetadata: getGroundingMetadataSchema().nullish(),
1193
1183
  urlContextMetadata: getUrlContextMetadataSchema().nullish()
1194
1184
  })
1195
1185
  ).nullish(),
1196
1186
  usageMetadata: usageSchema.nullish(),
1197
- promptFeedback: z3.object({
1198
- blockReason: z3.string().nullish(),
1199
- safetyRatings: z3.array(getSafetyRatingSchema()).nullish()
1187
+ promptFeedback: import_v43.z.object({
1188
+ blockReason: import_v43.z.string().nullish(),
1189
+ safetyRatings: import_v43.z.array(getSafetyRatingSchema()).nullish()
1200
1190
  }).nullish()
1201
1191
  })
1202
1192
  )
@@ -1204,31 +1194,31 @@ var chunkSchema = (0, import_provider_utils4.lazySchema)(
1204
1194
 
1205
1195
  // src/tool/code-execution.ts
1206
1196
  var import_provider_utils5 = require("@ai-sdk/provider-utils");
1207
- var z4 = __toESM(require("zod/v4"));
1197
+ var import_v44 = require("zod/v4");
1208
1198
  var codeExecution = (0, import_provider_utils5.createProviderDefinedToolFactoryWithOutputSchema)({
1209
1199
  id: "google.code_execution",
1210
1200
  name: "code_execution",
1211
- inputSchema: z4.object({
1212
- language: z4.string().describe("The programming language of the code."),
1213
- code: z4.string().describe("The code to be executed.")
1201
+ inputSchema: import_v44.z.object({
1202
+ language: import_v44.z.string().describe("The programming language of the code."),
1203
+ code: import_v44.z.string().describe("The code to be executed.")
1214
1204
  }),
1215
- outputSchema: z4.object({
1216
- outcome: z4.string().describe('The outcome of the execution (e.g., "OUTCOME_OK").'),
1217
- output: z4.string().describe("The output from the code execution.")
1205
+ outputSchema: import_v44.z.object({
1206
+ outcome: import_v44.z.string().describe('The outcome of the execution (e.g., "OUTCOME_OK").'),
1207
+ output: import_v44.z.string().describe("The output from the code execution.")
1218
1208
  })
1219
1209
  });
1220
1210
 
1221
1211
  // src/tool/google-search.ts
1222
1212
  var import_provider_utils6 = require("@ai-sdk/provider-utils");
1223
- var z5 = __toESM(require("zod/v4"));
1213
+ var import_v45 = require("zod/v4");
1224
1214
  var googleSearch = (0, import_provider_utils6.createProviderDefinedToolFactory)({
1225
1215
  id: "google.google_search",
1226
1216
  name: "google_search",
1227
1217
  inputSchema: (0, import_provider_utils6.lazySchema)(
1228
1218
  () => (0, import_provider_utils6.zodSchema)(
1229
- z5.object({
1230
- mode: z5.enum(["MODE_DYNAMIC", "MODE_UNSPECIFIED"]).default("MODE_UNSPECIFIED"),
1231
- dynamicThreshold: z5.number().default(1)
1219
+ import_v45.z.object({
1220
+ mode: import_v45.z.enum(["MODE_DYNAMIC", "MODE_UNSPECIFIED"]).default("MODE_UNSPECIFIED"),
1221
+ dynamicThreshold: import_v45.z.number().default(1)
1232
1222
  })
1233
1223
  )
1234
1224
  )
@@ -1236,11 +1226,11 @@ var googleSearch = (0, import_provider_utils6.createProviderDefinedToolFactory)(
1236
1226
 
1237
1227
  // src/tool/url-context.ts
1238
1228
  var import_provider_utils7 = require("@ai-sdk/provider-utils");
1239
- var z6 = __toESM(require("zod/v4"));
1229
+ var import_v46 = require("zod/v4");
1240
1230
  var urlContext = (0, import_provider_utils7.createProviderDefinedToolFactory)({
1241
1231
  id: "google.url_context",
1242
1232
  name: "url_context",
1243
- inputSchema: (0, import_provider_utils7.lazySchema)(() => (0, import_provider_utils7.zodSchema)(z6.object({})))
1233
+ inputSchema: (0, import_provider_utils7.lazySchema)(() => (0, import_provider_utils7.zodSchema)(import_v46.z.object({})))
1244
1234
  });
1245
1235
 
1246
1236
  // src/google-tools.ts