crewbus 10.0.9 → 10.0.10
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 +10 -0
- package/README.md +2 -2
- package/bin/crewbus.js +70 -5
- package/bin/lib/identity.js +19 -13
- package/bin/lib/launch.js +4 -1
- package/bin/lib/spawn.js +199 -14
- package/bin/lib/web.js +108 -26
- package/docs/LEAD_ASSIGN.md +75 -0
- package/docs/VERSION_SKEW.md +1 -1
- package/documentation.html +3 -2
- package/index.html +6 -6
- package/package.json +2 -2
- package/packages/contracts/launch.json +4 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 10.0.10 (2026-10-18)
|
|
4
|
+
|
|
5
|
+
MINOR RELEASE: Observer coordinator lane model (`boss` / `lead` / `peers`), auto-assigned lead (`--lead auto|board|none`), and Desktop app alignment. No board-schema change (`board.json` stays v2).
|
|
6
|
+
|
|
7
|
+
- **Auto-assigned Lead & Observer Lane Model (`--lead auto|board|none`)**: Separates spawn authority from acting lead. `spawn` bursts now auto-provision a persistent background coordinator (`lead`, role: `lead`) that monitors worker health, answers approval requests, runs respawn loops, and sends aggregate reports back to the spawner (`boss`). Workers pin all checkpoints, approvals, and completions `--to lead`.
|
|
8
|
+
- **Peer-to-Peer Lane Structure**: Establishes 3 explicit lanes: `boss` (human operator / board admin), `lead` (autonomous Observer coordinator), and `peers` (workers executing tasks). Workers coordinate with each other directly via peer-DMs and report to `lead` only for approvals and milestones.
|
|
9
|
+
- **Desktop App & Sidecar Alignment**: Desktop loopback server auto-provisions `boss` as the human operator (with transparent fallback for existing `lead` boards). Launch Studio composer adds a Coordinator selector (`auto` | `none`), surfaces live coordinator status, and displays role badges in the agent roster. Approvals view surfaces pending unacked approvals sent to `lead` for supervisor review.
|
|
10
|
+
- **Contract & Validation**: `packages/contracts/launch.json` and `validateLaunchPlan` updated with `lead` mode options and `coordinator` response payload.
|
|
11
|
+
- New tests: `test/crewbus.lead-assign.mjs` (33 checks) + expanded `test/crewbus.web-launch.mjs`.
|
|
12
|
+
|
|
3
13
|
## 10.0.9 (2026-10-17)
|
|
4
14
|
|
|
5
15
|
MINOR RELEASE: Workbench compound-memory layer (artifacts, lessons, needs-by) + opencode respawn capture fix. No board-schema change (`board.json` stays v2); the additive `artifacts/` and `lessons/` directories appear on first write — old boards pick them up lazily, nothing to migrate.
|
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# crewbus v10.0.
|
|
1
|
+
# crewbus v10.0.10 — DM bus
|
|
2
2
|
|
|
3
3
|
[](https://github.com/eamonpluto/crewbus/actions/workflows/ci.yml)
|
|
4
4
|
|
|
@@ -55,7 +55,7 @@ env overrides below.)
|
|
|
55
55
|
Layout: `board.json`, `agents/<name>.json`, `dm/<recipient>/<id>.json`,
|
|
56
56
|
`delivered/<recipient>/<id>.json` (push markers, written by the plugin).
|
|
57
57
|
|
|
58
|
-
Versions: `package.json` (currently 10.0.
|
|
58
|
+
Versions: `package.json` (currently 10.0.10) is the source of truth for the
|
|
59
59
|
release version. `board.json`'s `version: 2` is the **board schema version**
|
|
60
60
|
(a different number on purpose — do not "align" them). New to the project?
|
|
61
61
|
Start with `docs/QUICKSTART.md` (5 minutes).
|
package/bin/crewbus.js
CHANGED
|
@@ -46,7 +46,7 @@ import { VALID_ROLES, agentTokenMatches, assertMintWon, authorize, authorizeChec
|
|
|
46
46
|
import { saveTokenFile } from "./lib/tokenfile.js";
|
|
47
47
|
import { CLIENT_TLS, SYNC_LWW, cleanSyncRel, clientInsecureFromArgs, crewSurvey, httpJson, readPemFlag, readSyncState, readTombstones, relayAuthEntries, relayCredFor, relayCredHeaders, setupClientTls, splitByWeight, syncRound, syncWalk, warnInsecureOnce, writeSyncState, writeTombstone, SYNC_SUBS, SYNC_UNION, RELAY_CAPS, SUB_CAP, SUB_CAP_NOTE, tombstoneIdForRel, readSyncDoc } from "./lib/sync.js";
|
|
48
48
|
import { devicePath, isLoopbackHost, newDeviceCred, newPairToken, pairingPath, parseDeviceCred, readDevice, readRelayState, relaySecretFromArgs, remoteSpawn, requireRelayClientCert, requireRelaySecret, requireScope, tryAcquireFence, verifyOidcJwt, writeRelayState, relayStatePath, bearerFromReq, getOidcConfig, getOidcJwks, b64urlDecode, b64urlJson, jwsRawToDer, oidcGetJson, OIDC_SKEW_SEC, OIDC_JWKS_TTL_MS, OIDC_ALG_HASH, OIDC_EC_SIZE, deviceFromReq } from "./lib/relay.js";
|
|
49
|
-
import { assertGitCheckout, bootRespawnedWorker, bootWorker, buildCrewContext, buildRespawnBrief, buildRespawnTarget, buildSpawnPrompt, buildSpawnTarget, formatSpawnCmd, isPidStale, killWorkers, maybeIsolate, opencodeStorageStatus, parseAllowEnv, pidAlive, provisionBranch, provisionWorktree, readWorkerSession, requireAutoConfirm, resolveOpencodeExe, sandboxPresent, scrubChildEnv, syncWorkerSession, workerStatus, worktreeStamp, defaultMaxTurnsFor, ensureBoardCliShim, installCliToUserPath } from "./lib/spawn.js";
|
|
49
|
+
import { assertGitCheckout, bootRespawnedWorker, bootWorker, buildCoordinatorPrompt, buildCrewContext, buildRespawnBrief, buildRespawnTarget, buildSpawnPrompt, buildSpawnTarget, formatSpawnCmd, isPidStale, killWorkers, LEAD_NAME, maybeIsolate, opencodeStorageStatus, parseAllowEnv, pidAlive, provisionAutoLead, provisionBranch, provisionWorktree, readWorkerSession, requireAutoConfirm, resolveOpencodeExe, sandboxPresent, scrubChildEnv, syncWorkerSession, workerStatus, worktreeStamp, defaultMaxTurnsFor, ensureBoardCliShim, installCliToUserPath } from "./lib/spawn.js";
|
|
50
50
|
import { appendChainRecord, auditHmacKey, boardTotalBytes, chainFilePath, countChannels, dirSize, doExportToFile, enforceAgentQuota, enforceBytesQuota, enforceChannelQuota, holdActive, holdDocPath, holdRefusal, parseQuotaBytes, parseQuotaCount, readBackupInner, readBoardQuotas, readChainRecords, readHold, readSnapshotSchedule, resolveBackupKeyMaterial, setAuditForward, snapshotStamp, startAuditForwarder, verifyChainRecords, collectBoardFiles, encryptBackupPayload, decryptBackupPayload, rawKeyFromMaterial, deriveBackupKey, toAuditExport, spoolAuditEvent, postAuditEvent, auditSpoolDir, drainAuditSpool, enqueueAuditForward, signAuditRecord, chainRecordHash, AUDIT_FORWARD_URL, AUDIT_FORWARD_KEY } from "./lib/export.js";
|
|
51
51
|
import { ackedIds, checkSendRateLimit, deliverDMs, enforceMaxChars, filterDigest, findDuplicateSend, findMessageById, heartbeat, isVerified, loadManifest, manifestPath, msgTimeMs, parseRecipients, printDigest, printMsg, readDMs, readVisible, recordBroadcastManifest, requireFanoutConfirm, resolveFwdDepth, runVerifier, verifyMessageSig, isHigh, signMessage, untrustedEnvelope, relTime, rateFilePath, broadcastTargets, readBroadcastsFor, formatTo, msgHeader, readAckMarker, splitCommand, readRecipientsFile } from "./lib/mail.js";
|
|
52
52
|
import { batchReplyIds, collectBatch, contributingGroups, expandGroups, expandGroupsOrFail, gatherTelemetry, groupTelemetryData, heuristicSenderType, readGroup, ensureGroupCreatedAt, readResultRecord, writeResultRecord, findFirstVerifiedReply } from "./lib/groups.js";
|
|
@@ -2893,7 +2893,30 @@ function cmdSpawn(args) {
|
|
|
2893
2893
|
rosterGroups.sort((a, b) => String(a.name).localeCompare(String(b.name)));
|
|
2894
2894
|
const taskGroups = rosterGroups.filter((g) => groupNames.includes(g.name));
|
|
2895
2895
|
const offTask = rosterGroups.length - taskGroups.length;
|
|
2896
|
-
const crewFor = (to) => buildCrewContext({ name: to, from, subject, groups: taskGroups, myGroups: taskGroups.filter((g) => g.members.includes(to)).map((g) => g.name), offTask });
|
|
2896
|
+
const crewFor = (to, leadTarget) => buildCrewContext({ name: to, from, lead: leadTarget, subject, groups: taskGroups, myGroups: taskGroups.filter((g) => g.members.includes(to)).map((g) => g.name), offTask });
|
|
2897
|
+
// Lead auto-assignment (§auto-lead): `--lead auto|board|none` (default: auto).
|
|
2898
|
+
// Under `board` (or `auto` with a coding harness), spawn and lead are
|
|
2899
|
+
// separated: workers pin replies to the board's standing 'lead' lane and a
|
|
2900
|
+
// detached persistent coordinator is provisioned after the crew boots; the
|
|
2901
|
+
// spawner stays boss (reads, milestone DMs). `--lead none` (or `auto` with
|
|
2902
|
+
// purely generic harnesses) is the legacy star topology: replies pin to the
|
|
2903
|
+
// spawner, nothing else is provisioned.
|
|
2904
|
+
const leadFlagRaw = getFlag(args, "--lead");
|
|
2905
|
+
const hasCodingHarness = harnesses.some((h) => h !== "generic");
|
|
2906
|
+
let leadMode;
|
|
2907
|
+
if (leadFlagRaw === undefined) {
|
|
2908
|
+
leadMode = hasCodingHarness ? "board" : "none";
|
|
2909
|
+
} else {
|
|
2910
|
+
leadMode = String(leadFlagRaw).trim().toLowerCase();
|
|
2911
|
+
if (leadMode === "auto") {
|
|
2912
|
+
leadMode = hasCodingHarness ? "board" : "none";
|
|
2913
|
+
}
|
|
2914
|
+
}
|
|
2915
|
+
if (!["board", "none"].includes(leadMode)) fail(`invalid --lead "${leadFlagRaw}" (want auto|board|none)`);
|
|
2916
|
+
if (leadMode === "board" && !hasCodingHarness) {
|
|
2917
|
+
fail('--lead board needs a coding harness for the auto-coordinator (add --harness opencode, or pass --lead none under --harness generic)');
|
|
2918
|
+
}
|
|
2919
|
+
const leadTarget = leadMode === "board" ? "lead" : from;
|
|
2897
2920
|
const model = getFlag(args, "--model");
|
|
2898
2921
|
const auto = args.includes("--auto");
|
|
2899
2922
|
requireAutoConfirm(args);
|
|
@@ -2967,12 +2990,29 @@ function cmdSpawn(args) {
|
|
|
2967
2990
|
const driver = harnesses[i % harnesses.length];
|
|
2968
2991
|
const itemMaxTurns = maxTurnsNum !== undefined ? maxTurnsNum : ((driver === "claude" || driver === "grok") ? 50 : undefined);
|
|
2969
2992
|
const itemSpawnOpts = { ...spawnOpts, harness: driver, maxTurns: itemMaxTurns, allowTools: driver === "claude" ? allowTools : undefined };
|
|
2970
|
-
const previewPrompt = buildSpawnPrompt({ name: to, from, subject, body: body.trim(), replyId: previewBatch || "msg-<id>", rev, cwd, root, crew: crewFor(to), workbench: wbFor(to) });
|
|
2993
|
+
const previewPrompt = buildSpawnPrompt({ name: to, from, lead: leadTarget, subject, body: body.trim(), replyId: previewBatch || "msg-<id>", rev, cwd, root, crew: crewFor(to, leadTarget), workbench: wbFor(to) });
|
|
2971
2994
|
const t = buildSpawnTarget({ ...itemSpawnOpts, name: to, promptPath: `<logs>/${to}-<stamp>.prompt.md`, prompt: previewPrompt });
|
|
2972
2995
|
const wtNote = worktreePrefix !== undefined ? ` worktree ../${to}-<stamp> (branch ${worktreePrefix}/${to}-<stamp>)` : branchPrefix !== undefined ? ` branch ${branchPrefix}/${to}-<stamp>` : "";
|
|
2973
2996
|
console.log(`would spawn ${to} [${driver}] (${lifetime}) cwd ${cwd}${wtNote} cmd: ${formatSpawnCmd(t)} [board ${d.root}]`);
|
|
2974
2997
|
});
|
|
2975
|
-
console.log(`--- prompt (first worker) ---\n${buildSpawnPrompt({ name: recipients[0], from, subject, body: body.trim(), replyId: previewBatch || "msg-<id>", rev, cwd, root, crew: crewFor(recipients[0]), workbench: wbFor(recipients[0]) })}`);
|
|
2998
|
+
console.log(`--- prompt (first worker) ---\n${buildSpawnPrompt({ name: recipients[0], from, lead: leadTarget, subject, body: body.trim(), replyId: previewBatch || "msg-<id>", rev, cwd, root, crew: crewFor(recipients[0], leadTarget), workbench: wbFor(recipients[0]) })}`);
|
|
2999
|
+
if (leadMode === "board") {
|
|
3000
|
+
const existingLead = readAgent(d, "lead");
|
|
3001
|
+
const standing = existingLead && typeof existingLead.spawnedPid === "number" && pidAlive(existingLead.spawnedPid);
|
|
3002
|
+
if (standing) {
|
|
3003
|
+
console.log(`--- lead ---\na live coordinator already runs on the 'lead' lane (pid ${existingLead.spawnedPid}) — reused, not duplicated [board ${d.root}]`);
|
|
3004
|
+
} else if (existingLead && existingLead.offboarded) {
|
|
3005
|
+
console.log(`--- lead ---\nlane "lead" is offboarded: provision would be SKIPPED (re-onboard it, or pass --lead none) [board ${d.root}]`);
|
|
3006
|
+
} else {
|
|
3007
|
+
const coordPreview = buildCoordinatorPrompt({
|
|
3008
|
+
name: "lead", from, subject, body: body.trim(), batch: previewBatch,
|
|
3009
|
+
workers: recipients.map((name, i) => ({ name, id: previewBatch ? `${previewBatch}-${i + 1}` : "msg-<id>", harness: harnesses[i % harnesses.length] })),
|
|
3010
|
+
crew: crewFor(recipients[0], leadTarget), cwd, root, auto, workbench: wbFor(recipients[0]),
|
|
3011
|
+
});
|
|
3012
|
+
console.log(`--- lead ---\nwould spawn lead [${harnesses[0]}] (persistent — auto-provisioned lead, owner of this crew) cwd ${cwd} [board ${d.root}]`);
|
|
3013
|
+
console.log(`--- coordinator prompt (preview) ---\n${coordPreview}`);
|
|
3014
|
+
}
|
|
3015
|
+
}
|
|
2976
3016
|
return;
|
|
2977
3017
|
}
|
|
2978
3018
|
// Direct (N-copy) path is forced here (every worker needs its own message
|
|
@@ -3006,13 +3046,38 @@ function cmdSpawn(args) {
|
|
|
3006
3046
|
} else if (branchPrefix !== undefined) {
|
|
3007
3047
|
workerBranch = provisionBranch(cwd, branchPrefix, to).branch;
|
|
3008
3048
|
}
|
|
3009
|
-
const r = bootWorker(d, { ...itemSpawnOpts, cwd: workerCwd }, { to, id, from, subject, body: body.trim(), rev, logDir, budgetTokens, budgetMinutes, deadlineAt, spawnedWorktree: workerWorktree, spawnedBranch: workerBranch, spawnedLifetime: lifetime, crew: crewFor(to), workbench: wbFor(to) });
|
|
3049
|
+
const r = bootWorker(d, { ...itemSpawnOpts, cwd: workerCwd }, { to, id, from, lead: leadTarget, subject, body: body.trim(), rev, logDir, budgetTokens, budgetMinutes, deadlineAt, spawnedWorktree: workerWorktree, spawnedBranch: workerBranch, spawnedLifetime: lifetime, crew: crewFor(to, leadTarget), workbench: wbFor(to) });
|
|
3010
3050
|
const where = workerWorktree ? ` worktree ${workerWorktree}` : workerBranch ? ` branch ${workerBranch}` : "";
|
|
3011
3051
|
console.log(`spawned ${to} pid ${r.pid} [${driver}] (${lifetime}) log ${r.logPath} reply ${id}${where} [board ${d.root}]`);
|
|
3012
3052
|
} catch (e) {
|
|
3013
3053
|
console.log(`spawn FAILED ${to}: ${e.message} (brief ${id} still waits on the board) [board ${d.root}]`);
|
|
3014
3054
|
}
|
|
3015
3055
|
}
|
|
3056
|
+
// Auto-provisioned lead: runs after the crew boots so the coordinator's
|
|
3057
|
+
// roster carries the real brief ids, and so a lead boot failure can never
|
|
3058
|
+
// block worker boots.
|
|
3059
|
+
if (leadMode === "board") {
|
|
3060
|
+
const coordHarness = [ // first coding harness wins; generic is excluded above
|
|
3061
|
+
...harnesses.filter((h) => h !== "generic"),
|
|
3062
|
+
][0] || "opencode";
|
|
3063
|
+
const provision = provisionAutoLead(d, {
|
|
3064
|
+
spawnOpts: { ...spawnOpts, harness: coordHarness, maxTurns: undefined, allowTools: undefined },
|
|
3065
|
+
from, subject, body: body.trim(), rev, logDir,
|
|
3066
|
+
workers: res.items.map((it, i) => ({ name: it.to, id: it.id, harness: harnesses[i % harnesses.length] })),
|
|
3067
|
+
batch: res.batch, crew: crewFor(recipients[0], leadTarget), workbench: wbFor(recipients[0]), auto,
|
|
3068
|
+
});
|
|
3069
|
+
if (provision.action === "minted" && provision.pid) {
|
|
3070
|
+
console.log(`auto-lead provisioned: minted lane '${provision.leadName}' (role lead — owns this crew), coordinator pid ${provision.pid} (persistent, ${coordHarness}) log ${provision.logPath} [board ${d.root}]`);
|
|
3071
|
+
if (provision.token) console.log(`lead token (set CREWBUS_TOKEN=${provision.token} to act as '${provision.leadName}'): also saved to logs/lead.token`);
|
|
3072
|
+
} else if (provision.action === "minted") {
|
|
3073
|
+
console.log(`auto-lead provisioned with a caveat: ${provision.reason} [board ${d.root}]`);
|
|
3074
|
+
} else if (provision.action === "reused") {
|
|
3075
|
+
const standing = provision.pid ? `coordinator pid ${provision.pid} (standing)` : `claimed, no live coordinator — boot with: spawn --from ${from} --to ${provision.leadName} --persistent --body "you are the lead, read your crew"`;
|
|
3076
|
+
console.log(`auto-lead reused: '${provision.leadName}' lane (${standing}); this crew transferred to it (${provision.transferred} worker(s)) [board ${d.root}]`);
|
|
3077
|
+
} else {
|
|
3078
|
+
console.log(`auto-lead SKIPPED: ${provision.reason || "no reason recorded"} [board ${d.root}]`);
|
|
3079
|
+
}
|
|
3080
|
+
}
|
|
3016
3081
|
}
|
|
3017
3082
|
|
|
3018
3083
|
// Control-plane M1: `launch` validates the plan against
|
package/bin/lib/identity.js
CHANGED
|
@@ -405,26 +405,32 @@ export function mergeAgentDoc(prev, patch) {
|
|
|
405
405
|
}
|
|
406
406
|
|
|
407
407
|
// Loopback operator auto-provision (desktop plug-and-play):
|
|
408
|
-
// `serve`/`web` on 127.0.0.1 auto-creates
|
|
408
|
+
// `serve`/`web` on 127.0.0.1 auto-creates an operator identity on first boot so
|
|
409
409
|
// the dashboard can launch without any terminal step. First agent on the
|
|
410
410
|
// board becomes admin (see defaultRoleForNew), so this is the board owner.
|
|
411
|
-
//
|
|
411
|
+
// Under the 3-lane model (boss / lead / peers), fresh boards mint `boss` as the
|
|
412
|
+
// desktop human operator, allowing crew bursts to auto-provision `lead` as the
|
|
413
|
+
// autonomous coordinator. Existing boards that already claimed `lead` (or `boss`)
|
|
414
|
+
// are kept without disruption.
|
|
415
|
+
// CLI boards are untouched: this only fires when operator is missing AND the
|
|
412
416
|
// bind is loopback. Returns { from, token } or null when not applicable.
|
|
413
417
|
export function ensureLoopbackOperator(d, host) {
|
|
414
418
|
const loop = String(host || "127.0.0.1");
|
|
415
419
|
if (loop !== "127.0.0.1" && loop !== "localhost" && loop !== "::1") return null;
|
|
416
|
-
let
|
|
417
|
-
try {
|
|
418
|
-
|
|
420
|
+
let recBoss = null, recLead = null;
|
|
421
|
+
try { recBoss = readAgent(d, "boss"); } catch { recBoss = null; }
|
|
422
|
+
try { recLead = readAgent(d, "lead"); } catch { recLead = null; }
|
|
423
|
+
if (recBoss && (recBoss.tokenHash || recBoss.token)) return null; // already provisioned
|
|
424
|
+
if (recLead && (recLead.tokenHash || recLead.token)) return null; // already provisioned (legacy board)
|
|
419
425
|
if (countAgentRecords(d) > 0) return null; // board already has registered agents
|
|
420
426
|
const fresh = mintToken();
|
|
421
427
|
const salt = newSalt();
|
|
422
428
|
const now = new Date().toISOString();
|
|
423
429
|
let prev = null;
|
|
424
|
-
try { prev = readJson(path.join(d.agents, "
|
|
430
|
+
try { prev = readJson(path.join(d.agents, "boss.json")); } catch { prev = null; }
|
|
425
431
|
const { v, hlc } = stampSyncDoc(prev);
|
|
426
432
|
const doc = mergeAgentDoc(prev, {
|
|
427
|
-
name: "
|
|
433
|
+
name: "boss",
|
|
428
434
|
firstSeen: (prev && prev.firstSeen) || now,
|
|
429
435
|
lastSeen: now,
|
|
430
436
|
tokenHash: hashToken(fresh, salt),
|
|
@@ -438,9 +444,9 @@ export function ensureLoopbackOperator(d, host) {
|
|
|
438
444
|
let won = false;
|
|
439
445
|
try {
|
|
440
446
|
if (!prev) {
|
|
441
|
-
won = writeExclusiveJson(path.join(d.agents, "
|
|
447
|
+
won = writeExclusiveJson(path.join(d.agents, "boss.json"), doc);
|
|
442
448
|
} else {
|
|
443
|
-
writeAgentFile(d, "
|
|
449
|
+
writeAgentFile(d, "boss", doc);
|
|
444
450
|
won = true;
|
|
445
451
|
}
|
|
446
452
|
} catch { won = false; }
|
|
@@ -449,14 +455,14 @@ export function ensureLoopbackOperator(d, host) {
|
|
|
449
455
|
return null;
|
|
450
456
|
}
|
|
451
457
|
if (won) {
|
|
452
|
-
try { chmodAgentFile(path.join(d.agents, "
|
|
458
|
+
try { chmodAgentFile(path.join(d.agents, "boss.json")); } catch {}
|
|
453
459
|
try {
|
|
454
460
|
fs.mkdirSync(path.join(d.root, "logs"), { recursive: true });
|
|
455
|
-
fs.writeFileSync(path.join(d.root, "logs", "
|
|
456
|
-
try { fs.chmodSync(path.join(d.root, "logs", "
|
|
461
|
+
fs.writeFileSync(path.join(d.root, "logs", "boss.token"), fresh + "\n", "utf8");
|
|
462
|
+
try { fs.chmodSync(path.join(d.root, "logs", "boss.token"), 0o600); } catch {}
|
|
457
463
|
} catch {}
|
|
458
464
|
}
|
|
459
|
-
return won ? { from: "
|
|
465
|
+
return won ? { from: "boss", token: fresh } : null;
|
|
460
466
|
}
|
|
461
467
|
|
|
462
468
|
export function touchAgent(d, name, extra) { // line 2647
|
package/bin/lib/launch.js
CHANGED
|
@@ -276,6 +276,9 @@ export function validateLaunchPlan(raw) {
|
|
|
276
276
|
const model = r.model === undefined || r.model === null || String(r.model).trim() === "" ? undefined : String(r.model).trim();
|
|
277
277
|
if (model && model.length > 100) errors.push("model name too long (max 100 chars)");
|
|
278
278
|
|
|
279
|
+
const lead = r.lead === undefined || r.lead === null || String(r.lead).trim() === "" ? "auto" : String(r.lead).trim().toLowerCase();
|
|
280
|
+
if (!["auto", "board", "none"].includes(lead)) errors.push(`bad lead mode "${r.lead}" (want auto|board|none)`);
|
|
281
|
+
|
|
279
282
|
const plan = {
|
|
280
283
|
harness, harnesses: harnesses.length > 0 ? harnesses : ["generic"],
|
|
281
284
|
model, body, count: Number.isInteger(count) && count > 0 ? count : 1,
|
|
@@ -285,7 +288,7 @@ export function validateLaunchPlan(raw) {
|
|
|
285
288
|
priority: r.priority === undefined ? undefined : String(r.priority),
|
|
286
289
|
maxTurns: r.maxTurns === undefined ? undefined : String(r.maxTurns),
|
|
287
290
|
allowTools: r.allowTools === undefined ? undefined : String(r.allowTools),
|
|
288
|
-
permission, lifetime,
|
|
291
|
+
permission, lifetime, lead,
|
|
289
292
|
isolate: !!r.isolate, worktree: r.worktree, branch: r.branch,
|
|
290
293
|
budgetTokens: r.budgetTokens, budgetMinutes: r.budgetMinutes, timeout: r.timeout,
|
|
291
294
|
target: r.target === undefined ? "local" : r.target,
|
package/bin/lib/spawn.js
CHANGED
|
@@ -24,12 +24,20 @@ import crypto from "node:crypto";
|
|
|
24
24
|
import os from "node:os";
|
|
25
25
|
import { createRequire } from "node:module";
|
|
26
26
|
import { execFileSync, spawn } from "node:child_process";
|
|
27
|
-
import { fail, readJson, writeJson, cleanBranchPrefix } from "./store.js";
|
|
28
|
-
import { touchAgent } from "./identity.js";
|
|
27
|
+
import { fail, readJson, writeJson, writeExclusiveJson, cleanBranchPrefix } from "./store.js";
|
|
28
|
+
import { touchAgent, readAgent, writeAgentFile, assertMintWon, mintToken, newSalt, hashToken } from "./identity.js";
|
|
29
29
|
import { readVisible, isCheckpoint } from "./mail.js";
|
|
30
|
+
import { saveTokenFile, loadTokenFile } from "./tokenfile.js";
|
|
30
31
|
|
|
31
32
|
// cleanBranchPrefix lives in store.js (canonical home).
|
|
32
33
|
|
|
34
|
+
// Auto-provisioned lead lane: the board's standing coordinator lane name.
|
|
35
|
+
// `spawn --lead board` (the default) mints it once (first claim wins) and
|
|
36
|
+
// boots a detached persistent coordinator that owns the crew for the burst;
|
|
37
|
+
// the interactive spawner steps back to boss (reads the dashboard, gets
|
|
38
|
+
// milestone DMs). All worker prompts pin replies to this name.
|
|
39
|
+
export const LEAD_NAME = "lead";
|
|
40
|
+
|
|
33
41
|
export function sandboxPresent() { // line 1017
|
|
34
42
|
return !!(process.env.CONTAINER || process.env.DOCKER || process.env.CI || process.env.CREWBUS_SANDBOX);
|
|
35
43
|
}
|
|
@@ -162,8 +170,12 @@ export function parseAllowEnv(raw) { // line 4078
|
|
|
162
170
|
return String(raw).split(",").map((s) => String(s).trim()).filter(Boolean).join(",");
|
|
163
171
|
}
|
|
164
172
|
|
|
165
|
-
export function buildSpawnPrompt({ name, from, subject, body, replyId, rev, cwd, root, crew, workbench }) { // line 4090
|
|
173
|
+
export function buildSpawnPrompt({ name, from, lead, subject, body, replyId, rev, cwd, root, crew, workbench }) { // line 4090
|
|
166
174
|
const me = String(name || "you");
|
|
175
|
+
// Reply target: the sender by default (legacy star topology), or the
|
|
176
|
+
// board's lead lane under --lead board (spawn and lead separated: the
|
|
177
|
+
// spawner is boss, the auto-provisioned coordinator is lead).
|
|
178
|
+
const replyTo = String(lead || from || LEAD_NAME);
|
|
167
179
|
const crewLines = Array.isArray(crew) ? crew.map((l) => String(l)).filter((s) => s.trim() !== "") : [];
|
|
168
180
|
const wbLines = Array.isArray(workbench) ? workbench.map((l) => String(l)).filter((s) => s.trim() !== "") : [];
|
|
169
181
|
return [
|
|
@@ -178,9 +190,9 @@ export function buildSpawnPrompt({ name, from, subject, body, replyId, rev, cwd,
|
|
|
178
190
|
`Protocol:`,
|
|
179
191
|
`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.`,
|
|
180
192
|
`1. Work in ${cwd} (your harness already starts there).`,
|
|
181
|
-
`2. When done or blocked, DM a summary back: crewbus send --from ${me} --to ${
|
|
182
|
-
`2b. Checkpoint every few steps or before risky commands: crewbus send --from ${me} --to ${
|
|
183
|
-
`2c. Blocked and need approval (destructive/irreversible/out-of-scope only): crewbus send --priority high --from ${me} --to ${
|
|
193
|
+
`2. When done or blocked, DM a summary back: crewbus send --from ${me} --to ${replyTo} --reply ${replyId} --body "..."${replyTo === from ? ` (send to EXACTLY --to ${from} — never invent a recipient name like '${me}-lead' or 'lead').` : ` (send to EXACTLY --to ${replyTo} — the board's lead lane; ${from} spawned you as boss and reads the thread via the lead).`}`,
|
|
194
|
+
`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).`,
|
|
195
|
+
`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.`,
|
|
184
196
|
`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.`,
|
|
185
197
|
`4. Never post secrets — reference their location instead.${rev ? ` Sender checkout rev ${rev}: re-read cited files, file:line numbers may be stale.` : ""}`,
|
|
186
198
|
].join("\n");
|
|
@@ -200,14 +212,14 @@ export function buildSpawnPrompt({ name, from, subject, body, replyId, rev, cwd,
|
|
|
200
212
|
// LEAD_PLUS) — so the block points reads at channels and writes at DMs.
|
|
201
213
|
// Returns bullet lines (no header); the caller renders them under a
|
|
202
214
|
// Crew: header. Pure: unit-tested, no board IO.
|
|
203
|
-
export function buildCrewContext({ name, from, subject, groups, myGroups, offTask }) {
|
|
215
|
+
export function buildCrewContext({ name, from, lead: leadTarget, subject, groups, myGroups, offTask }) {
|
|
204
216
|
const all = (groups || []).filter((g) => g && g.name);
|
|
205
217
|
const mineSet = new Set(myGroups || []);
|
|
206
218
|
const mine = all.filter((g) => mineSet.has(g.name));
|
|
207
219
|
const others = all.filter((g) => !mineSet.has(g.name));
|
|
208
220
|
const lane = subject && String(subject).trim() ? String(subject).trim() : "the brief above";
|
|
209
221
|
const me = String(name || "you");
|
|
210
|
-
const lead = String(from ||
|
|
222
|
+
const lead = leadTarget !== undefined ? String(leadTarget) : String(from || LEAD_NAME);
|
|
211
223
|
const off = Math.max(0, Number(offTask) || 0);
|
|
212
224
|
const offNoun = (n) => `${n} other group${n === 1 ? "" : "s"}`;
|
|
213
225
|
const showMembers = (members) => {
|
|
@@ -230,10 +242,181 @@ export function buildCrewContext({ name, from, subject, groups, myGroups, offTas
|
|
|
230
242
|
}
|
|
231
243
|
out.push(`ask the group that owns a thing before asking ${lead}: crewbus send --from ${me} --to-group <group> --subject "..." --body "..." (reaches every member; ${lead} is for approvals and scope disputes only).`);
|
|
232
244
|
out.push(`read context freely: crewbus channel tail grp-<group> (a group's briefs + progress, reads need no token). Posting to channels needs lead rights — write everything via DMs.`);
|
|
233
|
-
out.push(`boot habit: crewbus agents + crewbus group list once, so you know who else is here.`);
|
|
245
|
+
out.push(`boot habit: crewbus agents + crewbus group list once, so you know who else is here. Broadcast one hello once you claimed your name (--to-group <group> when you have one, else a DM per sibling) so peers know you exist before they need you.`);
|
|
234
246
|
return out;
|
|
235
247
|
}
|
|
236
248
|
|
|
249
|
+
// Coordinator prompt for the auto-provisioned lead (--lead board, the spawn
|
|
250
|
+
// default): a detached persistent worker that OWNS the crew for the burst so
|
|
251
|
+
// the interactive spawner can step back to boss. This is infrastructure
|
|
252
|
+
// steering (the one place a brief may orchestrate): the coordinator TRIAGES
|
|
253
|
+
// and KEEPS THE BOARD ALIVE — it never rewrites the mission or does workers'
|
|
254
|
+
// jobs. Split of authority (docs/CREWS.md §auto-lead):
|
|
255
|
+
// peers — all strategy, peer DMs, self-coordination
|
|
256
|
+
// lead — env repair, respawn/health chasing, TTL pacing, verdicts on
|
|
257
|
+
// worker approval asks (fail-closed), verification of claims
|
|
258
|
+
// boss — the spawner identity (may poll at its own cadence): mission
|
|
259
|
+
// changes, scope disputes; receives milestone + final DMs
|
|
260
|
+
// `workers` is [{ name, id, harness }]; `batch` the batch id ("" when solo).
|
|
261
|
+
// Pure: unit-tested, no board IO — the caller boots it via bootWorker
|
|
262
|
+
// (prompt override) and stamps the log file itself.
|
|
263
|
+
export function buildCoordinatorPrompt({ name, from, subject, body, batch, workers, crew, cwd, root, auto, workbench }) {
|
|
264
|
+
const boss = String(from || "boss");
|
|
265
|
+
const me = String(name || LEAD_NAME);
|
|
266
|
+
const ws = Array.isArray(workers) ? workers.filter((w) => w && w.name) : [];
|
|
267
|
+
const crewLines = Array.isArray(crew) ? crew.map((l) => String(l)).filter((s) => s.trim() !== "") : [];
|
|
268
|
+
const wbLines = Array.isArray(workbench) ? workbench.map((l) => String(l)).filter((s) => s.trim() !== "") : [];
|
|
269
|
+
const today = new Date().toISOString().slice(0, 10);
|
|
270
|
+
return [
|
|
271
|
+
`You are '${me}' on crewbus (board: ${root}) — the auto-provisioned lead for this crew${batch ? ` (batch ${batch})` : ""}.`,
|
|
272
|
+
`${boss} spawned the crew as boss and left the acting lead seat to you from here on. This is an infrastructure/coordinator role, not a do-the-task role.`,
|
|
273
|
+
``,
|
|
274
|
+
`Mission the crew is working (from ${boss}${subject ? ` — ${subject}` : ""}):`,
|
|
275
|
+
String(body || "(original brief; see each worker's prompt file under logs/)"),
|
|
276
|
+
``,
|
|
277
|
+
...(crewLines.length > 0 ? ["Crew:", ...crewLines.map((l) => `- ${l}`), ""] : []),
|
|
278
|
+
...(batch ? ["Worker briefs (thread ids, for --reply):", ...ws.map((w) => `- ${w.name}: brief ${w.id}${w.harness ? ` [${w.harness}]` : ""}`), ""] : []),
|
|
279
|
+
...(wbLines.length > 0 ? ["Workbench (lessons + artifacts from prior work on this board):", ...wbLines, ""] : []),
|
|
280
|
+
`Your identity: token saved at logs/${me}.token — read it into CREWBUS_TOKEN at the top of each shell that sends (PowerShell: \$env:CREWBUS_TOKEN = Get-Content .crewbus/logs/${me}.token). All sends run as --from ${me}. Never re-register over your own name — re-read the token file after any restart or compaction.`,
|
|
281
|
+
``,
|
|
282
|
+
`Jobs, in order:`,
|
|
283
|
+
`0. Boot habit: crewbus agents + crewbus group list, so you know who is on the board (workers claim over the first minutes; re-check when triaging).`,
|
|
284
|
+
`1. Read every DM before acting on anything else: crewbus inbox --from ${me} --unacked --digest, full read on hits. Workers' checkpoints and finals arrive here (each pinned to --reply their brief id).`,
|
|
285
|
+
`2. Keep the board alive — poll in a loop, cheaply: crewbus listen --from ${me} --timeout 120000 (blocks until a DM arrives; re-issue after each wake; fall back to sleep 60 + inbox --digest when listen is unavailable). Triage as DMs land: unblock, dedupe sibling lanes, point a worker at its sibling's finding instead of redoing it.`,
|
|
286
|
+
`3. Watch crew health: crewbus spawn-status --all. A worker that exited without a final is a lane to close: prefer the catch-up path first (crewbus respawn --from ${me} --to <name>${ws.some((w) => w.harness === "opencode") ? " (--fresh when its session id was never captured)" : ""}${auto ? " --auto (this crew was spawned fully-unattended; respawns inherit it)" : ""}); fall back to a fresh spawn (crewbus spawn --from ${me} --to <name> --persistent ... same mission text) only when respawn data is gone. Respawns need your lead token loaded (owned-crew). Cap: 2 respawn attempts per lane before DM'ing the boss with the stall evidence.`,
|
|
287
|
+
`4. Approvals: a worker's "approval:" ask (destructive/irreversible/out-of-scope) waits on your verdict — answer by --reply on its thread within the ask's stated timeout (crewbus send --from ${me} --to <worker> --reply <id> --body "approved ..." | "denied: <reason>; try-instead ..."). Silence beyond the ask's timeout reads as deny, fail-closed. Secrets/exfiltration/isolation-escape asks are NEVER approvable — deny and flag the boss.`,
|
|
288
|
+
`5. Scope disputes or mission changes: DM the boss — crewbus send --from ${me} --to ${boss} --priority high --subject "..." (the boss may not have a session open; the DM waits on the board by design — that is fine, keep working conservatively meanwhile). Same lane for milestones: batch started, lane closed, blocked, final aggregate.`,
|
|
289
|
+
`6. Long promises get deadlines: when you push a task or a lane's window, stamp --needs-by <duration> on the DM; chase inbox rows marked [OVERDUE] explicitly; when a lane stalls, surface it to the boss rather than silently absorbing it.`,
|
|
290
|
+
`7. Verify before relaying: worker claims about files/output get spot-checked against the board and ${cwd} when reasonable; do not relay a claim you contradict. Record what you verified in the thread.`,
|
|
291
|
+
``,
|
|
292
|
+
`Never: change the workers' mission text (the mission above is the boss's words — pass it through verbatim), redo workers' work yourself, paste secrets (reference file paths), or micro-manage strategy. Peer-coordination belongs to the peers; you own health, verdicts, and the clock.`,
|
|
293
|
+
`Exit: when every lane has a final report or a deliberate stand-down, send the aggregate to the boss (crewbus send --from ${me} --to ${boss} --subject "result: ..." — include outcome, lanes closed, respawn count, artifacts left on the board), then you may exit. If the board is stalled with nothing spawnable, send the aggregate with the stall reason and exit.`,
|
|
294
|
+
``,
|
|
295
|
+
`Protocol:`,
|
|
296
|
+
`3. Poll cheap and often: crewbus inbox --from ${me} --unacked --digest (full read only on hits). A full inbox dump every step will eat your context window.`,
|
|
297
|
+
`4. Never post secrets — reference their location instead. Today is ${today}.`,
|
|
298
|
+
].join("\n");
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
// Provision the auto-lead for a spawn burst (--lead board): mint the 'lead'
|
|
303
|
+
// lane once per board (first claim wins, role = lead so spawn/respawn-kill
|
|
304
|
+
// authorize), hand its token over the same token-file convention workers use
|
|
305
|
+
// (logs/lead.token), boot a detached persistent coordinator with the prompt
|
|
306
|
+
// from buildCoordinatorPrompt, then TRANSFER crew ownership (workers'
|
|
307
|
+
// spawnedBy -> lead) so respawn/spawn-kill own-crew checks pass.
|
|
308
|
+
// opts: { d, spawnOpts, from, subject, body, rev, logDir, workers, batch,
|
|
309
|
+
// crew, workbench, auto }
|
|
310
|
+
// Returns { action: "minted"|"reused"|"skipped", reason?, leadName, pid?,
|
|
311
|
+
// logPath?, promptPath?, token?, transferred? } — token only on
|
|
312
|
+
// mint (printed once, then saved to the token file); a standing live
|
|
313
|
+
// coordinator is reused, never duplicated.
|
|
314
|
+
export function provisionAutoLead(d, opts) {
|
|
315
|
+
const leadName = LEAD_NAME;
|
|
316
|
+
const o = opts || {};
|
|
317
|
+
const boss = String(o.from || "boss");
|
|
318
|
+
if (boss === leadName) {
|
|
319
|
+
return { action: "skipped", reason: "the sender IS the lead lane — it bootstraps its own coordinator", leadName };
|
|
320
|
+
}
|
|
321
|
+
// Offboarded lead lane = deliberate teardown: refuse to skeleton it back
|
|
322
|
+
// up behind the caller's back (re-onboard it or pass --lead none).
|
|
323
|
+
const existing = readAgent(d, leadName);
|
|
324
|
+
if (existing && existing.offboarded) {
|
|
325
|
+
return { action: "skipped", reason: `lane "${leadName}" is offboarded (re-onboard it, or pass --lead none to pin replies to the spawner)`, leadName };
|
|
326
|
+
}
|
|
327
|
+
let token = null;
|
|
328
|
+
let minted = false;
|
|
329
|
+
if (existing && (existing.tokenHash || existing.token)) {
|
|
330
|
+
// Identity reuse — a lead lane already claims this name.
|
|
331
|
+
} else {
|
|
332
|
+
token = mintToken();
|
|
333
|
+
const salt = newSalt();
|
|
334
|
+
const tokenHash = hashToken(token, salt);
|
|
335
|
+
const doc = {
|
|
336
|
+
name: leadName, firstSeen: new Date().toISOString(), lastSeen: new Date().toISOString(),
|
|
337
|
+
lastDir: (o.spawnOpts && o.spawnOpts.cwd) || process.cwd(),
|
|
338
|
+
tokenHash, salt, role: "lead",
|
|
339
|
+
provisionedBy: boss, provisionedAt: new Date().toISOString(),
|
|
340
|
+
};
|
|
341
|
+
const claimed = writeExclusiveJson(path.join(d.agents, `${leadName}.json`), doc);
|
|
342
|
+
if (claimed) {
|
|
343
|
+
minted = true;
|
|
344
|
+
} else {
|
|
345
|
+
// Lost the exclusive create: either a concurrent minter won, or a
|
|
346
|
+
// legacy tokenless record holds the name (mint into it — this is the
|
|
347
|
+
// ensureSender post-revoke path, minus the token authentication step
|
|
348
|
+
// the caller already performed as board admin).
|
|
349
|
+
const again = readAgent(d, leadName);
|
|
350
|
+
if (again && !again.offboarded && !again.tokenHash && !again.token) {
|
|
351
|
+
const salt2 = newSalt();
|
|
352
|
+
again.tokenHash = hashToken(token, salt2);
|
|
353
|
+
again.salt = salt2;
|
|
354
|
+
if (!again.role) again.role = "lead";
|
|
355
|
+
writeAgentFile(d, leadName, again);
|
|
356
|
+
assertMintWon(d, leadName, again.tokenHash);
|
|
357
|
+
minted = true;
|
|
358
|
+
} else if (again && (again.tokenHash || again.token)) {
|
|
359
|
+
token = null; // absorbed by a concurrent minter — reuse its identity
|
|
360
|
+
} else {
|
|
361
|
+
return { action: "skipped", reason: `lane "${leadName}" raced a parallel claim that hid the name — retry or pass --lead none`, leadName };
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
// Always (re)record how this coordinator came to be, without clobbering
|
|
366
|
+
// an existing live one.
|
|
367
|
+
const rec = readAgent(d, leadName);
|
|
368
|
+
const standing = rec && typeof rec.spawnedPid === "number" && pidAlive(rec.spawnedPid);
|
|
369
|
+
if (minted) saveTokenFile(d.root, leadName, token);
|
|
370
|
+
let booted = null;
|
|
371
|
+
if (standing) {
|
|
372
|
+
// A live coordinator is already running on the lead lane (previous
|
|
373
|
+
// burst): never duplicate it — DMs land in the same lane by name.
|
|
374
|
+
} else {
|
|
375
|
+
try {
|
|
376
|
+
booted = bootWorker(d, o.spawnOpts, {
|
|
377
|
+
to: leadName, id: o.batch || "coord", from: boss, subject: o.subject,
|
|
378
|
+
body: o.body, rev: o.rev, logDir: o.logDir, crew: o.crew,
|
|
379
|
+
workbench: o.workbench, prompt: buildCoordinatorPrompt({
|
|
380
|
+
name: leadName, from: boss, subject: o.subject, body: o.body,
|
|
381
|
+
batch: o.batch, workers: o.workers, crew: o.crew,
|
|
382
|
+
cwd: (o.spawnOpts && o.spawnOpts.cwd) || process.cwd(),
|
|
383
|
+
root: d.root, auto: !!o.auto, workbench: o.workbench,
|
|
384
|
+
}),
|
|
385
|
+
spawnedLifetime: "persistent",
|
|
386
|
+
budgetTokens: undefined, budgetMinutes: undefined, deadlineAt: undefined,
|
|
387
|
+
});
|
|
388
|
+
} catch (e) {
|
|
389
|
+
const detail = String((e && (e.message || e)) || e).slice(0, 160);
|
|
390
|
+
if (minted) {
|
|
391
|
+
saveTokenFile(d.root, leadName, token);
|
|
392
|
+
try { touchAgent(d, leadName, { lastDir: (o.spawnOpts && o.spawnOpts.cwd) || undefined, provisionedBy: boss }); } catch {}
|
|
393
|
+
return { action: "minted", reason: `coordinator boot failed (${detail}) — lane minted; token at logs/${leadName}.token; boot it by hand (spawn --from ${boss} --to ${leadName} --persistent) or DM workers manually`, leadName, token, boss };
|
|
394
|
+
}
|
|
395
|
+
return { action: "skipped", reason: `coordinator boot failed (${detail}) — workers stay owned by ${boss}`, leadName };
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
try { touchAgent(d, leadName, { lastDir: (o.spawnOpts && o.spawnOpts.cwd) || undefined, spawnedBy: boss ?? undefined }); } catch {}
|
|
399
|
+
// Crew ownership transfer: workers now belong to the lead lane, which is
|
|
400
|
+
// what respawn/spawn-kill own-crew checks demand (docs/RBAC.md). The
|
|
401
|
+
// spawner's audit trail (appendChainRecord) preserves the original actor.
|
|
402
|
+
let transferred = 0;
|
|
403
|
+
for (const w of (Array.isArray(o.workers) ? o.workers : [])) {
|
|
404
|
+
if (!w || !w.name) continue;
|
|
405
|
+
try { touchAgent(d, w.name, { spawnedBy: leadName }); transferred += 1; } catch {}
|
|
406
|
+
}
|
|
407
|
+
return {
|
|
408
|
+
action: minted ? "minted" : "reused",
|
|
409
|
+
leadName,
|
|
410
|
+
pid: booted ? booted.pid : (rec && rec.spawnedPid),
|
|
411
|
+
logPath: booted ? booted.logPath : undefined,
|
|
412
|
+
promptPath: booted ? booted.promptPath : undefined,
|
|
413
|
+
token,
|
|
414
|
+
transferred,
|
|
415
|
+
boss,
|
|
416
|
+
stoodDown: !!standing,
|
|
417
|
+
};
|
|
418
|
+
}
|
|
419
|
+
|
|
237
420
|
// Resolve the real opencode binary from PATH, once per process. npm installs
|
|
238
421
|
// expose cmd/bash/ps1 shims that shell out to the real exe; running through
|
|
239
422
|
// them (the old `shell: true` path) drags the Bun binary into cmd.exe, which
|
|
@@ -891,12 +1074,14 @@ export function installCliToUserPath() {
|
|
|
891
1074
|
return { ok: true, binDir: userBinDir, addedToPath, detail };
|
|
892
1075
|
}
|
|
893
1076
|
|
|
894
|
-
export function bootWorker(d, spawnOpts, { to, id, from, subject, body, rev, logDir, budgetTokens, budgetMinutes, deadlineAt, spawnedWorktree, spawnedBranch, spawnedLifetime, sessionId, crew, workbench }) { // line 4338
|
|
1077
|
+
export function bootWorker(d, spawnOpts, { to, id, from, lead, subject, body, rev, logDir, budgetTokens, budgetMinutes, deadlineAt, spawnedWorktree, spawnedBranch, spawnedLifetime, sessionId, crew, workbench, prompt }) { // line 4338
|
|
895
1078
|
const { cwd, root } = spawnOpts;
|
|
896
1079
|
const stamp = new Date().toISOString().replace(/[:.]/g, "-");
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
1080
|
+
// Prompt override: the auto-lead coordinator passes its own brief
|
|
1081
|
+
// (buildCoordinatorPrompt); everything else uses the worker template.
|
|
1082
|
+
const finalPrompt = (typeof prompt === "string" && prompt.trim()) ? prompt : buildSpawnPrompt({ name: to, from, lead, subject, body, replyId: id, rev, cwd, root, crew, workbench });
|
|
1083
|
+
const promptPath = path.join(logDir, `${to}-${stamp}.prompt.md`);
|
|
1084
|
+
fs.writeFileSync(promptPath, finalPrompt + "\n");
|
|
900
1085
|
const logPath = path.join(logDir, `${to}-${stamp}.log`);
|
|
901
1086
|
// Boot metadata first: child stdout is often block-buffered (or never
|
|
902
1087
|
// flushed at all on some harnesses), so the log must carry proof of
|
|
@@ -934,7 +1119,7 @@ export function bootWorker(d, spawnOpts, { to, id, from, subject, body, rev, log
|
|
|
934
1119
|
preId = undefined;
|
|
935
1120
|
}
|
|
936
1121
|
}
|
|
937
|
-
const target = buildSpawnTarget({ ...spawnOpts, name: to, promptPath, prompt, sessionId: preId });
|
|
1122
|
+
const target = buildSpawnTarget({ ...spawnOpts, name: to, promptPath, prompt: finalPrompt, sessionId: preId });
|
|
938
1123
|
const { pid } = launchWorkerProcess({ exe: target.exe, args: target.args, shell: target.shell, cwd, env: childEnv, logPath, stdinPath: target.stdinPath });
|
|
939
1124
|
touchAgent(d, to, { spawnedPid: pid, spawnedAt: new Date().toISOString(), spawnedBy: from, briefId: id, lastDir: cwd, budgetTokens, budgetMinutes, budgetSince: (budgetTokens !== undefined || budgetMinutes !== undefined) ? new Date().toISOString() : undefined, deadlineAt, spawnedWorktree, spawnedBranch, spawnedLifetime, spawnedHarness: cleanHarnessDriver(spawnOpts.harness), spawnedEnvScrubbed: scrub.kept ? 0 : scrub.scrubbed.length });
|
|
940
1125
|
// Binding doc for the later respawn step (preassigned id lands here
|
package/bin/lib/web.js
CHANGED
|
@@ -19,7 +19,7 @@ import { fileURLToPath } from "node:url";
|
|
|
19
19
|
import { boardDir, requireBoard, getFlag, fail, writeJson, listJson, cleanWebName, readJson, readBoardMeta, writeBoardMeta, gitRevForBoard, newId, MAX_SPAWN, MAX_BODY_CHARS } from "./store.js";
|
|
20
20
|
import { readAgent, agentTokenMatches, authorizeCheck, ensureLoopbackOperator, mintToken, newSalt, hashToken, touchAgent } from "./identity.js";
|
|
21
21
|
import { readDMs, readVisible, ackedIds, ackedIdSet, findMessageById, deliverDMs, parseRecipients } from "./mail.js";
|
|
22
|
-
import { workerStatus, pidAlive, killWorkers, bootWorker, buildSpawnPrompt, buildSpawnTarget, formatSpawnCmd, installCliToUserPath, ensureBoardCliShim } from "./spawn.js";
|
|
22
|
+
import { workerStatus, pidAlive, killWorkers, bootWorker, buildSpawnPrompt, buildSpawnTarget, formatSpawnCmd, installCliToUserPath, ensureBoardCliShim, buildCoordinatorPrompt, provisionAutoLead, LEAD_NAME } from "./spawn.js";
|
|
23
23
|
import { groupTelemetryData, collectBatch, gatherTelemetry, listBatches } from "./groups.js";
|
|
24
24
|
import { httpJson } from "./sync.js";
|
|
25
25
|
import { readChainRecords, verifyChainRecords, appendChainRecord, readHold, readBoardQuotas } from "./export.js";
|
|
@@ -782,7 +782,12 @@ details.tech-details summary{cursor:pointer;font-weight:500;user-select:none}
|
|
|
782
782
|
<button type="button" data-perm="auto">auto</button>
|
|
783
783
|
<button type="button" data-perm="full">full</button>
|
|
784
784
|
</span>
|
|
785
|
-
<
|
|
785
|
+
<span class="dim" style="margin-left:8px">Coordinator:</span>
|
|
786
|
+
<select id="launch-lead" style="background:var(--panel);color:var(--ink);border:1px solid var(--line);border-radius:4px;padding:3px 8px;font-size:12px" title="Observer coordinator lane: auto provisions a persistent background coordinator (lead) to triage workers and report to you">
|
|
787
|
+
<option value="auto">auto (Observer coordinator)</option>
|
|
788
|
+
<option value="none">none (direct to me)</option>
|
|
789
|
+
</select>
|
|
790
|
+
<label class="dim" style="cursor:pointer;margin-left:6px"><input id="launch-dry" type="checkbox" checked> Dry-run</label>
|
|
786
791
|
</div>
|
|
787
792
|
|
|
788
793
|
<div class="composer-cwd-row" style="display:flex;align-items:center;gap:6px;margin-bottom:8px;font-size:12px">
|
|
@@ -801,7 +806,7 @@ details.tech-details summary{cursor:pointer;font-weight:500;user-select:none}
|
|
|
801
806
|
|
|
802
807
|
<div class="composer-bottom">
|
|
803
808
|
<div class="launch-identity" title="Desktop launches as the board owner (auto-provisioned) — no token step needed">
|
|
804
|
-
<span class="dim">launching as <b id="launch-as">
|
|
809
|
+
<span class="dim">launching as <b id="launch-as">boss</b> (auto)</span>
|
|
805
810
|
<input id="launch-from" type="hidden" value="">
|
|
806
811
|
<input id="launch-token" type="password" style="display:none" value="">
|
|
807
812
|
</div>
|
|
@@ -1152,7 +1157,8 @@ async function refresh(){
|
|
|
1152
1157
|
}).join('')||'<tr><td colspan="7" class="dim">no spawned workers</td></tr>';
|
|
1153
1158
|
Array.prototype.forEach.call(document.querySelectorAll('[data-kill]'),function(b){b.onclick=function(){kill([b.getAttribute('data-kill')]);};});
|
|
1154
1159
|
document.getElementById('agents').innerHTML=s.agents.map(function(a){
|
|
1155
|
-
|
|
1160
|
+
var roleBadge = a.role ? ' <span class="dim" style="font-size:11px">['+esc(a.role)+']</span>' : '';
|
|
1161
|
+
return '<tr><td><b>'+esc(a.name)+'</b>'+roleBadge+'</td><td>'+(a.active?DOT_SVG+' active':RING_SVG+' stale')+'</td><td title="'+esc(a.lastSeen||'?')+'">'+esc(ago(a.lastSeen))+'</td><td>'+esc(a.sessionId||'—')+'</td><td>'+a.dmCount+'</td><td>'+a.unacked+'</td></tr>';
|
|
1156
1162
|
}).join('')||'<tr><td colspan="6" class="dim">no agents yet</td></tr>';
|
|
1157
1163
|
document.getElementById('bcast').innerHTML=s.broadcasts.map(function(b){
|
|
1158
1164
|
var to=Array.isArray(b.to)?b.to.join(','):String(b.to||'');
|
|
@@ -1204,8 +1210,22 @@ async function refresh(){
|
|
|
1204
1210
|
return '<tr><td>'+esc(m.id)+'</td><td>'+esc(m.from)+'</td><td>'+(m.subject?'<b>'+esc(m.subject)+'</b><br>':'')+esc(m.head)+'</td><td><button data-ack="'+esc(m.id)+'">ack</button></td></tr>';
|
|
1205
1211
|
}).join('')||'<tr><td colspan="4" class="dim">inbox zero for '+esc(c.from)+'</td></tr>';
|
|
1206
1212
|
var ap=(tj.items||[]).filter(function(m){return m.subject&&m.subject.indexOf('approval: ')===0;});
|
|
1213
|
+
if(c.from!=='lead'){
|
|
1214
|
+
try{
|
|
1215
|
+
var lr=await fetch('/api/inbox?agent=lead&unacked=1&limit=50',{cache:'no-store'});
|
|
1216
|
+
if(lr.ok){
|
|
1217
|
+
var lj=await lr.json();
|
|
1218
|
+
var lap=(lj.items||[]).filter(function(m){return m.subject&&m.subject.indexOf('approval: ')===0;});
|
|
1219
|
+
for(var k=0;k<lap.length;k++){
|
|
1220
|
+
lap[k]._forLead=true;
|
|
1221
|
+
if(!ap.some(function(x){return x.id===lap[k].id;})) ap.push(lap[k]);
|
|
1222
|
+
}
|
|
1223
|
+
}
|
|
1224
|
+
}catch(_){}
|
|
1225
|
+
}
|
|
1207
1226
|
document.getElementById('approvals').innerHTML=ap.map(function(m){
|
|
1208
|
-
|
|
1227
|
+
var tag=m._forLead?' <span class="badge" style="font-size:10px;background:var(--panel);border:1px solid var(--line);padding:1px 4px;border-radius:3px">to lead</span>':'';
|
|
1228
|
+
return '<tr><td>'+esc(m.id)+tag+'</td><td>'+esc(m.from)+'</td><td>'+(m.subject?'<b>'+esc(m.subject)+'</b><br>':'')+esc(m.head)+'</td><td><input data-reason="'+esc(m.id)+'" maxlength="500" size="18" placeholder="optional reason"></td><td><button data-approve="'+esc(m.id)+'">approve</button> <button class="danger" data-deny="'+esc(m.id)+'">deny</button></td></tr>';
|
|
1209
1229
|
}).join('')||'<tr><td colspan="5" class="dim">no approval requests for '+esc(c.from)+'</td></tr>';
|
|
1210
1230
|
}else{
|
|
1211
1231
|
document.getElementById('triage').innerHTML='<tr><td colspan="4" class="dim">set identity above to triage</td></tr>';
|
|
@@ -1466,12 +1486,15 @@ async function doLaunch(dry){
|
|
|
1466
1486
|
}
|
|
1467
1487
|
var cwdEl=document.getElementById('launch-cwd');
|
|
1468
1488
|
var cwdVal=cwdEl?cwdEl.value.trim():'';
|
|
1489
|
+
var leadEl=document.getElementById('launch-lead');
|
|
1490
|
+
var leadVal=leadEl?leadEl.value.trim():'auto';
|
|
1469
1491
|
var payload={
|
|
1470
1492
|
from:lf, token:lt,
|
|
1471
1493
|
harness:selectedHarnesses.join(','),
|
|
1472
1494
|
harnesses:selectedHarnesses,
|
|
1473
1495
|
body:document.getElementById('launch-brief').value,
|
|
1474
1496
|
permission:document.getElementById('launch-permission').value,
|
|
1497
|
+
lead:leadVal,
|
|
1475
1498
|
dryRun:dry
|
|
1476
1499
|
};
|
|
1477
1500
|
if(cwdVal){
|
|
@@ -1488,11 +1511,22 @@ async function doLaunch(dry){
|
|
|
1488
1511
|
if(j.dryRun){
|
|
1489
1512
|
var warn=(j.warnings||[]).length?('warnings: '+j.warnings.join('; ')+'\\n'):'';
|
|
1490
1513
|
var cwdNotice=j.cwd?('target directory (cwd): '+j.cwd+'\\n'):'';
|
|
1491
|
-
|
|
1514
|
+
var coordNotice=j.coordinator?('\\ncoordinator ('+j.coordinator.name+'): '+(j.coordinator.action==='reused'?('reused standing pid '+j.coordinator.pid):(j.coordinator.action==='minted'?'would auto-provision':'skipped ('+(j.coordinator.reason||'')+')'))):'';
|
|
1515
|
+
try{renderLaunchDiff(j);}catch(_){}out.textContent=warn+cwdNotice+(j.commands||[]).map(function(c){return c.to+' ['+(c.harness||'')+']: '+c.command;}).join('\\n')+coordNotice+'\\n(dry-run — booted nothing)';
|
|
1492
1516
|
}else{
|
|
1493
1517
|
try{showUndoToast((j.workers||[]).map(function(w){return w.name;}));}catch(_){}
|
|
1494
1518
|
var cwdNotice=j.cwd?(' [cwd: '+j.cwd+']'):'';
|
|
1495
|
-
|
|
1519
|
+
var coordNotice='';
|
|
1520
|
+
if(j.coordinator){
|
|
1521
|
+
if(j.coordinator.action==='minted'&&j.coordinator.pid){
|
|
1522
|
+
coordNotice=' · coordinator: lead (pid '+j.coordinator.pid+')';
|
|
1523
|
+
}else if(j.coordinator.action==='reused'){
|
|
1524
|
+
coordNotice=' · coordinator: lead (reused'+(j.coordinator.pid?' pid '+j.coordinator.pid:'')+')';
|
|
1525
|
+
}else if(j.coordinator.reason){
|
|
1526
|
+
coordNotice=' · coordinator: skipped ('+j.coordinator.reason+')';
|
|
1527
|
+
}
|
|
1528
|
+
}
|
|
1529
|
+
out.textContent='launched: '+(j.workers||[]).map(function(w){return w.name+' ['+(w.driver||'')+']'+(w.pid?(' (pid '+w.pid+')'):'')+(w.error?(' ERROR '+w.error):'');}).join(', ')+coordNotice+cwdNotice;
|
|
1496
1530
|
}
|
|
1497
1531
|
}catch(e){out.textContent='launch failed: '+e.message;}
|
|
1498
1532
|
refresh();
|
|
@@ -2220,23 +2254,25 @@ export async function handleWebDashboardRoute(req, res, url, d) {
|
|
|
2220
2254
|
res.end(JSON.stringify({ error: "loopback only" }));
|
|
2221
2255
|
return true;
|
|
2222
2256
|
}
|
|
2223
|
-
const
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2257
|
+
for (const name of ["boss", "lead"]) {
|
|
2258
|
+
const tokenFile = path.join(d.root, "logs", `${name}.token`);
|
|
2259
|
+
let tok = "";
|
|
2260
|
+
try { tok = fs.readFileSync(tokenFile, "utf8").trim(); } catch {}
|
|
2261
|
+
// Verify the file token still matches the agent record: a stale file
|
|
2262
|
+
// (revoked/rotated operator) must not prefill a dead token.
|
|
2263
|
+
if (tok) {
|
|
2264
|
+
try {
|
|
2265
|
+
const rec = readAgent(d, name);
|
|
2266
|
+
if (rec && agentTokenMatches(rec, tok)) {
|
|
2267
|
+
res.writeHead(200, { "content-type": "application/json; charset=utf-8", "cache-control": "no-store" });
|
|
2268
|
+
res.end(JSON.stringify({ ok: true, from: name, token: tok }));
|
|
2269
|
+
return true;
|
|
2270
|
+
}
|
|
2271
|
+
} catch {}
|
|
2272
|
+
}
|
|
2237
2273
|
}
|
|
2238
2274
|
res.writeHead(404, { "content-type": "application/json; charset=utf-8", "cache-control": "no-store" });
|
|
2239
|
-
res.end(JSON.stringify({ ok: false, error: "no
|
|
2275
|
+
res.end(JSON.stringify({ ok: false, error: "no operator token found" }));
|
|
2240
2276
|
return true;
|
|
2241
2277
|
}
|
|
2242
2278
|
// Workspace memory (server-side, survives the random-port origin wipe):
|
|
@@ -2525,6 +2561,15 @@ export async function handleApiLaunch(d, body) {
|
|
|
2525
2561
|
if (!v.ok) return { status: 400, payload: { error: "launch plan invalid", errors: v.errors, warnings: v.warnings } };
|
|
2526
2562
|
const p = v.plan;
|
|
2527
2563
|
const harnesses = Array.isArray(p.harnesses) && p.harnesses.length > 0 ? p.harnesses : [p.harness || "opencode"];
|
|
2564
|
+
const hasCodingHarness = harnesses.some((h) => h !== "generic");
|
|
2565
|
+
let leadMode = p.lead || "auto";
|
|
2566
|
+
if (leadMode === "auto") {
|
|
2567
|
+
leadMode = hasCodingHarness ? "board" : "none";
|
|
2568
|
+
}
|
|
2569
|
+
if (leadMode === "board" && !hasCodingHarness) {
|
|
2570
|
+
return { status: 400, payload: { error: 'lead "board" needs a coding harness for the auto-coordinator (add a harness like opencode, or use lead "none")' } };
|
|
2571
|
+
}
|
|
2572
|
+
const leadTarget = leadMode === "board" ? LEAD_NAME : from;
|
|
2528
2573
|
const names = p.to ? String(p.to).split(",").map((s) => cleanWebName(s)).filter(Boolean)
|
|
2529
2574
|
: Array.from({ length: p.count }, (_, i) => `${cleanWebName(p.prefix || "w") || "w"}-${i + 1}`);
|
|
2530
2575
|
if (names.length === 0) return { status: 400, payload: { error: "no worker names (pass to or count)" } };
|
|
@@ -2537,9 +2582,10 @@ export async function handleApiLaunch(d, body) {
|
|
|
2537
2582
|
return { status: 400, payload: { error: 'generic harness needs cmd "..."' } };
|
|
2538
2583
|
}
|
|
2539
2584
|
if (v.plan.dryRun) {
|
|
2585
|
+
const previewBatch = names.length > 1 ? newId("batch") : undefined;
|
|
2540
2586
|
const rows = names.map((to, i) => {
|
|
2541
2587
|
const driver = harnesses[i % harnesses.length];
|
|
2542
|
-
const previewPrompt = buildSpawnPrompt({ name: to, from, subject: p.subject, body: p.body.trim(), replyId: "msg-<id>", rev, cwd, root: d.root });
|
|
2588
|
+
const previewPrompt = buildSpawnPrompt({ name: to, from, lead: leadTarget, subject: p.subject, body: p.body.trim(), replyId: previewBatch ? `${previewBatch}-${i + 1}` : "msg-<id>", rev, cwd, root: d.root });
|
|
2543
2589
|
const t = buildSpawnTarget({
|
|
2544
2590
|
harness: driver, cmd: body && body.cmd ? String(body.cmd) : undefined, model: p.model,
|
|
2545
2591
|
auto: p.permission === "auto" || p.permission === "full" ? true : undefined,
|
|
@@ -2548,7 +2594,28 @@ export async function handleApiLaunch(d, body) {
|
|
|
2548
2594
|
});
|
|
2549
2595
|
return { to, harness: driver, command: formatSpawnCmd(t) };
|
|
2550
2596
|
});
|
|
2551
|
-
|
|
2597
|
+
let coordinator = undefined;
|
|
2598
|
+
if (leadMode === "board") {
|
|
2599
|
+
const existingLead = readAgent(d, LEAD_NAME);
|
|
2600
|
+
const standing = existingLead && typeof existingLead.spawnedPid === "number" && pidAlive(existingLead.spawnedPid);
|
|
2601
|
+
if (standing) {
|
|
2602
|
+
coordinator = { name: LEAD_NAME, action: "reused", pid: existingLead.spawnedPid, note: "live coordinator already running" };
|
|
2603
|
+
} else if (existingLead && existingLead.offboarded) {
|
|
2604
|
+
coordinator = { name: LEAD_NAME, action: "skipped", reason: "lane is offboarded" };
|
|
2605
|
+
} else {
|
|
2606
|
+
const coordDriver = harnesses.find((h) => h !== "generic") || "opencode";
|
|
2607
|
+
const previewCoordPrompt = buildCoordinatorPrompt({
|
|
2608
|
+
name: LEAD_NAME, from, subject: p.subject, body: p.body.trim(), batch: previewBatch,
|
|
2609
|
+
workers: names.map((name, i) => ({ name, id: previewBatch ? `${previewBatch}-${i + 1}` : "msg-<id>", harness: harnesses[i % harnesses.length] })),
|
|
2610
|
+
cwd, root: d.root, auto: p.permission === "auto" || p.permission === "full",
|
|
2611
|
+
});
|
|
2612
|
+
coordinator = {
|
|
2613
|
+
name: LEAD_NAME, action: "minted", harness: coordDriver, wouldProvision: true,
|
|
2614
|
+
promptPreview: previewCoordPrompt.slice(0, 400),
|
|
2615
|
+
};
|
|
2616
|
+
}
|
|
2617
|
+
}
|
|
2618
|
+
return { status: 200, payload: { ok: true, dryRun: true, plan: p, cwd, warnings: v.warnings, commands: rows, coordinator } };
|
|
2552
2619
|
}
|
|
2553
2620
|
const auto = p.permission === "auto" || p.permission === "full" ? true : undefined;
|
|
2554
2621
|
const at = new Date().toISOString();
|
|
@@ -2567,11 +2634,26 @@ export async function handleApiLaunch(d, body) {
|
|
|
2567
2634
|
const driver = harnesses[i % harnesses.length];
|
|
2568
2635
|
const spawnOpts = { harness: driver, cmd: body && body.cmd ? String(body.cmd) : undefined, model: p.model, auto, maxTurns: p.maxTurns, allowTools: p.allowTools, cwd, root: d.root, prompt: null };
|
|
2569
2636
|
try {
|
|
2570
|
-
const r = bootWorker(d, spawnOpts, { to, id, from, subject: p.subject, body: p.body.trim(), rev, logDir });
|
|
2637
|
+
const r = bootWorker(d, spawnOpts, { to, id, from, lead: leadTarget, subject: p.subject, body: p.body.trim(), rev, logDir });
|
|
2571
2638
|
workers.push({ name: to, pid: r.pid, replyId: id, log: r.logPath, driver });
|
|
2572
2639
|
} catch (e) {
|
|
2573
2640
|
workers.push({ name: to, replyId: id, driver, error: String((e && e.message) || e) });
|
|
2574
2641
|
}
|
|
2575
2642
|
}
|
|
2576
|
-
|
|
2643
|
+
let coordinator = undefined;
|
|
2644
|
+
if (leadMode === "board") {
|
|
2645
|
+
const coordHarness = harnesses.find((h) => h !== "generic") || "opencode";
|
|
2646
|
+
const coordSpawnOpts = { harness: coordHarness, cmd: body && body.cmd ? String(body.cmd) : undefined, model: p.model, auto, cwd, root: d.root, prompt: null };
|
|
2647
|
+
try {
|
|
2648
|
+
coordinator = provisionAutoLead(d, {
|
|
2649
|
+
spawnOpts: coordSpawnOpts,
|
|
2650
|
+
from, subject: p.subject, body: p.body.trim(), rev, logDir,
|
|
2651
|
+
workers: res.items.map((it, i) => ({ name: it.to, id: it.id, harness: harnesses[i % harnesses.length] })),
|
|
2652
|
+
batch: res.batch, auto,
|
|
2653
|
+
});
|
|
2654
|
+
} catch (e) {
|
|
2655
|
+
coordinator = { action: "skipped", reason: `coordinator boot error: ${String((e && e.message) || e)}`, leadName: LEAD_NAME };
|
|
2656
|
+
}
|
|
2657
|
+
}
|
|
2658
|
+
return { status: 200, payload: { ok: true, cwd, workers, coordinator, warnings: v.warnings } };
|
|
2577
2659
|
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# Auto-assigned Lead & Observer Lane Model
|
|
2
|
+
|
|
3
|
+
Crewbus separates **spawning** from **leading**. Instead of the interactive spawner remaining the central router for all worker communications (sub-agent hub pattern), Crewbus defaults to an autonomous **lead** lane provisioned on the board, while workers collaborate peer-to-peer.
|
|
4
|
+
|
|
5
|
+
This architecture is modeled after decentralized multi-agent coordination patterns (e.g. Minecraft multi-agent peer collaboration):
|
|
6
|
+
- **Peers** communicate directly, self-organize strategy, and write findings to shared ambient memory (the board / Workbench).
|
|
7
|
+
- An **Observer** (`lead`) monitors health, chases failures/timeouts, fail-closes approvals, and verifies claims against actual artifacts.
|
|
8
|
+
- The **Boss** sets the objective and monitors milestones asynchronously without micromanaging execution.
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## 1. The Lane Model
|
|
13
|
+
|
|
14
|
+
| Lane | Actor | Authority & Responsibilities |
|
|
15
|
+
|---|---|---|
|
|
16
|
+
| **Boss** | User / Calling Session | • Sets the objective and mission parameters.<br>• Reads progress via dashboard, status commands, or milestone DMs.<br>• Resolves out-of-scope mission changes or irreconcilable disputes.<br>• Never routes routine peer messages. |
|
|
17
|
+
| **Lead** | Autonomous Board Coordinator (`lead`) | • **Observer Role**: Environment repairs, TTL chasing, respawn health (`spawn-status --all`, `respawn`).<br>• **Approvals**: Decides on irreversible/high-risk actions (`fail-closed`).<br>• **Verification**: Audits worker claims against actual files/logs before aggregating.<br>• **Milestones**: Relays aggregate outcomes back to the boss.<br>• *Never* settles peer strategy disputes or does workers' implementation tasks. |
|
|
18
|
+
| **Peers** | Worker Agents (`sec-1`, `sec-2`, ...) | • Own task strategy, execution, and local decisions.<br>• Direct peer-to-peer DMs for targeted cooperation and rescue calls.<br>• Post lessons and artifacts directly to the board Workbench.<br>• Checkpoint progress along threads.<br>• Consult groups first; escalate to lead only for scope/approvals. |
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## 2. CLI Control: `--lead auto|board|none`
|
|
23
|
+
|
|
24
|
+
When spawning workers with `crewbus spawn`:
|
|
25
|
+
|
|
26
|
+
```sh
|
|
27
|
+
# Default: auto-assigns lead if a coding harness is present
|
|
28
|
+
crewbus spawn --from boss --count 3 --harness opencode --body "Implement feature X"
|
|
29
|
+
|
|
30
|
+
# Explicit board coordinator
|
|
31
|
+
crewbus spawn --from boss --count 3 --harness opencode --lead board --body "Implement feature X"
|
|
32
|
+
|
|
33
|
+
# Legacy star topology (replies pin directly to boss)
|
|
34
|
+
crewbus spawn --from boss --count 3 --harness generic --lead none --body "Run test suite"
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Modes:
|
|
38
|
+
- **`auto` (default)**:
|
|
39
|
+
- If any coding harness (`opencode`, `claude`, `codex`, `grok`, `antigravity`, `cursor`) is used: selects `board` mode.
|
|
40
|
+
- If all workers use `generic` harnesses (shell commands without an LLM harness): falls back to `none` mode.
|
|
41
|
+
- **`board`**:
|
|
42
|
+
- Auto-provisions or reuses the board's standing `lead` lane.
|
|
43
|
+
- Workers' brief prompts pin reply targets and approval requests to `--to lead`.
|
|
44
|
+
- Requires at least one coding harness to run the coordinator prompt; fails loudly if attempted with pure `generic` harnesses.
|
|
45
|
+
- **`none`**:
|
|
46
|
+
- Legacy star topology: replies and approvals pin directly to the spawner (`--to <from>`).
|
|
47
|
+
- No autonomous coordinator is provisioned.
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## 3. Provisioning & Collision Rules
|
|
52
|
+
|
|
53
|
+
1. **First-Claim-Wins**:
|
|
54
|
+
- On a fresh board without a `lead` agent, `provisionAutoLead` mints the `lead` identity with `role: "lead"`.
|
|
55
|
+
- The token is saved to `logs/lead.token` according to the token-file convention.
|
|
56
|
+
2. **Reuse Standing Coordinators**:
|
|
57
|
+
- If an active coordinator is already running (live PID on the `lead` lane), subsequent `spawn` bursts reuse the standing coordinator rather than duplicating it.
|
|
58
|
+
- Workers from new bursts are transferred to the lead lane (`spawnedBy: "lead"`), preserving own-crew RBAC permissions for health tracking and `spawn-kill`.
|
|
59
|
+
3. **Offboarded Safety**:
|
|
60
|
+
- If the `lead` lane has been marked `offboarded: true` (deliberate teardown), auto-provisioning is skipped with a loud warning.
|
|
61
|
+
4. **Boss Detachment**:
|
|
62
|
+
- If `from === "lead"`, auto-provisioning skips into self-bootstrap mode to prevent recursion.
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## 4. Prompt Engineering
|
|
67
|
+
|
|
68
|
+
- **Workers (`buildSpawnPrompt`)**:
|
|
69
|
+
- Directs completion summaries, checkpoints, and approval requests to `--to lead`.
|
|
70
|
+
- Informs the worker that the spawner stepped back to boss and reads progress via the lead.
|
|
71
|
+
- Reinforces peer-first habits: consult groups before escalating to the lead.
|
|
72
|
+
- **Coordinator (`buildCoordinatorPrompt`)**:
|
|
73
|
+
- Injected with the verbatim mission text from the boss.
|
|
74
|
+
- Lists worker brief IDs for easy threading and reply tracking.
|
|
75
|
+
- Enforces polling discipline (`listen` / `inbox --digest`), fail-closed approval timeouts, and maximum 2 respawn attempts per lane before escalating stalls to the boss.
|
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.10`),
|
|
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);
|
package/documentation.html
CHANGED
|
@@ -86,7 +86,7 @@ code{overflow-wrap:anywhere}pre code{overflow-wrap:normal}
|
|
|
86
86
|
<main>
|
|
87
87
|
|
|
88
88
|
<h1>crewbus</h1>
|
|
89
|
-
<p class="sub">A zero-dependency local DM bus for AI coding agents — v10.0.
|
|
89
|
+
<p class="sub">A zero-dependency local DM bus for AI coding agents — v10.0.10 · package <code>crewbus</code> · <a href="https://github.com/eamonpluto/crewbus/actions/workflows/ci.yml">CI status</a></p>
|
|
90
90
|
<p class="sub">Lead audience: developers running <strong>mixed-harness crews</strong> (opencode, Claude Code, Codex, Antigravity, grok-build, Cursor). <code>package.json</code> is the release version source of truth; <code>board.json</code>'s <code>version: 2</code> is the board <em>schema</em> version, not the release.</p>
|
|
91
91
|
|
|
92
92
|
<h2 id="what">1 · What it is</h2>
|
|
@@ -302,6 +302,7 @@ crewbus init --harness <name> --portable # portable wiring
|
|
|
302
302
|
|
|
303
303
|
<h2 id="changes">16 · Changelog</h2>
|
|
304
304
|
<ul>
|
|
305
|
+
<li><strong>10.0.10</strong> — minor release: Observer coordinator lane model (<code>boss</code> / <code>lead</code> / <code>peers</code>), auto-assigned lead (<code>--lead auto|board|none</code>), and Desktop app alignment. Full text: <code>CHANGELOG.md ## 10.0.10</code>.</li>
|
|
305
306
|
<li><strong>10.0.9</strong> — minor release: Workbench compound-memory layer — artifacts with adoption/verification and deps edges, lessons auto-injected into spawn briefs, <code>--needs-by</code> handoff deadlines + <code>inbox --overdue</code>, feed-forward gather metrics, exact-recipient pinning in briefs; opencode respawn session capture fixed (direct exe boot + <code>opencode.db</code> storage fallback, doctor drift checks). Full text: <code>CHANGELOG.md ## 10.0.9</code>.</li>
|
|
306
307
|
<li><strong>10.0.8</strong> — patch release: Launch composer UI refinements (streamlined worker naming, clearer agent count stepper, flat composer card, clean launch console) & desktop companion. Full text: <code>CHANGELOG.md ## 10.0.8</code>.</li>
|
|
307
308
|
<li><strong>10.0.7</strong> — patch release: design refresh and icon fix across desktop and mobile shells. Full text: <code>CHANGELOG.md ## 10.0.7</code>.</li>
|
|
@@ -350,7 +351,7 @@ crewbus init --harness <name> --portable # portable wiring
|
|
|
350
351
|
<h3>Mobile shell</h3>
|
|
351
352
|
<p>Expo shell, remote-only v1 (see <code>apps/mobile/README.md</code>): pairs by QR scan, walks advertised + learned routes, offers triage/approvals/launch/fleet cards with an offline outbox that only retries on explicit tap. Triage groups inbox by brief thread; the Briefs screen shows one row per fan-out with tap-for-thread; a foreground watcher raises in-app alerts for approvals and dead workers.</p>
|
|
352
353
|
|
|
353
|
-
<footer>crewbus documentation · v10.0.
|
|
354
|
+
<footer>crewbus documentation · v10.0.10 tree · zero dependencies, node ≥18 · MIT</footer>
|
|
354
355
|
|
|
355
356
|
</main>
|
|
356
357
|
</div>
|
package/index.html
CHANGED
|
@@ -114,7 +114,7 @@ details{border-top:1px solid var(--line);padding:14px 0}summary{cursor:pointer;f
|
|
|
114
114
|
|
|
115
115
|
<div class="hero" id="top" data-page="home">
|
|
116
116
|
<div>
|
|
117
|
-
<span class="pill"><i></i>v10.0.
|
|
117
|
+
<span class="pill"><i></i>v10.0.10 is out</span>
|
|
118
118
|
<h1>Let your coding agents talk to each other.</h1>
|
|
119
119
|
<p class="lede">A zero-dependency local DM bus. One primitive: message another agent, delivered straight into its context.</p>
|
|
120
120
|
<div class="cta"><a class="btn" href="#install">Get started</a><a class="btn ghost" href="https://github.com/eamonpluto/crewbus">View on GitHub</a></div>
|
|
@@ -221,10 +221,10 @@ crewbus doctor</pre>
|
|
|
221
221
|
<h2>Desktop and mobile control plane.</h2>
|
|
222
222
|
<p class="sub">Run live crews from a native app, then approve worker actions from your phone. Everything stays on your machines.</p>
|
|
223
223
|
<div class="grid" style="grid-template-columns:repeat(auto-fit,minmax(300px,1fr))">
|
|
224
|
-
<div class="card"><h3>CrewBus Desktop <span class="tag">v0.1.
|
|
224
|
+
<div class="card"><h3>CrewBus Desktop <span class="tag">v0.1.23</span></h3><p>A native GUI built on Tauri v2. It supervises an isolated sidecar on <code>127.0.0.1</code>, with zero cloud dependency.</p>
|
|
225
225
|
<ul><li>Sidecar supervisor with auto-restart and port recovery</li><li>Fleet inspector: terminate workers live, with an Undo toast</li><li>Multi-harness launcher with a context-sensitive model selector</li><li>Briefs view: one row per fan-out with gathered threads; data-age + STALE banner</li><li>One-click QR code to pair the mobile companion</li></ul>
|
|
226
|
-
<div class="dl"><a class="btn" href="https://github.com/eamonpluto/crewbus/releases/download/desktop-v0.1.
|
|
227
|
-
<a href="https://github.com/eamonpluto/crewbus/releases/tag/desktop-v0.1.
|
|
226
|
+
<div class="dl"><a class="btn" href="https://github.com/eamonpluto/crewbus/releases/download/desktop-v0.1.23/CrewBus_0.1.23_x64-setup.exe">Windows</a><a class="btn" href="https://github.com/eamonpluto/crewbus/releases/download/desktop-v0.1.23/CrewBus_0.1.23_aarch64.dmg">macOS (Apple silicon)</a><a class="btn" href="https://github.com/eamonpluto/crewbus/releases/download/desktop-v0.1.23/CrewBus_0.1.23_amd64.AppImage">Linux</a></div>
|
|
227
|
+
<a href="https://github.com/eamonpluto/crewbus/releases/tag/desktop-v0.1.23">All release assets (.msi, .deb, .rpm)</a></div>
|
|
228
228
|
<div class="card"><h3>CrewBus Mobile <span class="tag t">preview</span></h3><p>A companion built on React Native and Expo. Pair with your desktop or relay by scanning a QR code, without exposing root credentials.</p>
|
|
229
229
|
<ul><li>Per-device credentials with narrow scopes</li><li>Approve or deny worker shell calls from anywhere</li><li>Briefs screen: one row per fan-out, tap for its thread; triage grouped by brief</li><li>Foreground watcher: approvals and dead workers raise an in-app alert + buzz</li><li>Offline outbox: queued actions retry when you tap</li><li>Launch card with dynamic model selection</li></ul>
|
|
230
230
|
<div class="dl"><a class="btn" href="https://expo.dev/artifacts/eas/clk0vyzypxygmxamqdpzhiib_2gggfvzsu053id9spg.apk">Android APK</a><a class="btn ghost" href="https://expo.dev/accounts/eamonpluto/projects/crewbus-mobile/builds/885a36dc-1689-4345-9274-6e31318b760f">EAS build</a></div>
|
|
@@ -267,7 +267,7 @@ POST /api/launch</pre>
|
|
|
267
267
|
<div id="faq"></div>
|
|
268
268
|
</div></section>
|
|
269
269
|
|
|
270
|
-
<div class="w"><footer><span>crewbus v10.0.
|
|
270
|
+
<div class="w"><footer><span>crewbus v10.0.10 · zero-dependency local DM bus</span><span><a href="https://github.com/eamonpluto/crewbus">GitHub</a></span></footer></div>
|
|
271
271
|
|
|
272
272
|
<script>
|
|
273
273
|
(function(){
|
|
@@ -309,7 +309,7 @@ cards('uses',[['Researchers','Parameter sweeps, parallel proof attempts where th
|
|
|
309
309
|
var C='init|Plants the board, writes agent instructions, installs harness wiring.|init --harness opencode;update|Self-update the global npm install to the registry latest.|update --check;register|First claim mints your token; later calls prove it.|register --from lead;token|Rotate, expire and inspect identity tokens.|token rotate --from lead;agents|Who exists and who is actually alive.|agents --active;send|The primitive: mission, scope and done-criteria in one DM.|send --to bob --body "…";inbox|Your mail, with no mark-read side effects.|inbox --unacked;listen|Block and print new arrivals, locally or via relay.|listen --timeout 60000;thread|One brief plus every reply, across inboxes.|thread --id msg-…;channel|Append-only public logs: post, tail, search, summarize.|channel tail findings;group|Named recipient sets for variant briefs.|group create team-a;gather|Reduce a batch to one transcript.|gather --batch …;ack|Accept a reply, optionally gated on a checker.|ack --verify "npm test";result|Keep verified-only group outcomes.|result record --group …;race|First verified result wins; losers stand down.|race close --kill;artifact|Publish, adopt and verify board artifacts so output compounds.|artifact list;lesson|Scoped one-liners auto-injected into later spawn briefs.|lesson post --scope … --text "…"spawn|Brief workers and boot them detached.|spawn --count 8;spawn-status|Running? Replied? Acked?|spawn-status --all;spawn-kill|Terminate workers by recorded pid.|spawn-kill --to w1;pool|Boot at most S of N at once, auto-replace exits.|pool --count 20;stop|The global kill switch.|stop --all;serve|Relay: sync, remote crews, health checks.|serve --port 8471;sync|Peer-to-peer board merge.|sync --with …;web|Fleet console on localhost.|web --port 0;doctor|Validate wiring and diagnose split boards.|doctor;prune|Retention windows for old mail and logs.|prune --dry-run';
|
|
310
310
|
$('cmds').innerHTML=tbl(['Command','What it does','Try first'],C.split(';').map(function(r){var p=r.split('|');return ['<code>'+p[0]+'</code>',p[1],'<code>'+p[2]+'</code>']}));
|
|
311
311
|
$('docs').innerHTML='QUICKSTART TROUBLESHOOTING WHEN_NOT COMPATIBILITY DELIVERY GROUPS VERIFIER CONSOLIDATOR LIMITS THREAT_MODEL ISOLATION STORAGE EXPERIMENTS IDENTITY RBAC OIDC_TLS AUDIT_EXPORT TENANCY HA SHARED_RESPONSIBILITY CERT_READINESS PAIRING CREWS SPLIT'.split(' ').map(function(d){return '<a href="https://github.com/eamonpluto/crewbus/blob/master/docs/'+d+'.md">'+d.toLowerCase()+'</a>'}).join('');
|
|
312
|
-
var R=[['10.0.9','2026-10-17','Workbench compound-memory layer: artifacts with adoption/verification and depends-on edges, lessons auto-injected into spawn briefs, needs-by handoff deadlines with inbox --overdue, feed-forward gather metrics; opencode respawn session capture fixed (direct exe boot + SQLite storage fallback).'],['10.0.8','2026-10-16','Launch composer UI refinements: streamlined agent naming, clearer count stepper, flat panel styling, and clean console.'],['10.0.7','2026-10-14','Design refresh and icon fixes across desktop and mobile shells.'],['10.0.6','2026-10-13','Dashboard client hotfix: a template-literal escape killed the whole script block at parse time — fixed, with a regression test that syntax-checks the served page.'],['10.0.5','2026-10-12','Self-update command: crewbus update [--check] [--yes] [--version x.y.z] via your own npm config.'],['10.0.4','2026-10-12','Dashboard Briefs view + gather endpoint, task-scoped spawn rosters, mobile brief/thread/watcher screens.'],['10.0.3','2026-10-10','Worker-record integrity (canonical doc merge), truthful presence, Crew roster block in spawn briefs, doctor dead-man scan.'],['10.0.2','2026-10-09','Target workspace selector and persistence in Launch Studio, clearer project popover, directory picker replaces the upload prompt, desktop companion v0.1.16.'],['10.0.1','2026-10-09','Windows opencode detection fix, model selector sync that blocks incompatible pairings, refreshed model catalog with live discovery.'],['10.0.0','2026-10-08','Multi-harness orchestration (--harness claude,antigravity), canonical model selector, native desktop app, mobile companion with QR pairing, full control plane.'],['7.0.0','2026-10-05','Renamed to crewbus. Human-in-the-loop approvals, long-run resilience, respawn, checkpoints and pool-resume.'],['6.0.0','2026-10-03','Fleet hardening: capability negotiation, credential scrub for workers, per-device pairing, weighted multi-relay crews.'],['5.0.0','2026-10-03','Enterprise tier: RBAC, OIDC, TLS, audit export, legal holds, encrypted backups, quotas, standby relays.'],['3.0.0','2026-09-24','Token-bound identity, presence, pruning, detached spawn, ack and threading, local dashboard.'],['2.0.0','earlier','The DM-only rewrite: one primitive, message another agent, plus the opencode push layer.']];
|
|
312
|
+
var R=[['10.0.10','2026-10-18','Observer coordinator lane model (boss / lead / peers), auto-assigned lead (--lead auto|board|none), and Desktop app alignment.'],['10.0.9','2026-10-17','Workbench compound-memory layer: artifacts with adoption/verification and depends-on edges, lessons auto-injected into spawn briefs, needs-by handoff deadlines with inbox --overdue, feed-forward gather metrics; opencode respawn session capture fixed (direct exe boot + SQLite storage fallback).'],['10.0.8','2026-10-16','Launch composer UI refinements: streamlined agent naming, clearer count stepper, flat panel styling, and clean console.'],['10.0.7','2026-10-14','Design refresh and icon fixes across desktop and mobile shells.'],['10.0.6','2026-10-13','Dashboard client hotfix: a template-literal escape killed the whole script block at parse time — fixed, with a regression test that syntax-checks the served page.'],['10.0.5','2026-10-12','Self-update command: crewbus update [--check] [--yes] [--version x.y.z] via your own npm config.'],['10.0.4','2026-10-12','Dashboard Briefs view + gather endpoint, task-scoped spawn rosters, mobile brief/thread/watcher screens.'],['10.0.3','2026-10-10','Worker-record integrity (canonical doc merge), truthful presence, Crew roster block in spawn briefs, doctor dead-man scan.'],['10.0.2','2026-10-09','Target workspace selector and persistence in Launch Studio, clearer project popover, directory picker replaces the upload prompt, desktop companion v0.1.16.'],['10.0.1','2026-10-09','Windows opencode detection fix, model selector sync that blocks incompatible pairings, refreshed model catalog with live discovery.'],['10.0.0','2026-10-08','Multi-harness orchestration (--harness claude,antigravity), canonical model selector, native desktop app, mobile companion with QR pairing, full control plane.'],['7.0.0','2026-10-05','Renamed to crewbus. Human-in-the-loop approvals, long-run resilience, respawn, checkpoints and pool-resume.'],['6.0.0','2026-10-03','Fleet hardening: capability negotiation, credential scrub for workers, per-device pairing, weighted multi-relay crews.'],['5.0.0','2026-10-03','Enterprise tier: RBAC, OIDC, TLS, audit export, legal holds, encrypted backups, quotas, standby relays.'],['3.0.0','2026-09-24','Token-bound identity, presence, pruning, detached spawn, ack and threading, local dashboard.'],['2.0.0','earlier','The DM-only rewrite: one primitive, message another agent, plus the opencode push layer.']];
|
|
313
313
|
$('rel').innerHTML=R.map(function(r){return '<div><b>'+r[0]+'</b><span class="mono">'+r[1]+'</span><p>'+r[2]+'</p></div>'}).join('');
|
|
314
314
|
var F=[['Is this just chat for robots?','No. The DM is the task object: a brief carries mission, scope and definition of done, replies thread back, and acks close the loop.'],['Can it run 10,000 agents at once?','10,000 is a broadcast limit: one brief reaches ten thousand inboxes. Live workers are whole harness processes, so size them like compute.'],['What stops an agent going rogue?','Token-bound identity with roles, relay auth with opt-in remote boot, untrusted-peer envelopes, loop and cost guards, budgets, dead-man timeouts and a global stop.'],['Does it phone home?','No. There are no accounts, no telemetry and no update checks. Boards sync only with peers you name.'],['What happens when a worker dies mid-brief?','The brief survives because it is a file, not a process. respawn reboots the worker with a catch-up brief, and pools replace exits automatically.'],['How are results verified?','ack --verify runs your tests or a checker. Only exit 0 records a verified result with its output.'],['When should I not use it?','Single-session work (use subagents), strict ordered pipelines (use a queue), and anything needing real-time guarantees, since the bus is files on disk.'],['Which Node versions work?','Node 18 and newer on Linux, macOS and Windows.'],['Who pays for the tokens agents burn?','Your model provider does. The bus itself costs nothing to run.']];
|
|
315
315
|
$('faq').innerHTML=F.map(function(f){return '<details><summary>'+f[0]+'</summary><p>'+f[1]+'</p></details>'}).join('');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "crewbus",
|
|
3
|
-
"version": "10.0.
|
|
3
|
+
"version": "10.0.10",
|
|
4
4
|
"description": "Zero-dependency message bus for AI coding-agent crews: message another agent, inserted into context, just a tool call.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"crewbus-hook": "bin/crewbus-hook.js"
|
|
10
10
|
},
|
|
11
11
|
"scripts": {
|
|
12
|
-
"test": "node test/crewbus.smoke.mjs && node test/crewbus.harness.mjs && node test/crewbus.opencode-respawn.mjs && node test/crewbus.compact.mjs && node test/crewbus.tokenfile.mjs && node test/crewbus.digest.mjs && node test/crewbus.workbench.mjs && node test/crewbus.control-plane.mjs && node test/crewbus.launch.mjs && node test/crewbus.web-launch.mjs && node test/crewbus.pair-api.mjs && node test/crewbus.web-panel.mjs && node test/crewbus.web-approot.mjs && node test/crewbus.client-runtime.mjs && node test/crewbus.runtime-wiring.mjs && node test/crewbus.desktop-sidecar.mjs && node test/crewbus.mobile-client.mjs && node test/crewbus.grok-hooks.mjs && node test/crewbus.holds-quotas.mjs && node test/crewbus.approval-protocol.mjs && node test/crewbus.approvals-init.mjs && node test/crewbus.approvals-web.mjs && node test/fault-injection.mjs && node test/integration.mjs",
|
|
12
|
+
"test": "node test/crewbus.smoke.mjs && node test/crewbus.harness.mjs && node test/crewbus.lead-assign.mjs && node test/crewbus.opencode-respawn.mjs && node test/crewbus.compact.mjs && node test/crewbus.tokenfile.mjs && node test/crewbus.digest.mjs && node test/crewbus.workbench.mjs && node test/crewbus.control-plane.mjs && node test/crewbus.launch.mjs && node test/crewbus.web-launch.mjs && node test/crewbus.pair-api.mjs && node test/crewbus.web-panel.mjs && node test/crewbus.web-approot.mjs && node test/crewbus.client-runtime.mjs && node test/crewbus.runtime-wiring.mjs && node test/crewbus.desktop-sidecar.mjs && node test/crewbus.mobile-client.mjs && node test/crewbus.grok-hooks.mjs && node test/crewbus.holds-quotas.mjs && node test/crewbus.approval-protocol.mjs && node test/crewbus.approvals-init.mjs && node test/crewbus.approvals-web.mjs && node test/fault-injection.mjs && node test/integration.mjs",
|
|
13
13
|
"bench": "node test/bench.mjs",
|
|
14
14
|
"bench:load": "node test/load.mjs",
|
|
15
15
|
"vendor": "node scripts/vendor-runtime.mjs"
|
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
"note": "Same validation as CLI launch wizard. Thin over bootWorker (local) or remoteSpawn (per relay). dryRun previews exact commands without booting.",
|
|
7
7
|
"request": {
|
|
8
8
|
"required": ["harness", "body"],
|
|
9
|
-
"optional": ["board", "count", "prefix", "to", "subject", "priority", "model", "maxTurns", "allowTools", "permission", "isolate", "worktree", "branch", "lifetime", "budgetTokens", "budgetMinutes", "timeout", "target", "dryRun"],
|
|
10
|
-
"defaults": { "count": 1, "permission": "supervised", "lifetime": "oneshot", "target": "local", "dryRun": false },
|
|
9
|
+
"optional": ["board", "count", "prefix", "to", "subject", "priority", "model", "maxTurns", "allowTools", "permission", "isolate", "worktree", "branch", "lifetime", "budgetTokens", "budgetMinutes", "timeout", "target", "dryRun", "lead"],
|
|
10
|
+
"defaults": { "count": 1, "permission": "supervised", "lifetime": "oneshot", "target": "local", "dryRun": false, "lead": "auto" },
|
|
11
11
|
"constraints": {
|
|
12
12
|
"harness": "one of harness.json drivers",
|
|
13
13
|
"body": "max 8000 chars (MAX_BODY_CHARS)",
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
"permission": "supervised|autoEdits|auto|full",
|
|
16
16
|
"lifetime": "oneshot|persistent",
|
|
17
17
|
"priority": "high|normal",
|
|
18
|
+
"lead": "auto|board|none",
|
|
18
19
|
"target": "local | {relays:[{url,weight}]}"
|
|
19
20
|
},
|
|
20
21
|
"permissionMapping": {
|
|
@@ -26,7 +27,7 @@
|
|
|
26
27
|
},
|
|
27
28
|
"response": {
|
|
28
29
|
"required": ["crewId", "batch", "workers"],
|
|
29
|
-
"optional": ["warnings"],
|
|
30
|
+
"optional": ["warnings", "coordinator"],
|
|
30
31
|
"worker": ["name", "pid?", "replyId", "relay?"]
|
|
31
32
|
}
|
|
32
33
|
}
|