import { EncodeOptions, DecodeOptions } from '@toon-format/toon'; export { DecodeOptions, EncodeOptions } from '@toon-format/toon'; import { l as SemanticDocument, d as SemanticNode, c as SemanticId, i as SSGNode, A as AgentCertification } from './types-BNownkHv.js'; /** * TOON Serialization for SemanticDOM * Token-Oriented Object Notation for LLM-efficient semantic document encoding * * TOON reduces token usage by ~40-50% compared to JSON, making it ideal * for passing SemanticDOM documents to AI agents. * * @packageDocumentation */ /** * Serializable representation of SemanticNode (without circular refs) */ interface SerializableNode { id: string; role: string; label: string; intent?: string; state: string; selector: string; xpath: string; a11y: { name: string; focusable: boolean; inTabOrder: boolean; level?: number; }; children: SerializableNode[]; value?: string | number | boolean; } /** * Serializable document format for TOON encoding */ interface SerializableDocument { version: string; standard: string; url: string; title: string; language: string; generatedAt: number; agentReady: { level: string; score: number; checks: Array<{ id: string; name: string; passed: boolean; }>; failures: Array<{ id: string; name: string; message: string; severity?: string; }>; }; root: SerializableNode; landmarks: Array<{ id: string; role: string; label: string; }>; interactables: Array<{ id: string; role: string; label: string; intent?: string; }>; stateGraph: Array<{ id: string; state: string; transitions: Array<{ from: string; to: string; trigger: string; }>; }>; } /** * Encode SemanticDocument to TOON format * * @param document - SemanticDocument to encode * @param options - TOON encoding options * @returns TOON formatted string * * @example * ```ts * const toon = toTOON(document); * // Saves ~40-50% tokens vs JSON * ``` */ declare function toTOON(document: SemanticDocument, options?: EncodeOptions): string; /** * Decode TOON string to partial SemanticDocument data * * Note: Returns plain object structure, not full SemanticDocument with Map indexes. * Use this for reading TOON data; create fresh SemanticDocument via parse() for full functionality. * * @param toon - TOON formatted string * @param options - TOON decoding options * @returns Decoded document data */ declare function fromTOON(toon: string, options?: DecodeOptions): SerializableDocument; /** * Encode just the semantic tree (nodes only) to TOON * Useful for passing to LLMs when you only need structure * * @param root - Root SemanticNode * @returns TOON formatted string of just the tree */ declare function treeToTOON(root: SemanticNode, options?: EncodeOptions): string; /** * Encode landmarks array to TOON (compact format) * * @param landmarks - Array of landmark nodes * @returns TOON formatted string */ declare function landmarksToTOON(landmarks: SemanticNode[], options?: EncodeOptions): string; /** * Encode interactables array to TOON (compact format) * * @param interactables - Array of interactive nodes * @returns TOON formatted string */ declare function interactablesToTOON(interactables: SemanticNode[], options?: EncodeOptions): string; /** * Encode state graph to TOON * * @param stateGraph - Map of SSG nodes * @returns TOON formatted string */ declare function stateGraphToTOON(stateGraph: Map, options?: EncodeOptions): string; /** * Encode certification report to TOON * * @param certification - AgentCertification object * @returns TOON formatted string */ declare function certificationToTOON(certification: AgentCertification, options?: EncodeOptions): string; /** * Calculate token savings estimate * * @param document - SemanticDocument to analyze * @returns Token comparison stats */ declare function estimateTokenSavings(document: SemanticDocument): { jsonTokens: number; toonTokens: number; savings: number; savingsPercent: number; }; export { certificationToTOON, estimateTokenSavings, fromTOON, interactablesToTOON, landmarksToTOON, stateGraphToTOON, toTOON, treeToTOON };