/** * Firecrawl direct HTTP transport (firecrawl tech-plan §1, D3). * * Performs direct POSTs against the Firecrawl v2 REST endpoints with an * `Authorization: Bearer fc-` header. There is NO internal retry — * shared execution owns retry policy. Fetch and timer are injectable for * tests. * * Mirrors `providers/tavily/client.ts` in structure, with one * Firecrawl-specific difference: the **error-envelope dual-check**. * Firecrawl returns HTTP 200 with `{ success: false }` for some business * errors (investigation §1.2), so the transport checks BOTH * `response.ok` and `body.success === false` after parsing. * * 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 * (Firecrawl 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 FirecrawlTransportDeps { readonly fetch?: ProviderQuotaFetch; readonly setTimeout?: typeof setTimeout; readonly clearTimeout?: typeof clearTimeout; readonly env?: NodeJS.ProcessEnv; } /** * Provider-native search request body fields (Firecrawl API field names). * The Adapter maps the Provider-neutral `SearchControls` into these before * calling {@link fetchFirecrawlSearch}; the transport never imports a * capability contract. * * `scrapeOptions` is nested (unlike `/scrape` which takes `formats` * top-level) — investigation §3.2 / tech-plan D4. */ export interface FirecrawlSearchParams { /** `[{type:"web"}]` default; `[{type:"news"}]` for news topic. */ readonly sources?: readonly { readonly type: string; }[]; readonly includeDomains?: readonly string[]; readonly tbs?: string; /** Gated by `--content-size high` → `{ formats: ["markdown"] }`. */ readonly scrapeOptions?: { readonly formats: readonly string[]; }; } /** * Provider-native scrape request body fields (Firecrawl API field names). * The Adapter maps the Reader request into these before calling * {@link fetchFirecrawlScrape}. */ export interface FirecrawlScrapeParams { /** `["markdown"]` (default) or `["text"]`. */ readonly formats: readonly string[]; /** Inverted from `retainImages`. */ readonly removeBase64Images?: boolean; /** Pinned per tech-plan D9 (cost-safety — avoids 5-credit enhanced proxy). */ readonly proxy: "basic"; } /** Provider-native map request body fields (Firecrawl API field names). */ export interface FirecrawlMapParams { readonly limit?: number; /** Mapped from `--instructions`. */ readonly search?: string; } export declare function resolveTimeoutMs(env: NodeJS.ProcessEnv): number; /** * Perform ONE POST against the Firecrawl /v2/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 Firecrawl-native API fields already mapped from * `SearchControls` by the Adapter. */ export declare function fetchFirecrawlSearch(apiKey: string, query: string, params: FirecrawlSearchParams | undefined, deps?: FirecrawlTransportDeps): Promise; /** * Perform ONE POST against the Firecrawl /v2/scrape 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; `params` carries the format + image/proxy options * already mapped from the Reader request by the Adapter. */ export declare function fetchFirecrawlScrape(apiKey: string, url: string, params: FirecrawlScrapeParams, deps?: FirecrawlTransportDeps): Promise; /** * Perform ONE POST against the Firecrawl /v2/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 Firecrawl-native API fields already mapped from * `MapRequest` by the Adapter. The /v2/map response is * `{ success, links: string[] }`. */ export declare function fetchFirecrawlMap(apiKey: string, url: string, params: FirecrawlMapParams | undefined, deps?: FirecrawlTransportDeps): Promise; /** * Perform ONE GET against Firecrawl /v2/team/credit-usage. No retry; no * response body in public errors. Returns the parsed JSON body (raw; the * quota Adapter normalizes into a `QuotaCategory`). The dual-check applies. */ export declare function fetchFirecrawlCreditUsage(apiKey: string, deps?: FirecrawlTransportDeps): Promise; /** * Provider-native crawl request body fields (Firecrawl API field names). * The Adapter maps `CrawlRequest` into these. `breadth` has no Firecrawl * equivalent and is rejected by the Adapter; `proxy` is pinned to * `"basic"` per tech-plan D9 (cost-safety — avoids the 5-credit enhanced * proxy) and nests under `scrapeOptions` (crawl/search nest scrape fields; * `/scrape` takes `proxy` top-level). `scrapeOptions` carries the same * fields as `/scrape`. */ export interface FirecrawlCrawlParams { /** v2 wire field name (was v1 `maxDepth`, which Firecrawl silently ignored). */ readonly maxDiscoveryDepth?: number; readonly limit?: number; readonly includePaths?: readonly string[]; readonly excludePaths?: readonly string[]; readonly scrapeOptions: { readonly formats: readonly string[]; readonly proxy: "basic"; }; } /** Result of POST /v2/crawl — `{ success, id, url }`. */ export interface FirecrawlCrawlCreateResult { readonly id: string; } /** Poll status values Firecrawl returns for GET /v2/crawl/{id}. */ export type FirecrawlCrawlStatus = "scraping" | "completed" | "failed" | "cancelled" | "not_found"; /** * Structured poll result. `status:"not_found"` is returned (not thrown) * for HTTP 404 so the Adapter can drop a stale state file and create a * fresh job. A `success:false` envelope is treated as a job failure * (`status:"failed"`). */ export interface FirecrawlCrawlPollResult { readonly status: FirecrawlCrawlStatus; /** Pages collected so far — present once the job is `completed`. */ readonly data?: readonly unknown[]; /** Pagination cursor for large completed sets; absent when exhausted. */ readonly next?: string; } /** One entry from GET /v2/crawl/active — used for reclaim-on-miss. */ export interface FirecrawlActiveCrawl { readonly id: string; readonly url?: string; /** v2 wire field (camelCase). `created_at` kept as a backward-compat alias. */ readonly createdAt?: string; readonly created_at?: string; readonly options?: unknown; } /** * Perform ONE POST against Firecrawl /v2/crawl (zero-retry is enforced by * shared execution, not here). Returns the structured create result * `{ id }`. The dual-check applies: a 200 with `{success:false}` is a * business error. */ export declare function createFirecrawlCrawl(apiKey: string, url: string, params: FirecrawlCrawlParams, deps?: FirecrawlTransportDeps): Promise; /** * Perform ONE GET against Firecrawl /v2/crawl/{id}. No retry. A 404 is NOT * a terminal transport error: it means the server-side job disappeared, so * the Adapter can drop the stale state file and create a fresh job. Returns * a structured poll result. A `success:false` envelope or `status:"failed"` * maps to `status:"failed"` so the Adapter handles job failure uniformly. */ export declare function pollFirecrawlCrawl(apiKey: string, id: string, deps?: FirecrawlTransportDeps): Promise; /** * Perform ONE GET against Firecrawl /v2/crawl/active (reclaim-on-miss). * Returns the active-job entries. The dual-check applies. */ export declare function listActiveFirecrawlCrawls(apiKey: string, deps?: FirecrawlTransportDeps): Promise; /** * Perform ONE GET against a Firecrawl crawl pagination `next` URL (large * completed sets). `next` may be absolute or relative; relative URLs are * resolved against {@link BASE_URL}. Returns `{ data?, next? }`. The * dual-check applies. */ export declare function fetchFirecrawlCrawlNext(apiKey: string, next: string, deps?: FirecrawlTransportDeps): Promise<{ readonly data?: readonly unknown[]; readonly next?: string; }>; //# sourceMappingURL=client.d.ts.map