@ai-sdk/google 4.0.0-beta.9 → 4.0.0-canary.51

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.
Files changed (47) hide show
  1. package/CHANGELOG.md +354 -4
  2. package/README.md +6 -4
  3. package/dist/index.d.ts +97 -54
  4. package/dist/index.js +1643 -575
  5. package/dist/index.js.map +1 -1
  6. package/dist/internal/index.d.ts +62 -22
  7. package/dist/internal/index.js +1261 -449
  8. package/dist/internal/index.js.map +1 -1
  9. package/docs/{15-google-generative-ai.mdx → 15-google.mdx} +46 -40
  10. package/package.json +13 -14
  11. package/src/{convert-google-generative-ai-usage.ts → convert-google-usage.ts} +11 -4
  12. package/src/convert-json-schema-to-openapi-schema.ts +1 -1
  13. package/src/convert-to-google-messages.ts +585 -0
  14. package/src/{google-generative-ai-embedding-options.ts → google-embedding-model-options.ts} +2 -2
  15. package/src/{google-generative-ai-embedding-model.ts → google-embedding-model.ts} +28 -15
  16. package/src/google-error.ts +1 -1
  17. package/src/google-files.ts +225 -0
  18. package/src/google-image-model-options.ts +23 -0
  19. package/src/{google-generative-ai-image-model.ts → google-image-model.ts} +61 -49
  20. package/src/{google-generative-ai-image-settings.ts → google-image-settings.ts} +2 -2
  21. package/src/google-json-accumulator.ts +336 -0
  22. package/src/{google-generative-ai-options.ts → google-language-model-options.ts} +32 -5
  23. package/src/{google-generative-ai-language-model.ts → google-language-model.ts} +586 -191
  24. package/src/google-prepare-tools.ts +68 -8
  25. package/src/google-prompt.ts +82 -0
  26. package/src/google-provider.ts +56 -47
  27. package/src/google-video-model-options.ts +43 -0
  28. package/src/{google-generative-ai-video-model.ts → google-video-model.ts} +11 -50
  29. package/src/{google-generative-ai-video-settings.ts → google-video-settings.ts} +2 -1
  30. package/src/index.ts +28 -9
  31. package/src/internal/index.ts +2 -2
  32. package/src/{map-google-generative-ai-finish-reason.ts → map-google-finish-reason.ts} +2 -2
  33. package/src/tool/code-execution.ts +2 -2
  34. package/src/tool/enterprise-web-search.ts +9 -3
  35. package/src/tool/file-search.ts +5 -7
  36. package/src/tool/google-maps.ts +3 -2
  37. package/src/tool/google-search.ts +10 -11
  38. package/src/tool/url-context.ts +4 -2
  39. package/src/tool/vertex-rag-store.ts +9 -6
  40. package/dist/index.d.mts +0 -384
  41. package/dist/index.mjs +0 -2519
  42. package/dist/index.mjs.map +0 -1
  43. package/dist/internal/index.d.mts +0 -287
  44. package/dist/internal/index.mjs +0 -1708
  45. package/dist/internal/index.mjs.map +0 -1
  46. package/src/convert-to-google-generative-ai-messages.ts +0 -239
  47. package/src/google-generative-ai-prompt.ts +0 -47
@@ -1,38 +1,25 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/internal/index.ts
21
- var internal_exports = {};
22
- __export(internal_exports, {
23
- GoogleGenerativeAILanguageModel: () => GoogleGenerativeAILanguageModel,
24
- getGroundingMetadataSchema: () => getGroundingMetadataSchema,
25
- getUrlContextMetadataSchema: () => getUrlContextMetadataSchema,
26
- googleTools: () => googleTools
27
- });
28
- module.exports = __toCommonJS(internal_exports);
1
+ // src/google-language-model.ts
2
+ import {
3
+ combineHeaders,
4
+ createEventSourceResponseHandler,
5
+ createJsonResponseHandler,
6
+ generateId,
7
+ isCustomReasoning,
8
+ lazySchema as lazySchema3,
9
+ mapReasoningToProviderBudget,
10
+ mapReasoningToProviderEffort,
11
+ parseProviderOptions,
12
+ postJsonToApi,
13
+ resolve,
14
+ serializeModelOptions,
15
+ WORKFLOW_SERIALIZE,
16
+ WORKFLOW_DESERIALIZE,
17
+ zodSchema as zodSchema3
18
+ } from "@ai-sdk/provider-utils";
19
+ import { z as z3 } from "zod/v4";
29
20
 
30
- // src/google-generative-ai-language-model.ts
31
- var import_provider_utils4 = require("@ai-sdk/provider-utils");
32
- var import_v43 = require("zod/v4");
33
-
34
- // src/convert-google-generative-ai-usage.ts
35
- function convertGoogleGenerativeAIUsage(usage) {
21
+ // src/convert-google-usage.ts
22
+ function convertGoogleUsage(usage) {
36
23
  var _a, _b, _c, _d;
37
24
  if (usage == null) {
38
25
  return {
@@ -186,21 +173,151 @@ function isEmptyObjectSchema(jsonSchema) {
186
173
  return jsonSchema != null && typeof jsonSchema === "object" && jsonSchema.type === "object" && (jsonSchema.properties == null || Object.keys(jsonSchema.properties).length === 0) && !jsonSchema.additionalProperties;
187
174
  }
188
175
 
189
- // src/convert-to-google-generative-ai-messages.ts
190
- var import_provider = require("@ai-sdk/provider");
191
- var import_provider_utils = require("@ai-sdk/provider-utils");
192
- function convertToGoogleGenerativeAIMessages(prompt, options) {
193
- var _a, _b, _c;
176
+ // src/convert-to-google-messages.ts
177
+ import {
178
+ UnsupportedFunctionalityError
179
+ } from "@ai-sdk/provider";
180
+ import {
181
+ convertToBase64,
182
+ getTopLevelMediaType,
183
+ isFullMediaType,
184
+ resolveFullMediaType,
185
+ resolveProviderReference
186
+ } from "@ai-sdk/provider-utils";
187
+ var dataUrlRegex = /^data:([^;,]+);base64,(.+)$/s;
188
+ function parseBase64DataUrl(value) {
189
+ const match = dataUrlRegex.exec(value);
190
+ if (match == null) {
191
+ return void 0;
192
+ }
193
+ return {
194
+ mediaType: match[1],
195
+ data: match[2]
196
+ };
197
+ }
198
+ function convertUrlToolResultPart(url) {
199
+ const parsedDataUrl = parseBase64DataUrl(url);
200
+ if (parsedDataUrl == null) {
201
+ return void 0;
202
+ }
203
+ return {
204
+ inlineData: {
205
+ mimeType: parsedDataUrl.mediaType,
206
+ data: parsedDataUrl.data
207
+ }
208
+ };
209
+ }
210
+ function appendToolResultParts(parts, toolName, outputValue) {
211
+ const functionResponseParts = [];
212
+ const responseTextParts = [];
213
+ for (const contentPart of outputValue) {
214
+ switch (contentPart.type) {
215
+ case "text": {
216
+ responseTextParts.push(contentPart.text);
217
+ break;
218
+ }
219
+ case "file": {
220
+ if (contentPart.data.type === "data") {
221
+ functionResponseParts.push({
222
+ inlineData: {
223
+ mimeType: resolveFullMediaType({ part: contentPart }),
224
+ data: convertToBase64(contentPart.data.data)
225
+ }
226
+ });
227
+ } else if (contentPart.data.type === "url") {
228
+ const functionResponsePart = convertUrlToolResultPart(
229
+ contentPart.data.url.toString()
230
+ );
231
+ if (functionResponsePart != null) {
232
+ functionResponseParts.push(functionResponsePart);
233
+ } else {
234
+ responseTextParts.push(JSON.stringify(contentPart));
235
+ }
236
+ } else {
237
+ responseTextParts.push(JSON.stringify(contentPart));
238
+ }
239
+ break;
240
+ }
241
+ default: {
242
+ responseTextParts.push(JSON.stringify(contentPart));
243
+ break;
244
+ }
245
+ }
246
+ }
247
+ parts.push({
248
+ functionResponse: {
249
+ name: toolName,
250
+ response: {
251
+ name: toolName,
252
+ content: responseTextParts.length > 0 ? responseTextParts.join("\n") : "Tool executed successfully."
253
+ },
254
+ ...functionResponseParts.length > 0 ? { parts: functionResponseParts } : {}
255
+ }
256
+ });
257
+ }
258
+ function appendLegacyToolResultParts(parts, toolName, outputValue) {
259
+ for (const contentPart of outputValue) {
260
+ switch (contentPart.type) {
261
+ case "text":
262
+ parts.push({
263
+ functionResponse: {
264
+ name: toolName,
265
+ response: {
266
+ name: toolName,
267
+ content: contentPart.text
268
+ }
269
+ }
270
+ });
271
+ break;
272
+ case "file": {
273
+ if (contentPart.data.type === "data" && getTopLevelMediaType(contentPart.mediaType) === "image") {
274
+ parts.push(
275
+ {
276
+ inlineData: {
277
+ mimeType: resolveFullMediaType({ part: contentPart }),
278
+ data: convertToBase64(contentPart.data.data)
279
+ }
280
+ },
281
+ {
282
+ text: "Tool executed successfully and returned this image as a response"
283
+ }
284
+ );
285
+ } else {
286
+ parts.push({ text: JSON.stringify(contentPart) });
287
+ }
288
+ break;
289
+ }
290
+ default:
291
+ parts.push({ text: JSON.stringify(contentPart) });
292
+ break;
293
+ }
294
+ }
295
+ }
296
+ function convertToGoogleMessages(prompt, options) {
297
+ var _a, _b, _c, _d;
194
298
  const systemInstructionParts = [];
195
299
  const contents = [];
196
300
  let systemMessagesAllowed = true;
197
301
  const isGemmaModel = (_a = options == null ? void 0 : options.isGemmaModel) != null ? _a : false;
198
- const providerOptionsName = (_b = options == null ? void 0 : options.providerOptionsName) != null ? _b : "google";
302
+ const providerOptionsNames = (_b = options == null ? void 0 : options.providerOptionsNames) != null ? _b : ["google"];
303
+ const isVertexLike = !providerOptionsNames.includes("google");
304
+ const supportsFunctionResponseParts = (_c = options == null ? void 0 : options.supportsFunctionResponseParts) != null ? _c : true;
305
+ const readProviderOpts = (part) => {
306
+ var _a2, _b2, _c2, _d2, _e;
307
+ for (const name of providerOptionsNames) {
308
+ const v = (_a2 = part.providerOptions) == null ? void 0 : _a2[name];
309
+ if (v != null) return v;
310
+ }
311
+ if (isVertexLike) {
312
+ return (_b2 = part.providerOptions) == null ? void 0 : _b2.google;
313
+ }
314
+ return (_e = (_c2 = part.providerOptions) == null ? void 0 : _c2.googleVertex) != null ? _e : (_d2 = part.providerOptions) == null ? void 0 : _d2.vertex;
315
+ };
199
316
  for (const { role, content } of prompt) {
200
317
  switch (role) {
201
318
  case "system": {
202
319
  if (!systemMessagesAllowed) {
203
- throw new import_provider.UnsupportedFunctionalityError({
320
+ throw new UnsupportedFunctionalityError({
204
321
  functionality: "system messages are only supported at the beginning of the conversation"
205
322
  });
206
323
  }
@@ -217,20 +334,54 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
217
334
  break;
218
335
  }
219
336
  case "file": {
220
- const mediaType = part.mediaType === "image/*" ? "image/jpeg" : part.mediaType;
221
- parts.push(
222
- part.data instanceof URL ? {
223
- fileData: {
224
- mimeType: mediaType,
225
- fileUri: part.data.toString()
226
- }
227
- } : {
228
- inlineData: {
229
- mimeType: mediaType,
230
- data: (0, import_provider_utils.convertToBase64)(part.data)
337
+ switch (part.data.type) {
338
+ case "url": {
339
+ parts.push({
340
+ fileData: {
341
+ mimeType: resolveFullMediaType({ part }),
342
+ fileUri: part.data.url.toString()
343
+ }
344
+ });
345
+ break;
346
+ }
347
+ case "reference": {
348
+ if (isVertexLike) {
349
+ throw new UnsupportedFunctionalityError({
350
+ functionality: "file parts with provider references"
351
+ });
231
352
  }
353
+ parts.push({
354
+ fileData: {
355
+ mimeType: resolveFullMediaType({ part }),
356
+ fileUri: resolveProviderReference({
357
+ reference: part.data.reference,
358
+ provider: "google"
359
+ })
360
+ }
361
+ });
362
+ break;
363
+ }
364
+ case "text": {
365
+ parts.push({
366
+ inlineData: {
367
+ mimeType: isFullMediaType(part.mediaType) ? part.mediaType : "text/plain",
368
+ data: convertToBase64(
369
+ new TextEncoder().encode(part.data.text)
370
+ )
371
+ }
372
+ });
373
+ break;
232
374
  }
233
- );
375
+ case "data": {
376
+ parts.push({
377
+ inlineData: {
378
+ mimeType: resolveFullMediaType({ part }),
379
+ data: convertToBase64(part.data.data)
380
+ }
381
+ });
382
+ break;
383
+ }
384
+ }
234
385
  break;
235
386
  }
236
387
  }
@@ -243,8 +394,7 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
243
394
  contents.push({
244
395
  role: "model",
245
396
  parts: content.map((part) => {
246
- var _a2, _b2, _c2, _d;
247
- const providerOpts = (_d = (_a2 = part.providerOptions) == null ? void 0 : _a2[providerOptionsName]) != null ? _d : providerOptionsName !== "google" ? (_b2 = part.providerOptions) == null ? void 0 : _b2.google : (_c2 = part.providerOptions) == null ? void 0 : _c2.vertex;
397
+ const providerOpts = readProviderOpts(part);
248
398
  const thoughtSignature = (providerOpts == null ? void 0 : providerOpts.thoughtSignature) != null ? String(providerOpts.thoughtSignature) : void 0;
249
399
  switch (part.type) {
250
400
  case "text": {
@@ -260,22 +410,89 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
260
410
  thoughtSignature
261
411
  };
262
412
  }
413
+ case "reasoning-file": {
414
+ switch (part.data.type) {
415
+ case "url": {
416
+ throw new UnsupportedFunctionalityError({
417
+ functionality: "File data URLs in assistant messages are not supported"
418
+ });
419
+ }
420
+ case "data": {
421
+ return {
422
+ inlineData: {
423
+ mimeType: part.mediaType,
424
+ data: convertToBase64(part.data.data)
425
+ },
426
+ thought: true,
427
+ thoughtSignature
428
+ };
429
+ }
430
+ }
431
+ break;
432
+ }
263
433
  case "file": {
264
- if (part.data instanceof URL) {
265
- throw new import_provider.UnsupportedFunctionalityError({
266
- functionality: "File data URLs in assistant messages are not supported"
267
- });
434
+ switch (part.data.type) {
435
+ case "url": {
436
+ throw new UnsupportedFunctionalityError({
437
+ functionality: "File data URLs in assistant messages are not supported"
438
+ });
439
+ }
440
+ case "reference": {
441
+ if (isVertexLike) {
442
+ throw new UnsupportedFunctionalityError({
443
+ functionality: "file parts with provider references"
444
+ });
445
+ }
446
+ return {
447
+ fileData: {
448
+ mimeType: part.mediaType,
449
+ fileUri: resolveProviderReference({
450
+ reference: part.data.reference,
451
+ provider: "google"
452
+ })
453
+ },
454
+ ...(providerOpts == null ? void 0 : providerOpts.thought) === true ? { thought: true } : {},
455
+ thoughtSignature
456
+ };
457
+ }
458
+ case "text": {
459
+ return {
460
+ inlineData: {
461
+ mimeType: isFullMediaType(part.mediaType) ? part.mediaType : "text/plain",
462
+ data: convertToBase64(
463
+ new TextEncoder().encode(part.data.text)
464
+ )
465
+ },
466
+ ...(providerOpts == null ? void 0 : providerOpts.thought) === true ? { thought: true } : {},
467
+ thoughtSignature
468
+ };
469
+ }
470
+ case "data": {
471
+ return {
472
+ inlineData: {
473
+ mimeType: part.mediaType,
474
+ data: convertToBase64(part.data.data)
475
+ },
476
+ ...(providerOpts == null ? void 0 : providerOpts.thought) === true ? { thought: true } : {},
477
+ thoughtSignature
478
+ };
479
+ }
268
480
  }
269
- return {
270
- inlineData: {
271
- mimeType: part.mediaType,
272
- data: (0, import_provider_utils.convertToBase64)(part.data)
273
- },
274
- ...(providerOpts == null ? void 0 : providerOpts.thought) === true ? { thought: true } : {},
275
- thoughtSignature
276
- };
481
+ break;
277
482
  }
278
483
  case "tool-call": {
484
+ const serverToolCallId = (providerOpts == null ? void 0 : providerOpts.serverToolCallId) != null ? String(providerOpts.serverToolCallId) : void 0;
485
+ const serverToolType = (providerOpts == null ? void 0 : providerOpts.serverToolType) != null ? String(providerOpts.serverToolType) : void 0;
486
+ if (serverToolCallId && serverToolType) {
487
+ return {
488
+ toolCall: {
489
+ toolType: serverToolType,
490
+ args: typeof part.input === "string" ? JSON.parse(part.input) : part.input,
491
+ id: serverToolCallId
492
+ },
493
+ thoughtSignature
494
+ };
495
+ }
279
496
  return {
280
497
  functionCall: {
281
498
  name: part.toolName,
@@ -284,6 +501,21 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
284
501
  thoughtSignature
285
502
  };
286
503
  }
504
+ case "tool-result": {
505
+ const serverToolCallId = (providerOpts == null ? void 0 : providerOpts.serverToolCallId) != null ? String(providerOpts.serverToolCallId) : void 0;
506
+ const serverToolType = (providerOpts == null ? void 0 : providerOpts.serverToolType) != null ? String(providerOpts.serverToolType) : void 0;
507
+ if (serverToolCallId && serverToolType) {
508
+ return {
509
+ toolResponse: {
510
+ toolType: serverToolType,
511
+ response: part.output.type === "json" ? part.output.value : {},
512
+ id: serverToolCallId
513
+ },
514
+ thoughtSignature
515
+ };
516
+ }
517
+ return void 0;
518
+ }
287
519
  }
288
520
  }).filter((part) => part !== void 0)
289
521
  });
@@ -296,38 +528,32 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
296
528
  if (part.type === "tool-approval-response") {
297
529
  continue;
298
530
  }
531
+ const partProviderOpts = readProviderOpts(part);
532
+ const serverToolCallId = (partProviderOpts == null ? void 0 : partProviderOpts.serverToolCallId) != null ? String(partProviderOpts.serverToolCallId) : void 0;
533
+ const serverToolType = (partProviderOpts == null ? void 0 : partProviderOpts.serverToolType) != null ? String(partProviderOpts.serverToolType) : void 0;
534
+ if (serverToolCallId && serverToolType) {
535
+ const serverThoughtSignature = (partProviderOpts == null ? void 0 : partProviderOpts.thoughtSignature) != null ? String(partProviderOpts.thoughtSignature) : void 0;
536
+ if (contents.length > 0) {
537
+ const lastContent = contents[contents.length - 1];
538
+ if (lastContent.role === "model") {
539
+ lastContent.parts.push({
540
+ toolResponse: {
541
+ toolType: serverToolType,
542
+ response: part.output.type === "json" ? part.output.value : {},
543
+ id: serverToolCallId
544
+ },
545
+ thoughtSignature: serverThoughtSignature
546
+ });
547
+ continue;
548
+ }
549
+ }
550
+ }
299
551
  const output = part.output;
300
552
  if (output.type === "content") {
301
- for (const contentPart of output.value) {
302
- switch (contentPart.type) {
303
- case "text":
304
- parts.push({
305
- functionResponse: {
306
- name: part.toolName,
307
- response: {
308
- name: part.toolName,
309
- content: contentPart.text
310
- }
311
- }
312
- });
313
- break;
314
- case "image-data":
315
- parts.push(
316
- {
317
- inlineData: {
318
- mimeType: contentPart.mediaType,
319
- data: contentPart.data
320
- }
321
- },
322
- {
323
- text: "Tool executed successfully and returned this image as a response"
324
- }
325
- );
326
- break;
327
- default:
328
- parts.push({ text: JSON.stringify(contentPart) });
329
- break;
330
- }
553
+ if (supportsFunctionResponseParts) {
554
+ appendToolResultParts(parts, part.toolName, output.value);
555
+ } else {
556
+ appendLegacyToolResultParts(parts, part.toolName, output.value);
331
557
  }
332
558
  } else {
333
559
  parts.push({
@@ -335,7 +561,7 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
335
561
  name: part.toolName,
336
562
  response: {
337
563
  name: part.toolName,
338
- content: output.type === "execution-denied" ? (_c = output.reason) != null ? _c : "Tool execution denied." : output.value
564
+ content: output.type === "execution-denied" ? (_d = output.reason) != null ? _d : "Tool call execution denied." : output.value
339
565
  }
340
566
  }
341
567
  });
@@ -365,58 +591,65 @@ function getModelPath(modelId) {
365
591
  }
366
592
 
367
593
  // src/google-error.ts
368
- var import_provider_utils2 = require("@ai-sdk/provider-utils");
369
- var import_v4 = require("zod/v4");
370
- var googleErrorDataSchema = (0, import_provider_utils2.lazySchema)(
371
- () => (0, import_provider_utils2.zodSchema)(
372
- import_v4.z.object({
373
- error: import_v4.z.object({
374
- code: import_v4.z.number().nullable(),
375
- message: import_v4.z.string(),
376
- status: import_v4.z.string()
594
+ import {
595
+ createJsonErrorResponseHandler,
596
+ lazySchema,
597
+ zodSchema
598
+ } from "@ai-sdk/provider-utils";
599
+ import { z } from "zod/v4";
600
+ var googleErrorDataSchema = lazySchema(
601
+ () => zodSchema(
602
+ z.object({
603
+ error: z.object({
604
+ code: z.number().nullable(),
605
+ message: z.string(),
606
+ status: z.string()
377
607
  })
378
608
  })
379
609
  )
380
610
  );
381
- var googleFailedResponseHandler = (0, import_provider_utils2.createJsonErrorResponseHandler)({
611
+ var googleFailedResponseHandler = createJsonErrorResponseHandler({
382
612
  errorSchema: googleErrorDataSchema,
383
613
  errorToMessage: (data) => data.error.message
384
614
  });
385
615
 
386
- // src/google-generative-ai-options.ts
387
- var import_provider_utils3 = require("@ai-sdk/provider-utils");
388
- var import_v42 = require("zod/v4");
389
- var googleLanguageModelOptions = (0, import_provider_utils3.lazySchema)(
390
- () => (0, import_provider_utils3.zodSchema)(
391
- import_v42.z.object({
392
- responseModalities: import_v42.z.array(import_v42.z.enum(["TEXT", "IMAGE"])).optional(),
393
- thinkingConfig: import_v42.z.object({
394
- thinkingBudget: import_v42.z.number().optional(),
395
- includeThoughts: import_v42.z.boolean().optional(),
616
+ // src/google-language-model-options.ts
617
+ import {
618
+ lazySchema as lazySchema2,
619
+ zodSchema as zodSchema2
620
+ } from "@ai-sdk/provider-utils";
621
+ import { z as z2 } from "zod/v4";
622
+ var googleLanguageModelOptions = lazySchema2(
623
+ () => zodSchema2(
624
+ z2.object({
625
+ responseModalities: z2.array(z2.enum(["TEXT", "IMAGE"])).optional(),
626
+ thinkingConfig: z2.object({
627
+ thinkingBudget: z2.number().optional(),
628
+ includeThoughts: z2.boolean().optional(),
396
629
  // https://ai.google.dev/gemini-api/docs/gemini-3?thinking=high#thinking_level
397
- thinkingLevel: import_v42.z.enum(["minimal", "low", "medium", "high"]).optional()
630
+ thinkingLevel: z2.enum(["minimal", "low", "medium", "high"]).optional()
398
631
  }).optional(),
399
632
  /**
400
633
  * Optional.
401
634
  * The name of the cached content used as context to serve the prediction.
402
635
  * Format: cachedContents/{cachedContent}
403
636
  */
404
- cachedContent: import_v42.z.string().optional(),
637
+ cachedContent: z2.string().optional(),
405
638
  /**
406
639
  * Optional. Enable structured output. Default is true.
407
640
  *
408
641
  * This is useful when the JSON Schema contains elements that are
409
642
  * not supported by the OpenAPI schema version that
410
- * Google Generative AI uses. You can use this to disable
643
+ * Google uses. You can use this to disable
411
644
  * structured outputs if you need to.
412
645
  */
413
- structuredOutputs: import_v42.z.boolean().optional(),
646
+ structuredOutputs: z2.boolean().optional(),
414
647
  /**
415
648
  * Optional. A list of unique safety settings for blocking unsafe content.
416
649
  */
417
- safetySettings: import_v42.z.array(
418
- import_v42.z.object({
419
- category: import_v42.z.enum([
650
+ safetySettings: z2.array(
651
+ z2.object({
652
+ category: z2.enum([
420
653
  "HARM_CATEGORY_UNSPECIFIED",
421
654
  "HARM_CATEGORY_HATE_SPEECH",
422
655
  "HARM_CATEGORY_DANGEROUS_CONTENT",
@@ -424,7 +657,7 @@ var googleLanguageModelOptions = (0, import_provider_utils3.lazySchema)(
424
657
  "HARM_CATEGORY_SEXUALLY_EXPLICIT",
425
658
  "HARM_CATEGORY_CIVIC_INTEGRITY"
426
659
  ]),
427
- threshold: import_v42.z.enum([
660
+ threshold: z2.enum([
428
661
  "HARM_BLOCK_THRESHOLD_UNSPECIFIED",
429
662
  "BLOCK_LOW_AND_ABOVE",
430
663
  "BLOCK_MEDIUM_AND_ABOVE",
@@ -434,7 +667,7 @@ var googleLanguageModelOptions = (0, import_provider_utils3.lazySchema)(
434
667
  ])
435
668
  })
436
669
  ).optional(),
437
- threshold: import_v42.z.enum([
670
+ threshold: z2.enum([
438
671
  "HARM_BLOCK_THRESHOLD_UNSPECIFIED",
439
672
  "BLOCK_LOW_AND_ABOVE",
440
673
  "BLOCK_MEDIUM_AND_ABOVE",
@@ -447,19 +680,19 @@ var googleLanguageModelOptions = (0, import_provider_utils3.lazySchema)(
447
680
  *
448
681
  * https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/audio-understanding
449
682
  */
450
- audioTimestamp: import_v42.z.boolean().optional(),
683
+ audioTimestamp: z2.boolean().optional(),
451
684
  /**
452
685
  * Optional. Defines labels used in billing reports. Available on Vertex AI only.
453
686
  *
454
687
  * https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/add-labels-to-api-calls
455
688
  */
456
- labels: import_v42.z.record(import_v42.z.string(), import_v42.z.string()).optional(),
689
+ labels: z2.record(z2.string(), z2.string()).optional(),
457
690
  /**
458
691
  * Optional. If specified, the media resolution specified will be used.
459
692
  *
460
693
  * https://ai.google.dev/api/generate-content#MediaResolution
461
694
  */
462
- mediaResolution: import_v42.z.enum([
695
+ mediaResolution: z2.enum([
463
696
  "MEDIA_RESOLUTION_UNSPECIFIED",
464
697
  "MEDIA_RESOLUTION_LOW",
465
698
  "MEDIA_RESOLUTION_MEDIUM",
@@ -470,8 +703,8 @@ var googleLanguageModelOptions = (0, import_provider_utils3.lazySchema)(
470
703
  *
471
704
  * https://ai.google.dev/gemini-api/docs/image-generation#aspect_ratios
472
705
  */
473
- imageConfig: import_v42.z.object({
474
- aspectRatio: import_v42.z.enum([
706
+ imageConfig: z2.object({
707
+ aspectRatio: z2.enum([
475
708
  "1:1",
476
709
  "2:3",
477
710
  "3:2",
@@ -487,7 +720,7 @@ var googleLanguageModelOptions = (0, import_provider_utils3.lazySchema)(
487
720
  "1:4",
488
721
  "4:1"
489
722
  ]).optional(),
490
- imageSize: import_v42.z.enum(["1K", "2K", "4K", "512"]).optional()
723
+ imageSize: z2.enum(["1K", "2K", "4K", "512"]).optional()
491
724
  }).optional(),
492
725
  /**
493
726
  * Optional. Configuration for grounding retrieval.
@@ -495,24 +728,47 @@ var googleLanguageModelOptions = (0, import_provider_utils3.lazySchema)(
495
728
  *
496
729
  * https://cloud.google.com/vertex-ai/generative-ai/docs/grounding/grounding-with-google-maps
497
730
  */
498
- retrievalConfig: import_v42.z.object({
499
- latLng: import_v42.z.object({
500
- latitude: import_v42.z.number(),
501
- longitude: import_v42.z.number()
731
+ retrievalConfig: z2.object({
732
+ latLng: z2.object({
733
+ latitude: z2.number(),
734
+ longitude: z2.number()
502
735
  }).optional()
503
- }).optional()
736
+ }).optional(),
737
+ /**
738
+ * Optional. When set to true, function call arguments will be streamed
739
+ * incrementally via partialArgs in streaming responses. Only supported
740
+ * on the Vertex AI API (not the Gemini API) and only for Gemini 3+
741
+ * models.
742
+ *
743
+ * @default false
744
+ *
745
+ * https://docs.cloud.google.com/vertex-ai/generative-ai/docs/multimodal/function-calling#streaming-fc
746
+ */
747
+ streamFunctionCallArguments: z2.boolean().optional(),
748
+ /**
749
+ * Optional. The service tier to use for the request.
750
+ */
751
+ serviceTier: z2.enum(["standard", "flex", "priority"]).optional()
504
752
  })
505
753
  )
506
754
  );
755
+ var VertexServiceTierMap = {
756
+ standard: "SERVICE_TIER_STANDARD",
757
+ flex: "SERVICE_TIER_FLEX",
758
+ priority: "SERVICE_TIER_PRIORITY"
759
+ };
507
760
 
508
761
  // src/google-prepare-tools.ts
509
- var import_provider2 = require("@ai-sdk/provider");
762
+ import {
763
+ UnsupportedFunctionalityError as UnsupportedFunctionalityError2
764
+ } from "@ai-sdk/provider";
510
765
  function prepareTools({
511
766
  tools,
512
767
  toolChoice,
513
- modelId
768
+ modelId,
769
+ isVertexProvider = false
514
770
  }) {
515
- var _a;
771
+ var _a, _b;
516
772
  tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
517
773
  const toolWarnings = [];
518
774
  const isLatest = [
@@ -521,13 +777,14 @@ function prepareTools({
521
777
  "gemini-pro-latest"
522
778
  ].some((id) => id === modelId);
523
779
  const isGemini2orNewer = modelId.includes("gemini-2") || modelId.includes("gemini-3") || modelId.includes("nano-banana") || isLatest;
780
+ const isGemini3orNewer = modelId.includes("gemini-3");
524
781
  const supportsFileSearch = modelId.includes("gemini-2.5") || modelId.includes("gemini-3");
525
782
  if (tools == null) {
526
783
  return { tools: void 0, toolConfig: void 0, toolWarnings };
527
784
  }
528
785
  const hasFunctionTools = tools.some((tool) => tool.type === "function");
529
786
  const hasProviderTools = tools.some((tool) => tool.type === "provider");
530
- if (hasFunctionTools && hasProviderTools) {
787
+ if (hasFunctionTools && hasProviderTools && !isGemini3orNewer) {
531
788
  toolWarnings.push({
532
789
  type: "unsupported",
533
790
  feature: `combination of function and provider-defined tools`
@@ -578,7 +835,7 @@ function prepareTools({
578
835
  toolWarnings.push({
579
836
  type: "unsupported",
580
837
  feature: `provider-defined tool ${tool.id}`,
581
- details: "The code execution tools is not supported with other Gemini models than Gemini 2."
838
+ details: "The code execution tool is not supported with other Gemini models than Gemini 2."
582
839
  });
583
840
  }
584
841
  break;
@@ -632,6 +889,47 @@ function prepareTools({
632
889
  break;
633
890
  }
634
891
  });
892
+ if (hasFunctionTools && isGemini3orNewer && googleTools2.length > 0) {
893
+ const functionDeclarations2 = [];
894
+ for (const tool of tools) {
895
+ if (tool.type === "function") {
896
+ functionDeclarations2.push({
897
+ name: tool.name,
898
+ description: (_a = tool.description) != null ? _a : "",
899
+ parameters: convertJSONSchemaToOpenAPISchema(tool.inputSchema)
900
+ });
901
+ }
902
+ }
903
+ const combinedToolConfig = {
904
+ functionCallingConfig: { mode: "VALIDATED" },
905
+ ...!isVertexProvider && {
906
+ includeServerSideToolInvocations: true
907
+ }
908
+ };
909
+ if (toolChoice != null) {
910
+ switch (toolChoice.type) {
911
+ case "auto":
912
+ break;
913
+ case "none":
914
+ combinedToolConfig.functionCallingConfig = { mode: "NONE" };
915
+ break;
916
+ case "required":
917
+ combinedToolConfig.functionCallingConfig = { mode: "ANY" };
918
+ break;
919
+ case "tool":
920
+ combinedToolConfig.functionCallingConfig = {
921
+ mode: "ANY",
922
+ allowedFunctionNames: [toolChoice.toolName]
923
+ };
924
+ break;
925
+ }
926
+ }
927
+ return {
928
+ tools: [...googleTools2, { functionDeclarations: functionDeclarations2 }],
929
+ toolConfig: combinedToolConfig,
930
+ toolWarnings
931
+ };
932
+ }
635
933
  return {
636
934
  tools: googleTools2.length > 0 ? googleTools2 : void 0,
637
935
  toolConfig: void 0,
@@ -645,7 +943,7 @@ function prepareTools({
645
943
  case "function":
646
944
  functionDeclarations.push({
647
945
  name: tool.name,
648
- description: (_a = tool.description) != null ? _a : "",
946
+ description: (_b = tool.description) != null ? _b : "",
649
947
  parameters: convertJSONSchemaToOpenAPISchema(tool.inputSchema)
650
948
  });
651
949
  if (tool.strict === true) {
@@ -708,15 +1006,238 @@ function prepareTools({
708
1006
  };
709
1007
  default: {
710
1008
  const _exhaustiveCheck = type;
711
- throw new import_provider2.UnsupportedFunctionalityError({
1009
+ throw new UnsupportedFunctionalityError2({
712
1010
  functionality: `tool choice type: ${_exhaustiveCheck}`
713
1011
  });
714
1012
  }
715
1013
  }
716
1014
  }
717
1015
 
718
- // src/map-google-generative-ai-finish-reason.ts
719
- function mapGoogleGenerativeAIFinishReason({
1016
+ // src/google-json-accumulator.ts
1017
+ var GoogleJSONAccumulator = class {
1018
+ constructor() {
1019
+ this.accumulatedArgs = {};
1020
+ this.jsonText = "";
1021
+ /**
1022
+ * Stack representing the currently "open" containers in the JSON output.
1023
+ * Entry 0 is always the root `{` object once the first value is written.
1024
+ */
1025
+ this.pathStack = [];
1026
+ /**
1027
+ * Whether a string value is currently "open" (willContinue was true),
1028
+ * meaning the closing quote has not yet been emitted.
1029
+ */
1030
+ this.stringOpen = false;
1031
+ }
1032
+ /**
1033
+ * Input: [{jsonPath:"$.brightness",numberValue:50}]
1034
+ * Output: { currentJSON:{brightness:50}, textDelta:'{"brightness":50' }
1035
+ */
1036
+ processPartialArgs(partialArgs) {
1037
+ let delta = "";
1038
+ for (const arg of partialArgs) {
1039
+ const rawPath = arg.jsonPath.replace(/^\$\./, "");
1040
+ if (!rawPath) continue;
1041
+ const segments = parsePath(rawPath);
1042
+ const existingValue = getNestedValue(this.accumulatedArgs, segments);
1043
+ const isStringContinuation = arg.stringValue != null && existingValue !== void 0;
1044
+ if (isStringContinuation) {
1045
+ const escaped = JSON.stringify(arg.stringValue).slice(1, -1);
1046
+ setNestedValue(
1047
+ this.accumulatedArgs,
1048
+ segments,
1049
+ existingValue + arg.stringValue
1050
+ );
1051
+ delta += escaped;
1052
+ continue;
1053
+ }
1054
+ const resolved = resolvePartialArgValue(arg);
1055
+ if (resolved == null) continue;
1056
+ setNestedValue(this.accumulatedArgs, segments, resolved.value);
1057
+ delta += this.emitNavigationTo(segments, arg, resolved.json);
1058
+ }
1059
+ this.jsonText += delta;
1060
+ return {
1061
+ currentJSON: this.accumulatedArgs,
1062
+ textDelta: delta
1063
+ };
1064
+ }
1065
+ /**
1066
+ * Input: jsonText='{"brightness":50', accumulatedArgs={brightness:50}
1067
+ * Output: { finalJSON:'{"brightness":50}', closingDelta:'}' }
1068
+ */
1069
+ finalize() {
1070
+ const finalArgs = JSON.stringify(this.accumulatedArgs);
1071
+ const closingDelta = finalArgs.slice(this.jsonText.length);
1072
+ return { finalJSON: finalArgs, closingDelta };
1073
+ }
1074
+ /**
1075
+ * Input: pathStack=[] (first call) or pathStack=[root,...] (subsequent calls)
1076
+ * Output: '{' (first call) or '' (subsequent calls)
1077
+ */
1078
+ ensureRoot() {
1079
+ if (this.pathStack.length === 0) {
1080
+ this.pathStack.push({ segment: "", isArray: false, childCount: 0 });
1081
+ return "{";
1082
+ }
1083
+ return "";
1084
+ }
1085
+ /**
1086
+ * Emits the JSON text fragment needed to navigate from the current open
1087
+ * path to the new leaf at `targetSegments`, then writes the value.
1088
+ *
1089
+ * Input: targetSegments=["recipe","name"], arg={jsonPath:"$.recipe.name",stringValue:"Lasagna"}, valueJson='"Lasagna"'
1090
+ * Output: '{"recipe":{"name":"Lasagna"'
1091
+ */
1092
+ emitNavigationTo(targetSegments, arg, valueJson) {
1093
+ let fragment = "";
1094
+ if (this.stringOpen) {
1095
+ fragment += '"';
1096
+ this.stringOpen = false;
1097
+ }
1098
+ fragment += this.ensureRoot();
1099
+ const targetContainerSegments = targetSegments.slice(0, -1);
1100
+ const leafSegment = targetSegments[targetSegments.length - 1];
1101
+ const commonDepth = this.findCommonStackDepth(targetContainerSegments);
1102
+ fragment += this.closeDownTo(commonDepth);
1103
+ fragment += this.openDownTo(targetContainerSegments, leafSegment);
1104
+ fragment += this.emitLeaf(leafSegment, arg, valueJson);
1105
+ return fragment;
1106
+ }
1107
+ /**
1108
+ * Returns the stack depth to preserve when navigating to a new target
1109
+ * container path. Always >= 1 (the root is never popped).
1110
+ *
1111
+ * Input: stack=[root,"recipe","ingredients",0], target=["recipe","ingredients",1]
1112
+ * Output: 3 (keep root+"recipe"+"ingredients")
1113
+ */
1114
+ findCommonStackDepth(targetContainer) {
1115
+ const maxDepth = Math.min(
1116
+ this.pathStack.length - 1,
1117
+ targetContainer.length
1118
+ );
1119
+ let common = 0;
1120
+ for (let i = 0; i < maxDepth; i++) {
1121
+ if (this.pathStack[i + 1].segment === targetContainer[i]) {
1122
+ common++;
1123
+ } else {
1124
+ break;
1125
+ }
1126
+ }
1127
+ return common + 1;
1128
+ }
1129
+ /**
1130
+ * Closes containers from the current stack depth back down to `targetDepth`.
1131
+ *
1132
+ * Input: this.pathStack=[root,"recipe","ingredients",0], targetDepth=3
1133
+ * Output: '}'
1134
+ */
1135
+ closeDownTo(targetDepth) {
1136
+ let fragment = "";
1137
+ while (this.pathStack.length > targetDepth) {
1138
+ const entry = this.pathStack.pop();
1139
+ fragment += entry.isArray ? "]" : "}";
1140
+ }
1141
+ return fragment;
1142
+ }
1143
+ /**
1144
+ * Opens containers from the current stack depth down to the full target
1145
+ * container path, emitting opening `{`, `[`, keys, and commas as needed.
1146
+ * `leafSegment` is used to determine if the innermost container is an array.
1147
+ *
1148
+ * Input: this.pathStack=[root], targetContainer=["recipe","ingredients"], leafSegment=0
1149
+ * Output: '"recipe":{"ingredients":['
1150
+ */
1151
+ openDownTo(targetContainer, leafSegment) {
1152
+ let fragment = "";
1153
+ const startIdx = this.pathStack.length - 1;
1154
+ for (let i = startIdx; i < targetContainer.length; i++) {
1155
+ const seg = targetContainer[i];
1156
+ const parentEntry = this.pathStack[this.pathStack.length - 1];
1157
+ if (parentEntry.childCount > 0) {
1158
+ fragment += ",";
1159
+ }
1160
+ parentEntry.childCount++;
1161
+ if (typeof seg === "string") {
1162
+ fragment += `${JSON.stringify(seg)}:`;
1163
+ }
1164
+ const childSeg = i + 1 < targetContainer.length ? targetContainer[i + 1] : leafSegment;
1165
+ const isArray = typeof childSeg === "number";
1166
+ fragment += isArray ? "[" : "{";
1167
+ this.pathStack.push({ segment: seg, isArray, childCount: 0 });
1168
+ }
1169
+ return fragment;
1170
+ }
1171
+ /**
1172
+ * Emits the comma, key, and value for a leaf entry in the current container.
1173
+ *
1174
+ * Input: leafSegment="name", arg={stringValue:"Lasagna"}, valueJson='"Lasagna"'
1175
+ * Output: '"name":"Lasagna"' (or ',"name":"Lasagna"' if container.childCount > 0)
1176
+ */
1177
+ emitLeaf(leafSegment, arg, valueJson) {
1178
+ let fragment = "";
1179
+ const container = this.pathStack[this.pathStack.length - 1];
1180
+ if (container.childCount > 0) {
1181
+ fragment += ",";
1182
+ }
1183
+ container.childCount++;
1184
+ if (typeof leafSegment === "string") {
1185
+ fragment += `${JSON.stringify(leafSegment)}:`;
1186
+ }
1187
+ if (arg.stringValue != null && arg.willContinue) {
1188
+ fragment += valueJson.slice(0, -1);
1189
+ this.stringOpen = true;
1190
+ } else {
1191
+ fragment += valueJson;
1192
+ }
1193
+ return fragment;
1194
+ }
1195
+ };
1196
+ function parsePath(rawPath) {
1197
+ const segments = [];
1198
+ for (const part of rawPath.split(".")) {
1199
+ const bracketIdx = part.indexOf("[");
1200
+ if (bracketIdx === -1) {
1201
+ segments.push(part);
1202
+ } else {
1203
+ if (bracketIdx > 0) segments.push(part.slice(0, bracketIdx));
1204
+ for (const m of part.matchAll(/\[(\d+)\]/g)) {
1205
+ segments.push(parseInt(m[1], 10));
1206
+ }
1207
+ }
1208
+ }
1209
+ return segments;
1210
+ }
1211
+ function getNestedValue(obj, segments) {
1212
+ let current = obj;
1213
+ for (const seg of segments) {
1214
+ if (current == null || typeof current !== "object") return void 0;
1215
+ current = current[seg];
1216
+ }
1217
+ return current;
1218
+ }
1219
+ function setNestedValue(obj, segments, value) {
1220
+ let current = obj;
1221
+ for (let i = 0; i < segments.length - 1; i++) {
1222
+ const seg = segments[i];
1223
+ const nextSeg = segments[i + 1];
1224
+ if (current[seg] == null) {
1225
+ current[seg] = typeof nextSeg === "number" ? [] : {};
1226
+ }
1227
+ current = current[seg];
1228
+ }
1229
+ current[segments[segments.length - 1]] = value;
1230
+ }
1231
+ function resolvePartialArgValue(arg) {
1232
+ var _a, _b;
1233
+ const value = (_b = (_a = arg.stringValue) != null ? _a : arg.numberValue) != null ? _b : arg.boolValue;
1234
+ if (value != null) return { value, json: JSON.stringify(value) };
1235
+ if ("nullValue" in arg) return { value: null, json: "null" };
1236
+ return void 0;
1237
+ }
1238
+
1239
+ // src/map-google-finish-reason.ts
1240
+ function mapGoogleFinishReason({
720
1241
  finishReason,
721
1242
  hasToolCalls
722
1243
  }) {
@@ -741,14 +1262,23 @@ function mapGoogleGenerativeAIFinishReason({
741
1262
  }
742
1263
  }
743
1264
 
744
- // src/google-generative-ai-language-model.ts
745
- var GoogleGenerativeAILanguageModel = class {
1265
+ // src/google-language-model.ts
1266
+ var GoogleLanguageModel = class _GoogleLanguageModel {
746
1267
  constructor(modelId, config) {
747
1268
  this.specificationVersion = "v4";
748
1269
  var _a;
749
1270
  this.modelId = modelId;
750
1271
  this.config = config;
751
- this.generateId = (_a = config.generateId) != null ? _a : import_provider_utils4.generateId;
1272
+ this.generateId = (_a = config.generateId) != null ? _a : generateId;
1273
+ }
1274
+ static [WORKFLOW_SERIALIZE](model) {
1275
+ return serializeModelOptions({
1276
+ modelId: model.modelId,
1277
+ config: model.config
1278
+ });
1279
+ }
1280
+ static [WORKFLOW_DESERIALIZE](options) {
1281
+ return new _GoogleLanguageModel(options.modelId, options.config);
752
1282
  }
753
1283
  get provider() {
754
1284
  return this.config.provider;
@@ -770,36 +1300,54 @@ var GoogleGenerativeAILanguageModel = class {
770
1300
  seed,
771
1301
  tools,
772
1302
  toolChoice,
1303
+ reasoning,
773
1304
  providerOptions
774
- }) {
775
- var _a;
1305
+ }, { isStreaming = false } = {}) {
1306
+ var _a, _b;
776
1307
  const warnings = [];
777
- const providerOptionsName = this.config.provider.includes("vertex") ? "vertex" : "google";
778
- let googleOptions = await (0, import_provider_utils4.parseProviderOptions)({
779
- provider: providerOptionsName,
780
- providerOptions,
781
- schema: googleLanguageModelOptions
782
- });
783
- if (googleOptions == null && providerOptionsName !== "google") {
784
- googleOptions = await (0, import_provider_utils4.parseProviderOptions)({
1308
+ const providerOptionsNames = this.config.provider.includes("vertex") ? ["googleVertex", "vertex"] : ["google"];
1309
+ let googleOptions;
1310
+ for (const name of providerOptionsNames) {
1311
+ googleOptions = await parseProviderOptions({
1312
+ provider: name,
1313
+ providerOptions,
1314
+ schema: googleLanguageModelOptions
1315
+ });
1316
+ if (googleOptions != null) break;
1317
+ }
1318
+ if (googleOptions == null && !providerOptionsNames.includes("google")) {
1319
+ googleOptions = await parseProviderOptions({
785
1320
  provider: "google",
786
1321
  providerOptions,
787
1322
  schema: googleLanguageModelOptions
788
1323
  });
789
1324
  }
1325
+ const isVertexProvider = this.config.provider.startsWith("google.vertex.");
790
1326
  if ((tools == null ? void 0 : tools.some(
791
1327
  (tool) => tool.type === "provider" && tool.id === "google.vertex_rag_store"
792
- )) && !this.config.provider.startsWith("google.vertex.")) {
1328
+ )) && !isVertexProvider) {
793
1329
  warnings.push({
794
1330
  type: "other",
795
1331
  message: `The 'vertex_rag_store' tool is only supported with the Google Vertex provider and might not be supported or could behave unexpectedly with the current Google provider (${this.config.provider}).`
796
1332
  });
797
1333
  }
1334
+ if ((googleOptions == null ? void 0 : googleOptions.streamFunctionCallArguments) && !isVertexProvider) {
1335
+ warnings.push({
1336
+ type: "other",
1337
+ message: `'streamFunctionCallArguments' is only supported on the Vertex AI API and will be ignored with the current Google provider (${this.config.provider}). See https://docs.cloud.google.com/vertex-ai/generative-ai/docs/multimodal/function-calling#streaming-fc`
1338
+ });
1339
+ }
1340
+ let sanitizedServiceTier = googleOptions == null ? void 0 : googleOptions.serviceTier;
1341
+ if ((googleOptions == null ? void 0 : googleOptions.serviceTier) && isVertexProvider) {
1342
+ sanitizedServiceTier = VertexServiceTierMap[googleOptions.serviceTier];
1343
+ }
798
1344
  const isGemmaModel = this.modelId.toLowerCase().startsWith("gemma-");
799
- const { contents, systemInstruction } = convertToGoogleGenerativeAIMessages(
800
- prompt,
801
- { isGemmaModel, providerOptionsName }
802
- );
1345
+ const supportsFunctionResponseParts = this.modelId.startsWith("gemini-3");
1346
+ const { contents, systemInstruction } = convertToGoogleMessages(prompt, {
1347
+ isGemmaModel,
1348
+ providerOptionsNames,
1349
+ supportsFunctionResponseParts
1350
+ });
803
1351
  const {
804
1352
  tools: googleTools2,
805
1353
  toolConfig: googleToolConfig,
@@ -807,8 +1355,28 @@ var GoogleGenerativeAILanguageModel = class {
807
1355
  } = prepareTools({
808
1356
  tools,
809
1357
  toolChoice,
810
- modelId: this.modelId
1358
+ modelId: this.modelId,
1359
+ isVertexProvider
1360
+ });
1361
+ const resolvedThinking = resolveThinkingConfig({
1362
+ reasoning,
1363
+ modelId: this.modelId,
1364
+ warnings
811
1365
  });
1366
+ const thinkingConfig = (googleOptions == null ? void 0 : googleOptions.thinkingConfig) || resolvedThinking ? { ...resolvedThinking, ...googleOptions == null ? void 0 : googleOptions.thinkingConfig } : void 0;
1367
+ const streamFunctionCallArguments = isStreaming && isVertexProvider ? (_a = googleOptions == null ? void 0 : googleOptions.streamFunctionCallArguments) != null ? _a : false : void 0;
1368
+ const toolConfig = googleToolConfig || streamFunctionCallArguments || (googleOptions == null ? void 0 : googleOptions.retrievalConfig) ? {
1369
+ ...googleToolConfig,
1370
+ ...streamFunctionCallArguments && {
1371
+ functionCallingConfig: {
1372
+ ...googleToolConfig == null ? void 0 : googleToolConfig.functionCallingConfig,
1373
+ streamFunctionCallArguments: true
1374
+ }
1375
+ },
1376
+ ...(googleOptions == null ? void 0 : googleOptions.retrievalConfig) && {
1377
+ retrievalConfig: googleOptions.retrievalConfig
1378
+ }
1379
+ } : void 0;
812
1380
  return {
813
1381
  args: {
814
1382
  generationConfig: {
@@ -826,13 +1394,13 @@ var GoogleGenerativeAILanguageModel = class {
826
1394
  responseSchema: (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && // Google GenAI does not support all OpenAPI Schema features,
827
1395
  // so this is needed as an escape hatch:
828
1396
  // TODO convert into provider option
829
- ((_a = googleOptions == null ? void 0 : googleOptions.structuredOutputs) != null ? _a : true) ? convertJSONSchemaToOpenAPISchema(responseFormat.schema) : void 0,
1397
+ ((_b = googleOptions == null ? void 0 : googleOptions.structuredOutputs) != null ? _b : true) ? convertJSONSchemaToOpenAPISchema(responseFormat.schema) : void 0,
830
1398
  ...(googleOptions == null ? void 0 : googleOptions.audioTimestamp) && {
831
1399
  audioTimestamp: googleOptions.audioTimestamp
832
1400
  },
833
1401
  // provider options:
834
1402
  responseModalities: googleOptions == null ? void 0 : googleOptions.responseModalities,
835
- thinkingConfig: googleOptions == null ? void 0 : googleOptions.thinkingConfig,
1403
+ thinkingConfig,
836
1404
  ...(googleOptions == null ? void 0 : googleOptions.mediaResolution) && {
837
1405
  mediaResolution: googleOptions.mediaResolution
838
1406
  },
@@ -844,36 +1412,37 @@ var GoogleGenerativeAILanguageModel = class {
844
1412
  systemInstruction: isGemmaModel ? void 0 : systemInstruction,
845
1413
  safetySettings: googleOptions == null ? void 0 : googleOptions.safetySettings,
846
1414
  tools: googleTools2,
847
- toolConfig: (googleOptions == null ? void 0 : googleOptions.retrievalConfig) ? {
848
- ...googleToolConfig,
849
- retrievalConfig: googleOptions.retrievalConfig
850
- } : googleToolConfig,
1415
+ toolConfig,
851
1416
  cachedContent: googleOptions == null ? void 0 : googleOptions.cachedContent,
852
- labels: googleOptions == null ? void 0 : googleOptions.labels
1417
+ labels: googleOptions == null ? void 0 : googleOptions.labels,
1418
+ serviceTier: sanitizedServiceTier
853
1419
  },
854
1420
  warnings: [...warnings, ...toolWarnings],
855
- providerOptionsName
1421
+ providerOptionsNames
856
1422
  };
857
1423
  }
858
1424
  async doGenerate(options) {
859
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
860
- const { args, warnings, providerOptionsName } = await this.getArgs(options);
861
- const mergedHeaders = (0, import_provider_utils4.combineHeaders)(
862
- await (0, import_provider_utils4.resolve)(this.config.headers),
1425
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
1426
+ const { args, warnings, providerOptionsNames } = await this.getArgs(options);
1427
+ const wrapProviderMetadata = (payload) => Object.fromEntries(
1428
+ providerOptionsNames.map((name) => [name, payload])
1429
+ );
1430
+ const mergedHeaders = combineHeaders(
1431
+ this.config.headers ? await resolve(this.config.headers) : void 0,
863
1432
  options.headers
864
1433
  );
865
1434
  const {
866
1435
  responseHeaders,
867
1436
  value: response,
868
1437
  rawValue: rawResponse
869
- } = await (0, import_provider_utils4.postJsonToApi)({
1438
+ } = await postJsonToApi({
870
1439
  url: `${this.config.baseURL}/${getModelPath(
871
1440
  this.modelId
872
1441
  )}:generateContent`,
873
1442
  headers: mergedHeaders,
874
1443
  body: args,
875
1444
  failedResponseHandler: googleFailedResponseHandler,
876
- successfulResponseHandler: (0, import_provider_utils4.createJsonResponseHandler)(responseSchema),
1445
+ successfulResponseHandler: createJsonResponseHandler(responseSchema),
877
1446
  abortSignal: options.abortSignal,
878
1447
  fetch: this.config.fetch
879
1448
  });
@@ -882,6 +1451,7 @@ var GoogleGenerativeAILanguageModel = class {
882
1451
  const parts = (_b = (_a = candidate.content) == null ? void 0 : _a.parts) != null ? _b : [];
883
1452
  const usageMetadata = response.usageMetadata;
884
1453
  let lastCodeExecutionToolCallId;
1454
+ let lastServerToolCallId;
885
1455
  for (const part of parts) {
886
1456
  if ("executableCode" in part && ((_c = part.executableCode) == null ? void 0 : _c.code)) {
887
1457
  const toolCallId = this.config.generateId();
@@ -906,11 +1476,9 @@ var GoogleGenerativeAILanguageModel = class {
906
1476
  });
907
1477
  lastCodeExecutionToolCallId = void 0;
908
1478
  } else if ("text" in part && part.text != null) {
909
- const thoughtSignatureMetadata = part.thoughtSignature ? {
910
- [providerOptionsName]: {
911
- thoughtSignature: part.thoughtSignature
912
- }
913
- } : void 0;
1479
+ const thoughtSignatureMetadata = part.thoughtSignature ? wrapProviderMetadata({
1480
+ thoughtSignature: part.thoughtSignature
1481
+ }) : void 0;
914
1482
  if (part.text.length === 0) {
915
1483
  if (thoughtSignatureMetadata != null && content.length > 0) {
916
1484
  const lastContent = content[content.length - 1];
@@ -923,65 +1491,95 @@ var GoogleGenerativeAILanguageModel = class {
923
1491
  providerMetadata: thoughtSignatureMetadata
924
1492
  });
925
1493
  }
926
- } else if ("functionCall" in part) {
1494
+ } else if ("functionCall" in part && part.functionCall.name != null && part.functionCall.args != null) {
927
1495
  content.push({
928
1496
  type: "tool-call",
929
1497
  toolCallId: this.config.generateId(),
930
1498
  toolName: part.functionCall.name,
931
1499
  input: JSON.stringify(part.functionCall.args),
932
- providerMetadata: part.thoughtSignature ? {
933
- [providerOptionsName]: {
934
- thoughtSignature: part.thoughtSignature
935
- }
936
- } : void 0
1500
+ providerMetadata: part.thoughtSignature ? wrapProviderMetadata({
1501
+ thoughtSignature: part.thoughtSignature
1502
+ }) : void 0
937
1503
  });
938
1504
  } else if ("inlineData" in part) {
939
1505
  const hasThought = part.thought === true;
940
1506
  const hasThoughtSignature = !!part.thoughtSignature;
941
1507
  content.push({
942
- type: "file",
943
- data: part.inlineData.data,
1508
+ type: hasThought ? "reasoning-file" : "file",
1509
+ data: { type: "data", data: part.inlineData.data },
944
1510
  mediaType: part.inlineData.mimeType,
945
- providerMetadata: hasThought || hasThoughtSignature ? {
946
- [providerOptionsName]: {
947
- ...hasThought ? { thought: true } : {},
948
- ...hasThoughtSignature ? { thoughtSignature: part.thoughtSignature } : {}
949
- }
950
- } : void 0
1511
+ providerMetadata: hasThoughtSignature ? wrapProviderMetadata({
1512
+ thoughtSignature: part.thoughtSignature
1513
+ }) : void 0
951
1514
  });
1515
+ } else if ("toolCall" in part && part.toolCall) {
1516
+ const toolCallId = (_e = part.toolCall.id) != null ? _e : this.config.generateId();
1517
+ lastServerToolCallId = toolCallId;
1518
+ content.push({
1519
+ type: "tool-call",
1520
+ toolCallId,
1521
+ toolName: `server:${part.toolCall.toolType}`,
1522
+ input: JSON.stringify((_f = part.toolCall.args) != null ? _f : {}),
1523
+ providerExecuted: true,
1524
+ dynamic: true,
1525
+ providerMetadata: part.thoughtSignature ? wrapProviderMetadata({
1526
+ thoughtSignature: part.thoughtSignature,
1527
+ serverToolCallId: toolCallId,
1528
+ serverToolType: part.toolCall.toolType
1529
+ }) : wrapProviderMetadata({
1530
+ serverToolCallId: toolCallId,
1531
+ serverToolType: part.toolCall.toolType
1532
+ })
1533
+ });
1534
+ } else if ("toolResponse" in part && part.toolResponse) {
1535
+ const responseToolCallId = (_g = lastServerToolCallId != null ? lastServerToolCallId : part.toolResponse.id) != null ? _g : this.config.generateId();
1536
+ content.push({
1537
+ type: "tool-result",
1538
+ toolCallId: responseToolCallId,
1539
+ toolName: `server:${part.toolResponse.toolType}`,
1540
+ result: (_h = part.toolResponse.response) != null ? _h : {},
1541
+ providerMetadata: part.thoughtSignature ? wrapProviderMetadata({
1542
+ thoughtSignature: part.thoughtSignature,
1543
+ serverToolCallId: responseToolCallId,
1544
+ serverToolType: part.toolResponse.toolType
1545
+ }) : wrapProviderMetadata({
1546
+ serverToolCallId: responseToolCallId,
1547
+ serverToolType: part.toolResponse.toolType
1548
+ })
1549
+ });
1550
+ lastServerToolCallId = void 0;
952
1551
  }
953
1552
  }
954
- const sources = (_e = extractSources({
1553
+ const sources = (_i = extractSources({
955
1554
  groundingMetadata: candidate.groundingMetadata,
956
1555
  generateId: this.config.generateId
957
- })) != null ? _e : [];
1556
+ })) != null ? _i : [];
958
1557
  for (const source of sources) {
959
1558
  content.push(source);
960
1559
  }
961
1560
  return {
962
1561
  content,
963
1562
  finishReason: {
964
- unified: mapGoogleGenerativeAIFinishReason({
1563
+ unified: mapGoogleFinishReason({
965
1564
  finishReason: candidate.finishReason,
966
1565
  // Only count client-executed tool calls for finish reason determination.
967
1566
  hasToolCalls: content.some(
968
1567
  (part) => part.type === "tool-call" && !part.providerExecuted
969
1568
  )
970
1569
  }),
971
- raw: (_f = candidate.finishReason) != null ? _f : void 0
1570
+ raw: (_j = candidate.finishReason) != null ? _j : void 0
972
1571
  },
973
- usage: convertGoogleGenerativeAIUsage(usageMetadata),
1572
+ usage: convertGoogleUsage(usageMetadata),
974
1573
  warnings,
975
- providerMetadata: {
976
- [providerOptionsName]: {
977
- promptFeedback: (_g = response.promptFeedback) != null ? _g : null,
978
- groundingMetadata: (_h = candidate.groundingMetadata) != null ? _h : null,
979
- urlContextMetadata: (_i = candidate.urlContextMetadata) != null ? _i : null,
980
- safetyRatings: (_j = candidate.safetyRatings) != null ? _j : null,
981
- usageMetadata: usageMetadata != null ? usageMetadata : null,
982
- finishMessage: (_k = candidate.finishMessage) != null ? _k : null
983
- }
984
- },
1574
+ providerMetadata: wrapProviderMetadata({
1575
+ promptFeedback: (_k = response.promptFeedback) != null ? _k : null,
1576
+ groundingMetadata: (_l = candidate.groundingMetadata) != null ? _l : null,
1577
+ urlContextMetadata: (_m = candidate.urlContextMetadata) != null ? _m : null,
1578
+ safetyRatings: (_n = candidate.safetyRatings) != null ? _n : null,
1579
+ usageMetadata: usageMetadata != null ? usageMetadata : null,
1580
+ finishMessage: (_o = candidate.finishMessage) != null ? _o : null,
1581
+ serviceTier: (_p = response.serviceTier) != null ? _p : null
1582
+ }),
985
1583
  request: { body: args },
986
1584
  response: {
987
1585
  // TODO timestamp, model id, id
@@ -991,19 +1589,25 @@ var GoogleGenerativeAILanguageModel = class {
991
1589
  };
992
1590
  }
993
1591
  async doStream(options) {
994
- const { args, warnings, providerOptionsName } = await this.getArgs(options);
995
- const headers = (0, import_provider_utils4.combineHeaders)(
996
- await (0, import_provider_utils4.resolve)(this.config.headers),
1592
+ const { args, warnings, providerOptionsNames } = await this.getArgs(
1593
+ options,
1594
+ { isStreaming: true }
1595
+ );
1596
+ const wrapProviderMetadata = (payload) => Object.fromEntries(
1597
+ providerOptionsNames.map((name) => [name, payload])
1598
+ );
1599
+ const headers = combineHeaders(
1600
+ this.config.headers ? await resolve(this.config.headers) : void 0,
997
1601
  options.headers
998
1602
  );
999
- const { responseHeaders, value: response } = await (0, import_provider_utils4.postJsonToApi)({
1603
+ const { responseHeaders, value: response } = await postJsonToApi({
1000
1604
  url: `${this.config.baseURL}/${getModelPath(
1001
1605
  this.modelId
1002
1606
  )}:streamGenerateContent?alt=sse`,
1003
1607
  headers,
1004
1608
  body: args,
1005
1609
  failedResponseHandler: googleFailedResponseHandler,
1006
- successfulResponseHandler: (0, import_provider_utils4.createEventSourceResponseHandler)(chunkSchema),
1610
+ successfulResponseHandler: createEventSourceResponseHandler(chunkSchema),
1007
1611
  abortSignal: options.abortSignal,
1008
1612
  fetch: this.config.fetch
1009
1613
  });
@@ -1015,6 +1619,7 @@ var GoogleGenerativeAILanguageModel = class {
1015
1619
  let providerMetadata = void 0;
1016
1620
  let lastGroundingMetadata = null;
1017
1621
  let lastUrlContextMetadata = null;
1622
+ let serviceTier = null;
1018
1623
  const generateId2 = this.config.generateId;
1019
1624
  let hasToolCalls = false;
1020
1625
  let currentTextBlockId = null;
@@ -1022,6 +1627,8 @@ var GoogleGenerativeAILanguageModel = class {
1022
1627
  let blockCounter = 0;
1023
1628
  const emittedSourceUrls = /* @__PURE__ */ new Set();
1024
1629
  let lastCodeExecutionToolCallId;
1630
+ let lastServerToolCallId;
1631
+ const activeStreamingToolCalls = [];
1025
1632
  return {
1026
1633
  stream: response.pipeThrough(
1027
1634
  new TransformStream({
@@ -1029,7 +1636,7 @@ var GoogleGenerativeAILanguageModel = class {
1029
1636
  controller.enqueue({ type: "stream-start", warnings });
1030
1637
  },
1031
1638
  transform(chunk, controller) {
1032
- var _a, _b, _c, _d, _e, _f, _g;
1639
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
1033
1640
  if (options.includeRawChunks) {
1034
1641
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
1035
1642
  }
@@ -1042,6 +1649,9 @@ var GoogleGenerativeAILanguageModel = class {
1042
1649
  if (usageMetadata != null) {
1043
1650
  usage = usageMetadata;
1044
1651
  }
1652
+ if (value.serviceTier != null) {
1653
+ serviceTier = value.serviceTier;
1654
+ }
1045
1655
  const candidate = (_a = value.candidates) == null ? void 0 : _a[0];
1046
1656
  if (candidate == null) {
1047
1657
  return;
@@ -1093,11 +1703,9 @@ var GoogleGenerativeAILanguageModel = class {
1093
1703
  lastCodeExecutionToolCallId = void 0;
1094
1704
  }
1095
1705
  } else if ("text" in part && part.text != null) {
1096
- const thoughtSignatureMetadata = part.thoughtSignature ? {
1097
- [providerOptionsName]: {
1098
- thoughtSignature: part.thoughtSignature
1099
- }
1100
- } : void 0;
1706
+ const thoughtSignatureMetadata = part.thoughtSignature ? wrapProviderMetadata({
1707
+ thoughtSignature: part.thoughtSignature
1708
+ }) : void 0;
1101
1709
  if (part.text.length === 0) {
1102
1710
  if (thoughtSignatureMetadata != null && currentTextBlockId !== null) {
1103
1711
  controller.enqueue({
@@ -1169,50 +1777,151 @@ var GoogleGenerativeAILanguageModel = class {
1169
1777
  }
1170
1778
  const hasThought = part.thought === true;
1171
1779
  const hasThoughtSignature = !!part.thoughtSignature;
1172
- const fileMeta = hasThought || hasThoughtSignature ? {
1173
- [providerOptionsName]: {
1174
- ...hasThought ? { thought: true } : {},
1175
- ...hasThoughtSignature ? { thoughtSignature: part.thoughtSignature } : {}
1176
- }
1177
- } : void 0;
1780
+ const fileMeta = hasThoughtSignature ? wrapProviderMetadata({
1781
+ thoughtSignature: part.thoughtSignature
1782
+ }) : void 0;
1178
1783
  controller.enqueue({
1179
- type: "file",
1784
+ type: hasThought ? "reasoning-file" : "file",
1180
1785
  mediaType: part.inlineData.mimeType,
1181
- data: part.inlineData.data,
1786
+ data: { type: "data", data: part.inlineData.data },
1182
1787
  providerMetadata: fileMeta
1183
1788
  });
1789
+ } else if ("toolCall" in part && part.toolCall) {
1790
+ const toolCallId = (_e = part.toolCall.id) != null ? _e : generateId2();
1791
+ lastServerToolCallId = toolCallId;
1792
+ const serverMeta = wrapProviderMetadata({
1793
+ ...part.thoughtSignature ? { thoughtSignature: part.thoughtSignature } : {},
1794
+ serverToolCallId: toolCallId,
1795
+ serverToolType: part.toolCall.toolType
1796
+ });
1797
+ controller.enqueue({
1798
+ type: "tool-call",
1799
+ toolCallId,
1800
+ toolName: `server:${part.toolCall.toolType}`,
1801
+ input: JSON.stringify((_f = part.toolCall.args) != null ? _f : {}),
1802
+ providerExecuted: true,
1803
+ dynamic: true,
1804
+ providerMetadata: serverMeta
1805
+ });
1806
+ } else if ("toolResponse" in part && part.toolResponse) {
1807
+ const responseToolCallId = (_g = lastServerToolCallId != null ? lastServerToolCallId : part.toolResponse.id) != null ? _g : generateId2();
1808
+ const serverMeta = wrapProviderMetadata({
1809
+ ...part.thoughtSignature ? { thoughtSignature: part.thoughtSignature } : {},
1810
+ serverToolCallId: responseToolCallId,
1811
+ serverToolType: part.toolResponse.toolType
1812
+ });
1813
+ controller.enqueue({
1814
+ type: "tool-result",
1815
+ toolCallId: responseToolCallId,
1816
+ toolName: `server:${part.toolResponse.toolType}`,
1817
+ result: (_h = part.toolResponse.response) != null ? _h : {},
1818
+ providerMetadata: serverMeta
1819
+ });
1820
+ lastServerToolCallId = void 0;
1184
1821
  }
1185
1822
  }
1186
- const toolCallDeltas = getToolCallsFromParts({
1187
- parts: content.parts,
1188
- generateId: generateId2,
1189
- providerOptionsName
1190
- });
1191
- if (toolCallDeltas != null) {
1192
- for (const toolCall of toolCallDeltas) {
1823
+ for (const part of parts) {
1824
+ if (!("functionCall" in part)) continue;
1825
+ const providerMeta = part.thoughtSignature ? wrapProviderMetadata({
1826
+ thoughtSignature: part.thoughtSignature
1827
+ }) : void 0;
1828
+ const isStreamingChunk = part.functionCall.partialArgs != null || part.functionCall.name != null && part.functionCall.willContinue === true;
1829
+ const isTerminalChunk = part.functionCall.name == null && part.functionCall.args == null && part.functionCall.partialArgs == null && part.functionCall.willContinue == null;
1830
+ const isCompleteCall = part.functionCall.name != null && part.functionCall.args != null && part.functionCall.partialArgs == null;
1831
+ if (isStreamingChunk) {
1832
+ if (part.functionCall.name != null && part.functionCall.willContinue === true) {
1833
+ const toolCallId = generateId2();
1834
+ const accumulator = new GoogleJSONAccumulator();
1835
+ activeStreamingToolCalls.push({
1836
+ toolCallId,
1837
+ toolName: part.functionCall.name,
1838
+ accumulator,
1839
+ providerMetadata: providerMeta
1840
+ });
1841
+ controller.enqueue({
1842
+ type: "tool-input-start",
1843
+ id: toolCallId,
1844
+ toolName: part.functionCall.name,
1845
+ providerMetadata: providerMeta
1846
+ });
1847
+ if (part.functionCall.partialArgs != null) {
1848
+ const { textDelta } = accumulator.processPartialArgs(
1849
+ part.functionCall.partialArgs
1850
+ );
1851
+ if (textDelta.length > 0) {
1852
+ controller.enqueue({
1853
+ type: "tool-input-delta",
1854
+ id: toolCallId,
1855
+ delta: textDelta,
1856
+ providerMetadata: providerMeta
1857
+ });
1858
+ }
1859
+ }
1860
+ } else if (part.functionCall.partialArgs != null && activeStreamingToolCalls.length > 0) {
1861
+ const active = activeStreamingToolCalls[activeStreamingToolCalls.length - 1];
1862
+ const { textDelta } = active.accumulator.processPartialArgs(
1863
+ part.functionCall.partialArgs
1864
+ );
1865
+ if (textDelta.length > 0) {
1866
+ controller.enqueue({
1867
+ type: "tool-input-delta",
1868
+ id: active.toolCallId,
1869
+ delta: textDelta,
1870
+ providerMetadata: providerMeta
1871
+ });
1872
+ }
1873
+ }
1874
+ } else if (isTerminalChunk && activeStreamingToolCalls.length > 0) {
1875
+ const active = activeStreamingToolCalls.pop();
1876
+ const { finalJSON, closingDelta } = active.accumulator.finalize();
1877
+ if (closingDelta.length > 0) {
1878
+ controller.enqueue({
1879
+ type: "tool-input-delta",
1880
+ id: active.toolCallId,
1881
+ delta: closingDelta,
1882
+ providerMetadata: active.providerMetadata
1883
+ });
1884
+ }
1885
+ controller.enqueue({
1886
+ type: "tool-input-end",
1887
+ id: active.toolCallId,
1888
+ providerMetadata: active.providerMetadata
1889
+ });
1890
+ controller.enqueue({
1891
+ type: "tool-call",
1892
+ toolCallId: active.toolCallId,
1893
+ toolName: active.toolName,
1894
+ input: finalJSON,
1895
+ providerMetadata: active.providerMetadata
1896
+ });
1897
+ hasToolCalls = true;
1898
+ } else if (isCompleteCall) {
1899
+ const toolCallId = generateId2();
1900
+ const toolName = part.functionCall.name;
1901
+ const args2 = typeof part.functionCall.args === "string" ? part.functionCall.args : JSON.stringify((_i = part.functionCall.args) != null ? _i : {});
1193
1902
  controller.enqueue({
1194
1903
  type: "tool-input-start",
1195
- id: toolCall.toolCallId,
1196
- toolName: toolCall.toolName,
1197
- providerMetadata: toolCall.providerMetadata
1904
+ id: toolCallId,
1905
+ toolName,
1906
+ providerMetadata: providerMeta
1198
1907
  });
1199
1908
  controller.enqueue({
1200
1909
  type: "tool-input-delta",
1201
- id: toolCall.toolCallId,
1202
- delta: toolCall.args,
1203
- providerMetadata: toolCall.providerMetadata
1910
+ id: toolCallId,
1911
+ delta: args2,
1912
+ providerMetadata: providerMeta
1204
1913
  });
1205
1914
  controller.enqueue({
1206
1915
  type: "tool-input-end",
1207
- id: toolCall.toolCallId,
1208
- providerMetadata: toolCall.providerMetadata
1916
+ id: toolCallId,
1917
+ providerMetadata: providerMeta
1209
1918
  });
1210
1919
  controller.enqueue({
1211
1920
  type: "tool-call",
1212
- toolCallId: toolCall.toolCallId,
1213
- toolName: toolCall.toolName,
1214
- input: toolCall.args,
1215
- providerMetadata: toolCall.providerMetadata
1921
+ toolCallId,
1922
+ toolName,
1923
+ input: args2,
1924
+ providerMetadata: providerMeta
1216
1925
  });
1217
1926
  hasToolCalls = true;
1218
1927
  }
@@ -1220,22 +1929,21 @@ var GoogleGenerativeAILanguageModel = class {
1220
1929
  }
1221
1930
  if (candidate.finishReason != null) {
1222
1931
  finishReason = {
1223
- unified: mapGoogleGenerativeAIFinishReason({
1932
+ unified: mapGoogleFinishReason({
1224
1933
  finishReason: candidate.finishReason,
1225
1934
  hasToolCalls
1226
1935
  }),
1227
1936
  raw: candidate.finishReason
1228
1937
  };
1229
- providerMetadata = {
1230
- [providerOptionsName]: {
1231
- promptFeedback: (_e = value.promptFeedback) != null ? _e : null,
1232
- groundingMetadata: lastGroundingMetadata,
1233
- urlContextMetadata: lastUrlContextMetadata,
1234
- safetyRatings: (_f = candidate.safetyRatings) != null ? _f : null,
1235
- usageMetadata: usageMetadata != null ? usageMetadata : null,
1236
- finishMessage: (_g = candidate.finishMessage) != null ? _g : null
1237
- }
1238
- };
1938
+ providerMetadata = wrapProviderMetadata({
1939
+ promptFeedback: (_j = value.promptFeedback) != null ? _j : null,
1940
+ groundingMetadata: lastGroundingMetadata,
1941
+ urlContextMetadata: lastUrlContextMetadata,
1942
+ safetyRatings: (_k = candidate.safetyRatings) != null ? _k : null,
1943
+ usageMetadata: usageMetadata != null ? usageMetadata : null,
1944
+ finishMessage: (_l = candidate.finishMessage) != null ? _l : null,
1945
+ serviceTier
1946
+ });
1239
1947
  }
1240
1948
  },
1241
1949
  flush(controller) {
@@ -1254,7 +1962,7 @@ var GoogleGenerativeAILanguageModel = class {
1254
1962
  controller.enqueue({
1255
1963
  type: "finish",
1256
1964
  finishReason,
1257
- usage: convertGoogleGenerativeAIUsage(usage),
1965
+ usage: convertGoogleUsage(usage),
1258
1966
  providerMetadata
1259
1967
  });
1260
1968
  }
@@ -1265,25 +1973,74 @@ var GoogleGenerativeAILanguageModel = class {
1265
1973
  };
1266
1974
  }
1267
1975
  };
1268
- function getToolCallsFromParts({
1269
- parts,
1270
- generateId: generateId2,
1271
- providerOptionsName
1976
+ function isGemini3Model(modelId) {
1977
+ return /gemini-3[\.\-]/i.test(modelId) || /gemini-3$/i.test(modelId);
1978
+ }
1979
+ function getMaxOutputTokensForGemini25Model() {
1980
+ return 65536;
1981
+ }
1982
+ function getMaxThinkingTokensForGemini25Model(modelId) {
1983
+ const id = modelId.toLowerCase();
1984
+ if (id.includes("2.5-pro") || id.includes("gemini-3-pro-image")) {
1985
+ return 32768;
1986
+ }
1987
+ return 24576;
1988
+ }
1989
+ function resolveThinkingConfig({
1990
+ reasoning,
1991
+ modelId,
1992
+ warnings
1272
1993
  }) {
1273
- const functionCallParts = parts == null ? void 0 : parts.filter(
1274
- (part) => "functionCall" in part
1275
- );
1276
- return functionCallParts == null || functionCallParts.length === 0 ? void 0 : functionCallParts.map((part) => ({
1277
- type: "tool-call",
1278
- toolCallId: generateId2(),
1279
- toolName: part.functionCall.name,
1280
- args: JSON.stringify(part.functionCall.args),
1281
- providerMetadata: part.thoughtSignature ? {
1282
- [providerOptionsName]: {
1283
- thoughtSignature: part.thoughtSignature
1284
- }
1285
- } : void 0
1286
- }));
1994
+ if (!isCustomReasoning(reasoning)) {
1995
+ return void 0;
1996
+ }
1997
+ if (isGemini3Model(modelId) && !modelId.includes("gemini-3-pro-image")) {
1998
+ return resolveGemini3ThinkingConfig({ reasoning, warnings });
1999
+ }
2000
+ return resolveGemini25ThinkingConfig({ reasoning, modelId, warnings });
2001
+ }
2002
+ function resolveGemini3ThinkingConfig({
2003
+ reasoning,
2004
+ warnings
2005
+ }) {
2006
+ if (reasoning === "none") {
2007
+ return { thinkingLevel: "minimal" };
2008
+ }
2009
+ const thinkingLevel = mapReasoningToProviderEffort({
2010
+ reasoning,
2011
+ effortMap: {
2012
+ minimal: "minimal",
2013
+ low: "low",
2014
+ medium: "medium",
2015
+ high: "high",
2016
+ xhigh: "high"
2017
+ },
2018
+ warnings
2019
+ });
2020
+ if (thinkingLevel == null) {
2021
+ return void 0;
2022
+ }
2023
+ return { thinkingLevel };
2024
+ }
2025
+ function resolveGemini25ThinkingConfig({
2026
+ reasoning,
2027
+ modelId,
2028
+ warnings
2029
+ }) {
2030
+ if (reasoning === "none") {
2031
+ return { thinkingBudget: 0 };
2032
+ }
2033
+ const thinkingBudget = mapReasoningToProviderBudget({
2034
+ reasoning,
2035
+ maxOutputTokens: getMaxOutputTokensForGemini25Model(),
2036
+ maxReasoningBudget: getMaxThinkingTokensForGemini25Model(modelId),
2037
+ minReasoningBudget: 0,
2038
+ warnings
2039
+ });
2040
+ if (thinkingBudget == null) {
2041
+ return void 0;
2042
+ }
2043
+ return { thinkingBudget };
1287
2044
  }
1288
2045
  function extractSources({
1289
2046
  groundingMetadata,
@@ -1379,256 +2136,312 @@ function extractSources({
1379
2136
  }
1380
2137
  return sources.length > 0 ? sources : void 0;
1381
2138
  }
1382
- var getGroundingMetadataSchema = () => import_v43.z.object({
1383
- webSearchQueries: import_v43.z.array(import_v43.z.string()).nullish(),
1384
- imageSearchQueries: import_v43.z.array(import_v43.z.string()).nullish(),
1385
- retrievalQueries: import_v43.z.array(import_v43.z.string()).nullish(),
1386
- searchEntryPoint: import_v43.z.object({ renderedContent: import_v43.z.string() }).nullish(),
1387
- groundingChunks: import_v43.z.array(
1388
- import_v43.z.object({
1389
- web: import_v43.z.object({ uri: import_v43.z.string(), title: import_v43.z.string().nullish() }).nullish(),
1390
- image: import_v43.z.object({
1391
- sourceUri: import_v43.z.string(),
1392
- imageUri: import_v43.z.string(),
1393
- title: import_v43.z.string().nullish(),
1394
- domain: import_v43.z.string().nullish()
2139
+ var getGroundingMetadataSchema = () => z3.object({
2140
+ webSearchQueries: z3.array(z3.string()).nullish(),
2141
+ imageSearchQueries: z3.array(z3.string()).nullish(),
2142
+ retrievalQueries: z3.array(z3.string()).nullish(),
2143
+ searchEntryPoint: z3.object({ renderedContent: z3.string() }).nullish(),
2144
+ groundingChunks: z3.array(
2145
+ z3.object({
2146
+ web: z3.object({ uri: z3.string(), title: z3.string().nullish() }).nullish(),
2147
+ image: z3.object({
2148
+ sourceUri: z3.string(),
2149
+ imageUri: z3.string(),
2150
+ title: z3.string().nullish(),
2151
+ domain: z3.string().nullish()
1395
2152
  }).nullish(),
1396
- retrievedContext: import_v43.z.object({
1397
- uri: import_v43.z.string().nullish(),
1398
- title: import_v43.z.string().nullish(),
1399
- text: import_v43.z.string().nullish(),
1400
- fileSearchStore: import_v43.z.string().nullish()
2153
+ retrievedContext: z3.object({
2154
+ uri: z3.string().nullish(),
2155
+ title: z3.string().nullish(),
2156
+ text: z3.string().nullish(),
2157
+ fileSearchStore: z3.string().nullish()
1401
2158
  }).nullish(),
1402
- maps: import_v43.z.object({
1403
- uri: import_v43.z.string().nullish(),
1404
- title: import_v43.z.string().nullish(),
1405
- text: import_v43.z.string().nullish(),
1406
- placeId: import_v43.z.string().nullish()
2159
+ maps: z3.object({
2160
+ uri: z3.string().nullish(),
2161
+ title: z3.string().nullish(),
2162
+ text: z3.string().nullish(),
2163
+ placeId: z3.string().nullish()
1407
2164
  }).nullish()
1408
2165
  })
1409
2166
  ).nullish(),
1410
- groundingSupports: import_v43.z.array(
1411
- import_v43.z.object({
1412
- segment: import_v43.z.object({
1413
- startIndex: import_v43.z.number().nullish(),
1414
- endIndex: import_v43.z.number().nullish(),
1415
- text: import_v43.z.string().nullish()
2167
+ groundingSupports: z3.array(
2168
+ z3.object({
2169
+ segment: z3.object({
2170
+ startIndex: z3.number().nullish(),
2171
+ endIndex: z3.number().nullish(),
2172
+ text: z3.string().nullish()
1416
2173
  }).nullish(),
1417
- segment_text: import_v43.z.string().nullish(),
1418
- groundingChunkIndices: import_v43.z.array(import_v43.z.number()).nullish(),
1419
- supportChunkIndices: import_v43.z.array(import_v43.z.number()).nullish(),
1420
- confidenceScores: import_v43.z.array(import_v43.z.number()).nullish(),
1421
- confidenceScore: import_v43.z.array(import_v43.z.number()).nullish()
2174
+ segment_text: z3.string().nullish(),
2175
+ groundingChunkIndices: z3.array(z3.number()).nullish(),
2176
+ supportChunkIndices: z3.array(z3.number()).nullish(),
2177
+ confidenceScores: z3.array(z3.number()).nullish(),
2178
+ confidenceScore: z3.array(z3.number()).nullish()
1422
2179
  })
1423
2180
  ).nullish(),
1424
- retrievalMetadata: import_v43.z.union([
1425
- import_v43.z.object({
1426
- webDynamicRetrievalScore: import_v43.z.number()
2181
+ retrievalMetadata: z3.union([
2182
+ z3.object({
2183
+ webDynamicRetrievalScore: z3.number()
1427
2184
  }),
1428
- import_v43.z.object({})
2185
+ z3.object({})
1429
2186
  ]).nullish()
1430
2187
  });
1431
- var getContentSchema = () => import_v43.z.object({
1432
- parts: import_v43.z.array(
1433
- import_v43.z.union([
2188
+ var partialArgSchema = z3.object({
2189
+ jsonPath: z3.string(),
2190
+ stringValue: z3.string().nullish(),
2191
+ numberValue: z3.number().nullish(),
2192
+ boolValue: z3.boolean().nullish(),
2193
+ nullValue: z3.unknown().nullish(),
2194
+ willContinue: z3.boolean().nullish()
2195
+ });
2196
+ var getContentSchema = () => z3.object({
2197
+ parts: z3.array(
2198
+ z3.union([
1434
2199
  // note: order matters since text can be fully empty
1435
- import_v43.z.object({
1436
- functionCall: import_v43.z.object({
1437
- name: import_v43.z.string(),
1438
- args: import_v43.z.unknown()
2200
+ z3.object({
2201
+ functionCall: z3.object({
2202
+ name: z3.string().nullish(),
2203
+ args: z3.unknown().nullish(),
2204
+ partialArgs: z3.array(partialArgSchema).nullish(),
2205
+ willContinue: z3.boolean().nullish()
2206
+ }),
2207
+ thoughtSignature: z3.string().nullish()
2208
+ }),
2209
+ z3.object({
2210
+ inlineData: z3.object({
2211
+ mimeType: z3.string(),
2212
+ data: z3.string()
2213
+ }),
2214
+ thought: z3.boolean().nullish(),
2215
+ thoughtSignature: z3.string().nullish()
2216
+ }),
2217
+ z3.object({
2218
+ toolCall: z3.object({
2219
+ toolType: z3.string(),
2220
+ args: z3.unknown().nullish(),
2221
+ id: z3.string()
1439
2222
  }),
1440
- thoughtSignature: import_v43.z.string().nullish()
2223
+ thoughtSignature: z3.string().nullish()
1441
2224
  }),
1442
- import_v43.z.object({
1443
- inlineData: import_v43.z.object({
1444
- mimeType: import_v43.z.string(),
1445
- data: import_v43.z.string()
2225
+ z3.object({
2226
+ toolResponse: z3.object({
2227
+ toolType: z3.string(),
2228
+ response: z3.unknown().nullish(),
2229
+ id: z3.string()
1446
2230
  }),
1447
- thought: import_v43.z.boolean().nullish(),
1448
- thoughtSignature: import_v43.z.string().nullish()
2231
+ thoughtSignature: z3.string().nullish()
1449
2232
  }),
1450
- import_v43.z.object({
1451
- executableCode: import_v43.z.object({
1452
- language: import_v43.z.string(),
1453
- code: import_v43.z.string()
2233
+ z3.object({
2234
+ executableCode: z3.object({
2235
+ language: z3.string(),
2236
+ code: z3.string()
1454
2237
  }).nullish(),
1455
- codeExecutionResult: import_v43.z.object({
1456
- outcome: import_v43.z.string(),
1457
- output: import_v43.z.string().nullish()
2238
+ codeExecutionResult: z3.object({
2239
+ outcome: z3.string(),
2240
+ output: z3.string().nullish()
1458
2241
  }).nullish(),
1459
- text: import_v43.z.string().nullish(),
1460
- thought: import_v43.z.boolean().nullish(),
1461
- thoughtSignature: import_v43.z.string().nullish()
2242
+ text: z3.string().nullish(),
2243
+ thought: z3.boolean().nullish(),
2244
+ thoughtSignature: z3.string().nullish()
1462
2245
  })
1463
2246
  ])
1464
2247
  ).nullish()
1465
2248
  });
1466
- var getSafetyRatingSchema = () => import_v43.z.object({
1467
- category: import_v43.z.string().nullish(),
1468
- probability: import_v43.z.string().nullish(),
1469
- probabilityScore: import_v43.z.number().nullish(),
1470
- severity: import_v43.z.string().nullish(),
1471
- severityScore: import_v43.z.number().nullish(),
1472
- blocked: import_v43.z.boolean().nullish()
2249
+ var getSafetyRatingSchema = () => z3.object({
2250
+ category: z3.string().nullish(),
2251
+ probability: z3.string().nullish(),
2252
+ probabilityScore: z3.number().nullish(),
2253
+ severity: z3.string().nullish(),
2254
+ severityScore: z3.number().nullish(),
2255
+ blocked: z3.boolean().nullish()
1473
2256
  });
1474
- var usageSchema = import_v43.z.object({
1475
- cachedContentTokenCount: import_v43.z.number().nullish(),
1476
- thoughtsTokenCount: import_v43.z.number().nullish(),
1477
- promptTokenCount: import_v43.z.number().nullish(),
1478
- candidatesTokenCount: import_v43.z.number().nullish(),
1479
- totalTokenCount: import_v43.z.number().nullish(),
2257
+ var tokenDetailsSchema = z3.array(
2258
+ z3.object({
2259
+ modality: z3.string(),
2260
+ tokenCount: z3.number()
2261
+ })
2262
+ ).nullish();
2263
+ var usageSchema = z3.object({
2264
+ cachedContentTokenCount: z3.number().nullish(),
2265
+ thoughtsTokenCount: z3.number().nullish(),
2266
+ promptTokenCount: z3.number().nullish(),
2267
+ candidatesTokenCount: z3.number().nullish(),
2268
+ totalTokenCount: z3.number().nullish(),
1480
2269
  // https://cloud.google.com/vertex-ai/generative-ai/docs/reference/rest/v1/GenerateContentResponse#TrafficType
1481
- trafficType: import_v43.z.string().nullish()
2270
+ trafficType: z3.string().nullish(),
2271
+ // https://ai.google.dev/api/generate-content#Modality
2272
+ promptTokensDetails: tokenDetailsSchema,
2273
+ candidatesTokensDetails: tokenDetailsSchema
1482
2274
  });
1483
- var getUrlContextMetadataSchema = () => import_v43.z.object({
1484
- urlMetadata: import_v43.z.array(
1485
- import_v43.z.object({
1486
- retrievedUrl: import_v43.z.string(),
1487
- urlRetrievalStatus: import_v43.z.string()
2275
+ var getUrlContextMetadataSchema = () => z3.object({
2276
+ urlMetadata: z3.array(
2277
+ z3.object({
2278
+ retrievedUrl: z3.string(),
2279
+ urlRetrievalStatus: z3.string()
1488
2280
  })
1489
2281
  ).nullish()
1490
2282
  });
1491
- var responseSchema = (0, import_provider_utils4.lazySchema)(
1492
- () => (0, import_provider_utils4.zodSchema)(
1493
- import_v43.z.object({
1494
- candidates: import_v43.z.array(
1495
- import_v43.z.object({
1496
- content: getContentSchema().nullish().or(import_v43.z.object({}).strict()),
1497
- finishReason: import_v43.z.string().nullish(),
1498
- finishMessage: import_v43.z.string().nullish(),
1499
- safetyRatings: import_v43.z.array(getSafetyRatingSchema()).nullish(),
2283
+ var responseSchema = lazySchema3(
2284
+ () => zodSchema3(
2285
+ z3.object({
2286
+ candidates: z3.array(
2287
+ z3.object({
2288
+ content: getContentSchema().nullish().or(z3.object({}).strict()),
2289
+ finishReason: z3.string().nullish(),
2290
+ finishMessage: z3.string().nullish(),
2291
+ safetyRatings: z3.array(getSafetyRatingSchema()).nullish(),
1500
2292
  groundingMetadata: getGroundingMetadataSchema().nullish(),
1501
2293
  urlContextMetadata: getUrlContextMetadataSchema().nullish()
1502
2294
  })
1503
2295
  ),
1504
2296
  usageMetadata: usageSchema.nullish(),
1505
- promptFeedback: import_v43.z.object({
1506
- blockReason: import_v43.z.string().nullish(),
1507
- safetyRatings: import_v43.z.array(getSafetyRatingSchema()).nullish()
1508
- }).nullish()
2297
+ promptFeedback: z3.object({
2298
+ blockReason: z3.string().nullish(),
2299
+ safetyRatings: z3.array(getSafetyRatingSchema()).nullish()
2300
+ }).nullish(),
2301
+ serviceTier: z3.string().nullish()
1509
2302
  })
1510
2303
  )
1511
2304
  );
1512
- var chunkSchema = (0, import_provider_utils4.lazySchema)(
1513
- () => (0, import_provider_utils4.zodSchema)(
1514
- import_v43.z.object({
1515
- candidates: import_v43.z.array(
1516
- import_v43.z.object({
2305
+ var chunkSchema = lazySchema3(
2306
+ () => zodSchema3(
2307
+ z3.object({
2308
+ candidates: z3.array(
2309
+ z3.object({
1517
2310
  content: getContentSchema().nullish(),
1518
- finishReason: import_v43.z.string().nullish(),
1519
- finishMessage: import_v43.z.string().nullish(),
1520
- safetyRatings: import_v43.z.array(getSafetyRatingSchema()).nullish(),
2311
+ finishReason: z3.string().nullish(),
2312
+ finishMessage: z3.string().nullish(),
2313
+ safetyRatings: z3.array(getSafetyRatingSchema()).nullish(),
1521
2314
  groundingMetadata: getGroundingMetadataSchema().nullish(),
1522
2315
  urlContextMetadata: getUrlContextMetadataSchema().nullish()
1523
2316
  })
1524
2317
  ).nullish(),
1525
2318
  usageMetadata: usageSchema.nullish(),
1526
- promptFeedback: import_v43.z.object({
1527
- blockReason: import_v43.z.string().nullish(),
1528
- safetyRatings: import_v43.z.array(getSafetyRatingSchema()).nullish()
1529
- }).nullish()
2319
+ promptFeedback: z3.object({
2320
+ blockReason: z3.string().nullish(),
2321
+ safetyRatings: z3.array(getSafetyRatingSchema()).nullish()
2322
+ }).nullish(),
2323
+ serviceTier: z3.string().nullish()
1530
2324
  })
1531
2325
  )
1532
2326
  );
1533
2327
 
1534
2328
  // src/tool/code-execution.ts
1535
- var import_provider_utils5 = require("@ai-sdk/provider-utils");
1536
- var import_v44 = require("zod/v4");
1537
- var codeExecution = (0, import_provider_utils5.createProviderToolFactoryWithOutputSchema)({
2329
+ import { createProviderExecutedToolFactory } from "@ai-sdk/provider-utils";
2330
+ import { z as z4 } from "zod/v4";
2331
+ var codeExecution = createProviderExecutedToolFactory({
1538
2332
  id: "google.code_execution",
1539
- inputSchema: import_v44.z.object({
1540
- language: import_v44.z.string().describe("The programming language of the code."),
1541
- code: import_v44.z.string().describe("The code to be executed.")
2333
+ inputSchema: z4.object({
2334
+ language: z4.string().describe("The programming language of the code."),
2335
+ code: z4.string().describe("The code to be executed.")
1542
2336
  }),
1543
- outputSchema: import_v44.z.object({
1544
- outcome: import_v44.z.string().describe('The outcome of the execution (e.g., "OUTCOME_OK").'),
1545
- output: import_v44.z.string().describe("The output from the code execution.")
2337
+ outputSchema: z4.object({
2338
+ outcome: z4.string().describe('The outcome of the execution (e.g., "OUTCOME_OK").'),
2339
+ output: z4.string().describe("The output from the code execution.")
1546
2340
  })
1547
2341
  });
1548
2342
 
1549
2343
  // src/tool/enterprise-web-search.ts
1550
- var import_provider_utils6 = require("@ai-sdk/provider-utils");
1551
- var import_v45 = require("zod/v4");
1552
- var enterpriseWebSearch = (0, import_provider_utils6.createProviderToolFactory)({
2344
+ import {
2345
+ createProviderExecutedToolFactory as createProviderExecutedToolFactory2,
2346
+ lazySchema as lazySchema4,
2347
+ zodSchema as zodSchema4
2348
+ } from "@ai-sdk/provider-utils";
2349
+ import { z as z5 } from "zod/v4";
2350
+ var enterpriseWebSearch = createProviderExecutedToolFactory2({
1553
2351
  id: "google.enterprise_web_search",
1554
- inputSchema: (0, import_provider_utils6.lazySchema)(() => (0, import_provider_utils6.zodSchema)(import_v45.z.object({})))
2352
+ inputSchema: lazySchema4(() => zodSchema4(z5.object({}))),
2353
+ outputSchema: lazySchema4(() => zodSchema4(z5.object({})))
1555
2354
  });
1556
2355
 
1557
2356
  // src/tool/file-search.ts
1558
- var import_provider_utils7 = require("@ai-sdk/provider-utils");
1559
- var import_v46 = require("zod/v4");
1560
- var fileSearchArgsBaseSchema = import_v46.z.object({
2357
+ import {
2358
+ createProviderExecutedToolFactory as createProviderExecutedToolFactory3,
2359
+ lazySchema as lazySchema5,
2360
+ zodSchema as zodSchema5
2361
+ } from "@ai-sdk/provider-utils";
2362
+ import { z as z6 } from "zod/v4";
2363
+ var fileSearchArgsBaseSchema = z6.object({
1561
2364
  /** The names of the file_search_stores to retrieve from.
1562
2365
  * Example: `fileSearchStores/my-file-search-store-123`
1563
2366
  */
1564
- fileSearchStoreNames: import_v46.z.array(import_v46.z.string()).describe(
2367
+ fileSearchStoreNames: z6.array(z6.string()).describe(
1565
2368
  "The names of the file_search_stores to retrieve from. Example: `fileSearchStores/my-file-search-store-123`"
1566
2369
  ),
1567
2370
  /** The number of file search retrieval chunks to retrieve. */
1568
- topK: import_v46.z.number().int().positive().describe("The number of file search retrieval chunks to retrieve.").optional(),
2371
+ topK: z6.number().int().positive().describe("The number of file search retrieval chunks to retrieve.").optional(),
1569
2372
  /** Metadata filter to apply to the file search retrieval documents.
1570
2373
  * See https://google.aip.dev/160 for the syntax of the filter expression.
1571
2374
  */
1572
- metadataFilter: import_v46.z.string().describe(
2375
+ metadataFilter: z6.string().describe(
1573
2376
  "Metadata filter to apply to the file search retrieval documents. See https://google.aip.dev/160 for the syntax of the filter expression."
1574
2377
  ).optional()
1575
2378
  }).passthrough();
1576
- var fileSearchArgsSchema = (0, import_provider_utils7.lazySchema)(
1577
- () => (0, import_provider_utils7.zodSchema)(fileSearchArgsBaseSchema)
1578
- );
1579
- var fileSearch = (0, import_provider_utils7.createProviderToolFactory)({
2379
+ var fileSearch = createProviderExecutedToolFactory3({
1580
2380
  id: "google.file_search",
1581
- inputSchema: fileSearchArgsSchema
2381
+ inputSchema: lazySchema5(() => zodSchema5(z6.object({}))),
2382
+ outputSchema: lazySchema5(() => zodSchema5(z6.object({})))
1582
2383
  });
1583
2384
 
1584
2385
  // src/tool/google-maps.ts
1585
- var import_provider_utils8 = require("@ai-sdk/provider-utils");
1586
- var import_v47 = require("zod/v4");
1587
- var googleMaps = (0, import_provider_utils8.createProviderToolFactory)({
2386
+ import {
2387
+ createProviderExecutedToolFactory as createProviderExecutedToolFactory4,
2388
+ lazySchema as lazySchema6,
2389
+ zodSchema as zodSchema6
2390
+ } from "@ai-sdk/provider-utils";
2391
+ import { z as z7 } from "zod/v4";
2392
+ var googleMaps = createProviderExecutedToolFactory4({
1588
2393
  id: "google.google_maps",
1589
- inputSchema: (0, import_provider_utils8.lazySchema)(() => (0, import_provider_utils8.zodSchema)(import_v47.z.object({})))
2394
+ inputSchema: lazySchema6(() => zodSchema6(z7.object({}))),
2395
+ outputSchema: lazySchema6(() => zodSchema6(z7.object({})))
1590
2396
  });
1591
2397
 
1592
2398
  // src/tool/google-search.ts
1593
- var import_provider_utils9 = require("@ai-sdk/provider-utils");
1594
- var import_v48 = require("zod/v4");
1595
- var googleSearchToolArgsBaseSchema = import_v48.z.object({
1596
- searchTypes: import_v48.z.object({
1597
- webSearch: import_v48.z.object({}).optional(),
1598
- imageSearch: import_v48.z.object({}).optional()
2399
+ import {
2400
+ createProviderExecutedToolFactory as createProviderExecutedToolFactory5,
2401
+ lazySchema as lazySchema7,
2402
+ zodSchema as zodSchema7
2403
+ } from "@ai-sdk/provider-utils";
2404
+ import { z as z8 } from "zod/v4";
2405
+ var googleSearchToolArgsBaseSchema = z8.object({
2406
+ searchTypes: z8.object({
2407
+ webSearch: z8.object({}).optional(),
2408
+ imageSearch: z8.object({}).optional()
1599
2409
  }).optional(),
1600
- timeRangeFilter: import_v48.z.object({
1601
- startTime: import_v48.z.string(),
1602
- endTime: import_v48.z.string()
2410
+ timeRangeFilter: z8.object({
2411
+ startTime: z8.string(),
2412
+ endTime: z8.string()
1603
2413
  }).optional()
1604
2414
  }).passthrough();
1605
- var googleSearchToolArgsSchema = (0, import_provider_utils9.lazySchema)(
1606
- () => (0, import_provider_utils9.zodSchema)(googleSearchToolArgsBaseSchema)
1607
- );
1608
- var googleSearch = (0, import_provider_utils9.createProviderToolFactory)(
1609
- {
1610
- id: "google.google_search",
1611
- inputSchema: googleSearchToolArgsSchema
1612
- }
1613
- );
2415
+ var googleSearch = createProviderExecutedToolFactory5({
2416
+ id: "google.google_search",
2417
+ inputSchema: lazySchema7(() => zodSchema7(z8.object({}))),
2418
+ outputSchema: lazySchema7(() => zodSchema7(z8.object({})))
2419
+ });
1614
2420
 
1615
2421
  // src/tool/url-context.ts
1616
- var import_provider_utils10 = require("@ai-sdk/provider-utils");
1617
- var import_v49 = require("zod/v4");
1618
- var urlContext = (0, import_provider_utils10.createProviderToolFactory)({
2422
+ import {
2423
+ createProviderExecutedToolFactory as createProviderExecutedToolFactory6,
2424
+ lazySchema as lazySchema8,
2425
+ zodSchema as zodSchema8
2426
+ } from "@ai-sdk/provider-utils";
2427
+ import { z as z9 } from "zod/v4";
2428
+ var urlContext = createProviderExecutedToolFactory6({
1619
2429
  id: "google.url_context",
1620
- inputSchema: (0, import_provider_utils10.lazySchema)(() => (0, import_provider_utils10.zodSchema)(import_v49.z.object({})))
2430
+ inputSchema: lazySchema8(() => zodSchema8(z9.object({}))),
2431
+ outputSchema: lazySchema8(() => zodSchema8(z9.object({})))
1621
2432
  });
1622
2433
 
1623
2434
  // src/tool/vertex-rag-store.ts
1624
- var import_provider_utils11 = require("@ai-sdk/provider-utils");
1625
- var import_v410 = require("zod/v4");
1626
- var vertexRagStore = (0, import_provider_utils11.createProviderToolFactory)({
2435
+ import {
2436
+ createProviderExecutedToolFactory as createProviderExecutedToolFactory7,
2437
+ lazySchema as lazySchema9,
2438
+ zodSchema as zodSchema9
2439
+ } from "@ai-sdk/provider-utils";
2440
+ import { z as z10 } from "zod/v4";
2441
+ var vertexRagStore = createProviderExecutedToolFactory7({
1627
2442
  id: "google.vertex_rag_store",
1628
- inputSchema: import_v410.z.object({
1629
- ragCorpus: import_v410.z.string(),
1630
- topK: import_v410.z.number().optional()
1631
- })
2443
+ inputSchema: lazySchema9(() => zodSchema9(z10.object({}))),
2444
+ outputSchema: lazySchema9(() => zodSchema9(z10.object({})))
1632
2445
  });
1633
2446
 
1634
2447
  // src/google-tools.ts
@@ -1690,11 +2503,10 @@ var googleTools = {
1690
2503
  */
1691
2504
  vertexRagStore
1692
2505
  };
1693
- // Annotate the CommonJS export names for ESM import in node:
1694
- 0 && (module.exports = {
1695
- GoogleGenerativeAILanguageModel,
2506
+ export {
2507
+ GoogleLanguageModel,
1696
2508
  getGroundingMetadataSchema,
1697
2509
  getUrlContextMetadataSchema,
1698
2510
  googleTools
1699
- });
2511
+ };
1700
2512
  //# sourceMappingURL=index.js.map