@ai-sdk/google 2.0.56 → 2.0.58

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 ? "2.0.56" : "0.0.0-test";
10
+ var VERSION = true ? "2.0.58" : "0.0.0-test";
11
11
 
12
12
  // src/google-generative-ai-embedding-model.ts
13
13
  import {
@@ -645,9 +645,8 @@ function prepareTools({
645
645
  "gemini-flash-lite-latest",
646
646
  "gemini-pro-latest"
647
647
  ].some((id) => id === modelId);
648
- const isGemini2orNewer = modelId.includes("gemini-2") || modelId.includes("gemini-3") || isLatest;
649
- const supportsDynamicRetrieval = modelId.includes("gemini-1.5-flash") && !modelId.includes("-8b");
650
- const supportsFileSearch = modelId.includes("gemini-2.5");
648
+ const isGemini2orNewer = modelId.includes("gemini-2") || modelId.includes("gemini-3") || modelId.includes("nano-banana") || isLatest;
649
+ const supportsFileSearch = modelId.includes("gemini-2.5") || modelId.includes("gemini-3");
651
650
  if (tools == null) {
652
651
  return { tools: void 0, toolConfig: void 0, toolWarnings };
653
652
  }
@@ -672,18 +671,13 @@ function prepareTools({
672
671
  switch (tool.id) {
673
672
  case "google.google_search":
674
673
  if (isGemini2orNewer) {
675
- googleTools2.push({ googleSearch: {} });
676
- } else if (supportsDynamicRetrieval) {
677
- googleTools2.push({
678
- googleSearchRetrieval: {
679
- dynamicRetrievalConfig: {
680
- mode: tool.args.mode,
681
- dynamicThreshold: tool.args.dynamicThreshold
682
- }
683
- }
684
- });
674
+ googleTools2.push({ googleSearch: { ...tool.args } });
685
675
  } else {
686
- googleTools2.push({ googleSearchRetrieval: {} });
676
+ toolWarnings.push({
677
+ type: "unsupported-tool",
678
+ tool,
679
+ details: "Google Search requires Gemini 2.0 or newer."
680
+ });
687
681
  }
688
682
  break;
689
683
  case "google.enterprise_web_search":
@@ -1356,7 +1350,7 @@ function extractSources({
1356
1350
  groundingMetadata,
1357
1351
  generateId: generateId3
1358
1352
  }) {
1359
- var _a, _b, _c, _d, _e;
1353
+ var _a, _b, _c, _d, _e, _f;
1360
1354
  if (!(groundingMetadata == null ? void 0 : groundingMetadata.groundingChunks)) {
1361
1355
  return void 0;
1362
1356
  }
@@ -1370,6 +1364,16 @@ function extractSources({
1370
1364
  url: chunk.web.uri,
1371
1365
  title: (_a = chunk.web.title) != null ? _a : void 0
1372
1366
  });
1367
+ } else if (chunk.image != null) {
1368
+ sources.push({
1369
+ type: "source",
1370
+ sourceType: "url",
1371
+ id: generateId3(),
1372
+ // Google requires attribution to the source URI, not the actual image URI.
1373
+ // TODO: add another type in v7 to allow both the image and source URL to be included separately
1374
+ url: chunk.image.sourceUri,
1375
+ title: (_b = chunk.image.title) != null ? _b : void 0
1376
+ });
1373
1377
  } else if (chunk.retrievedContext != null) {
1374
1378
  const uri = chunk.retrievedContext.uri;
1375
1379
  const fileSearchStore = chunk.retrievedContext.fileSearchStore;
@@ -1379,10 +1383,10 @@ function extractSources({
1379
1383
  sourceType: "url",
1380
1384
  id: generateId3(),
1381
1385
  url: uri,
1382
- title: (_b = chunk.retrievedContext.title) != null ? _b : void 0
1386
+ title: (_c = chunk.retrievedContext.title) != null ? _c : void 0
1383
1387
  });
1384
1388
  } else if (uri) {
1385
- const title = (_c = chunk.retrievedContext.title) != null ? _c : "Unknown Document";
1389
+ const title = (_d = chunk.retrievedContext.title) != null ? _d : "Unknown Document";
1386
1390
  let mediaType = "application/octet-stream";
1387
1391
  let filename = void 0;
1388
1392
  if (uri.endsWith(".pdf")) {
@@ -1412,7 +1416,7 @@ function extractSources({
1412
1416
  filename
1413
1417
  });
1414
1418
  } else if (fileSearchStore) {
1415
- const title = (_d = chunk.retrievedContext.title) != null ? _d : "Unknown Document";
1419
+ const title = (_e = chunk.retrievedContext.title) != null ? _e : "Unknown Document";
1416
1420
  sources.push({
1417
1421
  type: "source",
1418
1422
  sourceType: "document",
@@ -1429,7 +1433,7 @@ function extractSources({
1429
1433
  sourceType: "url",
1430
1434
  id: generateId3(),
1431
1435
  url: chunk.maps.uri,
1432
- title: (_e = chunk.maps.title) != null ? _e : void 0
1436
+ title: (_f = chunk.maps.title) != null ? _f : void 0
1433
1437
  });
1434
1438
  }
1435
1439
  }
@@ -1438,11 +1442,18 @@ function extractSources({
1438
1442
  }
1439
1443
  var getGroundingMetadataSchema = () => z5.object({
1440
1444
  webSearchQueries: z5.array(z5.string()).nullish(),
1445
+ imageSearchQueries: z5.array(z5.string()).nullish(),
1441
1446
  retrievalQueries: z5.array(z5.string()).nullish(),
1442
1447
  searchEntryPoint: z5.object({ renderedContent: z5.string() }).nullish(),
1443
1448
  groundingChunks: z5.array(
1444
1449
  z5.object({
1445
1450
  web: z5.object({ uri: z5.string(), title: z5.string().nullish() }).nullish(),
1451
+ image: z5.object({
1452
+ sourceUri: z5.string(),
1453
+ imageUri: z5.string(),
1454
+ title: z5.string().nullish(),
1455
+ domain: z5.string().nullish()
1456
+ }).nullish(),
1446
1457
  retrievedContext: z5.object({
1447
1458
  uri: z5.string().nullish(),
1448
1459
  title: z5.string().nullish(),
@@ -1658,17 +1669,23 @@ import {
1658
1669
  zodSchema as zodSchema9
1659
1670
  } from "@ai-sdk/provider-utils";
1660
1671
  import { z as z10 } from "zod/v4";
1672
+ var googleSearchToolArgsBaseSchema = z10.object({
1673
+ searchTypes: z10.object({
1674
+ webSearch: z10.object({}).optional(),
1675
+ imageSearch: z10.object({}).optional()
1676
+ }).optional(),
1677
+ timeRangeFilter: z10.object({
1678
+ startTime: z10.string(),
1679
+ endTime: z10.string()
1680
+ }).optional()
1681
+ }).passthrough();
1682
+ var googleSearchToolArgsSchema = lazySchema9(
1683
+ () => zodSchema9(googleSearchToolArgsBaseSchema)
1684
+ );
1661
1685
  var googleSearch = createProviderDefinedToolFactory4({
1662
1686
  id: "google.google_search",
1663
1687
  name: "google_search",
1664
- inputSchema: lazySchema9(
1665
- () => zodSchema9(
1666
- z10.object({
1667
- mode: z10.enum(["MODE_DYNAMIC", "MODE_UNSPECIFIED"]).default("MODE_UNSPECIFIED"),
1668
- dynamicThreshold: z10.number().default(1)
1669
- })
1670
- )
1671
- )
1688
+ inputSchema: googleSearchToolArgsSchema
1672
1689
  });
1673
1690
 
1674
1691
  // src/tool/url-context.ts