M4: Outside access (bridge, MCP server, CLI, Suites) — v0.5.0 #7

Merged
akib merged 1 commit from akib/m4-outside-access into main 2026-11-10 09:59:26 +00:00 AGit
Owner

M4: Outside access (v0.5.0)

Programs on the same computer can drive BlockFlow while Settings → Allow outside control is on (off by default; optional nativeMessaging permission). Together with M3 this is v0.5.0.

New

  • packages/bridge (blockflow-bridge): native-messaging host. Relays a per-user socket (token auth, NDJSON) to the extension (4-byte framing), rewrites JSON-RPC ids for concurrent clients, routes streamed notifications. blockflow-bridge install --extension-id <id> for Chrome, Chromium, Brave, Brave Origin, Edge, Firefox.
  • Extension side: src/browser/bridge.ts + bridgeHandlers.ts. validate, import (tagged "via bridge"), list, run (streamed steps, per-run secrets never stored), report, snapshot, stop, blobs/screenshots, suites. Settings page with status, install command and request log.
  • packages/mcp (blockflow-mcp): stdio MCP server with 9 tools, guide/block/schema resources and a write-and-repair prompt. Failure screenshots come back as images.
  • packages/cli (blockflow-cli): blockflow run|validate, npm run build:automation, throwaway profile, BLOCKFLOW_SECRET_*, JUnit/JSON/HTML, exit codes 0/1/2. New CI job cli.
  • Suites: Suites page, bf:suites, combined JUnit/HTML/JSON (suite-report.schema.json).
  • Protocol: src/core/bridgeProtocol.ts (mirrored in packages/bridge/protocol.mjs, kept in sync by a test).

Verification (this machine)

  • npm run check: 956 unit/DOM tests
  • npm run e2e: 275 checks in 24 specs, Chromium 156, headless and headed (new m4-bridge, m4-integration: the MCP repair loop through the real server/host/extension, suite.run, Suites and Settings pages)
  • M4 specs and the CLI e2e in Brave Origin (headed)
  • npm run e2e:firefox: 44 checks, Firefox 159, now including bridge, MCP and suites
  • node tests/cli/cli.e2e.mjs on Chromium and Brave; npm run build, npm run build:firefox

Findings

  • Chromium reads host manifests from <profile>/NativeMessagingHosts. Brave does not: it reads only its default folder under $HOME. On Linux, throwaway browsers (CLI, e2e) therefore also get a throwaway HOME (isolatedHostDirs), so nothing goes in the real home folder.
  • Brave does not start headless next to a running Brave; use --headed there.

Not done / not verified

  • CI validates the guide examples (they target live sites and need secrets) and runs fixture workflows through the CLI instead of running the examples.
  • Not run: Google Chrome (not installed here), Edge, macOS, Windows (Windows registry install is unit-tested only).
  • One error code (notConnected) covers both "socket unreachable" and "extension not connected". The CLI filters secret.unknown warnings for run-time secrets by matching message text.

🤖 Generated with Claude Code

## M4: Outside access (v0.5.0) Programs on the same computer can drive BlockFlow while **Settings → Allow outside control** is on (off by default; optional `nativeMessaging` permission). Together with M3 this is **v0.5.0**. ### New - **`packages/bridge`** (`blockflow-bridge`): native-messaging host. Relays a per-user socket (token auth, NDJSON) to the extension (4-byte framing), rewrites JSON-RPC ids for concurrent clients, routes streamed notifications. `blockflow-bridge install --extension-id <id>` for Chrome, Chromium, Brave, Brave Origin, Edge, Firefox. - **Extension side**: `src/browser/bridge.ts` + `bridgeHandlers.ts`. validate, import (tagged "via bridge"), list, run (streamed steps, per-run secrets never stored), report, snapshot, stop, blobs/screenshots, suites. Settings page with status, install command and request log. - **`packages/mcp`** (`blockflow-mcp`): stdio MCP server with 9 tools, guide/block/schema resources and a write-and-repair prompt. Failure screenshots come back as images. - **`packages/cli`** (`blockflow-cli`): `blockflow run|validate`, `npm run build:automation`, throwaway profile, `BLOCKFLOW_SECRET_*`, JUnit/JSON/HTML, exit codes 0/1/2. New CI job `cli`. - **Suites**: Suites page, `bf:suites`, combined JUnit/HTML/JSON (`suite-report.schema.json`). - Protocol: `src/core/bridgeProtocol.ts` (mirrored in `packages/bridge/protocol.mjs`, kept in sync by a test). ### Verification (this machine) - `npm run check`: 956 unit/DOM tests - `npm run e2e`: 275 checks in 24 specs, Chromium 156, headless and headed (new `m4-bridge`, `m4-integration`: the MCP repair loop through the real server/host/extension, `suite.run`, Suites and Settings pages) - M4 specs and the CLI e2e in **Brave Origin** (headed) - `npm run e2e:firefox`: 44 checks, Firefox 159, now including bridge, MCP and suites - `node tests/cli/cli.e2e.mjs` on Chromium and Brave; `npm run build`, `npm run build:firefox` ### Findings - Chromium reads host manifests from `<profile>/NativeMessagingHosts`. **Brave does not**: it reads only its default folder under `$HOME`. On Linux, throwaway browsers (CLI, e2e) therefore also get a throwaway `HOME` (`isolatedHostDirs`), so nothing goes in the real home folder. - Brave does not start headless next to a running Brave; use `--headed` there. ### Not done / not verified - CI **validates** the guide examples (they target live sites and need secrets) and runs fixture workflows through the CLI instead of running the examples. - Not run: Google Chrome (not installed here), Edge, macOS, Windows (Windows registry install is unit-tested only). - One error code (`notConnected`) covers both "socket unreachable" and "extension not connected". The CLI filters `secret.unknown` warnings for run-time secrets by matching message text. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Programs on the same computer can drive BlockFlow while Settings → "Allow outside control" is on
(off by default, optional nativeMessaging permission). Protocol: JSON-RPC 2.0 in
src/core/bridgeProtocol.ts, mirrored in packages/bridge/protocol.mjs (a test keeps them in sync).

- packages/bridge (blockflow-bridge): native host relaying a per-user socket (token auth, NDJSON)
  to the extension (4-byte framing), id rewriting for concurrent clients, notification routing,
  installer for Chrome/Chromium/Brave/Brave Origin/Edge/Firefox, client library.
- Extension: src/browser/bridge.ts (port lifecycle, capped reconnect) and bridgeHandlers.ts
  (validate, import "via bridge", list, run with streamed steps and per-run secrets never stored,
  report, snapshot, stop, blobs/screenshots, suites), Settings page, bf:bridge-log.
- packages/mcp (blockflow-mcp): stdio MCP server, 9 tools, guide/blocks/schema resources, the
  write-and-repair prompt; failure screenshots as images, progress notifications.
- packages/cli (blockflow-cli): `blockflow run|validate`, npm run build:automation, throwaway
  profile, BLOCKFLOW_SECRET_*, JUnit/JSON/HTML reports, exit codes 0/1/2; CI job `cli`.
- Suites: src/core/suite.ts, combined JUnit/HTML/JSON reports (suite-report.schema.json), Suites page.
- Throwaway browsers (CLI, e2e) get the host manifest in <profile>/NativeMessagingHosts and, on Linux,
  in every default folder under a throwaway HOME: Brave reads only its default folder.
- e2e: m4-bridge, m4-integration (MCP repair loop through the real server/host/extension, suite.run,
  Suites and Settings pages), Firefox bridge + MCP + suites (throwaway HOME), CLI e2e.
- Docs: lesson 09 (native messaging, example verified in Chromium), guide "Outside access", wiki
  Bridge / MCP Server / CLI pages and updates, llms.txt, status in IMPLEMENTATION/PLAN/README/Roadmap.

Verified: npm run check (956 tests); npm run e2e (275 checks, 24 specs, Chromium 156, headless and
headed); M4 specs and CLI e2e in Brave Origin (headed); npm run e2e:firefox (44 checks, Firefox 159);
CLI e2e on Chromium; build and build:firefox. Not run: Google Chrome (not installed), Edge, macOS, Windows.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
akib merged commit 7a561af31d into main 2026-11-10 09:59:26 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
akib/blockflow!7
No description provided.