MCP tool responses (e.g. Serena via mcpm) can deliver output.output as
undefined or a non-string at runtime despite the TypeScript interface
declaring it as string. Add the same typeof guard already used in
tool-output-truncator and other hooks, preventing a TypeError crash.
Fixes#3800
Root cause: bun build --target bun inlines top-level
var { spawn } = globalThis.Bun;
for every file that contains 'import { spawn } from "bun"'. On Node/Electron
where globalThis.Bun is undefined, this crashes with
Cannot destructure property 'spawn' of 'globalThis.Bun' as it is undefined.
26 source files had this import; the bundled output had 25 top-level destructures.
Fix:
- Add src/shared/bun-spawn-shim.ts: a thin wrapper that
- delegates to Bun.spawn/spawnSync when globalThis.Bun is present (real Bun)
- falls back to static ESM imports of node:child_process otherwise
- uses static 'import { spawn } from "node:child_process"' so Bun bundler
does NOT emit any globalThis.Bun destructures for this module
- Replace all 26 'from "bun"' spawn/spawnSync imports with relative paths to shim
- Replace 4 direct Bun.spawn() call sites with shim's spawn()
- Remove src/electron-compat.ts and script/prepend-electron-shim.ts (no longer needed)
- Update src/electron-compat.test.ts to assert 0 top-level globalThis.Bun destructures
Verification: grep -c '} = globalThis.Bun;' dist/index.js → 0 (was 25)
All 5921 tests pass (1 pre-existing timeout failure unrelated to this change).
Fixes#3797
On Node/Electron, globalThis.Bun is undefined. The Bun bundler emits top-level
var { spawn } = globalThis.Bun;
destructures from its internal modules, causing 'Cannot destructure property
of undefined' before any plugin hook is reached (25 occurrences in dist/index.js).
Fix:
- Add src/electron-compat.ts: a side-effect module that populates globalThis.Bun
with node:child_process-backed spawn/spawnSync shims when Bun is unavailable
- Add script/prepend-electron-shim.ts: post-build script that prepends the shim
code to dist/index.js, guaranteeing it runs BEFORE the top-level destructures
(Bun bundler does not preserve import side-effect evaluation order reliably)
- Update build script to run prepend-shim after bundling
- Add src/electron-compat.test.ts verifying shim position in dist
The shim only activates when globalThis.Bun is absent (real Bun runtime is
unaffected). Spawn-dependent features degrade gracefully at call time.
Fixes#3797 (follow-up to #3795/#3796)
Top-level `import { Database } from 'bun:sqlite'` caused Node/Electron's
ESM loader to reject the plugin at module-graph resolution time because
the `bun:` protocol is not in Node's allowed scheme list. This prevented
the OpenCode desktop app from loading the plugin at all.
Fix:
- Remove top-level static import of `bun:sqlite`
- Use a lazy importer (`_bunSqliteImporter`) that calls
`import('bun:sqlite').catch(() => null)` at runtime
- If the import returns null (non-Bun environment), log a warning and
return early — no DB override attempted, plugin loads normally
- Expose `__setBunSqliteImporterForTesting` / `__resetBunSqliteImporterForTesting`
test seams to verify the Node/Electron fallback path
Closes#3795
scheduleForcedExit() sets process.exitCode which taints the bun test runner's
own exit code for the entire suite. This caused CI to fail even though all
tests passed individually.
Fix:
- Add __disableScheduledForcedExitForTesting / __enableScheduledForcedExitForTesting
seams to skip scheduleForcedExit() during tests
- beforeEach disables forced exit; afterEach re-enables
- The 'fallback exit timer' test explicitly re-enables to verify setTimeout/clearTimeout
- Remove process.exitCode and exitSpy assertions that required forced exit to be active
(shutdown call counts are sufficient to verify behavior)
The test file modifies process.exitCode and emits process signals which can
leak into bun test's exit code. Add:
1. mock.module() sentinel to route to isolated batch (following abort-with-timeout.test.ts pattern)
2. Global afterAll() hook that resets process.exitCode = 0 before test runner checks it
3. Remove direct checks of process.exitCode in assertions - only check that process.exit() was called with the right code via spy
This ensures bun test exits with code 0 even after tests verify process.exit behavior.
Fixes#3792
Property 'parentSessionID' does not exist on type 'LaunchInput' / 'BackgroundTask'.
The correct casing is 'parentSessionId' (camelCase with lowercase 'd').
Fixes CI build failure on dev branch.
The global test-setup.ts (preloaded via bunfig.toml) already snapshots
process.env in beforeEach and restores it in afterEach for every test.
Per-file env tracking is duplicate work and creates four different
patterns for the same problem.
Affected files:
- src/shared/claude-config-dir.test.ts (beforeEach/afterEach pair)
- src/shared/plugin-command-discovery.test.ts (ENV_KEYS + envSnapshot)
- src/features/claude-code-agent-loader/loader.test.ts (try/finally)
- src/features/skill-mcp-manager/connection-env-vars.test.ts (ORIGINAL_ENV)
Atlas continuation only treated running background tasks as active work. When a delegated subagent had been launched but was still waiting for session creation, the task remained pending and Atlas could inject another continuation too early.
Treat pending tasks as active background work in the continuation injector and add regression coverage for the pending-session-creation race so delegated work is allowed to acquire a session before Atlas resumes the plan.
Tests: bun test src/hooks/atlas/boulder-continuation-injector.test.ts src/hooks/atlas/index.test.ts; bun run typecheck
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)
Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Rename BackgroundTask and attempt ID fields to camelCase across background-agent consumers while moving BackgroundManager construction to a single config object.
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)
Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>