feat(live): human live view via CDP screencast over SSE (C1) - #39
Merged
Conversation
New browser_live_view / browser_live_view_stop tools (31st/32nd). A CDP screencast (page.context().newCDPSession → Page.startScreencast, ack-per-frame, re-issued on navigation) streams JPEG frames over an ephemeral, token-gated 127.0.0.1 Server-Sent-Events server to a self-contained <canvas> viewer that auto-opens in the OS browser. Read-only; works for headless sessions too. Auto-closes on page close or stop. Zero new dependencies (node:http + SSE). broadcast() guards writableEnded/destroyed and handles async EPIPE/ECONNRESET in the write callback so a viewer disconnecting mid-stream can't crash the MCP process. Real screencast→SSE→frame integration test. Closes #29
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.
What
C1 —
browser_live_view/browser_live_view_stop(31st/32nd tools). Watch a session's browser in real time from a normal web page — works even headless.src/live/screencast.ts—page.context().newCDPSession(page)→Page.startScreencast(JPEG); acks each frame with its ownsessionId(ack-first, or the stream stalls); re-issues onload(screencast stops on hard nav); returns a stop fn.src/live/sse-server.ts— ephemeralnode:httpserver bound to127.0.0.1:0, token-gated;/stream=text/event-streamof base64 JPEG frames,/= the viewer. Zero new deps (SSE, nows).src/live/viewer-html.ts— self-contained<img>/EventSource viewer.src/live/open-url.ts— best-effort OS opener.src/live/manager.ts— one live view per session; replace-on-restart; auto-stop onpage.once('close').Read-only (no click-through) in v1. Returns a
127.0.0.1URL with an embedded token; auto-opens unlessopen:false.Robustness
Two sniper passes. Fixed a real process-crash:
broadcast()now guardswritableEnded/destroyedand consumes asyncEPIPE/ECONNRESETin theres.writecallback, so a viewer disconnecting mid-stream cannot crash the MCP process. Documented (@remarks) that the screencast does not auto-reattach after a B1 page recovery (callbrowser_live_viewagain).Security
Loopback-only bind, 128-bit random token validated on every request, auto-close on page close / stop / explicit teardown.
Validation
Docs: new Live view section in docs/mcp-tools.md + tool count 30→32 across README/docs.
Closes #29