@ai-sdk/google 2.0.17 → 2.0.18

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) {
@@ -53,12 +63,9 @@ function convertJSONSchemaToOpenAPISchema(jsonSchema) {
53
63
  enum: enumValues
54
64
  } = jsonSchema;
55
65
  const result = {};
56
- if (description)
57
- result.description = description;
58
- if (required)
59
- result.required = required;
60
- if (format)
61
- result.format = format;
66
+ if (description) result.description = description;
67
+ if (required) result.required = required;
68
+ if (format) result.format = format;
62
69
  if (constValue !== void 0) {
63
70
  result.enum = [constValue];
64
71
  }
@@ -304,12 +311,12 @@ function getModelPath(modelId) {
304
311
 
305
312
  // src/google-error.ts
306
313
  var import_provider_utils2 = require("@ai-sdk/provider-utils");
307
- var import_v4 = require("zod/v4");
308
- var googleErrorDataSchema = 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()
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()
313
320
  })
314
321
  });
315
322
  var googleFailedResponseHandler = (0, import_provider_utils2.createJsonErrorResponseHandler)({
@@ -318,19 +325,19 @@ var googleFailedResponseHandler = (0, import_provider_utils2.createJsonErrorResp
318
325
  });
319
326
 
320
327
  // src/google-generative-ai-options.ts
321
- var import_v42 = require("zod/v4");
322
- var googleGenerativeAIProviderOptions = import_v42.z.object({
323
- responseModalities: import_v42.z.array(import_v42.z.enum(["TEXT", "IMAGE"])).optional(),
324
- thinkingConfig: import_v42.z.object({
325
- thinkingBudget: import_v42.z.number().optional(),
326
- 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()
327
334
  }).optional(),
328
335
  /**
329
336
  Optional.
330
337
  The name of the cached content used as context to serve the prediction.
331
338
  Format: cachedContents/{cachedContent}
332
339
  */
333
- cachedContent: import_v42.z.string().optional(),
340
+ cachedContent: z2.string().optional(),
334
341
  /**
335
342
  * Optional. Enable structured output. Default is true.
336
343
  *
@@ -339,13 +346,13 @@ var googleGenerativeAIProviderOptions = import_v42.z.object({
339
346
  * Google Generative AI uses. You can use this to disable
340
347
  * structured outputs if you need to.
341
348
  */
342
- structuredOutputs: import_v42.z.boolean().optional(),
349
+ structuredOutputs: z2.boolean().optional(),
343
350
  /**
344
351
  Optional. A list of unique safety settings for blocking unsafe content.
345
352
  */
346
- safetySettings: import_v42.z.array(
347
- import_v42.z.object({
348
- category: import_v42.z.enum([
353
+ safetySettings: z2.array(
354
+ z2.object({
355
+ category: z2.enum([
349
356
  "HARM_CATEGORY_UNSPECIFIED",
350
357
  "HARM_CATEGORY_HATE_SPEECH",
351
358
  "HARM_CATEGORY_DANGEROUS_CONTENT",
@@ -353,7 +360,7 @@ var googleGenerativeAIProviderOptions = import_v42.z.object({
353
360
  "HARM_CATEGORY_SEXUALLY_EXPLICIT",
354
361
  "HARM_CATEGORY_CIVIC_INTEGRITY"
355
362
  ]),
356
- threshold: import_v42.z.enum([
363
+ threshold: z2.enum([
357
364
  "HARM_BLOCK_THRESHOLD_UNSPECIFIED",
358
365
  "BLOCK_LOW_AND_ABOVE",
359
366
  "BLOCK_MEDIUM_AND_ABOVE",
@@ -363,7 +370,7 @@ var googleGenerativeAIProviderOptions = import_v42.z.object({
363
370
  ])
364
371
  })
365
372
  ).optional(),
366
- threshold: import_v42.z.enum([
373
+ threshold: z2.enum([
367
374
  "HARM_BLOCK_THRESHOLD_UNSPECIFIED",
368
375
  "BLOCK_LOW_AND_ABOVE",
369
376
  "BLOCK_MEDIUM_AND_ABOVE",
@@ -376,13 +383,13 @@ var googleGenerativeAIProviderOptions = import_v42.z.object({
376
383
  *
377
384
  * https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/audio-understanding
378
385
  */
379
- audioTimestamp: import_v42.z.boolean().optional(),
386
+ audioTimestamp: z2.boolean().optional(),
380
387
  /**
381
388
  * Optional. Defines labels used in billing reports. Available on Vertex AI only.
382
389
  *
383
390
  * https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/add-labels-to-api-calls
384
391
  */
385
- labels: import_v42.z.record(import_v42.z.string(), import_v42.z.string()).optional()
392
+ labels: z2.record(z2.string(), z2.string()).optional()
386
393
  });
387
394
 
388
395
  // src/google-prepare-tools.ts
@@ -556,60 +563,60 @@ function mapGoogleGenerativeAIFinishReason({
556
563
 
557
564
  // src/tool/google-search.ts
558
565
  var import_provider_utils3 = require("@ai-sdk/provider-utils");
559
- var import_v43 = require("zod/v4");
560
- var groundingChunkSchema = import_v43.z.object({
561
- web: import_v43.z.object({ uri: import_v43.z.string(), title: import_v43.z.string() }).nullish(),
562
- retrievedContext: import_v43.z.object({ uri: import_v43.z.string(), title: import_v43.z.string() }).nullish()
566
+ var z3 = __toESM(require("zod/v4"));
567
+ var groundingChunkSchema = z3.object({
568
+ web: z3.object({ uri: z3.string(), title: z3.string() }).nullish(),
569
+ retrievedContext: z3.object({ uri: z3.string(), title: z3.string() }).nullish()
563
570
  });
564
- var groundingMetadataSchema = import_v43.z.object({
565
- webSearchQueries: import_v43.z.array(import_v43.z.string()).nullish(),
566
- retrievalQueries: import_v43.z.array(import_v43.z.string()).nullish(),
567
- searchEntryPoint: import_v43.z.object({ renderedContent: import_v43.z.string() }).nullish(),
568
- groundingChunks: import_v43.z.array(groundingChunkSchema).nullish(),
569
- groundingSupports: import_v43.z.array(
570
- import_v43.z.object({
571
- segment: import_v43.z.object({
572
- startIndex: import_v43.z.number().nullish(),
573
- endIndex: import_v43.z.number().nullish(),
574
- text: import_v43.z.string().nullish()
571
+ var groundingMetadataSchema = z3.object({
572
+ webSearchQueries: z3.array(z3.string()).nullish(),
573
+ retrievalQueries: z3.array(z3.string()).nullish(),
574
+ searchEntryPoint: z3.object({ renderedContent: z3.string() }).nullish(),
575
+ groundingChunks: z3.array(groundingChunkSchema).nullish(),
576
+ groundingSupports: z3.array(
577
+ z3.object({
578
+ segment: z3.object({
579
+ startIndex: z3.number().nullish(),
580
+ endIndex: z3.number().nullish(),
581
+ text: z3.string().nullish()
575
582
  }),
576
- segment_text: import_v43.z.string().nullish(),
577
- groundingChunkIndices: import_v43.z.array(import_v43.z.number()).nullish(),
578
- supportChunkIndices: import_v43.z.array(import_v43.z.number()).nullish(),
579
- confidenceScores: import_v43.z.array(import_v43.z.number()).nullish(),
580
- confidenceScore: import_v43.z.array(import_v43.z.number()).nullish()
583
+ segment_text: z3.string().nullish(),
584
+ groundingChunkIndices: z3.array(z3.number()).nullish(),
585
+ supportChunkIndices: z3.array(z3.number()).nullish(),
586
+ confidenceScores: z3.array(z3.number()).nullish(),
587
+ confidenceScore: z3.array(z3.number()).nullish()
581
588
  })
582
589
  ).nullish(),
583
- retrievalMetadata: import_v43.z.union([
584
- import_v43.z.object({
585
- webDynamicRetrievalScore: import_v43.z.number()
590
+ retrievalMetadata: z3.union([
591
+ z3.object({
592
+ webDynamicRetrievalScore: z3.number()
586
593
  }),
587
- import_v43.z.object({})
594
+ z3.object({})
588
595
  ]).nullish()
589
596
  });
590
597
  var googleSearch = (0, import_provider_utils3.createProviderDefinedToolFactory)({
591
598
  id: "google.google_search",
592
599
  name: "google_search",
593
- inputSchema: import_v43.z.object({
594
- mode: import_v43.z.enum(["MODE_DYNAMIC", "MODE_UNSPECIFIED"]).default("MODE_UNSPECIFIED"),
595
- dynamicThreshold: import_v43.z.number().default(1)
600
+ inputSchema: z3.object({
601
+ mode: z3.enum(["MODE_DYNAMIC", "MODE_UNSPECIFIED"]).default("MODE_UNSPECIFIED"),
602
+ dynamicThreshold: z3.number().default(1)
596
603
  })
597
604
  });
598
605
 
599
606
  // src/tool/url-context.ts
600
607
  var import_provider_utils4 = require("@ai-sdk/provider-utils");
601
- var import_v44 = require("zod/v4");
602
- var urlMetadataSchema = import_v44.z.object({
603
- retrievedUrl: import_v44.z.string(),
604
- urlRetrievalStatus: import_v44.z.string()
608
+ var z4 = __toESM(require("zod/v4"));
609
+ var urlMetadataSchema = z4.object({
610
+ retrievedUrl: z4.string(),
611
+ urlRetrievalStatus: z4.string()
605
612
  });
606
- var urlContextMetadataSchema = import_v44.z.object({
607
- urlMetadata: import_v44.z.array(urlMetadataSchema)
613
+ var urlContextMetadataSchema = z4.object({
614
+ urlMetadata: z4.array(urlMetadataSchema)
608
615
  });
609
616
  var urlContext = (0, import_provider_utils4.createProviderDefinedToolFactory)({
610
617
  id: "google.url_context",
611
618
  name: "url_context",
612
- inputSchema: import_v44.z.object({})
619
+ inputSchema: z4.object({})
613
620
  });
614
621
 
615
622
  // src/google-generative-ai-language-model.ts
@@ -1104,100 +1111,100 @@ function extractSources({
1104
1111
  title: chunk.web.title
1105
1112
  }));
1106
1113
  }
1107
- var contentSchema = import_v45.z.object({
1108
- parts: import_v45.z.array(
1109
- import_v45.z.union([
1114
+ var contentSchema = z5.object({
1115
+ parts: z5.array(
1116
+ z5.union([
1110
1117
  // note: order matters since text can be fully empty
1111
- import_v45.z.object({
1112
- functionCall: import_v45.z.object({
1113
- name: import_v45.z.string(),
1114
- args: import_v45.z.unknown()
1118
+ z5.object({
1119
+ functionCall: z5.object({
1120
+ name: z5.string(),
1121
+ args: z5.unknown()
1115
1122
  }),
1116
- thoughtSignature: import_v45.z.string().nullish()
1123
+ thoughtSignature: z5.string().nullish()
1117
1124
  }),
1118
- import_v45.z.object({
1119
- inlineData: import_v45.z.object({
1120
- mimeType: import_v45.z.string(),
1121
- data: import_v45.z.string()
1125
+ z5.object({
1126
+ inlineData: z5.object({
1127
+ mimeType: z5.string(),
1128
+ data: z5.string()
1122
1129
  })
1123
1130
  }),
1124
- import_v45.z.object({
1125
- executableCode: import_v45.z.object({
1126
- language: import_v45.z.string(),
1127
- code: import_v45.z.string()
1131
+ z5.object({
1132
+ executableCode: z5.object({
1133
+ language: z5.string(),
1134
+ code: z5.string()
1128
1135
  }).nullish(),
1129
- codeExecutionResult: import_v45.z.object({
1130
- outcome: import_v45.z.string(),
1131
- output: import_v45.z.string()
1136
+ codeExecutionResult: z5.object({
1137
+ outcome: z5.string(),
1138
+ output: z5.string()
1132
1139
  }).nullish(),
1133
- text: import_v45.z.string().nullish(),
1134
- thought: import_v45.z.boolean().nullish(),
1135
- thoughtSignature: import_v45.z.string().nullish()
1140
+ text: z5.string().nullish(),
1141
+ thought: z5.boolean().nullish(),
1142
+ thoughtSignature: z5.string().nullish()
1136
1143
  })
1137
1144
  ])
1138
1145
  ).nullish()
1139
1146
  });
1140
- var safetyRatingSchema = import_v45.z.object({
1141
- category: import_v45.z.string().nullish(),
1142
- probability: import_v45.z.string().nullish(),
1143
- probabilityScore: import_v45.z.number().nullish(),
1144
- severity: import_v45.z.string().nullish(),
1145
- severityScore: import_v45.z.number().nullish(),
1146
- blocked: import_v45.z.boolean().nullish()
1147
+ var safetyRatingSchema = z5.object({
1148
+ category: z5.string().nullish(),
1149
+ probability: z5.string().nullish(),
1150
+ probabilityScore: z5.number().nullish(),
1151
+ severity: z5.string().nullish(),
1152
+ severityScore: z5.number().nullish(),
1153
+ blocked: z5.boolean().nullish()
1147
1154
  });
1148
- var usageSchema = import_v45.z.object({
1149
- cachedContentTokenCount: import_v45.z.number().nullish(),
1150
- thoughtsTokenCount: import_v45.z.number().nullish(),
1151
- promptTokenCount: import_v45.z.number().nullish(),
1152
- candidatesTokenCount: import_v45.z.number().nullish(),
1153
- totalTokenCount: import_v45.z.number().nullish()
1155
+ var usageSchema = z5.object({
1156
+ cachedContentTokenCount: z5.number().nullish(),
1157
+ thoughtsTokenCount: z5.number().nullish(),
1158
+ promptTokenCount: z5.number().nullish(),
1159
+ candidatesTokenCount: z5.number().nullish(),
1160
+ totalTokenCount: z5.number().nullish()
1154
1161
  });
1155
- var responseSchema = import_v45.z.object({
1156
- candidates: import_v45.z.array(
1157
- import_v45.z.object({
1158
- content: contentSchema.nullish().or(import_v45.z.object({}).strict()),
1159
- finishReason: import_v45.z.string().nullish(),
1160
- safetyRatings: import_v45.z.array(safetyRatingSchema).nullish(),
1162
+ var responseSchema = z5.object({
1163
+ candidates: z5.array(
1164
+ z5.object({
1165
+ content: contentSchema.nullish().or(z5.object({}).strict()),
1166
+ finishReason: z5.string().nullish(),
1167
+ safetyRatings: z5.array(safetyRatingSchema).nullish(),
1161
1168
  groundingMetadata: groundingMetadataSchema.nullish(),
1162
1169
  urlContextMetadata: urlContextMetadataSchema.nullish()
1163
1170
  })
1164
1171
  ),
1165
1172
  usageMetadata: usageSchema.nullish(),
1166
- promptFeedback: import_v45.z.object({
1167
- blockReason: import_v45.z.string().nullish(),
1168
- safetyRatings: import_v45.z.array(safetyRatingSchema).nullish()
1173
+ promptFeedback: z5.object({
1174
+ blockReason: z5.string().nullish(),
1175
+ safetyRatings: z5.array(safetyRatingSchema).nullish()
1169
1176
  }).nullish()
1170
1177
  });
1171
- var chunkSchema = import_v45.z.object({
1172
- candidates: import_v45.z.array(
1173
- import_v45.z.object({
1178
+ var chunkSchema = z5.object({
1179
+ candidates: z5.array(
1180
+ z5.object({
1174
1181
  content: contentSchema.nullish(),
1175
- finishReason: import_v45.z.string().nullish(),
1176
- safetyRatings: import_v45.z.array(safetyRatingSchema).nullish(),
1182
+ finishReason: z5.string().nullish(),
1183
+ safetyRatings: z5.array(safetyRatingSchema).nullish(),
1177
1184
  groundingMetadata: groundingMetadataSchema.nullish(),
1178
1185
  urlContextMetadata: urlContextMetadataSchema.nullish()
1179
1186
  })
1180
1187
  ).nullish(),
1181
1188
  usageMetadata: usageSchema.nullish(),
1182
- promptFeedback: import_v45.z.object({
1183
- blockReason: import_v45.z.string().nullish(),
1184
- safetyRatings: import_v45.z.array(safetyRatingSchema).nullish()
1189
+ promptFeedback: z5.object({
1190
+ blockReason: z5.string().nullish(),
1191
+ safetyRatings: z5.array(safetyRatingSchema).nullish()
1185
1192
  }).nullish()
1186
1193
  });
1187
1194
 
1188
1195
  // src/tool/code-execution.ts
1189
1196
  var import_provider_utils6 = require("@ai-sdk/provider-utils");
1190
- var import_v46 = require("zod/v4");
1197
+ var z6 = __toESM(require("zod/v4"));
1191
1198
  var codeExecution = (0, import_provider_utils6.createProviderDefinedToolFactoryWithOutputSchema)({
1192
1199
  id: "google.code_execution",
1193
1200
  name: "code_execution",
1194
- inputSchema: import_v46.z.object({
1195
- language: import_v46.z.string().describe("The programming language of the code."),
1196
- code: import_v46.z.string().describe("The code to be executed.")
1201
+ inputSchema: z6.object({
1202
+ language: z6.string().describe("The programming language of the code."),
1203
+ code: z6.string().describe("The code to be executed.")
1197
1204
  }),
1198
- outputSchema: import_v46.z.object({
1199
- outcome: import_v46.z.string().describe('The outcome of the execution (e.g., "OUTCOME_OK").'),
1200
- output: import_v46.z.string().describe("The output from the code execution.")
1205
+ outputSchema: z6.object({
1206
+ outcome: z6.string().describe('The outcome of the execution (e.g., "OUTCOME_OK").'),
1207
+ output: z6.string().describe("The output from the code execution.")
1201
1208
  })
1202
1209
  });
1203
1210