API: extraction/router

better-web-search-mcp


better-web-search-mcp / extraction/router

extraction/router#

Interfaces#

GetPageOptions#

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

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:78
include_api_data?booleanWhether to include API data captured during a browser render.src/extraction/router.ts:74
include_structured_data?booleanWhether to attempt structured / hydration data extraction.src/extraction/router.ts:76
mode?"auto" | "browser" | "fast"auto escalates; fast skips the browser; browser forces it.src/extraction/router.ts:72

RoutedPage#

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

The page extraction returned by getPage.

Properties#

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

RouterDeps#

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

Injectable dependencies, defaulting to the real modules.

Properties#

PropertyTypeDefined in
browserPool?BrowserPoolsrc/extraction/router.ts:84
cache?Cachesrc/extraction/router.ts:83
extractMetadata?(html) => PageMetadatasrc/extraction/router.ts:88
extractStructuredData?(html) => StructuredDatasrc/extraction/router.ts:87
extractWithReadability?(html, url) => ReadabilityResult | nullsrc/extraction/router.ts:86
fetchPage?(url, opts) => Promise<FetchedPage>src/extraction/router.ts:85

Type Aliases#

RouterMethod#

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

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

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:103


BROWSER_API_CONFIDENCE#

const BROWSER_API_CONFIDENCE: 0.96 = 0.96

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


ENOUGH_CONTENT_LENGTH#

const ENOUGH_CONTENT_LENGTH: 500 = 500

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

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:98

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:99


HYDRATION_PRODUCT_CONFIDENCE#

const HYDRATION_PRODUCT_CONFIDENCE: 0.95 = 0.95

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


RENDERED_DOM_CONFIDENCE#

const RENDERED_DOM_CONFIDENCE: 0.9 = 0.9

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


STRUCTURED_CONTENT_LENGTH#

const STRUCTURED_CONTENT_LENGTH: 200 = 200

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

Minimum structured-content length for Level 2 to win.

Functions#

closeSharedBrowserPool()#

closeSharedBrowserPool(): Promise<void>

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

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:344

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:115

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

Parameters#

ParameterType
htmlstring

Returns#

boolean