crewbus 10.0.12 → 11.3.1
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/AGENTS.template.md +4 -4
- package/CHANGELOG.md +153 -0
- package/README.md +69 -44
- package/TEAM.template.md +1 -1
- package/bin/crewbus-hook.js +22 -5
- package/bin/crewbus-mcp.js +56 -48
- package/bin/crewbus.js +459 -238
- package/bin/lib/channels.js +1 -1
- package/bin/lib/export.js +1 -1
- package/bin/lib/groups.js +1 -5
- package/bin/lib/identity.js +90 -128
- package/bin/lib/launch.js +63 -8
- package/bin/lib/relay.js +25 -42
- package/bin/lib/spawn.js +155 -162
- package/bin/lib/store.js +2 -2
- package/bin/lib/web.js +241 -60
- package/claude-plugin/skills/crewbus/SKILL.md +1 -1
- package/docs/APPROVALS.md +8 -8
- package/docs/AUDIT_EXPORT.md +7 -7
- package/docs/CERT_READINESS.md +5 -5
- package/docs/COMPATIBILITY.md +6 -2
- package/docs/CONSOLIDATOR.md +6 -6
- package/docs/CONTROL_PLANE_SPEC.md +3 -3
- package/docs/CREWS.md +58 -55
- package/docs/DELIVERY.md +11 -8
- package/docs/GROUPS.md +8 -8
- package/docs/IDENTITY.md +6 -6
- package/docs/LONG_RUNS.md +3 -3
- package/docs/ORCHESTRATOR.md +87 -0
- package/docs/PAIRING.md +7 -7
- package/docs/QUICKSTART.md +81 -70
- package/docs/RBAC.md +84 -73
- package/docs/TENANCY.md +10 -10
- package/docs/THREAT_MODEL.md +3 -3
- package/docs/VERIFIER.md +10 -10
- package/docs/VERSION_SKEW.md +1 -1
- package/documentation.html +34 -24
- package/examples/hermes-pairing.md +3 -3
- package/examples/t3-pairing.md +1 -1
- package/index.html +6 -6
- package/opencode/plugins/dm-watch.js +1 -1
- package/opencode/tools/dm-send.js +1 -1
- package/package.json +27 -2
- package/packages/contracts/harness.json +15 -1
- package/packages/contracts/launch.json +2 -3
- package/packages/contracts/pairing.json +3 -3
- package/docs/LEAD_ASSIGN.md +0 -74
- package/docs/M1_CLI_DRAFT.md +0 -175
package/bin/crewbus-mcp.js
CHANGED
|
@@ -33,7 +33,17 @@ import { execFileSync } from "node:child_process";
|
|
|
33
33
|
const MAX_BODY_CHARS = 8000;
|
|
34
34
|
const MAX_RECIPIENTS = 10000;
|
|
35
35
|
const BROADCAST_AFTER = 20;
|
|
36
|
-
|
|
36
|
+
|
|
37
|
+
function packageVersion() {
|
|
38
|
+
try {
|
|
39
|
+
const pkg = JSON.parse(fs.readFileSync(new URL("../package.json", import.meta.url), "utf8"));
|
|
40
|
+
return typeof pkg.version === "string" ? pkg.version : "unknown";
|
|
41
|
+
} catch {
|
|
42
|
+
return "unknown";
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const SERVER_VERSION = packageVersion();
|
|
37
47
|
const KNOWN_PROTOCOL_VERSIONS = new Set(["2024-11-05", "2025-03-26", "2025-06-18"]);
|
|
38
48
|
|
|
39
49
|
// ---------------------------------------------------------------------------
|
|
@@ -679,25 +689,20 @@ function ensureSender(d, agent, token) {
|
|
|
679
689
|
// Mirrors the CLI matrix in bin/crewbus.js (authorizeCheck): call
|
|
680
690
|
// authorizeMcp() AFTER checkToken()/ensureSender() passes — never before,
|
|
681
691
|
// never instead. Do not merge into checkToken.
|
|
682
|
-
// Roles: {
|
|
683
|
-
//
|
|
684
|
-
//
|
|
685
|
-
//
|
|
686
|
-
//
|
|
687
|
-
// lead: send / spawn / respawn / group manage / channel post / result /
|
|
688
|
-
// race / lock / inbox / ack / redeliver + all reads.
|
|
689
|
-
// worker: send / inbox / ack / redeliver / lock (scoped) + all reads.
|
|
690
|
-
// auditor: read-only everything (inbox / gather / thread / channel tail);
|
|
691
|
-
// zero writes.
|
|
692
|
+
// Roles: {orchestrator, worker}.
|
|
693
|
+
// orchestrator: the board's single control-plane identity (all actions).
|
|
694
|
+
// worker: send / inbox / ack / redeliver / lock, artifacts, lessons,
|
|
695
|
+
// member-scoped channel posts.
|
|
696
|
+
// Records with any other/missing role are treated as workers.
|
|
692
697
|
// ---------------------------------------------------------------------------
|
|
693
698
|
|
|
694
|
-
const VALID_ROLES_MCP = ["
|
|
699
|
+
const VALID_ROLES_MCP = ["orchestrator", "worker"];
|
|
695
700
|
|
|
696
701
|
function roleOfRecordMcp(rec) {
|
|
697
702
|
if (rec && typeof rec.role === "string" && VALID_ROLES_MCP.includes(String(rec.role).toLowerCase())) {
|
|
698
703
|
return String(rec.role).toLowerCase();
|
|
699
704
|
}
|
|
700
|
-
return "
|
|
705
|
+
return "worker";
|
|
701
706
|
}
|
|
702
707
|
|
|
703
708
|
function getRoleMcp(d, agent) {
|
|
@@ -720,10 +725,7 @@ function readBoardAclMcp(d) {
|
|
|
720
725
|
meta = null;
|
|
721
726
|
}
|
|
722
727
|
const acl = (meta && typeof meta.acl === "object" && meta.acl) || {};
|
|
723
|
-
|
|
724
|
-
? String(acl.defaultRole).toLowerCase()
|
|
725
|
-
: "worker";
|
|
726
|
-
return { defaultRole: def, frozen: acl.frozen === true };
|
|
728
|
+
return { defaultRole: "worker", frozen: acl.frozen === true };
|
|
727
729
|
}
|
|
728
730
|
|
|
729
731
|
function isBoardFrozenMcp(d) {
|
|
@@ -731,7 +733,7 @@ function isBoardFrozenMcp(d) {
|
|
|
731
733
|
}
|
|
732
734
|
|
|
733
735
|
function defaultRoleForNewMcp(d) {
|
|
734
|
-
return
|
|
736
|
+
return "worker";
|
|
735
737
|
}
|
|
736
738
|
|
|
737
739
|
function readGroupMcp(d, name) {
|
|
@@ -747,40 +749,30 @@ function readGroupMcp(d, name) {
|
|
|
747
749
|
// Core RBAC decision (throwing twin: denials throw, handlers surface them as
|
|
748
750
|
// tool errors). Restricted-group scope is checked here too when
|
|
749
751
|
// scope.toGroups is present.
|
|
752
|
+
const WORKER_ACTIONS_MCP = new Set([
|
|
753
|
+
"send", "inbox", "ack", "redeliver", "lock", "artifact-write", "lesson-write", "hold-status",
|
|
754
|
+
]);
|
|
755
|
+
|
|
750
756
|
function authorizeMcp(d, agent, action, scope) {
|
|
751
757
|
const role = getRoleMcp(d, agent);
|
|
752
758
|
const act = String(action || "");
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
if (ADMIN_ONLY.has(act)) throw new Error(`role "${role}" cannot ${act} (need admin)`);
|
|
758
|
-
if (LEAD_PLUS.has(act) && role !== "lead") throw new Error(`role "${role}" cannot ${act} (need lead|admin)`);
|
|
759
|
-
if (act === "spawn-kill" && role !== "lead") throw new Error(`role "${role}" cannot spawn-kill (need lead|admin)`);
|
|
760
|
-
if (act === "channel-post" && role !== "lead") {
|
|
761
|
-
// Member-scoped channel posting (C4): members post to their group's
|
|
762
|
-
// channel; board channels + foreign groups stay lead|admin.
|
|
759
|
+
if (role === "orchestrator") {
|
|
760
|
+
// Full control plane.
|
|
761
|
+
} else if (role === "worker") {
|
|
762
|
+
if (act === "channel-post") {
|
|
763
763
|
const targetGroup = scope && scope.channelGroup ? String(scope.channelGroup) : undefined;
|
|
764
764
|
if (!targetGroup) {
|
|
765
|
-
throw new Error(`role "
|
|
765
|
+
throw new Error(`role "worker" may post only to a group channel it belongs to (board channels are orchestrator-only)`);
|
|
766
766
|
}
|
|
767
767
|
const gdoc = readGroupMcp(d, targetGroup);
|
|
768
|
-
if (!gdoc) throw new Error(`channel group "${targetGroup}" not found (
|
|
768
|
+
if (!gdoc) throw new Error(`channel group "${targetGroup}" not found (board channels are orchestrator-only)`);
|
|
769
769
|
const members = Array.isArray(gdoc.members) ? gdoc.members : [];
|
|
770
|
-
if (!members.includes(agent)) throw new Error(`group channel "${targetGroup}" — members only
|
|
771
|
-
}
|
|
772
|
-
|
|
773
|
-
throw new Error(`role "${role}" cannot ${act} (auditor is read-only)`);
|
|
774
|
-
}
|
|
775
|
-
}
|
|
776
|
-
if (act === "spawn-kill" && role === "lead") {
|
|
777
|
-
const targets = (scope && Array.isArray(scope.targets)) ? scope.targets : [];
|
|
778
|
-
for (const t of targets) {
|
|
779
|
-
const rec = readAgent(d, t);
|
|
780
|
-
if (rec && rec.spawnedBy && rec.spawnedBy !== agent) {
|
|
781
|
-
throw new Error(`lead "${agent}" cannot kill "${t}" (spawned by ${rec.spawnedBy}; own crew only)`);
|
|
782
|
-
}
|
|
770
|
+
if (!members.includes(agent)) throw new Error(`group channel "${targetGroup}" — members only`);
|
|
771
|
+
} else if (!WORKER_ACTIONS_MCP.has(act)) {
|
|
772
|
+
throw new Error(`role "worker" cannot ${act} (orchestrator only)`);
|
|
783
773
|
}
|
|
774
|
+
} else {
|
|
775
|
+
throw new Error(`unknown role "${role}" (want orchestrator|worker)`);
|
|
784
776
|
}
|
|
785
777
|
const toGroups = (scope && Array.isArray(scope.toGroups)) ? scope.toGroups : [];
|
|
786
778
|
if ((act === "send" || act === "spawn" || act === "pool") && toGroups.length > 0) {
|
|
@@ -788,8 +780,8 @@ function authorizeMcp(d, agent, action, scope) {
|
|
|
788
780
|
const doc = readGroupMcp(d, g);
|
|
789
781
|
if (doc && doc.restricted === true) {
|
|
790
782
|
const members = Array.isArray(doc.members) ? doc.members : [];
|
|
791
|
-
if (role !== "
|
|
792
|
-
throw new Error(`group "${g}" is restricted (member or
|
|
783
|
+
if (role !== "orchestrator" && !members.includes(agent)) {
|
|
784
|
+
throw new Error(`group "${g}" is restricted (member or orchestrator only)`);
|
|
793
785
|
}
|
|
794
786
|
}
|
|
795
787
|
}
|
|
@@ -1156,7 +1148,7 @@ function callTool(name, args) {
|
|
|
1156
1148
|
const d = requireBoard(root);
|
|
1157
1149
|
const agent = cleanName(a.agent, "agent");
|
|
1158
1150
|
checkToken(d, agent, resolveToken(a));
|
|
1159
|
-
authorizeMcp(d, agent, "ack");
|
|
1151
|
+
authorizeMcp(d, agent, "ack");
|
|
1160
1152
|
touchAgent(d, agent);
|
|
1161
1153
|
const id = a.id === undefined || a.id === null || String(a.id) === "" ? undefined : String(a.id);
|
|
1162
1154
|
const all = a.all === true;
|
|
@@ -1296,10 +1288,10 @@ function callTool(name, args) {
|
|
|
1296
1288
|
prev.tokenHash = hashTokenMcp(String(token), salt);
|
|
1297
1289
|
prev.salt = salt;
|
|
1298
1290
|
delete prev.token;
|
|
1299
|
-
if (!prev.role) prev.role = "
|
|
1291
|
+
if (!prev.role) prev.role = "worker"; // default role for legacy records
|
|
1300
1292
|
writeAgentHashed(path.join(d.agents, `${agent}.json`), prev);
|
|
1301
1293
|
} else if (!prev.role) {
|
|
1302
|
-
prev.role = "
|
|
1294
|
+
prev.role = "worker"; // default role for legacy records
|
|
1303
1295
|
writeAgentHashed(path.join(d.agents, `${agent}.json`), prev);
|
|
1304
1296
|
}
|
|
1305
1297
|
touchAgent(d, agent, session || undefined);
|
|
@@ -1418,6 +1410,22 @@ function handleMessage(msg) {
|
|
|
1418
1410
|
}
|
|
1419
1411
|
}
|
|
1420
1412
|
|
|
1413
|
+
const argv = process.argv.slice(2);
|
|
1414
|
+
if (argv.includes("--help") || argv.includes("-h")) {
|
|
1415
|
+
console.log(`crewbus-mcp ${SERVER_VERSION} — zero-dependency stdio MCP server for crewbus
|
|
1416
|
+
|
|
1417
|
+
Usage:
|
|
1418
|
+
node bin/crewbus-mcp.js [--version] [--help]
|
|
1419
|
+
|
|
1420
|
+
The server speaks newline-delimited JSON-RPC on stdio (MCP). Board resolution:
|
|
1421
|
+
CREWBUS_DIR wins, else <cwd>/.crewbus (walking up).`);
|
|
1422
|
+
process.exit(0);
|
|
1423
|
+
}
|
|
1424
|
+
if (argv.includes("--version") || argv.includes("-v") || argv.includes("-V")) {
|
|
1425
|
+
console.log(`crewbus-mcp ${SERVER_VERSION}`);
|
|
1426
|
+
process.exit(0);
|
|
1427
|
+
}
|
|
1428
|
+
|
|
1421
1429
|
const rl = readline.createInterface({ input: process.stdin, terminal: false });
|
|
1422
1430
|
rl.on("line", (line) => {
|
|
1423
1431
|
if (!line.trim()) return;
|