@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/CHANGELOG.md +14 -0
- package/dist/index.d.mts +16 -2
- package/dist/index.d.ts +16 -2
- package/dist/index.js +45 -28
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +45 -28
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +23 -2
- package/dist/internal/index.d.ts +23 -2
- package/dist/internal/index.js +44 -27
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +44 -27
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +2 -2
|
@@ -30,6 +30,7 @@ declare class GoogleGenerativeAILanguageModel implements LanguageModelV2 {
|
|
|
30
30
|
}
|
|
31
31
|
declare const getGroundingMetadataSchema: () => z.ZodObject<{
|
|
32
32
|
webSearchQueries: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
33
|
+
imageSearchQueries: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
33
34
|
retrievalQueries: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
34
35
|
searchEntryPoint: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
35
36
|
renderedContent: z.ZodString;
|
|
@@ -39,6 +40,12 @@ declare const getGroundingMetadataSchema: () => z.ZodObject<{
|
|
|
39
40
|
uri: z.ZodString;
|
|
40
41
|
title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
41
42
|
}, z.core.$strip>>>;
|
|
43
|
+
image: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
44
|
+
sourceUri: z.ZodString;
|
|
45
|
+
imageUri: z.ZodString;
|
|
46
|
+
title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
47
|
+
domain: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
48
|
+
}, z.core.$strip>>>;
|
|
42
49
|
retrievedContext: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
43
50
|
uri: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
44
51
|
title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
@@ -113,6 +120,7 @@ declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
113
120
|
}[] | null | undefined;
|
|
114
121
|
groundingMetadata?: {
|
|
115
122
|
webSearchQueries?: string[] | null | undefined;
|
|
123
|
+
imageSearchQueries?: string[] | null | undefined;
|
|
116
124
|
retrievalQueries?: string[] | null | undefined;
|
|
117
125
|
searchEntryPoint?: {
|
|
118
126
|
renderedContent: string;
|
|
@@ -122,6 +130,12 @@ declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
122
130
|
uri: string;
|
|
123
131
|
title?: string | null | undefined;
|
|
124
132
|
} | null | undefined;
|
|
133
|
+
image?: {
|
|
134
|
+
sourceUri: string;
|
|
135
|
+
imageUri: string;
|
|
136
|
+
title?: string | null | undefined;
|
|
137
|
+
domain?: string | null | undefined;
|
|
138
|
+
} | null | undefined;
|
|
125
139
|
retrievedContext?: {
|
|
126
140
|
uri?: string | null | undefined;
|
|
127
141
|
title?: string | null | undefined;
|
|
@@ -188,8 +202,15 @@ declare const googleTools: {
|
|
|
188
202
|
* Must have name "google_search".
|
|
189
203
|
*/
|
|
190
204
|
googleSearch: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{}, {
|
|
191
|
-
|
|
192
|
-
|
|
205
|
+
[x: string]: unknown;
|
|
206
|
+
searchTypes?: {
|
|
207
|
+
webSearch?: Record<string, never> | undefined;
|
|
208
|
+
imageSearch?: Record<string, never> | undefined;
|
|
209
|
+
} | undefined;
|
|
210
|
+
timeRangeFilter?: {
|
|
211
|
+
startTime: string;
|
|
212
|
+
endTime: string;
|
|
213
|
+
} | undefined;
|
|
193
214
|
}>;
|
|
194
215
|
/**
|
|
195
216
|
* Creates an Enterprise Web Search tool for grounding responses using a compliance-focused web index.
|
package/dist/internal/index.d.ts
CHANGED
|
@@ -30,6 +30,7 @@ declare class GoogleGenerativeAILanguageModel implements LanguageModelV2 {
|
|
|
30
30
|
}
|
|
31
31
|
declare const getGroundingMetadataSchema: () => z.ZodObject<{
|
|
32
32
|
webSearchQueries: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
33
|
+
imageSearchQueries: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
33
34
|
retrievalQueries: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
34
35
|
searchEntryPoint: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
35
36
|
renderedContent: z.ZodString;
|
|
@@ -39,6 +40,12 @@ declare const getGroundingMetadataSchema: () => z.ZodObject<{
|
|
|
39
40
|
uri: z.ZodString;
|
|
40
41
|
title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
41
42
|
}, z.core.$strip>>>;
|
|
43
|
+
image: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
44
|
+
sourceUri: z.ZodString;
|
|
45
|
+
imageUri: z.ZodString;
|
|
46
|
+
title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
47
|
+
domain: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
48
|
+
}, z.core.$strip>>>;
|
|
42
49
|
retrievedContext: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
43
50
|
uri: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
44
51
|
title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
@@ -113,6 +120,7 @@ declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
113
120
|
}[] | null | undefined;
|
|
114
121
|
groundingMetadata?: {
|
|
115
122
|
webSearchQueries?: string[] | null | undefined;
|
|
123
|
+
imageSearchQueries?: string[] | null | undefined;
|
|
116
124
|
retrievalQueries?: string[] | null | undefined;
|
|
117
125
|
searchEntryPoint?: {
|
|
118
126
|
renderedContent: string;
|
|
@@ -122,6 +130,12 @@ declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
122
130
|
uri: string;
|
|
123
131
|
title?: string | null | undefined;
|
|
124
132
|
} | null | undefined;
|
|
133
|
+
image?: {
|
|
134
|
+
sourceUri: string;
|
|
135
|
+
imageUri: string;
|
|
136
|
+
title?: string | null | undefined;
|
|
137
|
+
domain?: string | null | undefined;
|
|
138
|
+
} | null | undefined;
|
|
125
139
|
retrievedContext?: {
|
|
126
140
|
uri?: string | null | undefined;
|
|
127
141
|
title?: string | null | undefined;
|
|
@@ -188,8 +202,15 @@ declare const googleTools: {
|
|
|
188
202
|
* Must have name "google_search".
|
|
189
203
|
*/
|
|
190
204
|
googleSearch: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{}, {
|
|
191
|
-
|
|
192
|
-
|
|
205
|
+
[x: string]: unknown;
|
|
206
|
+
searchTypes?: {
|
|
207
|
+
webSearch?: Record<string, never> | undefined;
|
|
208
|
+
imageSearch?: Record<string, never> | undefined;
|
|
209
|
+
} | undefined;
|
|
210
|
+
timeRangeFilter?: {
|
|
211
|
+
startTime: string;
|
|
212
|
+
endTime: string;
|
|
213
|
+
} | undefined;
|
|
193
214
|
}>;
|
|
194
215
|
/**
|
|
195
216
|
* Creates an Enterprise Web Search tool for grounding responses using a compliance-focused web index.
|
package/dist/internal/index.js
CHANGED
|
@@ -479,9 +479,8 @@ function prepareTools({
|
|
|
479
479
|
"gemini-flash-lite-latest",
|
|
480
480
|
"gemini-pro-latest"
|
|
481
481
|
].some((id) => id === modelId);
|
|
482
|
-
const isGemini2orNewer = modelId.includes("gemini-2") || modelId.includes("gemini-3") || isLatest;
|
|
483
|
-
const
|
|
484
|
-
const supportsFileSearch = modelId.includes("gemini-2.5");
|
|
482
|
+
const isGemini2orNewer = modelId.includes("gemini-2") || modelId.includes("gemini-3") || modelId.includes("nano-banana") || isLatest;
|
|
483
|
+
const supportsFileSearch = modelId.includes("gemini-2.5") || modelId.includes("gemini-3");
|
|
485
484
|
if (tools == null) {
|
|
486
485
|
return { tools: void 0, toolConfig: void 0, toolWarnings };
|
|
487
486
|
}
|
|
@@ -506,18 +505,13 @@ function prepareTools({
|
|
|
506
505
|
switch (tool.id) {
|
|
507
506
|
case "google.google_search":
|
|
508
507
|
if (isGemini2orNewer) {
|
|
509
|
-
googleTools2.push({ googleSearch: {} });
|
|
510
|
-
} else if (supportsDynamicRetrieval) {
|
|
511
|
-
googleTools2.push({
|
|
512
|
-
googleSearchRetrieval: {
|
|
513
|
-
dynamicRetrievalConfig: {
|
|
514
|
-
mode: tool.args.mode,
|
|
515
|
-
dynamicThreshold: tool.args.dynamicThreshold
|
|
516
|
-
}
|
|
517
|
-
}
|
|
518
|
-
});
|
|
508
|
+
googleTools2.push({ googleSearch: { ...tool.args } });
|
|
519
509
|
} else {
|
|
520
|
-
|
|
510
|
+
toolWarnings.push({
|
|
511
|
+
type: "unsupported-tool",
|
|
512
|
+
tool,
|
|
513
|
+
details: "Google Search requires Gemini 2.0 or newer."
|
|
514
|
+
});
|
|
521
515
|
}
|
|
522
516
|
break;
|
|
523
517
|
case "google.enterprise_web_search":
|
|
@@ -1190,7 +1184,7 @@ function extractSources({
|
|
|
1190
1184
|
groundingMetadata,
|
|
1191
1185
|
generateId: generateId2
|
|
1192
1186
|
}) {
|
|
1193
|
-
var _a, _b, _c, _d, _e;
|
|
1187
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1194
1188
|
if (!(groundingMetadata == null ? void 0 : groundingMetadata.groundingChunks)) {
|
|
1195
1189
|
return void 0;
|
|
1196
1190
|
}
|
|
@@ -1204,6 +1198,16 @@ function extractSources({
|
|
|
1204
1198
|
url: chunk.web.uri,
|
|
1205
1199
|
title: (_a = chunk.web.title) != null ? _a : void 0
|
|
1206
1200
|
});
|
|
1201
|
+
} else if (chunk.image != null) {
|
|
1202
|
+
sources.push({
|
|
1203
|
+
type: "source",
|
|
1204
|
+
sourceType: "url",
|
|
1205
|
+
id: generateId2(),
|
|
1206
|
+
// Google requires attribution to the source URI, not the actual image URI.
|
|
1207
|
+
// TODO: add another type in v7 to allow both the image and source URL to be included separately
|
|
1208
|
+
url: chunk.image.sourceUri,
|
|
1209
|
+
title: (_b = chunk.image.title) != null ? _b : void 0
|
|
1210
|
+
});
|
|
1207
1211
|
} else if (chunk.retrievedContext != null) {
|
|
1208
1212
|
const uri = chunk.retrievedContext.uri;
|
|
1209
1213
|
const fileSearchStore = chunk.retrievedContext.fileSearchStore;
|
|
@@ -1213,10 +1217,10 @@ function extractSources({
|
|
|
1213
1217
|
sourceType: "url",
|
|
1214
1218
|
id: generateId2(),
|
|
1215
1219
|
url: uri,
|
|
1216
|
-
title: (
|
|
1220
|
+
title: (_c = chunk.retrievedContext.title) != null ? _c : void 0
|
|
1217
1221
|
});
|
|
1218
1222
|
} else if (uri) {
|
|
1219
|
-
const title = (
|
|
1223
|
+
const title = (_d = chunk.retrievedContext.title) != null ? _d : "Unknown Document";
|
|
1220
1224
|
let mediaType = "application/octet-stream";
|
|
1221
1225
|
let filename = void 0;
|
|
1222
1226
|
if (uri.endsWith(".pdf")) {
|
|
@@ -1246,7 +1250,7 @@ function extractSources({
|
|
|
1246
1250
|
filename
|
|
1247
1251
|
});
|
|
1248
1252
|
} else if (fileSearchStore) {
|
|
1249
|
-
const title = (
|
|
1253
|
+
const title = (_e = chunk.retrievedContext.title) != null ? _e : "Unknown Document";
|
|
1250
1254
|
sources.push({
|
|
1251
1255
|
type: "source",
|
|
1252
1256
|
sourceType: "document",
|
|
@@ -1263,7 +1267,7 @@ function extractSources({
|
|
|
1263
1267
|
sourceType: "url",
|
|
1264
1268
|
id: generateId2(),
|
|
1265
1269
|
url: chunk.maps.uri,
|
|
1266
|
-
title: (
|
|
1270
|
+
title: (_f = chunk.maps.title) != null ? _f : void 0
|
|
1267
1271
|
});
|
|
1268
1272
|
}
|
|
1269
1273
|
}
|
|
@@ -1272,11 +1276,18 @@ function extractSources({
|
|
|
1272
1276
|
}
|
|
1273
1277
|
var getGroundingMetadataSchema = () => import_v43.z.object({
|
|
1274
1278
|
webSearchQueries: import_v43.z.array(import_v43.z.string()).nullish(),
|
|
1279
|
+
imageSearchQueries: import_v43.z.array(import_v43.z.string()).nullish(),
|
|
1275
1280
|
retrievalQueries: import_v43.z.array(import_v43.z.string()).nullish(),
|
|
1276
1281
|
searchEntryPoint: import_v43.z.object({ renderedContent: import_v43.z.string() }).nullish(),
|
|
1277
1282
|
groundingChunks: import_v43.z.array(
|
|
1278
1283
|
import_v43.z.object({
|
|
1279
1284
|
web: import_v43.z.object({ uri: import_v43.z.string(), title: import_v43.z.string().nullish() }).nullish(),
|
|
1285
|
+
image: import_v43.z.object({
|
|
1286
|
+
sourceUri: import_v43.z.string(),
|
|
1287
|
+
imageUri: import_v43.z.string(),
|
|
1288
|
+
title: import_v43.z.string().nullish(),
|
|
1289
|
+
domain: import_v43.z.string().nullish()
|
|
1290
|
+
}).nullish(),
|
|
1280
1291
|
retrievedContext: import_v43.z.object({
|
|
1281
1292
|
uri: import_v43.z.string().nullish(),
|
|
1282
1293
|
title: import_v43.z.string().nullish(),
|
|
@@ -1476,17 +1487,23 @@ var googleMaps = (0, import_provider_utils8.createProviderDefinedToolFactory)({
|
|
|
1476
1487
|
// src/tool/google-search.ts
|
|
1477
1488
|
var import_provider_utils9 = require("@ai-sdk/provider-utils");
|
|
1478
1489
|
var import_v48 = require("zod/v4");
|
|
1490
|
+
var googleSearchToolArgsBaseSchema = import_v48.z.object({
|
|
1491
|
+
searchTypes: import_v48.z.object({
|
|
1492
|
+
webSearch: import_v48.z.object({}).optional(),
|
|
1493
|
+
imageSearch: import_v48.z.object({}).optional()
|
|
1494
|
+
}).optional(),
|
|
1495
|
+
timeRangeFilter: import_v48.z.object({
|
|
1496
|
+
startTime: import_v48.z.string(),
|
|
1497
|
+
endTime: import_v48.z.string()
|
|
1498
|
+
}).optional()
|
|
1499
|
+
}).passthrough();
|
|
1500
|
+
var googleSearchToolArgsSchema = (0, import_provider_utils9.lazySchema)(
|
|
1501
|
+
() => (0, import_provider_utils9.zodSchema)(googleSearchToolArgsBaseSchema)
|
|
1502
|
+
);
|
|
1479
1503
|
var googleSearch = (0, import_provider_utils9.createProviderDefinedToolFactory)({
|
|
1480
1504
|
id: "google.google_search",
|
|
1481
1505
|
name: "google_search",
|
|
1482
|
-
inputSchema:
|
|
1483
|
-
() => (0, import_provider_utils9.zodSchema)(
|
|
1484
|
-
import_v48.z.object({
|
|
1485
|
-
mode: import_v48.z.enum(["MODE_DYNAMIC", "MODE_UNSPECIFIED"]).default("MODE_UNSPECIFIED"),
|
|
1486
|
-
dynamicThreshold: import_v48.z.number().default(1)
|
|
1487
|
-
})
|
|
1488
|
-
)
|
|
1489
|
-
)
|
|
1506
|
+
inputSchema: googleSearchToolArgsSchema
|
|
1490
1507
|
});
|
|
1491
1508
|
|
|
1492
1509
|
// src/tool/url-context.ts
|