crewbus 10.0.7 → 10.0.9
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 +21 -0
- package/README.md +41 -8
- package/bin/crewbus.js +259 -27
- package/bin/lib/identity.js +56 -1
- package/bin/lib/mail.js +14 -2
- package/bin/lib/spawn.js +202 -10
- package/bin/lib/store.js +5 -3
- package/bin/lib/web.js +252 -49
- package/bin/lib/workbench.js +188 -0
- package/docs/SPLIT.md +5 -4
- package/docs/VERSION_SKEW.md +1 -1
- package/documentation.html +365 -359
- package/index.html +9 -8
- package/package.json +2 -2
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 { createRequire } from "node:module";
|
|
25
26
|
import { execFileSync, spawn } from "node:child_process";
|
|
26
27
|
import { fail, readJson, writeJson, cleanBranchPrefix } from "./store.js";
|
|
27
28
|
import { touchAgent } from "./identity.js";
|
|
@@ -161,9 +162,10 @@ export function parseAllowEnv(raw) { // line 4078
|
|
|
161
162
|
return String(raw).split(",").map((s) => String(s).trim()).filter(Boolean).join(",");
|
|
162
163
|
}
|
|
163
164
|
|
|
164
|
-
export function buildSpawnPrompt({ name, from, subject, body, replyId, rev, cwd, root, crew }) { // line 4090
|
|
165
|
+
export function buildSpawnPrompt({ name, from, subject, body, replyId, rev, cwd, root, crew, workbench }) { // line 4090
|
|
165
166
|
const me = String(name || "you");
|
|
166
167
|
const crewLines = Array.isArray(crew) ? crew.map((l) => String(l)).filter((s) => s.trim() !== "") : [];
|
|
168
|
+
const wbLines = Array.isArray(workbench) ? workbench.map((l) => String(l)).filter((s) => s.trim() !== "") : [];
|
|
167
169
|
return [
|
|
168
170
|
`You are '${me}' on crewbus (board: ${root}).`,
|
|
169
171
|
`CREWBUS_DIR and CREWBUS_AGENT ('${me}') are already set in your environment — send/inbox resolve the board automatically.`,
|
|
@@ -172,10 +174,11 @@ export function buildSpawnPrompt({ name, from, subject, body, replyId, rev, cwd,
|
|
|
172
174
|
body,
|
|
173
175
|
``,
|
|
174
176
|
...(crewLines.length > 0 ? ["Crew:", ...crewLines.map((l) => `- ${l}`), ""] : []),
|
|
177
|
+
...(wbLines.length > 0 ? ["Workbench (lessons + artifacts from prior work on this board):", ...wbLines, ""] : []),
|
|
175
178
|
`Protocol:`,
|
|
176
179
|
`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.`,
|
|
177
180
|
`1. Work in ${cwd} (your harness already starts there).`,
|
|
178
|
-
`2. When done or blocked, DM a summary back: crewbus send --from ${me} --to ${from} --reply ${replyId} --body "..."
|
|
181
|
+
`2. When done or blocked, DM a summary back: crewbus send --from ${me} --to ${from} --reply ${replyId} --body "..." (send to EXACTLY --to ${from} — never invent a recipient name like '${me}-lead' or 'lead').`,
|
|
179
182
|
`2b. Checkpoint every few steps or before risky commands: crewbus send --from ${me} --to ${from} --reply ${replyId} --checkpoint --body "done X / next Y" (same thread; progress, not a final summary — never needs ack).`,
|
|
180
183
|
`2c. Blocked and need approval (destructive/irreversible/out-of-scope only): crewbus send --priority high --from ${me} --to ${from} --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 ${from} (your named lead), re-validate scope after approval, secrets/exfiltration/isolation-escape are never approvable.`,
|
|
181
184
|
`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.`,
|
|
@@ -231,6 +234,43 @@ export function buildCrewContext({ name, from, subject, groups, myGroups, offTas
|
|
|
231
234
|
return out;
|
|
232
235
|
}
|
|
233
236
|
|
|
237
|
+
// Resolve the real opencode binary from PATH, once per process. npm installs
|
|
238
|
+
// expose cmd/bash/ps1 shims that shell out to the real exe; running through
|
|
239
|
+
// them (the old `shell: true` path) drags the Bun binary into cmd.exe, which
|
|
240
|
+
// block-buffers stdout in console-less detached contexts — a hard kill then
|
|
241
|
+
// drops the buffer and the worker log never reveals the session id. Each shim
|
|
242
|
+
// embeds its target path (cmd: "%dp0%\node_modules\...\opencode.exe", shims:
|
|
243
|
+
// "$basedir/node_modules/...\opencode.exe"), so extract it, verify the file
|
|
244
|
+
// exists, and memoize. Returns the exe path, or null when resolution fails —
|
|
245
|
+
// callers fall back to the shim invocation they always used.
|
|
246
|
+
let _opencodeExe = undefined; // undefined = unresolved; string | null after
|
|
247
|
+
export function resolveOpencodeExe() {
|
|
248
|
+
if (_opencodeExe !== undefined) return _opencodeExe;
|
|
249
|
+
_opencodeExe = null;
|
|
250
|
+
try {
|
|
251
|
+
const out = execFileSync(process.platform === "win32" ? "where" : "which", ["opencode"], { encoding: "utf8", shell: true, stdio: ["ignore", "pipe", "ignore"], timeout: 10000 });
|
|
252
|
+
for (const raw of String(out || "").split(/\r?\n/)) {
|
|
253
|
+
const shim = raw.trim();
|
|
254
|
+
if (!shim) continue;
|
|
255
|
+
let target = shim;
|
|
256
|
+
if (process.platform === "win32" && !/\.exe$/i.test(shim)) {
|
|
257
|
+
try {
|
|
258
|
+
const m = /"([^"\n]*?\.exe)"/i.exec(fs.readFileSync(shim, "utf8"));
|
|
259
|
+
if (m) target = m[1].replace(/%~?dp0%/gi, path.dirname(shim)).replace(/\$basedir/gi, path.dirname(shim));
|
|
260
|
+
} catch {}
|
|
261
|
+
}
|
|
262
|
+
target = path.resolve(target);
|
|
263
|
+
try {
|
|
264
|
+
if (fs.existsSync(target) && fs.statSync(target).isFile() && (process.platform === "win32" ? /\.exe$/i.test(target) : true)) {
|
|
265
|
+
_opencodeExe = target;
|
|
266
|
+
break;
|
|
267
|
+
}
|
|
268
|
+
} catch {}
|
|
269
|
+
}
|
|
270
|
+
} catch {}
|
|
271
|
+
return _opencodeExe;
|
|
272
|
+
}
|
|
273
|
+
|
|
234
274
|
export function buildSpawnTarget({ harness, cmd, model, auto, maxTurns, allowTools, cwd, name, promptPath, prompt, sessionId }) { // line 4114
|
|
235
275
|
const quoteFree = (s) => String(s).replace(/"/g, "'");
|
|
236
276
|
if (harness === "opencode") {
|
|
@@ -243,6 +283,11 @@ export function buildSpawnTarget({ harness, cmd, model, auto, maxTurns, allowToo
|
|
|
243
283
|
// extractHarnessSessionId / syncWorkerSession).
|
|
244
284
|
oargs.push("--format", "json");
|
|
245
285
|
oargs.push(shortMsg);
|
|
286
|
+
// The resolved real exe runs with shell:false: output streams to the log
|
|
287
|
+
// from byte one (no cmd.exe buffering) and the spawned pid IS the
|
|
288
|
+
// harness process, so kill semantics stay honest too.
|
|
289
|
+
const exe = resolveOpencodeExe();
|
|
290
|
+
if (exe) return { exe, args: oargs, shell: false };
|
|
246
291
|
return { exe: "opencode", args: oargs, shell: true };
|
|
247
292
|
}
|
|
248
293
|
if (harness === "claude") {
|
|
@@ -315,6 +360,12 @@ export function buildSpawnTarget({ harness, cmd, model, auto, maxTurns, allowToo
|
|
|
315
360
|
// cursor `--resume`. Generic has no session continuity: plain fresh boot of
|
|
316
361
|
// the catch-up brief. File/stdin plumbing mirrors buildSpawnTarget.
|
|
317
362
|
export function buildRespawnTarget({ harness, cmd, model, auto, maxTurns, allowTools, cwd, name, promptPath, prompt, sessionId }) { // respawn slice 2
|
|
363
|
+
// No captured session id (generic, or the respawn --fresh fallback when a
|
|
364
|
+
// harness id could not be captured): plain fresh boot of the catch-up
|
|
365
|
+
// brief — the same command shape as spawn.
|
|
366
|
+
if (!sessionId) {
|
|
367
|
+
return buildSpawnTarget({ harness, cmd, model, auto, maxTurns, allowTools, cwd, name, promptPath, prompt });
|
|
368
|
+
}
|
|
318
369
|
if (harness === "codex") {
|
|
319
370
|
const base = buildSpawnTarget({ harness, cmd, model, auto, maxTurns, allowTools, cwd, name, promptPath, prompt });
|
|
320
371
|
// Point at the catch-up file (which links the original brief), not the
|
|
@@ -337,9 +388,13 @@ export function buildRespawnTarget({ harness, cmd, model, auto, maxTurns, allowT
|
|
|
337
388
|
}
|
|
338
389
|
|
|
339
390
|
export function buildRespawnBrief({ name, attempt, origPromptPath, briefId, harnessSessionId, harness, lead, extraBody }) { // respawn slice 2
|
|
391
|
+
// --fresh respawn (opencode with no captured id) boots fresh like generic;
|
|
392
|
+
// the wording must not claim "prior context intact" when there is none.
|
|
340
393
|
const resumed = harness === "generic"
|
|
341
394
|
? "fresh session (generic harness has no session continuity — no prior context)"
|
|
342
|
-
:
|
|
395
|
+
: !harnessSessionId && harness === "opencode"
|
|
396
|
+
? "fresh session (opencode session id could not be captured; brief + checkpoints are your memory)"
|
|
397
|
+
: `resumed ${harness} session ${harnessSessionId} (prior context intact)`;
|
|
343
398
|
const lines = [
|
|
344
399
|
`You are '${name}': this is restart attempt ${attempt} (${resumed}). Your previous process died.`,
|
|
345
400
|
``,
|
|
@@ -452,6 +507,115 @@ export function extractHarnessSessionId(harness, text) { // respawn slice 1
|
|
|
452
507
|
return null;
|
|
453
508
|
}
|
|
454
509
|
|
|
510
|
+
// ----------------------------------------------------------- opencode storage fallback
|
|
511
|
+
// opencode.exe (a Bun binary) buffers ALL stdout when run through the cmd.exe
|
|
512
|
+
// wrapper in a console-less detached context; a hard kill drops the buffer, so
|
|
513
|
+
// the worker log can stay empty and the log-scan capture above never fires.
|
|
514
|
+
// opencode 1.19+ independently persists every session to its SQLite database
|
|
515
|
+
// (WAL) the moment a run starts — on every platform at
|
|
516
|
+
// `%USERPROFILE%\.local\share\opencode\opencode.db` — with the exact spawn
|
|
517
|
+
// marker `--title crewbus:<name>` (buildSpawnTarget) and the worker cwd in
|
|
518
|
+
// `directory` (forward slashes). node:sqlite ships with Node >= 22 (repo floor
|
|
519
|
+
// is 18): every failure below degrades SILENTLY to log-scan-only.
|
|
520
|
+
let _sqliteModule = undefined; // undefined = not probed; object or null after
|
|
521
|
+
function opencodeSqliteModule() {
|
|
522
|
+
if (_sqliteModule !== undefined) return _sqliteModule;
|
|
523
|
+
_sqliteModule = null;
|
|
524
|
+
// Dynamic import caches the module when its promise settles; the sync
|
|
525
|
+
// require keeps the first (possibly pre-microtask) probe working. Missing
|
|
526
|
+
// builtin (Node < 22) rejects — caught, cached as unavailable.
|
|
527
|
+
import("node:sqlite").then(
|
|
528
|
+
(m) => { _sqliteModule = m && typeof m.DatabaseSync === "function" ? m : null; },
|
|
529
|
+
() => {}
|
|
530
|
+
);
|
|
531
|
+
try {
|
|
532
|
+
const req = createRequire(import.meta.url);
|
|
533
|
+
const m = req("node:sqlite");
|
|
534
|
+
if (m && typeof m.DatabaseSync === "function") _sqliteModule = m;
|
|
535
|
+
} catch {}
|
|
536
|
+
return _sqliteModule;
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
// opencode normalizes paths to forward slashes and (verified) stores
|
|
540
|
+
// 'C:/Users/...'; compare lowercased on every platform. Both sides derive
|
|
541
|
+
// from the same spawn cwd wearing two spellings (Windows drive/segment
|
|
542
|
+
// casing disagrees freely; opencode's own normalization may recase
|
|
543
|
+
// elsewhere) — the matcher is about spellings, not filesystem identity.
|
|
544
|
+
function normalizeWorkspaceDir(dir) {
|
|
545
|
+
return String(dir || "").trim().replace(/\\/g, "/").replace(/\/+$/, "").toLowerCase();
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
// Best-effort opencode.db probe: { name, cwd, spawnedAt, dbPath? } -> id|null.
|
|
549
|
+
// Read-only (the WAL DB is opened readOnly whenever the Node build supports
|
|
550
|
+
// it); every failure returns null so the caller just stays log-scan-only. The
|
|
551
|
+
// 5-minute lookback from the spawn time guards title reuse across runs;
|
|
552
|
+
// ordering picks the newest row inside the window.
|
|
553
|
+
export function probeOpencodeStorage({ name, cwd, spawnedAt, dbPath } = {}) {
|
|
554
|
+
try {
|
|
555
|
+
const clean = String(name || "").trim();
|
|
556
|
+
if (!clean || !cwd) return null;
|
|
557
|
+
const birth = spawnedAt ? Date.parse(spawnedAt) : NaN;
|
|
558
|
+
if (Number.isNaN(birth)) return null; // no window -> refuse to guess
|
|
559
|
+
const mod = opencodeSqliteModule();
|
|
560
|
+
if (!mod || typeof mod.DatabaseSync !== "function") return null;
|
|
561
|
+
const dbFile = String(dbPath || process.env.OPENCODE_DB_PATH || path.join(os.homedir(), ".local", "share", "opencode", "opencode.db"));
|
|
562
|
+
if (!fs.existsSync(dbFile)) return null;
|
|
563
|
+
let db = null;
|
|
564
|
+
try {
|
|
565
|
+
db = new mod.DatabaseSync(dbFile, { readOnly: true });
|
|
566
|
+
} catch {
|
|
567
|
+
db = null;
|
|
568
|
+
}
|
|
569
|
+
if (!db) {
|
|
570
|
+
try { db = new mod.DatabaseSync(dbFile); } catch { return null; }
|
|
571
|
+
}
|
|
572
|
+
// Directory is filtered in JS, not SQL: sqlite `=` is case-sensitive and
|
|
573
|
+
// the row spelling may disagree in case with the recorded cwd.
|
|
574
|
+
let rows = [];
|
|
575
|
+
try {
|
|
576
|
+
rows = db.prepare("SELECT id, time_created, directory FROM session WHERE title = ? ORDER BY time_created DESC").all(`crewbus:${clean}`);
|
|
577
|
+
} catch {
|
|
578
|
+
// schema drift (doctor guards this with PRAGMA table_info(session))
|
|
579
|
+
try { db.close(); } catch {}
|
|
580
|
+
return null;
|
|
581
|
+
}
|
|
582
|
+
try { db.close(); } catch {}
|
|
583
|
+
const want = normalizeWorkspaceDir(cwd);
|
|
584
|
+
const floor = birth - 5 * 60 * 1000;
|
|
585
|
+
for (const row of rows) {
|
|
586
|
+
if (!row || typeof row.id !== "string" || !row.id.trim()) continue;
|
|
587
|
+
if (normalizeWorkspaceDir(row.directory) !== want) continue;
|
|
588
|
+
const t = typeof row.time_created === "bigint" ? Number(row.time_created) : row.time_created;
|
|
589
|
+
const at = typeof t === "number" ? (t > 1e12 ? t : t * 1000) : Date.parse(String(t));
|
|
590
|
+
if (Number.isNaN(at) || at < floor) continue;
|
|
591
|
+
return row.id.trim().slice(0, 200);
|
|
592
|
+
}
|
|
593
|
+
} catch {}
|
|
594
|
+
return null;
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
// Doctor support: can the storage fallback read session rows at all?
|
|
598
|
+
// One of "ok" | "drift" | "no-db" | "no-sqlite" | "error". Never throws.
|
|
599
|
+
export function opencodeStorageStatus(dbPath) {
|
|
600
|
+
const p = String(dbPath || process.env.OPENCODE_DB_PATH || path.join(os.homedir(), ".local", "share", "opencode", "opencode.db"));
|
|
601
|
+
const mod = opencodeSqliteModule();
|
|
602
|
+
const sqliteAvailable = !!mod && typeof mod.DatabaseSync === "function";
|
|
603
|
+
if (!fs.existsSync(p)) return { status: "no-db", dbPath: p, sqliteAvailable };
|
|
604
|
+
if (!sqliteAvailable) return { status: "no-sqlite", dbPath: p, sqliteAvailable: false };
|
|
605
|
+
try {
|
|
606
|
+
const db = new mod.DatabaseSync(p, { readOnly: true });
|
|
607
|
+
try {
|
|
608
|
+
const cols = db.prepare("PRAGMA table_info(session)").all().map((c) => c && c.name);
|
|
609
|
+
const ok = cols.includes("id") && cols.includes("title") && cols.includes("directory") && cols.includes("time_created");
|
|
610
|
+
return { status: ok ? "ok" : "drift", dbPath: p, sqliteAvailable: true };
|
|
611
|
+
} finally {
|
|
612
|
+
try { db.close(); } catch {}
|
|
613
|
+
}
|
|
614
|
+
} catch (e) {
|
|
615
|
+
return { status: "error", dbPath: p, sqliteAvailable: true, detail: String((e && (e.message || e)) || "").slice(0, 120) };
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
|
|
455
619
|
// Worker-session binding lives beside the agent doc (not inside it) so
|
|
456
620
|
// presence heartbeats — which rewrite agent docs field-by-field in five
|
|
457
621
|
// places — can never wipe a captured id. Machine-local like pids: never
|
|
@@ -516,16 +680,27 @@ function readLogTail(p, maxBytes) {
|
|
|
516
680
|
// "preassigned-confirmed" (log corroborates the minted id),
|
|
517
681
|
// "log" (found in the log, nothing minted), "log-override" (log disagrees
|
|
518
682
|
// with the minted id — trust the log: the installed harness may have
|
|
519
|
-
// ignored the pre-assign flag)
|
|
520
|
-
//
|
|
521
|
-
|
|
683
|
+
// ignored the pre-assign flag), and "storage" (read from the harness's own
|
|
684
|
+
// on-disk store when the log reveals nothing — see probeOpencodeStorage).
|
|
685
|
+
// Workers that never emit an id cost one small stat per status call, never
|
|
686
|
+
// a scan. Never throws.
|
|
687
|
+
const STORAGE_PROBE_INTERVAL_MS = 30000;
|
|
688
|
+
|
|
689
|
+
export function syncWorkerSession(d, name, logPath, storageProbe) { // respawn slice 1
|
|
522
690
|
const prev = readWorkerSession(d, name);
|
|
523
691
|
const lp = logPath || (prev && prev.logPath) || newestWorkerLog(d, name);
|
|
524
692
|
if (!lp) return prev;
|
|
525
693
|
const tail = readLogTail(lp, WORKER_SESSION_TAIL_BYTES);
|
|
526
694
|
if (!tail) return prev;
|
|
527
|
-
|
|
528
|
-
|
|
695
|
+
// Storage fallback applies only for opencode with no id captured yet, and
|
|
696
|
+
// at most every ~30s (storageCheckedAt guard). Log-scan keeps precedence:
|
|
697
|
+
// a log-confirmed id always wins over a DB-read one, regardless of order.
|
|
698
|
+
const storagePending = ((prev && prev.harness) === "opencode") && !(prev && prev.harnessSessionId);
|
|
699
|
+
const lastStorageAt = prev && prev.storageCheckedAt ? Date.parse(prev.storageCheckedAt) : NaN;
|
|
700
|
+
const storageDue = Number.isNaN(lastStorageAt) || Date.now() - lastStorageAt >= STORAGE_PROBE_INTERVAL_MS;
|
|
701
|
+
if (prev && prev.logPath === lp && prev.checkedSize === tail.size && prev.checkedMtime === tail.mtime && !(storagePending && storageDue)) return prev;
|
|
702
|
+
const nowMs = Date.now();
|
|
703
|
+
const now = new Date(nowMs).toISOString();
|
|
529
704
|
const extracted = extractHarnessSessionId(prev && prev.harness, tail.text);
|
|
530
705
|
const prevId = prev && prev.harnessSessionId;
|
|
531
706
|
let id = prevId || undefined;
|
|
@@ -538,6 +713,22 @@ export function syncWorkerSession(d, name, logPath) { // respawn slice 1
|
|
|
538
713
|
} else if (extracted && prevId && source === "preassigned") {
|
|
539
714
|
source = "preassigned-confirmed";
|
|
540
715
|
}
|
|
716
|
+
let storageCheckedAt = (prev && prev.storageCheckedAt) || undefined;
|
|
717
|
+
if (storagePending && storageDue && !id) { // log scan wins when both fire
|
|
718
|
+
storageCheckedAt = now;
|
|
719
|
+
const probe = storageProbe === undefined ? probeOpencodeStorage : storageProbe; // tests inject a fake
|
|
720
|
+
let probed = null;
|
|
721
|
+
try {
|
|
722
|
+
probed = probe({ name, cwd: prev && prev.cwd, spawnedAt: prev && prev.spawnedAt });
|
|
723
|
+
} catch {
|
|
724
|
+
probed = null;
|
|
725
|
+
}
|
|
726
|
+
if (probed) {
|
|
727
|
+
id = String(probed);
|
|
728
|
+
source = "storage";
|
|
729
|
+
capturedAt = now;
|
|
730
|
+
}
|
|
731
|
+
}
|
|
541
732
|
const doc = {
|
|
542
733
|
...((prev && typeof prev === "object") ? prev : {}),
|
|
543
734
|
name,
|
|
@@ -549,6 +740,7 @@ export function syncWorkerSession(d, name, logPath) { // respawn slice 1
|
|
|
549
740
|
harnessSessionId: id,
|
|
550
741
|
idSource: source,
|
|
551
742
|
capturedAt,
|
|
743
|
+
storageCheckedAt,
|
|
552
744
|
checkedSize: tail.size,
|
|
553
745
|
checkedMtime: tail.mtime,
|
|
554
746
|
checkedAt: now,
|
|
@@ -699,10 +891,10 @@ export function installCliToUserPath() {
|
|
|
699
891
|
return { ok: true, binDir: userBinDir, addedToPath, detail };
|
|
700
892
|
}
|
|
701
893
|
|
|
702
|
-
export function bootWorker(d, spawnOpts, { to, id, from, subject, body, rev, logDir, budgetTokens, budgetMinutes, deadlineAt, spawnedWorktree, spawnedBranch, spawnedLifetime, sessionId, crew }) { // line 4338
|
|
894
|
+
export function bootWorker(d, spawnOpts, { to, id, from, subject, body, rev, logDir, budgetTokens, budgetMinutes, deadlineAt, spawnedWorktree, spawnedBranch, spawnedLifetime, sessionId, crew, workbench }) { // line 4338
|
|
703
895
|
const { cwd, root } = spawnOpts;
|
|
704
896
|
const stamp = new Date().toISOString().replace(/[:.]/g, "-");
|
|
705
|
-
const prompt = buildSpawnPrompt({ name: to, from, subject, body, replyId: id, rev, cwd, root, crew });
|
|
897
|
+
const prompt = buildSpawnPrompt({ name: to, from, subject, body, replyId: id, rev, cwd, root, crew, workbench });
|
|
706
898
|
const promptPath = path.join(logDir, `${to}-${stamp}.prompt.md`);
|
|
707
899
|
fs.writeFileSync(promptPath, prompt + "\n");
|
|
708
900
|
const logPath = path.join(logDir, `${to}-${stamp}.log`);
|
package/bin/lib/store.js
CHANGED
|
@@ -118,12 +118,14 @@ export function dirs(root) { // line 122
|
|
|
118
118
|
cursors: path.join(root, "cursors"),
|
|
119
119
|
revoked: path.join(root, "revoked"),
|
|
120
120
|
holds: path.join(root, "holds"),
|
|
121
|
+
artifacts: path.join(root, "artifacts"),
|
|
122
|
+
lessons: path.join(root, "lessons"),
|
|
121
123
|
};
|
|
122
124
|
}
|
|
123
125
|
|
|
124
126
|
export function ensureBoard(root) { // line 142
|
|
125
127
|
const d = dirs(root);
|
|
126
|
-
for (const p of [d.root, d.agents, d.dm, d.delivered, d.broadcast, d.groups, d.channels, d.locks, d.results, d.tombstones, d.poolState, d.workerSessions, d.index, d.cursors, d.revoked, d.holds]) {
|
|
128
|
+
for (const p of [d.root, d.agents, d.dm, d.delivered, d.broadcast, d.groups, d.channels, d.locks, d.results, d.tombstones, d.poolState, d.workerSessions, d.index, d.cursors, d.revoked, d.holds, d.artifacts, d.lessons, path.join(root, "logs")]) {
|
|
127
129
|
fs.mkdirSync(p, { recursive: true });
|
|
128
130
|
}
|
|
129
131
|
const metaPath = path.join(d.root, "board.json");
|
|
@@ -224,7 +226,7 @@ export const VALUE_FLAGS = new Set(["--from", "--to", "--to-file", "--to-group",
|
|
|
224
226
|
// reads the same comma/newline-separated list from a file so large fan-outs
|
|
225
227
|
// don't hit Windows argv limits (~8191 chars).
|
|
226
228
|
// §4.4 value-taking flags (skipped with their value by restArgs).
|
|
227
|
-
for (const _f of ["--sender-type", "--fwd", "--secret", "--device", "--pair-token", "--pair-label", "--label", "--ttl", "--id", "--allow-env", "--allow-cmd", "--workdir-root", "--budget-tokens", "--budget-minutes", "--tls-cert", "--tls-key", "--tls-ca", "--mtls-ca", "--mtls-cert", "--mtls-key", "--oidc-issuer", "--oidc-audience", "--issuer", "--client-id", "--bearer", "--oidc-token", "--expires-in", "--service", "--offboard", "--target", "--reason", "--role", "--for", "--default-role", "--freeze", "--unfreeze", "--out", "--in", "--into", "--key-env", "--key-file", "--every", "--keep", "--out-dir", "--max-bytes", "--max-agents", "--max-channels", "--tenant", "--audit-forward", "--audit-forward-key", "--standby", "--promote-on-miss", "--fence", "--relay-interval", "--relays", "--weights", "--relay-auth", "--via", "--weight"]) VALUE_FLAGS.add(_f); // line 673
|
|
229
|
+
for (const _f of ["--sender-type", "--fwd", "--secret", "--device", "--pair-token", "--pair-label", "--label", "--ttl", "--id", "--allow-env", "--allow-cmd", "--workdir-root", "--budget-tokens", "--budget-minutes", "--tls-cert", "--tls-key", "--tls-ca", "--mtls-ca", "--mtls-cert", "--mtls-key", "--oidc-issuer", "--oidc-audience", "--issuer", "--client-id", "--bearer", "--oidc-token", "--expires-in", "--service", "--offboard", "--target", "--reason", "--role", "--for", "--default-role", "--freeze", "--unfreeze", "--out", "--in", "--into", "--key-env", "--key-file", "--every", "--keep", "--out-dir", "--max-bytes", "--max-agents", "--max-channels", "--tenant", "--audit-forward", "--audit-forward-key", "--standby", "--promote-on-miss", "--fence", "--relay-interval", "--relays", "--weights", "--relay-auth", "--via", "--weight", "--needs-by", "--deps", "--path", "--text", "--note"]) VALUE_FLAGS.add(_f); // line 673
|
|
228
230
|
|
|
229
231
|
export function cleanSenderType(raw) { // line 1181
|
|
230
232
|
if (raw === undefined || raw === null || String(raw).trim() === "") return undefined;
|
|
@@ -306,7 +308,7 @@ export function requireBoard(root) { // line 3105
|
|
|
306
308
|
);
|
|
307
309
|
}
|
|
308
310
|
const d = dirs(root);
|
|
309
|
-
for (const p of [d.root, d.agents, d.dm, d.delivered, d.broadcast, d.groups, d.tombstones, d.poolState, d.index, d.cursors, d.revoked]) {
|
|
311
|
+
for (const p of [d.root, d.agents, d.dm, d.delivered, d.broadcast, d.groups, d.tombstones, d.poolState, d.index, d.cursors, d.revoked, d.artifacts, d.lessons]) {
|
|
310
312
|
if (!p) continue;
|
|
311
313
|
fs.mkdirSync(p, { recursive: true });
|
|
312
314
|
}
|