import type { ModelRegistry } from "../../config/model-registry.js"; import type { AgentStorageApi } from "../../session/agent-storage.js"; export { formatNumber } from "@oh-my-pi/pi-utils"; export interface RenderResult { url: string; finalUrl: string; contentType: string; method: string; content: string; fetchedAt: string; /** True when the response body was cut mid-stream at {@link MAX_BYTES}. */ truncated: boolean; notes: string[]; } /** * Site-specific URL renderer: returns `null` for URLs it does not own. * `modelRegistry` is the session's, for handlers that read through a model (X via Grok). */ export type SpecialHandler = (url: string, timeout: number, signal?: AbortSignal, storage?: AgentStorageApi | null, modelRegistry?: ModelRegistry) => Promise; /** Network read bound for a fetched body; the only size limit on rendered URL content. */ export declare const MAX_BYTES: number; /** * Collapse blank-line runs and trim. Never shortens content: URL reads page the preview * themselves, and selectors, artifacts, and URL search must see the whole body. */ export declare function finalizeOutput(content: string): string; export interface LoadPageOptions { timeout?: number; headers?: Record; method?: string; body?: string; maxBytes?: number; signal?: AbortSignal; /** * Return true to skip reading the response body for this content type * (lowercased mime, no params). The caller is expected to re-fetch the * payload as binary; this avoids streaming + decoding huge binaries twice. */ skipBodyForContentType?: (contentType: string) => boolean; } export interface LoadPageResult { content: string; contentType: string; finalUrl: string; ok: boolean; status?: number; /** True when the body was cut mid-stream at maxBytes. */ truncated?: boolean; /** Last transport-level error message when ok is false. */ error?: string; /** True when the body read was skipped via skipBodyForContentType. */ bodySkipped?: boolean; /** * Bot protection that answered with its challenge or block page instead of the page. Such a * response is never `ok`, whatever its status, so a caller checking `ok` does not take it as content. */ blockedBy?: string; } /** * Fetch a page with timeout and size limit */ export declare function loadPage(url: string, options?: LoadPageOptions): Promise; /** * Convert HTML to markdown using Turndown with GFM support. * Strips script/style tags before conversion. */ export declare function htmlToBasicMarkdown(html: string): Promise; /** * Build a RenderResult from markdown content. Calls finalizeOutput internally. */ export declare function buildResult(md: string, opts: { url: string; finalUrl?: string; method: string; fetchedAt: string; notes?: string[]; contentType?: string; /** Pass the source `LoadPageResult.truncated` when `md` embeds a fetched body verbatim. */ truncated?: boolean; }): RenderResult; /** * Format a date value as YYYY-MM-DD. Returns empty string on invalid input. */ export declare function formatIsoDate(value?: string | number | Date): string; /** * Decode common HTML entities. */ export declare function decodeHtmlEntities(text: string): string; /** * Format seconds into HH:MM:SS or MM:SS. */ export declare function formatMediaDuration(totalSeconds: number): string; /** * Extract localized text, preferring en-US/en. */ export type LocalizedText = string | Record | null | undefined; export declare function getLocalizedText(value: LocalizedText, defaultLocale?: string): string | undefined; /** * Check if content looks like HTML by inspecting the leading tag. */ export declare function looksLikeHtml(content: string): boolean;