@ai-sdk/google 2.0.18 → 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.
package/dist/index.js CHANGED
@@ -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/index.ts
@@ -37,62 +27,71 @@ __export(src_exports, {
37
27
  module.exports = __toCommonJS(src_exports);
38
28
 
39
29
  // src/google-provider.ts
40
- var import_provider_utils9 = require("@ai-sdk/provider-utils");
30
+ var import_provider_utils11 = require("@ai-sdk/provider-utils");
41
31
 
42
32
  // src/version.ts
43
- var VERSION = true ? "2.0.18" : "0.0.0-test";
33
+ var VERSION = true ? "2.0.20" : "0.0.0-test";
44
34
 
45
35
  // src/google-generative-ai-embedding-model.ts
46
36
  var import_provider = require("@ai-sdk/provider");
47
- var import_provider_utils2 = require("@ai-sdk/provider-utils");
48
- var z3 = __toESM(require("zod/v4"));
37
+ var import_provider_utils3 = require("@ai-sdk/provider-utils");
38
+ var import_v43 = require("zod/v4");
49
39
 
50
40
  // src/google-error.ts
51
41
  var import_provider_utils = require("@ai-sdk/provider-utils");
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
- });
42
+ var import_v4 = require("zod/v4");
43
+ var googleErrorDataSchema = (0, import_provider_utils.lazySchema)(
44
+ () => (0, import_provider_utils.zodSchema)(
45
+ import_v4.z.object({
46
+ error: import_v4.z.object({
47
+ code: import_v4.z.number().nullable(),
48
+ message: import_v4.z.string(),
49
+ status: import_v4.z.string()
50
+ })
51
+ })
52
+ )
53
+ );
60
54
  var googleFailedResponseHandler = (0, import_provider_utils.createJsonErrorResponseHandler)({
61
55
  errorSchema: googleErrorDataSchema,
62
56
  errorToMessage: (data) => data.error.message
63
57
  });
64
58
 
65
59
  // src/google-generative-ai-embedding-options.ts
66
- 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
- });
60
+ var import_provider_utils2 = require("@ai-sdk/provider-utils");
61
+ var import_v42 = require("zod/v4");
62
+ var googleGenerativeAIEmbeddingProviderOptions = (0, import_provider_utils2.lazySchema)(
63
+ () => (0, import_provider_utils2.zodSchema)(
64
+ import_v42.z.object({
65
+ /**
66
+ * Optional. Optional reduced dimension for the output embedding.
67
+ * If set, excessive values in the output embedding are truncated from the end.
68
+ */
69
+ outputDimensionality: import_v42.z.number().optional(),
70
+ /**
71
+ * Optional. Specifies the task type for generating embeddings.
72
+ * Supported task types:
73
+ * - SEMANTIC_SIMILARITY: Optimized for text similarity.
74
+ * - CLASSIFICATION: Optimized for text classification.
75
+ * - CLUSTERING: Optimized for clustering texts based on similarity.
76
+ * - RETRIEVAL_DOCUMENT: Optimized for document retrieval.
77
+ * - RETRIEVAL_QUERY: Optimized for query-based retrieval.
78
+ * - QUESTION_ANSWERING: Optimized for answering questions.
79
+ * - FACT_VERIFICATION: Optimized for verifying factual information.
80
+ * - CODE_RETRIEVAL_QUERY: Optimized for retrieving code blocks based on natural language queries.
81
+ */
82
+ taskType: import_v42.z.enum([
83
+ "SEMANTIC_SIMILARITY",
84
+ "CLASSIFICATION",
85
+ "CLUSTERING",
86
+ "RETRIEVAL_DOCUMENT",
87
+ "RETRIEVAL_QUERY",
88
+ "QUESTION_ANSWERING",
89
+ "FACT_VERIFICATION",
90
+ "CODE_RETRIEVAL_QUERY"
91
+ ]).optional()
92
+ })
93
+ )
94
+ );
96
95
 
97
96
  // src/google-generative-ai-embedding-model.ts
98
97
  var GoogleGenerativeAIEmbeddingModel = class {
@@ -112,7 +111,7 @@ var GoogleGenerativeAIEmbeddingModel = class {
112
111
  abortSignal,
113
112
  providerOptions
114
113
  }) {
115
- const googleOptions = await (0, import_provider_utils2.parseProviderOptions)({
114
+ const googleOptions = await (0, import_provider_utils3.parseProviderOptions)({
116
115
  provider: "google",
117
116
  providerOptions,
118
117
  schema: googleGenerativeAIEmbeddingProviderOptions
@@ -125,8 +124,8 @@ var GoogleGenerativeAIEmbeddingModel = class {
125
124
  values
126
125
  });
127
126
  }
128
- const mergedHeaders = (0, import_provider_utils2.combineHeaders)(
129
- await (0, import_provider_utils2.resolve)(this.config.headers),
127
+ const mergedHeaders = (0, import_provider_utils3.combineHeaders)(
128
+ await (0, import_provider_utils3.resolve)(this.config.headers),
130
129
  headers
131
130
  );
132
131
  if (values.length === 1) {
@@ -134,7 +133,7 @@ var GoogleGenerativeAIEmbeddingModel = class {
134
133
  responseHeaders: responseHeaders2,
135
134
  value: response2,
136
135
  rawValue: rawValue2
137
- } = await (0, import_provider_utils2.postJsonToApi)({
136
+ } = await (0, import_provider_utils3.postJsonToApi)({
138
137
  url: `${this.config.baseURL}/models/${this.modelId}:embedContent`,
139
138
  headers: mergedHeaders,
140
139
  body: {
@@ -146,7 +145,7 @@ var GoogleGenerativeAIEmbeddingModel = class {
146
145
  taskType: googleOptions == null ? void 0 : googleOptions.taskType
147
146
  },
148
147
  failedResponseHandler: googleFailedResponseHandler,
149
- successfulResponseHandler: (0, import_provider_utils2.createJsonResponseHandler)(
148
+ successfulResponseHandler: (0, import_provider_utils3.createJsonResponseHandler)(
150
149
  googleGenerativeAISingleEmbeddingResponseSchema
151
150
  ),
152
151
  abortSignal,
@@ -162,7 +161,7 @@ var GoogleGenerativeAIEmbeddingModel = class {
162
161
  responseHeaders,
163
162
  value: response,
164
163
  rawValue
165
- } = await (0, import_provider_utils2.postJsonToApi)({
164
+ } = await (0, import_provider_utils3.postJsonToApi)({
166
165
  url: `${this.config.baseURL}/models/${this.modelId}:batchEmbedContents`,
167
166
  headers: mergedHeaders,
168
167
  body: {
@@ -174,7 +173,7 @@ var GoogleGenerativeAIEmbeddingModel = class {
174
173
  }))
175
174
  },
176
175
  failedResponseHandler: googleFailedResponseHandler,
177
- successfulResponseHandler: (0, import_provider_utils2.createJsonResponseHandler)(
176
+ successfulResponseHandler: (0, import_provider_utils3.createJsonResponseHandler)(
178
177
  googleGenerativeAITextEmbeddingResponseSchema
179
178
  ),
180
179
  abortSignal,
@@ -187,16 +186,24 @@ var GoogleGenerativeAIEmbeddingModel = class {
187
186
  };
188
187
  }
189
188
  };
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
- });
189
+ var googleGenerativeAITextEmbeddingResponseSchema = (0, import_provider_utils3.lazySchema)(
190
+ () => (0, import_provider_utils3.zodSchema)(
191
+ import_v43.z.object({
192
+ embeddings: import_v43.z.array(import_v43.z.object({ values: import_v43.z.array(import_v43.z.number()) }))
193
+ })
194
+ )
195
+ );
196
+ var googleGenerativeAISingleEmbeddingResponseSchema = (0, import_provider_utils3.lazySchema)(
197
+ () => (0, import_provider_utils3.zodSchema)(
198
+ import_v43.z.object({
199
+ embedding: import_v43.z.object({ values: import_v43.z.array(import_v43.z.number()) })
200
+ })
201
+ )
202
+ );
196
203
 
197
204
  // src/google-generative-ai-language-model.ts
198
205
  var import_provider_utils6 = require("@ai-sdk/provider-utils");
199
- var z7 = __toESM(require("zod/v4"));
206
+ var import_v45 = require("zod/v4");
200
207
 
201
208
  // src/convert-json-schema-to-openapi-schema.ts
202
209
  function convertJSONSchemaToOpenAPISchema(jsonSchema) {
@@ -294,7 +301,7 @@ function isEmptyObjectSchema(jsonSchema) {
294
301
 
295
302
  // src/convert-to-google-generative-ai-messages.ts
296
303
  var import_provider2 = require("@ai-sdk/provider");
297
- var import_provider_utils3 = require("@ai-sdk/provider-utils");
304
+ var import_provider_utils4 = require("@ai-sdk/provider-utils");
298
305
  function convertToGoogleGenerativeAIMessages(prompt, options) {
299
306
  var _a;
300
307
  const systemInstructionParts = [];
@@ -332,7 +339,7 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
332
339
  } : {
333
340
  inlineData: {
334
341
  mimeType: mediaType,
335
- data: (0, import_provider_utils3.convertToBase64)(part.data)
342
+ data: (0, import_provider_utils4.convertToBase64)(part.data)
336
343
  }
337
344
  }
338
345
  );
@@ -377,7 +384,7 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
377
384
  return {
378
385
  inlineData: {
379
386
  mimeType: part.mediaType,
380
- data: (0, import_provider_utils3.convertToBase64)(part.data)
387
+ data: (0, import_provider_utils4.convertToBase64)(part.data)
381
388
  }
382
389
  };
383
390
  }
@@ -468,72 +475,88 @@ function getModelPath(modelId) {
468
475
  }
469
476
 
470
477
  // src/google-generative-ai-options.ts
471
- 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(
497
- 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
- ]),
506
- threshold: z4.enum([
478
+ var import_provider_utils5 = require("@ai-sdk/provider-utils");
479
+ var import_v44 = require("zod/v4");
480
+ var googleGenerativeAIProviderOptions = (0, import_provider_utils5.lazySchema)(
481
+ () => (0, import_provider_utils5.zodSchema)(
482
+ import_v44.z.object({
483
+ responseModalities: import_v44.z.array(import_v44.z.enum(["TEXT", "IMAGE"])).optional(),
484
+ thinkingConfig: import_v44.z.object({
485
+ thinkingBudget: import_v44.z.number().optional(),
486
+ includeThoughts: import_v44.z.boolean().optional()
487
+ }).optional(),
488
+ /**
489
+ * Optional.
490
+ * The name of the cached content used as context to serve the prediction.
491
+ * Format: cachedContents/{cachedContent}
492
+ */
493
+ cachedContent: import_v44.z.string().optional(),
494
+ /**
495
+ * Optional. Enable structured output. Default is true.
496
+ *
497
+ * This is useful when the JSON Schema contains elements that are
498
+ * not supported by the OpenAPI schema version that
499
+ * Google Generative AI uses. You can use this to disable
500
+ * structured outputs if you need to.
501
+ */
502
+ structuredOutputs: import_v44.z.boolean().optional(),
503
+ /**
504
+ * Optional. A list of unique safety settings for blocking unsafe content.
505
+ */
506
+ safetySettings: import_v44.z.array(
507
+ import_v44.z.object({
508
+ category: import_v44.z.enum([
509
+ "HARM_CATEGORY_UNSPECIFIED",
510
+ "HARM_CATEGORY_HATE_SPEECH",
511
+ "HARM_CATEGORY_DANGEROUS_CONTENT",
512
+ "HARM_CATEGORY_HARASSMENT",
513
+ "HARM_CATEGORY_SEXUALLY_EXPLICIT",
514
+ "HARM_CATEGORY_CIVIC_INTEGRITY"
515
+ ]),
516
+ threshold: import_v44.z.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
+ ])
524
+ })
525
+ ).optional(),
526
+ threshold: import_v44.z.enum([
507
527
  "HARM_BLOCK_THRESHOLD_UNSPECIFIED",
508
528
  "BLOCK_LOW_AND_ABOVE",
509
529
  "BLOCK_MEDIUM_AND_ABOVE",
510
530
  "BLOCK_ONLY_HIGH",
511
531
  "BLOCK_NONE",
512
532
  "OFF"
513
- ])
533
+ ]).optional(),
534
+ /**
535
+ * Optional. Enables timestamp understanding for audio-only files.
536
+ *
537
+ * https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/audio-understanding
538
+ */
539
+ audioTimestamp: import_v44.z.boolean().optional(),
540
+ /**
541
+ * Optional. Defines labels used in billing reports. Available on Vertex AI only.
542
+ *
543
+ * https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/add-labels-to-api-calls
544
+ */
545
+ labels: import_v44.z.record(import_v44.z.string(), import_v44.z.string()).optional(),
546
+ /**
547
+ * Optional. If specified, the media resolution specified will be used.
548
+ *
549
+ * https://ai.google.dev/api/generate-content#MediaResolution
550
+ */
551
+ mediaResolution: import_v44.z.enum([
552
+ "MEDIA_RESOLUTION_UNSPECIFIED",
553
+ "MEDIA_RESOLUTION_LOW",
554
+ "MEDIA_RESOLUTION_MEDIUM",
555
+ "MEDIA_RESOLUTION_HIGH"
556
+ ]).optional()
514
557
  })
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
- });
558
+ )
559
+ );
537
560
 
538
561
  // src/google-prepare-tools.ts
539
562
  var import_provider3 = require("@ai-sdk/provider");
@@ -704,64 +727,6 @@ function mapGoogleGenerativeAIFinishReason({
704
727
  }
705
728
  }
706
729
 
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
730
  // src/google-generative-ai-language-model.ts
766
731
  var GoogleGenerativeAILanguageModel = class {
767
732
  constructor(modelId, config) {
@@ -1254,103 +1219,175 @@ function extractSources({
1254
1219
  title: chunk.web.title
1255
1220
  }));
1256
1221
  }
1257
- var contentSchema = z7.object({
1258
- parts: z7.array(
1259
- z7.union([
1222
+ var getGroundingMetadataSchema = () => import_v45.z.object({
1223
+ webSearchQueries: import_v45.z.array(import_v45.z.string()).nullish(),
1224
+ retrievalQueries: import_v45.z.array(import_v45.z.string()).nullish(),
1225
+ searchEntryPoint: import_v45.z.object({ renderedContent: import_v45.z.string() }).nullish(),
1226
+ groundingChunks: import_v45.z.array(
1227
+ import_v45.z.object({
1228
+ web: import_v45.z.object({ uri: import_v45.z.string(), title: import_v45.z.string() }).nullish(),
1229
+ retrievedContext: import_v45.z.object({ uri: import_v45.z.string(), title: import_v45.z.string() }).nullish()
1230
+ })
1231
+ ).nullish(),
1232
+ groundingSupports: import_v45.z.array(
1233
+ import_v45.z.object({
1234
+ segment: import_v45.z.object({
1235
+ startIndex: import_v45.z.number().nullish(),
1236
+ endIndex: import_v45.z.number().nullish(),
1237
+ text: import_v45.z.string().nullish()
1238
+ }),
1239
+ segment_text: import_v45.z.string().nullish(),
1240
+ groundingChunkIndices: import_v45.z.array(import_v45.z.number()).nullish(),
1241
+ supportChunkIndices: import_v45.z.array(import_v45.z.number()).nullish(),
1242
+ confidenceScores: import_v45.z.array(import_v45.z.number()).nullish(),
1243
+ confidenceScore: import_v45.z.array(import_v45.z.number()).nullish()
1244
+ })
1245
+ ).nullish(),
1246
+ retrievalMetadata: import_v45.z.union([
1247
+ import_v45.z.object({
1248
+ webDynamicRetrievalScore: import_v45.z.number()
1249
+ }),
1250
+ import_v45.z.object({})
1251
+ ]).nullish()
1252
+ });
1253
+ var getContentSchema = () => import_v45.z.object({
1254
+ parts: import_v45.z.array(
1255
+ import_v45.z.union([
1260
1256
  // note: order matters since text can be fully empty
1261
- z7.object({
1262
- functionCall: z7.object({
1263
- name: z7.string(),
1264
- args: z7.unknown()
1257
+ import_v45.z.object({
1258
+ functionCall: import_v45.z.object({
1259
+ name: import_v45.z.string(),
1260
+ args: import_v45.z.unknown()
1265
1261
  }),
1266
- thoughtSignature: z7.string().nullish()
1262
+ thoughtSignature: import_v45.z.string().nullish()
1267
1263
  }),
1268
- z7.object({
1269
- inlineData: z7.object({
1270
- mimeType: z7.string(),
1271
- data: z7.string()
1264
+ import_v45.z.object({
1265
+ inlineData: import_v45.z.object({
1266
+ mimeType: import_v45.z.string(),
1267
+ data: import_v45.z.string()
1272
1268
  })
1273
1269
  }),
1274
- z7.object({
1275
- executableCode: z7.object({
1276
- language: z7.string(),
1277
- code: z7.string()
1270
+ import_v45.z.object({
1271
+ executableCode: import_v45.z.object({
1272
+ language: import_v45.z.string(),
1273
+ code: import_v45.z.string()
1278
1274
  }).nullish(),
1279
- codeExecutionResult: z7.object({
1280
- outcome: z7.string(),
1281
- output: z7.string()
1275
+ codeExecutionResult: import_v45.z.object({
1276
+ outcome: import_v45.z.string(),
1277
+ output: import_v45.z.string()
1282
1278
  }).nullish(),
1283
- text: z7.string().nullish(),
1284
- thought: z7.boolean().nullish(),
1285
- thoughtSignature: z7.string().nullish()
1279
+ text: import_v45.z.string().nullish(),
1280
+ thought: import_v45.z.boolean().nullish(),
1281
+ thoughtSignature: import_v45.z.string().nullish()
1286
1282
  })
1287
1283
  ])
1288
1284
  ).nullish()
1289
1285
  });
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()
1286
+ var getSafetyRatingSchema = () => import_v45.z.object({
1287
+ category: import_v45.z.string().nullish(),
1288
+ probability: import_v45.z.string().nullish(),
1289
+ probabilityScore: import_v45.z.number().nullish(),
1290
+ severity: import_v45.z.string().nullish(),
1291
+ severityScore: import_v45.z.number().nullish(),
1292
+ blocked: import_v45.z.boolean().nullish()
1297
1293
  });
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()
1294
+ var usageSchema = import_v45.z.object({
1295
+ cachedContentTokenCount: import_v45.z.number().nullish(),
1296
+ thoughtsTokenCount: import_v45.z.number().nullish(),
1297
+ promptTokenCount: import_v45.z.number().nullish(),
1298
+ candidatesTokenCount: import_v45.z.number().nullish(),
1299
+ totalTokenCount: import_v45.z.number().nullish()
1304
1300
  });
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()
1301
+ var getUrlContextMetadataSchema = () => import_v45.z.object({
1302
+ urlMetadata: import_v45.z.array(
1303
+ import_v45.z.object({
1304
+ retrievedUrl: import_v45.z.string(),
1305
+ urlRetrievalStatus: import_v45.z.string()
1313
1306
  })
1314
- ),
1315
- usageMetadata: usageSchema.nullish(),
1316
- promptFeedback: z7.object({
1317
- blockReason: z7.string().nullish(),
1318
- safetyRatings: z7.array(safetyRatingSchema).nullish()
1319
- }).nullish()
1307
+ )
1320
1308
  });
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()
1309
+ var responseSchema = (0, import_provider_utils6.lazySchema)(
1310
+ () => (0, import_provider_utils6.zodSchema)(
1311
+ import_v45.z.object({
1312
+ candidates: import_v45.z.array(
1313
+ import_v45.z.object({
1314
+ content: getContentSchema().nullish().or(import_v45.z.object({}).strict()),
1315
+ finishReason: import_v45.z.string().nullish(),
1316
+ safetyRatings: import_v45.z.array(getSafetyRatingSchema()).nullish(),
1317
+ groundingMetadata: getGroundingMetadataSchema().nullish(),
1318
+ urlContextMetadata: getUrlContextMetadataSchema().nullish()
1319
+ })
1320
+ ),
1321
+ usageMetadata: usageSchema.nullish(),
1322
+ promptFeedback: import_v45.z.object({
1323
+ blockReason: import_v45.z.string().nullish(),
1324
+ safetyRatings: import_v45.z.array(getSafetyRatingSchema()).nullish()
1325
+ }).nullish()
1329
1326
  })
1330
- ).nullish(),
1331
- usageMetadata: usageSchema.nullish(),
1332
- promptFeedback: z7.object({
1333
- blockReason: z7.string().nullish(),
1334
- safetyRatings: z7.array(safetyRatingSchema).nullish()
1335
- }).nullish()
1336
- });
1327
+ )
1328
+ );
1329
+ var chunkSchema = (0, import_provider_utils6.lazySchema)(
1330
+ () => (0, import_provider_utils6.zodSchema)(
1331
+ import_v45.z.object({
1332
+ candidates: import_v45.z.array(
1333
+ import_v45.z.object({
1334
+ content: getContentSchema().nullish(),
1335
+ finishReason: import_v45.z.string().nullish(),
1336
+ safetyRatings: import_v45.z.array(getSafetyRatingSchema()).nullish(),
1337
+ groundingMetadata: getGroundingMetadataSchema().nullish(),
1338
+ urlContextMetadata: getUrlContextMetadataSchema().nullish()
1339
+ })
1340
+ ).nullish(),
1341
+ usageMetadata: usageSchema.nullish(),
1342
+ promptFeedback: import_v45.z.object({
1343
+ blockReason: import_v45.z.string().nullish(),
1344
+ safetyRatings: import_v45.z.array(getSafetyRatingSchema()).nullish()
1345
+ }).nullish()
1346
+ })
1347
+ )
1348
+ );
1337
1349
 
1338
1350
  // src/tool/code-execution.ts
1339
1351
  var import_provider_utils7 = require("@ai-sdk/provider-utils");
1340
- var z8 = __toESM(require("zod/v4"));
1352
+ var import_v46 = require("zod/v4");
1341
1353
  var codeExecution = (0, import_provider_utils7.createProviderDefinedToolFactoryWithOutputSchema)({
1342
1354
  id: "google.code_execution",
1343
1355
  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.")
1356
+ inputSchema: import_v46.z.object({
1357
+ language: import_v46.z.string().describe("The programming language of the code."),
1358
+ code: import_v46.z.string().describe("The code to be executed.")
1347
1359
  }),
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.")
1360
+ outputSchema: import_v46.z.object({
1361
+ outcome: import_v46.z.string().describe('The outcome of the execution (e.g., "OUTCOME_OK").'),
1362
+ output: import_v46.z.string().describe("The output from the code execution.")
1351
1363
  })
1352
1364
  });
1353
1365
 
1366
+ // src/tool/google-search.ts
1367
+ var import_provider_utils8 = require("@ai-sdk/provider-utils");
1368
+ var import_v47 = require("zod/v4");
1369
+ var googleSearch = (0, import_provider_utils8.createProviderDefinedToolFactory)({
1370
+ id: "google.google_search",
1371
+ name: "google_search",
1372
+ inputSchema: (0, import_provider_utils8.lazySchema)(
1373
+ () => (0, import_provider_utils8.zodSchema)(
1374
+ import_v47.z.object({
1375
+ mode: import_v47.z.enum(["MODE_DYNAMIC", "MODE_UNSPECIFIED"]).default("MODE_UNSPECIFIED"),
1376
+ dynamicThreshold: import_v47.z.number().default(1)
1377
+ })
1378
+ )
1379
+ )
1380
+ });
1381
+
1382
+ // src/tool/url-context.ts
1383
+ var import_provider_utils9 = require("@ai-sdk/provider-utils");
1384
+ var import_v48 = require("zod/v4");
1385
+ var urlContext = (0, import_provider_utils9.createProviderDefinedToolFactory)({
1386
+ id: "google.url_context",
1387
+ name: "url_context",
1388
+ inputSchema: (0, import_provider_utils9.lazySchema)(() => (0, import_provider_utils9.zodSchema)(import_v48.z.object({})))
1389
+ });
1390
+
1354
1391
  // src/google-tools.ts
1355
1392
  var googleTools = {
1356
1393
  /**
@@ -1377,8 +1414,8 @@ var googleTools = {
1377
1414
  };
1378
1415
 
1379
1416
  // src/google-generative-ai-image-model.ts
1380
- var import_provider_utils8 = require("@ai-sdk/provider-utils");
1381
- var z9 = __toESM(require("zod/v4"));
1417
+ var import_provider_utils10 = require("@ai-sdk/provider-utils");
1418
+ var import_v49 = require("zod/v4");
1382
1419
  var GoogleGenerativeAIImageModel = class {
1383
1420
  constructor(modelId, settings, config) {
1384
1421
  this.modelId = modelId;
@@ -1420,7 +1457,7 @@ var GoogleGenerativeAIImageModel = class {
1420
1457
  details: "This model does not support the `seed` option through this provider."
1421
1458
  });
1422
1459
  }
1423
- const googleOptions = await (0, import_provider_utils8.parseProviderOptions)({
1460
+ const googleOptions = await (0, import_provider_utils10.parseProviderOptions)({
1424
1461
  provider: "google",
1425
1462
  providerOptions,
1426
1463
  schema: googleImageProviderOptionsSchema
@@ -1439,12 +1476,12 @@ var GoogleGenerativeAIImageModel = class {
1439
1476
  instances: [{ prompt }],
1440
1477
  parameters
1441
1478
  };
1442
- const { responseHeaders, value: response } = await (0, import_provider_utils8.postJsonToApi)({
1479
+ const { responseHeaders, value: response } = await (0, import_provider_utils10.postJsonToApi)({
1443
1480
  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),
1481
+ headers: (0, import_provider_utils10.combineHeaders)(await (0, import_provider_utils10.resolve)(this.config.headers), headers),
1445
1482
  body,
1446
1483
  failedResponseHandler: googleFailedResponseHandler,
1447
- successfulResponseHandler: (0, import_provider_utils8.createJsonResponseHandler)(
1484
+ successfulResponseHandler: (0, import_provider_utils10.createJsonResponseHandler)(
1448
1485
  googleImageResponseSchema
1449
1486
  ),
1450
1487
  abortSignal,
@@ -1470,21 +1507,29 @@ var GoogleGenerativeAIImageModel = class {
1470
1507
  };
1471
1508
  }
1472
1509
  };
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
- });
1510
+ var googleImageResponseSchema = (0, import_provider_utils10.lazySchema)(
1511
+ () => (0, import_provider_utils10.zodSchema)(
1512
+ import_v49.z.object({
1513
+ predictions: import_v49.z.array(import_v49.z.object({ bytesBase64Encoded: import_v49.z.string() })).default([])
1514
+ })
1515
+ )
1516
+ );
1517
+ var googleImageProviderOptionsSchema = (0, import_provider_utils10.lazySchema)(
1518
+ () => (0, import_provider_utils10.zodSchema)(
1519
+ import_v49.z.object({
1520
+ personGeneration: import_v49.z.enum(["dont_allow", "allow_adult", "allow_all"]).nullish(),
1521
+ aspectRatio: import_v49.z.enum(["1:1", "3:4", "4:3", "9:16", "16:9"]).nullish()
1522
+ })
1523
+ )
1524
+ );
1480
1525
 
1481
1526
  // src/google-provider.ts
1482
1527
  function createGoogleGenerativeAI(options = {}) {
1483
1528
  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)(
1529
+ const baseURL = (_a = (0, import_provider_utils11.withoutTrailingSlash)(options.baseURL)) != null ? _a : "https://generativelanguage.googleapis.com/v1beta";
1530
+ const getHeaders = () => (0, import_provider_utils11.withUserAgentSuffix)(
1486
1531
  {
1487
- "x-goog-api-key": (0, import_provider_utils9.loadApiKey)({
1532
+ "x-goog-api-key": (0, import_provider_utils11.loadApiKey)({
1488
1533
  apiKey: options.apiKey,
1489
1534
  environmentVariableName: "GOOGLE_GENERATIVE_AI_API_KEY",
1490
1535
  description: "Google Generative AI"
@@ -1499,7 +1544,7 @@ function createGoogleGenerativeAI(options = {}) {
1499
1544
  provider: "google.generative-ai",
1500
1545
  baseURL,
1501
1546
  headers: getHeaders,
1502
- generateId: (_a2 = options.generateId) != null ? _a2 : import_provider_utils9.generateId,
1547
+ generateId: (_a2 = options.generateId) != null ? _a2 : import_provider_utils11.generateId,
1503
1548
  supportedUrls: () => ({
1504
1549
  "*": [
1505
1550
  // Google Generative Language "files" endpoint