Skip to content

fix(pool): fallback to SDK runner when cursor-agent binary not found on Windows#113

Merged
Nomadcxx merged 6 commits into
Nomadcxx:mainfrom
rodrigoperaltadev:fix/windows-pool-binary-fallback
Jun 28, 2026
Merged

fix(pool): fallback to SDK runner when cursor-agent binary not found on Windows#113
Nomadcxx merged 6 commits into
Nomadcxx:mainfrom
rodrigoperaltadev:fix/windows-pool-binary-fallback

Conversation

@rodrigoperaltadev

Copy link
Copy Markdown
Contributor

Summary

When CURSOR_ACP_AGENT_POOL=1 is enabled on Windows and cursor-agent.cmd is not installed at the expected path (%LOCALAPPDATA%\cursor-agent\cursor-agent.cmd), resolveCursorAgentBinary() returns the bare name without a full path. The pool runner then calls spawn("cursor-agent.cmd", ..., { shell: true }) which fails with an opaque cmd.exe error:

cursor-acp error: ""cursor-agent.cmd"" no se reconoce como un comando interno o externo...

This PR adds:

  1. A typed BinaryNotFoundError with a descriptive message (path attempted + CURSOR_AGENT_EXECUTABLE hint)
  2. A strict resolver variant (resolveCursorAgentBinaryStrict) used exclusively by the pool — the original resolveCursorAgentBinary is untouched (15 call sites)
  3. Graceful fallback to the SDK runner when the binary is missing, with a structured warn log emitted once per pool key
  4. Correct EventEmitter-based error propagation for the dual-failure path (binary missing + SDK also fails)

The pool is opt-in (CURSOR_ACP_AGENT_POOL not set = no change). macOS/Linux behavior is unchanged.

Changes

File Change
src/utils/errors.ts Add BinaryNotFoundError with attemptedPath field
src/utils/binary.ts Add resolveCursorAgentBinaryStrict() — throws on win32 when binary missing
src/client/cursor-agent-child.ts Catch BinaryNotFoundError, log warn once, fall back to SDK runner; fix async throw in error handler
src/plugin.ts Pass sdkApiKey to pool child for SDK fallback
tests/unit/binary-strict.test.ts 9 tests covering scenarios A–E (win32 throw, found, env override, linux, darwin)
tests/unit/cursor-agent-fallback.test.ts 3 tests: warn-once, SDK factory invoked, dual-failure message
package.json Add --isolate to test scripts (required for module-mocking isolation); register new test files in CI

Testing

# All new tests (run isolated — module mocks require it)
bun test --isolate tests/unit/binary-strict.test.ts tests/unit/cursor-agent-fallback.test.ts

# Full CI unit suite
bun run test:ci:unit

485/486 pass — the single failure (Plugin entry module ESM resolution) is pre-existing on main.

@Nomadcxx

Copy link
Copy Markdown
Owner

This is really helpful man, thank you.

I'm reviewing now, just want to make sure it will not conflict with next slice of changes I have planned for the plugin. At the moment I'm thinking of just biting the bullet and developing a very small hook and rule for cursor-agent so it can steer models better.. at the moment.. converting one set of tooling to another has become a nightmare.. malformed writes here and there (mostly with Composer if not exclusively at this point).

Repository owner deleted a comment from coderabbitai Bot Jun 28, 2026
@Nomadcxx Nomadcxx merged commit 031125b into Nomadcxx:main Jun 28, 2026
3 checks passed
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