import * as ai from 'ai'; import { Parallel } from 'parallel-web'; import { ExcerptSettings, FetchPolicy, AdvancedExtractSettings } from 'parallel-web/resources/top-level.mjs'; import { SourcePolicy } from 'parallel-web/resources/shared.mjs'; /** * Options for creating a custom search tool with code-supplied defaults. */ interface CreateSearchToolOptions { /** * API key for Parallel Web. If not provided, falls back to PARALLEL_API_KEY * environment variable. */ apiKey?: string; /** * Default search mode. 'basic' offers the lowest latency and works best with * 2-3 high-quality search queries. 'advanced' provides higher quality with more * advanced retrieval and compression. Defaults to 'advanced'. */ mode?: 'basic' | 'advanced'; /** * Upper bound on total characters across excerpts from all results. Defaults to * a dynamic value based on the request and client_model. */ max_chars_total?: number; /** * The model consuming the results, e.g. 'claude-opus-4-7'. Enables optimizations * tailored to the model's capabilities. */ client_model?: string; /** * Maximum number of search results to return. Defaults to 10. * Nested under advanced_settings in the v1 API. */ max_results?: number; /** * Excerpt settings for controlling excerpt length. * Nested under advanced_settings in the v1 API. */ excerpts?: ExcerptSettings; /** * ISO 3166-1 alpha-2 country code for geo-targeted search results. * Nested under advanced_settings in the v1 API. */ location?: string; /** * Source policy for controlling which domains to include/exclude and freshness. * Nested under advanced_settings in the v1 API. */ source_policy?: SourcePolicy | null; /** * Fetch policy for controlling cached vs fresh content. * Nested under advanced_settings in the v1 API. */ fetch_policy?: FetchPolicy | null; /** * Custom tool description. If not provided, uses the default description. */ description?: string; } /** * Search tool that mirrors the MCP web_search_preview tool. * Takes search_queries plus optional objective/mode, returns raw search response. */ declare const searchTool: ai.Tool<{ search_queries: string[]; mode: "basic" | "advanced" | null; objective?: string | null | undefined; }, Parallel.SearchResult>; /** * Factory function to create a search tool with custom defaults. * * Use this when you want to set defaults for mode, max_chars_total, client_model, * or advanced settings (max_results, excerpts, location, source_policy, * fetch_policy) in your code, so the LLM only needs to provide search_queries and * objective. * * @example * ```ts * const mySearchTool = createSearchTool({ * mode: 'basic', * max_results: 5, * excerpts: { max_chars_per_result: 5000 }, * }); * ``` */ declare function createSearchTool(options?: CreateSearchToolOptions): ai.Tool<{ search_queries: string[]; objective?: string | null | undefined; }, Parallel.SearchResult>; /** * Options for creating a custom extract tool with code-supplied defaults. */ interface CreateExtractToolOptions { /** * API key for Parallel Web. If not provided, falls back to PARALLEL_API_KEY * environment variable. */ apiKey?: string; /** * Excerpt settings for controlling excerpt length. In the v1 API excerpts are * always returned; size is controlled via these settings. * Nested under advanced_settings in the v1 API. */ excerpts?: ExcerptSettings; /** * Include full content from each URL. Set to true to enable with defaults, false * to disable, or provide FullContentSettings for fine-grained control. * Nested under advanced_settings in the v1 API. */ full_content?: AdvancedExtractSettings['full_content']; /** * Fetch policy for controlling cached vs fresh content. * Nested under advanced_settings in the v1 API. */ fetch_policy?: FetchPolicy | null; /** * Upper bound on total characters across excerpts from all extracted results. * Defaults to a dynamic value based on the request and client_model. */ max_chars_total?: number; /** * The model consuming the results, e.g. 'claude-opus-4-7'. Enables optimizations * tailored to the model's capabilities. */ client_model?: string; /** * Custom tool description. If not provided, uses the default description. */ description?: string; } /** * Extract tool that mirrors the MCP web_fetch tool. * Takes urls and optional objective, returns raw extract response. */ declare const extractTool: ai.Tool<{ urls: string[]; objective?: string | null | undefined; }, Parallel.ExtractResponse>; /** * Factory function to create an extract tool with custom defaults. * * Use this when you want to set defaults for excerpts, full_content, * fetch_policy, max_chars_total, or client_model in your code, so the LLM only * needs to provide urls and objective. * * @example * ```ts * const myExtractTool = createExtractTool({ * excerpts: { max_chars_per_result: 5000 }, * full_content: true, * }); * ``` */ declare function createExtractTool(options?: CreateExtractToolOptions): ai.Tool<{ urls: string[]; objective?: string | null | undefined; }, Parallel.ExtractResponse>; export { type CreateExtractToolOptions, type CreateSearchToolOptions, createExtractTool, createSearchTool, extractTool, searchTool };