@tablation/crew 0.143.3 → 0.144.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.
Files changed (2) hide show
  1. package/dist/cli.js +456 -317
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -6936,7 +6936,7 @@ import { promisify as promisify2 } from "util";
6936
6936
 
6937
6937
  // src/deprovision-host.ts
6938
6938
  import { spawnSync as spawnSync7 } from "child_process";
6939
- import { existsSync as existsSync32, readdirSync as readdirSync12 } from "fs";
6939
+ import { existsSync as existsSync33, readdirSync as readdirSync13 } from "fs";
6940
6940
 
6941
6941
  // src/repo-env.ts
6942
6942
  import { existsSync as existsSync19, mkdirSync as mkdirSync14, readFileSync as readFileSync20, renameSync as renameSync3, rmSync as rmSync10, writeFileSync as writeFileSync15 } from "fs";
@@ -14403,15 +14403,103 @@ async function reconcileRuns(o) {
14403
14403
  }
14404
14404
 
14405
14405
  // src/live-runs.ts
14406
- import { existsSync as existsSync31, readdirSync as readdirSync11, statSync as statSync10 } from "fs";
14406
+ import { existsSync as existsSync32, readdirSync as readdirSync12, statSync as statSync11 } from "fs";
14407
+ import { join as join35 } from "path";
14408
+
14409
+ // src/run-snapshot.ts
14410
+ import { closeSync as closeSync5, existsSync as existsSync31, fstatSync, openSync as openSync5, readSync as readSync2, readdirSync as readdirSync11, statSync as statSync10, readFileSync as readFileSync32 } from "fs";
14407
14411
  import { join as join34 } from "path";
14408
- function liveRuns(stateDir, isAlive = runIsAlive) {
14412
+ var TAIL_BYTES = 256 * 1024;
14413
+ var EXCERPT_CHARS = 280;
14414
+ function lastStreamEvent(streamPath) {
14415
+ let fd;
14416
+ try {
14417
+ fd = openSync5(streamPath, "r");
14418
+ } catch {
14419
+ return null;
14420
+ }
14421
+ try {
14422
+ const st = fstatSync(fd);
14423
+ const start = Math.max(0, st.size - TAIL_BYTES);
14424
+ const buf = Buffer.alloc(st.size - start);
14425
+ readSync2(fd, buf, 0, buf.length, start);
14426
+ const lines2 = buf.toString("utf8").split("\n");
14427
+ if (start > 0) lines2.shift();
14428
+ for (let i = lines2.length - 1; i >= 0; i--) {
14429
+ const line = lines2[i].trim();
14430
+ if (!line.startsWith("{")) continue;
14431
+ let parsed;
14432
+ try {
14433
+ parsed = JSON.parse(line);
14434
+ } catch {
14435
+ continue;
14436
+ }
14437
+ if (parsed.type !== "assistant" || !Array.isArray(parsed.message?.content)) continue;
14438
+ const blocks = parsed.message.content;
14439
+ for (let j = blocks.length - 1; j >= 0; j--) {
14440
+ const b = blocks[j];
14441
+ if (b.type !== "text" || !b.text?.trim()) continue;
14442
+ const text2 = b.text.replace(/\s+/g, " ").trim();
14443
+ return {
14444
+ text: text2.length > EXCERPT_CHARS ? `${text2.slice(0, EXCERPT_CHARS - 1)}\u2026` : text2,
14445
+ at: new Date(st.mtimeMs).toISOString()
14446
+ };
14447
+ }
14448
+ }
14449
+ return null;
14450
+ } catch {
14451
+ return null;
14452
+ } finally {
14453
+ closeSync5(fd);
14454
+ }
14455
+ }
14456
+ function outcomeOf(m) {
14457
+ if (m.interrupted) return "interrupted";
14458
+ return m.exitCode === void 0 || m.exitCode === null || m.exitCode === 0 ? "ok" : "failed";
14459
+ }
14460
+ function lastRunsBySeat(stateDir) {
14409
14461
  const dir = join34(stateDir, "streams");
14410
- if (!existsSync31(dir)) return [];
14411
- const out = [];
14462
+ const out = /* @__PURE__ */ new Map();
14463
+ if (!existsSync31(dir)) return out;
14412
14464
  for (const name of readdirSync11(dir)) {
14413
14465
  if (!name.endsWith(".jsonl") || name.endsWith(".events.jsonl")) continue;
14414
14466
  const streamPath = join34(dir, name);
14467
+ if (!runFinished(streamPath)) continue;
14468
+ const metaPath = `${streamPath}.meta.json`;
14469
+ let meta;
14470
+ let mtimeMs;
14471
+ try {
14472
+ meta = JSON.parse(readFileSync32(metaPath, "utf8"));
14473
+ mtimeMs = statSync10(metaPath).mtimeMs;
14474
+ } catch {
14475
+ continue;
14476
+ }
14477
+ if (!meta.route || !meta.role) continue;
14478
+ const key = `${meta.route}/${meta.role}`;
14479
+ const finishedAt = new Date(mtimeMs).toISOString();
14480
+ const have = out.get(key);
14481
+ if (have && have.finishedAt >= finishedAt) continue;
14482
+ out.set(key, {
14483
+ ticket: meta.ticket ?? null,
14484
+ startedAt: meta.startedAt ?? null,
14485
+ finishedAt,
14486
+ outcome: outcomeOf(meta),
14487
+ exitCode: meta.exitCode ?? null,
14488
+ route: meta.route,
14489
+ role: meta.role
14490
+ });
14491
+ }
14492
+ return out;
14493
+ }
14494
+
14495
+ // src/live-runs.ts
14496
+ function liveRuns(stateDir, isAlive = runIsAlive) {
14497
+ const dir = join35(stateDir, "streams");
14498
+ if (!existsSync32(dir)) return [];
14499
+ const out = [];
14500
+ for (const name of readdirSync12(dir)) {
14501
+ if (!name.endsWith(".jsonl") || name.endsWith(".events.jsonl")) continue;
14502
+ const streamPath = join35(dir, name);
14415
14503
  if (runFinished(streamPath)) continue;
14416
14504
  const sidecar = readRunSidecar(streamPath);
14417
14505
  if (!sidecar || !isAlive(sidecar)) continue;
@@ -14421,15 +14509,15 @@ function liveRuns(stateDir, isAlive = runIsAlive) {
14421
14509
  }
14422
14510
  function runActivity(stateDir, isAlive = runIsAlive) {
14423
14511
  const activeRuns = liveRuns(stateDir, isAlive).length;
14424
- const dir = join34(stateDir, "streams");
14512
+ const dir = join35(stateDir, "streams");
14425
14513
  let newest = 0;
14426
- if (existsSync31(dir)) {
14427
- for (const name of readdirSync11(dir)) {
14514
+ if (existsSync32(dir)) {
14515
+ for (const name of readdirSync12(dir)) {
14428
14516
  if (!name.endsWith(".jsonl") || name.endsWith(".events.jsonl")) continue;
14429
- const streamPath = join34(dir, name);
14517
+ const streamPath = join35(dir, name);
14430
14518
  if (!runFinished(streamPath)) continue;
14431
14519
  try {
14432
- newest = Math.max(newest, statSync10(`${streamPath}.meta.json`).mtimeMs);
14520
+ newest = Math.max(newest, statSync11(`${streamPath}.meta.json`).mtimeMs);
14433
14521
  } catch {
14434
14522
  }
14435
14523
  }
@@ -14479,7 +14567,7 @@ function describeRun(run4, route2, seatIds, worktreeOf = (d, n) => {
14479
14567
  } catch {
14480
14568
  return null;
14481
14569
  }
14482
- }) {
14570
+ }, o = {}) {
14483
14571
  const ownRoute = run4.route === routeSlug(route2.route);
14484
14572
  const repoDir = run4.repo ? reposOf(route2).find((t) => t.name === run4.repo)?.dir : void 0;
14485
14573
  const num2 = run4.ticket?.replace(/^\D+/, "") ?? "";
@@ -14496,7 +14584,14 @@ function describeRun(run4, route2, seatIds, worktreeOf = (d, n) => {
14496
14584
  deadline: run4.deadline ?? null,
14497
14585
  // CREW-3119: the harness still reads notes, and the process holding its stdin is alive.
14498
14586
  acceptsInput: !!run4.acceptsInput && pidAlive2(run4.ownerPid),
14499
- agentLogId: run4.agentLogRowId ?? null
14587
+ agentLogId: run4.agentLogRowId ?? null,
14588
+ // CREW-3247: the ticket's title, from the board (null when it could not be read).
14589
+ ticketTitle: run4.ticketRecordId ? o.titles?.get(run4.ticketRecordId) ?? null : null,
14590
+ // CREW-3247: this run's own latest text turn, so two runs of one role each have an excerpt.
14591
+ lastEvent: lastStreamEvent(run4.streamPath),
14592
+ // CREW-3247: a live run needs attention when it has outlived its wall-clock limit. A run that
14593
+ // failed is finished and reported on its seat's `lastRun` instead.
14594
+ attention: run4.deadline && Date.parse(run4.deadline) < (o.now ?? Date.now()) ? "past_deadline" : null
14500
14595
  };
14501
14596
  }
14502
14597
 
@@ -14532,7 +14627,7 @@ function realDeprovisionDeps(cfg, emit, crewHome, getStore) {
14532
14627
  if (host === "windows") return [];
14533
14628
  const ctx = installContext();
14534
14629
  const systemd = detectSystemd();
14535
- return ["run", "release", "passengers"].flatMap((job) => planInstall(cfg.ship, crewHome, host, systemd, job, ctx).unitPaths).filter((p) => existsSync32(p));
14630
+ return ["run", "release", "passengers"].flatMap((job) => planInstall(cfg.ship, crewHome, host, systemd, job, ctx).unitPaths).filter((p) => existsSync33(p));
14536
14631
  };
14537
14632
  return {
14538
14633
  liveRuns: () => liveRuns(stateDir).map((r) => ({ role: r.role, route: r.route, pid: r.pid, ticketRecordId: r.ticketRecordId ?? void 0, streamPath: r.streamPath })),
@@ -14600,11 +14695,11 @@ function realDeprovisionDeps(cfg, emit, crewHome, getStore) {
14600
14695
  },
14601
14696
  remaining() {
14602
14697
  const left = [];
14603
- if (existsSync32(cfg.configFile)) left.push(`config ${cfg.configFile}`);
14698
+ if (existsSync33(cfg.configFile)) left.push(`config ${cfg.configFile}`);
14604
14699
  for (const h of forgeHosts()) if (hasForgeToken(cfg.ship.forges, h, stateDir)) left.push(`forge token for ${h}`);
14605
14700
  if (hasRepositoryEnv(stateDir)) left.push("repository environment");
14606
14701
  try {
14607
- for (const k of readdirSync12(keysDir(stateDir))) left.push(`seat key ${k}`);
14702
+ for (const k of readdirSync13(keysDir(stateDir))) left.push(`seat key ${k}`);
14608
14703
  } catch {
14609
14704
  }
14610
14705
  for (const s of sandboxes()) left.push(`sandbox ${s}`);
@@ -15425,9 +15520,9 @@ function managedGitIdentityWarnings(kind, identity) {
15425
15520
 
15426
15521
  // src/selftest.ts
15427
15522
  import { spawn as spawn7 } from "child_process";
15428
- import { existsSync as existsSync33, mkdirSync as mkdirSync22, mkdtempSync as mkdtempSync2, readFileSync as readFileSync32, rmSync as rmSync17, writeFileSync as writeFileSync23 } from "fs";
15523
+ import { existsSync as existsSync34, mkdirSync as mkdirSync22, mkdtempSync as mkdtempSync2, readFileSync as readFileSync33, rmSync as rmSync17, writeFileSync as writeFileSync23 } from "fs";
15429
15524
  import { tmpdir as tmpdir5 } from "os";
15430
- import { join as join35 } from "path";
15525
+ import { join as join36 } from "path";
15431
15526
  var SELFTEST_TIMEOUT_MS = 12e4;
15432
15527
  var KEY_VAR = "CREW_API_KEY";
15433
15528
  var SELFTEST_PROMPT = "This is a read-only connectivity check. Use the tracker MCP tool to read this workspace (the workspaces find-one tool, using the workspace id below) and reply with the workspace's name alone, on one line. Do not write anything, do not create files, and do not use any other tool.\n\nWorkspace id: ";
@@ -15593,7 +15688,7 @@ async function runSelftest(i, deps = realDeps) {
15593
15688
  ...adapter.runEnv(spec),
15594
15689
  [KEY_VAR]: i.apiKey
15595
15690
  };
15596
- const cwd = mkdtempSync2(join35(tmpdir5(), "crew-selftest-"));
15691
+ const cwd = mkdtempSync2(join36(tmpdir5(), "crew-selftest-"));
15597
15692
  try {
15598
15693
  const run4 = await deps.run({
15599
15694
  bin: invocation.bin,
@@ -15626,11 +15721,11 @@ function formatResult(r) {
15626
15721
  const secs = `${(r.ms / 1e3).toFixed(1)}s`;
15627
15722
  return r.ok ? `${r.toolchain}: PASS ${r.detail} (${secs}${tok})` : `${r.toolchain}: FAIL ${r.failure} \u2014 ${r.detail} (${secs})`;
15628
15723
  }
15629
- var fileFor2 = (stateDir) => join35(stateDir, "selftest.json");
15724
+ var fileFor2 = (stateDir) => join36(stateDir, "selftest.json");
15630
15725
  function readSelftest(stateDir) {
15631
15726
  try {
15632
15727
  const p = fileFor2(stateDir);
15633
- return existsSync33(p) ? JSON.parse(readFileSync32(p, "utf8")) : {};
15728
+ return existsSync34(p) ? JSON.parse(readFileSync33(p, "utf8")) : {};
15634
15729
  } catch {
15635
15730
  return {};
15636
15731
  }
@@ -15651,7 +15746,7 @@ function doctorSelftestLines(stored, toolchains) {
15651
15746
  }
15652
15747
 
15653
15748
  // src/cli.ts
15654
- import { resolve as resolve7, dirname as dirname37, join as join62, basename as basename17 } from "path";
15749
+ import { resolve as resolve7, dirname as dirname37, join as join63, basename as basename17 } from "path";
15655
15750
  import { fileURLToPath as fileURLToPath2 } from "url";
15656
15751
  import { hostname as hostname5, homedir as homedir11, userInfo as userInfo2 } from "os";
15657
15752
  import { spawnSync as spawnSync14 } from "child_process";
@@ -15860,14 +15955,14 @@ function rosterMarkdown(roster, meId) {
15860
15955
  }
15861
15956
 
15862
15957
  // src/connect-resume.ts
15863
- import { mkdirSync as mkdirSync23, readFileSync as readFileSync33, rmSync as rmSync18, writeFileSync as writeFileSync24 } from "fs";
15864
- import { dirname as dirname17, join as join36 } from "path";
15958
+ import { mkdirSync as mkdirSync23, readFileSync as readFileSync34, rmSync as rmSync18, writeFileSync as writeFileSync24 } from "fs";
15959
+ import { dirname as dirname17, join as join37 } from "path";
15865
15960
  function lastSessionFile(stateDir) {
15866
- return join36(stateDir, "connect-session.json");
15961
+ return join37(stateDir, "connect-session.json");
15867
15962
  }
15868
15963
  function readPointers(stateDir) {
15869
15964
  try {
15870
- const parsed = JSON.parse(readFileSync33(lastSessionFile(stateDir), "utf8"));
15965
+ const parsed = JSON.parse(readFileSync34(lastSessionFile(stateDir), "utf8"));
15871
15966
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return {};
15872
15967
  const out = {};
15873
15968
  for (const [host, v] of Object.entries(parsed)) {
@@ -15967,15 +16062,15 @@ async function signOutSessions(o) {
15967
16062
  }
15968
16063
 
15969
16064
  // src/reset.ts
15970
- import { existsSync as existsSync34, mkdirSync as mkdirSync24, readFileSync as readFileSync34, readdirSync as readdirSync13, rmSync as rmSync19, statSync as statSync11, writeFileSync as writeFileSync25 } from "fs";
15971
- import { dirname as dirname18, join as join37 } from "path";
16065
+ import { existsSync as existsSync35, mkdirSync as mkdirSync24, readFileSync as readFileSync35, readdirSync as readdirSync14, rmSync as rmSync19, statSync as statSync12, writeFileSync as writeFileSync25 } from "fs";
16066
+ import { dirname as dirname18, join as join38 } from "path";
15972
16067
  import { hostFromUrl as hostFromUrl3 } from "@tablation/client";
15973
16068
  function clonedCheckoutsFile(stateDir) {
15974
- return join37(stateDir, "cloned-checkouts.json");
16069
+ return join38(stateDir, "cloned-checkouts.json");
15975
16070
  }
15976
16071
  function readClonedCheckouts(stateDir) {
15977
16072
  try {
15978
- const parsed = JSON.parse(readFileSync34(clonedCheckoutsFile(stateDir), "utf8"));
16073
+ const parsed = JSON.parse(readFileSync35(clonedCheckoutsFile(stateDir), "utf8"));
15979
16074
  return Array.isArray(parsed) ? parsed.filter((d) => typeof d === "string") : [];
15980
16075
  } catch {
15981
16076
  return [];
@@ -16040,7 +16135,7 @@ async function runReset(o, fx) {
16040
16135
  }
16041
16136
  if (o.beforeState) steps.push(...await o.beforeState());
16042
16137
  steps.push(...o.wipeState ? wipeStateDir(o.stateDir, o.dryRun) : removeState(o.stateDir, o.dryRun));
16043
- if (existsSync34(o.configFile)) {
16138
+ if (existsSync35(o.configFile)) {
16044
16139
  if (!o.dryRun) rmSync19(o.configFile, { force: true });
16045
16140
  steps.push({ step: "config", target: o.configFile, action: mark(o.dryRun) });
16046
16141
  } else {
@@ -16049,7 +16144,7 @@ async function runReset(o, fx) {
16049
16144
  return steps;
16050
16145
  }
16051
16146
  function removeCheckout(dir, dryRun, fx) {
16052
- if (!existsSync34(dir)) return { step: "checkout", target: dir, action: "absent", detail: "already gone" };
16147
+ if (!existsSync35(dir)) return { step: "checkout", target: dir, action: "absent", detail: "already gone" };
16053
16148
  const { dirty, linkedWorktrees } = fx.inspectCheckout(dir);
16054
16149
  if (dirty.length) {
16055
16150
  return { step: "checkout", target: dir, action: "kept", detail: `has uncommitted changes (${dirty.length} path${dirty.length === 1 ? "" : "s"}: ${dirty.slice(0, 5).join(", ")}${dirty.length > 5 ? ", \u2026" : ""})` };
@@ -16062,15 +16157,15 @@ function removeCheckout(dir, dryRun, fx) {
16062
16157
  }
16063
16158
  function removeState(stateDir, dryRun) {
16064
16159
  const out = [];
16065
- const targets = [join37(stateDir, "resolved"), join37(stateDir, "keys"), clonedCheckoutsFile(stateDir), join37(stateDir, "connect-session.json"), join37(stateDir, "reload-requested"), join37(stateDir, "daemon.started")];
16160
+ const targets = [join38(stateDir, "resolved"), join38(stateDir, "keys"), clonedCheckoutsFile(stateDir), join38(stateDir, "connect-session.json"), join38(stateDir, "reload-requested"), join38(stateDir, "daemon.started")];
16066
16161
  try {
16067
- for (const name of readdirSync13(stateDir)) {
16068
- if (name.startsWith(".") && statSync11(join37(stateDir, name)).isFile()) targets.push(join37(stateDir, name));
16162
+ for (const name of readdirSync14(stateDir)) {
16163
+ if (name.startsWith(".") && statSync12(join38(stateDir, name)).isFile()) targets.push(join38(stateDir, name));
16069
16164
  }
16070
16165
  } catch {
16071
16166
  }
16072
16167
  for (const t of targets) {
16073
- if (!existsSync34(t)) continue;
16168
+ if (!existsSync35(t)) continue;
16074
16169
  if (!dryRun) rmSync19(t, { recursive: true, force: true });
16075
16170
  out.push({ step: "state", target: t, action: mark(dryRun) });
16076
16171
  }
@@ -16080,12 +16175,12 @@ function removeState(stateDir, dryRun) {
16080
16175
  function wipeStateDir(stateDir, dryRun) {
16081
16176
  let names;
16082
16177
  try {
16083
- names = readdirSync13(stateDir);
16178
+ names = readdirSync14(stateDir);
16084
16179
  } catch {
16085
16180
  return [{ step: "state", target: stateDir, action: "absent", detail: "no state directory" }];
16086
16181
  }
16087
16182
  if (!names.length) return [{ step: "state", target: stateDir, action: "absent", detail: "already empty" }];
16088
- if (!dryRun) for (const n of names) rmSync19(join37(stateDir, n), { recursive: true, force: true });
16183
+ if (!dryRun) for (const n of names) rmSync19(join38(stateDir, n), { recursive: true, force: true });
16089
16184
  return [{ step: "state", target: stateDir, action: mark(dryRun), detail: `${names.length} entr${names.length === 1 ? "y" : "ies"}` }];
16090
16185
  }
16091
16186
  function describeResetStep(s) {
@@ -16167,9 +16262,9 @@ async function runDeprovision(o, fx, deps) {
16167
16262
  }
16168
16263
 
16169
16264
  // src/pool-member.ts
16170
- import { mkdirSync as mkdirSync25, readFileSync as readFileSync35, renameSync as renameSync5, writeFileSync as writeFileSync26 } from "fs";
16265
+ import { mkdirSync as mkdirSync25, readFileSync as readFileSync36, renameSync as renameSync5, writeFileSync as writeFileSync26 } from "fs";
16171
16266
  import { homedir as homedir8 } from "os";
16172
- import { dirname as dirname19, join as join38 } from "path";
16267
+ import { dirname as dirname19, join as join39 } from "path";
16173
16268
  var POOL_EXIT = { ok: 0, failed: 1, credential: 2 };
16174
16269
  function backoffMs(attempt) {
16175
16270
  return Math.min(6e4, 5e3 * 2 ** Math.max(0, attempt));
@@ -16411,14 +16506,14 @@ async function runPoolMember(deps) {
16411
16506
  }
16412
16507
  }
16413
16508
  function defaultMemberDir(env = process.env) {
16414
- return env.CREW_POOL_DIR ?? join38(env.XDG_STATE_HOME ?? join38(homedir8(), ".local", "state"), "crew-pool-member");
16509
+ return env.CREW_POOL_DIR ?? join39(env.XDG_STATE_HOME ?? join39(homedir8(), ".local", "state"), "crew-pool-member");
16415
16510
  }
16416
16511
  function fileMemberStore(dir) {
16417
- const file = join38(dir, "member.json");
16512
+ const file = join39(dir, "member.json");
16418
16513
  return {
16419
16514
  read() {
16420
16515
  try {
16421
- return JSON.parse(readFileSync35(file, "utf8"));
16516
+ return JSON.parse(readFileSync36(file, "utf8"));
16422
16517
  } catch {
16423
16518
  return {};
16424
16519
  }
@@ -16478,16 +16573,16 @@ function hostArchitecture(arch = process.arch) {
16478
16573
 
16479
16574
  // src/pool-member-host.ts
16480
16575
  import "child_process";
16481
- import { existsSync as existsSync37 } from "fs";
16576
+ import { existsSync as existsSync38 } from "fs";
16482
16577
  import { hostname as hostname3 } from "os";
16483
16578
 
16484
16579
  // src/machine-id.ts
16485
16580
  import { execFileSync as execFileSync12 } from "child_process";
16486
16581
  import { createHash as createHash8 } from "crypto";
16487
- import { existsSync as existsSync35, mkdirSync as mkdirSync26, readFileSync as readFileSync36, writeFileSync as writeFileSync27 } from "fs";
16488
- import { dirname as dirname20, join as join39 } from "path";
16582
+ import { existsSync as existsSync36, mkdirSync as mkdirSync26, readFileSync as readFileSync37, writeFileSync as writeFileSync27 } from "fs";
16583
+ import { dirname as dirname20, join as join40 } from "path";
16489
16584
  function machineIdPathFor(stateDir) {
16490
- return join39(stateDir, "machine-id");
16585
+ return join40(stateDir, "machine-id");
16491
16586
  }
16492
16587
  var sha256 = (s) => createHash8("sha256").update(s).digest("hex");
16493
16588
  function readRawMachineId(platform2 = process.platform) {
@@ -16500,8 +16595,8 @@ function readRawMachineId(platform2 = process.platform) {
16500
16595
  return /"IOPlatformUUID"\s*=\s*"([^"]+)"/.exec(out)?.[1];
16501
16596
  }
16502
16597
  for (const p of ["/etc/machine-id", "/var/lib/dbus/machine-id"]) {
16503
- if (existsSync35(p)) {
16504
- const id = readFileSync36(p, "utf8").trim();
16598
+ if (existsSync36(p)) {
16599
+ const id = readFileSync37(p, "utf8").trim();
16505
16600
  if (id) return id;
16506
16601
  }
16507
16602
  }
@@ -16512,8 +16607,8 @@ function readRawMachineId(platform2 = process.platform) {
16512
16607
  function ensureMachineId(stateDir, opts = {}) {
16513
16608
  if (opts.override?.trim()) return sha256(opts.override.trim());
16514
16609
  const path = machineIdPathFor(stateDir);
16515
- if (existsSync35(path)) {
16516
- const cached = readFileSync36(path, "utf8").trim();
16610
+ if (existsSync36(path)) {
16611
+ const cached = readFileSync37(path, "utf8").trim();
16517
16612
  if (/^[0-9a-f]{64}$/.test(cached)) return cached;
16518
16613
  }
16519
16614
  const raw = (opts.read ?? readRawMachineId)();
@@ -16533,7 +16628,7 @@ function matchShipRows(ships, shipName2, machineId) {
16533
16628
 
16534
16629
  // src/provision.ts
16535
16630
  import { spawnSync as spawnSync9 } from "child_process";
16536
- import { existsSync as existsSync36, readFileSync as readFileSync37, writeFileSync as writeFileSync28 } from "fs";
16631
+ import { existsSync as existsSync37, readFileSync as readFileSync38, writeFileSync as writeFileSync28 } from "fs";
16537
16632
  import { hostname as hostname2 } from "os";
16538
16633
  import { parseDocument as parseDocument3, isMap as isMap2, isScalar } from "yaml";
16539
16634
 
@@ -16542,7 +16637,7 @@ import { parseDocument as parseDocument2 } from "yaml";
16542
16637
 
16543
16638
  // src/repos-cmd.ts
16544
16639
  import { homedir as homedir9 } from "os";
16545
- import { basename as basename10, join as join40, resolve as resolve4 } from "path";
16640
+ import { basename as basename10, join as join41, resolve as resolve4 } from "path";
16546
16641
  import { isMap, isSeq, parseDocument, stringify as stringify2 } from "yaml";
16547
16642
  var ReposError = class extends Error {
16548
16643
  };
@@ -16820,7 +16915,7 @@ function planRepoClone(i) {
16820
16915
  }
16821
16916
  const ship = doc.get("ship", true);
16822
16917
  const basePath = String(m.get("reposBasePath") ?? (isMap(ship) ? ship.get("reposBasePath") : void 0) ?? "~/Crew");
16823
- const target = i.dir ? expandDir(i.dir, i.base) : join40(expandDir(basePath, i.base), i.route.split("/")[0], name);
16918
+ const target = i.dir ? expandDir(i.dir, i.base) : join41(expandDir(basePath, i.base), i.route.split("/")[0], name);
16824
16919
  const add = planRepoAdd({ text: i.text, base: i.base, route: i.route, path: target, origin: remote, resolved: i.resolved, name, isCheckout: i.isCheckout });
16825
16920
  const forgeHost = i.resolved?.repoForgeHosts?.[id];
16826
16921
  return { ...add, remote, target, ...forgeHost ? { forgeHost } : {} };
@@ -17151,7 +17246,7 @@ function realProvisionDeps(crewHome) {
17151
17246
  };
17152
17247
  const configFile = () => {
17153
17248
  const f = findConfigFile(crewHome);
17154
- return existsSync36(f) ? f : null;
17249
+ return existsSync37(f) ? f : null;
17155
17250
  };
17156
17251
  return {
17157
17252
  crew: spawnCrew,
@@ -17159,7 +17254,7 @@ function realProvisionDeps(crewHome) {
17159
17254
  enableRoute(route2) {
17160
17255
  const file = configFile();
17161
17256
  if (!file) return false;
17162
- const text2 = readFileSync37(file, "utf8");
17257
+ const text2 = readFileSync38(file, "utf8");
17163
17258
  const doc = parseDocument3(text2);
17164
17259
  const routes = doc.get("routes");
17165
17260
  const entry = routes?.items?.find((r) => r.get("route") === route2);
@@ -17185,14 +17280,14 @@ function realProvisionDeps(crewHome) {
17185
17280
  continue;
17186
17281
  }
17187
17282
  for (const p of plan.unitPaths) {
17188
- if (!existsSync36(p) || readFileSync37(p, "utf8") !== plan.unitContent[p]) unitsStale = true;
17283
+ if (!existsSync37(p) || readFileSync38(p, "utf8") !== plan.unitContent[p]) unitsStale = true;
17189
17284
  }
17190
17285
  }
17191
17286
  const label = labelFor(crewHome, "run");
17192
17287
  let running = false;
17193
17288
  let lingering = true;
17194
17289
  if (mechanism === "systemd") {
17195
- const system = ctx.root || existsSync36(systemUnitPathFor(label));
17290
+ const system = ctx.root || existsSync37(systemUnitPathFor(label));
17196
17291
  const ctl = system ? ["systemctl"] : ["systemctl", "--user"];
17197
17292
  running = spawnSync9(ctl[0], [...ctl.slice(1), "is-active", "--quiet", `${label}.service`], { env: withUserBusEnv() }).status === 0;
17198
17293
  if (!system) {
@@ -17209,7 +17304,7 @@ function realProvisionDeps(crewHome) {
17209
17304
  setShipSetting(key, value2) {
17210
17305
  const file = configFile();
17211
17306
  if (!file) return false;
17212
- const doc = parseDocument3(readFileSync37(file, "utf8"));
17307
+ const doc = parseDocument3(readFileSync38(file, "utf8"));
17213
17308
  if (doc.getIn(["ship", key]) === value2) return false;
17214
17309
  doc.setIn(["ship", key], value2);
17215
17310
  writeFileSync28(file, doc.toString());
@@ -17218,7 +17313,7 @@ function realProvisionDeps(crewHome) {
17218
17313
  applyManagedDefaults() {
17219
17314
  const file = configFile();
17220
17315
  if (!file) return [];
17221
- const doc = parseDocument3(readFileSync37(file, "utf8"));
17316
+ const doc = parseDocument3(readFileSync38(file, "utf8"));
17222
17317
  const wrote = applyManagedDefaultsToDoc(doc);
17223
17318
  if (wrote.length) writeFileSync28(file, doc.toString());
17224
17319
  return wrote;
@@ -17270,7 +17365,7 @@ function realPoolMemberDeps(o) {
17270
17365
  crewVersion: crewVersion(o.crewHome),
17271
17366
  hostname: hostname3()
17272
17367
  },
17273
- hasShipConfig: () => existsSync37(findConfigFile(o.crewHome)),
17368
+ hasShipConfig: () => existsSync38(findConfigFile(o.crewHome)),
17274
17369
  async provision(lease, instanceClass, shipKind) {
17275
17370
  const hosts = lease.forges.map((f) => f.host.toLowerCase());
17276
17371
  const lines2 = [];
@@ -18194,7 +18289,7 @@ ${waiting.map((t) => `| ${displayKey2(t)} | ${t.status} | ${blockers(t, i)} |`).
18194
18289
 
18195
18290
  // src/sandbox-hygiene.ts
18196
18291
  import { execFile as execFile3 } from "child_process";
18197
- import { existsSync as existsSync38, statfsSync as statfsSync2 } from "fs";
18292
+ import { existsSync as existsSync39, statfsSync as statfsSync2 } from "fs";
18198
18293
  import { promisify as promisify3 } from "util";
18199
18294
  var execFileP3 = promisify3(execFile3);
18200
18295
  var REAP_MIN_AGE_MS = 5 * 6e4;
@@ -18337,7 +18432,7 @@ async function realDiskReadings(ship) {
18337
18432
  const paths = ["/"];
18338
18433
  try {
18339
18434
  const root = (await run3(ship.sandbox?.engine ?? DEFAULT_CACHE_SETTINGS.engine, ["info", "--format", "{{.DockerRootDir}}"])).trim();
18340
- if (root && existsSync38(root)) paths.push(root);
18435
+ if (root && existsSync39(root)) paths.push(root);
18341
18436
  } catch {
18342
18437
  }
18343
18438
  return paths.flatMap((path) => {
@@ -18379,7 +18474,7 @@ function diskFullStop(state) {
18379
18474
 
18380
18475
  // src/poll.ts
18381
18476
  import { writeFileSync as writeFileSync29 } from "fs";
18382
- import { join as join41 } from "path";
18477
+ import { join as join42 } from "path";
18383
18478
 
18384
18479
  // src/stalled.ts
18385
18480
  var STALLED_AFTER_CYCLES = 30;
@@ -18695,7 +18790,7 @@ async function decideCycle(o) {
18695
18790
  }
18696
18791
  return decision;
18697
18792
  }
18698
- var digestPath = (stateDir, route2, role, runId) => join41(stateDir, `digest-${route2}-${role}${runId ? `-${runId}` : ""}.md`);
18793
+ var digestPath = (stateDir, route2, role, runId) => join42(stateDir, `digest-${route2}-${role}${runId ? `-${runId}` : ""}.md`);
18699
18794
  function otherRunsRemoved(tickets, own) {
18700
18795
  if (!own) return tickets;
18701
18796
  return tickets.filter((t) => t.id === own.ticket.id || !own.inFlight(t.id));
@@ -18904,7 +18999,7 @@ async function claimStillHeld(tracker, t, buildingStatus, affinity) {
18904
18999
  }
18905
19000
 
18906
19001
  // src/repo-refresh.ts
18907
- import { existsSync as existsSync39, mkdirSync as mkdirSync27, readFileSync as readFileSync38, writeFileSync as writeFileSync30 } from "fs";
19002
+ import { existsSync as existsSync40, mkdirSync as mkdirSync27, readFileSync as readFileSync39, writeFileSync as writeFileSync30 } from "fs";
18908
19003
  import { dirname as dirname22 } from "path";
18909
19004
  var REFRESH_COOLDOWN_MS = 2 * 6e4;
18910
19005
  var UNSERVABLE_PASSES_BEFORE_ATTENTION = 3;
@@ -18934,8 +19029,8 @@ function applyRepoRows(resolved, rows) {
18934
19029
  }
18935
19030
  function persistRepoRows(stateDir, routeName, rows) {
18936
19031
  const path = resolvedPathFor(stateDir, routeName);
18937
- if (!existsSync39(path)) return;
18938
- const raw = JSON.parse(readFileSync38(path, "utf8"));
19032
+ if (!existsSync40(path)) return;
19033
+ const raw = JSON.parse(readFileSync39(path, "utf8"));
18939
19034
  applyRepoRows(raw, rows);
18940
19035
  mkdirSync27(dirname22(path), { recursive: true });
18941
19036
  writeFileSync30(path, `${JSON.stringify(raw, null, 2)}
@@ -19414,7 +19509,7 @@ Ship ${shipName2} found: ${problem}. The release refuses to squash a ref nobody
19414
19509
  var localRefSkipReported = (ticket, problem, events) => events.some((e) => e.record_id === ticket.id && e.event_type === "local_ref_skip" && (e.message ?? "").includes(problem));
19415
19510
 
19416
19511
  // src/platform-gate.ts
19417
- import { join as join42 } from "path";
19512
+ import { join as join43 } from "path";
19418
19513
  function platformAdmitters(dir, baseRef, ship, tickets, locate) {
19419
19514
  const out = [];
19420
19515
  for (const t of tickets) {
@@ -19426,7 +19521,7 @@ function platformAdmitters(dir, baseRef, ship, tickets, locate) {
19426
19521
  const text2 = gitOk(dir, ["show", `${branch}:${file}`]);
19427
19522
  if (text2 === null) continue;
19428
19523
  try {
19429
- const { platform: platform2 } = parseRepoConfig(text2, join42(dir, file));
19524
+ const { platform: platform2 } = parseRepoConfig(text2, join43(dir, file));
19430
19525
  if (satisfies(ship, platform2)) out.push({ issueId: t.issue_id, branch, platform: platform2 });
19431
19526
  } catch (e) {
19432
19527
  if (e instanceof RepoConfigError) continue;
@@ -19442,13 +19537,13 @@ function platformStuckNote(repo, required, ship, issueIds) {
19442
19537
  }
19443
19538
 
19444
19539
  // src/connect-wizard.ts
19445
- import { delimiter, dirname as dirname23, join as join43 } from "path";
19446
- import { accessSync as accessSync3, constants as constants3, existsSync as existsSync40, mkdirSync as mkdirSync28, writeFileSync as writeFileSync31 } from "fs";
19540
+ import { delimiter, dirname as dirname23, join as join44 } from "path";
19541
+ import { accessSync as accessSync3, constants as constants3, existsSync as existsSync41, mkdirSync as mkdirSync28, writeFileSync as writeFileSync31 } from "fs";
19447
19542
  import { stringify as stringify3 } from "yaml";
19448
19543
  var HOST_PASSENGERS_DOCS_URL = "https://crew.tablation.dev/host-passengers";
19449
19544
  function shouldRunWizard(opts) {
19450
19545
  if (!opts.isTTY) return false;
19451
- const exists = opts.configExists ?? existsSync40;
19546
+ const exists = opts.configExists ?? existsSync41;
19452
19547
  return !configSearchPath(opts.crewHome).some((p) => exists(p));
19453
19548
  }
19454
19549
  function firstRunConfigPath() {
@@ -19465,7 +19560,7 @@ function defaultIsExecutable(p) {
19465
19560
  function findOnPath2(name, pathEnv, isExecutable = defaultIsExecutable) {
19466
19561
  for (const dir of pathEnv.split(delimiter)) {
19467
19562
  if (!dir) continue;
19468
- const candidate = join43(dir, name);
19563
+ const candidate = join44(dir, name);
19469
19564
  if (isExecutable(candidate)) return candidate;
19470
19565
  }
19471
19566
  return void 0;
@@ -19562,7 +19657,7 @@ Wrote ${o.configPath}.
19562
19657
  // src/connect-json.ts
19563
19658
  import { accessSync as accessSync4, constants as constants4 } from "fs";
19564
19659
  import { homedir as homedir10 } from "os";
19565
- import { dirname as dirname24, join as join44 } from "path";
19660
+ import { dirname as dirname24, join as join45 } from "path";
19566
19661
  import { delimiter as delimiter2 } from "path";
19567
19662
  var CHOICE_EXIT_CODE = 3;
19568
19663
  function createEmitter(json2, write) {
@@ -19601,12 +19696,12 @@ function agentBinSearchDirs(home, pathEnv, extraPath) {
19601
19696
  const dirs = [
19602
19697
  ...pathEnv.split(delimiter2),
19603
19698
  ...(extraPath ?? "").split(delimiter2),
19604
- join44(home, ".local/bin"),
19605
- join44(home, ".claude/local"),
19699
+ join45(home, ".local/bin"),
19700
+ join45(home, ".claude/local"),
19606
19701
  "/opt/homebrew/bin",
19607
19702
  "/usr/local/bin",
19608
- join44(home, ".npm-global/bin"),
19609
- join44(home, ".volta/bin")
19703
+ join45(home, ".npm-global/bin"),
19704
+ join45(home, ".volta/bin")
19610
19705
  ];
19611
19706
  return [...new Set(dirs.filter(Boolean))];
19612
19707
  }
@@ -19727,8 +19822,8 @@ async function collectDiagnostics(d) {
19727
19822
  }
19728
19823
 
19729
19824
  // src/release-run.ts
19730
- import { readFileSync as readFileSync39, writeFileSync as writeFileSync32, existsSync as existsSync41, copyFileSync, mkdirSync as mkdirSync29, mkdtempSync as mkdtempSync3, rmSync as rmSync20 } from "fs";
19731
- import { dirname as dirname25, join as join45 } from "path";
19825
+ import { readFileSync as readFileSync40, writeFileSync as writeFileSync32, existsSync as existsSync42, copyFileSync, mkdirSync as mkdirSync29, mkdtempSync as mkdtempSync3, rmSync as rmSync20 } from "fs";
19826
+ import { dirname as dirname25, join as join46 } from "path";
19732
19827
  import { tmpdir as tmpdir6, hostname as hostname4 } from "os";
19733
19828
 
19734
19829
  // src/release.ts
@@ -20518,13 +20613,13 @@ async function bump(o, size) {
20518
20613
  }
20519
20614
  return printed;
20520
20615
  }
20521
- const files = o.repo.release.versionFiles.map((f) => join45(o.cwd, f));
20616
+ const files = o.repo.release.versionFiles.map((f) => join46(o.cwd, f));
20522
20617
  const first = files[0];
20523
- if (!existsAt(first, existsSync41)) {
20618
+ if (!existsAt(first, existsSync42)) {
20524
20619
  o.emit.error(`no ${o.repo.release.versionFiles[0]} to read a version from`);
20525
20620
  return null;
20526
20621
  }
20527
- const firstText = readTextAt(first, (p) => readFileSync39(p, "utf8"));
20622
+ const firstText = readTextAt(first, (p) => readFileSync40(p, "utf8"));
20528
20623
  const problem = versionFileProblem(o.repo.release.versionFiles[0], firstText);
20529
20624
  if (problem) {
20530
20625
  o.emit.error(problem);
@@ -20543,7 +20638,7 @@ async function bump(o, size) {
20543
20638
  return version;
20544
20639
  }
20545
20640
  for (const f of files) {
20546
- const src = readTextAt(f, (p) => readFileSync39(p, "utf8"));
20641
+ const src = readTextAt(f, (p) => readFileSync40(p, "utf8"));
20547
20642
  const out = src.replace(/("version"\s*:\s*")[^"]*(")/, `$1${version}$2`);
20548
20643
  if (out === src) {
20549
20644
  o.emit.error(`no version field in ${f}`);
@@ -20556,13 +20651,13 @@ async function bump(o, size) {
20556
20651
  function writeChangelog(o, version, entries) {
20557
20652
  const file = o.repo.release.changelog;
20558
20653
  if (!file || entries.length === 0) return;
20559
- const path = join45(o.cwd, file);
20654
+ const path = join46(o.cwd, file);
20560
20655
  const section = renderChangelogSection(version, (/* @__PURE__ */ new Date()).toISOString().slice(0, 10), entries);
20561
20656
  if (o.dryRun) {
20562
20657
  o.emit.emit(`would prepend ${entries.length} entr(ies) to ${file}`);
20563
20658
  return;
20564
20659
  }
20565
- const existing = existsAt(path, existsSync41) ? readTextAt(path, (p) => readFileSync39(p, "utf8")) : "# Changelog\n";
20660
+ const existing = existsAt(path, existsSync42) ? readTextAt(path, (p) => readFileSync40(p, "utf8")) : "# Changelog\n";
20566
20661
  writeTextAt(path, insertChangelogSection(existing, section), writeFileSync32);
20567
20662
  }
20568
20663
  async function confirm(o, expected) {
@@ -20656,8 +20751,8 @@ function closeReleaseCheckout(cwd, root, dir, branch, run4 = gitOk) {
20656
20751
  function openReleaseCheckout(o) {
20657
20752
  const { remote, base } = o.repo.branch;
20658
20753
  const branch = `crew/release-${Date.now()}`;
20659
- const root = mkdtempSync3(join45(tmpdir6(), "crew-release-"));
20660
- const dir = join45(root, "checkout");
20754
+ const root = mkdtempSync3(join46(tmpdir6(), "crew-release-"));
20755
+ const dir = join46(root, "checkout");
20661
20756
  o.emit.emit(`release checkout: ${dir}`, { step: "release" });
20662
20757
  const close = () => closeReleaseCheckout(o.cwd, root, dir, branch);
20663
20758
  try {
@@ -20667,10 +20762,10 @@ function openReleaseCheckout(o) {
20667
20762
  throw e;
20668
20763
  }
20669
20764
  for (const f of o.repo.worktrees.copy) {
20670
- const src = join45(o.cwd, f);
20671
- if (!existsSync41(src)) continue;
20672
- mkdirSync29(dirname25(join45(dir, f)), { recursive: true });
20673
- copyFileSync(src, join45(dir, f));
20765
+ const src = join46(o.cwd, f);
20766
+ if (!existsSync42(src)) continue;
20767
+ mkdirSync29(dirname25(join46(dir, f)), { recursive: true });
20768
+ copyFileSync(src, join46(dir, f));
20674
20769
  }
20675
20770
  return { dir, branch, close };
20676
20771
  }
@@ -21489,15 +21584,15 @@ async function runCommentDeliveryPass(deps) {
21489
21584
  }
21490
21585
 
21491
21586
  // src/launchd-start.ts
21492
- import { readFileSync as readFileSync46 } from "fs";
21587
+ import { readFileSync as readFileSync47 } from "fs";
21493
21588
  import { spawnSync as spawnSync12 } from "child_process";
21494
21589
 
21495
21590
  // src/daemon-liveness.ts
21496
- import { existsSync as existsSync48, readFileSync as readFileSync45 } from "fs";
21591
+ import { existsSync as existsSync49, readFileSync as readFileSync46 } from "fs";
21497
21592
 
21498
21593
  // src/daemon.ts
21499
- import { existsSync as existsSync47, mkdirSync as mkdirSync35, readFileSync as readFileSync44, readdirSync as readdirSync14, rmSync as rmSync22, statSync as statSync13, writeFileSync as writeFileSync36 } from "fs";
21500
- import { join as join50 } from "path";
21594
+ import { existsSync as existsSync48, mkdirSync as mkdirSync35, readFileSync as readFileSync45, readdirSync as readdirSync15, rmSync as rmSync22, statSync as statSync14, writeFileSync as writeFileSync36 } from "fs";
21595
+ import { join as join51 } from "path";
21501
21596
  import { randomBytes } from "crypto";
21502
21597
 
21503
21598
  // src/fleet.ts
@@ -21587,16 +21682,16 @@ function nextRoles(decision, ran) {
21587
21682
  }
21588
21683
 
21589
21684
  // src/noop-runs.ts
21590
- import { existsSync as existsSync42, mkdirSync as mkdirSync30, readFileSync as readFileSync40, renameSync as renameSync6, writeFileSync as writeFileSync33 } from "fs";
21591
- import { join as join46 } from "path";
21685
+ import { existsSync as existsSync43, mkdirSync as mkdirSync30, readFileSync as readFileSync41, renameSync as renameSync6, writeFileSync as writeFileSync33 } from "fs";
21686
+ import { join as join47 } from "path";
21592
21687
  var NOOP_DELAYS_MS = [5, 15, 60].map((m) => m * 6e4);
21593
21688
  var DEFAULT_NOOP_REPEATS = 3;
21594
21689
  var NOOP_BOUNCED_MARKER = calloutHeader("WARNING", "Runs Changed Nothing");
21595
- var noopRunsPath = (stateDir) => join46(stateDir, "noop-runs.json");
21690
+ var noopRunsPath = (stateDir) => join47(stateDir, "noop-runs.json");
21596
21691
  var noopRunsKey = (issueId) => `noop_runs:${issueId}`;
21597
21692
  function readNoopRuns(stateDir) {
21598
21693
  try {
21599
- const v = JSON.parse(readFileSync40(noopRunsPath(stateDir), "utf8"));
21694
+ const v = JSON.parse(readFileSync41(noopRunsPath(stateDir), "utf8"));
21600
21695
  return v && typeof v === "object" && !Array.isArray(v) ? v : {};
21601
21696
  } catch {
21602
21697
  return {};
@@ -21622,7 +21717,7 @@ function recordNoopRun(stateDir, recordId, repeats, now = Date.now()) {
21622
21717
  return { count, nextAt, bounce: count >= repeats };
21623
21718
  }
21624
21719
  function clearNoopRuns(stateDir, recordId) {
21625
- if (!existsSync42(noopRunsPath(stateDir))) return;
21720
+ if (!existsSync43(noopRunsPath(stateDir))) return;
21626
21721
  const state = readNoopRuns(stateDir);
21627
21722
  if (!(recordId in state)) return;
21628
21723
  delete state[recordId];
@@ -21682,7 +21777,7 @@ async function settleNoopRun(o) {
21682
21777
  }
21683
21778
 
21684
21779
  // src/ship-name.ts
21685
- import { existsSync as existsSync43, mkdirSync as mkdirSync31, readFileSync as readFileSync41, renameSync as renameSync7, writeFileSync as writeFileSync34 } from "fs";
21780
+ import { existsSync as existsSync44, mkdirSync as mkdirSync31, readFileSync as readFileSync42, renameSync as renameSync7, writeFileSync as writeFileSync34 } from "fs";
21686
21781
  import { dirname as dirname26 } from "path";
21687
21782
  import { parseDocument as parseDocument4 } from "yaml";
21688
21783
  var ShipNameError = class extends Error {
@@ -21744,19 +21839,19 @@ async function syncRouteName(i) {
21744
21839
  return { status: "ok", ...base, action, name: i.local };
21745
21840
  }
21746
21841
  function readSyncedName(resolvedFile) {
21747
- if (!existsSync43(resolvedFile)) return void 0;
21842
+ if (!existsSync44(resolvedFile)) return void 0;
21748
21843
  try {
21749
- const v = JSON.parse(readFileSync41(resolvedFile, "utf8")).shipName;
21844
+ const v = JSON.parse(readFileSync42(resolvedFile, "utf8")).shipName;
21750
21845
  return typeof v === "string" ? v : void 0;
21751
21846
  } catch {
21752
21847
  return void 0;
21753
21848
  }
21754
21849
  }
21755
21850
  function writeSyncedName(resolvedFile, name) {
21756
- if (!existsSync43(resolvedFile)) return;
21851
+ if (!existsSync44(resolvedFile)) return;
21757
21852
  let raw;
21758
21853
  try {
21759
- raw = JSON.parse(readFileSync41(resolvedFile, "utf8"));
21854
+ raw = JSON.parse(readFileSync42(resolvedFile, "utf8"));
21760
21855
  } catch {
21761
21856
  return;
21762
21857
  }
@@ -21771,7 +21866,7 @@ function writeSyncedName(resolvedFile, name) {
21771
21866
  async function reconcileShipName(i) {
21772
21867
  let local = i.ship.name;
21773
21868
  try {
21774
- local = shipNameOfYaml(readFileSync41(i.configFile, "utf8")) ?? local;
21869
+ local = shipNameOfYaml(readFileSync42(i.configFile, "utf8")) ?? local;
21775
21870
  } catch {
21776
21871
  }
21777
21872
  const resolvedFile = resolvedPathFor(i.stateDir, i.route);
@@ -21795,7 +21890,7 @@ async function reconcileShipName(i) {
21795
21890
  }
21796
21891
  if (result.status !== "ok") return result;
21797
21892
  if (result.action === "adopt" || result.action === "row-wins") {
21798
- const text2 = readFileSync41(i.configFile, "utf8");
21893
+ const text2 = readFileSync42(i.configFile, "utf8");
21799
21894
  writeFileSync34(i.configFile, setShipNameInYaml(text2, result.name));
21800
21895
  i.ship.name = result.name;
21801
21896
  if (result.action === "row-wins") {
@@ -21841,7 +21936,7 @@ async function reconcileRouteShipName(o) {
21841
21936
  }
21842
21937
 
21843
21938
  // src/mirror-contract.ts
21844
- import { existsSync as existsSync44 } from "fs";
21939
+ import { existsSync as existsSync45 } from "fs";
21845
21940
 
21846
21941
  // src/passenger-mirror.ts
21847
21942
  import { mkdirSync as mkdirSync32 } from "fs";
@@ -21882,7 +21977,7 @@ function mirrorOutcome(m) {
21882
21977
 
21883
21978
  // src/mirror-contract.ts
21884
21979
  function lacksCheckout(ship, dir) {
21885
- return ship.runner === "sandbox" && !existsSync44(dir) && !remoteOf(dir);
21980
+ return ship.runner === "sandbox" && !existsSync45(dir) && !remoteOf(dir);
21886
21981
  }
21887
21982
  function skipsHostCheckout(ship) {
21888
21983
  return ship.runner === "sandbox";
@@ -21963,17 +22058,17 @@ function explainRefusal(readable, unreadable) {
21963
22058
 
21964
22059
  // src/ssh-keys.ts
21965
22060
  import { execFileSync as execFileSync13 } from "child_process";
21966
- import { existsSync as existsSync45, mkdirSync as mkdirSync33, readFileSync as readFileSync42, chmodSync as chmodSync3 } from "fs";
21967
- import { dirname as dirname28, join as join47 } from "path";
22061
+ import { existsSync as existsSync46, mkdirSync as mkdirSync33, readFileSync as readFileSync43, chmodSync as chmodSync3 } from "fs";
22062
+ import { dirname as dirname28, join as join48 } from "path";
21968
22063
  var SshKeyError = class extends Error {
21969
22064
  };
21970
22065
  function shipSshKeyPathFor(stateDir) {
21971
- return join47(stateDir, "ssh", "id_ed25519");
22066
+ return join48(stateDir, "ssh", "id_ed25519");
21972
22067
  }
21973
22068
  function ensureShipSshKeypair(stateDir) {
21974
22069
  const privateKeyPath = shipSshKeyPathFor(stateDir);
21975
22070
  const publicKeyPath = `${privateKeyPath}.pub`;
21976
- if (!existsSync45(privateKeyPath)) {
22071
+ if (!existsSync46(privateKeyPath)) {
21977
22072
  mkdirSync33(dirname28(privateKeyPath), { recursive: true });
21978
22073
  try {
21979
22074
  execFileSync13("ssh-keygen", [
@@ -21994,10 +22089,10 @@ function ensureShipSshKeypair(stateDir) {
21994
22089
  }
21995
22090
  chmodSync3(privateKeyPath, 384);
21996
22091
  }
21997
- if (!existsSync45(publicKeyPath)) {
22092
+ if (!existsSync46(publicKeyPath)) {
21998
22093
  throw new SshKeyError(`${privateKeyPath} exists but ${publicKeyPath} does not \u2014 regenerate or restore it`);
21999
22094
  }
22000
- const publicKey = readFileSync42(publicKeyPath, "utf8").trim();
22095
+ const publicKey = readFileSync43(publicKeyPath, "utf8").trim();
22001
22096
  return { privateKeyPath, publicKeyPath, publicKey };
22002
22097
  }
22003
22098
  function sshKeygenAvailable() {
@@ -22011,8 +22106,8 @@ function sshKeygenAvailable() {
22011
22106
 
22012
22107
  // src/periscope-idle.ts
22013
22108
  import { execFileSync as execFileSync14 } from "child_process";
22014
- import { statSync as statSync12 } from "fs";
22015
- import { join as join48 } from "path";
22109
+ import { statSync as statSync13 } from "fs";
22110
+ import { join as join49 } from "path";
22016
22111
  var MAX_SCANNED_FILES = 2e4;
22017
22112
  function newestWorktreeMtime(root) {
22018
22113
  const a = newestTrackedMtime(root);
@@ -22037,7 +22132,7 @@ function newestTrackedMtime(root) {
22037
22132
  if (!rel) continue;
22038
22133
  if (++scanned > MAX_SCANNED_FILES) break;
22039
22134
  try {
22040
- const m = statSync12(join48(root, rel)).mtimeMs;
22135
+ const m = statSync13(join49(root, rel)).mtimeMs;
22041
22136
  if (newest === null || m > newest) newest = m;
22042
22137
  } catch {
22043
22138
  }
@@ -22111,8 +22206,8 @@ async function runPeriscopeIdlePass(d) {
22111
22206
  }
22112
22207
 
22113
22208
  // src/periscope-cmd.ts
22114
- import { existsSync as existsSync46, mkdirSync as mkdirSync34, readFileSync as readFileSync43, rmSync as rmSync21, writeFileSync as writeFileSync35 } from "fs";
22115
- import { join as join49 } from "path";
22209
+ import { existsSync as existsSync47, mkdirSync as mkdirSync34, readFileSync as readFileSync44, rmSync as rmSync21, writeFileSync as writeFileSync35 } from "fs";
22210
+ import { join as join50 } from "path";
22116
22211
  var PeriscopeError = class extends Error {
22117
22212
  };
22118
22213
  var LivePeriscopeError = class extends PeriscopeError {
@@ -22122,8 +22217,8 @@ var LivePeriscopeError = class extends PeriscopeError {
22122
22217
  this.data = { refused: "live_periscope_exists", ...live2 };
22123
22218
  }
22124
22219
  };
22125
- var priorDir = (stateDir) => join49(stateDir, "periscope-priors");
22126
- var priorPath = (stateDir, ticketRecordId) => join49(priorDir(stateDir), `${ticketRecordId}.json`);
22220
+ var priorDir = (stateDir) => join50(stateDir, "periscope-priors");
22221
+ var priorPath = (stateDir, ticketRecordId) => join50(priorDir(stateDir), `${ticketRecordId}.json`);
22127
22222
  function removePeriscopePrior(stateDir, ticketRecordId) {
22128
22223
  rmSync21(priorPath(stateDir, ticketRecordId), { force: true });
22129
22224
  }
@@ -22137,7 +22232,7 @@ function writePeriscopePrior(stateDir, ticketRecordId, prior) {
22137
22232
  function readPeriscopePrior(stateDir, ticketRecordId) {
22138
22233
  try {
22139
22234
  const p = priorPath(stateDir, ticketRecordId);
22140
- return existsSync46(p) ? JSON.parse(readFileSync43(p, "utf8")) : void 0;
22235
+ return existsSync47(p) ? JSON.parse(readFileSync44(p, "utf8")) : void 0;
22141
22236
  } catch {
22142
22237
  return void 0;
22143
22238
  }
@@ -22699,15 +22794,15 @@ async function runDaemonLoop(o) {
22699
22794
  function latestMtime(path) {
22700
22795
  let stat2;
22701
22796
  try {
22702
- stat2 = statSync13(path);
22797
+ stat2 = statSync14(path);
22703
22798
  } catch {
22704
22799
  return 0;
22705
22800
  }
22706
22801
  if (stat2.isFile()) return stat2.mtimeMs;
22707
22802
  if (!stat2.isDirectory()) return 0;
22708
22803
  let latest = stat2.mtimeMs;
22709
- for (const entry of readdirSync14(path, { withFileTypes: true })) {
22710
- latest = Math.max(latest, latestMtime(join50(path, entry.name)));
22804
+ for (const entry of readdirSync15(path, { withFileTypes: true })) {
22805
+ latest = Math.max(latest, latestMtime(join51(path, entry.name)));
22711
22806
  }
22712
22807
  return latest;
22713
22808
  }
@@ -22716,20 +22811,20 @@ function computeTreeSignature(paths) {
22716
22811
  }
22717
22812
  function makeStaleChecker(paths, opts = {}) {
22718
22813
  const initial = computeTreeSignature(paths);
22719
- return () => computeTreeSignature(paths) !== initial || opts.reloadSentinel !== void 0 && existsSync47(opts.reloadSentinel);
22814
+ return () => computeTreeSignature(paths) !== initial || opts.reloadSentinel !== void 0 && existsSync48(opts.reloadSentinel);
22720
22815
  }
22721
22816
  function reloadSentinelFor(stateDir) {
22722
- return join50(stateDir, "reload-requested");
22817
+ return join51(stateDir, "reload-requested");
22723
22818
  }
22724
22819
  function readReloadRequestedAt(stateDir) {
22725
22820
  try {
22726
- return statSync13(reloadSentinelFor(stateDir)).mtimeMs;
22821
+ return statSync14(reloadSentinelFor(stateDir)).mtimeMs;
22727
22822
  } catch {
22728
22823
  return null;
22729
22824
  }
22730
22825
  }
22731
22826
  function daemonStampFor(stateDir) {
22732
- return join50(stateDir, "daemon.started");
22827
+ return join51(stateDir, "daemon.started");
22733
22828
  }
22734
22829
  function noteDaemonStarted(stateDir, now = Date.now()) {
22735
22830
  mkdirSync35(stateDir, { recursive: true });
@@ -22739,7 +22834,7 @@ function noteDaemonStarted(stateDir, now = Date.now()) {
22739
22834
  }
22740
22835
  function readDaemonStarted(stateDir) {
22741
22836
  try {
22742
- const v = JSON.parse(readFileSync44(daemonStampFor(stateDir), "utf8")).startedAt;
22837
+ const v = JSON.parse(readFileSync45(daemonStampFor(stateDir), "utf8")).startedAt;
22743
22838
  return typeof v === "number" ? v : null;
22744
22839
  } catch {
22745
22840
  return null;
@@ -22748,7 +22843,7 @@ function readDaemonStarted(stateDir) {
22748
22843
  function configChangedAfter(files, startedAt) {
22749
22844
  for (const f of files) {
22750
22845
  try {
22751
- if (statSync13(f).mtimeMs > startedAt) return f;
22846
+ if (statSync14(f).mtimeMs > startedAt) return f;
22752
22847
  } catch {
22753
22848
  }
22754
22849
  }
@@ -23596,7 +23691,7 @@ function parseSystemctlShow(text2) {
23596
23691
  }
23597
23692
  function lastLogLine(path, read = (p) => {
23598
23693
  try {
23599
- return readFileSync45(p, "utf8");
23694
+ return readFileSync46(p, "utf8");
23600
23695
  } catch {
23601
23696
  return null;
23602
23697
  }
@@ -23623,7 +23718,7 @@ function probeDaemonUnit(o) {
23623
23718
  const r = spawnSync11(cmd[0], cmd.slice(1), { encoding: "utf8" });
23624
23719
  return r.error ? null : { status: r.status, stdout: r.stdout ?? "" };
23625
23720
  });
23626
- const installed = o.plan.unitPaths.some((p) => existsSync48(p));
23721
+ const installed = o.plan.unitPaths.some((p) => existsSync49(p));
23627
23722
  let reading = null;
23628
23723
  if (installed && o.plan.mechanism === "launchd") {
23629
23724
  const r = run4(["launchctl", "print", `gui/${o.uid}/${o.label}`]);
@@ -23673,7 +23768,7 @@ function daemonProblem(d, route2) {
23673
23768
  }
23674
23769
  function readDaemonStamp(stateDir) {
23675
23770
  try {
23676
- const v = JSON.parse(readFileSync45(daemonStampFor(stateDir), "utf8"));
23771
+ const v = JSON.parse(readFileSync46(daemonStampFor(stateDir), "utf8"));
23677
23772
  if (typeof v.startedAt !== "number") return null;
23678
23773
  return typeof v.pid === "number" ? { pid: v.pid, startedAt: v.startedAt } : { startedAt: v.startedAt };
23679
23774
  } catch {
@@ -23702,7 +23797,7 @@ function defaultSleep2(ms3) {
23702
23797
  }
23703
23798
  function defaultReadLog(path) {
23704
23799
  try {
23705
- return readFileSync46(path, "utf8");
23800
+ return readFileSync47(path, "utf8");
23706
23801
  } catch {
23707
23802
  return null;
23708
23803
  }
@@ -23769,15 +23864,15 @@ function startLaunchdDaemon(o) {
23769
23864
  }
23770
23865
 
23771
23866
  // src/daemon-start-failure.ts
23772
- import { existsSync as existsSync49, mkdirSync as mkdirSync36, readFileSync as readFileSync47, unlinkSync as unlinkSync4, writeFileSync as writeFileSync37 } from "fs";
23773
- import { dirname as dirname29, join as join51 } from "path";
23867
+ import { existsSync as existsSync50, mkdirSync as mkdirSync36, readFileSync as readFileSync48, unlinkSync as unlinkSync4, writeFileSync as writeFileSync37 } from "fs";
23868
+ import { dirname as dirname29, join as join52 } from "path";
23774
23869
  var DAEMON_START_FAILED_KEY = "daemon_start_failed";
23775
23870
  var START_FAILURE_BACKOFF_MS = 6e4;
23776
23871
  var BACKOFF_AFTER_FAILURES = 2;
23777
- var fileFor3 = (stateDir) => join51(stateDir, ".daemon-start-failure.json");
23872
+ var fileFor3 = (stateDir) => join52(stateDir, ".daemon-start-failure.json");
23778
23873
  function readStartFailure(stateDir) {
23779
23874
  try {
23780
- const parsed = JSON.parse(readFileSync47(fileFor3(stateDir), "utf8"));
23875
+ const parsed = JSON.parse(readFileSync48(fileFor3(stateDir), "utf8"));
23781
23876
  return typeof parsed.reason === "string" && typeof parsed.count === "number" ? { reason: parsed.reason, count: parsed.count, firstAt: String(parsed.firstAt), lastAt: String(parsed.lastAt) } : null;
23782
23877
  } catch {
23783
23878
  return null;
@@ -23808,7 +23903,7 @@ function startFailureItem(record, o = {}) {
23808
23903
  return { kind: "daemon_start_failed", key: DAEMON_START_FAILED_KEY, message: parts.join(". ").replace(/\.\./g, "."), since: record.firstAt };
23809
23904
  }
23810
23905
  function clearStartFailure(state, stateDir) {
23811
- if (existsSync49(fileFor3(stateDir))) {
23906
+ if (existsSync50(fileFor3(stateDir))) {
23812
23907
  try {
23813
23908
  unlinkSync4(fileFor3(stateDir));
23814
23909
  } catch {
@@ -23835,7 +23930,7 @@ async function reportStartFailure(o) {
23835
23930
  return delay;
23836
23931
  }
23837
23932
  function fallbackStateDir(configFile) {
23838
- return join51(dirname29(configFile), "state");
23933
+ return join52(dirname29(configFile), "state");
23839
23934
  }
23840
23935
 
23841
23936
  // src/projects-cmd.ts
@@ -24163,7 +24258,7 @@ function missingReleaserWarning(repo, release, ships, now = Date.now()) {
24163
24258
  }
24164
24259
 
24165
24260
  // src/watch.ts
24166
- import { watch as watchFile, existsSync as existsSync50, statSync as statSync14, openSync as openSync5, readSync as readSync2, closeSync as closeSync5 } from "fs";
24261
+ import { watch as watchFile, existsSync as existsSync51, statSync as statSync15, openSync as openSync6, readSync as readSync3, closeSync as closeSync6 } from "fs";
24167
24262
  var E = "\x1B[";
24168
24263
  var dim = (s) => `${E}2m${s}${E}0m`;
24169
24264
  var bold = (s) => `${E}1m${s}${E}0m`;
@@ -24264,14 +24359,14 @@ function renderHeaders(states, now = Date.now()) {
24264
24359
  return states.map((s) => renderHeader(s, now)).join("");
24265
24360
  }
24266
24361
  function readFrom(file, from) {
24267
- if (!existsSync50(file)) return { events: [], offset: from };
24268
- const size = statSync14(file).size;
24362
+ if (!existsSync51(file)) return { events: [], offset: from };
24363
+ const size = statSync15(file).size;
24269
24364
  if (size < from) return readFrom(file, 0);
24270
24365
  if (size === from) return { events: [], offset: from };
24271
- const fd = openSync5(file, "r");
24366
+ const fd = openSync6(file, "r");
24272
24367
  const buf = Buffer.alloc(size - from);
24273
- readSync2(fd, buf, 0, buf.length, from);
24274
- closeSync5(fd);
24368
+ readSync3(fd, buf, 0, buf.length, from);
24369
+ closeSync6(fd);
24275
24370
  const text2 = buf.toString("utf8");
24276
24371
  const lastNewline = text2.lastIndexOf("\n");
24277
24372
  if (lastNewline === -1) return { events: [], offset: from };
@@ -24424,13 +24519,32 @@ function renderInbox(items, byConnection = false, subject) {
24424
24519
  var ConnectHttpError = class extends Error {
24425
24520
  status;
24426
24521
  path;
24427
- constructor(status2, path, statusText) {
24428
- super(`${path}: ${status2} ${statusText}`);
24522
+ constructor(status2, path, statusText, detail) {
24523
+ super(`${path}: ${status2} ${statusText}${detail ? ` \u2014 ${detail}` : ""}`);
24429
24524
  this.name = "ConnectHttpError";
24430
24525
  this.status = status2;
24431
24526
  this.path = path;
24432
24527
  }
24433
24528
  };
24529
+ async function errorDetail(res) {
24530
+ let text2 = "";
24531
+ try {
24532
+ text2 = (await res.text()).trim();
24533
+ } catch {
24534
+ return "";
24535
+ }
24536
+ if (!text2) return "";
24537
+ try {
24538
+ const m = JSON.parse(text2).message;
24539
+ if (typeof m === "string" && m) return m.slice(0, 300);
24540
+ if (Array.isArray(m) && m.length > 0) return m.map(String).join("; ").slice(0, 300);
24541
+ } catch {
24542
+ }
24543
+ return text2.slice(0, 300);
24544
+ }
24545
+ async function httpError(res, path) {
24546
+ return new ConnectHttpError(res.status, path, res.statusText, await errorDetail(res));
24547
+ }
24434
24548
  async function get(o, path) {
24435
24549
  const res = await fetch(`${o.baseUrl.replace(/\/+$/, "")}/api${path}`, {
24436
24550
  headers: {
@@ -24439,7 +24553,7 @@ async function get(o, path) {
24439
24553
  "User-Agent": o.userAgent ?? "Mozilla/5.0 TablationCrewAgent/1.0"
24440
24554
  }
24441
24555
  });
24442
- if (!res.ok) throw new ConnectHttpError(res.status, path, res.statusText);
24556
+ if (!res.ok) throw await httpError(res, path);
24443
24557
  return await res.json();
24444
24558
  }
24445
24559
  async function post2(o, path, body) {
@@ -24452,7 +24566,7 @@ async function post2(o, path, body) {
24452
24566
  },
24453
24567
  body: JSON.stringify(body)
24454
24568
  });
24455
- if (!res.ok) throw new ConnectHttpError(res.status, path, res.statusText);
24569
+ if (!res.ok) throw await httpError(res, path);
24456
24570
  return await res.json();
24457
24571
  }
24458
24572
  async function patch(o, path, body) {
@@ -24465,7 +24579,7 @@ async function patch(o, path, body) {
24465
24579
  },
24466
24580
  body: JSON.stringify(body)
24467
24581
  });
24468
- if (!res.ok) throw new ConnectHttpError(res.status, path, res.statusText);
24582
+ if (!res.ok) throw await httpError(res, path);
24469
24583
  return await res.json();
24470
24584
  }
24471
24585
  async function del(o, path) {
@@ -24476,7 +24590,7 @@ async function del(o, path) {
24476
24590
  "User-Agent": o.userAgent ?? "Mozilla/5.0 TablationCrewAgent/1.0"
24477
24591
  }
24478
24592
  });
24479
- if (!res.ok) throw new ConnectHttpError(res.status, path, res.statusText);
24593
+ if (!res.ok) throw await httpError(res, path);
24480
24594
  }
24481
24595
  async function provisionReleaseLocks(o, locksModelId, route2, repoNames) {
24482
24596
  const scopes = [...new Set(repoNames)].sort().map((r) => releaseLockScope(route2, r));
@@ -24706,11 +24820,26 @@ async function discover(o) {
24706
24820
  const hostPassengers = o.ship.hostPassengers ?? false;
24707
24821
  const sshPublicKey = o.ship.sshPublicKey;
24708
24822
  let shipColumns = /* @__PURE__ */ new Set();
24823
+ const shipOptions = /* @__PURE__ */ new Map();
24709
24824
  try {
24710
24825
  const shipsModel = await get(o, `/data-models/${out.shipsModelId}`);
24711
24826
  shipColumns = new Set((shipsModel.fields ?? []).map((f) => f.columnName));
24827
+ for (const f of shipsModel.fields ?? []) {
24828
+ const opts = f.fieldType?.choiceOptions;
24829
+ if (Array.isArray(opts)) shipOptions.set(f.columnName, new Set(opts.map((x) => x.value)));
24830
+ }
24712
24831
  } catch {
24713
24832
  }
24833
+ const skippedChoice = /* @__PURE__ */ new Set();
24834
+ const choiceOk = (column, value2) => {
24835
+ const opts = shipOptions.get(column);
24836
+ if (!opts || opts.has(value2)) return true;
24837
+ if (!skippedChoice.has(`${column}=${value2}`)) {
24838
+ skippedChoice.add(`${column}=${value2}`);
24839
+ provisioning.push(`workspace's Ships ${column} type has no "${value2}" option \u2014 left ${column} unset; update the template`);
24840
+ }
24841
+ return false;
24842
+ };
24714
24843
  const hostPeriscopes = shipColumns.has("host_periscopes") ? o.ship.hostPeriscopes : void 0;
24715
24844
  let ownerId;
24716
24845
  if (out.meId) {
@@ -24755,8 +24884,8 @@ async function discover(o) {
24755
24884
  if (writeMachineId) patchBody.machine_id = machineId;
24756
24885
  if ((mine[0].host_passengers ?? false) !== hostPassengers) patchBody.host_passengers = hostPassengers;
24757
24886
  if (hostPeriscopes !== void 0 && (mine[0].host_periscopes ?? false) !== hostPeriscopes) patchBody.host_periscopes = hostPeriscopes;
24758
- if (o.ship.kind && shipColumns.has("kind") && (mine[0].kind ?? "") !== o.ship.kind) patchBody.kind = o.ship.kind;
24759
- if (o.ship.instanceClass && shipColumns.has("instance_class") && (mine[0].instance_class ?? "") !== o.ship.instanceClass) patchBody.instance_class = o.ship.instanceClass;
24887
+ if (o.ship.kind && shipColumns.has("kind") && choiceOk("kind", o.ship.kind) && (mine[0].kind ?? "") !== o.ship.kind) patchBody.kind = o.ship.kind;
24888
+ if (o.ship.instanceClass && shipColumns.has("instance_class") && choiceOk("instance_class", o.ship.instanceClass) && (mine[0].instance_class ?? "") !== o.ship.instanceClass) patchBody.instance_class = o.ship.instanceClass;
24760
24889
  if (sshPublicKey !== void 0 && (mine[0].ssh_public_key ?? "") !== sshPublicKey) {
24761
24890
  patchBody.ssh_public_key = sshPublicKey;
24762
24891
  }
@@ -24769,6 +24898,10 @@ async function discover(o) {
24769
24898
  if ("owner_id" in patchBody) provisioning.push(`recorded owner on Ships row "${o.ship.name}"`);
24770
24899
  }
24771
24900
  } else if (mine.length === 0) {
24901
+ if (o.ship.platform && shipOptions.get("platform") && !shipOptions.get("platform").has(o.ship.platform)) {
24902
+ throw new Error(`workspace's Ships platform type has no "${o.ship.platform}" option \u2014 update the template`);
24903
+ }
24904
+ const kindValue = o.ship.kind ?? "developer_machine";
24772
24905
  const created = await post2(o, `/data-models/${out.shipsModelId}/records`, {
24773
24906
  name: o.ship.name,
24774
24907
  ...o.ship.platform ? { platform: o.ship.platform } : {},
@@ -24779,8 +24912,8 @@ async function discover(o) {
24779
24912
  ...writeMachineId ? { machine_id: machineId } : {},
24780
24913
  // ISSUE-2791: a ship connecting by hand is a developer machine; the
24781
24914
  // column arrives with a template update, so only written when present.
24782
- ...shipColumns.has("kind") ? { kind: o.ship.kind ?? "developer_machine" } : {},
24783
- ...o.ship.instanceClass && shipColumns.has("instance_class") ? { instance_class: o.ship.instanceClass } : {}
24915
+ ...shipColumns.has("kind") && choiceOk("kind", kindValue) ? { kind: kindValue } : {},
24916
+ ...o.ship.instanceClass && shipColumns.has("instance_class") && choiceOk("instance_class", o.ship.instanceClass) ? { instance_class: o.ship.instanceClass } : {}
24784
24917
  });
24785
24918
  shipRowId = created.id;
24786
24919
  out.shipRow = { id: shipRowId, name: o.ship.name, action: "created", matchedBy };
@@ -25043,14 +25176,14 @@ function describeCapability(i) {
25043
25176
  }
25044
25177
 
25045
25178
  // src/persona-avatars.ts
25046
- import { existsSync as existsSync51, readFileSync as readFileSync48 } from "fs";
25047
- import { join as join52 } from "path";
25179
+ import { existsSync as existsSync52, readFileSync as readFileSync49 } from "fs";
25180
+ import { join as join53 } from "path";
25048
25181
  var IMAGE_TYPES = { png: "image/png", svg: "image/svg+xml" };
25049
25182
  function personaAvatarFile(promptsDir, role) {
25050
25183
  for (const ext of ["png", "svg"]) {
25051
25184
  const name = `lane-${role}.${ext}`;
25052
- const path = join52(promptsDir, "personas", name);
25053
- if (existsSync51(path)) return { path, mimeType: IMAGE_TYPES[ext], name };
25185
+ const path = join53(promptsDir, "personas", name);
25186
+ if (existsSync52(path)) return { path, mimeType: IMAGE_TYPES[ext], name };
25054
25187
  }
25055
25188
  return void 0;
25056
25189
  }
@@ -25064,7 +25197,7 @@ async function syncPersonaAvatars(route2, agentPersonas, opts) {
25064
25197
  if (!file || !agentId) continue;
25065
25198
  try {
25066
25199
  const form = new FormData();
25067
- form.append("file", new Blob([readFileSync48(file.path)], { type: file.mimeType }), file.name);
25200
+ form.append("file", new Blob([readFileSync49(file.path)], { type: file.mimeType }), file.name);
25068
25201
  const res = await fetch(`${base}/${agentId}/avatar`, {
25069
25202
  method: "PUT",
25070
25203
  headers: { Authorization: `Bearer ${resolveApiKey(route2)}`, "User-Agent": opts.userAgent ?? "Mozilla/5.0 TablationCrewAgent/1.0" },
@@ -25105,14 +25238,14 @@ function avatarFailures(raw) {
25105
25238
  }
25106
25239
  function routeAvatarFailures(stateDir, route2) {
25107
25240
  try {
25108
- return avatarFailures(JSON.parse(readFileSync48(resolvedPathFor(stateDir, route2), "utf8")));
25241
+ return avatarFailures(JSON.parse(readFileSync49(resolvedPathFor(stateDir, route2), "utf8")));
25109
25242
  } catch {
25110
25243
  return [];
25111
25244
  }
25112
25245
  }
25113
25246
 
25114
25247
  // src/agents-sync-run.ts
25115
- import { existsSync as existsSync52, mkdirSync as mkdirSync38, readFileSync as readFileSync49, writeFileSync as writeFileSync39 } from "fs";
25248
+ import { existsSync as existsSync53, mkdirSync as mkdirSync38, readFileSync as readFileSync50, writeFileSync as writeFileSync39 } from "fs";
25116
25249
  import { dirname as dirname31 } from "path";
25117
25250
  async function runAgentsSync(target, o) {
25118
25251
  const dryRun = o.dryRun ?? false;
@@ -25158,7 +25291,7 @@ async function runAgentsSync(target, o) {
25158
25291
  }
25159
25292
  if (!dryRun) {
25160
25293
  const resolvedPath = resolvedPathFor(o.stateDir, target.route);
25161
- const raw = existsSync52(resolvedPath) ? JSON.parse(readFileSync49(resolvedPath, "utf8")) : {};
25294
+ const raw = existsSync53(resolvedPath) ? JSON.parse(readFileSync50(resolvedPath, "utf8")) : {};
25162
25295
  raw.agentPersonas = personaResult.agentPersonas;
25163
25296
  if (skillResult) raw.agentSkills = skillResult.agentSkills;
25164
25297
  if (!readOnly) raw.avatarSyncFailures = avatarFailures2;
@@ -25301,7 +25434,7 @@ async function showLogEntry(route2, entryId, opts = {}) {
25301
25434
 
25302
25435
  // src/repos-check.ts
25303
25436
  import { spawnSync as spawnSync13 } from "child_process";
25304
- import { readFileSync as readFileSync50 } from "fs";
25437
+ import { readFileSync as readFileSync51 } from "fs";
25305
25438
  import { basename as basename12 } from "path";
25306
25439
  var POSIX_SHELL = /^(?:ba|z|da|k|a|mk)?sh$|^fish$/;
25307
25440
  function checkHookSyntax(script, shell) {
@@ -25342,7 +25475,7 @@ function checkRepoSpec(dir, opts = {}) {
25342
25475
  }
25343
25476
  let parsed;
25344
25477
  try {
25345
- parsed = parseRepoConfig(readFileSync50(file, "utf8"), file);
25478
+ parsed = parseRepoConfig(readFileSync51(file, "utf8"), file);
25346
25479
  } catch (e) {
25347
25480
  if (!(e instanceof RepoConfigError)) throw e;
25348
25481
  return { ...empty, file, error: e.message, exitCode: 1 };
@@ -25806,7 +25939,7 @@ ${run4.err}` });
25806
25939
  }
25807
25940
 
25808
25941
  // src/sample-ticket.ts
25809
- import { basename as basename13, dirname as dirname32, join as join53 } from "path";
25942
+ import { basename as basename13, dirname as dirname32, join as join54 } from "path";
25810
25943
  var SAMPLE_REPO = "crew-sample";
25811
25944
  var SAMPLE_REMOTE = `local/${SAMPLE_REPO}`;
25812
25945
  var SAMPLE_MARKER = "sample: true";
@@ -25829,8 +25962,8 @@ has something safe to work on: its test and build hooks always pass, it has no
25829
25962
  remote, and \`crew sample-ticket --remove\` deletes it.
25830
25963
  `;
25831
25964
  function sampleDir(existing, reposBase, workspace) {
25832
- if (existing.length > 0) return join53(dirname32(existing[0]), SAMPLE_REPO);
25833
- return join53(reposBase, workspace, SAMPLE_REPO);
25965
+ if (existing.length > 0) return join54(dirname32(existing[0]), SAMPLE_REPO);
25966
+ return join54(reposBase, workspace, SAMPLE_REPO);
25834
25967
  }
25835
25968
  var SAMPLE_TITLE = "Sample: add a documented `greet` function with a test";
25836
25969
  function sampleDescription() {
@@ -25874,8 +26007,8 @@ function planSampleTicket(i) {
25874
26007
  }
25875
26008
 
25876
26009
  // src/worktree-sweep.ts
25877
- import { existsSync as existsSync53, readFileSync as readFileSync51, readdirSync as readdirSync15 } from "fs";
25878
- import { basename as basename14, dirname as dirname33, join as join54, resolve as resolve5 } from "path";
26010
+ import { existsSync as existsSync54, readFileSync as readFileSync52, readdirSync as readdirSync16 } from "fs";
26011
+ import { basename as basename14, dirname as dirname33, join as join55, resolve as resolve5 } from "path";
25879
26012
  function planWorktreeSweep(target, tickets, contract) {
25880
26013
  const terminal = new Set(contract.statuses.resolved.filter((s) => s !== contract.statuses.verified));
25881
26014
  const verified = contract.statuses.verified;
@@ -25944,7 +26077,7 @@ function siblingWorktreeDirs(target) {
25944
26077
  const registered = new Set(worktrees(target.dir).map((w) => resolve5(w.path)));
25945
26078
  let names;
25946
26079
  try {
25947
- names = readdirSync15(parent);
26080
+ names = readdirSync16(parent);
25948
26081
  } catch {
25949
26082
  return [];
25950
26083
  }
@@ -25952,7 +26085,7 @@ function siblingWorktreeDirs(target) {
25952
26085
  for (const name of names) {
25953
26086
  if (!name.startsWith(stem)) continue;
25954
26087
  const m = DIR_NUMBER_SUFFIXED.exec(name);
25955
- const path = join54(parent, name);
26088
+ const path = join55(parent, name);
25956
26089
  if (m && !registered.has(resolve5(path))) out.push({ path, number: m[1] });
25957
26090
  }
25958
26091
  return out;
@@ -25987,7 +26120,7 @@ async function applyWorktreeSweep(cwd, actions, dryRun, log, remote = "origin",
25987
26120
  let removed = 0;
25988
26121
  let keptBranches = 0;
25989
26122
  for (const a of actions) {
25990
- if (!dryRun && base && !a.keepBranch && existsSync53(a.path) && isHandBackMerge(a.path, base)) {
26123
+ if (!dryRun && base && !a.keepBranch && existsSync54(a.path) && isHandBackMerge(a.path, base)) {
25991
26124
  if (gitOk(a.path, ["merge", "--abort"]) !== null) {
25992
26125
  log.emit(
25993
26126
  `abandoned the hand-back merge of ${base} in ${a.path}: ${a.ticket.issue_id} deployed without it`,
@@ -26004,11 +26137,11 @@ async function applyWorktreeSweep(cwd, actions, dryRun, log, remote = "origin",
26004
26137
  { ticket: a.ticket.issue_id, step: "worktree" }
26005
26138
  );
26006
26139
  };
26007
- if (!dryRun && liveRun && existsSync53(a.path)) {
26140
+ if (!dryRun && liveRun && existsSync54(a.path)) {
26008
26141
  defer();
26009
26142
  continue;
26010
26143
  }
26011
- if (!dryRun && existsSync53(a.path)) {
26144
+ if (!dryRun && existsSync54(a.path)) {
26012
26145
  let dirty = false;
26013
26146
  try {
26014
26147
  dirty = status(a.path).length > 0;
@@ -26023,7 +26156,7 @@ async function applyWorktreeSweep(cwd, actions, dryRun, log, remote = "origin",
26023
26156
  continue;
26024
26157
  }
26025
26158
  }
26026
- if (!dryRun && a.requirePushed && a.branch && existsSync53(a.path) && remoteConfigured(cwd, remote) && worktreeHoldsUnpushed(a.path, remote)) {
26159
+ if (!dryRun && a.requirePushed && a.branch && existsSync54(a.path) && remoteConfigured(cwd, remote) && worktreeHoldsUnpushed(a.path, remote)) {
26027
26160
  if (pids.length) {
26028
26161
  defer();
26029
26162
  continue;
@@ -26074,7 +26207,7 @@ function isHandBackMerge(path, base) {
26074
26207
  if (!msgPath) return false;
26075
26208
  let first;
26076
26209
  try {
26077
- first = readFileSync51(resolve5(path, msgPath), "utf8").split("\n")[0] ?? "";
26210
+ first = readFileSync52(resolve5(path, msgPath), "utf8").split("\n")[0] ?? "";
26078
26211
  } catch {
26079
26212
  return false;
26080
26213
  }
@@ -26179,16 +26312,16 @@ function applyRemoteBranchCleanup(cwd, remote, branches2, dryRun, log) {
26179
26312
  }
26180
26313
 
26181
26314
  // src/stream-sweep.ts
26182
- import { existsSync as existsSync54, readdirSync as readdirSync16, rmSync as rmSync23, statSync as statSync15 } from "fs";
26183
- import { join as join55 } from "path";
26315
+ import { existsSync as existsSync55, readdirSync as readdirSync17, rmSync as rmSync23, statSync as statSync16 } from "fs";
26316
+ import { join as join56 } from "path";
26184
26317
  var DAY_MS2 = 24 * 60 * 60 * 1e3;
26185
26318
  function planStreamSweep(stateDir, retentionDays, now = Date.now()) {
26186
- const dir = join55(stateDir, "streams");
26187
- if (!existsSync54(dir)) return [];
26319
+ const dir = join56(stateDir, "streams");
26320
+ if (!existsSync55(dir)) return [];
26188
26321
  const cutoff = now - retentionDays * DAY_MS2;
26189
- return readdirSync16(dir).map((name) => join55(dir, name)).filter((path) => {
26322
+ return readdirSync17(dir).map((name) => join56(dir, name)).filter((path) => {
26190
26323
  try {
26191
- return statSync15(path).mtimeMs < cutoff;
26324
+ return statSync16(path).mtimeMs < cutoff;
26192
26325
  } catch {
26193
26326
  return false;
26194
26327
  }
@@ -26212,11 +26345,11 @@ function applyStreamSweep(paths, dryRun, log) {
26212
26345
  return removed;
26213
26346
  }
26214
26347
  function planEventsSweep(stateDir, retentionDays, now = Date.now()) {
26215
- if (!existsSync54(stateDir)) return [];
26348
+ if (!existsSync55(stateDir)) return [];
26216
26349
  const cutoff = now - retentionDays * DAY_MS2;
26217
- return readdirSync16(stateDir).filter((name) => ROTATED_EVENTS_RE.test(name)).map((name) => join55(stateDir, name)).filter((path) => {
26350
+ return readdirSync17(stateDir).filter((name) => ROTATED_EVENTS_RE.test(name)).map((name) => join56(stateDir, name)).filter((path) => {
26218
26351
  try {
26219
- return statSync15(path).mtimeMs < cutoff;
26352
+ return statSync16(path).mtimeMs < cutoff;
26220
26353
  } catch {
26221
26354
  return false;
26222
26355
  }
@@ -26224,7 +26357,7 @@ function planEventsSweep(stateDir, retentionDays, now = Date.now()) {
26224
26357
  }
26225
26358
 
26226
26359
  // src/cli.ts
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";
26360
+ import { realpathSync as realpathSync3, readFileSync as readFileSync55, existsSync as existsSync60, mkdirSync as mkdirSync42, writeFileSync as writeFileSync42, rmSync as rmSync26, unlinkSync as unlinkSync6, copyFileSync as copyFileSync2, renameSync as renameSync8, statSync as statSync19, readdirSync as readdirSync22 } from "fs";
26228
26361
  import { createInterface } from "readline/promises";
26229
26362
 
26230
26363
  // src/periscope-resume.ts
@@ -26300,33 +26433,33 @@ ${tail2(preview.output)}`);
26300
26433
  import { dirname as dirOf2, resolve as resolvePath } from "path";
26301
26434
 
26302
26435
  // src/bundle-staleness.ts
26303
- import { existsSync as existsSync55, readdirSync as readdirSync17, statSync as statSync16 } from "fs";
26304
- import { join as join56 } from "path";
26436
+ import { existsSync as existsSync56, readdirSync as readdirSync18, statSync as statSync17 } from "fs";
26437
+ import { join as join57 } from "path";
26305
26438
  function builtVersion() {
26306
- return true ? "0.143.3" : null;
26439
+ return true ? "0.144.0" : null;
26307
26440
  }
26308
26441
  var REBUILD_HINT = "rebuild with npm run build";
26309
26442
  function newestMtime(path) {
26310
26443
  let stat2;
26311
26444
  try {
26312
- stat2 = statSync16(path);
26445
+ stat2 = statSync17(path);
26313
26446
  } catch {
26314
26447
  return 0;
26315
26448
  }
26316
26449
  if (stat2.isFile()) return stat2.mtimeMs;
26317
26450
  if (!stat2.isDirectory()) return 0;
26318
26451
  let latest = stat2.mtimeMs;
26319
- for (const e of readdirSync17(path, { withFileTypes: true })) latest = Math.max(latest, newestMtime(join56(path, e.name)));
26452
+ for (const e of readdirSync18(path, { withFileTypes: true })) latest = Math.max(latest, newestMtime(join57(path, e.name)));
26320
26453
  return latest;
26321
26454
  }
26322
26455
  function bundleStaleness(i) {
26323
26456
  if (i.built === null || i.compiled) return null;
26324
- const src = join56(i.home, "src");
26325
- if (!existsSync55(src)) return null;
26457
+ const src = join57(i.home, "src");
26458
+ if (!existsSync56(src)) return null;
26326
26459
  if (i.built !== i.current) {
26327
26460
  return { kind: "version", builtVersion: i.built, message: `running a bundle built from ${i.built} (package.json names ${i.current}); ${REBUILD_HINT}` };
26328
26461
  }
26329
- const bundle = statSafe(join56(i.home, "dist", "cli.js"));
26462
+ const bundle = statSafe(join57(i.home, "dist", "cli.js"));
26330
26463
  if (bundle === null) return null;
26331
26464
  if (newestMtime(src) > bundle) {
26332
26465
  return { kind: "source", builtVersion: i.built, message: `running a bundle older than the source in src/ (both ${i.current}); ${REBUILD_HINT}` };
@@ -26335,7 +26468,7 @@ function bundleStaleness(i) {
26335
26468
  }
26336
26469
  function statSafe(p) {
26337
26470
  try {
26338
- return statSync16(p).mtimeMs;
26471
+ return statSync17(p).mtimeMs;
26339
26472
  } catch {
26340
26473
  return null;
26341
26474
  }
@@ -26493,8 +26626,8 @@ async function unregisterEndpoint(workspaceId, info, d) {
26493
26626
  import { createServer as createHttpServer } from "http";
26494
26627
  import { spawn as spawn9 } from "child_process";
26495
26628
  import { randomBytes as randomBytes2 } from "crypto";
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";
26629
+ import { existsSync as existsSync57, mkdirSync as mkdirSync39, readFileSync as readFileSync53, writeFileSync as writeFileSync40, unlinkSync as unlinkSync5, readdirSync as readdirSync19 } from "fs";
26630
+ import { join as join58 } from "path";
26498
26631
 
26499
26632
  // src/secret-compare.ts
26500
26633
  import { timingSafeEqual } from "crypto";
@@ -26587,20 +26720,20 @@ var defaultSpawn2 = (cmd, args, env) => {
26587
26720
  return child;
26588
26721
  };
26589
26722
  function syncDaemonStatePath(stateDir, workspaceId) {
26590
- return join57(stateDir, "passengers", `${workspaceId}-sync.json`);
26723
+ return join58(stateDir, "passengers", `${workspaceId}-sync.json`);
26591
26724
  }
26592
26725
  function readPersistedSyncDaemon(stateDir, workspaceId) {
26593
26726
  const path = syncDaemonStatePath(stateDir, workspaceId);
26594
- if (!existsSync56(path)) return void 0;
26727
+ if (!existsSync57(path)) return void 0;
26595
26728
  try {
26596
- return JSON.parse(readFileSync52(path, "utf8"));
26729
+ return JSON.parse(readFileSync53(path, "utf8"));
26597
26730
  } catch {
26598
26731
  return void 0;
26599
26732
  }
26600
26733
  }
26601
26734
  function writePersistedSyncDaemon(stateDir, state) {
26602
26735
  const path = syncDaemonStatePath(stateDir, state.workspaceId);
26603
- mkdirSync39(join57(stateDir, "passengers"), { recursive: true });
26736
+ mkdirSync39(join58(stateDir, "passengers"), { recursive: true });
26604
26737
  writeFileSync40(path, `${JSON.stringify(state, null, 2)}
26605
26738
  `);
26606
26739
  }
@@ -26621,10 +26754,10 @@ function waitForExit(pid, alive, timeoutMs = 5e3) {
26621
26754
  }
26622
26755
  }
26623
26756
  function readAllPersistedSyncWorkspaceIds(stateDir) {
26624
- const dir = join57(stateDir, "passengers");
26625
- if (!existsSync56(dir)) return [];
26757
+ const dir = join58(stateDir, "passengers");
26758
+ if (!existsSync57(dir)) return [];
26626
26759
  const suffix = "-sync.json";
26627
- return readdirSync18(dir).filter((f) => f.endsWith(suffix)).map((f) => f.slice(0, -suffix.length));
26760
+ return readdirSync19(dir).filter((f) => f.endsWith(suffix)).map((f) => f.slice(0, -suffix.length));
26628
26761
  }
26629
26762
  function syncPassengerSyncDaemons(plans, cfg, stateDir, deps = {}) {
26630
26763
  const alive = deps.isPidAlive ?? isPidAlive;
@@ -27088,7 +27221,7 @@ async function startWorktreeIntel(d) {
27088
27221
  }
27089
27222
 
27090
27223
  // src/contract-refusal.ts
27091
- import { join as join58 } from "path";
27224
+ import { join as join59 } from "path";
27092
27225
  function contractFixers(dir, baseRef, tickets, locate) {
27093
27226
  const out = [];
27094
27227
  for (const t of tickets) {
@@ -27100,7 +27233,7 @@ function contractFixers(dir, baseRef, tickets, locate) {
27100
27233
  const text2 = gitOk(dir, ["show", `${branch}:${file}`]);
27101
27234
  if (text2 === null) continue;
27102
27235
  try {
27103
- parseRepoConfig(text2, join58(dir, file));
27236
+ parseRepoConfig(text2, join59(dir, file));
27104
27237
  } catch (e) {
27105
27238
  if (e instanceof RepoConfigError) continue;
27106
27239
  throw e;
@@ -27114,19 +27247,19 @@ function contractFixers(dir, baseRef, tickets, locate) {
27114
27247
  import { createHash as createHash11 } from "crypto";
27115
27248
  import {
27116
27249
  chmodSync as chmodSync4,
27117
- closeSync as closeSync6,
27118
- existsSync as existsSync57,
27119
- fstatSync,
27120
- openSync as openSync6,
27121
- readSync as readSync3,
27122
- readdirSync as readdirSync19,
27250
+ closeSync as closeSync7,
27251
+ existsSync as existsSync58,
27252
+ fstatSync as fstatSync2,
27253
+ openSync as openSync7,
27254
+ readSync as readSync4,
27255
+ readdirSync as readdirSync20,
27123
27256
  rmSync as rmSync24,
27124
- statSync as statSync17,
27257
+ statSync as statSync18,
27125
27258
  watch
27126
27259
  } from "fs";
27127
27260
  import { createConnection } from "net";
27128
27261
  import { createServer as createServer2 } from "http";
27129
- import { basename as basename15, dirname as dirname35, join as join59 } from "path";
27262
+ import { basename as basename15, dirname as dirname35, join as join60 } from "path";
27130
27263
  import { execFile as execFile6, spawn as spawn12 } from "child_process";
27131
27264
 
27132
27265
  // src/periscope-control.ts
@@ -27363,7 +27496,7 @@ function runCrew(args, onLine, timeoutMs = 20 * 6e4) {
27363
27496
  // src/control-api.ts
27364
27497
  var PAUSABLE = ["dev", "design", "qa"];
27365
27498
  var CONTROL_SOCKET_NAME = "control.sock";
27366
- var controlSocketFor = (stateDir) => join59(stateDir, CONTROL_SOCKET_NAME);
27499
+ var controlSocketFor = (stateDir) => join60(stateDir, CONTROL_SOCKET_NAME);
27367
27500
  var MAX_SOCKET_PATH = 100;
27368
27501
  var MAX_TAIL_BYTES = 1024 * 1024;
27369
27502
  var MAX_WAIT_SECONDS = 30;
@@ -27450,30 +27583,30 @@ function candidates(live2, rotated) {
27450
27583
  const out = [live2];
27451
27584
  if (!rotated) return out;
27452
27585
  try {
27453
- for (const n of readdirSync19(dirname35(live2))) if (ROTATED_EVENTS_RE.test(n)) out.push(join59(dirname35(live2), n));
27586
+ for (const n of readdirSync20(dirname35(live2))) if (ROTATED_EVENTS_RE.test(n)) out.push(join60(dirname35(live2), n));
27454
27587
  } catch {
27455
27588
  }
27456
27589
  return out;
27457
27590
  }
27458
27591
  function readRange(path, from, max) {
27459
- const fd = openSync6(path, "r");
27592
+ const fd = openSync7(path, "r");
27460
27593
  try {
27461
- const size = fstatSync(fd).size;
27594
+ const size = fstatSync2(fd).size;
27462
27595
  const len = Math.max(0, Math.min(size - from, max));
27463
27596
  const buf = Buffer.alloc(len);
27464
27597
  let got = 0;
27465
27598
  while (got < len) {
27466
- const n = readSync3(fd, buf, got, len - got, from + got);
27599
+ const n = readSync4(fd, buf, got, len - got, from + got);
27467
27600
  if (n <= 0) break;
27468
27601
  got += n;
27469
27602
  }
27470
27603
  return { text: buf.subarray(0, got).toString("utf8"), size };
27471
27604
  } finally {
27472
- closeSync6(fd);
27605
+ closeSync7(fd);
27473
27606
  }
27474
27607
  }
27475
27608
  function lastLines2(path, n) {
27476
- const st = statSync17(path);
27609
+ const st = statSync18(path);
27477
27610
  const cursorAt = (off) => encodeCursor({ dev: st.dev, ino: st.ino, off });
27478
27611
  if (n <= 0 || st.size === 0) return { lines: [], cursor: cursorAt(st.size), reset: false };
27479
27612
  let start = st.size;
@@ -27494,7 +27627,7 @@ function lastLines2(path, n) {
27494
27627
  }
27495
27628
  function readTail(live2, opts) {
27496
27629
  const max = opts.maxBytes ?? MAX_TAIL_BYTES;
27497
- if (!existsSync57(live2)) {
27630
+ if (!existsSync58(live2)) {
27498
27631
  return { lines: [], cursor: opts.after ?? encodeCursor({ dev: 0, ino: 0, off: 0 }), reset: false };
27499
27632
  }
27500
27633
  const cur = opts.after ? decodeCursor(opts.after) : null;
@@ -27507,7 +27640,7 @@ function readTail(live2, opts) {
27507
27640
  } else {
27508
27641
  const found = candidates(live2, opts.rotated ?? false).find((p) => {
27509
27642
  try {
27510
- const s = statSync17(p);
27643
+ const s = statSync18(p);
27511
27644
  return s.ino === cur.ino && s.dev === cur.dev;
27512
27645
  } catch {
27513
27646
  return false;
@@ -27518,7 +27651,7 @@ function readTail(live2, opts) {
27518
27651
  off = cur.off;
27519
27652
  } else reset = true;
27520
27653
  }
27521
- let size = statSync17(path).size;
27654
+ let size = statSync18(path).size;
27522
27655
  if (off > size) {
27523
27656
  off = 0;
27524
27657
  reset = true;
@@ -27526,12 +27659,12 @@ function readTail(live2, opts) {
27526
27659
  if (off >= size && path !== live2) {
27527
27660
  path = live2;
27528
27661
  off = 0;
27529
- size = statSync17(path).size;
27662
+ size = statSync18(path).size;
27530
27663
  }
27531
27664
  const { text: text2 } = readRange(path, off, max);
27532
27665
  const cut = text2.lastIndexOf("\n");
27533
27666
  const whole = cut < 0 ? "" : text2.slice(0, cut + 1);
27534
- const st = statSync17(path);
27667
+ const st = statSync18(path);
27535
27668
  return {
27536
27669
  lines: whole.split("\n").filter((l) => l.length),
27537
27670
  cursor: encodeCursor({ dev: st.dev, ino: st.ino, off: off + Buffer.byteLength(whole) }),
@@ -27673,8 +27806,8 @@ async function route(deps, method, url, req, abort) {
27673
27806
  if (p.startsWith("/streams/") && get2) {
27674
27807
  const run4 = decodeURIComponent(p.slice("/streams/".length));
27675
27808
  if (!RUN_NAME_RE.test(run4) || run4.includes("..") || /\.(pid|meta\.json|events\.jsonl)$/.test(run4)) return err2(400, "not a run name");
27676
- const file = join59(deps.stateDir, "streams", run4.endsWith(".jsonl") ? run4 : `${run4}.jsonl`);
27677
- if (!existsSync57(file)) return err2(404, "no such run");
27809
+ const file = join60(deps.stateDir, "streams", run4.endsWith(".jsonl") ? run4 : `${run4}.jsonl`);
27810
+ if (!existsSync58(file)) return err2(404, "no such run");
27678
27811
  return tailReply(file, url.searchParams, false, abort);
27679
27812
  }
27680
27813
  const note = /^\/streams\/([^/]+)\/messages$/.exec(p);
@@ -27721,7 +27854,7 @@ function send2(res, r) {
27721
27854
  res.end(body);
27722
27855
  }
27723
27856
  async function socketIsStale(path) {
27724
- if (!existsSync57(path)) return false;
27857
+ if (!existsSync58(path)) return false;
27725
27858
  return new Promise((resolve8) => {
27726
27859
  const c = createConnection(path);
27727
27860
  c.once("connect", () => {
@@ -27740,7 +27873,7 @@ async function startControlServer(deps) {
27740
27873
  return null;
27741
27874
  }
27742
27875
  if (await socketIsStale(path)) rmSync24(path, { force: true });
27743
- else if (existsSync57(path)) {
27876
+ else if (existsSync58(path)) {
27744
27877
  log(`control API not started: ${path} is in use by another process`);
27745
27878
  return null;
27746
27879
  }
@@ -27826,19 +27959,19 @@ function crewJson(args, timeoutMs = 6e4) {
27826
27959
 
27827
27960
  // src/periscope-mcp.ts
27828
27961
  import { lstat, mkdir, readdir, readFile, readlink, realpath, rm, stat, writeFile } from "fs/promises";
27829
- import { basename as basename16, dirname as dirname36, isAbsolute as isAbsolute5, join as join61, relative as relative2, resolve as resolve6, sep } from "path";
27962
+ import { basename as basename16, dirname as dirname36, isAbsolute as isAbsolute5, join as join62, relative as relative2, resolve as resolve6, sep } from "path";
27830
27963
  import { z } from "zod";
27831
27964
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
27832
27965
  import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
27833
27966
 
27834
27967
  // src/periscope-endpoints.ts
27835
27968
  import { randomBytes as randomBytes3 } from "crypto";
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`);
27969
+ import { chmodSync as chmodSync5, existsSync as existsSync59, mkdirSync as mkdirSync41, readdirSync as readdirSync21, readFileSync as readFileSync54, rmSync as rmSync25, writeFileSync as writeFileSync41 } from "fs";
27970
+ import { join as join61 } from "path";
27971
+ var secretDir = (stateDir) => join61(stateDir, "periscope-mcp");
27972
+ var secretFile = (stateDir, id) => join61(secretDir(stateDir), `${id}.json`);
27973
+ var endpointDir = (stateDir) => join61(stateDir, "periscope-endpoints");
27974
+ var endpointFile = (stateDir, id) => join61(endpointDir(stateDir), `${id}.json`);
27842
27975
  function mintPeriscopeSecret(stateDir, ticketRecordId) {
27843
27976
  mkdirSync41(secretDir(stateDir), { recursive: true, mode: 448 });
27844
27977
  const secret = randomBytes3(32).toString("base64url");
@@ -27850,7 +27983,7 @@ function mintPeriscopeSecret(stateDir, ticketRecordId) {
27850
27983
  }
27851
27984
  function readPeriscopeSecret(stateDir, ticketRecordId) {
27852
27985
  try {
27853
- const v = JSON.parse(readFileSync53(secretFile(stateDir, ticketRecordId), "utf8"));
27986
+ const v = JSON.parse(readFileSync54(secretFile(stateDir, ticketRecordId), "utf8"));
27854
27987
  return typeof v.secret === "string" && v.secret ? v.secret : void 0;
27855
27988
  } catch {
27856
27989
  return void 0;
@@ -27861,7 +27994,7 @@ function removePeriscopeSecret(stateDir, ticketRecordId) {
27861
27994
  }
27862
27995
  function readPeriscopeEndpoint(stateDir, ticketRecordId) {
27863
27996
  try {
27864
- return JSON.parse(readFileSync53(endpointFile(stateDir, ticketRecordId), "utf8"));
27997
+ return JSON.parse(readFileSync54(endpointFile(stateDir, ticketRecordId), "utf8"));
27865
27998
  } catch {
27866
27999
  return void 0;
27867
28000
  }
@@ -27876,9 +28009,9 @@ function removePeriscopeEndpointRecord(stateDir, ticketRecordId) {
27876
28009
  }
27877
28010
  function listPeriscopeEndpoints(stateDir) {
27878
28011
  const dir = endpointDir(stateDir);
27879
- if (!existsSync58(dir)) return [];
28012
+ if (!existsSync59(dir)) return [];
27880
28013
  const out = [];
27881
- for (const name of readdirSync20(dir)) {
28014
+ for (const name of readdirSync21(dir)) {
27882
28015
  if (!name.endsWith(".json")) continue;
27883
28016
  const rec = readPeriscopeEndpoint(stateDir, name.slice(0, -".json".length));
27884
28017
  if (rec && typeof rec.endpointId === "string") out.push(rec);
@@ -27979,13 +28112,13 @@ async function resolveInWorktree(root, requested) {
27979
28112
  let abs;
27980
28113
  if (isAbsolute5(requested)) {
27981
28114
  abs = resolve6(requested);
27982
- if (isInside(root, abs)) abs = join61(realRoot, relative2(root, abs));
28115
+ if (isInside(root, abs)) abs = join62(realRoot, relative2(root, abs));
27983
28116
  } else {
27984
28117
  abs = resolve6(realRoot, requested);
27985
28118
  }
27986
28119
  if (!isInside(realRoot, abs)) throw new PathRefusal(`${requested} is outside this periscope's worktree`);
27987
28120
  const { real, rest } = await realAncestor(abs);
27988
- const final = rest ? join61(real, rest) : real;
28121
+ const final = rest ? join62(real, rest) : real;
27989
28122
  if (!isInside(realRoot, final)) throw new PathRefusal(`${requested} is outside this periscope's worktree`);
27990
28123
  if (relative2(realRoot, final).split(sep).includes(".git")) throw new PathRefusal(".git is not reachable from a periscope");
27991
28124
  return final;
@@ -28053,7 +28186,7 @@ function createPeriscopeMcpServer(d, sc) {
28053
28186
  const entries = (await readdir(abs, { withFileTypes: true })).filter((e) => e.name !== ".git");
28054
28187
  const lines2 = await Promise.all(entries.map(async (e) => {
28055
28188
  if (e.isDirectory()) return `[DIR] ${e.name}`;
28056
- const size = (await lstat(join61(abs, e.name))).size;
28189
+ const size = (await lstat(join62(abs, e.name))).size;
28057
28190
  return `[FILE] ${e.name} (${size} bytes)`;
28058
28191
  }));
28059
28192
  return text(lines2.join("\n") || "(empty)");
@@ -28119,7 +28252,7 @@ function createPeriscopeMcpServer(d, sc) {
28119
28252
  annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: false }
28120
28253
  }, async ({ path }) => {
28121
28254
  const parent = await inTree(dirname36(path) === "" ? "." : dirname36(path));
28122
- const abs = join61(parent, basename16(path));
28255
+ const abs = join62(parent, basename16(path));
28123
28256
  if (basename16(path) === ".git" || abs === parent) return text("path must name a file", true);
28124
28257
  const st = await lstat(abs).catch(() => void 0);
28125
28258
  if (!st) return text(`${path} does not exist`, true);
@@ -28614,7 +28747,7 @@ if (command === "provision") {
28614
28747
  process.exit(outcome.code);
28615
28748
  }
28616
28749
  if (command === "pool-member") {
28617
- const pool = poolConfigFrom(argv, process.env, () => readFileSync54(0, "utf8"));
28750
+ const pool = poolConfigFrom(argv, process.env, () => readFileSync55(0, "utf8"));
28618
28751
  if (typeof pool === "string") {
28619
28752
  process.stderr.write(`crew pool-member: ${pool}
28620
28753
  `);
@@ -28935,7 +29068,7 @@ if (command === "passenger-sync-daemon") {
28935
29068
  } else {
28936
29069
  const toleratesNoRoutes = command === "credential" || command === "forge" || command === "repos" || command === "ship" || command === "disconnect" && flag("reset") || command === "deprovision" || command === "connect" && flag("sign-out");
28937
29070
  const configless = command === "connect" && flag("sign-out") || command === "disconnect" && flag("reset") || command === "deprovision";
28938
- if (configless && !existsSync59(findConfigFile(CREW_HOME))) {
29071
+ if (configless && !existsSync60(findConfigFile(CREW_HOME))) {
28939
29072
  cfg = loadConfig(CREW_HOME, firstRunConfigPath(), { text: "ship: {}\n", allowNoRoutes: true });
28940
29073
  } else {
28941
29074
  cfg = loadConfig(CREW_HOME, void 0, toleratesNoRoutes ? { allowNoRoutes: true } : {});
@@ -28958,7 +29091,7 @@ if (command === "passenger-sync-daemon") {
28958
29091
  throw e;
28959
29092
  }
28960
29093
  if (command === "credential") {
28961
- const r = runCredential(positional[1], readFileSync54(0, "utf8"), cfg.ship.forges, cfg.ship.stateDir, process.env, !flag("no-miss"));
29094
+ const r = runCredential(positional[1], readFileSync55(0, "utf8"), cfg.ship.forges, cfg.ship.stateDir, process.env, !flag("no-miss"));
28962
29095
  process.stdout.write(r.out);
28963
29096
  process.stderr.write(r.err);
28964
29097
  process.exit(r.code);
@@ -28970,9 +29103,9 @@ if (command === "passenger-sync-daemon") {
28970
29103
  forges: cfg.ship.forges,
28971
29104
  stateDir: cfg.ship.stateDir,
28972
29105
  configFile: cfg.configFile,
28973
- readFile: (p) => readFileSync54(p, "utf8"),
29106
+ readFile: (p) => readFileSync55(p, "utf8"),
28974
29107
  writeFile: (p, t) => writeFileSync42(p, t),
28975
- stdin: () => readFileSync54(0, "utf8"),
29108
+ stdin: () => readFileSync55(0, "utf8"),
28976
29109
  env: process.env
28977
29110
  }
28978
29111
  );
@@ -29311,8 +29444,8 @@ if (command === "passenger-sync-daemon") {
29311
29444
  }
29312
29445
  if (host === "linux" && hasSystemd) {
29313
29446
  const label = labelFor(CREW_HOME, "run");
29314
- const staleTimer = join62(homedir11(), ".config", "systemd", "user", `${label}.timer`);
29315
- if (existsSync59(staleTimer)) {
29447
+ const staleTimer = join63(homedir11(), ".config", "systemd", "user", `${label}.timer`);
29448
+ if (existsSync60(staleTimer)) {
29316
29449
  process.stdout.write(
29317
29450
  `removing stale run timer from before the persistent-service cutover: ${staleTimer}${dryRun ? " (dry run)" : ""}
29318
29451
  `
@@ -29341,7 +29474,7 @@ if (command === "passenger-sync-daemon") {
29341
29474
  const { settled: doctorRepos, errors: refusedRepos } = await settleRepos(reposOf(c), (t) => t.name, (t) => resolveOneRepo(c, t));
29342
29475
  for (const e of refusedRepos) problems.push(`repo ${e.repo}: ${e.detail}`);
29343
29476
  for (const r of doctorRepos) {
29344
- if (!existsSync59(r.dir)) problems.push(`repo ${r.name}: ${r.dir} is missing on disk`);
29477
+ if (!existsSync60(r.dir)) problems.push(`repo ${r.name}: ${r.dir} is missing on disk`);
29345
29478
  if (!satisfies(host, r.config.platform)) problems.push(`repo ${r.name}: requires ${r.config.platform}, this host is ${host}`);
29346
29479
  readiness.push(...validateEffective(r.config).map((p) => `repo ${r.name}: ${p}`));
29347
29480
  }
@@ -29377,7 +29510,7 @@ if (command === "passenger-sync-daemon") {
29377
29510
  }
29378
29511
  async function doctorFix(o) {
29379
29512
  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))));
29380
- const unitExists = (p) => existsSync59(p);
29513
+ const unitExists = (p) => existsSync60(p);
29381
29514
  const crontab = o.host === "linux" ? spawnSync14("crontab", ["-l"], { encoding: "utf8" }).stdout ?? "" : "";
29382
29515
  const schedulerAbsent = o.host !== "windows" ? !schedulerInstalled(planInstall(cfg.ship, CREW_HOME, o.host, detectSystemd(), "run", installContext()), unitExists, crontab) : true;
29383
29516
  const plan = planFix({ routes, schedulerAbsent, host: o.host });
@@ -29394,7 +29527,7 @@ if (command === "passenger-sync-daemon") {
29394
29527
  for (const a of plan.actions) {
29395
29528
  if (a.kind === "enable") {
29396
29529
  if (prompter && !await prompter.confirm(`Route ${a.route} passes every check \u2014 set enabled: true in ${cfg.configFile}?`, false)) continue;
29397
- writeFileSync42(cfg.configFile, planEnable(readFileSync54(cfg.configFile, "utf8"), a.route));
29530
+ writeFileSync42(cfg.configFile, planEnable(readFileSync55(cfg.configFile, "utf8"), a.route));
29398
29531
  enabledSound.add(a.route);
29399
29532
  changed2.push(`enabled route ${a.route} in ${cfg.configFile}`);
29400
29533
  } else {
@@ -29623,7 +29756,7 @@ ${changed2.map((c) => ` - ${c}
29623
29756
  harnessBin: "claude",
29624
29757
  ...contract.sandboxNetwork ? { extraHosts: contract.sandboxNetwork.hosts, toolchains: contract.sandboxNetwork.toolchains } : {}
29625
29758
  },
29626
- policyFile: join62(cfg.ship.stateDir, "release", `${target.name}.policy.yaml`),
29759
+ policyFile: join63(cfg.ship.stateDir, "release", `${target.name}.policy.yaml`),
29627
29760
  repo: mirror,
29628
29761
  origin: forgeDescriptorFor(forgeHost).httpsUrl(mirror.host, mirror.path),
29629
29762
  base: effective.branch.base,
@@ -30890,7 +31023,7 @@ ${f.tail.trimEnd()}
30890
31023
  logFile: cfg.ship.logFile
30891
31024
  });
30892
31025
  }
30893
- const watchPaths = isCompiledBinary(import.meta.url) ? [process.execPath] : [join62(CREW_HOME, "src"), join62(CREW_HOME, "dist"), join62(CREW_HOME, "bin")];
31026
+ const watchPaths = isCompiledBinary(import.meta.url) ? [process.execPath] : [join63(CREW_HOME, "src"), join63(CREW_HOME, "dist"), join63(CREW_HOME, "bin")];
30894
31027
  const configPaths = daemonConfigPaths(cfg);
30895
31028
  watchPaths.push(...configPaths);
30896
31029
  noteDaemonStarted(cfg.ship.stateDir);
@@ -31228,7 +31361,7 @@ ${f.tail.trimEnd()}
31228
31361
  `);
31229
31362
  if (!dryRun) {
31230
31363
  const resolvedPath = resolvedPathFor(cfg.ship.stateDir, target.route);
31231
- const raw = existsSync59(resolvedPath) ? JSON.parse(readFileSync54(resolvedPath, "utf8")) : {};
31364
+ const raw = existsSync60(resolvedPath) ? JSON.parse(readFileSync55(resolvedPath, "utf8")) : {};
31232
31365
  raw.agentSkills = result.agentSkills;
31233
31366
  mkdirSync42(dirOf2(resolvedPath), { recursive: true });
31234
31367
  writeFileSync42(resolvedPath, `${JSON.stringify(raw, null, 2)}
@@ -31254,7 +31387,7 @@ ${f.tail.trimEnd()}
31254
31387
  throw e;
31255
31388
  }
31256
31389
  const oldName = cfg.ship.name;
31257
- writeFileSync42(cfg.configFile, setShipNameInYaml(readFileSync54(cfg.configFile, "utf8"), newName));
31390
+ writeFileSync42(cfg.configFile, setShipNameInYaml(readFileSync55(cfg.configFile, "utf8"), newName));
31258
31391
  cfg.ship.name = newName;
31259
31392
  let renameMachineId;
31260
31393
  try {
@@ -31301,7 +31434,7 @@ ${f.tail.trimEnd()}
31301
31434
  process.exit(2);
31302
31435
  };
31303
31436
  if (sub !== "add" && sub !== "list" && sub !== "clone" && sub !== "hooks" && sub !== "check") usage2();
31304
- const configText = readFileSync54(cfg.configFile, "utf8");
31437
+ const configText = readFileSync55(cfg.configFile, "utf8");
31305
31438
  if (sub === "check") {
31306
31439
  try {
31307
31440
  const routeArg = value("route") ?? positional[2];
@@ -31333,16 +31466,16 @@ ${f.tail.trimEnd()}
31333
31466
  try {
31334
31467
  const a = parseHooksArgs(positional.slice(2), routeNamesOf(configText));
31335
31468
  const dir = repoDirOf(configText, dirname37(cfg.configFile), a.route, a.name);
31336
- if (!existsSync59(dir)) throw new ReposError(`${dir} does not exist on disk`);
31337
- const files = { exists: (r) => existsSync59(resolvePath(dir, r)), list: (r) => {
31469
+ if (!existsSync60(dir)) throw new ReposError(`${dir} does not exist on disk`);
31470
+ const files = { exists: (r) => existsSync60(resolvePath(dir, r)), list: (r) => {
31338
31471
  try {
31339
- return readdirSync21(resolvePath(dir, r));
31472
+ return readdirSync22(resolvePath(dir, r));
31340
31473
  } catch {
31341
31474
  return [];
31342
31475
  }
31343
31476
  }, read: (r) => {
31344
31477
  try {
31345
- return readFileSync54(resolvePath(dir, r), "utf8");
31478
+ return readFileSync55(resolvePath(dir, r), "utf8");
31346
31479
  } catch {
31347
31480
  return void 0;
31348
31481
  }
@@ -31452,7 +31585,7 @@ ${f.tail.trimEnd()}
31452
31585
  if (sub === "list" && !routeName) usage2();
31453
31586
  if (sub === "add") {
31454
31587
  try {
31455
- const a = parseAddArgs(positional.slice(2), routeNamesOf(configText), (p) => existsSync59(resolvePath(p.replace(/^~(?=\/|$)/, homedir11()))));
31588
+ const a = parseAddArgs(positional.slice(2), routeNamesOf(configText), (p) => existsSync60(resolvePath(p.replace(/^~(?=\/|$)/, homedir11()))));
31456
31589
  routeName = a.route;
31457
31590
  addPath = a.path;
31458
31591
  addName = a.name;
@@ -31482,7 +31615,7 @@ ${f.tail.trimEnd()}
31482
31615
  const resolvedFile = resolvedPathFor(cfg.ship.stateDir, routeName);
31483
31616
  if (sub === "list" || sub === "add") {
31484
31617
  const liveRoute = cfg.routes.find((r) => r.route === routeName);
31485
- if (liveRoute?.resolved?.reposModelId && existsSync59(resolvedFile) && !dryRun) {
31618
+ if (liveRoute?.resolved?.reposModelId && existsSync60(resolvedFile) && !dryRun) {
31486
31619
  try {
31487
31620
  await hydrateApiKeys([liveRoute]);
31488
31621
  persistRepoRows(cfg.ship.stateDir, liveRoute.route, await new Tracker(liveRoute, cfg.ship).repoRowsForMap());
@@ -31491,16 +31624,16 @@ ${f.tail.trimEnd()}
31491
31624
  }
31492
31625
  }
31493
31626
  let resolvedRemotes;
31494
- if (existsSync59(resolvedFile)) {
31627
+ if (existsSync60(resolvedFile)) {
31495
31628
  try {
31496
- resolvedRemotes = JSON.parse(readFileSync54(resolvedFile, "utf8"));
31629
+ resolvedRemotes = JSON.parse(readFileSync55(resolvedFile, "utf8"));
31497
31630
  } catch {
31498
31631
  }
31499
31632
  }
31500
31633
  const originOf = (dir) => gitOk(dir, ["remote", "get-url", "origin"]) ?? void 0;
31501
31634
  const text2 = configText;
31502
31635
  const base = dirname37(cfg.configFile);
31503
- const isCheckout = (d) => existsSync59(`${d}/.git`);
31636
+ const isCheckout = (d) => existsSync60(`${d}/.git`);
31504
31637
  try {
31505
31638
  if (sub === "list") {
31506
31639
  if (flag("json")) {
@@ -31510,12 +31643,12 @@ ${f.tail.trimEnd()}
31510
31643
  base,
31511
31644
  resolved: resolvedRemotes,
31512
31645
  originOf,
31513
- exists: (d) => existsSync59(d),
31646
+ exists: (d) => existsSync60(d),
31514
31647
  isCheckout,
31515
31648
  repoHasHooks: (d) => REPO_CONFIG_FILENAMES.some((f) => {
31516
31649
  try {
31517
31650
  const path = resolvePath(d, f);
31518
- return Object.keys(parseRepoConfig(readFileSync54(path, "utf8"), path).hooks).length > 0;
31651
+ return Object.keys(parseRepoConfig(readFileSync55(path, "utf8"), path).hooks).length > 0;
31519
31652
  } catch {
31520
31653
  return false;
31521
31654
  }
@@ -31532,7 +31665,7 @@ ${f.tail.trimEnd()}
31532
31665
  for (const r of repos) {
31533
31666
  const origin2 = originOf(r.dir);
31534
31667
  const row = matchRepoName(origin2, resolvedRemotes);
31535
- const note = !existsSync59(r.dir) ? "missing on disk" : row ? `Repos row: ${row}` : `no Repos row matches ${normalizeRemote2(origin2) ?? "this checkout (no origin remote)"}`;
31668
+ const note = !existsSync60(r.dir) ? "missing on disk" : row ? `Repos row: ${row}` : `no Repos row matches ${normalizeRemote2(origin2) ?? "this checkout (no origin remote)"}`;
31536
31669
  process.stdout.write(`${r.name} ${r.dir} ${note}
31537
31670
  `);
31538
31671
  }
@@ -31544,9 +31677,9 @@ ${f.tail.trimEnd()}
31544
31677
  ` : `${human}
31545
31678
  `);
31546
31679
  const plan2 = planRepoClone({ text: text2, base, route: routeName, name: addName, resolved: resolvedRemotes, dir: value("dir"), isCheckout });
31547
- if (existsSync59(plan2.target) && (existsSync59(`${plan2.target}/.git`) || readdirSync21(plan2.target).length > 0)) {
31680
+ if (existsSync60(plan2.target) && (existsSync60(`${plan2.target}/.git`) || readdirSync22(plan2.target).length > 0)) {
31548
31681
  throw new ReposError(
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`
31682
+ existsSync60(`${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`
31550
31683
  );
31551
31684
  }
31552
31685
  if (dryRun) {
@@ -31571,7 +31704,7 @@ ${f.tail.trimEnd()}
31571
31704
  break;
31572
31705
  }
31573
31706
  const target = resolvePath(addPath.replace(/^~(?=\/|$)/, homedir11()));
31574
- const top = existsSync59(target) ? gitOk(target, ["rev-parse", "--show-toplevel"]) : null;
31707
+ const top = existsSync60(target) ? gitOk(target, ["rev-parse", "--show-toplevel"]) : null;
31575
31708
  if (!top) throw new ReposError(`${target} is not a git checkout`);
31576
31709
  const origin = originOf(top);
31577
31710
  const plan = planRepoAdd({
@@ -31623,8 +31756,8 @@ ${f.tail.trimEnd()}
31623
31756
  const created = await rowTracker.createRepoRow(rowPayload);
31624
31757
  process.stdout.write(`created Repos row ${String(rowPayload.name)} (${String(rowPayload.remote)}) ${created.id}
31625
31758
  `);
31626
- if (existsSync59(resolvedFile)) {
31627
- const raw = JSON.parse(readFileSync54(resolvedFile, "utf8"));
31759
+ if (existsSync60(resolvedFile)) {
31760
+ const raw = JSON.parse(readFileSync55(resolvedFile, "utf8"));
31628
31761
  raw.repoNames = { ...raw.repoNames, [created.id]: String(rowPayload.name) };
31629
31762
  raw.repoRemotes = { ...raw.repoRemotes, [created.id]: String(rowPayload.remote) };
31630
31763
  writeFileSync42(resolvedFile, `${JSON.stringify(raw, null, 2)}
@@ -32006,7 +32139,7 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
32006
32139
  process.exit(2);
32007
32140
  }
32008
32141
  if (found.shipNameAdopted && !dryRun) {
32009
- writeFileSync42(cfg.configFile, setShipNameInYaml(readFileSync54(cfg.configFile, "utf8"), found.shipNameAdopted));
32142
+ writeFileSync42(cfg.configFile, setShipNameInYaml(readFileSync55(cfg.configFile, "utf8"), found.shipNameAdopted));
32010
32143
  cfg.ship.name = found.shipNameAdopted;
32011
32144
  }
32012
32145
  if (found.shipRow) {
@@ -32049,10 +32182,10 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
32049
32182
  }
32050
32183
  }
32051
32184
  let previous;
32052
- const hadPreviousFile = existsSync59(resolvedPath);
32185
+ const hadPreviousFile = existsSync60(resolvedPath);
32053
32186
  if (hadPreviousFile) {
32054
32187
  try {
32055
- previous = JSON.parse(readFileSync54(resolvedPath, "utf8"));
32188
+ previous = JSON.parse(readFileSync55(resolvedPath, "utf8"));
32056
32189
  } catch {
32057
32190
  }
32058
32191
  }
@@ -32947,10 +33080,10 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
32947
33080
  startupSeconds: cfg.ship.intelStartupSeconds,
32948
33081
  prepare: async (path) => {
32949
33082
  for (const f of repoWt.config.worktrees.copy) {
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));
33083
+ const src = join63(repoWt.dir, f);
33084
+ if (!existsSync60(src) || existsSync60(join63(path, f))) continue;
33085
+ mkdirSync42(dirOf2(join63(path, f)), { recursive: true });
33086
+ copyFileSync2(src, join63(path, f));
32954
33087
  }
32955
33088
  const setup = repoWt.config.hooks.setup;
32956
33089
  return setup ? runScript(setup, { cwd: path, shell: shellWt }) : null;
@@ -33176,7 +33309,7 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
33176
33309
  const shellR = hit && resolveShell(hit.repo.config.shell ?? cfg.ship.shell);
33177
33310
  const resumed = await runPeriscopeResume({
33178
33311
  find: async () => hit && { row: hit.row, tag: hit.tag },
33179
- worktreeExists: (p) => existsSync59(p),
33312
+ worktreeExists: (p) => existsSync60(p),
33180
33313
  prepareDropFile,
33181
33314
  startProxy: (wt, url, n) => launchProxy(crewInvocation(CREW_HOME), wt, url, Number(n), { host: hit.row.host || "localhost", inject: hit.repo.config.periscope?.inspector !== "repo" }),
33182
33315
  relay: hit && previewRelayFor(hit.route) && {
@@ -33279,10 +33412,10 @@ ${where.join("\n")}`);
33279
33412
  },
33280
33413
  prepare: async (path) => {
33281
33414
  for (const f of repoP.config.worktrees.copy) {
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));
33415
+ const src = join63(repoP.dir, f);
33416
+ if (!existsSync60(src)) continue;
33417
+ mkdirSync42(dirOf2(join63(path, f)), { recursive: true });
33418
+ copyFileSync2(src, join63(path, f));
33286
33419
  }
33287
33420
  const setup = repoP.config.hooks.setup;
33288
33421
  return setup ? runScript(setup, { cwd: path, shell: shellP, onLine: (l) => {
@@ -33594,7 +33727,7 @@ ${where.join("\n")}`);
33594
33727
  };
33595
33728
  const droppedRoutes = [];
33596
33729
  try {
33597
- const rawCfg = parseYaml3(readFileSync54(cfg.configFile, "utf8"));
33730
+ const rawCfg = parseYaml3(readFileSync55(cfg.configFile, "utf8"));
33598
33731
  for (const r of rawCfg?.routes ?? []) {
33599
33732
  if (typeof r?.route !== "string" || cfg.routes.some((x) => x.route === r.route)) continue;
33600
33733
  try {
@@ -33724,7 +33857,7 @@ ${where.join("\n")}`);
33724
33857
  }
33725
33858
  case "log": {
33726
33859
  try {
33727
- const text2 = readFileSync54(cfg.ship.logFile, "utf8").split("\n");
33860
+ const text2 = readFileSync55(cfg.ship.logFile, "utf8").split("\n");
33728
33861
  process.stdout.write(`${text2.slice(-(Number(value("tail")) || 40)).join("\n")}
33729
33862
  `);
33730
33863
  } catch {
@@ -33747,7 +33880,7 @@ ${where.join("\n")}`);
33747
33880
  };
33748
33881
  if (!route2.resolved) fail2(`route ${route2.route} is not connected \u2014 run \`crew connect\` first`);
33749
33882
  const tracker = new Tracker(route2, cfg.ship);
33750
- const configText = readFileSync54(cfg.configFile, "utf8");
33883
+ const configText = readFileSync55(cfg.configFile, "utf8");
33751
33884
  const cfgBase = dirname37(cfg.configFile);
33752
33885
  const configured2 = configuredRepos(configText, route2.route, cfgBase);
33753
33886
  const dir = configured2.find((r) => r.name === SAMPLE_REPO)?.dir ?? sampleDir(configured2.map((r) => r.dir), route2.reposBasePath, route2.route.split("/")[0]);
@@ -33784,29 +33917,29 @@ ${where.join("\n")}`);
33784
33917
  }
33785
33918
  if (row) {
33786
33919
  await tracker.deleteRepoRow(row.id);
33787
- if (existsSync59(resolvedFile)) {
33788
- const raw = JSON.parse(readFileSync54(resolvedFile, "utf8"));
33920
+ if (existsSync60(resolvedFile)) {
33921
+ const raw = JSON.parse(readFileSync55(resolvedFile, "utf8"));
33789
33922
  if (raw.repoNames) delete raw.repoNames[row.id];
33790
33923
  if (raw.repoRemotes) delete raw.repoRemotes[row.id];
33791
33924
  writeFileSync42(resolvedFile, `${JSON.stringify(raw, null, 2)}
33792
33925
  `);
33793
33926
  }
33794
33927
  }
33795
- if (existsSync59(join62(dir, ".git")) && basename17(dir) === SAMPLE_REPO) rmSync26(dir, { recursive: true, force: true });
33928
+ if (existsSync60(join63(dir, ".git")) && basename17(dir) === SAMPLE_REPO) rmSync26(dir, { recursive: true, force: true });
33796
33929
  say("removed", { dir, closed }, `removed the sample repo${closed.length ? `, closed ${closed.join(", ")}` : ""}`);
33797
33930
  break;
33798
33931
  }
33799
33932
  const projectId = route2.resolved.areaId ?? resolveRepoProject(await tracker.projectRows(), value("project"));
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`);
33933
+ const fresh = !existsSync60(join63(dir, ".git"));
33934
+ if (existsSync60(dir) && fresh && readdirSync22(dir).length > 0) fail2(`${dir} exists and is not a git checkout \u2014 move it aside`);
33802
33935
  if (dryRun) {
33803
33936
  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`);
33804
33937
  break;
33805
33938
  }
33806
33939
  if (fresh) {
33807
33940
  mkdirSync42(dir, { recursive: true });
33808
- writeFileSync42(join62(dir, "README.md"), SAMPLE_README);
33809
- writeFileSync42(join62(dir, ".crew.yaml"), SAMPLE_CREW_YAML);
33941
+ writeFileSync42(join63(dir, "README.md"), SAMPLE_README);
33942
+ writeFileSync42(join63(dir, ".crew.yaml"), SAMPLE_CREW_YAML);
33810
33943
  const g = (...a) => {
33811
33944
  const r = spawnSync14("git", a, { cwd: dir, encoding: "utf8" });
33812
33945
  if (r.status !== 0) fail2(`git ${a[0]} failed in ${dir}: ${(r.stderr || r.stdout).trim()}`);
@@ -33824,8 +33957,8 @@ ${where.join("\n")}`);
33824
33957
  spec: { platform: "unix", releaseMode: "integrate", ciProvider: "none" }
33825
33958
  });
33826
33959
  repoId = (await tracker.createRepoRow(payload)).id;
33827
- if (existsSync59(resolvedFile)) {
33828
- const raw = JSON.parse(readFileSync54(resolvedFile, "utf8"));
33960
+ if (existsSync60(resolvedFile)) {
33961
+ const raw = JSON.parse(readFileSync55(resolvedFile, "utf8"));
33829
33962
  raw.repoNames = { ...raw.repoNames, [repoId]: SAMPLE_REPO };
33830
33963
  raw.repoRemotes = { ...raw.repoRemotes, [repoId]: SAMPLE_REMOTE };
33831
33964
  writeFileSync42(resolvedFile, `${JSON.stringify(raw, null, 2)}
@@ -33979,6 +34112,10 @@ ${where.join("\n")}`);
33979
34112
  const projects = projectModeLabels(await statusTracker.projectRowsWithModes().catch(() => []));
33980
34113
  const crewMinVersion = await readCrewFloor(route2, cfg.ship) ?? null;
33981
34114
  const runs = liveRuns(cfg.ship.stateDir);
34115
+ const runTitles = new Map(
34116
+ (await statusTracker.ticketsByIds([...new Set(runs.map((x) => x.ticketRecordId).filter((id) => !!id))]).catch(() => [])).map((t) => [t.id, t.title ?? null])
34117
+ );
34118
+ const lastRuns = lastRunsBySeat(cfg.ship.stateDir);
33982
34119
  const periscopes = await periscopesForStatus(cfg.ship.stateDir);
33983
34120
  if (flag("json")) {
33984
34121
  const nameSync = await reconcileRouteShipName({ route: route2, ship: cfg.ship, configFile: cfg.configFile, readOnly: true });
@@ -33999,7 +34136,9 @@ ${where.join("\n")}`);
33999
34136
  name: crewRow?.name ?? null,
34000
34137
  personaName,
34001
34138
  // Additive (CREW-2822): how many runs this seat has live right now.
34002
- running: runs.filter((x) => x.role === r && x.route === routeSlug(route2.route)).length
34139
+ running: runs.filter((x) => x.role === r && x.route === routeSlug(route2.route)).length,
34140
+ // Additive (CREW-3247): this seat's newest finished run on this ship, or null.
34141
+ lastRun: ((l) => l ? { ticket: l.ticket, startedAt: l.startedAt, finishedAt: l.finishedAt, outcome: l.outcome, exitCode: l.exitCode } : null)(lastRuns.get(`${routeSlug(route2.route)}/${r}`))
34003
34142
  };
34004
34143
  });
34005
34144
  process.stdout.write(`${JSON.stringify({
@@ -34049,7 +34188,7 @@ ${where.join("\n")}`);
34049
34188
  seats: seats2
34050
34189
  },
34051
34190
  // Additive (CREW-2822): every live run on this ship. `version` stays 1.
34052
- runs: runs.map((x) => describeRun(x, route2, seatIds)),
34191
+ runs: runs.map((x) => describeRun(x, route2, seatIds, void 0, { titles: runTitles })),
34053
34192
  // Additive (CREW-2857): every live periscope on this ship, from its local record. `version` stays 1.
34054
34193
  periscopes,
34055
34194
  watermark: state.watermark(routeSlug(route2.route)),
@@ -34203,7 +34342,7 @@ watermark: ${state.watermark(routeSlug(route2.route))}
34203
34342
  plan,
34204
34343
  label,
34205
34344
  uid: process.getuid?.() ?? 0,
34206
- system: plan.mechanism === "systemd" && existsSync59(systemUnitPathFor(label)),
34345
+ system: plan.mechanism === "systemd" && existsSync60(systemUnitPathFor(label)),
34207
34346
  stamp: readDaemonStamp(cfg.ship.stateDir)
34208
34347
  });
34209
34348
  })();
@@ -34219,7 +34358,7 @@ watermark: ${state.watermark(routeSlug(route2.route))}
34219
34358
  }
34220
34359
  for (const r of repos) {
34221
34360
  const remote = r.config.branch.remote;
34222
- if (existsSync59(r.dir)) {
34361
+ if (existsSync60(r.dir)) {
34223
34362
  pushAuth.push({
34224
34363
  route: c.route,
34225
34364
  repo: r.name,
@@ -34303,7 +34442,7 @@ watermark: ${state.watermark(routeSlug(route2.route))}
34303
34442
  else passed++;
34304
34443
  }
34305
34444
  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);
34445
+ const runtimeDir = runtimeDirWarning(process.platform, process.getuid?.() ?? null, existsSync60, userInfo2().username);
34307
34446
  if (runtimeDir) problems.push({ severity: "attention", kind: "runtime_dir_missing", message: runtimeDir });
34308
34447
  if (!flag("offline")) {
34309
34448
  const shipKind = await doctorShipKind(route2, cfg.ship);
@@ -34375,7 +34514,7 @@ routes: ${cfg.routes.map((c) => c.route).join(", ")}
34375
34514
  }
34376
34515
  try {
34377
34516
  const evFile = eventFileFor(cfg.ship.stateDir);
34378
- const evSize = existsSync59(evFile) ? statSync18(evFile).size : 0;
34517
+ const evSize = existsSync60(evFile) ? statSync19(evFile).size : 0;
34379
34518
  process.stdout.write(
34380
34519
  evSize > cfg.ship.eventsRotateBytes * 4 ? `events log: WARN ${evFile} is ${Math.round(evSize / 1048576)} MB (> 4x eventsRotateBytes); run \`crew reap\` to rotate it
34381
34520
  ` : "events log: ok\n"
@@ -34386,7 +34525,7 @@ routes: ${cfg.routes.map((c) => c.route).join(", ")}
34386
34525
  const unitPlan = planInstall(cfg.ship, CREW_HOME, host, detectSystemd(), "run", installContext());
34387
34526
  const abandons = unitAbandonsAgents(unitPlan, (p) => {
34388
34527
  try {
34389
- return readFileSync54(p, "utf8");
34528
+ return readFileSync55(p, "utf8");
34390
34529
  } catch {
34391
34530
  return null;
34392
34531
  }
@@ -34401,7 +34540,7 @@ routes: ${cfg.routes.map((c) => c.route).join(", ")}
34401
34540
  const pPlan = planInstall(cfg.ship, CREW_HOME, host, true, "passengers", installContext());
34402
34541
  const keeps = unitAbandonsAgents(pPlan, (p) => {
34403
34542
  try {
34404
- return readFileSync54(p, "utf8");
34543
+ return readFileSync55(p, "utf8");
34405
34544
  } catch {
34406
34545
  return null;
34407
34546
  }
@@ -34415,7 +34554,7 @@ routes: ${cfg.routes.map((c) => c.route).join(", ")}
34415
34554
  if (host === "linux" && detectSystemd()) {
34416
34555
  const ctl = planDaemonControl(CREW_HOME, host, true);
34417
34556
  const unitPlan = planInstall(cfg.ship, CREW_HOME, host, true, "run", installContext());
34418
- if (ctl.statusCommand && unitPlan.unitPaths.some((p) => existsSync59(p))) {
34557
+ if (ctl.statusCommand && unitPlan.unitPaths.some((p) => existsSync60(p))) {
34419
34558
  const st = spawnSync14(ctl.statusCommand[0], ctl.statusCommand.slice(1), { cwd: CREW_HOME, encoding: "utf8" });
34420
34559
  if (!st.error && st.status !== 0) {
34421
34560
  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");
@@ -34440,8 +34579,8 @@ routes: ${cfg.routes.map((c) => c.route).join(", ")}
34440
34579
  const changed2 = configChangedAfter(daemonConfigPaths(cfg), daemonStartedAt);
34441
34580
  if (changed2) {
34442
34581
  process.stdout.write(
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\`
34582
+ daemonDead ? `daemon config: WARN ${changed2} changed at ${new Date(statSync19(changed2).mtimeMs).toISOString()} \u2014 no daemon is running; the new config applies when it starts
34583
+ ` : `daemon config: WARN ${changed2} changed at ${new Date(statSync19(changed2).mtimeMs).toISOString()} but the daemon started at ${new Date(daemonStartedAt).toISOString()} \u2014 run \`crew reload\`
34445
34584
  `
34446
34585
  );
34447
34586
  }