cursor-delegate-mcp 2.9.0 → 2.10.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 +37 -0
- package/package.json +1 -1
- package/src/acp-client.js +24 -30
- package/src/acp-enums.js +3 -8
- package/src/delegate.js +93 -124
- package/src/doctor.js +74 -29
- package/src/errors.js +2 -4
- package/src/jsonrpc.js +14 -26
- package/src/model-options.js +9 -14
- package/src/proc.js +8 -13
- package/src/request-router.js +4 -11
- package/src/server.js +78 -103
- package/src/session-supervisor.js +4 -6
- package/src/spawn.js +112 -26
- package/src/turn-state.js +14 -22
- package/src/version.js +2 -4
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,43 @@ All notable changes to this project are documented here. The format follows
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [2.10.0] - 2026-11-22
|
|
10
|
+
|
|
11
|
+
### Changed
|
|
12
|
+
|
|
13
|
+
- On Windows, `cursor-agent` starts without cmd.exe. `cursor-agent.cmd` (and its copy `agent.cmd`)
|
|
14
|
+
only forwards to `cursor-agent.ps1`, which the bridge now runs through `powershell.exe -File`, so
|
|
15
|
+
`!`, `%VAR%`, `^` and quotes in `ACP_AGENT_ARGS` reach the agent unchanged.
|
|
16
|
+
|
|
17
|
+
### Fixed
|
|
18
|
+
|
|
19
|
+
- Progress lines and stall errors name the command or path of the last tool call, which
|
|
20
|
+
cursor-agent sends on the `tool_call_update`, capped at 200 characters.
|
|
21
|
+
- Windows launch:
|
|
22
|
+
- A launcher path or `ACP_AGENT_ARGS` argument with spaces arrives whole, including a quoted
|
|
23
|
+
section inside an argument (`--log-file="C:\a b\x.log"`).
|
|
24
|
+
- A `.ps1` `ACP_AGENT_COMMAND` runs through PowerShell instead of opening with its file
|
|
25
|
+
association.
|
|
26
|
+
- A Store app execution alias on `PATH`, such as `pwsh`, is found.
|
|
27
|
+
- Node 24 prints no DEP0190 deprecation warning.
|
|
28
|
+
- `doctor` reports the agent's version for a launcher prefix such as `node index.js acp`, and for a
|
|
29
|
+
`.ps1` launcher.
|
|
30
|
+
- `doctor` stops its version probe and handshake when the host aborts and returns once they have
|
|
31
|
+
exited. A server shutdown stops them too.
|
|
32
|
+
- `cancel`:
|
|
33
|
+
- a cancel during session setup keeps the prompt from being sent;
|
|
34
|
+
- `force` kills only the turns running when it arrived, not a resume that started during its
|
|
35
|
+
grace;
|
|
36
|
+
- a blank `sessionId` is rejected, and surrounding whitespace is trimmed.
|
|
37
|
+
- On SIGHUP (a closed terminal) the server stops its agents before exiting. The stdin close that
|
|
38
|
+
follows a hangup does not cut that wait short.
|
|
39
|
+
- The SessionStart hook sends npm's output to stderr, keeping the install summary out of the
|
|
40
|
+
session context.
|
|
41
|
+
|
|
42
|
+
### Internal
|
|
43
|
+
|
|
44
|
+
- Lockfile: hono 4.13.18.
|
|
45
|
+
|
|
9
46
|
## [2.9.0] - 2026-11-22
|
|
10
47
|
|
|
11
48
|
### Fixed
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cursor-delegate-mcp",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.10.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,14 +3,14 @@ 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 { commandExists, resolveAcpSpawn } from "./spawn.js";
|
|
6
|
+
import { commandExists, resolveAcpSpawn, spawnArgv } 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";
|
|
10
10
|
|
|
11
11
|
const STDERR_CAP = 64 * 1024;
|
|
12
|
-
// How long stop() waits for the
|
|
13
|
-
//
|
|
12
|
+
// How long stop() waits for the exit after the kill. SIGKILL and taskkill /F land in milliseconds,
|
|
13
|
+
// so this elapses only when the kill failed.
|
|
14
14
|
const STOP_EXIT_TIMEOUT_MS = 2000;
|
|
15
15
|
|
|
16
16
|
export class AcpClient extends EventEmitter {
|
|
@@ -34,12 +34,9 @@ export class AcpClient extends EventEmitter {
|
|
|
34
34
|
this._stopping = null;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
// stderr
|
|
38
|
-
//
|
|
39
|
-
//
|
|
40
|
-
// rebuilding a 64KB string per chunk was the whole cost of a noisy agent. A StringDecoder
|
|
41
|
-
// holds partial UTF-8 across chunk boundaries, so a multi-byte character split by the pipe
|
|
42
|
-
// does not land in the error message as a replacement char.
|
|
37
|
+
// The stderr tail an exit error quotes. Kept as chunks and joined on read, so a noisy agent costs
|
|
38
|
+
// a push per chunk; a StringDecoder keeps a multi-byte character split across reads intact.
|
|
39
|
+
// stderr is not ACP activity, so it does not feed the supervisor.
|
|
43
40
|
get stderrBuffer() {
|
|
44
41
|
const joined = this._stderrChunks.join("");
|
|
45
42
|
return joined.length > STDERR_CAP ? joined.slice(-STDERR_CAP) : joined;
|
|
@@ -55,7 +52,8 @@ export class AcpClient extends EventEmitter {
|
|
|
55
52
|
this._stderrLength = 0;
|
|
56
53
|
const stderrDecoder = new StringDecoder("utf8");
|
|
57
54
|
this._exitEmitted = false;
|
|
58
|
-
|
|
55
|
+
const argv = spawnArgv(command, args, opts);
|
|
56
|
+
this.child = spawn(argv.command, argv.args, { ...argv.options, detached: DETACHED, stdio: ["pipe", "pipe", "pipe"] });
|
|
59
57
|
this.child.stderr.on("data", (chunk) => {
|
|
60
58
|
const text = stderrDecoder.write(chunk);
|
|
61
59
|
if (text) {
|
|
@@ -66,9 +64,8 @@ export class AcpClient extends EventEmitter {
|
|
|
66
64
|
while (this._stderrChunks.length > 1 && this._stderrLength - this._stderrChunks[0].length >= STDERR_CAP) {
|
|
67
65
|
this._stderrLength -= this._stderrChunks.shift().length;
|
|
68
66
|
}
|
|
69
|
-
//
|
|
70
|
-
//
|
|
71
|
-
// grow with the flood; the public tail is still exactly one cap on read.
|
|
67
|
+
// A single read larger than the cap (seen on GitHub Windows runners) is sliced too, so
|
|
68
|
+
// retained memory stays bounded.
|
|
72
69
|
const overflow = this._stderrLength - STDERR_CAP;
|
|
73
70
|
if (overflow > 0) {
|
|
74
71
|
this._stderrChunks[0] = this._stderrChunks[0].slice(overflow);
|
|
@@ -77,9 +74,8 @@ export class AcpClient extends EventEmitter {
|
|
|
77
74
|
}
|
|
78
75
|
});
|
|
79
76
|
this.child.stderr.on("error", () => {});
|
|
80
|
-
//
|
|
81
|
-
//
|
|
82
|
-
// the whole MCP server down with it. stdout needs the same guard; readline adds none.
|
|
77
|
+
// session/cancel can be written after the agent is gone, and an unhandled pipe 'error' would
|
|
78
|
+
// take down the server. readline adds no handler on stdout either.
|
|
83
79
|
this.child.stdin.on("error", () => {});
|
|
84
80
|
this.child.stdout.on("error", () => {});
|
|
85
81
|
const emitExit = (code, signal) => {
|
|
@@ -88,9 +84,8 @@ export class AcpClient extends EventEmitter {
|
|
|
88
84
|
const stderr = this.stderrBuffer;
|
|
89
85
|
const err = makeError(
|
|
90
86
|
"agent-exit",
|
|
91
|
-
// stderr
|
|
92
|
-
//
|
|
93
|
-
// names it can sit anywhere in it. The 64KB ring buffer above is the bound.
|
|
87
|
+
// stderr whole, bounded by the 64KB buffer: why the agent died (a rejected model, a spent
|
|
88
|
+
// quota, an expired login) can sit anywhere in it.
|
|
94
89
|
`agent exited (code=${code}${signal ? ", signal=" + signal : ""})${stderr ? ": " + String(stderr) : ""}`
|
|
95
90
|
);
|
|
96
91
|
// exit + rejectAllPending both settle the same Promise.race; second rejection is intentional.
|
|
@@ -124,8 +119,6 @@ export class AcpClient extends EventEmitter {
|
|
|
124
119
|
});
|
|
125
120
|
return /** @type {Promise<void>} */ (new Promise((resolve, reject) => {
|
|
126
121
|
this.child.once("error", (e) => {
|
|
127
|
-
// Tagged like every other failure class so the caller gets
|
|
128
|
-
// "delegate failed [spawn-failed]: ..." instead of the one untagged prose error.
|
|
129
122
|
const err = makeError("spawn-failed", `Failed to spawn agent (${command}): ${e.message}. Install Cursor CLI and run 'cursor-agent login'.`);
|
|
130
123
|
reject(err);
|
|
131
124
|
});
|
|
@@ -133,8 +126,7 @@ export class AcpClient extends EventEmitter {
|
|
|
133
126
|
}));
|
|
134
127
|
}
|
|
135
128
|
|
|
136
|
-
// Stashed
|
|
137
|
-
// capability and model lists without paying for a second handshake.
|
|
129
|
+
// Stashed for the unknown-model check and doctor deep, so neither needs a second handshake.
|
|
138
130
|
async initialize() {
|
|
139
131
|
const res = await this.peer.request("initialize", { protocolVersion: 1, clientInfo: { name: "cursor-delegate-mcp", version: VERSION }, clientCapabilities: { _meta: { parameterizedModelPicker: true } } });
|
|
140
132
|
this.protocolVersion = res?.protocolVersion;
|
|
@@ -153,7 +145,12 @@ export class AcpClient extends EventEmitter {
|
|
|
153
145
|
setConfigOption(sessionId, configId, value) { return this.peer.request("session/set_config_option", { sessionId, configId, value: String(value) }); } // configId, not optionId; ACP wants a string value
|
|
154
146
|
setMode(sessionId, modeId) { return this.peer.request("session/set_mode", { sessionId, modeId }); }
|
|
155
147
|
prompt(sessionId, blocks) { return this.peer.request("session/prompt", { sessionId, prompt: blocks }); }
|
|
156
|
-
cancel(sessionId) {
|
|
148
|
+
cancel(sessionId) {
|
|
149
|
+
// Recorded so runDelegate can hold back a prompt not yet sent.
|
|
150
|
+
this.cancelRequested = true;
|
|
151
|
+
this.peer.notify("session/cancel", { sessionId });
|
|
152
|
+
return Promise.resolve();
|
|
153
|
+
}
|
|
157
154
|
|
|
158
155
|
getTranscript(n) { return this.peer ? this.peer.formatLog(n) : ""; }
|
|
159
156
|
|
|
@@ -179,8 +176,7 @@ export class AcpClient extends EventEmitter {
|
|
|
179
176
|
return true;
|
|
180
177
|
}
|
|
181
178
|
const alive = isChildAlive(child);
|
|
182
|
-
// Subscribed before the kill
|
|
183
|
-
// exit in the gap and leave this waiting on an event that has already fired.
|
|
179
|
+
// Subscribed before the kill, so an instant exit is not missed.
|
|
184
180
|
const exited = alive
|
|
185
181
|
? /** @type {Promise<boolean>} */ (new Promise((resolve) => child.once("exit", () => resolve(true))))
|
|
186
182
|
: Promise.resolve(true);
|
|
@@ -194,10 +190,8 @@ export class AcpClient extends EventEmitter {
|
|
|
194
190
|
}));
|
|
195
191
|
const observed = await Promise.race([exited, bounded]);
|
|
196
192
|
clearTimeout(timer);
|
|
197
|
-
//
|
|
198
|
-
//
|
|
199
|
-
// did not see the child die never gets that handler, so settle those RPCs only when
|
|
200
|
-
// the process is still alive and emitExit has not run.
|
|
193
|
+
// On an observed exit, emitExit rejects in-flight RPCs with stderr, and racing it here would
|
|
194
|
+
// drop that. Only a child still alive after the stop has its RPCs settled here.
|
|
201
195
|
if (!observed && !this._exitEmitted && isChildAlive(child)) {
|
|
202
196
|
try {
|
|
203
197
|
this.peer?.rejectAllPending(makeError("agent-exit", "agent process did not exit after stop"));
|
package/src/acp-enums.js
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
// value the tool documents, or document one it strips.
|
|
5
|
-
//
|
|
6
|
-
// Plan status follows ACP v1 PlanEntryStatus (no cancelled). Todo status follows Cursor's
|
|
7
|
-
// update_todos / create_plan todo arrays, which include cancelled. They stay separate
|
|
8
|
-
// constants so they can diverge.
|
|
1
|
+
// Allowed plan and todo values, shared by delegate.js's sanitizers and server.js's schemas so the
|
|
2
|
+
// two cannot drift. Plan status follows ACP v1 PlanEntryStatus (no cancelled); todo status follows
|
|
3
|
+
// Cursor's update_todos and create_plan arrays, which include cancelled.
|
|
9
4
|
|
|
10
5
|
export const PLAN_PRIORITIES = /** @type {const} */ (["high", "medium", "low"]);
|
|
11
6
|
|