@ai-sdk/google 3.0.0-beta.14 → 3.0.0-beta.15

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,7 +1,9 @@
1
1
  "use strict";
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
5
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
8
  var __export = (target, all) => {
7
9
  for (var name in all)
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
15
17
  }
16
18
  return to;
17
19
  };
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
+ ));
18
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
29
 
20
30
  // src/internal/index.ts
@@ -28,7 +38,7 @@ module.exports = __toCommonJS(internal_exports);
28
38
 
29
39
  // src/google-generative-ai-language-model.ts
30
40
  var import_provider_utils5 = require("@ai-sdk/provider-utils");
31
- var import_v45 = require("zod/v4");
41
+ var z5 = __toESM(require("zod/v4"));
32
42
 
33
43
  // src/convert-json-schema-to-openapi-schema.ts
34
44
  function convertJSONSchemaToOpenAPISchema(jsonSchema) {
@@ -301,12 +311,12 @@ function getModelPath(modelId) {
301
311
 
302
312
  // src/google-error.ts
303
313
  var import_provider_utils2 = require("@ai-sdk/provider-utils");
304
- var import_v4 = require("zod/v4");
305
- var googleErrorDataSchema = import_v4.z.object({
306
- error: import_v4.z.object({
307
- code: import_v4.z.number().nullable(),
308
- message: import_v4.z.string(),
309
- status: import_v4.z.string()
314
+ var z = __toESM(require("zod/v4"));
315
+ var googleErrorDataSchema = z.object({
316
+ error: z.object({
317
+ code: z.number().nullable(),
318
+ message: z.string(),
319
+ status: z.string()
310
320
  })
311
321
  });
312
322
  var googleFailedResponseHandler = (0, import_provider_utils2.createJsonErrorResponseHandler)({
@@ -315,19 +325,19 @@ var googleFailedResponseHandler = (0, import_provider_utils2.createJsonErrorResp
315
325
  });
316
326
 
317
327
  // src/google-generative-ai-options.ts
318
- var import_v42 = require("zod/v4");
319
- var googleGenerativeAIProviderOptions = import_v42.z.object({
320
- responseModalities: import_v42.z.array(import_v42.z.enum(["TEXT", "IMAGE"])).optional(),
321
- thinkingConfig: import_v42.z.object({
322
- thinkingBudget: import_v42.z.number().optional(),
323
- includeThoughts: import_v42.z.boolean().optional()
328
+ var z2 = __toESM(require("zod/v4"));
329
+ var googleGenerativeAIProviderOptions = z2.object({
330
+ responseModalities: z2.array(z2.enum(["TEXT", "IMAGE"])).optional(),
331
+ thinkingConfig: z2.object({
332
+ thinkingBudget: z2.number().optional(),
333
+ includeThoughts: z2.boolean().optional()
324
334
  }).optional(),
325
335
  /**
326
336
  Optional.
327
337
  The name of the cached content used as context to serve the prediction.
328
338
  Format: cachedContents/{cachedContent}
329
339
  */
330
- cachedContent: import_v42.z.string().optional(),
340
+ cachedContent: z2.string().optional(),
331
341
  /**
332
342
  * Optional. Enable structured output. Default is true.
333
343
  *
@@ -336,13 +346,13 @@ var googleGenerativeAIProviderOptions = import_v42.z.object({
336
346
  * Google Generative AI uses. You can use this to disable
337
347
  * structured outputs if you need to.
338
348
  */
339
- structuredOutputs: import_v42.z.boolean().optional(),
349
+ structuredOutputs: z2.boolean().optional(),
340
350
  /**
341
351
  Optional. A list of unique safety settings for blocking unsafe content.
342
352
  */
343
- safetySettings: import_v42.z.array(
344
- import_v42.z.object({
345
- category: import_v42.z.enum([
353
+ safetySettings: z2.array(
354
+ z2.object({
355
+ category: z2.enum([
346
356
  "HARM_CATEGORY_UNSPECIFIED",
347
357
  "HARM_CATEGORY_HATE_SPEECH",
348
358
  "HARM_CATEGORY_DANGEROUS_CONTENT",
@@ -350,7 +360,7 @@ var googleGenerativeAIProviderOptions = import_v42.z.object({
350
360
  "HARM_CATEGORY_SEXUALLY_EXPLICIT",
351
361
  "HARM_CATEGORY_CIVIC_INTEGRITY"
352
362
  ]),
353
- threshold: import_v42.z.enum([
363
+ threshold: z2.enum([
354
364
  "HARM_BLOCK_THRESHOLD_UNSPECIFIED",
355
365
  "BLOCK_LOW_AND_ABOVE",
356
366
  "BLOCK_MEDIUM_AND_ABOVE",
@@ -360,7 +370,7 @@ var googleGenerativeAIProviderOptions = import_v42.z.object({
360
370
  ])
361
371
  })
362
372
  ).optional(),
363
- threshold: import_v42.z.enum([
373
+ threshold: z2.enum([
364
374
  "HARM_BLOCK_THRESHOLD_UNSPECIFIED",
365
375
  "BLOCK_LOW_AND_ABOVE",
366
376
  "BLOCK_MEDIUM_AND_ABOVE",
@@ -373,19 +383,19 @@ var googleGenerativeAIProviderOptions = import_v42.z.object({
373
383
  *
374
384
  * https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/audio-understanding
375
385
  */
376
- audioTimestamp: import_v42.z.boolean().optional(),
386
+ audioTimestamp: z2.boolean().optional(),
377
387
  /**
378
388
  * Optional. Defines labels used in billing reports. Available on Vertex AI only.
379
389
  *
380
390
  * https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/add-labels-to-api-calls
381
391
  */
382
- labels: import_v42.z.record(import_v42.z.string(), import_v42.z.string()).optional(),
392
+ labels: z2.record(z2.string(), z2.string()).optional(),
383
393
  /**
384
394
  * Optional. If specified, the media resolution specified will be used.
385
395
  *
386
396
  * https://ai.google.dev/api/generate-content#MediaResolution
387
397
  */
388
- mediaResolution: import_v42.z.enum([
398
+ mediaResolution: z2.enum([
389
399
  "MEDIA_RESOLUTION_UNSPECIFIED",
390
400
  "MEDIA_RESOLUTION_LOW",
391
401
  "MEDIA_RESOLUTION_MEDIUM",
@@ -569,60 +579,60 @@ function mapGoogleGenerativeAIFinishReason({
569
579
 
570
580
  // src/tool/google-search.ts
571
581
  var import_provider_utils3 = require("@ai-sdk/provider-utils");
572
- var import_v43 = require("zod/v4");
573
- var groundingChunkSchema = import_v43.z.object({
574
- web: import_v43.z.object({ uri: import_v43.z.string(), title: import_v43.z.string() }).nullish(),
575
- retrievedContext: import_v43.z.object({ uri: import_v43.z.string(), title: import_v43.z.string() }).nullish()
582
+ var z3 = __toESM(require("zod/v4"));
583
+ var groundingChunkSchema = z3.object({
584
+ web: z3.object({ uri: z3.string(), title: z3.string() }).nullish(),
585
+ retrievedContext: z3.object({ uri: z3.string(), title: z3.string() }).nullish()
576
586
  });
577
- var groundingMetadataSchema = import_v43.z.object({
578
- webSearchQueries: import_v43.z.array(import_v43.z.string()).nullish(),
579
- retrievalQueries: import_v43.z.array(import_v43.z.string()).nullish(),
580
- searchEntryPoint: import_v43.z.object({ renderedContent: import_v43.z.string() }).nullish(),
581
- groundingChunks: import_v43.z.array(groundingChunkSchema).nullish(),
582
- groundingSupports: import_v43.z.array(
583
- import_v43.z.object({
584
- segment: import_v43.z.object({
585
- startIndex: import_v43.z.number().nullish(),
586
- endIndex: import_v43.z.number().nullish(),
587
- text: import_v43.z.string().nullish()
587
+ var groundingMetadataSchema = z3.object({
588
+ webSearchQueries: z3.array(z3.string()).nullish(),
589
+ retrievalQueries: z3.array(z3.string()).nullish(),
590
+ searchEntryPoint: z3.object({ renderedContent: z3.string() }).nullish(),
591
+ groundingChunks: z3.array(groundingChunkSchema).nullish(),
592
+ groundingSupports: z3.array(
593
+ z3.object({
594
+ segment: z3.object({
595
+ startIndex: z3.number().nullish(),
596
+ endIndex: z3.number().nullish(),
597
+ text: z3.string().nullish()
588
598
  }),
589
- segment_text: import_v43.z.string().nullish(),
590
- groundingChunkIndices: import_v43.z.array(import_v43.z.number()).nullish(),
591
- supportChunkIndices: import_v43.z.array(import_v43.z.number()).nullish(),
592
- confidenceScores: import_v43.z.array(import_v43.z.number()).nullish(),
593
- confidenceScore: import_v43.z.array(import_v43.z.number()).nullish()
599
+ segment_text: z3.string().nullish(),
600
+ groundingChunkIndices: z3.array(z3.number()).nullish(),
601
+ supportChunkIndices: z3.array(z3.number()).nullish(),
602
+ confidenceScores: z3.array(z3.number()).nullish(),
603
+ confidenceScore: z3.array(z3.number()).nullish()
594
604
  })
595
605
  ).nullish(),
596
- retrievalMetadata: import_v43.z.union([
597
- import_v43.z.object({
598
- webDynamicRetrievalScore: import_v43.z.number()
606
+ retrievalMetadata: z3.union([
607
+ z3.object({
608
+ webDynamicRetrievalScore: z3.number()
599
609
  }),
600
- import_v43.z.object({})
610
+ z3.object({})
601
611
  ]).nullish()
602
612
  });
603
613
  var googleSearch = (0, import_provider_utils3.createProviderDefinedToolFactory)({
604
614
  id: "google.google_search",
605
615
  name: "google_search",
606
- inputSchema: import_v43.z.object({
607
- mode: import_v43.z.enum(["MODE_DYNAMIC", "MODE_UNSPECIFIED"]).default("MODE_UNSPECIFIED"),
608
- dynamicThreshold: import_v43.z.number().default(1)
616
+ inputSchema: z3.object({
617
+ mode: z3.enum(["MODE_DYNAMIC", "MODE_UNSPECIFIED"]).default("MODE_UNSPECIFIED"),
618
+ dynamicThreshold: z3.number().default(1)
609
619
  })
610
620
  });
611
621
 
612
622
  // src/tool/url-context.ts
613
623
  var import_provider_utils4 = require("@ai-sdk/provider-utils");
614
- var import_v44 = require("zod/v4");
615
- var urlMetadataSchema = import_v44.z.object({
616
- retrievedUrl: import_v44.z.string(),
617
- urlRetrievalStatus: import_v44.z.string()
624
+ var z4 = __toESM(require("zod/v4"));
625
+ var urlMetadataSchema = z4.object({
626
+ retrievedUrl: z4.string(),
627
+ urlRetrievalStatus: z4.string()
618
628
  });
619
- var urlContextMetadataSchema = import_v44.z.object({
620
- urlMetadata: import_v44.z.array(urlMetadataSchema)
629
+ var urlContextMetadataSchema = z4.object({
630
+ urlMetadata: z4.array(urlMetadataSchema)
621
631
  });
622
632
  var urlContext = (0, import_provider_utils4.createProviderDefinedToolFactory)({
623
633
  id: "google.url_context",
624
634
  name: "url_context",
625
- inputSchema: import_v44.z.object({})
635
+ inputSchema: z4.object({})
626
636
  });
627
637
 
628
638
  // src/google-generative-ai-language-model.ts
@@ -1120,100 +1130,100 @@ function extractSources({
1120
1130
  title: chunk.web.title
1121
1131
  }));
1122
1132
  }
1123
- var contentSchema = import_v45.z.object({
1124
- parts: import_v45.z.array(
1125
- import_v45.z.union([
1133
+ var contentSchema = z5.object({
1134
+ parts: z5.array(
1135
+ z5.union([
1126
1136
  // note: order matters since text can be fully empty
1127
- import_v45.z.object({
1128
- functionCall: import_v45.z.object({
1129
- name: import_v45.z.string(),
1130
- args: import_v45.z.unknown()
1137
+ z5.object({
1138
+ functionCall: z5.object({
1139
+ name: z5.string(),
1140
+ args: z5.unknown()
1131
1141
  }),
1132
- thoughtSignature: import_v45.z.string().nullish()
1142
+ thoughtSignature: z5.string().nullish()
1133
1143
  }),
1134
- import_v45.z.object({
1135
- inlineData: import_v45.z.object({
1136
- mimeType: import_v45.z.string(),
1137
- data: import_v45.z.string()
1144
+ z5.object({
1145
+ inlineData: z5.object({
1146
+ mimeType: z5.string(),
1147
+ data: z5.string()
1138
1148
  })
1139
1149
  }),
1140
- import_v45.z.object({
1141
- executableCode: import_v45.z.object({
1142
- language: import_v45.z.string(),
1143
- code: import_v45.z.string()
1150
+ z5.object({
1151
+ executableCode: z5.object({
1152
+ language: z5.string(),
1153
+ code: z5.string()
1144
1154
  }).nullish(),
1145
- codeExecutionResult: import_v45.z.object({
1146
- outcome: import_v45.z.string(),
1147
- output: import_v45.z.string()
1155
+ codeExecutionResult: z5.object({
1156
+ outcome: z5.string(),
1157
+ output: z5.string()
1148
1158
  }).nullish(),
1149
- text: import_v45.z.string().nullish(),
1150
- thought: import_v45.z.boolean().nullish(),
1151
- thoughtSignature: import_v45.z.string().nullish()
1159
+ text: z5.string().nullish(),
1160
+ thought: z5.boolean().nullish(),
1161
+ thoughtSignature: z5.string().nullish()
1152
1162
  })
1153
1163
  ])
1154
1164
  ).nullish()
1155
1165
  });
1156
- var safetyRatingSchema = import_v45.z.object({
1157
- category: import_v45.z.string().nullish(),
1158
- probability: import_v45.z.string().nullish(),
1159
- probabilityScore: import_v45.z.number().nullish(),
1160
- severity: import_v45.z.string().nullish(),
1161
- severityScore: import_v45.z.number().nullish(),
1162
- blocked: import_v45.z.boolean().nullish()
1166
+ var safetyRatingSchema = z5.object({
1167
+ category: z5.string().nullish(),
1168
+ probability: z5.string().nullish(),
1169
+ probabilityScore: z5.number().nullish(),
1170
+ severity: z5.string().nullish(),
1171
+ severityScore: z5.number().nullish(),
1172
+ blocked: z5.boolean().nullish()
1163
1173
  });
1164
- var usageSchema = import_v45.z.object({
1165
- cachedContentTokenCount: import_v45.z.number().nullish(),
1166
- thoughtsTokenCount: import_v45.z.number().nullish(),
1167
- promptTokenCount: import_v45.z.number().nullish(),
1168
- candidatesTokenCount: import_v45.z.number().nullish(),
1169
- totalTokenCount: import_v45.z.number().nullish()
1174
+ var usageSchema = z5.object({
1175
+ cachedContentTokenCount: z5.number().nullish(),
1176
+ thoughtsTokenCount: z5.number().nullish(),
1177
+ promptTokenCount: z5.number().nullish(),
1178
+ candidatesTokenCount: z5.number().nullish(),
1179
+ totalTokenCount: z5.number().nullish()
1170
1180
  });
1171
- var responseSchema = import_v45.z.object({
1172
- candidates: import_v45.z.array(
1173
- import_v45.z.object({
1174
- content: contentSchema.nullish().or(import_v45.z.object({}).strict()),
1175
- finishReason: import_v45.z.string().nullish(),
1176
- safetyRatings: import_v45.z.array(safetyRatingSchema).nullish(),
1181
+ var responseSchema = z5.object({
1182
+ candidates: z5.array(
1183
+ z5.object({
1184
+ content: contentSchema.nullish().or(z5.object({}).strict()),
1185
+ finishReason: z5.string().nullish(),
1186
+ safetyRatings: z5.array(safetyRatingSchema).nullish(),
1177
1187
  groundingMetadata: groundingMetadataSchema.nullish(),
1178
1188
  urlContextMetadata: urlContextMetadataSchema.nullish()
1179
1189
  })
1180
1190
  ),
1181
1191
  usageMetadata: usageSchema.nullish(),
1182
- promptFeedback: import_v45.z.object({
1183
- blockReason: import_v45.z.string().nullish(),
1184
- safetyRatings: import_v45.z.array(safetyRatingSchema).nullish()
1192
+ promptFeedback: z5.object({
1193
+ blockReason: z5.string().nullish(),
1194
+ safetyRatings: z5.array(safetyRatingSchema).nullish()
1185
1195
  }).nullish()
1186
1196
  });
1187
- var chunkSchema = import_v45.z.object({
1188
- candidates: import_v45.z.array(
1189
- import_v45.z.object({
1197
+ var chunkSchema = z5.object({
1198
+ candidates: z5.array(
1199
+ z5.object({
1190
1200
  content: contentSchema.nullish(),
1191
- finishReason: import_v45.z.string().nullish(),
1192
- safetyRatings: import_v45.z.array(safetyRatingSchema).nullish(),
1201
+ finishReason: z5.string().nullish(),
1202
+ safetyRatings: z5.array(safetyRatingSchema).nullish(),
1193
1203
  groundingMetadata: groundingMetadataSchema.nullish(),
1194
1204
  urlContextMetadata: urlContextMetadataSchema.nullish()
1195
1205
  })
1196
1206
  ).nullish(),
1197
1207
  usageMetadata: usageSchema.nullish(),
1198
- promptFeedback: import_v45.z.object({
1199
- blockReason: import_v45.z.string().nullish(),
1200
- safetyRatings: import_v45.z.array(safetyRatingSchema).nullish()
1208
+ promptFeedback: z5.object({
1209
+ blockReason: z5.string().nullish(),
1210
+ safetyRatings: z5.array(safetyRatingSchema).nullish()
1201
1211
  }).nullish()
1202
1212
  });
1203
1213
 
1204
1214
  // src/tool/code-execution.ts
1205
1215
  var import_provider_utils6 = require("@ai-sdk/provider-utils");
1206
- var import_v46 = require("zod/v4");
1216
+ var z6 = __toESM(require("zod/v4"));
1207
1217
  var codeExecution = (0, import_provider_utils6.createProviderDefinedToolFactoryWithOutputSchema)({
1208
1218
  id: "google.code_execution",
1209
1219
  name: "code_execution",
1210
- inputSchema: import_v46.z.object({
1211
- language: import_v46.z.string().describe("The programming language of the code."),
1212
- code: import_v46.z.string().describe("The code to be executed.")
1220
+ inputSchema: z6.object({
1221
+ language: z6.string().describe("The programming language of the code."),
1222
+ code: z6.string().describe("The code to be executed.")
1213
1223
  }),
1214
- outputSchema: import_v46.z.object({
1215
- outcome: import_v46.z.string().describe('The outcome of the execution (e.g., "OUTCOME_OK").'),
1216
- output: import_v46.z.string().describe("The output from the code execution.")
1224
+ outputSchema: z6.object({
1225
+ outcome: z6.string().describe('The outcome of the execution (e.g., "OUTCOME_OK").'),
1226
+ output: z6.string().describe("The output from the code execution.")
1217
1227
  })
1218
1228
  });
1219
1229