cursor-delegate-mcp 1.18.1 → 1.20.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/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # Cursor Delegate
2
2
 
3
- **Stop burning your frontier agent's limits on boilerplate.** Delegate edits to Cursor's CLI agent — your agent writes the brief and reviews the diff.
3
+ **Stop burning your frontier agent's limits on boilerplate.**
4
+
5
+ Delegate edits to Cursor's CLI agent — your agent writes the brief and reviews the diff.
4
6
 
5
7
  [![npm version](https://img.shields.io/npm/v/cursor-delegate-mcp)](https://www.npmjs.com/package/cursor-delegate-mcp)
6
8
  [![npm downloads](https://img.shields.io/npm/dt/cursor-delegate-mcp)](https://www.npmjs.com/package/cursor-delegate-mcp)
@@ -22,7 +24,7 @@ Cursor Delegate is the MCP bridge that lets Claude Code, ChatGPT/Codex, Copilot
22
24
 
23
25
  ## 🧠 Frontier quality, kept
24
26
 
25
- Your assistant does what frontier models are actually for: understands the task, writes a precise brief, reviews the finished diff. **Composer 2.5** runs the implementation loop under that brief. Nothing lands unreviewed — the agent that scoped the work reads the changed files back before you see them.
27
+ Your assistant does what frontier models are for: understands the task, writes a precise brief, reviews the finished diff. **Composer 2.5** runs the implementation loop under that brief. The bundled skill puts the review step in the loop — the agent that scoped the work reads the changed files back before reporting.
26
28
 
27
29
  ## ⚡ Done faster
28
30
 
@@ -30,17 +32,9 @@ Composer 2.5 is built for throughput on multi-file edits. The whole delegation i
30
32
 
31
33
  ## 🔋 Your limits stop being the bottleneck
32
34
 
33
- Composer and Grok run on their **own usage allowance** on every Cursor plan — separate from the API-priced main quota, and generous enough that most people never reach the ceiling ([Cursor's own wording](https://cursor.com/pricing)). Your Claude or Codex subscription spends tokens only on the brief and the review, so the 5-hour window and weekly limits go a lot further. Paying per token on API? That grind moves onto Cursor capacity you already have.
35
+ Composer and Grok run on their **own usage allowance** on every Cursor plan — separate from the API-priced main quota, and generous enough that most people never reach the ceiling. Your Claude or Codex subscription spends tokens only on the brief and the review, so the 5-hour window and weekly limits go a lot further. Paying per token on API? That grind moves onto Cursor capacity you already have.
34
36
 
35
- ```
36
- You → your agent (plans & reviews)
37
- │ MCP delegate tool
38
- ▼
39
- cursor-agent (Composer 2.5 — implements)
40
- │ edits your workspace
41
- ▼
42
- Clean result: what changed, which files, the plan
43
- ```
37
+ ![You and your agent plan and review; the MCP delegate tool hands the brief to cursor-agent (Composer 2.5), which implements and edits your workspace; a clean result comes back with what changed, which files, and the plan, for your agent to review](assets/flow.png)
44
38
 
45
39
  ![Delegate result payload](assets/result-json.png)
46
40
 
@@ -48,12 +42,14 @@ You → your agent (plans & reviews)
48
42
 
49
43
  - 🤝 **Native plugins** — install into Claude Code, ChatGPT/Codex, or GitHub Copilot CLI and just say *"delegate this to Cursor"*. The shared skill teaches your agent how to delegate well.
50
44
  - 💬 **No stalled runs** — if Cursor needs to clarify, it ends the turn and returns the question as a normal result. Your agent reads it and answers by resuming the same session — nothing blocks on a modal waiting for input.
51
- - 📦 **Clean, named results** — final answer, changed files, session id, and the plan, returned as one compact JSON payload. Nothing to scrape, nothing to guess.
45
+ - 📦 **Clean, named results** — final answer, changed files, session id, and the plan, returned as one compact JSON payload. Nothing to scrape.
52
46
  - 📋 **Plan first** — `plan` mode: Cursor drafts a plan, you review it, then the same session implements it.
53
- - 🔍 **Ask anything** — `ask` mode: read-only Q&A over your codebase.
47
+ - 🔍 **Ask anything** — `ask` mode: Q&A over your codebase.
54
48
  - 🩺 **Self-diagnosing** — a `doctor` tool that tells you exactly what's missing if setup isn't right.
55
49
  - 🔌 **Portable** — plain stdio MCP, so it runs anywhere: VS Code, JetBrains, Windsurf, Visual Studio, and more.
56
50
 
51
+ `plan` and `ask` are instructions to the agent, and `workspace` is its working directory — [Security](SECURITY.md) and the [delegate reference](skills/delegate/reference.md) spell out what the bridge enforces and what it reports back.
52
+
57
53
  ## Install
58
54
 
59
55
  You need [Node.js 20+](https://nodejs.org/) and the [Cursor CLI](https://cursor.com/docs/cli/overview), logged in (`cursor-agent login`).
@@ -96,7 +92,7 @@ copilot plugin install andreilungeanu/cursor-delegate-mcp
96
92
  }
97
93
  }
98
94
  ```
99
-
95
+
100
96
  ### Client-specific config locations
101
97
 
102
98
  <details>
package/SECURITY.md CHANGED
@@ -2,17 +2,25 @@
2
2
 
3
3
  ## What this plugin does
4
4
 
5
- `cursor-delegate-mcp` spawns **cursor-agent** in your workspace and **auto-approves file
6
- write and permission requests** over ACP (`allow-always`). Delegated tasks can modify,
7
- create, or delete files under the chosen `workspace` directory.
5
+ `cursor-delegate-mcp` spawns **cursor-agent** in your workspace and **auto-approves every
6
+ permission it requests** over ACP, in every mode — `agent`, `plan` and `ask`. Each request is
7
+ answered with the broadest allow option the agent offered (`allow_always`, else `allow_once`).
8
8
 
9
- Treat every `delegate` call like handing an engineer write access to that tree.
9
+ `workspace` is the agent's working directory, and a run can reach outside it. `mode` is
10
+ passed to the agent as an instruction, so `plan` and `ask` describe how it behaves rather
11
+ than what it is permitted to do. Delegated tasks can create, modify, or delete files
12
+ anywhere your user account can reach, and reach the network.
13
+
14
+ Treat every `delegate` call like handing an engineer a shell on your machine. Your MCP host
15
+ is the orchestrator: it should scope the brief, then review `filesReportedByEditTools` and
16
+ the git diff. That field lists what the agent's edit tools reported touching; the git diff
17
+ is authoritative.
10
18
 
11
19
  ## Recommendations
12
20
 
13
21
  - Point `workspace` at the smallest directory that contains the task (not `$HOME` or `/`).
14
- - Review `filesReportedByEditTools` and the git diff before committing.
15
- - Use `mode: "plan"` when you only want a plan, not file changes.
22
+ It scopes what the agent works on, not what it can reach.
23
+ - Review the git diff before committing, after every run — including `plan` and `ask` ones.
16
24
  - Run verification (tests, lint) after delegation — the delegate skill asks Claude to do
17
25
  this, but automated gates in CI are still your backstop.
18
26
  - Do not commit secrets (`.env`, credentials, tokens). The bridge does not redact them from
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cursor-delegate-mcp",
3
- "version": "1.18.1",
3
+ "version": "1.20.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, or Copilot to Cursor's CLI agent — structured results, plan mode, and changed files.",
package/src/acp-client.js CHANGED
@@ -61,8 +61,9 @@ export class AcpClient extends EventEmitter {
61
61
  this.child.stderr.on("error", () => {});
62
62
  // A supervisor trip writes session/cancel, which can land after the agent is already gone.
63
63
  // Without a handler that surfaces as an unhandled 'error' event on some platforms, taking
64
- // the whole MCP server down with it.
64
+ // the whole MCP server down with it. stdout needs the same guard; readline adds none.
65
65
  this.child.stdin.on("error", () => {});
66
+ this.child.stdout.on("error", () => {});
66
67
  const emitExit = (code, signal) => {
67
68
  if (this._exitEmitted) return;
68
69
  this._exitEmitted = true;
@@ -80,7 +81,11 @@ export class AcpClient extends EventEmitter {
80
81
  this.router = null; // set before first stdout line
81
82
  this.peer = new JsonRpcPeer(this.child.stdout, this.child.stdin, {
82
83
  onNotification: (method, params) => { if (method === "session/update") this.emit("update", params); },
83
- onRequest: (id, method, params) => { if (this.router) this.router(id, method, params); },
84
+ // The router is async and its result discarded, so a throw from its own catch would reject
85
+ // unobserved and exit the process. Promise.resolve covers a sync router in tests.
86
+ onRequest: (id, method, params) => {
87
+ if (this.router) Promise.resolve(this.router(id, method, params)).catch(() => {});
88
+ },
84
89
  onActivity: () => this.emit("activity"),
85
90
  });
86
91
  this.router = createRequestRouter({
package/src/delegate.js CHANGED
@@ -12,6 +12,7 @@ import { normalizeAgentReportedFiles } from "./agent-reported-files.js";
12
12
  import { makeTurnState } from "./turn-state.js";
13
13
  import { makeError } from "./errors.js";
14
14
  import { PLAN_PRIORITIES, PLAN_STATUSES, TODO_STATUSES } from "./acp-enums.js";
15
+ import { optionsFrom, resolveEffortId, unsupportedWarning } from "./model-options.js";
15
16
 
16
17
  export const DEFAULT_MODEL = "composer-2.5";
17
18
  export const DEFAULT_HANDSHAKE_MS = 60000;
@@ -142,12 +143,32 @@ async function buildContextBlocks(contextFiles, workspace, client, warnings) {
142
143
  return blocks;
143
144
  }
144
145
 
146
+ // Only a session the agent does not have justifies a fresh one; falling back on anything else
147
+ // runs the task without the context the caller asked for. Code and wording together, never
148
+ // either: 2026.08.11 returns -32602 `Session "<id>" not found` when it is missing, but -32603
149
+ // `Failed to load session "<id>": <cause>` when restore fails, and that cause can carry the
150
+ // same words. A missed match costs a recoverable resume-failed; a false match costs a silent turn.
151
+ function isMissingSession(err) {
152
+ const message = err?.message || "";
153
+ return err?.code === -32602
154
+ && /\bsession\b/i.test(message)
155
+ && /\bnot found\b|\bdoes not exist\b|\bunknown session\b|\bno such session\b/i.test(message);
156
+ }
157
+
145
158
  async function openSession(client, resumeSessionId, workspace) {
146
159
  if (!resumeSessionId) return client.newSession(workspace);
147
160
  try {
148
161
  await client.loadSession(resumeSessionId, workspace);
149
162
  return { sessionId: resumeSessionId }; // load does not echo sessionId
150
163
  } catch (err) {
164
+ if (!isMissingSession(err)) {
165
+ throw makeError(
166
+ "resume-failed",
167
+ `session ${resumeSessionId} could not be loaded: ${err?.message || String(err)}.`
168
+ + ` The session was not resumed and no fresh session was started — retry, or omit`
169
+ + ` resumeSessionId to start fresh deliberately.`
170
+ );
171
+ }
151
172
  // Starting fresh is right, but silently doing so leaves the caller unable to tell a
152
173
  // stale id from a typo'd one — keep why the load failed.
153
174
  const fresh = await client.newSession(workspace);
@@ -184,16 +205,25 @@ async function applyConfig(client, sessionId, configId, value) {
184
205
  // The resolved model appears only in a set_config_option reply's configOptions (set_model
185
206
  // returns nothing). Absent for models that reject every option sent — the field then stays off.
186
207
  function servedModelFrom(res) {
187
- const opts = res?.configOptions;
188
- if (!Array.isArray(opts)) return undefined;
208
+ const opts = optionsFrom(res);
209
+ if (opts === undefined) return undefined;
189
210
  const m = opts.find((o) => o?.id === "model");
190
211
  return typeof m?.currentValue === "string" ? m.currentValue : undefined;
191
212
  }
192
213
 
214
+ // Sent under whichever id the model declares. A model that refuses fast leaves no option list;
215
+ // only then are the candidate ids tried in turn.
216
+ async function applyEffort(client, sessionId, value, modelOptions) {
217
+ const id = resolveEffortId(modelOptions, value);
218
+ if (id === undefined) return { applied: false };
219
+ const r = await applyConfig(client, sessionId, id, value);
220
+ return r.unsupported ? { applied: false } : { applied: true, res: r.res };
221
+ }
222
+
193
223
  /**
194
224
  * @param {{
195
225
  * spec?: string, mode?: string, resumeSessionId?: string, workspace?: string,
196
- * model?: string, fast?: boolean, reasoning?: string, context?: string,
226
+ * model?: string, fast?: boolean, effort?: string, context?: string,
197
227
  * contextFiles?: string[], clientFactory?: (opts: any) => any,
198
228
  * idleMs?: number, handshakeMs?: number, hardCapMs?: number, timeoutMs?: number,
199
229
  * onSessionReady?: (sessionId: string, client: any) => void,
@@ -203,7 +233,7 @@ function servedModelFrom(res) {
203
233
  */
204
234
  export async function runDelegate({
205
235
  spec, mode = "agent", resumeSessionId, workspace,
206
- model = DEFAULT_MODEL, fast = false, reasoning, context, contextFiles, clientFactory,
236
+ model = DEFAULT_MODEL, fast = false, effort, context, contextFiles, clientFactory,
207
237
  idleMs, handshakeMs, hardCapMs, timeoutMs,
208
238
  onSessionReady, onProgress, progressThrottleMs = 2000,
209
239
  heartbeatMs = DEFAULT_HEARTBEAT_MS,
@@ -215,6 +245,12 @@ export async function runDelegate({
215
245
  // Before the spawn: validating later costs a process, a handshake and a billed turn.
216
246
  assertWorkspace(workspace);
217
247
  const promptText = await resolveSpec(spec);
248
+ // addEventListener does not replay an abort that already fired, and the listener is registered
249
+ // below, so an abort during the await above is otherwise lost. Throwing, not supervisor.abort():
250
+ // tripping before supervise() installs its reject settles the supervisor with nothing listening.
251
+ if (signal?.aborted) {
252
+ throw makeError("aborted", "delegation aborted by MCP host");
253
+ }
218
254
  const capMs = hardCapMs ?? timeoutMs ?? envMs("CURSOR_DELEGATE_HARD_CAP_MS", 3600000);
219
255
  const shakeMs = handshakeMs ?? envMs("CURSOR_DELEGATE_HANDSHAKE_MS", DEFAULT_HANDSHAKE_MS);
220
256
  const turnIdleMs = idleMs ?? envMs("CURSOR_DELEGATE_IDLE_MS", 0);
@@ -365,15 +401,28 @@ export async function runDelegate({
365
401
  assertKnownModel(client, model);
366
402
  await client.setModel(sessionId, model);
367
403
  // fast is always sent — a resumed session may already have it on, so false is a real
368
- // instruction. reasoning and context go only when the caller named one. Each reply reports
369
- // the now-current model; the last one seen wins.
404
+ // instruction. Its reply carries this model's configOptions, which is where the effort id
405
+ // comes from. effort and context go only when the caller named one. Each reply reports the
406
+ // now-current model; the last one seen wins.
370
407
  const fastResult = await applyConfig(client, sessionId, "fast", fast);
371
- if (fastResult.unsupported && fast) unsupportedOptions.push("fast");
408
+ if (fastResult.unsupported && fast) unsupportedOptions.push({ arg: "fast" });
372
409
  else servedModel = servedModelFrom(fastResult.res) ?? servedModel;
373
- for (const [id, value] of [["reasoning", reasoning], ["context", context]]) {
374
- if (value === undefined) continue;
375
- const r = await applyConfig(client, sessionId, id, value);
376
- if (r.unsupported) unsupportedOptions.push(id);
410
+ let modelOptions = optionsFrom(fastResult.res);
411
+ // A model that refuses fast leaves no list. Re-asserting the model just set is inert, and
412
+ // its reply carries the full list — measured on claude-haiku-4-5, which refuses fast.
413
+ if (modelOptions === undefined && effort !== undefined) {
414
+ const reasserted = await applyConfig(client, sessionId, "model", model);
415
+ modelOptions = optionsFrom(reasserted.res);
416
+ servedModel = servedModelFrom(reasserted.res) ?? servedModel;
417
+ }
418
+ if (effort !== undefined) {
419
+ const applied = await applyEffort(client, sessionId, effort, modelOptions);
420
+ if (!applied.applied) unsupportedOptions.push({ arg: "effort", modelOptions });
421
+ else servedModel = servedModelFrom(applied.res) ?? servedModel;
422
+ }
423
+ if (context !== undefined) {
424
+ const r = await applyConfig(client, sessionId, "context", context);
425
+ if (r.unsupported) unsupportedOptions.push({ arg: "context" });
377
426
  else servedModel = servedModelFrom(r.res) ?? servedModel;
378
427
  }
379
428
  await client.setMode(sessionId, mode);
@@ -441,7 +490,7 @@ export async function runDelegate({
441
490
  // sessionTitle stays out of the result: it is a live label (progress) and a forensic one
442
491
  // (timeout errors), not a fact about the finished turn.
443
492
  if (resumeError) protocolWarnings.push(`resuming ${resumeSessionId} failed, started a fresh session: ${resumeError}`);
444
- for (const id of unsupportedOptions) protocolWarnings.push(`model ${model} has no ${id} option; the requested value was ignored`);
493
+ for (const u of unsupportedOptions) protocolWarnings.push(unsupportedWarning(model, u));
445
494
  protocolWarnings.push(...contextWarnings);
446
495
  if (state.planEntries.length > 0 || state.planOverview !== undefined || state.planDetail !== undefined) {
447
496
  // Sanitize even when the plan is discarded: the warnings it raises report malformed ACP
@@ -472,8 +521,7 @@ export async function runDelegate({
472
521
  // outstanding — it also lets a retry resume the work already done.
473
522
  const isTimeout = err?.reason === "hard-cap" || err?.reason === "idle-timeout";
474
523
  // A handshake timeout gets the forensics but not the long-command advice: no prompt was sent,
475
- // so no shell command explains the silence. The session may still exist (it is set before
476
- // set_model/set_config_option/set_mode, any of which can hang), so the resume hint applies.
524
+ // so no shell command explains the silence.
477
525
  const isStall = isTimeout || err?.reason === "handshake-timeout";
478
526
  if (isStall || err?.reason === "aborted" || err?.reason === "agent-exit") {
479
527
  const age = fmtDuration(supervisor.msSinceActivity());
@@ -487,20 +535,23 @@ export async function runDelegate({
487
535
  }
488
536
  const files = normalizeAgentReportedFiles([...state.touched], workspace);
489
537
  if (files.length) err.message += ` Files reported edited: ${files.join(", ")}.`;
490
- // Without this the resume hint below reads as "carry on from where you were", when the
491
- // requested session was never loaded.
492
- if (resumeError) {
493
- err.message += ` Note: resuming ${resumeSessionId} had already failed (${resumeError}),`
494
- + ` so this ran as a fresh session and none of that earlier work was in context.`;
495
- }
496
- if (sessionId) err.message += ` Resume with resumeSessionId ${sessionId}.`;
497
- if (isTimeout) {
498
- // Name the knob that actually fired: raising the hard cap does nothing for an
499
- // idle-timeout, whose ceiling is CURSOR_DELEGATE_IDLE_MS.
500
- const knob = err.reason === "idle-timeout" ? "CURSOR_DELEGATE_IDLE_MS" : "CURSOR_DELEGATE_HARD_CAP_MS";
501
- err.message += " cursor-agent does not stream shell output over ACP, so a long-running command emits"
502
- + ` nothing until it exits. Split the command, run it in the background and poll, or raise ${knob}.`;
503
- }
538
+ }
539
+ // Every failure after session/new leaves a live session, not just the stalls: the id is set
540
+ // before set_model/set_config_option/set_mode, so unknown-model and a rejected config value
541
+ // land here too and are abandoned without it.
542
+ if (resumeError) {
543
+ // Without this the resume hint reads as "carry on from where you were", when the requested
544
+ // session was never loaded.
545
+ err.message += ` Note: resuming ${resumeSessionId} had already failed (${resumeError}),`
546
+ + ` so this ran as a fresh session and none of that earlier work was in context.`;
547
+ }
548
+ if (sessionId) err.message += ` Resume with resumeSessionId ${sessionId}.`;
549
+ if (isTimeout) {
550
+ // Name the knob that actually fired: raising the hard cap does nothing for an
551
+ // idle-timeout, whose ceiling is CURSOR_DELEGATE_IDLE_MS.
552
+ const knob = err.reason === "idle-timeout" ? "CURSOR_DELEGATE_IDLE_MS" : "CURSOR_DELEGATE_HARD_CAP_MS";
553
+ err.message += " cursor-agent does not stream shell output over ACP, so a long-running command emits"
554
+ + ` nothing until it exits. Split the command, run it in the background and poll, or raise ${knob}.`;
504
555
  }
505
556
  // Opt-in: the frames land in the caller's context and nothing there is actionable — the
506
557
  // forensics above already carry that. Raw frames only help someone debugging the bridge.
package/src/doctor.js CHANGED
@@ -4,6 +4,7 @@ import { AcpClient } from "./acp-client.js";
4
4
  import { resolveAcpSpawn } from "./spawn.js";
5
5
  import { treeKill } from "./proc.js";
6
6
  import { readPackageVersion } from "./version.js";
7
+ import { allowedValues } from "./model-options.js";
7
8
 
8
9
  const HANDSHAKE_TIMEOUT_MS = 15_000;
9
10
  const VERSION_PROBE_TIMEOUT_MS = 10_000;
@@ -67,6 +68,12 @@ async function runDeepHandshake({ spawnSpec, clientFactory, workspace, timeoutMs
67
68
  details.models = (client.sessionModels?.availableModels ?? []).map((m) => m?.modelId).filter(Boolean);
68
69
  details.currentModel = client.sessionModels?.currentModelId ?? null;
69
70
  details.modes = (client.sessionModes?.availableModes ?? []).map((m) => m?.id).filter(Boolean);
71
+ // session/new already returned these. currentModel only — any other model needs a set_model
72
+ // first, which this handshake does not send.
73
+ details.currentModelOptions = (client.configOptions ?? [])
74
+ // model and mode are already reported as their own fields.
75
+ .filter((o) => typeof o?.id === "string" && o.id !== "model" && o.id !== "mode")
76
+ .map((o) => ({ id: o.id, values: allowedValues(o) }));
70
77
  })();
71
78
  const timeout = new Promise((_, reject) => {
72
79
  timer = setTimeout(() => {
@@ -0,0 +1,52 @@
1
+ // Config option ids differ per model, and a model rejects any id it does not declare. The set is
2
+ // knowable only once a model is selected, from the configOptions the agent echoes back.
3
+
4
+ // Mirrors cursor-agent's own classifier.
5
+ const THOUGHT_LEVEL_IDS = new Set(["thinking", "reasoning", "effort", "thought_level"]);
6
+
7
+ export function isThoughtLevel(opt) {
8
+ const id = typeof opt?.id === "string" ? opt.id.toLowerCase() : "";
9
+ if (THOUGHT_LEVEL_IDS.has(id)) return true;
10
+ const name = typeof opt?.name === "string" ? opt.name.toLowerCase() : "";
11
+ return /thinking|reasoning|thought/.test(name);
12
+ }
13
+
14
+ export function optionsFrom(res) {
15
+ return Array.isArray(res?.configOptions) ? res.configOptions : undefined;
16
+ }
17
+
18
+ export function allowedValues(opt) {
19
+ return (Array.isArray(opt?.options) ? opt.options : [])
20
+ .map((o) => o?.value)
21
+ .filter((v) => typeof v === "string");
22
+ }
23
+
24
+ function isBoolean(opt) {
25
+ const v = allowedValues(opt).slice().sort();
26
+ return v.length === 2 && v[0] === "false" && v[1] === "true";
27
+ }
28
+
29
+ // Claude declares thinking (true|false) and effort (low|medium|high) together, so the value picks
30
+ // the id. With no match, a non-boolean candidate still goes: the agent's own "Invalid value for X"
31
+ // names the allowed set. A boolean-only model (claude-haiku-4-5 declares just thinking) gets
32
+ // nothing — sending a level there is a guaranteed invalid value, which would fail the run.
33
+ export function resolveEffortId(options, value) {
34
+ const candidates = (Array.isArray(options) ? options : []).filter(isThoughtLevel);
35
+ if (candidates.length === 0) return undefined;
36
+ const pick = candidates.find((o) => allowedValues(o).includes(value))
37
+ ?? candidates.find((o) => !isBoolean(o));
38
+ return typeof pick?.id === "string" ? pick.id : undefined;
39
+ }
40
+
41
+ // effort's id varies per model, so name the ids the model declares. fast and context are sent
42
+ // under their own names.
43
+ export function unsupportedWarning(model, { arg, modelOptions }) {
44
+ if (arg !== "effort") return `model ${model} has no ${arg} option; the requested value was ignored`;
45
+ // No reply carried a list, so claiming the model declares nothing would assert a capability
46
+ // never observed.
47
+ if (modelOptions === undefined) return `effort ignored: ${model} did not report its option list`;
48
+ const ids = modelOptions.filter(isThoughtLevel).map((o) => o?.id).filter(Boolean);
49
+ return ids.length
50
+ ? `effort ignored: ${model} declares ${ids.join(", ")}, which did not take the requested value`
51
+ : `effort ignored: ${model} declares no thinking or reasoning option`;
52
+ }
package/src/server.js CHANGED
@@ -50,7 +50,7 @@ function rememberSession(set, id) {
50
50
  // Loaded at connect, before any tool schema is, so this carries only pre-call facts: what a
51
51
  // caller needs to decide whether to delegate at all. Call-time facts belong on the parameter
52
52
  // descriptions, read while the call is being written.
53
- export const SERVER_INSTRUCTIONS = `Delegate coding work to Cursor through the delegate tool. Every permission the agent requests is auto-approved, in every mode: mode="plan" and mode="ask" are instructions to the agent, not limits the bridge enforces, and the bridge cannot detect one being ignored. So scope workspace to the smallest relevant directory and review the git diff after every run, not only write-capable ones; filesReportedByEditTools lists what the agent's edit tools reported changing (absent when they reported none) but the diff is authoritative.`;
53
+ export const SERVER_INSTRUCTIONS = `Delegate coding work to Cursor through the delegate tool. Every permission the agent requests is auto-approved, in every mode: agent/plan/ask reach any file the user account can, and mode instructs the agent rather than limiting it. Scope workspace tightly and review the git diff after every run — filesReportedByEditTools carries only what the agent's edit tools reported; the diff is authoritative.`;
54
54
 
55
55
  const planEntrySchema = z.object({
56
56
  content: z.string(),
@@ -141,17 +141,17 @@ export const doctorOutputShape = {
141
141
  };
142
142
 
143
143
  export const delegateInputSchema = z.object({
144
- spec: z.string().trim().min(1, "spec must not be blank").describe("Inline task brief (default): goal, scope, decisions already made (constraints and fixed choices — quote the user's exact values verbatim), acceptance criteria. Point at files to read or mimic rather than pasting code. Optional file path if the user wants a persisted spec."),
145
- mode: z.enum(["agent", "plan", "ask"]).default("agent").describe("Requested agent mode. plan and ask are passed to the agent as instructions, not enforced by the bridge — the agent may write in any of them, so review the git diff after every run. ask held on every model tested while plan compliance varies by model, so prefer ask when you need the stricter read-only instruction."),
146
- resumeSessionId: z.string().optional().describe("Resume an existing ACP session instead of a new one"),
147
- workspace: z.string().optional().describe("Working directory for the agent. Optional; defaults to the server process cwd. Must already exist — never create one for the call."),
148
- model: z.string().trim().min(1, "model must be a non-empty string").default(DEFAULT_MODEL),
149
- fast: z.boolean().default(false).describe("Fast speed tier — higher cost; enable only when the user asks"),
144
+ spec: z.string().trim().min(1, "spec must not be blank").describe("Task brief: goal, scope, fixed decisions quoted exactly, acceptance criteria. Point at files to read rather than pasting code. A lone file path is read as the brief."),
145
+ mode: z.enum(["agent", "plan", "ask"]).default("agent").describe("agent implements; plan and ask are instructions to the agent, not limits."),
146
+ resumeSessionId: z.string().optional().describe("Continue an existing ACP session."),
147
+ workspace: z.string().optional().describe("The agent's working directory, not a limit. Defaults to the server process cwd, which under npx is often not your project root — pass it explicitly. Must already exist; never create one for the call."),
148
+ model: z.string().trim().min(1, "model must be a non-empty string").default(DEFAULT_MODEL).describe("Bare ACP family id, version included: composer-2.5, grok-4.5, claude-opus-5, gpt-5.6-sol. doctor deep:true lists every id."),
149
+ fast: z.boolean().default(false).describe("Fast tier; higher cost — only when the user asks."),
150
150
  // Which options a model offers, and their valid values, are only knowable by asking the
151
151
  // agent, so these stay open strings and the agent rejects what it does not accept.
152
- reasoning: z.string().trim().min(1).optional().describe("Reasoning effort. Not offered by every model; gpt-5.x accepts none, low, medium, high, extra-high."),
153
- context: z.string().trim().min(1).optional().describe("Context window size. Not offered by every model; gpt-5.x accepts 272k and 1m."),
154
- contextFiles: z.array(z.string()).optional().describe("Paths to attach instead of pasting file contents into spec. Text files are passed as references the agent may open; images (png, jpg, gif, webp, under 5MB) are sent inline. Relative paths resolve against workspace, and paths outside it are allowed — attach only files the agent should read. Anything skipped is reported in protocolWarnings, never fatal."),
152
+ effort: z.string().trim().min(1).optional().describe("Thinking effort; ids and values differ per model, and some offer none. gpt-5.x: none, low, medium, high, extra-high. doctor deep:true lists the current model's."),
153
+ context: z.string().trim().min(1).optional().describe("Context window size; gpt-5.x accepts 272k and 1m. Do not pass speculatively."),
154
+ contextFiles: z.array(z.string()).optional().describe("Paths to attach instead of pasting contents into spec. Text becomes references the agent may open; images (png/jpg/gif/webp, <5MB) are sent inline. Relative paths resolve against workspace but are not limited to it. Skips are reported in protocolWarnings, never fatal."),
155
155
  });
156
156
 
157
157
  /**
@@ -164,7 +164,7 @@ export const delegateInputSchema = z.object({
164
164
  * @returns {Promise<import("@modelcontextprotocol/sdk/types.js").CallToolResult>}
165
165
  */
166
166
  export async function runDelegateTool({ args, extra, runDelegate, inFlight, seenSessions = new Set() }) {
167
- const { spec, mode, resumeSessionId, workspace, model, fast, reasoning, context, contextFiles } = args;
167
+ const { spec, mode, resumeSessionId, workspace, model, fast, effort, context, contextFiles } = args;
168
168
 
169
169
  const progressToken = extra?._meta?.progressToken;
170
170
  /** @type {(message: string) => void} */
@@ -172,11 +172,13 @@ export async function runDelegateTool({ args, extra, runDelegate, inFlight, seen
172
172
  if (progressToken != null) {
173
173
  let progress = 0;
174
174
  onProgress = (message) => {
175
+ // sendNotification is async: its rejection settles outside this try and would exit the
176
+ // server. The try stays for a sync throw, which lands before Promise.resolve can wrap it.
175
177
  try {
176
- extra.sendNotification({
178
+ Promise.resolve(extra.sendNotification({
177
179
  method: "notifications/progress",
178
180
  params: { progressToken, progress: ++progress, message },
179
- });
181
+ })).catch(() => {});
180
182
  } catch {}
181
183
  };
182
184
  }
@@ -191,7 +193,7 @@ export async function runDelegateTool({ args, extra, runDelegate, inFlight, seen
191
193
  workspace: workspace || process.cwd(),
192
194
  model,
193
195
  fast,
194
- reasoning,
196
+ effort,
195
197
  context,
196
198
  contextFiles,
197
199
  onProgress,
@@ -243,7 +245,7 @@ export function buildServer({ runDelegate: runDelegateInjected, runDoctor: runDo
243
245
  "delegate",
244
246
  {
245
247
  description:
246
- `Delegate a coding task to cursor-agent over ACP. Never shell out to cursor-agent — use this tool only. Pass structured task text inline in spec (default); a file path is optional when the user wants a persisted brief. Defaults: mode=agent, model=${DEFAULT_MODEL}, fast=false. Plan workflow: mode=plan, then resume with mode=agent and resumeSessionId. Auto-approves every permission the agent requests, in any mode and anywhere on disk. Clarifying questions arrive as prose in result — resume with resumeSessionId to answer. Returns the final result, selection source, stop reason, session ID, agent-reported files, and optional plan. See the delegate skill for orchestration.`,
248
+ `Delegate a coding task to cursor-agent over ACP. Never shell out to cursor-agent — use this tool only. Auto-approves every permission the agent requests, in any mode and anywhere on disk. Clarifying questions arrive as prose in result — resume with resumeSessionId to answer. Keep model (${DEFAULT_MODEL}), fast and effort at their defaults unless the user asks. See the delegate skill.`,
247
249
  inputSchema: delegateInputSchema,
248
250
  annotations: {
249
251
  title: "Delegate coding task to Cursor",
@@ -260,10 +262,10 @@ export function buildServer({ runDelegate: runDelegateInjected, runDoctor: runDo
260
262
  "cancel",
261
263
  {
262
264
  description:
263
- "Best-effort cancel of an in-flight ACP delegation by sessionId. Sends session/cancel; the agent may finish the turn anyway. The delegate result carries cancelRequested: true when the turn was cancelled mid-run. MCP hosts that serialize tool calls cannot run this while delegate is in flight. With force: true, the agent process is killed if the turn is still running after a short grace period. Returns not-running for a session whose turn already ended (it is still resumable), and not-found for an id never seen this process.",
265
+ "Best-effort cancel of an in-flight delegation by sessionId. session/cancel is advisory — the agent may finish the turn anyway, and the delegate result then carries cancelRequested. Status: cancelled, killed, not-running (turn already ended, still resumable), not-found (id never seen this process).",
264
266
  inputSchema: {
265
267
  sessionId: z.string(),
266
- force: z.boolean().default(false).describe("After the cancel notify, wait a short grace period and kill the agent process if the delegation is still running"),
268
+ force: z.boolean().default(false).describe("Kill the agent process if the turn is still running after a short grace period."),
267
269
  },
268
270
  annotations: {
269
271
  title: "Cancel Cursor delegation",
@@ -305,12 +307,12 @@ export function buildServer({ runDelegate: runDelegateInjected, runDoctor: runDo
305
307
  "doctor",
306
308
  {
307
309
  description:
308
- "Report setup and health diagnostics: plugin version, MCP client capabilities, cursor-agent launcher resolution, and optional deep ACP handshake. Use when delegation fails or agent.found is false.",
310
+ "Setup diagnostics: plugin version, MCP client capabilities, cursor-agent launcher resolution. Run when delegation fails or agent.found is false.",
309
311
  inputSchema: {
310
312
  deep: z
311
313
  .boolean()
312
314
  .default(false)
313
- .describe("When true, run a lightweight ACP handshake (start → initialize → newSession) to verify the agent is usable"),
315
+ .describe("Run an ACP handshake (start → initialize → newSession) to verify the agent is usable; adds models, modes and the current model's options."),
314
316
  },
315
317
  annotations: {
316
318
  title: "Diagnose Cursor delegation setup",