Skip to content

Make the rebuilt ACP adapter the only ACP adapter - #5775

Merged
SawyerHood merged 5 commits into
mainfrom
acp-adapter-swap
Oct 20, 2026
Merged

SawyerHood merged 5 commits into
mainfrom
acp-adapter-swap

Conversation

@SawyerHood

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

bb shipped two ACP adapters side by side: the original (packages/provider-bridge-acp, plugin provider-acp, on by default) and the rebuilt one from #5266 (packages/provider-bridge-acp-next, plugin bb--provider-acp-next, opt-in and mutually exclusive through BUNDLED_PLUGIN_REPLACEMENTS). Fixes had to be made twice, and some weren't: #5374's shutdown cleanup only reached the original bridge. Deleting the original plugin directly would have caused data loss. The orphaned-builtin cleanup (removeUnbundledBuiltins) deletes a removed built-in's settings, so every default user's customAgents would have been wiped. Users who had opted in would have been left with provider-acp disabled and no ACP providers.

What changed

  • In-place swap. The rebuilt bridge and plugin now live at packages/provider-bridge-acp and plugins/provider-acp, under the original package names and the provider-acp plugin id. Default users' plugin rows, customAgents, and threads carry over unchanged, since provider ids are the same (acp-cursor, …). The -next directories are deleted. So are the opt-in switch (BUNDLED_PLUGIN_REPLACEMENTS, the standsAside catalog filter and the paired enable/disable in setEnabled) and their tests. Hardcoded bb--provider-acp-next ids in the plugin (known-agents.ts, registry-icons.ts, usage-source.ts) are now provider-acp. Registry icon refs resolve as provider-acp/registry-*.
  • Handover for opted-in users. RETIRED_BUNDLED_PLUGINS in builtin-registry.ts declares bb--provider-acp-next → provider-acp. At startup, handOverRetiredBuiltins() runs before removeUnbundledBuiltins(). If the retired row was enabled, it copies customAgents to provider-acp and turns provider-acp on. Then it deletes the retired row's settings, secrets and schedules. It does not clear the user's disabled-provider list, which normal orphan cleanup would, because both plugins own the same provider ids.
  • Plugin SDK. @get-bb/plugin-sdk/provider-bridge/acp now exports the rebuilt bridge. The export names and type shapes are the same as before, plus experimental_registerAcpDialect. provider-bridge/acp-next stays as a deprecated alias re-exporting /acp. docs/api_to_audit.md merges the two entries. No wire change; HostDaemonAcpLaunchSpec is identical.
  • fix(acp): clean up agents before worker exit #5374 ported to the rebuilt bridge. Every agent connection (thread sessions, model discovery, session-option discovery) is tracked and removed on exit. New connections are refused once shutdown starts. stdin close, SIGTERM and SIGINT share one awaited cleanup that releases sessions and kills tracked agents. Includes shutdown.test.ts from fix(acp): clean up agents before worker exit #5374.
  • References. Updated bundled-plugins, bb-official.json, first-party-plugins.json, forkable-plugins.json, the web bundled-marketplace list, turbo.json (the -next task config moved to bb-plugin-provider-acp), the provider-literal ratchet, plugin-build tests, docs/configuration.md, and the bb-guide plugin-authoring references.

How you verified

  • pnpm exec turbo run typecheck lint for @bb/provider-bridge-acp, bb-plugin-provider-acp, @get-bb/plugin-sdk, @bb/server, @bb/web, @bb/domain, and @bb/plugin-build. All passed.
  • turbo run test passed for the bridge (505 tests, including the 6 ported shutdown cases), the SDK (376), plugin-build (211) and domain (248).
    • The plugin package had 81 of 82 passing. The one failure is native-roots.test.ts omp, an environment-only failure because /tmp/.agents exists on the machine (per .bb/skills/test-audit). It passes with TMPDIR=/var/tmp/....
  • Server: vitest run over test/services/plugins, test/services/plugin-catalog, test/system/provider-management, test/system/execution-options, test/public/public-provider-installations and test/providers/provider-registry: 65 files and 765 tests passed. That includes the new retired-bundled-plugins.test.ts, which covers three cases: an enabled retired plugin hands off settings and turns its successor on; a disabled one leaves the successor alone and keeps disabled providers; and a missing successor.
  • packages/agent-runtime runtime.acp-topology.test.ts passed.
  • node scripts/check-plugin-forks.mjs plugins/provider-acp passed (with a clean TMPDIR). The provider-literal ratchet passed. The plugin SDK npm version guard passed (0.6.56 is unpublished, so no bump).
  • Not run locally: the full server suite, tarball smoke, Windows, and a live Cursor/opencode thread on the merged build.

Follow-up: #5692 and #5055 target only the removed original bridge and need re-targeting; #5694 touches both.

AGENT GENERATED

kirbyhood and others added 5 commits October 19, 2026 20:51
The rebuilt bridge and plugin (provider-bridge-acp-next, bb--provider-acp-next)
replace the original ones in place, under the original names and the
`provider-acp` plugin id, so every user's plugin row, customAgents and threads
carry over unchanged.

- packages/provider-bridge-acp and plugins/provider-acp now hold the rebuilt
  code; the -next directories, the opt-in switch (BUNDLED_PLUGIN_REPLACEMENTS)
  and its tests are gone.
- Users who had opted in: on startup, an enabled bb--provider-acp-next row hands
  its customAgents to provider-acp and turns provider-acp back on before the
  orphaned row is removed (RETIRED_BUNDLED_PLUGINS). The user's disabled
  provider list is kept, since both plugins own the same provider ids.
- @get-bb/plugin-sdk/provider-bridge/acp now exports the rebuilt bridge (same
  members plus experimental_registerAcpDialect); /acp-next stays as a
  deprecated alias.
- Port #5374 to the rebuilt bridge: track every agent connection (sessions and
  model/option discovery), refuse new ones once shutdown starts, and run the
  same awaited cleanup on stdin close, SIGTERM and SIGINT.
- Registries, turbo, forkable plugins, docs and the plugin guide updated.
The rebuilt bridge adds extension.state deltas (provider commands and
session options) and an agent-written thread.name to every Cursor cell;
messages, tools, approvals and turn lifecycle replay identically. Rewrote
bridge→runtime.current.ndjson with `pnpm --filter @bb/provider-parity
rerecord --provider acp-cursor` and the event pins with
UPDATE_PARITY_ROW_COUNTS=1. Row counts are unchanged.
… key

- Handover now runs before reconcileBundled and works when the user had
  removed "ACP providers": an enabled retired plugin restores a removed
  successor (restoreRemovedInstalledPlugin), and its customAgents are written
  under the successor id even when no row exists yet, so nothing is lost.
  Tests cover a removed successor, a missing one, and that the real
  RETIRED_BUNDLED_PLUGINS entry is unbundled with a bundled successor.
- Restore the acp-provider skill's "Custom ACP agents" section and OpenCode
  examples (lost when the -next copy replaced it), merged with the registry
  and per-directory discovery text.
- provider-bridge/acp-next: mark each re-export @deprecated so it reaches the
  bundled d.ts, and document that the two subpaths carry separate dialect
  registries and must not be mixed.
- turbo: @bb/provider-parity#test depends on packages/provider-bridge-acp.
# Conflicts:
#	packages/provider-bridge-acp-next/src/bridge/bridge.ts
# Conflicts:
#	packages/provider-bridge-acp-next/src/bridge/bridge.test.ts
@SawyerHood
SawyerHood merged commit a6ba06b into main Oct 20, 2026
86 of 89 checks passed
@SawyerHood
SawyerHood deleted the acp-adapter-swap branch October 20, 2026 00:06
ymichael added a commit that referenced this pull request Oct 20, 2026
## What was wrong

`origin/main` CI was red for about 10 consecutive pushes (6dc2e2d
through 0eac33e). Almost every failure was in bootstrap, before any
test ran: runners got very slow downloads from GitHub releases (`curl:
(28)` after about 1.6 MB of the 67 MB pnpm binary), nodejs.org
(`better-sqlite3` node-gyp headers `ETIMEDOUT`), and the npm registry
(`pnpm install` stalled on its last package until the 5-minute step
timeout). This hit both Linux and Windows runners, and the jobs that
failed changed from run to run. It has since cleared: [the run on
6701f6b](https://github.com/get-bb/bb/actions/runs/39344853306)
passed every job without any change. #5783 already hardened those
downloads, so this PR does not touch them again.

The one failure in our own code was [a Windows `packages-other` test
timeout](https://github.com/get-bb/bb/actions/runs/39343034529/job/118369137986):
`acp bridge > keeps CLI reasoning on the resolved model variant instead
of ACP config` timed out at 6166 ms against Vitest's default 5000 ms.
The test launches the fake ACP agent several times in a row (CLI model
list, then thread start, then turn). On Windows runners it took 1262 ms
and 2659 ms in other runs, so it was flaking on load, not a code
regression. Its sibling `uses modelCli only for model selection when
reasoningCli owns effort` has the same shape and already sets `20_000`.

## What changed

Both tests in `packages/provider-bridge-acp/src/bridge/bridge.test.ts`
(moved from `provider-bridge-acp-next` by #5775) that call
`sendModelList` and then `startThread` without an explicit timeout now
use the same `20_000` budget as their sibling:
- `keeps CLI reasoning on the resolved model variant instead of ACP
config`
- `warns and launches the family id when a reasoning variant is missing`

## Verification

`pnpm exec turbo run test --filter=@bb/provider-bridge-acp`: 25 files,
505 passed, 4 skipped.

> AGENT GENERATED

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <[email protected]>
SawyerHood added a commit that referenced this pull request Oct 20, 2026
## Human comments

## What was wrong

When bb shut a provider worker down (stdin close, SIGTERM or SIGINT),
the ACP bridge released every session and killed every agent at once.
ACP agents run their tool commands in process groups of their own, so a
command running at that moment outlived bb, re-parented to init. A
normal `thread stop` doesn't leave them, because it sends
`session/cancel` first and the agent ends its own commands. #5374 added
the shutdown hooks but deliberately skipped the cancel, to stay inside
the runtime's 5 s escalation window.

Found while live-testing #5775: Ctrl-C of bb mid-turn left Cursor's and
OpenCode's `sleep 120` running under systemd.

## What changed

- `packages/provider-bridge-acp/src/bridge/bridge.ts`: shutdown stops
each session through `stopSession` with a 1.5 s cancel window
(`SHUTDOWN_CANCEL_TIMEOUT_MS`). All sessions are stopped in parallel, so
total shutdown stays well inside 5 s. Connections owned by no session
(model/option discovery, sessions still starting) are killed straight
away, and anything left is killed afterwards. Previously one
`allSettled` killed every connection in parallel with releasing
sessions, so the agent died before it could handle a cancel.
- `shutdown.test.ts`: new case per shutdown path. A fake agent starts a
detached child on `session/prompt` and kills it on `session/cancel`; the
test asserts the child is gone once the bridge exits.

## How you verified

- The three new cases (SIGTERM, SIGINT, stdin) fail before the change
with "the agent's command outlived the bridge". They pass after it, as
do the six existing reap cases.
- `pnpm exec turbo run test lint typecheck
--filter=@bb/provider-bridge-acp`: 508 passed, 4 skipped.
- Live, on an isolated `start:worktree` build with real cursor-agent
2026.08.11 and opencode 1.18.35: both threads ran `sleep 120`, then bb
got Ctrl-C (SIGINT to its process group). Before the fix, both sleeps
survived. After it, ports are free and no `sleep`, `cursor-agent acp` or
`opencode acp` process is left.

> AGENT GENERATED

Co-authored-by: Sawyer <[email protected]>
SawyerHood added a commit that referenced this pull request Oct 20, 2026
…5813)

## Human comments

## What was wrong

Changing a thread's launch-time model or reasoning level restarts the
ACP agent. For an agent that cannot load or resume a session, the
restart started a fresh conversation while the turn was accepted, so the
thread silently lost its history (#5691). #5692 fixed this in the
original bridge, which #5775 deleted; the rebuilt bridge had the same
gap in `reconcileExecutionSettings`.

## What changed

Ports #5692 by @bb-slop-cop to the bridge that replaced the original:
- Before cancelling permissions, changing policy or stopping the
process, `reconcileExecutionSettings` refuses a launch model or
reasoning change when `!session.supportsLoadSession`. The error points
to a new thread, and the original session keeps working with its
original settings.
- Restorable agents and in-session (ACP-native) model changes are
unchanged.
- #5692's four-case regression test is carried over unchanged.

## How you verified

- Without the fix, both non-restorable cases fail and both restorable
controls pass; with it, all four pass.
- `pnpm exec turbo run test lint typecheck
--filter=@bb/provider-bridge-acp`: 512 passed, 4 skipped.
- Not reproduced live: Cursor and OpenCode both support `session/load`,
so neither is affected.

Fixes #5691. Supersedes #5692.

> AGENT GENERATED

Co-authored-by: bb-slop-cop[bot] <316425484+bb-slop-cop[bot]@users.noreply.github.com>
SawyerHood added a commit that referenced this pull request Oct 20, 2026
## Human comments

## What was wrong

ACP maintenance read installed and health versions with the shared
strict SemVer reader. Calendar versions with zero-padded month/day
components, such as cursor-agent's `2026.08.11-e8db854`, were discarded
even though the executable was found (#5693). #5694 fixed both bridges;
#5775 then deleted the original, so only its rebuilt-bridge half still
applies.

## What changed

Ports the surviving half of #5694 by @bb-slop-cop, at the bridge's new
path:
- `packages/provider-bridge-acp/src/bridge/provider-maintenance.ts` now
accepts complete calendar-version tokens locally for installed and
health versions.
- Ordinary SemVer parsing, the shared parser and latest-version
availability are unchanged.

## How you verified

- Without the fix, the 3 calendar-version cases fail and the 9 controls
pass; with it, all 12 pass.
- `pnpm exec turbo run test lint typecheck
--filter=@bb/provider-bridge-acp`: 522 passed, 4 skipped.
- Live: `/api/v1/system/providers/state` now reports `installedVersion:
"2026.08.11-e8db854"` for acp-cursor.

Fixes #5693. Supersedes #5694.

> AGENT GENERATED

Co-authored-by: bb-slop-cop[bot] <316425484+bb-slop-cop[bot]@users.noreply.github.com>
SawyerHood added a commit that referenced this pull request Oct 20, 2026
## Human comments

## What was wrong

bb passed OpenCode no permission policy, so OpenCode's own config
decided. With the default config, OpenCode ran shell commands without
asking even when the thread was in `accept-edits`, while Cursor asked
for the same commands. Found while live-testing #5775.

## What changed

- The bridge launches OpenCode-dialect agents with
`OPENCODE_PERMISSION`, which OpenCode merges over the `permission` keys
of its config:
- **`accept-edits`:** `edit` is allowed; `bash`, `webfetch` and
`external_directory` ask. OpenCode's ACP permission requests become bb
approvals.
  - **`full`:** all four are allowed.
- A permission-mode change restarts the OpenCode session with the new
policy, and OpenCode restores the conversation. Permission CLI flags
already work this way for other agents.
- Other dialects get no OpenCode policy.
- `dialectLaunchEnv` now also holds the existing `OPENCODE_CLIENT` /
`OPENCODE_ENABLE_QUESTION_TOOL` values.
- The acp-provider skill documents the behaviour.

## How you verified

- New bridge tests:
- an OpenCode session gets the `full` policy, then the `accept-edits`
policy after a mode change, and the session is replaced with
`contextLost: false`;
  - a generic ACP agent gets no policy.
- `pnpm exec turbo run test typecheck --filter=@bb/provider-bridge-acp`:
524 passed, 4 skipped.
- Live with opencode 1.18.35 in `accept-edits`:
  - a file write went through without asking;
- `touch oc-shell.flag` waited as a pending bb approval and ran only
after `bb thread interactions approve`;
- after switching the thread to `full`, a shell command ran without
asking.

> AGENT GENERATED
SawyerHood added a commit that referenced this pull request Oct 20, 2026
…vers (#5817)

## Human comments

## What was wrong

Three issues found while live-testing #5775 with Cursor and OpenCode.

- **New files showed as edits.**
- Cursor marks a created file with `oldText: "-- /dev/null"` and a `++
b/<path>` header line in `newText`; bb took both as file content.
- OpenCode's write tool sends no diff at all, and sends its tool events
only after the write.
- **A command cancelled by a steer was recorded as `completed`.** Cursor
never closes a tool call on cancel, so the bridge closed it as
`completed` when the turn later finished.
- **Retiring `bb--provider-acp-next` (#5775) left two things behind.**
Its registry cache stayed in plugin storage, and links to
`/settings/plugins/bb--provider-acp-next` pointed nowhere.

## What changed

- **File change kinds:**
- `tool-classification.ts` reads the `/dev/null` diff form as a new file
and drops the header.
- For an edit with no diff, the translator asks the bridge whether each
named path was created this turn: the file's creation time
(`birthtimeMs`) after the turn started, and not touched earlier in the
turn. If so, it reports `add`. Where the filesystem has no creation
time, the result is unknown and stays `update`.
- **Steered-away commands:**
- When a cancelled prompt hands over to a queued steer, the bridge emits
`acp/prompt/interrupted`, and the translator closes that prompt's
still-open tool calls as `interrupted`.
- The `acp-cursor/steer` parity lane is rerecorded. Its only change is
that one command now closes `interrupted` when the steer happens,
instead of `completed` at turn end.
- **Retired plugin leftovers:**
- The retired → successor map moves to `@bb/domain`
(`RETIRED_PLUGIN_SUCCESSORS`), shared by server and app.
- The handover now also deletes the retired plugin's key-value storage
(`deleteAllPluginKvValues`).
- `useRedirectRetiredPluginPaths` (mounted in `AppLayout`) rewrites any
path segment naming a retired plugin to its successor.

## How you verified

- New tests:
- **translation:** the Cursor `/dev/null` form, an update diff, a
diff-less write with created true/false/unknown, and a file written
twice in a turn (`add` then `update`);
- **bridge:** a command left open by a steered-away prompt closes
`interrupted` (it was `completed` before the change);
  - **server:** the handover deletes retired storage;
  - **domain:** path rewriting;
  - **app:** the redirect hook, in jsdom.
- Turbo runs:
  - `@bb/provider-bridge-acp`: 531 passed, 4 skipped;
  - `@bb/provider-parity`: 59 passed;
  - `@bb/domain`: 256 passed;
  - `@bb/db`: 632 passed;
  - typecheck and lint for `@bb/server` and `@bb/app`;
  - server plugin tests: 516 passed.
- Live, on an isolated build with real agents:
- Cursor's new file is `add` with diff `--- /dev/null / +++ b/… / +hello
cursor`;
- OpenCode's new file is `add` and a later edit of it in the same turn
is `update`;
  - steering Cursor off `sleep 40` records the command as `interrupted`.

> AGENT GENERATED
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants