This file provides context for AI coding assistants (Antigravity, Copilot, Cursor, etc.) working on this project.
OmniAntigravity Remote Chat (v1.3.0) is a premium mobile command center for Antigravity AI sessions.
Architecture: Node.js server connects to Antigravity via Chrome DevTools Protocol (CDP), mirrors the chat UI to a mobile browser via WebSocket, and adds remote workspace tools, supervisor intelligence, quota monitoring, and tunnel-based remote access.
- Runtime: Node.js 22+ (ESM modules,
"type": "module") - Server: Express.js 4.22, WebSocket (ws 8.x), Cookie-based auth, compression
- Frontend: Vanilla HTML/CSS/JS (no framework), 5 themes, PWA support
- Protocol: Chrome DevTools Protocol (CDP) for Antigravity communication
- Testing: Vitest 4.x (unit), custom smoke suite (integration)
- Tunneling: Cloudflare Quick Tunnels, Pinggy (SSH-based), ngrok (optional)
- Notifications: Telegram Bot (optional, lazy-loaded
node-telegram-bot-api) - AI Supervisor: OmniRoute OpenAI-compatible API (optional)
- Ports: CDP on 7800-7803 (configurable via
CDP_PORTS), web server on 4747 (configurable viaPORT) - Docker:
node:22-alpinewith production-only deps
src/
βββ server.js β Main server: Express + WebSocket + CDP actions (3400+ lines)
βββ config.js β Constants, env vars, feature flags, version
βββ env.js β dotenv bootstrap (resolves .env from project root)
βββ state.js β Shared mutable state + JSDoc type definitions
βββ supervisor.js β AI supervisor (OmniRoute), suggest queue, heuristic safety
βββ quota-service.js β Model quota polling via language server HTTPS API
βββ session-stats.js β In-memory session analytics and metrics
βββ screenshot-timeline.js β Persistent screenshot capture with disk storage
βββ ui_inspector.js β UI DOM inspection utilities
βββ cdp/
β βββ connection.js β CDP discovery, WebSocket connect, context management
βββ utils/
βββ network.js β getLocalIP, isLocalRequest, getJson
βββ process.js β killPortProcess, isPortFree, launchAntigravity
βββ hash.js β djb2 hash for snapshot diff detection
βββ telegram.js β Telegram bot: commands, inline keyboards, rate-limiting, threading
βββ workspace.js β File browser, terminal manager, Git actions, quick commands, uploads
public/
βββ index.html β Main mobile chat interface
βββ login.html β Authentication page
βββ admin.html β Admin panel (metrics, logs, tunnel control)
βββ minimal.html β Lite mode for unstable connections
βββ manifest.json β PWA manifest
βββ sw.js β Service worker
βββ css/ β Modular CSS: variables, themes (5), layout, components, workspace, assist, chat
βββ js/
β βββ app.js β Main client logic (WebSocket, rendering, UI state)
β βββ admin.js β Admin panel logic
β βββ login.js β Login page logic
β βββ minimal.js β Lite mode logic
β βββ theme-bootstrap.js β Theme initialization (CSP-compliant external script)
β βββ components/ β Modular workspace panels (assist, files, git, stats, terminal, timeline)
βββ icons/ β SVG app icons (standard + maskable)
scripts/
βββ cloudflare-tunnel.js β Cloudflare Quick Tunnel manager
βββ pinggy-tunnel.js β Pinggy SSH tunnel manager
βββ generate_ssl.js β SSL certificate generator (OpenSSL + Node.js crypto fallback)
βββ setup-ssl.js β Interactive SSL setup with mkcert
βββ install_context_menu.* β OS context menu installers (Windows/Linux)
βββ start.sh / start.bat β Shell launchers (local)
βββ start_web.sh / start_web.bat β Shell launchers (remote)
βββ sync_features.py β Feature sync utility
βββ windows-wsl-remote/ β PowerShell scripts for WSL2 integration
test/
βββ test.js β Integration/smoke test suite
βββ unit/ β Vitest unit tests (9 test files)
βββ config.test.js
βββ hash.test.js
βββ network.test.js
βββ quota-service.test.js
βββ screenshot-timeline.test.js
βββ session-stats.test.js
βββ supervisor.test.js
βββ telegram.test.js
launcher.js β Node.js entry point (QR code, tunnel orchestration)
data/ β Runtime data (quick-commands.json, screenshots/, uploads/)
docs/ β Extended documentation (CODE_DOCUMENTATION, plans, competitive analysis)
- ESM imports β All
.jsfiles useimport/export, notrequire(). Exceptions:fix_ts.cjsandsync_wsl.cjs(CommonJS utilities) - PROJECT_ROOT β
src/config.jsusesjoin(__dirname, '..')asPROJECT_ROOTsince it lives insrc/ - CDP connection β
discoverCDP()scans configurable ports (default 7800-7803) for Antigravity targets - Multi-window β
discoverAllCDP()returns all available CDP workbench targets across ports - Auth β Cookie-based via
omni_ag_auth, password fromAPP_PASSWORDenv var, LAN auto-auth - CSP enforcement β Strict
Content-Security-Policyvia both HTTP header and meta tags; zero inline JS - Snapshot polling β Background loop captures DOM snapshots, detects changes via hash, and broadcasts via WebSocket
- Tunnel support β Multi-provider tunnel system (Cloudflare, Pinggy, ngrok) with automatic fallback
- Supervisor β OmniRoute-backed AI supervisor with heuristic safety gates and suggest queue
- Quota monitoring β Discovers local
language_serverprocesses, probes HTTPS endpoints for quota data - Screenshot timeline β Disk-persisted screenshot captures with manifest, auto-capture on change, pruning
- Session stats β In-memory metrics (messages, approvals, errors, uploads, screen activity)
- Telegram integration β Lazy-loaded bot with commands, inline keyboards, rate-limiting, message threading
- Workspace tools β File browser, terminal streaming, Git panel, assist chat, all via REST API
- Theme system β 5 themes (dark, light, slate, pastel, rainbow) with CSS variables and persistence
POST /login,POST /logout,GET /health,GET /snapshot
POST /send,POST /stop,POST /set-mode,POST /set-modelPOST /new-chat,GET /chat-history,POST /select-chat,GET /chat-status
GET /cdp-targets,POST /select-target,POST /api/launch-windowPOST /remote-click,POST /remote-scroll,GET /app-state
GET /api/fs/ls,GET /api/fs/catGET /api/terminal/history,POST /api/terminal/run,POST /api/terminal/stopGET /api/git/status,POST /api/git/add,POST /api/git/commit,POST /api/git/pushGET /api/quick-commands,PUT /api/admin/quick-commands
POST /api/interact-actionGET /api/suggestions,GET /api/suggestions/pendingPOST /api/suggestions/:id/approve,POST /api/suggestions/:id/rejectDELETE /api/suggestions
GET /api/stats,GET /api/quotaGET /api/timeline,GET /api/timeline/:filename,POST /api/timeline/capture,DELETE /api/timeline
POST /api/assist/chat,GET /api/assist/history,DELETE /api/assist/history
GET /api/screencast/status,POST /api/screencast/start,POST /api/screencast/stopPOST /api/upload-image
GET /admin,GET /api/admin/logs,GET /api/admin/metricsGET /api/admin/tunnel,POST /api/admin/tunnel/start,POST /api/admin/tunnel/stop
GET /ssl-status,POST /generate-ssl,GET /debug-ui,GET /ui-inspect,GET /minimal
npm start # Start server directly
npm run dev # Dev server (alias for start)
npm run start:local # Launch with QR code (Wi-Fi)
npm run start:web # Launch with tunnel (Cloudflare preferred)
npm run start:web:pinggy # Launch with Pinggy tunnel
npm run setup:ssl # Generate trusted HTTPS certificates
npm test # Run integration/smoke test suite
npm run test:unit # Run Vitest unit tests
npm run test:unit:watch # Run Vitest in watch mode
npm run test:coverage # Run Vitest with V8 coverage
npm run test:all # Run both smoke + unit tests- Never use
require()β this is an ESM project ("type": "module") - The
public/directory is served as static files fromPROJECT_ROOT - SSL certs go in
certs/at project root (auto-generated viascripts/setup-ssl.js) .envcontains secrets β never commit it (it's in.gitignore)- Runtime data lives in
data/(quick-commands.json, screenshots/, uploads/) - The
_tasks/and_references/directories are internal development tracking β not part of the product - Frontend workspace panels in
public/js/components/are modular and self-contained - Telegram bot is lazy-loaded β the server works fine without
node-telegram-bot-apiinstalled - The supervisor is optional β set
OMNIROUTE_SUPERVISOR_ENABLED=trueto activate - CSP is enforced both via HTTP header and HTML meta tags for defense-in-depth