@ai-sdk/google 2.0.18 → 2.0.19

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.
package/dist/index.js CHANGED
@@ -37,62 +37,71 @@ __export(src_exports, {
37
37
  module.exports = __toCommonJS(src_exports);
38
38
 
39
39
  // src/google-provider.ts
40
- var import_provider_utils9 = require("@ai-sdk/provider-utils");
40
+ var import_provider_utils11 = require("@ai-sdk/provider-utils");
41
41
 
42
42
  // src/version.ts
43
- var VERSION = true ? "2.0.18" : "0.0.0-test";
43
+ var VERSION = true ? "2.0.19" : "0.0.0-test";
44
44
 
45
45
  // src/google-generative-ai-embedding-model.ts
46
46
  var import_provider = require("@ai-sdk/provider");
47
- var import_provider_utils2 = require("@ai-sdk/provider-utils");
47
+ var import_provider_utils3 = require("@ai-sdk/provider-utils");
48
48
  var z3 = __toESM(require("zod/v4"));
49
49
 
50
50
  // src/google-error.ts
51
51
  var import_provider_utils = require("@ai-sdk/provider-utils");
52
52
  var z = __toESM(require("zod/v4"));
53
- var googleErrorDataSchema = z.object({
54
- error: z.object({
55
- code: z.number().nullable(),
56
- message: z.string(),
57
- status: z.string()
58
- })
59
- });
53
+ var googleErrorDataSchema = (0, import_provider_utils.lazySchema)(
54
+ () => (0, import_provider_utils.zodSchema)(
55
+ z.object({
56
+ error: z.object({
57
+ code: z.number().nullable(),
58
+ message: z.string(),
59
+ status: z.string()
60
+ })
61
+ })
62
+ )
63
+ );
60
64
  var googleFailedResponseHandler = (0, import_provider_utils.createJsonErrorResponseHandler)({
61
65
  errorSchema: googleErrorDataSchema,
62
66
  errorToMessage: (data) => data.error.message
63
67
  });
64
68
 
65
69
  // src/google-generative-ai-embedding-options.ts
70
+ var import_provider_utils2 = require("@ai-sdk/provider-utils");
66
71
  var z2 = __toESM(require("zod/v4"));
67
- var googleGenerativeAIEmbeddingProviderOptions = z2.object({
68
- /**
69
- * Optional. Optional reduced dimension for the output embedding.
70
- * If set, excessive values in the output embedding are truncated from the end.
71
- */
72
- outputDimensionality: z2.number().optional(),
73
- /**
74
- * Optional. Specifies the task type for generating embeddings.
75
- * Supported task types:
76
- * - SEMANTIC_SIMILARITY: Optimized for text similarity.
77
- * - CLASSIFICATION: Optimized for text classification.
78
- * - CLUSTERING: Optimized for clustering texts based on similarity.
79
- * - RETRIEVAL_DOCUMENT: Optimized for document retrieval.
80
- * - RETRIEVAL_QUERY: Optimized for query-based retrieval.
81
- * - QUESTION_ANSWERING: Optimized for answering questions.
82
- * - FACT_VERIFICATION: Optimized for verifying factual information.
83
- * - CODE_RETRIEVAL_QUERY: Optimized for retrieving code blocks based on natural language queries.
84
- */
85
- taskType: z2.enum([
86
- "SEMANTIC_SIMILARITY",
87
- "CLASSIFICATION",
88
- "CLUSTERING",
89
- "RETRIEVAL_DOCUMENT",
90
- "RETRIEVAL_QUERY",
91
- "QUESTION_ANSWERING",
92
- "FACT_VERIFICATION",
93
- "CODE_RETRIEVAL_QUERY"
94
- ]).optional()
95
- });
72
+ var googleGenerativeAIEmbeddingProviderOptions = (0, import_provider_utils2.lazySchema)(
73
+ () => (0, import_provider_utils2.zodSchema)(
74
+ z2.object({
75
+ /**
76
+ * Optional. Optional reduced dimension for the output embedding.
77
+ * If set, excessive values in the output embedding are truncated from the end.
78
+ */
79
+ outputDimensionality: z2.number().optional(),
80
+ /**
81
+ * Optional. Specifies the task type for generating embeddings.
82
+ * Supported task types:
83
+ * - SEMANTIC_SIMILARITY: Optimized for text similarity.
84
+ * - CLASSIFICATION: Optimized for text classification.
85
+ * - CLUSTERING: Optimized for clustering texts based on similarity.
86
+ * - RETRIEVAL_DOCUMENT: Optimized for document retrieval.
87
+ * - RETRIEVAL_QUERY: Optimized for query-based retrieval.
88
+ * - QUESTION_ANSWERING: Optimized for answering questions.
89
+ * - FACT_VERIFICATION: Optimized for verifying factual information.
90
+ * - CODE_RETRIEVAL_QUERY: Optimized for retrieving code blocks based on natural language queries.
91
+ */
92
+ taskType: z2.enum([
93
+ "SEMANTIC_SIMILARITY",
94
+ "CLASSIFICATION",
95
+ "CLUSTERING",
96
+ "RETRIEVAL_DOCUMENT",
97
+ "RETRIEVAL_QUERY",
98
+ "QUESTION_ANSWERING",
99
+ "FACT_VERIFICATION",
100
+ "CODE_RETRIEVAL_QUERY"
101
+ ]).optional()
102
+ })
103
+ )
104
+ );
96
105
 
97
106
  // src/google-generative-ai-embedding-model.ts
98
107
  var GoogleGenerativeAIEmbeddingModel = class {
@@ -112,7 +121,7 @@ var GoogleGenerativeAIEmbeddingModel = class {
112
121
  abortSignal,
113
122
  providerOptions
114
123
  }) {
115
- const googleOptions = await (0, import_provider_utils2.parseProviderOptions)({
124
+ const googleOptions = await (0, import_provider_utils3.parseProviderOptions)({
116
125
  provider: "google",
117
126
  providerOptions,
118
127
  schema: googleGenerativeAIEmbeddingProviderOptions
@@ -125,8 +134,8 @@ var GoogleGenerativeAIEmbeddingModel = class {
125
134
  values
126
135
  });
127
136
  }
128
- const mergedHeaders = (0, import_provider_utils2.combineHeaders)(
129
- await (0, import_provider_utils2.resolve)(this.config.headers),
137
+ const mergedHeaders = (0, import_provider_utils3.combineHeaders)(
138
+ await (0, import_provider_utils3.resolve)(this.config.headers),
130
139
  headers
131
140
  );
132
141
  if (values.length === 1) {
@@ -134,7 +143,7 @@ var GoogleGenerativeAIEmbeddingModel = class {
134
143
  responseHeaders: responseHeaders2,
135
144
  value: response2,
136
145
  rawValue: rawValue2
137
- } = await (0, import_provider_utils2.postJsonToApi)({
146
+ } = await (0, import_provider_utils3.postJsonToApi)({
138
147
  url: `${this.config.baseURL}/models/${this.modelId}:embedContent`,
139
148
  headers: mergedHeaders,
140
149
  body: {
@@ -146,7 +155,7 @@ var GoogleGenerativeAIEmbeddingModel = class {
146
155
  taskType: googleOptions == null ? void 0 : googleOptions.taskType
147
156
  },
148
157
  failedResponseHandler: googleFailedResponseHandler,
149
- successfulResponseHandler: (0, import_provider_utils2.createJsonResponseHandler)(
158
+ successfulResponseHandler: (0, import_provider_utils3.createJsonResponseHandler)(
150
159
  googleGenerativeAISingleEmbeddingResponseSchema
151
160
  ),
152
161
  abortSignal,
@@ -162,7 +171,7 @@ var GoogleGenerativeAIEmbeddingModel = class {
162
171
  responseHeaders,
163
172
  value: response,
164
173
  rawValue
165
- } = await (0, import_provider_utils2.postJsonToApi)({
174
+ } = await (0, import_provider_utils3.postJsonToApi)({
166
175
  url: `${this.config.baseURL}/models/${this.modelId}:batchEmbedContents`,
167
176
  headers: mergedHeaders,
168
177
  body: {
@@ -174,7 +183,7 @@ var GoogleGenerativeAIEmbeddingModel = class {
174
183
  }))
175
184
  },
176
185
  failedResponseHandler: googleFailedResponseHandler,
177
- successfulResponseHandler: (0, import_provider_utils2.createJsonResponseHandler)(
186
+ successfulResponseHandler: (0, import_provider_utils3.createJsonResponseHandler)(
178
187
  googleGenerativeAITextEmbeddingResponseSchema
179
188
  ),
180
189
  abortSignal,
@@ -187,16 +196,24 @@ var GoogleGenerativeAIEmbeddingModel = class {
187
196
  };
188
197
  }
189
198
  };
190
- var googleGenerativeAITextEmbeddingResponseSchema = z3.object({
191
- embeddings: z3.array(z3.object({ values: z3.array(z3.number()) }))
192
- });
193
- var googleGenerativeAISingleEmbeddingResponseSchema = z3.object({
194
- embedding: z3.object({ values: z3.array(z3.number()) })
195
- });
199
+ var googleGenerativeAITextEmbeddingResponseSchema = (0, import_provider_utils3.lazySchema)(
200
+ () => (0, import_provider_utils3.zodSchema)(
201
+ z3.object({
202
+ embeddings: z3.array(z3.object({ values: z3.array(z3.number()) }))
203
+ })
204
+ )
205
+ );
206
+ var googleGenerativeAISingleEmbeddingResponseSchema = (0, import_provider_utils3.lazySchema)(
207
+ () => (0, import_provider_utils3.zodSchema)(
208
+ z3.object({
209
+ embedding: z3.object({ values: z3.array(z3.number()) })
210
+ })
211
+ )
212
+ );
196
213
 
197
214
  // src/google-generative-ai-language-model.ts
198
215
  var import_provider_utils6 = require("@ai-sdk/provider-utils");
199
- var z7 = __toESM(require("zod/v4"));
216
+ var z5 = __toESM(require("zod/v4"));
200
217
 
201
218
  // src/convert-json-schema-to-openapi-schema.ts
202
219
  function convertJSONSchemaToOpenAPISchema(jsonSchema) {
@@ -294,7 +311,7 @@ function isEmptyObjectSchema(jsonSchema) {
294
311
 
295
312
  // src/convert-to-google-generative-ai-messages.ts
296
313
  var import_provider2 = require("@ai-sdk/provider");
297
- var import_provider_utils3 = require("@ai-sdk/provider-utils");
314
+ var import_provider_utils4 = require("@ai-sdk/provider-utils");
298
315
  function convertToGoogleGenerativeAIMessages(prompt, options) {
299
316
  var _a;
300
317
  const systemInstructionParts = [];
@@ -332,7 +349,7 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
332
349
  } : {
333
350
  inlineData: {
334
351
  mimeType: mediaType,
335
- data: (0, import_provider_utils3.convertToBase64)(part.data)
352
+ data: (0, import_provider_utils4.convertToBase64)(part.data)
336
353
  }
337
354
  }
338
355
  );
@@ -377,7 +394,7 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
377
394
  return {
378
395
  inlineData: {
379
396
  mimeType: part.mediaType,
380
- data: (0, import_provider_utils3.convertToBase64)(part.data)
397
+ data: (0, import_provider_utils4.convertToBase64)(part.data)
381
398
  }
382
399
  };
383
400
  }
@@ -468,41 +485,54 @@ function getModelPath(modelId) {
468
485
  }
469
486
 
470
487
  // src/google-generative-ai-options.ts
488
+ var import_provider_utils5 = require("@ai-sdk/provider-utils");
471
489
  var z4 = __toESM(require("zod/v4"));
472
- var googleGenerativeAIProviderOptions = z4.object({
473
- responseModalities: z4.array(z4.enum(["TEXT", "IMAGE"])).optional(),
474
- thinkingConfig: z4.object({
475
- thinkingBudget: z4.number().optional(),
476
- includeThoughts: z4.boolean().optional()
477
- }).optional(),
478
- /**
479
- Optional.
480
- The name of the cached content used as context to serve the prediction.
481
- Format: cachedContents/{cachedContent}
482
- */
483
- cachedContent: z4.string().optional(),
484
- /**
485
- * Optional. Enable structured output. Default is true.
486
- *
487
- * This is useful when the JSON Schema contains elements that are
488
- * not supported by the OpenAPI schema version that
489
- * Google Generative AI uses. You can use this to disable
490
- * structured outputs if you need to.
491
- */
492
- structuredOutputs: z4.boolean().optional(),
493
- /**
494
- Optional. A list of unique safety settings for blocking unsafe content.
495
- */
496
- safetySettings: z4.array(
490
+ var googleGenerativeAIProviderOptions = (0, import_provider_utils5.lazySchema)(
491
+ () => (0, import_provider_utils5.zodSchema)(
497
492
  z4.object({
498
- category: z4.enum([
499
- "HARM_CATEGORY_UNSPECIFIED",
500
- "HARM_CATEGORY_HATE_SPEECH",
501
- "HARM_CATEGORY_DANGEROUS_CONTENT",
502
- "HARM_CATEGORY_HARASSMENT",
503
- "HARM_CATEGORY_SEXUALLY_EXPLICIT",
504
- "HARM_CATEGORY_CIVIC_INTEGRITY"
505
- ]),
493
+ responseModalities: z4.array(z4.enum(["TEXT", "IMAGE"])).optional(),
494
+ thinkingConfig: z4.object({
495
+ thinkingBudget: z4.number().optional(),
496
+ includeThoughts: z4.boolean().optional()
497
+ }).optional(),
498
+ /**
499
+ * Optional.
500
+ * The name of the cached content used as context to serve the prediction.
501
+ * Format: cachedContents/{cachedContent}
502
+ */
503
+ cachedContent: z4.string().optional(),
504
+ /**
505
+ * Optional. Enable structured output. Default is true.
506
+ *
507
+ * This is useful when the JSON Schema contains elements that are
508
+ * not supported by the OpenAPI schema version that
509
+ * Google Generative AI uses. You can use this to disable
510
+ * structured outputs if you need to.
511
+ */
512
+ structuredOutputs: z4.boolean().optional(),
513
+ /**
514
+ * Optional. A list of unique safety settings for blocking unsafe content.
515
+ */
516
+ safetySettings: z4.array(
517
+ z4.object({
518
+ category: z4.enum([
519
+ "HARM_CATEGORY_UNSPECIFIED",
520
+ "HARM_CATEGORY_HATE_SPEECH",
521
+ "HARM_CATEGORY_DANGEROUS_CONTENT",
522
+ "HARM_CATEGORY_HARASSMENT",
523
+ "HARM_CATEGORY_SEXUALLY_EXPLICIT",
524
+ "HARM_CATEGORY_CIVIC_INTEGRITY"
525
+ ]),
526
+ threshold: z4.enum([
527
+ "HARM_BLOCK_THRESHOLD_UNSPECIFIED",
528
+ "BLOCK_LOW_AND_ABOVE",
529
+ "BLOCK_MEDIUM_AND_ABOVE",
530
+ "BLOCK_ONLY_HIGH",
531
+ "BLOCK_NONE",
532
+ "OFF"
533
+ ])
534
+ })
535
+ ).optional(),
506
536
  threshold: z4.enum([
507
537
  "HARM_BLOCK_THRESHOLD_UNSPECIFIED",
508
538
  "BLOCK_LOW_AND_ABOVE",
@@ -510,30 +540,33 @@ var googleGenerativeAIProviderOptions = z4.object({
510
540
  "BLOCK_ONLY_HIGH",
511
541
  "BLOCK_NONE",
512
542
  "OFF"
513
- ])
543
+ ]).optional(),
544
+ /**
545
+ * Optional. Enables timestamp understanding for audio-only files.
546
+ *
547
+ * https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/audio-understanding
548
+ */
549
+ audioTimestamp: z4.boolean().optional(),
550
+ /**
551
+ * Optional. Defines labels used in billing reports. Available on Vertex AI only.
552
+ *
553
+ * https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/add-labels-to-api-calls
554
+ */
555
+ labels: z4.record(z4.string(), z4.string()).optional(),
556
+ /**
557
+ * Optional. If specified, the media resolution specified will be used.
558
+ *
559
+ * https://ai.google.dev/api/generate-content#MediaResolution
560
+ */
561
+ mediaResolution: z4.enum([
562
+ "MEDIA_RESOLUTION_UNSPECIFIED",
563
+ "MEDIA_RESOLUTION_LOW",
564
+ "MEDIA_RESOLUTION_MEDIUM",
565
+ "MEDIA_RESOLUTION_HIGH"
566
+ ]).optional()
514
567
  })
515
- ).optional(),
516
- threshold: z4.enum([
517
- "HARM_BLOCK_THRESHOLD_UNSPECIFIED",
518
- "BLOCK_LOW_AND_ABOVE",
519
- "BLOCK_MEDIUM_AND_ABOVE",
520
- "BLOCK_ONLY_HIGH",
521
- "BLOCK_NONE",
522
- "OFF"
523
- ]).optional(),
524
- /**
525
- * Optional. Enables timestamp understanding for audio-only files.
526
- *
527
- * https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/audio-understanding
528
- */
529
- audioTimestamp: z4.boolean().optional(),
530
- /**
531
- * Optional. Defines labels used in billing reports. Available on Vertex AI only.
532
- *
533
- * https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/add-labels-to-api-calls
534
- */
535
- labels: z4.record(z4.string(), z4.string()).optional()
536
- });
568
+ )
569
+ );
537
570
 
538
571
  // src/google-prepare-tools.ts
539
572
  var import_provider3 = require("@ai-sdk/provider");
@@ -704,64 +737,6 @@ function mapGoogleGenerativeAIFinishReason({
704
737
  }
705
738
  }
706
739
 
707
- // src/tool/google-search.ts
708
- var import_provider_utils4 = require("@ai-sdk/provider-utils");
709
- var z5 = __toESM(require("zod/v4"));
710
- var groundingChunkSchema = z5.object({
711
- web: z5.object({ uri: z5.string(), title: z5.string() }).nullish(),
712
- retrievedContext: z5.object({ uri: z5.string(), title: z5.string() }).nullish()
713
- });
714
- var groundingMetadataSchema = z5.object({
715
- webSearchQueries: z5.array(z5.string()).nullish(),
716
- retrievalQueries: z5.array(z5.string()).nullish(),
717
- searchEntryPoint: z5.object({ renderedContent: z5.string() }).nullish(),
718
- groundingChunks: z5.array(groundingChunkSchema).nullish(),
719
- groundingSupports: z5.array(
720
- z5.object({
721
- segment: z5.object({
722
- startIndex: z5.number().nullish(),
723
- endIndex: z5.number().nullish(),
724
- text: z5.string().nullish()
725
- }),
726
- segment_text: z5.string().nullish(),
727
- groundingChunkIndices: z5.array(z5.number()).nullish(),
728
- supportChunkIndices: z5.array(z5.number()).nullish(),
729
- confidenceScores: z5.array(z5.number()).nullish(),
730
- confidenceScore: z5.array(z5.number()).nullish()
731
- })
732
- ).nullish(),
733
- retrievalMetadata: z5.union([
734
- z5.object({
735
- webDynamicRetrievalScore: z5.number()
736
- }),
737
- z5.object({})
738
- ]).nullish()
739
- });
740
- var googleSearch = (0, import_provider_utils4.createProviderDefinedToolFactory)({
741
- id: "google.google_search",
742
- name: "google_search",
743
- inputSchema: z5.object({
744
- mode: z5.enum(["MODE_DYNAMIC", "MODE_UNSPECIFIED"]).default("MODE_UNSPECIFIED"),
745
- dynamicThreshold: z5.number().default(1)
746
- })
747
- });
748
-
749
- // src/tool/url-context.ts
750
- var import_provider_utils5 = require("@ai-sdk/provider-utils");
751
- var z6 = __toESM(require("zod/v4"));
752
- var urlMetadataSchema = z6.object({
753
- retrievedUrl: z6.string(),
754
- urlRetrievalStatus: z6.string()
755
- });
756
- var urlContextMetadataSchema = z6.object({
757
- urlMetadata: z6.array(urlMetadataSchema)
758
- });
759
- var urlContext = (0, import_provider_utils5.createProviderDefinedToolFactory)({
760
- id: "google.url_context",
761
- name: "url_context",
762
- inputSchema: z6.object({})
763
- });
764
-
765
740
  // src/google-generative-ai-language-model.ts
766
741
  var GoogleGenerativeAILanguageModel = class {
767
742
  constructor(modelId, config) {
@@ -1254,103 +1229,175 @@ function extractSources({
1254
1229
  title: chunk.web.title
1255
1230
  }));
1256
1231
  }
1257
- var contentSchema = z7.object({
1258
- parts: z7.array(
1259
- z7.union([
1232
+ var getGroundingMetadataSchema = () => z5.object({
1233
+ webSearchQueries: z5.array(z5.string()).nullish(),
1234
+ retrievalQueries: z5.array(z5.string()).nullish(),
1235
+ searchEntryPoint: z5.object({ renderedContent: z5.string() }).nullish(),
1236
+ groundingChunks: z5.array(
1237
+ z5.object({
1238
+ web: z5.object({ uri: z5.string(), title: z5.string() }).nullish(),
1239
+ retrievedContext: z5.object({ uri: z5.string(), title: z5.string() }).nullish()
1240
+ })
1241
+ ).nullish(),
1242
+ groundingSupports: z5.array(
1243
+ z5.object({
1244
+ segment: z5.object({
1245
+ startIndex: z5.number().nullish(),
1246
+ endIndex: z5.number().nullish(),
1247
+ text: z5.string().nullish()
1248
+ }),
1249
+ segment_text: z5.string().nullish(),
1250
+ groundingChunkIndices: z5.array(z5.number()).nullish(),
1251
+ supportChunkIndices: z5.array(z5.number()).nullish(),
1252
+ confidenceScores: z5.array(z5.number()).nullish(),
1253
+ confidenceScore: z5.array(z5.number()).nullish()
1254
+ })
1255
+ ).nullish(),
1256
+ retrievalMetadata: z5.union([
1257
+ z5.object({
1258
+ webDynamicRetrievalScore: z5.number()
1259
+ }),
1260
+ z5.object({})
1261
+ ]).nullish()
1262
+ });
1263
+ var getContentSchema = () => z5.object({
1264
+ parts: z5.array(
1265
+ z5.union([
1260
1266
  // note: order matters since text can be fully empty
1261
- z7.object({
1262
- functionCall: z7.object({
1263
- name: z7.string(),
1264
- args: z7.unknown()
1267
+ z5.object({
1268
+ functionCall: z5.object({
1269
+ name: z5.string(),
1270
+ args: z5.unknown()
1265
1271
  }),
1266
- thoughtSignature: z7.string().nullish()
1272
+ thoughtSignature: z5.string().nullish()
1267
1273
  }),
1268
- z7.object({
1269
- inlineData: z7.object({
1270
- mimeType: z7.string(),
1271
- data: z7.string()
1274
+ z5.object({
1275
+ inlineData: z5.object({
1276
+ mimeType: z5.string(),
1277
+ data: z5.string()
1272
1278
  })
1273
1279
  }),
1274
- z7.object({
1275
- executableCode: z7.object({
1276
- language: z7.string(),
1277
- code: z7.string()
1280
+ z5.object({
1281
+ executableCode: z5.object({
1282
+ language: z5.string(),
1283
+ code: z5.string()
1278
1284
  }).nullish(),
1279
- codeExecutionResult: z7.object({
1280
- outcome: z7.string(),
1281
- output: z7.string()
1285
+ codeExecutionResult: z5.object({
1286
+ outcome: z5.string(),
1287
+ output: z5.string()
1282
1288
  }).nullish(),
1283
- text: z7.string().nullish(),
1284
- thought: z7.boolean().nullish(),
1285
- thoughtSignature: z7.string().nullish()
1289
+ text: z5.string().nullish(),
1290
+ thought: z5.boolean().nullish(),
1291
+ thoughtSignature: z5.string().nullish()
1286
1292
  })
1287
1293
  ])
1288
1294
  ).nullish()
1289
1295
  });
1290
- var safetyRatingSchema = z7.object({
1291
- category: z7.string().nullish(),
1292
- probability: z7.string().nullish(),
1293
- probabilityScore: z7.number().nullish(),
1294
- severity: z7.string().nullish(),
1295
- severityScore: z7.number().nullish(),
1296
- blocked: z7.boolean().nullish()
1296
+ var getSafetyRatingSchema = () => z5.object({
1297
+ category: z5.string().nullish(),
1298
+ probability: z5.string().nullish(),
1299
+ probabilityScore: z5.number().nullish(),
1300
+ severity: z5.string().nullish(),
1301
+ severityScore: z5.number().nullish(),
1302
+ blocked: z5.boolean().nullish()
1297
1303
  });
1298
- var usageSchema = z7.object({
1299
- cachedContentTokenCount: z7.number().nullish(),
1300
- thoughtsTokenCount: z7.number().nullish(),
1301
- promptTokenCount: z7.number().nullish(),
1302
- candidatesTokenCount: z7.number().nullish(),
1303
- totalTokenCount: z7.number().nullish()
1304
+ var usageSchema = z5.object({
1305
+ cachedContentTokenCount: z5.number().nullish(),
1306
+ thoughtsTokenCount: z5.number().nullish(),
1307
+ promptTokenCount: z5.number().nullish(),
1308
+ candidatesTokenCount: z5.number().nullish(),
1309
+ totalTokenCount: z5.number().nullish()
1304
1310
  });
1305
- var responseSchema = z7.object({
1306
- candidates: z7.array(
1307
- z7.object({
1308
- content: contentSchema.nullish().or(z7.object({}).strict()),
1309
- finishReason: z7.string().nullish(),
1310
- safetyRatings: z7.array(safetyRatingSchema).nullish(),
1311
- groundingMetadata: groundingMetadataSchema.nullish(),
1312
- urlContextMetadata: urlContextMetadataSchema.nullish()
1311
+ var getUrlContextMetadataSchema = () => z5.object({
1312
+ urlMetadata: z5.array(
1313
+ z5.object({
1314
+ retrievedUrl: z5.string(),
1315
+ urlRetrievalStatus: z5.string()
1313
1316
  })
1314
- ),
1315
- usageMetadata: usageSchema.nullish(),
1316
- promptFeedback: z7.object({
1317
- blockReason: z7.string().nullish(),
1318
- safetyRatings: z7.array(safetyRatingSchema).nullish()
1319
- }).nullish()
1317
+ )
1320
1318
  });
1321
- var chunkSchema = z7.object({
1322
- candidates: z7.array(
1323
- z7.object({
1324
- content: contentSchema.nullish(),
1325
- finishReason: z7.string().nullish(),
1326
- safetyRatings: z7.array(safetyRatingSchema).nullish(),
1327
- groundingMetadata: groundingMetadataSchema.nullish(),
1328
- urlContextMetadata: urlContextMetadataSchema.nullish()
1319
+ var responseSchema = (0, import_provider_utils6.lazySchema)(
1320
+ () => (0, import_provider_utils6.zodSchema)(
1321
+ z5.object({
1322
+ candidates: z5.array(
1323
+ z5.object({
1324
+ content: getContentSchema().nullish().or(z5.object({}).strict()),
1325
+ finishReason: z5.string().nullish(),
1326
+ safetyRatings: z5.array(getSafetyRatingSchema()).nullish(),
1327
+ groundingMetadata: getGroundingMetadataSchema().nullish(),
1328
+ urlContextMetadata: getUrlContextMetadataSchema().nullish()
1329
+ })
1330
+ ),
1331
+ usageMetadata: usageSchema.nullish(),
1332
+ promptFeedback: z5.object({
1333
+ blockReason: z5.string().nullish(),
1334
+ safetyRatings: z5.array(getSafetyRatingSchema()).nullish()
1335
+ }).nullish()
1329
1336
  })
1330
- ).nullish(),
1331
- usageMetadata: usageSchema.nullish(),
1332
- promptFeedback: z7.object({
1333
- blockReason: z7.string().nullish(),
1334
- safetyRatings: z7.array(safetyRatingSchema).nullish()
1335
- }).nullish()
1336
- });
1337
+ )
1338
+ );
1339
+ var chunkSchema = (0, import_provider_utils6.lazySchema)(
1340
+ () => (0, import_provider_utils6.zodSchema)(
1341
+ z5.object({
1342
+ candidates: z5.array(
1343
+ z5.object({
1344
+ content: getContentSchema().nullish(),
1345
+ finishReason: z5.string().nullish(),
1346
+ safetyRatings: z5.array(getSafetyRatingSchema()).nullish(),
1347
+ groundingMetadata: getGroundingMetadataSchema().nullish(),
1348
+ urlContextMetadata: getUrlContextMetadataSchema().nullish()
1349
+ })
1350
+ ).nullish(),
1351
+ usageMetadata: usageSchema.nullish(),
1352
+ promptFeedback: z5.object({
1353
+ blockReason: z5.string().nullish(),
1354
+ safetyRatings: z5.array(getSafetyRatingSchema()).nullish()
1355
+ }).nullish()
1356
+ })
1357
+ )
1358
+ );
1337
1359
 
1338
1360
  // src/tool/code-execution.ts
1339
1361
  var import_provider_utils7 = require("@ai-sdk/provider-utils");
1340
- var z8 = __toESM(require("zod/v4"));
1362
+ var z6 = __toESM(require("zod/v4"));
1341
1363
  var codeExecution = (0, import_provider_utils7.createProviderDefinedToolFactoryWithOutputSchema)({
1342
1364
  id: "google.code_execution",
1343
1365
  name: "code_execution",
1344
- inputSchema: z8.object({
1345
- language: z8.string().describe("The programming language of the code."),
1346
- code: z8.string().describe("The code to be executed.")
1366
+ inputSchema: z6.object({
1367
+ language: z6.string().describe("The programming language of the code."),
1368
+ code: z6.string().describe("The code to be executed.")
1347
1369
  }),
1348
- outputSchema: z8.object({
1349
- outcome: z8.string().describe('The outcome of the execution (e.g., "OUTCOME_OK").'),
1350
- output: z8.string().describe("The output from the code execution.")
1370
+ outputSchema: z6.object({
1371
+ outcome: z6.string().describe('The outcome of the execution (e.g., "OUTCOME_OK").'),
1372
+ output: z6.string().describe("The output from the code execution.")
1351
1373
  })
1352
1374
  });
1353
1375
 
1376
+ // src/tool/google-search.ts
1377
+ var import_provider_utils8 = require("@ai-sdk/provider-utils");
1378
+ var z7 = __toESM(require("zod/v4"));
1379
+ var googleSearch = (0, import_provider_utils8.createProviderDefinedToolFactory)({
1380
+ id: "google.google_search",
1381
+ name: "google_search",
1382
+ inputSchema: (0, import_provider_utils8.lazySchema)(
1383
+ () => (0, import_provider_utils8.zodSchema)(
1384
+ z7.object({
1385
+ mode: z7.enum(["MODE_DYNAMIC", "MODE_UNSPECIFIED"]).default("MODE_UNSPECIFIED"),
1386
+ dynamicThreshold: z7.number().default(1)
1387
+ })
1388
+ )
1389
+ )
1390
+ });
1391
+
1392
+ // src/tool/url-context.ts
1393
+ var import_provider_utils9 = require("@ai-sdk/provider-utils");
1394
+ var z8 = __toESM(require("zod/v4"));
1395
+ var urlContext = (0, import_provider_utils9.createProviderDefinedToolFactory)({
1396
+ id: "google.url_context",
1397
+ name: "url_context",
1398
+ inputSchema: (0, import_provider_utils9.lazySchema)(() => (0, import_provider_utils9.zodSchema)(z8.object({})))
1399
+ });
1400
+
1354
1401
  // src/google-tools.ts
1355
1402
  var googleTools = {
1356
1403
  /**
@@ -1377,7 +1424,7 @@ var googleTools = {
1377
1424
  };
1378
1425
 
1379
1426
  // src/google-generative-ai-image-model.ts
1380
- var import_provider_utils8 = require("@ai-sdk/provider-utils");
1427
+ var import_provider_utils10 = require("@ai-sdk/provider-utils");
1381
1428
  var z9 = __toESM(require("zod/v4"));
1382
1429
  var GoogleGenerativeAIImageModel = class {
1383
1430
  constructor(modelId, settings, config) {
@@ -1420,7 +1467,7 @@ var GoogleGenerativeAIImageModel = class {
1420
1467
  details: "This model does not support the `seed` option through this provider."
1421
1468
  });
1422
1469
  }
1423
- const googleOptions = await (0, import_provider_utils8.parseProviderOptions)({
1470
+ const googleOptions = await (0, import_provider_utils10.parseProviderOptions)({
1424
1471
  provider: "google",
1425
1472
  providerOptions,
1426
1473
  schema: googleImageProviderOptionsSchema
@@ -1439,12 +1486,12 @@ var GoogleGenerativeAIImageModel = class {
1439
1486
  instances: [{ prompt }],
1440
1487
  parameters
1441
1488
  };
1442
- const { responseHeaders, value: response } = await (0, import_provider_utils8.postJsonToApi)({
1489
+ const { responseHeaders, value: response } = await (0, import_provider_utils10.postJsonToApi)({
1443
1490
  url: `${this.config.baseURL}/models/${this.modelId}:predict`,
1444
- headers: (0, import_provider_utils8.combineHeaders)(await (0, import_provider_utils8.resolve)(this.config.headers), headers),
1491
+ headers: (0, import_provider_utils10.combineHeaders)(await (0, import_provider_utils10.resolve)(this.config.headers), headers),
1445
1492
  body,
1446
1493
  failedResponseHandler: googleFailedResponseHandler,
1447
- successfulResponseHandler: (0, import_provider_utils8.createJsonResponseHandler)(
1494
+ successfulResponseHandler: (0, import_provider_utils10.createJsonResponseHandler)(
1448
1495
  googleImageResponseSchema
1449
1496
  ),
1450
1497
  abortSignal,
@@ -1470,21 +1517,29 @@ var GoogleGenerativeAIImageModel = class {
1470
1517
  };
1471
1518
  }
1472
1519
  };
1473
- var googleImageResponseSchema = z9.object({
1474
- predictions: z9.array(z9.object({ bytesBase64Encoded: z9.string() })).default([])
1475
- });
1476
- var googleImageProviderOptionsSchema = z9.object({
1477
- personGeneration: z9.enum(["dont_allow", "allow_adult", "allow_all"]).nullish(),
1478
- aspectRatio: z9.enum(["1:1", "3:4", "4:3", "9:16", "16:9"]).nullish()
1479
- });
1520
+ var googleImageResponseSchema = (0, import_provider_utils10.lazySchema)(
1521
+ () => (0, import_provider_utils10.zodSchema)(
1522
+ z9.object({
1523
+ predictions: z9.array(z9.object({ bytesBase64Encoded: z9.string() })).default([])
1524
+ })
1525
+ )
1526
+ );
1527
+ var googleImageProviderOptionsSchema = (0, import_provider_utils10.lazySchema)(
1528
+ () => (0, import_provider_utils10.zodSchema)(
1529
+ z9.object({
1530
+ personGeneration: z9.enum(["dont_allow", "allow_adult", "allow_all"]).nullish(),
1531
+ aspectRatio: z9.enum(["1:1", "3:4", "4:3", "9:16", "16:9"]).nullish()
1532
+ })
1533
+ )
1534
+ );
1480
1535
 
1481
1536
  // src/google-provider.ts
1482
1537
  function createGoogleGenerativeAI(options = {}) {
1483
1538
  var _a;
1484
- const baseURL = (_a = (0, import_provider_utils9.withoutTrailingSlash)(options.baseURL)) != null ? _a : "https://generativelanguage.googleapis.com/v1beta";
1485
- const getHeaders = () => (0, import_provider_utils9.withUserAgentSuffix)(
1539
+ const baseURL = (_a = (0, import_provider_utils11.withoutTrailingSlash)(options.baseURL)) != null ? _a : "https://generativelanguage.googleapis.com/v1beta";
1540
+ const getHeaders = () => (0, import_provider_utils11.withUserAgentSuffix)(
1486
1541
  {
1487
- "x-goog-api-key": (0, import_provider_utils9.loadApiKey)({
1542
+ "x-goog-api-key": (0, import_provider_utils11.loadApiKey)({
1488
1543
  apiKey: options.apiKey,
1489
1544
  environmentVariableName: "GOOGLE_GENERATIVE_AI_API_KEY",
1490
1545
  description: "Google Generative AI"
@@ -1499,7 +1554,7 @@ function createGoogleGenerativeAI(options = {}) {
1499
1554
  provider: "google.generative-ai",
1500
1555
  baseURL,
1501
1556
  headers: getHeaders,
1502
- generateId: (_a2 = options.generateId) != null ? _a2 : import_provider_utils9.generateId,
1557
+ generateId: (_a2 = options.generateId) != null ? _a2 : import_provider_utils11.generateId,
1503
1558
  supportedUrls: () => ({
1504
1559
  "*": [
1505
1560
  // Google Generative Language "files" endpoint