cursor-delegate-mcp 2.8.0 → 2.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -6,6 +6,16 @@ All notable changes to this project are documented here. The format follows
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [2.9.0] - 2026-11-22
10
+
11
+ ### Fixed
12
+
13
+ - A missing cursor-agent on Windows is reported as `spawn-failed` with the install hint, and
14
+ `doctor` reports `found: false`. Launched through cmd.exe it read as `agent-exit` quoting cmd's
15
+ "is not recognized" line, and `doctor` reported `found: true`.
16
+ - `cancel` with `force` returns as soon as the turn settles, in about 60 ms, instead of waiting out
17
+ its 5 s grace.
18
+
9
19
  ## [2.8.0] - 2026-11-08
10
20
 
11
21
  ### Added
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cursor-delegate-mcp",
3
- "version": "2.8.0",
3
+ "version": "2.9.0",
4
4
  "mcpName": "io.github.andreilungeanu/cursor-delegate-mcp",
5
5
  "type": "module",
6
6
  "description": "Delegate multi-file coding work from Claude Code, Codex, Copilot, or any MCP client to Cursor's CLI agent — structured results, plan mode, and changed files.",
package/src/acp-client.js CHANGED
@@ -3,7 +3,7 @@ import { EventEmitter } from "node:events";
3
3
  import { StringDecoder } from "node:string_decoder";
4
4
  import { JsonRpcPeer } from "./jsonrpc.js";
5
5
  import { createRequestRouter } from "./request-router.js";
6
- import { resolveAcpSpawn } from "./spawn.js";
6
+ import { commandExists, resolveAcpSpawn } from "./spawn.js";
7
7
  import { DETACHED, isChildAlive, treeKill } from "./proc.js";
8
8
  import { VERSION } from "./version.js";
9
9
  import { makeError } from "./errors.js";
@@ -47,6 +47,10 @@ export class AcpClient extends EventEmitter {
47
47
 
48
48
  start() {
49
49
  const { command, args, options } = this.spawnSpec;
50
+ const opts = /** @type {{ shell?: boolean, env?: NodeJS.ProcessEnv }} */ (options);
51
+ if (opts?.shell && !commandExists(command, opts.env)) {
52
+ return Promise.reject(makeError("spawn-failed", `Failed to spawn agent (${command}): not found on PATH. Install Cursor CLI and run 'cursor-agent login'.`));
53
+ }
50
54
  this._stderrChunks = [];
51
55
  this._stderrLength = 0;
52
56
  const stderrDecoder = new StringDecoder("utf8");
package/src/doctor.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import process from "node:process";
2
2
  import { spawn } from "node:child_process";
3
3
  import { AcpClient } from "./acp-client.js";
4
- import { resolveAcpSpawn } from "./spawn.js";
4
+ import { commandExists, resolveAcpSpawn } from "./spawn.js";
5
5
  import { DETACHED, treeKill } from "./proc.js";
6
6
  import { readPackageVersion } from "./version.js";
7
7
  import { describeOptions } from "./model-options.js";
@@ -40,6 +40,8 @@ export function probeAgentVersion(spawnSpec, timeoutMs = VERSION_PROBE_TIMEOUT_M
40
40
  const isJsScript = isJsLauncher(launcher);
41
41
  const execCommand = isJsScript ? process.execPath : command;
42
42
  const execArgs = isJsScript ? [launcher, "--version"] : ["--version"];
43
+ // Through a shell, a missing launcher still spawns (the shell does) and would read as found.
44
+ if (options?.shell && !isJsScript && !commandExists(launcher, options.env)) return Promise.resolve({ found: false, version: null });
43
45
  return new Promise((resolve) => {
44
46
  let settled = false;
45
47
  let stdout = "";
package/src/server.js CHANGED
@@ -323,7 +323,12 @@ export function buildServer({ runDelegate: runDelegateInjected, runDoctor: runDo
323
323
  // finally removes its handle when the turn actually settles.
324
324
  return cancelResult("cancelled", sessionId);
325
325
  }
326
- await new Promise((r) => setTimeout(r, forceGraceMs));
326
+ // Watched rather than slept through: cursor-agent can stop a cancelled turn well inside the
327
+ // grace, and the delegation's finally drops its handle the moment the turn settles.
328
+ const graceEnds = Date.now() + forceGraceMs;
329
+ while (Date.now() < graceEnds && inFlight.get(sessionId)?.size) {
330
+ await new Promise((r) => setTimeout(r, Math.min(50, Math.max(1, graceEnds - Date.now()))));
331
+ }
327
332
  const stillRunning = inFlight.get(sessionId);
328
333
  if (!stillRunning || stillRunning.size === 0) return cancelResult("cancelled", sessionId);
329
334
  // Snapshot before awaiting stop. A resume that registers during teardown must not be
package/src/spawn.js CHANGED
@@ -1,4 +1,6 @@
1
1
  import process from "node:process";
2
+ import { existsSync, statSync } from "node:fs";
3
+ import path from "node:path";
2
4
 
3
5
  export function splitArgs(raw) {
4
6
  const args = [];
@@ -33,3 +35,22 @@ export function resolveAcpSpawn() {
33
35
  const win32 = process.platform === "win32";
34
36
  return { command, args, options: { shell: win32, ...(win32 ? { env: agentEnv() } : {}) } };
35
37
  }
38
+
39
+ // Through a shell the spawn itself always succeeds: cmd.exe starts, fails to find the launcher and
40
+ // exits 1 with a localized "is not recognized" line, so Node's spawn 'error' event never fires and
41
+ // a missing cursor-agent reads as an agent crash. Resolving the launcher first is what lets that
42
+ // case be reported as not installed. Mirrors cmd's lookup: a path is checked as given, a bare name
43
+ // against each PATH entry, both with and without each PATHEXT extension. Pass the env the child
44
+ // will get: on win32 that is agentEnv(), not process.env.
45
+ export function commandExists(command, env = process.env) {
46
+ const name = String(command || "").replace(/^["']|["']$/g, "");
47
+ if (!name) return false;
48
+ const pathKey = Object.keys(env).find((k) => k.toUpperCase() === "PATH");
49
+ const extKey = Object.keys(env).find((k) => k.toUpperCase() === "PATHEXT");
50
+ const exts = ["", ...String((extKey && env[extKey]) || ".COM;.EXE;.BAT;.CMD").split(";").filter(Boolean)];
51
+ const isFile = (p) => { try { return existsSync(p) && statSync(p).isFile(); } catch { return false; } };
52
+ const hit = (base) => exts.some((ext) => isFile(base + ext) || isFile(base + ext.toLowerCase()));
53
+ if (/[\\/]/.test(name)) return hit(name);
54
+ const dirs = String((pathKey && env[pathKey]) || "").split(path.delimiter).filter(Boolean);
55
+ return dirs.some((dir) => hit(path.join(dir.replace(/^"|"$/g, ""), name)));
56
+ }