High-Performance Desktop Context Graph, Time-Series Persistence & MCP Provider for Local AI Agents and Voice Interfaces
The Active Desktop Context Engine (ADCE) is a privacy-first Windows background daemon and Model Context Protocol (MCP) server.
Instead of relying on resource-heavy screenshot OCR, periodic screen polling, or cloud telemetry, ADCE integrates directly with native Win32 WinEvent hooks and UI Automation (UIA) caching to maintain a live, structured model of the user's active desktop environment with minimal resource overhead.
- 100% Local Data Sovereignty: Complete on-device execution. Active window titles, document contents, and application states never leave localhostβensuring enterprise privacy and zero telemetry leakage.
- Deterministic Focus & Window Topology: Event-driven tracking of foreground application envelopes, process metadata, window hierarchies, and focused UI controls via decoupled asynchronous channels.
- Virtual Desktop & Workspace Awareness: Extraction of active Virtual Desktop GUIDs, friendly names, and desktop indices via native COM interop.
- Container-Aware Tab Discovery: Targeted tab enumeration across modern browsers (Waterfox, Firefox, Chrome, Edge) and code editors (VS Code, Antigravity) without triggering unpruned DOM crawling stalls.
- Automated Credential & Privacy Sanitization: Built-in security firewall (
ContextPrivacySanitizer) that detectsIsPasswordcontrols to redact passwords ([REDACTED_PASSWORD]), masks sensitive file buffers (.env,.pem,.kdbx,id_rsa), and strips OAuth tokens/query strings from browser address bars before context envelopes leave the extraction plane. - Token-Efficient MCP Streaming: Compact, high-density JSON context snapshots over local MCP endpoints (
get_desktop_context,desktop://current), giving local LLMs actionable workflow awareness without wasting tokens on raw screen dumps. - Historical State Persistence: Embedded time-series storage (SQLite WAL) tracking focus transitions and tab history for temporal agent reasoning.
ADCE was designed to bridge low-level Windows accessibility infrastructure with high-level agentic AI and voice interfaces:
- Unopinionated Accessibility Primitives (Core Vision): Rather than imposing rigid application-specific workflows, ADCE aims to surface clean, structured desktop primitives (window identity, container tabs, active editor buffers, workspace IDs, focused control types). Downstream speech recognition engines (Caster, Dragonfly, Talon) and local AI agent loops can consume these primitives to drive window switching, contextual grammar activation, or dynamic tool execution.
- Dual-Consumer Architecture: A single high-performance engine serves both real-time local accessibility and voice tools (via direct .NET / IPC bindings) and local AI coding assistants (via Model Context Protocol JSON-RPC endpoints).
- Non-Invasive Execution: 100% out-of-process execution using official Windows accessibility (
FlaUI.UIA3), Win32 hooks (SetWinEventHook), and Virtual Desktop COM interfaces, requiring zero DLL injection or kernel drivers. - Targeted Zonal Anchoring: By scoping extractions to target class names and container bounding boxes, ADCE avoids the classic pitfalls of blind recursive DOM walking across modern Chromium and Gecko applications.
π Verified Downstream Use Case: ADCE has been empirically integrated into Caster via caster-user-directory-and-notes, powering dynamic sub-window voice grammar activation (e.g. automatically activating CLI/Git commands only when focused in VS Code / Antigravity IDE integrated terminals without audio stutter). See the full First Real-World Use Case Guide.
| System Tray & Non-Activating Live HUD | Antigravity IDE (Monaco Editor & Zones) |
|---|---|
![]() |
![]() |
ADCE is structured as a high-performance, unidirectional 4-tier pipeline designed for minimal resource overhead and zero cross-apartment COM deadlocks:
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β ADCE PRODUCTION ARCHITECTURE β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β 1. OS EVENT HOOK PLANE (Win32 Low-Level Event Hooks) β
β βββ SetWinEventHook listeners (EVENT_SYSTEM_FOREGROUND, EVENT_OBJECT_FOCUS) β
β βββ Dedicated STA Message Pump Thread with Barrier Synchronization β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β 2. CONCURRENCY & EXTRACTION PLANE (FlaUI.UIA3 + Win32 Gating) β
β βββ Win32 Shallow Filter (< 0.5 ms): Fast HWND, process & WS/WS_EX bitmask pre-gating β
β βββ Async Channel Debouncer: 50ms trailing-edge window with 250ms burst delay clamp β
β βββ Monotonic Epoch Guard: Supersedes stale in-flight extractions β
β βββ Scoped CacheRequest Batching: Single-roundtrip FlaUI.UIA3 COM queries (< 15 ms) β
β βββ Ancestor Chain Climber: Resolves leaf controls to typed DesktopSemanticZones β
β βββ Privacy Sanitizer: Redacts passwords, secret files, and address bar tokens β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β 3. PERSISTENCE & STORAGE PLANE (Dual-Tier In-Memory + SQLite WAL) β
β βββ L1 In-Memory Atomic Cache: Lock-free instant query reads (< 15 ns) β
β βββ L2 Time-Series WAL Store: Channel-decoupled asynchronous SQLite persistence β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β 4. HOST DAEMON & CONSUMER INTERFACES (Tray Daemon & Model Context Protocol) β
β βββ System Tray Background Daemon: PerMonitorV2 DPI aware with dynamic status icon β
β βββ Non-Activating Live DevTools HUD: Floating diagnostic overlay (WS_EX_NOACTIVATE) β
β βββ Model Context Protocol (MCP) Server: Universal JSON-RPC 2.0 (Stdio & HTTP/SSE) β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
ADCE functions as both a production codebase and an evolving research ledger tracking low-level COM experiments, UI Automation benchmarks, and systems architecture.
π Central Documentation Entrypoint: Explore the full documentation suite in
docs/CONTEXT.md.
| Document | Description |
|---|---|
| ποΈ Architecture & Modular Implementation Plan | 5-project solution architecture, decoupled work packages, and phased execution milestones. |
| π Requirements & Dynamic Discovery Specification | 5 Desktop Framework Archetypes, dynamic heuristic discovery pipeline, and performance targets. |
| π Model Context Protocol (MCP) Schema Spec | JSON schema specifications, decoupled envelope definitions, and MCP tool endpoints. |
| π UI Automation Structures Reference (SSOT) | Definitive structural map of UIA node hierarchies and target zones across major applications. |
| βοΈ Gate 2 Hostile Architecture & Systems Review | Adversarial systems review evaluating COM apartment deadlocks, GC churn, and UIPI boundaries. |
| Project / Subsystem | Deep Dive Reference | Focus Area |
|---|---|---|
ADCE.Core |
ADCE.Core Deep-Dive | Domain models, immutable state envelopes, sequence equality mechanics. |
ADCE.Extraction |
ADCE.Extraction Deep-Dive | Win32 shallow gating, UIPI filtering, single-roundtrip batch caching. |
ADCE.EventPipeline |
ADCE Event Pipeline Deep-Dive | Dedicated STA message pump, WinEvent hooks, trailing-edge debouncing. |
ADCE.Storage |
ADCE.Storage Deep-Dive | Dual-tier storage, L1 in-memory cache, channel-decoupled SQLite WAL store. |
ADCE.Mcp |
ADCE.Mcp Deep-Dive | JSON-RPC 2.0 protocol handlers, Stdio & SSE/HTTP transport layers. |
ADCE.Daemon |
ADCE.Daemon Deep-Dive | System tray hosting, non-activating DevTools HUD overlay, lifecycle management. |
| Guide | Description |
|---|---|
| π Educational Refresher & Architecture Guide | Plain-English walkthrough of UI Automation, Win32 systems programming, and FlaUI caching. |
| π First Real-World Use Case: Caster Dynamic Terminal Grammars | Verified downstream integration: Dynamic sub-window grammar activation in VS Code / Antigravity IDE via low-latency SSE streaming. |
| ποΈ ADCE Focus & Zone Detection Explained | Visual guide to Windows focus mechanics, parent-chain climbing, and semantic zone detection. |
| π§ͺ Educational Guide: Test Harness & Verification | Deep dive into stimulus-response testing, claim verification, and empirical measurement. |
| Category | Resources |
|---|---|
| Testing & Roadmap | β’ Empirical Test Harness Spec β’ Reviewer Observations & Hardening Roadmap |
| Engineering Postmortems | β’ Milestone 2 Postmortem (Extraction & Sessions) β’ Milestone 4 Postmortem (Focus Bleeding & Child HWNDs) β’ Milestone 4.5 Postmortem (Stimulus Test Harness) β’ Milestone 6 Postmortem (Tray Daemon & DevTools HUD) |
| Telemetry & Evidence | β’ Empirical Telemetry Benchmarks (FlaUI UIA3 / Win32 Shallow) β’ Canonical Ground-Truth Evidence Ledger β’ Milestones 5 & 6 Diagnostic Report |
| External Research Audits | β’ External Research Hub β’ Tree-sitter & Syntactic Scoping β’ TIRG-DLL & Text Geometry β’ AccessKit & Accessibility Primitives β’ FlaUI & Roemer Deep Dive β’ Wheel Reinvention Synthesis |
| Upstream Research Lineage | β’ Foundational accessibility research documents (001β018) in caster-user-directory-and-notes. |
π§ Note on Future Roadmap: A full, interactive guided walkthrough and wiki synthesizing the end-to-end codebase mechanics will be developed as the project reaches its next milestone.
Following our 4-Gate Epistemic Protocol, ADCE engineering is structured across clear progressive phases:
| Phase / Milestone | Description | Status | Deliverables & Artifacts |
|---|---|---|---|
| Phase 1: Physical Observation | Identify DOM traversal traps and latency bottlenecks across real-world apps. | [x] Complete |
β’ Doc 010: DOM Traversal Telemetry β’ Exposed 6,800-node DOM COM stall. |
| Phase 2: Adversarial Evaluation & Spikes | Gate 2 & Gate 3 empirical tests validating container targeting and Win32 gating. | [x] Complete |
β’ Micro-Spike 1 Telemetry (FlaUI UIA3) β’ Micro-Spike 2 Telemetry (Win32 Shallow) |
| Phase 3: Ecosystem Audit & Synthesis | Deep-dive audits of leading open-source Windows/COM/UIA tooling catalogs. | [x] Complete |
β’ Simon Mourier Ecosystem Suite β’ Roman Baeriswyl (Roemer / FlaUI) Deep Dive β’ Synthesis & Wheel Reinvention Audit |
| Phase 4: Architectural Specs & SSOT | Formalize ground-truth target zones, heuristic discovery archetypes, and MCP schemas. | [x] Complete |
β’ UI Automation SSOT Reference β’ Dynamic Discovery & Requirements Spec β’ MCP JSON Schema Specification |
| Phase 5: Production Daemon Suite | Build modular multi-project solution (ADCE.slnx), event pipeline, storage, and MCP server. |
[x] Complete |
β’ Milestone 1: ADCE.Core domain models, events & serialization ([x] Complete)β’ Milestone 2: ADCE.Extraction standalone context grabber ([x] Complete)β’ Milestone 3: Low-overhead event pipeline ( SetWinEventHook + channel debouncer) ([x] Complete)β’ Milestone 4: SQLite WAL store & in-memory live cache ( [x] Complete)β’ Milestone 4.5: Ground-Truth Stimulus Test Harness ( [x] Complete)β’ Milestone 5: High-Performance MCP Server (Stdio & SSE/HTTP) ( [x] Complete)β’ Milestone 6: Windows System Tray Daemon & Live DevTools HUD ( [x] Complete) |
| Phase 6: Self-Healing & Hardening (Milestone 7) | Externalize app definitions and implement unmapped control logging for AI self-labeling. | [ ] Active |
β’ WP 7.1: Known Limitations & Technical Gaps specification ([x] Complete)β’ WP 7.2: Declarative App Definitions Engine ( app_definitions.json) ([ ] Scheduled)β’ WP 7.3: Self-Healing Telemetry Logger for unmapped [Unknown] subtrees ([ ] Scheduled)β’ WP 7.4: Epistemic Hierarchy & Documentation Harmonization ( [x] Complete) |
| Phase 7: Advanced Context Primitives (Milestone 8) | Extract text selections, caret offsets, and on-demand full document buffers. | [ ] Scheduled |
β’ WP 8.1: Caret position & active text selection extraction (TextPattern)β’ WP 8.2: Opt-in full document & editor buffer extraction ( get_document_text)β’ WP 8.3: Multi-tier configurable privacy depth levels |
| Phase 8: External Voice & Agent Bindings (Milestone 9) | Connect Caster Dragonfly grammars and local AI assistants to live MCP streaming endpoints. | [ ] Deferred |
β’ WP 9.1: Caster / Dragonfly dynamic voice grammar bindings β’ WP 9.2: Local AI coding assistant dynamic prompt injection loops |
Transparency regarding physical OS boundaries and framework constraints is a foundational tenet of ADCE:
-
Custom Canvas & Non-Accessible Toolkits:
Applications built using pure immediate-mode custom graphics engines (e.g. Flutter, raw WebGL/HTML5 canvas, legacy Java AWT, Blender, Figma) do not construct standard Windows UI Automation trees unless explicitly run with accessibility flags enabled by the vendor. For these applications, ADCE accurately captures the top-level window envelope, process identity, and bounding coordinates, but falls back to
DesktopSemanticZone.Unknownfor intra-canvas sub-widgets. -
Chromium AXTree Asynchronous IPC Latency:
Unlike native Win32/WinUI controls whose vtables live in local memory (
$\approx 1\text{β}5\text{ ms}$ response), Chromium/Electron applications marshal accessibility nodes on an asynchronous internal thread (AXTree). Deep queries across large Electron DOMs incur physical cross-process IPC delays ($\approx 40\text{β}75\text{ ms}$ ). ADCE compensates for this via 50ms trailing-edge debouncing and scoped container bounding box pruning. - Virtualized UI Element Trees: Modern controls utilizing virtualization (e.g. large file lists, virtualized tables, or long chat message streams) only instantiate UIA nodes for elements currently visible in the viewport. ADCE cannot inspect items that have been virtualized out of the active visual subtree without programmatic scrolling.
-
Single Global OS Keyboard Focus Pointer:
Windows maintains a single global keyboard focus point at the OS level (
GetFocus/GetGUIThreadInfo). When the user shifts focus between multiple non-foreground windows, background windows reflect their last-known captured state until brought to the foreground. -
UIA3 vs. UIA2 Driver Boundary:
ADCE runs exclusively on
FlaUI.UIA3over native WindowsUIAutomationCore.dll(vtable COM). It does not maintain backwards compatibility shims for legacyUIA2(UIAutomationClient.dll/ MSAA wrappers), as UIA2 lacks batchCacheRequestsupport and suffers from high cross-apartment STA marshalling overhead.
- Language & Framework: C# 14 / .NET 10 (LTS) (
net10.0-windows) - UI Automation Engine: FlaUI.UIA3 (v5.0.0+) over native
UIAutomationCore.dll - Concurrency: Native Win32
WinEventhooks decoupled viaSystem.Threading.Channelsinto MTA background workers - Persistence: Embedded SQLite (WAL mode) with single-writer asynchronous queue & L1 cache
- Protocol: Model Context Protocol (MCP) JSON-RPC 2.0 (Stdio / SSE / HTTP Minimal API)
- DevTools HUD: WinForms Non-Activating overlay (
WS_EX_NOACTIVATE | WS_EX_TOPMOST)
# Launch System Tray Daemon with live non-activating floating HUD overlay
dotnet run --project src/ADCE.Daemon -- --hud
# Launch System Tray Daemon with MCP server on HTTP/SSE port 8424
dotnet run --project src/ADCE.Daemon
# Launch as headless MCP server over Stdio (for IDE/Agent integration)
dotnet run --project src/ADCE.Daemon -- --stdio# Visualize recent context transitions and application time distribution
dotnet run --project src/ADCE.Spikes -- --timeline 20# Run full automated unit test suite across all 5 projects (136 tests)
dotnet test
# Run Milestone 6 Daemon & End-to-End integration verification spike
dotnet run --project src/ADCE.Spikes -- --spike6
# Run Milestone 4 SQLite WAL store & L1 in-memory live cache verification spike
dotnet run --project src/ADCE.Spikes -- --storage
# Run Milestone 3 live event pipeline spike (listening for foreground & focus transitions)
dotnet run --project src/ADCE.Spikes -- --events -d 15
# Run Milestone 2 live standalone context grabber against active foreground window
dotnet run --project src/ADCE.Spikes -- --grabADCE's technical architecture is informed by foundational research across the Windows systems and accessibility ecosystems:
- FlaUI by Roman Baeriswyl (
Roemer) (MIT License): Powers ADCE's high-throughput UIA3 COM vtable automation andCacheRequestbatch extraction. - Microsoft.Data.Sqlite (MIT License) & SQLitePCLRaw by Eric Sink (Apache-2.0): Powers ADCE's embedded time-series state persistence.
- Simon Mourier (
smourier): Open-source systems tools (HwndExplorer,UInspect) audited during exploratory research for low-overhead Win32 filtering techniques. - Caster Upstream Lineage: Research documents 001β018 detailing the initial DOM traversal benchmarks and epistemic protocols that originated this engine.
Licensed under the Apache License, Version 2.0. See LICENSE for details.


