/** * html-readability.ts, readable article text out of an HTML document, when * the optional parser is installed to produce it. * * `jsdom` and `@mozilla/readability` are both declared under * `optionalDependencies`. This file used to import both statically, which made * that declaration untrue for every surface that reaches knowledge extraction, * and the daemon reaches it, through knowledge/extractors.ts. With * `packages/sdk/node_modules/jsdom` removed, measured here: * `bun build packages/sdk/src/platform/daemon/cli.ts --compile` failed with * `Could not resolve: "jsdom"` and produced no binary at all, and the same * graph run from source died at MODULE INIT with `Cannot find package 'jsdom'` *, before main(), before the activity logger had a destination, and before * daemon/cli.ts's fatal-boot handler existed to say anything about it. * * Both are now reached through utils/optional-dependency.ts at the moment an * extraction actually needs them. When they are absent the extraction returns * `null` with a stated reason, and knowledge/extractors.ts falls back to its * lightweight HTML path carrying that reason as a warning, which is what the * `optionalDependencies` declaration promised in the first place. */ export interface ReadableHtmlExtraction { readonly title?: string | undefined; readonly byline?: string | undefined; readonly siteName?: string | undefined; readonly excerpt?: string | undefined; readonly textContent: string; readonly length: number; readonly links: readonly string[]; readonly headings: readonly string[]; readonly paragraphSamples: readonly string[]; } /** Whether the readable-HTML path can run in this installation, and why not. */ export interface HtmlReadabilityAvailability { readonly available: boolean; readonly reason?: string; } type JsdomModule = typeof import('jsdom'); type ReadabilityModule = typeof import('@mozilla/readability'); interface ReadabilityToolchain { readonly JSDOM: JsdomModule['JSDOM']; readonly Readability: ReadabilityModule['Readability']; } type ReadabilityToolchainLoad = { readonly available: true; readonly toolchain: ReadabilityToolchain; } | { readonly available: false; readonly reason: string; }; /** * Resolve both optional packages, or state which one is missing. * * The specifiers are written out literally so a bundler still sees them and * bundles the packages when they ARE installed; only the moment of evaluation * moves from module init to first use. */ export declare function loadHtmlReadabilityToolchain(): Promise; /** * Report whether readable-HTML extraction is available without performing one. * Loads the packages if they have not been tried yet; the outcome is cached per * process by utils/optional-dependency.ts, so this costs one resolution attempt. */ export declare function describeHtmlReadabilityAvailability(): Promise; /** * Extract readable article text, or `null` when there is nothing readable, * and also `null` when the optional parser is not installed. The two cases are * told apart by `describeHtmlReadabilityAvailability()`; extractors.ts reports * the second as a warning on its fallback result, so a missing package never * looks like an empty page. */ export declare function extractReadableHtml(html: string): Promise; export {}; //# sourceMappingURL=html-readability.d.ts.map