/** * Tavily search-provider adapter for `web.search`. * * Implements the {@link SearchProvider} contract from `./provider.ts` and * registers itself in the {@link searchProviders} registry on import. The * adapter performs exactly one outbound HTTPS request per invocation * (Requirement 6.7), forwards the caller-provided {@link AbortSignal} to * the underlying transport so the 15-second `web.search` timeout is * honored (Requirement 1.8), and returns a {@link RawProviderResponse} * describing the HTTP outcome plus the raw hit list. * * Status-to-error-kind classification (`401/403 → auth`, `429 → rate-limit`, * `5xx → server`, non-JSON → `parse`, other non-2xx → `http`) is the * responsibility of the `web.search` handler; this adapter only exposes * the raw HTTP `status` and the parsed (or `parseError`-flagged) hit list * so that mapping can be applied uniformly across providers (Requirements * 6.1, 6.2, 6.5, 6.6). * * Endpoint and request shape match the design's "Per-provider notes → * Tavily" section (`.kiro/specs/web-search-and-fetch/design.md`): * * - POST `https://api.tavily.com/search` * - Body: `{ api_key, query, max_results, search_depth: "basic" }` * where `max_results` is clamped to `[1..20]` defensively. * - Response: `{ results: [{ title, url, content }] }` mapped into * `SearchResult { title, url, snippet }`. */ import https from "node:https"; import { type SearchProvider } from "./provider.js"; /** * Inject point for the underlying HTTPS transport so unit/property * tests can drive the adapter without touching the network. The * default mirrors the standard `node:https.request` signature. * * Kept module-private (not exported as a normal export) because the * public adapter contract intentionally takes no transport argument — * `web.search` always uses the default transport in production. */ type HttpsRequestFn = typeof https.request; /** * Test-only seam: swap the HTTPS transport used by the adapter. * Production callers never invoke this; tests use it to inject a * stubbed `request` implementation that emits scripted responses. */ export declare function __setTavilyHttpsRequestForTesting(fn: HttpsRequestFn | undefined): void; /** * Tavily adapter. Registered in {@link searchProviders} as a * side-effect of importing this module — `web.search` resolves the * active provider via the registry. */ export declare const tavilyProvider: SearchProvider; export {};