import { AgentCompletion } from "../models"; import { ToolDefinition, ToolHandler } from "../models/types"; import { Customizer } from "../customizer"; import { Attachment, Builder, ContextSection } from "../builders/types"; import { PageValidationResult } from "./pageValidator"; export interface TransformPageArgs { pageState: string; message: string; instructions?: string; builder: Builder; additionalSections: ContextSection[]; /** True when this is the builder page (has chat panel). */ isBuilder?: boolean; /** Product name for branding in prompts (defaults to 'SynthOS'). */ productName?: string; /** Optional image attachments sent alongside the user message. */ attachments?: Attachment[]; /** Chat history from the shell — used for newBuild detection instead of counting DOM elements. */ history?: { role: string; content: string; }[]; /** Optional tool definitions exposed to the builder (on-demand context loading). */ tools?: ToolDefinition[]; /** Executors keyed by tool name. Required when `tools` is provided. */ toolHandlers?: Record; /** Fired once per tool-use iteration with the names of tools about to execute. */ onToolCall?: (names: string[]) => void; } export type ChangeOp = { op: "update"; nodeId: string; html: string; } | { op: "replace"; nodeId: string; html: string; } | { op: "delete"; nodeId: string; } | { op: "insert"; parentId: string; position: "prepend" | "append" | "before" | "after"; html: string; } | { op: "style-element"; nodeId: string; style: string; } | { op: "search-replace"; nodeId: string; search: string; replace: string; } | { op: "search-insert"; nodeId: string; after: string; content: string; }; export type ChangeList = ChangeOp[]; export interface TransformPageResult { html: string; changeCount: number; /** For 'reply' results — the assistant's text response (shell displays it). */ replyText?: string; /** For 'error' results — the error message (shell displays it). */ errorText?: string; /** Page validation results (undefined if validation was skipped). */ validation?: PageValidationResult; /** Number of change ops that were silently skipped (missing target, locked, etc.). */ skippedOps?: number; /** Short human-readable reasons for each skipped op, in order. */ skipReasons?: string[]; } export interface ApplyChangeListReport { html: string; skippedOps: number; skipReasons: string[]; } export declare function transformPage(args: TransformPageArgs): Promise>; /** * Assign sequential `data-nid` to every element in the HTML. * Skips trivial elements (br, wbr, col, source) that the LLM never targets. */ export declare function assignNodeIds(html: string): { html: string; nodeCount: number; }; /** * Remove all `data-nid` attributes from the HTML. */ export declare function stripNodeIds(html: string): string; /** * Find `needle` in `haystack` using whitespace-normalized comparison. * Collapses runs of whitespace (spaces, tabs, newlines) into a single space * for comparison purposes but returns the position in the original string. * Returns -1 if no match found. */ export declare function normalizedIndexOf(haystack: string, needle: string): { start: number; end: number; } | null; /** * Remove duplicate inline `