feat(dashboard): port read-only views to daemon SDK via WS bridge#37
Open
Codename-11 wants to merge 1 commit into
Open
feat(dashboard): port read-only views to daemon SDK via WS bridge#37Codename-11 wants to merge 1 commit into
Codename-11 wants to merge 1 commit into
Conversation
Adds a vanilla-JS daemon bridge that speaks the same binary-mux WebSocket protocol as `@axiom-labs/arc-client` so the dashboard can talk directly to the v3 daemon without pulling the Node SDK into the browser bundle. - `public/components/arc-client-bridge.js` (new) — frame codec + RPC / subscribe client that mirrors `packages/client/src/frame.ts` + `protocol.ts` byte-for-byte. Exposes `ensureArcClient()` which lazily fetches the daemon token from the dashboard and opens a WS, retrying on failure so the HTTP fallback stays working until the daemon is up. - `public/components/profiles.js` — prefers `profile.list` over the WS when the daemon is reachable; falls back to `/api/profiles` otherwise. - `public/components/overview.js` — augments `/api/overview` with live `health.get` + `agent.list` results from the daemon. - `src/api.ts` — new `daemonToken` handler (localhost-only) plus `readDaemonRootToken` + `isLocalRequest` helpers. - `src/server.ts` — registers `/api/daemon-token` and proxies `/ws` upgrades that carry the `arc-daemon` subprotocol to 127.0.0.1:7272. Rewrites the daemon's 101 response to echo the subprotocol (strict WS clients reject handshakes that don't). Returns 502 when the daemon is offline so the dashboard degrades cleanly to HTTP. - `tests/bridge.test.ts` (new, 7 tests) — proves the bridge codec round-trips byte-identically with the authoritative client codec, and exercises the `daemonToken` helpers. Typecheck clean; all 31 dashboard tests pass. E2E smoke verified: auth.login + health.get + profile.list all succeed through the proxy; `/api/daemon-token` returns 503 and `/ws` returns 502 when the daemon isn't running. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
arc-client-bridge.js) that speaks the same binary-mux WebSocket protocol as@axiom-labs/arc-client, so the dashboard talks to the v3 daemon without pulling the Node SDK into the browser.profiles.js(profile.list) andoverview.js(health.get+agent.list) to the new bridge, falling back to the existing HTTP API when the daemon isn't running./wssubprotocol-routed proxy (arc-daemon) that forwards browser WS upgrades to127.0.0.1:7272, rewriting the daemon's 101 response to echo the subprotocol so strict WS clients accept the handshake. Returns 502 when the daemon is offline.GET /api/daemon-token(localhost-only) so in-browser code can read~/.arc/auth.json#rootTokenwithout the secret leaving the loopback interface.Test plan
npx tsc --noEmit— cleannpx vitest run packages/dashboard/tests/bridge.test.ts— 7 tests pass (frame codec byte-for-byte identity with@axiom-labs/arc-client,readDaemonRootToken/isLocalRequesthelpers)auth.login+health.get+profile.listthrough the proxy succeed/api/daemon-tokenreturns 503 and/wsreturns 502 when daemon isn't running (graceful HTTP fallback)Notes
chat.jsorstyles/*.cssper the worktree instructions (pre-existing WIP)./wspath is preserved for existing components; only upgrades that advertiseSec-WebSocket-Protocol: arc-daemonare routed to the daemon.ensureArcClient()caches a live connection but re-tries on failure so callers don't permanently lock into HTTP when the daemon comes up later.Generated with Claude Code