@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.
@@ -430,9 +430,13 @@ var googleGenerativeAIProviderOptions = lazySchema2(
430
430
  "5:4",
431
431
  "9:16",
432
432
  "16:9",
433
- "21:9"
433
+ "21:9",
434
+ "1:8",
435
+ "8:1",
436
+ "1:4",
437
+ "4:1"
434
438
  ]).optional(),
435
- imageSize: z2.enum(["1K", "2K", "4K"]).optional()
439
+ imageSize: z2.enum(["1K", "2K", "4K", "512"]).optional()
436
440
  }).optional(),
437
441
  /**
438
442
  * Optional. Configuration for grounding retrieval.
@@ -467,9 +471,8 @@ function prepareTools({
467
471
  "gemini-flash-lite-latest",
468
472
  "gemini-pro-latest"
469
473
  ].some((id) => id === modelId);
470
- const isGemini2orNewer = modelId.includes("gemini-2") || modelId.includes("gemini-3") || isLatest;
471
- const supportsDynamicRetrieval = modelId.includes("gemini-1.5-flash") && !modelId.includes("-8b");
472
- const supportsFileSearch = modelId.includes("gemini-2.5");
474
+ const isGemini2orNewer = modelId.includes("gemini-2") || modelId.includes("gemini-3") || modelId.includes("nano-banana") || isLatest;
475
+ const supportsFileSearch = modelId.includes("gemini-2.5") || modelId.includes("gemini-3");
473
476
  if (tools == null) {
474
477
  return { tools: void 0, toolConfig: void 0, toolWarnings };
475
478
  }
@@ -494,18 +497,13 @@ function prepareTools({
494
497
  switch (tool.id) {
495
498
  case "google.google_search":
496
499
  if (isGemini2orNewer) {
497
- googleTools2.push({ googleSearch: {} });
498
- } else if (supportsDynamicRetrieval) {
499
- googleTools2.push({
500
- googleSearchRetrieval: {
501
- dynamicRetrievalConfig: {
502
- mode: tool.args.mode,
503
- dynamicThreshold: tool.args.dynamicThreshold
504
- }
505
- }
506
- });
500
+ googleTools2.push({ googleSearch: { ...tool.args } });
507
501
  } else {
508
- googleTools2.push({ googleSearchRetrieval: {} });
502
+ toolWarnings.push({
503
+ type: "unsupported-tool",
504
+ tool,
505
+ details: "Google Search requires Gemini 2.0 or newer."
506
+ });
509
507
  }
510
508
  break;
511
509
  case "google.enterprise_web_search":
@@ -1178,7 +1176,7 @@ function extractSources({
1178
1176
  groundingMetadata,
1179
1177
  generateId: generateId2
1180
1178
  }) {
1181
- var _a, _b, _c, _d, _e;
1179
+ var _a, _b, _c, _d, _e, _f;
1182
1180
  if (!(groundingMetadata == null ? void 0 : groundingMetadata.groundingChunks)) {
1183
1181
  return void 0;
1184
1182
  }
@@ -1192,6 +1190,16 @@ function extractSources({
1192
1190
  url: chunk.web.uri,
1193
1191
  title: (_a = chunk.web.title) != null ? _a : void 0
1194
1192
  });
1193
+ } else if (chunk.image != null) {
1194
+ sources.push({
1195
+ type: "source",
1196
+ sourceType: "url",
1197
+ id: generateId2(),
1198
+ // Google requires attribution to the source URI, not the actual image URI.
1199
+ // TODO: add another type in v7 to allow both the image and source URL to be included separately
1200
+ url: chunk.image.sourceUri,
1201
+ title: (_b = chunk.image.title) != null ? _b : void 0
1202
+ });
1195
1203
  } else if (chunk.retrievedContext != null) {
1196
1204
  const uri = chunk.retrievedContext.uri;
1197
1205
  const fileSearchStore = chunk.retrievedContext.fileSearchStore;
@@ -1201,10 +1209,10 @@ function extractSources({
1201
1209
  sourceType: "url",
1202
1210
  id: generateId2(),
1203
1211
  url: uri,
1204
- title: (_b = chunk.retrievedContext.title) != null ? _b : void 0
1212
+ title: (_c = chunk.retrievedContext.title) != null ? _c : void 0
1205
1213
  });
1206
1214
  } else if (uri) {
1207
- const title = (_c = chunk.retrievedContext.title) != null ? _c : "Unknown Document";
1215
+ const title = (_d = chunk.retrievedContext.title) != null ? _d : "Unknown Document";
1208
1216
  let mediaType = "application/octet-stream";
1209
1217
  let filename = void 0;
1210
1218
  if (uri.endsWith(".pdf")) {
@@ -1234,7 +1242,7 @@ function extractSources({
1234
1242
  filename
1235
1243
  });
1236
1244
  } else if (fileSearchStore) {
1237
- const title = (_d = chunk.retrievedContext.title) != null ? _d : "Unknown Document";
1245
+ const title = (_e = chunk.retrievedContext.title) != null ? _e : "Unknown Document";
1238
1246
  sources.push({
1239
1247
  type: "source",
1240
1248
  sourceType: "document",
@@ -1251,7 +1259,7 @@ function extractSources({
1251
1259
  sourceType: "url",
1252
1260
  id: generateId2(),
1253
1261
  url: chunk.maps.uri,
1254
- title: (_e = chunk.maps.title) != null ? _e : void 0
1262
+ title: (_f = chunk.maps.title) != null ? _f : void 0
1255
1263
  });
1256
1264
  }
1257
1265
  }
@@ -1260,11 +1268,18 @@ function extractSources({
1260
1268
  }
1261
1269
  var getGroundingMetadataSchema = () => z3.object({
1262
1270
  webSearchQueries: z3.array(z3.string()).nullish(),
1271
+ imageSearchQueries: z3.array(z3.string()).nullish(),
1263
1272
  retrievalQueries: z3.array(z3.string()).nullish(),
1264
1273
  searchEntryPoint: z3.object({ renderedContent: z3.string() }).nullish(),
1265
1274
  groundingChunks: z3.array(
1266
1275
  z3.object({
1267
1276
  web: z3.object({ uri: z3.string(), title: z3.string().nullish() }).nullish(),
1277
+ image: z3.object({
1278
+ sourceUri: z3.string(),
1279
+ imageUri: z3.string(),
1280
+ title: z3.string().nullish(),
1281
+ domain: z3.string().nullish()
1282
+ }).nullish(),
1268
1283
  retrievedContext: z3.object({
1269
1284
  uri: z3.string().nullish(),
1270
1285
  title: z3.string().nullish(),
@@ -1480,17 +1495,23 @@ import {
1480
1495
  zodSchema as zodSchema7
1481
1496
  } from "@ai-sdk/provider-utils";
1482
1497
  import { z as z8 } from "zod/v4";
1498
+ var googleSearchToolArgsBaseSchema = z8.object({
1499
+ searchTypes: z8.object({
1500
+ webSearch: z8.object({}).optional(),
1501
+ imageSearch: z8.object({}).optional()
1502
+ }).optional(),
1503
+ timeRangeFilter: z8.object({
1504
+ startTime: z8.string(),
1505
+ endTime: z8.string()
1506
+ }).optional()
1507
+ }).passthrough();
1508
+ var googleSearchToolArgsSchema = lazySchema7(
1509
+ () => zodSchema7(googleSearchToolArgsBaseSchema)
1510
+ );
1483
1511
  var googleSearch = createProviderDefinedToolFactory4({
1484
1512
  id: "google.google_search",
1485
1513
  name: "google_search",
1486
- inputSchema: lazySchema7(
1487
- () => zodSchema7(
1488
- z8.object({
1489
- mode: z8.enum(["MODE_DYNAMIC", "MODE_UNSPECIFIED"]).default("MODE_UNSPECIFIED"),
1490
- dynamicThreshold: z8.number().default(1)
1491
- })
1492
- )
1493
- )
1514
+ inputSchema: googleSearchToolArgsSchema
1494
1515
  });
1495
1516
 
1496
1517
  // src/tool/url-context.ts