import { J as SearchPageOptions, K as SearchFilterName, L as CodexCredentials, Q as SearchResult, R as ExecutionOptions, U as ReadOptions, V as ImageSearchResult, W as ReadResult, Y as SearchPagination, s as ProviderCapabilities, z as ImageSearchOptions } from "./provider-BeqDw0W2.mjs"; //#region src/version.d.ts /** The package build and process instance currently serving requests. */ interface RuntimeInfo { readonly version: string; readonly buildId: string; readonly processStartedAt: string; } declare const version: string; /** Immutable identity of the loaded package and hosting process. */ declare const runtimeInfo: RuntimeInfo; //#endregion //#region src/core/providers.d.ts declare const builtinProviders: readonly ["brave", "context", "exa", "firecrawl", "jina", "mojeek", "openai-codex", "searxng", "serpapi", "serpbase", "tavily", "tinyfish"]; type WebSearchProviderName = (typeof builtinProviders)[number]; //#endregion //#region src/core/errors.d.ts /** Base error for all web operations. */ declare class WebError extends Error { constructor(message: string, options?: Readonly); } /** HTTP failure with status code, URL, and response body. */ declare class HTTPError extends WebError { readonly statusCode: number; readonly url: string; readonly body: string; constructor(statusCode: number, url: string, body: string, options?: Readonly); isNotFound(): boolean; isRateLimit(): boolean; isServerError(): boolean; } /** Provider credit exhaustion, retaining the original HTTP status and response. */ declare class PaymentError extends HTTPError { constructor(statusCode: number, url: string, body: string); } /** Thrown when a provider rejects the API key (HTTP 401). */ declare class AuthError extends WebError { readonly provider: string; constructor(message: string, provider: string); } /** Thrown on HTTP 429. Check {@link retryAfter} for seconds until retry. */ declare class RateLimitError extends WebError { readonly retryAfter: number; constructor(retryAfter: number); } /** Thrown when {@link create} is called with an unregistered provider name. */ declare class UnknownProviderError extends WebError { readonly provider: string; constructor(provider: string); } /** Thrown when the search query is empty or whitespace-only. */ declare class EmptyQueryError extends WebError { constructor(); } /** Thrown when a search continuation is malformed or belongs to another request. */ declare class InvalidSearchContinuationError extends WebError { constructor(); } /** Thrown when the reverse image search URL is empty or whitespace-only. */ declare class EmptyImageUrlError extends WebError { constructor(); } /** Thrown when reverse image search receives a non-HTTP URL. */ declare class InvalidImageUrlError extends WebError { constructor(); } /** Thrown when the read URL is empty or whitespace-only. */ declare class EmptyUrlError extends WebError { constructor(); } /** Thrown when a read continuation token is malformed or belongs to another request. */ declare class InvalidReadContinuationError extends WebError { constructor(); } /** Thrown when the page changed before a continued read. */ declare class StaleReadContinuationError extends WebError { constructor(); } declare class InvalidProviderUrlError extends WebError { readonly provider: string; constructor(provider: string); } /** Thrown when a provider does not implement the search capability. */ declare class SearchNotSupportedError extends WebError { readonly provider: string; constructor(provider: string); } /** Thrown when a provider does not implement reverse image search. */ declare class ImageSearchNotSupportedError extends WebError { readonly provider: string; constructor(provider: string); } /** Thrown when a provider does not implement the read capability. */ declare class ReadNotSupportedError extends WebError { readonly provider: string; constructor(provider: string); } /** Thrown when no provider can be selected from env or registry. */ declare class NoProviderConfiguredError extends WebError { constructor(); } /** Thrown when providers are configured but none are currently reachable. */ declare class NoProviderAvailableError extends WebError { 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 WebError { 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 WebError} subclass. * Preserves payment errors; otherwise maps 401 to AuthError and 429 to RateLimitError. * @param {*} error - Caught value. * @param {string} provider - Provider that raised the error. * @returns {WebError} Normalized web error. */ declare function normalizeError(error: unknown, provider?: string): WebError; //#endregion //#region src/core/codex-auth.d.ts /** Minimal native Pi/OMP auth interface; refresh tokens never cross it. */ interface CodexHostAuth { readonly getProviderAuthStatus?: (provider: string) => { readonly configured: boolean; }; /** Pi resolves current auth but exposes no forced renewal through this API. */ readonly getProviderAuth?: (provider: string) => Promise<{ readonly auth: { readonly apiKey?: string; }; } | undefined>; readonly hasOAuth?: (provider: string) => boolean; readonly get?: (provider: string) => unknown; readonly reload?: () => void; readonly getApiKey?: (provider: string) => Promise; readonly getOAuthAccess?: (provider: string, sessionId?: string, options?: { readonly forceRefresh?: boolean; readonly signal?: Readonly; }) => Promise; } /** * Reuse the invoking Pi/OMP login for this operation without global credential registration. * @param host - Pi model registry or OMP auth storage from the extension context. * @param run - Search or discovery operation. * @param sessionId - OMP account affinity for this session. * @returns {T} The operation's result, with scoped host auth. */ declare function withCodexHostAuth(host: CodexHostAuth | undefined, run: () => T, sessionId?: string): T; //#endregion //#region src/core/search-filters.d.ts /** Requested filters that a named provider ignores or has not declared. */ interface SearchFilterReport { readonly provider: string; readonly ignoredFilters: readonly SearchFilterName[]; readonly undeclaredFilters: readonly SearchFilterName[]; } //#endregion //#region src/core/fallback.d.ts /** Operation whose automatic provider selection may continue after a failure. */ type FallbackOperation = "search" | "read"; /** Serializable failure retained by detailed automatic-provider responses. */ interface ProviderFailure { readonly provider: string; readonly error: string; } /** Raised when automatic selection cannot return after one or more eligible provider failures. */ declare class ProviderFallbackError extends WebError { readonly operation: FallbackOperation; readonly attempts: readonly string[]; readonly failures: readonly ProviderFailure[]; constructor(operation: FallbackOperation, failures: readonly ProviderFailure[], cause?: unknown); } //#endregion //#region src/core/all.d.ts type SearchAllOptions = SearchPageOptions & { readonly providers?: readonly string[]; }; /** One provider record retained as evidence for a deduplicated result. */ interface SearchAllEvidence extends SearchResult { provider: string; } /** Stable representative plus every provider record for one normalized URL. */ interface SearchAllResult extends SearchAllEvidence { providers: string[]; evidence: SearchAllEvidence[]; } interface ProviderError { provider: string; error: Error; } interface SearchProviderMetadata { readonly provider: string; readonly metadata: Readonly>; } /** One provider's independent continuation state in a fanout response. */ interface SearchProviderPagination { readonly provider: string; readonly pagination: SearchPagination; } interface SearchAllResponse { results: SearchAllResult[]; successfulProviders: string[]; errors: ProviderError[]; filterReports: SearchFilterReport[]; providerPagination: SearchProviderPagination[]; providerMetadata?: SearchProviderMetadata[]; } /** Results from one named provider with effective filter diagnostics. */ interface SearchProviderResult { readonly provider: string; readonly results: readonly SearchResult[]; readonly ignoredFilters: readonly SearchFilterName[]; readonly undeclaredFilters: readonly SearchFilterName[]; readonly pagination: SearchPagination; readonly metadata?: Readonly>; } /** Result from automatic search with ordered provider-attempt diagnostics. */ interface SearchWithFallbackResult extends SearchProviderResult { readonly provider: string; readonly attempts: readonly string[]; readonly failures: readonly ProviderFailure[]; } /** * 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. * @param {string} query - Search query. * @param {SearchAllOptions} options - Provider and result options. * @returns {Promise} Deduplicated provider results. */ declare function searchAll(query: string, options?: SearchAllOptions): Promise; /** * Like {@link searchAll}, but also returns successful provider names, * filter diagnostics, and errors for each provider. A `deadline` keeps the * providers that finished and lists the rest in `errors`. A cancelled * `signal` still rejects. Automatic selection probes reachability inside each * provider's slot, so a hanging endpoint costs only that provider. * @param {string} query - Search query. * @param {SearchAllOptions} options - Provider and result options. * @returns {Promise} Results and provider failures. */ declare function searchAllDetailed(query: string, options?: SearchAllOptions): Promise; /** * Search through automatic providers in order, continuing after eligible transient failures. * @param query - Search query. * @param options - Search options forwarded to the selected provider. * @returns {Promise} Results, provider, and attempt diagnostics. */ declare function searchWithFallback(query: string, options?: Readonly): Promise; /** * Search one named provider and report filters it could not apply. * @param providerName - Registered provider name. * @param query - Search query. * @param options - Search options forwarded to the provider. * @returns {Promise} Results and effective filter diagnostics. */ declare function searchProviderDetailed(providerName: string, query: string, options?: Readonly): Promise; //#endregion //#region src/core/search-continuation.d.ts declare const MAX_SEARCH_CONTINUATION_LENGTH = 4096; declare const MAX_PROVIDER_SEARCH_CONTINUATION_LENGTH = 2048; //#endregion //#region src/core/image.d.ts /** Built-in providers that accept an image URL as a search input. */ declare const imageSearchProviderNames: readonly ["serpapi"]; /** Name of a built-in reverse image search provider. */ type ImageSearchProviderName = (typeof imageSearchProviderNames)[number]; /** Reverse image search options with an optional provider override. */ interface ImageSearchByUrlOptions extends ImageSearchOptions { readonly provider?: string; } /** * Finds public pages containing or resembling an image available by URL. * @param url - Public HTTP or HTTPS image URL. * @param options - Provider and result limit. * @returns {Promise} Normalized reverse image matches. */ declare function searchByImage(url: string, options?: Readonly): Promise; //#endregion //#region src/core/read.d.ts declare const readProviderNames: readonly ["jina", "context", "firecrawl", "tinyfish", "tavily"]; type ReadProviderName = (typeof readProviderNames)[number]; /** Default portable content limit used by agent surfaces. */ declare const DEFAULT_AGENT_READ_MAX_CHARS = 20000; /** Largest portable content page accepted by agent surfaces. */ declare const MAX_AGENT_READ_CHARS = 200000; /** Package guarantees that apply after every provider returns. */ declare const packageCapabilities: { readonly execution: { readonly cancellation: { readonly option: "signal"; }; readonly deadline: { readonly option: "deadline"; readonly unit: "unix-ms"; readonly agentOption: "timeoutSeconds"; readonly agentUnit: "seconds"; readonly agentMaximum: 3600; }; readonly concurrency: { readonly option: "concurrency"; readonly default: 3; readonly maximum: 10; readonly scope: "batch-and-fanout"; }; }; readonly search: { readonly continuation: { readonly option: "continuation"; readonly opaque: true; readonly maximum: 4096; readonly providerStateMaximum: 2048; readonly scope: "single-provider-query"; }; }; readonly read: { readonly outputLimit: { readonly option: "maxChars"; readonly unit: "unicode-code-points"; readonly minimum: 1; readonly agentDefault: 20000; readonly agentMaximum: 200000; }; readonly continuation: { readonly option: "continuation"; readonly opaque: true; }; }; }; interface ReadUrlOptions extends ReadOptions { readonly provider?: string; readonly maxChars?: number; readonly continuation?: string; /** Keeps the page's links in a bounded read. Defaults to false. */ readonly links?: boolean; /** Keeps the page's image URLs in a bounded read. Defaults to false. */ readonly images?: boolean; } /** Read result with requested mode, effective provider, and provider-attempt diagnostics. */ interface ReadUrlDetailedResult { readonly result: Readonly; readonly requestedProvider: string; readonly provider: string; readonly attempts: readonly string[]; readonly failures: readonly ProviderFailure[]; } /** * Reads a URL while preserving the original result contract. * @param url - URL to read. * @param options - Provider, native read options, and portable output options. * @returns {Promise} The normalized page result. */ declare function readUrl(url: string, options?: Readonly): Promise; /** * Reads a URL and reports the effective provider after automatic fallback. * @param url - URL to read. * @param options - Provider, native read options, and portable output options. * @returns {Promise} Result, provider, attempts, and failures. */ declare function readUrlDetailed(url: string, options?: Readonly): Promise; //#endregion //#region src/core/execution.d.ts declare const DEFAULT_CONCURRENCY = 3; declare const MAX_CONCURRENCY = 10; /** Longest time budget an agent surface accepts through `timeoutSeconds`. */ declare const MAX_AGENT_TIMEOUT_SECONDS = 3600; /** * Turns the time budget an agent passes into the absolute deadline the library takes. * @param seconds - Whole seconds from now, or undefined for no deadline. * @returns {number | undefined} Unix timestamp in milliseconds. */ declare function deadlineAfterSeconds(seconds: number | undefined): number | undefined; //#endregion //#region src/core/batch.d.ts /** Maximum number of network operations accepted by one agent-tool batch. */ declare const MAX_BATCH_ITEMS = 10; /** Shared search options applied to every query in a batch. */ type SearchBatchOptions = SearchPageOptions & { readonly provider?: string; }; /** One successful or failed query outcome. */ type SearchBatchItem = { readonly query: string; readonly provider: string; readonly results: readonly (SearchResult | SearchAllResult)[]; readonly filterReports: readonly SearchFilterReport[]; readonly pagination?: SearchPagination; readonly providerPagination?: readonly SearchProviderPagination[]; readonly providerMetadata?: readonly SearchProviderMetadata[]; readonly errors?: readonly { readonly provider: string; readonly error: string; }[]; readonly attempts?: readonly string[]; readonly failures?: readonly ProviderFailure[]; } | { readonly query: string; readonly error: string; readonly attempts?: readonly string[]; readonly failures?: readonly ProviderFailure[]; }; /** One successful or failed URL outcome. */ type ReadBatchItem = { readonly url: string; readonly result: ReadResult; } | { readonly url: string; readonly error: string; }; /** One detailed URL outcome with effective provider provenance. */ type ReadBatchDetailedItem = { readonly url: string; readonly result: Readonly; readonly requestedProvider: string; readonly provider: string; readonly attempts: readonly string[]; readonly failures: readonly ProviderFailure[]; } | { readonly url: string; readonly error: string; readonly attempts?: readonly string[]; readonly failures?: readonly ProviderFailure[]; }; /** * Searches independent queries in parallel while preserving input order and failures. * @param queries - Search queries to execute. * @param options - Shared provider and search options. * @returns {Promise} One result or error for every query. */ declare function searchBatch(queries: readonly string[], options?: Readonly): Promise; /** * Reads independent URLs while preserving the original batch contract. * @param urls - URLs to read. * @param options - Shared provider and read options. * @returns {Promise} One result or error for every URL. */ declare function readBatch(urls: readonly string[], options?: Readonly): Promise; /** * Reads independent URLs and reports effective provider provenance per item. * @param urls - URLs to read. * @param options - Shared provider and read options. * @returns {Promise} Detailed outcomes for every URL. */ declare function readBatchDetailed(urls: readonly string[], options?: Readonly): Promise; //#endregion //#region src/core/resolve.d.ts declare function detectAvailableProviders(): string[]; declare function resolveDefaultProvider(): string; interface ProviderStatus { name: string; configured: boolean; envVar: string | null; /** * Set by {@link listProvidersAsync} when the provider implements * {@link AvailabilityProvider.isAvailable}. `true` = probe succeeded, * `false` = probe failed (host down / unreachable / timeout), `undefined` = * no reachability probe was performed (trust `configured`). */ reachable?: boolean; readonly searchFilters?: readonly SearchFilterName[]; readonly searchCategories?: readonly string[]; readonly capabilities: ProviderCapabilities; } 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. * @param options - Shared cancellation, deadline, and concurrency controls. * @returns {Promise} Configured and reachable provider names. */ declare function detectAvailableProvidersAsync(options?: Readonly): 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`). * @param options - Shared cancellation, deadline, and concurrency controls. * @returns {Promise} Provider status rows. */ declare function listProvidersAsync(options?: Readonly): 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). * @param options - Shared cancellation and deadline controls. * @returns {Promise} First reachable configured provider. */ declare function resolveDefaultProviderAsync(options?: Readonly): Promise; //#endregion export { withCodexHostAuth as $, ImageSearchProviderName as A, SearchProviderMetadata as B, ReadUrlDetailedResult as C, builtinProviders as Ct, readUrl as D, readProviderNames as E, version as Et, ProviderError as F, searchAllDetailed as G, SearchProviderResult as H, SearchAllEvidence as I, FallbackOperation as J, searchProviderDetailed as K, SearchAllOptions as L, searchByImage as M, MAX_PROVIDER_SEARCH_CONTINUATION_LENGTH as N, readUrlDetailed as O, MAX_SEARCH_CONTINUATION_LENGTH as P, CodexHostAuth as Q, SearchAllResponse as R, ReadProviderName as S, WebSearchProviderName as St, packageCapabilities as T, runtimeInfo as Tt, SearchWithFallbackResult as U, SearchProviderPagination as V, searchAll as W, ProviderFallbackError as X, ProviderFailure as Y, SearchFilterReport as Z, MAX_AGENT_TIMEOUT_SECONDS as _, StaleReadContinuationError as _t, listProvidersAsync as a, ImageSearchNotSupportedError as at, DEFAULT_AGENT_READ_MAX_CHARS as b, normalizeError as bt, MAX_BATCH_ITEMS as c, InvalidProviderUrlError as ct, SearchBatchItem as d, NoProviderAvailableError as dt, AuthError as et, SearchBatchOptions as f, NoProviderConfiguredError as ft, DEFAULT_CONCURRENCY as g, SearchNotSupportedError as gt, searchBatch as h, ReadNotSupportedError as ht, listProviders as i, HTTPError as it, imageSearchProviderNames as j, ImageSearchByUrlOptions as k, ReadBatchDetailedItem as l, InvalidReadContinuationError as lt, readBatchDetailed as m, RateLimitError as mt, detectAvailableProviders as n, EmptyQueryError as nt, resolveDefaultProvider as o, InvalidDateFilterError as ot, readBatch as p, PaymentError as pt, searchWithFallback as q, detectAvailableProvidersAsync as r, EmptyUrlError as rt, resolveDefaultProviderAsync as s, InvalidImageUrlError as st, ProviderStatus as t, EmptyImageUrlError as tt, ReadBatchItem as u, InvalidSearchContinuationError as ut, MAX_CONCURRENCY as v, UnknownProviderError as vt, ReadUrlOptions as w, RuntimeInfo as wt, MAX_AGENT_READ_CHARS as x, validateDateFilters as xt, deadlineAfterSeconds as y, WebError as yt, SearchAllResult as z }; //# sourceMappingURL=index-B3iVN_Ow.d.mts.map