/** * HTML-to-readable-text conversion and a permissive `Set-Cookie` parser, * shared by `web.fetch` (via `capture.ts`) and DuckDuckGo's lite-HTML adapter. * * - {@link toReadableText} strips chrome/non-rendering content from HTML and * returns visible prose with whitespace collapsed (cheerio-based, no * browser/jsdom dependency). * - {@link parseSetCookie} parses one `Set-Cookie` value into a * {@link CookieInfo}; regex-driven and permissive — malformed or missing * attributes are simply absent rather than a hard error. */ import type { CookieInfo } from "./types.js"; /** * Convert an HTML document into a single readable text string. * * The conversion: * 1. Parses `html` with cheerio (no DOM/browser dependency). * 2. Removes executable/non-text subtrees and obvious page-level chrome while * preserving headers, footers, and asides nested inside the chosen article * or main content. * 3. Removes every HTML comment node anywhere in the tree. * 4. Extracts the remaining text via `$.root().text()`. * 5. Collapses runs of page-text whitespace while preserving line breaks and * indentation inside `
` blocks.
 * 6. Appends a deduplicated "Links" section so the agent can find the
 *    correct URL for any link on the page without guessing.
 *
 * @param html     - Raw HTML string to convert.
 * @param baseUrl  - The final page URL (used to resolve relative hrefs).
 *                   When provided, all href values are resolved to absolute
 *                   URLs. When omitted, relative hrefs are included as-is.
 */
export declare function toReadableText(html: string, baseUrl?: string): string;
/**
 * Parse a single `Set-Cookie` header value into a {@link CookieInfo}.
 *
 * The parser is intentionally permissive: it never throws for malformed
 * input. The first `;`-separated attribute is treated as the
 * `name=value` pair (with everything after the first `=` taken verbatim
 * as the value, matching common server practice). Subsequent attributes
 * are matched case-insensitively against the public RFC 6265 set the
 * `web.fetch` tool surfaces:
 *
 * - `Domain`        → {@link CookieInfo.domain}
 * - `Path`          → {@link CookieInfo.path}
 * - `Expires`       → {@link CookieInfo.expires} as an ISO 8601 string
 *                     (omitted if the date string fails to parse)
 * - `Max-Age`       → {@link CookieInfo.maxAge} as a finite integer
 *                     (omitted if not a finite integer)
 * - `HttpOnly`      → {@link CookieInfo.httpOnly} = `true`
 * - `Secure`        → {@link CookieInfo.secure}   = `true`
 * - `SameSite=…`    → {@link CookieInfo.sameSite} normalized to
 *                     `"Strict"`/`"Lax"`/`"None"` (omitted if value is
 *                     unknown)
 *
 * Unknown attributes (e.g. `Priority`, `Partitioned`) are ignored. When
 * an attribute is missing, malformed, or unrecognised, the corresponding
 * field is simply absent from the returned object.
 *
 * The header value is expected to be a single cookie. Callers that
 * receive multiple cookies in a single header (which servers must not
 * do, but a few do) should split on the appropriate boundary before
 * calling this function.
 */
export declare function parseSetCookie(value: string): CookieInfo;