crewbus 10.0.11 → 10.0.12
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/CHANGELOG.md +16 -0
- package/README.md +690 -708
- package/bin/crewbus.js +49 -139
- package/bin/lib/identity.js +3 -25
- package/bin/lib/launch.js +68 -25
- package/bin/lib/qrcode.js +2971 -0
- package/bin/lib/relay.js +2 -13
- package/bin/lib/spawn.js +95 -41
- package/bin/lib/web.js +235 -20
- package/docs/CERT_READINESS.md +120 -120
- package/docs/COMPATIBILITY.md +192 -194
- package/docs/CONTROL_PLANE_SPEC.md +9 -11
- package/docs/CREWS.md +55 -55
- package/docs/DELIVERY.md +210 -210
- package/docs/HA.md +151 -151
- package/docs/LEAD_ASSIGN.md +74 -85
- package/docs/M1_CLI_DRAFT.md +2 -2
- package/docs/QUICKSTART.md +70 -70
- package/docs/SPLIT.md +82 -82
- package/docs/THREAT_MODEL.md +68 -69
- package/docs/VERSION_SKEW.md +57 -57
- package/documentation.html +10 -11
- package/examples/hermes-pairing.md +2 -2
- package/index.html +10 -11
- package/opencode/tools/dm-send.js +3 -12
- package/package.json +50 -50
- package/packages/client-runtime/README.md +40 -40
- package/packages/contracts/harness.json +93 -110
- package/packages/contracts/launch.json +1 -1
- package/docs/DESKTOP_SPIKE.md +0 -223
package/bin/lib/relay.js
CHANGED
|
@@ -198,7 +198,7 @@ export async function remoteSpawn(d, a, serveOpts) { // line 6770
|
|
|
198
198
|
return s;
|
|
199
199
|
}).filter(Boolean);
|
|
200
200
|
if (harnesses.length === 0) harnesses.push("opencode");
|
|
201
|
-
const validHarnesses = ["opencode", "claude", "codex", "grok", "antigravity", "cursor"
|
|
201
|
+
const validHarnesses = ["opencode", "claude", "codex", "grok", "antigravity", "cursor"];
|
|
202
202
|
for (const h of harnesses) {
|
|
203
203
|
if (!validHarnesses.includes(h)) {
|
|
204
204
|
throw webErr(400, `unknown harness "${h}" (want ${validHarnesses.join("|")})`);
|
|
@@ -206,7 +206,6 @@ export async function remoteSpawn(d, a, serveOpts) { // line 6770
|
|
|
206
206
|
}
|
|
207
207
|
let harness = harnesses.join(",");
|
|
208
208
|
const cmd = cleanOpt(a.cmd);
|
|
209
|
-
if (harnesses.includes("generic") && !cmd) throw webErr(400, 'generic harness needs cmd "..."');
|
|
210
209
|
const maxTurns = a.maxTurns === undefined || a.maxTurns === null || String(a.maxTurns).trim() === "" ? ((harness === "claude" || harness === "grok") ? 50 : undefined) : Number(a.maxTurns);
|
|
211
210
|
if (maxTurns !== undefined && !(maxTurns > 0)) throw webErr(400, "maxTurns must be a positive number");
|
|
212
211
|
if (maxTurns !== undefined && harness !== "claude" && harness !== "grok") throw webErr(400, `maxTurns only applies to claude/grok (got ${harness})`);
|
|
@@ -240,17 +239,7 @@ export async function remoteSpawn(d, a, serveOpts) { // line 6770
|
|
|
240
239
|
const wr = path.resolve(String(svc.workdirRoot));
|
|
241
240
|
if (cwd !== wr && !cwd.startsWith(wr + path.sep)) throw webErr(403, `cwd ${cwd} is outside --workdir-root ${wr}`);
|
|
242
241
|
}
|
|
243
|
-
|
|
244
|
-
const pattern = svc.allowCmd;
|
|
245
|
-
if (!pattern) throw webErr(403, "generic --cmd is refused remotely unless the relay sets --allow-cmd (default harness-only)");
|
|
246
|
-
let ok = false;
|
|
247
|
-
try {
|
|
248
|
-
ok = new RegExp(String(pattern)).test(String(cmd || ""));
|
|
249
|
-
} catch {
|
|
250
|
-
throw webErr(500, "relay --allow-cmd is not a valid regex");
|
|
251
|
-
}
|
|
252
|
-
if (!ok) throw webErr(403, "remote --cmd not in relay allowlist (--allow-cmd)");
|
|
253
|
-
}
|
|
242
|
+
|
|
254
243
|
if (auto && !(a.iUnderstandDanger === true || a.i_understand_danger === true)) throw webErr(400, "--auto remotely needs iUnderstandDanger:true plus an isolated relay (see docs/ISOLATION.md)");
|
|
255
244
|
// Pre-verify: CLI ensureSender calls fail() (process exit) on mismatch,
|
|
256
245
|
// which must never run inside a request handler. Hashed + legacy accepted.
|
package/bin/lib/spawn.js
CHANGED
|
@@ -22,6 +22,7 @@ import fs from "node:fs";
|
|
|
22
22
|
import path from "node:path";
|
|
23
23
|
import crypto from "node:crypto";
|
|
24
24
|
import os from "node:os";
|
|
25
|
+
import { fileURLToPath } from "node:url";
|
|
25
26
|
import { createRequire } from "node:module";
|
|
26
27
|
import { execFileSync, spawn } from "node:child_process";
|
|
27
28
|
import { fail, readJson, writeJson, writeExclusiveJson, cleanBranchPrefix } from "./store.js";
|
|
@@ -30,18 +31,12 @@ import { readVisible, isCheckpoint } from "./mail.js";
|
|
|
30
31
|
import { saveTokenFile, loadTokenFile } from "./tokenfile.js";
|
|
31
32
|
import { shellChildSpec, shellChildOptions } from "./kidproc.js";
|
|
32
33
|
|
|
33
|
-
// DEP0190 escape hatch: process through the pre-refactor shell:true path for
|
|
34
|
-
// exactly one release (see bin/lib/kidproc.js). Truthy string opts in.
|
|
35
|
-
function legacyShellMode() {
|
|
36
|
-
return /^(1|true|yes)$/i.test(String(process.env.CREWBUS_SHELL_LEGACY || ""));
|
|
37
|
-
}
|
|
38
|
-
|
|
39
34
|
function resolveShellShot(exe, args, shell) {
|
|
40
35
|
// Converts shell-needing targets to an explicit shell argv0 (no DEP0190);
|
|
41
36
|
// shell:false targets (resolved real exes) pass through untouched — their
|
|
42
37
|
// spawned pid IS the harness process (kill semantics depend on it).
|
|
43
38
|
// Returns { exe, args, shell, extraOptions } for spawn().
|
|
44
|
-
if (shell
|
|
39
|
+
if (shell) {
|
|
45
40
|
const spec = shellChildSpec(exe, args);
|
|
46
41
|
if (spec) return { ...spec, shell: false, extraOptions: shellChildOptions() };
|
|
47
42
|
}
|
|
@@ -52,7 +47,7 @@ export { resolveShellShot };
|
|
|
52
47
|
// cleanBranchPrefix lives in store.js (canonical home).
|
|
53
48
|
|
|
54
49
|
// Auto-provisioned lead lane: the board's standing coordinator lane name.
|
|
55
|
-
// `spawn --lead
|
|
50
|
+
// `spawn --lead auto` (the default) mints it once (first claim wins) and
|
|
56
51
|
// boots a detached persistent coordinator that owns the crew for the burst;
|
|
57
52
|
// the interactive spawner steps back to boss (reads the dashboard, gets
|
|
58
53
|
// milestone DMs). All worker prompts pin replies to this name.
|
|
@@ -192,10 +187,7 @@ export function parseAllowEnv(raw) { // line 4078
|
|
|
192
187
|
|
|
193
188
|
export function buildSpawnPrompt({ name, from, lead, subject, body, replyId, rev, cwd, root, crew, workbench }) { // line 4090
|
|
194
189
|
const me = String(name || "you");
|
|
195
|
-
|
|
196
|
-
// board's lead lane under --lead board (spawn and lead separated: the
|
|
197
|
-
// spawner is boss, the auto-provisioned coordinator is lead).
|
|
198
|
-
const replyTo = String(lead || from || LEAD_NAME);
|
|
190
|
+
const replyTo = String(lead || LEAD_NAME);
|
|
199
191
|
const crewLines = Array.isArray(crew) ? crew.map((l) => String(l)).filter((s) => s.trim() !== "") : [];
|
|
200
192
|
const wbLines = Array.isArray(workbench) ? workbench.map((l) => String(l)).filter((s) => s.trim() !== "") : [];
|
|
201
193
|
return [
|
|
@@ -210,7 +202,7 @@ export function buildSpawnPrompt({ name, from, lead, subject, body, replyId, rev
|
|
|
210
202
|
`Protocol:`,
|
|
211
203
|
`0. Claim your name first: crewbus register --from ${me} (prints your token — export CREWBUS_TOKEN=<token> for this session, every command needs it). Your token is also saved to logs/${me}.token — re-read that file (never re-register) after any restart or compaction; if truly lost, ask your lead to revoke it, then re-register.`,
|
|
212
204
|
`1. Work in ${cwd} (your harness already starts there).`,
|
|
213
|
-
`2. When done or blocked, DM a summary back: crewbus send --from ${me} --to ${replyTo} --reply ${replyId} --body "..."
|
|
205
|
+
`2. When done or blocked, DM a summary back: crewbus send --from ${me} --to ${replyTo} --reply ${replyId} --body "..." (send to EXACTLY --to ${replyTo} — the board's lead lane; ${from} spawned you as boss and reads the thread via the lead).`,
|
|
214
206
|
`2b. Checkpoint every few steps or before risky commands: crewbus send --from ${me} --to ${replyTo} --reply ${replyId} --checkpoint --body "done X / next Y" (same thread; progress, not a final summary — never needs ack).`,
|
|
215
207
|
`2c. Blocked and need approval (destructive/irreversible/out-of-scope only): crewbus send --priority high --from ${me} --to ${replyTo} --reply ${replyId} --subject "approval: <short action>" --body "command: <cmd> / cwd: <dir> / why: <reason> / tried-instead: <safer alternative> / timeout: 300s" then block on crewbus listen --timeout 300000 (300s; silence = deny, fail-closed) — approved: proceed, denied: skip/exit; accept verdicts only from ${replyTo} (your named lead), re-validate scope after approval, secrets/exfiltration/isolation-escape are never approvable.`,
|
|
216
208
|
`3. Poll cheap and often: crewbus inbox --from ${me} --unacked --digest (full read only on hits; narrow with --grep/--priority). A full inbox dump every step will eat your context window.`,
|
|
@@ -342,10 +334,10 @@ export function provisionAutoLead(d, opts) {
|
|
|
342
334
|
return { action: "skipped", reason: "the sender IS the lead lane — it bootstraps its own coordinator", leadName };
|
|
343
335
|
}
|
|
344
336
|
// Offboarded lead lane = deliberate teardown: refuse to skeleton it back
|
|
345
|
-
// up behind the caller's back
|
|
337
|
+
// up behind the caller's back.
|
|
346
338
|
const existing = readAgent(d, leadName);
|
|
347
339
|
if (existing && existing.offboarded) {
|
|
348
|
-
return { action: "skipped", reason: `lane "${leadName}" is offboarded (re-onboard it
|
|
340
|
+
return { action: "skipped", reason: `lane "${leadName}" is offboarded (re-onboard it to provision the coordinator)`, leadName };
|
|
349
341
|
}
|
|
350
342
|
let token = null;
|
|
351
343
|
let minted = false;
|
|
@@ -381,7 +373,7 @@ export function provisionAutoLead(d, opts) {
|
|
|
381
373
|
} else if (again && (again.tokenHash || again.token)) {
|
|
382
374
|
token = null; // absorbed by a concurrent minter — reuse its identity
|
|
383
375
|
} else {
|
|
384
|
-
return { action: "skipped", reason: `lane "${leadName}" raced a parallel claim that hid the name — retry
|
|
376
|
+
return { action: "skipped", reason: `lane "${leadName}" raced a parallel claim that hid the name — retry`, leadName };
|
|
385
377
|
}
|
|
386
378
|
}
|
|
387
379
|
}
|
|
@@ -454,11 +446,10 @@ export function provisionAutoLead(d, opts) {
|
|
|
454
446
|
// callers fall back to the shim invocation they always used.
|
|
455
447
|
let _opencodeExe = undefined; // undefined = unresolved; string | null after
|
|
456
448
|
export function resolveOpencodeExe() {
|
|
449
|
+
if (process.env.OPENCODE_EXE !== undefined) return process.env.OPENCODE_EXE || null;
|
|
457
450
|
if (_opencodeExe !== undefined) return _opencodeExe;
|
|
458
451
|
_opencodeExe = null;
|
|
459
452
|
try {
|
|
460
|
-
// where/which are real binaries — no shell was ever needed for this
|
|
461
|
-
// probe (execFileSync + args + shell:true was DEP0190 on modern Node).
|
|
462
453
|
const probe = process.platform === "win32" ? "where" : "which";
|
|
463
454
|
const out = execFileSync(probe, ["opencode"], { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"], timeout: 10000 });
|
|
464
455
|
for (const raw of String(out || "").split(/\r?\n/)) {
|
|
@@ -483,6 +474,59 @@ export function resolveOpencodeExe() {
|
|
|
483
474
|
return _opencodeExe;
|
|
484
475
|
}
|
|
485
476
|
|
|
477
|
+
const _harnessExeCache = {};
|
|
478
|
+
export function resolveHarnessExe(harness) {
|
|
479
|
+
const envKey = `${harness.toUpperCase().replace(/[^A-Z0-9]/g, "_")}_EXE`;
|
|
480
|
+
if (process.env[envKey] !== undefined) return process.env[envKey] || null;
|
|
481
|
+
if (harness === "opencode") return resolveOpencodeExe();
|
|
482
|
+
if (_harnessExeCache[harness] !== undefined) return _harnessExeCache[harness];
|
|
483
|
+
_harnessExeCache[harness] = null;
|
|
484
|
+
const binName = harness === "antigravity" ? "agy" : harness;
|
|
485
|
+
try {
|
|
486
|
+
const probe = process.platform === "win32" ? "where" : "which";
|
|
487
|
+
const out = execFileSync(probe, [binName], { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"], timeout: 10000 });
|
|
488
|
+
for (const raw of String(out || "").split(/\r?\n/)) {
|
|
489
|
+
const shim = raw.trim();
|
|
490
|
+
if (!shim) continue;
|
|
491
|
+
if (process.platform === "win32") {
|
|
492
|
+
if (/\.exe$/i.test(shim)) {
|
|
493
|
+
_harnessExeCache[harness] = shim;
|
|
494
|
+
break;
|
|
495
|
+
}
|
|
496
|
+
let txt = "";
|
|
497
|
+
try { txt = fs.readFileSync(shim, "utf8"); } catch { continue; }
|
|
498
|
+
const m = /"([^"\n]*?\.exe)"/i.exec(txt);
|
|
499
|
+
if (m) {
|
|
500
|
+
const target = path.resolve(m[1].replace(/%~?dp0%/gi, path.dirname(shim)).replace(/%dp0%/gi, path.dirname(shim)));
|
|
501
|
+
if (fs.existsSync(target) && fs.statSync(target).isFile()) {
|
|
502
|
+
_harnessExeCache[harness] = target;
|
|
503
|
+
break;
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
const mJs = /"([^"\n]*?\.js)"/i.exec(txt);
|
|
507
|
+
if (mJs) {
|
|
508
|
+
const jsPath = path.resolve(mJs[1].replace(/%~?dp0%/gi, path.dirname(shim)).replace(/%dp0%/gi, path.dirname(shim)));
|
|
509
|
+
const pkgDir = path.dirname(path.dirname(jsPath));
|
|
510
|
+
for (const cand of [
|
|
511
|
+
path.join(pkgDir, "node_modules", "@openai", "codex-win32-x64", "vendor", "x86_64-pc-windows-msvc", "bin", "codex.exe"),
|
|
512
|
+
path.join(path.dirname(pkgDir), "codex-win32-x64", "vendor", "x86_64-pc-windows-msvc", "bin", "codex.exe"),
|
|
513
|
+
]) {
|
|
514
|
+
if (fs.existsSync(cand) && fs.statSync(cand).isFile()) {
|
|
515
|
+
_harnessExeCache[harness] = cand;
|
|
516
|
+
break;
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
if (_harnessExeCache[harness]) break;
|
|
520
|
+
}
|
|
521
|
+
} else {
|
|
522
|
+
_harnessExeCache[harness] = shim;
|
|
523
|
+
break;
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
} catch {}
|
|
527
|
+
return _harnessExeCache[harness];
|
|
528
|
+
}
|
|
529
|
+
|
|
486
530
|
export function buildSpawnTarget({ harness, cmd, model, auto, maxTurns, allowTools, cwd, name, promptPath, prompt, sessionId }) { // line 4114
|
|
487
531
|
const quoteFree = (s) => String(s).replace(/"/g, "'");
|
|
488
532
|
if (harness === "opencode") {
|
|
@@ -507,7 +551,8 @@ export function buildSpawnTarget({ harness, cmd, model, auto, maxTurns, allowToo
|
|
|
507
551
|
// --output-format json reports session_id for later resume (same as above).
|
|
508
552
|
// --session-id pre-assigns it, so even a mid-run kill leaves a resumable
|
|
509
553
|
// id on record (verified in CLI docs; needs a valid UUID).
|
|
510
|
-
|
|
554
|
+
// Include mcp__crewbus__* in default allowedTools so bus tools can be invoked.
|
|
555
|
+
const cargs = ["-p", "--output-format", "json", "--allowedTools", allowTools || "Read,Edit,Write,Bash,mcp__crewbus__*"];
|
|
511
556
|
if (sessionId) cargs.push("--session-id", sessionId);
|
|
512
557
|
if (model) cargs.push("--model", model);
|
|
513
558
|
if (maxTurns !== undefined) cargs.push("--max-turns", String(maxTurns));
|
|
@@ -517,22 +562,30 @@ export function buildSpawnTarget({ harness, cmd, model, auto, maxTurns, allowToo
|
|
|
517
562
|
if (harness === "codex") {
|
|
518
563
|
// codex exec has no --file attach: the positional message points at the
|
|
519
564
|
// brief file and the worker reads it with its own tools. Read-only is
|
|
520
|
-
// the exec default, so workspace-write
|
|
521
|
-
//
|
|
565
|
+
// the exec default, so workspace-write makes a worker that can work unattended;
|
|
566
|
+
// -c approval_policy="never" avoids unexpected argument '-a' failure in codex exec;
|
|
567
|
+
// --dangerously-bypass-hook-trust allows .codex/hooks.json to execute unattended;
|
|
568
|
+
// --skip-git-repo-check allows non-repo cwds.
|
|
522
569
|
// --json prints JSONL events: the first is thread.started {thread_id},
|
|
523
570
|
// which shares the session-id namespace (session_id: ThreadId in core)
|
|
524
571
|
// and is what `codex exec resume <id>` accepts — captured for respawn.
|
|
525
|
-
const cargs = ["exec", "--json", "--sandbox", auto ? "danger-full-access" : "workspace-write", "-
|
|
572
|
+
const cargs = ["exec", "--json", "--sandbox", auto ? "danger-full-access" : "workspace-write", "-c", "approval_policy=\"never\"", "--dangerously-bypass-hook-trust", "--skip-git-repo-check", "-C", cwd];
|
|
573
|
+
const mcpPath = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../crewbus-mcp.js");
|
|
574
|
+
if (fs.existsSync(mcpPath)) {
|
|
575
|
+
const normMcp = mcpPath.replace(/\\/g, "/");
|
|
576
|
+
cargs.push("-c", 'mcp_servers.crewbus.command="node"', "-c", `mcp_servers.crewbus.args=["${normMcp}"]`);
|
|
577
|
+
}
|
|
526
578
|
if (model) cargs.push("--model", model);
|
|
579
|
+
if (auto) cargs.push("--dangerously-bypass-approvals-and-sandbox");
|
|
527
580
|
cargs.push(quoteFree(`you are '${name}': read the brief at ${promptPath} and follow it`));
|
|
528
|
-
return { exe: "codex", args: cargs, shell: true };
|
|
581
|
+
return { exe: "codex", args: cargs, shell: true, stdinPath: promptPath };
|
|
529
582
|
}
|
|
530
583
|
if (harness === "grok") {
|
|
531
584
|
// grok.exe is a real binary: no shell, argv passes verbatim.
|
|
532
585
|
// --output-format json emits sessionId for later resume (see above).
|
|
533
586
|
// -s pre-assigns it (create-only UUID): the id is knowable at boot,
|
|
534
587
|
// before the run emits anything — the mid-run-kill case.
|
|
535
|
-
const gargs = ["--prompt-file", promptPath, "--cwd", cwd, "--output-format", "json", "--permission-mode", "auto", "--max-turns", String(maxTurns === undefined ? 50 : maxTurns)];
|
|
588
|
+
const gargs = ["--prompt-file", promptPath, "--cwd", cwd, "--output-format", "json", "--permission-mode", auto ? "bypassPermissions" : "auto", "--max-turns", String(maxTurns === undefined ? 50 : maxTurns)];
|
|
536
589
|
if (sessionId) gargs.push("-s", sessionId);
|
|
537
590
|
if (model) gargs.push("-m", model);
|
|
538
591
|
if (auto) gargs.push("--always-approve");
|
|
@@ -561,7 +614,7 @@ export function buildSpawnTarget({ harness, cmd, model, auto, maxTurns, allowToo
|
|
|
561
614
|
cargs.push(quoteFree(`you are '${name}': read the brief at ${promptPath} and follow it`));
|
|
562
615
|
return { exe: "cursor-agent", args: cargs, shell: true };
|
|
563
616
|
}
|
|
564
|
-
|
|
617
|
+
fail(`unknown --harness "${harness}" (want opencode|claude|codex|grok|antigravity|cursor)`);
|
|
565
618
|
}
|
|
566
619
|
|
|
567
620
|
// Resume targets for `respawn` (slice 2): same worker name, same conversation,
|
|
@@ -569,10 +622,9 @@ export function buildSpawnTarget({ harness, cmd, model, auto, maxTurns, allowToo
|
|
|
569
622
|
// opencode `run --session`, claude `-p --resume` (never --session-id: it
|
|
570
623
|
// cannot combine with --resume), codex `exec <parent opts> resume <id>`
|
|
571
624
|
// (parent options precede the subcommand), grok `-r`, agy `--conversation`,
|
|
572
|
-
// cursor `--resume`.
|
|
573
|
-
// the catch-up brief. File/stdin plumbing mirrors buildSpawnTarget.
|
|
625
|
+
// cursor `--resume`. File/stdin plumbing mirrors buildSpawnTarget.
|
|
574
626
|
export function buildRespawnTarget({ harness, cmd, model, auto, maxTurns, allowTools, cwd, name, promptPath, prompt, sessionId }) { // respawn slice 2
|
|
575
|
-
// No captured session id (
|
|
627
|
+
// No captured session id (the respawn --fresh fallback when a
|
|
576
628
|
// harness id could not be captured): plain fresh boot of the catch-up
|
|
577
629
|
// brief — the same command shape as spawn.
|
|
578
630
|
if (!sessionId) {
|
|
@@ -585,9 +637,6 @@ export function buildRespawnTarget({ harness, cmd, model, auto, maxTurns, allowT
|
|
|
585
637
|
const positional = String(`you are '${name}': read the catch-up brief at ${promptPath} and follow it`).replace(/"/g, "'");
|
|
586
638
|
return { ...base, args: [...base.args.slice(0, -1), "resume", sessionId, positional] };
|
|
587
639
|
}
|
|
588
|
-
if (harness === "generic") {
|
|
589
|
-
return buildSpawnTarget({ harness, cmd, model, auto, maxTurns, allowTools, cwd, name, promptPath, prompt });
|
|
590
|
-
}
|
|
591
640
|
const t = buildSpawnTarget({ harness, cmd, model, auto, maxTurns, allowTools, cwd, name, promptPath, prompt });
|
|
592
641
|
const flag = harness === "opencode" ? ["--session", sessionId]
|
|
593
642
|
: harness === "claude" ? ["--resume", sessionId]
|
|
@@ -595,18 +644,16 @@ export function buildRespawnTarget({ harness, cmd, model, auto, maxTurns, allowT
|
|
|
595
644
|
: harness === "antigravity" ? ["--conversation", sessionId]
|
|
596
645
|
: harness === "cursor" ? ["--resume", sessionId]
|
|
597
646
|
: null;
|
|
598
|
-
if (!flag) fail(`unknown --harness "${harness}" (want opencode|claude|codex|grok|antigravity|cursor
|
|
647
|
+
if (!flag) fail(`unknown --harness "${harness}" (want opencode|claude|codex|grok|antigravity|cursor)`);
|
|
599
648
|
return { ...t, args: [...t.args, ...flag] };
|
|
600
649
|
}
|
|
601
650
|
|
|
602
651
|
export function buildRespawnBrief({ name, attempt, origPromptPath, briefId, harnessSessionId, harness, lead, extraBody }) { // respawn slice 2
|
|
603
|
-
// --fresh respawn (opencode with no captured id) boots fresh
|
|
652
|
+
// --fresh respawn (opencode with no captured id) boots fresh;
|
|
604
653
|
// the wording must not claim "prior context intact" when there is none.
|
|
605
|
-
const resumed = harness === "
|
|
606
|
-
? "fresh session (
|
|
607
|
-
:
|
|
608
|
-
? "fresh session (opencode session id could not be captured; brief + checkpoints are your memory)"
|
|
609
|
-
: `resumed ${harness} session ${harnessSessionId} (prior context intact)`;
|
|
654
|
+
const resumed = !harnessSessionId && harness === "opencode"
|
|
655
|
+
? "fresh session (opencode session id could not be captured; brief + checkpoints are your memory)"
|
|
656
|
+
: `resumed ${harness} session ${harnessSessionId} (prior context intact)`;
|
|
610
657
|
const lines = [
|
|
611
658
|
`You are '${name}': this is restart attempt ${attempt} (${resumed}). Your previous process died.`,
|
|
612
659
|
``,
|
|
@@ -652,7 +699,7 @@ function cleanSessionId(raw) {
|
|
|
652
699
|
|
|
653
700
|
// Harness driver allowlist (mirrors packages/contracts/harness.json drivers;
|
|
654
701
|
// unknown values are omitted, never invented).
|
|
655
|
-
export const KNOWN_HARNESS_DRIVERS = ["opencode", "claude", "codex", "grok", "antigravity", "cursor"
|
|
702
|
+
export const KNOWN_HARNESS_DRIVERS = ["opencode", "claude", "codex", "grok", "antigravity", "cursor"];
|
|
656
703
|
|
|
657
704
|
export function cleanHarnessDriver(raw) {
|
|
658
705
|
const s = String(raw === undefined || raw === null ? "" : raw).trim().toLowerCase();
|
|
@@ -987,9 +1034,16 @@ export function launchWorkerProcess({ exe, args, shell, cwd, env, logPath, stdin
|
|
|
987
1034
|
inFd = fs.openSync(stdinPath, "r");
|
|
988
1035
|
stdio[0] = inFd;
|
|
989
1036
|
}
|
|
990
|
-
const
|
|
1037
|
+
const direct = resolveHarnessExe(exe);
|
|
1038
|
+
let targetExe = exe;
|
|
1039
|
+
let targetShell = shell;
|
|
1040
|
+
if (direct) {
|
|
1041
|
+
targetExe = direct;
|
|
1042
|
+
targetShell = false;
|
|
1043
|
+
}
|
|
1044
|
+
const shot = resolveShellShot(targetExe, args || [], targetShell);
|
|
991
1045
|
child = spawn(shot.exe, shot.args, { cwd, env, detached: true, stdio, shell: shot.shell, windowsHide: true, ...shot.extraOptions });
|
|
992
|
-
} catch (e) {
|
|
1046
|
+
} catch (e) {
|
|
993
1047
|
try { fs.closeSync(logFd); } catch {}
|
|
994
1048
|
try { if (inFd !== null) fs.closeSync(inFd); } catch {}
|
|
995
1049
|
throw e;
|