@ai-sdk/gateway 4.0.139 → 4.0.142

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.
@@ -51,25 +51,22 @@ export type DeepSeekSearchOutput = DeepSeekSearchResponse | GatewayToolError;
51
51
  const deepseekSearchInputSchema = lazySchema(() =>
52
52
  zodSchema(
53
53
  z.object({
54
- query: z
55
- .string()
56
- .describe(
57
- 'Web search query, 1 to 128 Unicode characters. Supports site:, -site:, lang:, after:, before:, and quoted phrases.',
58
- ),
59
- count: z
60
- .number()
61
- .int()
62
- .optional()
63
- .describe('Number of results, 1 to 50 (default: 10).'),
64
- need_content: z
65
- .boolean()
66
- .optional()
67
- .describe('Include available page content (default: false).'),
68
- ori_question: z
69
- .string()
70
- .nullable()
71
- .optional()
72
- .describe('Original user question, 1 to 128 Unicode characters.'),
54
+ query: z.describe(
55
+ z.string(),
56
+ 'Web search query, 1 to 128 Unicode characters. Supports site:, -site:, lang:, after:, before:, and quoted phrases.',
57
+ ),
58
+ count: z.describe(
59
+ z.optional(z.number().check(z.int())),
60
+ 'Number of results, 1 to 50 (default: 10).',
61
+ ),
62
+ need_content: z.describe(
63
+ z.optional(z.boolean()),
64
+ 'Include available page content (default: false).',
65
+ ),
66
+ ori_question: z.describe(
67
+ z.optional(z.nullable(z.string())),
68
+ 'Original user question, 1 to 128 Unicode characters.',
69
+ ),
73
70
  }),
74
71
  ),
75
72
  );
@@ -77,26 +74,28 @@ const deepseekSearchInputSchema = lazySchema(() =>
77
74
  const deepseekSearchOutputSchema = lazySchema(() =>
78
75
  zodSchema(
79
76
  z.union([
80
- z
81
- .object({
77
+ z.catchall(
78
+ z.object({
82
79
  results: z.array(
83
- z
84
- .object({
85
- authority: z.number().nullish(),
86
- content: z.string().nullish(),
87
- date: z.string().nullish(),
88
- rerank_score: z.number().nullish(),
89
- site_icon: z.string().nullish(),
90
- site_name: z.string().nullish(),
91
- snippet: z.string().nullish(),
92
- summary: z.string().nullish(),
93
- title: z.string().nullish(),
94
- url: z.string().nullish(),
95
- })
96
- .passthrough(),
80
+ z.catchall(
81
+ z.object({
82
+ authority: z.nullish(z.number()),
83
+ content: z.nullish(z.string()),
84
+ date: z.nullish(z.string()),
85
+ rerank_score: z.nullish(z.number()),
86
+ site_icon: z.nullish(z.string()),
87
+ site_name: z.nullish(z.string()),
88
+ snippet: z.nullish(z.string()),
89
+ summary: z.nullish(z.string()),
90
+ title: z.nullish(z.string()),
91
+ url: z.nullish(z.string()),
92
+ }),
93
+ z.unknown(),
94
+ ),
97
95
  ),
98
- })
99
- .passthrough(),
96
+ }),
97
+ z.unknown(),
98
+ ),
100
99
  gatewayToolErrorSchema(),
101
100
  ]),
102
101
  ),
@@ -176,110 +176,117 @@ export type ExaSearchOutput = ExaSearchResponse | ExaSearchError;
176
176
  const exaSearchInputSchema = lazySchema(() =>
177
177
  zodSchema(
178
178
  z.object({
179
- query: z
180
- .string()
181
- .describe('Natural-language web search query. This is required.'),
182
- type: z
183
- .enum(['auto', 'fast', 'instant'])
184
- .optional()
185
- .describe(
186
- 'Search method. Use auto for the default balance of speed and quality.',
179
+ query: z.describe(
180
+ z.string(),
181
+ 'Natural-language web search query. This is required.',
182
+ ),
183
+ type: z.describe(
184
+ z.optional(z.enum(['auto', 'fast', 'instant'])),
185
+ 'Search method. Use auto for the default balance of speed and quality.',
186
+ ),
187
+ num_results: z.describe(
188
+ z.optional(z.number()),
189
+ 'Maximum number of results to return (1-100, default: 10).',
190
+ ),
191
+ category: z.describe(
192
+ z.optional(
193
+ z.enum([
194
+ 'company',
195
+ 'people',
196
+ 'research paper',
197
+ 'news',
198
+ 'personal site',
199
+ 'financial report',
200
+ ]),
187
201
  ),
188
- num_results: z
189
- .number()
190
- .optional()
191
- .describe('Maximum number of results to return (1-100, default: 10).'),
192
- category: z
193
- .enum([
194
- 'company',
195
- 'people',
196
- 'research paper',
197
- 'news',
198
- 'personal site',
199
- 'financial report',
200
- ])
201
- .optional()
202
- .describe('Optional content category to focus results.'),
203
- user_location: z
204
- .string()
205
- .optional()
206
- .describe("Two-letter ISO country code such as 'US'."),
207
- include_domains: z
208
- .array(z.string())
209
- .optional()
210
- .describe('Only return results from these domains.'),
211
- exclude_domains: z
212
- .array(z.string())
213
- .optional()
214
- .describe('Exclude results from these domains.'),
215
- start_published_date: z
216
- .string()
217
- .optional()
218
- .describe('Only return links published after this ISO 8601 date.'),
219
- end_published_date: z
220
- .string()
221
- .optional()
222
- .describe('Only return links published before this ISO 8601 date.'),
223
- contents: z
224
- .object({
225
- text: z
226
- .union([
227
- z.boolean(),
228
- z.object({
229
- max_characters: z.number().optional(),
230
- include_html_tags: z.boolean().optional(),
231
- verbosity: z.enum(['compact', 'standard', 'full']).optional(),
232
- include_sections: z
233
- .array(
234
- z.enum([
235
- 'header',
236
- 'navigation',
237
- 'banner',
238
- 'body',
239
- 'sidebar',
240
- 'footer',
241
- 'metadata',
242
- ]),
243
- )
244
- .optional(),
245
- exclude_sections: z
246
- .array(
247
- z.enum([
248
- 'header',
249
- 'navigation',
250
- 'banner',
251
- 'body',
252
- 'sidebar',
253
- 'footer',
254
- 'metadata',
255
- ]),
256
- )
257
- .optional(),
258
- }),
259
- ])
260
- .optional(),
261
- highlights: z
262
- .union([
263
- z.boolean(),
202
+ 'Optional content category to focus results.',
203
+ ),
204
+ user_location: z.describe(
205
+ z.optional(z.string()),
206
+ "Two-letter ISO country code such as 'US'.",
207
+ ),
208
+ include_domains: z.describe(
209
+ z.optional(z.array(z.string())),
210
+ 'Only return results from these domains.',
211
+ ),
212
+ exclude_domains: z.describe(
213
+ z.optional(z.array(z.string())),
214
+ 'Exclude results from these domains.',
215
+ ),
216
+ start_published_date: z.describe(
217
+ z.optional(z.string()),
218
+ 'Only return links published after this ISO 8601 date.',
219
+ ),
220
+ end_published_date: z.describe(
221
+ z.optional(z.string()),
222
+ 'Only return links published before this ISO 8601 date.',
223
+ ),
224
+ contents: z.describe(
225
+ z.optional(
226
+ z.object({
227
+ text: z.optional(
228
+ z.union([
229
+ z.boolean(),
230
+ z.object({
231
+ max_characters: z.optional(z.number()),
232
+ include_html_tags: z.optional(z.boolean()),
233
+ verbosity: z.optional(
234
+ z.enum(['compact', 'standard', 'full']),
235
+ ),
236
+ include_sections: z.optional(
237
+ z.array(
238
+ z.enum([
239
+ 'header',
240
+ 'navigation',
241
+ 'banner',
242
+ 'body',
243
+ 'sidebar',
244
+ 'footer',
245
+ 'metadata',
246
+ ]),
247
+ ),
248
+ ),
249
+ exclude_sections: z.optional(
250
+ z.array(
251
+ z.enum([
252
+ 'header',
253
+ 'navigation',
254
+ 'banner',
255
+ 'body',
256
+ 'sidebar',
257
+ 'footer',
258
+ 'metadata',
259
+ ]),
260
+ ),
261
+ ),
262
+ }),
263
+ ]),
264
+ ),
265
+ highlights: z.optional(
266
+ z.union([
267
+ z.boolean(),
268
+ z.object({
269
+ query: z.optional(z.string()),
270
+ max_characters: z.optional(z.number()),
271
+ }),
272
+ ]),
273
+ ),
274
+ max_age_hours: z.optional(z.number()),
275
+ livecrawl_timeout: z.optional(z.number()),
276
+ subpages: z.optional(z.number()),
277
+ subpage_target: z.optional(
278
+ z.union([z.string(), z.array(z.string())]),
279
+ ),
280
+ extras: z.optional(
264
281
  z.object({
265
- query: z.string().optional(),
266
- max_characters: z.number().optional(),
282
+ links: z.optional(z.number()),
283
+ image_links: z.optional(z.number()),
267
284
  }),
268
- ])
269
- .optional(),
270
- max_age_hours: z.number().optional(),
271
- livecrawl_timeout: z.number().optional(),
272
- subpages: z.number().optional(),
273
- subpage_target: z.union([z.string(), z.array(z.string())]).optional(),
274
- extras: z
275
- .object({
276
- links: z.number().optional(),
277
- image_links: z.number().optional(),
278
- })
279
- .optional(),
280
- })
281
- .optional()
282
- .describe('Controls extracted page content and freshness.'),
285
+ ),
286
+ }),
287
+ ),
288
+ 'Controls extracted page content and freshness.',
289
+ ),
283
290
  }),
284
291
  ),
285
292
  );
@@ -289,36 +296,36 @@ const exaSearchOutputSchema = lazySchema(() =>
289
296
  z.union([
290
297
  z.object({
291
298
  requestId: z.string(),
292
- searchType: z.string().optional(),
293
- resolvedSearchType: z.string().optional(),
299
+ searchType: z.optional(z.string()),
300
+ resolvedSearchType: z.optional(z.string()),
294
301
  results: z.array(
295
302
  z.object({
296
303
  title: z.string(),
297
304
  url: z.string(),
298
305
  id: z.string(),
299
- publishedDate: z.string().nullable().optional(),
300
- author: z.string().nullable().optional(),
301
- image: z.string().nullable().optional(),
302
- favicon: z.string().nullable().optional(),
303
- text: z.string().optional(),
304
- highlights: z.array(z.string()).optional(),
305
- highlightScores: z.array(z.number()).optional(),
306
- summary: z.string().optional(),
307
- subpages: z.array(z.any()).optional(),
308
- extras: z
309
- .object({
310
- links: z.array(z.string()).optional(),
311
- imageLinks: z.array(z.string()).optional(),
312
- })
313
- .optional(),
306
+ publishedDate: z.optional(z.nullable(z.string())),
307
+ author: z.optional(z.nullable(z.string())),
308
+ image: z.optional(z.nullable(z.string())),
309
+ favicon: z.optional(z.nullable(z.string())),
310
+ text: z.optional(z.string()),
311
+ highlights: z.optional(z.array(z.string())),
312
+ highlightScores: z.optional(z.array(z.number())),
313
+ summary: z.optional(z.string()),
314
+ subpages: z.optional(z.array(z.any())),
315
+ extras: z.optional(
316
+ z.object({
317
+ links: z.optional(z.array(z.string())),
318
+ imageLinks: z.optional(z.array(z.string())),
319
+ }),
320
+ ),
321
+ }),
322
+ ),
323
+ costDollars: z.optional(
324
+ z.object({
325
+ total: z.optional(z.number()),
326
+ search: z.optional(z.record(z.string(), z.number())),
314
327
  }),
315
328
  ),
316
- costDollars: z
317
- .object({
318
- total: z.number().optional(),
319
- search: z.record(z.string(), z.number()).optional(),
320
- })
321
- .optional(),
322
329
  }),
323
330
  z.object({
324
331
  error: z.enum([
@@ -330,7 +337,7 @@ const exaSearchOutputSchema = lazySchema(() =>
330
337
  'execution_error',
331
338
  'unknown',
332
339
  ]),
333
- statusCode: z.number().optional(),
340
+ statusCode: z.optional(z.number()),
334
341
  message: z.string(),
335
342
  }),
336
343
  ]),
@@ -18,8 +18,8 @@ export interface GatewayToolError {
18
18
  }
19
19
 
20
20
  export const gatewayToolErrorSchema = () =>
21
- z
22
- .object({
21
+ z.catchall(
22
+ z.object({
23
23
  error: z.enum([
24
24
  'api_error',
25
25
  'configuration_error',
@@ -32,8 +32,9 @@ export const gatewayToolErrorSchema = () =>
32
32
  'unknown_tool',
33
33
  ]),
34
34
  message: z.string(),
35
- statusCode: z.number().optional(),
36
- retryAfter: z.string().optional(),
37
- statusText: z.string().optional(),
38
- })
39
- .passthrough();
35
+ statusCode: z.optional(z.number()),
36
+ retryAfter: z.optional(z.string()),
37
+ statusText: z.optional(z.string()),
38
+ }),
39
+ z.unknown(),
40
+ );
@@ -226,108 +226,91 @@ export type ParallelSearchOutput = ParallelSearchResponse | ParallelSearchError;
226
226
  const parallelSearchInputSchema = lazySchema(() =>
227
227
  zodSchema(
228
228
  z.object({
229
- objective: z
230
- .string()
231
- .describe(
232
- 'Natural-language description of the web research goal, including source or freshness guidance and broader context from the task. Maximum 5000 characters.',
233
- ),
234
-
235
- search_queries: z
236
- .array(z.string())
237
- .optional()
238
- .describe(
239
- 'Provide 2-3 concise keyword queries, 3-6 words each (max 5, 200 chars each). Strongly recommended; the search runs on these queries.',
240
- ),
241
-
242
- mode: z
243
- .enum(parallelSearchModes)
244
- .optional()
245
- .describe(
246
- 'Search mode: "turbo" and "fast" return quickly with shorter excerpts, "basic" is balanced (default), "advanced" is the most thorough. "turbo" supports English and Japanese only. "one-shot" and "agentic" are deprecated aliases of "basic" and "advanced".',
247
- ),
248
-
249
- max_results: z
250
- .number()
251
- .optional()
252
- .describe(
253
- 'Maximum number of results to return (1-20). Defaults to 10 if not specified.',
254
- ),
255
-
256
- source_policy: z
257
- .object({
258
- include_domains: z
259
- .array(z.string())
260
- .optional()
261
- .describe(
229
+ objective: z.describe(
230
+ z.string(),
231
+ 'Natural-language description of the web research goal, including source or freshness guidance and broader context from the task. Maximum 5000 characters.',
232
+ ),
233
+
234
+ search_queries: z.describe(
235
+ z.optional(z.array(z.string())),
236
+ 'Provide 2-3 concise keyword queries, 3-6 words each (max 5, 200 chars each). Strongly recommended; the search runs on these queries.',
237
+ ),
238
+
239
+ mode: z.describe(
240
+ z.optional(z.enum(parallelSearchModes)),
241
+ 'Search mode: "turbo" and "fast" return quickly with shorter excerpts, "basic" is balanced (default), "advanced" is the most thorough. "turbo" supports English and Japanese only. "one-shot" and "agentic" are deprecated aliases of "basic" and "advanced".',
242
+ ),
243
+
244
+ max_results: z.describe(
245
+ z.optional(z.number()),
246
+ 'Maximum number of results to return (1-20). Defaults to 10 if not specified.',
247
+ ),
248
+
249
+ source_policy: z.describe(
250
+ z.optional(
251
+ z.object({
252
+ include_domains: z.describe(
253
+ z.optional(z.array(z.string())),
262
254
  "Domains or domain/path prefixes to restrict results to, without scheme or port. Example: ['wikipedia.org', 'docs.python.org/3'].",
263
255
  ),
264
- exclude_domains: z
265
- .array(z.string())
266
- .optional()
267
- .describe(
256
+ exclude_domains: z.describe(
257
+ z.optional(z.array(z.string())),
268
258
  "Domains or domain/path prefixes to exclude, without scheme or port. Example: ['reddit.com'].",
269
259
  ),
270
- after_date: z
271
- .string()
272
- .optional()
273
- .describe(
260
+ after_date: z.describe(
261
+ z.optional(z.string()),
274
262
  'Only include results published on or after this date. Use an ISO 8601 calendar date formatted YYYY-MM-DD (e.g. 2025-01-01); do not include a time.',
275
263
  ),
276
- })
277
- .optional()
278
- .describe(
279
- 'Source policy for controlling which domains to include/exclude and freshness.',
264
+ }),
265
+ ),
266
+ 'Source policy for controlling which domains to include/exclude and freshness.',
267
+ ),
268
+
269
+ excerpts: z.describe(
270
+ z.optional(
271
+ z.object({
272
+ max_chars_per_result: z.describe(
273
+ z.optional(z.number()),
274
+ 'Maximum characters per result.',
275
+ ),
276
+ max_chars_total: z.describe(
277
+ z.optional(z.number()),
278
+ 'Deprecated: use the top-level max_chars_total.',
279
+ ),
280
+ }),
280
281
  ),
282
+ 'Excerpt configuration for controlling result length.',
283
+ ),
284
+
285
+ max_chars_total: z.describe(
286
+ z.optional(z.number()),
287
+ 'Maximum total characters across all result excerpts.',
288
+ ),
281
289
 
282
- excerpts: z
283
- .object({
284
- max_chars_per_result: z
285
- .number()
286
- .optional()
287
- .describe('Maximum characters per result.'),
288
- max_chars_total: z
289
- .number()
290
- .optional()
291
- .describe('Deprecated: use the top-level max_chars_total.'),
292
- })
293
- .optional()
294
- .describe('Excerpt configuration for controlling result length.'),
295
-
296
- max_chars_total: z
297
- .number()
298
- .optional()
299
- .describe('Maximum total characters across all result excerpts.'),
300
-
301
- fetch_policy: z
302
- .object({
303
- max_age_seconds: z
304
- .number()
305
- .optional()
306
- .describe(
290
+ fetch_policy: z.describe(
291
+ z.optional(
292
+ z.object({
293
+ max_age_seconds: z.describe(
294
+ z.optional(z.number()),
307
295
  'Maximum age of cached content in seconds before a live fetch, minimum 600.',
308
296
  ),
309
- timeout_seconds: z
310
- .number()
311
- .optional()
312
- .describe(
297
+ timeout_seconds: z.describe(
298
+ z.optional(z.number()),
313
299
  'Timeout in seconds for a live fetch when content is not cached. Capped by the gateway tool timeout.',
314
300
  ),
315
- disable_cache_fallback: z
316
- .boolean()
317
- .optional()
318
- .describe(
301
+ disable_cache_fallback: z.describe(
302
+ z.optional(z.boolean()),
319
303
  'Return an error instead of older cached content when a live fetch fails.',
320
304
  ),
321
- })
322
- .optional()
323
- .describe('Fetch policy for controlling content freshness.'),
324
-
325
- location: z
326
- .string()
327
- .optional()
328
- .describe(
329
- 'ISO 3166-1 alpha-2 country code to localize results, e.g. "us".',
305
+ }),
330
306
  ),
307
+ 'Fetch policy for controlling content freshness.',
308
+ ),
309
+
310
+ location: z.describe(
311
+ z.optional(z.string()),
312
+ 'ISO 3166-1 alpha-2 country code to localize results, e.g. "us".',
313
+ ),
331
314
  }),
332
315
  ),
333
316
  );
@@ -341,26 +324,32 @@ const parallelSearchOutputSchema = lazySchema(() =>
341
324
  results: z.array(
342
325
  z.object({
343
326
  url: z.string(),
344
- title: z.string().nullable().optional(),
345
- publish_date: z.string().nullable().optional(),
327
+ title: z.optional(z.nullable(z.string())),
328
+ publish_date: z.optional(z.nullable(z.string())),
346
329
  excerpts: z.array(z.string()),
347
330
  }),
348
331
  ),
349
- warnings: z
350
- .array(
351
- z.object({
352
- type: z.string(),
353
- message: z.string(),
354
- detail: z.record(z.string(), z.unknown()).nullable().optional(),
355
- }),
356
- )
357
- .nullable()
358
- .optional(),
359
- usage: z
360
- .array(z.object({ name: z.string(), count: z.number().optional() }))
361
- .nullable()
362
- .optional(),
363
- session_id: z.string().optional(),
332
+ warnings: z.optional(
333
+ z.nullable(
334
+ z.array(
335
+ z.object({
336
+ type: z.string(),
337
+ message: z.string(),
338
+ detail: z.optional(
339
+ z.nullable(z.record(z.string(), z.unknown())),
340
+ ),
341
+ }),
342
+ ),
343
+ ),
344
+ ),
345
+ usage: z.optional(
346
+ z.nullable(
347
+ z.array(
348
+ z.object({ name: z.string(), count: z.optional(z.number()) }),
349
+ ),
350
+ ),
351
+ ),
352
+ session_id: z.optional(z.string()),
364
353
  }),
365
354
  // Error response
366
355
  gatewayToolErrorSchema(),