crewbus 10.0.11 → 11.3.0
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 +151 -0
- package/README.md +713 -706
- package/TEAM.template.md +1 -1
- package/bin/crewbus-hook.js +22 -5
- package/bin/crewbus-mcp.js +56 -48
- package/bin/crewbus.js +486 -355
- 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 +92 -152
- package/bin/lib/launch.js +128 -30
- package/bin/lib/qrcode.js +2971 -0
- package/bin/lib/relay.js +26 -54
- package/bin/lib/spawn.js +241 -194
- package/bin/lib/store.js +2 -2
- package/bin/lib/web.js +277 -59
- 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 +120 -120
- package/docs/COMPATIBILITY.md +196 -194
- package/docs/CONSOLIDATOR.md +6 -6
- package/docs/CONTROL_PLANE_SPEC.md +12 -14
- package/docs/CREWS.md +16 -13
- package/docs/DELIVERY.md +213 -210
- package/docs/GROUPS.md +8 -8
- package/docs/HA.md +151 -151
- package/docs/IDENTITY.md +6 -6
- package/docs/LEAD_ASSIGN.md +3 -85
- package/docs/LONG_RUNS.md +3 -3
- package/docs/M1_CLI_DRAFT.md +9 -9
- package/docs/ORCHESTRATOR.md +87 -0
- package/docs/PAIRING.md +7 -7
- package/docs/QUICKSTART.md +24 -13
- package/docs/RBAC.md +84 -73
- package/docs/SPLIT.md +82 -82
- package/docs/TENANCY.md +10 -10
- package/docs/THREAT_MODEL.md +68 -69
- package/docs/VERIFIER.md +10 -10
- package/docs/VERSION_SKEW.md +57 -57
- package/documentation.html +37 -29
- package/examples/hermes-pairing.md +3 -3
- package/examples/t3-pairing.md +1 -1
- package/index.html +13 -14
- package/opencode/plugins/dm-watch.js +1 -1
- package/opencode/tools/dm-send.js +4 -13
- package/package.json +75 -50
- package/packages/client-runtime/README.md +40 -40
- package/packages/contracts/harness.json +108 -111
- package/packages/contracts/launch.json +2 -3
- package/packages/contracts/pairing.json +3 -3
- package/docs/DESKTOP_SPIKE.md +0 -223
package/bin/lib/relay.js
CHANGED
|
@@ -40,9 +40,9 @@ import crypto from "node:crypto";
|
|
|
40
40
|
import http from "node:http";
|
|
41
41
|
import https from "node:https";
|
|
42
42
|
import { readJson, writeJson, listJson, getFlag, cleanWebName, gitRevForBoard, MAX_BODY_CHARS, MAX_FWD_DEPTH, webErr } from "./store.js";
|
|
43
|
-
import { readAgent, agentTokenMatches, mintToken, newSalt, hashToken, timingSafeEqualStr, writeAgentFile, isBoardFrozen, defaultRoleForNew, authorizeThrow, authorizeCheck, touchAgent } from "./identity.js";
|
|
43
|
+
import { readAgent, agentTokenMatches, mintToken, newSalt, hashToken, timingSafeEqualStr, writeAgentFile, isBoardFrozen, defaultRoleForNew, authorizeThrow, authorizeCheck, touchAgent, ensureOrchestrator, ORCHESTRATOR_NAME } from "./identity.js";
|
|
44
44
|
import { httpJson } from "./sync.js";
|
|
45
|
-
import { killWorkers, pidAlive, bootWorker, parseAllowEnv, isPidStale } from "./spawn.js";
|
|
45
|
+
import { killWorkers, pidAlive, bootWorker, parseAllowEnv, isPidStale, parseModelList, modelForIndex, modelListErrors } from "./spawn.js";
|
|
46
46
|
import { expandGroups, heuristicSenderType } from "./groups.js";
|
|
47
47
|
import { deliverDMs, findMessageById } from "./mail.js";
|
|
48
48
|
import { appendChainRecord } from "./export.js";
|
|
@@ -133,10 +133,12 @@ export async function remoteSpawn(d, a, serveOpts) { // line 6770
|
|
|
133
133
|
return s !== undefined && s.trim() !== "" ? s : undefined;
|
|
134
134
|
};
|
|
135
135
|
const rawFrom = cleanStr(a.from);
|
|
136
|
-
if (!rawFrom || !rawFrom.trim()) throw webErr(400, "missing from (
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
136
|
+
if (!rawFrom || !rawFrom.trim()) throw webErr(400, "missing from (requester name)");
|
|
137
|
+
// Remote control-plane actions run as the relay board's single orchestrator.
|
|
138
|
+
// The relay secret (or a device credential with launch:spawn) is the auth
|
|
139
|
+
// boundary; `from` is kept only as audit metadata by the route.
|
|
140
|
+
ensureOrchestrator(d);
|
|
141
|
+
const from = ORCHESTRATOR_NAME;
|
|
140
142
|
// Recipients: to (string|array) + to_group + count/prefix, same as CLI.
|
|
141
143
|
const toParts = [];
|
|
142
144
|
if (a.to !== undefined && a.to !== null) {
|
|
@@ -198,7 +200,7 @@ export async function remoteSpawn(d, a, serveOpts) { // line 6770
|
|
|
198
200
|
return s;
|
|
199
201
|
}).filter(Boolean);
|
|
200
202
|
if (harnesses.length === 0) harnesses.push("opencode");
|
|
201
|
-
const validHarnesses = ["opencode", "claude", "codex", "grok", "antigravity", "cursor", "
|
|
203
|
+
const validHarnesses = ["opencode", "claude", "codex", "grok", "antigravity", "cursor", "qwen"];
|
|
202
204
|
for (const h of harnesses) {
|
|
203
205
|
if (!validHarnesses.includes(h)) {
|
|
204
206
|
throw webErr(400, `unknown harness "${h}" (want ${validHarnesses.join("|")})`);
|
|
@@ -206,10 +208,9 @@ export async function remoteSpawn(d, a, serveOpts) { // line 6770
|
|
|
206
208
|
}
|
|
207
209
|
let harness = harnesses.join(",");
|
|
208
210
|
const cmd = cleanOpt(a.cmd);
|
|
209
|
-
|
|
210
|
-
const maxTurns = a.maxTurns === undefined || a.maxTurns === null || String(a.maxTurns).trim() === "" ? ((harness === "claude" || harness === "grok") ? 50 : undefined) : Number(a.maxTurns);
|
|
211
|
+
const maxTurns = a.maxTurns === undefined || a.maxTurns === null || String(a.maxTurns).trim() === "" ? ((harness === "claude" || harness === "grok" || harness === "qwen") ? 50 : undefined) : Number(a.maxTurns);
|
|
211
212
|
if (maxTurns !== undefined && !(maxTurns > 0)) throw webErr(400, "maxTurns must be a positive number");
|
|
212
|
-
if (maxTurns !== undefined && harness !== "claude" && harness !== "grok") throw webErr(400, `maxTurns only applies to claude/grok (got ${harness})`);
|
|
213
|
+
if (maxTurns !== undefined && harness !== "claude" && harness !== "grok" && harness !== "qwen") throw webErr(400, `maxTurns only applies to claude/grok/qwen (got ${harness})`);
|
|
213
214
|
const allowTools = cleanOpt(a.allowTools);
|
|
214
215
|
if (allowTools !== undefined && harness !== "claude") throw webErr(400, `allowTools only applies to claude (got ${harness})`);
|
|
215
216
|
const body = cleanStr(a.body);
|
|
@@ -219,7 +220,14 @@ export async function remoteSpawn(d, a, serveOpts) { // line 6770
|
|
|
219
220
|
const cleanSub = subject ? subject.slice(0, 120) : undefined;
|
|
220
221
|
const replyTo = cleanOpt(a.replyTo);
|
|
221
222
|
const cleanRep = replyTo ? replyTo.slice(0, 80) : undefined;
|
|
222
|
-
const
|
|
223
|
+
const modelList = parseModelList(a.models !== undefined ? a.models : a.model);
|
|
224
|
+
if (a.models === undefined && a.model !== undefined && a.model !== null && String(a.model).trim() !== "" && modelList.length === 0) {
|
|
225
|
+
throw webErr(400, "invalid model (empty after splitting on commas)");
|
|
226
|
+
}
|
|
227
|
+
const modelErr = modelListErrors(modelList)[0];
|
|
228
|
+
if (modelErr) throw webErr(400, modelErr);
|
|
229
|
+
const models = modelList;
|
|
230
|
+
const model = models[0];
|
|
223
231
|
const auto = a.auto === true;
|
|
224
232
|
const lifetime = a.lifetime === "persistent" ? "persistent" : "oneshot";
|
|
225
233
|
if (a.lifetime !== undefined && a.lifetime !== null && !["oneshot", "persistent"].includes(String(a.lifetime))) throw webErr(400, "lifetime must be oneshot|persistent");
|
|
@@ -240,47 +248,11 @@ export async function remoteSpawn(d, a, serveOpts) { // line 6770
|
|
|
240
248
|
const wr = path.resolve(String(svc.workdirRoot));
|
|
241
249
|
if (cwd !== wr && !cwd.startsWith(wr + path.sep)) throw webErr(403, `cwd ${cwd} is outside --workdir-root ${wr}`);
|
|
242
250
|
}
|
|
243
|
-
|
|
244
|
-
const pattern = svc.allowCmd;
|
|
245
|
-
if (!pattern) throw webErr(403, "generic --cmd is refused remotely unless the relay sets --allow-cmd (default harness-only)");
|
|
246
|
-
let ok = false;
|
|
247
|
-
try {
|
|
248
|
-
ok = new RegExp(String(pattern)).test(String(cmd || ""));
|
|
249
|
-
} catch {
|
|
250
|
-
throw webErr(500, "relay --allow-cmd is not a valid regex");
|
|
251
|
-
}
|
|
252
|
-
if (!ok) throw webErr(403, "remote --cmd not in relay allowlist (--allow-cmd)");
|
|
253
|
-
}
|
|
251
|
+
|
|
254
252
|
if (auto && !(a.iUnderstandDanger === true || a.i_understand_danger === true)) throw webErr(400, "--auto remotely needs iUnderstandDanger:true plus an isolated relay (see docs/ISOLATION.md)");
|
|
255
|
-
|
|
256
|
-
// which must never run inside a request handler. Hashed + legacy accepted.
|
|
257
|
-
const existing = readAgent(d, from);
|
|
258
|
-
if (existing && (existing.tokenHash || existing.token) && !agentTokenMatches(existing, token)) throw webErr(403, `bad token for "${from}"`);
|
|
259
|
-
let minted = { created: false };
|
|
260
|
-
if (!existing) {
|
|
261
|
-
if (isBoardFrozen(d)) throw webErr(403, `board is frozen — new registrations refused (ask an admin to register --from <admin> --for ${from})`);
|
|
262
|
-
const fresh = mintToken();
|
|
263
|
-
const salt = newSalt();
|
|
264
|
-
writeAgentFile(d, from, { name: from, firstSeen: new Date().toISOString(), lastSeen: new Date().toISOString(), lastDir: process.cwd(), tokenHash: hashToken(fresh, salt), salt, role: defaultRoleForNew(d) });
|
|
265
|
-
minted = { created: true, token: fresh };
|
|
266
|
-
} else if (existing.token && !existing.tokenHash) {
|
|
267
|
-
const salt = newSalt();
|
|
268
|
-
existing.tokenHash = hashToken(String(token), salt);
|
|
269
|
-
existing.salt = salt;
|
|
270
|
-
delete existing.token;
|
|
271
|
-
if (!existing.role) existing.role = "lead"; // back-compat backfill
|
|
272
|
-
writeAgentFile(d, from, existing);
|
|
273
|
-
} else if (!existing.tokenHash && !existing.token) {
|
|
274
|
-
const fresh = mintToken();
|
|
275
|
-
const salt = newSalt();
|
|
276
|
-
existing.tokenHash = hashToken(fresh, salt);
|
|
277
|
-
existing.salt = salt;
|
|
278
|
-
if (!existing.role) existing.role = defaultRoleForNew(d);
|
|
279
|
-
writeAgentFile(d, from, existing);
|
|
280
|
-
minted = { created: true, token: fresh };
|
|
281
|
-
}
|
|
253
|
+
|
|
282
254
|
// Phase 1b: relay spawn honors the same matrix as CLI spawn (worker/auditor
|
|
283
|
-
// refused; restricted --to-group needs
|
|
255
|
+
// refused; restricted --to-group needs orchestrator/member). Throwing twin so
|
|
284
256
|
// a denial is a 403, never a process exit.
|
|
285
257
|
authorizeThrow(d, from, "spawn", {
|
|
286
258
|
toGroups: String(a.to_group === undefined || a.to_group === null ? "" : a.to_group).split(",").map((s) => String(s).trim().toLowerCase().replace(/[^a-z0-9_.-]/g, "-").slice(0, 40)).filter(Boolean),
|
|
@@ -290,10 +262,10 @@ export async function remoteSpawn(d, a, serveOpts) { // line 6770
|
|
|
290
262
|
const at = new Date().toISOString();
|
|
291
263
|
const logDir = path.join(d.root, "logs");
|
|
292
264
|
fs.mkdirSync(logDir, { recursive: true });
|
|
293
|
-
const spawnOpts = { harness, cmd, model, auto, maxTurns, allowTools, cwd, root: d.root, prompt: null, keepEnv: a.keepEnv === true, allowEnv: parseAllowEnv(a.allowEnv) };
|
|
265
|
+
const spawnOpts = { harness, cmd, model, models, auto, maxTurns, allowTools, cwd, root: d.root, prompt: null, keepEnv: a.keepEnv === true, allowEnv: parseAllowEnv(a.allowEnv) };
|
|
294
266
|
const senderType = (() => {
|
|
295
267
|
const t = a.senderType !== undefined ? String(a.senderType).toLowerCase() : (a.sender_type !== undefined ? String(a.sender_type).toLowerCase() : undefined);
|
|
296
|
-
if (t !== undefined && !["human", "
|
|
268
|
+
if (t !== undefined && !["human", "orchestrator", "peer"].includes(t)) throw webErr(400, "senderType must be human|orchestrator|peer");
|
|
297
269
|
return t || heuristicSenderType(d, from);
|
|
298
270
|
})();
|
|
299
271
|
const fwd = (() => {
|
|
@@ -316,10 +288,11 @@ export async function remoteSpawn(d, a, serveOpts) { // line 6770
|
|
|
316
288
|
for (let i = 0; i < res.items.length; i++) {
|
|
317
289
|
const { to, id } = res.items[i];
|
|
318
290
|
const driver = harnesses[i % harnesses.length];
|
|
319
|
-
const itemMaxTurns = maxTurns === undefined ? ((driver === "claude" || driver === "grok") ? 50 : undefined) : Number(maxTurns);
|
|
291
|
+
const itemMaxTurns = maxTurns === undefined ? ((driver === "claude" || driver === "grok" || driver === "qwen") ? 50 : undefined) : Number(maxTurns);
|
|
320
292
|
const itemSpawnOpts = {
|
|
321
293
|
...spawnOpts,
|
|
322
294
|
harness: driver,
|
|
295
|
+
model: modelForIndex(models, i),
|
|
323
296
|
maxTurns: itemMaxTurns,
|
|
324
297
|
allowTools: driver === "claude" ? allowTools : undefined,
|
|
325
298
|
};
|
|
@@ -331,7 +304,6 @@ export async function remoteSpawn(d, a, serveOpts) { // line 6770
|
|
|
331
304
|
}
|
|
332
305
|
}
|
|
333
306
|
const out = { results };
|
|
334
|
-
if (minted.created) out.senderToken = minted.token;
|
|
335
307
|
return out;
|
|
336
308
|
}
|
|
337
309
|
|