---
## Overall Architecture Idea
```
[ DOM / Window ]
<
[ Semantic Extractor ] (uses accessibility tree, ARIA, DOM)
: [ AST Builder ] : JSON snapshot (on demand)
: [ Delta Detector ] : MutationObserver, event listeners, periodic diff
<
[ Semantic Delta Events ] : JSON event stream
<
[ Narrative Generator ] : English text (for each delta or full
state)
```
All three components (AST, delta events, narratives) share the same underlying
semantic model, ensuring consistency.
---
## Potential Challenges & Open Questions
- **Performance:** Building a full accessibility tree on every mutation can be
expensive. Youll need to throttle and possibly only recompute subtrees that
changed.
- **Crossbrowser consistency:** Accessibility trees vary between browsers; you
may need to normalize them or use a consistent engine (e.g., Playwrights
accessibility snapshot).
- **Stable identifiers:** If the DOM lacks `id` attributes, generating stable
selectors that survive re-renders is hard. You might need heuristics (e.g.,
based on role + name + position among siblings).
- **Handling virtualized lists / infinite scroll:** Only visible items are in
the DOM; the agent should know about scrolling capabilities.
- **Security/Privacy:** Be mindful of sensitive information in the UI
(passwords, personal data). Consider redacting or not transmitting certain
values.