@ai-sdk/google 2.0.46 → 2.0.47

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.
@@ -45,6 +45,12 @@ declare const getGroundingMetadataSchema: () => z.ZodObject<{
45
45
  text: z.ZodOptional<z.ZodNullable<z.ZodString>>;
46
46
  fileSearchStore: z.ZodOptional<z.ZodNullable<z.ZodString>>;
47
47
  }, z.core.$strip>>>;
48
+ maps: z.ZodOptional<z.ZodNullable<z.ZodObject<{
49
+ uri: z.ZodOptional<z.ZodNullable<z.ZodString>>;
50
+ title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
51
+ text: z.ZodOptional<z.ZodNullable<z.ZodString>>;
52
+ placeId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
53
+ }, z.core.$strip>>>;
48
54
  }, z.core.$strip>>>>;
49
55
  groundingSupports: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
50
56
  segment: z.ZodObject<{
@@ -122,6 +128,12 @@ declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
122
128
  text?: string | null | undefined;
123
129
  fileSearchStore?: string | null | undefined;
124
130
  } | null | undefined;
131
+ maps?: {
132
+ uri?: string | null | undefined;
133
+ title?: string | null | undefined;
134
+ text?: string | null | undefined;
135
+ placeId?: string | null | undefined;
136
+ } | null | undefined;
125
137
  }[] | null | undefined;
126
138
  groundingSupports?: {
127
139
  segment: {
@@ -179,6 +191,14 @@ declare const googleTools: {
179
191
  mode?: "MODE_DYNAMIC" | "MODE_UNSPECIFIED";
180
192
  dynamicThreshold?: number;
181
193
  }>;
194
+ /**
195
+ * Creates a Google Maps grounding tool that gives the model access to Google Maps data.
196
+ * Must have name "google_maps".
197
+ *
198
+ * @see https://ai.google.dev/gemini-api/docs/maps-grounding
199
+ * @see https://cloud.google.com/vertex-ai/generative-ai/docs/grounding/grounding-with-google-maps
200
+ */
201
+ googleMaps: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{}, {}>;
182
202
  /**
183
203
  * Creates a URL context tool that gives Google direct access to real-time web content.
184
204
  * Must have name "url_context".
@@ -45,6 +45,12 @@ declare const getGroundingMetadataSchema: () => z.ZodObject<{
45
45
  text: z.ZodOptional<z.ZodNullable<z.ZodString>>;
46
46
  fileSearchStore: z.ZodOptional<z.ZodNullable<z.ZodString>>;
47
47
  }, z.core.$strip>>>;
48
+ maps: z.ZodOptional<z.ZodNullable<z.ZodObject<{
49
+ uri: z.ZodOptional<z.ZodNullable<z.ZodString>>;
50
+ title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
51
+ text: z.ZodOptional<z.ZodNullable<z.ZodString>>;
52
+ placeId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
53
+ }, z.core.$strip>>>;
48
54
  }, z.core.$strip>>>>;
49
55
  groundingSupports: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
50
56
  segment: z.ZodObject<{
@@ -122,6 +128,12 @@ declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
122
128
  text?: string | null | undefined;
123
129
  fileSearchStore?: string | null | undefined;
124
130
  } | null | undefined;
131
+ maps?: {
132
+ uri?: string | null | undefined;
133
+ title?: string | null | undefined;
134
+ text?: string | null | undefined;
135
+ placeId?: string | null | undefined;
136
+ } | null | undefined;
125
137
  }[] | null | undefined;
126
138
  groundingSupports?: {
127
139
  segment: {
@@ -179,6 +191,14 @@ declare const googleTools: {
179
191
  mode?: "MODE_DYNAMIC" | "MODE_UNSPECIFIED";
180
192
  dynamicThreshold?: number;
181
193
  }>;
194
+ /**
195
+ * Creates a Google Maps grounding tool that gives the model access to Google Maps data.
196
+ * Must have name "google_maps".
197
+ *
198
+ * @see https://ai.google.dev/gemini-api/docs/maps-grounding
199
+ * @see https://cloud.google.com/vertex-ai/generative-ai/docs/grounding/grounding-with-google-maps
200
+ */
201
+ googleMaps: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{}, {}>;
182
202
  /**
183
203
  * Creates a URL context tool that gives Google direct access to real-time web content.
184
204
  * Must have name "url_context".
@@ -423,6 +423,18 @@ var googleGenerativeAIProviderOptions = (0, import_provider_utils3.lazySchema)(
423
423
  "21:9"
424
424
  ]).optional(),
425
425
  imageSize: import_v42.z.enum(["1K", "2K", "4K"]).optional()
426
+ }).optional(),
427
+ /**
428
+ * Optional. Configuration for grounding retrieval.
429
+ * Used to provide location context for Google Maps and Google Search grounding.
430
+ *
431
+ * https://cloud.google.com/vertex-ai/generative-ai/docs/grounding/grounding-with-google-maps
432
+ */
433
+ retrievalConfig: import_v42.z.object({
434
+ latLng: import_v42.z.object({
435
+ latitude: import_v42.z.number(),
436
+ longitude: import_v42.z.number()
437
+ }).optional()
426
438
  }).optional()
427
439
  })
428
440
  )
@@ -537,6 +549,17 @@ function prepareTools({
537
549
  });
538
550
  }
539
551
  break;
552
+ case "google.google_maps":
553
+ if (isGemini2orNewer) {
554
+ googleTools2.push({ googleMaps: {} });
555
+ } else {
556
+ toolWarnings.push({
557
+ type: "unsupported-tool",
558
+ tool,
559
+ details: "The Google Maps grounding tool is not supported with Gemini models other than Gemini 2 or newer."
560
+ });
561
+ }
562
+ break;
540
563
  default:
541
564
  toolWarnings.push({ type: "unsupported-tool", tool });
542
565
  break;
@@ -732,7 +755,10 @@ var GoogleGenerativeAILanguageModel = class {
732
755
  systemInstruction: isGemmaModel ? void 0 : systemInstruction,
733
756
  safetySettings: googleOptions == null ? void 0 : googleOptions.safetySettings,
734
757
  tools: googleTools2,
735
- toolConfig: googleToolConfig,
758
+ toolConfig: (googleOptions == null ? void 0 : googleOptions.retrievalConfig) ? {
759
+ ...googleToolConfig,
760
+ retrievalConfig: googleOptions.retrievalConfig
761
+ } : googleToolConfig,
736
762
  cachedContent: googleOptions == null ? void 0 : googleOptions.cachedContent,
737
763
  labels: googleOptions == null ? void 0 : googleOptions.labels
738
764
  },
@@ -1117,7 +1143,7 @@ function extractSources({
1117
1143
  groundingMetadata,
1118
1144
  generateId: generateId2
1119
1145
  }) {
1120
- var _a, _b, _c, _d;
1146
+ var _a, _b, _c, _d, _e;
1121
1147
  if (!(groundingMetadata == null ? void 0 : groundingMetadata.groundingChunks)) {
1122
1148
  return void 0;
1123
1149
  }
@@ -1183,6 +1209,16 @@ function extractSources({
1183
1209
  filename: fileSearchStore.split("/").pop()
1184
1210
  });
1185
1211
  }
1212
+ } else if (chunk.maps != null) {
1213
+ if (chunk.maps.uri) {
1214
+ sources.push({
1215
+ type: "source",
1216
+ sourceType: "url",
1217
+ id: generateId2(),
1218
+ url: chunk.maps.uri,
1219
+ title: (_e = chunk.maps.title) != null ? _e : void 0
1220
+ });
1221
+ }
1186
1222
  }
1187
1223
  }
1188
1224
  return sources.length > 0 ? sources : void 0;
@@ -1199,6 +1235,12 @@ var getGroundingMetadataSchema = () => import_v43.z.object({
1199
1235
  title: import_v43.z.string().nullish(),
1200
1236
  text: import_v43.z.string().nullish(),
1201
1237
  fileSearchStore: import_v43.z.string().nullish()
1238
+ }).nullish(),
1239
+ maps: import_v43.z.object({
1240
+ uri: import_v43.z.string().nullish(),
1241
+ title: import_v43.z.string().nullish(),
1242
+ text: import_v43.z.string().nullish(),
1243
+ placeId: import_v43.z.string().nullish()
1202
1244
  }).nullish()
1203
1245
  })
1204
1246
  ).nullish(),
@@ -1366,40 +1408,49 @@ var fileSearch = (0, import_provider_utils6.createProviderDefinedToolFactory)({
1366
1408
  inputSchema: fileSearchArgsSchema
1367
1409
  });
1368
1410
 
1369
- // src/tool/google-search.ts
1411
+ // src/tool/google-maps.ts
1370
1412
  var import_provider_utils7 = require("@ai-sdk/provider-utils");
1371
1413
  var import_v46 = require("zod/v4");
1372
- var googleSearch = (0, import_provider_utils7.createProviderDefinedToolFactory)({
1414
+ var googleMaps = (0, import_provider_utils7.createProviderDefinedToolFactory)({
1415
+ id: "google.google_maps",
1416
+ name: "google_maps",
1417
+ inputSchema: (0, import_provider_utils7.lazySchema)(() => (0, import_provider_utils7.zodSchema)(import_v46.z.object({})))
1418
+ });
1419
+
1420
+ // src/tool/google-search.ts
1421
+ var import_provider_utils8 = require("@ai-sdk/provider-utils");
1422
+ var import_v47 = require("zod/v4");
1423
+ var googleSearch = (0, import_provider_utils8.createProviderDefinedToolFactory)({
1373
1424
  id: "google.google_search",
1374
1425
  name: "google_search",
1375
- inputSchema: (0, import_provider_utils7.lazySchema)(
1376
- () => (0, import_provider_utils7.zodSchema)(
1377
- import_v46.z.object({
1378
- mode: import_v46.z.enum(["MODE_DYNAMIC", "MODE_UNSPECIFIED"]).default("MODE_UNSPECIFIED"),
1379
- dynamicThreshold: import_v46.z.number().default(1)
1426
+ inputSchema: (0, import_provider_utils8.lazySchema)(
1427
+ () => (0, import_provider_utils8.zodSchema)(
1428
+ import_v47.z.object({
1429
+ mode: import_v47.z.enum(["MODE_DYNAMIC", "MODE_UNSPECIFIED"]).default("MODE_UNSPECIFIED"),
1430
+ dynamicThreshold: import_v47.z.number().default(1)
1380
1431
  })
1381
1432
  )
1382
1433
  )
1383
1434
  });
1384
1435
 
1385
1436
  // src/tool/url-context.ts
1386
- var import_provider_utils8 = require("@ai-sdk/provider-utils");
1387
- var import_v47 = require("zod/v4");
1388
- var urlContext = (0, import_provider_utils8.createProviderDefinedToolFactory)({
1437
+ var import_provider_utils9 = require("@ai-sdk/provider-utils");
1438
+ var import_v48 = require("zod/v4");
1439
+ var urlContext = (0, import_provider_utils9.createProviderDefinedToolFactory)({
1389
1440
  id: "google.url_context",
1390
1441
  name: "url_context",
1391
- inputSchema: (0, import_provider_utils8.lazySchema)(() => (0, import_provider_utils8.zodSchema)(import_v47.z.object({})))
1442
+ inputSchema: (0, import_provider_utils9.lazySchema)(() => (0, import_provider_utils9.zodSchema)(import_v48.z.object({})))
1392
1443
  });
1393
1444
 
1394
1445
  // src/tool/vertex-rag-store.ts
1395
- var import_provider_utils9 = require("@ai-sdk/provider-utils");
1396
- var import_v48 = require("zod/v4");
1397
- var vertexRagStore = (0, import_provider_utils9.createProviderDefinedToolFactory)({
1446
+ var import_provider_utils10 = require("@ai-sdk/provider-utils");
1447
+ var import_v49 = require("zod/v4");
1448
+ var vertexRagStore = (0, import_provider_utils10.createProviderDefinedToolFactory)({
1398
1449
  id: "google.vertex_rag_store",
1399
1450
  name: "vertex_rag_store",
1400
- inputSchema: import_v48.z.object({
1401
- ragCorpus: import_v48.z.string(),
1402
- topK: import_v48.z.number().optional()
1451
+ inputSchema: import_v49.z.object({
1452
+ ragCorpus: import_v49.z.string(),
1453
+ topK: import_v49.z.number().optional()
1403
1454
  })
1404
1455
  });
1405
1456
 
@@ -1410,6 +1461,14 @@ var googleTools = {
1410
1461
  * Must have name "google_search".
1411
1462
  */
1412
1463
  googleSearch,
1464
+ /**
1465
+ * Creates a Google Maps grounding tool that gives the model access to Google Maps data.
1466
+ * Must have name "google_maps".
1467
+ *
1468
+ * @see https://ai.google.dev/gemini-api/docs/maps-grounding
1469
+ * @see https://cloud.google.com/vertex-ai/generative-ai/docs/grounding/grounding-with-google-maps
1470
+ */
1471
+ googleMaps,
1413
1472
  /**
1414
1473
  * Creates a URL context tool that gives Google direct access to real-time web content.
1415
1474
  * Must have name "url_context".