crewbus 10.0.8 → 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 +12 -0
- package/README.md +41 -8
- package/bin/crewbus.js +249 -23
- package/bin/lib/identity.js +1 -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/workbench.js +188 -0
- package/docs/SPLIT.md +5 -4
- package/docs/VERSION_SKEW.md +1 -1
- package/documentation.html +365 -361
- package/index.html +4 -4
- package/package.json +2 -2
package/bin/lib/mail.js
CHANGED
|
@@ -69,7 +69,7 @@ export function findMessageById(d, id) {
|
|
|
69
69
|
return null;
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
export function deliverDMs(d, { from, recipients, body, subject, replyTo, artifact, priority, checkpoint, senderType, fwd, rev, at, forceBroadcast, forceDirect }) {
|
|
72
|
+
export function deliverDMs(d, { from, recipients, body, subject, replyTo, artifact, priority, checkpoint, senderType, fwd, rev, at, forceBroadcast, forceDirect, needsBy }) {
|
|
73
73
|
const isAll = recipients.length === 1 && recipients[0] === "@all";
|
|
74
74
|
// Large fan-outs (> BROADCAST_AFTER) and @all go to ONE broadcast file;
|
|
75
75
|
// small fan-outs keep one copy per recipient (unique id each, shared batch).
|
|
@@ -84,6 +84,7 @@ export function deliverDMs(d, { from, recipients, body, subject, replyTo, artifa
|
|
|
84
84
|
if (checkpoint === true) msg.checkpoint = true;
|
|
85
85
|
if (senderType) msg.senderType = senderType;
|
|
86
86
|
if (typeof fwd === "number") msg.fwd = fwd;
|
|
87
|
+
if (needsBy) msg.needsBy = needsBy;
|
|
87
88
|
if (rev) msg.rev = rev;
|
|
88
89
|
const sig = signMessage({ ...msg, to: msg.to });
|
|
89
90
|
if (sig) msg.sig = sig;
|
|
@@ -106,6 +107,7 @@ export function deliverDMs(d, { from, recipients, body, subject, replyTo, artifa
|
|
|
106
107
|
if (checkpoint === true) msg.checkpoint = true;
|
|
107
108
|
if (senderType) msg.senderType = senderType;
|
|
108
109
|
if (typeof fwd === "number") msg.fwd = fwd;
|
|
110
|
+
if (needsBy) msg.needsBy = needsBy;
|
|
109
111
|
if (batch) msg.batch = batch;
|
|
110
112
|
if (rev) msg.rev = rev;
|
|
111
113
|
const sig = signMessage(msg);
|
|
@@ -293,6 +295,7 @@ export function printMsg(m, showTo, json) {
|
|
|
293
295
|
console.log(` ${untrustedEnvelope(m.from, m.senderType || "peer")}`);
|
|
294
296
|
if (m.subject) console.log(` subj: ${m.subject}`);
|
|
295
297
|
if (m.artifact) console.log(` artifact: ${m.artifact}`);
|
|
298
|
+
if (m.needsBy) console.log(` needs-by: ${m.needsBy}${isOverdue(m) ? " (OVERDUE)" : ""}`);
|
|
296
299
|
if (isHigh(m)) console.log(` priority: high`);
|
|
297
300
|
if (isCheckpoint(m)) console.log(` checkpoint: progress (not a final summary)`);
|
|
298
301
|
if (typeof m.fwd === "number") console.log(` fwd: ${m.fwd}/${MAX_FWD_DEPTH}`);
|
|
@@ -330,6 +333,15 @@ export function isHigh(m) {
|
|
|
330
333
|
return m && String(m.priority || "").toLowerCase() === "high";
|
|
331
334
|
}
|
|
332
335
|
|
|
336
|
+
// Needs-by deadline (L4 handoff): present on messages the sender stamped
|
|
337
|
+
// with --needs-by; overdue once the timestamp passes. Read-only helpers,
|
|
338
|
+
// shared by printMsg / printDigest / inbox --overdue.
|
|
339
|
+
export function isOverdue(m) {
|
|
340
|
+
if (!m || !m.needsBy) return false;
|
|
341
|
+
const t = Date.parse(m.needsBy);
|
|
342
|
+
return !Number.isNaN(t) && t < Date.now();
|
|
343
|
+
}
|
|
344
|
+
|
|
333
345
|
// Progress checkpoints ride the DM thread (replyTo the brief) but are not
|
|
334
346
|
// work awaiting acceptance: triage views (--unacked, ack timeout hints,
|
|
335
347
|
// spawn-status reply detection) skip them; transcripts show them labeled.
|
|
@@ -372,7 +384,7 @@ export function enforceMaxChars(items, maxChars) {
|
|
|
372
384
|
export function printDigest(items) {
|
|
373
385
|
for (const m of items) {
|
|
374
386
|
const head = String(m.body || "").split("\n")[0].slice(0, 140);
|
|
375
|
-
console.log(`${m.id} [peer:${m.from}]${isHigh(m) ? " [!HIGH]" : ""}${isCheckpoint(m) ? " [checkpoint]" : ""}${m.subject ? ` subj:${String(m.subject).slice(0, 80)}` : ""} :: ${head}`);
|
|
387
|
+
console.log(`${m.id} [peer:${m.from}]${isHigh(m) ? " [!HIGH]" : ""}${isCheckpoint(m) ? " [checkpoint]" : ""}${isOverdue(m) ? " [OVERDUE]" : m.needsBy ? " [needs-by]" : ""}${m.subject ? ` subj:${String(m.subject).slice(0, 80)}` : ""}${m.needsBy ? ` by:${String(m.needsBy).slice(0, 16)}` : ""} :: ${head}`);
|
|
376
388
|
}
|
|
377
389
|
}
|
|
378
390
|
|
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, path.join(root, "logs")]) {
|
|
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
|
}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
// bin/lib/workbench.js — Artifacts + lessons: the compound-memory layer.
|
|
2
|
+
// Purpose: make worker output load-bearing for teammates instead of
|
|
3
|
+
// DM-status-only (feed-forward, the Minecraft-paper lever set):
|
|
4
|
+
// artifacts = board objects with depends-on edges; adoption + verification
|
|
5
|
+
// are recorded ON the object, so a later crew can see what was reused and
|
|
6
|
+
// what held up (artifact publish|list|show|adopt|verify).
|
|
7
|
+
// lessons = scoped one-liners auto-injected into later spawn briefs
|
|
8
|
+
// (lesson post|list), so a lesson learned once is paid forward without
|
|
9
|
+
// anyone re-deriving it.
|
|
10
|
+
// Zero-dependency Node 18+ ESM. Side-effect-free at top level. Storage:
|
|
11
|
+
// artifacts/<id>.json {id, from, at, path, summary?, deps[], adoptedBy[], verifiedBy[]}
|
|
12
|
+
// lessons/<id>.json {id, from, scope, text, at}
|
|
13
|
+
import fs from "node:fs";
|
|
14
|
+
import path from "node:path";
|
|
15
|
+
import { fail, readJson, writeJson, listJson, newId } from "./store.js";
|
|
16
|
+
|
|
17
|
+
// Artifact ids minted via newId("art"): art-<YYMMDD>-<HHMMSS>-<8hex>.
|
|
18
|
+
export const ARTIFACT_ID_RE = /\bart-[0-9]{6}-[0-9]{6}-[0-9a-f]{8}\b/g;
|
|
19
|
+
|
|
20
|
+
export function artifactPath(d, id) {
|
|
21
|
+
return path.join(d.artifacts, `${id}.json`);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function readArtifactById(d, id) {
|
|
25
|
+
if (!id) return null;
|
|
26
|
+
try {
|
|
27
|
+
const a = readJson(artifactPath(d, id));
|
|
28
|
+
return a && a.id === id ? a : null;
|
|
29
|
+
} catch {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Newest first (board reads answer "what exists lately", not history).
|
|
35
|
+
export function listArtifacts(d, { limit } = {}) {
|
|
36
|
+
const items = listJson(d.artifacts)
|
|
37
|
+
.map((e) => e && e.data)
|
|
38
|
+
.filter((a) => a && a.id && a.path);
|
|
39
|
+
items.sort((a, b) => String(b.at).localeCompare(String(a.at)) || String(b.id).localeCompare(String(a.id)));
|
|
40
|
+
return typeof limit === "number" ? items.slice(0, Math.max(0, limit)) : items;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function cleanArtifactId(raw, flag) {
|
|
44
|
+
const f = flag || "--id";
|
|
45
|
+
if (raw === undefined || raw === null || String(raw).trim() === "") fail(`missing ${f} <artifact-id>`);
|
|
46
|
+
const c = String(raw).trim().toLowerCase();
|
|
47
|
+
if (!/^art-[0-9]{6}-[0-9]{6}-[0-9a-f]{8}$/.test(c)) fail(`invalid ${f} "${raw}" (want an art-<id> from artifact list)`);
|
|
48
|
+
return c;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Lesson scopes: freeform short names like groups; missing reads as
|
|
52
|
+
// "global" so one-off lessons still reach every later brief.
|
|
53
|
+
export function cleanLessonScope(raw, flag) {
|
|
54
|
+
const f = flag || "--scope";
|
|
55
|
+
if (raw === undefined || raw === null || String(raw).trim() === "") return "global";
|
|
56
|
+
const c = String(raw).trim().toLowerCase().replace(/[^a-z0-9_.-]/g, "-").slice(0, 60);
|
|
57
|
+
if (!c) fail(`invalid ${f} "${raw}"`);
|
|
58
|
+
return c;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export function parseArtifactDeps(raw) {
|
|
62
|
+
if (raw === undefined || raw === null || String(raw).trim() === "") return [];
|
|
63
|
+
return String(raw).split(",").map((s) => cleanArtifactId(s, "--deps")).filter((x, i, a) => a.indexOf(x) === i);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export function publishArtifact(d, { from, ref, summary, deps, at }) {
|
|
67
|
+
const cleanRef = String(ref === undefined || ref === null ? "" : ref).trim();
|
|
68
|
+
if (!cleanRef) fail('missing --path <path-or-url> (where the artifact lives; reference, never inline secrets)');
|
|
69
|
+
const doc = {
|
|
70
|
+
id: newId("art"),
|
|
71
|
+
from,
|
|
72
|
+
at,
|
|
73
|
+
path: cleanRef.slice(0, 500),
|
|
74
|
+
summary: String(summary || "").trim().slice(0, 500) || undefined,
|
|
75
|
+
deps: Array.isArray(deps) ? deps : [],
|
|
76
|
+
adoptedBy: [],
|
|
77
|
+
verifiedBy: [],
|
|
78
|
+
};
|
|
79
|
+
for (const dep of doc.deps) {
|
|
80
|
+
if (!readArtifactById(d, dep)) fail(`dep ${dep} not found on this board (publish the dependency first, or drop it)`);
|
|
81
|
+
}
|
|
82
|
+
writeJson(artifactPath(d, doc.id), doc);
|
|
83
|
+
return doc;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export function adoptArtifact(d, { id, from, note, at }) {
|
|
87
|
+
const a = readArtifactById(d, id);
|
|
88
|
+
if (!a) fail(`unknown artifact ${id} (artifact list to see what's on the board)`);
|
|
89
|
+
if (!a.adoptedBy.some((e) => e.by === from)) {
|
|
90
|
+
a.adoptedBy.push({ by: from, at, note: String(note || "").trim().slice(0, 200) || undefined });
|
|
91
|
+
writeJson(artifactPath(d, id), a);
|
|
92
|
+
}
|
|
93
|
+
return a;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export function verifyArtifact(d, { id, from, note, at }) {
|
|
97
|
+
const a = readArtifactById(d, id);
|
|
98
|
+
if (!a) fail(`unknown artifact ${id} (artifact list to see what's on the board)`);
|
|
99
|
+
if (!a.verifiedBy.some((e) => e.by === from)) {
|
|
100
|
+
a.verifiedBy.push({ by: from, at, note: String(note || "").trim().slice(0, 200) || undefined });
|
|
101
|
+
writeJson(artifactPath(d, id), a);
|
|
102
|
+
}
|
|
103
|
+
return a;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export function postLesson(d, { from, scope, text, at }) {
|
|
107
|
+
const t = String(text === undefined || text === null ? "" : text).trim();
|
|
108
|
+
if (!t) fail('missing --text "..." (one or two sentences: what happened + what to do differently)');
|
|
109
|
+
const doc = { id: newId("les"), from, scope: cleanLessonScope(scope), text: t.slice(0, 800), at };
|
|
110
|
+
writeJson(path.join(d.lessons, `${doc.id}.json`), doc);
|
|
111
|
+
return doc;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// Oldest first (a lesson list is a history read, unlike artifacts).
|
|
115
|
+
export function listLessons(d, { scope } = {}) {
|
|
116
|
+
let items = listJson(d.lessons)
|
|
117
|
+
.map((e) => e && e.data)
|
|
118
|
+
.filter((l) => l && l.id && l.text);
|
|
119
|
+
items.sort((a, b) => String(a.at).localeCompare(String(b.at)) || String(a.id).localeCompare(String(b.id)));
|
|
120
|
+
if (scope !== undefined) items = items.filter((l) => l.scope === cleanLessonScope(scope));
|
|
121
|
+
return items;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// Brief injection selection: lessons whose scope matches one of this
|
|
125
|
+
// spawn's groups (or global), newest last-N reversed so the freshest
|
|
126
|
+
// lessons land first in the brief. Cap keeps prompts bounded.
|
|
127
|
+
export function selectLessons(d, { scopes = [], limit = 8 } = {}) {
|
|
128
|
+
const scopeSet = new Set(["global", ...(scopes || []).map(String)]);
|
|
129
|
+
const picked = listLessons(d).filter((l) => scopeSet.has(l.scope));
|
|
130
|
+
return picked.slice(-Math.max(0, limit)).reverse();
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// Pure renderer: the Workbench: block for spawn briefs. Returns bullet
|
|
134
|
+
// lines (no header); caller joins under a header. Empty board -> [].
|
|
135
|
+
export function renderWorkbenchBlock({ lessons, artifacts, me }) {
|
|
136
|
+
const les = (lessons || []).slice(0, 8);
|
|
137
|
+
const arts = (artifacts || []).slice(0, 6);
|
|
138
|
+
const out = [];
|
|
139
|
+
for (const l of les) out.push(`- lesson [${l.scope}] ${l.text} (from ${l.from})`);
|
|
140
|
+
for (const a of arts) {
|
|
141
|
+
const state = [];
|
|
142
|
+
if (a.adoptedBy && a.adoptedBy.length) state.push(`adopted x${a.adoptedBy.length}`);
|
|
143
|
+
if (a.verifiedBy && a.verifiedBy.length) state.push("verified");
|
|
144
|
+
out.push(`- artifact ${a.id} ${a.path}${a.summary ? ` — ${a.summary}` : ""}${state.length ? ` (${state.join(", ")})` : ""}`);
|
|
145
|
+
}
|
|
146
|
+
if (out.length === 0) return out;
|
|
147
|
+
out.push(`(verify before reuse; publish yours: artifact publish --path <p> [--deps <id,id>] / lesson post --scope <s> --text "..."; reuse a piece: artifact adopt|verify --id <id> --from ${String(me || "you")})`);
|
|
148
|
+
return out;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// Gather metrics (pure given a lookup fn): scan transcript messages for
|
|
152
|
+
// artifact references (the m.artifact field + art- ids in bodies), then
|
|
153
|
+
// score feed-forward: an edge is a message whose sender is NOT the
|
|
154
|
+
// artifact's producer — someone downstream actually consumed upstream
|
|
155
|
+
// output on the board itself.
|
|
156
|
+
export function workbenchMetrics(items, lookup) {
|
|
157
|
+
const seenEdges = new Set();
|
|
158
|
+
const refs = new Map();
|
|
159
|
+
const producers = new Set();
|
|
160
|
+
let feedForward = 0;
|
|
161
|
+
let adopted = 0;
|
|
162
|
+
let verified = 0;
|
|
163
|
+
for (const m of items || []) {
|
|
164
|
+
if (!m) continue;
|
|
165
|
+
const text = `${m.artifact || ""} ${m.body || ""}`;
|
|
166
|
+
const ids = new Set(String(text).match(ARTIFACT_ID_RE) || []);
|
|
167
|
+
for (const id of ids) {
|
|
168
|
+
const a = lookup(id);
|
|
169
|
+
if (!a) continue;
|
|
170
|
+
// Adoption/verification are per-artifact facts; count each artifact
|
|
171
|
+
// once no matter how many transcript messages cite it.
|
|
172
|
+
if (!refs.has(id)) {
|
|
173
|
+
refs.set(id, a);
|
|
174
|
+
producers.add(a.from);
|
|
175
|
+
if (a.adoptedBy && a.adoptedBy.length) adopted++;
|
|
176
|
+
if (a.verifiedBy && a.verifiedBy.length) verified++;
|
|
177
|
+
}
|
|
178
|
+
if (m.from && m.from !== a.from) {
|
|
179
|
+
const key = `${m.id}|${id}`;
|
|
180
|
+
if (!seenEdges.has(key)) {
|
|
181
|
+
seenEdges.add(key);
|
|
182
|
+
feedForward++;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
return { artifactRefs: refs.size, producers: producers.size, feedForward, adopted, verified };
|
|
188
|
+
}
|
package/docs/SPLIT.md
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
Status: landed. `bin/crewbus.js` is a dispatcher that intentionally
|
|
4
4
|
retains the `cmd*` wrappers, `USAGE`, `main()`, and the opencode
|
|
5
|
-
tool/plugin embeds; domain logic lives in the
|
|
5
|
+
tool/plugin embeds; domain logic lives in the 13 lib modules
|
|
6
6
|
(`bin/lib/` holds channels, export, groups, identity, launch, mail,
|
|
7
|
-
relay, spawn, store, sync, tokenfile, web; import block,
|
|
8
|
-
`bin/crewbus.js` lines 44–
|
|
7
|
+
relay, spawn, store, sync, tokenfile, web, workbench; import block,
|
|
8
|
+
`bin/crewbus.js` lines 44–56). No behavior change is intended, with one deliberate exception recorded in CHANGELOG (parseRecipients full-version canonicalization).
|
|
9
9
|
|
|
10
10
|
## Module map
|
|
11
11
|
|
|
@@ -23,9 +23,10 @@ relay, spawn, store, sync, tokenfile, web; import block,
|
|
|
23
23
|
| `bin/lib/channels.js` | Shared channels + locks: log IO, per-reader cursors, digest/summarize, group mirrors, advisory locks, channel text-merge | `appendChannelPost`, `readChannelPosts`, `tailChannelPosts`, `parseChannelText`, `mergeChannelText`, `mirrorToGroupChannels`, `acquireLockDoc`, `releaseLockDoc` |
|
|
24
24
|
| `bin/lib/web.js` | Dashboard + API: snapshots, HTML render, ack/kill/launch handlers, `cmdWeb`; control-plane additions: `handleApiLaunch`, `POST /api/launch`, `GET /api/harnesses\|routes\|holds\|quotas`, Holds/Quotas/AppRoot sections | `boardSnapshot`, `fleetSnapshot`, `channelsSnapshot`, `resultsSnapshot`, `auditSnapshot`, `renderBoardHtml`, `handleApiAck`, `handleApiKill`, `handleApiLaunch`, `cmdWeb` |
|
|
25
25
|
| `bin/lib/tokenfile.js` | Token-file convention for long runs: save/re-read agent tokens across compaction/restart amnesia (0600 best-effort); standalone, no local imports (cycle-free) | `tokenFilePath`, `saveTokenFile`, `loadTokenFile` |
|
|
26
|
+
| `bin/lib/workbench.js` | Artifacts + lessons (compound-memory layer): artifact objects with deps/adoption/verification edges, scoped lessons, spawn-brief Workbench block, gather metrics; pure helpers, monolith keeps `cmdArtifact`/`cmdLesson` | `publishArtifact`, `adoptArtifact`, `verifyArtifact`, `readArtifactById`, `listArtifacts`, `listLessons`, `postLesson`, `selectLessons`, `renderWorkbenchBlock`, `workbenchMetrics`, `cleanArtifactId`, `cleanLessonScope`, `parseArtifactDeps`, `ARTIFACT_ID_RE` |
|
|
26
27
|
|
|
27
28
|
Full export lists: see the import block at the top of `bin/crewbus.js`
|
|
28
|
-
(lines 44–
|
|
29
|
+
(lines 44–56). Entry-point `cmd*` functions (e.g. `cmdSend`, `cmdSync`,
|
|
29
30
|
`cmdServe`) stay in the monolith; lib modules carry the computation helpers
|
|
30
31
|
those verbs call.
|
|
31
32
|
|
package/docs/VERSION_SKEW.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Version skew (mixed-relay operation)
|
|
2
2
|
|
|
3
|
-
How crewbus versions interoperate. Evidence: `package.json:2` (`10.0.
|
|
3
|
+
How crewbus versions interoperate. Evidence: `package.json:2` (`10.0.9`),
|
|
4
4
|
`CHANGELOG.md` (10.0.0 2026-10-08; 7.0.0 2026-10-05; 6.4.0–6.0.0; 4.1.0/4.0.0 baseline).
|
|
5
5
|
Capabilities: `RELAY_CAPS` + `launch` per `packages/contracts/board-caps.json:6-8`.
|
|
6
6
|
Cell behavior is the NEW side's verified behavior (`bin/lib/sync.js` refs);
|