Skip to content

Ship a plugin SDK runtime bundle so packaged builtin plugins can load - #794

Merged
SawyerHood merged 1 commit into
mainfrom
bb/built-in-plugins-stopped-working-thr_iwa34dp467
Jul 18, 2026
Merged

SawyerHood merged 1 commit into
mainfrom
bb/built-in-plugins-stopped-working-thr_iwa34dp467

Conversation

@SawyerHood

Copy link
Copy Markdown
Collaborator

Problem

The published bb-app 0.0.31 boots with every builtin plugin except secrets failing — connect, automations, custom-instructions, inline-vis all report:

plugin connect failed to load: Cannot find module '@bb/plugin-sdk'

Reproduced against the real npm artifacts: 0.0.30 loads all builtins; 0.0.31 fails on both upgraded and fresh data dirs, so every packaged 0.0.31 install is affected (npm + desktop). Store officials (github, docs, memory, tasks) carry the same import and fail on install.

Root cause

Three things intersect:

  1. buildPluginServer keeps @bb/plugin-sdk external in plugin server bundles, per a comment claiming "the server's loader resolves it" — but the jiti loader had no such mapping; it relied on normal Node resolution.
  2. That was accidentally fine until now: plugins only imported SDK types, which are erased at build. Every 0.0.30 bundle has zero runtime SDK references.
  3. Plugin SDK 0.3 (Plugin SDK 0.3: consolidated API and SDK change #716) introduced defineRpcContract — the first runtime SDK export — and the plugins adopted it. 0.0.31 bundles carry a live import { defineRpcContract } from "@bb/plugin-sdk", which resolves in source checkouts (workspace node_modules) but not in the packaged app, where @bb/plugin-sdk is inlined into the server bundle and never shipped as a resolvable module.

Inlining the SDK into plugin bundles at build time is not a viable fix: third-party authors never have the SDK installed (it's not on npm — the scaffold maps the specifier to bundled .d.ts files only), so the specifier must survive to load time and be provided by the server.

Fix

  • The server build now bundles the SDK runtime (tiny: defineRpcContract + one constant, zero deps) into dist/plugin-sdk-runtime.js.
  • The plugin loader aliases @bb/plugin-sdk to that file when it exists next to the server bundle (packaged app, built checkout). Source checkouts have no such file and keep workspace resolution, so dev behavior is unchanged.
  • This fixes builtins, store officials, and third-party plugins (bundled and source-loaded) in one place, matching the original design intent.
  • Updated the stale comments in build-plugin-server.ts.

Why CI and the publish smoke missed it

Same blind spot as #735: clean checkouts always resolve the workspace SDK, so only packed artifacts fail. The publish workflow's tarball smoke boots the full stack but only checked /health — plugin load failures are warn-level. The smoke now polls bb plugin list --json until every default-enabled builtin reaches running and fails on any plugin in error, closing this regression class for good.

Validation

  • pnpm exec turbo run typecheck --filter=@bb/server --filter=@bb/plugin-build
  • pnpm exec turbo run smoke:tarball --filter=bb-app --force — packs the tarball, boots it, and all five default-enabled builtins reach running (the same assertion fails against the published 0.0.31, which reports status: "error" for four of five)
  • jiti alias behavior verified in isolation against the shipped jiti version

Needs a 0.0.32 release to reach affected users; until then rolling back to 0.0.30 is the only workaround.

🤖 Generated with Claude Code

The published bb-app 0.0.31 boots with every builtin plugin except
secrets failing: "Cannot find module '@bb/plugin-sdk'". Plugin server
bundles keep @bb/plugin-sdk external on the assumption the server's
loader resolves it, but the jiti loader had no such mapping — it only
worked in source checkouts where the workspace package resolves from
node_modules. Plugin SDK 0.3 introduced defineRpcContract, the first
runtime (non-type) SDK export, so 0.0.31 is the first release whose
bundles carry a live SDK import into the packaged app, where nothing
can resolve it. Inlining at build time is not an option: third-party
authors only ever have the SDK's bundled .d.ts (it is not on npm), so
the specifier must survive to load time.

Fix: the server build now bundles the SDK runtime into
dist/plugin-sdk-runtime.js, and the plugin loader aliases
@bb/plugin-sdk to that file when it exists next to the server bundle
(packaged app, built checkout). Source checkouts have no such file and
keep workspace resolution. This covers builtins, store officials, and
third-party plugins in one place.

The publish workflow's tarball smoke passed on 0.0.31 because plugin
load failures are warn-level and it only checked /health. It now polls
`bb plugin list --json` until every default-enabled builtin reaches
"running" and fails on any plugin in "error".

Co-Authored-By: Claude Fable 5 <[email protected]>
@SawyerHood
SawyerHood merged commit c08d394 into main Jul 18, 2026
10 checks passed
@SawyerHood
SawyerHood deleted the bb/built-in-plugins-stopped-working-thr_iwa34dp467 branch July 18, 2026 00:58
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.

1 participant