@ai-sdk/google 2.0.0-beta.6 → 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.
@@ -21,14 +21,14 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
21
21
  var internal_exports = {};
22
22
  __export(internal_exports, {
23
23
  GoogleGenerativeAILanguageModel: () => GoogleGenerativeAILanguageModel,
24
- groundingMetadataSchema: () => groundingMetadataSchema,
24
+ googleTools: () => googleTools,
25
25
  safetyRatingSchema: () => safetyRatingSchema
26
26
  });
27
27
  module.exports = __toCommonJS(internal_exports);
28
28
 
29
29
  // src/google-generative-ai-language-model.ts
30
- var import_provider_utils3 = require("@ai-sdk/provider-utils");
31
- var import_v43 = require("zod/v4");
30
+ var import_provider_utils5 = require("@ai-sdk/provider-utils");
31
+ var import_v45 = require("zod/v4");
32
32
 
33
33
  // src/convert-json-schema-to-openapi-schema.ts
34
34
  function convertJSONSchemaToOpenAPISchema(jsonSchema) {
@@ -268,17 +268,6 @@ var googleFailedResponseHandler = (0, import_provider_utils2.createJsonErrorResp
268
268
 
269
269
  // src/google-generative-ai-options.ts
270
270
  var import_v42 = require("zod/v4");
271
- var dynamicRetrievalConfig = import_v42.z.object({
272
- /**
273
- * The mode of the predictor to be used in dynamic retrieval.
274
- */
275
- mode: import_v42.z.enum(["MODE_UNSPECIFIED", "MODE_DYNAMIC"]).optional(),
276
- /**
277
- * The threshold to be used in dynamic retrieval. If not set, a system default
278
- * value is used.
279
- */
280
- dynamicThreshold: import_v42.z.number().optional()
281
- });
282
271
  var googleGenerativeAIProviderOptions = import_v42.z.object({
283
272
  responseModalities: import_v42.z.array(import_v42.z.enum(["TEXT", "IMAGE"])).optional(),
284
273
  thinkingConfig: import_v42.z.object({
@@ -336,21 +325,7 @@ var googleGenerativeAIProviderOptions = import_v42.z.object({
336
325
  *
337
326
  * https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/audio-understanding
338
327
  */
339
- audioTimestamp: import_v42.z.boolean().optional(),
340
- /**
341
- Optional. When enabled, the model will use Google search to ground the response.
342
-
343
- @see https://cloud.google.com/vertex-ai/generative-ai/docs/grounding/overview
344
- */
345
- useSearchGrounding: import_v42.z.boolean().optional(),
346
- /**
347
- Optional. Specifies the dynamic retrieval configuration.
348
-
349
- @note Dynamic retrieval is only compatible with Gemini 1.5 Flash.
350
-
351
- @see https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/ground-with-google-search#dynamic-retrieval
352
- */
353
- dynamicRetrievalConfig: dynamicRetrievalConfig.optional()
328
+ audioTimestamp: import_v42.z.boolean().optional()
354
329
  });
355
330
 
356
331
  // src/google-prepare-tools.ts
@@ -358,8 +333,6 @@ var import_provider2 = require("@ai-sdk/provider");
358
333
  function prepareTools({
359
334
  tools,
360
335
  toolChoice,
361
- useSearchGrounding,
362
- dynamicRetrievalConfig: dynamicRetrievalConfig2,
363
336
  modelId
364
337
  }) {
365
338
  var _a;
@@ -367,28 +340,76 @@ function prepareTools({
367
340
  const toolWarnings = [];
368
341
  const isGemini2 = modelId.includes("gemini-2");
369
342
  const supportsDynamicRetrieval = modelId.includes("gemini-1.5-flash") && !modelId.includes("-8b");
370
- if (useSearchGrounding) {
343
+ if (tools == null) {
344
+ return { tools: void 0, toolConfig: void 0, toolWarnings };
345
+ }
346
+ const hasFunctionTools = tools.some((tool) => tool.type === "function");
347
+ const hasProviderDefinedTools = tools.some(
348
+ (tool) => tool.type === "provider-defined"
349
+ );
350
+ if (hasFunctionTools && hasProviderDefinedTools) {
351
+ toolWarnings.push({
352
+ type: "unsupported-tool",
353
+ tool: tools.find((tool) => tool.type === "function"),
354
+ 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."
355
+ });
356
+ }
357
+ if (hasProviderDefinedTools) {
358
+ const googleTools2 = {};
359
+ const providerDefinedTools = tools.filter(
360
+ (tool) => tool.type === "provider-defined"
361
+ );
362
+ providerDefinedTools.forEach((tool) => {
363
+ switch (tool.id) {
364
+ case "google.google_search":
365
+ if (isGemini2) {
366
+ googleTools2.googleSearch = {};
367
+ } else if (supportsDynamicRetrieval) {
368
+ googleTools2.googleSearchRetrieval = {
369
+ dynamicRetrievalConfig: {
370
+ mode: tool.args.mode,
371
+ dynamicThreshold: tool.args.dynamicThreshold
372
+ }
373
+ };
374
+ } else {
375
+ googleTools2.googleSearchRetrieval = {};
376
+ }
377
+ break;
378
+ case "google.url_context":
379
+ if (isGemini2) {
380
+ googleTools2.urlContext = {};
381
+ } else {
382
+ toolWarnings.push({
383
+ type: "unsupported-tool",
384
+ tool,
385
+ details: "The URL context tool is not supported with other Gemini models than Gemini 2."
386
+ });
387
+ }
388
+ break;
389
+ default:
390
+ toolWarnings.push({ type: "unsupported-tool", tool });
391
+ break;
392
+ }
393
+ });
371
394
  return {
372
- tools: isGemini2 ? { googleSearch: {} } : {
373
- googleSearchRetrieval: !supportsDynamicRetrieval || !dynamicRetrievalConfig2 ? {} : { dynamicRetrievalConfig: dynamicRetrievalConfig2 }
374
- },
395
+ tools: Object.keys(googleTools2).length > 0 ? googleTools2 : void 0,
375
396
  toolConfig: void 0,
376
397
  toolWarnings
377
398
  };
378
399
  }
379
- if (tools == null) {
380
- return { tools: void 0, toolConfig: void 0, toolWarnings };
381
- }
382
400
  const functionDeclarations = [];
383
401
  for (const tool of tools) {
384
- if (tool.type === "provider-defined") {
385
- toolWarnings.push({ type: "unsupported-tool", tool });
386
- } else {
387
- functionDeclarations.push({
388
- name: tool.name,
389
- description: (_a = tool.description) != null ? _a : "",
390
- parameters: convertJSONSchemaToOpenAPISchema(tool.inputSchema)
391
- });
402
+ switch (tool.type) {
403
+ case "function":
404
+ functionDeclarations.push({
405
+ name: tool.name,
406
+ description: (_a = tool.description) != null ? _a : "",
407
+ parameters: convertJSONSchemaToOpenAPISchema(tool.inputSchema)
408
+ });
409
+ break;
410
+ default:
411
+ toolWarnings.push({ type: "unsupported-tool", tool });
412
+ break;
392
413
  }
393
414
  }
394
415
  if (toolChoice == null) {
@@ -465,12 +486,72 @@ function mapGoogleGenerativeAIFinishReason({
465
486
  }
466
487
  }
467
488
 
489
+ // src/tool/google-search.ts
490
+ var import_provider_utils3 = require("@ai-sdk/provider-utils");
491
+ var import_v43 = require("zod/v4");
492
+ var groundingChunkSchema = import_v43.z.object({
493
+ web: import_v43.z.object({ uri: import_v43.z.string(), title: import_v43.z.string() }).nullish(),
494
+ retrievedContext: import_v43.z.object({ uri: import_v43.z.string(), title: import_v43.z.string() }).nullish()
495
+ });
496
+ var groundingMetadataSchema = import_v43.z.object({
497
+ webSearchQueries: import_v43.z.array(import_v43.z.string()).nullish(),
498
+ retrievalQueries: import_v43.z.array(import_v43.z.string()).nullish(),
499
+ searchEntryPoint: import_v43.z.object({ renderedContent: import_v43.z.string() }).nullish(),
500
+ groundingChunks: import_v43.z.array(groundingChunkSchema).nullish(),
501
+ groundingSupports: import_v43.z.array(
502
+ import_v43.z.object({
503
+ segment: import_v43.z.object({
504
+ startIndex: import_v43.z.number().nullish(),
505
+ endIndex: import_v43.z.number().nullish(),
506
+ text: import_v43.z.string().nullish()
507
+ }),
508
+ segment_text: import_v43.z.string().nullish(),
509
+ groundingChunkIndices: import_v43.z.array(import_v43.z.number()).nullish(),
510
+ supportChunkIndices: import_v43.z.array(import_v43.z.number()).nullish(),
511
+ confidenceScores: import_v43.z.array(import_v43.z.number()).nullish(),
512
+ confidenceScore: import_v43.z.array(import_v43.z.number()).nullish()
513
+ })
514
+ ).nullish(),
515
+ retrievalMetadata: import_v43.z.union([
516
+ import_v43.z.object({
517
+ webDynamicRetrievalScore: import_v43.z.number()
518
+ }),
519
+ import_v43.z.object({})
520
+ ]).nullish()
521
+ });
522
+ var googleSearch = (0, import_provider_utils3.createProviderDefinedToolFactory)({
523
+ id: "google.google_search",
524
+ name: "google_search",
525
+ inputSchema: import_v43.z.object({
526
+ mode: import_v43.z.enum(["MODE_DYNAMIC", "MODE_UNSPECIFIED"]).default("MODE_UNSPECIFIED"),
527
+ dynamicThreshold: import_v43.z.number().default(1)
528
+ })
529
+ });
530
+
531
+ // src/tool/url-context.ts
532
+ var import_provider_utils4 = require("@ai-sdk/provider-utils");
533
+ var import_v44 = require("zod/v4");
534
+ var urlMetadataSchema = import_v44.z.object({
535
+ retrievedUrl: import_v44.z.string(),
536
+ urlRetrievalStatus: import_v44.z.string()
537
+ });
538
+ var urlContextMetadataSchema = import_v44.z.object({
539
+ urlMetadata: import_v44.z.array(urlMetadataSchema)
540
+ });
541
+ var urlContext = (0, import_provider_utils4.createProviderDefinedToolFactory)({
542
+ id: "google.url_context",
543
+ name: "url_context",
544
+ inputSchema: import_v44.z.object({})
545
+ });
546
+
468
547
  // src/google-generative-ai-language-model.ts
469
548
  var GoogleGenerativeAILanguageModel = class {
470
549
  constructor(modelId, config) {
471
550
  this.specificationVersion = "v2";
551
+ var _a;
472
552
  this.modelId = modelId;
473
553
  this.config = config;
554
+ this.generateId = (_a = config.generateId) != null ? _a : import_provider_utils5.generateId;
474
555
  }
475
556
  get provider() {
476
557
  return this.config.provider;
@@ -494,9 +575,9 @@ var GoogleGenerativeAILanguageModel = class {
494
575
  toolChoice,
495
576
  providerOptions
496
577
  }) {
497
- var _a, _b, _c;
578
+ var _a, _b;
498
579
  const warnings = [];
499
- const googleOptions = await (0, import_provider_utils3.parseProviderOptions)({
580
+ const googleOptions = await (0, import_provider_utils5.parseProviderOptions)({
500
581
  provider: "google",
501
582
  providerOptions,
502
583
  schema: googleGenerativeAIProviderOptions
@@ -513,14 +594,12 @@ var GoogleGenerativeAILanguageModel = class {
513
594
  { isGemmaModel }
514
595
  );
515
596
  const {
516
- tools: googleTools,
597
+ tools: googleTools2,
517
598
  toolConfig: googleToolConfig,
518
599
  toolWarnings
519
600
  } = prepareTools({
520
601
  tools,
521
602
  toolChoice,
522
- useSearchGrounding: (_b = googleOptions == null ? void 0 : googleOptions.useSearchGrounding) != null ? _b : false,
523
- dynamicRetrievalConfig: googleOptions == null ? void 0 : googleOptions.dynamicRetrievalConfig,
524
603
  modelId: this.modelId
525
604
  });
526
605
  return {
@@ -540,7 +619,7 @@ var GoogleGenerativeAILanguageModel = class {
540
619
  responseSchema: (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && // Google GenAI does not support all OpenAPI Schema features,
541
620
  // so this is needed as an escape hatch:
542
621
  // TODO convert into provider option
543
- ((_c = googleOptions == null ? void 0 : googleOptions.structuredOutputs) != null ? _c : true) ? convertJSONSchemaToOpenAPISchema(responseFormat.schema) : void 0,
622
+ ((_b = googleOptions == null ? void 0 : googleOptions.structuredOutputs) != null ? _b : true) ? convertJSONSchemaToOpenAPISchema(responseFormat.schema) : void 0,
544
623
  ...(googleOptions == null ? void 0 : googleOptions.audioTimestamp) && {
545
624
  audioTimestamp: googleOptions.audioTimestamp
546
625
  },
@@ -551,7 +630,7 @@ var GoogleGenerativeAILanguageModel = class {
551
630
  contents,
552
631
  systemInstruction: isGemmaModel ? void 0 : systemInstruction,
553
632
  safetySettings: googleOptions == null ? void 0 : googleOptions.safetySettings,
554
- tools: googleTools,
633
+ tools: googleTools2,
555
634
  toolConfig: googleToolConfig,
556
635
  cachedContent: googleOptions == null ? void 0 : googleOptions.cachedContent
557
636
  },
@@ -559,25 +638,25 @@ var GoogleGenerativeAILanguageModel = class {
559
638
  };
560
639
  }
561
640
  async doGenerate(options) {
562
- var _a, _b, _c, _d, _e, _f, _g, _h, _i;
641
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
563
642
  const { args, warnings } = await this.getArgs(options);
564
643
  const body = JSON.stringify(args);
565
- const mergedHeaders = (0, import_provider_utils3.combineHeaders)(
566
- await (0, import_provider_utils3.resolve)(this.config.headers),
644
+ const mergedHeaders = (0, import_provider_utils5.combineHeaders)(
645
+ await (0, import_provider_utils5.resolve)(this.config.headers),
567
646
  options.headers
568
647
  );
569
648
  const {
570
649
  responseHeaders,
571
650
  value: response,
572
651
  rawValue: rawResponse
573
- } = await (0, import_provider_utils3.postJsonToApi)({
652
+ } = await (0, import_provider_utils5.postJsonToApi)({
574
653
  url: `${this.config.baseURL}/${getModelPath(
575
654
  this.modelId
576
655
  )}:generateContent`,
577
656
  headers: mergedHeaders,
578
657
  body: args,
579
658
  failedResponseHandler: googleFailedResponseHandler,
580
- successfulResponseHandler: (0, import_provider_utils3.createJsonResponseHandler)(responseSchema),
659
+ successfulResponseHandler: (0, import_provider_utils5.createJsonResponseHandler)(responseSchema),
581
660
  abortSignal: options.abortSignal,
582
661
  fetch: this.config.fetch
583
662
  });
@@ -631,7 +710,9 @@ var GoogleGenerativeAILanguageModel = class {
631
710
  providerMetadata: {
632
711
  google: {
633
712
  groundingMetadata: (_h = candidate.groundingMetadata) != null ? _h : null,
634
- safetyRatings: (_i = candidate.safetyRatings) != null ? _i : null
713
+ urlContextMetadata: (_i = candidate.urlContextMetadata) != null ? _i : null,
714
+ safetyRatings: (_j = candidate.safetyRatings) != null ? _j : null,
715
+ usageMetadata: usageMetadata != null ? usageMetadata : null
635
716
  }
636
717
  },
637
718
  request: { body },
@@ -645,18 +726,18 @@ var GoogleGenerativeAILanguageModel = class {
645
726
  async doStream(options) {
646
727
  const { args, warnings } = await this.getArgs(options);
647
728
  const body = JSON.stringify(args);
648
- const headers = (0, import_provider_utils3.combineHeaders)(
649
- await (0, import_provider_utils3.resolve)(this.config.headers),
729
+ const headers = (0, import_provider_utils5.combineHeaders)(
730
+ await (0, import_provider_utils5.resolve)(this.config.headers),
650
731
  options.headers
651
732
  );
652
- const { responseHeaders, value: response } = await (0, import_provider_utils3.postJsonToApi)({
733
+ const { responseHeaders, value: response } = await (0, import_provider_utils5.postJsonToApi)({
653
734
  url: `${this.config.baseURL}/${getModelPath(
654
735
  this.modelId
655
736
  )}:streamGenerateContent?alt=sse`,
656
737
  headers,
657
738
  body: args,
658
739
  failedResponseHandler: googleFailedResponseHandler,
659
- successfulResponseHandler: (0, import_provider_utils3.createEventSourceResponseHandler)(chunkSchema),
740
+ successfulResponseHandler: (0, import_provider_utils5.createEventSourceResponseHandler)(chunkSchema),
660
741
  abortSignal: options.abortSignal,
661
742
  fetch: this.config.fetch
662
743
  });
@@ -667,7 +748,7 @@ var GoogleGenerativeAILanguageModel = class {
667
748
  totalTokens: void 0
668
749
  };
669
750
  let providerMetadata = void 0;
670
- const generateId = this.config.generateId;
751
+ const generateId2 = this.config.generateId;
671
752
  let hasToolCalls = false;
672
753
  let currentTextBlockId = null;
673
754
  let currentReasoningBlockId = null;
@@ -679,7 +760,7 @@ var GoogleGenerativeAILanguageModel = class {
679
760
  controller.enqueue({ type: "stream-start", warnings });
680
761
  },
681
762
  transform(chunk, controller) {
682
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
763
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
683
764
  if (options.includeRawChunks) {
684
765
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
685
766
  }
@@ -760,7 +841,7 @@ var GoogleGenerativeAILanguageModel = class {
760
841
  }
761
842
  const toolCallDeltas = getToolCallsFromParts({
762
843
  parts: content.parts,
763
- generateId
844
+ generateId: generateId2
764
845
  });
765
846
  if (toolCallDeltas != null) {
766
847
  for (const toolCall of toolCallDeltas) {
@@ -795,7 +876,7 @@ var GoogleGenerativeAILanguageModel = class {
795
876
  });
796
877
  const sources = (_h = extractSources({
797
878
  groundingMetadata: candidate.groundingMetadata,
798
- generateId
879
+ generateId: generateId2
799
880
  })) != null ? _h : [];
800
881
  for (const source of sources) {
801
882
  controller.enqueue(source);
@@ -803,9 +884,13 @@ var GoogleGenerativeAILanguageModel = class {
803
884
  providerMetadata = {
804
885
  google: {
805
886
  groundingMetadata: (_i = candidate.groundingMetadata) != null ? _i : null,
806
- safetyRatings: (_j = candidate.safetyRatings) != null ? _j : null
887
+ urlContextMetadata: (_j = candidate.urlContextMetadata) != null ? _j : null,
888
+ safetyRatings: (_k = candidate.safetyRatings) != null ? _k : null
807
889
  }
808
890
  };
891
+ if (usageMetadata != null) {
892
+ providerMetadata.google.usageMetadata = usageMetadata;
893
+ }
809
894
  }
810
895
  },
811
896
  flush(controller) {
@@ -837,14 +922,14 @@ var GoogleGenerativeAILanguageModel = class {
837
922
  };
838
923
  function getToolCallsFromParts({
839
924
  parts,
840
- generateId
925
+ generateId: generateId2
841
926
  }) {
842
927
  const functionCallParts = parts == null ? void 0 : parts.filter(
843
928
  (part) => "functionCall" in part
844
929
  );
845
930
  return functionCallParts == null || functionCallParts.length === 0 ? void 0 : functionCallParts.map((part) => ({
846
931
  type: "tool-call",
847
- toolCallId: generateId(),
932
+ toolCallId: generateId2(),
848
933
  toolName: part.functionCall.name,
849
934
  args: JSON.stringify(part.functionCall.args)
850
935
  }));
@@ -856,7 +941,7 @@ function getInlineDataParts(parts) {
856
941
  }
857
942
  function extractSources({
858
943
  groundingMetadata,
859
- generateId
944
+ generateId: generateId2
860
945
  }) {
861
946
  var _a;
862
947
  return (_a = groundingMetadata == null ? void 0 : groundingMetadata.groundingChunks) == null ? void 0 : _a.filter(
@@ -864,105 +949,91 @@ function extractSources({
864
949
  ).map((chunk) => ({
865
950
  type: "source",
866
951
  sourceType: "url",
867
- id: generateId(),
952
+ id: generateId2(),
868
953
  url: chunk.web.uri,
869
954
  title: chunk.web.title
870
955
  }));
871
956
  }
872
- var contentSchema = import_v43.z.object({
873
- parts: import_v43.z.array(
874
- import_v43.z.union([
957
+ var contentSchema = import_v45.z.object({
958
+ parts: import_v45.z.array(
959
+ import_v45.z.union([
875
960
  // note: order matters since text can be fully empty
876
- import_v43.z.object({
877
- functionCall: import_v43.z.object({
878
- name: import_v43.z.string(),
879
- args: import_v43.z.unknown()
961
+ import_v45.z.object({
962
+ functionCall: import_v45.z.object({
963
+ name: import_v45.z.string(),
964
+ args: import_v45.z.unknown()
880
965
  })
881
966
  }),
882
- import_v43.z.object({
883
- inlineData: import_v43.z.object({
884
- mimeType: import_v43.z.string(),
885
- data: import_v43.z.string()
967
+ import_v45.z.object({
968
+ inlineData: import_v45.z.object({
969
+ mimeType: import_v45.z.string(),
970
+ data: import_v45.z.string()
886
971
  })
887
972
  }),
888
- import_v43.z.object({
889
- text: import_v43.z.string().nullish(),
890
- thought: import_v43.z.boolean().nullish()
973
+ import_v45.z.object({
974
+ text: import_v45.z.string().nullish(),
975
+ thought: import_v45.z.boolean().nullish()
891
976
  })
892
977
  ])
893
978
  ).nullish()
894
979
  });
895
- var groundingChunkSchema = import_v43.z.object({
896
- web: import_v43.z.object({ uri: import_v43.z.string(), title: import_v43.z.string() }).nullish(),
897
- retrievedContext: import_v43.z.object({ uri: import_v43.z.string(), title: import_v43.z.string() }).nullish()
898
- });
899
- var groundingMetadataSchema = import_v43.z.object({
900
- webSearchQueries: import_v43.z.array(import_v43.z.string()).nullish(),
901
- retrievalQueries: import_v43.z.array(import_v43.z.string()).nullish(),
902
- searchEntryPoint: import_v43.z.object({ renderedContent: import_v43.z.string() }).nullish(),
903
- groundingChunks: import_v43.z.array(groundingChunkSchema).nullish(),
904
- groundingSupports: import_v43.z.array(
905
- import_v43.z.object({
906
- segment: import_v43.z.object({
907
- startIndex: import_v43.z.number().nullish(),
908
- endIndex: import_v43.z.number().nullish(),
909
- text: import_v43.z.string().nullish()
910
- }),
911
- segment_text: import_v43.z.string().nullish(),
912
- groundingChunkIndices: import_v43.z.array(import_v43.z.number()).nullish(),
913
- supportChunkIndices: import_v43.z.array(import_v43.z.number()).nullish(),
914
- confidenceScores: import_v43.z.array(import_v43.z.number()).nullish(),
915
- confidenceScore: import_v43.z.array(import_v43.z.number()).nullish()
916
- })
917
- ).nullish(),
918
- retrievalMetadata: import_v43.z.union([
919
- import_v43.z.object({
920
- webDynamicRetrievalScore: import_v43.z.number()
921
- }),
922
- import_v43.z.object({})
923
- ]).nullish()
924
- });
925
- var safetyRatingSchema = import_v43.z.object({
926
- category: import_v43.z.string().nullish(),
927
- probability: import_v43.z.string().nullish(),
928
- probabilityScore: import_v43.z.number().nullish(),
929
- severity: import_v43.z.string().nullish(),
930
- severityScore: import_v43.z.number().nullish(),
931
- blocked: import_v43.z.boolean().nullish()
980
+ var safetyRatingSchema = import_v45.z.object({
981
+ category: import_v45.z.string().nullish(),
982
+ probability: import_v45.z.string().nullish(),
983
+ probabilityScore: import_v45.z.number().nullish(),
984
+ severity: import_v45.z.string().nullish(),
985
+ severityScore: import_v45.z.number().nullish(),
986
+ blocked: import_v45.z.boolean().nullish()
932
987
  });
933
- var usageSchema = import_v43.z.object({
934
- cachedContentTokenCount: import_v43.z.number().nullish(),
935
- thoughtsTokenCount: import_v43.z.number().nullish(),
936
- promptTokenCount: import_v43.z.number().nullish(),
937
- candidatesTokenCount: import_v43.z.number().nullish(),
938
- totalTokenCount: import_v43.z.number().nullish()
988
+ var usageSchema = import_v45.z.object({
989
+ cachedContentTokenCount: import_v45.z.number().nullish(),
990
+ thoughtsTokenCount: import_v45.z.number().nullish(),
991
+ promptTokenCount: import_v45.z.number().nullish(),
992
+ candidatesTokenCount: import_v45.z.number().nullish(),
993
+ totalTokenCount: import_v45.z.number().nullish()
939
994
  });
940
- var responseSchema = import_v43.z.object({
941
- candidates: import_v43.z.array(
942
- import_v43.z.object({
943
- content: contentSchema.nullish().or(import_v43.z.object({}).strict()),
944
- finishReason: import_v43.z.string().nullish(),
945
- safetyRatings: import_v43.z.array(safetyRatingSchema).nullish(),
946
- groundingMetadata: groundingMetadataSchema.nullish()
995
+ var responseSchema = import_v45.z.object({
996
+ candidates: import_v45.z.array(
997
+ import_v45.z.object({
998
+ content: contentSchema.nullish().or(import_v45.z.object({}).strict()),
999
+ finishReason: import_v45.z.string().nullish(),
1000
+ safetyRatings: import_v45.z.array(safetyRatingSchema).nullish(),
1001
+ groundingMetadata: groundingMetadataSchema.nullish(),
1002
+ urlContextMetadata: urlContextMetadataSchema.nullish()
947
1003
  })
948
1004
  ),
949
1005
  usageMetadata: usageSchema.nullish()
950
1006
  });
951
- var chunkSchema = import_v43.z.object({
952
- candidates: import_v43.z.array(
953
- import_v43.z.object({
1007
+ var chunkSchema = import_v45.z.object({
1008
+ candidates: import_v45.z.array(
1009
+ import_v45.z.object({
954
1010
  content: contentSchema.nullish(),
955
- finishReason: import_v43.z.string().nullish(),
956
- safetyRatings: import_v43.z.array(safetyRatingSchema).nullish(),
957
- groundingMetadata: groundingMetadataSchema.nullish()
1011
+ finishReason: import_v45.z.string().nullish(),
1012
+ safetyRatings: import_v45.z.array(safetyRatingSchema).nullish(),
1013
+ groundingMetadata: groundingMetadataSchema.nullish(),
1014
+ urlContextMetadata: urlContextMetadataSchema.nullish()
958
1015
  })
959
1016
  ).nullish(),
960
1017
  usageMetadata: usageSchema.nullish()
961
1018
  });
1019
+
1020
+ // src/google-tools.ts
1021
+ var googleTools = {
1022
+ /**
1023
+ * Creates a Google search tool that gives Google direct access to real-time web content.
1024
+ * Must have name "google_search".
1025
+ */
1026
+ googleSearch,
1027
+ /**
1028
+ * Creates a URL context tool that gives Google direct access to real-time web content.
1029
+ * Must have name "url_context".
1030
+ */
1031
+ urlContext
1032
+ };
962
1033
  // Annotate the CommonJS export names for ESM import in node:
963
1034
  0 && (module.exports = {
964
1035
  GoogleGenerativeAILanguageModel,
965
- groundingMetadataSchema,
1036
+ googleTools,
966
1037
  safetyRatingSchema
967
1038
  });
968
1039
  //# sourceMappingURL=index.js.map