cursor-delegate-mcp 1.11.1 → 1.13.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/PRIVACY.md +1 -1
- package/README.md +7 -7
- package/SECURITY.md +1 -1
- package/TERMS.md +1 -1
- package/package.json +1 -1
- package/src/acp-client.js +8 -5
- package/src/delegate.js +87 -127
- package/src/doctor.js +0 -1
- package/src/request-router.js +1 -10
- package/src/server.js +17 -99
package/PRIVACY.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Privacy
|
|
2
2
|
|
|
3
|
-
Cursor Delegate
|
|
3
|
+
Cursor Delegate runs as a local stdio MCP server. The project author does not operate a backend for the plugin and does not receive your code, prompts, workspace contents, session identifiers, diagnostics, or usage telemetry.
|
|
4
4
|
|
|
5
5
|
Claude Code installs run the server bundled in the plugin cache. On first session, the plugin may run `npm install --omit=dev` inside that cache to fetch its open-source runtime dependencies; it does not install them into your project. Codex, Copilot, VS Code, and standalone MCP configurations start the published package through `npx`, so npm may apply its own registry logging under npm's policies.
|
|
6
6
|
|
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Cursor Delegate
|
|
1
|
+
# Cursor Delegate
|
|
2
2
|
|
|
3
3
|
**Keep the brains. Delegate the build.**
|
|
4
4
|
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
[](LICENSE)
|
|
9
9
|
[](https://github.com/andreilungeanu/cursor-delegate-mcp/actions/workflows/test.yml)
|
|
10
10
|
|
|
11
|
-
<img src="assets/logo-light.png" alt="Cursor Delegate
|
|
11
|
+
<img src="assets/logo-light.png" alt="Cursor Delegate logo" width="150" align="left" hspace="15">
|
|
12
12
|
|
|
13
13
|
Use your best coding agent where its judgment matters most: understanding the task, shaping the plan, and reviewing the result.
|
|
14
14
|
|
|
@@ -43,7 +43,7 @@ You → your agent (plans & reviews)
|
|
|
43
43
|
## Features
|
|
44
44
|
|
|
45
45
|
- 🤝 **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.
|
|
46
|
-
- 💬 **No stalled runs** — if Cursor
|
|
46
|
+
- 💬 **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.
|
|
47
47
|
- 📦 **Clean, typed results** — final answer, changed files, session id, and the plan, returned as validated structured output. Nothing to parse, nothing to guess.
|
|
48
48
|
- 📋 **Plan first** — `plan` mode: Cursor drafts a plan, you review it, then the same session implements it.
|
|
49
49
|
- 🔍 **Ask anything** — `ask` mode: read-only Q&A over your codebase, zero file changes.
|
|
@@ -88,7 +88,7 @@ copilot plugin install andreilungeanu/cursor-delegate-mcp
|
|
|
88
88
|
```json
|
|
89
89
|
{
|
|
90
90
|
"servers": {
|
|
91
|
-
"cursor-delegate
|
|
91
|
+
"cursor-delegate": {
|
|
92
92
|
"type": "stdio",
|
|
93
93
|
"command": "npx",
|
|
94
94
|
"args": ["-y", "cursor-delegate-mcp"]
|
|
@@ -114,7 +114,7 @@ Under **Settings → Tools → AI Assistant → Model Context Protocol (MCP)**,
|
|
|
114
114
|
```json
|
|
115
115
|
{
|
|
116
116
|
"mcpServers": {
|
|
117
|
-
"cursor-delegate
|
|
117
|
+
"cursor-delegate": {
|
|
118
118
|
"command": "npx",
|
|
119
119
|
"args": ["-y", "cursor-delegate-mcp"]
|
|
120
120
|
}
|
|
@@ -132,7 +132,7 @@ Heads-up: Cascade caps you at 100 tools across all servers.
|
|
|
132
132
|
```json
|
|
133
133
|
{
|
|
134
134
|
"servers": {
|
|
135
|
-
"cursor-delegate
|
|
135
|
+
"cursor-delegate": {
|
|
136
136
|
"type": "stdio",
|
|
137
137
|
"command": "npx",
|
|
138
138
|
"args": ["-y", "cursor-delegate-mcp"]
|
|
@@ -152,7 +152,7 @@ Add the following server to the client's MCP config:
|
|
|
152
152
|
```json
|
|
153
153
|
{
|
|
154
154
|
"mcpServers": {
|
|
155
|
-
"cursor-delegate
|
|
155
|
+
"cursor-delegate": {
|
|
156
156
|
"command": "npx",
|
|
157
157
|
"args": ["-y", "cursor-delegate-mcp"]
|
|
158
158
|
}
|
package/SECURITY.md
CHANGED
|
@@ -11,7 +11,7 @@ Treat every `delegate` call like handing an engineer write access to that tree.
|
|
|
11
11
|
## Recommendations
|
|
12
12
|
|
|
13
13
|
- Point `workspace` at the smallest directory that contains the task (not `$HOME` or `/`).
|
|
14
|
-
- Review `
|
|
14
|
+
- Review `filesReportedByEditTools` and the git diff before committing.
|
|
15
15
|
- Use `mode: "plan"` when you only want a plan, not file changes.
|
|
16
16
|
- Run verification (tests, lint) after delegation — the delegate skill asks Claude to do
|
|
17
17
|
this, but automated gates in CI are still your backstop.
|
package/TERMS.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Terms of Use
|
|
2
2
|
|
|
3
|
-
Cursor Delegate
|
|
3
|
+
Cursor Delegate is provided under the MIT License on an "as is" basis, without warranties or guarantees.
|
|
4
4
|
|
|
5
5
|
The plugin runs locally and starts `cursor-agent` with access to the workspace selected for a delegation. Delegated agent-mode tasks may create, modify, or delete files. You are responsible for choosing an appropriate workspace, reviewing changes, protecting credentials, and complying with the terms that apply to Cursor, your MCP host, and any model you select.
|
|
6
6
|
|
package/package.json
CHANGED
package/src/acp-client.js
CHANGED
|
@@ -9,10 +9,9 @@ import { VERSION } from "./version.js";
|
|
|
9
9
|
const STDERR_CAP = 64 * 1024;
|
|
10
10
|
|
|
11
11
|
export class AcpClient extends EventEmitter {
|
|
12
|
-
constructor({ spawnSpec,
|
|
12
|
+
constructor({ spawnSpec, mode, onCreatePlan, onTodos } = {}) {
|
|
13
13
|
super();
|
|
14
14
|
this.spawnSpec = spawnSpec || resolveAcpSpawn();
|
|
15
|
-
this.onElicit = onElicit;
|
|
16
15
|
this.mode = mode;
|
|
17
16
|
this.onCreatePlan = onCreatePlan;
|
|
18
17
|
this.onTodos = onTodos;
|
|
@@ -51,15 +50,19 @@ export class AcpClient extends EventEmitter {
|
|
|
51
50
|
this.router = createRequestRouter({
|
|
52
51
|
respond: (id, r) => this.peer.respond(id, r),
|
|
53
52
|
respondError: (id, c, m) => this.peer.respondError(id, c, m),
|
|
54
|
-
onElicit: this.onElicit,
|
|
55
53
|
onCreatePlan: this.onCreatePlan,
|
|
56
54
|
onTodos: this.onTodos,
|
|
57
55
|
mode: this.mode,
|
|
58
56
|
log: (e) => this.emit("ack", e),
|
|
59
57
|
});
|
|
60
58
|
return new Promise((resolve, reject) => {
|
|
61
|
-
this.child.once("error", (e) =>
|
|
62
|
-
|
|
59
|
+
this.child.once("error", (e) => {
|
|
60
|
+
// Tagged like every other failure class so the caller gets
|
|
61
|
+
// "delegate failed [spawn-failed]: ..." instead of the one untagged prose error.
|
|
62
|
+
const err = new Error(`Failed to spawn agent (${command}): ${e.message}. Install Cursor CLI and run 'cursor-agent login'.`);
|
|
63
|
+
err.reason = "spawn-failed";
|
|
64
|
+
reject(err);
|
|
65
|
+
});
|
|
63
66
|
this.child.once("spawn", () => resolve());
|
|
64
67
|
});
|
|
65
68
|
}
|
package/src/delegate.js
CHANGED
|
@@ -23,6 +23,15 @@ function fmtDuration(ms) {
|
|
|
23
23
|
return s < 60 ? `${s}s` : `${Math.floor(s / 60)}m${String(s % 60).padStart(2, "0")}s`;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
// Cutting a UTF-16 string at an arbitrary index can split a surrogate pair and leave a lone
|
|
27
|
+
// half-character — ill-formed Unicode that strict JSON consumers reject or mangle. Step back
|
|
28
|
+
// one unit when the boundary would land inside a pair.
|
|
29
|
+
function cutAtCodePoint(s, n) {
|
|
30
|
+
if (n >= s.length) return s;
|
|
31
|
+
const cu = s.charCodeAt(n - 1);
|
|
32
|
+
return s.slice(0, cu >= 0xd800 && cu <= 0xdbff ? n - 1 : n);
|
|
33
|
+
}
|
|
34
|
+
|
|
26
35
|
// Two different questions, and conflating them is what made a typo'd brief cost a live turn.
|
|
27
36
|
// "Could this be a path?" is deliberately loose — a one-line brief ending in .md is worth a
|
|
28
37
|
// stat. "Was a path clearly intended?" has to be strict, because an ordinary inline spec
|
|
@@ -169,20 +178,32 @@ function assertKnownModel(client, model) {
|
|
|
169
178
|
// rejection as the answer. Two distinct -32602s, both measured: "Unknown model config
|
|
170
179
|
// option: X" means this model has no such knob — report it and carry on. "Invalid value
|
|
171
180
|
// for X: Y" means the caller named a value the model rejects, which must not be swallowed.
|
|
172
|
-
// Returns true when the
|
|
181
|
+
// Returns { unsupported, res }: unsupported is true when the model has no such knob; res is the
|
|
182
|
+
// set_config_option reply, which echoes the now-current model's configOptions (incl. the served
|
|
183
|
+
// model id) — the only place the agent reports what model actually took after set_model.
|
|
173
184
|
async function applyConfig(client, sessionId, configId, value) {
|
|
174
185
|
try {
|
|
175
|
-
await client.setConfigOption(sessionId, configId, value);
|
|
176
|
-
return false;
|
|
186
|
+
const res = await client.setConfigOption(sessionId, configId, value);
|
|
187
|
+
return { unsupported: false, res };
|
|
177
188
|
} catch (err) {
|
|
178
189
|
if (err?.code !== -32602 || !/unknown model config option/i.test(err?.message || "")) throw err;
|
|
179
|
-
return true;
|
|
190
|
+
return { unsupported: true };
|
|
180
191
|
}
|
|
181
192
|
}
|
|
182
193
|
|
|
194
|
+
// The agent reports the resolved model only inside a set_config_option reply's configOptions
|
|
195
|
+
// (set_model itself returns nothing). Read it there when present; absent for models that reject
|
|
196
|
+
// every option we send, which is fine — the field then stays off.
|
|
197
|
+
function servedModelFrom(res) {
|
|
198
|
+
const opts = res?.configOptions;
|
|
199
|
+
if (!Array.isArray(opts)) return undefined;
|
|
200
|
+
const m = opts.find((o) => o?.id === "model");
|
|
201
|
+
return typeof m?.currentValue === "string" ? m.currentValue : undefined;
|
|
202
|
+
}
|
|
203
|
+
|
|
183
204
|
export async function runDelegate({
|
|
184
|
-
spec, mode = "agent", resumeSessionId, workspace,
|
|
185
|
-
model = DEFAULT_MODEL, fast = false, reasoning, context, contextFiles, clientFactory,
|
|
205
|
+
spec, mode = "agent", resumeSessionId, workspace,
|
|
206
|
+
model = DEFAULT_MODEL, fast = false, reasoning, context, contextFiles, clientFactory,
|
|
186
207
|
idleMs, handshakeMs, hardCapMs, timeoutMs,
|
|
187
208
|
onSessionReady, onProgress, progressThrottleMs = 2000,
|
|
188
209
|
heartbeatMs = DEFAULT_HEARTBEAT_MS,
|
|
@@ -202,17 +223,6 @@ export async function runDelegate({
|
|
|
202
223
|
const turnIdleMs = idleMs ?? envMs("CURSOR_DELEGATE_IDLE_MS", 0);
|
|
203
224
|
const MAX_OUTPUT = 10 * 1024 * 1024;
|
|
204
225
|
const TRUNCATION_MARKER = "\n\n[output truncated at 10MB]";
|
|
205
|
-
const questionsAsked = [];
|
|
206
|
-
const recordQuestions = (q) => {
|
|
207
|
-
if (q.kind !== "ask_question") return;
|
|
208
|
-
for (const question of q.questions || []) {
|
|
209
|
-
if (typeof question?.prompt === "string" && question.prompt) questionsAsked.push(question.prompt);
|
|
210
|
-
}
|
|
211
|
-
};
|
|
212
|
-
const wrappedElicit = onElicit
|
|
213
|
-
? async (q) => { recordQuestions(q); return onElicit(q); }
|
|
214
|
-
: async (q) => { recordQuestions(q); return null; };
|
|
215
|
-
|
|
216
226
|
// merge:false replaces the list, merge:true upserts by id. Entries always arrive complete,
|
|
217
227
|
// so a keyed set is enough — no field-level merging.
|
|
218
228
|
let todos = new Map();
|
|
@@ -309,7 +319,7 @@ export async function runDelegate({
|
|
|
309
319
|
};
|
|
310
320
|
|
|
311
321
|
const make = clientFactory || ((opts) => new AcpClient(opts));
|
|
312
|
-
const client = make({
|
|
322
|
+
const client = make({ mode, onCreatePlan: recordCreatePlan, onTodos: recordTodos });
|
|
313
323
|
const supervisor = new SessionSupervisor(client, { idleMs: turnIdleMs, handshakeMs: shakeMs, hardCapMs: capMs });
|
|
314
324
|
const onAbort = () => supervisor.abort();
|
|
315
325
|
signal?.addEventListener("abort", onAbort, { once: true });
|
|
@@ -342,8 +352,9 @@ export async function runDelegate({
|
|
|
342
352
|
resultChunks.push(text);
|
|
343
353
|
resultLength += text.length;
|
|
344
354
|
} else if (remaining > 0) {
|
|
345
|
-
|
|
346
|
-
|
|
355
|
+
const cut = cutAtCodePoint(text, remaining);
|
|
356
|
+
resultChunks.push(cut);
|
|
357
|
+
resultLength += cut.length;
|
|
347
358
|
truncated = true;
|
|
348
359
|
} else {
|
|
349
360
|
truncated = true;
|
|
@@ -414,19 +425,6 @@ export async function runDelegate({
|
|
|
414
425
|
// The bridge cannot see inside a running shell command, so a long silence is reported
|
|
415
426
|
// rather than acted on: the caller gets elapsed time and frame age and can decide.
|
|
416
427
|
let lastToolLabel = null;
|
|
417
|
-
// A shell write arrives as execute, a file write as edit; delete and move round out ACP's
|
|
418
|
-
// write-capable kinds. read, search, think and fetch stay out — a plan turn is expected
|
|
419
|
-
// to do those.
|
|
420
|
-
const WRITE_CAPABLE_KINDS = new Set(["edit", "delete", "move", "execute"]);
|
|
421
|
-
// Scoped to plan/ask deliberately. In agent mode this is every turn and carries nothing;
|
|
422
|
-
// in plan/ask a disk-touching turn is abnormal — the plan itself travels over ACP as a
|
|
423
|
-
// string via cursor/create_plan, not as a file — so the base rate makes it worth reading.
|
|
424
|
-
// It records what the agent *ran*, never what changed: a command is not a change list.
|
|
425
|
-
const WRITE_ACTIVITY_CAP = 20;
|
|
426
|
-
const watchingWrites = mode === "plan" || mode === "ask";
|
|
427
|
-
let writeCapableActivity = [];
|
|
428
|
-
let writeActivityById = new Map();
|
|
429
|
-
let modeChanged;
|
|
430
428
|
let sessionTitle;
|
|
431
429
|
let promptInFlight = false;
|
|
432
430
|
let heartbeat = null;
|
|
@@ -456,15 +454,12 @@ export async function runDelegate({
|
|
|
456
454
|
if (up.sessionUpdate === "plan") {
|
|
457
455
|
planEntries = up.entries || [];
|
|
458
456
|
}
|
|
459
|
-
//
|
|
460
|
-
//
|
|
461
|
-
//
|
|
462
|
-
|
|
463
|
-
modeChanged = { from: mode, to: up.currentModeId };
|
|
464
|
-
}
|
|
465
|
-
// The agent names the turn a beat after the prompt lands ("File Creator"). Cheap
|
|
466
|
-
// label for a caller juggling several delegations.
|
|
457
|
+
// The agent names the turn a beat after the prompt lands ("File Creator"). Useful as an
|
|
458
|
+
// ephemeral label while several delegations run, and in timeout forensics — but not in
|
|
459
|
+
// the result, where it arrives after there is nothing left to tell apart and has been
|
|
460
|
+
// measured contradicting the answer ("No Image Detected" on a turn describing an image).
|
|
467
461
|
if (up.sessionUpdate === "session_info_update" && typeof up.title === "string" && up.title) {
|
|
462
|
+
if (up.title !== sessionTitle) { try { onProgress?.(`turn titled: ${up.title}`.slice(0, 200)); } catch {} }
|
|
468
463
|
sessionTitle = up.title;
|
|
469
464
|
}
|
|
470
465
|
if (up.sessionUpdate === "agent_thought_chunk" && up.content?.text) {
|
|
@@ -475,15 +470,6 @@ export async function runDelegate({
|
|
|
475
470
|
const label = up.title || up.kind || "tool";
|
|
476
471
|
const path = up.locations?.[0]?.path;
|
|
477
472
|
lastToolLabel = String(label) + (path ? " — " + path : "");
|
|
478
|
-
if (watchingWrites && WRITE_CAPABLE_KINDS.has(up.kind) && writeCapableActivity.length < WRITE_ACTIVITY_CAP) {
|
|
479
|
-
const entry = { kind: up.kind, detail: lastToolLabel.slice(0, 300) };
|
|
480
|
-
writeCapableActivity.push(entry);
|
|
481
|
-
// An execute call names itself — its title is the shell command. An edit call does
|
|
482
|
-
// not: the title is a bare "Edit File" and locations is empty, so the only thing
|
|
483
|
-
// separating docs/plan.md from src/api.js is the diff frame that follows. Keep the
|
|
484
|
-
// id so that frame can fill the path in.
|
|
485
|
-
if (up.toolCallId != null) writeActivityById.set(up.toolCallId, entry);
|
|
486
|
-
}
|
|
487
473
|
try { onProgress?.(("running: " + lastToolLabel).slice(0, 200)); } catch {}
|
|
488
474
|
}
|
|
489
475
|
if (up.sessionUpdate === "agent_message_chunk" && up.content?.text) {
|
|
@@ -496,18 +482,8 @@ export async function runDelegate({
|
|
|
496
482
|
for (const c of up.content || []) {
|
|
497
483
|
if (c.type === "diff" && c.path) {
|
|
498
484
|
touched.add(c.path);
|
|
499
|
-
const pending = writeActivityById.get(up.toolCallId);
|
|
500
|
-
if (pending && !pending.path) {
|
|
501
|
-
pending.path = normalizeAgentReportedFiles([c.path], workspace)[0];
|
|
502
|
-
}
|
|
503
485
|
try { onProgress?.("editing " + c.path); } catch {}
|
|
504
486
|
}
|
|
505
|
-
// cursor-agent has never been observed emitting these; ACP allows an agent to
|
|
506
|
-
// stream tool output this way, so treat it like message text rather than drop it.
|
|
507
|
-
if (c.type === "content" && typeof c.content?.text === "string") {
|
|
508
|
-
if (!sawToolCall || (collectingPostToolResult && activeToolCalls.size === 0)) appendResult(c.content.text);
|
|
509
|
-
messageProgress.push(c.content.text);
|
|
510
|
-
}
|
|
511
487
|
}
|
|
512
488
|
}
|
|
513
489
|
});
|
|
@@ -515,6 +491,7 @@ export async function runDelegate({
|
|
|
515
491
|
let sessionId;
|
|
516
492
|
let resumeError;
|
|
517
493
|
const unsupportedOptions = [];
|
|
494
|
+
let servedModel;
|
|
518
495
|
const contextWarnings = [];
|
|
519
496
|
try {
|
|
520
497
|
const res = await supervisor.supervise(async () => {
|
|
@@ -528,11 +505,16 @@ export async function runDelegate({
|
|
|
528
505
|
assertKnownModel(client, model);
|
|
529
506
|
await client.setModel(sessionId, model);
|
|
530
507
|
// fast is always sent: a resumed session may already have it on, so false is a real
|
|
531
|
-
// instruction. reasoning and context are only sent when the caller named one.
|
|
532
|
-
|
|
508
|
+
// instruction. reasoning and context are only sent when the caller named one. Each reply
|
|
509
|
+
// reports the now-current model; keep the last one seen as the served model.
|
|
510
|
+
const fastResult = await applyConfig(client, sessionId, "fast", fast);
|
|
511
|
+
if (fastResult.unsupported && fast) unsupportedOptions.push("fast");
|
|
512
|
+
else servedModel = servedModelFrom(fastResult.res) ?? servedModel;
|
|
533
513
|
for (const [id, value] of [["reasoning", reasoning], ["context", context]]) {
|
|
534
514
|
if (value === undefined) continue;
|
|
535
|
-
|
|
515
|
+
const r = await applyConfig(client, sessionId, id, value);
|
|
516
|
+
if (r.unsupported) unsupportedOptions.push(id);
|
|
517
|
+
else servedModel = servedModelFrom(r.res) ?? servedModel;
|
|
536
518
|
}
|
|
537
519
|
await client.setMode(sessionId, mode);
|
|
538
520
|
resetResult();
|
|
@@ -547,11 +529,8 @@ export async function runDelegate({
|
|
|
547
529
|
todos = new Map();
|
|
548
530
|
sawTodoFrame = false;
|
|
549
531
|
discardedResult = "";
|
|
550
|
-
writeCapableActivity = [];
|
|
551
|
-
writeActivityById = new Map();
|
|
552
532
|
touched.clear();
|
|
553
533
|
lastToolLabel = null;
|
|
554
|
-
modeChanged = undefined;
|
|
555
534
|
sessionTitle = undefined;
|
|
556
535
|
supervisor.promptStarted();
|
|
557
536
|
startHeartbeat();
|
|
@@ -571,44 +550,21 @@ export async function runDelegate({
|
|
|
571
550
|
: "none";
|
|
572
551
|
const protocolWarnings = [];
|
|
573
552
|
// plan.detail is the model restating — into chat's sibling channel — a plan it also filed via
|
|
574
|
-
// create_plan
|
|
575
|
-
// one ACP payload. The detail is never load-bearing: the plan lives in the agent's own session
|
|
553
|
+
// create_plan. The detail is never load-bearing: the plan lives in the agent's own session
|
|
576
554
|
// (which is what a resume-to-implement reads, not this field) and the orchestrator approves
|
|
577
|
-
// from result + plan.entries. So in plan/ask
|
|
578
|
-
//
|
|
579
|
-
//
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
dropPlanDetail = true;
|
|
585
|
-
if (!(finalMessageAvailable && result.length >= PLAN_TERSE_FLOOR)) {
|
|
586
|
-
result = planDetail;
|
|
587
|
-
resultSource = "plan-detail";
|
|
588
|
-
}
|
|
589
|
-
}
|
|
590
|
-
if (resultSource !== "plan-detail") {
|
|
591
|
-
if (!finalMessageAvailable && discardedResult) {
|
|
592
|
-
result = discardedResult;
|
|
593
|
-
resultSource = "pre-tool-fallback";
|
|
594
|
-
protocolWarnings.push(
|
|
595
|
-
"the agent ran a tool after its last message and never spoke again, so no final message closed the turn."
|
|
596
|
-
+ " result carries the last message before that tool call — it may be a preamble rather than the answer."
|
|
597
|
-
);
|
|
598
|
-
} else if (!finalMessageAvailable) {
|
|
599
|
-
protocolWarnings.push("the agent ended the turn without emitting any message; result is empty.");
|
|
600
|
-
}
|
|
601
|
-
}
|
|
602
|
-
// A runaway reply comes back whole and can blow the caller's context (104K chars in one
|
|
603
|
-
// test). When the caller sets a ceiling, cut the result to it and say so, so the truncation
|
|
604
|
-
// is never mistaken for a complete answer.
|
|
605
|
-
if (Number.isFinite(maxResultChars) && maxResultChars > 0 && result.length > maxResultChars) {
|
|
606
|
-
const original = result.length;
|
|
607
|
-
result = result.slice(0, maxResultChars) + `\n\n[result truncated at ${maxResultChars} chars]`;
|
|
555
|
+
// from result + plan.entries. So in plan/ask drop the detail and let result be the agent's own
|
|
556
|
+
// message verbatim — no bridge-side guess at whether that message "is really the plan". In
|
|
557
|
+
// agent mode the plan was accepted and result is the implementation report — both stay.
|
|
558
|
+
const dropPlanDetail = typeof planDetail === "string" && (mode === "plan" || mode === "ask");
|
|
559
|
+
if (!finalMessageAvailable && discardedResult) {
|
|
560
|
+
result = discardedResult;
|
|
561
|
+
resultSource = "pre-tool-fallback";
|
|
608
562
|
protocolWarnings.push(
|
|
609
|
-
|
|
610
|
-
+ "
|
|
563
|
+
"the agent ran a tool after its last message and never spoke again, so no final message closed the turn."
|
|
564
|
+
+ " result carries the last message before that tool call — it may be a preamble rather than the answer."
|
|
611
565
|
);
|
|
566
|
+
} else if (!finalMessageAvailable) {
|
|
567
|
+
protocolWarnings.push("the agent ended the turn without emitting any message; result is empty.");
|
|
612
568
|
}
|
|
613
569
|
let stopReason;
|
|
614
570
|
if (res?.stopReason !== undefined) {
|
|
@@ -623,41 +579,43 @@ export async function runDelegate({
|
|
|
623
579
|
}
|
|
624
580
|
const out = {
|
|
625
581
|
result,
|
|
626
|
-
resultSource,
|
|
627
|
-
finalMessageAvailable,
|
|
628
582
|
sessionId,
|
|
629
|
-
filesReportedByAgent: normalizeAgentReportedFiles([...touched], workspace),
|
|
630
|
-
resumed: !!resumeSessionId && sessionId === resumeSessionId,
|
|
631
583
|
};
|
|
584
|
+
// Like every other collection here, absence means "nothing reported": an empty list on
|
|
585
|
+
// every read-only turn read as a claim that nothing changed, which this field cannot make
|
|
586
|
+
// (shell-driven edits leave no diff event).
|
|
587
|
+
const filesReported = normalizeAgentReportedFiles([...touched], workspace);
|
|
588
|
+
if (filesReported.length) out.filesReportedByEditTools = filesReported;
|
|
589
|
+
// resultSource is a caveat, not a fact worth stating on every turn: on the happy path
|
|
590
|
+
// (post-tool / tool-free-stream) result is simply the answer, so say nothing. Surface it only
|
|
591
|
+
// when it warns — pre-tool-fallback, none. finalMessageAvailable is dropped outright: it
|
|
592
|
+
// stated the same thing in a second boolean. resumed is emitted only when a resume actually
|
|
593
|
+
// took; a fresh session or a failed resume (which carries its own warning) leaves it absent.
|
|
594
|
+
if (resultSource !== "post-tool" && resultSource !== "tool-free-stream") out.resultSource = resultSource;
|
|
595
|
+
if (!!resumeSessionId && sessionId === resumeSessionId) out.resumed = true;
|
|
596
|
+
// Only when the agent served a different model than asked — e.g. "default" routing to a
|
|
597
|
+
// concrete id, or a cross-model resume. Silence means the request was honored.
|
|
598
|
+
if (servedModel !== undefined && servedModel !== model) out.effectiveModel = servedModel;
|
|
632
599
|
if (stopReason !== undefined) out.stopReason = stopReason;
|
|
633
|
-
//
|
|
634
|
-
//
|
|
635
|
-
if (questionsAsked.length) out.questionsAsked = questionsAsked;
|
|
636
|
-
if (sessionTitle) out.sessionTitle = sessionTitle;
|
|
600
|
+
// sessionTitle stays out of the result: it is a live label (progress) and a forensic one
|
|
601
|
+
// (timeout errors), not a fact about the finished turn.
|
|
637
602
|
if (resumeError) protocolWarnings.push(`resuming ${resumeSessionId} failed, started a fresh session: ${resumeError}`);
|
|
638
603
|
for (const id of unsupportedOptions) protocolWarnings.push(`model ${model} has no ${id} option; the requested value was ignored`);
|
|
639
604
|
protocolWarnings.push(...contextWarnings);
|
|
640
605
|
if (planEntries.length > 0 || planOverview !== undefined || planDetail !== undefined) {
|
|
641
606
|
out.plan = sanitizePlan(protocolWarnings);
|
|
642
|
-
// In plan/ask
|
|
643
|
-
//
|
|
644
|
-
// overview are structured and unique, and always stay.
|
|
607
|
+
// In plan/ask result already carries the agent's own plan message, so the detail here is a
|
|
608
|
+
// duplicate — drop it. entries and overview are structured and unique, and always stay.
|
|
645
609
|
if (dropPlanDetail) delete out.plan.detail;
|
|
646
610
|
}
|
|
647
611
|
// Most successful turns emit no todos at all, so an empty list would read as "nothing
|
|
648
|
-
// done" rather than "not tracked". Report only what the agent actually sent
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
protocolWarnings
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
+ " for what ran, and the diff for what changed."
|
|
656
|
-
);
|
|
657
|
-
}
|
|
658
|
-
if (modeChanged) {
|
|
659
|
-
out.modeChanged = modeChanged;
|
|
660
|
-
protocolWarnings.push(`agent switched mode from ${modeChanged.from} to ${modeChanged.to} mid-session`);
|
|
612
|
+
// done" rather than "not tracked". Report only what the agent actually sent — and of
|
|
613
|
+
// that, the full list only when it says something todoProgress cannot: which items
|
|
614
|
+
// remain. On a fully-completed turn the list restates the counts entry by entry.
|
|
615
|
+
if (sawTodoFrame) {
|
|
616
|
+
const { todos: todoList, todoProgress } = sanitizeTodos(protocolWarnings);
|
|
617
|
+
out.todoProgress = todoProgress;
|
|
618
|
+
if (todoProgress.completed < todoProgress.total) out.todos = todoList;
|
|
661
619
|
}
|
|
662
620
|
if (protocolWarnings.length) out.protocolWarnings = protocolWarnings;
|
|
663
621
|
return out;
|
|
@@ -694,9 +652,11 @@ export async function runDelegate({
|
|
|
694
652
|
}
|
|
695
653
|
if (sessionId) err.message += ` Resume with resumeSessionId ${sessionId}.`;
|
|
696
654
|
if (isTimeout) {
|
|
655
|
+
// Name the knob that actually fired: raising the hard cap does nothing for an
|
|
656
|
+
// idle-timeout, whose ceiling is CURSOR_DELEGATE_IDLE_MS.
|
|
657
|
+
const knob = err.reason === "idle-timeout" ? "CURSOR_DELEGATE_IDLE_MS" : "CURSOR_DELEGATE_HARD_CAP_MS";
|
|
697
658
|
err.message += " cursor-agent does not stream shell output over ACP, so a long-running command emits"
|
|
698
|
-
+
|
|
699
|
-
+ " CURSOR_DELEGATE_HARD_CAP_MS.";
|
|
659
|
+
+ ` nothing until it exits. Split the command, run it in the background and poll, or raise ${knob}.`;
|
|
700
660
|
}
|
|
701
661
|
}
|
|
702
662
|
// Opt-in, because the frames land in the caller's context and nothing there is
|
package/src/doctor.js
CHANGED
package/src/request-router.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const ACK_METHODS = new Set(["cursor/task", "cursor/generate_image"]);
|
|
2
2
|
|
|
3
|
-
export function createRequestRouter({ respond, respondError,
|
|
3
|
+
export function createRequestRouter({ respond, respondError, onCreatePlan, onTodos, mode = "agent", log = () => {} }) {
|
|
4
4
|
return async function handle(id, method, params) {
|
|
5
5
|
try {
|
|
6
6
|
if (method === "session/request_permission") {
|
|
@@ -11,15 +11,6 @@ export function createRequestRouter({ respond, respondError, onElicit, onCreateP
|
|
|
11
11
|
opts[0];
|
|
12
12
|
return respond(id, { outcome: { outcome: "selected", optionId: pick?.optionId } });
|
|
13
13
|
}
|
|
14
|
-
if (method === "cursor/ask_question") {
|
|
15
|
-
const ans = onElicit
|
|
16
|
-
? await onElicit({ kind: "ask_question", title: params?.title, questions: params?.questions || [], raw: params })
|
|
17
|
-
: null;
|
|
18
|
-
if (ans?.answers?.length) {
|
|
19
|
-
return respond(id, { outcome: { outcome: "answered", answers: ans.answers } });
|
|
20
|
-
}
|
|
21
|
-
return respond(id, { outcome: { outcome: "cancelled" } });
|
|
22
|
-
}
|
|
23
14
|
if (method === "cursor/create_plan") {
|
|
24
15
|
onCreatePlan?.({
|
|
25
16
|
overview: params?.overview,
|
package/src/server.js
CHANGED
|
@@ -30,7 +30,7 @@ function rememberSession(set, id) {
|
|
|
30
30
|
// Loaded at connect, before any tool schema is, so this carries only pre-call facts: what a
|
|
31
31
|
// caller needs to decide whether to delegate at all. Call-time facts belong on the parameter
|
|
32
32
|
// descriptions, read while the call is being written.
|
|
33
|
-
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;
|
|
33
|
+
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.`;
|
|
34
34
|
|
|
35
35
|
const planEntrySchema = z.object({
|
|
36
36
|
content: z.string(),
|
|
@@ -40,49 +40,39 @@ const planEntrySchema = z.object({
|
|
|
40
40
|
|
|
41
41
|
const delegateOutputSchema = z.object({
|
|
42
42
|
result: z.string(),
|
|
43
|
-
resultSource: z.enum(["
|
|
44
|
-
"
|
|
43
|
+
resultSource: z.enum(["pre-tool-fallback", "none"]).optional().describe(
|
|
44
|
+
"Present only as a caveat on result; absent on the happy path, where result is simply the agent's answer. pre-tool-fallback: no final message closed the turn and result is the last message before the agent's final tool call — read protocolWarnings before trusting it. none: the turn produced no message and result is empty."
|
|
45
|
+
),
|
|
46
|
+
effectiveModel: z.string().optional().describe(
|
|
47
|
+
"The model id the agent reported serving, present only when it differs from the model you requested — e.g. \"default\" resolving to a concrete id, or a cross-model resume. Read from the agent's post-set_model config report; absent when the agent confirmed the requested id or reported no model (some models report none)."
|
|
45
48
|
),
|
|
46
|
-
finalMessageAvailable: z.boolean().optional(),
|
|
47
49
|
stopReason: z.string().optional().describe(
|
|
48
50
|
"Present only when it is not the ordinary end_turn — a refusal, a cancel, or an output cap. Absence means the turn ended normally."
|
|
49
51
|
),
|
|
50
52
|
sessionId: z.string(),
|
|
51
|
-
|
|
52
|
-
"Files the agent reported
|
|
53
|
-
),
|
|
54
|
-
questionsAsked: z.array(z.string()).optional().describe(
|
|
55
|
-
"Clarifying questions the agent raised through elicitation. Absent on most turns — the agent usually asks in prose and ends the turn, which this does not capture; read result for that."
|
|
53
|
+
filesReportedByEditTools: z.array(z.string()).optional().describe(
|
|
54
|
+
"Files the agent's edit tools reported changing, via native ACP diff events. Absent when they reported none — which is not proof nothing changed: shell-driven edits leave no diff event; the git diff is authoritative."
|
|
56
55
|
),
|
|
57
|
-
resumed: z.boolean().optional()
|
|
58
|
-
|
|
59
|
-
"Short title the agent gave this turn. Present on most turns; purely a label."
|
|
56
|
+
resumed: z.boolean().optional().describe(
|
|
57
|
+
"Present and true only when a requested resume took (the returned session id matched resumeSessionId). Absent for a fresh session, or when a resume failed — a failed resume is reported in protocolWarnings."
|
|
60
58
|
),
|
|
61
|
-
autoAnswered: z.array(z.object({ prompt: z.string(), chosen: z.string() })).optional(),
|
|
62
|
-
fallbackAnswers: z.array(z.object({ prompt: z.string(), given: z.string(), chosen: z.string() })).optional(),
|
|
63
59
|
cancelRequested: z.boolean().optional(),
|
|
64
60
|
protocolWarnings: z.array(z.string()).optional().describe(
|
|
65
|
-
"Non-fatal diagnostics that did not justify failing the call — dropped or sanitized ACP fields, a failed resume, ignored model options, skipped contextFiles
|
|
61
|
+
"Non-fatal diagnostics that did not justify failing the call — dropped or sanitized ACP fields, a failed resume, ignored model options, skipped contextFiles. Read whenever present."
|
|
66
62
|
),
|
|
67
63
|
plan: z.object({
|
|
68
64
|
entries: z.array(planEntrySchema),
|
|
69
65
|
overview: z.string().optional(),
|
|
70
66
|
detail: z.string().optional(),
|
|
71
67
|
}).optional().describe(
|
|
72
|
-
"The agent's plan. entries and overview are the structured plan and always present when a plan exists. detail (a prose rendition the agent also filed) is kept only in agent mode; in plan/ask it is dropped because result already carries the
|
|
68
|
+
"The agent's plan. entries and overview are the structured plan and always present when a plan exists. detail (a prose rendition the agent also filed) is kept only in agent mode; in plan/ask it is dropped because result already carries the agent's own plan message. To act on a plan, resume the sessionId rather than forwarding detail: the plan lives in the agent's session."
|
|
73
69
|
),
|
|
74
70
|
todos: z.array(z.object({
|
|
75
71
|
id: z.string(),
|
|
76
72
|
content: z.string(),
|
|
77
73
|
status: z.enum(["pending", "in_progress", "completed"]).optional(),
|
|
78
74
|
})).optional().describe(
|
|
79
|
-
"Todo
|
|
80
|
-
),
|
|
81
|
-
modeChanged: z.object({ from: z.string(), to: z.string() }).optional().describe(
|
|
82
|
-
"Set when the agent switched itself out of the requested mode mid-session. Absence does not mean the mode was honored — an agent can write while staying in plan."
|
|
83
|
-
),
|
|
84
|
-
writeCapableActivity: z.array(z.object({ kind: z.string(), detail: z.string(), path: z.string().optional() })).optional().describe(
|
|
85
|
-
"Write-capable tool calls (edit/delete/move/execute) the agent ran during a plan or ask turn, which are expected to change nothing. Records what ran, not what changed — kind is what the tool could do, not proof it wrote: an execute entry may be a read-only command like `ls -la`. Read detail for the evidence and the git diff for the truth. Only populated for mode plan and ask."
|
|
75
|
+
"Todo items the agent left unfinished, present only when todoProgress shows completed < total — read it to see what remains before resuming. Absent both when the agent tracked no todos (common on short tasks) and when everything tracked was completed; todoProgress tells those apart."
|
|
86
76
|
),
|
|
87
77
|
todoProgress: z.object({
|
|
88
78
|
total: z.number(),
|
|
@@ -98,7 +88,6 @@ const doctorOutputSchema = z.object({
|
|
|
98
88
|
name: z.string().nullable(),
|
|
99
89
|
version: z.string().nullable(),
|
|
100
90
|
capabilities: z.record(z.unknown()),
|
|
101
|
-
supportsElicitation: z.boolean(),
|
|
102
91
|
}).passthrough(),
|
|
103
92
|
agent: z.object({ found: z.boolean() }).passthrough(),
|
|
104
93
|
runtime: z.object({
|
|
@@ -113,7 +102,7 @@ const doctorOutputSchema = z.object({
|
|
|
113
102
|
|
|
114
103
|
export const delegateInputSchema = z.object({
|
|
115
104
|
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."),
|
|
116
|
-
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
|
|
105
|
+
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."),
|
|
117
106
|
resumeSessionId: z.string().optional().describe("Resume an existing ACP session instead of a new one"),
|
|
118
107
|
workspace: z.string().optional().describe("Working directory for the agent (defaults to cwd). Must be an existing directory; the call fails rather than creating it."),
|
|
119
108
|
model: z.string().trim().min(1, "model must be a non-empty string").default(DEFAULT_MODEL),
|
|
@@ -123,26 +112,10 @@ export const delegateInputSchema = z.object({
|
|
|
123
112
|
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."),
|
|
124
113
|
context: z.string().trim().min(1).optional().describe("Context window size. Not offered by every model; gpt-5.x accepts 272k and 1m."),
|
|
125
114
|
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."),
|
|
126
|
-
maxResultChars: z.number().int().positive().optional().describe("Cap the returned result to this many characters. A longer result is truncated with a marker and a protocolWarning, so a runaway agent reply cannot blow up your context; the truncation is never reported as a complete answer."),
|
|
127
115
|
});
|
|
128
116
|
|
|
129
|
-
// A cursor/ask_question question is multi-select when it sets allowMultiple, and the answer
|
|
130
|
-
// field (selectedOptionIds) is a list either way. Only split on commas for those, so a
|
|
131
|
-
// single-select label that itself contains a comma still matches whole.
|
|
132
|
-
function matchOptions(choice, opts = [], allowMultiple = false) {
|
|
133
|
-
const norm = (s) => String(s ?? "").trim().toLowerCase();
|
|
134
|
-
const ids = [];
|
|
135
|
-
for (const part of allowMultiple ? String(choice).split(",") : [String(choice)]) {
|
|
136
|
-
const want = norm(part);
|
|
137
|
-
if (!want) continue;
|
|
138
|
-
const hit = opts.find((o) => norm(o.id) === want || norm(o.label) === want);
|
|
139
|
-
if (hit && !ids.includes(hit.id)) ids.push(hit.id);
|
|
140
|
-
}
|
|
141
|
-
return ids;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
117
|
export async function runDelegateTool({ args, extra, server, runDelegate, inFlight, seenSessions = new Set() }) {
|
|
145
|
-
const { spec, mode, resumeSessionId, workspace, model, fast, reasoning, context, contextFiles
|
|
118
|
+
const { spec, mode, resumeSessionId, workspace, model, fast, reasoning, context, contextFiles } = args;
|
|
146
119
|
|
|
147
120
|
const progressToken = extra?._meta?.progressToken;
|
|
148
121
|
let onProgress = () => {};
|
|
@@ -158,57 +131,6 @@ export async function runDelegateTool({ args, extra, server, runDelegate, inFlig
|
|
|
158
131
|
};
|
|
159
132
|
}
|
|
160
133
|
|
|
161
|
-
const supportsElicitation = !!server.server.getClientCapabilities?.()?.elicitation;
|
|
162
|
-
const autoAnswered = [];
|
|
163
|
-
const fallbackAnswers = [];
|
|
164
|
-
|
|
165
|
-
const onElicit = async ({ title, questions }) => {
|
|
166
|
-
const answers = [];
|
|
167
|
-
for (const q of questions || []) {
|
|
168
|
-
const opts = q.options || [];
|
|
169
|
-
if (!supportsElicitation) {
|
|
170
|
-
// There is no user to ask, so allowMultiple changes nothing here: selecting every
|
|
171
|
-
// option would consent to more than the caller asked for. Take the first and
|
|
172
|
-
// disclose it. An option-less question answers empty rather than [null].
|
|
173
|
-
const first = opts[0];
|
|
174
|
-
autoAnswered.push({ prompt: String(q.prompt ?? ""), chosen: String(first?.label || first?.id || "") });
|
|
175
|
-
answers.push({ questionId: q.id, selectedOptionIds: first?.id ? [first.id] : [] });
|
|
176
|
-
continue;
|
|
177
|
-
}
|
|
178
|
-
const listing = opts.map((o) => o.label || o.id).join(", ");
|
|
179
|
-
const result = await server.server.elicitInput({
|
|
180
|
-
message: title ? `${title}: ${q.prompt}` : `cursor-agent asks: ${q.prompt}`,
|
|
181
|
-
requestedSchema: {
|
|
182
|
-
type: "object",
|
|
183
|
-
properties: {
|
|
184
|
-
choice: {
|
|
185
|
-
type: "string",
|
|
186
|
-
description: !opts.length
|
|
187
|
-
? "your answer"
|
|
188
|
-
: q.allowMultiple
|
|
189
|
-
? `Options (pick one or more, comma-separated): ${listing}`
|
|
190
|
-
: `Options: ${listing}`,
|
|
191
|
-
},
|
|
192
|
-
},
|
|
193
|
-
required: ["choice"],
|
|
194
|
-
},
|
|
195
|
-
});
|
|
196
|
-
if (result.action !== "accept") return null;
|
|
197
|
-
const choice = result.content?.choice || "";
|
|
198
|
-
const selectedOptionIds = matchOptions(choice, opts, q.allowMultiple);
|
|
199
|
-
if (!selectedOptionIds.length && opts.length) {
|
|
200
|
-
selectedOptionIds.push(opts[0].id);
|
|
201
|
-
fallbackAnswers.push({
|
|
202
|
-
prompt: String(q.prompt ?? ""),
|
|
203
|
-
given: String(choice),
|
|
204
|
-
chosen: String(opts[0].label || opts[0].id || ""),
|
|
205
|
-
});
|
|
206
|
-
}
|
|
207
|
-
answers.push({ questionId: q.id, selectedOptionIds });
|
|
208
|
-
}
|
|
209
|
-
return { answers };
|
|
210
|
-
};
|
|
211
|
-
|
|
212
134
|
let capturedSessionId;
|
|
213
135
|
let handle;
|
|
214
136
|
try {
|
|
@@ -222,8 +144,6 @@ export async function runDelegateTool({ args, extra, server, runDelegate, inFlig
|
|
|
222
144
|
reasoning,
|
|
223
145
|
context,
|
|
224
146
|
contextFiles,
|
|
225
|
-
maxResultChars,
|
|
226
|
-
onElicit,
|
|
227
147
|
onProgress,
|
|
228
148
|
signal: extra?.signal,
|
|
229
149
|
onSessionReady: (sessionId, client) => {
|
|
@@ -238,8 +158,6 @@ export async function runDelegateTool({ args, extra, server, runDelegate, inFlig
|
|
|
238
158
|
onProgress(`session ready: ${sessionId}`);
|
|
239
159
|
},
|
|
240
160
|
});
|
|
241
|
-
if (autoAnswered.length) out.autoAnswered = autoAnswered;
|
|
242
|
-
if (fallbackAnswers.length) out.fallbackAnswers = fallbackAnswers;
|
|
243
161
|
if (handle?.cancelRequested) out.cancelRequested = true;
|
|
244
162
|
return {
|
|
245
163
|
content: [{ type: "text", text: JSON.stringify(out, null, 2) }],
|
|
@@ -269,7 +187,7 @@ export function buildServer({ runDelegate: runDelegateInjected, runDoctor: runDo
|
|
|
269
187
|
"delegate",
|
|
270
188
|
{
|
|
271
189
|
description:
|
|
272
|
-
`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
|
|
190
|
+
`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.`,
|
|
273
191
|
inputSchema: delegateInputSchema,
|
|
274
192
|
outputSchema: delegateOutputSchema,
|
|
275
193
|
annotations: {
|
|
@@ -346,7 +264,7 @@ export function buildServer({ runDelegate: runDelegateInjected, runDoctor: runDo
|
|
|
346
264
|
"doctor",
|
|
347
265
|
{
|
|
348
266
|
description:
|
|
349
|
-
"Report setup and health diagnostics: plugin version, MCP client capabilities
|
|
267
|
+
"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.",
|
|
350
268
|
inputSchema: {
|
|
351
269
|
deep: z
|
|
352
270
|
.boolean()
|