@agent-deck/cli 2.0.0 → 2.1.1

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 (63) hide show
  1. package/dist/agent-harness.d.ts +3 -0
  2. package/dist/agent-harness.d.ts.map +1 -1
  3. package/dist/agent-harness.js +64 -6
  4. package/dist/agent-harness.js.map +1 -1
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/index.js +10 -2
  7. package/dist/index.js.map +1 -1
  8. package/dist/mcp-bridge.d.ts +83 -1
  9. package/dist/mcp-bridge.d.ts.map +1 -1
  10. package/dist/mcp-bridge.js +252 -7
  11. package/dist/mcp-bridge.js.map +1 -1
  12. package/dist/mcp-config.d.ts +13 -1
  13. package/dist/mcp-config.d.ts.map +1 -1
  14. package/dist/mcp-config.js +49 -1
  15. package/dist/mcp-config.js.map +1 -1
  16. package/dist/muse-skills/agent-deck-playbooks/SKILL.md +23 -0
  17. package/dist/muse-skills/agent-deck-run/SKILL.md +86 -0
  18. package/dist/muse-skills/agent-deck-session/SKILL.md +59 -0
  19. package/dist/muse-skills/agent-deck-setup/SKILL.md +32 -0
  20. package/dist/muse-skills.d.ts +42 -0
  21. package/dist/muse-skills.d.ts.map +1 -0
  22. package/dist/muse-skills.js +149 -0
  23. package/dist/muse-skills.js.map +1 -0
  24. package/dist/run-adapter.d.ts +100 -0
  25. package/dist/run-adapter.d.ts.map +1 -0
  26. package/dist/run-adapter.js +73 -0
  27. package/dist/run-adapter.js.map +1 -0
  28. package/dist/run-claude.d.ts +41 -0
  29. package/dist/run-claude.d.ts.map +1 -0
  30. package/dist/run-claude.js +91 -0
  31. package/dist/run-claude.js.map +1 -0
  32. package/dist/run-codex.d.ts +75 -0
  33. package/dist/run-codex.d.ts.map +1 -0
  34. package/dist/run-codex.js +337 -0
  35. package/dist/run-codex.js.map +1 -0
  36. package/dist/run-cursor.d.ts +79 -0
  37. package/dist/run-cursor.d.ts.map +1 -0
  38. package/dist/run-cursor.js +455 -0
  39. package/dist/run-cursor.js.map +1 -0
  40. package/dist/run-detach.d.ts +36 -0
  41. package/dist/run-detach.d.ts.map +1 -0
  42. package/dist/run-detach.js +233 -0
  43. package/dist/run-detach.js.map +1 -0
  44. package/dist/run-muse.d.ts +127 -0
  45. package/dist/run-muse.d.ts.map +1 -0
  46. package/dist/run-muse.js +499 -0
  47. package/dist/run-muse.js.map +1 -0
  48. package/dist/run-status.d.ts +62 -0
  49. package/dist/run-status.d.ts.map +1 -0
  50. package/dist/run-status.js +552 -0
  51. package/dist/run-status.js.map +1 -0
  52. package/dist/run.d.ts +191 -0
  53. package/dist/run.d.ts.map +1 -0
  54. package/dist/run.js +680 -0
  55. package/dist/run.js.map +1 -0
  56. package/dist/setup.d.ts.map +1 -1
  57. package/dist/setup.js +51 -10
  58. package/dist/setup.js.map +1 -1
  59. package/dist/use.d.ts +1 -1
  60. package/dist/use.d.ts.map +1 -1
  61. package/dist/use.js +16 -15
  62. package/dist/use.js.map +1 -1
  63. package/package.json +5 -4
@@ -0,0 +1,499 @@
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.MUSE_STDERR_NOTICE_PATTERN = exports.MUSE_FORBIDDEN_FLAGS = exports.MUSE_FLAGS_FOR_PROFILE = exports.MUSE_EDIT_FLAGS = exports.MUSE_READONLY_FLAGS = void 0;
7
+ exports.resolveMuseBin = resolveMuseBin;
8
+ exports.museReadonlyFlagsSupported = museReadonlyFlagsSupported;
9
+ exports.assertSafeMuseResumeId = assertSafeMuseResumeId;
10
+ exports.buildMuseArgv = buildMuseArgv;
11
+ exports.defaultMuseProbe = defaultMuseProbe;
12
+ exports.defaultMuseSpawn = defaultMuseSpawn;
13
+ exports.museEventsFromLine = museEventsFromLine;
14
+ exports.museNoticeFromStderr = museNoticeFromStderr;
15
+ exports.mergeMuseLines = mergeMuseLines;
16
+ exports.defaultMuseFileReader = defaultMuseFileReader;
17
+ exports.isMuseSignedIn = isMuseSignedIn;
18
+ exports.hasMuseMcpEntry = hasMuseMcpEntry;
19
+ exports.createMuseAdapter = createMuseAdapter;
20
+ /**
21
+ * Muse adapter for `agent-deck run` (NOT-407).
22
+ *
23
+ * Drives `muse exec --json` (start) and `muse exec --json --session-id <id>`
24
+ * (resume) as a child process and maps the JSONL stream onto normalized
25
+ * events. Verified against Muse Code 1.4.4 (1.4.4-R5419.1) via `muse
26
+ * --version`, `muse --help`, `muse exec --help`, `muse mcp --help`, `muse mcp
27
+ * login --help`, `muse config --help`, and echo-provider captures in
28
+ * /tmp/smoke. Tool mapping for this version: readonly passes
29
+ * `--disable-write --disable-shell`; edit passes no extra flags (Muse's
30
+ * default bounded permissions: approval on-request, sandbox on):
31
+ *
32
+ * - Every stdout record carries `stream: {kind: "session", id}`; that id is
33
+ * the session id. Assistant text streams as `run.output.delta`
34
+ * (`payload.text`); tool calls arrive as `tool_batch.effect.started`
35
+ * (`payload.record.tool_name`, e.g. "read_memory" in a stored session
36
+ * log); the final `run.terminal.completed` carries the result `text`.
37
+ * Anything else (task.lifecycle.*, turn.input.user, ...) is ignored so a
38
+ * newer CLI cannot break the log.
39
+ * - Warnings (the untrusted-workspace notice, "Agent delegation: auto
40
+ * unavailable") print to stderr as `muse: ...` lines, never to stdout, so
41
+ * the adapter merges stdout and stderr by arrival and maps warning-shaped
42
+ * stderr lines to `notice` events. Notices never fail the run.
43
+ * - Resume passes the previous session id via `--session-id <id>` and the
44
+ * process reports the same id back (verified with the echo provider).
45
+ * - `--permission-profile` selects ONLY enterprise-plane profiles: 1.4.4
46
+ * ships with none, user settings.json has no such key ("profile does not
47
+ * exist" for every candidate id), so the adapter never passes it. Tool
48
+ * profiles map to Muse's own enforcement flags instead (see below). A
49
+ * literal `--permission-profile` mapping would fail closed on every
50
+ * default (`readonly`) run, so the product call is capability flags with
51
+ * runtime verification: readonly fails closed unless the installed muse
52
+ * lists both enforcement flags in `muse exec --help`.
53
+ * - Signed-in preflight is `providers.meta` in the Muse auth file (or
54
+ * META_API_KEY), which makes no model call; there is no `login status`
55
+ * subcommand.
56
+ *
57
+ * Never selected, with no flag, env var, or option that selects them:
58
+ * `--yolo`, `--trust-workspace`, `--disable-approval`, `--disable-sandbox`
59
+ * (all disable checks or mark the workspace trusted), and
60
+ * `--permission-profile` (no valid id exists; any value aborts the run).
61
+ * `--disable-write`/`--disable-shell` only narrow capabilities for readonly
62
+ * and leave approval and the sandbox on. Tests assert no generated argv ever
63
+ * contains the forbidden flags.
64
+ */
65
+ const node_child_process_1 = require("node:child_process");
66
+ const node_fs_1 = __importDefault(require("node:fs"));
67
+ const node_os_1 = __importDefault(require("node:os"));
68
+ const node_path_1 = __importDefault(require("node:path"));
69
+ const node_readline_1 = __importDefault(require("node:readline"));
70
+ const mcp_config_1 = require("./mcp-config");
71
+ /**
72
+ * readonly: Muse's own read-only enforcement — `--disable-write` blocks
73
+ * non-shell workspace file writes and `--disable-shell` blocks workspace
74
+ * shell execution, so a readonly run cannot modify the checkout.
75
+ */
76
+ exports.MUSE_READONLY_FLAGS = ['--disable-write', '--disable-shell'];
77
+ /**
78
+ * edit: default bounded permissions (approval on-request, sandbox on) with
79
+ * no extra flags — there is no named profile to select, and the default
80
+ * never disables checks.
81
+ */
82
+ exports.MUSE_EDIT_FLAGS = [];
83
+ exports.MUSE_FLAGS_FOR_PROFILE = {
84
+ readonly: exports.MUSE_READONLY_FLAGS,
85
+ edit: exports.MUSE_EDIT_FLAGS,
86
+ };
87
+ /** Flags that must never appear in generated argv (bypass checks or trust). */
88
+ exports.MUSE_FORBIDDEN_FLAGS = [
89
+ '--yolo',
90
+ '--trust-workspace',
91
+ '--disable-approval',
92
+ '--disable-sandbox',
93
+ '--permission-profile',
94
+ ];
95
+ function resolveMuseBin() {
96
+ return process.env.MUSE_BIN?.trim() || 'muse';
97
+ }
98
+ /**
99
+ * Readonly enforcement is structural AND verified: the flags exist in
100
+ * `muse exec --help` output (Muse Code 1.4.4), and planStart fails closed
101
+ * when the installed muse does not list them, so readonly never silently
102
+ * runs under default permissions. Help text, not a model call.
103
+ */
104
+ function museReadonlyFlagsSupported(probe, bin) {
105
+ const help = probe(bin, ['exec', '--help']);
106
+ if (help.code !== 0) {
107
+ return false;
108
+ }
109
+ const text = `${help.stdout}\n${help.stderr}`;
110
+ return exports.MUSE_READONLY_FLAGS.every((flag) => text.includes(flag));
111
+ }
112
+ /**
113
+ * Resume ids are muse session ids (UUIDs); a leading `-` is never legitimate
114
+ * and would be parsed as an exec option, so it fails closed in planStart and
115
+ * throws here.
116
+ */
117
+ function assertSafeMuseResumeId(resumeId) {
118
+ if (resumeId.startsWith('-')) {
119
+ throw new Error(`Invalid --resume id ${JSON.stringify(resumeId)}: session ids never start with '-'. ` +
120
+ 'Pass the session id printed as sessionId in a previous run log.');
121
+ }
122
+ }
123
+ /**
124
+ * Pure argv builder (everything after the `muse` binary). Start:
125
+ * `exec --json [--disable-write --disable-shell] -- <prompt>`; resume:
126
+ * `exec --json --session-id <id> [--disable-write --disable-shell] -- <prompt>`.
127
+ * The `--` terminator (accepted by `muse exec`, verified with the echo
128
+ * provider) keeps dash-leading prompts from being parsed as muse options.
129
+ */
130
+ function buildMuseArgv(args) {
131
+ const argv = ['exec', '--json'];
132
+ if (args.resumeId !== undefined) {
133
+ assertSafeMuseResumeId(args.resumeId);
134
+ argv.push('--session-id', args.resumeId);
135
+ }
136
+ argv.push(...exports.MUSE_FLAGS_FOR_PROFILE[args.tools]);
137
+ argv.push('--', args.prompt);
138
+ return argv;
139
+ }
140
+ function defaultMuseProbe(bin, argv) {
141
+ try {
142
+ const probed = (0, node_child_process_1.spawnSync)(bin, argv, { encoding: 'utf8', timeout: 15000 });
143
+ return { code: probed.status ?? 1, stdout: probed.stdout ?? '', stderr: probed.stderr ?? '' };
144
+ }
145
+ catch {
146
+ return { code: 127, stdout: '', stderr: '' };
147
+ }
148
+ }
149
+ function defaultMuseSpawn(bin, argv, opts) {
150
+ const child = (0, node_child_process_1.spawn)(bin, argv, { cwd: opts.cwd, stdio: ['ignore', 'pipe', 'pipe'] });
151
+ let spawnError = null;
152
+ child.on('error', (error) => {
153
+ spawnError = error;
154
+ child.stdout?.destroy();
155
+ child.stderr?.destroy();
156
+ });
157
+ const stderrChunks = [];
158
+ child.stderr?.on('data', (chunk) => {
159
+ stderrChunks.push(Buffer.from(chunk));
160
+ });
161
+ // A second listener on the same stream is fine: every `data` listener gets
162
+ // all chunks, so the tail buffer and the readline iterator below each see
163
+ // the full stderr (verified with a node one-liner, NOT-407).
164
+ function lines(input) {
165
+ async function* gen() {
166
+ const rl = node_readline_1.default.createInterface({ input: input });
167
+ try {
168
+ for await (const line of rl) {
169
+ yield line;
170
+ }
171
+ }
172
+ catch {
173
+ // The stream is destroyed when the spawn itself fails; the spawn
174
+ // error below is the actionable failure.
175
+ }
176
+ if (spawnError) {
177
+ throw spawnError;
178
+ }
179
+ }
180
+ return gen();
181
+ }
182
+ const wait = () => new Promise((resolve) => {
183
+ let settled = false;
184
+ const done = (code) => {
185
+ if (settled) {
186
+ return;
187
+ }
188
+ settled = true;
189
+ resolve({
190
+ code,
191
+ stderrTail: Buffer.concat(stderrChunks).toString('utf8').slice(-2000),
192
+ });
193
+ };
194
+ child.on('close', done);
195
+ child.on('error', () => done(127));
196
+ });
197
+ return { stdout: lines(child.stdout), stderr: lines(child.stderr), wait };
198
+ }
199
+ function withSession(event, ctx) {
200
+ return ctx.sessionId ? { ...event, sessionId: ctx.sessionId } : event;
201
+ }
202
+ function asRecord(value) {
203
+ return typeof value === 'object' && value !== null ? value : null;
204
+ }
205
+ function nonEmptyString(value) {
206
+ return typeof value === 'string' && value ? value : null;
207
+ }
208
+ /**
209
+ * Map one `muse exec --json` stdout line onto normalized events. The session
210
+ * id is captured from `stream: {kind: "session", id}` on every record (no
211
+ * log line); `run.output.delta` becomes `text`; `tool_batch.effect.started`
212
+ * becomes `tool`; `run.terminal.completed` becomes `result` (subtype
213
+ * `success`, result text); any other `run.terminal.*` becomes `result`
214
+ * (subtype `failed`). Unknown kinds are ignored so a newer CLI cannot break
215
+ * the log. Never throws: unparseable lines become `notice`.
216
+ */
217
+ function museEventsFromLine(line, ctx) {
218
+ const trimmed = line.trim();
219
+ if (!trimmed) {
220
+ return [];
221
+ }
222
+ let event;
223
+ try {
224
+ event = JSON.parse(trimmed);
225
+ }
226
+ catch {
227
+ return [
228
+ withSession({ kind: 'notice', message: `unparseable muse output: ${trimmed.slice(0, 300)}` }, ctx),
229
+ ];
230
+ }
231
+ const record = asRecord(event);
232
+ if (!record) {
233
+ return [];
234
+ }
235
+ const stream = asRecord(record.stream);
236
+ if (stream?.kind === 'session') {
237
+ const id = nonEmptyString(stream.id);
238
+ if (id) {
239
+ ctx.sessionId = id;
240
+ }
241
+ }
242
+ const payloadType = nonEmptyString(record.payload_type);
243
+ if (!payloadType) {
244
+ return [];
245
+ }
246
+ const payload = asRecord(record.payload);
247
+ if (payloadType === 'run.output.delta') {
248
+ const text = payload ? nonEmptyString(payload.text) : null;
249
+ return text ? [withSession({ kind: 'text', text }, ctx)] : [];
250
+ }
251
+ if (payloadType === 'tool_batch.effect.started') {
252
+ const item = payload ? asRecord(payload.record) : null;
253
+ const name = (item ? nonEmptyString(item.tool_name) : null) ??
254
+ (item ? nonEmptyString(item.call_id) : null) ??
255
+ 'tool';
256
+ return [withSession({ kind: 'tool', name }, ctx)];
257
+ }
258
+ if (payloadType === 'run.terminal.completed') {
259
+ const text = payload ? nonEmptyString(payload.text) : null;
260
+ return [withSession({ kind: 'result', subtype: 'success', result: text ?? null }, ctx)];
261
+ }
262
+ if (payloadType.startsWith('run.terminal.')) {
263
+ const text = payload ? nonEmptyString(payload.text) : null;
264
+ const reason = payload ? nonEmptyString(payload.reason) : null;
265
+ return [withSession({ kind: 'result', subtype: 'failed', result: text ?? reason ?? null }, ctx)];
266
+ }
267
+ return [];
268
+ }
269
+ /** Stderr lines matching this surface as `notice` events; others are ignored. */
270
+ exports.MUSE_STDERR_NOTICE_PATTERN = /warning|untrusted|delegation|error|fail/i;
271
+ /**
272
+ * Map one stderr line onto a `notice` message. Muse prints startup warnings
273
+ * (`muse: Agent delegation: auto unavailable: workspace is untrusted.`,
274
+ * `muse: warning: rules file ... skipped ...`) to stderr; those surface as
275
+ * notices while routine diagnostics (`muse: workspace root: ...`, plugin
276
+ * lines) stay out of the log. Returns null for ignored lines. Never throws.
277
+ */
278
+ function museNoticeFromStderr(line) {
279
+ const trimmed = line.trim();
280
+ if (!trimmed) {
281
+ return null;
282
+ }
283
+ if (!exports.MUSE_STDERR_NOTICE_PATTERN.test(trimmed)) {
284
+ return null;
285
+ }
286
+ return trimmed.slice(0, 500);
287
+ }
288
+ /**
289
+ * Merge stdout and stderr line iterables by arrival so startup warnings
290
+ * (stderr) land in the log in real order ahead of the streamed answer. Both
291
+ * sides are always consumed (no pipe deadlock); a rejection on either side
292
+ * throws, and the other side's pending read can never reject unobserved.
293
+ */
294
+ async function* mergeMuseLines(stdout, stderr) {
295
+ const outIt = stdout[Symbol.asyncIterator]();
296
+ const errIt = stderr[Symbol.asyncIterator]();
297
+ const safeNext = (which) => {
298
+ const it = which === 'out' ? outIt : errIt;
299
+ return it
300
+ .next()
301
+ .then((result) => ({ which, settled: { ok: true, result } }), (error) => ({ which, settled: { ok: false, error } }));
302
+ };
303
+ const NEVER = new Promise(() => { });
304
+ let outDone = false;
305
+ let errDone = false;
306
+ let outNext = safeNext('out');
307
+ let errNext = safeNext('err');
308
+ const fail = (error) => new Error(`muse run failed: ${String(error instanceof Error ? error.message : error).slice(0, 300)}`);
309
+ while (!outDone || !errDone) {
310
+ const winner = await Promise.race([
311
+ outDone ? NEVER : outNext,
312
+ errDone ? NEVER : errNext,
313
+ ]);
314
+ if (winner.settled.ok === false) {
315
+ throw fail(winner.settled.error);
316
+ }
317
+ if (winner.settled.result.done) {
318
+ if (winner.which === 'out') {
319
+ outDone = true;
320
+ }
321
+ else {
322
+ errDone = true;
323
+ }
324
+ continue;
325
+ }
326
+ yield { source: winner.which, line: winner.settled.result.value };
327
+ if (winner.which === 'out') {
328
+ outNext = safeNext('out');
329
+ }
330
+ else {
331
+ errNext = safeNext('err');
332
+ }
333
+ }
334
+ }
335
+ function defaultMuseFileReader(filePath) {
336
+ try {
337
+ return node_fs_1.default.readFileSync(filePath, 'utf8');
338
+ }
339
+ catch {
340
+ return null;
341
+ }
342
+ }
343
+ function parseJsonObject(text) {
344
+ try {
345
+ return asRecord(JSON.parse(text));
346
+ }
347
+ catch {
348
+ return null;
349
+ }
350
+ }
351
+ function museAuthFilePath() {
352
+ // Mirrors resolveMuseGlobalConfigDir (mcp-config.ts): Muse honors
353
+ // XDG_CONFIG_HOME for its user settings; otherwise ~/.config.
354
+ const configHome = process.env.XDG_CONFIG_HOME?.trim() || node_path_1.default.join(node_os_1.default.homedir(), '.config');
355
+ return node_path_1.default.join(configHome, 'muse', 'auth.json');
356
+ }
357
+ /**
358
+ * Non-model signed-in check: META_API_KEY takes priority over the account
359
+ * login (`muse login --help`), otherwise the auth file must record a `meta`
360
+ * provider (token itself lives in the keychain; only the metadata is read).
361
+ */
362
+ function isMuseSignedIn(readFile) {
363
+ if (process.env.META_API_KEY?.trim()) {
364
+ return true;
365
+ }
366
+ const auth = readFile(museAuthFilePath());
367
+ if (!auth) {
368
+ return false;
369
+ }
370
+ const providers = parseJsonObject(auth)?.providers;
371
+ return asRecord(providers)?.meta != null;
372
+ }
373
+ /**
374
+ * The agent-deck MCP entry must exist in the global Muse settings or the
375
+ * cwd's project `.mcp.json` (whichever `agent-deck use --client muse` wrote);
376
+ * without it no session receipt can ever appear in the log.
377
+ */
378
+ function hasMuseMcpEntry(cwd, readFile) {
379
+ const candidates = [
380
+ (0, mcp_config_1.resolveConfigPath)('muse', 'global'),
381
+ (0, mcp_config_1.resolveConfigPath)('muse', 'project', cwd),
382
+ ];
383
+ for (const candidate of candidates) {
384
+ const text = readFile(candidate);
385
+ if (!text) {
386
+ continue;
387
+ }
388
+ const servers = parseJsonObject(text)?.mcpServers;
389
+ if (asRecord(servers)?.['agent-deck'] != null) {
390
+ return true;
391
+ }
392
+ }
393
+ return false;
394
+ }
395
+ function createMuseAdapter(deps = {}) {
396
+ const bin = deps.bin ?? resolveMuseBin();
397
+ const probe = deps.probe ?? defaultMuseProbe;
398
+ const spawnFn = deps.spawn ?? defaultMuseSpawn;
399
+ const readFile = deps.readFile ?? defaultMuseFileReader;
400
+ return {
401
+ id: 'muse',
402
+ async preflight() {
403
+ const version = probe(bin, ['--version']);
404
+ if (version.code !== 0) {
405
+ return {
406
+ ok: false,
407
+ remedy: `muse CLI not found (tried "${bin}"): install Muse Code 1.4+ and ensure 'muse' is on PATH (or set MUSE_BIN=/path/to/muse), then retry.`,
408
+ };
409
+ }
410
+ if (!isMuseSignedIn(readFile)) {
411
+ return {
412
+ ok: false,
413
+ remedy: 'muse is not signed in: run `muse login`, then retry.',
414
+ };
415
+ }
416
+ return { ok: true };
417
+ },
418
+ planStart(args) {
419
+ if (args.resumeId !== undefined && args.resumeId.startsWith('-')) {
420
+ return {
421
+ ok: false,
422
+ remedy: `Invalid --resume id ${JSON.stringify(args.resumeId)}: session ids never start with '-'. ` +
423
+ 'Pass the session id printed as sessionId in a previous run log.',
424
+ };
425
+ }
426
+ if (args.tools === 'readonly' && !museReadonlyFlagsSupported(probe, bin)) {
427
+ return {
428
+ ok: false,
429
+ remedy: 'muse readonly enforcement unavailable: this muse build does not list --disable-write --disable-shell ' +
430
+ 'in `muse exec --help`. Upgrade to Muse Code 1.4+, then retry. ' +
431
+ 'Refusing to run --tools readonly under default permissions.',
432
+ };
433
+ }
434
+ if (!hasMuseMcpEntry(args.cwd, readFile)) {
435
+ return {
436
+ ok: false,
437
+ remedy: 'agent-deck MCP server is not registered with Muse: run `agent-deck setup --client muse` to register it, ' +
438
+ 'then retry. If Muse reports the server needs authorization, run `muse mcp login agent-deck` (see `muse mcp --help`).',
439
+ };
440
+ }
441
+ // Never trust the workspace from run: no --trust-workspace/--yolo, so
442
+ // trustOverride stays false and the untrusted warning surfaces as a
443
+ // notice (agent delegation unavailable is a known limit).
444
+ return { ok: true, trustOverride: false };
445
+ },
446
+ async *start(args) {
447
+ const argv = buildMuseArgv({
448
+ prompt: args.prompt,
449
+ tools: args.tools,
450
+ ...(args.resumeId !== undefined ? { resumeId: args.resumeId } : {}),
451
+ });
452
+ if (args.resumeId !== undefined) {
453
+ yield {
454
+ kind: 'notice',
455
+ message: `Resuming muse session ${args.resumeId} with --tools ${args.tools} flags passed to the resumed process.`,
456
+ sessionId: args.resumeId,
457
+ };
458
+ }
459
+ const wrapSpawnError = (error) => new Error(`muse run failed: ${String(error instanceof Error ? error.message : error).slice(0, 300)}`);
460
+ let child;
461
+ try {
462
+ child = spawnFn(bin, argv, { cwd: args.cwd });
463
+ }
464
+ catch (error) {
465
+ throw wrapSpawnError(error);
466
+ }
467
+ const ctx = { sessionId: args.resumeId ?? null };
468
+ try {
469
+ for await (const merged of mergeMuseLines(child.stdout, child.stderr)) {
470
+ if (merged.source === 'err') {
471
+ const message = museNoticeFromStderr(merged.line);
472
+ if (message) {
473
+ yield withSession({ kind: 'notice', message }, ctx);
474
+ }
475
+ continue;
476
+ }
477
+ for (const event of museEventsFromLine(merged.line, ctx)) {
478
+ yield event;
479
+ }
480
+ }
481
+ }
482
+ catch (error) {
483
+ throw wrapSpawnError(error);
484
+ }
485
+ let settled;
486
+ try {
487
+ settled = await child.wait();
488
+ }
489
+ catch (error) {
490
+ throw wrapSpawnError(error);
491
+ }
492
+ const { code, stderrTail } = settled;
493
+ if (code !== 0) {
494
+ throw new Error(`muse exited with code ${code}${stderrTail ? `: ${stderrTail.slice(0, 300)}` : ''}`);
495
+ }
496
+ },
497
+ };
498
+ }
499
+ //# sourceMappingURL=run-muse.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-muse.js","sourceRoot":"","sources":["../src/run-muse.ts"],"names":[],"mappings":";;;;;;AAuFA,wCAEC;AAQ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@ -0,0 +1,62 @@
1
+ export type RunInspectState = 'running' | 'ended' | 'error' | 'died';
2
+ export type RunStatusInfo = {
3
+ runId: string;
4
+ deck: string;
5
+ client: string;
6
+ state: RunInspectState;
7
+ sessionId: string | null;
8
+ startedAt: string;
9
+ lastLogTs: string | null;
10
+ logPath: string;
11
+ };
12
+ export type RunInspectDeps = {
13
+ homeDir?: string;
14
+ /** Follow poll interval (tests only; default 100ms). */
15
+ followPollMs?: number;
16
+ };
17
+ export declare const RUN_LIST_DEFAULT_LIMIT = 20;
18
+ /**
19
+ * True when `pid` is alive and not obviously recycled: the runner process
20
+ * started before it wrote `startedAt`, so a live pid whose start time is
21
+ * well after `startedAt` must be a different process.
22
+ */
23
+ export declare function isRunPidAlive(pid: number, startedAt: string): boolean;
24
+ export type CollectedStatus = {
25
+ found: false;
26
+ } | {
27
+ found: true;
28
+ info: RunStatusInfo;
29
+ warnings: string[];
30
+ corruptMeta: boolean;
31
+ };
32
+ export declare function collectRunStatus(runId: string, homeDir: string): CollectedStatus;
33
+ export declare function printRunStatusHelp(): void;
34
+ export declare function parseRunStatusArgs(args: string[]): {
35
+ runId: string;
36
+ json: boolean;
37
+ } | {
38
+ error: string;
39
+ };
40
+ export declare function runRunStatusCommand(args: string[], deps?: RunInspectDeps): Promise<number>;
41
+ export declare function printRunLogHelp(): void;
42
+ type ParsedLogArgs = {
43
+ runId: string;
44
+ tail: number | null;
45
+ follow: boolean;
46
+ json: boolean;
47
+ };
48
+ export declare function parseRunLogArgs(args: string[]): ParsedLogArgs | {
49
+ error: string;
50
+ };
51
+ export declare function runRunLogCommand(args: string[], deps?: RunInspectDeps): Promise<number>;
52
+ export declare function printRunListHelp(): void;
53
+ export declare function parseRunListArgs(args: string[]): {
54
+ json: boolean;
55
+ limit: number;
56
+ } | {
57
+ error: string;
58
+ };
59
+ export declare function listRunInfos(homeDir: string, limit: number): RunStatusInfo[];
60
+ export declare function runRunListCommand(args: string[], deps?: RunInspectDeps): Promise<number>;
61
+ export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