@ai-sdk/google 4.0.0-beta.7 → 4.0.0-beta.82

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 (71) hide show
  1. package/CHANGELOG.md +614 -5
  2. package/README.md +6 -4
  3. package/dist/index.d.ts +301 -50
  4. package/dist/index.js +5410 -639
  5. package/dist/index.js.map +1 -1
  6. package/dist/internal/index.d.ts +100 -26
  7. package/dist/internal/index.js +1653 -451
  8. package/dist/internal/index.js.map +1 -1
  9. package/docs/{15-google-generative-ai.mdx → 15-google.mdx} +784 -69
  10. package/package.json +16 -17
  11. package/src/{convert-google-generative-ai-usage.ts → convert-google-usage.ts} +13 -5
  12. package/src/convert-json-schema-to-openapi-schema.ts +1 -1
  13. package/src/convert-to-google-messages.ts +647 -0
  14. package/src/{google-generative-ai-embedding-options.ts → google-embedding-model-options.ts} +9 -2
  15. package/src/{google-generative-ai-embedding-model.ts → google-embedding-model.ts} +31 -18
  16. package/src/google-error.ts +1 -1
  17. package/src/google-files.ts +225 -0
  18. package/src/google-image-model-options.ts +35 -0
  19. package/src/{google-generative-ai-image-model.ts → google-image-model.ts} +116 -65
  20. package/src/{google-generative-ai-image-settings.ts → google-image-settings.ts} +2 -2
  21. package/src/google-json-accumulator.ts +371 -0
  22. package/src/{google-generative-ai-options.ts → google-language-model-options.ts} +50 -5
  23. package/src/{google-generative-ai-language-model.ts → google-language-model.ts} +701 -219
  24. package/src/google-prepare-tools.ts +72 -12
  25. package/src/google-prompt.ts +86 -0
  26. package/src/google-provider.ts +157 -53
  27. package/src/google-speech-api.ts +36 -0
  28. package/src/google-speech-model-options.ts +48 -0
  29. package/src/google-speech-model.ts +311 -0
  30. package/src/google-video-model-options.ts +43 -0
  31. package/src/{google-generative-ai-video-model.ts → google-video-model.ts} +25 -60
  32. package/src/{google-generative-ai-video-settings.ts → google-video-settings.ts} +2 -1
  33. package/src/index.ts +40 -9
  34. package/src/interactions/build-google-interactions-stream-transform.ts +818 -0
  35. package/src/interactions/cancel-google-interaction.ts +60 -0
  36. package/src/interactions/convert-google-interactions-usage.ts +47 -0
  37. package/src/interactions/convert-to-google-interactions-input.ts +557 -0
  38. package/src/interactions/extract-google-interactions-sources.ts +252 -0
  39. package/src/interactions/google-interactions-agent.ts +15 -0
  40. package/src/interactions/google-interactions-api.ts +530 -0
  41. package/src/interactions/google-interactions-language-model-options.ts +262 -0
  42. package/src/interactions/google-interactions-language-model.ts +776 -0
  43. package/src/interactions/google-interactions-prompt.ts +582 -0
  44. package/src/interactions/google-interactions-provider-metadata.ts +23 -0
  45. package/src/interactions/map-google-interactions-finish-reason.ts +31 -0
  46. package/src/interactions/parse-google-interactions-outputs.ts +252 -0
  47. package/src/interactions/poll-google-interactions.ts +129 -0
  48. package/src/interactions/prepare-google-interactions-tools.ts +245 -0
  49. package/src/interactions/stream-google-interactions.ts +242 -0
  50. package/src/interactions/synthesize-google-interactions-agent-stream.ts +185 -0
  51. package/src/internal/index.ts +3 -2
  52. package/src/{map-google-generative-ai-finish-reason.ts → map-google-finish-reason.ts} +3 -3
  53. package/src/realtime/google-realtime-event-mapper.ts +383 -0
  54. package/src/realtime/google-realtime-model-options.ts +3 -0
  55. package/src/realtime/google-realtime-model.ts +160 -0
  56. package/src/realtime/index.ts +2 -0
  57. package/src/tool/code-execution.ts +2 -2
  58. package/src/tool/enterprise-web-search.ts +9 -3
  59. package/src/tool/file-search.ts +5 -7
  60. package/src/tool/google-maps.ts +3 -2
  61. package/src/tool/google-search.ts +11 -12
  62. package/src/tool/url-context.ts +4 -2
  63. package/src/tool/vertex-rag-store.ts +9 -6
  64. package/dist/index.d.mts +0 -376
  65. package/dist/index.mjs +0 -2517
  66. package/dist/index.mjs.map +0 -1
  67. package/dist/internal/index.d.mts +0 -284
  68. package/dist/internal/index.mjs +0 -1706
  69. package/dist/internal/index.mjs.map +0 -1
  70. package/src/convert-to-google-generative-ai-messages.ts +0 -239
  71. package/src/google-generative-ai-prompt.ts +0 -38
@@ -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);
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";
19
20
 
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);
29
-
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,163 @@ 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 SKIP_THOUGHT_SIGNATURE_VALIDATOR = "skip_thought_signature_validator";
188
+ var dataUrlRegex = /^data:([^;,]+);base64,(.+)$/s;
189
+ function parseBase64DataUrl(value) {
190
+ const match = dataUrlRegex.exec(value);
191
+ if (match == null) {
192
+ return void 0;
193
+ }
194
+ return {
195
+ mediaType: match[1],
196
+ data: match[2]
197
+ };
198
+ }
199
+ function convertUrlToolResultPart(url) {
200
+ const parsedDataUrl = parseBase64DataUrl(url);
201
+ if (parsedDataUrl == null) {
202
+ return void 0;
203
+ }
204
+ return {
205
+ inlineData: {
206
+ mimeType: parsedDataUrl.mediaType,
207
+ data: parsedDataUrl.data
208
+ }
209
+ };
210
+ }
211
+ function appendToolResultParts(parts, toolName, outputValue, toolCallId) {
212
+ const functionResponseParts = [];
213
+ const responseTextParts = [];
214
+ for (const contentPart of outputValue) {
215
+ switch (contentPart.type) {
216
+ case "text": {
217
+ responseTextParts.push(contentPart.text);
218
+ break;
219
+ }
220
+ case "file": {
221
+ if (contentPart.data.type === "data") {
222
+ functionResponseParts.push({
223
+ inlineData: {
224
+ mimeType: resolveFullMediaType({ part: contentPart }),
225
+ data: convertToBase64(contentPart.data.data)
226
+ }
227
+ });
228
+ } else if (contentPart.data.type === "url") {
229
+ const functionResponsePart = convertUrlToolResultPart(
230
+ contentPart.data.url.toString()
231
+ );
232
+ if (functionResponsePart != null) {
233
+ functionResponseParts.push(functionResponsePart);
234
+ } else {
235
+ responseTextParts.push(JSON.stringify(contentPart));
236
+ }
237
+ } else {
238
+ responseTextParts.push(JSON.stringify(contentPart));
239
+ }
240
+ break;
241
+ }
242
+ default: {
243
+ responseTextParts.push(JSON.stringify(contentPart));
244
+ break;
245
+ }
246
+ }
247
+ }
248
+ parts.push({
249
+ functionResponse: {
250
+ ...toolCallId != null ? { id: toolCallId } : {},
251
+ name: toolName,
252
+ response: {
253
+ name: toolName,
254
+ content: responseTextParts.length > 0 ? responseTextParts.join("\n") : "Tool executed successfully."
255
+ },
256
+ ...functionResponseParts.length > 0 ? { parts: functionResponseParts } : {}
257
+ }
258
+ });
259
+ }
260
+ function appendLegacyToolResultParts(parts, toolName, outputValue, toolCallId) {
261
+ for (const contentPart of outputValue) {
262
+ switch (contentPart.type) {
263
+ case "text":
264
+ parts.push({
265
+ functionResponse: {
266
+ ...toolCallId != null ? { id: toolCallId } : {},
267
+ name: toolName,
268
+ response: {
269
+ name: toolName,
270
+ content: contentPart.text
271
+ }
272
+ }
273
+ });
274
+ break;
275
+ case "file": {
276
+ if (contentPart.data.type === "data" && getTopLevelMediaType(contentPart.mediaType) === "image") {
277
+ parts.push(
278
+ {
279
+ inlineData: {
280
+ mimeType: resolveFullMediaType({ part: contentPart }),
281
+ data: convertToBase64(contentPart.data.data)
282
+ }
283
+ },
284
+ {
285
+ text: "Tool executed successfully and returned this image as a response"
286
+ }
287
+ );
288
+ } else {
289
+ parts.push({ text: JSON.stringify(contentPart) });
290
+ }
291
+ break;
292
+ }
293
+ default:
294
+ parts.push({ text: JSON.stringify(contentPart) });
295
+ break;
296
+ }
297
+ }
298
+ }
299
+ function convertToGoogleMessages(prompt, options) {
300
+ var _a, _b, _c, _d, _e;
194
301
  const systemInstructionParts = [];
195
302
  const contents = [];
196
303
  let systemMessagesAllowed = true;
197
304
  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";
305
+ const isGemini3Model2 = (_b = options == null ? void 0 : options.isGemini3Model) != null ? _b : false;
306
+ const onWarning = options == null ? void 0 : options.onWarning;
307
+ const providerOptionsNames = (_c = options == null ? void 0 : options.providerOptionsNames) != null ? _c : ["google"];
308
+ const isVertexLike = !providerOptionsNames.includes("google");
309
+ const supportsFunctionResponseParts = (_d = options == null ? void 0 : options.supportsFunctionResponseParts) != null ? _d : true;
310
+ let sentinelInjected = false;
311
+ const missingSignatureToolNames = [];
312
+ const injectSkipSignature = (toolName) => {
313
+ missingSignatureToolNames.push(toolName);
314
+ sentinelInjected = true;
315
+ return SKIP_THOUGHT_SIGNATURE_VALIDATOR;
316
+ };
317
+ const readProviderOpts = (part) => {
318
+ var _a2, _b2, _c2, _d2, _e2;
319
+ for (const name of providerOptionsNames) {
320
+ const v = (_a2 = part.providerOptions) == null ? void 0 : _a2[name];
321
+ if (v != null) return v;
322
+ }
323
+ if (isVertexLike) {
324
+ return (_b2 = part.providerOptions) == null ? void 0 : _b2.google;
325
+ }
326
+ return (_e2 = (_c2 = part.providerOptions) == null ? void 0 : _c2.googleVertex) != null ? _e2 : (_d2 = part.providerOptions) == null ? void 0 : _d2.vertex;
327
+ };
199
328
  for (const { role, content } of prompt) {
200
329
  switch (role) {
201
330
  case "system": {
202
331
  if (!systemMessagesAllowed) {
203
- throw new import_provider.UnsupportedFunctionalityError({
332
+ throw new UnsupportedFunctionalityError({
204
333
  functionality: "system messages are only supported at the beginning of the conversation"
205
334
  });
206
335
  }
@@ -217,20 +346,54 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
217
346
  break;
218
347
  }
219
348
  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)
349
+ switch (part.data.type) {
350
+ case "url": {
351
+ parts.push({
352
+ fileData: {
353
+ mimeType: resolveFullMediaType({ part }),
354
+ fileUri: part.data.url.toString()
355
+ }
356
+ });
357
+ break;
358
+ }
359
+ case "reference": {
360
+ if (isVertexLike) {
361
+ throw new UnsupportedFunctionalityError({
362
+ functionality: "file parts with provider references"
363
+ });
231
364
  }
365
+ parts.push({
366
+ fileData: {
367
+ mimeType: resolveFullMediaType({ part }),
368
+ fileUri: resolveProviderReference({
369
+ reference: part.data.reference,
370
+ provider: "google"
371
+ })
372
+ }
373
+ });
374
+ break;
232
375
  }
233
- );
376
+ case "text": {
377
+ parts.push({
378
+ inlineData: {
379
+ mimeType: isFullMediaType(part.mediaType) ? part.mediaType : "text/plain",
380
+ data: convertToBase64(
381
+ new TextEncoder().encode(part.data.text)
382
+ )
383
+ }
384
+ });
385
+ break;
386
+ }
387
+ case "data": {
388
+ parts.push({
389
+ inlineData: {
390
+ mimeType: resolveFullMediaType({ part }),
391
+ data: convertToBase64(part.data.data)
392
+ }
393
+ });
394
+ break;
395
+ }
396
+ }
234
397
  break;
235
398
  }
236
399
  }
@@ -243,8 +406,7 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
243
406
  contents.push({
244
407
  role: "model",
245
408
  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;
409
+ const providerOpts = readProviderOpts(part);
248
410
  const thoughtSignature = (providerOpts == null ? void 0 : providerOpts.thoughtSignature) != null ? String(providerOpts.thoughtSignature) : void 0;
249
411
  switch (part.type) {
250
412
  case "text": {
@@ -260,30 +422,114 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
260
422
  thoughtSignature
261
423
  };
262
424
  }
425
+ case "reasoning-file": {
426
+ switch (part.data.type) {
427
+ case "url": {
428
+ throw new UnsupportedFunctionalityError({
429
+ functionality: "File data URLs in assistant messages are not supported"
430
+ });
431
+ }
432
+ case "data": {
433
+ return {
434
+ inlineData: {
435
+ mimeType: part.mediaType,
436
+ data: convertToBase64(part.data.data)
437
+ },
438
+ thought: true,
439
+ thoughtSignature
440
+ };
441
+ }
442
+ }
443
+ break;
444
+ }
263
445
  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
- });
446
+ switch (part.data.type) {
447
+ case "url": {
448
+ throw new UnsupportedFunctionalityError({
449
+ functionality: "File data URLs in assistant messages are not supported"
450
+ });
451
+ }
452
+ case "reference": {
453
+ if (isVertexLike) {
454
+ throw new UnsupportedFunctionalityError({
455
+ functionality: "file parts with provider references"
456
+ });
457
+ }
458
+ return {
459
+ fileData: {
460
+ mimeType: part.mediaType,
461
+ fileUri: resolveProviderReference({
462
+ reference: part.data.reference,
463
+ provider: "google"
464
+ })
465
+ },
466
+ ...(providerOpts == null ? void 0 : providerOpts.thought) === true ? { thought: true } : {},
467
+ thoughtSignature
468
+ };
469
+ }
470
+ case "text": {
471
+ return {
472
+ inlineData: {
473
+ mimeType: isFullMediaType(part.mediaType) ? part.mediaType : "text/plain",
474
+ data: convertToBase64(
475
+ new TextEncoder().encode(part.data.text)
476
+ )
477
+ },
478
+ ...(providerOpts == null ? void 0 : providerOpts.thought) === true ? { thought: true } : {},
479
+ thoughtSignature
480
+ };
481
+ }
482
+ case "data": {
483
+ return {
484
+ inlineData: {
485
+ mimeType: part.mediaType,
486
+ data: convertToBase64(part.data.data)
487
+ },
488
+ ...(providerOpts == null ? void 0 : providerOpts.thought) === true ? { thought: true } : {},
489
+ thoughtSignature
490
+ };
491
+ }
268
492
  }
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
- };
493
+ break;
277
494
  }
278
495
  case "tool-call": {
496
+ const serverToolCallId = (providerOpts == null ? void 0 : providerOpts.serverToolCallId) != null ? String(providerOpts.serverToolCallId) : void 0;
497
+ const serverToolType = (providerOpts == null ? void 0 : providerOpts.serverToolType) != null ? String(providerOpts.serverToolType) : void 0;
498
+ const effectiveThoughtSignature = thoughtSignature != null ? thoughtSignature : isGemini3Model2 ? injectSkipSignature(part.toolName) : void 0;
499
+ if (serverToolCallId && serverToolType) {
500
+ return {
501
+ toolCall: {
502
+ toolType: serverToolType,
503
+ args: typeof part.input === "string" ? JSON.parse(part.input) : part.input,
504
+ id: serverToolCallId
505
+ },
506
+ thoughtSignature: effectiveThoughtSignature
507
+ };
508
+ }
279
509
  return {
280
510
  functionCall: {
511
+ ...part.toolCallId != null ? { id: part.toolCallId } : {},
281
512
  name: part.toolName,
282
513
  args: part.input
283
514
  },
284
- thoughtSignature
515
+ thoughtSignature: effectiveThoughtSignature
285
516
  };
286
517
  }
518
+ case "tool-result": {
519
+ const serverToolCallId = (providerOpts == null ? void 0 : providerOpts.serverToolCallId) != null ? String(providerOpts.serverToolCallId) : void 0;
520
+ const serverToolType = (providerOpts == null ? void 0 : providerOpts.serverToolType) != null ? String(providerOpts.serverToolType) : void 0;
521
+ if (serverToolCallId && serverToolType) {
522
+ return {
523
+ toolResponse: {
524
+ toolType: serverToolType,
525
+ response: part.output.type === "json" ? part.output.value : {},
526
+ id: serverToolCallId
527
+ },
528
+ thoughtSignature
529
+ };
530
+ }
531
+ return void 0;
532
+ }
287
533
  }
288
534
  }).filter((part) => part !== void 0)
289
535
  });
@@ -296,46 +542,51 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
296
542
  if (part.type === "tool-approval-response") {
297
543
  continue;
298
544
  }
545
+ const partProviderOpts = readProviderOpts(part);
546
+ const serverToolCallId = (partProviderOpts == null ? void 0 : partProviderOpts.serverToolCallId) != null ? String(partProviderOpts.serverToolCallId) : void 0;
547
+ const serverToolType = (partProviderOpts == null ? void 0 : partProviderOpts.serverToolType) != null ? String(partProviderOpts.serverToolType) : void 0;
548
+ if (serverToolCallId && serverToolType) {
549
+ const serverThoughtSignature = (partProviderOpts == null ? void 0 : partProviderOpts.thoughtSignature) != null ? String(partProviderOpts.thoughtSignature) : void 0;
550
+ if (contents.length > 0) {
551
+ const lastContent = contents[contents.length - 1];
552
+ if (lastContent.role === "model") {
553
+ lastContent.parts.push({
554
+ toolResponse: {
555
+ toolType: serverToolType,
556
+ response: part.output.type === "json" ? part.output.value : {},
557
+ id: serverToolCallId
558
+ },
559
+ thoughtSignature: serverThoughtSignature
560
+ });
561
+ continue;
562
+ }
563
+ }
564
+ }
299
565
  const output = part.output;
300
566
  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
- }
567
+ if (supportsFunctionResponseParts) {
568
+ appendToolResultParts(
569
+ parts,
570
+ part.toolName,
571
+ output.value,
572
+ part.toolCallId
573
+ );
574
+ } else {
575
+ appendLegacyToolResultParts(
576
+ parts,
577
+ part.toolName,
578
+ output.value,
579
+ part.toolCallId
580
+ );
331
581
  }
332
582
  } else {
333
583
  parts.push({
334
584
  functionResponse: {
585
+ ...part.toolCallId != null ? { id: part.toolCallId } : {},
335
586
  name: part.toolName,
336
587
  response: {
337
588
  name: part.toolName,
338
- content: output.type === "execution-denied" ? (_c = output.reason) != null ? _c : "Tool execution denied." : output.value
589
+ content: output.type === "execution-denied" ? (_e = output.reason) != null ? _e : "Tool call execution denied." : output.value
339
590
  }
340
591
  }
341
592
  });
@@ -353,6 +604,13 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
353
604
  const systemText = systemInstructionParts.map((part) => part.text).join("\n\n");
354
605
  contents[0].parts.unshift({ text: systemText + "\n\n" });
355
606
  }
607
+ if (sentinelInjected && onWarning != null) {
608
+ const uniqueToolNames = Array.from(new Set(missingSignatureToolNames));
609
+ onWarning({
610
+ type: "other",
611
+ message: `Replayed ${missingSignatureToolNames.length} \`functionCall\` part(s) for a Gemini 3 model without a \`thoughtSignature\` (tools: ${uniqueToolNames.map((name) => `\`${name}\``).join(", ")}). Injected the documented \`skip_thought_signature_validator\` sentinel to keep the request from failing with HTTP 400. The likely cause is application code that drops \`providerOptions.google.thoughtSignature\` when persisting or serializing assistant tool-call messages. See https://ai.google.dev/gemini-api/docs/thought-signatures.`
612
+ });
613
+ }
356
614
  return {
357
615
  systemInstruction: systemInstructionParts.length > 0 && !isGemmaModel ? { parts: systemInstructionParts } : void 0,
358
616
  contents
@@ -365,58 +623,65 @@ function getModelPath(modelId) {
365
623
  }
366
624
 
367
625
  // 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()
626
+ import {
627
+ createJsonErrorResponseHandler,
628
+ lazySchema,
629
+ zodSchema
630
+ } from "@ai-sdk/provider-utils";
631
+ import { z } from "zod/v4";
632
+ var googleErrorDataSchema = lazySchema(
633
+ () => zodSchema(
634
+ z.object({
635
+ error: z.object({
636
+ code: z.number().nullable(),
637
+ message: z.string(),
638
+ status: z.string()
377
639
  })
378
640
  })
379
641
  )
380
642
  );
381
- var googleFailedResponseHandler = (0, import_provider_utils2.createJsonErrorResponseHandler)({
643
+ var googleFailedResponseHandler = createJsonErrorResponseHandler({
382
644
  errorSchema: googleErrorDataSchema,
383
645
  errorToMessage: (data) => data.error.message
384
646
  });
385
647
 
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(),
648
+ // src/google-language-model-options.ts
649
+ import {
650
+ lazySchema as lazySchema2,
651
+ zodSchema as zodSchema2
652
+ } from "@ai-sdk/provider-utils";
653
+ import { z as z2 } from "zod/v4";
654
+ var googleLanguageModelOptions = lazySchema2(
655
+ () => zodSchema2(
656
+ z2.object({
657
+ responseModalities: z2.array(z2.enum(["TEXT", "IMAGE"])).optional(),
658
+ thinkingConfig: z2.object({
659
+ thinkingBudget: z2.number().optional(),
660
+ includeThoughts: z2.boolean().optional(),
396
661
  // https://ai.google.dev/gemini-api/docs/gemini-3?thinking=high#thinking_level
397
- thinkingLevel: import_v42.z.enum(["minimal", "low", "medium", "high"]).optional()
662
+ thinkingLevel: z2.enum(["minimal", "low", "medium", "high"]).optional()
398
663
  }).optional(),
399
664
  /**
400
665
  * Optional.
401
666
  * The name of the cached content used as context to serve the prediction.
402
667
  * Format: cachedContents/{cachedContent}
403
668
  */
404
- cachedContent: import_v42.z.string().optional(),
669
+ cachedContent: z2.string().optional(),
405
670
  /**
406
671
  * Optional. Enable structured output. Default is true.
407
672
  *
408
673
  * This is useful when the JSON Schema contains elements that are
409
674
  * not supported by the OpenAPI schema version that
410
- * Google Generative AI uses. You can use this to disable
675
+ * Google uses. You can use this to disable
411
676
  * structured outputs if you need to.
412
677
  */
413
- structuredOutputs: import_v42.z.boolean().optional(),
678
+ structuredOutputs: z2.boolean().optional(),
414
679
  /**
415
680
  * Optional. A list of unique safety settings for blocking unsafe content.
416
681
  */
417
- safetySettings: import_v42.z.array(
418
- import_v42.z.object({
419
- category: import_v42.z.enum([
682
+ safetySettings: z2.array(
683
+ z2.object({
684
+ category: z2.enum([
420
685
  "HARM_CATEGORY_UNSPECIFIED",
421
686
  "HARM_CATEGORY_HATE_SPEECH",
422
687
  "HARM_CATEGORY_DANGEROUS_CONTENT",
@@ -424,7 +689,7 @@ var googleLanguageModelOptions = (0, import_provider_utils3.lazySchema)(
424
689
  "HARM_CATEGORY_SEXUALLY_EXPLICIT",
425
690
  "HARM_CATEGORY_CIVIC_INTEGRITY"
426
691
  ]),
427
- threshold: import_v42.z.enum([
692
+ threshold: z2.enum([
428
693
  "HARM_BLOCK_THRESHOLD_UNSPECIFIED",
429
694
  "BLOCK_LOW_AND_ABOVE",
430
695
  "BLOCK_MEDIUM_AND_ABOVE",
@@ -434,7 +699,7 @@ var googleLanguageModelOptions = (0, import_provider_utils3.lazySchema)(
434
699
  ])
435
700
  })
436
701
  ).optional(),
437
- threshold: import_v42.z.enum([
702
+ threshold: z2.enum([
438
703
  "HARM_BLOCK_THRESHOLD_UNSPECIFIED",
439
704
  "BLOCK_LOW_AND_ABOVE",
440
705
  "BLOCK_MEDIUM_AND_ABOVE",
@@ -447,19 +712,19 @@ var googleLanguageModelOptions = (0, import_provider_utils3.lazySchema)(
447
712
  *
448
713
  * https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/audio-understanding
449
714
  */
450
- audioTimestamp: import_v42.z.boolean().optional(),
715
+ audioTimestamp: z2.boolean().optional(),
451
716
  /**
452
717
  * Optional. Defines labels used in billing reports. Available on Vertex AI only.
453
718
  *
454
719
  * https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/add-labels-to-api-calls
455
720
  */
456
- labels: import_v42.z.record(import_v42.z.string(), import_v42.z.string()).optional(),
721
+ labels: z2.record(z2.string(), z2.string()).optional(),
457
722
  /**
458
723
  * Optional. If specified, the media resolution specified will be used.
459
724
  *
460
725
  * https://ai.google.dev/api/generate-content#MediaResolution
461
726
  */
462
- mediaResolution: import_v42.z.enum([
727
+ mediaResolution: z2.enum([
463
728
  "MEDIA_RESOLUTION_UNSPECIFIED",
464
729
  "MEDIA_RESOLUTION_LOW",
465
730
  "MEDIA_RESOLUTION_MEDIUM",
@@ -470,8 +735,8 @@ var googleLanguageModelOptions = (0, import_provider_utils3.lazySchema)(
470
735
  *
471
736
  * https://ai.google.dev/gemini-api/docs/image-generation#aspect_ratios
472
737
  */
473
- imageConfig: import_v42.z.object({
474
- aspectRatio: import_v42.z.enum([
738
+ imageConfig: z2.object({
739
+ aspectRatio: z2.enum([
475
740
  "1:1",
476
741
  "2:3",
477
742
  "3:2",
@@ -487,7 +752,7 @@ var googleLanguageModelOptions = (0, import_provider_utils3.lazySchema)(
487
752
  "1:4",
488
753
  "4:1"
489
754
  ]).optional(),
490
- imageSize: import_v42.z.enum(["1K", "2K", "4K", "512"]).optional()
755
+ imageSize: z2.enum(["1K", "2K", "4K", "512"]).optional()
491
756
  }).optional(),
492
757
  /**
493
758
  * Optional. Configuration for grounding retrieval.
@@ -495,24 +760,62 @@ var googleLanguageModelOptions = (0, import_provider_utils3.lazySchema)(
495
760
  *
496
761
  * https://cloud.google.com/vertex-ai/generative-ai/docs/grounding/grounding-with-google-maps
497
762
  */
498
- retrievalConfig: import_v42.z.object({
499
- latLng: import_v42.z.object({
500
- latitude: import_v42.z.number(),
501
- longitude: import_v42.z.number()
763
+ retrievalConfig: z2.object({
764
+ latLng: z2.object({
765
+ latitude: z2.number(),
766
+ longitude: z2.number()
502
767
  }).optional()
503
- }).optional()
768
+ }).optional(),
769
+ /**
770
+ * Optional. When set to true, function call arguments will be streamed
771
+ * incrementally via partialArgs in streaming responses. Only supported
772
+ * on the Vertex AI API (not the Gemini API) and only for Gemini 3+
773
+ * models.
774
+ *
775
+ * @default false
776
+ *
777
+ * https://docs.cloud.google.com/vertex-ai/generative-ai/docs/multimodal/function-calling#streaming-fc
778
+ */
779
+ streamFunctionCallArguments: z2.boolean().optional(),
780
+ /**
781
+ * Optional. The service tier to use for the request. Sent as the
782
+ * `serviceTier` body field. Gemini API only.
783
+ */
784
+ serviceTier: z2.enum(["standard", "flex", "priority"]).optional(),
785
+ /**
786
+ * Optional. Vertex AI only. Sent as the
787
+ * `X-Vertex-AI-LLM-Shared-Request-Type` request header to select a
788
+ * shared (PayGo) tier. With Provisioned Throughput allocated and
789
+ * `requestType` unset, the request falls back to this tier only if
790
+ * PT capacity is exhausted.
791
+ *
792
+ * https://docs.cloud.google.com/vertex-ai/generative-ai/docs/priority-paygo
793
+ * https://docs.cloud.google.com/vertex-ai/generative-ai/docs/flex-paygo
794
+ */
795
+ sharedRequestType: z2.enum(["priority", "flex", "standard"]).optional(),
796
+ /**
797
+ * Optional. Vertex AI only. Sent as the `X-Vertex-AI-LLM-Request-Type`
798
+ * request header. Set to `'shared'` together with `sharedRequestType`
799
+ * to bypass Provisioned Throughput entirely.
800
+ *
801
+ * https://docs.cloud.google.com/vertex-ai/generative-ai/docs/priority-paygo
802
+ */
803
+ requestType: z2.enum(["shared"]).optional()
504
804
  })
505
805
  )
506
806
  );
507
807
 
508
808
  // src/google-prepare-tools.ts
509
- var import_provider2 = require("@ai-sdk/provider");
809
+ import {
810
+ UnsupportedFunctionalityError as UnsupportedFunctionalityError2
811
+ } from "@ai-sdk/provider";
510
812
  function prepareTools({
511
813
  tools,
512
814
  toolChoice,
513
- modelId
815
+ modelId,
816
+ isVertexProvider = false
514
817
  }) {
515
- var _a;
818
+ var _a, _b;
516
819
  tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
517
820
  const toolWarnings = [];
518
821
  const isLatest = [
@@ -521,13 +824,14 @@ function prepareTools({
521
824
  "gemini-pro-latest"
522
825
  ].some((id) => id === modelId);
523
826
  const isGemini2orNewer = modelId.includes("gemini-2") || modelId.includes("gemini-3") || modelId.includes("nano-banana") || isLatest;
827
+ const isGemini3orNewer = modelId.includes("gemini-3");
524
828
  const supportsFileSearch = modelId.includes("gemini-2.5") || modelId.includes("gemini-3");
525
829
  if (tools == null) {
526
830
  return { tools: void 0, toolConfig: void 0, toolWarnings };
527
831
  }
528
832
  const hasFunctionTools = tools.some((tool) => tool.type === "function");
529
833
  const hasProviderTools = tools.some((tool) => tool.type === "provider");
530
- if (hasFunctionTools && hasProviderTools) {
834
+ if (hasFunctionTools && hasProviderTools && !isGemini3orNewer) {
531
835
  toolWarnings.push({
532
836
  type: "unsupported",
533
837
  feature: `combination of function and provider-defined tools`
@@ -578,7 +882,7 @@ function prepareTools({
578
882
  toolWarnings.push({
579
883
  type: "unsupported",
580
884
  feature: `provider-defined tool ${tool.id}`,
581
- details: "The code execution tools is not supported with other Gemini models than Gemini 2."
885
+ details: "The code execution tool is not supported with other Gemini models than Gemini 2."
582
886
  });
583
887
  }
584
888
  break;
@@ -632,6 +936,47 @@ function prepareTools({
632
936
  break;
633
937
  }
634
938
  });
939
+ if (hasFunctionTools && isGemini3orNewer && googleTools2.length > 0) {
940
+ const functionDeclarations2 = [];
941
+ for (const tool of tools) {
942
+ if (tool.type === "function") {
943
+ functionDeclarations2.push({
944
+ name: tool.name,
945
+ description: (_a = tool.description) != null ? _a : "",
946
+ parameters: convertJSONSchemaToOpenAPISchema(tool.inputSchema)
947
+ });
948
+ }
949
+ }
950
+ const combinedToolConfig = {
951
+ functionCallingConfig: { mode: "VALIDATED" },
952
+ ...!isVertexProvider && {
953
+ includeServerSideToolInvocations: true
954
+ }
955
+ };
956
+ if (toolChoice != null) {
957
+ switch (toolChoice.type) {
958
+ case "auto":
959
+ break;
960
+ case "none":
961
+ combinedToolConfig.functionCallingConfig = { mode: "NONE" };
962
+ break;
963
+ case "required":
964
+ combinedToolConfig.functionCallingConfig = { mode: "ANY" };
965
+ break;
966
+ case "tool":
967
+ combinedToolConfig.functionCallingConfig = {
968
+ mode: "ANY",
969
+ allowedFunctionNames: [toolChoice.toolName]
970
+ };
971
+ break;
972
+ }
973
+ }
974
+ return {
975
+ tools: [...googleTools2, { functionDeclarations: functionDeclarations2 }],
976
+ toolConfig: combinedToolConfig,
977
+ toolWarnings
978
+ };
979
+ }
635
980
  return {
636
981
  tools: googleTools2.length > 0 ? googleTools2 : void 0,
637
982
  toolConfig: void 0,
@@ -645,7 +990,7 @@ function prepareTools({
645
990
  case "function":
646
991
  functionDeclarations.push({
647
992
  name: tool.name,
648
- description: (_a = tool.description) != null ? _a : "",
993
+ description: (_b = tool.description) != null ? _b : "",
649
994
  parameters: convertJSONSchemaToOpenAPISchema(tool.inputSchema)
650
995
  });
651
996
  if (tool.strict === true) {
@@ -708,15 +1053,256 @@ function prepareTools({
708
1053
  };
709
1054
  default: {
710
1055
  const _exhaustiveCheck = type;
711
- throw new import_provider2.UnsupportedFunctionalityError({
1056
+ throw new UnsupportedFunctionalityError2({
712
1057
  functionality: `tool choice type: ${_exhaustiveCheck}`
713
1058
  });
714
1059
  }
715
1060
  }
716
1061
  }
717
1062
 
718
- // src/map-google-generative-ai-finish-reason.ts
719
- function mapGoogleGenerativeAIFinishReason({
1063
+ // src/google-json-accumulator.ts
1064
+ var GoogleJSONAccumulator = class {
1065
+ constructor() {
1066
+ this.accumulatedArgs = {};
1067
+ this.jsonText = "";
1068
+ /**
1069
+ * Stack representing the currently "open" containers in the JSON output.
1070
+ * Entry 0 is always the root `{` object once the first value is written.
1071
+ */
1072
+ this.pathStack = [];
1073
+ /**
1074
+ * Whether a string value is currently "open" (willContinue was true),
1075
+ * meaning the closing quote has not yet been emitted.
1076
+ */
1077
+ this.stringOpen = false;
1078
+ }
1079
+ /**
1080
+ * Input: [{jsonPath:"$.brightness",numberValue:50}]
1081
+ * Output: { currentJSON:{brightness:50}, textDelta:'{"brightness":50' }
1082
+ */
1083
+ processPartialArgs(partialArgs) {
1084
+ let delta = "";
1085
+ for (const arg of partialArgs) {
1086
+ const rawPath = arg.jsonPath.replace(/^\$\./, "");
1087
+ if (!rawPath) continue;
1088
+ const segments = parsePath(rawPath);
1089
+ const existingValue = getNestedValue(this.accumulatedArgs, segments);
1090
+ const isStringContinuation = arg.stringValue != null && existingValue !== void 0;
1091
+ if (isStringContinuation) {
1092
+ const escaped = JSON.stringify(arg.stringValue).slice(1, -1);
1093
+ setNestedValue(
1094
+ this.accumulatedArgs,
1095
+ segments,
1096
+ existingValue + arg.stringValue
1097
+ );
1098
+ delta += escaped;
1099
+ continue;
1100
+ }
1101
+ const resolved = resolvePartialArgValue(arg);
1102
+ if (resolved == null) continue;
1103
+ setNestedValue(this.accumulatedArgs, segments, resolved.value);
1104
+ delta += this.emitNavigationTo(segments, arg, resolved.json);
1105
+ }
1106
+ this.jsonText += delta;
1107
+ return {
1108
+ currentJSON: this.accumulatedArgs,
1109
+ textDelta: delta
1110
+ };
1111
+ }
1112
+ /**
1113
+ * Input: jsonText='{"brightness":50', accumulatedArgs={brightness:50}
1114
+ * Output: { finalJSON:'{"brightness":50}', closingDelta:'}' }
1115
+ */
1116
+ finalize() {
1117
+ const finalArgs = JSON.stringify(this.accumulatedArgs);
1118
+ const closingDelta = finalArgs.slice(this.jsonText.length);
1119
+ return { finalJSON: finalArgs, closingDelta };
1120
+ }
1121
+ /**
1122
+ * Input: pathStack=[] (first call) or pathStack=[root,...] (subsequent calls)
1123
+ * Output: '{' (first call) or '' (subsequent calls)
1124
+ */
1125
+ ensureRoot() {
1126
+ if (this.pathStack.length === 0) {
1127
+ this.pathStack.push({ segment: "", isArray: false, childCount: 0 });
1128
+ return "{";
1129
+ }
1130
+ return "";
1131
+ }
1132
+ /**
1133
+ * Emits the JSON text fragment needed to navigate from the current open
1134
+ * path to the new leaf at `targetSegments`, then writes the value.
1135
+ *
1136
+ * Input: targetSegments=["recipe","name"], arg={jsonPath:"$.recipe.name",stringValue:"Lasagna"}, valueJson='"Lasagna"'
1137
+ * Output: '{"recipe":{"name":"Lasagna"'
1138
+ */
1139
+ emitNavigationTo(targetSegments, arg, valueJson) {
1140
+ let fragment = "";
1141
+ if (this.stringOpen) {
1142
+ fragment += '"';
1143
+ this.stringOpen = false;
1144
+ }
1145
+ fragment += this.ensureRoot();
1146
+ const targetContainerSegments = targetSegments.slice(0, -1);
1147
+ const leafSegment = targetSegments[targetSegments.length - 1];
1148
+ const commonDepth = this.findCommonStackDepth(targetContainerSegments);
1149
+ fragment += this.closeDownTo(commonDepth);
1150
+ fragment += this.openDownTo(targetContainerSegments, leafSegment);
1151
+ fragment += this.emitLeaf(leafSegment, arg, valueJson);
1152
+ return fragment;
1153
+ }
1154
+ /**
1155
+ * Returns the stack depth to preserve when navigating to a new target
1156
+ * container path. Always >= 1 (the root is never popped).
1157
+ *
1158
+ * Input: stack=[root,"recipe","ingredients",0], target=["recipe","ingredients",1]
1159
+ * Output: 3 (keep root+"recipe"+"ingredients")
1160
+ */
1161
+ findCommonStackDepth(targetContainer) {
1162
+ const maxDepth = Math.min(
1163
+ this.pathStack.length - 1,
1164
+ targetContainer.length
1165
+ );
1166
+ let common = 0;
1167
+ for (let i = 0; i < maxDepth; i++) {
1168
+ if (this.pathStack[i + 1].segment === targetContainer[i]) {
1169
+ common++;
1170
+ } else {
1171
+ break;
1172
+ }
1173
+ }
1174
+ return common + 1;
1175
+ }
1176
+ /**
1177
+ * Closes containers from the current stack depth back down to `targetDepth`.
1178
+ *
1179
+ * Input: this.pathStack=[root,"recipe","ingredients",0], targetDepth=3
1180
+ * Output: '}'
1181
+ */
1182
+ closeDownTo(targetDepth) {
1183
+ let fragment = "";
1184
+ while (this.pathStack.length > targetDepth) {
1185
+ const entry = this.pathStack.pop();
1186
+ fragment += entry.isArray ? "]" : "}";
1187
+ }
1188
+ return fragment;
1189
+ }
1190
+ /**
1191
+ * Opens containers from the current stack depth down to the full target
1192
+ * container path, emitting opening `{`, `[`, keys, and commas as needed.
1193
+ * `leafSegment` is used to determine if the innermost container is an array.
1194
+ *
1195
+ * Input: this.pathStack=[root], targetContainer=["recipe","ingredients"], leafSegment=0
1196
+ * Output: '"recipe":{"ingredients":['
1197
+ */
1198
+ openDownTo(targetContainer, leafSegment) {
1199
+ let fragment = "";
1200
+ const startIdx = this.pathStack.length - 1;
1201
+ for (let i = startIdx; i < targetContainer.length; i++) {
1202
+ const pathSegment = targetContainer[i];
1203
+ const parentEntry = this.pathStack[this.pathStack.length - 1];
1204
+ if (parentEntry.childCount > 0) {
1205
+ fragment += ",";
1206
+ }
1207
+ parentEntry.childCount++;
1208
+ if (typeof pathSegment === "string") {
1209
+ fragment += `${JSON.stringify(pathSegment)}:`;
1210
+ }
1211
+ const childSeg = i + 1 < targetContainer.length ? targetContainer[i + 1] : leafSegment;
1212
+ const isArray = typeof childSeg === "number";
1213
+ fragment += isArray ? "[" : "{";
1214
+ this.pathStack.push({ segment: pathSegment, isArray, childCount: 0 });
1215
+ }
1216
+ return fragment;
1217
+ }
1218
+ /**
1219
+ * Emits the comma, key, and value for a leaf entry in the current container.
1220
+ *
1221
+ * Input: leafSegment="name", arg={stringValue:"Lasagna"}, valueJson='"Lasagna"'
1222
+ * Output: '"name":"Lasagna"' (or ',"name":"Lasagna"' if container.childCount > 0)
1223
+ */
1224
+ emitLeaf(leafSegment, arg, valueJson) {
1225
+ let fragment = "";
1226
+ const container = this.pathStack[this.pathStack.length - 1];
1227
+ if (container.childCount > 0) {
1228
+ fragment += ",";
1229
+ }
1230
+ container.childCount++;
1231
+ if (typeof leafSegment === "string") {
1232
+ fragment += `${JSON.stringify(leafSegment)}:`;
1233
+ }
1234
+ if (arg.stringValue != null && arg.willContinue) {
1235
+ fragment += valueJson.slice(0, -1);
1236
+ this.stringOpen = true;
1237
+ } else {
1238
+ fragment += valueJson;
1239
+ }
1240
+ return fragment;
1241
+ }
1242
+ };
1243
+ function parsePath(rawPath) {
1244
+ const segments = [];
1245
+ for (const part of rawPath.split(".")) {
1246
+ const bracketIdx = part.indexOf("[");
1247
+ if (bracketIdx === -1) {
1248
+ segments.push(part);
1249
+ } else {
1250
+ if (bracketIdx > 0) segments.push(part.slice(0, bracketIdx));
1251
+ for (const m of part.matchAll(/\[(\d+)\]/g)) {
1252
+ segments.push(parseInt(m[1], 10));
1253
+ }
1254
+ }
1255
+ }
1256
+ return segments;
1257
+ }
1258
+ var hasOwn = Object.prototype.hasOwnProperty;
1259
+ function hasOwnProperty(obj, key) {
1260
+ return hasOwn.call(obj, key);
1261
+ }
1262
+ function defineOwnProperty(obj, key, value) {
1263
+ Object.defineProperty(obj, key, {
1264
+ value,
1265
+ enumerable: true,
1266
+ configurable: true,
1267
+ writable: true
1268
+ });
1269
+ }
1270
+ function getNestedValue(obj, segments) {
1271
+ let current = obj;
1272
+ for (const pathSegment of segments) {
1273
+ if (current == null || typeof current !== "object") return void 0;
1274
+ const currentRecord = current;
1275
+ if (!hasOwnProperty(currentRecord, pathSegment)) return void 0;
1276
+ current = currentRecord[pathSegment];
1277
+ }
1278
+ return current;
1279
+ }
1280
+ function setNestedValue(obj, segments, value) {
1281
+ let current = obj;
1282
+ for (let i = 0; i < segments.length - 1; i++) {
1283
+ const pathSegment = segments[i];
1284
+ const nextSeg = segments[i + 1];
1285
+ if (!hasOwnProperty(current, pathSegment) || current[pathSegment] == null) {
1286
+ defineOwnProperty(
1287
+ current,
1288
+ pathSegment,
1289
+ typeof nextSeg === "number" ? [] : {}
1290
+ );
1291
+ }
1292
+ current = current[pathSegment];
1293
+ }
1294
+ defineOwnProperty(current, segments[segments.length - 1], value);
1295
+ }
1296
+ function resolvePartialArgValue(arg) {
1297
+ var _a, _b;
1298
+ const value = (_b = (_a = arg.stringValue) != null ? _a : arg.numberValue) != null ? _b : arg.boolValue;
1299
+ if (value != null) return { value, json: JSON.stringify(value) };
1300
+ if ("nullValue" in arg) return { value: null, json: "null" };
1301
+ return void 0;
1302
+ }
1303
+
1304
+ // src/map-google-finish-reason.ts
1305
+ function mapGoogleFinishReason({
720
1306
  finishReason,
721
1307
  hasToolCalls
722
1308
  }) {
@@ -741,14 +1327,23 @@ function mapGoogleGenerativeAIFinishReason({
741
1327
  }
742
1328
  }
743
1329
 
744
- // src/google-generative-ai-language-model.ts
745
- var GoogleGenerativeAILanguageModel = class {
1330
+ // src/google-language-model.ts
1331
+ var GoogleLanguageModel = class _GoogleLanguageModel {
746
1332
  constructor(modelId, config) {
747
- this.specificationVersion = "v3";
1333
+ this.specificationVersion = "v4";
748
1334
  var _a;
749
1335
  this.modelId = modelId;
750
1336
  this.config = config;
751
- this.generateId = (_a = config.generateId) != null ? _a : import_provider_utils4.generateId;
1337
+ this.generateId = (_a = config.generateId) != null ? _a : generateId;
1338
+ }
1339
+ static [WORKFLOW_SERIALIZE](model) {
1340
+ return serializeModelOptions({
1341
+ modelId: model.modelId,
1342
+ config: model.config
1343
+ });
1344
+ }
1345
+ static [WORKFLOW_DESERIALIZE](options) {
1346
+ return new _GoogleLanguageModel(options.modelId, options.config);
752
1347
  }
753
1348
  get provider() {
754
1349
  return this.config.provider;
@@ -770,36 +1365,74 @@ var GoogleGenerativeAILanguageModel = class {
770
1365
  seed,
771
1366
  tools,
772
1367
  toolChoice,
1368
+ reasoning,
773
1369
  providerOptions
774
- }) {
775
- var _a;
1370
+ }, { isStreaming = false } = {}) {
1371
+ var _a, _b;
776
1372
  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)({
1373
+ const providerOptionsNames = this.config.provider.includes("vertex") ? ["googleVertex", "vertex"] : ["google"];
1374
+ let googleOptions;
1375
+ for (const name of providerOptionsNames) {
1376
+ googleOptions = await parseProviderOptions({
1377
+ provider: name,
1378
+ providerOptions,
1379
+ schema: googleLanguageModelOptions
1380
+ });
1381
+ if (googleOptions != null) break;
1382
+ }
1383
+ if (googleOptions == null && !providerOptionsNames.includes("google")) {
1384
+ googleOptions = await parseProviderOptions({
785
1385
  provider: "google",
786
1386
  providerOptions,
787
1387
  schema: googleLanguageModelOptions
788
1388
  });
789
1389
  }
1390
+ const isVertexProvider = this.config.provider.startsWith("google.vertex.");
790
1391
  if ((tools == null ? void 0 : tools.some(
791
1392
  (tool) => tool.type === "provider" && tool.id === "google.vertex_rag_store"
792
- )) && !this.config.provider.startsWith("google.vertex.")) {
1393
+ )) && !isVertexProvider) {
793
1394
  warnings.push({
794
1395
  type: "other",
795
1396
  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
1397
  });
797
1398
  }
1399
+ if ((googleOptions == null ? void 0 : googleOptions.streamFunctionCallArguments) && !isVertexProvider) {
1400
+ warnings.push({
1401
+ type: "other",
1402
+ 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`
1403
+ });
1404
+ }
1405
+ if ((googleOptions == null ? void 0 : googleOptions.serviceTier) && isVertexProvider) {
1406
+ warnings.push({
1407
+ type: "other",
1408
+ message: "'serviceTier' is a Gemini API option and is not supported on Vertex AI. Use 'sharedRequestType' (and optionally 'requestType') instead. See https://docs.cloud.google.com/vertex-ai/generative-ai/docs/priority-paygo"
1409
+ });
1410
+ }
1411
+ if (((googleOptions == null ? void 0 : googleOptions.sharedRequestType) || (googleOptions == null ? void 0 : googleOptions.requestType)) && !isVertexProvider) {
1412
+ warnings.push({
1413
+ type: "other",
1414
+ message: `'sharedRequestType' and 'requestType' are Vertex AI options and are ignored with the current Google provider (${this.config.provider}).`
1415
+ });
1416
+ }
1417
+ const vertexPaygoHeaders = isVertexProvider && ((googleOptions == null ? void 0 : googleOptions.sharedRequestType) || (googleOptions == null ? void 0 : googleOptions.requestType)) ? {
1418
+ ...googleOptions.sharedRequestType && {
1419
+ "X-Vertex-AI-LLM-Shared-Request-Type": googleOptions.sharedRequestType
1420
+ },
1421
+ ...googleOptions.requestType && {
1422
+ "X-Vertex-AI-LLM-Request-Type": googleOptions.requestType
1423
+ }
1424
+ } : void 0;
1425
+ const bodyServiceTier = isVertexProvider ? void 0 : googleOptions == null ? void 0 : googleOptions.serviceTier;
798
1426
  const isGemmaModel = this.modelId.toLowerCase().startsWith("gemma-");
799
- const { contents, systemInstruction } = convertToGoogleGenerativeAIMessages(
800
- prompt,
801
- { isGemmaModel, providerOptionsName }
802
- );
1427
+ const isGemini3Model2 = /^gemini-3[.-]/.test(this.modelId);
1428
+ const supportsFunctionResponseParts = isGemini3Model2;
1429
+ const { contents, systemInstruction } = convertToGoogleMessages(prompt, {
1430
+ isGemmaModel,
1431
+ isGemini3Model: isGemini3Model2,
1432
+ onWarning: (warning) => warnings.push(warning),
1433
+ providerOptionsNames,
1434
+ supportsFunctionResponseParts
1435
+ });
803
1436
  const {
804
1437
  tools: googleTools2,
805
1438
  toolConfig: googleToolConfig,
@@ -807,8 +1440,28 @@ var GoogleGenerativeAILanguageModel = class {
807
1440
  } = prepareTools({
808
1441
  tools,
809
1442
  toolChoice,
810
- modelId: this.modelId
1443
+ modelId: this.modelId,
1444
+ isVertexProvider
811
1445
  });
1446
+ const resolvedThinking = resolveThinkingConfig({
1447
+ reasoning,
1448
+ modelId: this.modelId,
1449
+ warnings
1450
+ });
1451
+ const thinkingConfig = (googleOptions == null ? void 0 : googleOptions.thinkingConfig) || resolvedThinking ? { ...resolvedThinking, ...googleOptions == null ? void 0 : googleOptions.thinkingConfig } : void 0;
1452
+ const streamFunctionCallArguments = isStreaming && isVertexProvider ? (_a = googleOptions == null ? void 0 : googleOptions.streamFunctionCallArguments) != null ? _a : false : void 0;
1453
+ const toolConfig = googleToolConfig || streamFunctionCallArguments || (googleOptions == null ? void 0 : googleOptions.retrievalConfig) ? {
1454
+ ...googleToolConfig,
1455
+ ...streamFunctionCallArguments && {
1456
+ functionCallingConfig: {
1457
+ ...googleToolConfig == null ? void 0 : googleToolConfig.functionCallingConfig,
1458
+ streamFunctionCallArguments: true
1459
+ }
1460
+ },
1461
+ ...(googleOptions == null ? void 0 : googleOptions.retrievalConfig) && {
1462
+ retrievalConfig: googleOptions.retrievalConfig
1463
+ }
1464
+ } : void 0;
812
1465
  return {
813
1466
  args: {
814
1467
  generationConfig: {
@@ -826,13 +1479,13 @@ var GoogleGenerativeAILanguageModel = class {
826
1479
  responseSchema: (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && // Google GenAI does not support all OpenAPI Schema features,
827
1480
  // so this is needed as an escape hatch:
828
1481
  // TODO convert into provider option
829
- ((_a = googleOptions == null ? void 0 : googleOptions.structuredOutputs) != null ? _a : true) ? convertJSONSchemaToOpenAPISchema(responseFormat.schema) : void 0,
1482
+ ((_b = googleOptions == null ? void 0 : googleOptions.structuredOutputs) != null ? _b : true) ? convertJSONSchemaToOpenAPISchema(responseFormat.schema) : void 0,
830
1483
  ...(googleOptions == null ? void 0 : googleOptions.audioTimestamp) && {
831
1484
  audioTimestamp: googleOptions.audioTimestamp
832
1485
  },
833
1486
  // provider options:
834
1487
  responseModalities: googleOptions == null ? void 0 : googleOptions.responseModalities,
835
- thinkingConfig: googleOptions == null ? void 0 : googleOptions.thinkingConfig,
1488
+ thinkingConfig,
836
1489
  ...(googleOptions == null ? void 0 : googleOptions.mediaResolution) && {
837
1490
  mediaResolution: googleOptions.mediaResolution
838
1491
  },
@@ -844,36 +1497,39 @@ var GoogleGenerativeAILanguageModel = class {
844
1497
  systemInstruction: isGemmaModel ? void 0 : systemInstruction,
845
1498
  safetySettings: googleOptions == null ? void 0 : googleOptions.safetySettings,
846
1499
  tools: googleTools2,
847
- toolConfig: (googleOptions == null ? void 0 : googleOptions.retrievalConfig) ? {
848
- ...googleToolConfig,
849
- retrievalConfig: googleOptions.retrievalConfig
850
- } : googleToolConfig,
1500
+ toolConfig,
851
1501
  cachedContent: googleOptions == null ? void 0 : googleOptions.cachedContent,
852
- labels: googleOptions == null ? void 0 : googleOptions.labels
1502
+ labels: googleOptions == null ? void 0 : googleOptions.labels,
1503
+ serviceTier: bodyServiceTier
853
1504
  },
854
1505
  warnings: [...warnings, ...toolWarnings],
855
- providerOptionsName
1506
+ providerOptionsNames,
1507
+ extraHeaders: vertexPaygoHeaders
856
1508
  };
857
1509
  }
858
1510
  async doGenerate(options) {
859
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
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),
863
- options.headers
1511
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
1512
+ const { args, warnings, providerOptionsNames, extraHeaders } = await this.getArgs(options);
1513
+ const wrapProviderMetadata = (payload) => Object.fromEntries(
1514
+ providerOptionsNames.map((name) => [name, payload])
1515
+ );
1516
+ const mergedHeaders = combineHeaders(
1517
+ this.config.headers ? await resolve(this.config.headers) : void 0,
1518
+ options.headers,
1519
+ extraHeaders
864
1520
  );
865
1521
  const {
866
1522
  responseHeaders,
867
1523
  value: response,
868
1524
  rawValue: rawResponse
869
- } = await (0, import_provider_utils4.postJsonToApi)({
1525
+ } = await postJsonToApi({
870
1526
  url: `${this.config.baseURL}/${getModelPath(
871
1527
  this.modelId
872
1528
  )}:generateContent`,
873
1529
  headers: mergedHeaders,
874
1530
  body: args,
875
1531
  failedResponseHandler: googleFailedResponseHandler,
876
- successfulResponseHandler: (0, import_provider_utils4.createJsonResponseHandler)(responseSchema),
1532
+ successfulResponseHandler: createJsonResponseHandler(responseSchema),
877
1533
  abortSignal: options.abortSignal,
878
1534
  fetch: this.config.fetch
879
1535
  });
@@ -882,6 +1538,7 @@ var GoogleGenerativeAILanguageModel = class {
882
1538
  const parts = (_b = (_a = candidate.content) == null ? void 0 : _a.parts) != null ? _b : [];
883
1539
  const usageMetadata = response.usageMetadata;
884
1540
  let lastCodeExecutionToolCallId;
1541
+ let lastServerToolCallId;
885
1542
  for (const part of parts) {
886
1543
  if ("executableCode" in part && ((_c = part.executableCode) == null ? void 0 : _c.code)) {
887
1544
  const toolCallId = this.config.generateId();
@@ -906,11 +1563,9 @@ var GoogleGenerativeAILanguageModel = class {
906
1563
  });
907
1564
  lastCodeExecutionToolCallId = void 0;
908
1565
  } else if ("text" in part && part.text != null) {
909
- const thoughtSignatureMetadata = part.thoughtSignature ? {
910
- [providerOptionsName]: {
911
- thoughtSignature: part.thoughtSignature
912
- }
913
- } : void 0;
1566
+ const thoughtSignatureMetadata = part.thoughtSignature ? wrapProviderMetadata({
1567
+ thoughtSignature: part.thoughtSignature
1568
+ }) : void 0;
914
1569
  if (part.text.length === 0) {
915
1570
  if (thoughtSignatureMetadata != null && content.length > 0) {
916
1571
  const lastContent = content[content.length - 1];
@@ -923,64 +1578,95 @@ var GoogleGenerativeAILanguageModel = class {
923
1578
  providerMetadata: thoughtSignatureMetadata
924
1579
  });
925
1580
  }
926
- } else if ("functionCall" in part) {
1581
+ } else if ("functionCall" in part && part.functionCall.name != null) {
927
1582
  content.push({
928
1583
  type: "tool-call",
929
- toolCallId: this.config.generateId(),
1584
+ toolCallId: (_e = part.functionCall.id) != null ? _e : this.config.generateId(),
930
1585
  toolName: part.functionCall.name,
931
- input: JSON.stringify(part.functionCall.args),
932
- providerMetadata: part.thoughtSignature ? {
933
- [providerOptionsName]: {
934
- thoughtSignature: part.thoughtSignature
935
- }
936
- } : void 0
1586
+ input: JSON.stringify((_f = part.functionCall.args) != null ? _f : {}),
1587
+ providerMetadata: part.thoughtSignature ? wrapProviderMetadata({
1588
+ thoughtSignature: part.thoughtSignature
1589
+ }) : void 0
937
1590
  });
938
1591
  } else if ("inlineData" in part) {
939
1592
  const hasThought = part.thought === true;
940
1593
  const hasThoughtSignature = !!part.thoughtSignature;
941
1594
  content.push({
942
- type: "file",
943
- data: part.inlineData.data,
1595
+ type: hasThought ? "reasoning-file" : "file",
1596
+ data: { type: "data", data: part.inlineData.data },
944
1597
  mediaType: part.inlineData.mimeType,
945
- providerMetadata: hasThought || hasThoughtSignature ? {
946
- [providerOptionsName]: {
947
- ...hasThought ? { thought: true } : {},
948
- ...hasThoughtSignature ? { thoughtSignature: part.thoughtSignature } : {}
949
- }
950
- } : void 0
1598
+ providerMetadata: hasThoughtSignature ? wrapProviderMetadata({
1599
+ thoughtSignature: part.thoughtSignature
1600
+ }) : void 0
1601
+ });
1602
+ } else if ("toolCall" in part && part.toolCall) {
1603
+ const toolCallId = (_g = part.toolCall.id) != null ? _g : this.config.generateId();
1604
+ lastServerToolCallId = toolCallId;
1605
+ content.push({
1606
+ type: "tool-call",
1607
+ toolCallId,
1608
+ toolName: `server:${part.toolCall.toolType}`,
1609
+ input: JSON.stringify((_h = part.toolCall.args) != null ? _h : {}),
1610
+ providerExecuted: true,
1611
+ dynamic: true,
1612
+ providerMetadata: part.thoughtSignature ? wrapProviderMetadata({
1613
+ thoughtSignature: part.thoughtSignature,
1614
+ serverToolCallId: toolCallId,
1615
+ serverToolType: part.toolCall.toolType
1616
+ }) : wrapProviderMetadata({
1617
+ serverToolCallId: toolCallId,
1618
+ serverToolType: part.toolCall.toolType
1619
+ })
1620
+ });
1621
+ } else if ("toolResponse" in part && part.toolResponse) {
1622
+ const responseToolCallId = (_i = lastServerToolCallId != null ? lastServerToolCallId : part.toolResponse.id) != null ? _i : this.config.generateId();
1623
+ content.push({
1624
+ type: "tool-result",
1625
+ toolCallId: responseToolCallId,
1626
+ toolName: `server:${part.toolResponse.toolType}`,
1627
+ result: (_j = part.toolResponse.response) != null ? _j : {},
1628
+ providerMetadata: part.thoughtSignature ? wrapProviderMetadata({
1629
+ thoughtSignature: part.thoughtSignature,
1630
+ serverToolCallId: responseToolCallId,
1631
+ serverToolType: part.toolResponse.toolType
1632
+ }) : wrapProviderMetadata({
1633
+ serverToolCallId: responseToolCallId,
1634
+ serverToolType: part.toolResponse.toolType
1635
+ })
951
1636
  });
1637
+ lastServerToolCallId = void 0;
952
1638
  }
953
1639
  }
954
- const sources = (_e = extractSources({
1640
+ const sources = (_k = extractSources({
955
1641
  groundingMetadata: candidate.groundingMetadata,
956
1642
  generateId: this.config.generateId
957
- })) != null ? _e : [];
1643
+ })) != null ? _k : [];
958
1644
  for (const source of sources) {
959
1645
  content.push(source);
960
1646
  }
961
1647
  return {
962
1648
  content,
963
1649
  finishReason: {
964
- unified: mapGoogleGenerativeAIFinishReason({
1650
+ unified: mapGoogleFinishReason({
965
1651
  finishReason: candidate.finishReason,
966
1652
  // Only count client-executed tool calls for finish reason determination.
967
1653
  hasToolCalls: content.some(
968
1654
  (part) => part.type === "tool-call" && !part.providerExecuted
969
1655
  )
970
1656
  }),
971
- raw: (_f = candidate.finishReason) != null ? _f : void 0
1657
+ raw: (_l = candidate.finishReason) != null ? _l : void 0
972
1658
  },
973
- usage: convertGoogleGenerativeAIUsage(usageMetadata),
1659
+ usage: convertGoogleUsage(usageMetadata),
974
1660
  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
- }
983
- },
1661
+ providerMetadata: wrapProviderMetadata({
1662
+ promptFeedback: (_m = response.promptFeedback) != null ? _m : null,
1663
+ groundingMetadata: (_n = candidate.groundingMetadata) != null ? _n : null,
1664
+ urlContextMetadata: (_o = candidate.urlContextMetadata) != null ? _o : null,
1665
+ safetyRatings: (_p = candidate.safetyRatings) != null ? _p : null,
1666
+ usageMetadata: usageMetadata != null ? usageMetadata : null,
1667
+ finishMessage: (_q = candidate.finishMessage) != null ? _q : null,
1668
+ serviceTier: (_r = usageMetadata == null ? void 0 : usageMetadata.serviceTier) != null ? _r : null
1669
+ }),
984
1670
  request: { body: args },
985
1671
  response: {
986
1672
  // TODO timestamp, model id, id
@@ -990,19 +1676,23 @@ var GoogleGenerativeAILanguageModel = class {
990
1676
  };
991
1677
  }
992
1678
  async doStream(options) {
993
- const { args, warnings, providerOptionsName } = await this.getArgs(options);
994
- const headers = (0, import_provider_utils4.combineHeaders)(
995
- await (0, import_provider_utils4.resolve)(this.config.headers),
996
- options.headers
1679
+ const { args, warnings, providerOptionsNames, extraHeaders } = await this.getArgs(options, { isStreaming: true });
1680
+ const wrapProviderMetadata = (payload) => Object.fromEntries(
1681
+ providerOptionsNames.map((name) => [name, payload])
1682
+ );
1683
+ const headers = combineHeaders(
1684
+ this.config.headers ? await resolve(this.config.headers) : void 0,
1685
+ options.headers,
1686
+ extraHeaders
997
1687
  );
998
- const { responseHeaders, value: response } = await (0, import_provider_utils4.postJsonToApi)({
1688
+ const { responseHeaders, value: response } = await postJsonToApi({
999
1689
  url: `${this.config.baseURL}/${getModelPath(
1000
1690
  this.modelId
1001
1691
  )}:streamGenerateContent?alt=sse`,
1002
1692
  headers,
1003
1693
  body: args,
1004
1694
  failedResponseHandler: googleFailedResponseHandler,
1005
- successfulResponseHandler: (0, import_provider_utils4.createEventSourceResponseHandler)(chunkSchema),
1695
+ successfulResponseHandler: createEventSourceResponseHandler(chunkSchema),
1006
1696
  abortSignal: options.abortSignal,
1007
1697
  fetch: this.config.fetch
1008
1698
  });
@@ -1021,6 +1711,36 @@ var GoogleGenerativeAILanguageModel = class {
1021
1711
  let blockCounter = 0;
1022
1712
  const emittedSourceUrls = /* @__PURE__ */ new Set();
1023
1713
  let lastCodeExecutionToolCallId;
1714
+ let lastServerToolCallId;
1715
+ const activeStreamingToolCalls = [];
1716
+ const finishActiveStreamingToolCall = (controller) => {
1717
+ const active = activeStreamingToolCalls.pop();
1718
+ if (active == null) {
1719
+ return;
1720
+ }
1721
+ const { finalJSON, closingDelta } = active.accumulator.finalize();
1722
+ if (closingDelta.length > 0) {
1723
+ controller.enqueue({
1724
+ type: "tool-input-delta",
1725
+ id: active.toolCallId,
1726
+ delta: closingDelta,
1727
+ providerMetadata: active.providerMetadata
1728
+ });
1729
+ }
1730
+ controller.enqueue({
1731
+ type: "tool-input-end",
1732
+ id: active.toolCallId,
1733
+ providerMetadata: active.providerMetadata
1734
+ });
1735
+ controller.enqueue({
1736
+ type: "tool-call",
1737
+ toolCallId: active.toolCallId,
1738
+ toolName: active.toolName,
1739
+ input: finalJSON,
1740
+ providerMetadata: active.providerMetadata
1741
+ });
1742
+ hasToolCalls = true;
1743
+ };
1024
1744
  return {
1025
1745
  stream: response.pipeThrough(
1026
1746
  new TransformStream({
@@ -1028,7 +1748,7 @@ var GoogleGenerativeAILanguageModel = class {
1028
1748
  controller.enqueue({ type: "stream-start", warnings });
1029
1749
  },
1030
1750
  transform(chunk, controller) {
1031
- var _a, _b, _c, _d, _e, _f;
1751
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
1032
1752
  if (options.includeRawChunks) {
1033
1753
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
1034
1754
  }
@@ -1092,11 +1812,9 @@ var GoogleGenerativeAILanguageModel = class {
1092
1812
  lastCodeExecutionToolCallId = void 0;
1093
1813
  }
1094
1814
  } else if ("text" in part && part.text != null) {
1095
- const thoughtSignatureMetadata = part.thoughtSignature ? {
1096
- [providerOptionsName]: {
1097
- thoughtSignature: part.thoughtSignature
1098
- }
1099
- } : void 0;
1815
+ const thoughtSignatureMetadata = part.thoughtSignature ? wrapProviderMetadata({
1816
+ thoughtSignature: part.thoughtSignature
1817
+ }) : void 0;
1100
1818
  if (part.text.length === 0) {
1101
1819
  if (thoughtSignatureMetadata != null && currentTextBlockId !== null) {
1102
1820
  controller.enqueue({
@@ -1168,50 +1886,156 @@ var GoogleGenerativeAILanguageModel = class {
1168
1886
  }
1169
1887
  const hasThought = part.thought === true;
1170
1888
  const hasThoughtSignature = !!part.thoughtSignature;
1171
- const fileMeta = hasThought || hasThoughtSignature ? {
1172
- [providerOptionsName]: {
1173
- ...hasThought ? { thought: true } : {},
1174
- ...hasThoughtSignature ? { thoughtSignature: part.thoughtSignature } : {}
1175
- }
1176
- } : void 0;
1889
+ const fileMeta = hasThoughtSignature ? wrapProviderMetadata({
1890
+ thoughtSignature: part.thoughtSignature
1891
+ }) : void 0;
1177
1892
  controller.enqueue({
1178
- type: "file",
1893
+ type: hasThought ? "reasoning-file" : "file",
1179
1894
  mediaType: part.inlineData.mimeType,
1180
- data: part.inlineData.data,
1895
+ data: { type: "data", data: part.inlineData.data },
1181
1896
  providerMetadata: fileMeta
1182
1897
  });
1898
+ } else if ("toolCall" in part && part.toolCall) {
1899
+ const toolCallId = (_e = part.toolCall.id) != null ? _e : generateId2();
1900
+ lastServerToolCallId = toolCallId;
1901
+ const serverMeta = wrapProviderMetadata({
1902
+ ...part.thoughtSignature ? { thoughtSignature: part.thoughtSignature } : {},
1903
+ serverToolCallId: toolCallId,
1904
+ serverToolType: part.toolCall.toolType
1905
+ });
1906
+ controller.enqueue({
1907
+ type: "tool-call",
1908
+ toolCallId,
1909
+ toolName: `server:${part.toolCall.toolType}`,
1910
+ input: JSON.stringify((_f = part.toolCall.args) != null ? _f : {}),
1911
+ providerExecuted: true,
1912
+ dynamic: true,
1913
+ providerMetadata: serverMeta
1914
+ });
1915
+ } else if ("toolResponse" in part && part.toolResponse) {
1916
+ const responseToolCallId = (_g = lastServerToolCallId != null ? lastServerToolCallId : part.toolResponse.id) != null ? _g : generateId2();
1917
+ const serverMeta = wrapProviderMetadata({
1918
+ ...part.thoughtSignature ? { thoughtSignature: part.thoughtSignature } : {},
1919
+ serverToolCallId: responseToolCallId,
1920
+ serverToolType: part.toolResponse.toolType
1921
+ });
1922
+ controller.enqueue({
1923
+ type: "tool-result",
1924
+ toolCallId: responseToolCallId,
1925
+ toolName: `server:${part.toolResponse.toolType}`,
1926
+ result: (_h = part.toolResponse.response) != null ? _h : {},
1927
+ providerMetadata: serverMeta
1928
+ });
1929
+ lastServerToolCallId = void 0;
1183
1930
  }
1184
1931
  }
1185
- const toolCallDeltas = getToolCallsFromParts({
1186
- parts: content.parts,
1187
- generateId: generateId2,
1188
- providerOptionsName
1189
- });
1190
- if (toolCallDeltas != null) {
1191
- for (const toolCall of toolCallDeltas) {
1932
+ for (const part of parts) {
1933
+ if (!("functionCall" in part)) continue;
1934
+ const providerMeta = part.thoughtSignature ? wrapProviderMetadata({
1935
+ thoughtSignature: part.thoughtSignature
1936
+ }) : void 0;
1937
+ const isStreamingChunk = part.functionCall.partialArgs != null || part.functionCall.name != null && part.functionCall.willContinue === true;
1938
+ const isTerminalChunk = part.functionCall.name == null && part.functionCall.args == null && part.functionCall.partialArgs == null && part.functionCall.willContinue == null;
1939
+ const isCompleteCall = part.functionCall.name != null && part.functionCall.args != null && part.functionCall.partialArgs == null;
1940
+ const isNoArgsCompleteCall = part.functionCall.name != null && part.functionCall.args == null && part.functionCall.partialArgs == null && part.functionCall.willContinue !== true;
1941
+ if (isStreamingChunk) {
1942
+ if (part.functionCall.name != null) {
1943
+ const toolCallId = (_i = part.functionCall.id) != null ? _i : generateId2();
1944
+ const accumulator = new GoogleJSONAccumulator();
1945
+ activeStreamingToolCalls.push({
1946
+ toolCallId,
1947
+ toolName: part.functionCall.name,
1948
+ accumulator,
1949
+ providerMetadata: providerMeta
1950
+ });
1951
+ controller.enqueue({
1952
+ type: "tool-input-start",
1953
+ id: toolCallId,
1954
+ toolName: part.functionCall.name,
1955
+ providerMetadata: providerMeta
1956
+ });
1957
+ if (part.functionCall.partialArgs != null) {
1958
+ const partialArgs = part.functionCall.partialArgs;
1959
+ const { textDelta } = accumulator.processPartialArgs(partialArgs);
1960
+ if (textDelta.length > 0) {
1961
+ controller.enqueue({
1962
+ type: "tool-input-delta",
1963
+ id: toolCallId,
1964
+ delta: textDelta,
1965
+ providerMetadata: providerMeta
1966
+ });
1967
+ }
1968
+ if (part.functionCall.willContinue !== true && partialArgs.every((arg) => arg.willContinue !== true)) {
1969
+ finishActiveStreamingToolCall(controller);
1970
+ }
1971
+ }
1972
+ } else if (part.functionCall.partialArgs != null && activeStreamingToolCalls.length > 0) {
1973
+ const active = activeStreamingToolCalls[activeStreamingToolCalls.length - 1];
1974
+ const partialArgs = part.functionCall.partialArgs;
1975
+ const { textDelta } = active.accumulator.processPartialArgs(partialArgs);
1976
+ if (textDelta.length > 0) {
1977
+ controller.enqueue({
1978
+ type: "tool-input-delta",
1979
+ id: active.toolCallId,
1980
+ delta: textDelta,
1981
+ providerMetadata: providerMeta
1982
+ });
1983
+ }
1984
+ if (part.functionCall.willContinue !== true && partialArgs.every((arg) => arg.willContinue !== true)) {
1985
+ finishActiveStreamingToolCall(controller);
1986
+ }
1987
+ }
1988
+ } else if (isTerminalChunk && activeStreamingToolCalls.length > 0) {
1989
+ finishActiveStreamingToolCall(controller);
1990
+ } else if (isCompleteCall) {
1991
+ const toolCallId = (_j = part.functionCall.id) != null ? _j : generateId2();
1992
+ const toolName = part.functionCall.name;
1993
+ const args2 = typeof part.functionCall.args === "string" ? part.functionCall.args : JSON.stringify((_k = part.functionCall.args) != null ? _k : {});
1192
1994
  controller.enqueue({
1193
1995
  type: "tool-input-start",
1194
- id: toolCall.toolCallId,
1195
- toolName: toolCall.toolName,
1196
- providerMetadata: toolCall.providerMetadata
1996
+ id: toolCallId,
1997
+ toolName,
1998
+ providerMetadata: providerMeta
1197
1999
  });
1198
2000
  controller.enqueue({
1199
2001
  type: "tool-input-delta",
1200
- id: toolCall.toolCallId,
1201
- delta: toolCall.args,
1202
- providerMetadata: toolCall.providerMetadata
2002
+ id: toolCallId,
2003
+ delta: args2,
2004
+ providerMetadata: providerMeta
1203
2005
  });
1204
2006
  controller.enqueue({
1205
2007
  type: "tool-input-end",
1206
- id: toolCall.toolCallId,
1207
- providerMetadata: toolCall.providerMetadata
2008
+ id: toolCallId,
2009
+ providerMetadata: providerMeta
1208
2010
  });
1209
2011
  controller.enqueue({
1210
2012
  type: "tool-call",
1211
- toolCallId: toolCall.toolCallId,
1212
- toolName: toolCall.toolName,
1213
- input: toolCall.args,
1214
- providerMetadata: toolCall.providerMetadata
2013
+ toolCallId,
2014
+ toolName,
2015
+ input: args2,
2016
+ providerMetadata: providerMeta
2017
+ });
2018
+ hasToolCalls = true;
2019
+ } else if (isNoArgsCompleteCall) {
2020
+ const toolCallId = (_l = part.functionCall.id) != null ? _l : generateId2();
2021
+ const toolName = part.functionCall.name;
2022
+ controller.enqueue({
2023
+ type: "tool-input-start",
2024
+ id: toolCallId,
2025
+ toolName,
2026
+ providerMetadata: providerMeta
2027
+ });
2028
+ controller.enqueue({
2029
+ type: "tool-input-end",
2030
+ id: toolCallId,
2031
+ providerMetadata: providerMeta
2032
+ });
2033
+ controller.enqueue({
2034
+ type: "tool-call",
2035
+ toolCallId,
2036
+ toolName,
2037
+ input: "{}",
2038
+ providerMetadata: providerMeta
1215
2039
  });
1216
2040
  hasToolCalls = true;
1217
2041
  }
@@ -1219,23 +2043,21 @@ var GoogleGenerativeAILanguageModel = class {
1219
2043
  }
1220
2044
  if (candidate.finishReason != null) {
1221
2045
  finishReason = {
1222
- unified: mapGoogleGenerativeAIFinishReason({
2046
+ unified: mapGoogleFinishReason({
1223
2047
  finishReason: candidate.finishReason,
1224
2048
  hasToolCalls
1225
2049
  }),
1226
2050
  raw: candidate.finishReason
1227
2051
  };
1228
- providerMetadata = {
1229
- [providerOptionsName]: {
1230
- promptFeedback: (_e = value.promptFeedback) != null ? _e : null,
1231
- groundingMetadata: lastGroundingMetadata,
1232
- urlContextMetadata: lastUrlContextMetadata,
1233
- safetyRatings: (_f = candidate.safetyRatings) != null ? _f : null
1234
- }
1235
- };
1236
- if (usageMetadata != null) {
1237
- providerMetadata[providerOptionsName].usageMetadata = usageMetadata;
1238
- }
2052
+ providerMetadata = wrapProviderMetadata({
2053
+ promptFeedback: (_m = value.promptFeedback) != null ? _m : null,
2054
+ groundingMetadata: lastGroundingMetadata,
2055
+ urlContextMetadata: lastUrlContextMetadata,
2056
+ safetyRatings: (_n = candidate.safetyRatings) != null ? _n : null,
2057
+ usageMetadata: usageMetadata != null ? usageMetadata : null,
2058
+ finishMessage: (_o = candidate.finishMessage) != null ? _o : null,
2059
+ serviceTier: (_p = usage == null ? void 0 : usage.serviceTier) != null ? _p : null
2060
+ });
1239
2061
  }
1240
2062
  },
1241
2063
  flush(controller) {
@@ -1254,7 +2076,7 @@ var GoogleGenerativeAILanguageModel = class {
1254
2076
  controller.enqueue({
1255
2077
  type: "finish",
1256
2078
  finishReason,
1257
- usage: convertGoogleGenerativeAIUsage(usage),
2079
+ usage: convertGoogleUsage(usage),
1258
2080
  providerMetadata
1259
2081
  });
1260
2082
  }
@@ -1265,25 +2087,74 @@ var GoogleGenerativeAILanguageModel = class {
1265
2087
  };
1266
2088
  }
1267
2089
  };
1268
- function getToolCallsFromParts({
1269
- parts,
1270
- generateId: generateId2,
1271
- providerOptionsName
2090
+ function isGemini3Model(modelId) {
2091
+ return /gemini-3[\.\-]/i.test(modelId) || /gemini-3$/i.test(modelId);
2092
+ }
2093
+ function getMaxOutputTokensForGemini25Model() {
2094
+ return 65536;
2095
+ }
2096
+ function getMaxThinkingTokensForGemini25Model(modelId) {
2097
+ const id = modelId.toLowerCase();
2098
+ if (id.includes("2.5-pro") || id.includes("gemini-3-pro-image")) {
2099
+ return 32768;
2100
+ }
2101
+ return 24576;
2102
+ }
2103
+ function resolveThinkingConfig({
2104
+ reasoning,
2105
+ modelId,
2106
+ warnings
1272
2107
  }) {
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
- }));
2108
+ if (!isCustomReasoning(reasoning)) {
2109
+ return void 0;
2110
+ }
2111
+ if (isGemini3Model(modelId) && !modelId.includes("gemini-3-pro-image")) {
2112
+ return resolveGemini3ThinkingConfig({ reasoning, warnings });
2113
+ }
2114
+ return resolveGemini25ThinkingConfig({ reasoning, modelId, warnings });
2115
+ }
2116
+ function resolveGemini3ThinkingConfig({
2117
+ reasoning,
2118
+ warnings
2119
+ }) {
2120
+ if (reasoning === "none") {
2121
+ return { thinkingLevel: "minimal" };
2122
+ }
2123
+ const thinkingLevel = mapReasoningToProviderEffort({
2124
+ reasoning,
2125
+ effortMap: {
2126
+ minimal: "minimal",
2127
+ low: "low",
2128
+ medium: "medium",
2129
+ high: "high",
2130
+ xhigh: "high"
2131
+ },
2132
+ warnings
2133
+ });
2134
+ if (thinkingLevel == null) {
2135
+ return void 0;
2136
+ }
2137
+ return { thinkingLevel };
2138
+ }
2139
+ function resolveGemini25ThinkingConfig({
2140
+ reasoning,
2141
+ modelId,
2142
+ warnings
2143
+ }) {
2144
+ if (reasoning === "none") {
2145
+ return { thinkingBudget: 0 };
2146
+ }
2147
+ const thinkingBudget = mapReasoningToProviderBudget({
2148
+ reasoning,
2149
+ maxOutputTokens: getMaxOutputTokensForGemini25Model(),
2150
+ maxReasoningBudget: getMaxThinkingTokensForGemini25Model(modelId),
2151
+ minReasoningBudget: 0,
2152
+ warnings
2153
+ });
2154
+ if (thinkingBudget == null) {
2155
+ return void 0;
2156
+ }
2157
+ return { thinkingBudget };
1287
2158
  }
1288
2159
  function extractSources({
1289
2160
  groundingMetadata,
@@ -1379,254 +2250,585 @@ function extractSources({
1379
2250
  }
1380
2251
  return sources.length > 0 ? sources : void 0;
1381
2252
  }
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()
2253
+ var getGroundingMetadataSchema = () => z3.object({
2254
+ webSearchQueries: z3.array(z3.string()).nullish(),
2255
+ imageSearchQueries: z3.array(z3.string()).nullish(),
2256
+ retrievalQueries: z3.array(z3.string()).nullish(),
2257
+ searchEntryPoint: z3.object({ renderedContent: z3.string() }).nullish(),
2258
+ groundingChunks: z3.array(
2259
+ z3.object({
2260
+ web: z3.object({ uri: z3.string(), title: z3.string().nullish() }).nullish(),
2261
+ image: z3.object({
2262
+ sourceUri: z3.string(),
2263
+ imageUri: z3.string(),
2264
+ title: z3.string().nullish(),
2265
+ domain: z3.string().nullish()
1395
2266
  }).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()
2267
+ retrievedContext: z3.object({
2268
+ uri: z3.string().nullish(),
2269
+ title: z3.string().nullish(),
2270
+ text: z3.string().nullish(),
2271
+ fileSearchStore: z3.string().nullish()
1401
2272
  }).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()
2273
+ maps: z3.object({
2274
+ uri: z3.string().nullish(),
2275
+ title: z3.string().nullish(),
2276
+ text: z3.string().nullish(),
2277
+ placeId: z3.string().nullish()
1407
2278
  }).nullish()
1408
2279
  })
1409
2280
  ).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()
2281
+ groundingSupports: z3.array(
2282
+ z3.object({
2283
+ segment: z3.object({
2284
+ startIndex: z3.number().nullish(),
2285
+ endIndex: z3.number().nullish(),
2286
+ text: z3.string().nullish()
1416
2287
  }).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()
2288
+ segment_text: z3.string().nullish(),
2289
+ groundingChunkIndices: z3.array(z3.number()).nullish(),
2290
+ supportChunkIndices: z3.array(z3.number()).nullish(),
2291
+ confidenceScores: z3.array(z3.number()).nullish(),
2292
+ confidenceScore: z3.array(z3.number()).nullish()
1422
2293
  })
1423
2294
  ).nullish(),
1424
- retrievalMetadata: import_v43.z.union([
1425
- import_v43.z.object({
1426
- webDynamicRetrievalScore: import_v43.z.number()
2295
+ retrievalMetadata: z3.union([
2296
+ z3.object({
2297
+ webDynamicRetrievalScore: z3.number()
1427
2298
  }),
1428
- import_v43.z.object({})
2299
+ z3.object({})
1429
2300
  ]).nullish()
1430
2301
  });
1431
- var getContentSchema = () => import_v43.z.object({
1432
- parts: import_v43.z.array(
1433
- import_v43.z.union([
2302
+ var partialArgSchema = z3.object({
2303
+ jsonPath: z3.string(),
2304
+ stringValue: z3.string().nullish(),
2305
+ numberValue: z3.number().nullish(),
2306
+ boolValue: z3.boolean().nullish(),
2307
+ nullValue: z3.unknown().nullish(),
2308
+ willContinue: z3.boolean().nullish()
2309
+ });
2310
+ var getContentSchema = () => z3.object({
2311
+ parts: z3.array(
2312
+ z3.union([
1434
2313
  // 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()
2314
+ z3.object({
2315
+ functionCall: z3.object({
2316
+ id: z3.string().nullish(),
2317
+ name: z3.string().nullish(),
2318
+ args: z3.unknown().nullish(),
2319
+ partialArgs: z3.array(partialArgSchema).nullish(),
2320
+ willContinue: z3.boolean().nullish()
1439
2321
  }),
1440
- thoughtSignature: import_v43.z.string().nullish()
2322
+ thoughtSignature: z3.string().nullish()
1441
2323
  }),
1442
- import_v43.z.object({
1443
- inlineData: import_v43.z.object({
1444
- mimeType: import_v43.z.string(),
1445
- data: import_v43.z.string()
2324
+ z3.object({
2325
+ inlineData: z3.object({
2326
+ mimeType: z3.string(),
2327
+ data: z3.string()
1446
2328
  }),
1447
- thought: import_v43.z.boolean().nullish(),
1448
- thoughtSignature: import_v43.z.string().nullish()
2329
+ thought: z3.boolean().nullish(),
2330
+ thoughtSignature: z3.string().nullish()
1449
2331
  }),
1450
- import_v43.z.object({
1451
- executableCode: import_v43.z.object({
1452
- language: import_v43.z.string(),
1453
- code: import_v43.z.string()
2332
+ z3.object({
2333
+ toolCall: z3.object({
2334
+ toolType: z3.string(),
2335
+ args: z3.unknown().nullish(),
2336
+ id: z3.string()
2337
+ }),
2338
+ thoughtSignature: z3.string().nullish()
2339
+ }),
2340
+ z3.object({
2341
+ toolResponse: z3.object({
2342
+ toolType: z3.string(),
2343
+ response: z3.unknown().nullish(),
2344
+ id: z3.string()
2345
+ }),
2346
+ thoughtSignature: z3.string().nullish()
2347
+ }),
2348
+ z3.object({
2349
+ executableCode: z3.object({
2350
+ language: z3.string(),
2351
+ code: z3.string()
1454
2352
  }).nullish(),
1455
- codeExecutionResult: import_v43.z.object({
1456
- outcome: import_v43.z.string(),
1457
- output: import_v43.z.string().nullish()
2353
+ codeExecutionResult: z3.object({
2354
+ outcome: z3.string(),
2355
+ output: z3.string().nullish()
1458
2356
  }).nullish(),
1459
- text: import_v43.z.string().nullish(),
1460
- thought: import_v43.z.boolean().nullish(),
1461
- thoughtSignature: import_v43.z.string().nullish()
2357
+ text: z3.string().nullish(),
2358
+ thought: z3.boolean().nullish(),
2359
+ thoughtSignature: z3.string().nullish()
1462
2360
  })
1463
2361
  ])
1464
2362
  ).nullish()
1465
2363
  });
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()
2364
+ var getSafetyRatingSchema = () => z3.object({
2365
+ category: z3.string().nullish(),
2366
+ probability: z3.string().nullish(),
2367
+ probabilityScore: z3.number().nullish(),
2368
+ severity: z3.string().nullish(),
2369
+ severityScore: z3.number().nullish(),
2370
+ blocked: z3.boolean().nullish()
1473
2371
  });
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(),
2372
+ var tokenDetailsSchema = z3.array(
2373
+ z3.object({
2374
+ modality: z3.string(),
2375
+ tokenCount: z3.number()
2376
+ })
2377
+ ).nullish();
2378
+ var usageSchema = z3.object({
2379
+ cachedContentTokenCount: z3.number().nullish(),
2380
+ thoughtsTokenCount: z3.number().nullish(),
2381
+ promptTokenCount: z3.number().nullish(),
2382
+ candidatesTokenCount: z3.number().nullish(),
2383
+ totalTokenCount: z3.number().nullish(),
1480
2384
  // https://cloud.google.com/vertex-ai/generative-ai/docs/reference/rest/v1/GenerateContentResponse#TrafficType
1481
- trafficType: import_v43.z.string().nullish()
2385
+ trafficType: z3.string().nullish(),
2386
+ serviceTier: z3.string().nullish(),
2387
+ // https://ai.google.dev/api/generate-content#Modality
2388
+ promptTokensDetails: tokenDetailsSchema,
2389
+ candidatesTokensDetails: tokenDetailsSchema
1482
2390
  });
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()
2391
+ var getUrlContextMetadataSchema = () => z3.object({
2392
+ urlMetadata: z3.array(
2393
+ z3.object({
2394
+ retrievedUrl: z3.string(),
2395
+ urlRetrievalStatus: z3.string()
1488
2396
  })
1489
2397
  ).nullish()
1490
2398
  });
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
- safetyRatings: import_v43.z.array(getSafetyRatingSchema()).nullish(),
2399
+ var responseSchema = lazySchema3(
2400
+ () => zodSchema3(
2401
+ z3.object({
2402
+ candidates: z3.array(
2403
+ z3.object({
2404
+ content: getContentSchema().nullish().or(z3.object({}).strict()),
2405
+ finishReason: z3.string().nullish(),
2406
+ finishMessage: z3.string().nullish(),
2407
+ safetyRatings: z3.array(getSafetyRatingSchema()).nullish(),
1499
2408
  groundingMetadata: getGroundingMetadataSchema().nullish(),
1500
2409
  urlContextMetadata: getUrlContextMetadataSchema().nullish()
1501
2410
  })
1502
2411
  ),
1503
2412
  usageMetadata: usageSchema.nullish(),
1504
- promptFeedback: import_v43.z.object({
1505
- blockReason: import_v43.z.string().nullish(),
1506
- safetyRatings: import_v43.z.array(getSafetyRatingSchema()).nullish()
2413
+ promptFeedback: z3.object({
2414
+ blockReason: z3.string().nullish(),
2415
+ safetyRatings: z3.array(getSafetyRatingSchema()).nullish()
1507
2416
  }).nullish()
1508
2417
  })
1509
2418
  )
1510
2419
  );
1511
- var chunkSchema = (0, import_provider_utils4.lazySchema)(
1512
- () => (0, import_provider_utils4.zodSchema)(
1513
- import_v43.z.object({
1514
- candidates: import_v43.z.array(
1515
- import_v43.z.object({
2420
+ var chunkSchema = lazySchema3(
2421
+ () => zodSchema3(
2422
+ z3.object({
2423
+ candidates: z3.array(
2424
+ z3.object({
1516
2425
  content: getContentSchema().nullish(),
1517
- finishReason: import_v43.z.string().nullish(),
1518
- safetyRatings: import_v43.z.array(getSafetyRatingSchema()).nullish(),
2426
+ finishReason: z3.string().nullish(),
2427
+ finishMessage: z3.string().nullish(),
2428
+ safetyRatings: z3.array(getSafetyRatingSchema()).nullish(),
1519
2429
  groundingMetadata: getGroundingMetadataSchema().nullish(),
1520
2430
  urlContextMetadata: getUrlContextMetadataSchema().nullish()
1521
2431
  })
1522
2432
  ).nullish(),
1523
2433
  usageMetadata: usageSchema.nullish(),
1524
- promptFeedback: import_v43.z.object({
1525
- blockReason: import_v43.z.string().nullish(),
1526
- safetyRatings: import_v43.z.array(getSafetyRatingSchema()).nullish()
2434
+ promptFeedback: z3.object({
2435
+ blockReason: z3.string().nullish(),
2436
+ safetyRatings: z3.array(getSafetyRatingSchema()).nullish()
1527
2437
  }).nullish()
1528
2438
  })
1529
2439
  )
1530
2440
  );
1531
2441
 
2442
+ // src/google-speech-model.ts
2443
+ import {
2444
+ combineHeaders as combineHeaders2,
2445
+ convertBase64ToUint8Array,
2446
+ createJsonResponseHandler as createJsonResponseHandler2,
2447
+ parseProviderOptions as parseProviderOptions2,
2448
+ postJsonToApi as postJsonToApi2,
2449
+ resolve as resolve2,
2450
+ serializeModelOptions as serializeModelOptions2,
2451
+ WORKFLOW_DESERIALIZE as WORKFLOW_DESERIALIZE2,
2452
+ WORKFLOW_SERIALIZE as WORKFLOW_SERIALIZE2
2453
+ } from "@ai-sdk/provider-utils";
2454
+
2455
+ // src/google-speech-api.ts
2456
+ import { lazySchema as lazySchema4, zodSchema as zodSchema4 } from "@ai-sdk/provider-utils";
2457
+ import { z as z4 } from "zod/v4";
2458
+ var googleSpeechResponseSchema = lazySchema4(
2459
+ () => zodSchema4(
2460
+ z4.object({
2461
+ candidates: z4.array(
2462
+ z4.object({
2463
+ content: z4.object({
2464
+ parts: z4.array(
2465
+ z4.object({
2466
+ inlineData: z4.object({
2467
+ mimeType: z4.string().nullish(),
2468
+ data: z4.string().nullish()
2469
+ }).nullish()
2470
+ })
2471
+ ).nullish()
2472
+ }).nullish()
2473
+ })
2474
+ ).nullish()
2475
+ })
2476
+ )
2477
+ );
2478
+
2479
+ // src/google-speech-model-options.ts
2480
+ import {
2481
+ lazySchema as lazySchema5,
2482
+ zodSchema as zodSchema5
2483
+ } from "@ai-sdk/provider-utils";
2484
+ import { z as z5 } from "zod/v4";
2485
+ var prebuiltVoiceConfigSchema = z5.object({
2486
+ voiceName: z5.string()
2487
+ });
2488
+ var voiceConfigSchema = z5.object({
2489
+ prebuiltVoiceConfig: prebuiltVoiceConfigSchema
2490
+ });
2491
+ var googleSpeechProviderOptionsSchema = lazySchema5(
2492
+ () => zodSchema5(
2493
+ z5.object({
2494
+ /**
2495
+ * Multi-speaker configuration for dialogue audio. When provided, this
2496
+ * overrides the top-level `voice`. The Gemini TTS API supports up to two
2497
+ * speakers; each speaker name must match a name used in the input text.
2498
+ *
2499
+ * https://ai.google.dev/gemini-api/docs/speech-generation#multi-speaker
2500
+ */
2501
+ multiSpeakerVoiceConfig: z5.object({
2502
+ speakerVoiceConfigs: z5.array(
2503
+ z5.object({
2504
+ speaker: z5.string(),
2505
+ voiceConfig: voiceConfigSchema
2506
+ })
2507
+ )
2508
+ }).optional()
2509
+ })
2510
+ )
2511
+ );
2512
+
2513
+ // src/google-speech-model.ts
2514
+ var DEFAULT_VOICE = "Kore";
2515
+ var DEFAULT_SAMPLE_RATE = 24e3;
2516
+ var GoogleSpeechModel = class _GoogleSpeechModel {
2517
+ constructor(modelId, config) {
2518
+ this.modelId = modelId;
2519
+ this.config = config;
2520
+ this.specificationVersion = "v4";
2521
+ }
2522
+ static [WORKFLOW_SERIALIZE2](model) {
2523
+ return serializeModelOptions2({
2524
+ modelId: model.modelId,
2525
+ config: model.config
2526
+ });
2527
+ }
2528
+ static [WORKFLOW_DESERIALIZE2](options) {
2529
+ return new _GoogleSpeechModel(options.modelId, options.config);
2530
+ }
2531
+ get provider() {
2532
+ return this.config.provider;
2533
+ }
2534
+ async getArgs({
2535
+ text,
2536
+ voice = DEFAULT_VOICE,
2537
+ outputFormat,
2538
+ instructions,
2539
+ speed,
2540
+ language,
2541
+ providerOptions
2542
+ }) {
2543
+ const warnings = [];
2544
+ const providerOptionsNames = this.config.provider.includes("vertex") ? ["googleVertex", "vertex"] : ["google"];
2545
+ let googleOptions;
2546
+ for (const name of providerOptionsNames) {
2547
+ googleOptions = await parseProviderOptions2({
2548
+ provider: name,
2549
+ providerOptions,
2550
+ schema: googleSpeechProviderOptionsSchema
2551
+ });
2552
+ if (googleOptions != null) {
2553
+ break;
2554
+ }
2555
+ }
2556
+ if (googleOptions == null && !providerOptionsNames.includes("google")) {
2557
+ googleOptions = await parseProviderOptions2({
2558
+ provider: "google",
2559
+ providerOptions,
2560
+ schema: googleSpeechProviderOptionsSchema
2561
+ });
2562
+ }
2563
+ const multiSpeakerVoiceConfig = googleOptions == null ? void 0 : googleOptions.multiSpeakerVoiceConfig;
2564
+ const speechConfig = multiSpeakerVoiceConfig ? { multiSpeakerVoiceConfig } : { voiceConfig: { prebuiltVoiceConfig: { voiceName: voice } } };
2565
+ let promptText = text;
2566
+ if (instructions != null) {
2567
+ if (multiSpeakerVoiceConfig) {
2568
+ warnings.push({
2569
+ type: "unsupported",
2570
+ feature: "instructions",
2571
+ details: "Google Gemini TTS ignores `instructions` when `multiSpeakerVoiceConfig` is set, because prepending them would break multi-speaker transcript parsing."
2572
+ });
2573
+ } else {
2574
+ promptText = `${instructions}: ${text}`;
2575
+ }
2576
+ }
2577
+ if (speed != null) {
2578
+ warnings.push({
2579
+ type: "unsupported",
2580
+ feature: "speed",
2581
+ details: "Google Gemini TTS models do not support the `speed` option. It was ignored."
2582
+ });
2583
+ }
2584
+ if (language != null) {
2585
+ warnings.push({
2586
+ type: "unsupported",
2587
+ feature: "language",
2588
+ details: "Google Gemini TTS models do not support the `language` option. Language is detected automatically from the input text."
2589
+ });
2590
+ }
2591
+ let resolvedOutputFormat = "wav";
2592
+ if (outputFormat === "pcm") {
2593
+ resolvedOutputFormat = "pcm";
2594
+ } else if (outputFormat != null && outputFormat !== "wav") {
2595
+ warnings.push({
2596
+ type: "unsupported",
2597
+ feature: "outputFormat",
2598
+ details: `Unsupported output format: ${outputFormat}. Using wav instead.`
2599
+ });
2600
+ }
2601
+ const requestBody = {
2602
+ contents: [{ role: "user", parts: [{ text: promptText }] }],
2603
+ generationConfig: {
2604
+ responseModalities: ["AUDIO"],
2605
+ speechConfig
2606
+ }
2607
+ };
2608
+ return { requestBody, warnings, outputFormat: resolvedOutputFormat };
2609
+ }
2610
+ async doGenerate(options) {
2611
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
2612
+ const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
2613
+ const { requestBody, warnings, outputFormat } = await this.getArgs(options);
2614
+ const {
2615
+ value: response,
2616
+ responseHeaders,
2617
+ rawValue: rawResponse
2618
+ } = await postJsonToApi2({
2619
+ url: `${this.config.baseURL}/models/${this.modelId}:generateContent`,
2620
+ headers: combineHeaders2(
2621
+ this.config.headers ? await resolve2(this.config.headers) : void 0,
2622
+ options.headers
2623
+ ),
2624
+ body: requestBody,
2625
+ failedResponseHandler: googleFailedResponseHandler,
2626
+ successfulResponseHandler: createJsonResponseHandler2(
2627
+ googleSpeechResponseSchema
2628
+ ),
2629
+ abortSignal: options.abortSignal,
2630
+ fetch: this.config.fetch
2631
+ });
2632
+ let base64Audio;
2633
+ let mimeType;
2634
+ for (const candidate of (_d = response.candidates) != null ? _d : []) {
2635
+ for (const part of (_f = (_e = candidate.content) == null ? void 0 : _e.parts) != null ? _f : []) {
2636
+ if ((_g = part.inlineData) == null ? void 0 : _g.data) {
2637
+ base64Audio = part.inlineData.data;
2638
+ mimeType = (_h = part.inlineData.mimeType) != null ? _h : void 0;
2639
+ break;
2640
+ }
2641
+ }
2642
+ if (base64Audio != null) {
2643
+ break;
2644
+ }
2645
+ }
2646
+ const sampleRate = (_i = parseSampleRate(mimeType)) != null ? _i : DEFAULT_SAMPLE_RATE;
2647
+ const pcm = base64Audio != null ? convertBase64ToUint8Array(base64Audio) : new Uint8Array(0);
2648
+ const audio = outputFormat === "pcm" || pcm.length === 0 ? pcm : addWavHeader(pcm, sampleRate);
2649
+ if (outputFormat === "pcm" && pcm.length > 0) {
2650
+ warnings.push({
2651
+ type: "unsupported",
2652
+ feature: "outputFormat",
2653
+ details: `Returning raw PCM audio (signed 16-bit little-endian, mono, ${sampleRate} Hz). These bytes have no container header and are not directly playable; see providerMetadata.google for the sample rate and mime type.`
2654
+ });
2655
+ }
2656
+ return {
2657
+ audio,
2658
+ warnings,
2659
+ request: {
2660
+ body: JSON.stringify(requestBody)
2661
+ },
2662
+ response: {
2663
+ timestamp: currentDate,
2664
+ modelId: this.modelId,
2665
+ headers: responseHeaders,
2666
+ body: rawResponse
2667
+ },
2668
+ providerMetadata: {
2669
+ google: {
2670
+ sampleRate,
2671
+ mimeType: mimeType != null ? mimeType : null
2672
+ }
2673
+ }
2674
+ };
2675
+ }
2676
+ };
2677
+ function parseSampleRate(mimeType) {
2678
+ if (mimeType == null) {
2679
+ return void 0;
2680
+ }
2681
+ const match = /rate=(\d+)/.exec(mimeType);
2682
+ return match ? Number.parseInt(match[1], 10) : void 0;
2683
+ }
2684
+ function addWavHeader(pcm, sampleRate) {
2685
+ const numChannels = 1;
2686
+ const bitsPerSample = 16;
2687
+ const blockAlign = numChannels * bitsPerSample / 8;
2688
+ const byteRate = sampleRate * blockAlign;
2689
+ const dataSize = pcm.length;
2690
+ const buffer = new ArrayBuffer(44 + dataSize);
2691
+ const view = new DataView(buffer);
2692
+ writeAscii(view, 0, "RIFF");
2693
+ view.setUint32(4, 36 + dataSize, true);
2694
+ writeAscii(view, 8, "WAVE");
2695
+ writeAscii(view, 12, "fmt ");
2696
+ view.setUint32(16, 16, true);
2697
+ view.setUint16(20, 1, true);
2698
+ view.setUint16(22, numChannels, true);
2699
+ view.setUint32(24, sampleRate, true);
2700
+ view.setUint32(28, byteRate, true);
2701
+ view.setUint16(32, blockAlign, true);
2702
+ view.setUint16(34, bitsPerSample, true);
2703
+ writeAscii(view, 36, "data");
2704
+ view.setUint32(40, dataSize, true);
2705
+ const out = new Uint8Array(buffer);
2706
+ out.set(pcm, 44);
2707
+ return out;
2708
+ }
2709
+ function writeAscii(view, offset, text) {
2710
+ for (let i = 0; i < text.length; i++) {
2711
+ view.setUint8(offset + i, text.charCodeAt(i));
2712
+ }
2713
+ }
2714
+
1532
2715
  // src/tool/code-execution.ts
1533
- var import_provider_utils5 = require("@ai-sdk/provider-utils");
1534
- var import_v44 = require("zod/v4");
1535
- var codeExecution = (0, import_provider_utils5.createProviderToolFactoryWithOutputSchema)({
2716
+ import { createProviderExecutedToolFactory } from "@ai-sdk/provider-utils";
2717
+ import { z as z6 } from "zod/v4";
2718
+ var codeExecution = createProviderExecutedToolFactory({
1536
2719
  id: "google.code_execution",
1537
- inputSchema: import_v44.z.object({
1538
- language: import_v44.z.string().describe("The programming language of the code."),
1539
- code: import_v44.z.string().describe("The code to be executed.")
2720
+ inputSchema: z6.object({
2721
+ language: z6.string().describe("The programming language of the code."),
2722
+ code: z6.string().describe("The code to be executed.")
1540
2723
  }),
1541
- outputSchema: import_v44.z.object({
1542
- outcome: import_v44.z.string().describe('The outcome of the execution (e.g., "OUTCOME_OK").'),
1543
- output: import_v44.z.string().describe("The output from the code execution.")
2724
+ outputSchema: z6.object({
2725
+ outcome: z6.string().describe('The outcome of the execution (e.g., "OUTCOME_OK").'),
2726
+ output: z6.string().describe("The output from the code execution.")
1544
2727
  })
1545
2728
  });
1546
2729
 
1547
2730
  // src/tool/enterprise-web-search.ts
1548
- var import_provider_utils6 = require("@ai-sdk/provider-utils");
1549
- var import_v45 = require("zod/v4");
1550
- var enterpriseWebSearch = (0, import_provider_utils6.createProviderToolFactory)({
2731
+ import {
2732
+ createProviderExecutedToolFactory as createProviderExecutedToolFactory2,
2733
+ lazySchema as lazySchema6,
2734
+ zodSchema as zodSchema6
2735
+ } from "@ai-sdk/provider-utils";
2736
+ import { z as z7 } from "zod/v4";
2737
+ var enterpriseWebSearch = createProviderExecutedToolFactory2({
1551
2738
  id: "google.enterprise_web_search",
1552
- inputSchema: (0, import_provider_utils6.lazySchema)(() => (0, import_provider_utils6.zodSchema)(import_v45.z.object({})))
2739
+ inputSchema: lazySchema6(() => zodSchema6(z7.object({}))),
2740
+ outputSchema: lazySchema6(() => zodSchema6(z7.object({})))
1553
2741
  });
1554
2742
 
1555
2743
  // src/tool/file-search.ts
1556
- var import_provider_utils7 = require("@ai-sdk/provider-utils");
1557
- var import_v46 = require("zod/v4");
1558
- var fileSearchArgsBaseSchema = import_v46.z.object({
2744
+ import {
2745
+ createProviderExecutedToolFactory as createProviderExecutedToolFactory3,
2746
+ lazySchema as lazySchema7,
2747
+ zodSchema as zodSchema7
2748
+ } from "@ai-sdk/provider-utils";
2749
+ import { z as z8 } from "zod/v4";
2750
+ var fileSearchArgsBaseSchema = z8.object({
1559
2751
  /** The names of the file_search_stores to retrieve from.
1560
2752
  * Example: `fileSearchStores/my-file-search-store-123`
1561
2753
  */
1562
- fileSearchStoreNames: import_v46.z.array(import_v46.z.string()).describe(
2754
+ fileSearchStoreNames: z8.array(z8.string()).describe(
1563
2755
  "The names of the file_search_stores to retrieve from. Example: `fileSearchStores/my-file-search-store-123`"
1564
2756
  ),
1565
2757
  /** The number of file search retrieval chunks to retrieve. */
1566
- topK: import_v46.z.number().int().positive().describe("The number of file search retrieval chunks to retrieve.").optional(),
2758
+ topK: z8.number().int().positive().describe("The number of file search retrieval chunks to retrieve.").optional(),
1567
2759
  /** Metadata filter to apply to the file search retrieval documents.
1568
2760
  * See https://google.aip.dev/160 for the syntax of the filter expression.
1569
2761
  */
1570
- metadataFilter: import_v46.z.string().describe(
2762
+ metadataFilter: z8.string().describe(
1571
2763
  "Metadata filter to apply to the file search retrieval documents. See https://google.aip.dev/160 for the syntax of the filter expression."
1572
2764
  ).optional()
1573
2765
  }).passthrough();
1574
- var fileSearchArgsSchema = (0, import_provider_utils7.lazySchema)(
1575
- () => (0, import_provider_utils7.zodSchema)(fileSearchArgsBaseSchema)
1576
- );
1577
- var fileSearch = (0, import_provider_utils7.createProviderToolFactory)({
2766
+ var fileSearch = createProviderExecutedToolFactory3({
1578
2767
  id: "google.file_search",
1579
- inputSchema: fileSearchArgsSchema
2768
+ inputSchema: lazySchema7(() => zodSchema7(z8.object({}))),
2769
+ outputSchema: lazySchema7(() => zodSchema7(z8.object({})))
1580
2770
  });
1581
2771
 
1582
2772
  // src/tool/google-maps.ts
1583
- var import_provider_utils8 = require("@ai-sdk/provider-utils");
1584
- var import_v47 = require("zod/v4");
1585
- var googleMaps = (0, import_provider_utils8.createProviderToolFactory)({
2773
+ import {
2774
+ createProviderExecutedToolFactory as createProviderExecutedToolFactory4,
2775
+ lazySchema as lazySchema8,
2776
+ zodSchema as zodSchema8
2777
+ } from "@ai-sdk/provider-utils";
2778
+ import { z as z9 } from "zod/v4";
2779
+ var googleMaps = createProviderExecutedToolFactory4({
1586
2780
  id: "google.google_maps",
1587
- inputSchema: (0, import_provider_utils8.lazySchema)(() => (0, import_provider_utils8.zodSchema)(import_v47.z.object({})))
2781
+ inputSchema: lazySchema8(() => zodSchema8(z9.object({}))),
2782
+ outputSchema: lazySchema8(() => zodSchema8(z9.object({})))
1588
2783
  });
1589
2784
 
1590
2785
  // src/tool/google-search.ts
1591
- var import_provider_utils9 = require("@ai-sdk/provider-utils");
1592
- var import_v48 = require("zod/v4");
1593
- var googleSearchToolArgsBaseSchema = import_v48.z.object({
1594
- searchTypes: import_v48.z.object({
1595
- webSearch: import_v48.z.object({}).optional(),
1596
- imageSearch: import_v48.z.object({}).optional()
2786
+ import {
2787
+ createProviderExecutedToolFactory as createProviderExecutedToolFactory5,
2788
+ lazySchema as lazySchema9,
2789
+ zodSchema as zodSchema9
2790
+ } from "@ai-sdk/provider-utils";
2791
+ import { z as z10 } from "zod/v4";
2792
+ var googleSearchToolArgsBaseSchema = z10.object({
2793
+ searchTypes: z10.object({
2794
+ webSearch: z10.object({}).optional(),
2795
+ imageSearch: z10.object({}).optional()
1597
2796
  }).optional(),
1598
- timeRangeFilter: import_v48.z.object({
1599
- startTime: import_v48.z.string(),
1600
- endTime: import_v48.z.string()
2797
+ timeRangeFilter: z10.object({
2798
+ startTime: z10.string(),
2799
+ endTime: z10.string()
1601
2800
  }).optional()
1602
2801
  }).passthrough();
1603
- var googleSearchToolArgsSchema = (0, import_provider_utils9.lazySchema)(
1604
- () => (0, import_provider_utils9.zodSchema)(googleSearchToolArgsBaseSchema)
1605
- );
1606
- var googleSearch = (0, import_provider_utils9.createProviderToolFactory)(
1607
- {
1608
- id: "google.google_search",
1609
- inputSchema: googleSearchToolArgsSchema
1610
- }
1611
- );
2802
+ var googleSearch = createProviderExecutedToolFactory5({
2803
+ id: "google.google_search",
2804
+ inputSchema: lazySchema9(() => zodSchema9(z10.object({}))),
2805
+ outputSchema: lazySchema9(() => zodSchema9(z10.object({})))
2806
+ });
1612
2807
 
1613
2808
  // src/tool/url-context.ts
1614
- var import_provider_utils10 = require("@ai-sdk/provider-utils");
1615
- var import_v49 = require("zod/v4");
1616
- var urlContext = (0, import_provider_utils10.createProviderToolFactory)({
2809
+ import {
2810
+ createProviderExecutedToolFactory as createProviderExecutedToolFactory6,
2811
+ lazySchema as lazySchema10,
2812
+ zodSchema as zodSchema10
2813
+ } from "@ai-sdk/provider-utils";
2814
+ import { z as z11 } from "zod/v4";
2815
+ var urlContext = createProviderExecutedToolFactory6({
1617
2816
  id: "google.url_context",
1618
- inputSchema: (0, import_provider_utils10.lazySchema)(() => (0, import_provider_utils10.zodSchema)(import_v49.z.object({})))
2817
+ inputSchema: lazySchema10(() => zodSchema10(z11.object({}))),
2818
+ outputSchema: lazySchema10(() => zodSchema10(z11.object({})))
1619
2819
  });
1620
2820
 
1621
2821
  // src/tool/vertex-rag-store.ts
1622
- var import_provider_utils11 = require("@ai-sdk/provider-utils");
1623
- var import_v410 = require("zod/v4");
1624
- var vertexRagStore = (0, import_provider_utils11.createProviderToolFactory)({
2822
+ import {
2823
+ createProviderExecutedToolFactory as createProviderExecutedToolFactory7,
2824
+ lazySchema as lazySchema11,
2825
+ zodSchema as zodSchema11
2826
+ } from "@ai-sdk/provider-utils";
2827
+ import { z as z12 } from "zod/v4";
2828
+ var vertexRagStore = createProviderExecutedToolFactory7({
1625
2829
  id: "google.vertex_rag_store",
1626
- inputSchema: import_v410.z.object({
1627
- ragCorpus: import_v410.z.string(),
1628
- topK: import_v410.z.number().optional()
1629
- })
2830
+ inputSchema: lazySchema11(() => zodSchema11(z12.object({}))),
2831
+ outputSchema: lazySchema11(() => zodSchema11(z12.object({})))
1630
2832
  });
1631
2833
 
1632
2834
  // src/google-tools.ts
@@ -1688,11 +2890,11 @@ var googleTools = {
1688
2890
  */
1689
2891
  vertexRagStore
1690
2892
  };
1691
- // Annotate the CommonJS export names for ESM import in node:
1692
- 0 && (module.exports = {
1693
- GoogleGenerativeAILanguageModel,
2893
+ export {
2894
+ GoogleLanguageModel,
2895
+ GoogleSpeechModel,
1694
2896
  getGroundingMetadataSchema,
1695
2897
  getUrlContextMetadataSchema,
1696
2898
  googleTools
1697
- });
2899
+ };
1698
2900
  //# sourceMappingURL=index.js.map