@ai-sdk/google 3.0.127 → 3.0.128

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.
@@ -29,7 +29,7 @@ __export(index_exports, {
29
29
  module.exports = __toCommonJS(index_exports);
30
30
 
31
31
  // src/google-generative-ai-language-model.ts
32
- var import_provider_utils4 = require("@ai-sdk/provider-utils");
32
+ var import_provider_utils5 = require("@ai-sdk/provider-utils");
33
33
  var import_v43 = require("zod/v4");
34
34
 
35
35
  // src/convert-google-generative-ai-usage.ts
@@ -372,19 +372,28 @@ function parseBase64DataUrl(value) {
372
372
  data: match[2]
373
373
  };
374
374
  }
375
- function convertUrlToolResultPart(url) {
375
+ function convertUrlToolResultPart(url, mediaType, supportedFunctionResponseUrls) {
376
376
  const parsedDataUrl = parseBase64DataUrl(url);
377
- if (parsedDataUrl == null) {
378
- return void 0;
377
+ if (parsedDataUrl != null) {
378
+ return {
379
+ inlineData: {
380
+ mimeType: parsedDataUrl.mediaType,
381
+ data: parsedDataUrl.data
382
+ }
383
+ };
379
384
  }
380
- return {
381
- inlineData: {
382
- mimeType: parsedDataUrl.mediaType,
383
- data: parsedDataUrl.data
385
+ return mediaType != null && (0, import_provider_utils.isUrlSupported)({
386
+ url,
387
+ mediaType,
388
+ supportedUrls: supportedFunctionResponseUrls
389
+ }) ? {
390
+ fileData: {
391
+ mimeType: mediaType,
392
+ fileUri: url
384
393
  }
385
- };
394
+ } : void 0;
386
395
  }
387
- function appendToolResultParts(parts, toolName, outputValue, toolCallId, includeFunctionCallIds = true) {
396
+ function appendToolResultParts(parts, toolName, outputValue, toolCallId, includeFunctionCallIds = true, supportedFunctionResponseUrls = {}) {
388
397
  const functionResponseParts = [];
389
398
  const responseTextParts = [];
390
399
  for (const contentPart of outputValue) {
@@ -406,7 +415,9 @@ function appendToolResultParts(parts, toolName, outputValue, toolCallId, include
406
415
  case "image-url":
407
416
  case "file-url": {
408
417
  const functionResponsePart = convertUrlToolResultPart(
409
- contentPart.url
418
+ contentPart.url,
419
+ contentPart.mediaType,
420
+ supportedFunctionResponseUrls
410
421
  );
411
422
  if (functionResponsePart != null) {
412
423
  functionResponseParts.push(functionResponsePart);
@@ -471,7 +482,7 @@ function appendLegacyToolResultParts(parts, toolName, outputValue, toolCallId, i
471
482
  }
472
483
  }
473
484
  function convertToGoogleGenerativeAIMessages(prompt, options) {
474
- var _a, _b, _c, _d, _e, _f;
485
+ var _a, _b, _c, _d, _e, _f, _g;
475
486
  const systemInstructionParts = [];
476
487
  const contents = [];
477
488
  let systemMessagesAllowed = true;
@@ -481,6 +492,7 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
481
492
  const supportsFunctionResponseParts = (_d = options == null ? void 0 : options.supportsFunctionResponseParts) != null ? _d : true;
482
493
  const onWarning = options == null ? void 0 : options.onWarning;
483
494
  const includeFunctionCallIds = (_e = options == null ? void 0 : options.includeFunctionCallIds) != null ? _e : true;
495
+ const supportedFunctionResponseUrls = (_f = options == null ? void 0 : options.supportedFunctionResponseUrls) != null ? _f : {};
484
496
  let sentinelInjected = false;
485
497
  const missingSignatureToolNames = [];
486
498
  const injectSkipSignature = (toolName) => {
@@ -662,7 +674,8 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
662
674
  part.toolName,
663
675
  output.value,
664
676
  part.toolCallId,
665
- includeFunctionCallIds
677
+ includeFunctionCallIds,
678
+ supportedFunctionResponseUrls
666
679
  );
667
680
  } else {
668
681
  appendLegacyToolResultParts(
@@ -680,7 +693,7 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
680
693
  name: part.toolName,
681
694
  response: {
682
695
  name: part.toolName,
683
- content: output.type === "execution-denied" ? (_f = output.reason) != null ? _f : "Tool call execution denied." : output.value
696
+ content: output.type === "execution-denied" ? (_g = output.reason) != null ? _g : "Tool call execution denied." : output.value
684
697
  }
685
698
  }
686
699
  });
@@ -711,16 +724,82 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
711
724
  };
712
725
  }
713
726
 
727
+ // src/download-tool-result-files.ts
728
+ var import_provider_utils2 = require("@ai-sdk/provider-utils");
729
+ async function downloadToolResultFiles(prompt, {
730
+ abortSignal,
731
+ supportedUrls = {}
732
+ }) {
733
+ async function downloadOutput(output) {
734
+ if (output.type !== "content") {
735
+ return output;
736
+ }
737
+ return {
738
+ ...output,
739
+ value: await Promise.all(
740
+ output.value.map(async (part) => {
741
+ var _a;
742
+ if (part.type !== "file-url" && part.type !== "image-url") {
743
+ return part;
744
+ }
745
+ if (part.type === "file-url" && part.mediaType != null && (0, import_provider_utils2.isUrlSupported)({
746
+ url: part.url,
747
+ mediaType: part.mediaType,
748
+ supportedUrls
749
+ })) {
750
+ return part;
751
+ }
752
+ const blob = await (0, import_provider_utils2.downloadBlob)(part.url, { abortSignal });
753
+ return {
754
+ type: part.type === "file-url" ? "file-data" : "image-data",
755
+ data: (0, import_provider_utils2.convertUint8ArrayToBase64)(
756
+ new Uint8Array(await blob.arrayBuffer())
757
+ ),
758
+ mediaType: blob.type || (part.type === "file-url" ? (_a = part.mediaType) != null ? _a : "application/octet-stream" : "image/*"),
759
+ providerOptions: part.providerOptions
760
+ };
761
+ })
762
+ )
763
+ };
764
+ }
765
+ return Promise.all(
766
+ prompt.map(async (message) => {
767
+ switch (message.role) {
768
+ case "assistant":
769
+ return {
770
+ ...message,
771
+ content: await Promise.all(
772
+ message.content.map(
773
+ async (part) => part.type === "tool-result" ? { ...part, output: await downloadOutput(part.output) } : part
774
+ )
775
+ )
776
+ };
777
+ case "tool":
778
+ return {
779
+ ...message,
780
+ content: await Promise.all(
781
+ message.content.map(
782
+ async (part) => part.type === "tool-result" ? { ...part, output: await downloadOutput(part.output) } : part
783
+ )
784
+ )
785
+ };
786
+ default:
787
+ return message;
788
+ }
789
+ })
790
+ );
791
+ }
792
+
714
793
  // src/get-model-path.ts
715
794
  function getModelPath(modelId) {
716
795
  return modelId.includes("/") ? modelId : `models/${modelId}`;
717
796
  }
718
797
 
719
798
  // src/google-error.ts
720
- var import_provider_utils2 = require("@ai-sdk/provider-utils");
799
+ var import_provider_utils3 = require("@ai-sdk/provider-utils");
721
800
  var import_v4 = require("zod/v4");
722
- var googleErrorDataSchema = (0, import_provider_utils2.lazySchema)(
723
- () => (0, import_provider_utils2.zodSchema)(
801
+ var googleErrorDataSchema = (0, import_provider_utils3.lazySchema)(
802
+ () => (0, import_provider_utils3.zodSchema)(
724
803
  import_v4.z.object({
725
804
  error: import_v4.z.object({
726
805
  code: import_v4.z.number().nullable(),
@@ -731,16 +810,16 @@ var googleErrorDataSchema = (0, import_provider_utils2.lazySchema)(
731
810
  })
732
811
  )
733
812
  );
734
- var googleFailedResponseHandler = (0, import_provider_utils2.createJsonErrorResponseHandler)({
813
+ var googleFailedResponseHandler = (0, import_provider_utils3.createJsonErrorResponseHandler)({
735
814
  errorSchema: googleErrorDataSchema,
736
815
  errorToMessage: (data) => data.error.message
737
816
  });
738
817
 
739
818
  // src/google-generative-ai-options.ts
740
- var import_provider_utils3 = require("@ai-sdk/provider-utils");
819
+ var import_provider_utils4 = require("@ai-sdk/provider-utils");
741
820
  var import_v42 = require("zod/v4");
742
- var googleLanguageModelOptions = (0, import_provider_utils3.lazySchema)(
743
- () => (0, import_provider_utils3.zodSchema)(
821
+ var googleLanguageModelOptions = (0, import_provider_utils4.lazySchema)(
822
+ () => (0, import_provider_utils4.zodSchema)(
744
823
  import_v42.z.object({
745
824
  responseModalities: import_v42.z.array(import_v42.z.enum(["TEXT", "IMAGE"])).optional(),
746
825
  thinkingConfig: import_v42.z.object({
@@ -1474,13 +1553,20 @@ var configurableSafetySettingCategories = [
1474
1553
  "HARM_CATEGORY_SEXUALLY_EXPLICIT"
1475
1554
  ];
1476
1555
  var gemini25ModelPattern2 = /(^|\/)gemini-2\.5(?:[.-]|$)/i;
1556
+ var googleCloudStorageFunctionResponseUrls = {
1557
+ "image/png": [/^gs:\/\/.*$/],
1558
+ "image/jpeg": [/^gs:\/\/.*$/],
1559
+ "image/webp": [/^gs:\/\/.*$/],
1560
+ "application/pdf": [/^gs:\/\/.*$/],
1561
+ "text/plain": [/^gs:\/\/.*$/]
1562
+ };
1477
1563
  var GoogleGenerativeAILanguageModel = class {
1478
1564
  constructor(modelId, config) {
1479
1565
  this.specificationVersion = "v3";
1480
1566
  var _a;
1481
1567
  this.modelId = modelId;
1482
1568
  this.config = config;
1483
- this.generateId = (_a = config.generateId) != null ? _a : import_provider_utils4.generateId;
1569
+ this.generateId = (_a = config.generateId) != null ? _a : import_provider_utils5.generateId;
1484
1570
  }
1485
1571
  get provider() {
1486
1572
  return this.config.provider;
@@ -1502,18 +1588,19 @@ var GoogleGenerativeAILanguageModel = class {
1502
1588
  seed,
1503
1589
  tools,
1504
1590
  toolChoice,
1505
- providerOptions
1591
+ providerOptions,
1592
+ abortSignal
1506
1593
  }, { isStreaming = false } = {}) {
1507
1594
  var _a, _b, _c;
1508
1595
  const warnings = [];
1509
1596
  const providerOptionsName = this.config.provider.includes("vertex") ? "vertex" : "google";
1510
- let googleOptions = await (0, import_provider_utils4.parseProviderOptions)({
1597
+ let googleOptions = await (0, import_provider_utils5.parseProviderOptions)({
1511
1598
  provider: providerOptionsName,
1512
1599
  providerOptions,
1513
1600
  schema: googleLanguageModelOptions
1514
1601
  });
1515
1602
  if (googleOptions == null && providerOptionsName !== "google") {
1516
- googleOptions = await (0, import_provider_utils4.parseProviderOptions)({
1603
+ googleOptions = await (0, import_provider_utils5.parseProviderOptions)({
1517
1604
  provider: "google",
1518
1605
  providerOptions,
1519
1606
  schema: googleLanguageModelOptions
@@ -1591,15 +1678,21 @@ var GoogleGenerativeAILanguageModel = class {
1591
1678
  });
1592
1679
  }
1593
1680
  const { usesGemini3Features } = getGoogleModelCapabilities(this.modelId);
1681
+ const supportedFunctionResponseUrls = usesGemini3Features && isVertexProvider ? googleCloudStorageFunctionResponseUrls : void 0;
1682
+ const promptWithDownloadedToolResultFiles = isVertexProvider ? await downloadToolResultFiles(prompt, {
1683
+ abortSignal,
1684
+ supportedUrls: supportedFunctionResponseUrls
1685
+ }) : prompt;
1594
1686
  const { contents, systemInstruction } = convertToGoogleGenerativeAIMessages(
1595
- prompt,
1687
+ promptWithDownloadedToolResultFiles,
1596
1688
  {
1597
1689
  isGemmaModel,
1598
1690
  isGemini3Model: usesGemini3Features,
1599
1691
  providerOptionsName,
1600
1692
  supportsFunctionResponseParts: usesGemini3Features,
1601
1693
  onWarning: (warning) => warnings.push(warning),
1602
- includeFunctionCallIds: !isVertexProvider
1694
+ includeFunctionCallIds: !isVertexProvider,
1695
+ supportedFunctionResponseUrls
1603
1696
  }
1604
1697
  );
1605
1698
  const {
@@ -1676,8 +1769,8 @@ var GoogleGenerativeAILanguageModel = class {
1676
1769
  async doGenerate(options) {
1677
1770
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
1678
1771
  const { args, warnings, providerOptionsName, extraHeaders } = await this.getArgs(options);
1679
- const mergedHeaders = (0, import_provider_utils4.combineHeaders)(
1680
- await (0, import_provider_utils4.resolve)(this.config.headers),
1772
+ const mergedHeaders = (0, import_provider_utils5.combineHeaders)(
1773
+ await (0, import_provider_utils5.resolve)(this.config.headers),
1681
1774
  options.headers,
1682
1775
  extraHeaders
1683
1776
  );
@@ -1685,14 +1778,14 @@ var GoogleGenerativeAILanguageModel = class {
1685
1778
  responseHeaders,
1686
1779
  value: response,
1687
1780
  rawValue: rawResponse
1688
- } = await (0, import_provider_utils4.postJsonToApi)({
1781
+ } = await (0, import_provider_utils5.postJsonToApi)({
1689
1782
  url: `${this.config.baseURL}/${getModelPath(
1690
1783
  this.modelId
1691
1784
  )}:generateContent`,
1692
1785
  headers: mergedHeaders,
1693
1786
  body: args,
1694
1787
  failedResponseHandler: googleFailedResponseHandler,
1695
- successfulResponseHandler: (0, import_provider_utils4.createJsonResponseHandler)(responseSchema),
1788
+ successfulResponseHandler: (0, import_provider_utils5.createJsonResponseHandler)(responseSchema),
1696
1789
  abortSignal: options.abortSignal,
1697
1790
  fetch: this.config.fetch
1698
1791
  });
@@ -1863,19 +1956,19 @@ var GoogleGenerativeAILanguageModel = class {
1863
1956
  }
1864
1957
  async doStream(options) {
1865
1958
  const { args, warnings, providerOptionsName, extraHeaders } = await this.getArgs(options, { isStreaming: true });
1866
- const headers = (0, import_provider_utils4.combineHeaders)(
1867
- await (0, import_provider_utils4.resolve)(this.config.headers),
1959
+ const headers = (0, import_provider_utils5.combineHeaders)(
1960
+ await (0, import_provider_utils5.resolve)(this.config.headers),
1868
1961
  options.headers,
1869
1962
  extraHeaders
1870
1963
  );
1871
- const { responseHeaders, value: response } = await (0, import_provider_utils4.postJsonToApi)({
1964
+ const { responseHeaders, value: response } = await (0, import_provider_utils5.postJsonToApi)({
1872
1965
  url: `${this.config.baseURL}/${getModelPath(
1873
1966
  this.modelId
1874
1967
  )}:streamGenerateContent?alt=sse`,
1875
1968
  headers,
1876
1969
  body: args,
1877
1970
  failedResponseHandler: googleFailedResponseHandler,
1878
- successfulResponseHandler: (0, import_provider_utils4.createEventSourceResponseHandler)(chunkSchema),
1971
+ successfulResponseHandler: (0, import_provider_utils5.createEventSourceResponseHandler)(chunkSchema),
1879
1972
  abortSignal: options.abortSignal,
1880
1973
  fetch: this.config.fetch
1881
1974
  });
@@ -2554,8 +2647,8 @@ var getUrlContextMetadataSchema = () => import_v43.z.object({
2554
2647
  })
2555
2648
  ).nullish()
2556
2649
  });
2557
- var responseSchema = (0, import_provider_utils4.lazySchema)(
2558
- () => (0, import_provider_utils4.zodSchema)(
2650
+ var responseSchema = (0, import_provider_utils5.lazySchema)(
2651
+ () => (0, import_provider_utils5.zodSchema)(
2559
2652
  import_v43.z.object({
2560
2653
  responseId: import_v43.z.string().nullish(),
2561
2654
  candidates: import_v43.z.array(
@@ -2576,8 +2669,8 @@ var responseSchema = (0, import_provider_utils4.lazySchema)(
2576
2669
  })
2577
2670
  )
2578
2671
  );
2579
- var chunkSchema = (0, import_provider_utils4.lazySchema)(
2580
- () => (0, import_provider_utils4.zodSchema)(
2672
+ var chunkSchema = (0, import_provider_utils5.lazySchema)(
2673
+ () => (0, import_provider_utils5.zodSchema)(
2581
2674
  import_v43.z.object({
2582
2675
  responseId: import_v43.z.string().nullish(),
2583
2676
  candidates: import_v43.z.array(
@@ -2603,9 +2696,9 @@ function isConfirmedPromptBlockReason(blockReason) {
2603
2696
  }
2604
2697
 
2605
2698
  // src/tool/code-execution.ts
2606
- var import_provider_utils5 = require("@ai-sdk/provider-utils");
2699
+ var import_provider_utils6 = require("@ai-sdk/provider-utils");
2607
2700
  var import_v44 = require("zod/v4");
2608
- var codeExecution = (0, import_provider_utils5.createProviderToolFactoryWithOutputSchema)({
2701
+ var codeExecution = (0, import_provider_utils6.createProviderToolFactoryWithOutputSchema)({
2609
2702
  id: "google.code_execution",
2610
2703
  inputSchema: import_v44.z.object({
2611
2704
  language: import_v44.z.string().describe("The programming language of the code."),
@@ -2618,15 +2711,15 @@ var codeExecution = (0, import_provider_utils5.createProviderToolFactoryWithOutp
2618
2711
  });
2619
2712
 
2620
2713
  // src/tool/enterprise-web-search.ts
2621
- var import_provider_utils6 = require("@ai-sdk/provider-utils");
2714
+ var import_provider_utils7 = require("@ai-sdk/provider-utils");
2622
2715
  var import_v45 = require("zod/v4");
2623
- var enterpriseWebSearch = (0, import_provider_utils6.createProviderToolFactory)({
2716
+ var enterpriseWebSearch = (0, import_provider_utils7.createProviderToolFactory)({
2624
2717
  id: "google.enterprise_web_search",
2625
- inputSchema: (0, import_provider_utils6.lazySchema)(() => (0, import_provider_utils6.zodSchema)(import_v45.z.object({})))
2718
+ inputSchema: (0, import_provider_utils7.lazySchema)(() => (0, import_provider_utils7.zodSchema)(import_v45.z.object({})))
2626
2719
  });
2627
2720
 
2628
2721
  // src/tool/file-search.ts
2629
- var import_provider_utils7 = require("@ai-sdk/provider-utils");
2722
+ var import_provider_utils8 = require("@ai-sdk/provider-utils");
2630
2723
  var import_v46 = require("zod/v4");
2631
2724
  var fileSearchArgsBaseSchema = import_v46.z.object({
2632
2725
  /** The names of the file_search_stores to retrieve from.
@@ -2644,24 +2737,24 @@ var fileSearchArgsBaseSchema = import_v46.z.object({
2644
2737
  "Metadata filter to apply to the file search retrieval documents. See https://google.aip.dev/160 for the syntax of the filter expression."
2645
2738
  ).optional()
2646
2739
  }).passthrough();
2647
- var fileSearchArgsSchema = (0, import_provider_utils7.lazySchema)(
2648
- () => (0, import_provider_utils7.zodSchema)(fileSearchArgsBaseSchema)
2740
+ var fileSearchArgsSchema = (0, import_provider_utils8.lazySchema)(
2741
+ () => (0, import_provider_utils8.zodSchema)(fileSearchArgsBaseSchema)
2649
2742
  );
2650
- var fileSearch = (0, import_provider_utils7.createProviderToolFactory)({
2743
+ var fileSearch = (0, import_provider_utils8.createProviderToolFactory)({
2651
2744
  id: "google.file_search",
2652
2745
  inputSchema: fileSearchArgsSchema
2653
2746
  });
2654
2747
 
2655
2748
  // src/tool/google-maps.ts
2656
- var import_provider_utils8 = require("@ai-sdk/provider-utils");
2749
+ var import_provider_utils9 = require("@ai-sdk/provider-utils");
2657
2750
  var import_v47 = require("zod/v4");
2658
- var googleMaps = (0, import_provider_utils8.createProviderToolFactory)({
2751
+ var googleMaps = (0, import_provider_utils9.createProviderToolFactory)({
2659
2752
  id: "google.google_maps",
2660
- inputSchema: (0, import_provider_utils8.lazySchema)(() => (0, import_provider_utils8.zodSchema)(import_v47.z.object({})))
2753
+ inputSchema: (0, import_provider_utils9.lazySchema)(() => (0, import_provider_utils9.zodSchema)(import_v47.z.object({})))
2661
2754
  });
2662
2755
 
2663
2756
  // src/tool/google-search.ts
2664
- var import_provider_utils9 = require("@ai-sdk/provider-utils");
2757
+ var import_provider_utils10 = require("@ai-sdk/provider-utils");
2665
2758
  var import_v48 = require("zod/v4");
2666
2759
  var googleSearchToolArgsBaseSchema = import_v48.z.object({
2667
2760
  searchTypes: import_v48.z.object({
@@ -2673,10 +2766,10 @@ var googleSearchToolArgsBaseSchema = import_v48.z.object({
2673
2766
  endTime: import_v48.z.string()
2674
2767
  }).optional()
2675
2768
  }).passthrough();
2676
- var googleSearchToolArgsSchema = (0, import_provider_utils9.lazySchema)(
2677
- () => (0, import_provider_utils9.zodSchema)(googleSearchToolArgsBaseSchema)
2769
+ var googleSearchToolArgsSchema = (0, import_provider_utils10.lazySchema)(
2770
+ () => (0, import_provider_utils10.zodSchema)(googleSearchToolArgsBaseSchema)
2678
2771
  );
2679
- var googleSearch = (0, import_provider_utils9.createProviderToolFactory)(
2772
+ var googleSearch = (0, import_provider_utils10.createProviderToolFactory)(
2680
2773
  {
2681
2774
  id: "google.google_search",
2682
2775
  inputSchema: googleSearchToolArgsSchema
@@ -2684,17 +2777,17 @@ var googleSearch = (0, import_provider_utils9.createProviderToolFactory)(
2684
2777
  );
2685
2778
 
2686
2779
  // src/tool/url-context.ts
2687
- var import_provider_utils10 = require("@ai-sdk/provider-utils");
2780
+ var import_provider_utils11 = require("@ai-sdk/provider-utils");
2688
2781
  var import_v49 = require("zod/v4");
2689
- var urlContext = (0, import_provider_utils10.createProviderToolFactory)({
2782
+ var urlContext = (0, import_provider_utils11.createProviderToolFactory)({
2690
2783
  id: "google.url_context",
2691
- inputSchema: (0, import_provider_utils10.lazySchema)(() => (0, import_provider_utils10.zodSchema)(import_v49.z.object({})))
2784
+ inputSchema: (0, import_provider_utils11.lazySchema)(() => (0, import_provider_utils11.zodSchema)(import_v49.z.object({})))
2692
2785
  });
2693
2786
 
2694
2787
  // src/tool/vertex-rag-store.ts
2695
- var import_provider_utils11 = require("@ai-sdk/provider-utils");
2788
+ var import_provider_utils12 = require("@ai-sdk/provider-utils");
2696
2789
  var import_v410 = require("zod/v4");
2697
- var vertexRagStore = (0, import_provider_utils11.createProviderToolFactory)({
2790
+ var vertexRagStore = (0, import_provider_utils12.createProviderToolFactory)({
2698
2791
  id: "google.vertex_rag_store",
2699
2792
  inputSchema: import_v410.z.object({
2700
2793
  ragCorpus: import_v410.z.string(),
@@ -2763,7 +2856,7 @@ var googleTools = {
2763
2856
  };
2764
2857
 
2765
2858
  // src/interactions/google-interactions-language-model.ts
2766
- var import_provider_utils18 = require("@ai-sdk/provider-utils");
2859
+ var import_provider_utils19 = require("@ai-sdk/provider-utils");
2767
2860
 
2768
2861
  // src/interactions/convert-google-interactions-usage.ts
2769
2862
  function convertGoogleInteractionsUsage(usage) {
@@ -3529,7 +3622,7 @@ function buildGoogleInteractionsStreamTransform({
3529
3622
  }
3530
3623
 
3531
3624
  // src/interactions/convert-to-google-interactions-input.ts
3532
- var import_provider_utils12 = require("@ai-sdk/provider-utils");
3625
+ var import_provider_utils13 = require("@ai-sdk/provider-utils");
3533
3626
  function getTopLevelMediaType(mediaType) {
3534
3627
  const slashIndex = mediaType.indexOf("/");
3535
3628
  return slashIndex === -1 ? mediaType : mediaType.substring(0, slashIndex);
@@ -3718,7 +3811,7 @@ function convertFilePartToContent({
3718
3811
  }
3719
3812
  return {
3720
3813
  type: kind,
3721
- data: (0, import_provider_utils12.convertToBase64)(part.data),
3814
+ data: (0, import_provider_utils13.convertToBase64)(part.data),
3722
3815
  mime_type: part.mediaType,
3723
3816
  ...resolutionField
3724
3817
  };
@@ -3769,7 +3862,7 @@ function compactPromptForPreviousInteraction({
3769
3862
  }
3770
3863
  function safeParseToolArgs(input) {
3771
3864
  try {
3772
- const parsed = (0, import_provider_utils12.secureJsonParse)(input);
3865
+ const parsed = (0, import_provider_utils13.secureJsonParse)(input);
3773
3866
  if (parsed != null && typeof parsed === "object" && !Array.isArray(parsed)) {
3774
3867
  return parsed;
3775
3868
  }
@@ -3892,7 +3985,7 @@ function filePartToImageBlock({
3892
3985
  }
3893
3986
  return {
3894
3987
  type: "image",
3895
- data: (0, import_provider_utils12.convertToBase64)(part.data),
3988
+ data: (0, import_provider_utils13.convertToBase64)(part.data),
3896
3989
  mime_type: part.mediaType
3897
3990
  };
3898
3991
  }
@@ -3919,7 +4012,7 @@ ${block.text}`
3919
4012
  }
3920
4013
 
3921
4014
  // src/interactions/google-interactions-api.ts
3922
- var import_provider_utils13 = require("@ai-sdk/provider-utils");
4015
+ var import_provider_utils14 = require("@ai-sdk/provider-utils");
3923
4016
  var import_v411 = require("zod/v4");
3924
4017
  var tokenByModalitySchema = () => import_v411.z.object({
3925
4018
  modality: import_v411.z.string().nullish(),
@@ -4082,8 +4175,8 @@ var stepSchema = () => {
4082
4175
  import_v411.z.object({ type: import_v411.z.string() }).loose()
4083
4176
  ]);
4084
4177
  };
4085
- var googleInteractionsResponseSchema = (0, import_provider_utils13.lazySchema)(
4086
- () => (0, import_provider_utils13.zodSchema)(
4178
+ var googleInteractionsResponseSchema = (0, import_provider_utils14.lazySchema)(
4179
+ () => (0, import_provider_utils14.zodSchema)(
4087
4180
  import_v411.z.object({
4088
4181
  /*
4089
4182
  * `id` is omitted from the response body when `store: false` (fully
@@ -4104,8 +4197,8 @@ var googleInteractionsResponseSchema = (0, import_provider_utils13.lazySchema)(
4104
4197
  }).loose()
4105
4198
  )
4106
4199
  );
4107
- var googleInteractionsEventSchema = (0, import_provider_utils13.lazySchema)(
4108
- () => (0, import_provider_utils13.zodSchema)(
4200
+ var googleInteractionsEventSchema = (0, import_provider_utils14.lazySchema)(
4201
+ () => (0, import_provider_utils14.zodSchema)(
4109
4202
  (() => {
4110
4203
  const status = interactionStatusSchema();
4111
4204
  const annotation = annotationSchema();
@@ -4262,10 +4355,10 @@ var googleInteractionsEventSchema = (0, import_provider_utils13.lazySchema)(
4262
4355
  );
4263
4356
 
4264
4357
  // src/interactions/google-interactions-language-model-options.ts
4265
- var import_provider_utils14 = require("@ai-sdk/provider-utils");
4358
+ var import_provider_utils15 = require("@ai-sdk/provider-utils");
4266
4359
  var import_v412 = require("zod/v4");
4267
- var googleInteractionsLanguageModelOptions = (0, import_provider_utils14.lazySchema)(
4268
- () => (0, import_provider_utils14.zodSchema)(
4360
+ var googleInteractionsLanguageModelOptions = (0, import_provider_utils15.lazySchema)(
4361
+ () => (0, import_provider_utils15.zodSchema)(
4269
4362
  import_v412.z.object({
4270
4363
  previousInteractionId: import_v412.z.string().nullish(),
4271
4364
  store: import_v412.z.boolean().nullish(),
@@ -4632,10 +4725,10 @@ function parseGoogleInteractionsOutputs({
4632
4725
  }
4633
4726
 
4634
4727
  // src/interactions/poll-google-interactions.ts
4635
- var import_provider_utils16 = require("@ai-sdk/provider-utils");
4728
+ var import_provider_utils17 = require("@ai-sdk/provider-utils");
4636
4729
 
4637
4730
  // src/interactions/cancel-google-interaction.ts
4638
- var import_provider_utils15 = require("@ai-sdk/provider-utils");
4731
+ var import_provider_utils16 = require("@ai-sdk/provider-utils");
4639
4732
  var getOriginalFetch = () => globalThis.fetch;
4640
4733
  async function cancelGoogleInteraction({
4641
4734
  baseURL,
@@ -4650,9 +4743,9 @@ async function cancelGoogleInteraction({
4650
4743
  try {
4651
4744
  const response = await fetch(url, {
4652
4745
  method: "POST",
4653
- headers: (0, import_provider_utils15.withUserAgentSuffix)(
4654
- (0, import_provider_utils15.combineHeaders)({ "Content-Type": "application/json" }, headers),
4655
- (0, import_provider_utils15.getRuntimeEnvironmentUserAgent)()
4746
+ headers: (0, import_provider_utils16.withUserAgentSuffix)(
4747
+ (0, import_provider_utils16.combineHeaders)({ "Content-Type": "application/json" }, headers),
4748
+ (0, import_provider_utils16.getRuntimeEnvironmentUserAgent)()
4656
4749
  ),
4657
4750
  body: "{}"
4658
4751
  });
@@ -4702,16 +4795,16 @@ async function pollGoogleInteractionUntilTerminal({
4702
4795
  `google.interactions: timed out polling interaction ${interactionId} after ${timeoutMs}ms.`
4703
4796
  );
4704
4797
  }
4705
- await (0, import_provider_utils16.delay)(nextDelayMs, { abortSignal });
4798
+ await (0, import_provider_utils17.delay)(nextDelayMs, { abortSignal });
4706
4799
  const {
4707
4800
  value: response,
4708
4801
  rawValue: rawResponse,
4709
4802
  responseHeaders
4710
- } = await (0, import_provider_utils16.getFromApi)({
4803
+ } = await (0, import_provider_utils17.getFromApi)({
4711
4804
  url,
4712
4805
  headers,
4713
4806
  failedResponseHandler: googleFailedResponseHandler,
4714
- successfulResponseHandler: (0, import_provider_utils16.createJsonResponseHandler)(
4807
+ successfulResponseHandler: (0, import_provider_utils17.createJsonResponseHandler)(
4715
4808
  googleInteractionsResponseSchema
4716
4809
  ),
4717
4810
  abortSignal,
@@ -4723,7 +4816,7 @@ async function pollGoogleInteractionUntilTerminal({
4723
4816
  nextDelayMs = Math.min(nextDelayMs * 2, maxDelayMs);
4724
4817
  }
4725
4818
  } catch (error) {
4726
- if ((0, import_provider_utils16.isAbortError)(error)) {
4819
+ if ((0, import_provider_utils17.isAbortError)(error)) {
4727
4820
  await cancelOnServer();
4728
4821
  }
4729
4822
  throw error;
@@ -4879,7 +4972,7 @@ function prepareGoogleInteractionsTools({
4879
4972
  }
4880
4973
 
4881
4974
  // src/interactions/stream-google-interactions.ts
4882
- var import_provider_utils17 = require("@ai-sdk/provider-utils");
4975
+ var import_provider_utils18 = require("@ai-sdk/provider-utils");
4883
4976
  var DEFAULT_MAX_RETRIES = 3;
4884
4977
  var DEFAULT_RETRY_DELAY_MS = 500;
4885
4978
  function streamGoogleInteractionEvents({
@@ -4926,11 +5019,11 @@ function streamGoogleInteractionEvents({
4926
5019
  return `${base}?${params.toString()}`;
4927
5020
  }
4928
5021
  async function openReader() {
4929
- const { value: stream } = await (0, import_provider_utils17.getFromApi)({
5022
+ const { value: stream } = await (0, import_provider_utils18.getFromApi)({
4930
5023
  url: buildUrl(),
4931
5024
  headers: eventSourceHeaders,
4932
5025
  failedResponseHandler: googleFailedResponseHandler,
4933
- successfulResponseHandler: (0, import_provider_utils17.createEventSourceResponseHandler)(
5026
+ successfulResponseHandler: (0, import_provider_utils18.createEventSourceResponseHandler)(
4934
5027
  googleInteractionsEventSchema
4935
5028
  ),
4936
5029
  abortSignal: effectiveSignal,
@@ -4947,7 +5040,7 @@ function streamGoogleInteractionEvents({
4947
5040
  currentReader = await openReader();
4948
5041
  receivedAnyEventThisAttempt = false;
4949
5042
  } catch (error) {
4950
- if ((0, import_provider_utils17.isAbortError)(error) || effectiveSignal.aborted) {
5043
+ if ((0, import_provider_utils18.isAbortError)(error) || effectiveSignal.aborted) {
4951
5044
  controller.error(error);
4952
5045
  return;
4953
5046
  }
@@ -4956,7 +5049,7 @@ function streamGoogleInteractionEvents({
4956
5049
  controller.error(error);
4957
5050
  return;
4958
5051
  }
4959
- await (0, import_provider_utils17.delay)(retryDelayMs * attempt, {
5052
+ await (0, import_provider_utils18.delay)(retryDelayMs * attempt, {
4960
5053
  abortSignal: effectiveSignal
4961
5054
  });
4962
5055
  continue;
@@ -4977,7 +5070,7 @@ function streamGoogleInteractionEvents({
4977
5070
  );
4978
5071
  return;
4979
5072
  }
4980
- await (0, import_provider_utils17.delay)(retryDelayMs * attempt, {
5073
+ await (0, import_provider_utils18.delay)(retryDelayMs * attempt, {
4981
5074
  abortSignal: effectiveSignal
4982
5075
  });
4983
5076
  } else {
@@ -4997,7 +5090,7 @@ function streamGoogleInteractionEvents({
4997
5090
  }
4998
5091
  controller.enqueue(value);
4999
5092
  } catch (error) {
5000
- if ((0, import_provider_utils17.isAbortError)(error) || effectiveSignal.aborted) {
5093
+ if ((0, import_provider_utils18.isAbortError)(error) || effectiveSignal.aborted) {
5001
5094
  controller.error(error);
5002
5095
  return;
5003
5096
  }
@@ -5007,7 +5100,7 @@ function streamGoogleInteractionEvents({
5007
5100
  controller.error(error);
5008
5101
  return;
5009
5102
  }
5010
- await (0, import_provider_utils17.delay)(retryDelayMs * attempt, {
5103
+ await (0, import_provider_utils18.delay)(retryDelayMs * attempt, {
5011
5104
  abortSignal: effectiveSignal
5012
5105
  });
5013
5106
  }
@@ -5219,7 +5312,7 @@ var GoogleInteractionsLanguageModel = class {
5219
5312
  async getArgs(options) {
5220
5313
  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;
5221
5314
  const warnings = [];
5222
- const opts = await (0, import_provider_utils18.parseProviderOptions)({
5315
+ const opts = await (0, import_provider_utils19.parseProviderOptions)({
5223
5316
  provider: "google",
5224
5317
  providerOptions: options.providerOptions,
5225
5318
  schema: googleInteractionsLanguageModelOptions
@@ -5476,17 +5569,17 @@ var GoogleInteractionsLanguageModel = class {
5476
5569
  var _a, _b, _c, _d, _e, _f;
5477
5570
  const { args, warnings, isAgent, pollingTimeoutMs } = await this.getArgs(options);
5478
5571
  const url = `${this.config.baseURL}/interactions`;
5479
- const mergedHeaders = (0, import_provider_utils18.combineHeaders)(
5572
+ const mergedHeaders = (0, import_provider_utils19.combineHeaders)(
5480
5573
  INTERACTIONS_API_REVISION_HEADER,
5481
- this.config.headers ? await (0, import_provider_utils18.resolve)(this.config.headers) : void 0,
5574
+ this.config.headers ? await (0, import_provider_utils19.resolve)(this.config.headers) : void 0,
5482
5575
  options.headers
5483
5576
  );
5484
- const postResult = await (0, import_provider_utils18.postJsonToApi)({
5577
+ const postResult = await (0, import_provider_utils19.postJsonToApi)({
5485
5578
  url,
5486
5579
  headers: mergedHeaders,
5487
5580
  body: args,
5488
5581
  failedResponseHandler: googleFailedResponseHandler,
5489
- successfulResponseHandler: (0, import_provider_utils18.createJsonResponseHandler)(
5582
+ successfulResponseHandler: (0, import_provider_utils19.createJsonResponseHandler)(
5490
5583
  googleInteractionsResponseSchema
5491
5584
  ),
5492
5585
  abortSignal: options.abortSignal,
@@ -5513,7 +5606,7 @@ var GoogleInteractionsLanguageModel = class {
5513
5606
  const interactionId = typeof response.id === "string" && response.id.length > 0 ? response.id : void 0;
5514
5607
  const { content, hasFunctionCall } = parseGoogleInteractionsOutputs({
5515
5608
  steps: (_b = response.steps) != null ? _b : null,
5516
- generateId: (_c = this.config.generateId) != null ? _c : import_provider_utils18.generateId,
5609
+ generateId: (_c = this.config.generateId) != null ? _c : import_provider_utils19.generateId,
5517
5610
  interactionId
5518
5611
  });
5519
5612
  const finishReason = {
@@ -5561,9 +5654,9 @@ var GoogleInteractionsLanguageModel = class {
5561
5654
  var _a;
5562
5655
  const { args, warnings, isBackground, pollingTimeoutMs } = await this.getArgs(options);
5563
5656
  const url = `${this.config.baseURL}/interactions`;
5564
- const mergedHeaders = (0, import_provider_utils18.combineHeaders)(
5657
+ const mergedHeaders = (0, import_provider_utils19.combineHeaders)(
5565
5658
  INTERACTIONS_API_REVISION_HEADER,
5566
- this.config.headers ? await (0, import_provider_utils18.resolve)(this.config.headers) : void 0,
5659
+ this.config.headers ? await (0, import_provider_utils19.resolve)(this.config.headers) : void 0,
5567
5660
  options.headers
5568
5661
  );
5569
5662
  if (isBackground) {
@@ -5577,12 +5670,12 @@ var GoogleInteractionsLanguageModel = class {
5577
5670
  });
5578
5671
  }
5579
5672
  const body = { ...args, stream: true };
5580
- const { responseHeaders, value: response } = await (0, import_provider_utils18.postJsonToApi)({
5673
+ const { responseHeaders, value: response } = await (0, import_provider_utils19.postJsonToApi)({
5581
5674
  url,
5582
5675
  headers: mergedHeaders,
5583
5676
  body,
5584
5677
  failedResponseHandler: googleFailedResponseHandler,
5585
- successfulResponseHandler: (0, import_provider_utils18.createEventSourceResponseHandler)(
5678
+ successfulResponseHandler: (0, import_provider_utils19.createEventSourceResponseHandler)(
5586
5679
  googleInteractionsEventSchema
5587
5680
  ),
5588
5681
  abortSignal: options.abortSignal,
@@ -5591,7 +5684,7 @@ var GoogleInteractionsLanguageModel = class {
5591
5684
  const headerServiceTier = responseHeaders == null ? void 0 : responseHeaders["x-gemini-service-tier"];
5592
5685
  const transform = buildGoogleInteractionsStreamTransform({
5593
5686
  warnings,
5594
- generateId: (_a = this.config.generateId) != null ? _a : import_provider_utils18.generateId,
5687
+ generateId: (_a = this.config.generateId) != null ? _a : import_provider_utils19.generateId,
5595
5688
  includeRawChunks: options.includeRawChunks,
5596
5689
  serviceTier: headerServiceTier
5597
5690
  });
@@ -5628,12 +5721,12 @@ var GoogleInteractionsLanguageModel = class {
5628
5721
  pollingTimeoutMs
5629
5722
  }) {
5630
5723
  var _a, _b;
5631
- const postResult = await (0, import_provider_utils18.postJsonToApi)({
5724
+ const postResult = await (0, import_provider_utils19.postJsonToApi)({
5632
5725
  url,
5633
5726
  headers: mergedHeaders,
5634
5727
  body: args,
5635
5728
  failedResponseHandler: googleFailedResponseHandler,
5636
- successfulResponseHandler: (0, import_provider_utils18.createJsonResponseHandler)(
5729
+ successfulResponseHandler: (0, import_provider_utils19.createJsonResponseHandler)(
5637
5730
  googleInteractionsResponseSchema
5638
5731
  ),
5639
5732
  abortSignal: options.abortSignal,
@@ -5651,7 +5744,7 @@ var GoogleInteractionsLanguageModel = class {
5651
5744
  const synthesized = synthesizeGoogleInteractionsAgentStream({
5652
5745
  response: postResponse,
5653
5746
  warnings,
5654
- generateId: (_a = this.config.generateId) != null ? _a : import_provider_utils18.generateId,
5747
+ generateId: (_a = this.config.generateId) != null ? _a : import_provider_utils19.generateId,
5655
5748
  includeRawChunks: options.includeRawChunks,
5656
5749
  headerServiceTier
5657
5750
  });
@@ -5671,7 +5764,7 @@ var GoogleInteractionsLanguageModel = class {
5671
5764
  });
5672
5765
  const transform = buildGoogleInteractionsStreamTransform({
5673
5766
  warnings,
5674
- generateId: (_b = this.config.generateId) != null ? _b : import_provider_utils18.generateId,
5767
+ generateId: (_b = this.config.generateId) != null ? _b : import_provider_utils19.generateId,
5675
5768
  includeRawChunks: options.includeRawChunks,
5676
5769
  serviceTier: headerServiceTier
5677
5770
  });