Repository navigation
Run the ACP bb-bridge MCP server from the bridge module, not the bootstrap - #1932
Conversation
…strap Since #1640 the provider bridge runs under the provider-bridge worker bootstrap, so process.argv[1] inside the bridge names the bootstrap. The ACP bridge used argv[1] as the entry for the bb-bridge MCP server child, which exited with the bootstrap usage error and made ACP agents reject session/new with 'bb-bridge: Transport closed' (shown as 'Internal error'). Use the bridge's own import.meta.url as the MCP server entry, carry error.data.details into rejected agent errors, and add a test that runs the bridge under the bootstrap and executes the advertised MCP command. Fixes #1918 Co-Authored-By: Claude <[email protected]>
|
🚨 SLOP COP 🚨 · I am SlopCop. I am reviewing this change for security, code quality, performance, architecture, and test coverage. I will post one final review after the parallel checks finish. |
There was a problem hiding this comment.
🚨 SLOP COP 🚨 · review
Plain-English summary
This change fixes how BB starts its tool server for ACP agents. BB now runs the bridge module instead of the worker bootstrap. ACP sessions no longer fail because the tool transport closes during setup. The change also adds useful agent error details and a process-level regression test.
Review result
I found no blocking defects. I found no concrete security, correctness, performance, architecture, or duplicate-code defect.
- Security: The change adds no new trust boundary. The ACP child already controlled the existing error message path.
- Quality:
import.meta.urlselectsbridge.tsin source and builthost.jsin a package. - Architecture: The repository has no duplicate production resolver for this MCP entry. A daemon protocol increase is not necessary.
- Performance: The new error formatting runs only after an agent error. The repaired process path adds no hot-path cost.
- Refactor check: The new test repeats small process-test helpers. A shared helper has little value for one test.
Validation
- All 165 ACP package tests passed through Turbo.
- The ACP package type check passed through Turbo.
git diff --checkpassed.- All GitHub checks passed.
- The built
host.jsreturned a valid MCPinitializeresponse. - The current dev app loaded through Dev Browser.
- A real OpenCode ACP thread completed and returned
ok. This test used the repaired provider bridge path.
The repository has no browser route for the MCP transport itself. The process test and live ACP thread give direct coverage.
As optional hardening, a later change can limit ACP error text and use a bounded MCP input reader. Those concerns predate this repair and do not block it.
The test landed on main reading item/agentMessage/delta from the deleted thread/event notifications; the bridge behavior it verifies (the MCP server command advertised from the bridge module under the bootstrap) already worked — only the test's assistant-text observer was stale. Co-Authored-By: Claude Fable 5 <[email protected]>
The test landed on main reading item/agentMessage/delta from the deleted thread/event notifications; the bridge behavior it verifies (the MCP server command advertised from the bridge module under the bootstrap) already worked — only the test's assistant-text observer was stale. Co-Authored-By: Claude Fable 5 <[email protected]>
The test landed on main reading item/agentMessage/delta from the deleted thread/event notifications; the bridge behavior it verifies (the MCP server command advertised from the bridge module under the bootstrap) already worked — only the test's assistant-text observer was stale. Co-Authored-By: Claude Fable 5 <[email protected]>
## What was wrong Cursor ACP applies its project MCP approval gate to client-supplied session MCP servers. ACP has no client permission round trip for that gate, so Cursor rejected the valid `bb-bridge` stdio config before spawning it. The same config-advertisement path exists before and after #1834, and the #1932 bootstrap fix remains valid; the missing Cursor approval was the separate root cause. ## What changed The ACP bridge now installs the exact bb-owned session MCP fingerprint in the Cursor project approval store before `session/new`, `session/load`, or `session/fork`. It limits the workaround to `cursor-agent` plus the `bb-bridge` config, preserves existing approvals, serializes concurrent updates, and removes approvals that bb installed when the session ends. The MCP child also reports `initialize` back to the bridge, giving host-side diagnostics for both config construction and successful child startup. No server/host-daemon wire contract changed, so `HOST_DAEMON_PROTOCOL_VERSION` does not need a bump. ## How you verified Added fingerprint, approval-file preservation/concurrency, session-lifecycle, and MCP initialize diagnostic regressions. These expose the missing approval before the fix and pass afterward. - `pnpm exec turbo run test --filter=bb-plugin-provider-acp --force` — 175 passed - `pnpm exec turbo run typecheck --filter=bb-plugin-provider-acp` - Isolated manual run against Cursor CLI `2026.06.19-20-24-33-653a7fb`, with approval installed after ACP `initialize` and before `session/new`; Cursor spawned and initialized the MCP server Fixes #2018 > AGENT GENERATED: by GPT-5
What was wrong
Since #1640 the agent runtime starts every provider bridge through the provider-bridge bootstrap (
node <bridge-worker-entry> <bridge module> <pluginId> <dataDir>), so inside the ACP bridgeprocess.argv[1]is the bootstrap, not the bridge module.resolveBridgeProcessArgsForMcpServer()inplugins/provider-acp/src/bridge/bridge.tsstill usedprocess.argv[1]as the entry for thebb-bridgeMCP server child. The child ran the bootstrap with--mcp-stdio, printedprovider bridge bootstrap usage: ...and exited 1. ACP agents (omp, Cursor, Grok, Pi ACP) then rejectedsession/newwithbb-bridge: Transport closed, and bb showed onlyInternal errorbecauseagent-connection.tsdroppederror.data. Root-cause report: https://get-bb.github.io/reports/issues/1918.htmlWhat changed
plugins/provider-acp/src/bridge/bridge.ts: the MCP server entry is nowfileURLToPath(import.meta.url)(the bridge's own module/artifact in every launch mode), withprocess.execArgvand--mcp-stdioas before.plugins/provider-acp/src/bridge/agent-connection.ts: newformatAgentError()appendserror.data.details(or a string / JSONdata) to the rejectedError, so agent-side failures such asInternal error: bb-bridge: Transport closedare diagnosable from bb logs.src/bridge/mcp-server-entry.test.ts: spawns the bridge under the real bootstrap, reads the advertisedbb-bridgeMCP server config from the fake ACP agent, and executes that command; it must answer MCPinitialize. Existing tests only hit the TCP side channel and import the bridge in-process (argv[1] is vitest there), so they did not catch this.src/bridge/agent-connection.test.tsforformatAgentError().No wire change between server and host daemon, so no
HOST_DAEMON_PROTOCOL_VERSIONbump.How you verified
mcp-server-entry.test.tsfails onmain(a76bab0):After the fix:
pnpm exec turbo run test typecheck --filter=bb-plugin-provider-acp --force:Live check on a dev instance from this branch (
scripts/bb-dev-app current) withacp-grok:bb thread spawn --provider acp-grokreachesidle(before the fix this failed at thread start withInternal error), and the agent reportsFOUND bb-bridge/update_environment_directorywith the tool description when asked to search its MCP tools.Fixes #1918