crewbus 10.0.12 → 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 +135 -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 +49 -46
- 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/LEAD_ASSIGN.md +2 -73
- package/docs/LONG_RUNS.md +3 -3
- package/docs/M1_CLI_DRAFT.md +7 -7
- 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 +33 -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/bin/lib/spawn.js
CHANGED
|
@@ -26,7 +26,7 @@ import { fileURLToPath } from "node:url";
|
|
|
26
26
|
import { createRequire } from "node:module";
|
|
27
27
|
import { execFileSync, spawn } from "node:child_process";
|
|
28
28
|
import { fail, readJson, writeJson, writeExclusiveJson, cleanBranchPrefix } from "./store.js";
|
|
29
|
-
import { touchAgent, readAgent, writeAgentFile, assertMintWon, mintToken, newSalt, hashToken } from "./identity.js";
|
|
29
|
+
import { touchAgent, readAgent, writeAgentFile, assertMintWon, mintToken, newSalt, hashToken, agentTokenMatches, ensureOrchestrator, ORCHESTRATOR_NAME } from "./identity.js";
|
|
30
30
|
import { readVisible, isCheckpoint } from "./mail.js";
|
|
31
31
|
import { saveTokenFile, loadTokenFile } from "./tokenfile.js";
|
|
32
32
|
import { shellChildSpec, shellChildOptions } from "./kidproc.js";
|
|
@@ -46,12 +46,10 @@ export { resolveShellShot };
|
|
|
46
46
|
|
|
47
47
|
// cleanBranchPrefix lives in store.js (canonical home).
|
|
48
48
|
|
|
49
|
-
//
|
|
50
|
-
//
|
|
51
|
-
//
|
|
52
|
-
|
|
53
|
-
// milestone DMs). All worker prompts pin replies to this name.
|
|
54
|
-
export const LEAD_NAME = "lead";
|
|
49
|
+
// The board's single control-plane identity. spawn ensures it exists (and
|
|
50
|
+
// boots it as a detached persistent coordinator when it is not already live).
|
|
51
|
+
// All worker prompts pin replies to this name.
|
|
52
|
+
export { ORCHESTRATOR_NAME };
|
|
55
53
|
|
|
56
54
|
export function sandboxPresent() { // line 1017
|
|
57
55
|
return !!(process.env.CONTAINER || process.env.DOCKER || process.env.CI || process.env.CREWBUS_SANDBOX);
|
|
@@ -153,10 +151,10 @@ export function scrubChildEnv(baseEnv, opts) { // line 4062
|
|
|
153
151
|
const keepEnv = !!(opts && opts.keepEnv);
|
|
154
152
|
const allow = String((opts && opts.allowEnv) || "").split(",").map((s) => String(s).trim()).filter(Boolean);
|
|
155
153
|
// Identity tokens (CREWBUS_* members of SCRUB_EXACT) are ALWAYS stripped,
|
|
156
|
-
// even under --keep-env/--allow-env: an inherited
|
|
157
|
-
// legitimate use (checkToken binds tokens to names; the worker claims
|
|
158
|
-
// own identity on first send), it only enables
|
|
159
|
-
//
|
|
154
|
+
// even under --keep-env/--allow-env: an inherited orchestrator token never
|
|
155
|
+
// has legitimate use (checkToken binds tokens to names; the worker claims
|
|
156
|
+
// its own identity on first send), it only enables impersonation. --keep-env
|
|
157
|
+
// and --allow-env keep working for non-identity vars.
|
|
160
158
|
const alwaysStrip = (key) => SCRUB_EXACT.has(key) && String(key).startsWith("CREWBUS_");
|
|
161
159
|
if (keepEnv) {
|
|
162
160
|
const env = {};
|
|
@@ -185,26 +183,26 @@ export function parseAllowEnv(raw) { // line 4078
|
|
|
185
183
|
return String(raw).split(",").map((s) => String(s).trim()).filter(Boolean).join(",");
|
|
186
184
|
}
|
|
187
185
|
|
|
188
|
-
export function buildSpawnPrompt({ name,
|
|
186
|
+
export function buildSpawnPrompt({ name, orchestrator, subject, body, replyId, rev, cwd, root, crew, workbench }) { // line 4090
|
|
189
187
|
const me = String(name || "you");
|
|
190
|
-
const replyTo = String(
|
|
188
|
+
const replyTo = String(orchestrator || ORCHESTRATOR_NAME);
|
|
191
189
|
const crewLines = Array.isArray(crew) ? crew.map((l) => String(l)).filter((s) => s.trim() !== "") : [];
|
|
192
190
|
const wbLines = Array.isArray(workbench) ? workbench.map((l) => String(l)).filter((s) => s.trim() !== "") : [];
|
|
193
191
|
return [
|
|
194
192
|
`You are '${me}' on crewbus (board: ${root}).`,
|
|
195
193
|
`CREWBUS_DIR and CREWBUS_AGENT ('${me}') are already set in your environment — send/inbox resolve the board automatically.`,
|
|
196
194
|
``,
|
|
197
|
-
`Brief from ${
|
|
195
|
+
`Brief from the board orchestrator${subject ? ` — ${subject}` : ""}:`,
|
|
198
196
|
body,
|
|
199
197
|
``,
|
|
200
198
|
...(crewLines.length > 0 ? ["Crew:", ...crewLines.map((l) => `- ${l}`), ""] : []),
|
|
201
199
|
...(wbLines.length > 0 ? ["Workbench (lessons + artifacts from prior work on this board):", ...wbLines, ""] : []),
|
|
202
200
|
`Protocol:`,
|
|
203
|
-
`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
|
|
201
|
+
`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 the orchestrator to revoke it, then re-register.`,
|
|
204
202
|
`1. Work in ${cwd} (your harness already starts there).`,
|
|
205
|
-
`2. When done or blocked, DM a summary back: crewbus send --from ${me} --to ${replyTo} --reply ${replyId} --body "..." (send to EXACTLY --to ${replyTo} — the board
|
|
203
|
+
`2. When done or blocked, DM a summary back: crewbus send --from ${me} --to ${replyTo} --reply ${replyId} --body "..." (send to EXACTLY --to ${replyTo} — the board orchestrator, which owns this crew).`,
|
|
206
204
|
`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).`,
|
|
207
|
-
`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} (
|
|
205
|
+
`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} (the orchestrator), re-validate scope after approval, secrets/exfiltration/isolation-escape are never approvable.`,
|
|
208
206
|
`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.`,
|
|
209
207
|
`4. Never post secrets — reference their location instead.${rev ? ` Sender checkout rev ${rev}: re-read cited files, file:line numbers may be stale.` : ""}`,
|
|
210
208
|
].join("\n");
|
|
@@ -212,26 +210,23 @@ export function buildSpawnPrompt({ name, from, lead, subject, body, replyId, rev
|
|
|
212
210
|
|
|
213
211
|
// Crew context block for the spawn prompt: the roster a worker needs to
|
|
214
212
|
// talk peer-direct instead of star-topologizing every question through
|
|
215
|
-
// the
|
|
216
|
-
// only — [{ name, members }]; `myGroups` the group names this
|
|
217
|
-
// belongs to; `subject` the lane line for my groups (the spawn
|
|
218
|
-
// --subject); `offTask` how many board groups from unrelated
|
|
219
|
-
// briefs exist
|
|
220
|
-
//
|
|
221
|
-
//
|
|
222
|
-
// task). Workers may send to each other (and to-group) and tail any
|
|
223
|
-
// channel, but channel-post is lead|admin-only (see identity.js
|
|
224
|
-
// LEAD_PLUS) — so the block points reads at channels and writes at DMs.
|
|
213
|
+
// the orchestrator. `groups` is the TASK roster — the groups named in this
|
|
214
|
+
// spawn only — [{ name, members }]; `myGroups` the group names this
|
|
215
|
+
// recipient belongs to; `subject` the lane line for my groups (the spawn
|
|
216
|
+
// call's --subject); `offTask` how many board groups from unrelated
|
|
217
|
+
// concurrent briefs exist. Workers may send to each other (and to-group)
|
|
218
|
+
// and tail any channel, but channel-post is member-scoped — so the block
|
|
219
|
+
// points reads at channels and writes at DMs.
|
|
225
220
|
// Returns bullet lines (no header); the caller renders them under a
|
|
226
221
|
// Crew: header. Pure: unit-tested, no board IO.
|
|
227
|
-
export function buildCrewContext({ name,
|
|
222
|
+
export function buildCrewContext({ name, orchestrator, subject, groups, myGroups, offTask }) {
|
|
228
223
|
const all = (groups || []).filter((g) => g && g.name);
|
|
229
224
|
const mineSet = new Set(myGroups || []);
|
|
230
225
|
const mine = all.filter((g) => mineSet.has(g.name));
|
|
231
226
|
const others = all.filter((g) => !mineSet.has(g.name));
|
|
232
227
|
const lane = subject && String(subject).trim() ? String(subject).trim() : "the brief above";
|
|
233
228
|
const me = String(name || "you");
|
|
234
|
-
const
|
|
229
|
+
const orch = orchestrator !== undefined ? String(orchestrator) : ORCHESTRATOR_NAME;
|
|
235
230
|
const off = Math.max(0, Number(offTask) || 0);
|
|
236
231
|
const offNoun = (n) => `${n} other group${n === 1 ? "" : "s"}`;
|
|
237
232
|
const showMembers = (members) => {
|
|
@@ -252,38 +247,28 @@ export function buildCrewContext({ name, from, lead: leadTarget, subject, groups
|
|
|
252
247
|
} else {
|
|
253
248
|
out.push(off > 0 ? `${offNoun(off)} exist on this board (crewbus group list to discover).` : `discover who else is on this board with: crewbus agents (plus crewbus group list once groups exist).`);
|
|
254
249
|
}
|
|
255
|
-
out.push(`ask the group that owns a thing before asking ${
|
|
256
|
-
out.push(`read context freely: crewbus channel tail grp-<group> (a group's briefs + progress, reads need no token). Posting to
|
|
250
|
+
out.push(`ask the group that owns a thing before asking ${orch}: crewbus send --from ${me} --to-group <group> --subject "..." --body "..." (reaches every member; ${orch} is for approvals and scope disputes only).`);
|
|
251
|
+
out.push(`read context freely: crewbus channel tail grp-<group> (a group's briefs + progress, reads need no token). Posting to a board channel is orchestrator-only — write everything via DMs.`);
|
|
257
252
|
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.`);
|
|
258
253
|
return out;
|
|
259
254
|
}
|
|
260
255
|
|
|
261
|
-
//
|
|
262
|
-
//
|
|
263
|
-
// the
|
|
264
|
-
//
|
|
265
|
-
//
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
// lead — env repair, respawn/health chasing, TTL pacing, verdicts on
|
|
269
|
-
// worker approval asks (fail-closed), verification of claims
|
|
270
|
-
// boss — the spawner identity (may poll at its own cadence): mission
|
|
271
|
-
// changes, scope disputes; receives milestone + final DMs
|
|
272
|
-
// `workers` is [{ name, id, harness }]; `batch` the batch id ("" when solo).
|
|
273
|
-
// Pure: unit-tested, no board IO — the caller boots it via bootWorker
|
|
274
|
-
// (prompt override) and stamps the log file itself.
|
|
275
|
-
export function buildCoordinatorPrompt({ name, from, subject, body, batch, workers, crew, cwd, root, auto, workbench, budgetTokens, budgetMinutes }) {
|
|
276
|
-
const boss = String(from || "boss");
|
|
277
|
-
const me = String(name || LEAD_NAME);
|
|
256
|
+
// Orchestrator prompt: the board's persistent control-plane agent. It owns
|
|
257
|
+
// the crew — it wrote the briefs, triages, approves, verifies, and reports —
|
|
258
|
+
// but never does the workers' tasks. `workers` is [{ name, id, harness }];
|
|
259
|
+
// `batch` the batch id ("" when solo). Pure: unit-tested, no board IO — the
|
|
260
|
+
// caller boots it via bootWorker (prompt override) and stamps the log file.
|
|
261
|
+
export function buildOrchestratorPrompt({ name, subject, body, batch, workers, crew, cwd, root, auto, workbench, budgetTokens, budgetMinutes }) {
|
|
262
|
+
const me = String(name || ORCHESTRATOR_NAME);
|
|
278
263
|
const ws = Array.isArray(workers) ? workers.filter((w) => w && w.name) : [];
|
|
279
264
|
const crewLines = Array.isArray(crew) ? crew.map((l) => String(l)).filter((s) => s.trim() !== "") : [];
|
|
280
265
|
const wbLines = Array.isArray(workbench) ? workbench.map((l) => String(l)).filter((s) => s.trim() !== "") : [];
|
|
281
266
|
const today = new Date().toISOString().slice(0, 10);
|
|
282
267
|
return [
|
|
283
|
-
`You are '${me}' on crewbus (board: ${root}) — the
|
|
284
|
-
|
|
268
|
+
`You are '${me}' on crewbus (board: ${root}) — the board orchestrator${batch ? ` (batch ${batch})` : ""}.`,
|
|
269
|
+
`You own this crew: you wrote the briefs, you own the workers, and you triage, approve, verify, and report. This is a control-plane role, not a do-the-task role.`,
|
|
285
270
|
``,
|
|
286
|
-
`Mission
|
|
271
|
+
`Mission${subject ? ` — ${subject}` : ""}:`,
|
|
287
272
|
String(body || "(original brief; see each worker's prompt file under logs/)"),
|
|
288
273
|
``,
|
|
289
274
|
...(crewLines.length > 0 ? ["Crew:", ...crewLines.map((l) => `- ${l}`), ""] : []),
|
|
@@ -291,21 +276,21 @@ export function buildCoordinatorPrompt({ name, from, subject, body, batch, worke
|
|
|
291
276
|
...(wbLines.length > 0 ? ["Workbench (lessons + artifacts from prior work on this board):", ...wbLines, ""] : []),
|
|
292
277
|
`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.`,
|
|
293
278
|
...(budgetTokens !== undefined || budgetMinutes !== undefined
|
|
294
|
-
? [`Budget mandate:${budgetTokens !== undefined ? ` ~${budgetTokens} est. tokens total${budgetMinutes !== undefined ? " and" : ""}` : ""}${budgetMinutes !== undefined ? ` ${budgetMinutes} wall-clock minutes total` : ""} — coordinate within it: batch your polls (listen --timeout 120000), digest-read first, and post the aggregate
|
|
279
|
+
? [`Budget mandate:${budgetTokens !== undefined ? ` ~${budgetTokens} est. tokens total${budgetMinutes !== undefined ? " and" : ""}` : ""}${budgetMinutes !== undefined ? ` ${budgetMinutes} wall-clock minutes total` : ""} — coordinate within it: batch your polls (listen --timeout 120000), digest-read first, and post the aggregate on the board BEFORE the budget runs out (a budgeted orchestrator gets reaped at the cap).`, ``]
|
|
295
280
|
: []),
|
|
296
281
|
``,
|
|
297
282
|
`Jobs, in order:`,
|
|
298
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).`,
|
|
299
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).`,
|
|
300
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.`,
|
|
301
|
-
`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 --
|
|
302
|
-
`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
|
|
303
|
-
`5. Scope disputes or mission changes:
|
|
304
|
-
`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,
|
|
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 --to <name> --persistent ... same mission text) only when respawn data is gone. Cap: 2 respawn attempts per lane before recording the stall on the board.`,
|
|
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 record it on the board.`,
|
|
288
|
+
`5. Scope disputes or mission changes: record the open question on the board (artifact/lesson) and keep working conservatively; surface it in your aggregate. 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, record it on the board rather than silently absorbing it.`,
|
|
305
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.`,
|
|
306
291
|
``,
|
|
307
|
-
`Never: change the workers' mission text (the mission above is the
|
|
308
|
-
`Exit: when every lane has a final report or a deliberate stand-down,
|
|
292
|
+
`Never: change the workers' mission text (the mission above is the user's brief — 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, post the aggregate on the board (artifact publish and/or lesson post — include outcome, lanes closed, respawn count, artifacts left), then you may exit. If the board is stalled with nothing spawnable, post the aggregate with the stall reason and exit.`,
|
|
309
294
|
``,
|
|
310
295
|
`Protocol:`,
|
|
311
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.`,
|
|
@@ -314,87 +299,39 @@ export function buildCoordinatorPrompt({ name, from, subject, body, batch, worke
|
|
|
314
299
|
}
|
|
315
300
|
|
|
316
301
|
|
|
317
|
-
//
|
|
318
|
-
//
|
|
319
|
-
//
|
|
320
|
-
//
|
|
321
|
-
//
|
|
322
|
-
//
|
|
323
|
-
//
|
|
324
|
-
//
|
|
325
|
-
//
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
// coordinator is reused, never duplicated.
|
|
329
|
-
export function provisionAutoLead(d, opts) {
|
|
330
|
-
const leadName = LEAD_NAME;
|
|
302
|
+
// Ensure the board orchestrator exists, boot it as a detached persistent
|
|
303
|
+
// coordinator when it is not already live, then transfer crew ownership
|
|
304
|
+
// (workers' spawnedBy -> orchestrator). A live orchestrator is reused, never
|
|
305
|
+
// duplicated: briefs land in the same lane by name.
|
|
306
|
+
// opts: { d, spawnOpts, subject, body, rev, logDir, workers, batch,
|
|
307
|
+
// crew, workbench, auto, budgetTokens, budgetMinutes }
|
|
308
|
+
// Returns { action: "created"|"reused"|"skipped", reason?, orchestratorName,
|
|
309
|
+
// pid?, logPath?, promptPath?, token?, transferred?, stoodDown? }.
|
|
310
|
+
// `token` is returned only when the identity was minted by this call.
|
|
311
|
+
export function provisionOrchestrator(d, opts) {
|
|
312
|
+
const orchestratorName = ORCHESTRATOR_NAME;
|
|
331
313
|
const o = opts || {};
|
|
332
|
-
const
|
|
333
|
-
if (
|
|
334
|
-
return { action: "skipped", reason: "
|
|
314
|
+
const ident = ensureOrchestrator(d);
|
|
315
|
+
if (!ident) {
|
|
316
|
+
return { action: "skipped", reason: "could not mint the board orchestrator", orchestratorName };
|
|
335
317
|
}
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
return { action: "skipped", reason: `lane "${leadName}" is offboarded (re-onboard it to provision the coordinator)`, leadName };
|
|
341
|
-
}
|
|
342
|
-
let token = null;
|
|
343
|
-
let minted = false;
|
|
344
|
-
if (existing && (existing.tokenHash || existing.token)) {
|
|
345
|
-
// Identity reuse — a lead lane already claims this name.
|
|
346
|
-
} else {
|
|
347
|
-
token = mintToken();
|
|
348
|
-
const salt = newSalt();
|
|
349
|
-
const tokenHash = hashToken(token, salt);
|
|
350
|
-
const doc = {
|
|
351
|
-
name: leadName, firstSeen: new Date().toISOString(), lastSeen: new Date().toISOString(),
|
|
352
|
-
lastDir: (o.spawnOpts && o.spawnOpts.cwd) || process.cwd(),
|
|
353
|
-
tokenHash, salt, role: "lead",
|
|
354
|
-
provisionedBy: boss, provisionedAt: new Date().toISOString(),
|
|
355
|
-
};
|
|
356
|
-
const claimed = writeExclusiveJson(path.join(d.agents, `${leadName}.json`), doc);
|
|
357
|
-
if (claimed) {
|
|
358
|
-
minted = true;
|
|
359
|
-
} else {
|
|
360
|
-
// Lost the exclusive create: either a concurrent minter won, or a
|
|
361
|
-
// legacy tokenless record holds the name (mint into it — this is the
|
|
362
|
-
// ensureSender post-revoke path, minus the token authentication step
|
|
363
|
-
// the caller already performed as board admin).
|
|
364
|
-
const again = readAgent(d, leadName);
|
|
365
|
-
if (again && !again.offboarded && !again.tokenHash && !again.token) {
|
|
366
|
-
const salt2 = newSalt();
|
|
367
|
-
again.tokenHash = hashToken(token, salt2);
|
|
368
|
-
again.salt = salt2;
|
|
369
|
-
if (!again.role) again.role = "lead";
|
|
370
|
-
writeAgentFile(d, leadName, again);
|
|
371
|
-
assertMintWon(d, leadName, again.tokenHash);
|
|
372
|
-
minted = true;
|
|
373
|
-
} else if (again && (again.tokenHash || again.token)) {
|
|
374
|
-
token = null; // absorbed by a concurrent minter — reuse its identity
|
|
375
|
-
} else {
|
|
376
|
-
return { action: "skipped", reason: `lane "${leadName}" raced a parallel claim that hid the name — retry`, leadName };
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
// Always (re)record how this coordinator came to be, without clobbering
|
|
381
|
-
// an existing live one. Standing = pid alive AND not stale (reboot + OS
|
|
382
|
-
// pid reuse: a different (unrelated) process recycled the pid — see
|
|
383
|
-
// isPidStale; stale never blocks a fresh boot, it just disqualifies reuse).
|
|
384
|
-
const rec = readAgent(d, leadName);
|
|
318
|
+
const token = ident.created ? ident.token : undefined;
|
|
319
|
+
const rec = readAgent(d, orchestratorName);
|
|
320
|
+
// Standing = pid alive AND not stale (reboot + OS pid reuse: an unrelated
|
|
321
|
+
// process recycled the pid — see isPidStale; stale disqualifies reuse).
|
|
385
322
|
const standing = rec && typeof rec.spawnedPid === "number" && pidAlive(rec.spawnedPid) && !isPidStale(rec.spawnedPid, rec.spawnedAt);
|
|
386
|
-
|
|
323
|
+
const coordToken = loadTokenFile(d.root, orchestratorName) || ident.token;
|
|
324
|
+
if (!standing && !coordToken) {
|
|
325
|
+
return { action: "skipped", reason: `orchestrator lane has no live coordinator and no token file`, orchestratorName };
|
|
326
|
+
}
|
|
387
327
|
let booted = null;
|
|
388
|
-
if (standing) {
|
|
389
|
-
// A live coordinator is already running on the lead lane (previous
|
|
390
|
-
// burst): never duplicate it — DMs land in the same lane by name.
|
|
391
|
-
} else {
|
|
328
|
+
if (!standing) {
|
|
392
329
|
try {
|
|
393
330
|
booted = bootWorker(d, o.spawnOpts, {
|
|
394
|
-
to:
|
|
331
|
+
to: orchestratorName, id: o.batch || "orchestrator", from: orchestratorName, orchestrator: orchestratorName, subject: o.subject,
|
|
395
332
|
body: o.body, rev: o.rev, logDir: o.logDir, crew: o.crew,
|
|
396
|
-
workbench: o.workbench, prompt:
|
|
397
|
-
name:
|
|
333
|
+
workbench: o.workbench, prompt: buildOrchestratorPrompt({
|
|
334
|
+
name: orchestratorName, subject: o.subject, body: o.body,
|
|
398
335
|
batch: o.batch, workers: o.workers, crew: o.crew,
|
|
399
336
|
cwd: (o.spawnOpts && o.spawnOpts.cwd) || process.cwd(),
|
|
400
337
|
root: d.root, auto: !!o.auto, workbench: o.workbench,
|
|
@@ -405,32 +342,29 @@ export function provisionAutoLead(d, opts) {
|
|
|
405
342
|
});
|
|
406
343
|
} catch (e) {
|
|
407
344
|
const detail = String((e && (e.message || e)) || e).slice(0, 160);
|
|
408
|
-
if (
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
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 };
|
|
345
|
+
if (ident.created) {
|
|
346
|
+
try { touchAgent(d, orchestratorName, { lastDir: (o.spawnOpts && o.spawnOpts.cwd) || undefined }); } catch {}
|
|
347
|
+
return { action: "created", reason: `orchestrator boot failed (${detail}) — lane minted; token at logs/${orchestratorName}.token`, orchestratorName, token };
|
|
412
348
|
}
|
|
413
|
-
return { action: "skipped", reason: `
|
|
349
|
+
return { action: "skipped", reason: `orchestrator boot failed (${detail})`, orchestratorName };
|
|
414
350
|
}
|
|
415
351
|
}
|
|
416
|
-
try { touchAgent(d,
|
|
417
|
-
// Crew ownership
|
|
418
|
-
//
|
|
419
|
-
// spawner's audit trail (appendChainRecord) preserves the original actor.
|
|
352
|
+
try { touchAgent(d, orchestratorName, { lastDir: (o.spawnOpts && o.spawnOpts.cwd) || undefined }); } catch {}
|
|
353
|
+
// Crew ownership: workers belong to the orchestrator (audit keeps the
|
|
354
|
+
// original actor in the chain record).
|
|
420
355
|
let transferred = 0;
|
|
421
356
|
for (const w of (Array.isArray(o.workers) ? o.workers : [])) {
|
|
422
357
|
if (!w || !w.name) continue;
|
|
423
|
-
try { touchAgent(d, w.name, { spawnedBy:
|
|
358
|
+
try { touchAgent(d, w.name, { spawnedBy: orchestratorName }); transferred += 1; } catch {}
|
|
424
359
|
}
|
|
425
360
|
return {
|
|
426
|
-
action:
|
|
427
|
-
|
|
361
|
+
action: standing ? "reused" : (booted ? "created" : "skipped"),
|
|
362
|
+
orchestratorName,
|
|
428
363
|
pid: booted ? booted.pid : (rec && rec.spawnedPid),
|
|
429
364
|
logPath: booted ? booted.logPath : undefined,
|
|
430
365
|
promptPath: booted ? booted.promptPath : undefined,
|
|
431
366
|
token,
|
|
432
367
|
transferred,
|
|
433
|
-
boss,
|
|
434
368
|
stoodDown: !!standing,
|
|
435
369
|
};
|
|
436
370
|
}
|
|
@@ -527,6 +461,35 @@ export function resolveHarnessExe(harness) {
|
|
|
527
461
|
return _harnessExeCache[harness];
|
|
528
462
|
}
|
|
529
463
|
|
|
464
|
+
// Per-worker model lists: `--model a,b,c` applies a/b/c to workers in order
|
|
465
|
+
// and cycles when there are more workers than models (same semantics as
|
|
466
|
+
// `--harness`). A single value keeps the old apply-to-all behavior. Model IDs
|
|
467
|
+
// do not contain commas today (provider/model, dashes, dots, colons are all
|
|
468
|
+
// fine), so the comma is the list separator.
|
|
469
|
+
export const MODEL_NAME_MAX = 100;
|
|
470
|
+
|
|
471
|
+
export function parseModelList(raw) {
|
|
472
|
+
if (raw === undefined || raw === null) return [];
|
|
473
|
+
const list = Array.isArray(raw) ? raw : String(raw).split(",");
|
|
474
|
+
return list
|
|
475
|
+
.map((m) => (m === undefined || m === null ? "" : String(m).trim()))
|
|
476
|
+
.filter(Boolean);
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
export function modelForIndex(models, i) {
|
|
480
|
+
if (!Array.isArray(models) || models.length === 0) return undefined;
|
|
481
|
+
const n = models.length;
|
|
482
|
+
return models[((i % n) + n) % n];
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
export function modelListErrors(models) {
|
|
486
|
+
const errors = [];
|
|
487
|
+
for (const m of Array.isArray(models) ? models : []) {
|
|
488
|
+
if (String(m).length > MODEL_NAME_MAX) errors.push(`model name too long (max ${MODEL_NAME_MAX} chars)`);
|
|
489
|
+
}
|
|
490
|
+
return errors;
|
|
491
|
+
}
|
|
492
|
+
|
|
530
493
|
export function buildSpawnTarget({ harness, cmd, model, auto, maxTurns, allowTools, cwd, name, promptPath, prompt, sessionId }) { // line 4114
|
|
531
494
|
const quoteFree = (s) => String(s).replace(/"/g, "'");
|
|
532
495
|
if (harness === "opencode") {
|
|
@@ -614,7 +577,21 @@ export function buildSpawnTarget({ harness, cmd, model, auto, maxTurns, allowToo
|
|
|
614
577
|
cargs.push(quoteFree(`you are '${name}': read the brief at ${promptPath} and follow it`));
|
|
615
578
|
return { exe: "cursor-agent", args: cargs, shell: true };
|
|
616
579
|
}
|
|
617
|
-
|
|
580
|
+
if (harness === "qwen") {
|
|
581
|
+
// qwen is executed via CLI.
|
|
582
|
+
// --output-format json reports session id.
|
|
583
|
+
// --session-id pre-assigns session UUID for crash-safe resume.
|
|
584
|
+
// Positional brief prompt directs worker to read brief file.
|
|
585
|
+
const qargs = ["--output-format", "json"];
|
|
586
|
+
if (sessionId) qargs.push("--session-id", sessionId);
|
|
587
|
+
if (model) qargs.push("--model", model);
|
|
588
|
+
if (maxTurns !== undefined) qargs.push("--max-session-turns", String(maxTurns));
|
|
589
|
+
if (auto) qargs.push("-y", "--approval-mode", "yolo");
|
|
590
|
+
if (allowTools) qargs.push("--allowed-tools", allowTools);
|
|
591
|
+
qargs.push(quoteFree(`you are '${name}': read the brief at ${promptPath} and follow it`));
|
|
592
|
+
return { exe: "qwen", args: qargs, shell: true, stdinPath: promptPath };
|
|
593
|
+
}
|
|
594
|
+
fail(`unknown --harness "${harness}" (want opencode|claude|codex|grok|antigravity|cursor|qwen)`);
|
|
618
595
|
}
|
|
619
596
|
|
|
620
597
|
// Resume targets for `respawn` (slice 2): same worker name, same conversation,
|
|
@@ -643,12 +620,13 @@ export function buildRespawnTarget({ harness, cmd, model, auto, maxTurns, allowT
|
|
|
643
620
|
: harness === "grok" ? ["-r", sessionId]
|
|
644
621
|
: harness === "antigravity" ? ["--conversation", sessionId]
|
|
645
622
|
: harness === "cursor" ? ["--resume", sessionId]
|
|
623
|
+
: harness === "qwen" ? ["--resume", sessionId]
|
|
646
624
|
: null;
|
|
647
|
-
if (!flag) fail(`unknown --harness "${harness}" (want opencode|claude|codex|grok|antigravity|cursor)`);
|
|
625
|
+
if (!flag) fail(`unknown --harness "${harness}" (want opencode|claude|codex|grok|antigravity|cursor|qwen)`);
|
|
648
626
|
return { ...t, args: [...t.args, ...flag] };
|
|
649
627
|
}
|
|
650
628
|
|
|
651
|
-
export function buildRespawnBrief({ name, attempt, origPromptPath, briefId, harnessSessionId, harness,
|
|
629
|
+
export function buildRespawnBrief({ name, attempt, origPromptPath, briefId, harnessSessionId, harness, orchestrator, extraBody }) { // respawn slice 2
|
|
652
630
|
// --fresh respawn (opencode with no captured id) boots fresh;
|
|
653
631
|
// the wording must not claim "prior context intact" when there is none.
|
|
654
632
|
const resumed = !harnessSessionId && harness === "opencode"
|
|
@@ -661,10 +639,10 @@ export function buildRespawnBrief({ name, attempt, origPromptPath, briefId, harn
|
|
|
661
639
|
`Then read your inbox: crewbus inbox --from ${name} (catch up on anything sent while you were down).`,
|
|
662
640
|
`Then read your checkpoints: crewbus thread --id ${briefId} (latest checkpoint is your resume point — do not redo its "done" steps).`,
|
|
663
641
|
`Continue the brief; do not redo completed steps — check files/worktree state first.`,
|
|
664
|
-
`When done or blocked, DM a summary back: crewbus send --from ${name} --to ${
|
|
642
|
+
`When done or blocked, DM a summary back: crewbus send --from ${name} --to ${orchestrator} --reply ${briefId} --body "..." (same thread as the original brief).`,
|
|
665
643
|
`Same approval protocol as your original brief: send --priority high --subject "approval: ..." then listen --timeout 300000 (300s, silence = deny, fail-closed).`,
|
|
666
644
|
];
|
|
667
|
-
if (extraBody && String(extraBody).trim()) lines.push("", "Additional instructions from
|
|
645
|
+
if (extraBody && String(extraBody).trim()) lines.push("", "Additional instructions from the orchestrator:", String(extraBody).trim());
|
|
668
646
|
return lines.join("\n");
|
|
669
647
|
}
|
|
670
648
|
|
|
@@ -699,7 +677,7 @@ function cleanSessionId(raw) {
|
|
|
699
677
|
|
|
700
678
|
// Harness driver allowlist (mirrors packages/contracts/harness.json drivers;
|
|
701
679
|
// unknown values are omitted, never invented).
|
|
702
|
-
export const KNOWN_HARNESS_DRIVERS = ["opencode", "claude", "codex", "grok", "antigravity", "cursor"];
|
|
680
|
+
export const KNOWN_HARNESS_DRIVERS = ["opencode", "claude", "codex", "grok", "antigravity", "cursor", "qwen"];
|
|
703
681
|
|
|
704
682
|
export function cleanHarnessDriver(raw) {
|
|
705
683
|
const s = String(raw === undefined || raw === null ? "" : raw).trim().toLowerCase();
|
|
@@ -1160,12 +1138,12 @@ export function installCliToUserPath() {
|
|
|
1160
1138
|
return { ok: true, binDir: userBinDir, addedToPath, detail };
|
|
1161
1139
|
}
|
|
1162
1140
|
|
|
1163
|
-
export function bootWorker(d, spawnOpts, { to, id, from,
|
|
1141
|
+
export function bootWorker(d, spawnOpts, { to, id, from, orchestrator, subject, body, rev, logDir, budgetTokens, budgetMinutes, deadlineAt, spawnedWorktree, spawnedBranch, spawnedLifetime, sessionId, crew, workbench, prompt }) { // line 4338
|
|
1164
1142
|
const { cwd, root } = spawnOpts;
|
|
1165
1143
|
const stamp = new Date().toISOString().replace(/[:.]/g, "-");
|
|
1166
|
-
// Prompt override: the
|
|
1167
|
-
// (
|
|
1168
|
-
const finalPrompt = (typeof prompt === "string" && prompt.trim()) ? prompt : buildSpawnPrompt({ name: to,
|
|
1144
|
+
// Prompt override: the orchestrator passes its own prompt
|
|
1145
|
+
// (buildOrchestratorPrompt); everything else uses the worker template.
|
|
1146
|
+
const finalPrompt = (typeof prompt === "string" && prompt.trim()) ? prompt : buildSpawnPrompt({ name: to, orchestrator, subject, body, replyId: id, rev, cwd, root, crew, workbench });
|
|
1169
1147
|
const promptPath = path.join(logDir, `${to}-${stamp}.prompt.md`);
|
|
1170
1148
|
fs.writeFileSync(promptPath, finalPrompt + "\n");
|
|
1171
1149
|
const logPath = path.join(logDir, `${to}-${stamp}.log`);
|
|
@@ -1198,7 +1176,7 @@ export function bootWorker(d, spawnOpts, { to, id, from, lead, subject, body, re
|
|
|
1198
1176
|
// (tests); otherwise mint fresh. opencode/codex rely on log parsing
|
|
1199
1177
|
// (early event stream / thread.started); cursor/agy offer neither.
|
|
1200
1178
|
let preId = sessionId && String(sessionId).trim() ? String(sessionId).trim() : undefined;
|
|
1201
|
-
if (!preId && (spawnOpts.harness === "claude" || spawnOpts.harness === "grok")) {
|
|
1179
|
+
if (!preId && (spawnOpts.harness === "claude" || spawnOpts.harness === "grok" || spawnOpts.harness === "qwen")) {
|
|
1202
1180
|
try {
|
|
1203
1181
|
preId = crypto.randomUUID();
|
|
1204
1182
|
} catch {
|
|
@@ -1233,13 +1211,14 @@ export function bootWorker(d, spawnOpts, { to, id, from, lead, subject, body, re
|
|
|
1233
1211
|
// brief points at the original prompt file and the same reply thread, so a
|
|
1234
1212
|
// resumed worker continues instead of restarting. Returns
|
|
1235
1213
|
// { pid, logPath, promptPath, attempt }. Binding keeps the original
|
|
1236
|
-
//
|
|
1214
|
+
// briefId/harnessSessionId; spawnedAt refreshes to the new pid launch and
|
|
1215
|
+
// respawnCount increments.
|
|
1237
1216
|
export function bootRespawnedWorker(d, spawnOpts, { to, briefId, from, sessionId, attempt, origPromptPath, extraBody, logDir }) { // respawn slice 2
|
|
1238
1217
|
const { harness, cwd } = spawnOpts;
|
|
1239
1218
|
const stamp = new Date().toISOString().replace(/[:.]/g, "-");
|
|
1240
1219
|
const catchup = buildRespawnBrief({
|
|
1241
1220
|
name: to, attempt, origPromptPath, briefId,
|
|
1242
|
-
harnessSessionId: sessionId, harness,
|
|
1221
|
+
harnessSessionId: sessionId, harness, orchestrator: from, extraBody,
|
|
1243
1222
|
});
|
|
1244
1223
|
const promptPath = path.join(logDir, `${to}-${stamp}.respawn.md`);
|
|
1245
1224
|
fs.writeFileSync(promptPath, catchup + "\n");
|
|
@@ -1266,9 +1245,11 @@ export function bootRespawnedWorker(d, spawnOpts, { to, briefId, from, sessionId
|
|
|
1266
1245
|
if (harness === "claude") childEnv.CLAUDE_CODE_RESUME_INTERRUPTED_TURN = "1";
|
|
1267
1246
|
const target = buildRespawnTarget({ ...spawnOpts, name: to, promptPath, prompt: catchup, sessionId });
|
|
1268
1247
|
const { pid } = launchWorkerProcess({ exe: target.exe, args: target.args, shell: target.shell, cwd, env: childEnv, logPath, stdinPath: target.stdinPath });
|
|
1269
|
-
//
|
|
1270
|
-
|
|
1248
|
+
// New pid + new launch stamp: spawnedAt must track the process the record
|
|
1249
|
+
// now points at, or the recycled-pid guard reads the fresh worker as stale.
|
|
1250
|
+
// briefId/spawnedBy stay original.
|
|
1271
1251
|
const now = new Date().toISOString();
|
|
1252
|
+
touchAgent(d, to, { spawnedPid: pid, spawnedAt: now, lastDir: cwd });
|
|
1272
1253
|
let prev = null;
|
|
1273
1254
|
try {
|
|
1274
1255
|
prev = readWorkerSession(d, to);
|
|
@@ -1277,7 +1258,7 @@ export function bootRespawnedWorker(d, spawnOpts, { to, briefId, from, sessionId
|
|
|
1277
1258
|
fs.mkdirSync(path.join(d.root, "worker-sessions"), { recursive: true });
|
|
1278
1259
|
writeJson(workerSessionPath(d, to), {
|
|
1279
1260
|
...(prev || {}),
|
|
1280
|
-
name: to, spawnedPid: pid, logPath, promptPath,
|
|
1261
|
+
name: to, spawnedPid: pid, spawnedAt: now, logPath, promptPath,
|
|
1281
1262
|
respawnCount: ((prev && prev.respawnCount) || 0) + 1,
|
|
1282
1263
|
lastRespawnAt: now,
|
|
1283
1264
|
});
|
|
@@ -1479,6 +1460,18 @@ export async function killWorkers(d, names) { // line 4529
|
|
|
1479
1460
|
process.kill(pid);
|
|
1480
1461
|
}
|
|
1481
1462
|
} catch (e) {
|
|
1463
|
+
// The process may have exited between the liveness check and the kill
|
|
1464
|
+
// call (taskkill also returns non-zero for a dying tree). Re-check
|
|
1465
|
+
// before reporting failure — a dead pid is not a kill failure.
|
|
1466
|
+
let dead = false;
|
|
1467
|
+
for (let i = 0; i < 20 && !dead; i++) {
|
|
1468
|
+
await new Promise((r) => setTimeout(r, 50));
|
|
1469
|
+
dead = !pidAlive(pid);
|
|
1470
|
+
}
|
|
1471
|
+
if (dead) {
|
|
1472
|
+
out.push({ name, result: "already-exited", pid });
|
|
1473
|
+
continue;
|
|
1474
|
+
}
|
|
1482
1475
|
out.push({ name, result: "kill-failed", pid, detail: String((e && e.code) || e) });
|
|
1483
1476
|
continue;
|
|
1484
1477
|
}
|
|
@@ -1495,6 +1488,6 @@ export async function killWorkers(d, names) { // line 4529
|
|
|
1495
1488
|
|
|
1496
1489
|
export function defaultMaxTurnsFor(harness, raw) { // line 1172
|
|
1497
1490
|
if (raw !== undefined && raw !== null && String(raw).trim() !== "") return Number(raw);
|
|
1498
|
-
if (harness === "claude" || harness === "grok") return 50;
|
|
1491
|
+
if (harness === "claude" || harness === "grok" || harness === "qwen") return 50;
|
|
1499
1492
|
return undefined;
|
|
1500
1493
|
}
|
package/bin/lib/store.js
CHANGED
|
@@ -219,7 +219,7 @@ export function getFlag(args, flag) { // line 658
|
|
|
219
219
|
|
|
220
220
|
// Positional args with flag values removed (so `send --from alice --to bob`
|
|
221
221
|
// with no body doesn't mistake "alice bob" for a message).
|
|
222
|
-
export const VALUE_FLAGS = new Set(["--from", "--to", "--to-file", "--to-group", "--body", "--subject", "--reply", "--replyTo", "--session", "--board", "--limit", "--after", "--timeout", "--id", "--harness", "--cmd", "--cwd", "--model", "--max-turns", "--allow-tools", "--window", "--older-than", "--lines", "--token", "--port", "--host", "--group", "--add", "--batch", "--with", "--interval", "--count", "--prefix", "--max-spawn", "--pool-size", "--pool", "--queue", "--agents", "--iters", "--scope", "--ttl", "--worktree", "--branch", "--grep", "--priority", "--max-chars", "--cursor", "--verify", "--msg", "--artifact"]); // line 665
|
|
222
|
+
export const VALUE_FLAGS = new Set(["--from", "--to", "--to-file", "--to-group", "--body", "--subject", "--reply", "--replyTo", "--session", "--board", "--limit", "--after", "--timeout", "--id", "--harness", "--cmd", "--cwd", "--model", "--orchestrator-model", "--max-turns", "--allow-tools", "--window", "--older-than", "--lines", "--token", "--port", "--host", "--group", "--add", "--batch", "--with", "--interval", "--count", "--prefix", "--max-spawn", "--pool-size", "--pool", "--queue", "--agents", "--iters", "--scope", "--ttl", "--worktree", "--branch", "--grep", "--priority", "--max-chars", "--cursor", "--verify", "--msg", "--artifact", "--registry"]); // line 665
|
|
223
223
|
|
|
224
224
|
// Comma-separated recipients: `--to alice,bob,carol` fans out one DM per
|
|
225
225
|
// recipient (same body/subject, unique id each). Keeps the DM-only model
|
|
@@ -232,7 +232,7 @@ for (const _f of ["--sender-type", "--fwd", "--secret", "--device", "--pair-toke
|
|
|
232
232
|
export function cleanSenderType(raw) { // line 1181
|
|
233
233
|
if (raw === undefined || raw === null || String(raw).trim() === "") return undefined;
|
|
234
234
|
const t = String(raw).trim().toLowerCase();
|
|
235
|
-
if (!["human", "
|
|
235
|
+
if (!["human", "orchestrator", "peer"].includes(t)) fail(`--sender-type must be human|orchestrator|peer (got "${raw}")`);
|
|
236
236
|
return t;
|
|
237
237
|
}
|
|
238
238
|
|