Commit Graph

4270 Commits

Author SHA1 Message Date
Paolo Notaro d800fec6b1 fix(runtime-fallback): prevent infinite loop when fallback model equals current model 2026-05-05 21:01:50 +02:00
YeonGyu-Kim bcaae1037d fix(directory-agents-injector): guard against non-string output.output
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
2026-05-06 03:49:37 +09:00
YeonGyu-Kim e9d7dca604 fix(session-notification): tolerate shell promises without nothrow 2026-05-05 23:06:01 +09:00
YeonGyu-Kim f8defe2588 fix(node-runtime-compat): harden Bun spawn shim 2026-05-05 22:59:43 +09:00
YeonGyu-Kim 3ddc757b15 fix(bun-spawn-shim): eliminate globalThis.Bun top-level destructures for Electron/Node compat
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
2026-05-05 22:41:45 +09:00
YeonGyu-Kim f178ea3207 fix(electron-compat): prepend globalThis.Bun shim to prevent Electron/Node crash
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)
2026-05-05 22:17:06 +09:00
YeonGyu-Kim aae619c58f fix(ultrawork): align lazy sqlite fallback test
Keep bun:sqlite loading lazy and verify the unavailable-runtime fallback without a test-only importer seam.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-05-05 19:09:31 +09:00
YeonGyu-Kim c537e840ee fix(ultrawork): handle bun:sqlite import failure directly
Use the lazy bun:sqlite importer inside the deferred override microtask and keep the unavailable-runtime test on the rejected-import path.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-05-05 19:09:31 +09:00
YeonGyu-Kim f4a225b6cd fix(ultrawork): lazy-load bun:sqlite to support Node/Electron runtime
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
2026-05-05 19:09:31 +09:00
YeonGyu-Kim 32fab88d68 fix(process-cleanup): add test seam to prevent process.exitCode contaminating bun runner
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)
2026-05-05 19:04:40 +09:00
YeonGyu-Kim ad535cd29d fix(process-cleanup): isolate test and avoid checking process.exitCode directly
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
2026-05-05 05:15:59 +09:00
YeonGyu-Kim 45452a039c Merge pull request #3731 from yizhifengye/fix/process-cleanup-infinite-loop-epipe
fix(background-agent): detach error listener before running body to s…
2026-05-05 04:24:01 +09:00
YeonGyu-Kim fd62f5b072 Merge pull request #3639 from auyua9/fix/fatal-cleanup-exit
fix(background): exit after fatal cleanup
2026-05-05 04:15:50 +09:00
YeonGyu-Kim ef7ac52286 Merge pull request #3771 from tw-yshuang/fix/atlas-pending-continuation-race
fix(atlas): block continuation while delegated tasks are pending
2026-05-05 04:15:46 +09:00
YeonGyu-Kim 6323fa8ef9 fix(background-agent): fix parentSessionID -> parentSessionId typo causing TS build failure
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.
2026-05-05 03:53:44 +09:00
YeonGyu-Kim e699f3388d Merge pull request #3455 from CHLK/fix/cli-run-premature-exit-with-background-tasks
fix(cli-run): prevent premature exit when background tasks are active
2026-05-04 23:58:34 +09:00
YeonGyu-Kim 9c8aab9f22 Merge pull request #3420 from grandmaster451/fix-version-comparison
fix(auto-update): use semantic version comparison instead of string e…
2026-05-04 23:58:26 +09:00
YeonGyu-Kim 8c8522ee72 Merge pull request #3415 from lightrabbit/fix/skill-mcp-stdio-cwd
fix(skill-mcp): pass workspace directory as cwd to stdio MCP processes
2026-05-04 23:58:22 +09:00
YeonGyu-Kim 7b28298b2a Merge pull request #3414 from garnetlyx/fix/sandbox-cache-availability-check
fix: use in-process flag instead of existsSync for cache availability
2026-05-04 23:58:19 +09:00
Matan Kushner b98d474812 test: remove redundant local env restoration
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)
2026-05-04 20:11:50 +09:00
YeonGyu-Kim fa255e14c6 test(create-managers): align openclaw mock with refactored BackgroundManager config object
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-05-04 16:30:23 +09:00
YeonGyu-Kim dd4166cb57 test(session-notification): provide chainable Bun shell mock for sender tests
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-05-04 16:30:23 +09:00
YeonGyu-Kim ce5bcd1d9b test(call-omo-agent): align background task fixtures with normalized field names
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-05-04 16:30:23 +09:00
YeonGyu-Kim 63170f4dd8 test(lsp): use named tmpdir import to avoid node:os mock leak
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-05-04 16:30:23 +09:00
YeonGyu-Kim 4e763fb0cb test(team-mode/team-worktree): use named tmpdir import to avoid mock leak
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-05-04 16:30:23 +09:00
YeonGyu-Kim 700ba1e541 test(unstable-agent-babysitter): align task fixture with sessionId field
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-05-04 16:30:06 +09:00
YeonGyu-Kim 7fefb59a06 test(stop-continuation-guard): rename parentSessionId/parentMessageId in task fixture
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-05-04 16:30:06 +09:00
YeonGyu-Kim 65c1b50946 test(background-agent): align manager test fixtures with normalized field names
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-05-04 16:30:06 +09:00
YeonGyu-Kim 3ae9f5f104 fix(background-agent): prevent false task completion on status API outage
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-05-04 16:30:06 +09:00
YeonGyu-Kim 4f32ecd7de test(deps): avoid Bun-specific path metadata
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-05-04 02:10:57 +09:00
YeonGyu-Kim 1045354776 test(deps): cover picomatch security floor
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-05-04 02:09:45 +09:00
YeonGyu-Kim 1a881b374e test(agents): cover OpenCode Agent.list sort with runtime-name prefixes
🤖 Generated with assistance of [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
2026-05-04 01:44:07 +09:00
YeonGyu-Kim 81d36ae749 test(cli-installer): cover telemetry shutdown failure isolation
🤖 Generated with assistance of [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
2026-05-04 01:44:04 +09:00
YeonGyu-Kim e395eadfa4 feat(ralph-loop): add loop session recovery state tracker
🤖 Generated with assistance of [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
2026-05-04 01:44:01 +09:00
YeonGyu-Kim 6a8bdcaa25 feat(team-mode): add resolveCallerTeamLead helper
🤖 Generated with assistance of [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
2026-05-04 01:43:55 +09:00
tw-yshuang 56e4044927 fix(atlas): block continuation while delegated tasks are pending
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>
2026-05-03 17:24:46 +08:00
YeonGyu-Kim da251c9b30 refactor(background-agent): normalize task ID field naming
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>
2026-05-02 03:01:03 +09:00
YeonGyu-Kim 92dab9285c refactor(telemetry): narrow PostHog client and mark omo_daily_active anonymous 2026-05-02 00:11:01 +09:00
YeonGyu-Kim b8a5f27dee refactor(telemetry): drop plugin_loaded capture from plugin entry 2026-05-02 00:10:59 +09:00
YeonGyu-Kim 14568db278 refactor(telemetry): drop run lifecycle events and captureException from runner 2026-05-02 00:10:57 +09:00
YeonGyu-Kim be2eee6306 refactor(telemetry): drop install events from cli-installer 2026-05-02 00:10:54 +09:00
YeonGyu-Kim bae62ab582 fix(agents): allow Momus and Metis delegation
Keep Momus and Metis read-only for file edits while allowing task-based invocation for planning review workflows.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-05-01 19:27:25 +09:00
YeonGyu-Kim b88e32cbdd Merge pull request #3678 from MoerAI/fix/spawn-windows-hide-env
fix(bun-install): forward process.env so child bun install inherits proxy settings (fixes #3528)
2026-05-01 19:18:46 +09:00
YeonGyu-Kim c7da46ea5a Merge pull request #3679 from MoerAI/fix/file-uri-rejection-explanation
fix(resolve-file-uri): explain project boundary restriction in rejection warning (fixes #3554)
2026-05-01 19:18:43 +09:00
YeonGyu-Kim 6f79968aeb Merge pull request #3701 from MoerAI/fix/context-window-monitor-pct-clamp
fix(context-window-monitor): clamp displayed context status percentages so the directive stays trustworthy (fixes #3655)
2026-05-01 19:18:40 +09:00
YeonGyu-Kim bd41344c26 Merge pull request #3708 from mrosnerr/feat/cmux-notification-provider
feat(notification): add cmux as notification provider
2026-05-01 19:18:37 +09:00
YeonGyu-Kim 586bb3f551 Merge pull request #3711 from mrosnerr/fix/notification-scheduler-platform
fix(notification): session-idle notifications never fire due to stale platform
2026-05-01 19:18:34 +09:00
YeonGyu-Kim 793f24a62f Merge pull request #3715 from mrosnerr/fix/messages-transform-hook-isolation
fix(messages-transform): isolate hook failures so tool-pair-validator always runs
2026-05-01 19:18:31 +09:00
YeonGyu-Kim c3beb370a5 fix(doctor): detect gh when Bun.which misses it
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-05-01 18:56:09 +09:00
YeonGyu-Kim 9c4bcebb22 fix(plugin): normalize bare schema refs
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-05-01 18:55:57 +09:00