Problem
The plugin fails to load in OpenCode Desktop (Electron/Node.js runtime) with this error:
error=Only URLs with a scheme in: file, data, node, and electron are supported by the default ESM loader. Received protocol 'bun:' failed to load plugin
The root cause is line in dist/index.js:
import { Database } from "bun:sqlite";
The bundle has // @bun at the top, meaning it was compiled with Bun's bundler which inlines bun: protocol imports. These are Bun-specific and are rejected by Node.js/Electron's ESM loader.
Why the CLI works but Desktop doesn't
- OpenCode CLI (
opencode terminal command) ships as a native Bun binary (opencode-windows-x64/bin/opencode.exe). It runs on Bun, so bun:sqlite works fine.
- OpenCode Desktop is an Electron app. Electron uses Node.js as its JS runtime, which does not support
bun: protocol URLs.
Impact
- Every startup of OpenCode Desktop triggers repeated plugin load failures
- The retry loop on each worktree causes the app to freeze on startup
- Ensemble tools (
team_create, team_spawn, etc.) are completely non-functional in Desktop
Affected versions
Checked all published versions (0.1.0 → 0.14.1) — all have bun:sqlite in the bundle.
Fix
Rebuild the bundle targeting Node.js/Electron instead of Bun. Replace bun:sqlite with a Node-compatible alternative:
better-sqlite3 drop-in replacement, same synchronous API (db.exec(), db.query().get(), etc.)
node:sqlite built-in since Node 22, but API differs slightly and it's still experimental
better-sqlite3 is the safest drop-in with no API changes needed in src/db.ts.
Problem
The plugin fails to load in OpenCode Desktop (Electron/Node.js runtime) with this error:
The root cause is line in
dist/index.js:The bundle has
// @bunat the top, meaning it was compiled with Bun's bundler which inlinesbun:protocol imports. These are Bun-specific and are rejected by Node.js/Electron's ESM loader.Why the CLI works but Desktop doesn't
opencodeterminal command) ships as a native Bun binary (opencode-windows-x64/bin/opencode.exe). It runs on Bun, sobun:sqliteworks fine.bun:protocol URLs.Impact
team_create,team_spawn, etc.) are completely non-functional in DesktopAffected versions
Checked all published versions (
0.1.0→0.14.1) — all havebun:sqlitein the bundle.Fix
Rebuild the bundle targeting Node.js/Electron instead of Bun. Replace
bun:sqlitewith a Node-compatible alternative:better-sqlite3drop-in replacement, same synchronous API (db.exec(),db.query().get(), etc.)node:sqlitebuilt-in since Node 22, but API differs slightly and it's still experimentalbetter-sqlite3is the safest drop-in with no API changes needed insrc/db.ts.