@ai-sdk/google 2.0.28 → 2.0.30

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.28" : "0.0.0-test";
10
+ var VERSION = true ? "2.0.30" : "0.0.0-test";
11
11
 
12
12
  // src/google-generative-ai-embedding-model.ts
13
13
  import {
@@ -600,6 +600,7 @@ function prepareTools({
600
600
  const toolWarnings = [];
601
601
  const isGemini2 = modelId.includes("gemini-2");
602
602
  const supportsDynamicRetrieval = modelId.includes("gemini-1.5-flash") && !modelId.includes("-8b");
603
+ const supportsFileSearch = modelId.includes("gemini-2.5");
603
604
  if (tools == null) {
604
605
  return { tools: void 0, toolConfig: void 0, toolWarnings };
605
606
  }
@@ -659,6 +660,17 @@ function prepareTools({
659
660
  });
660
661
  }
661
662
  break;
663
+ case "google.file_search":
664
+ if (supportsFileSearch) {
665
+ googleTools2.push({ fileSearch: { ...tool.args } });
666
+ } else {
667
+ toolWarnings.push({
668
+ type: "unsupported-tool",
669
+ tool,
670
+ details: "The file search tool is only supported with Gemini 2.5 models."
671
+ });
672
+ }
673
+ break;
662
674
  default:
663
675
  toolWarnings.push({ type: "unsupported-tool", tool });
664
676
  break;
@@ -1264,7 +1276,13 @@ var getGroundingMetadataSchema = () => z5.object({
1264
1276
  groundingChunks: z5.array(
1265
1277
  z5.object({
1266
1278
  web: z5.object({ uri: z5.string(), title: z5.string().nullish() }).nullish(),
1267
- retrievedContext: z5.object({ uri: z5.string(), title: z5.string().nullish() }).nullish()
1279
+ retrievedContext: z5.union([
1280
+ z5.object({ uri: z5.string(), title: z5.string().nullish() }).nullish(),
1281
+ z5.object({
1282
+ title: z5.string().nullish(),
1283
+ text: z5.string().nullish()
1284
+ })
1285
+ ])
1268
1286
  })
1269
1287
  ).nullish(),
1270
1288
  groundingSupports: z5.array(
@@ -1401,21 +1419,53 @@ var codeExecution = createProviderDefinedToolFactoryWithOutputSchema({
1401
1419
  })
1402
1420
  });
1403
1421
 
1404
- // src/tool/google-search.ts
1422
+ // src/tool/file-search.ts
1405
1423
  import {
1406
1424
  createProviderDefinedToolFactory,
1407
1425
  lazySchema as lazySchema6,
1408
1426
  zodSchema as zodSchema6
1409
1427
  } from "@ai-sdk/provider-utils";
1410
1428
  import { z as z7 } from "zod/v4";
1411
- var googleSearch = createProviderDefinedToolFactory({
1429
+ var fileSearchArgsBaseSchema = z7.object({
1430
+ /** The names of the file_search_stores to retrieve from.
1431
+ * Example: `fileSearchStores/my-file-search-store-123`
1432
+ */
1433
+ fileSearchStoreNames: z7.array(z7.string()).describe(
1434
+ "The names of the file_search_stores to retrieve from. Example: `fileSearchStores/my-file-search-store-123`"
1435
+ ),
1436
+ /** The number of file search retrieval chunks to retrieve. */
1437
+ topK: z7.number().int().positive().describe("The number of file search retrieval chunks to retrieve.").optional(),
1438
+ /** Metadata filter to apply to the file search retrieval documents.
1439
+ * See https://google.aip.dev/160 for the syntax of the filter expression.
1440
+ */
1441
+ metadataFilter: z7.string().describe(
1442
+ "Metadata filter to apply to the file search retrieval documents. See https://google.aip.dev/160 for the syntax of the filter expression."
1443
+ ).optional()
1444
+ }).passthrough();
1445
+ var fileSearchArgsSchema = lazySchema6(
1446
+ () => zodSchema6(fileSearchArgsBaseSchema)
1447
+ );
1448
+ var fileSearch = createProviderDefinedToolFactory({
1449
+ id: "google.file_search",
1450
+ name: "file_search",
1451
+ inputSchema: fileSearchArgsSchema
1452
+ });
1453
+
1454
+ // src/tool/google-search.ts
1455
+ import {
1456
+ createProviderDefinedToolFactory as createProviderDefinedToolFactory2,
1457
+ lazySchema as lazySchema7,
1458
+ zodSchema as zodSchema7
1459
+ } from "@ai-sdk/provider-utils";
1460
+ import { z as z8 } from "zod/v4";
1461
+ var googleSearch = createProviderDefinedToolFactory2({
1412
1462
  id: "google.google_search",
1413
1463
  name: "google_search",
1414
- inputSchema: lazySchema6(
1415
- () => zodSchema6(
1416
- z7.object({
1417
- mode: z7.enum(["MODE_DYNAMIC", "MODE_UNSPECIFIED"]).default("MODE_UNSPECIFIED"),
1418
- dynamicThreshold: z7.number().default(1)
1464
+ inputSchema: lazySchema7(
1465
+ () => zodSchema7(
1466
+ z8.object({
1467
+ mode: z8.enum(["MODE_DYNAMIC", "MODE_UNSPECIFIED"]).default("MODE_UNSPECIFIED"),
1468
+ dynamicThreshold: z8.number().default(1)
1419
1469
  })
1420
1470
  )
1421
1471
  )
@@ -1423,15 +1473,15 @@ var googleSearch = createProviderDefinedToolFactory({
1423
1473
 
1424
1474
  // src/tool/url-context.ts
1425
1475
  import {
1426
- createProviderDefinedToolFactory as createProviderDefinedToolFactory2,
1427
- lazySchema as lazySchema7,
1428
- zodSchema as zodSchema7
1476
+ createProviderDefinedToolFactory as createProviderDefinedToolFactory3,
1477
+ lazySchema as lazySchema8,
1478
+ zodSchema as zodSchema8
1429
1479
  } from "@ai-sdk/provider-utils";
1430
- import { z as z8 } from "zod/v4";
1431
- var urlContext = createProviderDefinedToolFactory2({
1480
+ import { z as z9 } from "zod/v4";
1481
+ var urlContext = createProviderDefinedToolFactory3({
1432
1482
  id: "google.url_context",
1433
1483
  name: "url_context",
1434
- inputSchema: lazySchema7(() => zodSchema7(z8.object({})))
1484
+ inputSchema: lazySchema8(() => zodSchema8(z9.object({})))
1435
1485
  });
1436
1486
 
1437
1487
  // src/google-tools.ts
@@ -1446,6 +1496,17 @@ var googleTools = {
1446
1496
  * Must have name "url_context".
1447
1497
  */
1448
1498
  urlContext,
1499
+ /**
1500
+ * Enables Retrieval Augmented Generation (RAG) via the Gemini File Search tool.
1501
+ * Must have name "file_search".
1502
+ *
1503
+ * @param fileSearchStoreNames - Fully-qualified File Search store resource names.
1504
+ * @param metadataFilter - Optional filter expression to restrict the files that can be retrieved.
1505
+ * @param topK - Optional result limit for the number of chunks returned from File Search.
1506
+ *
1507
+ * @see https://ai.google.dev/gemini-api/docs/file-search
1508
+ */
1509
+ fileSearch,
1449
1510
  /**
1450
1511
  * A tool that enables the model to generate and run Python code.
1451
1512
  * Must have name "code_execution".
@@ -1463,13 +1524,13 @@ var googleTools = {
1463
1524
  import {
1464
1525
  combineHeaders as combineHeaders3,
1465
1526
  createJsonResponseHandler as createJsonResponseHandler3,
1466
- lazySchema as lazySchema8,
1527
+ lazySchema as lazySchema9,
1467
1528
  parseProviderOptions as parseProviderOptions3,
1468
1529
  postJsonToApi as postJsonToApi3,
1469
1530
  resolve as resolve3,
1470
- zodSchema as zodSchema8
1531
+ zodSchema as zodSchema9
1471
1532
  } from "@ai-sdk/provider-utils";
1472
- import { z as z9 } from "zod/v4";
1533
+ import { z as z10 } from "zod/v4";
1473
1534
  var GoogleGenerativeAIImageModel = class {
1474
1535
  constructor(modelId, settings, config) {
1475
1536
  this.modelId = modelId;
@@ -1561,26 +1622,27 @@ var GoogleGenerativeAIImageModel = class {
1561
1622
  };
1562
1623
  }
1563
1624
  };
1564
- var googleImageResponseSchema = lazySchema8(
1565
- () => zodSchema8(
1566
- z9.object({
1567
- predictions: z9.array(z9.object({ bytesBase64Encoded: z9.string() })).default([])
1625
+ var googleImageResponseSchema = lazySchema9(
1626
+ () => zodSchema9(
1627
+ z10.object({
1628
+ predictions: z10.array(z10.object({ bytesBase64Encoded: z10.string() })).default([])
1568
1629
  })
1569
1630
  )
1570
1631
  );
1571
- var googleImageProviderOptionsSchema = lazySchema8(
1572
- () => zodSchema8(
1573
- z9.object({
1574
- personGeneration: z9.enum(["dont_allow", "allow_adult", "allow_all"]).nullish(),
1575
- aspectRatio: z9.enum(["1:1", "3:4", "4:3", "9:16", "16:9"]).nullish()
1632
+ var googleImageProviderOptionsSchema = lazySchema9(
1633
+ () => zodSchema9(
1634
+ z10.object({
1635
+ personGeneration: z10.enum(["dont_allow", "allow_adult", "allow_all"]).nullish(),
1636
+ aspectRatio: z10.enum(["1:1", "3:4", "4:3", "9:16", "16:9"]).nullish()
1576
1637
  })
1577
1638
  )
1578
1639
  );
1579
1640
 
1580
1641
  // src/google-provider.ts
1581
1642
  function createGoogleGenerativeAI(options = {}) {
1582
- var _a;
1643
+ var _a, _b;
1583
1644
  const baseURL = (_a = withoutTrailingSlash(options.baseURL)) != null ? _a : "https://generativelanguage.googleapis.com/v1beta";
1645
+ const providerName = (_b = options.name) != null ? _b : "google.generative-ai";
1584
1646
  const getHeaders = () => withUserAgentSuffix(
1585
1647
  {
1586
1648
  "x-goog-api-key": loadApiKey({
@@ -1595,7 +1657,7 @@ function createGoogleGenerativeAI(options = {}) {
1595
1657
  const createChatModel = (modelId) => {
1596
1658
  var _a2;
1597
1659
  return new GoogleGenerativeAILanguageModel(modelId, {
1598
- provider: "google.generative-ai",
1660
+ provider: providerName,
1599
1661
  baseURL,
1600
1662
  headers: getHeaders,
1601
1663
  generateId: (_a2 = options.generateId) != null ? _a2 : generateId2,
@@ -1615,13 +1677,13 @@ function createGoogleGenerativeAI(options = {}) {
1615
1677
  });
1616
1678
  };
1617
1679
  const createEmbeddingModel = (modelId) => new GoogleGenerativeAIEmbeddingModel(modelId, {
1618
- provider: "google.generative-ai",
1680
+ provider: providerName,
1619
1681
  baseURL,
1620
1682
  headers: getHeaders,
1621
1683
  fetch: options.fetch
1622
1684
  });
1623
1685
  const createImageModel = (modelId, settings = {}) => new GoogleGenerativeAIImageModel(modelId, settings, {
1624
- provider: "google.generative-ai",
1686
+ provider: providerName,
1625
1687
  baseURL,
1626
1688
  headers: getHeaders,
1627
1689
  fetch: options.fetch