Files
jmj c037b43f4a Initial commit: PulseWall hub, Android app, and protocol docs
- hub: FastAPI backend (MCP server, ADB LAN controller, bridge, storage)
- hub/web: Vue 3 admin console (device manager, screen mirror, chat workbench)
- android: Kotlin shell app with WebView stage, OTA, telemetry, keep-alive
- protocol: architecture, MCP schema, and WebSocket protocol specs
2026-11-30 07:37:34 +08:00

55 lines
4.0 KiB
Markdown

# PulseWall System Architecture (v1.0)
PulseWall is an AI-driven live information wall, real-time device status monitor, and bidirectional interactive terminal consisting of:
1. **Upstream AI Clients**: Any standard MCP client (e.g., `dsh`, Claude, Cursor, custom agents) plus optional event-stream adapter plugins for real-time reverse callbacks.
2. **Python Hub (`hub/`)**: Central bridge exposing:
- Standard **MCP Server** (Streamable HTTP `/mcp` + REST/SSE event bridge)
- **WebSocket Device Gateway** (`/ws/device/{device_id}`) for multi-device Android connectivity (LAN first, WAN/WSS ready)
- **Config Center** pushing OpenAI-compatible repair model settings (`base_url`, `api_key`, `model`, limits) and global themes to connected devices
- **LAN-Only Developer Debug / ADB Controller** (`/api/lan-debug/...`, strictly restricted to RFC1918/loopback clients, disabled by default per device)
- **Audit Log, Page Snapshots & Web Admin Panel** (`/admin`) backed by SQLite
3. **Android 11 Native App (`android/`)**: Kotlin native client (`minSdk = 30`) featuring:
- **Layered Capability Providers**: `basic` (always), `root` (auto-detected), `accessibility` (reserved), `adb_lan` (Hub-side)
- **Native Unbreakable Layer**: Fullscreen red emergency alarm, wake-screen, sound/TTS/vibration, Preset-First quick-action dialogs
- **Dual-Stage WebView Renderer**: Pre-render static validator + offscreen sandbox trial -> smooth switch to main WebView + automatic healthy snapshot rollback
- **End-Side OpenAI Repair Sentinel**: Fixes syntax/CSS/responsive/WebView-compatibility issues locally using Hub-pushed OpenAI config, and escalates data/semantic questions back to the upstream AI via Hub
## Render & Self-Healing State Machine
```
Upstream AI calls render_page(device_id, html, ...)
│
▼
Hub forwards WS `render.apply` (task_id) ──► Android Validator & Offscreen Sandbox
│ │
│ ┌────────┴────────┐
│ [PASS] [ERROR]
│ │ │
│ ▼ ▼
│ Mount to Main WebView End-Side Repair AI (OpenAI API)
│ Save Healthy Snapshot (up to max_retries, default 3)
│ │ │
│ │ ┌────────┴────────┐
│ │ [fix_locally] [ask_upstream]
│ │ │ │
│ │ Re-validate Return/Emit Clarification
│ │ & Hot-Swap Question to Upstream AI
│ ▼
│ Runtime Console Watchdog
│ (window.onerror / unhandledrejection / console.error / Vue)
│ │
│ [Runtime Error]
│ ▼
│ Debounce & Deduplicate ──► End-Side Repair AI
│ (Fallback: Auto-rollback to last Healthy Snapshot)
```
## Security Boundaries
- **MCP & Device Gateway**: Protected by bearer/header API token (configurable in Hub; optional relaxed mode for local trusted LAN).
- **LAN Developer Debug / ADB API**:
1. Hard network guard rejecting any non-private IP (`127.0.0.0/8`, `10.0.0.0/8`, `172.16.0.0/12`, `192.168.0.0/16`, `::1`) and rejecting requests with public `X-Forwarded-For` headers.
2. Requires both global `lan_debug_enabled=true` and per-device authorization.
3. Every command is recorded in SQLite audit logs; destructive commands require confirmation or are blocked.