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

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,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/index.ts
@@ -27,62 +37,71 @@ __export(src_exports, {
27
37
  module.exports = __toCommonJS(src_exports);
28
38
 
29
39
  // src/google-provider.ts
30
- var import_provider_utils9 = require("@ai-sdk/provider-utils");
40
+ var import_provider_utils11 = require("@ai-sdk/provider-utils");
31
41
 
32
42
  // src/version.ts
33
- var VERSION = true ? "3.0.0-beta.14" : "0.0.0-test";
43
+ var VERSION = true ? "3.0.0-beta.16" : "0.0.0-test";
34
44
 
35
45
  // src/google-generative-ai-embedding-model.ts
36
46
  var import_provider = require("@ai-sdk/provider");
37
- var import_provider_utils2 = require("@ai-sdk/provider-utils");
38
- var import_v43 = require("zod/v4");
47
+ var import_provider_utils3 = require("@ai-sdk/provider-utils");
48
+ var z3 = __toESM(require("zod/v4"));
39
49
 
40
50
  // src/google-error.ts
41
51
  var import_provider_utils = require("@ai-sdk/provider-utils");
42
- var import_v4 = require("zod/v4");
43
- var googleErrorDataSchema = import_v4.z.object({
44
- error: import_v4.z.object({
45
- code: import_v4.z.number().nullable(),
46
- message: import_v4.z.string(),
47
- status: import_v4.z.string()
48
- })
49
- });
52
+ var z = __toESM(require("zod/v4"));
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
+ );
50
64
  var googleFailedResponseHandler = (0, import_provider_utils.createJsonErrorResponseHandler)({
51
65
  errorSchema: googleErrorDataSchema,
52
66
  errorToMessage: (data) => data.error.message
53
67
  });
54
68
 
55
69
  // src/google-generative-ai-embedding-options.ts
56
- var import_v42 = require("zod/v4");
57
- var googleGenerativeAIEmbeddingProviderOptions = import_v42.z.object({
58
- /**
59
- * Optional. Optional reduced dimension for the output embedding.
60
- * If set, excessive values in the output embedding are truncated from the end.
61
- */
62
- outputDimensionality: import_v42.z.number().optional(),
63
- /**
64
- * Optional. Specifies the task type for generating embeddings.
65
- * Supported task types:
66
- * - SEMANTIC_SIMILARITY: Optimized for text similarity.
67
- * - CLASSIFICATION: Optimized for text classification.
68
- * - CLUSTERING: Optimized for clustering texts based on similarity.
69
- * - RETRIEVAL_DOCUMENT: Optimized for document retrieval.
70
- * - RETRIEVAL_QUERY: Optimized for query-based retrieval.
71
- * - QUESTION_ANSWERING: Optimized for answering questions.
72
- * - FACT_VERIFICATION: Optimized for verifying factual information.
73
- * - CODE_RETRIEVAL_QUERY: Optimized for retrieving code blocks based on natural language queries.
74
- */
75
- taskType: import_v42.z.enum([
76
- "SEMANTIC_SIMILARITY",
77
- "CLASSIFICATION",
78
- "CLUSTERING",
79
- "RETRIEVAL_DOCUMENT",
80
- "RETRIEVAL_QUERY",
81
- "QUESTION_ANSWERING",
82
- "FACT_VERIFICATION",
83
- "CODE_RETRIEVAL_QUERY"
84
- ]).optional()
85
- });
70
+ var import_provider_utils2 = require("@ai-sdk/provider-utils");
71
+ var z2 = __toESM(require("zod/v4"));
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
+ );
86
105
 
87
106
  // src/google-generative-ai-embedding-model.ts
88
107
  var GoogleGenerativeAIEmbeddingModel = class {
@@ -102,7 +121,7 @@ var GoogleGenerativeAIEmbeddingModel = class {
102
121
  abortSignal,
103
122
  providerOptions
104
123
  }) {
105
- const googleOptions = await (0, import_provider_utils2.parseProviderOptions)({
124
+ const googleOptions = await (0, import_provider_utils3.parseProviderOptions)({
106
125
  provider: "google",
107
126
  providerOptions,
108
127
  schema: googleGenerativeAIEmbeddingProviderOptions
@@ -115,8 +134,8 @@ var GoogleGenerativeAIEmbeddingModel = class {
115
134
  values
116
135
  });
117
136
  }
118
- const mergedHeaders = (0, import_provider_utils2.combineHeaders)(
119
- 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),
120
139
  headers
121
140
  );
122
141
  if (values.length === 1) {
@@ -124,7 +143,7 @@ var GoogleGenerativeAIEmbeddingModel = class {
124
143
  responseHeaders: responseHeaders2,
125
144
  value: response2,
126
145
  rawValue: rawValue2
127
- } = await (0, import_provider_utils2.postJsonToApi)({
146
+ } = await (0, import_provider_utils3.postJsonToApi)({
128
147
  url: `${this.config.baseURL}/models/${this.modelId}:embedContent`,
129
148
  headers: mergedHeaders,
130
149
  body: {
@@ -136,7 +155,7 @@ var GoogleGenerativeAIEmbeddingModel = class {
136
155
  taskType: googleOptions == null ? void 0 : googleOptions.taskType
137
156
  },
138
157
  failedResponseHandler: googleFailedResponseHandler,
139
- successfulResponseHandler: (0, import_provider_utils2.createJsonResponseHandler)(
158
+ successfulResponseHandler: (0, import_provider_utils3.createJsonResponseHandler)(
140
159
  googleGenerativeAISingleEmbeddingResponseSchema
141
160
  ),
142
161
  abortSignal,
@@ -152,7 +171,7 @@ var GoogleGenerativeAIEmbeddingModel = class {
152
171
  responseHeaders,
153
172
  value: response,
154
173
  rawValue
155
- } = await (0, import_provider_utils2.postJsonToApi)({
174
+ } = await (0, import_provider_utils3.postJsonToApi)({
156
175
  url: `${this.config.baseURL}/models/${this.modelId}:batchEmbedContents`,
157
176
  headers: mergedHeaders,
158
177
  body: {
@@ -164,7 +183,7 @@ var GoogleGenerativeAIEmbeddingModel = class {
164
183
  }))
165
184
  },
166
185
  failedResponseHandler: googleFailedResponseHandler,
167
- successfulResponseHandler: (0, import_provider_utils2.createJsonResponseHandler)(
186
+ successfulResponseHandler: (0, import_provider_utils3.createJsonResponseHandler)(
168
187
  googleGenerativeAITextEmbeddingResponseSchema
169
188
  ),
170
189
  abortSignal,
@@ -177,16 +196,24 @@ var GoogleGenerativeAIEmbeddingModel = class {
177
196
  };
178
197
  }
179
198
  };
180
- var googleGenerativeAITextEmbeddingResponseSchema = import_v43.z.object({
181
- embeddings: import_v43.z.array(import_v43.z.object({ values: import_v43.z.array(import_v43.z.number()) }))
182
- });
183
- var googleGenerativeAISingleEmbeddingResponseSchema = import_v43.z.object({
184
- embedding: import_v43.z.object({ values: import_v43.z.array(import_v43.z.number()) })
185
- });
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
+ );
186
213
 
187
214
  // src/google-generative-ai-language-model.ts
188
215
  var import_provider_utils6 = require("@ai-sdk/provider-utils");
189
- var import_v47 = require("zod/v4");
216
+ var z5 = __toESM(require("zod/v4"));
190
217
 
191
218
  // src/convert-json-schema-to-openapi-schema.ts
192
219
  function convertJSONSchemaToOpenAPISchema(jsonSchema) {
@@ -284,7 +311,7 @@ function isEmptyObjectSchema(jsonSchema) {
284
311
 
285
312
  // src/convert-to-google-generative-ai-messages.ts
286
313
  var import_provider2 = require("@ai-sdk/provider");
287
- var import_provider_utils3 = require("@ai-sdk/provider-utils");
314
+ var import_provider_utils4 = require("@ai-sdk/provider-utils");
288
315
  function convertToGoogleGenerativeAIMessages(prompt, options) {
289
316
  var _a, _b;
290
317
  const systemInstructionParts = [];
@@ -322,7 +349,7 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
322
349
  } : {
323
350
  inlineData: {
324
351
  mimeType: mediaType,
325
- data: (0, import_provider_utils3.convertToBase64)(part.data)
352
+ data: (0, import_provider_utils4.convertToBase64)(part.data)
326
353
  }
327
354
  }
328
355
  );
@@ -367,7 +394,7 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
367
394
  return {
368
395
  inlineData: {
369
396
  mimeType: part.mediaType,
370
- data: (0, import_provider_utils3.convertToBase64)(part.data)
397
+ data: (0, import_provider_utils4.convertToBase64)(part.data)
371
398
  }
372
399
  };
373
400
  }
@@ -458,83 +485,88 @@ function getModelPath(modelId) {
458
485
  }
459
486
 
460
487
  // src/google-generative-ai-options.ts
461
- var import_v44 = require("zod/v4");
462
- var googleGenerativeAIProviderOptions = import_v44.z.object({
463
- responseModalities: import_v44.z.array(import_v44.z.enum(["TEXT", "IMAGE"])).optional(),
464
- thinkingConfig: import_v44.z.object({
465
- thinkingBudget: import_v44.z.number().optional(),
466
- includeThoughts: import_v44.z.boolean().optional()
467
- }).optional(),
468
- /**
469
- Optional.
470
- The name of the cached content used as context to serve the prediction.
471
- Format: cachedContents/{cachedContent}
472
- */
473
- cachedContent: import_v44.z.string().optional(),
474
- /**
475
- * Optional. Enable structured output. Default is true.
476
- *
477
- * This is useful when the JSON Schema contains elements that are
478
- * not supported by the OpenAPI schema version that
479
- * Google Generative AI uses. You can use this to disable
480
- * structured outputs if you need to.
481
- */
482
- structuredOutputs: import_v44.z.boolean().optional(),
483
- /**
484
- Optional. A list of unique safety settings for blocking unsafe content.
485
- */
486
- safetySettings: import_v44.z.array(
487
- import_v44.z.object({
488
- category: import_v44.z.enum([
489
- "HARM_CATEGORY_UNSPECIFIED",
490
- "HARM_CATEGORY_HATE_SPEECH",
491
- "HARM_CATEGORY_DANGEROUS_CONTENT",
492
- "HARM_CATEGORY_HARASSMENT",
493
- "HARM_CATEGORY_SEXUALLY_EXPLICIT",
494
- "HARM_CATEGORY_CIVIC_INTEGRITY"
495
- ]),
496
- threshold: import_v44.z.enum([
488
+ var import_provider_utils5 = require("@ai-sdk/provider-utils");
489
+ var z4 = __toESM(require("zod/v4"));
490
+ var googleGenerativeAIProviderOptions = (0, import_provider_utils5.lazySchema)(
491
+ () => (0, import_provider_utils5.zodSchema)(
492
+ z4.object({
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(),
536
+ threshold: z4.enum([
497
537
  "HARM_BLOCK_THRESHOLD_UNSPECIFIED",
498
538
  "BLOCK_LOW_AND_ABOVE",
499
539
  "BLOCK_MEDIUM_AND_ABOVE",
500
540
  "BLOCK_ONLY_HIGH",
501
541
  "BLOCK_NONE",
502
542
  "OFF"
503
- ])
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()
504
567
  })
505
- ).optional(),
506
- threshold: import_v44.z.enum([
507
- "HARM_BLOCK_THRESHOLD_UNSPECIFIED",
508
- "BLOCK_LOW_AND_ABOVE",
509
- "BLOCK_MEDIUM_AND_ABOVE",
510
- "BLOCK_ONLY_HIGH",
511
- "BLOCK_NONE",
512
- "OFF"
513
- ]).optional(),
514
- /**
515
- * Optional. Enables timestamp understanding for audio-only files.
516
- *
517
- * https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/audio-understanding
518
- */
519
- audioTimestamp: import_v44.z.boolean().optional(),
520
- /**
521
- * Optional. Defines labels used in billing reports. Available on Vertex AI only.
522
- *
523
- * https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/add-labels-to-api-calls
524
- */
525
- labels: import_v44.z.record(import_v44.z.string(), import_v44.z.string()).optional(),
526
- /**
527
- * Optional. If specified, the media resolution specified will be used.
528
- *
529
- * https://ai.google.dev/api/generate-content#MediaResolution
530
- */
531
- mediaResolution: import_v44.z.enum([
532
- "MEDIA_RESOLUTION_UNSPECIFIED",
533
- "MEDIA_RESOLUTION_LOW",
534
- "MEDIA_RESOLUTION_MEDIUM",
535
- "MEDIA_RESOLUTION_HIGH"
536
- ]).optional()
537
- });
568
+ )
569
+ );
538
570
 
539
571
  // src/google-prepare-tools.ts
540
572
  var import_provider3 = require("@ai-sdk/provider");
@@ -710,64 +742,6 @@ function mapGoogleGenerativeAIFinishReason({
710
742
  }
711
743
  }
712
744
 
713
- // src/tool/google-search.ts
714
- var import_provider_utils4 = require("@ai-sdk/provider-utils");
715
- var import_v45 = require("zod/v4");
716
- var groundingChunkSchema = import_v45.z.object({
717
- web: import_v45.z.object({ uri: import_v45.z.string(), title: import_v45.z.string() }).nullish(),
718
- retrievedContext: import_v45.z.object({ uri: import_v45.z.string(), title: import_v45.z.string() }).nullish()
719
- });
720
- var groundingMetadataSchema = import_v45.z.object({
721
- webSearchQueries: import_v45.z.array(import_v45.z.string()).nullish(),
722
- retrievalQueries: import_v45.z.array(import_v45.z.string()).nullish(),
723
- searchEntryPoint: import_v45.z.object({ renderedContent: import_v45.z.string() }).nullish(),
724
- groundingChunks: import_v45.z.array(groundingChunkSchema).nullish(),
725
- groundingSupports: import_v45.z.array(
726
- import_v45.z.object({
727
- segment: import_v45.z.object({
728
- startIndex: import_v45.z.number().nullish(),
729
- endIndex: import_v45.z.number().nullish(),
730
- text: import_v45.z.string().nullish()
731
- }),
732
- segment_text: import_v45.z.string().nullish(),
733
- groundingChunkIndices: import_v45.z.array(import_v45.z.number()).nullish(),
734
- supportChunkIndices: import_v45.z.array(import_v45.z.number()).nullish(),
735
- confidenceScores: import_v45.z.array(import_v45.z.number()).nullish(),
736
- confidenceScore: import_v45.z.array(import_v45.z.number()).nullish()
737
- })
738
- ).nullish(),
739
- retrievalMetadata: import_v45.z.union([
740
- import_v45.z.object({
741
- webDynamicRetrievalScore: import_v45.z.number()
742
- }),
743
- import_v45.z.object({})
744
- ]).nullish()
745
- });
746
- var googleSearch = (0, import_provider_utils4.createProviderDefinedToolFactory)({
747
- id: "google.google_search",
748
- name: "google_search",
749
- inputSchema: import_v45.z.object({
750
- mode: import_v45.z.enum(["MODE_DYNAMIC", "MODE_UNSPECIFIED"]).default("MODE_UNSPECIFIED"),
751
- dynamicThreshold: import_v45.z.number().default(1)
752
- })
753
- });
754
-
755
- // src/tool/url-context.ts
756
- var import_provider_utils5 = require("@ai-sdk/provider-utils");
757
- var import_v46 = require("zod/v4");
758
- var urlMetadataSchema = import_v46.z.object({
759
- retrievedUrl: import_v46.z.string(),
760
- urlRetrievalStatus: import_v46.z.string()
761
- });
762
- var urlContextMetadataSchema = import_v46.z.object({
763
- urlMetadata: import_v46.z.array(urlMetadataSchema)
764
- });
765
- var urlContext = (0, import_provider_utils5.createProviderDefinedToolFactory)({
766
- id: "google.url_context",
767
- name: "url_context",
768
- inputSchema: import_v46.z.object({})
769
- });
770
-
771
745
  // src/google-generative-ai-language-model.ts
772
746
  var GoogleGenerativeAILanguageModel = class {
773
747
  constructor(modelId, config) {
@@ -1263,103 +1237,175 @@ function extractSources({
1263
1237
  title: chunk.web.title
1264
1238
  }));
1265
1239
  }
1266
- var contentSchema = import_v47.z.object({
1267
- parts: import_v47.z.array(
1268
- import_v47.z.union([
1240
+ var getGroundingMetadataSchema = () => z5.object({
1241
+ webSearchQueries: z5.array(z5.string()).nullish(),
1242
+ retrievalQueries: z5.array(z5.string()).nullish(),
1243
+ searchEntryPoint: z5.object({ renderedContent: z5.string() }).nullish(),
1244
+ groundingChunks: z5.array(
1245
+ z5.object({
1246
+ web: z5.object({ uri: z5.string(), title: z5.string() }).nullish(),
1247
+ retrievedContext: z5.object({ uri: z5.string(), title: z5.string() }).nullish()
1248
+ })
1249
+ ).nullish(),
1250
+ groundingSupports: z5.array(
1251
+ z5.object({
1252
+ segment: z5.object({
1253
+ startIndex: z5.number().nullish(),
1254
+ endIndex: z5.number().nullish(),
1255
+ text: z5.string().nullish()
1256
+ }),
1257
+ segment_text: z5.string().nullish(),
1258
+ groundingChunkIndices: z5.array(z5.number()).nullish(),
1259
+ supportChunkIndices: z5.array(z5.number()).nullish(),
1260
+ confidenceScores: z5.array(z5.number()).nullish(),
1261
+ confidenceScore: z5.array(z5.number()).nullish()
1262
+ })
1263
+ ).nullish(),
1264
+ retrievalMetadata: z5.union([
1265
+ z5.object({
1266
+ webDynamicRetrievalScore: z5.number()
1267
+ }),
1268
+ z5.object({})
1269
+ ]).nullish()
1270
+ });
1271
+ var getContentSchema = () => z5.object({
1272
+ parts: z5.array(
1273
+ z5.union([
1269
1274
  // note: order matters since text can be fully empty
1270
- import_v47.z.object({
1271
- functionCall: import_v47.z.object({
1272
- name: import_v47.z.string(),
1273
- args: import_v47.z.unknown()
1275
+ z5.object({
1276
+ functionCall: z5.object({
1277
+ name: z5.string(),
1278
+ args: z5.unknown()
1274
1279
  }),
1275
- thoughtSignature: import_v47.z.string().nullish()
1280
+ thoughtSignature: z5.string().nullish()
1276
1281
  }),
1277
- import_v47.z.object({
1278
- inlineData: import_v47.z.object({
1279
- mimeType: import_v47.z.string(),
1280
- data: import_v47.z.string()
1282
+ z5.object({
1283
+ inlineData: z5.object({
1284
+ mimeType: z5.string(),
1285
+ data: z5.string()
1281
1286
  })
1282
1287
  }),
1283
- import_v47.z.object({
1284
- executableCode: import_v47.z.object({
1285
- language: import_v47.z.string(),
1286
- code: import_v47.z.string()
1288
+ z5.object({
1289
+ executableCode: z5.object({
1290
+ language: z5.string(),
1291
+ code: z5.string()
1287
1292
  }).nullish(),
1288
- codeExecutionResult: import_v47.z.object({
1289
- outcome: import_v47.z.string(),
1290
- output: import_v47.z.string()
1293
+ codeExecutionResult: z5.object({
1294
+ outcome: z5.string(),
1295
+ output: z5.string()
1291
1296
  }).nullish(),
1292
- text: import_v47.z.string().nullish(),
1293
- thought: import_v47.z.boolean().nullish(),
1294
- thoughtSignature: import_v47.z.string().nullish()
1297
+ text: z5.string().nullish(),
1298
+ thought: z5.boolean().nullish(),
1299
+ thoughtSignature: z5.string().nullish()
1295
1300
  })
1296
1301
  ])
1297
1302
  ).nullish()
1298
1303
  });
1299
- var safetyRatingSchema = import_v47.z.object({
1300
- category: import_v47.z.string().nullish(),
1301
- probability: import_v47.z.string().nullish(),
1302
- probabilityScore: import_v47.z.number().nullish(),
1303
- severity: import_v47.z.string().nullish(),
1304
- severityScore: import_v47.z.number().nullish(),
1305
- blocked: import_v47.z.boolean().nullish()
1304
+ var getSafetyRatingSchema = () => z5.object({
1305
+ category: z5.string().nullish(),
1306
+ probability: z5.string().nullish(),
1307
+ probabilityScore: z5.number().nullish(),
1308
+ severity: z5.string().nullish(),
1309
+ severityScore: z5.number().nullish(),
1310
+ blocked: z5.boolean().nullish()
1306
1311
  });
1307
- var usageSchema = import_v47.z.object({
1308
- cachedContentTokenCount: import_v47.z.number().nullish(),
1309
- thoughtsTokenCount: import_v47.z.number().nullish(),
1310
- promptTokenCount: import_v47.z.number().nullish(),
1311
- candidatesTokenCount: import_v47.z.number().nullish(),
1312
- totalTokenCount: import_v47.z.number().nullish()
1312
+ var usageSchema = z5.object({
1313
+ cachedContentTokenCount: z5.number().nullish(),
1314
+ thoughtsTokenCount: z5.number().nullish(),
1315
+ promptTokenCount: z5.number().nullish(),
1316
+ candidatesTokenCount: z5.number().nullish(),
1317
+ totalTokenCount: z5.number().nullish()
1313
1318
  });
1314
- var responseSchema = import_v47.z.object({
1315
- candidates: import_v47.z.array(
1316
- import_v47.z.object({
1317
- content: contentSchema.nullish().or(import_v47.z.object({}).strict()),
1318
- finishReason: import_v47.z.string().nullish(),
1319
- safetyRatings: import_v47.z.array(safetyRatingSchema).nullish(),
1320
- groundingMetadata: groundingMetadataSchema.nullish(),
1321
- urlContextMetadata: urlContextMetadataSchema.nullish()
1319
+ var getUrlContextMetadataSchema = () => z5.object({
1320
+ urlMetadata: z5.array(
1321
+ z5.object({
1322
+ retrievedUrl: z5.string(),
1323
+ urlRetrievalStatus: z5.string()
1322
1324
  })
1323
- ),
1324
- usageMetadata: usageSchema.nullish(),
1325
- promptFeedback: import_v47.z.object({
1326
- blockReason: import_v47.z.string().nullish(),
1327
- safetyRatings: import_v47.z.array(safetyRatingSchema).nullish()
1328
- }).nullish()
1325
+ )
1329
1326
  });
1330
- var chunkSchema = import_v47.z.object({
1331
- candidates: import_v47.z.array(
1332
- import_v47.z.object({
1333
- content: contentSchema.nullish(),
1334
- finishReason: import_v47.z.string().nullish(),
1335
- safetyRatings: import_v47.z.array(safetyRatingSchema).nullish(),
1336
- groundingMetadata: groundingMetadataSchema.nullish(),
1337
- urlContextMetadata: urlContextMetadataSchema.nullish()
1327
+ var responseSchema = (0, import_provider_utils6.lazySchema)(
1328
+ () => (0, import_provider_utils6.zodSchema)(
1329
+ z5.object({
1330
+ candidates: z5.array(
1331
+ z5.object({
1332
+ content: getContentSchema().nullish().or(z5.object({}).strict()),
1333
+ finishReason: z5.string().nullish(),
1334
+ safetyRatings: z5.array(getSafetyRatingSchema()).nullish(),
1335
+ groundingMetadata: getGroundingMetadataSchema().nullish(),
1336
+ urlContextMetadata: getUrlContextMetadataSchema().nullish()
1337
+ })
1338
+ ),
1339
+ usageMetadata: usageSchema.nullish(),
1340
+ promptFeedback: z5.object({
1341
+ blockReason: z5.string().nullish(),
1342
+ safetyRatings: z5.array(getSafetyRatingSchema()).nullish()
1343
+ }).nullish()
1338
1344
  })
1339
- ).nullish(),
1340
- usageMetadata: usageSchema.nullish(),
1341
- promptFeedback: import_v47.z.object({
1342
- blockReason: import_v47.z.string().nullish(),
1343
- safetyRatings: import_v47.z.array(safetyRatingSchema).nullish()
1344
- }).nullish()
1345
- });
1345
+ )
1346
+ );
1347
+ var chunkSchema = (0, import_provider_utils6.lazySchema)(
1348
+ () => (0, import_provider_utils6.zodSchema)(
1349
+ z5.object({
1350
+ candidates: z5.array(
1351
+ z5.object({
1352
+ content: getContentSchema().nullish(),
1353
+ finishReason: z5.string().nullish(),
1354
+ safetyRatings: z5.array(getSafetyRatingSchema()).nullish(),
1355
+ groundingMetadata: getGroundingMetadataSchema().nullish(),
1356
+ urlContextMetadata: getUrlContextMetadataSchema().nullish()
1357
+ })
1358
+ ).nullish(),
1359
+ usageMetadata: usageSchema.nullish(),
1360
+ promptFeedback: z5.object({
1361
+ blockReason: z5.string().nullish(),
1362
+ safetyRatings: z5.array(getSafetyRatingSchema()).nullish()
1363
+ }).nullish()
1364
+ })
1365
+ )
1366
+ );
1346
1367
 
1347
1368
  // src/tool/code-execution.ts
1348
1369
  var import_provider_utils7 = require("@ai-sdk/provider-utils");
1349
- var import_v48 = require("zod/v4");
1370
+ var z6 = __toESM(require("zod/v4"));
1350
1371
  var codeExecution = (0, import_provider_utils7.createProviderDefinedToolFactoryWithOutputSchema)({
1351
1372
  id: "google.code_execution",
1352
1373
  name: "code_execution",
1353
- inputSchema: import_v48.z.object({
1354
- language: import_v48.z.string().describe("The programming language of the code."),
1355
- code: import_v48.z.string().describe("The code to be executed.")
1374
+ inputSchema: z6.object({
1375
+ language: z6.string().describe("The programming language of the code."),
1376
+ code: z6.string().describe("The code to be executed.")
1356
1377
  }),
1357
- outputSchema: import_v48.z.object({
1358
- outcome: import_v48.z.string().describe('The outcome of the execution (e.g., "OUTCOME_OK").'),
1359
- output: import_v48.z.string().describe("The output from the code execution.")
1378
+ outputSchema: z6.object({
1379
+ outcome: z6.string().describe('The outcome of the execution (e.g., "OUTCOME_OK").'),
1380
+ output: z6.string().describe("The output from the code execution.")
1360
1381
  })
1361
1382
  });
1362
1383
 
1384
+ // src/tool/google-search.ts
1385
+ var import_provider_utils8 = require("@ai-sdk/provider-utils");
1386
+ var z7 = __toESM(require("zod/v4"));
1387
+ var googleSearch = (0, import_provider_utils8.createProviderDefinedToolFactory)({
1388
+ id: "google.google_search",
1389
+ name: "google_search",
1390
+ inputSchema: (0, import_provider_utils8.lazySchema)(
1391
+ () => (0, import_provider_utils8.zodSchema)(
1392
+ z7.object({
1393
+ mode: z7.enum(["MODE_DYNAMIC", "MODE_UNSPECIFIED"]).default("MODE_UNSPECIFIED"),
1394
+ dynamicThreshold: z7.number().default(1)
1395
+ })
1396
+ )
1397
+ )
1398
+ });
1399
+
1400
+ // src/tool/url-context.ts
1401
+ var import_provider_utils9 = require("@ai-sdk/provider-utils");
1402
+ var z8 = __toESM(require("zod/v4"));
1403
+ var urlContext = (0, import_provider_utils9.createProviderDefinedToolFactory)({
1404
+ id: "google.url_context",
1405
+ name: "url_context",
1406
+ inputSchema: (0, import_provider_utils9.lazySchema)(() => (0, import_provider_utils9.zodSchema)(z8.object({})))
1407
+ });
1408
+
1363
1409
  // src/google-tools.ts
1364
1410
  var googleTools = {
1365
1411
  /**
@@ -1386,8 +1432,8 @@ var googleTools = {
1386
1432
  };
1387
1433
 
1388
1434
  // src/google-generative-ai-image-model.ts
1389
- var import_provider_utils8 = require("@ai-sdk/provider-utils");
1390
- var import_v49 = require("zod/v4");
1435
+ var import_provider_utils10 = require("@ai-sdk/provider-utils");
1436
+ var z9 = __toESM(require("zod/v4"));
1391
1437
  var GoogleGenerativeAIImageModel = class {
1392
1438
  constructor(modelId, settings, config) {
1393
1439
  this.modelId = modelId;
@@ -1429,7 +1475,7 @@ var GoogleGenerativeAIImageModel = class {
1429
1475
  details: "This model does not support the `seed` option through this provider."
1430
1476
  });
1431
1477
  }
1432
- const googleOptions = await (0, import_provider_utils8.parseProviderOptions)({
1478
+ const googleOptions = await (0, import_provider_utils10.parseProviderOptions)({
1433
1479
  provider: "google",
1434
1480
  providerOptions,
1435
1481
  schema: googleImageProviderOptionsSchema
@@ -1448,12 +1494,12 @@ var GoogleGenerativeAIImageModel = class {
1448
1494
  instances: [{ prompt }],
1449
1495
  parameters
1450
1496
  };
1451
- const { responseHeaders, value: response } = await (0, import_provider_utils8.postJsonToApi)({
1497
+ const { responseHeaders, value: response } = await (0, import_provider_utils10.postJsonToApi)({
1452
1498
  url: `${this.config.baseURL}/models/${this.modelId}:predict`,
1453
- headers: (0, import_provider_utils8.combineHeaders)(await (0, import_provider_utils8.resolve)(this.config.headers), headers),
1499
+ headers: (0, import_provider_utils10.combineHeaders)(await (0, import_provider_utils10.resolve)(this.config.headers), headers),
1454
1500
  body,
1455
1501
  failedResponseHandler: googleFailedResponseHandler,
1456
- successfulResponseHandler: (0, import_provider_utils8.createJsonResponseHandler)(
1502
+ successfulResponseHandler: (0, import_provider_utils10.createJsonResponseHandler)(
1457
1503
  googleImageResponseSchema
1458
1504
  ),
1459
1505
  abortSignal,
@@ -1479,21 +1525,29 @@ var GoogleGenerativeAIImageModel = class {
1479
1525
  };
1480
1526
  }
1481
1527
  };
1482
- var googleImageResponseSchema = import_v49.z.object({
1483
- predictions: import_v49.z.array(import_v49.z.object({ bytesBase64Encoded: import_v49.z.string() })).default([])
1484
- });
1485
- var googleImageProviderOptionsSchema = import_v49.z.object({
1486
- personGeneration: import_v49.z.enum(["dont_allow", "allow_adult", "allow_all"]).nullish(),
1487
- aspectRatio: import_v49.z.enum(["1:1", "3:4", "4:3", "9:16", "16:9"]).nullish()
1488
- });
1528
+ var googleImageResponseSchema = (0, import_provider_utils10.lazySchema)(
1529
+ () => (0, import_provider_utils10.zodSchema)(
1530
+ z9.object({
1531
+ predictions: z9.array(z9.object({ bytesBase64Encoded: z9.string() })).default([])
1532
+ })
1533
+ )
1534
+ );
1535
+ var googleImageProviderOptionsSchema = (0, import_provider_utils10.lazySchema)(
1536
+ () => (0, import_provider_utils10.zodSchema)(
1537
+ z9.object({
1538
+ personGeneration: z9.enum(["dont_allow", "allow_adult", "allow_all"]).nullish(),
1539
+ aspectRatio: z9.enum(["1:1", "3:4", "4:3", "9:16", "16:9"]).nullish()
1540
+ })
1541
+ )
1542
+ );
1489
1543
 
1490
1544
  // src/google-provider.ts
1491
1545
  function createGoogleGenerativeAI(options = {}) {
1492
1546
  var _a;
1493
- const baseURL = (_a = (0, import_provider_utils9.withoutTrailingSlash)(options.baseURL)) != null ? _a : "https://generativelanguage.googleapis.com/v1beta";
1494
- const getHeaders = () => (0, import_provider_utils9.withUserAgentSuffix)(
1547
+ const baseURL = (_a = (0, import_provider_utils11.withoutTrailingSlash)(options.baseURL)) != null ? _a : "https://generativelanguage.googleapis.com/v1beta";
1548
+ const getHeaders = () => (0, import_provider_utils11.withUserAgentSuffix)(
1495
1549
  {
1496
- "x-goog-api-key": (0, import_provider_utils9.loadApiKey)({
1550
+ "x-goog-api-key": (0, import_provider_utils11.loadApiKey)({
1497
1551
  apiKey: options.apiKey,
1498
1552
  environmentVariableName: "GOOGLE_GENERATIVE_AI_API_KEY",
1499
1553
  description: "Google Generative AI"
@@ -1508,7 +1562,7 @@ function createGoogleGenerativeAI(options = {}) {
1508
1562
  provider: "google.generative-ai",
1509
1563
  baseURL,
1510
1564
  headers: getHeaders,
1511
- generateId: (_a2 = options.generateId) != null ? _a2 : import_provider_utils9.generateId,
1565
+ generateId: (_a2 = options.generateId) != null ? _a2 : import_provider_utils11.generateId,
1512
1566
  supportedUrls: () => ({
1513
1567
  "*": [
1514
1568
  // Google Generative Language "files" endpoint