@ai-sdk/gateway 3.0.26 → 3.0.28
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 +12 -0
- package/README.md +8 -0
- package/dist/index.d.mts +142 -0
- package/dist/index.d.ts +142 -0
- package/dist/index.js +127 -40
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +123 -32
- package/dist/index.mjs.map +1 -1
- package/docs/00-ai-gateway.mdx +109 -0
- package/package.json +1 -1
- package/src/gateway-tools.ts +11 -0
- package/src/tool/parallel-search.ts +295 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @ai-sdk/gateway
|
|
2
2
|
|
|
3
|
+
## 3.0.28
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 1524271: chore: add skill information to README files
|
|
8
|
+
|
|
9
|
+
## 3.0.27
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 0acff64: feat (provider/gateway): add parallel search tool
|
|
14
|
+
|
|
3
15
|
## 3.0.26
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -10,6 +10,14 @@ The Gateway provider is available in the `@ai-sdk/gateway` module. You can insta
|
|
|
10
10
|
npm i @ai-sdk/gateway
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
+
## Skill for Coding Agents
|
|
14
|
+
|
|
15
|
+
If you use coding agents such as Claude Code or Cursor, we highly recommend adding the AI SDK skill to your repository:
|
|
16
|
+
|
|
17
|
+
```shell
|
|
18
|
+
npx skills add vercel/ai
|
|
19
|
+
```
|
|
20
|
+
|
|
13
21
|
## Provider Instance
|
|
14
22
|
|
|
15
23
|
You can import the default provider instance `gateway` from `@ai-sdk/gateway`:
|
package/dist/index.d.mts
CHANGED
|
@@ -194,10 +194,152 @@ interface PerplexitySearchInput {
|
|
|
194
194
|
type PerplexitySearchOutput = PerplexitySearchResponse | PerplexitySearchError;
|
|
195
195
|
declare const perplexitySearchToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<PerplexitySearchInput, PerplexitySearchOutput, PerplexitySearchConfig>;
|
|
196
196
|
|
|
197
|
+
interface ParallelSearchSourcePolicy {
|
|
198
|
+
/**
|
|
199
|
+
* List of domains to include in search results.
|
|
200
|
+
* Example: ['wikipedia.org', 'nature.com']
|
|
201
|
+
*/
|
|
202
|
+
includeDomains?: string[];
|
|
203
|
+
/**
|
|
204
|
+
* List of domains to exclude from search results.
|
|
205
|
+
* Example: ['reddit.com', 'twitter.com']
|
|
206
|
+
*/
|
|
207
|
+
excludeDomains?: string[];
|
|
208
|
+
/**
|
|
209
|
+
* Only include results published after this date (ISO 8601 format).
|
|
210
|
+
* Example: '2024-01-01'
|
|
211
|
+
*/
|
|
212
|
+
afterDate?: string;
|
|
213
|
+
}
|
|
214
|
+
interface ParallelSearchExcerpts {
|
|
215
|
+
/**
|
|
216
|
+
* Maximum characters per result.
|
|
217
|
+
*/
|
|
218
|
+
maxCharsPerResult?: number;
|
|
219
|
+
/**
|
|
220
|
+
* Maximum total characters across all results.
|
|
221
|
+
*/
|
|
222
|
+
maxCharsTotal?: number;
|
|
223
|
+
}
|
|
224
|
+
interface ParallelSearchFetchPolicy {
|
|
225
|
+
/**
|
|
226
|
+
* Maximum age in seconds for cached content.
|
|
227
|
+
* Set to 0 to always fetch fresh content.
|
|
228
|
+
*/
|
|
229
|
+
maxAgeSeconds?: number;
|
|
230
|
+
}
|
|
231
|
+
interface ParallelSearchConfig {
|
|
232
|
+
/**
|
|
233
|
+
* Mode preset for different use cases:
|
|
234
|
+
* - "one-shot": Comprehensive results with longer excerpts for single-response answers (default)
|
|
235
|
+
* - "agentic": Concise, token-efficient results for multi-step agentic workflows
|
|
236
|
+
*/
|
|
237
|
+
mode?: 'one-shot' | 'agentic';
|
|
238
|
+
/**
|
|
239
|
+
* Default maximum number of results to return (1-20).
|
|
240
|
+
* Defaults to 10 if not specified.
|
|
241
|
+
*/
|
|
242
|
+
maxResults?: number;
|
|
243
|
+
/**
|
|
244
|
+
* Default source policy for controlling which domains to include/exclude.
|
|
245
|
+
*/
|
|
246
|
+
sourcePolicy?: ParallelSearchSourcePolicy;
|
|
247
|
+
/**
|
|
248
|
+
* Default excerpt configuration for controlling result length.
|
|
249
|
+
*/
|
|
250
|
+
excerpts?: ParallelSearchExcerpts;
|
|
251
|
+
/**
|
|
252
|
+
* Default fetch policy for controlling content freshness.
|
|
253
|
+
*/
|
|
254
|
+
fetchPolicy?: ParallelSearchFetchPolicy;
|
|
255
|
+
}
|
|
256
|
+
interface ParallelSearchResult {
|
|
257
|
+
/** URL of the search result */
|
|
258
|
+
url: string;
|
|
259
|
+
/** Title of the search result */
|
|
260
|
+
title: string;
|
|
261
|
+
/** Extracted text excerpt/content from the page */
|
|
262
|
+
excerpt: string;
|
|
263
|
+
/** Publication date of the content (may be null) */
|
|
264
|
+
publishDate?: string | null;
|
|
265
|
+
/** Relevance score for the result */
|
|
266
|
+
relevanceScore?: number;
|
|
267
|
+
}
|
|
268
|
+
interface ParallelSearchResponse {
|
|
269
|
+
/** Unique identifier for this search request */
|
|
270
|
+
searchId: string;
|
|
271
|
+
/** Array of search results */
|
|
272
|
+
results: ParallelSearchResult[];
|
|
273
|
+
}
|
|
274
|
+
interface ParallelSearchError {
|
|
275
|
+
/** Error type */
|
|
276
|
+
error: 'api_error' | 'rate_limit' | 'timeout' | 'invalid_input' | 'configuration_error' | 'unknown';
|
|
277
|
+
/** HTTP status code if applicable */
|
|
278
|
+
statusCode?: number;
|
|
279
|
+
/** Human-readable error message */
|
|
280
|
+
message: string;
|
|
281
|
+
}
|
|
282
|
+
interface ParallelSearchInput {
|
|
283
|
+
/**
|
|
284
|
+
* Natural-language description of the web research goal.
|
|
285
|
+
* Include source or freshness guidance and broader context from the task.
|
|
286
|
+
* Maximum 5000 characters.
|
|
287
|
+
*/
|
|
288
|
+
objective: string;
|
|
289
|
+
/**
|
|
290
|
+
* Optional search queries to supplement the objective.
|
|
291
|
+
* Maximum 200 characters per query.
|
|
292
|
+
*/
|
|
293
|
+
search_queries?: string[];
|
|
294
|
+
/**
|
|
295
|
+
* Mode preset for different use cases:
|
|
296
|
+
* - "one-shot": Comprehensive results with longer excerpts
|
|
297
|
+
* - "agentic": Concise, token-efficient results for multi-step workflows
|
|
298
|
+
*/
|
|
299
|
+
mode?: 'one-shot' | 'agentic';
|
|
300
|
+
/**
|
|
301
|
+
* Maximum number of results to return (1-20).
|
|
302
|
+
* Defaults to 10 if not specified.
|
|
303
|
+
*/
|
|
304
|
+
max_results?: number;
|
|
305
|
+
/**
|
|
306
|
+
* Source policy for controlling which domains to include/exclude.
|
|
307
|
+
*/
|
|
308
|
+
source_policy?: {
|
|
309
|
+
include_domains?: string[];
|
|
310
|
+
exclude_domains?: string[];
|
|
311
|
+
after_date?: string;
|
|
312
|
+
};
|
|
313
|
+
/**
|
|
314
|
+
* Excerpt configuration for controlling result length.
|
|
315
|
+
*/
|
|
316
|
+
excerpts?: {
|
|
317
|
+
max_chars_per_result?: number;
|
|
318
|
+
max_chars_total?: number;
|
|
319
|
+
};
|
|
320
|
+
/**
|
|
321
|
+
* Fetch policy for controlling content freshness.
|
|
322
|
+
*/
|
|
323
|
+
fetch_policy?: {
|
|
324
|
+
max_age_seconds?: number;
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
type ParallelSearchOutput = ParallelSearchResponse | ParallelSearchError;
|
|
328
|
+
declare const parallelSearchToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<ParallelSearchInput, ParallelSearchOutput, ParallelSearchConfig>;
|
|
329
|
+
|
|
197
330
|
/**
|
|
198
331
|
* Gateway-specific provider-defined tools.
|
|
199
332
|
*/
|
|
200
333
|
declare const gatewayTools: {
|
|
334
|
+
/**
|
|
335
|
+
* Search the web using Parallel AI's Search API for LLM-optimized excerpts.
|
|
336
|
+
*
|
|
337
|
+
* Takes a natural language objective and returns relevant excerpts,
|
|
338
|
+
* replacing multiple keyword searches with a single call for broad
|
|
339
|
+
* or complex queries. Supports different search types for depth vs
|
|
340
|
+
* breadth tradeoffs.
|
|
341
|
+
*/
|
|
342
|
+
parallelSearch: (config?: ParallelSearchConfig) => ReturnType<typeof parallelSearchToolFactory>;
|
|
201
343
|
/**
|
|
202
344
|
* Search the web using Perplexity's Search API for real-time information,
|
|
203
345
|
* news, research papers, and articles.
|
package/dist/index.d.ts
CHANGED
|
@@ -194,10 +194,152 @@ interface PerplexitySearchInput {
|
|
|
194
194
|
type PerplexitySearchOutput = PerplexitySearchResponse | PerplexitySearchError;
|
|
195
195
|
declare const perplexitySearchToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<PerplexitySearchInput, PerplexitySearchOutput, PerplexitySearchConfig>;
|
|
196
196
|
|
|
197
|
+
interface ParallelSearchSourcePolicy {
|
|
198
|
+
/**
|
|
199
|
+
* List of domains to include in search results.
|
|
200
|
+
* Example: ['wikipedia.org', 'nature.com']
|
|
201
|
+
*/
|
|
202
|
+
includeDomains?: string[];
|
|
203
|
+
/**
|
|
204
|
+
* List of domains to exclude from search results.
|
|
205
|
+
* Example: ['reddit.com', 'twitter.com']
|
|
206
|
+
*/
|
|
207
|
+
excludeDomains?: string[];
|
|
208
|
+
/**
|
|
209
|
+
* Only include results published after this date (ISO 8601 format).
|
|
210
|
+
* Example: '2024-01-01'
|
|
211
|
+
*/
|
|
212
|
+
afterDate?: string;
|
|
213
|
+
}
|
|
214
|
+
interface ParallelSearchExcerpts {
|
|
215
|
+
/**
|
|
216
|
+
* Maximum characters per result.
|
|
217
|
+
*/
|
|
218
|
+
maxCharsPerResult?: number;
|
|
219
|
+
/**
|
|
220
|
+
* Maximum total characters across all results.
|
|
221
|
+
*/
|
|
222
|
+
maxCharsTotal?: number;
|
|
223
|
+
}
|
|
224
|
+
interface ParallelSearchFetchPolicy {
|
|
225
|
+
/**
|
|
226
|
+
* Maximum age in seconds for cached content.
|
|
227
|
+
* Set to 0 to always fetch fresh content.
|
|
228
|
+
*/
|
|
229
|
+
maxAgeSeconds?: number;
|
|
230
|
+
}
|
|
231
|
+
interface ParallelSearchConfig {
|
|
232
|
+
/**
|
|
233
|
+
* Mode preset for different use cases:
|
|
234
|
+
* - "one-shot": Comprehensive results with longer excerpts for single-response answers (default)
|
|
235
|
+
* - "agentic": Concise, token-efficient results for multi-step agentic workflows
|
|
236
|
+
*/
|
|
237
|
+
mode?: 'one-shot' | 'agentic';
|
|
238
|
+
/**
|
|
239
|
+
* Default maximum number of results to return (1-20).
|
|
240
|
+
* Defaults to 10 if not specified.
|
|
241
|
+
*/
|
|
242
|
+
maxResults?: number;
|
|
243
|
+
/**
|
|
244
|
+
* Default source policy for controlling which domains to include/exclude.
|
|
245
|
+
*/
|
|
246
|
+
sourcePolicy?: ParallelSearchSourcePolicy;
|
|
247
|
+
/**
|
|
248
|
+
* Default excerpt configuration for controlling result length.
|
|
249
|
+
*/
|
|
250
|
+
excerpts?: ParallelSearchExcerpts;
|
|
251
|
+
/**
|
|
252
|
+
* Default fetch policy for controlling content freshness.
|
|
253
|
+
*/
|
|
254
|
+
fetchPolicy?: ParallelSearchFetchPolicy;
|
|
255
|
+
}
|
|
256
|
+
interface ParallelSearchResult {
|
|
257
|
+
/** URL of the search result */
|
|
258
|
+
url: string;
|
|
259
|
+
/** Title of the search result */
|
|
260
|
+
title: string;
|
|
261
|
+
/** Extracted text excerpt/content from the page */
|
|
262
|
+
excerpt: string;
|
|
263
|
+
/** Publication date of the content (may be null) */
|
|
264
|
+
publishDate?: string | null;
|
|
265
|
+
/** Relevance score for the result */
|
|
266
|
+
relevanceScore?: number;
|
|
267
|
+
}
|
|
268
|
+
interface ParallelSearchResponse {
|
|
269
|
+
/** Unique identifier for this search request */
|
|
270
|
+
searchId: string;
|
|
271
|
+
/** Array of search results */
|
|
272
|
+
results: ParallelSearchResult[];
|
|
273
|
+
}
|
|
274
|
+
interface ParallelSearchError {
|
|
275
|
+
/** Error type */
|
|
276
|
+
error: 'api_error' | 'rate_limit' | 'timeout' | 'invalid_input' | 'configuration_error' | 'unknown';
|
|
277
|
+
/** HTTP status code if applicable */
|
|
278
|
+
statusCode?: number;
|
|
279
|
+
/** Human-readable error message */
|
|
280
|
+
message: string;
|
|
281
|
+
}
|
|
282
|
+
interface ParallelSearchInput {
|
|
283
|
+
/**
|
|
284
|
+
* Natural-language description of the web research goal.
|
|
285
|
+
* Include source or freshness guidance and broader context from the task.
|
|
286
|
+
* Maximum 5000 characters.
|
|
287
|
+
*/
|
|
288
|
+
objective: string;
|
|
289
|
+
/**
|
|
290
|
+
* Optional search queries to supplement the objective.
|
|
291
|
+
* Maximum 200 characters per query.
|
|
292
|
+
*/
|
|
293
|
+
search_queries?: string[];
|
|
294
|
+
/**
|
|
295
|
+
* Mode preset for different use cases:
|
|
296
|
+
* - "one-shot": Comprehensive results with longer excerpts
|
|
297
|
+
* - "agentic": Concise, token-efficient results for multi-step workflows
|
|
298
|
+
*/
|
|
299
|
+
mode?: 'one-shot' | 'agentic';
|
|
300
|
+
/**
|
|
301
|
+
* Maximum number of results to return (1-20).
|
|
302
|
+
* Defaults to 10 if not specified.
|
|
303
|
+
*/
|
|
304
|
+
max_results?: number;
|
|
305
|
+
/**
|
|
306
|
+
* Source policy for controlling which domains to include/exclude.
|
|
307
|
+
*/
|
|
308
|
+
source_policy?: {
|
|
309
|
+
include_domains?: string[];
|
|
310
|
+
exclude_domains?: string[];
|
|
311
|
+
after_date?: string;
|
|
312
|
+
};
|
|
313
|
+
/**
|
|
314
|
+
* Excerpt configuration for controlling result length.
|
|
315
|
+
*/
|
|
316
|
+
excerpts?: {
|
|
317
|
+
max_chars_per_result?: number;
|
|
318
|
+
max_chars_total?: number;
|
|
319
|
+
};
|
|
320
|
+
/**
|
|
321
|
+
* Fetch policy for controlling content freshness.
|
|
322
|
+
*/
|
|
323
|
+
fetch_policy?: {
|
|
324
|
+
max_age_seconds?: number;
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
type ParallelSearchOutput = ParallelSearchResponse | ParallelSearchError;
|
|
328
|
+
declare const parallelSearchToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<ParallelSearchInput, ParallelSearchOutput, ParallelSearchConfig>;
|
|
329
|
+
|
|
197
330
|
/**
|
|
198
331
|
* Gateway-specific provider-defined tools.
|
|
199
332
|
*/
|
|
200
333
|
declare const gatewayTools: {
|
|
334
|
+
/**
|
|
335
|
+
* Search the web using Parallel AI's Search API for LLM-optimized excerpts.
|
|
336
|
+
*
|
|
337
|
+
* Takes a natural language objective and returns relevant excerpts,
|
|
338
|
+
* replacing multiple keyword searches with a single call for broad
|
|
339
|
+
* or complex queries. Supports different search types for depth vs
|
|
340
|
+
* breadth tradeoffs.
|
|
341
|
+
*/
|
|
342
|
+
parallelSearch: (config?: ParallelSearchConfig) => ReturnType<typeof parallelSearchToolFactory>;
|
|
201
343
|
/**
|
|
202
344
|
* Search the web using Perplexity's Search API for real-time information,
|
|
203
345
|
* news, research papers, and articles.
|
package/dist/index.js
CHANGED
|
@@ -34,7 +34,7 @@ __export(src_exports, {
|
|
|
34
34
|
module.exports = __toCommonJS(src_exports);
|
|
35
35
|
|
|
36
36
|
// src/gateway-provider.ts
|
|
37
|
-
var
|
|
37
|
+
var import_provider_utils10 = require("@ai-sdk/provider-utils");
|
|
38
38
|
|
|
39
39
|
// src/errors/as-gateway-error.ts
|
|
40
40
|
var import_provider = require("@ai-sdk/provider");
|
|
@@ -847,83 +847,161 @@ var gatewayImageResponseSchema = import_v47.z.object({
|
|
|
847
847
|
providerMetadata: import_v47.z.record(import_v47.z.string(), providerMetadataEntrySchema).optional()
|
|
848
848
|
});
|
|
849
849
|
|
|
850
|
-
// src/tool/
|
|
850
|
+
// src/tool/parallel-search.ts
|
|
851
851
|
var import_provider_utils8 = require("@ai-sdk/provider-utils");
|
|
852
852
|
var import_zod = require("zod");
|
|
853
|
-
var
|
|
853
|
+
var parallelSearchInputSchema = (0, import_provider_utils8.lazySchema)(
|
|
854
854
|
() => (0, import_provider_utils8.zodSchema)(
|
|
855
855
|
import_zod.z.object({
|
|
856
|
-
|
|
857
|
-
"
|
|
856
|
+
objective: import_zod.z.string().describe(
|
|
857
|
+
"Natural-language description of the web research goal, including source or freshness guidance and broader context from the task. Maximum 5000 characters."
|
|
858
|
+
),
|
|
859
|
+
search_queries: import_zod.z.array(import_zod.z.string()).optional().describe(
|
|
860
|
+
"Optional search queries to supplement the objective. Maximum 200 characters per query."
|
|
861
|
+
),
|
|
862
|
+
mode: import_zod.z.enum(["one-shot", "agentic"]).optional().describe(
|
|
863
|
+
'Mode preset: "one-shot" for comprehensive results with longer excerpts (default), "agentic" for concise, token-efficient results for multi-step workflows.'
|
|
858
864
|
),
|
|
859
865
|
max_results: import_zod.z.number().optional().describe(
|
|
866
|
+
"Maximum number of results to return (1-20). Defaults to 10 if not specified."
|
|
867
|
+
),
|
|
868
|
+
source_policy: import_zod.z.object({
|
|
869
|
+
include_domains: import_zod.z.array(import_zod.z.string()).optional().describe("List of domains to include in search results."),
|
|
870
|
+
exclude_domains: import_zod.z.array(import_zod.z.string()).optional().describe("List of domains to exclude from search results."),
|
|
871
|
+
after_date: import_zod.z.string().optional().describe(
|
|
872
|
+
"Only include results published after this date (ISO 8601 format)."
|
|
873
|
+
)
|
|
874
|
+
}).optional().describe(
|
|
875
|
+
"Source policy for controlling which domains to include/exclude and freshness."
|
|
876
|
+
),
|
|
877
|
+
excerpts: import_zod.z.object({
|
|
878
|
+
max_chars_per_result: import_zod.z.number().optional().describe("Maximum characters per result."),
|
|
879
|
+
max_chars_total: import_zod.z.number().optional().describe("Maximum total characters across all results.")
|
|
880
|
+
}).optional().describe("Excerpt configuration for controlling result length."),
|
|
881
|
+
fetch_policy: import_zod.z.object({
|
|
882
|
+
max_age_seconds: import_zod.z.number().optional().describe(
|
|
883
|
+
"Maximum age in seconds for cached content. Set to 0 to always fetch fresh content."
|
|
884
|
+
)
|
|
885
|
+
}).optional().describe("Fetch policy for controlling content freshness.")
|
|
886
|
+
})
|
|
887
|
+
)
|
|
888
|
+
);
|
|
889
|
+
var parallelSearchOutputSchema = (0, import_provider_utils8.lazySchema)(
|
|
890
|
+
() => (0, import_provider_utils8.zodSchema)(
|
|
891
|
+
import_zod.z.union([
|
|
892
|
+
// Success response
|
|
893
|
+
import_zod.z.object({
|
|
894
|
+
searchId: import_zod.z.string(),
|
|
895
|
+
results: import_zod.z.array(
|
|
896
|
+
import_zod.z.object({
|
|
897
|
+
url: import_zod.z.string(),
|
|
898
|
+
title: import_zod.z.string(),
|
|
899
|
+
excerpt: import_zod.z.string(),
|
|
900
|
+
publishDate: import_zod.z.string().nullable().optional(),
|
|
901
|
+
relevanceScore: import_zod.z.number().optional()
|
|
902
|
+
})
|
|
903
|
+
)
|
|
904
|
+
}),
|
|
905
|
+
// Error response
|
|
906
|
+
import_zod.z.object({
|
|
907
|
+
error: import_zod.z.enum([
|
|
908
|
+
"api_error",
|
|
909
|
+
"rate_limit",
|
|
910
|
+
"timeout",
|
|
911
|
+
"invalid_input",
|
|
912
|
+
"configuration_error",
|
|
913
|
+
"unknown"
|
|
914
|
+
]),
|
|
915
|
+
statusCode: import_zod.z.number().optional(),
|
|
916
|
+
message: import_zod.z.string()
|
|
917
|
+
})
|
|
918
|
+
])
|
|
919
|
+
)
|
|
920
|
+
);
|
|
921
|
+
var parallelSearchToolFactory = (0, import_provider_utils8.createProviderToolFactoryWithOutputSchema)({
|
|
922
|
+
id: "gateway.parallel_search",
|
|
923
|
+
inputSchema: parallelSearchInputSchema,
|
|
924
|
+
outputSchema: parallelSearchOutputSchema
|
|
925
|
+
});
|
|
926
|
+
var parallelSearch = (config = {}) => parallelSearchToolFactory(config);
|
|
927
|
+
|
|
928
|
+
// src/tool/perplexity-search.ts
|
|
929
|
+
var import_provider_utils9 = require("@ai-sdk/provider-utils");
|
|
930
|
+
var import_zod2 = require("zod");
|
|
931
|
+
var perplexitySearchInputSchema = (0, import_provider_utils9.lazySchema)(
|
|
932
|
+
() => (0, import_provider_utils9.zodSchema)(
|
|
933
|
+
import_zod2.z.object({
|
|
934
|
+
query: import_zod2.z.union([import_zod2.z.string(), import_zod2.z.array(import_zod2.z.string())]).describe(
|
|
935
|
+
"Search query (string) or multiple queries (array of up to 5 strings). Multi-query searches return combined results from all queries."
|
|
936
|
+
),
|
|
937
|
+
max_results: import_zod2.z.number().optional().describe(
|
|
860
938
|
"Maximum number of search results to return (1-20, default: 10)"
|
|
861
939
|
),
|
|
862
|
-
max_tokens_per_page:
|
|
940
|
+
max_tokens_per_page: import_zod2.z.number().optional().describe(
|
|
863
941
|
"Maximum number of tokens to extract per search result page (256-2048, default: 2048)"
|
|
864
942
|
),
|
|
865
|
-
max_tokens:
|
|
943
|
+
max_tokens: import_zod2.z.number().optional().describe(
|
|
866
944
|
"Maximum total tokens across all search results (default: 25000, max: 1000000)"
|
|
867
945
|
),
|
|
868
|
-
country:
|
|
946
|
+
country: import_zod2.z.string().optional().describe(
|
|
869
947
|
"Two-letter ISO 3166-1 alpha-2 country code for regional search results (e.g., 'US', 'GB', 'FR')"
|
|
870
948
|
),
|
|
871
|
-
search_domain_filter:
|
|
949
|
+
search_domain_filter: import_zod2.z.array(import_zod2.z.string()).optional().describe(
|
|
872
950
|
"List of domains to include or exclude from search results (max 20). To include: ['nature.com', 'science.org']. To exclude: ['-example.com', '-spam.net']"
|
|
873
951
|
),
|
|
874
|
-
search_language_filter:
|
|
952
|
+
search_language_filter: import_zod2.z.array(import_zod2.z.string()).optional().describe(
|
|
875
953
|
"List of ISO 639-1 language codes to filter results (max 10, lowercase). Examples: ['en', 'fr', 'de']"
|
|
876
954
|
),
|
|
877
|
-
search_after_date:
|
|
955
|
+
search_after_date: import_zod2.z.string().optional().describe(
|
|
878
956
|
"Include only results published after this date. Format: 'MM/DD/YYYY' (e.g., '3/1/2025'). Cannot be used with search_recency_filter."
|
|
879
957
|
),
|
|
880
|
-
search_before_date:
|
|
958
|
+
search_before_date: import_zod2.z.string().optional().describe(
|
|
881
959
|
"Include only results published before this date. Format: 'MM/DD/YYYY' (e.g., '3/15/2025'). Cannot be used with search_recency_filter."
|
|
882
960
|
),
|
|
883
|
-
last_updated_after_filter:
|
|
961
|
+
last_updated_after_filter: import_zod2.z.string().optional().describe(
|
|
884
962
|
"Include only results last updated after this date. Format: 'MM/DD/YYYY' (e.g., '3/1/2025'). Cannot be used with search_recency_filter."
|
|
885
963
|
),
|
|
886
|
-
last_updated_before_filter:
|
|
964
|
+
last_updated_before_filter: import_zod2.z.string().optional().describe(
|
|
887
965
|
"Include only results last updated before this date. Format: 'MM/DD/YYYY' (e.g., '3/15/2025'). Cannot be used with search_recency_filter."
|
|
888
966
|
),
|
|
889
|
-
search_recency_filter:
|
|
967
|
+
search_recency_filter: import_zod2.z.enum(["day", "week", "month", "year"]).optional().describe(
|
|
890
968
|
"Filter results by relative time period. Cannot be used with search_after_date or search_before_date."
|
|
891
969
|
)
|
|
892
970
|
})
|
|
893
971
|
)
|
|
894
972
|
);
|
|
895
|
-
var perplexitySearchOutputSchema = (0,
|
|
896
|
-
() => (0,
|
|
897
|
-
|
|
973
|
+
var perplexitySearchOutputSchema = (0, import_provider_utils9.lazySchema)(
|
|
974
|
+
() => (0, import_provider_utils9.zodSchema)(
|
|
975
|
+
import_zod2.z.union([
|
|
898
976
|
// Success response
|
|
899
|
-
|
|
900
|
-
results:
|
|
901
|
-
|
|
902
|
-
title:
|
|
903
|
-
url:
|
|
904
|
-
snippet:
|
|
905
|
-
date:
|
|
906
|
-
lastUpdated:
|
|
977
|
+
import_zod2.z.object({
|
|
978
|
+
results: import_zod2.z.array(
|
|
979
|
+
import_zod2.z.object({
|
|
980
|
+
title: import_zod2.z.string(),
|
|
981
|
+
url: import_zod2.z.string(),
|
|
982
|
+
snippet: import_zod2.z.string(),
|
|
983
|
+
date: import_zod2.z.string().optional(),
|
|
984
|
+
lastUpdated: import_zod2.z.string().optional()
|
|
907
985
|
})
|
|
908
986
|
),
|
|
909
|
-
id:
|
|
987
|
+
id: import_zod2.z.string()
|
|
910
988
|
}),
|
|
911
989
|
// Error response
|
|
912
|
-
|
|
913
|
-
error:
|
|
990
|
+
import_zod2.z.object({
|
|
991
|
+
error: import_zod2.z.enum([
|
|
914
992
|
"api_error",
|
|
915
993
|
"rate_limit",
|
|
916
994
|
"timeout",
|
|
917
995
|
"invalid_input",
|
|
918
996
|
"unknown"
|
|
919
997
|
]),
|
|
920
|
-
statusCode:
|
|
921
|
-
message:
|
|
998
|
+
statusCode: import_zod2.z.number().optional(),
|
|
999
|
+
message: import_zod2.z.string()
|
|
922
1000
|
})
|
|
923
1001
|
])
|
|
924
1002
|
)
|
|
925
1003
|
);
|
|
926
|
-
var perplexitySearchToolFactory = (0,
|
|
1004
|
+
var perplexitySearchToolFactory = (0, import_provider_utils9.createProviderToolFactoryWithOutputSchema)({
|
|
927
1005
|
id: "gateway.perplexity_search",
|
|
928
1006
|
inputSchema: perplexitySearchInputSchema,
|
|
929
1007
|
outputSchema: perplexitySearchOutputSchema
|
|
@@ -932,6 +1010,15 @@ var perplexitySearch = (config = {}) => perplexitySearchToolFactory(config);
|
|
|
932
1010
|
|
|
933
1011
|
// src/gateway-tools.ts
|
|
934
1012
|
var gatewayTools = {
|
|
1013
|
+
/**
|
|
1014
|
+
* Search the web using Parallel AI's Search API for LLM-optimized excerpts.
|
|
1015
|
+
*
|
|
1016
|
+
* Takes a natural language objective and returns relevant excerpts,
|
|
1017
|
+
* replacing multiple keyword searches with a single call for broad
|
|
1018
|
+
* or complex queries. Supports different search types for depth vs
|
|
1019
|
+
* breadth tradeoffs.
|
|
1020
|
+
*/
|
|
1021
|
+
parallelSearch,
|
|
935
1022
|
/**
|
|
936
1023
|
* Search the web using Perplexity's Search API for real-time information,
|
|
937
1024
|
* news, research papers, and articles.
|
|
@@ -951,10 +1038,10 @@ async function getVercelRequestId() {
|
|
|
951
1038
|
}
|
|
952
1039
|
|
|
953
1040
|
// src/gateway-provider.ts
|
|
954
|
-
var
|
|
1041
|
+
var import_provider_utils11 = require("@ai-sdk/provider-utils");
|
|
955
1042
|
|
|
956
1043
|
// src/version.ts
|
|
957
|
-
var VERSION = true ? "3.0.
|
|
1044
|
+
var VERSION = true ? "3.0.28" : "0.0.0-test";
|
|
958
1045
|
|
|
959
1046
|
// src/gateway-provider.ts
|
|
960
1047
|
var AI_GATEWAY_PROTOCOL_VERSION = "0.0.1";
|
|
@@ -964,11 +1051,11 @@ function createGatewayProvider(options = {}) {
|
|
|
964
1051
|
let metadataCache = null;
|
|
965
1052
|
const cacheRefreshMillis = (_a8 = options.metadataCacheRefreshMillis) != null ? _a8 : 1e3 * 60 * 5;
|
|
966
1053
|
let lastFetchTime = 0;
|
|
967
|
-
const baseURL = (_b8 = (0,
|
|
1054
|
+
const baseURL = (_b8 = (0, import_provider_utils10.withoutTrailingSlash)(options.baseURL)) != null ? _b8 : "https://ai-gateway.vercel.sh/v3/ai";
|
|
968
1055
|
const getHeaders = async () => {
|
|
969
1056
|
try {
|
|
970
1057
|
const auth = await getGatewayAuthToken(options);
|
|
971
|
-
return (0,
|
|
1058
|
+
return (0, import_provider_utils11.withUserAgentSuffix)(
|
|
972
1059
|
{
|
|
973
1060
|
Authorization: `Bearer ${auth.token}`,
|
|
974
1061
|
"ai-gateway-protocol-version": AI_GATEWAY_PROTOCOL_VERSION,
|
|
@@ -987,15 +1074,15 @@ function createGatewayProvider(options = {}) {
|
|
|
987
1074
|
}
|
|
988
1075
|
};
|
|
989
1076
|
const createO11yHeaders = () => {
|
|
990
|
-
const deploymentId = (0,
|
|
1077
|
+
const deploymentId = (0, import_provider_utils10.loadOptionalSetting)({
|
|
991
1078
|
settingValue: void 0,
|
|
992
1079
|
environmentVariableName: "VERCEL_DEPLOYMENT_ID"
|
|
993
1080
|
});
|
|
994
|
-
const environment = (0,
|
|
1081
|
+
const environment = (0, import_provider_utils10.loadOptionalSetting)({
|
|
995
1082
|
settingValue: void 0,
|
|
996
1083
|
environmentVariableName: "VERCEL_ENV"
|
|
997
1084
|
});
|
|
998
|
-
const region = (0,
|
|
1085
|
+
const region = (0, import_provider_utils10.loadOptionalSetting)({
|
|
999
1086
|
settingValue: void 0,
|
|
1000
1087
|
environmentVariableName: "VERCEL_REGION"
|
|
1001
1088
|
});
|
|
@@ -1088,7 +1175,7 @@ function createGatewayProvider(options = {}) {
|
|
|
1088
1175
|
}
|
|
1089
1176
|
var gateway = createGatewayProvider();
|
|
1090
1177
|
async function getGatewayAuthToken(options) {
|
|
1091
|
-
const apiKey = (0,
|
|
1178
|
+
const apiKey = (0, import_provider_utils10.loadOptionalSetting)({
|
|
1092
1179
|
settingValue: options.apiKey,
|
|
1093
1180
|
environmentVariableName: "AI_GATEWAY_API_KEY"
|
|
1094
1181
|
});
|