API: extraction/router

better-web-search-mcp


better-web-search-mcp / extraction/router

extraction/router#

Interfaces#

GetPageOptions#

Defined in: src/extraction/router.ts:76

Options controlling the escalation pipeline.

Properties#

PropertyTypeDescriptionDefined in
browser_fallback?booleanWhether to fall back to a browser render when HTTP is insufficient.src/extraction/router.ts:84
include_api_data?booleanWhether to include API data captured during a browser render.src/extraction/router.ts:80
include_structured_data?booleanWhether to attempt structured / hydration data extraction.src/extraction/router.ts:82
mode?"auto" | "browser" | "fast"auto escalates; fast skips the browser; browser forces it.src/extraction/router.ts:78

RoutedPage#

Defined in: src/extraction/router.ts:49

The page extraction returned by getPage.

Properties#

PropertyTypeDescriptionDefined in
api_endpointsunknownAPI endpoint payloads captured during a browser render.src/extraction/router.ts:68
contentstringThe extracted content (Markdown or plain text).src/extraction/router.ts:55
evidence?Evidence[]Alternative-source evidence appended when the primary extraction was blocked.src/extraction/router.ts:72
extraction{ confidence: number; method: RouterMethod; rendered: boolean; }Metadata about the winning extraction method.src/extraction/router.ts:57
extraction.confidencenumberConfidence in the content, 0..1.src/extraction/router.ts:61
extraction.methodRouterMethodThe method that produced the content.src/extraction/router.ts:59
extraction.renderedbooleanWhether a browser render was required.src/extraction/router.ts:63
metadataPageMetadataPage metadata (title, description, published, author, siteName).src/extraction/router.ts:70
structured_dataunknownStructured data (JSON-LD / hydration) found on the page.src/extraction/router.ts:66
titlestringThe page title.src/extraction/router.ts:53
urlstringThe page URL.src/extraction/router.ts:51

RouterDeps#

Defined in: src/extraction/router.ts:88

Injectable dependencies, defaulting to the real modules.

Properties#

PropertyTypeDescriptionDefined in
browserPool?BrowserPool-src/extraction/router.ts:90
cache?Cache-src/extraction/router.ts:89
extractMetadata?(html) => PageMetadata-src/extraction/router.ts:94
extractStructuredData?(html) => StructuredData-src/extraction/router.ts:93
extractWithReadability?(html, url) => ReadabilityResult | null-src/extraction/router.ts:92
fetchPage?(url, opts) => Promise<FetchedPage>-src/extraction/router.ts:91
ssrf?SsrfDepsInjectable DNS resolution for the SSRF guard, so tests need no network.src/extraction/router.ts:96

Type Aliases#

RouterMethod#

RouterMethod = "http_fetch" | "hydration_data" | "browser_api_intercept" | "rendered_dom"

Defined in: src/extraction/router.ts:42

The extraction method chosen by the router.

Variables#

BEST_EFFORT_CONFIDENCE#

const BEST_EFFORT_CONFIDENCE: 0.5 = 0.5

Defined in: src/extraction/router.ts:111


BROWSER_API_CONFIDENCE#

const BROWSER_API_CONFIDENCE: 0.96 = 0.96

Defined in: src/extraction/router.ts:109


ENOUGH_CONTENT_LENGTH#

const ENOUGH_CONTENT_LENGTH: 500 = 500

Defined in: src/extraction/router.ts:100

Minimum visible-text length (after stripping tags) for Level 1 to win.


HTTP_FETCH_CONFIDENCE#

const HTTP_FETCH_CONFIDENCE: 0.85 = 0.85

Defined in: src/extraction/router.ts:106

Confidence baselines per extraction tier (Level 1..3 + best-effort).


HYDRATION_CONFIDENCE#

const HYDRATION_CONFIDENCE: 0.9 = 0.9

Defined in: src/extraction/router.ts:107


HYDRATION_PRODUCT_CONFIDENCE#

const HYDRATION_PRODUCT_CONFIDENCE: 0.95 = 0.95

Defined in: src/extraction/router.ts:108


RENDERED_DOM_CONFIDENCE#

const RENDERED_DOM_CONFIDENCE: 0.9 = 0.9

Defined in: src/extraction/router.ts:110


STRUCTURED_CONTENT_LENGTH#

const STRUCTURED_CONTENT_LENGTH: 200 = 200

Defined in: src/extraction/router.ts:103

Minimum structured-content length for Level 2 to win.

Functions#

closeSharedBrowserPool()#

closeSharedBrowserPool(): Promise<void>

Defined in: src/extraction/router.ts:178

Close and forget the shared browser pool (server shutdown, tests).

Returns#

Promise<void>


getPage()#

getPage(url, opts?, deps?): Promise<RoutedPage>

Defined in: src/extraction/router.ts:364

Fetch and extract a page, escalating through the three tiers as needed.

Parameters#

ParameterTypeDescription
urlstringThe page URL to extract.
optsGetPageOptionsEscalation options (mode, include flags, browser fallback).
depsRouterDepsInjectable dependencies for testing.

Returns#

Promise<RoutedPage>


hasEnoughContent()#

hasEnoughContent(html): boolean

Defined in: src/extraction/router.ts:123

Whether a page has enough visible text to be useful without a browser.

Parameters#

ParameterType
htmlstring

Returns#

boolean