@ai-sdk/gateway 4.0.141 → 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.
- package/CHANGELOG.md +11 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +453 -424
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/errors/create-gateway-error.ts +4 -4
- package/src/gateway-batch.ts +29 -27
- package/src/gateway-decision-model.ts +21 -21
- package/src/gateway-embedding-model.ts +7 -7
- package/src/gateway-fetch-metadata.ts +33 -29
- package/src/gateway-generation-info.ts +13 -11
- package/src/gateway-image-model.ts +17 -16
- package/src/gateway-language-model-settings.ts +1 -0
- package/src/gateway-provider-options.ts +72 -50
- package/src/gateway-provider.ts +1 -1
- package/src/gateway-reranking-model.ts +6 -6
- package/src/gateway-speech-model.ts +8 -8
- package/src/gateway-spend-report.ts +19 -18
- package/src/gateway-transcription-model.ts +18 -18
- package/src/gateway-video-model.ts +31 -30
- package/src/tool/browserbase-fetch.ts +22 -29
- package/src/tool/browserbase-search.ts +15 -17
- package/src/tool/deepseek-fetch.ts +10 -10
- package/src/tool/deepseek-search.ts +36 -37
- package/src/tool/exa-search.ts +132 -125
- package/src/tool/gateway-tool-error.ts +8 -7
- package/src/tool/parallel-search.ts +93 -104
- package/src/tool/perplexity-search.ts +62 -85
- package/src/tool/tako-search.ts +277 -275
- package/src/zod.ts +47 -5
package/src/tool/exa-search.ts
CHANGED
|
@@ -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
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
.optional()
|
|
185
|
-
.
|
|
186
|
-
|
|
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
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
.
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
.
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
.
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
)
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
.optional(),
|
|
261
|
-
|
|
262
|
-
.
|
|
263
|
-
|
|
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
|
-
|
|
266
|
-
|
|
282
|
+
links: z.optional(z.number()),
|
|
283
|
+
image_links: z.optional(z.number()),
|
|
267
284
|
}),
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
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.
|
|
293
|
-
resolvedSearchType: z.
|
|
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.
|
|
300
|
-
author: z.
|
|
301
|
-
image: z.
|
|
302
|
-
favicon: z.
|
|
303
|
-
text: z.
|
|
304
|
-
highlights: z.array(z.string())
|
|
305
|
-
highlightScores: z.array(z.number())
|
|
306
|
-
summary: z.
|
|
307
|
-
subpages: z.array(z.any())
|
|
308
|
-
extras: z
|
|
309
|
-
.object({
|
|
310
|
-
links: z.array(z.string())
|
|
311
|
-
imageLinks: z.array(z.string())
|
|
312
|
-
})
|
|
313
|
-
|
|
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.
|
|
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.
|
|
36
|
-
retryAfter: z.
|
|
37
|
-
statusText: z.
|
|
38
|
-
})
|
|
39
|
-
.
|
|
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
|
-
.
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
),
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
.
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
.
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
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
|
-
|
|
265
|
-
|
|
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
|
-
|
|
271
|
-
|
|
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
|
-
|
|
278
|
-
.
|
|
279
|
-
|
|
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
|
-
|
|
283
|
-
.
|
|
284
|
-
|
|
285
|
-
.
|
|
286
|
-
|
|
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
|
-
|
|
310
|
-
|
|
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
|
-
|
|
316
|
-
|
|
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.
|
|
345
|
-
publish_date: z.
|
|
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
|
-
.
|
|
351
|
-
z.
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
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(),
|