@ai-sdk/google 3.0.37 → 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.37" : "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":
@@ -1299,10 +1293,30 @@ var GoogleGenerativeAILanguageModel = class {
1299
1293
  });
1300
1294
  }
1301
1295
  } else if ("inlineData" in part) {
1296
+ if (currentTextBlockId !== null) {
1297
+ controller.enqueue({
1298
+ type: "text-end",
1299
+ id: currentTextBlockId
1300
+ });
1301
+ currentTextBlockId = null;
1302
+ }
1303
+ if (currentReasoningBlockId !== null) {
1304
+ controller.enqueue({
1305
+ type: "reasoning-end",
1306
+ id: currentReasoningBlockId
1307
+ });
1308
+ currentReasoningBlockId = null;
1309
+ }
1310
+ const thoughtSignatureMetadata = part.thoughtSignature ? {
1311
+ [providerOptionsName]: {
1312
+ thoughtSignature: part.thoughtSignature
1313
+ }
1314
+ } : void 0;
1302
1315
  controller.enqueue({
1303
1316
  type: "file",
1304
1317
  mediaType: part.inlineData.mimeType,
1305
- data: part.inlineData.data
1318
+ data: part.inlineData.data,
1319
+ providerMetadata: thoughtSignatureMetadata
1306
1320
  });
1307
1321
  }
1308
1322
  }
@@ -1413,7 +1427,7 @@ function extractSources({
1413
1427
  groundingMetadata,
1414
1428
  generateId: generateId3
1415
1429
  }) {
1416
- var _a, _b, _c, _d, _e;
1430
+ var _a, _b, _c, _d, _e, _f;
1417
1431
  if (!(groundingMetadata == null ? void 0 : groundingMetadata.groundingChunks)) {
1418
1432
  return void 0;
1419
1433
  }
@@ -1427,6 +1441,16 @@ function extractSources({
1427
1441
  url: chunk.web.uri,
1428
1442
  title: (_a = chunk.web.title) != null ? _a : void 0
1429
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
+ });
1430
1454
  } else if (chunk.retrievedContext != null) {
1431
1455
  const uri = chunk.retrievedContext.uri;
1432
1456
  const fileSearchStore = chunk.retrievedContext.fileSearchStore;
@@ -1436,10 +1460,10 @@ function extractSources({
1436
1460
  sourceType: "url",
1437
1461
  id: generateId3(),
1438
1462
  url: uri,
1439
- title: (_b = chunk.retrievedContext.title) != null ? _b : void 0
1463
+ title: (_c = chunk.retrievedContext.title) != null ? _c : void 0
1440
1464
  });
1441
1465
  } else if (uri) {
1442
- const title = (_c = chunk.retrievedContext.title) != null ? _c : "Unknown Document";
1466
+ const title = (_d = chunk.retrievedContext.title) != null ? _d : "Unknown Document";
1443
1467
  let mediaType = "application/octet-stream";
1444
1468
  let filename = void 0;
1445
1469
  if (uri.endsWith(".pdf")) {
@@ -1469,7 +1493,7 @@ function extractSources({
1469
1493
  filename
1470
1494
  });
1471
1495
  } else if (fileSearchStore) {
1472
- const title = (_d = chunk.retrievedContext.title) != null ? _d : "Unknown Document";
1496
+ const title = (_e = chunk.retrievedContext.title) != null ? _e : "Unknown Document";
1473
1497
  sources.push({
1474
1498
  type: "source",
1475
1499
  sourceType: "document",
@@ -1486,7 +1510,7 @@ function extractSources({
1486
1510
  sourceType: "url",
1487
1511
  id: generateId3(),
1488
1512
  url: chunk.maps.uri,
1489
- title: (_e = chunk.maps.title) != null ? _e : void 0
1513
+ title: (_f = chunk.maps.title) != null ? _f : void 0
1490
1514
  });
1491
1515
  }
1492
1516
  }
@@ -1495,11 +1519,18 @@ function extractSources({
1495
1519
  }
1496
1520
  var getGroundingMetadataSchema = () => z5.object({
1497
1521
  webSearchQueries: z5.array(z5.string()).nullish(),
1522
+ imageSearchQueries: z5.array(z5.string()).nullish(),
1498
1523
  retrievalQueries: z5.array(z5.string()).nullish(),
1499
1524
  searchEntryPoint: z5.object({ renderedContent: z5.string() }).nullish(),
1500
1525
  groundingChunks: z5.array(
1501
1526
  z5.object({
1502
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(),
1503
1534
  retrievedContext: z5.object({
1504
1535
  uri: z5.string().nullish(),
1505
1536
  title: z5.string().nullish(),
@@ -1712,17 +1743,25 @@ import {
1712
1743
  zodSchema as zodSchema9
1713
1744
  } from "@ai-sdk/provider-utils";
1714
1745
  import { z as z10 } from "zod/v4";
1715
- var googleSearch = createProviderToolFactory4({
1716
- id: "google.google_search",
1717
- inputSchema: lazySchema9(
1718
- () => zodSchema9(
1719
- z10.object({
1720
- mode: z10.enum(["MODE_DYNAMIC", "MODE_UNSPECIFIED"]).default("MODE_UNSPECIFIED"),
1721
- dynamicThreshold: z10.number().default(1)
1722
- })
1723
- )
1724
- )
1725
- });
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
+ );
1726
1765
 
1727
1766
  // src/tool/url-context.ts
1728
1767
  import {