Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
feat: loopback HTTP mirror on :5553 when HTTPS is active
Adam Eivyc5509cc6c795
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex 8ee2ce5761..b4bc4401b1 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -1,5 +1,6 @@## Added+- **Loopback HTTP mirror on port 5553 when HTTPS is active** — Tailscale's Let's Encrypt cert only covers `<machine>.<tailnet>.ts.net`, so `https://localhost:5555` always tripped a cert warning. When HTTPS is active the server now also spins up a plain HTTP listener bound to `127.0.0.1:5553` that attaches to the same Express app and Socket.IO instance — `http://localhost:5553` works without cert warnings and Chrome still treats it as a secure context (so getUserMedia / mic access continues to work). Override the port via `PORTOS_HTTP_PORT`. Documented in `docs/PORTS.md`.- **Voice agent — universal accessibility-mode DOM driving** — the voice Chief-of-Staff can now navigate to any page and operate any control by voice. New `ui_navigate` tool with a 100+ entry named-page enum ("take me to tasks" / "chief of staff agents" / "calendar" all route correctly instead of defaulting to Daily Log). New accessibility layer: a client-side DOM indexer (`client/src/services/domIndex.js`) walks `<main>` for interactable elements (tabs, buttons, links, inputs, selects, textareas, checkboxes, radios), resolves labels via the standard aria → `<label for>` → wrapping label → text → placeholder → title chain, stamps stable `data-voice-ref` refs, and caps at 200 elements. `useVoiceUiSync` hook (debounced MutationObserver scoped to `<main>`, change-detection via content signature) pushes the index to the server whenever it actually changes. Server stores the index on per-socket state and — for UI-driving user turns (verb-gated by regex to keep the 80% of turns that don't need it cheap) — injects a compact page summary into the LLM's system prompt. New tools: `ui_click` (tab/button/link by label with optional kind hint), `ui_fill` (text inputs + textareas, uses React-safe native value setter so `onChange` fires), `ui_select` (dropdowns with fuzzy option matching), `ui_check` (checkboxes + radios), `ui_list_interactables` (deep-dive fallback). Misses return a helpful `available` list to the LLM so it can self-correct instead of silently failing. **In-turn chained flows**: after a ui_* action fires, the server pauses briefly for the client to push the post-action DOM index, then attaches the fresh summary to the tool result — so multi-step flows like "create a task named Foo with description Bar" can complete in a single turn (ui_click New Task → see the modal → ui_fill Name → ui_fill Description → ui_click Save).- **Per-peer DNS override on the Instances page** — peer cards now expose an "edit host" control that lets you swap the raw Tailscale IP (`http://100.83.147.46:5555`) for a trusted HTTPS DNS name (`https://void.taile8179.ts.net:5555`). Once set, the server's probe, socket relay, sync orchestrator, and query proxy all route through `https://<host>` instead of `http://<ip>` — so app links in `PeerAppsList` also upgrade to HTTPS automatically. New `GET /api/instances/tailnet-suffix` endpoint shells out to the local `tailscale status --json` and returns the MagicDNS suffix + the full peer map, which the Instances UI uses to auto-suggest DNS names: match by Tailscale IP first (authoritative), fall back to `<peer.hostname>.<suffix>` composition. The UI's "use `<suggested>`" button applies the suggestion in one click. `updatePeer` now accepts an optional `host` field (validated as a DNS name; empty string clears); invalid hosts return 400 instead of silent no-ops. `addPeer` also accepts `host` for direct-DNS registration. Vite dev proxy auto-detects `data/certs/cert.pem` and flips its target to `https://localhost:5555` with `secure: false` when HTTPS is active, fixing "socket hang up" errors in dev mode. 44 tests (3 new) cover valid/invalid/cleared host handling.- **HTTPS with auto-renewing Let's Encrypt cert via Tailscale (self-signed fallback)** — Chrome refuses `getUserMedia` (mic) access over plain HTTP on a `100.x.x.x` Tailscale IP because the origin isn't a secure context. New `scripts/setup-cert.js` prefers a real Let's Encrypt cert via `tailscale cert <machine>.<tailnet>.ts.net` (Tailscale owns `ts.net` and solves the DNS-01 challenge for you — browsers trust the cert with zero click-through) and drops it into `data/certs/{cert,key}.pem`. If the Tailscale CLI is missing, the machine isn't logged in, or HTTPS Certificates aren't enabled in the tailnet admin, the script falls back to a self-signed cert with SANs for `localhost`, `127.0.0.1`, and every non-internal IPv4 (including the Tailscale IP). `server/index.js` picks `https.createServer` whenever `data/certs/{cert,key}.pem` exist and falls back to HTTP with a warning otherwise. New `server/services/certRenewer.js` runs daily on the server process, calls `tailscale cert` (no-op unless the LE cert is <2/3 lifetime remaining), and hot-swaps the live HTTPS server's `SecureContext` with the renewed cert — no restart needed. `npm start` runs the cert script before PM2 boot so fresh installs come up with HTTPS out of the box; `npm run setup:cert --force` regenerates on demand. Socket.IO auto-upgrades to WSS (same-origin relative paths). Access via `https://<machine>.<tailnet>.ts.net:5555` to get the trusted cert; the Tailscale IP still works but will show a cert mismatch.diff --git a/docs/PORTS.md b/docs/PORTS.mdindex 6f7e13fe47..04d561af6c 100644--- a/docs/PORTS.md+++ b/docs/PORTS.md@@ -23,6 +23,7 @@ Common port labels:| Port | Process | Label | Description ||------|---------|-------|-------------|+| 5553 | portos-server | api-local | Loopback-only HTTP mirror of the API (only listens when HTTPS is active on 5555). Lets `http://localhost:5553` work without cert warnings. Override with `PORTOS_HTTP_PORT`. || 5554 | portos-client | ui | Vite dev server (React UI) || 5555 | portos-server | api | Main API server || 5556 | portos-browser | cdp | Chrome DevTools Protocol |diff --git a/server/index.js b/server/index.jsindex 43092efe52..2448c9fc21 100644--- a/server/index.js+++ b/server/index.js@@ -417,6 +417,21 @@ ensureSelf()console.log(`⚠️ HTTP only — getUserMedia (mic) will not work over Tailscale IP. Run "npm run setup:cert" to enable HTTPS.`);} else {initCertRenewer(httpServer);+ // Tailscale's Let's Encrypt cert only covers <machine>.<tailnet>.ts.net,+ // so https://localhost:PORT fails the cert check. Spin up a loopback-+ // only HTTP listener on a sibling port for local dev/debugging —+ // Chrome treats http://localhost as a secure context so getUserMedia+ // still works. Same Express app + same Socket.IO instance (via+ // io.attach), so routes and websocket events are identical.+ const localHttpPort = Number(process.env.PORTOS_HTTP_PORT) || Number(PORT) - 2;+ const localServer = createHttpServer(app);+ io.attach(localServer);+ localServer.listen(localHttpPort, '127.0.0.1', () => {+ console.log(`🔓 Local HTTP also at http://localhost:${localHttpPort} (loopback only, no cert warnings)`);+ });+ localServer.on('error', (err) => {+ console.warn(`⚠️ Local HTTP fallback on :${localHttpPort} failed: ${err.message} — Tailscale HTTPS still active`);+ });}// Set up process error handlers with io instance