@ai-sdk/google 2.0.48 → 2.0.50

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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # @ai-sdk/google
2
2
 
3
+ ## 2.0.50
4
+
5
+ ### Patch Changes
6
+
7
+ - 7c30c1d: fix(provider/google): preserve nested empty object schemas in tool parameters to fix "property is not defined" validation errors when using required properties with empty object types
8
+
9
+ ## 2.0.49
10
+
11
+ ### Patch Changes
12
+
13
+ - 3ea80e7: feat(provider/google): add enterpriseWebSearch tool
14
+
3
15
  ## 2.0.48
4
16
 
5
17
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -189,6 +189,17 @@ declare const googleTools: {
189
189
  mode?: "MODE_DYNAMIC" | "MODE_UNSPECIFIED";
190
190
  dynamicThreshold?: number;
191
191
  }>;
192
+ /**
193
+ * Creates an Enterprise Web Search tool for grounding responses using a compliance-focused web index.
194
+ * Designed for highly-regulated industries (finance, healthcare, public sector).
195
+ * Does not log customer data and supports VPC service controls.
196
+ * Must have name "enterprise_web_search".
197
+ *
198
+ * @note Only available on Vertex AI. Requires Gemini 2.0 or newer.
199
+ *
200
+ * @see https://cloud.google.com/vertex-ai/generative-ai/docs/grounding/web-grounding-enterprise
201
+ */
202
+ enterpriseWebSearch: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{}, {}>;
192
203
  /**
193
204
  * Creates a Google Maps grounding tool that gives the model access to Google Maps data.
194
205
  * Must have name "google_maps".
package/dist/index.d.ts CHANGED
@@ -189,6 +189,17 @@ declare const googleTools: {
189
189
  mode?: "MODE_DYNAMIC" | "MODE_UNSPECIFIED";
190
190
  dynamicThreshold?: number;
191
191
  }>;
192
+ /**
193
+ * Creates an Enterprise Web Search tool for grounding responses using a compliance-focused web index.
194
+ * Designed for highly-regulated industries (finance, healthcare, public sector).
195
+ * Does not log customer data and supports VPC service controls.
196
+ * Must have name "enterprise_web_search".
197
+ *
198
+ * @note Only available on Vertex AI. Requires Gemini 2.0 or newer.
199
+ *
200
+ * @see https://cloud.google.com/vertex-ai/generative-ai/docs/grounding/web-grounding-enterprise
201
+ */
202
+ enterpriseWebSearch: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{}, {}>;
192
203
  /**
193
204
  * Creates a Google Maps grounding tool that gives the model access to Google Maps data.
194
205
  * Must have name "google_maps".
package/dist/index.js CHANGED
@@ -27,10 +27,10 @@ __export(src_exports, {
27
27
  module.exports = __toCommonJS(src_exports);
28
28
 
29
29
  // src/google-provider.ts
30
- var import_provider_utils14 = require("@ai-sdk/provider-utils");
30
+ var import_provider_utils15 = require("@ai-sdk/provider-utils");
31
31
 
32
32
  // src/version.ts
33
- var VERSION = true ? "2.0.48" : "0.0.0-test";
33
+ var VERSION = true ? "2.0.50" : "0.0.0-test";
34
34
 
35
35
  // src/google-generative-ai-embedding-model.ts
36
36
  var import_provider = require("@ai-sdk/provider");
@@ -206,10 +206,16 @@ var import_provider_utils6 = require("@ai-sdk/provider-utils");
206
206
  var import_v45 = require("zod/v4");
207
207
 
208
208
  // src/convert-json-schema-to-openapi-schema.ts
209
- function convertJSONSchemaToOpenAPISchema(jsonSchema) {
210
- if (jsonSchema == null || isEmptyObjectSchema(jsonSchema)) {
209
+ function convertJSONSchemaToOpenAPISchema(jsonSchema, isRoot = true) {
210
+ if (jsonSchema == null) {
211
211
  return void 0;
212
212
  }
213
+ if (isEmptyObjectSchema(jsonSchema)) {
214
+ if (isRoot) {
215
+ return void 0;
216
+ }
217
+ return { type: "object" };
218
+ }
213
219
  if (typeof jsonSchema === "boolean") {
214
220
  return { type: "boolean", properties: {} };
215
221
  }
@@ -256,17 +262,19 @@ function convertJSONSchemaToOpenAPISchema(jsonSchema) {
256
262
  if (properties != null) {
257
263
  result.properties = Object.entries(properties).reduce(
258
264
  (acc, [key, value]) => {
259
- acc[key] = convertJSONSchemaToOpenAPISchema(value);
265
+ acc[key] = convertJSONSchemaToOpenAPISchema(value, false);
260
266
  return acc;
261
267
  },
262
268
  {}
263
269
  );
264
270
  }
265
271
  if (items) {
266
- result.items = Array.isArray(items) ? items.map(convertJSONSchemaToOpenAPISchema) : convertJSONSchemaToOpenAPISchema(items);
272
+ result.items = Array.isArray(items) ? items.map((item) => convertJSONSchemaToOpenAPISchema(item, false)) : convertJSONSchemaToOpenAPISchema(items, false);
267
273
  }
268
274
  if (allOf) {
269
- result.allOf = allOf.map(convertJSONSchemaToOpenAPISchema);
275
+ result.allOf = allOf.map(
276
+ (item) => convertJSONSchemaToOpenAPISchema(item, false)
277
+ );
270
278
  }
271
279
  if (anyOf) {
272
280
  if (anyOf.some(
@@ -276,21 +284,30 @@ function convertJSONSchemaToOpenAPISchema(jsonSchema) {
276
284
  (schema) => !(typeof schema === "object" && (schema == null ? void 0 : schema.type) === "null")
277
285
  );
278
286
  if (nonNullSchemas.length === 1) {
279
- const converted = convertJSONSchemaToOpenAPISchema(nonNullSchemas[0]);
287
+ const converted = convertJSONSchemaToOpenAPISchema(
288
+ nonNullSchemas[0],
289
+ false
290
+ );
280
291
  if (typeof converted === "object") {
281
292
  result.nullable = true;
282
293
  Object.assign(result, converted);
283
294
  }
284
295
  } else {
285
- result.anyOf = nonNullSchemas.map(convertJSONSchemaToOpenAPISchema);
296
+ result.anyOf = nonNullSchemas.map(
297
+ (item) => convertJSONSchemaToOpenAPISchema(item, false)
298
+ );
286
299
  result.nullable = true;
287
300
  }
288
301
  } else {
289
- result.anyOf = anyOf.map(convertJSONSchemaToOpenAPISchema);
302
+ result.anyOf = anyOf.map(
303
+ (item) => convertJSONSchemaToOpenAPISchema(item, false)
304
+ );
290
305
  }
291
306
  }
292
307
  if (oneOf) {
293
- result.oneOf = oneOf.map(convertJSONSchemaToOpenAPISchema);
308
+ result.oneOf = oneOf.map(
309
+ (item) => convertJSONSchemaToOpenAPISchema(item, false)
310
+ );
294
311
  }
295
312
  if (minLength !== void 0) {
296
313
  result.minLength = minLength;
@@ -651,6 +668,17 @@ function prepareTools({
651
668
  googleTools2.push({ googleSearchRetrieval: {} });
652
669
  }
653
670
  break;
671
+ case "google.enterprise_web_search":
672
+ if (isGemini2orNewer) {
673
+ googleTools2.push({ enterpriseWebSearch: {} });
674
+ } else {
675
+ toolWarnings.push({
676
+ type: "unsupported-tool",
677
+ tool,
678
+ details: "Enterprise Web Search requires Gemini 2.0 or newer."
679
+ });
680
+ }
681
+ break;
654
682
  case "google.url_context":
655
683
  if (isGemini2orNewer) {
656
684
  googleTools2.push({ urlContext: {} });
@@ -1535,77 +1563,86 @@ var codeExecution = (0, import_provider_utils7.createProviderDefinedToolFactoryW
1535
1563
  })
1536
1564
  });
1537
1565
 
1538
- // src/tool/file-search.ts
1566
+ // src/tool/enterprise-web-search.ts
1539
1567
  var import_provider_utils8 = require("@ai-sdk/provider-utils");
1540
1568
  var import_v47 = require("zod/v4");
1541
- var fileSearchArgsBaseSchema = import_v47.z.object({
1569
+ var enterpriseWebSearch = (0, import_provider_utils8.createProviderDefinedToolFactory)({
1570
+ id: "google.enterprise_web_search",
1571
+ name: "enterprise_web_search",
1572
+ inputSchema: (0, import_provider_utils8.lazySchema)(() => (0, import_provider_utils8.zodSchema)(import_v47.z.object({})))
1573
+ });
1574
+
1575
+ // src/tool/file-search.ts
1576
+ var import_provider_utils9 = require("@ai-sdk/provider-utils");
1577
+ var import_v48 = require("zod/v4");
1578
+ var fileSearchArgsBaseSchema = import_v48.z.object({
1542
1579
  /** The names of the file_search_stores to retrieve from.
1543
1580
  * Example: `fileSearchStores/my-file-search-store-123`
1544
1581
  */
1545
- fileSearchStoreNames: import_v47.z.array(import_v47.z.string()).describe(
1582
+ fileSearchStoreNames: import_v48.z.array(import_v48.z.string()).describe(
1546
1583
  "The names of the file_search_stores to retrieve from. Example: `fileSearchStores/my-file-search-store-123`"
1547
1584
  ),
1548
1585
  /** The number of file search retrieval chunks to retrieve. */
1549
- topK: import_v47.z.number().int().positive().describe("The number of file search retrieval chunks to retrieve.").optional(),
1586
+ topK: import_v48.z.number().int().positive().describe("The number of file search retrieval chunks to retrieve.").optional(),
1550
1587
  /** Metadata filter to apply to the file search retrieval documents.
1551
1588
  * See https://google.aip.dev/160 for the syntax of the filter expression.
1552
1589
  */
1553
- metadataFilter: import_v47.z.string().describe(
1590
+ metadataFilter: import_v48.z.string().describe(
1554
1591
  "Metadata filter to apply to the file search retrieval documents. See https://google.aip.dev/160 for the syntax of the filter expression."
1555
1592
  ).optional()
1556
1593
  }).passthrough();
1557
- var fileSearchArgsSchema = (0, import_provider_utils8.lazySchema)(
1558
- () => (0, import_provider_utils8.zodSchema)(fileSearchArgsBaseSchema)
1594
+ var fileSearchArgsSchema = (0, import_provider_utils9.lazySchema)(
1595
+ () => (0, import_provider_utils9.zodSchema)(fileSearchArgsBaseSchema)
1559
1596
  );
1560
- var fileSearch = (0, import_provider_utils8.createProviderDefinedToolFactory)({
1597
+ var fileSearch = (0, import_provider_utils9.createProviderDefinedToolFactory)({
1561
1598
  id: "google.file_search",
1562
1599
  name: "file_search",
1563
1600
  inputSchema: fileSearchArgsSchema
1564
1601
  });
1565
1602
 
1566
1603
  // src/tool/google-maps.ts
1567
- var import_provider_utils9 = require("@ai-sdk/provider-utils");
1568
- var import_v48 = require("zod/v4");
1569
- var googleMaps = (0, import_provider_utils9.createProviderDefinedToolFactory)({
1604
+ var import_provider_utils10 = require("@ai-sdk/provider-utils");
1605
+ var import_v49 = require("zod/v4");
1606
+ var googleMaps = (0, import_provider_utils10.createProviderDefinedToolFactory)({
1570
1607
  id: "google.google_maps",
1571
1608
  name: "google_maps",
1572
- inputSchema: (0, import_provider_utils9.lazySchema)(() => (0, import_provider_utils9.zodSchema)(import_v48.z.object({})))
1609
+ inputSchema: (0, import_provider_utils10.lazySchema)(() => (0, import_provider_utils10.zodSchema)(import_v49.z.object({})))
1573
1610
  });
1574
1611
 
1575
1612
  // src/tool/google-search.ts
1576
- var import_provider_utils10 = require("@ai-sdk/provider-utils");
1577
- var import_v49 = require("zod/v4");
1578
- var googleSearch = (0, import_provider_utils10.createProviderDefinedToolFactory)({
1613
+ var import_provider_utils11 = require("@ai-sdk/provider-utils");
1614
+ var import_v410 = require("zod/v4");
1615
+ var googleSearch = (0, import_provider_utils11.createProviderDefinedToolFactory)({
1579
1616
  id: "google.google_search",
1580
1617
  name: "google_search",
1581
- inputSchema: (0, import_provider_utils10.lazySchema)(
1582
- () => (0, import_provider_utils10.zodSchema)(
1583
- import_v49.z.object({
1584
- mode: import_v49.z.enum(["MODE_DYNAMIC", "MODE_UNSPECIFIED"]).default("MODE_UNSPECIFIED"),
1585
- dynamicThreshold: import_v49.z.number().default(1)
1618
+ inputSchema: (0, import_provider_utils11.lazySchema)(
1619
+ () => (0, import_provider_utils11.zodSchema)(
1620
+ import_v410.z.object({
1621
+ mode: import_v410.z.enum(["MODE_DYNAMIC", "MODE_UNSPECIFIED"]).default("MODE_UNSPECIFIED"),
1622
+ dynamicThreshold: import_v410.z.number().default(1)
1586
1623
  })
1587
1624
  )
1588
1625
  )
1589
1626
  });
1590
1627
 
1591
1628
  // src/tool/url-context.ts
1592
- var import_provider_utils11 = require("@ai-sdk/provider-utils");
1593
- var import_v410 = require("zod/v4");
1594
- var urlContext = (0, import_provider_utils11.createProviderDefinedToolFactory)({
1629
+ var import_provider_utils12 = require("@ai-sdk/provider-utils");
1630
+ var import_v411 = require("zod/v4");
1631
+ var urlContext = (0, import_provider_utils12.createProviderDefinedToolFactory)({
1595
1632
  id: "google.url_context",
1596
1633
  name: "url_context",
1597
- inputSchema: (0, import_provider_utils11.lazySchema)(() => (0, import_provider_utils11.zodSchema)(import_v410.z.object({})))
1634
+ inputSchema: (0, import_provider_utils12.lazySchema)(() => (0, import_provider_utils12.zodSchema)(import_v411.z.object({})))
1598
1635
  });
1599
1636
 
1600
1637
  // src/tool/vertex-rag-store.ts
1601
- var import_provider_utils12 = require("@ai-sdk/provider-utils");
1602
- var import_v411 = require("zod/v4");
1603
- var vertexRagStore = (0, import_provider_utils12.createProviderDefinedToolFactory)({
1638
+ var import_provider_utils13 = require("@ai-sdk/provider-utils");
1639
+ var import_v412 = require("zod/v4");
1640
+ var vertexRagStore = (0, import_provider_utils13.createProviderDefinedToolFactory)({
1604
1641
  id: "google.vertex_rag_store",
1605
1642
  name: "vertex_rag_store",
1606
- inputSchema: import_v411.z.object({
1607
- ragCorpus: import_v411.z.string(),
1608
- topK: import_v411.z.number().optional()
1643
+ inputSchema: import_v412.z.object({
1644
+ ragCorpus: import_v412.z.string(),
1645
+ topK: import_v412.z.number().optional()
1609
1646
  })
1610
1647
  });
1611
1648
 
@@ -1616,6 +1653,17 @@ var googleTools = {
1616
1653
  * Must have name "google_search".
1617
1654
  */
1618
1655
  googleSearch,
1656
+ /**
1657
+ * Creates an Enterprise Web Search tool for grounding responses using a compliance-focused web index.
1658
+ * Designed for highly-regulated industries (finance, healthcare, public sector).
1659
+ * Does not log customer data and supports VPC service controls.
1660
+ * Must have name "enterprise_web_search".
1661
+ *
1662
+ * @note Only available on Vertex AI. Requires Gemini 2.0 or newer.
1663
+ *
1664
+ * @see https://cloud.google.com/vertex-ai/generative-ai/docs/grounding/web-grounding-enterprise
1665
+ */
1666
+ enterpriseWebSearch,
1619
1667
  /**
1620
1668
  * Creates a Google Maps grounding tool that gives the model access to Google Maps data.
1621
1669
  * Must have name "google_maps".
@@ -1659,8 +1707,8 @@ var googleTools = {
1659
1707
  };
1660
1708
 
1661
1709
  // src/google-generative-ai-image-model.ts
1662
- var import_provider_utils13 = require("@ai-sdk/provider-utils");
1663
- var import_v412 = require("zod/v4");
1710
+ var import_provider_utils14 = require("@ai-sdk/provider-utils");
1711
+ var import_v413 = require("zod/v4");
1664
1712
  var GoogleGenerativeAIImageModel = class {
1665
1713
  constructor(modelId, settings, config) {
1666
1714
  this.modelId = modelId;
@@ -1702,7 +1750,7 @@ var GoogleGenerativeAIImageModel = class {
1702
1750
  details: "This model does not support the `seed` option through this provider."
1703
1751
  });
1704
1752
  }
1705
- const googleOptions = await (0, import_provider_utils13.parseProviderOptions)({
1753
+ const googleOptions = await (0, import_provider_utils14.parseProviderOptions)({
1706
1754
  provider: "google",
1707
1755
  providerOptions,
1708
1756
  schema: googleImageProviderOptionsSchema
@@ -1721,12 +1769,12 @@ var GoogleGenerativeAIImageModel = class {
1721
1769
  instances: [{ prompt }],
1722
1770
  parameters
1723
1771
  };
1724
- const { responseHeaders, value: response } = await (0, import_provider_utils13.postJsonToApi)({
1772
+ const { responseHeaders, value: response } = await (0, import_provider_utils14.postJsonToApi)({
1725
1773
  url: `${this.config.baseURL}/models/${this.modelId}:predict`,
1726
- headers: (0, import_provider_utils13.combineHeaders)(await (0, import_provider_utils13.resolve)(this.config.headers), headers),
1774
+ headers: (0, import_provider_utils14.combineHeaders)(await (0, import_provider_utils14.resolve)(this.config.headers), headers),
1727
1775
  body,
1728
1776
  failedResponseHandler: googleFailedResponseHandler,
1729
- successfulResponseHandler: (0, import_provider_utils13.createJsonResponseHandler)(
1777
+ successfulResponseHandler: (0, import_provider_utils14.createJsonResponseHandler)(
1730
1778
  googleImageResponseSchema
1731
1779
  ),
1732
1780
  abortSignal,
@@ -1752,18 +1800,18 @@ var GoogleGenerativeAIImageModel = class {
1752
1800
  };
1753
1801
  }
1754
1802
  };
1755
- var googleImageResponseSchema = (0, import_provider_utils13.lazySchema)(
1756
- () => (0, import_provider_utils13.zodSchema)(
1757
- import_v412.z.object({
1758
- predictions: import_v412.z.array(import_v412.z.object({ bytesBase64Encoded: import_v412.z.string() })).default([])
1803
+ var googleImageResponseSchema = (0, import_provider_utils14.lazySchema)(
1804
+ () => (0, import_provider_utils14.zodSchema)(
1805
+ import_v413.z.object({
1806
+ predictions: import_v413.z.array(import_v413.z.object({ bytesBase64Encoded: import_v413.z.string() })).default([])
1759
1807
  })
1760
1808
  )
1761
1809
  );
1762
- var googleImageProviderOptionsSchema = (0, import_provider_utils13.lazySchema)(
1763
- () => (0, import_provider_utils13.zodSchema)(
1764
- import_v412.z.object({
1765
- personGeneration: import_v412.z.enum(["dont_allow", "allow_adult", "allow_all"]).nullish(),
1766
- aspectRatio: import_v412.z.enum(["1:1", "3:4", "4:3", "9:16", "16:9"]).nullish()
1810
+ var googleImageProviderOptionsSchema = (0, import_provider_utils14.lazySchema)(
1811
+ () => (0, import_provider_utils14.zodSchema)(
1812
+ import_v413.z.object({
1813
+ personGeneration: import_v413.z.enum(["dont_allow", "allow_adult", "allow_all"]).nullish(),
1814
+ aspectRatio: import_v413.z.enum(["1:1", "3:4", "4:3", "9:16", "16:9"]).nullish()
1767
1815
  })
1768
1816
  )
1769
1817
  );
@@ -1771,11 +1819,11 @@ var googleImageProviderOptionsSchema = (0, import_provider_utils13.lazySchema)(
1771
1819
  // src/google-provider.ts
1772
1820
  function createGoogleGenerativeAI(options = {}) {
1773
1821
  var _a, _b;
1774
- const baseURL = (_a = (0, import_provider_utils14.withoutTrailingSlash)(options.baseURL)) != null ? _a : "https://generativelanguage.googleapis.com/v1beta";
1822
+ const baseURL = (_a = (0, import_provider_utils15.withoutTrailingSlash)(options.baseURL)) != null ? _a : "https://generativelanguage.googleapis.com/v1beta";
1775
1823
  const providerName = (_b = options.name) != null ? _b : "google.generative-ai";
1776
- const getHeaders = () => (0, import_provider_utils14.withUserAgentSuffix)(
1824
+ const getHeaders = () => (0, import_provider_utils15.withUserAgentSuffix)(
1777
1825
  {
1778
- "x-goog-api-key": (0, import_provider_utils14.loadApiKey)({
1826
+ "x-goog-api-key": (0, import_provider_utils15.loadApiKey)({
1779
1827
  apiKey: options.apiKey,
1780
1828
  environmentVariableName: "GOOGLE_GENERATIVE_AI_API_KEY",
1781
1829
  description: "Google Generative AI"
@@ -1790,7 +1838,7 @@ function createGoogleGenerativeAI(options = {}) {
1790
1838
  provider: providerName,
1791
1839
  baseURL,
1792
1840
  headers: getHeaders,
1793
- generateId: (_a2 = options.generateId) != null ? _a2 : import_provider_utils14.generateId,
1841
+ generateId: (_a2 = options.generateId) != null ? _a2 : import_provider_utils15.generateId,
1794
1842
  supportedUrls: () => ({
1795
1843
  "*": [
1796
1844
  // Google Generative Language "files" endpoint