@agent-deck/cli 2.3.2 → 2.5.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.
Files changed (81) hide show
  1. package/dist/agent-harness.js +5 -5
  2. package/dist/bin.js +0 -0
  3. package/dist/codex-plugin.d.ts +33 -8
  4. package/dist/codex-plugin.d.ts.map +1 -1
  5. package/dist/codex-plugin.js +80 -16
  6. package/dist/codex-plugin.js.map +1 -1
  7. package/dist/cursor-mcp-inspect.d.ts +7 -6
  8. package/dist/cursor-mcp-inspect.d.ts.map +1 -1
  9. package/dist/cursor-mcp-inspect.js +59 -30
  10. package/dist/cursor-mcp-inspect.js.map +1 -1
  11. package/dist/debug-mcp.d.ts.map +1 -1
  12. package/dist/debug-mcp.js +50 -12
  13. package/dist/debug-mcp.js.map +1 -1
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +4 -1
  16. package/dist/index.js.map +1 -1
  17. package/dist/launcher-migration.d.ts +22 -0
  18. package/dist/launcher-migration.d.ts.map +1 -0
  19. package/dist/launcher-migration.js +274 -0
  20. package/dist/launcher-migration.js.map +1 -0
  21. package/dist/mcp-bridge.d.ts.map +1 -1
  22. package/dist/mcp-bridge.js +5 -0
  23. package/dist/mcp-bridge.js.map +1 -1
  24. package/dist/mcp-config.d.ts +112 -52
  25. package/dist/mcp-config.d.ts.map +1 -1
  26. package/dist/mcp-config.js +504 -195
  27. package/dist/mcp-config.js.map +1 -1
  28. package/dist/mcp-launcher.d.ts.map +1 -1
  29. package/dist/mcp-launcher.js +7 -0
  30. package/dist/mcp-launcher.js.map +1 -1
  31. package/dist/muse-skills/agent-deck-run/SKILL.md +48 -46
  32. package/dist/muse-skills/agent-deck-session/SKILL.md +9 -6
  33. package/dist/muse-skills/agent-deck-setup/SKILL.md +22 -6
  34. package/dist/setup.d.ts +3 -1
  35. package/dist/setup.d.ts.map +1 -1
  36. package/dist/setup.js +152 -42
  37. package/dist/setup.js.map +1 -1
  38. package/dist/start.d.ts +4 -1
  39. package/dist/start.d.ts.map +1 -1
  40. package/dist/start.js +8 -5
  41. package/dist/start.js.map +1 -1
  42. package/dist/upgrade.d.ts.map +1 -1
  43. package/dist/upgrade.js +33 -5
  44. package/dist/upgrade.js.map +1 -1
  45. package/dist/use.d.ts +1 -1
  46. package/dist/use.d.ts.map +1 -1
  47. package/dist/use.js +92 -48
  48. package/dist/use.js.map +1 -1
  49. package/package.json +3 -3
  50. package/dist/coordinator.d.ts +0 -2
  51. package/dist/coordinator.d.ts.map +0 -1
  52. package/dist/coordinator.js +0 -153
  53. package/dist/coordinator.js.map +0 -1
  54. package/dist/grant-issue.d.ts +0 -39
  55. package/dist/grant-issue.d.ts.map +0 -1
  56. package/dist/grant-issue.js +0 -133
  57. package/dist/grant-issue.js.map +0 -1
  58. package/dist/grant-store.d.ts +0 -35
  59. package/dist/grant-store.d.ts.map +0 -1
  60. package/dist/grant-store.js +0 -302
  61. package/dist/grant-store.js.map +0 -1
  62. package/dist/run-adapter.d.ts +0 -100
  63. package/dist/run-adapter.d.ts.map +0 -1
  64. package/dist/run-adapter.js +0 -73
  65. package/dist/run-adapter.js.map +0 -1
  66. package/dist/run-claude.d.ts +0 -41
  67. package/dist/run-claude.d.ts.map +0 -1
  68. package/dist/run-claude.js +0 -91
  69. package/dist/run-claude.js.map +0 -1
  70. package/dist/run-codex.d.ts +0 -75
  71. package/dist/run-codex.d.ts.map +0 -1
  72. package/dist/run-codex.js +0 -337
  73. package/dist/run-codex.js.map +0 -1
  74. package/dist/run-cursor.d.ts +0 -79
  75. package/dist/run-cursor.d.ts.map +0 -1
  76. package/dist/run-cursor.js +0 -455
  77. package/dist/run-cursor.js.map +0 -1
  78. package/dist/run-muse.d.ts +0 -127
  79. package/dist/run-muse.d.ts.map +0 -1
  80. package/dist/run-muse.js +0 -499
  81. package/dist/run-muse.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"run-cursor.d.ts","sourceRoot":"","sources":["../src/run-cursor.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E,GAAG,EAAE,MAAM,CAAA;CAAE,KAAK,WAAW,CAAC;AAE9F,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE;IAAE,GAAG,EAAE,MAAM,CAAA;CAAE,GAAG,WAAW,CA6ClG;AAED;;;;;GAKG;AACH,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CA4BnE;AAsDD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,MAAM,EACd,IAAI,GAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAO,GAC/B,eAAe,EAAE,CAyJnB;AAED,MAAM,MAAM,iBAAiB,GAAG;IAC9B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,KAAK,CAAC,EAAE,WAAW,CAAC;CACrB,CAAC;AAEF,wBAAgB,mBAAmB,CAAC,IAAI,GAAE,iBAAsB,GAAG,aAAa,CAoF/E"}
@@ -1,455 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.CURSOR_OUTPUT_FORMAT = exports.CURSOR_JSON_VERSION_NOTE = void 0;
7
- exports.resolveCursorBin = resolveCursorBin;
8
- exports.assertSafeCursorResumeId = assertSafeCursorResumeId;
9
- exports.buildCursorArgv = buildCursorArgv;
10
- exports.defaultCursorProbe = defaultCursorProbe;
11
- exports.defaultCursorSpawn = defaultCursorSpawn;
12
- exports.isCursorStatusAuthenticated = isCursorStatusAuthenticated;
13
- exports.cursorEventsFromOutput = cursorEventsFromOutput;
14
- exports.createCursorAdapter = createCursorAdapter;
15
- /**
16
- * Cursor adapter for `agent-deck run` (NOT-406).
17
- *
18
- * Drives `cursor-agent -p --trust --output-format json` (start and resume, the
19
- * latter adding `--resume <chatId>`) as a child process and maps the single
20
- * result object onto normalized events. Verified against cursor-agent
21
- * 2026.10.01 (`cursor-agent --help`, `cursor-agent status --format json`):
22
- *
23
- * - Output format is single-shot `json`, not `stream-json`: the stream-json
24
- * event shape is uncaptured (no incremental events were observed), while
25
- * the owner's smoke test verified `json` returns a result object with
26
- * `session_id`. Consequence: all log lines land when the process exits, so
27
- * status polling shows no intermediate lines for Cursor.
28
- * - The answer text is yielded as one `text` event (so the shared session
29
- * receipt check sees it) followed by `result`; the full result object is
30
- * the `result` payload.
31
- * - Tool mapping: `readonly` passes no write-enabling flag; `edit` passes
32
- * `--force`. `--yolo` (an alias for `--force`) is never passed and no
33
- * option can select it; `--approve-mcps` is never passed (separate owner
34
- * decision required).
35
- * - Deck receipt is mandatory on start (not resume): a success whose output
36
- * lacks a `◆ ... ·` display_summary line fails closed as `error`, because
37
- * Cursor's global MCP entry is last-workspace-wins and a missing receipt
38
- * would otherwise look like a correctly bound run. Resume is exempt (the
39
- * harness prints the receipt on the first turn only).
40
- * - `--force` means "allow commands unless explicitly denied" (auto-approval),
41
- * and `-p` help says print mode "has access to all tools, including write
42
- * and shell", so whether readonly truly cannot write is settled by the
43
- * operator edit-vs-readonly test, not by the flags.
44
- * - `--trust` is passed on every launch (the caller named --cwd explicitly)
45
- * and recorded as `trustOverride: true` in meta.json — the existing meta
46
- * field for "launch bypassed a client workspace-trust guard". Without it
47
- * the CLI prints "Workspace Trust Required" with an empty success, so that
48
- * string (and any empty result at exit 0) fails closed as `error`.
49
- * - Signed-in preflight is `cursor-agent status --format json` (exit 0 even
50
- * when signed out, so the output is parsed, not just the exit code), which
51
- * makes no model call.
52
- * - The prompt is passed after a `--` terminator (verified: `cursor-agent -p
53
- * --trust --output-format json -- --help` treats `--help` as the prompt
54
- * instead of printing help), so dash-leading prompts cannot be parsed as
55
- * options. Resume ids starting with `-` fail closed in planStart.
56
- */
57
- const node_child_process_1 = require("node:child_process");
58
- const node_readline_1 = __importDefault(require("node:readline"));
59
- exports.CURSOR_JSON_VERSION_NOTE = 'cursor-agent 2026.10.01';
60
- /** Single-shot result object; stream-json incremental shape is unverified. */
61
- exports.CURSOR_OUTPUT_FORMAT = 'json';
62
- function resolveCursorBin() {
63
- return process.env.CURSOR_BIN?.trim() || 'cursor-agent';
64
- }
65
- /**
66
- * Resume ids are cursor chat ids (32-hex); a leading `-` is never legitimate
67
- * and would be parsed as a cursor-agent option, so it fails closed in
68
- * planStart and throws here. Belt and suspenders with the `--` placement
69
- * below: this builder never emits a dash-leading id at all.
70
- */
71
- function assertSafeCursorResumeId(resumeId) {
72
- if (resumeId.startsWith('-')) {
73
- throw new Error(`Invalid --resume id ${JSON.stringify(resumeId)}: session ids never start with '-'. ` +
74
- 'Pass the chat id printed as sessionId in a previous run log.');
75
- }
76
- }
77
- /**
78
- * Pure argv builder (everything after the `cursor-agent` binary):
79
- * `-p --trust --output-format json [--force] [--resume <id>] -- <prompt>`.
80
- * `--force` only for the edit profile; `--yolo` and `--approve-mcps` are
81
- * never emitted. The `--` terminator keeps dash-leading prompts from being
82
- * parsed as cursor-agent options.
83
- */
84
- function buildCursorArgv(args) {
85
- const argv = ['-p', '--trust', '--output-format', exports.CURSOR_OUTPUT_FORMAT];
86
- if (args.tools === 'edit') {
87
- argv.push('--force');
88
- }
89
- if (args.resumeId !== undefined) {
90
- assertSafeCursorResumeId(args.resumeId);
91
- argv.push('--resume', args.resumeId);
92
- }
93
- argv.push('--', args.prompt);
94
- return argv;
95
- }
96
- function defaultCursorProbe(bin, argv) {
97
- try {
98
- const probed = (0, node_child_process_1.spawnSync)(bin, argv, { encoding: 'utf8', timeout: 15000 });
99
- return { code: probed.status ?? 1, stdout: probed.stdout ?? '', stderr: probed.stderr ?? '' };
100
- }
101
- catch {
102
- return { code: 127, stdout: '', stderr: '' };
103
- }
104
- }
105
- function defaultCursorSpawn(bin, argv, opts) {
106
- const child = (0, node_child_process_1.spawn)(bin, argv, { cwd: opts.cwd, stdio: ['ignore', 'pipe', 'pipe'] });
107
- let spawnError = null;
108
- child.on('error', (error) => {
109
- spawnError = error;
110
- child.stdout?.destroy();
111
- });
112
- const stderrChunks = [];
113
- child.stderr?.on('data', (chunk) => {
114
- stderrChunks.push(Buffer.from(chunk));
115
- });
116
- async function* lines() {
117
- const rl = node_readline_1.default.createInterface({ input: child.stdout });
118
- try {
119
- for await (const line of rl) {
120
- yield line;
121
- }
122
- }
123
- catch {
124
- // The stdout stream is destroyed when the spawn itself fails; the
125
- // spawn error below is the actionable failure.
126
- }
127
- if (spawnError) {
128
- throw spawnError;
129
- }
130
- }
131
- const wait = () => new Promise((resolve) => {
132
- let settled = false;
133
- const done = (code) => {
134
- if (settled) {
135
- return;
136
- }
137
- settled = true;
138
- resolve({
139
- code,
140
- stderrTail: Buffer.concat(stderrChunks).toString('utf8').slice(-2000),
141
- });
142
- };
143
- child.on('close', done);
144
- child.on('error', () => done(127));
145
- });
146
- return { stdout: lines(), wait };
147
- }
148
- /**
149
- * `cursor-agent status --format json` exits 0 even when signed out
150
- * (`{"status":"unauthenticated","isAuthenticated":false,...}`), so the
151
- * output decides. The `isAuthenticated` boolean wins; the `status` string
152
- * and a text fallback cover older shapes. Unknown output fails closed.
153
- */
154
- function isCursorStatusAuthenticated(output) {
155
- const trimmed = output.trim();
156
- if (trimmed) {
157
- try {
158
- const parsed = JSON.parse(trimmed);
159
- if (typeof parsed === 'object' && parsed !== null) {
160
- const record = parsed;
161
- if (typeof record.isAuthenticated === 'boolean') {
162
- return record.isAuthenticated;
163
- }
164
- if (typeof record.status === 'string') {
165
- const status = record.status.trim().toLowerCase();
166
- if (status === 'authenticated') {
167
- return true;
168
- }
169
- if (status === 'unauthenticated') {
170
- return false;
171
- }
172
- }
173
- }
174
- }
175
- catch {
176
- // Fall through to the text heuristics below.
177
- }
178
- }
179
- if (/not logged in|unauthenticated/i.test(trimmed)) {
180
- return false;
181
- }
182
- return /logged in/i.test(trimmed);
183
- }
184
- function asRecord(value) {
185
- return typeof value === 'object' && value !== null && !Array.isArray(value)
186
- ? value
187
- : null;
188
- }
189
- function nonEmptyString(value) {
190
- return typeof value === 'string' && value ? value : null;
191
- }
192
- function firstString(record, keys) {
193
- for (const key of keys) {
194
- const value = nonEmptyString(record[key]);
195
- if (value) {
196
- return value;
197
- }
198
- }
199
- return null;
200
- }
201
- function stringArray(value) {
202
- if (!Array.isArray(value)) {
203
- return [];
204
- }
205
- return value.filter((entry) => typeof entry === 'string' && !!entry);
206
- }
207
- function toolNames(value) {
208
- if (!Array.isArray(value)) {
209
- return [];
210
- }
211
- const names = [];
212
- for (const entry of value) {
213
- if (typeof entry === 'string' && entry) {
214
- names.push(entry);
215
- continue;
216
- }
217
- const record = asRecord(entry);
218
- if (!record) {
219
- continue;
220
- }
221
- const name = nonEmptyString(record.name) ??
222
- nonEmptyString(record.tool) ??
223
- (nonEmptyString(record.command) ? `command:${record.command}`.slice(0, 200) : null);
224
- if (name) {
225
- names.push(name);
226
- }
227
- }
228
- return names;
229
- }
230
- /**
231
- * Map the single-shot `--output-format json` stdout onto normalized events:
232
- * the result object's `session_id` becomes `sessionId`; the answer text
233
- * becomes one `text` event; tool arrays become `tool` events; warning arrays
234
- * become `notice` events; the full object becomes the `result` payload
235
- * (subtype `success`, or `failed` when the object carries `error`,
236
- * `is_error: true`, or a non-`success` subtype).
237
- *
238
- * Throws (so the shared run code marks the run `error`) on "Workspace Trust
239
- * Required", on empty output at exit 0, on non-JSON output, on a result
240
- * object with no answer text, tool call, or error content (a bare session
241
- * id, including the resume-id fallback, is not content), and — on start
242
- * only, not resume — on a success whose output lacks a `◆ ... ·` deck
243
- * receipt line. Never returns an empty event list: success always ends with
244
- * a `result` event.
245
- */
246
- function cursorEventsFromOutput(stdout, opts = {}) {
247
- if (stdout.includes('Workspace Trust Required')) {
248
- throw new Error('cursor-agent reported "Workspace Trust Required": open the folder in Cursor and accept the workspace trust prompt, then retry.');
249
- }
250
- const trimmed = stdout.trim();
251
- if (!trimmed) {
252
- throw new Error('cursor-agent returned an empty result (exit 0): retry the run; if it persists, check `cursor-agent status` and re-run the prompt by hand to see the raw error.');
253
- }
254
- let resultObject = null;
255
- let parsedWhole = false;
256
- try {
257
- resultObject = asRecord(JSON.parse(trimmed));
258
- parsedWhole = resultObject !== null;
259
- }
260
- catch {
261
- parsedWhole = false;
262
- }
263
- const notices = [];
264
- if (!parsedWhole) {
265
- // Tolerate warning lines around the result object; anything that is not
266
- // JSON becomes a notice so a newer CLI cannot break the log.
267
- for (const line of trimmed.split('\n')) {
268
- const candidate = line.trim();
269
- if (!candidate) {
270
- continue;
271
- }
272
- try {
273
- const parsed = asRecord(JSON.parse(candidate));
274
- if (parsed) {
275
- resultObject = parsed;
276
- }
277
- }
278
- catch {
279
- notices.push({
280
- kind: 'notice',
281
- message: `unparseable cursor-agent output: ${candidate.slice(0, 300)}`,
282
- });
283
- }
284
- }
285
- }
286
- if (!resultObject) {
287
- throw new Error(`cursor-agent returned unexpected (non-JSON) output: ${trimmed.slice(0, 300)} Re-run the prompt by hand with --output-format json to see the raw error.`);
288
- }
289
- // Session aliases are chat-id shaped only: a bare `id` may be a request
290
- // or message id rather than the chat id, which would resume the wrong
291
- // session.
292
- const sessionId = firstString(resultObject, ['session_id', 'sessionId', 'chat_id', 'chatId']) ??
293
- opts.resumeId ??
294
- null;
295
- const withSession = sessionId ? { sessionId } : {};
296
- const errorValue = resultObject.error;
297
- const errorText = nonEmptyString(errorValue);
298
- const isErrorFlag = resultObject.is_error === true;
299
- const subtypeRaw = nonEmptyString(resultObject.subtype);
300
- const nonSuccessSubtype = subtypeRaw && subtypeRaw !== 'success' ? subtypeRaw : null;
301
- if (errorText || asRecord(errorValue) || isErrorFlag || nonSuccessSubtype) {
302
- return [
303
- ...notices.map((notice) => sessionId ? { ...notice, sessionId } : notice),
304
- {
305
- kind: 'result',
306
- subtype: nonSuccessSubtype ?? 'failed',
307
- result: errorValue ?? resultObject,
308
- ...withSession,
309
- },
310
- ];
311
- }
312
- const events = [...notices];
313
- const warnings = [
314
- ...stringArray(resultObject.warnings),
315
- ...stringArray(resultObject.notices),
316
- ...stringArray(resultObject.messages).filter((message) => /warn/i.test(message)),
317
- ];
318
- for (const warning of warnings) {
319
- events.push({ kind: 'notice', message: warning.slice(0, 500), ...withSession });
320
- }
321
- const answerText = firstString(resultObject, [
322
- 'result',
323
- 'text',
324
- 'message',
325
- 'response',
326
- 'output',
327
- 'answer',
328
- ]);
329
- // Array content blocks (claude-style text/tool_use) when the result nests them.
330
- const blocks = Array.isArray(resultObject.content) ? resultObject.content : [];
331
- for (const block of blocks) {
332
- const record = asRecord(block);
333
- if (!record) {
334
- continue;
335
- }
336
- if ((record.type === 'text' || record.type === undefined) && typeof record.text === 'string' && record.text) {
337
- events.push({ kind: 'text', text: record.text, ...withSession });
338
- }
339
- else if ((record.type === 'tool_use' || record.type === 'function_call') &&
340
- typeof record.name === 'string' &&
341
- record.name) {
342
- events.push({ kind: 'tool', name: record.name, ...withSession });
343
- }
344
- }
345
- if (answerText) {
346
- events.push({ kind: 'text', text: answerText, ...withSession });
347
- }
348
- const tools = [
349
- ...toolNames(resultObject.tool_calls),
350
- ...toolNames(resultObject.tools_used),
351
- ...toolNames(resultObject.tools),
352
- ];
353
- for (const name of tools) {
354
- events.push({ kind: 'tool', name: name.slice(0, 200), ...withSession });
355
- }
356
- // A bare session id (including the resume-id fallback) is not content:
357
- // `{"session_id":"x","result":""}` and `{}` on --resume are empty results.
358
- const hasContent = answerText !== null ||
359
- tools.length > 0 ||
360
- events.some((event) => event.kind === 'text' || event.kind === 'tool');
361
- if (!hasContent) {
362
- throw new Error('cursor-agent returned an empty result (exit 0): the result object has no answer text or tool calls — retry the run; if it persists, re-run the prompt by hand to see the raw error.');
363
- }
364
- // Mandatory deck receipt on start: without a `◆ ... ·` display_summary
365
- // line the run cannot prove it bound to the requested deck (Cursor's
366
- // global MCP entry is last-workspace-wins). Resume is exempt — the
367
- // harness prints the receipt on the first turn only, so a resumed turn
368
- // legitimately carries no new receipt. A present-but-wrong receipt is
369
- // caught by the shared mismatch check in run.ts.
370
- if (opts.resumeId === undefined && !/◆\s*[^·\r\n]+?\s*·/.test(stdout)) {
371
- throw new Error("cursor-agent run produced no deck receipt (missing ◆ display_summary line): the session may be bound to another folder's deck. Ask the agent to call get_session_context and print display_summary verbatim, then retry.");
372
- }
373
- events.push({ kind: 'result', subtype: 'success', result: resultObject, ...withSession });
374
- return sessionId
375
- ? events.map((event) => ('sessionId' in event && event.sessionId ? event : { ...event, sessionId }))
376
- : events;
377
- }
378
- function createCursorAdapter(deps = {}) {
379
- const bin = deps.bin ?? resolveCursorBin();
380
- const probe = deps.probe ?? defaultCursorProbe;
381
- const spawnFn = deps.spawn ?? defaultCursorSpawn;
382
- return {
383
- id: 'cursor',
384
- async preflight() {
385
- const version = probe(bin, ['--version']);
386
- if (version.code !== 0) {
387
- return {
388
- ok: false,
389
- remedy: `cursor-agent CLI not found (tried "${bin}"): install cursor-agent 2026.10+ and ensure 'cursor-agent' is on PATH (or set CURSOR_BIN=/path/to/cursor-agent), then retry.`,
390
- };
391
- }
392
- const status = probe(bin, ['status', '--format', 'json']);
393
- if (status.code !== 0 || !isCursorStatusAuthenticated(status.stdout)) {
394
- return {
395
- ok: false,
396
- remedy: 'cursor-agent is not signed in: run `cursor-agent login`, then retry.',
397
- };
398
- }
399
- return { ok: true };
400
- },
401
- planStart(args) {
402
- if (args.resumeId !== undefined && args.resumeId.startsWith('-')) {
403
- return {
404
- ok: false,
405
- remedy: `Invalid --resume id ${JSON.stringify(args.resumeId)}: session ids never start with '-'. ` +
406
- 'Pass the chat id printed as sessionId in a previous run log.',
407
- };
408
- }
409
- // --trust is passed on every launch, so every cursor run records the
410
- // workspace-trust grant.
411
- return { ok: true, trustOverride: true };
412
- },
413
- async *start(args) {
414
- const argv = buildCursorArgv({
415
- prompt: args.prompt,
416
- tools: args.tools,
417
- ...(args.resumeId !== undefined ? { resumeId: args.resumeId } : {}),
418
- });
419
- const wrapSpawnError = (error) => new Error(`cursor-agent run failed: ${String(error instanceof Error ? error.message : error).slice(0, 300)}`);
420
- let child;
421
- try {
422
- child = spawnFn(bin, argv, { cwd: args.cwd });
423
- }
424
- catch (error) {
425
- throw wrapSpawnError(error);
426
- }
427
- const lines = [];
428
- try {
429
- for await (const line of child.stdout) {
430
- lines.push(line);
431
- }
432
- }
433
- catch (error) {
434
- throw wrapSpawnError(error);
435
- }
436
- let settled;
437
- try {
438
- settled = await child.wait();
439
- }
440
- catch (error) {
441
- throw wrapSpawnError(error);
442
- }
443
- const { code, stderrTail } = settled;
444
- if (code !== 0) {
445
- throw new Error(`cursor-agent exited with code ${code}${stderrTail ? `: ${stderrTail.slice(0, 300)}` : ''}`);
446
- }
447
- // Single-shot json: the whole stdout is one result object, so every
448
- // event lands here, when the process exits.
449
- yield* cursorEventsFromOutput(lines.join('\n'), {
450
- ...(args.resumeId !== undefined ? { resumeId: args.resumeId } : {}),
451
- });
452
- },
453
- };
454
- }
455
- //# sourceMappingURL=run-cursor.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"run-cursor.js","sourceRoot":"","sources":["../src/run-cursor.ts"],"names":[],"mappings":";;;;;;AAyDA,4CAEC;AAcD,4DAOC;AASD,0CAWC;AAKD,gDAOC;AAUD,gDA6CC;AAQD,kEA4BC;AAsED,wDA4JC;AAQD,kDAoFC;AAzgBD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,2DAAsD;AACtD,kEAAqC;AASxB,QAAA,wBAAwB,GAAG,yBAAyB,CAAC;AAElE,8EAA8E;AACjE,QAAA,oBAAoB,GAAG,MAAM,CAAC;AAE3C,SAAgB,gBAAgB;IAC9B,OAAO,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,IAAI,EAAE,IAAI,cAAc,CAAC;AAC1D,CAAC;AAQD;;;;;GAKG;AACH,SAAgB,wBAAwB,CAAC,QAAgB;IACvD,IAAI,QAAQ,CAAC,UAAU,CAAC,GAAG,CAA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AC9B,CAAC;YACD,MAAM,KAAK,GAAa,EAAE,CAAC;YAC3B,IAAI,CAAC;gBACH,IAAI,KAAK,EAAE,MAAM,IAAI,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC;oBACtC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBACnB,CAAC;YACH,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,MAAM,cAAc,CAAC,KAAK,CAAC,CAAC;YAC9B,CAAC;YACD,IAAI,OAAoD,CAAC;YACzD,IAAI,CAAC;gBACH,OAAO,GAAG,MAAM,KAAK,CAAC,IAAI,EAAE,CAAC;YAC/B,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,MAAM,cAAc,CAAC,KAAK,CAAC,CAAC;YAC9B,CAAC;YACD,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;YACrC,IAAI,IAAI,KAAK,CAAC,EAAE,CAAC;gBACf,MAAM,IAAI,KAAK,CACb,iCAAiC,IAAI,GAAG,UAAU,CAAC,CAAC,CAAC,KAAK,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAC5F,CAAC;YACJ,CAAC;YACD,oEAAoE;YACpE,4CAA4C;YAC5C,KAAK,CAAC,CAAC,sBAAsB,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;gBAC9C,GAAG,CAAC,IAAI,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aACpE,CAAC,CAAC;QACL,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -1,127 +0,0 @@
1
- import { type ClientAdapter, type NormalizedEvent, type RunToolsProfile } from './run-adapter';
2
- /**
3
- * readonly: Muse's own read-only enforcement — `--disable-write` blocks
4
- * non-shell workspace file writes and `--disable-shell` blocks workspace
5
- * shell execution, so a readonly run cannot modify the checkout.
6
- */
7
- export declare const MUSE_READONLY_FLAGS: readonly string[];
8
- /**
9
- * edit: default bounded permissions (approval on-request, sandbox on) with
10
- * no extra flags — there is no named profile to select, and the default
11
- * never disables checks.
12
- */
13
- export declare const MUSE_EDIT_FLAGS: readonly string[];
14
- export declare const MUSE_FLAGS_FOR_PROFILE: Record<RunToolsProfile, readonly string[]>;
15
- /** Flags that must never appear in generated argv (bypass checks or trust). */
16
- export declare const MUSE_FORBIDDEN_FLAGS: readonly string[];
17
- export declare function resolveMuseBin(): string;
18
- /**
19
- * Readonly enforcement is structural AND verified: the flags exist in
20
- * `muse exec --help` output (Muse Code 1.4.4), and planStart fails closed
21
- * when the installed muse does not list them, so readonly never silently
22
- * runs under default permissions. Help text, not a model call.
23
- */
24
- export declare function museReadonlyFlagsSupported(probe: (bin: string, argv: string[]) => {
25
- code: number;
26
- stdout: string;
27
- stderr: string;
28
- }, bin: string): boolean;
29
- export type MuseArgvArgs = {
30
- prompt: string;
31
- tools: RunToolsProfile;
32
- resumeId?: string;
33
- };
34
- /**
35
- * Resume ids are muse session ids (UUIDs); a leading `-` is never legitimate
36
- * and would be parsed as an exec option, so it fails closed in planStart and
37
- * throws here.
38
- */
39
- export declare function assertSafeMuseResumeId(resumeId: string): void;
40
- /**
41
- * Pure argv builder (everything after the `muse` binary). Start:
42
- * `exec --json [--disable-write --disable-shell] -- <prompt>`; resume:
43
- * `exec --json --session-id <id> [--disable-write --disable-shell] -- <prompt>`.
44
- * The `--` terminator (accepted by `muse exec`, verified with the echo
45
- * provider) keeps dash-leading prompts from being parsed as muse options.
46
- */
47
- export declare function buildMuseArgv(args: MuseArgvArgs): string[];
48
- export type MuseProbeResult = {
49
- code: number;
50
- stdout: string;
51
- stderr: string;
52
- };
53
- export type MuseProbe = (bin: string, argv: string[]) => MuseProbeResult;
54
- export declare function defaultMuseProbe(bin: string, argv: string[]): MuseProbeResult;
55
- export type MuseChild = {
56
- /** Stdout split into lines (without line terminators). */
57
- stdout: AsyncIterable<string>;
58
- /** Stderr split into lines (without line terminators). */
59
- stderr: AsyncIterable<string>;
60
- wait: () => Promise<{
61
- code: number | null;
62
- stderrTail: string;
63
- }>;
64
- };
65
- export type MuseSpawn = (bin: string, argv: string[], opts: {
66
- cwd: string;
67
- }) => MuseChild;
68
- export declare function defaultMuseSpawn(bin: string, argv: string[], opts: {
69
- cwd: string;
70
- }): MuseChild;
71
- export type MuseLineContext = {
72
- sessionId: string | null;
73
- };
74
- /**
75
- * Map one `muse exec --json` stdout line onto normalized events. The session
76
- * id is captured from `stream: {kind: "session", id}` on every record (no
77
- * log line); `run.output.delta` becomes `text`; `tool_batch.effect.started`
78
- * becomes `tool`; `run.terminal.completed` becomes `result` (subtype
79
- * `success`, result text); any other `run.terminal.*` becomes `result`
80
- * (subtype `failed`). Unknown kinds are ignored so a newer CLI cannot break
81
- * the log. Never throws: unparseable lines become `notice`.
82
- */
83
- export declare function museEventsFromLine(line: string, ctx: MuseLineContext): NormalizedEvent[];
84
- /** Stderr lines matching this surface as `notice` events; others are ignored. */
85
- export declare const MUSE_STDERR_NOTICE_PATTERN: RegExp;
86
- /**
87
- * Map one stderr line onto a `notice` message. Muse prints startup warnings
88
- * (`muse: Agent delegation: auto unavailable: workspace is untrusted.`,
89
- * `muse: warning: rules file ... skipped ...`) to stderr; those surface as
90
- * notices while routine diagnostics (`muse: workspace root: ...`, plugin
91
- * lines) stay out of the log. Returns null for ignored lines. Never throws.
92
- */
93
- export declare function museNoticeFromStderr(line: string): string | null;
94
- type MergedLine = {
95
- source: 'out' | 'err';
96
- line: string;
97
- };
98
- /**
99
- * Merge stdout and stderr line iterables by arrival so startup warnings
100
- * (stderr) land in the log in real order ahead of the streamed answer. Both
101
- * sides are always consumed (no pipe deadlock); a rejection on either side
102
- * throws, and the other side's pending read can never reject unobserved.
103
- */
104
- export declare function mergeMuseLines(stdout: AsyncIterable<string>, stderr: AsyncIterable<string>): AsyncGenerator<MergedLine>;
105
- export type MuseFileReader = (path: string) => string | null;
106
- export declare function defaultMuseFileReader(filePath: string): string | null;
107
- /**
108
- * Non-model signed-in check: META_API_KEY takes priority over the account
109
- * login (`muse login --help`), otherwise the auth file must record a `meta`
110
- * provider (token itself lives in the keychain; only the metadata is read).
111
- */
112
- export declare function isMuseSignedIn(readFile: MuseFileReader): boolean;
113
- /**
114
- * The agent-deck MCP entry must exist in the global Muse settings or the
115
- * cwd's project `.mcp.json` (whichever `agent-deck use --client muse` wrote);
116
- * without it no session receipt can ever appear in the log.
117
- */
118
- export declare function hasMuseMcpEntry(cwd: string, readFile: MuseFileReader): boolean;
119
- export type MuseAdapterDeps = {
120
- bin?: string;
121
- probe?: MuseProbe;
122
- spawn?: MuseSpawn;
123
- readFile?: MuseFileReader;
124
- };
125
- export declare function createMuseAdapter(deps?: MuseAdapterDeps): ClientAdapter;
126
- export {};
127
- //# sourceMappingURL=run-muse.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"run-muse.d.ts","sourceRoot":"","sources":["../src/run-muse.ts"],"names":[],"mappings":"AAoDA,OAAO,EAEL,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,eAAe,EACrB,MAAM,eAAe,CAAC;AAEvB;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,EAAE,SAAS,MAAM,EAA2C,CAAC;AAE7F;;;;GAIG;AACH,eAAO,MAAM,eAAe,EAAE,SAAS,MAAM,EAAO,CAAC;AAErD,eAAO,MAAM,sBAAsB,EAAE,MAAM,CAAC,eAAe,EAAE,SAAS,MAAM,EAAE,CAG7E,CAAC;AAEF,+EAA+E;AAC/E,eAAO,MAAM,oBAAoB,EAAE,SAAS,MAAM,EAMjD,CAAC;AAEF,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAED;;;;;GAKG;AACH,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK;IAAE,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