feat(plugins): the lab Chrome leaves the core for the lab-chrome plugin (plugin sockets, chrome.lab, full modal) #16

Closed
gabrielvidal wants to merge 0 commits from lab-chrome-plugin into main
pull from: lab-chrome-plugin
Owner

Summary

The lab Chrome (Settings → Browser, the conversation's Browser dock with the noVNC live view and Take over, and the container's on-demand life) leaves the core for the lab-chrome live plugin: gabrielvidal/ai-agent-plugins#8. The core keeps the Chrome chip (the harness capability chrome, meta.chrome) and gains three generic platform hooks the plugin is built on. This is move E of the "what could move into ai-agent-plugins" map (form ai-agent-moves-to-ai-agent-plugins_o2qxmd). The hooks are:

  • plugin websockets, which a sandboxed frame couldn't open before;
  • a chrome.lab provider;
  • a full-size app.modal.

Key changes

  • sockets[] + aiAgentPlugin.openSocket(id, {protocols}):

    • backend/plugins/sockets.py: WS /api/plugins/{pid}/sockets/{sid} bridges only to the upstream the plugin declared. It is owner only and refused on the guest host, using the gate's handshake rules, moved from chrome/routes.py as ws_caller; on the owner's internet address the session is re-checked every 5 s. Declaring a socket needs operator approval and enters the fingerprint.
    • GET /proxy/tools/plugins/{pid}/sockets/{sid}/probe → {up, open, lastActiveAt}, for the plugin's own handlers.
    • Frontend: business/plugins/frameSockets.ts. The host opens the real websocket with the reader's cookies and relays it over postMessage, binary as transferred ArrayBuffers, ≤ 4 sockets per frame, all closed with the frame. The frame side is a WebSocket-like channel in the bridge script, which noVNC's RFB takes as is.
  • provides: {"chrome.lab": action} (backend/plugins/chrome_bridge.py):

    • {op: "status"} returns {reachable, chipDefault, guests}, cached 10 s. runs/routes.py _guest_chrome keeps a guest's --chrome only with guests. The composer reads its chip default from the same action (usePluginProvider + usePluginRead).
    • {op: "ensure"} runs before a lab claude run launches with --chrome (runs/service.py, spawn and resume). It replaces lifecycle.ensure_up and never blocks a launch on a failure.
  • ui.slots[].size on app.modal (sm|md|lg|full): full is near full screen, with the frame filling it (PluginModalHost).

  • Conversation data: the conversation.gizmos update adds chrome and worker; hub/conversations rows add chrome.

  • Carry-over carryover.chrome: /data/chrome.json goes to the plugin's legacy-settings.json at once. It is merged into the owner's config at the plugin's install (_plugin_changed) or the next start; a key still at its field's default takes the old value. Then the file is renamed ….migrated.

  • Removed:

    • backend/chrome/, /api/chrome* and schemas/chrome.py (plus the generated types and openapi.json entries);
    • the SSE chrome event and the lab.integrations permission (catalog, matrix, roles mock);
    • BrowserDock, BrowserSettings, the panel store, the header's Browser button and pane-menu item, and the eye popover's Browser switch (the plugin's slot vis replaces it);
    • @novnc/novnc (package, lockfile, novnc.d.ts, the vite chunk) and the Settings registry's Browser entry.

    /settings/browser redirects to /settings/plugin/lab-chrome. ChromeToggle (the chip and badge) and sidecar/routes_chrome.py stay.

  • Docs:

    • docs/plugins.md has a new section, "Websockets, the lab browser and a full modal";
    • CLAUDE.md's lab-browser section is rewritten;
    • docs/settings.md and docs/security.md (G3) note the move.

Key decisions

  • A generic relay rather than core noVNC.
    • A sandboxed frame has no network or cookies, so the host opens the socket and relays it. The core no longer ships a VNC client, and noVNC lives in the plugin.
    • Side effect: npx vite on the EVOX2 no longer dies on noVNC's top-level await.
    • The route never takes a URL from the caller; only the declared target can be reached.
  • chrome.lab is a provider, not a generic run hook.
    • The core already knows --chrome (the chip, meta.chrome), so "who runs the browser a lab --chrome run drives" is one narrow question with two ops.
    • harnessHooks (SessionStart) didn't fit: they run inside the harness on every machine and can't hold a launch for the container.
  • The idle job learns "someone is watching" from the socket probe (relays open, last frame) instead of a heartbeat action from the frame: one generic number, no extra subprocess per minute.
  • The header's Browser button and pane-menu item are gone. The core can't know a plugin's modal slot, and the bottom-right pill (the old dock's main entry) opens the live view.
  • The lab.integrations permission is removed: Browser was its only route, and the authz test forbids a route permission with no route. Stored roles drop unknown ids on read.

Changelog

  • Changed: the lab Chrome (live view, Take over, on-demand start and stop, its settings) is now the Lab Chrome plugin — Settings → Plugins → Lab Chrome; /settings/browser takes you there.
  • Added: plugins can open a websocket from their pages to a target they declare (owner only), and show a page in a full-screen app modal.
  • Removed: the core's Browser dock, Settings → Browser page and the header's Browser button.

Test notes

  • Not deployed from the EVOX2. Deploy and the plugin install go through the Homelab after review.

  • Homelab steps, in this order. The live hub's validate_manifest rejects the plugin until this hub change is deployed: the top-level sockets, provides.chrome.lab and ui.slots[].size are new.

    1. Merge ai-agent #16 and ai-agent-plugins gabrielvidal/ai-agent-plugins#8.
    2. Deploy the hub with ai-agent-deploy (blue-green). At that start, carryover.chrome copies /data/chrome.json (chip default, guests, keep, idle minutes) into the plugin's shared legacy-settings.json; the plugin isn't installed yet, so the file stays in place.
    3. Install plugins/lab-chrome and approve it (operator approval: an internal proxy, a hub secret, a socket). Right after the install, the install route's _plugin_changed runs carryover.chrome again: the old settings merge into the owner's config, and /data/chrome.json is renamed ….migrated.
    4. Set its Host sidecar token to the lab's SIDECAR_TOKEN (the same one video-extract uses).

    Between steps 2 and 3, the Chrome chip still launches --chrome, but nothing starts the lab Chrome, guests don't keep --chrome, and there is no live view. Do steps 2–4 back to back.

  • Conflicts: sibling PRs (moves A–D, F and other sessions' plugin moves) touch root.tsx, settings/registry.ts, CLAUDE.md, docs/plugins.md, plugins/carryover.py and main.py. Rebase in merge order.

  • Backend: every module ran in its own process under bwrap (throwaway /data): 155/157 pass. test_tool_proxy_media (test_the_quota_is_seerrs_…) and test_typed_plugins (test_records_carry_kind) fail identically on main e1b7b4ab. New test_plugin_sockets.py (14) covers:

    • the manifest;
    • a real relay to a local websocket server (both ways, subprotocol, open count);
    • the refusals (guest, nobody, undeclared, upstream down);
    • the provider (cache, ensure, a broken plugin);
    • _guest_chrome, the chrome row and the carry-over.

    The ported test_gate and test_remote_access socket tests pass, as do test_authz and test_authz_matrix (golden updated).

  • Frontend: tsc --noEmit is clean. Full vitest: 1063/1066; the 3 failures (useShareTarget ×2, FreshContext CacheExpiredNotice) fail on main too. New frameSockets.test.ts (4). npm run build:mock builds, with no noVNC in dist.

  • Live, on a local hub (port 8135):

    • The plugin was installed with its socket pointed at a stub RFB 3.8 server: the PNG of a fake sign-in page, raw encoding, and a pointer click paints a dot. Its proxy pointed at a stub sidecar.
    • From Python, the hub's relay carried RFB 003.008 and refused an undeclared socket and a cross-site handshake (403).
    • In headless Chromium (screenshots): the pill painted a thumbnail; a tap opened the live view, which connected through openSocket; Take over and a click on "Next" reached the server (its log: click 899,574) and the dot came back as an update; /settings/browser redirected to the plugin's page.
    • {op: ensure} answered through the hub.

Screenshots

2-live-view.png
3-take-over-click.png
1-conversation-pill.png
5-settings-status.png

## Summary The lab Chrome (Settings → Browser, the conversation's Browser dock with the noVNC live view and *Take over*, and the container's on-demand life) leaves the core for the **`lab-chrome` live plugin**: https://git.gabvdl.xyz/gabrielvidal/ai-agent-plugins/pulls/8. The core keeps the **Chrome chip** (the harness capability `chrome`, `meta.chrome`) and gains three generic platform hooks the plugin is built on. This is move E of the "what could move into ai-agent-plugins" map (form `ai-agent-moves-to-ai-agent-plugins_o2qxmd`). The hooks are: - **plugin websockets**, which a sandboxed frame couldn't open before; - **a `chrome.lab` provider**; - **a full-size `app.modal`**. ## Key changes - **`sockets[]` + `aiAgentPlugin.openSocket(id, {protocols})`**: - `backend/plugins/sockets.py`: `WS /api/plugins/{pid}/sockets/{sid}` bridges only to the upstream the plugin declared. It is owner only and refused on the guest host, using the gate's handshake rules, moved from `chrome/routes.py` as `ws_caller`; on the owner's internet address the session is re-checked every 5 s. Declaring a socket needs operator approval and enters the fingerprint. - `GET /proxy/tools/plugins/{pid}/sockets/{sid}/probe` → `{up, open, lastActiveAt}`, for the plugin's own handlers. - Frontend: `business/plugins/frameSockets.ts`. The host opens the real websocket with the reader's cookies and relays it over postMessage, binary as transferred ArrayBuffers, ≤ 4 sockets per frame, all closed with the frame. The frame side is a WebSocket-like channel in the bridge script, which noVNC's `RFB` takes as is. - **`provides: {"chrome.lab": action}`** (`backend/plugins/chrome_bridge.py`): - `{op: "status"}` returns `{reachable, chipDefault, guests}`, cached 10 s. `runs/routes.py _guest_chrome` keeps a guest's `--chrome` only with `guests`. The composer reads its chip default from the same action (`usePluginProvider` + `usePluginRead`). - `{op: "ensure"}` runs before a lab claude run launches with `--chrome` (`runs/service.py`, spawn and resume). It replaces `lifecycle.ensure_up` and never blocks a launch on a failure. - **`ui.slots[].size`** on `app.modal` (`sm|md|lg|full`): `full` is near full screen, with the frame filling it (`PluginModalHost`). - **Conversation data**: the `conversation.gizmos` update adds `chrome` and `worker`; `hub/conversations` rows add `chrome`. - **Carry-over** `carryover.chrome`: `/data/chrome.json` goes to the plugin's `legacy-settings.json` at once. It is merged into the owner's config at the plugin's install (`_plugin_changed`) or the next start; a key still at its field's default takes the old value. Then the file is renamed `….migrated`. - **Removed**: - `backend/chrome/`, `/api/chrome*` and `schemas/chrome.py` (plus the generated types and `openapi.json` entries); - the SSE `chrome` event and the `lab.integrations` permission (catalog, matrix, roles mock); - `BrowserDock`, `BrowserSettings`, the panel store, the header's Browser button and pane-menu item, and the eye popover's *Browser* switch (the plugin's slot `vis` replaces it); - `@novnc/novnc` (package, lockfile, `novnc.d.ts`, the vite chunk) and the Settings registry's Browser entry. `/settings/browser` redirects to `/settings/plugin/lab-chrome`. `ChromeToggle` (the chip and badge) and `sidecar/routes_chrome.py` stay. - **Docs**: - `docs/plugins.md` has a new section, "Websockets, the lab browser and a full modal"; - CLAUDE.md's lab-browser section is rewritten; - `docs/settings.md` and `docs/security.md` (G3) note the move. ## Key decisions - **A generic relay rather than core noVNC.** - A sandboxed frame has no network or cookies, so the host opens the socket and relays it. The core no longer ships a VNC client, and noVNC lives in the plugin. - Side effect: `npx vite` on the EVOX2 no longer dies on noVNC's top-level await. - The route never takes a URL from the caller; only the declared target can be reached. - **`chrome.lab` is a provider, not a generic run hook.** - The core already knows `--chrome` (the chip, `meta.chrome`), so "who runs the browser a lab `--chrome` run drives" is one narrow question with two ops. - `harnessHooks` (`SessionStart`) didn't fit: they run inside the harness on every machine and can't hold a launch for the container. - **The idle job learns "someone is watching" from the socket probe** (relays open, last frame) instead of a heartbeat action from the frame: one generic number, no extra subprocess per minute. - **The header's Browser button and pane-menu item are gone.** The core can't know a plugin's modal slot, and the bottom-right pill (the old dock's main entry) opens the live view. - **The `lab.integrations` permission is removed**: Browser was its only route, and the authz test forbids a route permission with no route. Stored roles drop unknown ids on read. ## Changelog - Changed: the lab Chrome (live view, *Take over*, on-demand start and stop, its settings) is now the **Lab Chrome** plugin — Settings → Plugins → Lab Chrome; `/settings/browser` takes you there. - Added: plugins can open a websocket from their pages to a target they declare (owner only), and show a page in a full-screen app modal. - Removed: the core's Browser dock, Settings → Browser page and the header's Browser button. ## Test notes - **Not deployed from the EVOX2.** Deploy and the plugin install go through the Homelab after review. - **Homelab steps, in this order.** The live hub's `validate_manifest` rejects the plugin until this hub change is deployed: the top-level `sockets`, `provides.chrome.lab` and `ui.slots[].size` are new. 1. Merge ai-agent https://git.gabvdl.xyz/gabrielvidal/ai-agent/pulls/16 and ai-agent-plugins https://git.gabvdl.xyz/gabrielvidal/ai-agent-plugins/pulls/8. 2. Deploy the hub with `ai-agent-deploy` (blue-green). At that start, `carryover.chrome` copies `/data/chrome.json` (chip default, guests, keep, idle minutes) into the plugin's shared `legacy-settings.json`; the plugin isn't installed yet, so the file stays in place. 3. Install `plugins/lab-chrome` and approve it (operator approval: an internal proxy, a hub secret, a socket). Right after the install, the install route's `_plugin_changed` runs `carryover.chrome` again: the old settings merge into the owner's config, and `/data/chrome.json` is renamed `….migrated`. 4. Set its **Host sidecar token** to the lab's `SIDECAR_TOKEN` (the same one video-extract uses). Between steps 2 and 3, the Chrome chip still launches `--chrome`, but nothing starts the lab Chrome, guests don't keep `--chrome`, and there is no live view. **Do steps 2–4 back to back.** - **Conflicts**: sibling PRs (moves A–D, F and other sessions' plugin moves) touch `root.tsx`, `settings/registry.ts`, `CLAUDE.md`, `docs/plugins.md`, `plugins/carryover.py` and `main.py`. Rebase in merge order. - **Backend**: every module ran in its own process under bwrap (throwaway `/data`): 155/157 pass. `test_tool_proxy_media` (`test_the_quota_is_seerrs_…`) and `test_typed_plugins` (`test_records_carry_kind`) fail identically on `main` e1b7b4ab. New `test_plugin_sockets.py` (14) covers: - the manifest; - a real relay to a local websocket server (both ways, subprotocol, open count); - the refusals (guest, nobody, undeclared, upstream down); - the provider (cache, ensure, a broken plugin); - `_guest_chrome`, the `chrome` row and the carry-over. The ported `test_gate` and `test_remote_access` socket tests pass, as do `test_authz` and `test_authz_matrix` (golden updated). - **Frontend**: `tsc --noEmit` is clean. Full vitest: 1063/1066; the 3 failures (`useShareTarget` ×2, `FreshContext` CacheExpiredNotice) fail on `main` too. New `frameSockets.test.ts` (4). `npm run build:mock` builds, with no noVNC in `dist`. - **Live, on a local hub (port 8135)**: - The plugin was installed with its socket pointed at a **stub RFB 3.8 server**: the PNG of a fake sign-in page, raw encoding, and a pointer click paints a dot. Its proxy pointed at a stub sidecar. - From Python, the hub's relay carried `RFB 003.008` and refused an undeclared socket and a cross-site handshake (403). - In headless Chromium (screenshots): the pill painted a thumbnail; a tap opened the live view, which connected through `openSocket`; *Take over* and a click on "Next" reached the server (its log: `click 899,574`) and the dot came back as an update; `/settings/browser` redirected to the plugin's page. - `{op: ensure}` answered through the hub. ## Screenshots ![2-live-view.png](https://git.gabvdl.xyz/attachments/77e6363c-4cde-4f9c-ae73-99d67ee2bc34) ![3-take-over-click.png](https://git.gabvdl.xyz/attachments/d7027d74-fae9-461a-a496-1e628e380942) ![1-conversation-pill.png](https://git.gabvdl.xyz/attachments/eedf9793-47d7-49d5-ae92-16a0799de835) ![5-settings-status.png](https://git.gabvdl.xyz/attachments/be794c56-6cca-437a-ad3b-b35e8d8a1cc4)
gabrielvidal self-assigned this 2026-11-27 00:19:15 +01:00
gabrielvidal added 1 commit 2026-11-27 00:19:15 +01:00
Settings → Browser, the conversation's Browser dock (noVNC live view and
take-over) and the container's on-demand life move into the lab-chrome
live plugin (ai-agent-plugins). The core keeps the Chrome chip (the
harness capability chrome) and gains three generic hooks:

- sockets[] + aiAgentPlugin.openSocket(id): a frame's websocket, opened by
  the host with the reader's cookies and relayed over postMessage to
  WS /api/plugins/{pid}/sockets/{sid}, which bridges only to the declared
  upstream (owner only, the gate's handshake rules, never the guest host;
  operator approval). GET …/sockets/{sid}/probe → {up, open, lastActiveAt}
  for the plugin's handlers.
- provides chrome.lab (plugins/chrome_bridge.py): {op: status} → the chip
  default and whether guests' runs keep --chrome; {op: ensure} before a
  lab --chrome run launches (spawn and resume).
- ui.slots[].size on app.modal (full = near full screen, frame filling it);
  conversation.gizmos' update and hub/conversations rows carry chrome.

Gone: backend/chrome/, /api/chrome*, schemas/chrome.py, the SSE chrome
event, the lab.integrations permission, BrowserDock/BrowserSettings/store,
the Browser header button and eye switch, @novnc/novnc. /settings/browser
redirects to /settings/plugin/lab-chrome; carryover.chrome moves
/data/chrome.json into the plugin's config.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Author
Owner

Merged into main as 3e40144e (batch merge of the EVOX2 plugin moves on top of main 0797e454, all ai-agent suites green) and deployed: ai-agent @ 7c397fbc live since 2026-11-27 00:57. lab-chrome installed, its sidecar token set.

Merged into `main` as 3e40144e (batch merge of the EVOX2 plugin moves on top of main 0797e454, all ai-agent suites green) and deployed: ai-agent @ 7c397fbc live since 2026-11-27 00:57. lab-chrome installed, its sidecar token set.
gabrielvidal closed this pull request 2026-11-27 00:58:16 +01:00

Pull request closed

Please reopen this pull request to perform a merge.
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: gabrielvidal/ai-agent#16