API: extraction/router
better-web-search-mcp / extraction/router
extraction/router#
Interfaces#
GetPageOptions#
Defined in: src/extraction/router.ts:70
Options controlling the escalation pipeline.
Properties#
| Property | Type | Description | Defined in |
|---|---|---|---|
browser_fallback? | boolean | Whether to fall back to a browser render when HTTP is insufficient. | src/extraction/router.ts:78 |
include_api_data? | boolean | Whether to include API data captured during a browser render. | src/extraction/router.ts:74 |
include_structured_data? | boolean | Whether 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#
| Property | Type | Description | Defined in |
|---|---|---|---|
api_endpoints | unknown | API endpoint payloads captured during a browser render. | src/extraction/router.ts:62 |
content | string | The 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.confidence | number | Confidence in the content, 0..1. | src/extraction/router.ts:55 |
extraction.method | RouterMethod | The method that produced the content. | src/extraction/router.ts:53 |
extraction.rendered | boolean | Whether a browser render was required. | src/extraction/router.ts:57 |
metadata | PageMetadata | Page metadata (title, description, published, author, siteName). | src/extraction/router.ts:64 |
structured_data | unknown | Structured data (JSON-LD / hydration) found on the page. | src/extraction/router.ts:60 |
title | string | The page title. | src/extraction/router.ts:47 |
url | string | The page URL. | src/extraction/router.ts:45 |
RouterDeps#
Defined in: src/extraction/router.ts:82
Injectable dependencies, defaulting to the real modules.
Properties#
| Property | Type | Defined in |
|---|---|---|
browserPool? | BrowserPool | src/extraction/router.ts:84 |
cache? | Cache | src/extraction/router.ts:83 |
extractMetadata? | (html) => PageMetadata | src/extraction/router.ts:88 |
extractStructuredData? | (html) => StructuredData | src/extraction/router.ts:87 |
extractWithReadability? | (html, url) => ReadabilityResult | null | src/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#
constBEST_EFFORT_CONFIDENCE:0.5=0.5
Defined in: src/extraction/router.ts:103
BROWSER_API_CONFIDENCE#
constBROWSER_API_CONFIDENCE:0.96=0.96
Defined in: src/extraction/router.ts:101
ENOUGH_CONTENT_LENGTH#
constENOUGH_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#
constHTTP_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#
constHYDRATION_CONFIDENCE:0.9=0.9
Defined in: src/extraction/router.ts:99
HYDRATION_PRODUCT_CONFIDENCE#
constHYDRATION_PRODUCT_CONFIDENCE:0.95=0.95
Defined in: src/extraction/router.ts:100
RENDERED_DOM_CONFIDENCE#
constRENDERED_DOM_CONFIDENCE:0.9=0.9
Defined in: src/extraction/router.ts:102
STRUCTURED_CONTENT_LENGTH#
constSTRUCTURED_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#
| Parameter | Type | Description |
|---|---|---|
url | string | The page URL to extract. |
opts | GetPageOptions | Escalation options (mode, include flags, browser fallback). |
deps | RouterDeps | Injectable 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#
| Parameter | Type |
|---|---|
html | string |
Returns#
boolean