Expand description
§semantic-dom-ssg
Machine-readable web semantics for AI agents.
This crate provides O(1) element lookup, deterministic navigation, and token-efficient serialization formats optimized for LLM consumption.
§Features
- O(1) Lookup: Hash-indexed nodes via
AHashMap - State Graph: Explicit FSM for UI states and transitions
- Agent Summary: ~100 tokens vs ~800 for JSON (87% reduction)
- Security: Input validation, URL sanitization, size limits
§Quick Start
use semantic_dom_ssg::{SemanticDOM, Config};
let html = r#"<html><body><main><button>Submit</button></main></body></html>"#;
let sdom = SemanticDOM::parse(html, Config::default()).unwrap();
// O(1) lookup by iterating index
for (id, node) in &sdom.index {
println!("{}: {}", id, node.label);
}
// Token-efficient summary (~100 tokens)
let summary = sdom.to_agent_summary();
println!("{}", summary);§Security
This crate implements security hardening:
- Input size limits (10MB default)
- URL protocol validation (https, http, file only)
- No script execution (HTML parsing only)
Structs§
- Agent
Certification - Agent certification result
- Config
- Configuration for SemanticDOM parsing
- Security
Config - Security configuration for SemanticDOM operations
- SemanticDOM
- The main SemanticDOM structure
- Semantic
Node - A semantic node in the DOM tree
- State
- A state in the Semantic State Graph
- State
Graph - The Semantic State Graph
- Token
Comparison - Token usage comparison result
- Transition
- A transition between states in the SSG
- Validation
Check - A validation check result
Enums§
- Certification
Level - Certification levels based on compliance
- Error
- Errors that can occur during SemanticDOM operations
- Semantic
Intent - User intent classification for an element
- Semantic
Role - Semantic role for an element based on ARIA and HTML5 semantics
Constants§
Functions§
- compare_
token_ usage - Compare token usage between formats
- to_
agent_ summary - Generate a token-efficient agent summary
- to_
audio_ summary - Generate an audio/screen-reader friendly summary
- to_
nav_ summary - Generate a navigation-focused summary
- to_
one_ liner - Generate a one-line summary (~20 tokens)
- validate_
url - Validate a URL against security rules
Type Aliases§
- Result
- Result type for SemanticDOM operations