@ai-sdk/google 2.0.55 → 2.0.57

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.55" : "0.0.0-test";
10
+ var VERSION = true ? "2.0.57" : "0.0.0-test";
11
11
 
12
12
  // src/google-generative-ai-embedding-model.ts
13
13
  import {
@@ -604,9 +604,13 @@ var googleGenerativeAIProviderOptions = lazySchema4(
604
604
  "5:4",
605
605
  "9:16",
606
606
  "16:9",
607
- "21:9"
607
+ "21:9",
608
+ "1:8",
609
+ "8:1",
610
+ "1:4",
611
+ "4:1"
608
612
  ]).optional(),
609
- imageSize: z4.enum(["1K", "2K", "4K"]).optional()
613
+ imageSize: z4.enum(["1K", "2K", "4K", "512"]).optional()
610
614
  }).optional(),
611
615
  /**
612
616
  * Optional. Configuration for grounding retrieval.
@@ -641,9 +645,8 @@ function prepareTools({
641
645
  "gemini-flash-lite-latest",
642
646
  "gemini-pro-latest"
643
647
  ].some((id) => id === modelId);
644
- const isGemini2orNewer = modelId.includes("gemini-2") || modelId.includes("gemini-3") || isLatest;
645
- const supportsDynamicRetrieval = modelId.includes("gemini-1.5-flash") && !modelId.includes("-8b");
646
- 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");
647
650
  if (tools == null) {
648
651
  return { tools: void 0, toolConfig: void 0, toolWarnings };
649
652
  }
@@ -668,18 +671,13 @@ function prepareTools({
668
671
  switch (tool.id) {
669
672
  case "google.google_search":
670
673
  if (isGemini2orNewer) {
671
- googleTools2.push({ googleSearch: {} });
672
- } else if (supportsDynamicRetrieval) {
673
- googleTools2.push({
674
- googleSearchRetrieval: {
675
- dynamicRetrievalConfig: {
676
- mode: tool.args.mode,
677
- dynamicThreshold: tool.args.dynamicThreshold
678
- }
679
- }
680
- });
674
+ googleTools2.push({ googleSearch: { ...tool.args } });
681
675
  } else {
682
- googleTools2.push({ googleSearchRetrieval: {} });
676
+ toolWarnings.push({
677
+ type: "unsupported-tool",
678
+ tool,
679
+ details: "Google Search requires Gemini 2.0 or newer."
680
+ });
683
681
  }
684
682
  break;
685
683
  case "google.enterprise_web_search":
@@ -1352,7 +1350,7 @@ function extractSources({
1352
1350
  groundingMetadata,
1353
1351
  generateId: generateId3
1354
1352
  }) {
1355
- var _a, _b, _c, _d, _e;
1353
+ var _a, _b, _c, _d, _e, _f;
1356
1354
  if (!(groundingMetadata == null ? void 0 : groundingMetadata.groundingChunks)) {
1357
1355
  return void 0;
1358
1356
  }
@@ -1366,6 +1364,16 @@ function extractSources({
1366
1364
  url: chunk.web.uri,
1367
1365
  title: (_a = chunk.web.title) != null ? _a : void 0
1368
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
+ });
1369
1377
  } else if (chunk.retrievedContext != null) {
1370
1378
  const uri = chunk.retrievedContext.uri;
1371
1379
  const fileSearchStore = chunk.retrievedContext.fileSearchStore;
@@ -1375,10 +1383,10 @@ function extractSources({
1375
1383
  sourceType: "url",
1376
1384
  id: generateId3(),
1377
1385
  url: uri,
1378
- title: (_b = chunk.retrievedContext.title) != null ? _b : void 0
1386
+ title: (_c = chunk.retrievedContext.title) != null ? _c : void 0
1379
1387
  });
1380
1388
  } else if (uri) {
1381
- const title = (_c = chunk.retrievedContext.title) != null ? _c : "Unknown Document";
1389
+ const title = (_d = chunk.retrievedContext.title) != null ? _d : "Unknown Document";
1382
1390
  let mediaType = "application/octet-stream";
1383
1391
  let filename = void 0;
1384
1392
  if (uri.endsWith(".pdf")) {
@@ -1408,7 +1416,7 @@ function extractSources({
1408
1416
  filename
1409
1417
  });
1410
1418
  } else if (fileSearchStore) {
1411
- const title = (_d = chunk.retrievedContext.title) != null ? _d : "Unknown Document";
1419
+ const title = (_e = chunk.retrievedContext.title) != null ? _e : "Unknown Document";
1412
1420
  sources.push({
1413
1421
  type: "source",
1414
1422
  sourceType: "document",
@@ -1425,7 +1433,7 @@ function extractSources({
1425
1433
  sourceType: "url",
1426
1434
  id: generateId3(),
1427
1435
  url: chunk.maps.uri,
1428
- title: (_e = chunk.maps.title) != null ? _e : void 0
1436
+ title: (_f = chunk.maps.title) != null ? _f : void 0
1429
1437
  });
1430
1438
  }
1431
1439
  }
@@ -1434,11 +1442,18 @@ function extractSources({
1434
1442
  }
1435
1443
  var getGroundingMetadataSchema = () => z5.object({
1436
1444
  webSearchQueries: z5.array(z5.string()).nullish(),
1445
+ imageSearchQueries: z5.array(z5.string()).nullish(),
1437
1446
  retrievalQueries: z5.array(z5.string()).nullish(),
1438
1447
  searchEntryPoint: z5.object({ renderedContent: z5.string() }).nullish(),
1439
1448
  groundingChunks: z5.array(
1440
1449
  z5.object({
1441
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(),
1442
1457
  retrievedContext: z5.object({
1443
1458
  uri: z5.string().nullish(),
1444
1459
  title: z5.string().nullish(),
@@ -1654,17 +1669,23 @@ import {
1654
1669
  zodSchema as zodSchema9
1655
1670
  } from "@ai-sdk/provider-utils";
1656
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
+ );
1657
1685
  var googleSearch = createProviderDefinedToolFactory4({
1658
1686
  id: "google.google_search",
1659
1687
  name: "google_search",
1660
- inputSchema: lazySchema9(
1661
- () => zodSchema9(
1662
- z10.object({
1663
- mode: z10.enum(["MODE_DYNAMIC", "MODE_UNSPECIFIED"]).default("MODE_UNSPECIFIED"),
1664
- dynamicThreshold: z10.number().default(1)
1665
- })
1666
- )
1667
- )
1688
+ inputSchema: googleSearchToolArgsSchema
1668
1689
  });
1669
1690
 
1670
1691
  // src/tool/url-context.ts