@ai-sdk/google 3.0.38 → 3.0.39

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.mjs CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  } from "@ai-sdk/provider-utils";
8
8
 
9
9
  // src/version.ts
10
- var VERSION = true ? "3.0.38" : "0.0.0-test";
10
+ var VERSION = true ? "3.0.39" : "0.0.0-test";
11
11
 
12
12
  // src/google-generative-ai-embedding-model.ts
13
13
  import {
@@ -684,8 +684,7 @@ function prepareTools({
684
684
  "gemini-flash-lite-latest",
685
685
  "gemini-pro-latest"
686
686
  ].some((id) => id === modelId);
687
- const isGemini2orNewer = modelId.includes("gemini-2") || modelId.includes("gemini-3") || isLatest;
688
- const supportsDynamicRetrieval = modelId.includes("gemini-1.5-flash") && !modelId.includes("-8b");
687
+ const isGemini2orNewer = modelId.includes("gemini-2") || modelId.includes("gemini-3") || modelId.includes("nano-banana") || isLatest;
689
688
  const supportsFileSearch = modelId.includes("gemini-2.5") || modelId.includes("gemini-3");
690
689
  if (tools == null) {
691
690
  return { tools: void 0, toolConfig: void 0, toolWarnings };
@@ -705,18 +704,13 @@ function prepareTools({
705
704
  switch (tool.id) {
706
705
  case "google.google_search":
707
706
  if (isGemini2orNewer) {
708
- googleTools2.push({ googleSearch: {} });
709
- } else if (supportsDynamicRetrieval) {
710
- googleTools2.push({
711
- googleSearchRetrieval: {
712
- dynamicRetrievalConfig: {
713
- mode: tool.args.mode,
714
- dynamicThreshold: tool.args.dynamicThreshold
715
- }
716
- }
717
- });
707
+ googleTools2.push({ googleSearch: { ...tool.args } });
718
708
  } else {
719
- googleTools2.push({ googleSearchRetrieval: {} });
709
+ toolWarnings.push({
710
+ type: "unsupported",
711
+ feature: `provider-defined tool ${tool.id}`,
712
+ details: "Google Search requires Gemini 2.0 or newer."
713
+ });
720
714
  }
721
715
  break;
722
716
  case "google.enterprise_web_search":
@@ -1433,7 +1427,7 @@ function extractSources({
1433
1427
  groundingMetadata,
1434
1428
  generateId: generateId3
1435
1429
  }) {
1436
- var _a, _b, _c, _d, _e;
1430
+ var _a, _b, _c, _d, _e, _f;
1437
1431
  if (!(groundingMetadata == null ? void 0 : groundingMetadata.groundingChunks)) {
1438
1432
  return void 0;
1439
1433
  }
@@ -1447,6 +1441,16 @@ function extractSources({
1447
1441
  url: chunk.web.uri,
1448
1442
  title: (_a = chunk.web.title) != null ? _a : void 0
1449
1443
  });
1444
+ } else if (chunk.image != null) {
1445
+ sources.push({
1446
+ type: "source",
1447
+ sourceType: "url",
1448
+ id: generateId3(),
1449
+ // Google requires attribution to the source URI, not the actual image URI.
1450
+ // TODO: add another type in v7 to allow both the image and source URL to be included separately
1451
+ url: chunk.image.sourceUri,
1452
+ title: (_b = chunk.image.title) != null ? _b : void 0
1453
+ });
1450
1454
  } else if (chunk.retrievedContext != null) {
1451
1455
  const uri = chunk.retrievedContext.uri;
1452
1456
  const fileSearchStore = chunk.retrievedContext.fileSearchStore;
@@ -1456,10 +1460,10 @@ function extractSources({
1456
1460
  sourceType: "url",
1457
1461
  id: generateId3(),
1458
1462
  url: uri,
1459
- title: (_b = chunk.retrievedContext.title) != null ? _b : void 0
1463
+ title: (_c = chunk.retrievedContext.title) != null ? _c : void 0
1460
1464
  });
1461
1465
  } else if (uri) {
1462
- const title = (_c = chunk.retrievedContext.title) != null ? _c : "Unknown Document";
1466
+ const title = (_d = chunk.retrievedContext.title) != null ? _d : "Unknown Document";
1463
1467
  let mediaType = "application/octet-stream";
1464
1468
  let filename = void 0;
1465
1469
  if (uri.endsWith(".pdf")) {
@@ -1489,7 +1493,7 @@ function extractSources({
1489
1493
  filename
1490
1494
  });
1491
1495
  } else if (fileSearchStore) {
1492
- const title = (_d = chunk.retrievedContext.title) != null ? _d : "Unknown Document";
1496
+ const title = (_e = chunk.retrievedContext.title) != null ? _e : "Unknown Document";
1493
1497
  sources.push({
1494
1498
  type: "source",
1495
1499
  sourceType: "document",
@@ -1506,7 +1510,7 @@ function extractSources({
1506
1510
  sourceType: "url",
1507
1511
  id: generateId3(),
1508
1512
  url: chunk.maps.uri,
1509
- title: (_e = chunk.maps.title) != null ? _e : void 0
1513
+ title: (_f = chunk.maps.title) != null ? _f : void 0
1510
1514
  });
1511
1515
  }
1512
1516
  }
@@ -1515,11 +1519,18 @@ function extractSources({
1515
1519
  }
1516
1520
  var getGroundingMetadataSchema = () => z5.object({
1517
1521
  webSearchQueries: z5.array(z5.string()).nullish(),
1522
+ imageSearchQueries: z5.array(z5.string()).nullish(),
1518
1523
  retrievalQueries: z5.array(z5.string()).nullish(),
1519
1524
  searchEntryPoint: z5.object({ renderedContent: z5.string() }).nullish(),
1520
1525
  groundingChunks: z5.array(
1521
1526
  z5.object({
1522
1527
  web: z5.object({ uri: z5.string(), title: z5.string().nullish() }).nullish(),
1528
+ image: z5.object({
1529
+ sourceUri: z5.string(),
1530
+ imageUri: z5.string(),
1531
+ title: z5.string().nullish(),
1532
+ domain: z5.string().nullish()
1533
+ }).nullish(),
1523
1534
  retrievedContext: z5.object({
1524
1535
  uri: z5.string().nullish(),
1525
1536
  title: z5.string().nullish(),
@@ -1732,17 +1743,25 @@ import {
1732
1743
  zodSchema as zodSchema9
1733
1744
  } from "@ai-sdk/provider-utils";
1734
1745
  import { z as z10 } from "zod/v4";
1735
- var googleSearch = createProviderToolFactory4({
1736
- id: "google.google_search",
1737
- inputSchema: lazySchema9(
1738
- () => zodSchema9(
1739
- z10.object({
1740
- mode: z10.enum(["MODE_DYNAMIC", "MODE_UNSPECIFIED"]).default("MODE_UNSPECIFIED"),
1741
- dynamicThreshold: z10.number().default(1)
1742
- })
1743
- )
1744
- )
1745
- });
1746
+ var googleSearchToolArgsBaseSchema = z10.object({
1747
+ searchTypes: z10.object({
1748
+ webSearch: z10.object({}).optional(),
1749
+ imageSearch: z10.object({}).optional()
1750
+ }).optional(),
1751
+ timeRangeFilter: z10.object({
1752
+ startTime: z10.string(),
1753
+ endTime: z10.string()
1754
+ }).optional()
1755
+ }).passthrough();
1756
+ var googleSearchToolArgsSchema = lazySchema9(
1757
+ () => zodSchema9(googleSearchToolArgsBaseSchema)
1758
+ );
1759
+ var googleSearch = createProviderToolFactory4(
1760
+ {
1761
+ id: "google.google_search",
1762
+ inputSchema: googleSearchToolArgsSchema
1763
+ }
1764
+ );
1746
1765
 
1747
1766
  // src/tool/url-context.ts
1748
1767
  import {