import type { AithosAuth } from "./auth.js"; import { type AithosSdkEndpoints } from "./endpoints.js"; /** Opt-in scope a mandate must carry to invoke `aithos.web_extract`. */ export declare const WEB_EXTRACT_SCOPE: "web.extract"; export interface ExtractArgs { /** * Mandate ID under which this call should be attributed. * * - **Owner sessions**: optional. The SDK uses the owner's own DID * as a sentinel "self" mandate id — the proxy skips mandate checks * when the envelope is owner-signed. * - **Delegate sessions**: required. Must reference the imported * mandate bundle the SDK signs with; the proxy enforces the * `web.extract` scope. */ readonly mandateId?: string; /** Absolute http(s) URL to extract. */ readonly url: string; /** * Playwright `waitUntil` strategy passed straight through to the * server-side navigation. Defaults to `"networkidle"` server-side * if omitted. */ readonly waitUntil?: "load" | "domcontentloaded" | "networkidle"; /** Navigation timeout in ms. Server validates [1000, 60000]. */ readonly timeoutMs?: number; /** Reserved for audit-level deduplication; the proxy currently does not * enforce idempotency keys for extractions. */ readonly idempotencyKey?: string; /** Abort signal to cancel the request. */ readonly signal?: AbortSignal; } export interface ExtractMeta { readonly title: string | null; readonly description: string | null; readonly lang: string | null; readonly charset: string | null; readonly viewport: string | null; readonly canonical: string | null; readonly og: Readonly>; } export interface ExtractHeading { readonly level: 1 | 2 | 3 | 4 | 5 | 6; readonly text: string; readonly id: string | null; } export interface ExtractSection { readonly tag: string; readonly role: string | null; readonly html: string; readonly text_len: number; } export interface ExtractLink { readonly label: string; readonly href: string; readonly internal: boolean; } export interface ExtractImage { readonly src: string; readonly alt: string | null; readonly role: string | null; } export interface ExtractFormField { readonly type: string; readonly name: string | null; readonly required: boolean; } export interface ExtractForm { readonly action: string | null; readonly method: string; readonly fields: readonly ExtractFormField[]; } export interface ExtractStructure { readonly headings: readonly ExtractHeading[]; readonly sections: readonly ExtractSection[]; readonly nav_links: readonly ExtractLink[]; readonly forms: readonly ExtractForm[]; } export interface ExtractContent { readonly main_html: string; readonly main_text: string; readonly images: readonly ExtractImage[]; readonly links: { readonly internal: readonly ExtractLink[]; readonly external: readonly ExtractLink[]; }; } export interface ExtractStyles { readonly css: string; readonly inline_styles_count: number; } export interface PaletteEntry { readonly hex: string; readonly weight: number; readonly role: "background" | "text" | "accent" | "other"; } export interface ComponentStyle { readonly count: number; readonly bg: string | null; readonly fg: string | null; readonly border: string | null; readonly radius: string | null; readonly padding: string | null; readonly font_size: string | null; readonly font_weight: string | null; } export interface VisualSignature { readonly colors: { readonly palette: readonly PaletteEntry[]; readonly background: string | null; readonly text: string | null; readonly primary: string | null; readonly link: string | null; }; readonly typography: { readonly heading_font: string | null; readonly body_font: string | null; readonly size_scale: readonly number[]; readonly base_size_px: number | null; readonly base_line_height: number | null; }; readonly radii: { readonly button: string | null; readonly input: string | null; readonly card: string | null; }; readonly spacing: { readonly base_unit_px: number | null; readonly common_gaps_px: readonly number[]; }; readonly layout: { readonly max_content_width_px: number | null; readonly mode: "flex" | "grid" | "block" | null; }; readonly components: { readonly buttons: readonly ComponentStyle[]; readonly inputs: readonly ComponentStyle[]; readonly cards: readonly ComponentStyle[]; }; } export interface ExtractIconDeclaration { /** href as written in the HTML (relative or absolute). */ readonly href: string; /** rel value, lowercased: "icon", "apple-touch-icon", "shortcut icon", ... */ readonly rel: string; /** Declared `sizes` attribute, e.g. "180x180" or "any" or null. */ readonly sizes: string | null; /** Declared mime type, e.g. "image/svg+xml" or null. */ readonly type: string | null; } /** * Logo asset resolved server-side. The Lambda picks the best * symbol-only asset available on the page — declared declarations + conventional well-known paths * (/apple-touch-icon.png, /favicon.svg, /favicon.ico) — in that * order of expected quality. Null when nothing resolves. * * Favicons are symbol-only by construction (no designer ships a * wordmark inside a 16-180 px icon), which sidesteps the * lockup-vs-symbol problem callers used to handle client-side with * a vision model. */ export interface ExtractLogo { /** Absolute URL of the asset that was successfully fetched. */ readonly url: string; /** Which source produced the winner. */ readonly source: "link-icon-svg" | "link-apple-touch-icon" | "link-icon-large" | "link-icon" | "link-shortcut-icon" | "well-known-apple-180" | "well-known-apple" | "well-known-svg" | "well-known-png-large" | "well-known-ico"; readonly content_type: string; readonly size_bytes: number; /** Base64-encoded asset bytes (no `data:` prefix). Build a data * URI with `data:${content_type};base64,${base64}`. */ readonly base64: string; } export interface ExtractData { readonly url: string; readonly final_url: string; readonly fetched_at: string; readonly render_ms: number; readonly meta: ExtractMeta; readonly structure: ExtractStructure; readonly content: ExtractContent; readonly styles: ExtractStyles; readonly visual_signature: VisualSignature; /** * Best logo asset resolved by the lambda — null when no * declaration and no conventional favicon * path produced a usable image. Callers should then let the * operator upload the logo manually rather than treat this as * a fatal error. */ readonly logo: ExtractLogo | null; } export interface ExtractResult { /** Cleaned extraction payload. */ readonly data: ExtractData; /** Microcredits charged for this call (1 on success, 0 on refunded failures). */ readonly creditsCharged: number; /** Wallet balance after the (possibly refunded) debit. */ readonly walletBalance: number; /** Audit log id for traceability. */ readonly auditId: string; } export interface FetchAssetArgs { /** Absolute http(s) URL of the asset to fetch. */ readonly url: string; /** Mandate id under which this call should be attributed. */ readonly mandateId?: string; /** Abort signal. */ readonly signal?: AbortSignal; } export interface FetchAssetResult { /** Asset payload. */ readonly data: { /** URL we asked the proxy to fetch. */ readonly url: string; /** URL after the proxy followed any redirects. */ readonly final_url: string; /** Content-Type reported by the upstream server. */ readonly content_type: string; /** Size of the fetched body in bytes. */ readonly size_bytes: number; /** Base64-encoded body (no `data:` prefix). Build a data URI * with `data:${content_type};base64,${base64}`. */ readonly base64: string; }; /** Microcredits charged for this call. */ readonly creditsCharged: number; readonly walletBalance: number; readonly auditId: string; } export interface WebNamespaceDeps { readonly auth: AithosAuth; readonly appDid: string; readonly endpoints: AithosSdkEndpoints; readonly fetch: typeof fetch; } /** * `sdk.web` namespace — Aithos's web extraction primitive. * * Designed so a downstream agent can read the static content of any * public page (HTML, purged CSS, computed visual signature) without * involving an LLM — saving ~30× over a Bedrock-based extraction in * both latency and cost. * * @throws {AithosSDKError} — same error taxonomy as `sdk.compute`, * including `-32071` (insufficient balance with `{required, available}` * in `data`) and `-32042` (mandate scope mismatch). */ export declare class WebNamespace { #private; constructor(deps: WebNamespaceDeps); /** * Extract a public webpage. Returns the cleaned HTML, purged CSS and * a deterministic visual signature (palette, typography, dominant * radii, spacing, layout mode, component digests). */ extract(args: ExtractArgs): Promise; /** * Fetch a single asset (image / font / css / json …) server-side, * bypassing browser CORS. Returns the bytes as base64 + content-type. * * Use when `fetch(url, {mode: "cors"})` and `` * canvas readback both fail because the asset server doesn't return * Access-Control-Allow-Origin headers — typical for production * sites' logos hosted on the main domain. * * For the common "logo of a webpage" case the lambda already * resolves and embeds the best symbol-only logo in * {@link extract}'s `data.logo` field; you only need fetchAsset * when extract's logo doesn't fit, when picking up secondary * assets (og:image, hero image, document download), or when * fetching an asset on a page you haven't extracted. * * Costs 1 mc per successful fetch, full refund on failure. Server * caps: 15 s timeout, 10 MB body, http/https only. */ fetchAsset(args: FetchAssetArgs): Promise; } //# sourceMappingURL=web.d.ts.map