//#region src/version.d.ts declare const version: string; //#endregion //#region src/core/providers.d.ts declare const builtinProviders: readonly ["brave", "exa", "jina", "searxng", "serpapi", "serpbase", "tavily"]; type WebSearchProviderName = typeof builtinProviders[number]; //#endregion //#region src/core/types.d.ts interface SearchResult { url: string; title: string; snippet: string; score?: number; publishedDate?: string; author?: string; image?: string; favicon?: string; text?: string; highlights?: string[]; summary?: string; metadata?: Record; } interface SearchOptions { maxResults?: number; includeDomains?: string[]; excludeDomains?: string[]; startPublishedDate?: string; endPublishedDate?: string; category?: string; } interface ReadResult { url: string; title?: string; description?: string; content: string; text?: string; html?: string; publishedDate?: string; image?: string; links?: string[]; images?: string[]; metadata?: Record; } interface ReadOptions { format?: 'markdown' | 'text' | 'html'; maxTokens?: number; targetSelector?: string; removeSelector?: string; timeout?: number; noCache?: boolean; } interface SearchProvider { name(): string; search(query: string, options?: SearchOptions): Promise; read?(url: string, options?: ReadOptions): Promise; /** * Optional reachability probe. Used by {@link searchAll} and async detection * helpers to skip self-hosted / optional providers whose endpoint is not * responding, without failing the fan-out. Providers backed by paid APIs * usually omit this and rely on env-var presence as the configured signal. * Should resolve quickly (<= ~2s) and never throw. */ isAvailable?(): Promise; } interface ProviderConfig { apiKey?: string; baseURL?: string; readBaseURL?: string; } type ProviderFactory = (config: ProviderConfig) => SearchProvider; interface ClientOptions { maxRetries?: number; baseDelay?: number; timeout?: number; userAgent?: string; } //#endregion //#region src/core/errors.d.ts /** Base error for all askweb operations. */ declare class AskwebError extends Error { constructor(message: string, options?: ErrorOptions); } /** Non-auth HTTP error with status code, URL, and response body. */ declare class HTTPError extends AskwebError { readonly statusCode: number; readonly url: string; readonly body: string; constructor(statusCode: number, url: string, body: string); isNotFound(): boolean; isRateLimit(): boolean; isServerError(): boolean; } /** Thrown when a provider rejects the API key (HTTP 401). */ declare class AuthError extends AskwebError { readonly provider: string; constructor(message: string, provider: string); } /** Thrown on HTTP 429. Check {@link retryAfter} for seconds until retry. */ declare class RateLimitError extends AskwebError { readonly retryAfter: number; constructor(retryAfter: number); } /** Thrown when {@link create} is called with an unregistered provider name. */ declare class UnknownProviderError extends AskwebError { readonly provider: string; constructor(provider: string); } /** Thrown when the search query is empty or whitespace-only. */ declare class EmptyQueryError extends AskwebError { constructor(); } /** Thrown when the read URL is empty or whitespace-only. */ declare class EmptyUrlError extends AskwebError { constructor(); } /** Thrown when a provider does not implement the read capability. */ declare class ReadNotSupportedError extends AskwebError { readonly provider: string; constructor(provider: string); } /** Thrown when no provider can be selected from env or registry. */ declare class NoProviderConfiguredError extends AskwebError { constructor(); } /** Thrown when providers are configured but none are currently reachable. */ declare class NoProviderAvailableError extends AskwebError { readonly providers: readonly string[]; constructor(providers: readonly string[]); } /** Thrown when a date filter string is not valid ISO 8601 or the range is reversed. */ declare class InvalidDateFilterError extends AskwebError { readonly field: string; readonly value: string; readonly reason: string; constructor(field: string, value: string, reason: string); } declare function validateDateFilters(startPublishedDate?: string, endPublishedDate?: string): void; /** * Convert any caught error into a typed {@link AskwebError} subclass. * Maps HTTP status codes to specific error types (401 → AuthError, 429 → RateLimitError). */ declare function normalizeError(error: unknown, provider?: string): AskwebError; //#endregion //#region src/core/client.d.ts /** HTTP client with exponential backoff retry and error mapping to askweb error types. */ declare class Client { readonly maxRetries: number; readonly baseDelay: number; readonly timeout: number; readonly userAgent: string; private readonly fetch; constructor(options?: ClientOptions); /** Send a GET request and parse the JSON response. */ getJSON(url: string, headers?: Record, signal?: AbortSignal): Promise; /** Send a POST request with a JSON body and parse the JSON response. */ postJSON(url: string, body: Record, headers?: Record, signal?: AbortSignal): Promise; private mapError; } /** Lazily-initialized singleton {@link Client} used by all providers. */ declare function defaultClient(): Client; //#endregion //#region src/core/registry.d.ts /** * Register a provider factory with the registry. * Called by providers on import to self-register. */ declare function register(name: string, defaultURL: string, factory: ProviderFactory): void; /** * Create a provider instance by name. * Resolves apiKey from config or environment variable (PROVIDER_NAME_API_KEY). */ declare function create(name: string, config?: ProviderConfig): SearchProvider; /** * List all registered provider names. */ declare function providers(): string[]; /** * Check if a provider is registered. */ declare function has(name: string): boolean; //#endregion //#region src/core/all.d.ts interface SearchAllOptions extends SearchOptions { providers?: string[]; } interface SearchAllResult extends SearchResult { provider: string; } interface ProviderError { provider: string; error: Error; } interface SearchAllResponse { results: SearchAllResult[]; errors: ProviderError[]; } /** * Query multiple providers in parallel and return deduplicated results. * Providers are auto-detected from env vars unless explicitly specified. * Individual provider failures don't affect other results. */ declare function searchAll(query: string, options?: SearchAllOptions): Promise; /** * Like {@link searchAll}, but also returns per-provider errors so callers * can tell which providers failed and why. */ declare function searchAllDetailed(query: string, options?: SearchAllOptions): Promise; //#endregion //#region src/core/read.d.ts declare const readProviderNames: readonly ["jina"]; type ReadProviderName = typeof readProviderNames[number]; interface ReadUrlOptions extends ReadOptions { provider?: ReadProviderName | (string & {}); } declare function readUrl(url: string, options?: ReadUrlOptions): Promise; //#endregion //#region src/core/resolve.d.ts declare function detectAvailableProviders(): WebSearchProviderName[]; declare function resolveDefaultProvider(): WebSearchProviderName; interface ProviderStatus { name: WebSearchProviderName; configured: boolean; envVar: string | null; /** * Set by {@link listProvidersAsync} when the provider implements * {@link SearchProvider.isAvailable}. `true` = probe succeeded, `false` = * probe failed (host down / unreachable / timeout), `undefined` = no probe * was performed (sync caller) or provider has no probe (trust `configured`). */ reachable?: boolean; } declare function listProviders(): ProviderStatus[]; /** * Async variant: returns only providers that are both declaratively configured * (env var present or registered) AND — if they implement `isAvailable()` — * pass the reachability probe. Use for fan-out flows (`searchAll`) where an * unreachable self-hosted endpoint should be skipped instead of producing a * connection-refused error. Sync {@link detectAvailableProviders} stays the * declarative source of truth for env-var inspection. */ declare function detectAvailableProvidersAsync(): Promise; /** * Async variant of {@link listProviders} that also runs the per-provider * reachability probe and surfaces it as `reachable` on each row. Providers * without an `isAvailable()` probe get `reachable: undefined` (trust * `configured`). */ declare function listProvidersAsync(): Promise; /** * Async variant of {@link resolveDefaultProvider}: returns the first provider * that is configured AND (if it has an `isAvailable()` probe) reachable. Use * in flows that should not crash when the env-preferred default is down * (e.g. SearXNG on `localhost:8080` without a running instance). */ declare function resolveDefaultProviderAsync(): Promise; //#endregion export { NoProviderAvailableError as A, ReadOptions as B, defaultClient as C, EmptyUrlError as D, EmptyQueryError as E, normalizeError as F, WebSearchProviderName as G, SearchOptions as H, validateDateFilters as I, builtinProviders as K, ClientOptions as L, RateLimitError as M, ReadNotSupportedError as N, HTTPError as O, UnknownProviderError as P, ProviderConfig as R, Client as S, AuthError as T, SearchProvider as U, ReadResult as V, SearchResult as W, searchAllDetailed as _, listProvidersAsync as a, providers as b, ReadProviderName as c, readUrl as d, ProviderError as f, searchAll as g, SearchAllResult as h, listProviders as i, NoProviderConfiguredError as j, InvalidDateFilterError as k, ReadUrlOptions as l, SearchAllResponse as m, detectAvailableProviders as n, resolveDefaultProvider as o, SearchAllOptions as p, version as q, detectAvailableProvidersAsync as r, resolveDefaultProviderAsync as s, ProviderStatus as t, readProviderNames as u, create as v, AskwebError as w, register as x, has as y, ProviderFactory as z }; //# sourceMappingURL=index2.d.mts.map