@ai-sdk/google 3.0.126 → 3.0.127

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -106,14 +106,14 @@ var GoogleTranscriptionModel = class {
106
106
  });
107
107
  }
108
108
  async doGenerate(options) {
109
- var _a, _b, _c, _d, _e, _f;
109
+ var _a2, _b, _c, _d, _e, _f;
110
110
  if (isLiveTranscriptionModelId(this.modelId)) {
111
111
  throw new import_provider.InvalidArgumentError({
112
112
  argument: "modelId",
113
113
  message: `Model '${this.modelId}' only supports streaming transcription, which requires AI SDK v7. Use a unary model such as 'gemini-3.5-transcribe'.`
114
114
  });
115
115
  }
116
- const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
116
+ const currentDate = (_c = (_b = (_a2 = this.config._internal) == null ? void 0 : _a2.currentDate) == null ? void 0 : _b.call(_a2)) != null ? _c : /* @__PURE__ */ new Date();
117
117
  const warnings = [];
118
118
  const googleOptions = await this.parseOptions(options.providerOptions);
119
119
  const transcriptionConfig = buildTranscriptionConfig(googleOptions);
@@ -184,7 +184,7 @@ var GoogleTranscriptionModel = class {
184
184
  }
185
185
  };
186
186
  function buildTranscriptionConfig(options) {
187
- var _a;
187
+ var _a2;
188
188
  if (options == null) return void 0;
189
189
  const config = {};
190
190
  if (options.languageCodes != null) {
@@ -195,7 +195,7 @@ function buildTranscriptionConfig(options) {
195
195
  }
196
196
  if (options.mode != null || options.diarization === true || options.wordTimestamp === true) {
197
197
  config.mode = {
198
- type: ((_a = options.mode) != null ? _a : "VERBATIM").toLowerCase(),
198
+ type: ((_a2 = options.mode) != null ? _a2 : "VERBATIM").toLowerCase(),
199
199
  ...options.diarization === true ? { diarization_mode: "speaker" } : {},
200
200
  ...options.wordTimestamp === true ? { timestamp_granularities: ["word"] } : {}
201
201
  };
@@ -235,7 +235,7 @@ var googleInteractionsTranscriptionResponseSchema = import_v43.z.object({
235
235
  var import_provider_utils24 = require("@ai-sdk/provider-utils");
236
236
 
237
237
  // src/version.ts
238
- var VERSION = true ? "3.0.126" : "0.0.0-test";
238
+ var VERSION = true ? "3.0.127" : "0.0.0-test";
239
239
 
240
240
  // src/google-generative-ai-embedding-model.ts
241
241
  var import_provider2 = require("@ai-sdk/provider");
@@ -305,11 +305,31 @@ var googleEmbeddingModelOptions = (0, import_provider_utils3.lazySchema)(
305
305
  );
306
306
 
307
307
  // src/google-generative-ai-embedding-model.ts
308
+ var _a;
309
+ _a = import_provider_utils4.EXPERIMENTAL_EMBEDDING_MODEL_PROVIDER_OPTIONS_TRANSFORMER;
308
310
  var GoogleGenerativeAIEmbeddingModel = class {
309
311
  constructor(modelId, config) {
310
312
  this.specificationVersion = "v3";
311
313
  this.maxEmbeddingsPerCall = 100;
312
314
  this.supportsParallelCalls = true;
315
+ this[_a] = ({ providerOptions, values, startIndex, endIndex }) => {
316
+ var _a2;
317
+ const multimodalContent = (_a2 = providerOptions == null ? void 0 : providerOptions.google) == null ? void 0 : _a2.content;
318
+ if (!Array.isArray(multimodalContent)) {
319
+ return providerOptions;
320
+ }
321
+ validateMultimodalContentLength({
322
+ multimodalContent,
323
+ values
324
+ });
325
+ return {
326
+ ...providerOptions,
327
+ google: {
328
+ ...providerOptions == null ? void 0 : providerOptions.google,
329
+ content: multimodalContent.slice(startIndex, endIndex)
330
+ }
331
+ };
332
+ };
313
333
  this.modelId = modelId;
314
334
  this.config = config;
315
335
  }
@@ -340,11 +360,7 @@ var GoogleGenerativeAIEmbeddingModel = class {
340
360
  headers
341
361
  );
342
362
  const multimodalContent = googleOptions == null ? void 0 : googleOptions.content;
343
- if (multimodalContent != null && multimodalContent.length !== values.length) {
344
- throw new Error(
345
- `The number of multimodal content entries (${multimodalContent.length}) must match the number of values (${values.length}).`
346
- );
347
- }
363
+ validateMultimodalContentLength({ multimodalContent, values });
348
364
  if (values.length === 1) {
349
365
  const valueParts = multimodalContent == null ? void 0 : multimodalContent[0];
350
366
  const textPart = values[0] ? [{ text: values[0] }] : [];
@@ -429,6 +445,16 @@ var googleGenerativeAISingleEmbeddingResponseSchema = (0, import_provider_utils4
429
445
  })
430
446
  )
431
447
  );
448
+ function validateMultimodalContentLength({
449
+ multimodalContent,
450
+ values
451
+ }) {
452
+ if (multimodalContent != null && multimodalContent.length !== values.length) {
453
+ throw new Error(
454
+ `The number of multimodal content entries (${multimodalContent.length}) must match the number of values (${values.length}).`
455
+ );
456
+ }
457
+ }
432
458
 
433
459
  // src/google-generative-ai-language-model.ts
434
460
  var import_provider_utils7 = require("@ai-sdk/provider-utils");
@@ -436,7 +462,7 @@ var import_v47 = require("zod/v4");
436
462
 
437
463
  // src/convert-google-generative-ai-usage.ts
438
464
  function convertGoogleGenerativeAIUsage(usage) {
439
- var _a, _b, _c, _d;
465
+ var _a2, _b, _c, _d;
440
466
  if (usage == null) {
441
467
  return {
442
468
  inputTokens: {
@@ -453,7 +479,7 @@ function convertGoogleGenerativeAIUsage(usage) {
453
479
  raw: void 0
454
480
  };
455
481
  }
456
- const promptTokens = (_a = usage.promptTokenCount) != null ? _a : 0;
482
+ const promptTokens = (_a2 = usage.promptTokenCount) != null ? _a2 : 0;
457
483
  const candidatesTokens = (_b = usage.candidatesTokenCount) != null ? _b : 0;
458
484
  const cachedContentTokens = (_c = usage.cachedContentTokenCount) != null ? _c : 0;
459
485
  const thoughtsTokens = (_d = usage.thoughtsTokenCount) != null ? _d : 0;
@@ -873,11 +899,11 @@ function appendLegacyToolResultParts(parts, toolName, outputValue, toolCallId, i
873
899
  }
874
900
  }
875
901
  function convertToGoogleGenerativeAIMessages(prompt, options) {
876
- var _a, _b, _c, _d, _e, _f;
902
+ var _a2, _b, _c, _d, _e, _f;
877
903
  const systemInstructionParts = [];
878
904
  const contents = [];
879
905
  let systemMessagesAllowed = true;
880
- const isGemmaModel = (_a = options == null ? void 0 : options.isGemmaModel) != null ? _a : false;
906
+ const isGemmaModel = (_a2 = options == null ? void 0 : options.isGemmaModel) != null ? _a2 : false;
881
907
  const isGemini3Model = (_b = options == null ? void 0 : options.isGemini3Model) != null ? _b : false;
882
908
  const providerOptionsName = (_c = options == null ? void 0 : options.providerOptionsName) != null ? _c : "google";
883
909
  const supportsFunctionResponseParts = (_d = options == null ? void 0 : options.supportsFunctionResponseParts) != null ? _d : true;
@@ -1564,10 +1590,10 @@ function prepareTools({
1564
1590
  }
1565
1591
  }
1566
1592
  function prepareFunctionDeclaration(tool) {
1567
- var _a;
1593
+ var _a2;
1568
1594
  const declaration = {
1569
1595
  name: tool.name,
1570
- description: (_a = tool.description) != null ? _a : ""
1596
+ description: (_a2 = tool.description) != null ? _a2 : ""
1571
1597
  };
1572
1598
  try {
1573
1599
  return {
@@ -1815,8 +1841,8 @@ function setNestedValue(obj, segments, value) {
1815
1841
  defineOwnProperty(current, segments[segments.length - 1], value);
1816
1842
  }
1817
1843
  function resolvePartialArgValue(arg) {
1818
- var _a, _b;
1819
- const value = (_b = (_a = arg.stringValue) != null ? _a : arg.numberValue) != null ? _b : arg.boolValue;
1844
+ var _a2, _b;
1845
+ const value = (_b = (_a2 = arg.stringValue) != null ? _a2 : arg.numberValue) != null ? _b : arg.boolValue;
1820
1846
  if (value != null) return { value, json: JSON.stringify(value) };
1821
1847
  if ("nullValue" in arg) return { value: null, json: "null" };
1822
1848
  return void 0;
@@ -1859,17 +1885,17 @@ var gemini25ModelPattern2 = /(^|\/)gemini-2\.5(?:[.-]|$)/i;
1859
1885
  var GoogleGenerativeAILanguageModel = class {
1860
1886
  constructor(modelId, config) {
1861
1887
  this.specificationVersion = "v3";
1862
- var _a;
1888
+ var _a2;
1863
1889
  this.modelId = modelId;
1864
1890
  this.config = config;
1865
- this.generateId = (_a = config.generateId) != null ? _a : import_provider_utils7.generateId;
1891
+ this.generateId = (_a2 = config.generateId) != null ? _a2 : import_provider_utils7.generateId;
1866
1892
  }
1867
1893
  get provider() {
1868
1894
  return this.config.provider;
1869
1895
  }
1870
1896
  get supportedUrls() {
1871
- var _a, _b, _c;
1872
- return (_c = (_b = (_a = this.config).supportedUrls) == null ? void 0 : _b.call(_a)) != null ? _c : {};
1897
+ var _a2, _b, _c;
1898
+ return (_c = (_b = (_a2 = this.config).supportedUrls) == null ? void 0 : _b.call(_a2)) != null ? _c : {};
1873
1899
  }
1874
1900
  async getArgs({
1875
1901
  prompt,
@@ -1886,7 +1912,7 @@ var GoogleGenerativeAILanguageModel = class {
1886
1912
  toolChoice,
1887
1913
  providerOptions
1888
1914
  }, { isStreaming = false } = {}) {
1889
- var _a, _b, _c;
1915
+ var _a2, _b, _c;
1890
1916
  const warnings = [];
1891
1917
  const providerOptionsName = this.config.provider.includes("vertex") ? "vertex" : "google";
1892
1918
  let googleOptions = await (0, import_provider_utils7.parseProviderOptions)({
@@ -1994,7 +2020,7 @@ var GoogleGenerativeAILanguageModel = class {
1994
2020
  modelId: this.modelId,
1995
2021
  isVertexProvider
1996
2022
  });
1997
- const streamFunctionCallArguments = isStreaming && isVertexProvider ? (_a = googleOptions == null ? void 0 : googleOptions.streamFunctionCallArguments) != null ? _a : false : void 0;
2023
+ const streamFunctionCallArguments = isStreaming && isVertexProvider ? (_a2 = googleOptions == null ? void 0 : googleOptions.streamFunctionCallArguments) != null ? _a2 : false : void 0;
1998
2024
  const safetyThreshold = googleOptions == null ? void 0 : googleOptions.threshold;
1999
2025
  const safetySettings = (_b = googleOptions == null ? void 0 : googleOptions.safetySettings) != null ? _b : safetyThreshold != null ? configurableSafetySettingCategories.map((category) => ({
2000
2026
  category,
@@ -2056,7 +2082,7 @@ var GoogleGenerativeAILanguageModel = class {
2056
2082
  };
2057
2083
  }
2058
2084
  async doGenerate(options) {
2059
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
2085
+ var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
2060
2086
  const { args, warnings, providerOptionsName, extraHeaders } = await this.getArgs(options);
2061
2087
  const mergedHeaders = (0, import_provider_utils7.combineHeaders)(
2062
2088
  await (0, import_provider_utils7.resolve)(this.config.headers),
@@ -2078,7 +2104,7 @@ var GoogleGenerativeAILanguageModel = class {
2078
2104
  abortSignal: options.abortSignal,
2079
2105
  fetch: this.config.fetch
2080
2106
  });
2081
- const candidate = (_a = response.candidates) == null ? void 0 : _a[0];
2107
+ const candidate = (_a2 = response.candidates) == null ? void 0 : _a2[0];
2082
2108
  const promptBlockReason = (_b = response.promptFeedback) == null ? void 0 : _b.blockReason;
2083
2109
  const confirmedPromptBlockReason = isConfirmedPromptBlockReason(
2084
2110
  promptBlockReason
@@ -2317,7 +2343,7 @@ var GoogleGenerativeAILanguageModel = class {
2317
2343
  controller.enqueue({ type: "stream-start", warnings });
2318
2344
  },
2319
2345
  transform(chunk, controller) {
2320
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
2346
+ var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
2321
2347
  if (options.includeRawChunks) {
2322
2348
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
2323
2349
  }
@@ -2347,7 +2373,7 @@ var GoogleGenerativeAILanguageModel = class {
2347
2373
  };
2348
2374
  }
2349
2375
  }
2350
- const candidate = (_a = value.candidates) == null ? void 0 : _a[0];
2376
+ const candidate = (_a2 = value.candidates) == null ? void 0 : _a2[0];
2351
2377
  if (candidate != null) {
2352
2378
  if (candidate.groundingMetadata != null) {
2353
2379
  lastGroundingMetadata = candidate.groundingMetadata;
@@ -2656,7 +2682,7 @@ var GoogleGenerativeAILanguageModel = class {
2656
2682
  }
2657
2683
  },
2658
2684
  flush(controller) {
2659
- var _a;
2685
+ var _a2;
2660
2686
  if (currentTextBlockId !== null) {
2661
2687
  controller.enqueue({
2662
2688
  type: "text-end",
@@ -2681,7 +2707,7 @@ var GoogleGenerativeAILanguageModel = class {
2681
2707
  safetyRatings: lastSafetyRatings,
2682
2708
  usageMetadata: usage != null ? usage : null,
2683
2709
  finishMessage: lastFinishMessage,
2684
- serviceTier: (_a = usage == null ? void 0 : usage.serviceTier) != null ? _a : null
2710
+ serviceTier: (_a2 = usage == null ? void 0 : usage.serviceTier) != null ? _a2 : null
2685
2711
  }
2686
2712
  }
2687
2713
  });
@@ -2697,7 +2723,7 @@ function extractSources({
2697
2723
  groundingMetadata,
2698
2724
  generateId: generateId3
2699
2725
  }) {
2700
- var _a, _b, _c, _d, _e, _f;
2726
+ var _a2, _b, _c, _d, _e, _f;
2701
2727
  if (!(groundingMetadata == null ? void 0 : groundingMetadata.groundingChunks)) {
2702
2728
  return void 0;
2703
2729
  }
@@ -2709,7 +2735,7 @@ function extractSources({
2709
2735
  sourceType: "url",
2710
2736
  id: generateId3(),
2711
2737
  url: chunk.web.uri,
2712
- title: (_a = chunk.web.title) != null ? _a : void 0
2738
+ title: (_a2 = chunk.web.title) != null ? _a2 : void 0
2713
2739
  });
2714
2740
  } else if (chunk.image != null) {
2715
2741
  sources.push({
@@ -3173,7 +3199,7 @@ var GoogleGenerativeAIImageModel = class {
3173
3199
  return this.doGenerateImagen(options);
3174
3200
  }
3175
3201
  async doGenerateImagen(options) {
3176
- var _a, _b, _c;
3202
+ var _a2, _b, _c;
3177
3203
  const {
3178
3204
  prompt,
3179
3205
  n = 1,
@@ -3216,7 +3242,7 @@ var GoogleGenerativeAIImageModel = class {
3216
3242
  providerOptions,
3217
3243
  schema: googleImageModelOptionsSchema
3218
3244
  });
3219
- const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
3245
+ const currentDate = (_c = (_b = (_a2 = this.config._internal) == null ? void 0 : _a2.currentDate) == null ? void 0 : _b.call(_a2)) != null ? _c : /* @__PURE__ */ new Date();
3220
3246
  const parameters = {
3221
3247
  sampleCount: n
3222
3248
  };
@@ -3275,7 +3301,7 @@ var GoogleGenerativeAIImageModel = class {
3275
3301
  };
3276
3302
  }
3277
3303
  async doGenerateGemini(options) {
3278
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
3304
+ var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
3279
3305
  const {
3280
3306
  prompt,
3281
3307
  n,
@@ -3335,7 +3361,7 @@ var GoogleGenerativeAIImageModel = class {
3335
3361
  providerOptions,
3336
3362
  schema: googleImageModelOptionsSchema
3337
3363
  });
3338
- const { googleSearch: _strippedGoogleSearch, ...passthroughGoogleOptions } = (_a = providerOptions == null ? void 0 : providerOptions.google) != null ? _a : {};
3364
+ const { googleSearch: _strippedGoogleSearch, ...passthroughGoogleOptions } = (_a2 = providerOptions == null ? void 0 : providerOptions.google) != null ? _a2 : {};
3339
3365
  const languageModel = new GoogleGenerativeAILanguageModel(this.modelId, {
3340
3366
  provider: this.config.provider,
3341
3367
  baseURL: this.config.baseURL,
@@ -3436,16 +3462,16 @@ var import_provider6 = require("@ai-sdk/provider");
3436
3462
  var import_provider_utils16 = require("@ai-sdk/provider-utils");
3437
3463
  var import_v416 = require("zod/v4");
3438
3464
  function getFirstFrameImage(options) {
3439
- var _a, _b;
3440
- return (_b = (_a = options.frameImages) == null ? void 0 : _a.find((frame) => frame.frameType === "first_frame")) == null ? void 0 : _b.image;
3465
+ var _a2, _b;
3466
+ return (_b = (_a2 = options.frameImages) == null ? void 0 : _a2.find((frame) => frame.frameType === "first_frame")) == null ? void 0 : _b.image;
3441
3467
  }
3442
3468
  function resolveStartImage(options) {
3443
- var _a;
3444
- return (_a = getFirstFrameImage(options)) != null ? _a : options.image;
3469
+ var _a2;
3470
+ return (_a2 = getFirstFrameImage(options)) != null ? _a2 : options.image;
3445
3471
  }
3446
3472
  function getLastFrameImage(options) {
3447
- var _a, _b;
3448
- return (_b = (_a = options.frameImages) == null ? void 0 : _a.find((frame) => frame.frameType === "last_frame")) == null ? void 0 : _b.image;
3473
+ var _a2, _b;
3474
+ return (_b = (_a2 = options.frameImages) == null ? void 0 : _a2.find((frame) => frame.frameType === "last_frame")) == null ? void 0 : _b.image;
3449
3475
  }
3450
3476
  function getInputReferences(options) {
3451
3477
  if (options.frameImages != null && options.frameImages.length > 0) {
@@ -3510,8 +3536,8 @@ var GoogleGenerativeAIVideoModel = class {
3510
3536
  return 4;
3511
3537
  }
3512
3538
  async doGenerate(options) {
3513
- var _a, _b, _c, _d, _e, _f, _g, _h;
3514
- const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
3539
+ var _a2, _b, _c, _d, _e, _f, _g, _h;
3540
+ const currentDate = (_c = (_b = (_a2 = this.config._internal) == null ? void 0 : _a2.currentDate) == null ? void 0 : _b.call(_a2)) != null ? _c : /* @__PURE__ */ new Date();
3515
3541
  const warnings = [];
3516
3542
  const googleOptions = await (0, import_provider_utils16.parseProviderOptions)({
3517
3543
  provider: "google",
@@ -3741,7 +3767,7 @@ var import_provider_utils23 = require("@ai-sdk/provider-utils");
3741
3767
 
3742
3768
  // src/interactions/convert-google-interactions-usage.ts
3743
3769
  function convertGoogleInteractionsUsage(usage) {
3744
- var _a, _b, _c, _d, _e, _f, _g, _h;
3770
+ var _a2, _b, _c, _d, _e, _f, _g, _h;
3745
3771
  if (usage == null) {
3746
3772
  return {
3747
3773
  inputTokens: {
@@ -3758,7 +3784,7 @@ function convertGoogleInteractionsUsage(usage) {
3758
3784
  raw: void 0
3759
3785
  };
3760
3786
  }
3761
- const totalInput = (_a = usage.total_input_tokens) != null ? _a : 0;
3787
+ const totalInput = (_a2 = usage.total_input_tokens) != null ? _a2 : 0;
3762
3788
  const totalOutput = (_b = usage.total_output_tokens) != null ? _b : 0;
3763
3789
  const totalThought = (_c = usage.total_thought_tokens) != null ? _c : 0;
3764
3790
  const totalCached = (_d = usage.total_cached_tokens) != null ? _d : 0;
@@ -3816,7 +3842,7 @@ function annotationToSource({
3816
3842
  annotation,
3817
3843
  generateId: generateId3
3818
3844
  }) {
3819
- var _a, _b, _c, _d, _e;
3845
+ var _a2, _b, _c, _d, _e;
3820
3846
  switch (annotation.type) {
3821
3847
  case "url_citation": {
3822
3848
  const a = annotation;
@@ -3831,7 +3857,7 @@ function annotationToSource({
3831
3857
  }
3832
3858
  case "file_citation": {
3833
3859
  const a = annotation;
3834
- const uri = (_b = (_a = a.url) != null ? _a : a.document_uri) != null ? _b : a.file_name;
3860
+ const uri = (_b = (_a2 = a.url) != null ? _a2 : a.document_uri) != null ? _b : a.file_name;
3835
3861
  if (uri == null || uri.length === 0) return void 0;
3836
3862
  if (uri.startsWith("http://") || uri.startsWith("https://")) {
3837
3863
  return {
@@ -3872,11 +3898,11 @@ function builtinToolResultToSources({
3872
3898
  block,
3873
3899
  generateId: generateId3
3874
3900
  }) {
3875
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
3901
+ var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
3876
3902
  const sources = [];
3877
3903
  switch (block.type) {
3878
3904
  case "url_context_result": {
3879
- const result = (_a = block.result) != null ? _a : [];
3905
+ const result = (_a2 = block.result) != null ? _a2 : [];
3880
3906
  for (const entry of result) {
3881
3907
  if ((entry == null ? void 0 : entry.url) == null || entry.url.length === 0) continue;
3882
3908
  if (entry.status != null && entry.status !== "success") continue;
@@ -3959,14 +3985,14 @@ function annotationsToSources({
3959
3985
  annotations,
3960
3986
  generateId: generateId3
3961
3987
  }) {
3962
- var _a;
3988
+ var _a2;
3963
3989
  if (annotations == null) return [];
3964
3990
  const seen = /* @__PURE__ */ new Set();
3965
3991
  const sources = [];
3966
3992
  for (const annotation of annotations) {
3967
3993
  const source = annotationToSource({ annotation, generateId: generateId3 });
3968
3994
  if (source == null) continue;
3969
- const key = source.sourceType === "url" ? `url:${source.url}` : `doc:${(_a = source.filename) != null ? _a : source.title}`;
3995
+ const key = source.sourceType === "url" ? `url:${source.url}` : `doc:${(_a2 = source.filename) != null ? _a2 : source.title}`;
3970
3996
  if (seen.has(key)) continue;
3971
3997
  seen.add(key);
3972
3998
  sources.push(source);
@@ -4033,15 +4059,15 @@ function buildGoogleInteractionsStreamTransform({
4033
4059
  const openBlocks = /* @__PURE__ */ new Map();
4034
4060
  const emittedSourceKeys = /* @__PURE__ */ new Set();
4035
4061
  function sourceKey(source) {
4036
- var _a;
4037
- return source.sourceType === "url" ? `url:${source.url}` : `doc:${(_a = source.filename) != null ? _a : source.title}`;
4062
+ var _a2;
4063
+ return source.sourceType === "url" ? `url:${source.url}` : `doc:${(_a2 = source.filename) != null ? _a2 : source.title}`;
4038
4064
  }
4039
4065
  return new TransformStream({
4040
4066
  start(controller) {
4041
4067
  controller.enqueue({ type: "stream-start", warnings });
4042
4068
  },
4043
4069
  transform(chunk, controller) {
4044
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t;
4070
+ var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t;
4045
4071
  if (includeRawChunks) {
4046
4072
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
4047
4073
  }
@@ -4080,7 +4106,7 @@ function buildGoogleInteractionsStreamTransform({
4080
4106
  const blockId = `${interactionId != null ? interactionId : "interaction"}:${index}`;
4081
4107
  const stepType = step == null ? void 0 : step.type;
4082
4108
  if (stepType === "model_output") {
4083
- const initial = (_a = step == null ? void 0 : step.content) == null ? void 0 : _a[0];
4109
+ const initial = (_a2 = step == null ? void 0 : step.content) == null ? void 0 : _a2[0];
4084
4110
  if ((initial == null ? void 0 : initial.type) === "text") {
4085
4111
  openBlocks.set(index, {
4086
4112
  kind: "text",
@@ -4522,7 +4548,7 @@ function convertToGoogleInteractionsInput({
4522
4548
  store,
4523
4549
  mediaResolution
4524
4550
  }) {
4525
- var _a, _b, _c, _d, _e, _f, _g;
4551
+ var _a2, _b, _c, _d, _e, _f, _g;
4526
4552
  const warnings = [];
4527
4553
  const incoherentCombo = previousInteractionId != null && store === false;
4528
4554
  const shouldCompact = previousInteractionId != null && store !== false;
@@ -4579,7 +4605,7 @@ function convertToGoogleInteractionsInput({
4579
4605
  pendingModelOutput.push({ type: "text", text: part.text });
4580
4606
  } else if (part.type === "reasoning") {
4581
4607
  flushModelOutput();
4582
- const signature = (_b = (_a = part.providerOptions) == null ? void 0 : _a.google) == null ? void 0 : _b.signature;
4608
+ const signature = (_b = (_a2 = part.providerOptions) == null ? void 0 : _a2.google) == null ? void 0 : _b.signature;
4583
4609
  steps.push({
4584
4610
  type: "thought",
4585
4611
  ...signature != null ? { signature } : {},
@@ -4706,8 +4732,8 @@ function compactPromptForPreviousInteraction({
4706
4732
  for (const message of prompt) {
4707
4733
  if (message.role === "assistant") {
4708
4734
  const matchesLinkedInteraction = message.content.some((part) => {
4709
- var _a, _b;
4710
- const partInteractionId = (_b = (_a = part.providerOptions) == null ? void 0 : _a.google) == null ? void 0 : _b.interactionId;
4735
+ var _a2, _b;
4736
+ const partInteractionId = (_b = (_a2 = part.providerOptions) == null ? void 0 : _a2.google) == null ? void 0 : _b.interactionId;
4711
4737
  return partInteractionId === previousInteractionId;
4712
4738
  });
4713
4739
  if (matchesLinkedInteraction) {
@@ -4759,7 +4785,7 @@ function convertToolResultPart({
4759
4785
  signature,
4760
4786
  warnings
4761
4787
  }) {
4762
- var _a;
4788
+ var _a2;
4763
4789
  const base = {
4764
4790
  type: "function_result",
4765
4791
  call_id: toolCallId,
@@ -4779,7 +4805,7 @@ function convertToolResultPart({
4779
4805
  return {
4780
4806
  ...base,
4781
4807
  is_error: true,
4782
- result: (_a = output.reason) != null ? _a : "Tool execution denied by user."
4808
+ result: (_a2 = output.reason) != null ? _a2 : "Tool execution denied by user."
4783
4809
  };
4784
4810
  case "content": {
4785
4811
  const blocks = [];
@@ -5459,7 +5485,7 @@ function parseGoogleInteractionsOutputs({
5459
5485
  generateId: generateId3,
5460
5486
  interactionId
5461
5487
  }) {
5462
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
5488
+ var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
5463
5489
  const content = [];
5464
5490
  let hasFunctionCall = false;
5465
5491
  if (steps == null) {
@@ -5474,7 +5500,7 @@ function parseGoogleInteractionsOutputs({
5474
5500
  break;
5475
5501
  }
5476
5502
  case "model_output": {
5477
- const blocks = (_a = step.content) != null ? _a : [];
5503
+ const blocks = (_a2 = step.content) != null ? _a2 : [];
5478
5504
  for (const block of blocks) {
5479
5505
  if (block == null || typeof block !== "object") continue;
5480
5506
  const blockType = block.type;
@@ -5709,7 +5735,7 @@ function prepareGoogleInteractionsTools({
5709
5735
  tools,
5710
5736
  toolChoice
5711
5737
  }) {
5712
- var _a, _b, _c, _d;
5738
+ var _a2, _b, _c, _d;
5713
5739
  const toolWarnings = [];
5714
5740
  const normalized = (tools == null ? void 0 : tools.length) ? tools : void 0;
5715
5741
  if (normalized == null) {
@@ -5721,7 +5747,7 @@ function prepareGoogleInteractionsTools({
5721
5747
  interactionsTools.push({
5722
5748
  type: "function",
5723
5749
  name: tool.name,
5724
- description: (_a = tool.description) != null ? _a : "",
5750
+ description: (_a2 = tool.description) != null ? _a2 : "",
5725
5751
  parameters: tool.inputSchema
5726
5752
  });
5727
5753
  continue;
@@ -6025,7 +6051,7 @@ function synthesizeGoogleInteractionsAgentStream({
6025
6051
  }) {
6026
6052
  return new ReadableStream({
6027
6053
  start(controller) {
6028
- var _a, _b, _c;
6054
+ var _a2, _b, _c;
6029
6055
  controller.enqueue({ type: "stream-start", warnings });
6030
6056
  const interactionId = typeof response.id === "string" && response.id.length > 0 ? response.id : void 0;
6031
6057
  let timestamp;
@@ -6039,7 +6065,7 @@ function synthesizeGoogleInteractionsAgentStream({
6039
6065
  controller.enqueue({
6040
6066
  type: "response-metadata",
6041
6067
  ...interactionId != null ? { id: interactionId } : {},
6042
- modelId: (_a = response.model) != null ? _a : void 0,
6068
+ modelId: (_a2 = response.model) != null ? _a2 : void 0,
6043
6069
  ...timestamp ? { timestamp } : {}
6044
6070
  });
6045
6071
  if (includeRawChunks) {
@@ -6191,7 +6217,7 @@ var GoogleInteractionsLanguageModel = class {
6191
6217
  };
6192
6218
  }
6193
6219
  async getArgs(options) {
6194
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F;
6220
+ var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F;
6195
6221
  const warnings = [];
6196
6222
  const opts = await (0, import_provider_utils23.parseProviderOptions)({
6197
6223
  provider: "google",
@@ -6226,7 +6252,7 @@ var GoogleInteractionsLanguageModel = class {
6226
6252
  warnings.push(...prepared.toolWarnings);
6227
6253
  }
6228
6254
  const responseFormatEntries = [];
6229
- if (((_a = options.responseFormat) == null ? void 0 : _a.type) === "json") {
6255
+ if (((_a2 = options.responseFormat) == null ? void 0 : _a2.type) === "json") {
6230
6256
  if (isAgent) {
6231
6257
  warnings.push({
6232
6258
  type: "other",
@@ -6386,7 +6412,7 @@ var GoogleInteractionsLanguageModel = class {
6386
6412
  } else {
6387
6413
  const env = opts.environment;
6388
6414
  const sources = (_A = env.sources) == null ? void 0 : _A.map((s) => {
6389
- var _a2;
6415
+ var _a3;
6390
6416
  if (s.type === "inline") {
6391
6417
  return {
6392
6418
  type: "inline",
@@ -6397,7 +6423,7 @@ var GoogleInteractionsLanguageModel = class {
6397
6423
  return pruneUndefined({
6398
6424
  type: s.type,
6399
6425
  source: s.source,
6400
- target: (_a2 = s.target) != null ? _a2 : void 0
6426
+ target: (_a3 = s.target) != null ? _a3 : void 0
6401
6427
  });
6402
6428
  });
6403
6429
  let network;
@@ -6407,10 +6433,10 @@ var GoogleInteractionsLanguageModel = class {
6407
6433
  network = {
6408
6434
  allowlist: env.network.allowlist.map(
6409
6435
  (entry) => {
6410
- var _a2;
6436
+ var _a3;
6411
6437
  return pruneUndefined({
6412
6438
  domain: entry.domain,
6413
- transform: (_a2 = entry.transform) != null ? _a2 : void 0
6439
+ transform: (_a3 = entry.transform) != null ? _a3 : void 0
6414
6440
  });
6415
6441
  }
6416
6442
  )
@@ -6447,7 +6473,7 @@ var GoogleInteractionsLanguageModel = class {
6447
6473
  };
6448
6474
  }
6449
6475
  async doGenerate(options) {
6450
- var _a, _b, _c, _d, _e, _f;
6476
+ var _a2, _b, _c, _d, _e, _f;
6451
6477
  const { args, warnings, isAgent, pollingTimeoutMs } = await this.getArgs(options);
6452
6478
  const url = `${this.config.baseURL}/interactions`;
6453
6479
  const mergedHeaders = (0, import_provider_utils23.combineHeaders)(
@@ -6482,7 +6508,7 @@ var GoogleInteractionsLanguageModel = class {
6482
6508
  });
6483
6509
  response = polled.response;
6484
6510
  rawResponse = polled.rawResponse;
6485
- responseHeaders = (_a = polled.responseHeaders) != null ? _a : responseHeaders;
6511
+ responseHeaders = (_a2 = polled.responseHeaders) != null ? _a2 : responseHeaders;
6486
6512
  }
6487
6513
  const interactionId = typeof response.id === "string" && response.id.length > 0 ? response.id : void 0;
6488
6514
  const { content, hasFunctionCall } = parseGoogleInteractionsOutputs({
@@ -6532,7 +6558,7 @@ var GoogleInteractionsLanguageModel = class {
6532
6558
  };
6533
6559
  }
6534
6560
  async doStream(options) {
6535
- var _a;
6561
+ var _a2;
6536
6562
  const { args, warnings, isBackground, pollingTimeoutMs } = await this.getArgs(options);
6537
6563
  const url = `${this.config.baseURL}/interactions`;
6538
6564
  const mergedHeaders = (0, import_provider_utils23.combineHeaders)(
@@ -6565,7 +6591,7 @@ var GoogleInteractionsLanguageModel = class {
6565
6591
  const headerServiceTier = responseHeaders == null ? void 0 : responseHeaders["x-gemini-service-tier"];
6566
6592
  const transform = buildGoogleInteractionsStreamTransform({
6567
6593
  warnings,
6568
- generateId: (_a = this.config.generateId) != null ? _a : import_provider_utils23.generateId,
6594
+ generateId: (_a2 = this.config.generateId) != null ? _a2 : import_provider_utils23.generateId,
6569
6595
  includeRawChunks: options.includeRawChunks,
6570
6596
  serviceTier: headerServiceTier
6571
6597
  });
@@ -6601,7 +6627,7 @@ var GoogleInteractionsLanguageModel = class {
6601
6627
  options,
6602
6628
  pollingTimeoutMs
6603
6629
  }) {
6604
- var _a, _b;
6630
+ var _a2, _b;
6605
6631
  const postResult = await (0, import_provider_utils23.postJsonToApi)({
6606
6632
  url,
6607
6633
  headers: mergedHeaders,
@@ -6625,7 +6651,7 @@ var GoogleInteractionsLanguageModel = class {
6625
6651
  const synthesized = synthesizeGoogleInteractionsAgentStream({
6626
6652
  response: postResponse,
6627
6653
  warnings,
6628
- generateId: (_a = this.config.generateId) != null ? _a : import_provider_utils23.generateId,
6654
+ generateId: (_a2 = this.config.generateId) != null ? _a2 : import_provider_utils23.generateId,
6629
6655
  includeRawChunks: options.includeRawChunks,
6630
6656
  headerServiceTier
6631
6657
  });
@@ -6698,8 +6724,8 @@ function supportsExternalFileUrls(modelId) {
6698
6724
  return /(^|\/)gemini-/.test(modelId) && !/(^|\/)gemini-2\.0/.test(modelId);
6699
6725
  }
6700
6726
  function createGoogleGenerativeAI(options = {}) {
6701
- var _a, _b;
6702
- const baseURL = (_a = (0, import_provider_utils24.withoutTrailingSlash)(options.baseURL)) != null ? _a : "https://generativelanguage.googleapis.com/v1beta";
6727
+ var _a2, _b;
6728
+ const baseURL = (_a2 = (0, import_provider_utils24.withoutTrailingSlash)(options.baseURL)) != null ? _a2 : "https://generativelanguage.googleapis.com/v1beta";
6703
6729
  const providerName = (_b = options.name) != null ? _b : "google.generative-ai";
6704
6730
  const getHeaders = () => (0, import_provider_utils24.withUserAgentSuffix)(
6705
6731
  {
@@ -6713,12 +6739,12 @@ function createGoogleGenerativeAI(options = {}) {
6713
6739
  `ai-sdk/google/${VERSION}`
6714
6740
  );
6715
6741
  const createChatModel = (modelId) => {
6716
- var _a2;
6742
+ var _a3;
6717
6743
  return new GoogleGenerativeAILanguageModel(modelId, {
6718
6744
  provider: providerName,
6719
6745
  baseURL,
6720
6746
  headers: getHeaders,
6721
- generateId: (_a2 = options.generateId) != null ? _a2 : import_provider_utils24.generateId,
6747
+ generateId: (_a3 = options.generateId) != null ? _a3 : import_provider_utils24.generateId,
6722
6748
  supportedUrls: () => ({
6723
6749
  "*": [
6724
6750
  // Google Generative Language "files" endpoint
@@ -6759,24 +6785,24 @@ function createGoogleGenerativeAI(options = {}) {
6759
6785
  fetch: options.fetch
6760
6786
  });
6761
6787
  const createVideoModel = (modelId) => {
6762
- var _a2;
6788
+ var _a3;
6763
6789
  return new GoogleGenerativeAIVideoModel(modelId, {
6764
6790
  provider: providerName,
6765
6791
  baseURL,
6766
6792
  headers: getHeaders,
6767
6793
  fetch: options.fetch,
6768
- generateId: (_a2 = options.generateId) != null ? _a2 : import_provider_utils24.generateId
6794
+ generateId: (_a3 = options.generateId) != null ? _a3 : import_provider_utils24.generateId
6769
6795
  });
6770
6796
  };
6771
6797
  const createInteractionsModel = (modelIdOrAgent) => {
6772
- var _a2;
6798
+ var _a3;
6773
6799
  return new GoogleInteractionsLanguageModel(
6774
6800
  modelIdOrAgent,
6775
6801
  {
6776
6802
  provider: `${providerName}.interactions`,
6777
6803
  baseURL,
6778
6804
  headers: getHeaders,
6779
- generateId: (_a2 = options.generateId) != null ? _a2 : import_provider_utils24.generateId,
6805
+ generateId: (_a3 = options.generateId) != null ? _a3 : import_provider_utils24.generateId,
6780
6806
  fetch: options.fetch
6781
6807
  }
6782
6808
  );