@ai-sdk/google 2.0.0-beta.7 → 2.0.0-beta.8

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
@@ -27,7 +27,7 @@ module.exports = __toCommonJS(src_exports);
27
27
 
28
28
  // src/google-provider.ts
29
29
  var import_provider4 = require("@ai-sdk/provider");
30
- var import_provider_utils5 = require("@ai-sdk/provider-utils");
30
+ var import_provider_utils7 = require("@ai-sdk/provider-utils");
31
31
 
32
32
  // src/google-generative-ai-embedding-model.ts
33
33
  var import_provider = require("@ai-sdk/provider");
@@ -150,8 +150,8 @@ var googleGenerativeAITextEmbeddingResponseSchema = import_v43.z.object({
150
150
  });
151
151
 
152
152
  // src/google-generative-ai-language-model.ts
153
- var import_provider_utils4 = require("@ai-sdk/provider-utils");
154
- var import_v45 = require("zod/v4");
153
+ var import_provider_utils6 = require("@ai-sdk/provider-utils");
154
+ var import_v47 = require("zod/v4");
155
155
 
156
156
  // src/convert-json-schema-to-openapi-schema.ts
157
157
  function convertJSONSchemaToOpenAPISchema(jsonSchema) {
@@ -376,17 +376,6 @@ function getModelPath(modelId) {
376
376
 
377
377
  // src/google-generative-ai-options.ts
378
378
  var import_v44 = require("zod/v4");
379
- var dynamicRetrievalConfig = import_v44.z.object({
380
- /**
381
- * The mode of the predictor to be used in dynamic retrieval.
382
- */
383
- mode: import_v44.z.enum(["MODE_UNSPECIFIED", "MODE_DYNAMIC"]).optional(),
384
- /**
385
- * The threshold to be used in dynamic retrieval. If not set, a system default
386
- * value is used.
387
- */
388
- dynamicThreshold: import_v44.z.number().optional()
389
- });
390
379
  var googleGenerativeAIProviderOptions = import_v44.z.object({
391
380
  responseModalities: import_v44.z.array(import_v44.z.enum(["TEXT", "IMAGE"])).optional(),
392
381
  thinkingConfig: import_v44.z.object({
@@ -444,21 +433,7 @@ var googleGenerativeAIProviderOptions = import_v44.z.object({
444
433
  *
445
434
  * https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/audio-understanding
446
435
  */
447
- audioTimestamp: import_v44.z.boolean().optional(),
448
- /**
449
- Optional. When enabled, the model will use Google search to ground the response.
450
-
451
- @see https://cloud.google.com/vertex-ai/generative-ai/docs/grounding/overview
452
- */
453
- useSearchGrounding: import_v44.z.boolean().optional(),
454
- /**
455
- Optional. Specifies the dynamic retrieval configuration.
456
-
457
- @note Dynamic retrieval is only compatible with Gemini 1.5 Flash.
458
-
459
- @see https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/ground-with-google-search#dynamic-retrieval
460
- */
461
- dynamicRetrievalConfig: dynamicRetrievalConfig.optional()
436
+ audioTimestamp: import_v44.z.boolean().optional()
462
437
  });
463
438
 
464
439
  // src/google-prepare-tools.ts
@@ -466,8 +441,6 @@ var import_provider3 = require("@ai-sdk/provider");
466
441
  function prepareTools({
467
442
  tools,
468
443
  toolChoice,
469
- useSearchGrounding,
470
- dynamicRetrievalConfig: dynamicRetrievalConfig2,
471
444
  modelId
472
445
  }) {
473
446
  var _a;
@@ -475,28 +448,76 @@ function prepareTools({
475
448
  const toolWarnings = [];
476
449
  const isGemini2 = modelId.includes("gemini-2");
477
450
  const supportsDynamicRetrieval = modelId.includes("gemini-1.5-flash") && !modelId.includes("-8b");
478
- if (useSearchGrounding) {
451
+ if (tools == null) {
452
+ return { tools: void 0, toolConfig: void 0, toolWarnings };
453
+ }
454
+ const hasFunctionTools = tools.some((tool) => tool.type === "function");
455
+ const hasProviderDefinedTools = tools.some(
456
+ (tool) => tool.type === "provider-defined"
457
+ );
458
+ if (hasFunctionTools && hasProviderDefinedTools) {
459
+ toolWarnings.push({
460
+ type: "unsupported-tool",
461
+ tool: tools.find((tool) => tool.type === "function"),
462
+ details: "Cannot mix function tools with provider-defined tools in the same request. Please use either function tools or provider-defined tools, but not both."
463
+ });
464
+ }
465
+ if (hasProviderDefinedTools) {
466
+ const googleTools2 = {};
467
+ const providerDefinedTools = tools.filter(
468
+ (tool) => tool.type === "provider-defined"
469
+ );
470
+ providerDefinedTools.forEach((tool) => {
471
+ switch (tool.id) {
472
+ case "google.google_search":
473
+ if (isGemini2) {
474
+ googleTools2.googleSearch = {};
475
+ } else if (supportsDynamicRetrieval) {
476
+ googleTools2.googleSearchRetrieval = {
477
+ dynamicRetrievalConfig: {
478
+ mode: tool.args.mode,
479
+ dynamicThreshold: tool.args.dynamicThreshold
480
+ }
481
+ };
482
+ } else {
483
+ googleTools2.googleSearchRetrieval = {};
484
+ }
485
+ break;
486
+ case "google.url_context":
487
+ if (isGemini2) {
488
+ googleTools2.urlContext = {};
489
+ } else {
490
+ toolWarnings.push({
491
+ type: "unsupported-tool",
492
+ tool,
493
+ details: "The URL context tool is not supported with other Gemini models than Gemini 2."
494
+ });
495
+ }
496
+ break;
497
+ default:
498
+ toolWarnings.push({ type: "unsupported-tool", tool });
499
+ break;
500
+ }
501
+ });
479
502
  return {
480
- tools: isGemini2 ? { googleSearch: {} } : {
481
- googleSearchRetrieval: !supportsDynamicRetrieval || !dynamicRetrievalConfig2 ? {} : { dynamicRetrievalConfig: dynamicRetrievalConfig2 }
482
- },
503
+ tools: Object.keys(googleTools2).length > 0 ? googleTools2 : void 0,
483
504
  toolConfig: void 0,
484
505
  toolWarnings
485
506
  };
486
507
  }
487
- if (tools == null) {
488
- return { tools: void 0, toolConfig: void 0, toolWarnings };
489
- }
490
508
  const functionDeclarations = [];
491
509
  for (const tool of tools) {
492
- if (tool.type === "provider-defined") {
493
- toolWarnings.push({ type: "unsupported-tool", tool });
494
- } else {
495
- functionDeclarations.push({
496
- name: tool.name,
497
- description: (_a = tool.description) != null ? _a : "",
498
- parameters: convertJSONSchemaToOpenAPISchema(tool.inputSchema)
499
- });
510
+ switch (tool.type) {
511
+ case "function":
512
+ functionDeclarations.push({
513
+ name: tool.name,
514
+ description: (_a = tool.description) != null ? _a : "",
515
+ parameters: convertJSONSchemaToOpenAPISchema(tool.inputSchema)
516
+ });
517
+ break;
518
+ default:
519
+ toolWarnings.push({ type: "unsupported-tool", tool });
520
+ break;
500
521
  }
501
522
  }
502
523
  if (toolChoice == null) {
@@ -573,12 +594,72 @@ function mapGoogleGenerativeAIFinishReason({
573
594
  }
574
595
  }
575
596
 
597
+ // src/tool/google-search.ts
598
+ var import_provider_utils4 = require("@ai-sdk/provider-utils");
599
+ var import_v45 = require("zod/v4");
600
+ var groundingChunkSchema = import_v45.z.object({
601
+ web: import_v45.z.object({ uri: import_v45.z.string(), title: import_v45.z.string() }).nullish(),
602
+ retrievedContext: import_v45.z.object({ uri: import_v45.z.string(), title: import_v45.z.string() }).nullish()
603
+ });
604
+ var groundingMetadataSchema = import_v45.z.object({
605
+ webSearchQueries: import_v45.z.array(import_v45.z.string()).nullish(),
606
+ retrievalQueries: import_v45.z.array(import_v45.z.string()).nullish(),
607
+ searchEntryPoint: import_v45.z.object({ renderedContent: import_v45.z.string() }).nullish(),
608
+ groundingChunks: import_v45.z.array(groundingChunkSchema).nullish(),
609
+ groundingSupports: import_v45.z.array(
610
+ import_v45.z.object({
611
+ segment: import_v45.z.object({
612
+ startIndex: import_v45.z.number().nullish(),
613
+ endIndex: import_v45.z.number().nullish(),
614
+ text: import_v45.z.string().nullish()
615
+ }),
616
+ segment_text: import_v45.z.string().nullish(),
617
+ groundingChunkIndices: import_v45.z.array(import_v45.z.number()).nullish(),
618
+ supportChunkIndices: import_v45.z.array(import_v45.z.number()).nullish(),
619
+ confidenceScores: import_v45.z.array(import_v45.z.number()).nullish(),
620
+ confidenceScore: import_v45.z.array(import_v45.z.number()).nullish()
621
+ })
622
+ ).nullish(),
623
+ retrievalMetadata: import_v45.z.union([
624
+ import_v45.z.object({
625
+ webDynamicRetrievalScore: import_v45.z.number()
626
+ }),
627
+ import_v45.z.object({})
628
+ ]).nullish()
629
+ });
630
+ var googleSearch = (0, import_provider_utils4.createProviderDefinedToolFactory)({
631
+ id: "google.google_search",
632
+ name: "google_search",
633
+ inputSchema: import_v45.z.object({
634
+ mode: import_v45.z.enum(["MODE_DYNAMIC", "MODE_UNSPECIFIED"]).default("MODE_UNSPECIFIED"),
635
+ dynamicThreshold: import_v45.z.number().default(1)
636
+ })
637
+ });
638
+
639
+ // src/tool/url-context.ts
640
+ var import_provider_utils5 = require("@ai-sdk/provider-utils");
641
+ var import_v46 = require("zod/v4");
642
+ var urlMetadataSchema = import_v46.z.object({
643
+ retrievedUrl: import_v46.z.string(),
644
+ urlRetrievalStatus: import_v46.z.string()
645
+ });
646
+ var urlContextMetadataSchema = import_v46.z.object({
647
+ urlMetadata: import_v46.z.array(urlMetadataSchema)
648
+ });
649
+ var urlContext = (0, import_provider_utils5.createProviderDefinedToolFactory)({
650
+ id: "google.url_context",
651
+ name: "url_context",
652
+ inputSchema: import_v46.z.object({})
653
+ });
654
+
576
655
  // src/google-generative-ai-language-model.ts
577
656
  var GoogleGenerativeAILanguageModel = class {
578
657
  constructor(modelId, config) {
579
658
  this.specificationVersion = "v2";
659
+ var _a;
580
660
  this.modelId = modelId;
581
661
  this.config = config;
662
+ this.generateId = (_a = config.generateId) != null ? _a : import_provider_utils6.generateId;
582
663
  }
583
664
  get provider() {
584
665
  return this.config.provider;
@@ -602,9 +683,9 @@ var GoogleGenerativeAILanguageModel = class {
602
683
  toolChoice,
603
684
  providerOptions
604
685
  }) {
605
- var _a, _b, _c;
686
+ var _a, _b;
606
687
  const warnings = [];
607
- const googleOptions = await (0, import_provider_utils4.parseProviderOptions)({
688
+ const googleOptions = await (0, import_provider_utils6.parseProviderOptions)({
608
689
  provider: "google",
609
690
  providerOptions,
610
691
  schema: googleGenerativeAIProviderOptions
@@ -621,14 +702,12 @@ var GoogleGenerativeAILanguageModel = class {
621
702
  { isGemmaModel }
622
703
  );
623
704
  const {
624
- tools: googleTools,
705
+ tools: googleTools2,
625
706
  toolConfig: googleToolConfig,
626
707
  toolWarnings
627
708
  } = prepareTools({
628
709
  tools,
629
710
  toolChoice,
630
- useSearchGrounding: (_b = googleOptions == null ? void 0 : googleOptions.useSearchGrounding) != null ? _b : false,
631
- dynamicRetrievalConfig: googleOptions == null ? void 0 : googleOptions.dynamicRetrievalConfig,
632
711
  modelId: this.modelId
633
712
  });
634
713
  return {
@@ -648,7 +727,7 @@ var GoogleGenerativeAILanguageModel = class {
648
727
  responseSchema: (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && // Google GenAI does not support all OpenAPI Schema features,
649
728
  // so this is needed as an escape hatch:
650
729
  // TODO convert into provider option
651
- ((_c = googleOptions == null ? void 0 : googleOptions.structuredOutputs) != null ? _c : true) ? convertJSONSchemaToOpenAPISchema(responseFormat.schema) : void 0,
730
+ ((_b = googleOptions == null ? void 0 : googleOptions.structuredOutputs) != null ? _b : true) ? convertJSONSchemaToOpenAPISchema(responseFormat.schema) : void 0,
652
731
  ...(googleOptions == null ? void 0 : googleOptions.audioTimestamp) && {
653
732
  audioTimestamp: googleOptions.audioTimestamp
654
733
  },
@@ -659,7 +738,7 @@ var GoogleGenerativeAILanguageModel = class {
659
738
  contents,
660
739
  systemInstruction: isGemmaModel ? void 0 : systemInstruction,
661
740
  safetySettings: googleOptions == null ? void 0 : googleOptions.safetySettings,
662
- tools: googleTools,
741
+ tools: googleTools2,
663
742
  toolConfig: googleToolConfig,
664
743
  cachedContent: googleOptions == null ? void 0 : googleOptions.cachedContent
665
744
  },
@@ -667,25 +746,25 @@ var GoogleGenerativeAILanguageModel = class {
667
746
  };
668
747
  }
669
748
  async doGenerate(options) {
670
- var _a, _b, _c, _d, _e, _f, _g, _h, _i;
749
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
671
750
  const { args, warnings } = await this.getArgs(options);
672
751
  const body = JSON.stringify(args);
673
- const mergedHeaders = (0, import_provider_utils4.combineHeaders)(
674
- await (0, import_provider_utils4.resolve)(this.config.headers),
752
+ const mergedHeaders = (0, import_provider_utils6.combineHeaders)(
753
+ await (0, import_provider_utils6.resolve)(this.config.headers),
675
754
  options.headers
676
755
  );
677
756
  const {
678
757
  responseHeaders,
679
758
  value: response,
680
759
  rawValue: rawResponse
681
- } = await (0, import_provider_utils4.postJsonToApi)({
760
+ } = await (0, import_provider_utils6.postJsonToApi)({
682
761
  url: `${this.config.baseURL}/${getModelPath(
683
762
  this.modelId
684
763
  )}:generateContent`,
685
764
  headers: mergedHeaders,
686
765
  body: args,
687
766
  failedResponseHandler: googleFailedResponseHandler,
688
- successfulResponseHandler: (0, import_provider_utils4.createJsonResponseHandler)(responseSchema),
767
+ successfulResponseHandler: (0, import_provider_utils6.createJsonResponseHandler)(responseSchema),
689
768
  abortSignal: options.abortSignal,
690
769
  fetch: this.config.fetch
691
770
  });
@@ -739,7 +818,8 @@ var GoogleGenerativeAILanguageModel = class {
739
818
  providerMetadata: {
740
819
  google: {
741
820
  groundingMetadata: (_h = candidate.groundingMetadata) != null ? _h : null,
742
- safetyRatings: (_i = candidate.safetyRatings) != null ? _i : null,
821
+ urlContextMetadata: (_i = candidate.urlContextMetadata) != null ? _i : null,
822
+ safetyRatings: (_j = candidate.safetyRatings) != null ? _j : null,
743
823
  usageMetadata: usageMetadata != null ? usageMetadata : null
744
824
  }
745
825
  },
@@ -754,18 +834,18 @@ var GoogleGenerativeAILanguageModel = class {
754
834
  async doStream(options) {
755
835
  const { args, warnings } = await this.getArgs(options);
756
836
  const body = JSON.stringify(args);
757
- const headers = (0, import_provider_utils4.combineHeaders)(
758
- await (0, import_provider_utils4.resolve)(this.config.headers),
837
+ const headers = (0, import_provider_utils6.combineHeaders)(
838
+ await (0, import_provider_utils6.resolve)(this.config.headers),
759
839
  options.headers
760
840
  );
761
- const { responseHeaders, value: response } = await (0, import_provider_utils4.postJsonToApi)({
841
+ const { responseHeaders, value: response } = await (0, import_provider_utils6.postJsonToApi)({
762
842
  url: `${this.config.baseURL}/${getModelPath(
763
843
  this.modelId
764
844
  )}:streamGenerateContent?alt=sse`,
765
845
  headers,
766
846
  body: args,
767
847
  failedResponseHandler: googleFailedResponseHandler,
768
- successfulResponseHandler: (0, import_provider_utils4.createEventSourceResponseHandler)(chunkSchema),
848
+ successfulResponseHandler: (0, import_provider_utils6.createEventSourceResponseHandler)(chunkSchema),
769
849
  abortSignal: options.abortSignal,
770
850
  fetch: this.config.fetch
771
851
  });
@@ -776,7 +856,7 @@ var GoogleGenerativeAILanguageModel = class {
776
856
  totalTokens: void 0
777
857
  };
778
858
  let providerMetadata = void 0;
779
- const generateId2 = this.config.generateId;
859
+ const generateId3 = this.config.generateId;
780
860
  let hasToolCalls = false;
781
861
  let currentTextBlockId = null;
782
862
  let currentReasoningBlockId = null;
@@ -788,7 +868,7 @@ var GoogleGenerativeAILanguageModel = class {
788
868
  controller.enqueue({ type: "stream-start", warnings });
789
869
  },
790
870
  transform(chunk, controller) {
791
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
871
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
792
872
  if (options.includeRawChunks) {
793
873
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
794
874
  }
@@ -869,7 +949,7 @@ var GoogleGenerativeAILanguageModel = class {
869
949
  }
870
950
  const toolCallDeltas = getToolCallsFromParts({
871
951
  parts: content.parts,
872
- generateId: generateId2
952
+ generateId: generateId3
873
953
  });
874
954
  if (toolCallDeltas != null) {
875
955
  for (const toolCall of toolCallDeltas) {
@@ -904,7 +984,7 @@ var GoogleGenerativeAILanguageModel = class {
904
984
  });
905
985
  const sources = (_h = extractSources({
906
986
  groundingMetadata: candidate.groundingMetadata,
907
- generateId: generateId2
987
+ generateId: generateId3
908
988
  })) != null ? _h : [];
909
989
  for (const source of sources) {
910
990
  controller.enqueue(source);
@@ -912,7 +992,8 @@ var GoogleGenerativeAILanguageModel = class {
912
992
  providerMetadata = {
913
993
  google: {
914
994
  groundingMetadata: (_i = candidate.groundingMetadata) != null ? _i : null,
915
- safetyRatings: (_j = candidate.safetyRatings) != null ? _j : null
995
+ urlContextMetadata: (_j = candidate.urlContextMetadata) != null ? _j : null,
996
+ safetyRatings: (_k = candidate.safetyRatings) != null ? _k : null
916
997
  }
917
998
  };
918
999
  if (usageMetadata != null) {
@@ -949,14 +1030,14 @@ var GoogleGenerativeAILanguageModel = class {
949
1030
  };
950
1031
  function getToolCallsFromParts({
951
1032
  parts,
952
- generateId: generateId2
1033
+ generateId: generateId3
953
1034
  }) {
954
1035
  const functionCallParts = parts == null ? void 0 : parts.filter(
955
1036
  (part) => "functionCall" in part
956
1037
  );
957
1038
  return functionCallParts == null || functionCallParts.length === 0 ? void 0 : functionCallParts.map((part) => ({
958
1039
  type: "tool-call",
959
- toolCallId: generateId2(),
1040
+ toolCallId: generateId3(),
960
1041
  toolName: part.functionCall.name,
961
1042
  args: JSON.stringify(part.functionCall.args)
962
1043
  }));
@@ -968,7 +1049,7 @@ function getInlineDataParts(parts) {
968
1049
  }
969
1050
  function extractSources({
970
1051
  groundingMetadata,
971
- generateId: generateId2
1052
+ generateId: generateId3
972
1053
  }) {
973
1054
  var _a;
974
1055
  return (_a = groundingMetadata == null ? void 0 : groundingMetadata.groundingChunks) == null ? void 0 : _a.filter(
@@ -976,108 +1057,94 @@ function extractSources({
976
1057
  ).map((chunk) => ({
977
1058
  type: "source",
978
1059
  sourceType: "url",
979
- id: generateId2(),
1060
+ id: generateId3(),
980
1061
  url: chunk.web.uri,
981
1062
  title: chunk.web.title
982
1063
  }));
983
1064
  }
984
- var contentSchema = import_v45.z.object({
985
- parts: import_v45.z.array(
986
- import_v45.z.union([
1065
+ var contentSchema = import_v47.z.object({
1066
+ parts: import_v47.z.array(
1067
+ import_v47.z.union([
987
1068
  // note: order matters since text can be fully empty
988
- import_v45.z.object({
989
- functionCall: import_v45.z.object({
990
- name: import_v45.z.string(),
991
- args: import_v45.z.unknown()
1069
+ import_v47.z.object({
1070
+ functionCall: import_v47.z.object({
1071
+ name: import_v47.z.string(),
1072
+ args: import_v47.z.unknown()
992
1073
  })
993
1074
  }),
994
- import_v45.z.object({
995
- inlineData: import_v45.z.object({
996
- mimeType: import_v45.z.string(),
997
- data: import_v45.z.string()
1075
+ import_v47.z.object({
1076
+ inlineData: import_v47.z.object({
1077
+ mimeType: import_v47.z.string(),
1078
+ data: import_v47.z.string()
998
1079
  })
999
1080
  }),
1000
- import_v45.z.object({
1001
- text: import_v45.z.string().nullish(),
1002
- thought: import_v45.z.boolean().nullish()
1081
+ import_v47.z.object({
1082
+ text: import_v47.z.string().nullish(),
1083
+ thought: import_v47.z.boolean().nullish()
1003
1084
  })
1004
1085
  ])
1005
1086
  ).nullish()
1006
1087
  });
1007
- var groundingChunkSchema = import_v45.z.object({
1008
- web: import_v45.z.object({ uri: import_v45.z.string(), title: import_v45.z.string() }).nullish(),
1009
- retrievedContext: import_v45.z.object({ uri: import_v45.z.string(), title: import_v45.z.string() }).nullish()
1010
- });
1011
- var groundingMetadataSchema = import_v45.z.object({
1012
- webSearchQueries: import_v45.z.array(import_v45.z.string()).nullish(),
1013
- retrievalQueries: import_v45.z.array(import_v45.z.string()).nullish(),
1014
- searchEntryPoint: import_v45.z.object({ renderedContent: import_v45.z.string() }).nullish(),
1015
- groundingChunks: import_v45.z.array(groundingChunkSchema).nullish(),
1016
- groundingSupports: import_v45.z.array(
1017
- import_v45.z.object({
1018
- segment: import_v45.z.object({
1019
- startIndex: import_v45.z.number().nullish(),
1020
- endIndex: import_v45.z.number().nullish(),
1021
- text: import_v45.z.string().nullish()
1022
- }),
1023
- segment_text: import_v45.z.string().nullish(),
1024
- groundingChunkIndices: import_v45.z.array(import_v45.z.number()).nullish(),
1025
- supportChunkIndices: import_v45.z.array(import_v45.z.number()).nullish(),
1026
- confidenceScores: import_v45.z.array(import_v45.z.number()).nullish(),
1027
- confidenceScore: import_v45.z.array(import_v45.z.number()).nullish()
1028
- })
1029
- ).nullish(),
1030
- retrievalMetadata: import_v45.z.union([
1031
- import_v45.z.object({
1032
- webDynamicRetrievalScore: import_v45.z.number()
1033
- }),
1034
- import_v45.z.object({})
1035
- ]).nullish()
1036
- });
1037
- var safetyRatingSchema = import_v45.z.object({
1038
- category: import_v45.z.string().nullish(),
1039
- probability: import_v45.z.string().nullish(),
1040
- probabilityScore: import_v45.z.number().nullish(),
1041
- severity: import_v45.z.string().nullish(),
1042
- severityScore: import_v45.z.number().nullish(),
1043
- blocked: import_v45.z.boolean().nullish()
1088
+ var safetyRatingSchema = import_v47.z.object({
1089
+ category: import_v47.z.string().nullish(),
1090
+ probability: import_v47.z.string().nullish(),
1091
+ probabilityScore: import_v47.z.number().nullish(),
1092
+ severity: import_v47.z.string().nullish(),
1093
+ severityScore: import_v47.z.number().nullish(),
1094
+ blocked: import_v47.z.boolean().nullish()
1044
1095
  });
1045
- var usageSchema = import_v45.z.object({
1046
- cachedContentTokenCount: import_v45.z.number().nullish(),
1047
- thoughtsTokenCount: import_v45.z.number().nullish(),
1048
- promptTokenCount: import_v45.z.number().nullish(),
1049
- candidatesTokenCount: import_v45.z.number().nullish(),
1050
- totalTokenCount: import_v45.z.number().nullish()
1096
+ var usageSchema = import_v47.z.object({
1097
+ cachedContentTokenCount: import_v47.z.number().nullish(),
1098
+ thoughtsTokenCount: import_v47.z.number().nullish(),
1099
+ promptTokenCount: import_v47.z.number().nullish(),
1100
+ candidatesTokenCount: import_v47.z.number().nullish(),
1101
+ totalTokenCount: import_v47.z.number().nullish()
1051
1102
  });
1052
- var responseSchema = import_v45.z.object({
1053
- candidates: import_v45.z.array(
1054
- import_v45.z.object({
1055
- content: contentSchema.nullish().or(import_v45.z.object({}).strict()),
1056
- finishReason: import_v45.z.string().nullish(),
1057
- safetyRatings: import_v45.z.array(safetyRatingSchema).nullish(),
1058
- groundingMetadata: groundingMetadataSchema.nullish()
1103
+ var responseSchema = import_v47.z.object({
1104
+ candidates: import_v47.z.array(
1105
+ import_v47.z.object({
1106
+ content: contentSchema.nullish().or(import_v47.z.object({}).strict()),
1107
+ finishReason: import_v47.z.string().nullish(),
1108
+ safetyRatings: import_v47.z.array(safetyRatingSchema).nullish(),
1109
+ groundingMetadata: groundingMetadataSchema.nullish(),
1110
+ urlContextMetadata: urlContextMetadataSchema.nullish()
1059
1111
  })
1060
1112
  ),
1061
1113
  usageMetadata: usageSchema.nullish()
1062
1114
  });
1063
- var chunkSchema = import_v45.z.object({
1064
- candidates: import_v45.z.array(
1065
- import_v45.z.object({
1115
+ var chunkSchema = import_v47.z.object({
1116
+ candidates: import_v47.z.array(
1117
+ import_v47.z.object({
1066
1118
  content: contentSchema.nullish(),
1067
- finishReason: import_v45.z.string().nullish(),
1068
- safetyRatings: import_v45.z.array(safetyRatingSchema).nullish(),
1069
- groundingMetadata: groundingMetadataSchema.nullish()
1119
+ finishReason: import_v47.z.string().nullish(),
1120
+ safetyRatings: import_v47.z.array(safetyRatingSchema).nullish(),
1121
+ groundingMetadata: groundingMetadataSchema.nullish(),
1122
+ urlContextMetadata: urlContextMetadataSchema.nullish()
1070
1123
  })
1071
1124
  ).nullish(),
1072
1125
  usageMetadata: usageSchema.nullish()
1073
1126
  });
1074
1127
 
1128
+ // src/google-tools.ts
1129
+ var googleTools = {
1130
+ /**
1131
+ * Creates a Google search tool that gives Google direct access to real-time web content.
1132
+ * Must have name "google_search".
1133
+ */
1134
+ googleSearch,
1135
+ /**
1136
+ * Creates a URL context tool that gives Google direct access to real-time web content.
1137
+ * Must have name "url_context".
1138
+ */
1139
+ urlContext
1140
+ };
1141
+
1075
1142
  // src/google-provider.ts
1076
1143
  function createGoogleGenerativeAI(options = {}) {
1077
1144
  var _a;
1078
- const baseURL = (_a = (0, import_provider_utils5.withoutTrailingSlash)(options.baseURL)) != null ? _a : "https://generativelanguage.googleapis.com/v1beta";
1145
+ const baseURL = (_a = (0, import_provider_utils7.withoutTrailingSlash)(options.baseURL)) != null ? _a : "https://generativelanguage.googleapis.com/v1beta";
1079
1146
  const getHeaders = () => ({
1080
- "x-goog-api-key": (0, import_provider_utils5.loadApiKey)({
1147
+ "x-goog-api-key": (0, import_provider_utils7.loadApiKey)({
1081
1148
  apiKey: options.apiKey,
1082
1149
  environmentVariableName: "GOOGLE_GENERATIVE_AI_API_KEY",
1083
1150
  description: "Google Generative AI"
@@ -1090,7 +1157,7 @@ function createGoogleGenerativeAI(options = {}) {
1090
1157
  provider: "google.generative-ai",
1091
1158
  baseURL,
1092
1159
  headers: getHeaders,
1093
- generateId: (_a2 = options.generateId) != null ? _a2 : import_provider_utils5.generateId,
1160
+ generateId: (_a2 = options.generateId) != null ? _a2 : import_provider_utils7.generateId,
1094
1161
  supportedUrls: () => ({
1095
1162
  "*": [
1096
1163
  // Only allow requests to the Google Generative Language "files" endpoint
@@ -1124,6 +1191,7 @@ function createGoogleGenerativeAI(options = {}) {
1124
1191
  provider.imageModel = (modelId) => {
1125
1192
  throw new import_provider4.NoSuchModelError({ modelId, modelType: "imageModel" });
1126
1193
  };
1194
+ provider.tools = googleTools;
1127
1195
  return provider;
1128
1196
  }
1129
1197
  var google = createGoogleGenerativeAI();