/** * Tavily direct HTTP transport (DESIGN.md §5, §7; tech-plan §7). * * Performs direct POSTs against the Tavily REST endpoints with an * `Authorization: Bearer ` header. There is NO internal retry — * shared execution owns retry policy. Fetch and timer are injectable for * tests. * * Mirrors `providers/minimax/coding-plan-client.ts` in structure, but * SIMPLER: Tavily uses HTTP-status exclusively for errors (no body-level * business status code like MiniMax's `base_resp.status_code`). Error * responses are `{ "detail": { "error": "message" } }`; the transport * maps HTTP status to Scoutline errors at the transport layer only — no * second body-parsing layer needed. * * Boundary rules (ARCHITECTURE.md §2): * - May import Adapter-local config and normalized errors. * - May import `ProviderQuotaFetch` from `providers/types.ts`. * - Must NOT import command presentation, capability contracts, or * another Provider's Adapter. * - Must NOT perform response field normalization — the Adapter owns * that. This module declares Provider-native request-body types * only (Tavily API field names); it does not import SearchControls * or any capability contract. */ import type { ProviderQuotaFetch } from "../types.js"; /** Injectable transport dependencies (fetch, timers, env). */ export interface TavilyTransportDeps { readonly fetch?: ProviderQuotaFetch; readonly setTimeout?: typeof setTimeout; readonly clearTimeout?: typeof clearTimeout; readonly env?: NodeJS.ProcessEnv; } /** * Provider-native search request body fields (Tavily API field names). * The Adapter maps the Provider-neutral `SearchControls` into these * before calling {@link fetchTavilySearch}; the transport never imports * a capability contract. */ export interface TavilySearchParams { readonly topic?: string; readonly search_depth?: string; readonly include_domains?: readonly string[]; readonly time_range?: string; } /** * Provider-native extract request options. The Adapter maps * `contentSize` to `extract_depth`; the transport sends the body. */ export interface TavilyExtractParams { readonly extract_depth?: string; /** * Output format forwarded to the Tavily extract API (T8-03). Controls * whether the API returns markdown or plain text in `raw_content`. */ readonly format?: "markdown" | "text"; /** * Seconds the server may spend on the extraction (CC-2, #66). The * /extract API documents `timeout` as a float in [1.0, 60.0] with * depth-dependent defaults (10s basic / 30s advanced). */ readonly timeout?: number; } /** * Provider-native crawl request body fields (Tavily API field names). * The Adapter maps the Provider-neutral `CrawlRequest` into these before * calling {@link fetchTavilyCrawl}; the transport never imports a * capability contract. */ export interface TavilyCrawlParams { readonly max_depth?: number; readonly max_breadth?: number; readonly limit?: number; readonly select_paths?: readonly string[]; readonly exclude_paths?: readonly string[]; readonly instructions?: string; readonly format?: string; readonly extract_depth?: string; readonly timeout?: number; } /** * Provider-native map request body fields (Tavily API field names). * The Adapter maps the Provider-neutral `MapRequest` into these before * calling {@link fetchTavilyMap}; the transport never imports a * capability contract. * * Map returns URLs only — no `format`, `extract_depth`, or `timeout` * fields. The /map endpoint surfaces the discovered site structure and * deliberately omits per-page extraction controls. The client-side timeout * mirrors the crawl pattern (T8-02): at least 150s + 5s buffer. */ export interface TavilyMapParams { readonly max_depth?: number; readonly max_breadth?: number; readonly limit?: number; readonly select_paths?: readonly string[]; readonly exclude_paths?: readonly string[]; readonly instructions?: string; } /** * Provider-native research request body fields (Tavily API field names). * The Adapter maps the Provider-neutral `ResearchRequest` into these * before calling {@link createTavilyResearch}; the transport never * imports a capability contract. */ export interface TavilyResearchParams { readonly query: string; readonly model?: string; readonly output_length?: string; readonly citation_format?: string; readonly domain?: string; } /** * Structured result of POST /research. The endpoint returns HTTP 201 * (Created) with `{ request_id, status: "pending" }`. */ export interface TavilyResearchCreateResult { readonly requestId: string; readonly status: string; } /** * Structured result of GET /research/{id}. `status: "not_found"` is * returned (not thrown) for HTTP 404 so the Adapter can treat a stale * state file as "delete it and create a new task" rather than a terminal * transport error. */ export interface TavilyResearchPollResult { readonly status: "pending" | "in_progress" | "completed" | "failed" | "not_found"; readonly content?: string; readonly sources?: readonly TavilyResearchPollSource[]; } export interface TavilyResearchPollSource { readonly title?: string; readonly url?: string; } export declare function resolveTimeoutMs(env: NodeJS.ProcessEnv): number; /** * Perform ONE POST against the Tavily /search endpoint. No retry; no * response body in public errors. Returns the parsed JSON body (raw; * the Adapter post-processes into normalized search sources). * * `params` carries Tavily-native API fields already mapped from * `SearchControls` by the Adapter. */ export declare function fetchTavilySearch(apiKey: string, query: string, params?: TavilySearchParams, deps?: TavilyTransportDeps): Promise; /** * Perform ONE POST against the Tavily /extract endpoint. No retry; no * response body in public errors. Returns the parsed JSON body (raw; * the Adapter post-processes into a normalized ReaderFetchResult). * * `url` is a single URL; the transport wraps it as `urls: [url]` per * the Tavily API contract. */ export declare function fetchTavilyExtract(apiKey: string, url: string, params?: TavilyExtractParams, deps?: TavilyTransportDeps): Promise; /** * Perform ONE POST against the Tavily /crawl endpoint. No retry; no * response body in public errors. Returns the parsed JSON body (raw; the * Adapter post-processes into a normalized CrawlResult). * * `params` carries Tavily-native API fields already mapped from * `CrawlRequest` by the Adapter. */ export declare function fetchTavilyCrawl(apiKey: string, url: string, params?: TavilyCrawlParams, deps?: TavilyTransportDeps): Promise; /** * Perform ONE POST against the Tavily /map endpoint. No retry; no * response body in public errors. Returns the parsed JSON body (raw; the * Adapter post-processes into a normalized MapResult). * * `params` carries Tavily-native API fields already mapped from * `MapRequest` by the Adapter. The /map response is `{ results: string[] }` * — an array of URL strings, NOT an array of page objects — and is * returned as raw `unknown` for the Adapter to normalize. */ export declare function fetchTavilyMap(apiKey: string, url: string, params?: TavilyMapParams, deps?: TavilyTransportDeps): Promise; export declare function fetchTavilyUsage(apiKey: string, deps?: TavilyTransportDeps): Promise; /** * Perform ONE POST against the Tavily /research endpoint. No retry; no * response body in public errors. Returns the structured create result * `{ requestId, status }`. * * Note: /research returns HTTP 201 (Created) on success, not 200. The * shared `postTavilyJson` treats any 2xx as success (`res.ok`), so 201 * is handled correctly without special-casing the status mapping. */ export declare function createTavilyResearch(apiKey: string, query: string, params?: Omit, deps?: TavilyTransportDeps): Promise; /** * Perform ONE GET against the Tavily /research/{request_id} endpoint. * No retry. Returns a structured poll result. * * Unlike other GETs, a 404 is NOT a terminal transport error here: it * means the server-side task has expired/disappeared, so the Adapter can * delete the stale state file and create a fresh task. The poll result * carries `status: "not_found"` for that case. All other non-2xx statuses * throw the standard mapped error (auth, rate limit, 5xx). */ export declare function pollTavilyResearch(apiKey: string, requestId: string, deps?: TavilyTransportDeps): Promise; //# sourceMappingURL=client.d.ts.map