agent-dealer 1.4.3 → 1.4.5

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 (72) hide show
  1. package/bundle/server/dist/adapters/muse-capability.js +81 -8
  2. package/bundle/server/dist/adapters/muse-capability.test.js +89 -1
  3. package/bundle/server/dist/coordinator/args.js +7 -9
  4. package/bundle/server/dist/coordinator/args.test.js +5 -2
  5. package/bundle/server/dist/coordinator/commands.js +2 -1
  6. package/bundle/server/dist/coordinator/muse-spawn.js +1 -0
  7. package/bundle/server/dist/coordinator/reviewer-browser-probe.js +2 -3
  8. package/bundle/server/dist/coordinator/spawn.js +25 -5
  9. package/bundle/server/dist/coordinator/spawn.test.js +84 -0
  10. package/bundle/server/dist/runners/muse-config-core.js +33 -9
  11. package/bundle/server/dist/runners/muse-config.test.js +13 -8
  12. package/bundle/server/dist/runners/spawn-cli.js +12 -4
  13. package/bundle/server/dist/runners/spawn-cli.test.js +19 -0
  14. package/bundle/server/package.json +2 -2
  15. package/bundle/server/static-ui/assets/index-2IuALSbV.js +64 -0
  16. package/bundle/server/static-ui/assets/index-MgimDoh2.css +1 -0
  17. package/bundle/server/static-ui/index.html +2 -2
  18. package/bundle/shared/package.json +1 -1
  19. package/dist/bin.js +0 -0
  20. package/package.json +2 -3
  21. package/bundle/server/dist/adapters/authority-lifecycle.js +0 -289
  22. package/bundle/server/dist/adapters/execution-authority.js +0 -103
  23. package/bundle/server/dist/adapters/execution-authority.test.js +0 -166
  24. package/bundle/server/dist/adapters/external.js +0 -20
  25. package/bundle/server/dist/coordinator/authority-recovery.integration.test.js +0 -661
  26. package/bundle/server/dist/coordinator/dispatcher.js +0 -58
  27. package/bundle/server/dist/coordinator/dispatcher.test.js +0 -81
  28. package/bundle/server/dist/coordinator/intent-forecast.js +0 -13
  29. package/bundle/server/dist/coordinator/intent-forecast.test.js +0 -34
  30. package/bundle/server/dist/coordinator/session-lifecycle.integration.test.js +0 -127
  31. package/bundle/server/dist/coordinator/session-lifecycle.js +0 -280
  32. package/bundle/server/dist/coordinator/session-lifecycle.test.js +0 -121
  33. package/bundle/server/dist/db/authority-attempts-stale-at-migration.test.js +0 -65
  34. package/bundle/server/dist/intake/agent-routing.js +0 -32
  35. package/bundle/server/dist/queue/answers.test.js +0 -117
  36. package/bundle/server/dist/queue/dispatcher-recovery.test.js +0 -37
  37. package/bundle/server/dist/queue/dispatcher.js +0 -597
  38. package/bundle/server/dist/queue/plan-delegation.js +0 -27
  39. package/bundle/server/dist/queue/plan-delegation.test.js +0 -61
  40. package/bundle/server/dist/queue/plan-gate.test.js +0 -55
  41. package/bundle/server/dist/queue/result-qa.js +0 -66
  42. package/bundle/server/dist/queue/result-qa.test.js +0 -146
  43. package/bundle/server/dist/repository/authority-attempts.js +0 -189
  44. package/bundle/server/dist/repository/result-qa.js +0 -37
  45. package/bundle/server/dist/runners/codex-args.js +0 -59
  46. package/bundle/server/dist/runners/codex-args.test.js +0 -72
  47. package/bundle/server/dist/runners/codex-resume.test.js +0 -19
  48. package/bundle/server/dist/runners/codex.js +0 -46
  49. package/bundle/server/dist/runners/muse-code-settings.js +0 -23
  50. package/bundle/server/dist/runners/muse-code-settings.test.js +0 -18
  51. package/bundle/server/dist/runners/persist.js +0 -142
  52. package/bundle/server/dist/runners/qa.js +0 -54
  53. package/bundle/server/dist/runners/run-context.js +0 -183
  54. package/bundle/server/dist/runners/stream-json.test.js +0 -95
  55. package/bundle/server/dist/trace-summary.js +0 -93
  56. package/bundle/server/dist/usage-summary.js +0 -61
  57. package/bundle/server/dist/usage-summary.test.js +0 -33
  58. package/bundle/server/static-ui/assets/index-CHCiztRI.css +0 -1
  59. package/bundle/server/static-ui/assets/index-CrLQFFpw.js +0 -64
  60. package/bundle/server/static-ui/fonts/Monaco.ttf +0 -0
  61. package/bundle/shared/dist/cursor-auth-health.d.ts +0 -12
  62. package/bundle/shared/dist/cursor-auth-health.js +0 -36
  63. package/bundle/shared/dist/cursor-auth-health.test.d.ts +0 -1
  64. package/bundle/shared/dist/cursor-auth-health.test.js +0 -40
  65. package/bundle/shared/dist/plan-triage.d.ts +0 -317
  66. package/bundle/shared/dist/plan-triage.js +0 -65
  67. package/bundle/shared/dist/plan-triage.test.d.ts +0 -1
  68. package/bundle/shared/dist/plan-triage.test.js +0 -66
  69. package/bundle/shared/dist/result-qa.d.ts +0 -45
  70. package/bundle/shared/dist/result-qa.js +0 -25
  71. package/bundle/shared/dist/result-qa.test.d.ts +0 -1
  72. package/bundle/shared/dist/result-qa.test.js +0 -60
@@ -5,8 +5,8 @@ import os from "node:os";
5
5
  import path from "node:path";
6
6
  import { assertMuseArgv, buildMuseArgv, NOT_177_EVIDENCE, prepareMuseAttempt as prepareMuseAttemptPinned, unenforceableRestrictions, } from "./muse-config.js";
7
7
  import { pathToFileURL } from "node:url";
8
- // The Muse sandbox leaves temp dirs writable, so the module refuses them: fixtures live under $HOME.
9
- const SCRATCH = fs.mkdtempSync(path.join(os.homedir(), ".dealer-muse-config-test-"));
8
+ // The Muse sandbox leaves temp dirs writable, so the module refuses them: fixtures live outside system temp directories.
9
+ const SCRATCH = fs.mkdtempSync(path.resolve(import.meta.dirname, "../../../../.dealer-muse-config-test-"));
10
10
  after(() => fs.rmSync(SCRATCH, { recursive: true, force: true }));
11
11
  const ENFORCED = { mcp_tool_allowlist_enforcement: true, cron_tool_disable: true };
12
12
  // Production code has no seam that accepts other enforcement evidence. The enforced paths are exercised
@@ -142,7 +142,10 @@ test("developer: the full assigned Agent Deck surface, sandbox on, no unrestrict
142
142
  assert.equal(flag("--sandbox-network"), "restricted");
143
143
  assert.equal(flag("--model"), "muse-spark-1.3-contributor");
144
144
  assert.equal(flag("--session-id"), SESSION);
145
- assert.equal(attempt.argv.at(-1), "Implement the ticket");
145
+ const promptFile = path.join(attempt.root, "prompt.txt");
146
+ assert.deepEqual(attempt.argv.slice(-2), ["--prompt-file", promptFile]);
147
+ assert.equal(fs.statSync(promptFile).mode & 0o777, 0o600);
148
+ assert.equal(fs.readFileSync(promptFile, "utf8"), "Implement the ticket");
146
149
  for (const bad of ["--yolo", "--disable-sandbox", "--disable-approval", "--trust-workspace", "-w", "--worktree", "--disable-write", "--disable-shell"]) {
147
150
  assert.equal(attempt.argv.includes(bad), false, bad);
148
151
  }
@@ -178,13 +181,13 @@ test("reviewer: read-only flags and the allowlisted deck reads, mutation denied"
178
181
  attempt.cleanup();
179
182
  }
180
183
  // A reviewer argv without the read-only flags is refused, as is a developer with them.
181
- assert.equal(code(() => assertMuseArgv(buildMuseArgv({ role: "developer", sessionId: SESSION, maxModelSteps: 5, prompt: "x" }), "reviewer")), "invalid_argv");
182
- assert.equal(code(() => assertMuseArgv(buildMuseArgv({ role: "reviewer", sessionId: SESSION, maxModelSteps: 5, prompt: "x" }), "developer")), "invalid_argv");
184
+ assert.equal(code(() => assertMuseArgv(buildMuseArgv({ role: "developer", sessionId: SESSION, maxModelSteps: 5, promptFile: "/prompt.txt" }), "reviewer")), "invalid_argv");
185
+ assert.equal(code(() => assertMuseArgv(buildMuseArgv({ role: "reviewer", sessionId: SESSION, maxModelSteps: 5, promptFile: "/prompt.txt" }), "developer")), "invalid_argv");
183
186
  });
184
187
  test("argv guard refuses every trust/sandbox/orchestration widening flag", () => {
185
- const base = buildMuseArgv({ role: "developer", sessionId: SESSION, maxModelSteps: 5, prompt: "x" });
188
+ const base = buildMuseArgv({ role: "developer", sessionId: SESSION, maxModelSteps: 5, promptFile: "/prompt.txt" });
186
189
  for (const bad of ["--yolo", "--disable-sandbox", "--disable-approval", "--trust-workspace", "-w", "--worktree=nested", "--preset", "--agents", "--permission-profile"]) {
187
- const argv = [...base.slice(0, -1), bad, "x"];
190
+ const argv = [...base.slice(0, -2), bad, ...base.slice(-2)];
188
191
  assert.equal(code(() => assertMuseArgv(argv, "developer")), "invalid_argv", bad);
189
192
  }
190
193
  const relaxed = base.map((a) => (a === "restricted" ? "proxy-only" : a));
@@ -556,7 +559,7 @@ test("launch contract: cwd is the real worktree and argv/env/cwd/stdin must matc
556
559
  "drop --approval-judge off": { ...launch, argv: without("--approval-judge", 2) },
557
560
  "add --base-url": { ...launch, argv: [...launch.argv.slice(0, -1), "--base-url", "http://evil.invalid", launch.argv.at(-1)] },
558
561
  "duplicate flag": { ...launch, argv: [...launch.argv.slice(0, -1), "--json", launch.argv.at(-1)] },
559
- "change prompt": { ...launch, argv: [...launch.argv.slice(0, -1), "other prompt"] },
562
+ "change prompt path": { ...launch, argv: [...launch.argv.slice(0, -1), "other prompt"] },
560
563
  "ambient XDG_CONFIG_HOME": { ...launch, env: { ...launch.env, XDG_CONFIG_HOME: fx.operatorConfigHome } },
561
564
  "ambient XDG_DATA_HOME": { ...launch, env: { ...launch.env, XDG_DATA_HOME: "/operator/data" } },
562
565
  "extra env": { ...launch, env: { ...launch.env, META_API_KEY: API_KEY } },
@@ -566,6 +569,8 @@ test("launch contract: cwd is the real worktree and argv/env/cwd/stdin must matc
566
569
  for (const [name, bad] of Object.entries(widened)) {
567
570
  assert.equal(code(() => attempt.verify(bad)), "invalid_argv", name);
568
571
  }
572
+ fs.writeFileSync(attempt.argv.at(-1), "changed prompt");
573
+ assert.equal(code(() => attempt.verify()), "invalid_argv");
569
574
  }
570
575
  finally {
571
576
  attempt.cleanup();
@@ -47,6 +47,16 @@ function abortKillGraceMs() {
47
47
  return Number(process.env.SPAWN_ABORT_KILL_GRACE_MS ?? 5_000);
48
48
  }
49
49
  export async function spawnCli(runId, cmd, args, cwd, opts) {
50
+ // NOT-225: Node rejects a raw NUL in argv before a process exists.
51
+ const argv = sanitizeArgv(args);
52
+ if (opts.runtime) {
53
+ // Linux MAX_ARG_STRLEN includes the terminating NUL. Measure UTF-8 bytes.
54
+ const oversized = argv.findIndex((arg) => Buffer.byteLength(arg) >= 128 * 1024);
55
+ if (oversized !== -1) {
56
+ const code = "prompt_too_large_for_argv";
57
+ throw Object.assign(new Error(`${code}: ${opts.runtime} argument ${oversized} exceeds the 128 KiB limit (including its terminator)`), { code });
58
+ }
59
+ }
50
60
  await acquireSpawnSlot();
51
61
  try {
52
62
  return await new Promise((resolve, reject) => {
@@ -189,9 +199,7 @@ export async function spawnCli(runId, cmd, args, cwd, opts) {
189
199
  logStream.on("error", (err) => {
190
200
  console.error(`[spawn-cli] log stream error for ${opts.logPath}`, err);
191
201
  });
192
- // NOT-225: sanitize before spawn — a raw NUL in any arg throws
193
- // ERR_INVALID_ARG_VALUE synchronously (no process, no pid, no log).
194
- const child = spawn(cmd, sanitizeArgv(args), {
202
+ const child = spawn(cmd, argv, {
195
203
  cwd,
196
204
  // Extra vars (e.g. codex's bearer-token env var for its per-attempt CODEX_HOME
197
205
  // MCP config, agent-deck-bind.ts) are added on top of, never in place of, the
@@ -200,7 +208,7 @@ export async function spawnCli(runId, cmd, args, cwd, opts) {
200
208
  env: opts.exactEnv ? { ...opts.env } : { ...process.env, ...opts.env },
201
209
  stdio: opts.stdin === undefined ? ["ignore", "pipe", "pipe"] : ["pipe", "pipe", "pipe"],
202
210
  });
203
- // NOT-278: the stdin payload (Muse API key) is written once and closed right after
211
+ // The stdin payload is written once and closed right after
204
212
  // spawn. It never reaches the log stream, the transcript, or any error below.
205
213
  if (opts.stdin !== undefined) {
206
214
  const payload = opts.stdin;
@@ -378,3 +378,22 @@ test("spawnCli does not linger-kill a child that exits inside the terminal grace
378
378
  assert.equal(result.idleTimedOut, false);
379
379
  assert.equal(result.exitCode, 0);
380
380
  });
381
+ test("spawnCli delivers all 200 KiB of a UTF-8 prompt on stdin", async (t) => {
382
+ const dir = fs.mkdtempSync(path.join(os.tmpdir(), "dealer-stdin-"));
383
+ t.after(() => fs.rmSync(dir, { recursive: true, force: true }));
384
+ const prompt = "é".repeat(100 * 1024);
385
+ const result = await spawnCli("large-stdin", process.execPath, ["-e", "const fs = require('node:fs'); fs.writeFileSync('received-bytes', String(fs.readFileSync(0).length))"], dir, { logPath: path.join(dir, "stdout.log"), timeoutMs: 5000, stdin: prompt });
386
+ assert.equal(result.exitCode, 0);
387
+ assert.equal(Number(fs.readFileSync(path.join(dir, "received-bytes"), "utf8")), Buffer.byteLength(prompt));
388
+ });
389
+ test("spawnCli rejects an oversized worker argument before spawning", async (t) => {
390
+ const dir = fs.mkdtempSync(path.join(os.tmpdir(), "dealer-argv-"));
391
+ t.after(() => fs.rmSync(dir, { recursive: true, force: true }));
392
+ const logPath = path.join(dir, "stdout.log");
393
+ await assert.rejects(spawnCli("large-argv", "nonexistent-binary", ["é".repeat(65_537)], dir, {
394
+ logPath,
395
+ runtime: "codex_local",
396
+ timeoutMs: 5000,
397
+ }), { code: "prompt_too_large_for_argv", message: /prompt_too_large_for_argv: codex_local/ });
398
+ assert.equal(fs.existsSync(logPath), false);
399
+ });
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent-dealer/server",
3
- "version": "1.4.3",
3
+ "version": "1.4.5",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "files": [
@@ -23,7 +23,7 @@
23
23
  "test": "AGENT_DEALER_SKIP_GITHUB_HEALTH=1 AGENT_DEALER_SKIP_AGENT_HEALTH=1 npm run build -w @agent-dealer/shared && AGENT_DEALER_SKIP_GITHUB_HEALTH=1 AGENT_DEALER_SKIP_AGENT_HEALTH=1 node ../../scripts/run-workspace-tests.mjs"
24
24
  },
25
25
  "dependencies": {
26
- "@agent-dealer/shared": "1.4.3",
26
+ "@agent-dealer/shared": "1.4.5",
27
27
  "@fastify/cors": "^11.0.1",
28
28
  "@fastify/static": "^8.2.0",
29
29
  "@modelcontextprotocol/sdk": "^1.29.0",