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

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 ? "3.0.0-beta.15" : "0.0.0-test";
43
+ var VERSION = true ? "3.0.0-beta.17" : "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, _b;
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,41 +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
- /**
537
- * Optional. If specified, the media resolution specified will be used.
538
- *
539
- * https://ai.google.dev/api/generate-content#MediaResolution
540
- */
541
- mediaResolution: z4.enum([
542
- "MEDIA_RESOLUTION_UNSPECIFIED",
543
- "MEDIA_RESOLUTION_LOW",
544
- "MEDIA_RESOLUTION_MEDIUM",
545
- "MEDIA_RESOLUTION_HIGH"
546
- ]).optional()
547
- });
568
+ )
569
+ );
548
570
 
549
571
  // src/google-prepare-tools.ts
550
572
  var import_provider3 = require("@ai-sdk/provider");
@@ -720,64 +742,6 @@ function mapGoogleGenerativeAIFinishReason({
720
742
  }
721
743
  }
722
744
 
723
- // src/tool/google-search.ts
724
- var import_provider_utils4 = require("@ai-sdk/provider-utils");
725
- var z5 = __toESM(require("zod/v4"));
726
- var groundingChunkSchema = z5.object({
727
- web: z5.object({ uri: z5.string(), title: z5.string() }).nullish(),
728
- retrievedContext: z5.object({ uri: z5.string(), title: z5.string() }).nullish()
729
- });
730
- var groundingMetadataSchema = z5.object({
731
- webSearchQueries: z5.array(z5.string()).nullish(),
732
- retrievalQueries: z5.array(z5.string()).nullish(),
733
- searchEntryPoint: z5.object({ renderedContent: z5.string() }).nullish(),
734
- groundingChunks: z5.array(groundingChunkSchema).nullish(),
735
- groundingSupports: z5.array(
736
- z5.object({
737
- segment: z5.object({
738
- startIndex: z5.number().nullish(),
739
- endIndex: z5.number().nullish(),
740
- text: z5.string().nullish()
741
- }),
742
- segment_text: z5.string().nullish(),
743
- groundingChunkIndices: z5.array(z5.number()).nullish(),
744
- supportChunkIndices: z5.array(z5.number()).nullish(),
745
- confidenceScores: z5.array(z5.number()).nullish(),
746
- confidenceScore: z5.array(z5.number()).nullish()
747
- })
748
- ).nullish(),
749
- retrievalMetadata: z5.union([
750
- z5.object({
751
- webDynamicRetrievalScore: z5.number()
752
- }),
753
- z5.object({})
754
- ]).nullish()
755
- });
756
- var googleSearch = (0, import_provider_utils4.createProviderDefinedToolFactory)({
757
- id: "google.google_search",
758
- name: "google_search",
759
- inputSchema: z5.object({
760
- mode: z5.enum(["MODE_DYNAMIC", "MODE_UNSPECIFIED"]).default("MODE_UNSPECIFIED"),
761
- dynamicThreshold: z5.number().default(1)
762
- })
763
- });
764
-
765
- // src/tool/url-context.ts
766
- var import_provider_utils5 = require("@ai-sdk/provider-utils");
767
- var z6 = __toESM(require("zod/v4"));
768
- var urlMetadataSchema = z6.object({
769
- retrievedUrl: z6.string(),
770
- urlRetrievalStatus: z6.string()
771
- });
772
- var urlContextMetadataSchema = z6.object({
773
- urlMetadata: z6.array(urlMetadataSchema)
774
- });
775
- var urlContext = (0, import_provider_utils5.createProviderDefinedToolFactory)({
776
- id: "google.url_context",
777
- name: "url_context",
778
- inputSchema: z6.object({})
779
- });
780
-
781
745
  // src/google-generative-ai-language-model.ts
782
746
  var GoogleGenerativeAILanguageModel = class {
783
747
  constructor(modelId, config) {
@@ -1273,103 +1237,175 @@ function extractSources({
1273
1237
  title: chunk.web.title
1274
1238
  }));
1275
1239
  }
1276
- var contentSchema = z7.object({
1277
- parts: z7.array(
1278
- z7.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([
1279
1274
  // note: order matters since text can be fully empty
1280
- z7.object({
1281
- functionCall: z7.object({
1282
- name: z7.string(),
1283
- args: z7.unknown()
1275
+ z5.object({
1276
+ functionCall: z5.object({
1277
+ name: z5.string(),
1278
+ args: z5.unknown()
1284
1279
  }),
1285
- thoughtSignature: z7.string().nullish()
1280
+ thoughtSignature: z5.string().nullish()
1286
1281
  }),
1287
- z7.object({
1288
- inlineData: z7.object({
1289
- mimeType: z7.string(),
1290
- data: z7.string()
1282
+ z5.object({
1283
+ inlineData: z5.object({
1284
+ mimeType: z5.string(),
1285
+ data: z5.string()
1291
1286
  })
1292
1287
  }),
1293
- z7.object({
1294
- executableCode: z7.object({
1295
- language: z7.string(),
1296
- code: z7.string()
1288
+ z5.object({
1289
+ executableCode: z5.object({
1290
+ language: z5.string(),
1291
+ code: z5.string()
1297
1292
  }).nullish(),
1298
- codeExecutionResult: z7.object({
1299
- outcome: z7.string(),
1300
- output: z7.string()
1293
+ codeExecutionResult: z5.object({
1294
+ outcome: z5.string(),
1295
+ output: z5.string()
1301
1296
  }).nullish(),
1302
- text: z7.string().nullish(),
1303
- thought: z7.boolean().nullish(),
1304
- thoughtSignature: z7.string().nullish()
1297
+ text: z5.string().nullish(),
1298
+ thought: z5.boolean().nullish(),
1299
+ thoughtSignature: z5.string().nullish()
1305
1300
  })
1306
1301
  ])
1307
1302
  ).nullish()
1308
1303
  });
1309
- var safetyRatingSchema = z7.object({
1310
- category: z7.string().nullish(),
1311
- probability: z7.string().nullish(),
1312
- probabilityScore: z7.number().nullish(),
1313
- severity: z7.string().nullish(),
1314
- severityScore: z7.number().nullish(),
1315
- blocked: z7.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()
1316
1311
  });
1317
- var usageSchema = z7.object({
1318
- cachedContentTokenCount: z7.number().nullish(),
1319
- thoughtsTokenCount: z7.number().nullish(),
1320
- promptTokenCount: z7.number().nullish(),
1321
- candidatesTokenCount: z7.number().nullish(),
1322
- totalTokenCount: z7.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()
1323
1318
  });
1324
- var responseSchema = z7.object({
1325
- candidates: z7.array(
1326
- z7.object({
1327
- content: contentSchema.nullish().or(z7.object({}).strict()),
1328
- finishReason: z7.string().nullish(),
1329
- safetyRatings: z7.array(safetyRatingSchema).nullish(),
1330
- groundingMetadata: groundingMetadataSchema.nullish(),
1331
- urlContextMetadata: urlContextMetadataSchema.nullish()
1319
+ var getUrlContextMetadataSchema = () => z5.object({
1320
+ urlMetadata: z5.array(
1321
+ z5.object({
1322
+ retrievedUrl: z5.string(),
1323
+ urlRetrievalStatus: z5.string()
1332
1324
  })
1333
- ),
1334
- usageMetadata: usageSchema.nullish(),
1335
- promptFeedback: z7.object({
1336
- blockReason: z7.string().nullish(),
1337
- safetyRatings: z7.array(safetyRatingSchema).nullish()
1338
- }).nullish()
1325
+ )
1339
1326
  });
1340
- var chunkSchema = z7.object({
1341
- candidates: z7.array(
1342
- z7.object({
1343
- content: contentSchema.nullish(),
1344
- finishReason: z7.string().nullish(),
1345
- safetyRatings: z7.array(safetyRatingSchema).nullish(),
1346
- groundingMetadata: groundingMetadataSchema.nullish(),
1347
- 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()
1348
1344
  })
1349
- ).nullish(),
1350
- usageMetadata: usageSchema.nullish(),
1351
- promptFeedback: z7.object({
1352
- blockReason: z7.string().nullish(),
1353
- safetyRatings: z7.array(safetyRatingSchema).nullish()
1354
- }).nullish()
1355
- });
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
+ );
1356
1367
 
1357
1368
  // src/tool/code-execution.ts
1358
1369
  var import_provider_utils7 = require("@ai-sdk/provider-utils");
1359
- var z8 = __toESM(require("zod/v4"));
1370
+ var z6 = __toESM(require("zod/v4"));
1360
1371
  var codeExecution = (0, import_provider_utils7.createProviderDefinedToolFactoryWithOutputSchema)({
1361
1372
  id: "google.code_execution",
1362
1373
  name: "code_execution",
1363
- inputSchema: z8.object({
1364
- language: z8.string().describe("The programming language of the code."),
1365
- code: z8.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.")
1366
1377
  }),
1367
- outputSchema: z8.object({
1368
- outcome: z8.string().describe('The outcome of the execution (e.g., "OUTCOME_OK").'),
1369
- output: z8.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.")
1370
1381
  })
1371
1382
  });
1372
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
+
1373
1409
  // src/google-tools.ts
1374
1410
  var googleTools = {
1375
1411
  /**
@@ -1396,7 +1432,7 @@ var googleTools = {
1396
1432
  };
1397
1433
 
1398
1434
  // src/google-generative-ai-image-model.ts
1399
- var import_provider_utils8 = require("@ai-sdk/provider-utils");
1435
+ var import_provider_utils10 = require("@ai-sdk/provider-utils");
1400
1436
  var z9 = __toESM(require("zod/v4"));
1401
1437
  var GoogleGenerativeAIImageModel = class {
1402
1438
  constructor(modelId, settings, config) {
@@ -1439,7 +1475,7 @@ var GoogleGenerativeAIImageModel = class {
1439
1475
  details: "This model does not support the `seed` option through this provider."
1440
1476
  });
1441
1477
  }
1442
- const googleOptions = await (0, import_provider_utils8.parseProviderOptions)({
1478
+ const googleOptions = await (0, import_provider_utils10.parseProviderOptions)({
1443
1479
  provider: "google",
1444
1480
  providerOptions,
1445
1481
  schema: googleImageProviderOptionsSchema
@@ -1458,12 +1494,12 @@ var GoogleGenerativeAIImageModel = class {
1458
1494
  instances: [{ prompt }],
1459
1495
  parameters
1460
1496
  };
1461
- const { responseHeaders, value: response } = await (0, import_provider_utils8.postJsonToApi)({
1497
+ const { responseHeaders, value: response } = await (0, import_provider_utils10.postJsonToApi)({
1462
1498
  url: `${this.config.baseURL}/models/${this.modelId}:predict`,
1463
- 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),
1464
1500
  body,
1465
1501
  failedResponseHandler: googleFailedResponseHandler,
1466
- successfulResponseHandler: (0, import_provider_utils8.createJsonResponseHandler)(
1502
+ successfulResponseHandler: (0, import_provider_utils10.createJsonResponseHandler)(
1467
1503
  googleImageResponseSchema
1468
1504
  ),
1469
1505
  abortSignal,
@@ -1489,21 +1525,29 @@ var GoogleGenerativeAIImageModel = class {
1489
1525
  };
1490
1526
  }
1491
1527
  };
1492
- var googleImageResponseSchema = z9.object({
1493
- predictions: z9.array(z9.object({ bytesBase64Encoded: z9.string() })).default([])
1494
- });
1495
- var googleImageProviderOptionsSchema = z9.object({
1496
- personGeneration: z9.enum(["dont_allow", "allow_adult", "allow_all"]).nullish(),
1497
- aspectRatio: z9.enum(["1:1", "3:4", "4:3", "9:16", "16:9"]).nullish()
1498
- });
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
+ );
1499
1543
 
1500
1544
  // src/google-provider.ts
1501
1545
  function createGoogleGenerativeAI(options = {}) {
1502
1546
  var _a;
1503
- const baseURL = (_a = (0, import_provider_utils9.withoutTrailingSlash)(options.baseURL)) != null ? _a : "https://generativelanguage.googleapis.com/v1beta";
1504
- 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)(
1505
1549
  {
1506
- "x-goog-api-key": (0, import_provider_utils9.loadApiKey)({
1550
+ "x-goog-api-key": (0, import_provider_utils11.loadApiKey)({
1507
1551
  apiKey: options.apiKey,
1508
1552
  environmentVariableName: "GOOGLE_GENERATIVE_AI_API_KEY",
1509
1553
  description: "Google Generative AI"
@@ -1518,7 +1562,7 @@ function createGoogleGenerativeAI(options = {}) {
1518
1562
  provider: "google.generative-ai",
1519
1563
  baseURL,
1520
1564
  headers: getHeaders,
1521
- generateId: (_a2 = options.generateId) != null ? _a2 : import_provider_utils9.generateId,
1565
+ generateId: (_a2 = options.generateId) != null ? _a2 : import_provider_utils11.generateId,
1522
1566
  supportedUrls: () => ({
1523
1567
  "*": [
1524
1568
  // Google Generative Language "files" endpoint