@tablation/crew 0.143.1 → 0.143.3

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/dist/cli.js CHANGED
@@ -976,6 +976,15 @@ var TUNNEL_REJECTED_KEY = "tunnel_rejected";
976
976
  function tunnelRejectedMessage(workspaceId, quickExits) {
977
977
  return `the relay tunnel for workspace ${workspaceId} exited before settling on ${quickExits} consecutive cycles, which is how a refused claim looks (the relay logs "slug already owned by another workspace/ssh key") \u2014 rotate the slug with \`crew rotate-passenger-url\` or check the relay journal. If the relay logged no rejection, a Linux passengers unit without KillMode=process kills the tunnel when the sync exits (CREW-2994): run \`crew install\`, and see \`crew doctor\``;
978
978
  }
979
+ function staleTunnelAttentionKeys(openKeys, plannedIds) {
980
+ const prefixes = [`${TUNNEL_REJECTED_KEY}:`, `${RELAY_CONTROL_UNSUPPORTED_KEY}:`];
981
+ return openKeys.filter((key) => {
982
+ const prefix = prefixes.find((p) => key.startsWith(p));
983
+ if (!prefix) return false;
984
+ const id = key.slice(prefix.length);
985
+ return !id.startsWith("periscope:") && !plannedIds.has(id);
986
+ });
987
+ }
979
988
  function rejectedTunnels(stateDir) {
980
989
  const out = [];
981
990
  for (const workspaceId of readAllPersistedWorkspaceIds(stateDir)) {
@@ -1036,6 +1045,11 @@ function periscopeTunnelRejectedItem(ticket, quickExits, nowIso) {
1036
1045
  message: `the relay preview tunnel for periscope ${ticket} exited before settling on ${quickExits} consecutive passes; its link does not work. Check that the relay supports the \`preview\` tunnel kind (crew-relay) and that the route key is accepted, or end the periscope.`
1037
1046
  };
1038
1047
  }
1048
+ function staleTunnelKeys(openKeys, sidecars) {
1049
+ const watched = new Set(sidecars.filter((sc) => sc.slug && !sc.tunnelStopped).map((sc) => periscopeTunnelKey(sc.ticket)));
1050
+ const prefix = `${TUNNEL_REJECTED_KEY}:periscope:`;
1051
+ return openKeys.filter((key) => key.startsWith(prefix) && !watched.has(key));
1052
+ }
1039
1053
  async function runPeriscopeTunnelPass(d) {
1040
1054
  let respawned = 0;
1041
1055
  for (const sc of d.sidecars()) {
@@ -15637,10 +15651,10 @@ function doctorSelftestLines(stored, toolchains) {
15637
15651
  }
15638
15652
 
15639
15653
  // src/cli.ts
15640
- import { resolve as resolve7, dirname as dirname37, join as join61, basename as basename17 } from "path";
15654
+ import { resolve as resolve7, dirname as dirname37, join as join62, basename as basename17 } from "path";
15641
15655
  import { fileURLToPath as fileURLToPath2 } from "url";
15642
15656
  import { hostname as hostname5, homedir as homedir11, userInfo as userInfo2 } from "os";
15643
- import { spawnSync as spawnSync13 } from "child_process";
15657
+ import { spawnSync as spawnSync14 } from "child_process";
15644
15658
  import { parse as parseYaml3 } from "yaml";
15645
15659
 
15646
15660
  // src/argv.ts
@@ -17976,6 +17990,9 @@ function acceptedBy(t, i) {
17976
17990
  }
17977
17991
  function parkTarget(t, i) {
17978
17992
  const person = (m) => m && (m.kind === "hold" || m.kind === "person") ? m : void 0;
17993
+ const heldHere = !!t.held_by_ship_id && t.held_by_ship_id === i.myShipId && !!i.workModes && modeOf(t, i.workModes) === "hybrid";
17994
+ const heldOp = heldHere ? operatorOf(i.roster) : void 0;
17995
+ if (heldOp) return { step: "operator", member: heldOp };
17979
17996
  const a = acceptor(t, i);
17980
17997
  const unverified = a && !a.member ? a.name : void 0;
17981
17998
  const byAcceptor = person(a?.member);
@@ -21471,6 +21488,10 @@ async function runCommentDeliveryPass(deps) {
21471
21488
  return n;
21472
21489
  }
21473
21490
 
21491
+ // src/launchd-start.ts
21492
+ import { readFileSync as readFileSync46 } from "fs";
21493
+ import { spawnSync as spawnSync12 } from "child_process";
21494
+
21474
21495
  // src/daemon-liveness.ts
21475
21496
  import { existsSync as existsSync48, readFileSync as readFileSync45 } from "fs";
21476
21497
 
@@ -22895,6 +22916,7 @@ async function applyRouteDecision(o, ctx, decision) {
22895
22916
  openKeys: () => openShipAttention(o.state).filter((i) => i.kind === "periscope_idle").map((i) => i.key),
22896
22917
  warn: (message) => emit.warn(message, { step: "sweep" })
22897
22918
  });
22919
+ for (const key of staleTunnelKeys(openShipAttention(o.state).map((i) => i.key), readPeriscopeSidecars(o.ship.stateDir))) clearShipAttention(o.state, key);
22898
22920
  if (o.ship.relayPreviews && o.ship.relayHost) {
22899
22921
  const ship = o.ship;
22900
22922
  const relayHost = ship.relayHost;
@@ -23659,8 +23681,95 @@ function readDaemonStamp(stateDir) {
23659
23681
  }
23660
23682
  }
23661
23683
 
23684
+ // src/launchd-start.ts
23685
+ function launchdStartState(r) {
23686
+ if (!r.loaded) return "unloaded";
23687
+ return r.pid !== null ? "running" : "loaded";
23688
+ }
23689
+ function planLaunchdStart(r, unit) {
23690
+ const state = launchdStartState(r);
23691
+ if (state === "running") return { state, commands: [] };
23692
+ if (state === "loaded") return { state, commands: [["launchctl", "kickstart", `gui/${unit.uid}/${unit.label}`]] };
23693
+ return { state, commands: [["launchctl", "load", unit.unitPath]] };
23694
+ }
23695
+ var LOG_TAIL_LINES = 10;
23696
+ function defaultRun(cmd) {
23697
+ const r = spawnSync12(cmd[0], cmd.slice(1), { encoding: "utf8" });
23698
+ return r.error ? null : { status: r.status, stdout: r.stdout ?? "", stderr: r.stderr ?? "" };
23699
+ }
23700
+ function defaultSleep2(ms3) {
23701
+ Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms3);
23702
+ }
23703
+ function defaultReadLog(path) {
23704
+ try {
23705
+ return readFileSync46(path, "utf8");
23706
+ } catch {
23707
+ return null;
23708
+ }
23709
+ }
23710
+ function logTail(text2, n = LOG_TAIL_LINES) {
23711
+ if (text2 === null) return [];
23712
+ return text2.split("\n").map((l) => l.trimEnd()).filter((l) => l.trim() !== "").slice(-n);
23713
+ }
23714
+ function startLaunchdDaemon(o) {
23715
+ const run4 = o.run ?? defaultRun;
23716
+ const sleep = o.sleep ?? defaultSleep2;
23717
+ const readLog = o.readLog ?? defaultReadLog;
23718
+ let out = "";
23719
+ let err3 = "";
23720
+ const read = () => {
23721
+ const r = run4(["launchctl", "print", `gui/${o.uid}/${o.label}`]);
23722
+ if (!r || r.status !== 0) return { loaded: false, pid: null, lastExitCode: null };
23723
+ return { loaded: true, ...parseLaunchctlPrint(r.stdout) };
23724
+ };
23725
+ const reading = o.assumeUnloaded ? { loaded: false, pid: null, lastExitCode: null } : read();
23726
+ const plan = planLaunchdStart(reading, o);
23727
+ if (plan.state === "running") {
23728
+ out += `crew daemon start: already running (pid ${reading.pid})
23729
+ `;
23730
+ return { exitCode: 0, stdout: out, stderr: err3 };
23731
+ }
23732
+ if (o.dryRun) {
23733
+ for (const c of plan.commands) out += `would run: ${c.join(" ")}
23734
+ `;
23735
+ return { exitCode: 0, stdout: out, stderr: err3 };
23736
+ }
23737
+ for (const cmd of plan.commands) {
23738
+ const res = run4(cmd);
23739
+ if (res?.stdout) out += res.stdout;
23740
+ if (res?.stderr) err3 += res.stderr;
23741
+ if (!res || res.status !== 0) {
23742
+ err3 += `crew daemon start: ${cmd.join(" ")} exited ${res?.status ?? "error"}
23743
+ `;
23744
+ return { exitCode: 1, stdout: out, stderr: err3 };
23745
+ }
23746
+ }
23747
+ if (plan.state === "unloaded" && !o.verifyAfterLoad) return { exitCode: 0, stdout: out, stderr: err3 };
23748
+ sleep(o.settleMs ?? 3e3);
23749
+ const after = read();
23750
+ if (after.loaded && after.pid !== null) {
23751
+ out += `crew daemon start: running (pid ${after.pid})
23752
+ `;
23753
+ return { exitCode: 0, stdout: out, stderr: err3 };
23754
+ }
23755
+ err3 += "crew daemon start: the daemon did not stay up.\n";
23756
+ err3 += ` last exit status: ${after.lastExitCode ?? "none recorded"}
23757
+ `;
23758
+ const tail3 = logTail(readLog(o.schedulerLog));
23759
+ if (tail3.length) {
23760
+ err3 += ` last lines of ${o.schedulerLog}:
23761
+ `;
23762
+ for (const l of tail3) err3 += ` ${l}
23763
+ `;
23764
+ } else {
23765
+ err3 += ` ${o.schedulerLog} has no output
23766
+ `;
23767
+ }
23768
+ return { exitCode: 1, stdout: out, stderr: err3 };
23769
+ }
23770
+
23662
23771
  // src/daemon-start-failure.ts
23663
- import { existsSync as existsSync49, mkdirSync as mkdirSync36, readFileSync as readFileSync46, unlinkSync as unlinkSync4, writeFileSync as writeFileSync37 } from "fs";
23772
+ import { existsSync as existsSync49, mkdirSync as mkdirSync36, readFileSync as readFileSync47, unlinkSync as unlinkSync4, writeFileSync as writeFileSync37 } from "fs";
23664
23773
  import { dirname as dirname29, join as join51 } from "path";
23665
23774
  var DAEMON_START_FAILED_KEY = "daemon_start_failed";
23666
23775
  var START_FAILURE_BACKOFF_MS = 6e4;
@@ -23668,7 +23777,7 @@ var BACKOFF_AFTER_FAILURES = 2;
23668
23777
  var fileFor3 = (stateDir) => join51(stateDir, ".daemon-start-failure.json");
23669
23778
  function readStartFailure(stateDir) {
23670
23779
  try {
23671
- const parsed = JSON.parse(readFileSync46(fileFor3(stateDir), "utf8"));
23780
+ const parsed = JSON.parse(readFileSync47(fileFor3(stateDir), "utf8"));
23672
23781
  return typeof parsed.reason === "string" && typeof parsed.count === "number" ? { reason: parsed.reason, count: parsed.count, firstAt: String(parsed.firstAt), lastAt: String(parsed.lastAt) } : null;
23673
23782
  } catch {
23674
23783
  return null;
@@ -24934,7 +25043,7 @@ function describeCapability(i) {
24934
25043
  }
24935
25044
 
24936
25045
  // src/persona-avatars.ts
24937
- import { existsSync as existsSync51, readFileSync as readFileSync47 } from "fs";
25046
+ import { existsSync as existsSync51, readFileSync as readFileSync48 } from "fs";
24938
25047
  import { join as join52 } from "path";
24939
25048
  var IMAGE_TYPES = { png: "image/png", svg: "image/svg+xml" };
24940
25049
  function personaAvatarFile(promptsDir, role) {
@@ -24955,7 +25064,7 @@ async function syncPersonaAvatars(route2, agentPersonas, opts) {
24955
25064
  if (!file || !agentId) continue;
24956
25065
  try {
24957
25066
  const form = new FormData();
24958
- form.append("file", new Blob([readFileSync47(file.path)], { type: file.mimeType }), file.name);
25067
+ form.append("file", new Blob([readFileSync48(file.path)], { type: file.mimeType }), file.name);
24959
25068
  const res = await fetch(`${base}/${agentId}/avatar`, {
24960
25069
  method: "PUT",
24961
25070
  headers: { Authorization: `Bearer ${resolveApiKey(route2)}`, "User-Agent": opts.userAgent ?? "Mozilla/5.0 TablationCrewAgent/1.0" },
@@ -24996,14 +25105,14 @@ function avatarFailures(raw) {
24996
25105
  }
24997
25106
  function routeAvatarFailures(stateDir, route2) {
24998
25107
  try {
24999
- return avatarFailures(JSON.parse(readFileSync47(resolvedPathFor(stateDir, route2), "utf8")));
25108
+ return avatarFailures(JSON.parse(readFileSync48(resolvedPathFor(stateDir, route2), "utf8")));
25000
25109
  } catch {
25001
25110
  return [];
25002
25111
  }
25003
25112
  }
25004
25113
 
25005
25114
  // src/agents-sync-run.ts
25006
- import { existsSync as existsSync52, mkdirSync as mkdirSync38, readFileSync as readFileSync48, writeFileSync as writeFileSync39 } from "fs";
25115
+ import { existsSync as existsSync52, mkdirSync as mkdirSync38, readFileSync as readFileSync49, writeFileSync as writeFileSync39 } from "fs";
25007
25116
  import { dirname as dirname31 } from "path";
25008
25117
  async function runAgentsSync(target, o) {
25009
25118
  const dryRun = o.dryRun ?? false;
@@ -25049,7 +25158,7 @@ async function runAgentsSync(target, o) {
25049
25158
  }
25050
25159
  if (!dryRun) {
25051
25160
  const resolvedPath = resolvedPathFor(o.stateDir, target.route);
25052
- const raw = existsSync52(resolvedPath) ? JSON.parse(readFileSync48(resolvedPath, "utf8")) : {};
25161
+ const raw = existsSync52(resolvedPath) ? JSON.parse(readFileSync49(resolvedPath, "utf8")) : {};
25053
25162
  raw.agentPersonas = personaResult.agentPersonas;
25054
25163
  if (skillResult) raw.agentSkills = skillResult.agentSkills;
25055
25164
  if (!readOnly) raw.avatarSyncFailures = avatarFailures2;
@@ -25191,8 +25300,8 @@ async function showLogEntry(route2, entryId, opts = {}) {
25191
25300
  }
25192
25301
 
25193
25302
  // src/repos-check.ts
25194
- import { spawnSync as spawnSync12 } from "child_process";
25195
- import { readFileSync as readFileSync49 } from "fs";
25303
+ import { spawnSync as spawnSync13 } from "child_process";
25304
+ import { readFileSync as readFileSync50 } from "fs";
25196
25305
  import { basename as basename12 } from "path";
25197
25306
  var POSIX_SHELL = /^(?:ba|z|da|k|a|mk)?sh$|^fish$/;
25198
25307
  function checkHookSyntax(script, shell) {
@@ -25200,10 +25309,10 @@ function checkHookSyntax(script, shell) {
25200
25309
  const name = basename12(spec.bin).replace(/\.exe$/i, "").toLowerCase();
25201
25310
  let run4;
25202
25311
  if (POSIX_SHELL.test(name)) {
25203
- run4 = spawnSync12(spec.bin, ["-n"], { input: script, encoding: "utf8" });
25312
+ run4 = spawnSync13(spec.bin, ["-n"], { input: script, encoding: "utf8" });
25204
25313
  } else if (/^(pwsh|powershell)$/.test(name)) {
25205
25314
  const parse3 = "$e=$null;[void][System.Management.Automation.Language.Parser]::ParseInput($env:CREW_CHECK_SCRIPT,[ref]$null,[ref]$e);if($e){$e|ForEach-Object{[Console]::Error.WriteLine($_.Message)};exit 1}";
25206
- run4 = spawnSync12(spec.bin, ["-NoProfile", "-NonInteractive", "-Command", parse3], {
25315
+ run4 = spawnSync13(spec.bin, ["-NoProfile", "-NonInteractive", "-Command", parse3], {
25207
25316
  encoding: "utf8",
25208
25317
  env: { ...process.env, CREW_CHECK_SCRIPT: script }
25209
25318
  });
@@ -25233,7 +25342,7 @@ function checkRepoSpec(dir, opts = {}) {
25233
25342
  }
25234
25343
  let parsed;
25235
25344
  try {
25236
- parsed = parseRepoConfig(readFileSync49(file, "utf8"), file);
25345
+ parsed = parseRepoConfig(readFileSync50(file, "utf8"), file);
25237
25346
  } catch (e) {
25238
25347
  if (!(e instanceof RepoConfigError)) throw e;
25239
25348
  return { ...empty, file, error: e.message, exitCode: 1 };
@@ -25765,7 +25874,7 @@ function planSampleTicket(i) {
25765
25874
  }
25766
25875
 
25767
25876
  // src/worktree-sweep.ts
25768
- import { existsSync as existsSync53, readFileSync as readFileSync50, readdirSync as readdirSync15 } from "fs";
25877
+ import { existsSync as existsSync53, readFileSync as readFileSync51, readdirSync as readdirSync15 } from "fs";
25769
25878
  import { basename as basename14, dirname as dirname33, join as join54, resolve as resolve5 } from "path";
25770
25879
  function planWorktreeSweep(target, tickets, contract) {
25771
25880
  const terminal = new Set(contract.statuses.resolved.filter((s) => s !== contract.statuses.verified));
@@ -25965,7 +26074,7 @@ function isHandBackMerge(path, base) {
25965
26074
  if (!msgPath) return false;
25966
26075
  let first;
25967
26076
  try {
25968
- first = readFileSync50(resolve5(path, msgPath), "utf8").split("\n")[0] ?? "";
26077
+ first = readFileSync51(resolve5(path, msgPath), "utf8").split("\n")[0] ?? "";
25969
26078
  } catch {
25970
26079
  return false;
25971
26080
  }
@@ -26115,7 +26224,7 @@ function planEventsSweep(stateDir, retentionDays, now = Date.now()) {
26115
26224
  }
26116
26225
 
26117
26226
  // src/cli.ts
26118
- import { realpathSync as realpathSync3, readFileSync as readFileSync53, existsSync as existsSync58, mkdirSync as mkdirSync42, writeFileSync as writeFileSync42, rmSync as rmSync26, unlinkSync as unlinkSync6, copyFileSync as copyFileSync2, renameSync as renameSync8, statSync as statSync17, readdirSync as readdirSync20 } from "fs";
26227
+ import { realpathSync as realpathSync3, readFileSync as readFileSync54, existsSync as existsSync59, mkdirSync as mkdirSync42, writeFileSync as writeFileSync42, rmSync as rmSync26, unlinkSync as unlinkSync6, copyFileSync as copyFileSync2, renameSync as renameSync8, statSync as statSync18, readdirSync as readdirSync21 } from "fs";
26119
26228
  import { createInterface } from "readline/promises";
26120
26229
 
26121
26230
  // src/periscope-resume.ts
@@ -26190,6 +26299,48 @@ ${tail2(preview.output)}`);
26190
26299
  // src/cli.ts
26191
26300
  import { dirname as dirOf2, resolve as resolvePath } from "path";
26192
26301
 
26302
+ // src/bundle-staleness.ts
26303
+ import { existsSync as existsSync55, readdirSync as readdirSync17, statSync as statSync16 } from "fs";
26304
+ import { join as join56 } from "path";
26305
+ function builtVersion() {
26306
+ return true ? "0.143.3" : null;
26307
+ }
26308
+ var REBUILD_HINT = "rebuild with npm run build";
26309
+ function newestMtime(path) {
26310
+ let stat2;
26311
+ try {
26312
+ stat2 = statSync16(path);
26313
+ } catch {
26314
+ return 0;
26315
+ }
26316
+ if (stat2.isFile()) return stat2.mtimeMs;
26317
+ if (!stat2.isDirectory()) return 0;
26318
+ let latest = stat2.mtimeMs;
26319
+ for (const e of readdirSync17(path, { withFileTypes: true })) latest = Math.max(latest, newestMtime(join56(path, e.name)));
26320
+ return latest;
26321
+ }
26322
+ function bundleStaleness(i) {
26323
+ if (i.built === null || i.compiled) return null;
26324
+ const src = join56(i.home, "src");
26325
+ if (!existsSync55(src)) return null;
26326
+ if (i.built !== i.current) {
26327
+ return { kind: "version", builtVersion: i.built, message: `running a bundle built from ${i.built} (package.json names ${i.current}); ${REBUILD_HINT}` };
26328
+ }
26329
+ const bundle = statSafe(join56(i.home, "dist", "cli.js"));
26330
+ if (bundle === null) return null;
26331
+ if (newestMtime(src) > bundle) {
26332
+ return { kind: "source", builtVersion: i.built, message: `running a bundle older than the source in src/ (both ${i.current}); ${REBUILD_HINT}` };
26333
+ }
26334
+ return null;
26335
+ }
26336
+ function statSafe(p) {
26337
+ try {
26338
+ return statSync16(p).mtimeMs;
26339
+ } catch {
26340
+ return null;
26341
+ }
26342
+ }
26343
+
26193
26344
  // src/relay-probe.ts
26194
26345
  async function probeRelayControl(relayUrl, apiKey, userAgent, fetchFn = fetch, timeoutMs = 1e4) {
26195
26346
  const started = Date.now();
@@ -26342,8 +26493,8 @@ async function unregisterEndpoint(workspaceId, info, d) {
26342
26493
  import { createServer as createHttpServer } from "http";
26343
26494
  import { spawn as spawn9 } from "child_process";
26344
26495
  import { randomBytes as randomBytes2 } from "crypto";
26345
- import { existsSync as existsSync55, mkdirSync as mkdirSync39, readFileSync as readFileSync51, writeFileSync as writeFileSync40, unlinkSync as unlinkSync5, readdirSync as readdirSync17 } from "fs";
26346
- import { join as join56 } from "path";
26496
+ import { existsSync as existsSync56, mkdirSync as mkdirSync39, readFileSync as readFileSync52, writeFileSync as writeFileSync40, unlinkSync as unlinkSync5, readdirSync as readdirSync18 } from "fs";
26497
+ import { join as join57 } from "path";
26347
26498
 
26348
26499
  // src/secret-compare.ts
26349
26500
  import { timingSafeEqual } from "crypto";
@@ -26436,20 +26587,20 @@ var defaultSpawn2 = (cmd, args, env) => {
26436
26587
  return child;
26437
26588
  };
26438
26589
  function syncDaemonStatePath(stateDir, workspaceId) {
26439
- return join56(stateDir, "passengers", `${workspaceId}-sync.json`);
26590
+ return join57(stateDir, "passengers", `${workspaceId}-sync.json`);
26440
26591
  }
26441
26592
  function readPersistedSyncDaemon(stateDir, workspaceId) {
26442
26593
  const path = syncDaemonStatePath(stateDir, workspaceId);
26443
- if (!existsSync55(path)) return void 0;
26594
+ if (!existsSync56(path)) return void 0;
26444
26595
  try {
26445
- return JSON.parse(readFileSync51(path, "utf8"));
26596
+ return JSON.parse(readFileSync52(path, "utf8"));
26446
26597
  } catch {
26447
26598
  return void 0;
26448
26599
  }
26449
26600
  }
26450
26601
  function writePersistedSyncDaemon(stateDir, state) {
26451
26602
  const path = syncDaemonStatePath(stateDir, state.workspaceId);
26452
- mkdirSync39(join56(stateDir, "passengers"), { recursive: true });
26603
+ mkdirSync39(join57(stateDir, "passengers"), { recursive: true });
26453
26604
  writeFileSync40(path, `${JSON.stringify(state, null, 2)}
26454
26605
  `);
26455
26606
  }
@@ -26470,10 +26621,10 @@ function waitForExit(pid, alive, timeoutMs = 5e3) {
26470
26621
  }
26471
26622
  }
26472
26623
  function readAllPersistedSyncWorkspaceIds(stateDir) {
26473
- const dir = join56(stateDir, "passengers");
26474
- if (!existsSync55(dir)) return [];
26624
+ const dir = join57(stateDir, "passengers");
26625
+ if (!existsSync56(dir)) return [];
26475
26626
  const suffix = "-sync.json";
26476
- return readdirSync17(dir).filter((f) => f.endsWith(suffix)).map((f) => f.slice(0, -suffix.length));
26627
+ return readdirSync18(dir).filter((f) => f.endsWith(suffix)).map((f) => f.slice(0, -suffix.length));
26477
26628
  }
26478
26629
  function syncPassengerSyncDaemons(plans, cfg, stateDir, deps = {}) {
26479
26630
  const alive = deps.isPidAlive ?? isPidAlive;
@@ -26937,7 +27088,7 @@ async function startWorktreeIntel(d) {
26937
27088
  }
26938
27089
 
26939
27090
  // src/contract-refusal.ts
26940
- import { join as join57 } from "path";
27091
+ import { join as join58 } from "path";
26941
27092
  function contractFixers(dir, baseRef, tickets, locate) {
26942
27093
  const out = [];
26943
27094
  for (const t of tickets) {
@@ -26949,7 +27100,7 @@ function contractFixers(dir, baseRef, tickets, locate) {
26949
27100
  const text2 = gitOk(dir, ["show", `${branch}:${file}`]);
26950
27101
  if (text2 === null) continue;
26951
27102
  try {
26952
- parseRepoConfig(text2, join57(dir, file));
27103
+ parseRepoConfig(text2, join58(dir, file));
26953
27104
  } catch (e) {
26954
27105
  if (e instanceof RepoConfigError) continue;
26955
27106
  throw e;
@@ -26964,18 +27115,18 @@ import { createHash as createHash11 } from "crypto";
26964
27115
  import {
26965
27116
  chmodSync as chmodSync4,
26966
27117
  closeSync as closeSync6,
26967
- existsSync as existsSync56,
27118
+ existsSync as existsSync57,
26968
27119
  fstatSync,
26969
27120
  openSync as openSync6,
26970
27121
  readSync as readSync3,
26971
- readdirSync as readdirSync18,
27122
+ readdirSync as readdirSync19,
26972
27123
  rmSync as rmSync24,
26973
- statSync as statSync16,
27124
+ statSync as statSync17,
26974
27125
  watch
26975
27126
  } from "fs";
26976
27127
  import { createConnection } from "net";
26977
27128
  import { createServer as createServer2 } from "http";
26978
- import { basename as basename15, dirname as dirname35, join as join58 } from "path";
27129
+ import { basename as basename15, dirname as dirname35, join as join59 } from "path";
26979
27130
  import { execFile as execFile6, spawn as spawn12 } from "child_process";
26980
27131
 
26981
27132
  // src/periscope-control.ts
@@ -27212,7 +27363,7 @@ function runCrew(args, onLine, timeoutMs = 20 * 6e4) {
27212
27363
  // src/control-api.ts
27213
27364
  var PAUSABLE = ["dev", "design", "qa"];
27214
27365
  var CONTROL_SOCKET_NAME = "control.sock";
27215
- var controlSocketFor = (stateDir) => join58(stateDir, CONTROL_SOCKET_NAME);
27366
+ var controlSocketFor = (stateDir) => join59(stateDir, CONTROL_SOCKET_NAME);
27216
27367
  var MAX_SOCKET_PATH = 100;
27217
27368
  var MAX_TAIL_BYTES = 1024 * 1024;
27218
27369
  var MAX_WAIT_SECONDS = 30;
@@ -27299,7 +27450,7 @@ function candidates(live2, rotated) {
27299
27450
  const out = [live2];
27300
27451
  if (!rotated) return out;
27301
27452
  try {
27302
- for (const n of readdirSync18(dirname35(live2))) if (ROTATED_EVENTS_RE.test(n)) out.push(join58(dirname35(live2), n));
27453
+ for (const n of readdirSync19(dirname35(live2))) if (ROTATED_EVENTS_RE.test(n)) out.push(join59(dirname35(live2), n));
27303
27454
  } catch {
27304
27455
  }
27305
27456
  return out;
@@ -27322,7 +27473,7 @@ function readRange(path, from, max) {
27322
27473
  }
27323
27474
  }
27324
27475
  function lastLines2(path, n) {
27325
- const st = statSync16(path);
27476
+ const st = statSync17(path);
27326
27477
  const cursorAt = (off) => encodeCursor({ dev: st.dev, ino: st.ino, off });
27327
27478
  if (n <= 0 || st.size === 0) return { lines: [], cursor: cursorAt(st.size), reset: false };
27328
27479
  let start = st.size;
@@ -27343,7 +27494,7 @@ function lastLines2(path, n) {
27343
27494
  }
27344
27495
  function readTail(live2, opts) {
27345
27496
  const max = opts.maxBytes ?? MAX_TAIL_BYTES;
27346
- if (!existsSync56(live2)) {
27497
+ if (!existsSync57(live2)) {
27347
27498
  return { lines: [], cursor: opts.after ?? encodeCursor({ dev: 0, ino: 0, off: 0 }), reset: false };
27348
27499
  }
27349
27500
  const cur = opts.after ? decodeCursor(opts.after) : null;
@@ -27356,7 +27507,7 @@ function readTail(live2, opts) {
27356
27507
  } else {
27357
27508
  const found = candidates(live2, opts.rotated ?? false).find((p) => {
27358
27509
  try {
27359
- const s = statSync16(p);
27510
+ const s = statSync17(p);
27360
27511
  return s.ino === cur.ino && s.dev === cur.dev;
27361
27512
  } catch {
27362
27513
  return false;
@@ -27367,7 +27518,7 @@ function readTail(live2, opts) {
27367
27518
  off = cur.off;
27368
27519
  } else reset = true;
27369
27520
  }
27370
- let size = statSync16(path).size;
27521
+ let size = statSync17(path).size;
27371
27522
  if (off > size) {
27372
27523
  off = 0;
27373
27524
  reset = true;
@@ -27375,12 +27526,12 @@ function readTail(live2, opts) {
27375
27526
  if (off >= size && path !== live2) {
27376
27527
  path = live2;
27377
27528
  off = 0;
27378
- size = statSync16(path).size;
27529
+ size = statSync17(path).size;
27379
27530
  }
27380
27531
  const { text: text2 } = readRange(path, off, max);
27381
27532
  const cut = text2.lastIndexOf("\n");
27382
27533
  const whole = cut < 0 ? "" : text2.slice(0, cut + 1);
27383
- const st = statSync16(path);
27534
+ const st = statSync17(path);
27384
27535
  return {
27385
27536
  lines: whole.split("\n").filter((l) => l.length),
27386
27537
  cursor: encodeCursor({ dev: st.dev, ino: st.ino, off: off + Buffer.byteLength(whole) }),
@@ -27522,8 +27673,8 @@ async function route(deps, method, url, req, abort) {
27522
27673
  if (p.startsWith("/streams/") && get2) {
27523
27674
  const run4 = decodeURIComponent(p.slice("/streams/".length));
27524
27675
  if (!RUN_NAME_RE.test(run4) || run4.includes("..") || /\.(pid|meta\.json|events\.jsonl)$/.test(run4)) return err2(400, "not a run name");
27525
- const file = join58(deps.stateDir, "streams", run4.endsWith(".jsonl") ? run4 : `${run4}.jsonl`);
27526
- if (!existsSync56(file)) return err2(404, "no such run");
27676
+ const file = join59(deps.stateDir, "streams", run4.endsWith(".jsonl") ? run4 : `${run4}.jsonl`);
27677
+ if (!existsSync57(file)) return err2(404, "no such run");
27527
27678
  return tailReply(file, url.searchParams, false, abort);
27528
27679
  }
27529
27680
  const note = /^\/streams\/([^/]+)\/messages$/.exec(p);
@@ -27570,7 +27721,7 @@ function send2(res, r) {
27570
27721
  res.end(body);
27571
27722
  }
27572
27723
  async function socketIsStale(path) {
27573
- if (!existsSync56(path)) return false;
27724
+ if (!existsSync57(path)) return false;
27574
27725
  return new Promise((resolve8) => {
27575
27726
  const c = createConnection(path);
27576
27727
  c.once("connect", () => {
@@ -27589,7 +27740,7 @@ async function startControlServer(deps) {
27589
27740
  return null;
27590
27741
  }
27591
27742
  if (await socketIsStale(path)) rmSync24(path, { force: true });
27592
- else if (existsSync56(path)) {
27743
+ else if (existsSync57(path)) {
27593
27744
  log(`control API not started: ${path} is in use by another process`);
27594
27745
  return null;
27595
27746
  }
@@ -27675,19 +27826,19 @@ function crewJson(args, timeoutMs = 6e4) {
27675
27826
 
27676
27827
  // src/periscope-mcp.ts
27677
27828
  import { lstat, mkdir, readdir, readFile, readlink, realpath, rm, stat, writeFile } from "fs/promises";
27678
- import { basename as basename16, dirname as dirname36, isAbsolute as isAbsolute5, join as join60, relative as relative2, resolve as resolve6, sep } from "path";
27829
+ import { basename as basename16, dirname as dirname36, isAbsolute as isAbsolute5, join as join61, relative as relative2, resolve as resolve6, sep } from "path";
27679
27830
  import { z } from "zod";
27680
27831
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
27681
27832
  import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
27682
27833
 
27683
27834
  // src/periscope-endpoints.ts
27684
27835
  import { randomBytes as randomBytes3 } from "crypto";
27685
- import { chmodSync as chmodSync5, existsSync as existsSync57, mkdirSync as mkdirSync41, readdirSync as readdirSync19, readFileSync as readFileSync52, rmSync as rmSync25, writeFileSync as writeFileSync41 } from "fs";
27686
- import { join as join59 } from "path";
27687
- var secretDir = (stateDir) => join59(stateDir, "periscope-mcp");
27688
- var secretFile = (stateDir, id) => join59(secretDir(stateDir), `${id}.json`);
27689
- var endpointDir = (stateDir) => join59(stateDir, "periscope-endpoints");
27690
- var endpointFile = (stateDir, id) => join59(endpointDir(stateDir), `${id}.json`);
27836
+ import { chmodSync as chmodSync5, existsSync as existsSync58, mkdirSync as mkdirSync41, readdirSync as readdirSync20, readFileSync as readFileSync53, rmSync as rmSync25, writeFileSync as writeFileSync41 } from "fs";
27837
+ import { join as join60 } from "path";
27838
+ var secretDir = (stateDir) => join60(stateDir, "periscope-mcp");
27839
+ var secretFile = (stateDir, id) => join60(secretDir(stateDir), `${id}.json`);
27840
+ var endpointDir = (stateDir) => join60(stateDir, "periscope-endpoints");
27841
+ var endpointFile = (stateDir, id) => join60(endpointDir(stateDir), `${id}.json`);
27691
27842
  function mintPeriscopeSecret(stateDir, ticketRecordId) {
27692
27843
  mkdirSync41(secretDir(stateDir), { recursive: true, mode: 448 });
27693
27844
  const secret = randomBytes3(32).toString("base64url");
@@ -27699,7 +27850,7 @@ function mintPeriscopeSecret(stateDir, ticketRecordId) {
27699
27850
  }
27700
27851
  function readPeriscopeSecret(stateDir, ticketRecordId) {
27701
27852
  try {
27702
- const v = JSON.parse(readFileSync52(secretFile(stateDir, ticketRecordId), "utf8"));
27853
+ const v = JSON.parse(readFileSync53(secretFile(stateDir, ticketRecordId), "utf8"));
27703
27854
  return typeof v.secret === "string" && v.secret ? v.secret : void 0;
27704
27855
  } catch {
27705
27856
  return void 0;
@@ -27710,7 +27861,7 @@ function removePeriscopeSecret(stateDir, ticketRecordId) {
27710
27861
  }
27711
27862
  function readPeriscopeEndpoint(stateDir, ticketRecordId) {
27712
27863
  try {
27713
- return JSON.parse(readFileSync52(endpointFile(stateDir, ticketRecordId), "utf8"));
27864
+ return JSON.parse(readFileSync53(endpointFile(stateDir, ticketRecordId), "utf8"));
27714
27865
  } catch {
27715
27866
  return void 0;
27716
27867
  }
@@ -27725,9 +27876,9 @@ function removePeriscopeEndpointRecord(stateDir, ticketRecordId) {
27725
27876
  }
27726
27877
  function listPeriscopeEndpoints(stateDir) {
27727
27878
  const dir = endpointDir(stateDir);
27728
- if (!existsSync57(dir)) return [];
27879
+ if (!existsSync58(dir)) return [];
27729
27880
  const out = [];
27730
- for (const name of readdirSync19(dir)) {
27881
+ for (const name of readdirSync20(dir)) {
27731
27882
  if (!name.endsWith(".json")) continue;
27732
27883
  const rec = readPeriscopeEndpoint(stateDir, name.slice(0, -".json".length));
27733
27884
  if (rec && typeof rec.endpointId === "string") out.push(rec);
@@ -27828,13 +27979,13 @@ async function resolveInWorktree(root, requested) {
27828
27979
  let abs;
27829
27980
  if (isAbsolute5(requested)) {
27830
27981
  abs = resolve6(requested);
27831
- if (isInside(root, abs)) abs = join60(realRoot, relative2(root, abs));
27982
+ if (isInside(root, abs)) abs = join61(realRoot, relative2(root, abs));
27832
27983
  } else {
27833
27984
  abs = resolve6(realRoot, requested);
27834
27985
  }
27835
27986
  if (!isInside(realRoot, abs)) throw new PathRefusal(`${requested} is outside this periscope's worktree`);
27836
27987
  const { real, rest } = await realAncestor(abs);
27837
- const final = rest ? join60(real, rest) : real;
27988
+ const final = rest ? join61(real, rest) : real;
27838
27989
  if (!isInside(realRoot, final)) throw new PathRefusal(`${requested} is outside this periscope's worktree`);
27839
27990
  if (relative2(realRoot, final).split(sep).includes(".git")) throw new PathRefusal(".git is not reachable from a periscope");
27840
27991
  return final;
@@ -27902,7 +28053,7 @@ function createPeriscopeMcpServer(d, sc) {
27902
28053
  const entries = (await readdir(abs, { withFileTypes: true })).filter((e) => e.name !== ".git");
27903
28054
  const lines2 = await Promise.all(entries.map(async (e) => {
27904
28055
  if (e.isDirectory()) return `[DIR] ${e.name}`;
27905
- const size = (await lstat(join60(abs, e.name))).size;
28056
+ const size = (await lstat(join61(abs, e.name))).size;
27906
28057
  return `[FILE] ${e.name} (${size} bytes)`;
27907
28058
  }));
27908
28059
  return text(lines2.join("\n") || "(empty)");
@@ -27968,7 +28119,7 @@ function createPeriscopeMcpServer(d, sc) {
27968
28119
  annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: false }
27969
28120
  }, async ({ path }) => {
27970
28121
  const parent = await inTree(dirname36(path) === "" ? "." : dirname36(path));
27971
- const abs = join60(parent, basename16(path));
28122
+ const abs = join61(parent, basename16(path));
27972
28123
  if (basename16(path) === ".git" || abs === parent) return text("path must name a file", true);
27973
28124
  const st = await lstat(abs).catch(() => void 0);
27974
28125
  if (!st) return text(`${path} does not exist`, true);
@@ -28327,11 +28478,15 @@ if (helpRequest(argv)) usage(void 0, true);
28327
28478
  var versionReq = versionRequest(argv);
28328
28479
  if (versionReq) {
28329
28480
  const version = crewVersion(CREW_HOME);
28330
- process.stdout.write(versionReq.json ? `${JSON.stringify({ version, home: CREW_HOME, compiled: isCompiledBinary(import.meta.url) })}
28331
- ` : `${version}
28481
+ const stale = bundleStaleness({ built: builtVersion(), current: version, home: CREW_HOME, compiled: isCompiledBinary(import.meta.url) });
28482
+ process.stdout.write(versionReq.json ? `${JSON.stringify({ version, home: CREW_HOME, compiled: isCompiledBinary(import.meta.url), builtVersion: builtVersion(), stale: stale !== null })}
28483
+ ` : `${stale ? `${version} (${stale.kind === "version" ? `running a bundle built from ${stale.builtVersion}` : "running a bundle older than the source in src/"}; ${REBUILD_HINT})` : version}
28332
28484
  `);
28333
28485
  process.exit(0);
28334
28486
  }
28487
+ var staleBundle = bundleStaleness({ built: builtVersion(), current: crewVersion(CREW_HOME), home: CREW_HOME, compiled: isCompiledBinary(import.meta.url) });
28488
+ if (staleBundle) process.stderr.write(`crew: warning: ${staleBundle.message}
28489
+ `);
28335
28490
  var flag = (name) => argv.includes(`--${name}`);
28336
28491
  var value = (name) => {
28337
28492
  const i = argv.indexOf(`--${name}`);
@@ -28459,7 +28614,7 @@ if (command === "provision") {
28459
28614
  process.exit(outcome.code);
28460
28615
  }
28461
28616
  if (command === "pool-member") {
28462
- const pool = poolConfigFrom(argv, process.env, () => readFileSync53(0, "utf8"));
28617
+ const pool = poolConfigFrom(argv, process.env, () => readFileSync54(0, "utf8"));
28463
28618
  if (typeof pool === "string") {
28464
28619
  process.stderr.write(`crew pool-member: ${pool}
28465
28620
  `);
@@ -28780,7 +28935,7 @@ if (command === "passenger-sync-daemon") {
28780
28935
  } else {
28781
28936
  const toleratesNoRoutes = command === "credential" || command === "forge" || command === "repos" || command === "ship" || command === "disconnect" && flag("reset") || command === "deprovision" || command === "connect" && flag("sign-out");
28782
28937
  const configless = command === "connect" && flag("sign-out") || command === "disconnect" && flag("reset") || command === "deprovision";
28783
- if (configless && !existsSync58(findConfigFile(CREW_HOME))) {
28938
+ if (configless && !existsSync59(findConfigFile(CREW_HOME))) {
28784
28939
  cfg = loadConfig(CREW_HOME, firstRunConfigPath(), { text: "ship: {}\n", allowNoRoutes: true });
28785
28940
  } else {
28786
28941
  cfg = loadConfig(CREW_HOME, void 0, toleratesNoRoutes ? { allowNoRoutes: true } : {});
@@ -28803,7 +28958,7 @@ if (command === "passenger-sync-daemon") {
28803
28958
  throw e;
28804
28959
  }
28805
28960
  if (command === "credential") {
28806
- const r = runCredential(positional[1], readFileSync53(0, "utf8"), cfg.ship.forges, cfg.ship.stateDir, process.env, !flag("no-miss"));
28961
+ const r = runCredential(positional[1], readFileSync54(0, "utf8"), cfg.ship.forges, cfg.ship.stateDir, process.env, !flag("no-miss"));
28807
28962
  process.stdout.write(r.out);
28808
28963
  process.stderr.write(r.err);
28809
28964
  process.exit(r.code);
@@ -28815,9 +28970,9 @@ if (command === "passenger-sync-daemon") {
28815
28970
  forges: cfg.ship.forges,
28816
28971
  stateDir: cfg.ship.stateDir,
28817
28972
  configFile: cfg.configFile,
28818
- readFile: (p) => readFileSync53(p, "utf8"),
28973
+ readFile: (p) => readFileSync54(p, "utf8"),
28819
28974
  writeFile: (p, t) => writeFileSync42(p, t),
28820
- stdin: () => readFileSync53(0, "utf8"),
28975
+ stdin: () => readFileSync54(0, "utf8"),
28821
28976
  env: process.env
28822
28977
  }
28823
28978
  );
@@ -28969,6 +29124,10 @@ if (command === "passenger-sync-daemon") {
28969
29124
  apiKeys: passengerApiKeys(apiRoutes),
28970
29125
  controlSocket: controlSocketFor(cfg.ship.stateDir),
28971
29126
  onStatus: (workspaceId, status2, info) => {
29127
+ if (status2 === "disconnected" && !planned.has(workspaceId)) {
29128
+ clearShipAttention(state, `${TUNNEL_REJECTED_KEY}:${workspaceId}`);
29129
+ clearShipAttention(state, `${RELAY_CONTROL_UNSUPPORTED_KEY}:${workspaceId}`);
29130
+ }
28972
29131
  const owningRoute = apiRoutes.find((r) => r.resolved?.workspaceId === workspaceId);
28973
29132
  if (!owningRoute) return;
28974
29133
  pending.push(
@@ -29000,6 +29159,7 @@ if (command === "passenger-sync-daemon") {
29000
29159
  for (const plan of containerPlans) pending.push(reconcileEndpoint(plan.workspaceId, reconcile));
29001
29160
  for (const plan of plans) pending.push(reconcileRelayUrl(plan.workspaceId, apiRoutes));
29002
29161
  await Promise.all(pending);
29162
+ for (const key of staleTunnelAttentionKeys(openShipAttention(state).map((i) => i.key), planned)) clearShipAttention(state, key);
29003
29163
  await reconcilePeriscopeEndpoints();
29004
29164
  } catch (e) {
29005
29165
  emit.warn(`ship tunnel sync failed: ${e.message}`, { step: "passengers" });
@@ -29151,14 +29311,14 @@ if (command === "passenger-sync-daemon") {
29151
29311
  }
29152
29312
  if (host === "linux" && hasSystemd) {
29153
29313
  const label = labelFor(CREW_HOME, "run");
29154
- const staleTimer = join61(homedir11(), ".config", "systemd", "user", `${label}.timer`);
29155
- if (existsSync58(staleTimer)) {
29314
+ const staleTimer = join62(homedir11(), ".config", "systemd", "user", `${label}.timer`);
29315
+ if (existsSync59(staleTimer)) {
29156
29316
  process.stdout.write(
29157
29317
  `removing stale run timer from before the persistent-service cutover: ${staleTimer}${dryRun ? " (dry run)" : ""}
29158
29318
  `
29159
29319
  );
29160
29320
  if (!dryRun) {
29161
- spawnSync13("systemctl", ["--user", "disable", "--now", `${label}.timer`], { cwd: CREW_HOME, env: withUserBusEnv() });
29321
+ spawnSync14("systemctl", ["--user", "disable", "--now", `${label}.timer`], { cwd: CREW_HOME, env: withUserBusEnv() });
29162
29322
  try {
29163
29323
  unlinkSync6(staleTimer);
29164
29324
  } catch {
@@ -29181,7 +29341,7 @@ if (command === "passenger-sync-daemon") {
29181
29341
  const { settled: doctorRepos, errors: refusedRepos } = await settleRepos(reposOf(c), (t) => t.name, (t) => resolveOneRepo(c, t));
29182
29342
  for (const e of refusedRepos) problems.push(`repo ${e.repo}: ${e.detail}`);
29183
29343
  for (const r of doctorRepos) {
29184
- if (!existsSync58(r.dir)) problems.push(`repo ${r.name}: ${r.dir} is missing on disk`);
29344
+ if (!existsSync59(r.dir)) problems.push(`repo ${r.name}: ${r.dir} is missing on disk`);
29185
29345
  if (!satisfies(host, r.config.platform)) problems.push(`repo ${r.name}: requires ${r.config.platform}, this host is ${host}`);
29186
29346
  readiness.push(...validateEffective(r.config).map((p) => `repo ${r.name}: ${p}`));
29187
29347
  }
@@ -29217,8 +29377,8 @@ if (command === "passenger-sync-daemon") {
29217
29377
  }
29218
29378
  async function doctorFix(o) {
29219
29379
  const routes = await Promise.all(routesInScope(cfg.routes, named).map((c) => gatherHealth({ route: c.route, enabled: c.enabled, hasRepos: reposOf(c).length > 0 }, () => routeProblems(c))));
29220
- const unitExists = (p) => existsSync58(p);
29221
- const crontab = o.host === "linux" ? spawnSync13("crontab", ["-l"], { encoding: "utf8" }).stdout ?? "" : "";
29380
+ const unitExists = (p) => existsSync59(p);
29381
+ const crontab = o.host === "linux" ? spawnSync14("crontab", ["-l"], { encoding: "utf8" }).stdout ?? "" : "";
29222
29382
  const schedulerAbsent = o.host !== "windows" ? !schedulerInstalled(planInstall(cfg.ship, CREW_HOME, o.host, detectSystemd(), "run", installContext()), unitExists, crontab) : true;
29223
29383
  const plan = planFix({ routes, schedulerAbsent, host: o.host });
29224
29384
  for (const n of plan.notes) process.stdout.write(`fix: ${n}
@@ -29234,7 +29394,7 @@ if (command === "passenger-sync-daemon") {
29234
29394
  for (const a of plan.actions) {
29235
29395
  if (a.kind === "enable") {
29236
29396
  if (prompter && !await prompter.confirm(`Route ${a.route} passes every check \u2014 set enabled: true in ${cfg.configFile}?`, false)) continue;
29237
- writeFileSync42(cfg.configFile, planEnable(readFileSync53(cfg.configFile, "utf8"), a.route));
29397
+ writeFileSync42(cfg.configFile, planEnable(readFileSync54(cfg.configFile, "utf8"), a.route));
29238
29398
  enabledSound.add(a.route);
29239
29399
  changed2.push(`enabled route ${a.route} in ${cfg.configFile}`);
29240
29400
  } else {
@@ -29463,7 +29623,7 @@ ${changed2.map((c) => ` - ${c}
29463
29623
  harnessBin: "claude",
29464
29624
  ...contract.sandboxNetwork ? { extraHosts: contract.sandboxNetwork.hosts, toolchains: contract.sandboxNetwork.toolchains } : {}
29465
29625
  },
29466
- policyFile: join61(cfg.ship.stateDir, "release", `${target.name}.policy.yaml`),
29626
+ policyFile: join62(cfg.ship.stateDir, "release", `${target.name}.policy.yaml`),
29467
29627
  repo: mirror,
29468
29628
  origin: forgeDescriptorFor(forgeHost).httpsUrl(mirror.host, mirror.path),
29469
29629
  base: effective.branch.base,
@@ -30567,6 +30727,41 @@ ${f.tail.trimEnd()}
30567
30727
  );
30568
30728
  break;
30569
30729
  }
30730
+ const launchdStart = (o) => {
30731
+ const runPlan = planInstall(cfg.ship, CREW_HOME, host, detectSystemd(), "run", installContext());
30732
+ const label = labelFor(CREW_HOME, "run");
30733
+ const r = startLaunchdDaemon({
30734
+ unitPath: runPlan.unitPaths[0],
30735
+ label,
30736
+ uid: process.getuid?.() ?? 0,
30737
+ schedulerLog: runPlan.schedulerLog,
30738
+ dryRun,
30739
+ ...o,
30740
+ run: (c) => {
30741
+ const res2 = spawnSync14(c[0], c.slice(1), { cwd: CREW_HOME, encoding: "utf8", env: withUserBusEnv() });
30742
+ return res2.error ? null : { status: res2.status, stdout: res2.stdout ?? "", stderr: res2.stderr ?? "" };
30743
+ }
30744
+ });
30745
+ if (r.stdout) process.stdout.write(r.stdout);
30746
+ if (r.stderr) process.stderr.write(r.stderr);
30747
+ process.exitCode = r.exitCode;
30748
+ return true;
30749
+ };
30750
+ if (control.mechanism === "launchd" && daemonSub === "start") {
30751
+ launchdStart({});
30752
+ break;
30753
+ }
30754
+ if (control.mechanism === "launchd" && daemonSub === "restart") {
30755
+ if (dryRun) process.stdout.write(`would run: ${control.stopCommand.join(" ")}
30756
+ `);
30757
+ else {
30758
+ const res2 = spawnSync14(control.stopCommand[0], control.stopCommand.slice(1), { cwd: CREW_HOME, encoding: "utf8", env: withUserBusEnv() });
30759
+ if (res2.stdout) process.stdout.write(res2.stdout);
30760
+ if (res2.stderr) process.stderr.write(res2.stderr);
30761
+ }
30762
+ launchdStart({ verifyAfterLoad: true, assumeUnloaded: true });
30763
+ break;
30764
+ }
30570
30765
  if (daemonSub === "restart") {
30571
30766
  const commands = [control.stopCommand, control.startCommand];
30572
30767
  if (dryRun) {
@@ -30576,7 +30771,7 @@ ${f.tail.trimEnd()}
30576
30771
  }
30577
30772
  let failed = false;
30578
30773
  for (const cmd2 of commands) {
30579
- const res2 = spawnSync13(cmd2[0], cmd2.slice(1), { cwd: CREW_HOME, encoding: "utf8", env: withUserBusEnv() });
30774
+ const res2 = spawnSync14(cmd2[0], cmd2.slice(1), { cwd: CREW_HOME, encoding: "utf8", env: withUserBusEnv() });
30580
30775
  if (res2.stdout) process.stdout.write(res2.stdout);
30581
30776
  if (res2.stderr) process.stderr.write(res2.stderr);
30582
30777
  if (cmd2 === control.startCommand && (res2.error || res2.status !== 0)) {
@@ -30594,7 +30789,7 @@ ${f.tail.trimEnd()}
30594
30789
  `);
30595
30790
  break;
30596
30791
  }
30597
- const res = spawnSync13(cmd[0], cmd.slice(1), { cwd: CREW_HOME, encoding: "utf8", env: withUserBusEnv() });
30792
+ const res = spawnSync14(cmd[0], cmd.slice(1), { cwd: CREW_HOME, encoding: "utf8", env: withUserBusEnv() });
30598
30793
  if (res.stdout) process.stdout.write(res.stdout);
30599
30794
  if (res.stderr) process.stderr.write(res.stderr);
30600
30795
  if (daemonSub !== "status" && (res.error || res.status !== 0)) {
@@ -30610,7 +30805,20 @@ ${f.tail.trimEnd()}
30610
30805
  process.stderr.write("crew: daemon does not support --dry-run \u2014 it only ever performs real cycles.\n");
30611
30806
  process.exit(2);
30612
30807
  }
30613
- requireArmed("run the daemon loop");
30808
+ if (!fleetWide && !route2.enabled) {
30809
+ const reason = `route "${route2.route}" is not enabled in ${cfg.configFile} \u2014 refusing to run the daemon loop`;
30810
+ process.stderr.write(`crew: ${reason}.
30811
+ `);
30812
+ await failDaemonStart({
30813
+ stateDir: cfg.ship.stateDir,
30814
+ reason,
30815
+ fix: `Set \`enabled: true\` on route "${route2.route}" in crew.yaml, or name an enabled route in the unit`,
30816
+ code: 1,
30817
+ routes: cfg.routes,
30818
+ ship: cfg.ship,
30819
+ logFile: cfg.ship.logFile
30820
+ });
30821
+ }
30614
30822
  const daemonRoutes = fleetWide ? cfg.routes.filter((r) => r.enabled) : [route2];
30615
30823
  if (!daemonRoutes.length) {
30616
30824
  emit.error("no enabled routes \u2014 nothing for the daemon to serve");
@@ -30682,7 +30890,7 @@ ${f.tail.trimEnd()}
30682
30890
  logFile: cfg.ship.logFile
30683
30891
  });
30684
30892
  }
30685
- const watchPaths = isCompiledBinary(import.meta.url) ? [process.execPath] : [join61(CREW_HOME, "src"), join61(CREW_HOME, "dist"), join61(CREW_HOME, "bin")];
30893
+ const watchPaths = isCompiledBinary(import.meta.url) ? [process.execPath] : [join62(CREW_HOME, "src"), join62(CREW_HOME, "dist"), join62(CREW_HOME, "bin")];
30686
30894
  const configPaths = daemonConfigPaths(cfg);
30687
30895
  watchPaths.push(...configPaths);
30688
30896
  noteDaemonStarted(cfg.ship.stateDir);
@@ -31020,7 +31228,7 @@ ${f.tail.trimEnd()}
31020
31228
  `);
31021
31229
  if (!dryRun) {
31022
31230
  const resolvedPath = resolvedPathFor(cfg.ship.stateDir, target.route);
31023
- const raw = existsSync58(resolvedPath) ? JSON.parse(readFileSync53(resolvedPath, "utf8")) : {};
31231
+ const raw = existsSync59(resolvedPath) ? JSON.parse(readFileSync54(resolvedPath, "utf8")) : {};
31024
31232
  raw.agentSkills = result.agentSkills;
31025
31233
  mkdirSync42(dirOf2(resolvedPath), { recursive: true });
31026
31234
  writeFileSync42(resolvedPath, `${JSON.stringify(raw, null, 2)}
@@ -31046,7 +31254,7 @@ ${f.tail.trimEnd()}
31046
31254
  throw e;
31047
31255
  }
31048
31256
  const oldName = cfg.ship.name;
31049
- writeFileSync42(cfg.configFile, setShipNameInYaml(readFileSync53(cfg.configFile, "utf8"), newName));
31257
+ writeFileSync42(cfg.configFile, setShipNameInYaml(readFileSync54(cfg.configFile, "utf8"), newName));
31050
31258
  cfg.ship.name = newName;
31051
31259
  let renameMachineId;
31052
31260
  try {
@@ -31093,7 +31301,7 @@ ${f.tail.trimEnd()}
31093
31301
  process.exit(2);
31094
31302
  };
31095
31303
  if (sub !== "add" && sub !== "list" && sub !== "clone" && sub !== "hooks" && sub !== "check") usage2();
31096
- const configText = readFileSync53(cfg.configFile, "utf8");
31304
+ const configText = readFileSync54(cfg.configFile, "utf8");
31097
31305
  if (sub === "check") {
31098
31306
  try {
31099
31307
  const routeArg = value("route") ?? positional[2];
@@ -31125,16 +31333,16 @@ ${f.tail.trimEnd()}
31125
31333
  try {
31126
31334
  const a = parseHooksArgs(positional.slice(2), routeNamesOf(configText));
31127
31335
  const dir = repoDirOf(configText, dirname37(cfg.configFile), a.route, a.name);
31128
- if (!existsSync58(dir)) throw new ReposError(`${dir} does not exist on disk`);
31129
- const files = { exists: (r) => existsSync58(resolvePath(dir, r)), list: (r) => {
31336
+ if (!existsSync59(dir)) throw new ReposError(`${dir} does not exist on disk`);
31337
+ const files = { exists: (r) => existsSync59(resolvePath(dir, r)), list: (r) => {
31130
31338
  try {
31131
- return readdirSync20(resolvePath(dir, r));
31339
+ return readdirSync21(resolvePath(dir, r));
31132
31340
  } catch {
31133
31341
  return [];
31134
31342
  }
31135
31343
  }, read: (r) => {
31136
31344
  try {
31137
- return readFileSync53(resolvePath(dir, r), "utf8");
31345
+ return readFileSync54(resolvePath(dir, r), "utf8");
31138
31346
  } catch {
31139
31347
  return void 0;
31140
31348
  }
@@ -31244,7 +31452,7 @@ ${f.tail.trimEnd()}
31244
31452
  if (sub === "list" && !routeName) usage2();
31245
31453
  if (sub === "add") {
31246
31454
  try {
31247
- const a = parseAddArgs(positional.slice(2), routeNamesOf(configText), (p) => existsSync58(resolvePath(p.replace(/^~(?=\/|$)/, homedir11()))));
31455
+ const a = parseAddArgs(positional.slice(2), routeNamesOf(configText), (p) => existsSync59(resolvePath(p.replace(/^~(?=\/|$)/, homedir11()))));
31248
31456
  routeName = a.route;
31249
31457
  addPath = a.path;
31250
31458
  addName = a.name;
@@ -31274,7 +31482,7 @@ ${f.tail.trimEnd()}
31274
31482
  const resolvedFile = resolvedPathFor(cfg.ship.stateDir, routeName);
31275
31483
  if (sub === "list" || sub === "add") {
31276
31484
  const liveRoute = cfg.routes.find((r) => r.route === routeName);
31277
- if (liveRoute?.resolved?.reposModelId && existsSync58(resolvedFile) && !dryRun) {
31485
+ if (liveRoute?.resolved?.reposModelId && existsSync59(resolvedFile) && !dryRun) {
31278
31486
  try {
31279
31487
  await hydrateApiKeys([liveRoute]);
31280
31488
  persistRepoRows(cfg.ship.stateDir, liveRoute.route, await new Tracker(liveRoute, cfg.ship).repoRowsForMap());
@@ -31283,16 +31491,16 @@ ${f.tail.trimEnd()}
31283
31491
  }
31284
31492
  }
31285
31493
  let resolvedRemotes;
31286
- if (existsSync58(resolvedFile)) {
31494
+ if (existsSync59(resolvedFile)) {
31287
31495
  try {
31288
- resolvedRemotes = JSON.parse(readFileSync53(resolvedFile, "utf8"));
31496
+ resolvedRemotes = JSON.parse(readFileSync54(resolvedFile, "utf8"));
31289
31497
  } catch {
31290
31498
  }
31291
31499
  }
31292
31500
  const originOf = (dir) => gitOk(dir, ["remote", "get-url", "origin"]) ?? void 0;
31293
31501
  const text2 = configText;
31294
31502
  const base = dirname37(cfg.configFile);
31295
- const isCheckout = (d) => existsSync58(`${d}/.git`);
31503
+ const isCheckout = (d) => existsSync59(`${d}/.git`);
31296
31504
  try {
31297
31505
  if (sub === "list") {
31298
31506
  if (flag("json")) {
@@ -31302,12 +31510,12 @@ ${f.tail.trimEnd()}
31302
31510
  base,
31303
31511
  resolved: resolvedRemotes,
31304
31512
  originOf,
31305
- exists: (d) => existsSync58(d),
31513
+ exists: (d) => existsSync59(d),
31306
31514
  isCheckout,
31307
31515
  repoHasHooks: (d) => REPO_CONFIG_FILENAMES.some((f) => {
31308
31516
  try {
31309
31517
  const path = resolvePath(d, f);
31310
- return Object.keys(parseRepoConfig(readFileSync53(path, "utf8"), path).hooks).length > 0;
31518
+ return Object.keys(parseRepoConfig(readFileSync54(path, "utf8"), path).hooks).length > 0;
31311
31519
  } catch {
31312
31520
  return false;
31313
31521
  }
@@ -31324,7 +31532,7 @@ ${f.tail.trimEnd()}
31324
31532
  for (const r of repos) {
31325
31533
  const origin2 = originOf(r.dir);
31326
31534
  const row = matchRepoName(origin2, resolvedRemotes);
31327
- const note = !existsSync58(r.dir) ? "missing on disk" : row ? `Repos row: ${row}` : `no Repos row matches ${normalizeRemote2(origin2) ?? "this checkout (no origin remote)"}`;
31535
+ const note = !existsSync59(r.dir) ? "missing on disk" : row ? `Repos row: ${row}` : `no Repos row matches ${normalizeRemote2(origin2) ?? "this checkout (no origin remote)"}`;
31328
31536
  process.stdout.write(`${r.name} ${r.dir} ${note}
31329
31537
  `);
31330
31538
  }
@@ -31336,9 +31544,9 @@ ${f.tail.trimEnd()}
31336
31544
  ` : `${human}
31337
31545
  `);
31338
31546
  const plan2 = planRepoClone({ text: text2, base, route: routeName, name: addName, resolved: resolvedRemotes, dir: value("dir"), isCheckout });
31339
- if (existsSync58(plan2.target) && (existsSync58(`${plan2.target}/.git`) || readdirSync20(plan2.target).length > 0)) {
31547
+ if (existsSync59(plan2.target) && (existsSync59(`${plan2.target}/.git`) || readdirSync21(plan2.target).length > 0)) {
31340
31548
  throw new ReposError(
31341
- existsSync58(`${plan2.target}/.git`) ? `${plan2.target} is already a checkout \u2014 attach it with \`crew repos add ${routeName} ${plan2.name} ${plan2.target}\`` : `${plan2.target} exists and is not empty \u2014 pass --dir to clone somewhere else`
31549
+ existsSync59(`${plan2.target}/.git`) ? `${plan2.target} is already a checkout \u2014 attach it with \`crew repos add ${routeName} ${plan2.name} ${plan2.target}\`` : `${plan2.target} exists and is not empty \u2014 pass --dir to clone somewhere else`
31342
31550
  );
31343
31551
  }
31344
31552
  if (dryRun) {
@@ -31363,7 +31571,7 @@ ${f.tail.trimEnd()}
31363
31571
  break;
31364
31572
  }
31365
31573
  const target = resolvePath(addPath.replace(/^~(?=\/|$)/, homedir11()));
31366
- const top = existsSync58(target) ? gitOk(target, ["rev-parse", "--show-toplevel"]) : null;
31574
+ const top = existsSync59(target) ? gitOk(target, ["rev-parse", "--show-toplevel"]) : null;
31367
31575
  if (!top) throw new ReposError(`${target} is not a git checkout`);
31368
31576
  const origin = originOf(top);
31369
31577
  const plan = planRepoAdd({
@@ -31415,8 +31623,8 @@ ${f.tail.trimEnd()}
31415
31623
  const created = await rowTracker.createRepoRow(rowPayload);
31416
31624
  process.stdout.write(`created Repos row ${String(rowPayload.name)} (${String(rowPayload.remote)}) ${created.id}
31417
31625
  `);
31418
- if (existsSync58(resolvedFile)) {
31419
- const raw = JSON.parse(readFileSync53(resolvedFile, "utf8"));
31626
+ if (existsSync59(resolvedFile)) {
31627
+ const raw = JSON.parse(readFileSync54(resolvedFile, "utf8"));
31420
31628
  raw.repoNames = { ...raw.repoNames, [created.id]: String(rowPayload.name) };
31421
31629
  raw.repoRemotes = { ...raw.repoRemotes, [created.id]: String(rowPayload.remote) };
31422
31630
  writeFileSync42(resolvedFile, `${JSON.stringify(raw, null, 2)}
@@ -31798,7 +32006,7 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
31798
32006
  process.exit(2);
31799
32007
  }
31800
32008
  if (found.shipNameAdopted && !dryRun) {
31801
- writeFileSync42(cfg.configFile, setShipNameInYaml(readFileSync53(cfg.configFile, "utf8"), found.shipNameAdopted));
32009
+ writeFileSync42(cfg.configFile, setShipNameInYaml(readFileSync54(cfg.configFile, "utf8"), found.shipNameAdopted));
31802
32010
  cfg.ship.name = found.shipNameAdopted;
31803
32011
  }
31804
32012
  if (found.shipRow) {
@@ -31841,10 +32049,10 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
31841
32049
  }
31842
32050
  }
31843
32051
  let previous;
31844
- const hadPreviousFile = existsSync58(resolvedPath);
32052
+ const hadPreviousFile = existsSync59(resolvedPath);
31845
32053
  if (hadPreviousFile) {
31846
32054
  try {
31847
- previous = JSON.parse(readFileSync53(resolvedPath, "utf8"));
32055
+ previous = JSON.parse(readFileSync54(resolvedPath, "utf8"));
31848
32056
  } catch {
31849
32057
  }
31850
32058
  }
@@ -32739,10 +32947,10 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
32739
32947
  startupSeconds: cfg.ship.intelStartupSeconds,
32740
32948
  prepare: async (path) => {
32741
32949
  for (const f of repoWt.config.worktrees.copy) {
32742
- const src = join61(repoWt.dir, f);
32743
- if (!existsSync58(src) || existsSync58(join61(path, f))) continue;
32744
- mkdirSync42(dirOf2(join61(path, f)), { recursive: true });
32745
- copyFileSync2(src, join61(path, f));
32950
+ const src = join62(repoWt.dir, f);
32951
+ if (!existsSync59(src) || existsSync59(join62(path, f))) continue;
32952
+ mkdirSync42(dirOf2(join62(path, f)), { recursive: true });
32953
+ copyFileSync2(src, join62(path, f));
32746
32954
  }
32747
32955
  const setup = repoWt.config.hooks.setup;
32748
32956
  return setup ? runScript(setup, { cwd: path, shell: shellWt }) : null;
@@ -32968,7 +33176,7 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
32968
33176
  const shellR = hit && resolveShell(hit.repo.config.shell ?? cfg.ship.shell);
32969
33177
  const resumed = await runPeriscopeResume({
32970
33178
  find: async () => hit && { row: hit.row, tag: hit.tag },
32971
- worktreeExists: (p) => existsSync58(p),
33179
+ worktreeExists: (p) => existsSync59(p),
32972
33180
  prepareDropFile,
32973
33181
  startProxy: (wt, url, n) => launchProxy(crewInvocation(CREW_HOME), wt, url, Number(n), { host: hit.row.host || "localhost", inject: hit.repo.config.periscope?.inspector !== "repo" }),
32974
33182
  relay: hit && previewRelayFor(hit.route) && {
@@ -33071,10 +33279,10 @@ ${where.join("\n")}`);
33071
33279
  },
33072
33280
  prepare: async (path) => {
33073
33281
  for (const f of repoP.config.worktrees.copy) {
33074
- const src = join61(repoP.dir, f);
33075
- if (!existsSync58(src)) continue;
33076
- mkdirSync42(dirOf2(join61(path, f)), { recursive: true });
33077
- copyFileSync2(src, join61(path, f));
33282
+ const src = join62(repoP.dir, f);
33283
+ if (!existsSync59(src)) continue;
33284
+ mkdirSync42(dirOf2(join62(path, f)), { recursive: true });
33285
+ copyFileSync2(src, join62(path, f));
33078
33286
  }
33079
33287
  const setup = repoP.config.hooks.setup;
33080
33288
  return setup ? runScript(setup, { cwd: path, shell: shellP, onLine: (l) => {
@@ -33185,7 +33393,7 @@ ${where.join("\n")}`);
33185
33393
  process.stdout.write(upOutput(res, terminal));
33186
33394
  const opener = openerFor(process.platform);
33187
33395
  if (opener && shouldOpen({ open: flag("open"), noOpen: flag("no-open"), json: jsonP, terminal })) {
33188
- const r = spawnSync13(opener, [res.url], { stdio: "ignore" });
33396
+ const r = spawnSync14(opener, [res.url], { stdio: "ignore" });
33189
33397
  if (r.error || r.status !== 0) process.stderr.write(`crew periscope: could not open ${res.url} with ${opener}
33190
33398
  `);
33191
33399
  }
@@ -33386,7 +33594,7 @@ ${where.join("\n")}`);
33386
33594
  };
33387
33595
  const droppedRoutes = [];
33388
33596
  try {
33389
- const rawCfg = parseYaml3(readFileSync53(cfg.configFile, "utf8"));
33597
+ const rawCfg = parseYaml3(readFileSync54(cfg.configFile, "utf8"));
33390
33598
  for (const r of rawCfg?.routes ?? []) {
33391
33599
  if (typeof r?.route !== "string" || cfg.routes.some((x) => x.route === r.route)) continue;
33392
33600
  try {
@@ -33433,10 +33641,10 @@ ${where.join("\n")}`);
33433
33641
  }
33434
33642
  const host = hostPlatform();
33435
33643
  const control = host === "windows" ? null : planDaemonControl(CREW_HOME, host, detectSystemd());
33436
- const unitStatus = control?.statusCommand ? spawnSync13(control.statusCommand[0], control.statusCommand.slice(1), { cwd: CREW_HOME, encoding: "utf8", env: withUserBusEnv() }) : null;
33644
+ const unitStatus = control?.statusCommand ? spawnSync14(control.statusCommand[0], control.statusCommand.slice(1), { cwd: CREW_HOME, encoding: "utf8", env: withUserBusEnv() }) : null;
33437
33645
  const unitRunning = unitStatus !== null && !unitStatus.error && unitStatus.status === 0;
33438
33646
  if (!unitRunning && control?.mechanism === "systemd" && control.startCommand) {
33439
- const res = spawnSync13(control.startCommand[0], control.startCommand.slice(1), { cwd: CREW_HOME, encoding: "utf8" });
33647
+ const res = spawnSync14(control.startCommand[0], control.startCommand.slice(1), { cwd: CREW_HOME, encoding: "utf8" });
33440
33648
  if (res.error || res.status !== 0) {
33441
33649
  process.stderr.write(`crew reload: ${control.startCommand.join(" ")} exited ${res.status ?? "error"}
33442
33650
  `);
@@ -33458,7 +33666,7 @@ ${where.join("\n")}`);
33458
33666
  );
33459
33667
  if (flag("now") && control?.stopCommand && control.startCommand) {
33460
33668
  for (const cmd of [control.stopCommand, control.startCommand]) {
33461
- const res = spawnSync13(cmd[0], cmd.slice(1), { cwd: CREW_HOME, encoding: "utf8", env: withUserBusEnv() });
33669
+ const res = spawnSync14(cmd[0], cmd.slice(1), { cwd: CREW_HOME, encoding: "utf8", env: withUserBusEnv() });
33462
33670
  if (cmd === control.startCommand && (res.error || res.status !== 0)) {
33463
33671
  process.stderr.write(`crew reload: ${cmd.join(" ")} exited ${res.status ?? "error"}
33464
33672
  `);
@@ -33516,7 +33724,7 @@ ${where.join("\n")}`);
33516
33724
  }
33517
33725
  case "log": {
33518
33726
  try {
33519
- const text2 = readFileSync53(cfg.ship.logFile, "utf8").split("\n");
33727
+ const text2 = readFileSync54(cfg.ship.logFile, "utf8").split("\n");
33520
33728
  process.stdout.write(`${text2.slice(-(Number(value("tail")) || 40)).join("\n")}
33521
33729
  `);
33522
33730
  } catch {
@@ -33539,7 +33747,7 @@ ${where.join("\n")}`);
33539
33747
  };
33540
33748
  if (!route2.resolved) fail2(`route ${route2.route} is not connected \u2014 run \`crew connect\` first`);
33541
33749
  const tracker = new Tracker(route2, cfg.ship);
33542
- const configText = readFileSync53(cfg.configFile, "utf8");
33750
+ const configText = readFileSync54(cfg.configFile, "utf8");
33543
33751
  const cfgBase = dirname37(cfg.configFile);
33544
33752
  const configured2 = configuredRepos(configText, route2.route, cfgBase);
33545
33753
  const dir = configured2.find((r) => r.name === SAMPLE_REPO)?.dir ?? sampleDir(configured2.map((r) => r.dir), route2.reposBasePath, route2.route.split("/")[0]);
@@ -33576,31 +33784,31 @@ ${where.join("\n")}`);
33576
33784
  }
33577
33785
  if (row) {
33578
33786
  await tracker.deleteRepoRow(row.id);
33579
- if (existsSync58(resolvedFile)) {
33580
- const raw = JSON.parse(readFileSync53(resolvedFile, "utf8"));
33787
+ if (existsSync59(resolvedFile)) {
33788
+ const raw = JSON.parse(readFileSync54(resolvedFile, "utf8"));
33581
33789
  if (raw.repoNames) delete raw.repoNames[row.id];
33582
33790
  if (raw.repoRemotes) delete raw.repoRemotes[row.id];
33583
33791
  writeFileSync42(resolvedFile, `${JSON.stringify(raw, null, 2)}
33584
33792
  `);
33585
33793
  }
33586
33794
  }
33587
- if (existsSync58(join61(dir, ".git")) && basename17(dir) === SAMPLE_REPO) rmSync26(dir, { recursive: true, force: true });
33795
+ if (existsSync59(join62(dir, ".git")) && basename17(dir) === SAMPLE_REPO) rmSync26(dir, { recursive: true, force: true });
33588
33796
  say("removed", { dir, closed }, `removed the sample repo${closed.length ? `, closed ${closed.join(", ")}` : ""}`);
33589
33797
  break;
33590
33798
  }
33591
33799
  const projectId = route2.resolved.areaId ?? resolveRepoProject(await tracker.projectRows(), value("project"));
33592
- const fresh = !existsSync58(join61(dir, ".git"));
33593
- if (existsSync58(dir) && fresh && readdirSync20(dir).length > 0) fail2(`${dir} exists and is not a git checkout \u2014 move it aside`);
33800
+ const fresh = !existsSync59(join62(dir, ".git"));
33801
+ if (existsSync59(dir) && fresh && readdirSync21(dir).length > 0) fail2(`${dir} exists and is not a git checkout \u2014 move it aside`);
33594
33802
  if (dryRun) {
33595
33803
  say("dry-run", { dir, newCheckout: fresh, repoRow: row?.id ?? null }, `would ${fresh ? "create" : "reuse"} ${dir}${row ? "" : ", create the Repos row"}, and file one ${tracker.contract.statuses.approved} ticket`);
33596
33804
  break;
33597
33805
  }
33598
33806
  if (fresh) {
33599
33807
  mkdirSync42(dir, { recursive: true });
33600
- writeFileSync42(join61(dir, "README.md"), SAMPLE_README);
33601
- writeFileSync42(join61(dir, ".crew.yaml"), SAMPLE_CREW_YAML);
33808
+ writeFileSync42(join62(dir, "README.md"), SAMPLE_README);
33809
+ writeFileSync42(join62(dir, ".crew.yaml"), SAMPLE_CREW_YAML);
33602
33810
  const g = (...a) => {
33603
- const r = spawnSync13("git", a, { cwd: dir, encoding: "utf8" });
33811
+ const r = spawnSync14("git", a, { cwd: dir, encoding: "utf8" });
33604
33812
  if (r.status !== 0) fail2(`git ${a[0]} failed in ${dir}: ${(r.stderr || r.stdout).trim()}`);
33605
33813
  };
33606
33814
  g("init", "-b", "main");
@@ -33616,8 +33824,8 @@ ${where.join("\n")}`);
33616
33824
  spec: { platform: "unix", releaseMode: "integrate", ciProvider: "none" }
33617
33825
  });
33618
33826
  repoId = (await tracker.createRepoRow(payload)).id;
33619
- if (existsSync58(resolvedFile)) {
33620
- const raw = JSON.parse(readFileSync53(resolvedFile, "utf8"));
33827
+ if (existsSync59(resolvedFile)) {
33828
+ const raw = JSON.parse(readFileSync54(resolvedFile, "utf8"));
33621
33829
  raw.repoNames = { ...raw.repoNames, [repoId]: SAMPLE_REPO };
33622
33830
  raw.repoRemotes = { ...raw.repoRemotes, [repoId]: SAMPLE_REMOTE };
33623
33831
  writeFileSync42(resolvedFile, `${JSON.stringify(raw, null, 2)}
@@ -33995,7 +34203,7 @@ watermark: ${state.watermark(routeSlug(route2.route))}
33995
34203
  plan,
33996
34204
  label,
33997
34205
  uid: process.getuid?.() ?? 0,
33998
- system: plan.mechanism === "systemd" && existsSync58(systemUnitPathFor(label)),
34206
+ system: plan.mechanism === "systemd" && existsSync59(systemUnitPathFor(label)),
33999
34207
  stamp: readDaemonStamp(cfg.ship.stateDir)
34000
34208
  });
34001
34209
  })();
@@ -34011,7 +34219,7 @@ watermark: ${state.watermark(routeSlug(route2.route))}
34011
34219
  }
34012
34220
  for (const r of repos) {
34013
34221
  const remote = r.config.branch.remote;
34014
- if (existsSync58(r.dir)) {
34222
+ if (existsSync59(r.dir)) {
34015
34223
  pushAuth.push({
34016
34224
  route: c.route,
34017
34225
  repo: r.name,
@@ -34094,7 +34302,8 @@ watermark: ${state.watermark(routeSlug(route2.route))}
34094
34302
  if (dp) problems.push(dp);
34095
34303
  else passed++;
34096
34304
  }
34097
- const runtimeDir = runtimeDirWarning(process.platform, process.getuid?.() ?? null, existsSync58, userInfo2().username);
34305
+ if (staleBundle) problems.push({ severity: "blocker", kind: "stale_bundle", message: staleBundle.message, remedy: "npm run build" });
34306
+ const runtimeDir = runtimeDirWarning(process.platform, process.getuid?.() ?? null, existsSync59, userInfo2().username);
34098
34307
  if (runtimeDir) problems.push({ severity: "attention", kind: "runtime_dir_missing", message: runtimeDir });
34099
34308
  if (!flag("offline")) {
34100
34309
  const shipKind = await doctorShipKind(route2, cfg.ship);
@@ -34140,6 +34349,11 @@ watermark: ${state.watermark(routeSlug(route2.route))}
34140
34349
  routes: ${cfg.routes.map((c) => c.route).join(", ")}
34141
34350
  `
34142
34351
  );
34352
+ if (staleBundle) {
34353
+ process.stdout.write(`bundle: BLOCKER ${staleBundle.message}
34354
+ `);
34355
+ process.exitCode = 1;
34356
+ }
34143
34357
  for (const w of roleCapWarnings(cfg.ship)) process.stdout.write(`role concurrency: WARN ${w}
34144
34358
  `);
34145
34359
  for (const r of cfg.routes) for (const f of routeAvatarFailures(cfg.ship.stateDir, r.route)) process.stdout.write(`persona avatar: WARN ${r.route}: ${f.role} avatar failed to upload (${f.detail}); run \`crew agents sync\` again
@@ -34161,7 +34375,7 @@ routes: ${cfg.routes.map((c) => c.route).join(", ")}
34161
34375
  }
34162
34376
  try {
34163
34377
  const evFile = eventFileFor(cfg.ship.stateDir);
34164
- const evSize = existsSync58(evFile) ? statSync17(evFile).size : 0;
34378
+ const evSize = existsSync59(evFile) ? statSync18(evFile).size : 0;
34165
34379
  process.stdout.write(
34166
34380
  evSize > cfg.ship.eventsRotateBytes * 4 ? `events log: WARN ${evFile} is ${Math.round(evSize / 1048576)} MB (> 4x eventsRotateBytes); run \`crew reap\` to rotate it
34167
34381
  ` : "events log: ok\n"
@@ -34172,7 +34386,7 @@ routes: ${cfg.routes.map((c) => c.route).join(", ")}
34172
34386
  const unitPlan = planInstall(cfg.ship, CREW_HOME, host, detectSystemd(), "run", installContext());
34173
34387
  const abandons = unitAbandonsAgents(unitPlan, (p) => {
34174
34388
  try {
34175
- return readFileSync53(p, "utf8");
34389
+ return readFileSync54(p, "utf8");
34176
34390
  } catch {
34177
34391
  return null;
34178
34392
  }
@@ -34187,7 +34401,7 @@ routes: ${cfg.routes.map((c) => c.route).join(", ")}
34187
34401
  const pPlan = planInstall(cfg.ship, CREW_HOME, host, true, "passengers", installContext());
34188
34402
  const keeps = unitAbandonsAgents(pPlan, (p) => {
34189
34403
  try {
34190
- return readFileSync53(p, "utf8");
34404
+ return readFileSync54(p, "utf8");
34191
34405
  } catch {
34192
34406
  return null;
34193
34407
  }
@@ -34201,8 +34415,8 @@ routes: ${cfg.routes.map((c) => c.route).join(", ")}
34201
34415
  if (host === "linux" && detectSystemd()) {
34202
34416
  const ctl = planDaemonControl(CREW_HOME, host, true);
34203
34417
  const unitPlan = planInstall(cfg.ship, CREW_HOME, host, true, "run", installContext());
34204
- if (ctl.statusCommand && unitPlan.unitPaths.some((p) => existsSync58(p))) {
34205
- const st = spawnSync13(ctl.statusCommand[0], ctl.statusCommand.slice(1), { cwd: CREW_HOME, encoding: "utf8" });
34418
+ if (ctl.statusCommand && unitPlan.unitPaths.some((p) => existsSync59(p))) {
34419
+ const st = spawnSync14(ctl.statusCommand[0], ctl.statusCommand.slice(1), { cwd: CREW_HOME, encoding: "utf8" });
34206
34420
  if (!st.error && st.status !== 0) {
34207
34421
  process.stdout.write("daemon unit: WARN installed but not running \u2014 no work is picked up; run `crew reload` (or `crew daemon start`), and `crew install` if the unit still says Restart=on-failure\n");
34208
34422
  }
@@ -34226,8 +34440,8 @@ routes: ${cfg.routes.map((c) => c.route).join(", ")}
34226
34440
  const changed2 = configChangedAfter(daemonConfigPaths(cfg), daemonStartedAt);
34227
34441
  if (changed2) {
34228
34442
  process.stdout.write(
34229
- daemonDead ? `daemon config: WARN ${changed2} changed at ${new Date(statSync17(changed2).mtimeMs).toISOString()} \u2014 no daemon is running; the new config applies when it starts
34230
- ` : `daemon config: WARN ${changed2} changed at ${new Date(statSync17(changed2).mtimeMs).toISOString()} but the daemon started at ${new Date(daemonStartedAt).toISOString()} \u2014 run \`crew reload\`
34443
+ daemonDead ? `daemon config: WARN ${changed2} changed at ${new Date(statSync18(changed2).mtimeMs).toISOString()} \u2014 no daemon is running; the new config applies when it starts
34444
+ ` : `daemon config: WARN ${changed2} changed at ${new Date(statSync18(changed2).mtimeMs).toISOString()} but the daemon started at ${new Date(daemonStartedAt).toISOString()} \u2014 run \`crew reload\`
34231
34445
  `
34232
34446
  );
34233
34447
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tablation/crew",
3
- "version": "0.143.1",
3
+ "version": "0.143.3",
4
4
  "description": "A standing team of headless agents that picks work off a Tablation board, does it on a machine you control, and reports back.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -568,7 +568,9 @@ ticket looks:
568
568
  person — a comment alone is not a stop.
569
569
 
570
570
  The decision belongs to whoever made the call on the ticket, so the digest
571
- resolves `park to` in this order and the first that resolves wins: (1) the
571
+ resolves `park to` in this order and the first that resolves wins: (0) in a
572
+ `hybrid` project, the **ship operator** of the ship currently holding the
573
+ ticket (`held_by_ship_id` is this ship); (1) the
572
574
  **acceptor**, the person who last moved the ticket into `accepted` (the
573
575
  `accepted by` column; a lane, workflow or the system promoting it does not
574
576
  count); (2) the **filer**, only when a hold or a linked person, never a