@tablation/crew 0.169.4 → 0.169.6

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 +305 -181
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -136,13 +136,13 @@ function periscopeSummary(cfg) {
136
136
  if (routes.length === 0) return `off (no enabled route sets hostPeriscopes: true; ${limits})`;
137
137
  return `ON for ${routes.join(", ")} (${cfg.ship.relayPreviews ? "previews relayed" : `host ${cfg.ship.previewHost ?? "NOT SET (ship.previewHost)"}`}, ${limits})`;
138
138
  }
139
- async function previewHostProblem(cfg, resolve8 = (h) => lookup(h)) {
139
+ async function previewHostProblem(cfg, resolve9 = (h) => lookup(h)) {
140
140
  if (periscopeRoutes(cfg).length === 0) return void 0;
141
141
  if (cfg.ship.relayPreviews) return void 0;
142
142
  const host = cfg.ship.previewHost;
143
143
  if (!host) return "ship.previewHost is not set \u2014 a route hosts periscopes, so Passengers have no host to be sent to";
144
144
  try {
145
- await resolve8(host);
145
+ await resolve9(host);
146
146
  } catch {
147
147
  return `ship.previewHost "${host}" does not resolve from this machine`;
148
148
  }
@@ -791,11 +791,11 @@ function urlPort(url) {
791
791
  }
792
792
  }
793
793
  function hostListening(port, host, timeoutMs) {
794
- return new Promise((resolve8) => {
794
+ return new Promise((resolve9) => {
795
795
  const s = connect({ port, host });
796
796
  const done = (ok) => {
797
797
  s.destroy();
798
- resolve8(ok);
798
+ resolve9(ok);
799
799
  };
800
800
  s.setTimeout(timeoutMs, () => done(false));
801
801
  s.once("connect", () => done(true));
@@ -5164,6 +5164,24 @@ function credentialSource(r) {
5164
5164
  }
5165
5165
  return process.env.CREW_API_KEY?.trim() ? "CREW_API_KEY" : "none";
5166
5166
  }
5167
+ function siblingRouteKey(routes, host, sameWorkspace, hostOf) {
5168
+ for (const r of routes) {
5169
+ const [workspace] = splitRoute(r.route);
5170
+ if (hostOf(r.baseUrl) !== host || !sameWorkspace(workspace)) continue;
5171
+ const source = credentialSource(r);
5172
+ if (source === "none") continue;
5173
+ try {
5174
+ return {
5175
+ apiKey: resolveApiKey(r),
5176
+ source,
5177
+ workspace,
5178
+ ...source === "apiKeyFile" ? { apiKeyFile: r.apiKeyFile, apiKeyVar: r.apiKeyVar } : {}
5179
+ };
5180
+ } catch {
5181
+ }
5182
+ }
5183
+ return void 0;
5184
+ }
5167
5185
  var KEYCHAIN_ELIGIBLE_ROUTES = /* @__PURE__ */ new WeakSet();
5168
5186
  async function hydrateApiKeys(routes, getStore = getSessionStore) {
5169
5187
  let store;
@@ -7477,12 +7495,12 @@ function envForRepository(entries, repo) {
7477
7495
  }
7478
7496
 
7479
7497
  // src/interrupted.ts
7480
- import { existsSync as existsSync30, readdirSync as readdirSync10, readFileSync as readFileSync32 } from "fs";
7498
+ import { existsSync as existsSync30, readdirSync as readdirSync10, readFileSync as readFileSync33 } from "fs";
7481
7499
  import { join as join36 } from "path";
7482
7500
 
7483
7501
  // src/agent.ts
7484
7502
  import { spawnSync as spawnSync7 } from "child_process";
7485
- import { readFileSync as readFileSync31, existsSync as existsSync29, statSync as statSync9, mkdirSync as mkdirSync23, writeFileSync as writeFileSync24, createWriteStream, openSync as openSync4, closeSync as closeSync4, readSync } from "fs";
7503
+ import { readFileSync as readFileSync32, existsSync as existsSync29, statSync as statSync9, mkdirSync as mkdirSync23, writeFileSync as writeFileSync24, createWriteStream, openSync as openSync4, closeSync as closeSync4, readSync } from "fs";
7486
7504
  import { StringDecoder } from "string_decoder";
7487
7505
  import { finished } from "stream/promises";
7488
7506
  import { join as join35, dirname as dirname17, basename as basename9 } from "path";
@@ -9192,9 +9210,9 @@ function createBridge(o) {
9192
9210
  }
9193
9211
  async function runBridge(stateDir, route2, ticket) {
9194
9212
  const bridge = createBridge({ attachFile: attachFilePath(stateDir, route2, ticket) });
9195
- const closed = new Promise((resolve8) => {
9196
- bridge.server.onclose = resolve8;
9197
- process.stdin.on("end", resolve8);
9213
+ const closed = new Promise((resolve9) => {
9214
+ bridge.server.onclose = resolve9;
9215
+ process.stdin.on("end", resolve9);
9198
9216
  });
9199
9217
  await bridge.start(new StdioServerTransport());
9200
9218
  await closed;
@@ -9634,7 +9652,7 @@ var unregisterRunInput = (run4) => {
9634
9652
  var runInputFor = (run4) => live.get(run4);
9635
9653
 
9636
9654
  // src/agent-log.ts
9637
- import { existsSync as existsSync25, mkdirSync as mkdirSync19, readdirSync as readdirSync8, readFileSync as readFileSync25, rmSync as rmSync14, writeFileSync as writeFileSync20 } from "fs";
9655
+ import { existsSync as existsSync25, mkdirSync as mkdirSync19, readdirSync as readdirSync8, readFileSync as readFileSync26, rmSync as rmSync14, writeFileSync as writeFileSync20 } from "fs";
9638
9656
  import { join as join29 } from "path";
9639
9657
 
9640
9658
  // src/pending-backoff.ts
@@ -11573,6 +11591,8 @@ import { join as join27 } from "path";
11573
11591
  import { StaleWriteError as StaleWriteError3 } from "@tablation/client";
11574
11592
 
11575
11593
  // src/conflict.ts
11594
+ import { readFileSync as readFileSync25 } from "fs";
11595
+ import { resolve as resolve4 } from "path";
11576
11596
  import { StaleWriteError as StaleWriteError2 } from "@tablation/client";
11577
11597
  var BOUNCE_MARKER = calloutHeader("WARNING", "Merge Conflict");
11578
11598
  function worktreeForBranch(cwd, branch) {
@@ -11615,9 +11635,45 @@ function planConflictBounce(cwd, ticket, branch, base, paths, events, merged = [
11615
11635
  siblings
11616
11636
  };
11617
11637
  }
11638
+ function isOwnUnresolvedMerge(worktree, base) {
11639
+ const mergeHead = gitOk(worktree, ["rev-parse", "-q", "--verify", "MERGE_HEAD"]);
11640
+ if (!mergeHead) return false;
11641
+ const baseTip = gitOk(worktree, ["rev-parse", "--verify", "-q", base]);
11642
+ if (!baseTip || !isAncestor(worktree, mergeHead, baseTip)) return false;
11643
+ const msgPath = gitOk(worktree, ["rev-parse", "--git-path", "MERGE_MSG"]);
11644
+ if (!msgPath) return false;
11645
+ try {
11646
+ const first = readFileSync25(resolve4(worktree, msgPath), "utf8").split("\n")[0] ?? "";
11647
+ if (!/^Merge (?:remote-tracking )?branch '/.test(first)) return false;
11648
+ } catch {
11649
+ return false;
11650
+ }
11651
+ const unmerged = new Set((gitOk(worktree, ["diff", "--name-only", "--diff-filter=U"]) ?? "").split("\n").filter(Boolean));
11652
+ for (const line of (gitOk(worktree, ["status", "--porcelain"]) ?? "").split("\n").filter(Boolean)) {
11653
+ const xy = line.slice(0, 2);
11654
+ const path = line.slice(3);
11655
+ if (unmerged.has(path)) continue;
11656
+ if (xy === "??" || xy[1] !== " ") return false;
11657
+ }
11658
+ for (const path of unmerged) {
11659
+ try {
11660
+ if (!/^<{7} /m.test(readFileSync25(resolve4(worktree, path), "utf8"))) return false;
11661
+ } catch {
11662
+ return false;
11663
+ }
11664
+ }
11665
+ return true;
11666
+ }
11618
11667
  function refreshBranch(worktree, base) {
11619
- const dirty = gitOk(worktree, ["status", "--porcelain"]);
11620
- if (dirty) return { clean: false, paths: [], why: "the worktree has uncommitted changes" };
11668
+ if (gitOk(worktree, ["status", "--porcelain"])) {
11669
+ if (!isOwnUnresolvedMerge(worktree, base)) {
11670
+ return { clean: false, paths: [], why: "the worktree has uncommitted changes" };
11671
+ }
11672
+ gitOk(worktree, ["merge", "--abort"]);
11673
+ if (gitOk(worktree, ["status", "--porcelain"])) {
11674
+ return { clean: false, paths: [], why: "the worktree has uncommitted changes" };
11675
+ }
11676
+ }
11621
11677
  const upstream = gitOk(worktree, ["rev-parse", "-q", "--verify", "@{upstream}"]);
11622
11678
  const head = gitOk(worktree, ["rev-parse", "HEAD"]);
11623
11679
  if (upstream && head && upstream !== head && isAncestor(worktree, head, upstream)) {
@@ -11661,6 +11717,34 @@ function escalateComment(b) {
11661
11717
  ${absorbed ? `Each earlier hand-back was answered by merging \`${b.base}\` in, and \`${b.base}\` moved underneath the branch every time. This file is changing faster than the lanes can absorb it, so it needs a person to sequence this ticket against the others touching it.` : `The branch ${b.priorBaseSha ? `does not contain \`${b.priorBaseSha}\`, the \`${b.base}\` tip it was last handed back for` : "was pushed"} \u2014 the hand-back was answered without merging \`${b.base}\` in, or this ticket overlaps work that has already shipped and needs rethinking rather than merging.`}
11662
11718
  That is a call for a person, not another lap through the lanes.`;
11663
11719
  }
11720
+ var STALE_RETRIES = 3;
11721
+ var cell = (t, column) => t[column] ?? null;
11722
+ function ticketMoves(read, now, contract, seat) {
11723
+ const moves = [];
11724
+ if (now.status !== read.status) moves.push(`status ${read.status} -> ${now.status}`);
11725
+ const assignee = cell(now, contract.columns.assignee);
11726
+ if (assignee !== cell(read, contract.columns.assignee) && assignee !== seat) moves.push(`assignee is now ${String(assignee)}`);
11727
+ const held = cell(now, contract.columns.heldBy);
11728
+ if (held !== cell(read, contract.columns.heldBy)) moves.push(`held by ${String(held)}`);
11729
+ return moves;
11730
+ }
11731
+ async function writeUnlessMoved(writer, ticket, patch2, contract, seat) {
11732
+ let stamp2 = ticket.updated_at;
11733
+ for (let i = 0; i <= STALE_RETRIES; i++) {
11734
+ try {
11735
+ await writer.updateTicket(ticket.id, patch2, stamp2);
11736
+ return { ok: true };
11737
+ } catch (e) {
11738
+ if (!(e instanceof StaleWriteError2)) throw e;
11739
+ if (!writer.ticket) return { ok: false, moved: "the row changed" };
11740
+ const now = await writer.ticket(ticket.id);
11741
+ const moves = ticketMoves(ticket, now, contract, seat);
11742
+ if (moves.length) return { ok: false, moved: moves.join(", ") };
11743
+ stamp2 = now.updated_at;
11744
+ }
11745
+ }
11746
+ return { ok: false, moved: "the row kept changing" };
11747
+ }
11664
11748
  async function applyConflictBounce(writer, b, contract, memberId, log, dryRun) {
11665
11749
  const t = { ticket: b.ticket.issue_id, step: "merge" };
11666
11750
  const absorbed = b.priorBounces > 0 && b.priorBounces < MAX_ABSORBED_HANDBACKS && !!b.priorBaseSha && isAncestor(b.worktree ?? b.cwd, b.priorBaseSha, b.branch);
@@ -11673,7 +11757,11 @@ async function applyConflictBounce(writer, b, contract, memberId, log, dryRun) {
11673
11757
  return { kind: "escalated" };
11674
11758
  }
11675
11759
  try {
11676
- await writer.updateTicket(b.ticket.id, { status: contract.statuses.needsHuman }, b.ticket.updated_at);
11760
+ const w = await writeUnlessMoved(writer, b.ticket, { status: contract.statuses.needsHuman }, contract, memberId);
11761
+ if (!w.ok) {
11762
+ log.emit(`${displayKey(b.ticket)} changed on the board since this run read it (${w.moved}) \u2014 not escalating over it`, t);
11763
+ return { kind: "stale" };
11764
+ }
11677
11765
  await writer.postEvent(b.ticket.id, escalateComment(b), memberId, "conflict_escalated").catch((e) => {
11678
11766
  log.warn(`escalated, but the note failed to post: ${e.message}`, t);
11679
11767
  });
@@ -11710,11 +11798,17 @@ async function applyConflictBounce(writer, b, contract, memberId, log, dryRun) {
11710
11798
  if (r.paths.length) b.paths = r.paths;
11711
11799
  }
11712
11800
  try {
11713
- await writer.updateTicket(
11714
- b.ticket.id,
11801
+ const w = await writeUnlessMoved(
11802
+ writer,
11803
+ b.ticket,
11715
11804
  { status: contract.statuses.building, assignee_id: null },
11716
- b.ticket.updated_at
11805
+ contract,
11806
+ memberId
11717
11807
  );
11808
+ if (!w.ok) {
11809
+ log.emit(`${displayKey(b.ticket)} changed on the board since this run read it (${w.moved}) \u2014 not handing it back over it`, t);
11810
+ return { kind: "stale" };
11811
+ }
11718
11812
  await writer.postEvent(
11719
11813
  b.ticket.id,
11720
11814
  handBackComment(b, merged),
@@ -11945,11 +12039,17 @@ async function applyBuildFailureBounce(writer, b, contract, memberId, log, dryRu
11945
12039
  return { kind: "escalated" };
11946
12040
  }
11947
12041
  try {
11948
- await writer.updateTicket(
11949
- b.ticket.id,
12042
+ const w = await writeUnlessMoved(
12043
+ writer,
12044
+ b.ticket,
11950
12045
  { status: contract.statuses.needsHuman, ...prior.operatorId ? { assignee_id: prior.operatorId } : {} },
11951
- b.ticket.updated_at
12046
+ contract,
12047
+ memberId
11952
12048
  );
12049
+ if (!w.ok) {
12050
+ log.emit(`${displayKey(b.ticket)} changed on the board since this run read it (${w.moved}) \u2014 not escalating over it`, t);
12051
+ return { kind: "stale" };
12052
+ }
11953
12053
  await writer.postEvent(b.ticket.id, buildFailureEscalation(b, prior.previousNote), memberId, "build_failed_escalated").catch(() => {
11954
12054
  log.warn("escalated, but the note failed to post", t);
11955
12055
  });
@@ -11965,11 +12065,17 @@ async function applyBuildFailureBounce(writer, b, contract, memberId, log, dryRu
11965
12065
  return { kind: "handed-back" };
11966
12066
  }
11967
12067
  try {
11968
- await writer.updateTicket(
11969
- b.ticket.id,
12068
+ const w = await writeUnlessMoved(
12069
+ writer,
12070
+ b.ticket,
11970
12071
  { status: contract.statuses.building, assignee_id: null },
11971
- b.ticket.updated_at
12072
+ contract,
12073
+ memberId
11972
12074
  );
12075
+ if (!w.ok) {
12076
+ log.emit(`${displayKey(b.ticket)} changed on the board since this run read it (${w.moved}) \u2014 not handing it back over it`, t);
12077
+ return { kind: "stale" };
12078
+ }
11973
12079
  await writer.postEvent(b.ticket.id, buildFailureComment(b, repeat), memberId, "build_failed").catch(() => {
11974
12080
  log.warn("handed back, but the note failed to post", t);
11975
12081
  });
@@ -13276,7 +13382,7 @@ async function replayQueuedAgentRuns(stateDir, route2, keyFor, log, now = /* @__
13276
13382
  const path = join29(dir, f2);
13277
13383
  let q2;
13278
13384
  try {
13279
- q2 = JSON.parse(readFileSync25(path, "utf8"));
13385
+ q2 = JSON.parse(readFileSync26(path, "utf8"));
13280
13386
  } catch {
13281
13387
  continue;
13282
13388
  }
@@ -13329,7 +13435,7 @@ async function replayQueuedTicketCounters(stateDir, route2, keyFor, log, now = /
13329
13435
  const path = join29(dir, f2);
13330
13436
  let q2;
13331
13437
  try {
13332
- q2 = JSON.parse(readFileSync25(path, "utf8"));
13438
+ q2 = JSON.parse(readFileSync26(path, "utf8"));
13333
13439
  } catch {
13334
13440
  continue;
13335
13441
  }
@@ -13588,7 +13694,7 @@ var HandoffTranscriptTracker = class {
13588
13694
  };
13589
13695
 
13590
13696
  // src/seat-notes.ts
13591
- import { appendFileSync as appendFileSync3, mkdirSync as mkdirSync20, readFileSync as readFileSync26, renameSync as renameSync4, rmSync as rmSync15, writeFileSync as writeFileSync21 } from "fs";
13697
+ import { appendFileSync as appendFileSync3, mkdirSync as mkdirSync20, readFileSync as readFileSync27, renameSync as renameSync4, rmSync as rmSync15, writeFileSync as writeFileSync21 } from "fs";
13592
13698
  import { randomUUID } from "crypto";
13593
13699
  import { join as join30 } from "path";
13594
13700
  var fileFor2 = (stateDir, role) => join30(stateDir, "seat-notes", `${role}.jsonl`);
@@ -13596,7 +13702,7 @@ var sameTicket = (a, b) => a.trim().toLowerCase() === b.trim().toLowerCase();
13596
13702
  function readAll(stateDir, role) {
13597
13703
  let raw;
13598
13704
  try {
13599
- raw = readFileSync26(fileFor2(stateDir, role), "utf8");
13705
+ raw = readFileSync27(fileFor2(stateDir, role), "utf8");
13600
13706
  } catch {
13601
13707
  return [];
13602
13708
  }
@@ -13650,7 +13756,7 @@ function seatNotesSection(notes) {
13650
13756
  import { createHash as createHash5 } from "crypto";
13651
13757
  import { spawn as spawn4 } from "child_process";
13652
13758
  import { execFileSync as execFileSync8 } from "child_process";
13653
- import { existsSync as existsSync26, mkdirSync as mkdirSync21, readFileSync as readFileSync27, renameSync as renameSync5, writeFileSync as writeFileSync22, rmSync as rmSync16, statSync as statSync8 } from "fs";
13759
+ import { existsSync as existsSync26, mkdirSync as mkdirSync21, readFileSync as readFileSync28, renameSync as renameSync5, writeFileSync as writeFileSync22, rmSync as rmSync16, statSync as statSync8 } from "fs";
13654
13760
  import { dirname as dirname15, join as join31 } from "path";
13655
13761
  import { fileURLToPath } from "url";
13656
13762
  import { tmpdir as tmpdir4 } from "os";
@@ -13668,7 +13774,7 @@ var SANDBOX_BRIDGE_PATH = `${CREW_PREFIX}/bin/intel-bridge`;
13668
13774
  function readBridgeBundle() {
13669
13775
  const here = dirname15(fileURLToPath(import.meta.url));
13670
13776
  for (const p of [join31(here, "sandbox-intel-bridge.cjs"), join31(here, "..", "dist", "sandbox-intel-bridge.cjs")]) {
13671
- if (existsSync26(p)) return readFileSync27(p, "utf8");
13777
+ if (existsSync26(p)) return readFileSync28(p, "utf8");
13672
13778
  }
13673
13779
  return void 0;
13674
13780
  }
@@ -13752,7 +13858,7 @@ var HOST_CA_BUNDLES = ["/etc/ssl/certs/ca-certificates.crt", "/etc/pki/tls/certs
13752
13858
  function readHostCaBundle(paths = HOST_CA_BUNDLES) {
13753
13859
  for (const path of paths) {
13754
13860
  try {
13755
- return readFileSync27(path, "utf8");
13861
+ return readFileSync28(path, "utf8");
13756
13862
  } catch {
13757
13863
  }
13758
13864
  }
@@ -13846,7 +13952,7 @@ var shipSandboxRef = () => ({ name: SHIP_SANDBOX_KEY, decl: { packages: [], setu
13846
13952
  var sandboxStatePath = (stateDir) => join31(stateDir, "sandbox-images.json");
13847
13953
  function readSandboxState(stateDir) {
13848
13954
  try {
13849
- const v = JSON.parse(readFileSync27(sandboxStatePath(stateDir), "utf8"));
13955
+ const v = JSON.parse(readFileSync28(sandboxStatePath(stateDir), "utf8"));
13850
13956
  return v && typeof v === "object" && !Array.isArray(v) ? v : {};
13851
13957
  } catch {
13852
13958
  return {};
@@ -13887,7 +13993,7 @@ function sandboxImageStatus(state, plan) {
13887
13993
  return { status: "ok", detail: `${current.tag} built ${current.builtAt}, claude ${current.claude ?? "unknown"}` };
13888
13994
  }
13889
13995
  var BUILD_INTERRUPTED = -1;
13890
- var spawnBuildRunner = (engine = "docker") => (args, logPath) => new Promise((resolve8) => {
13996
+ var spawnBuildRunner = (engine = "docker") => (args, logPath) => new Promise((resolve9) => {
13891
13997
  const child = spawn4(engine, args, { stdio: ["ignore", "pipe", "pipe"] });
13892
13998
  const chunks = [];
13893
13999
  child.stdout.on("data", (d) => chunks.push(d));
@@ -13895,7 +14001,7 @@ var spawnBuildRunner = (engine = "docker") => (args, logPath) => new Promise((re
13895
14001
  const done = (code, extra = "") => {
13896
14002
  writeFileSync22(logPath, `$ ${engine} ${args.join(" ")}
13897
14003
  ${Buffer.concat(chunks).toString("utf8")}${extra}`, { flag: "a" });
13898
- resolve8(code);
14004
+ resolve9(code);
13899
14005
  };
13900
14006
  child.on("error", (e) => done(127, `${e.message}
13901
14007
  `));
@@ -14056,7 +14162,7 @@ function expandSkillMarkers(text2, lookup2, opts = {}) {
14056
14162
  }
14057
14163
 
14058
14164
  // src/skills.ts
14059
- import { readFileSync as readFileSync30, readdirSync as readdirSync9, existsSync as existsSync28 } from "fs";
14165
+ import { readFileSync as readFileSync31, readdirSync as readdirSync9, existsSync as existsSync28 } from "fs";
14060
14166
  import { join as join33 } from "path";
14061
14167
  import { parse as parseYaml2 } from "yaml";
14062
14168
  import { TablationClient as TablationClient3, StaleWriteError as StaleWriteError5, TablationApiError as TablationApiError3 } from "@tablation/client";
@@ -14073,7 +14179,7 @@ ${additions}`;
14073
14179
  }
14074
14180
 
14075
14181
  // src/persona-file.ts
14076
- import { readFileSync as readFileSync28 } from "fs";
14182
+ import { readFileSync as readFileSync29 } from "fs";
14077
14183
  import { parse as parseYaml } from "yaml";
14078
14184
  function parsePersonaText(text2, path) {
14079
14185
  const match = /^---\n([\s\S]*?)\n---\n([\s\S]*)$/.exec(text2);
@@ -14085,11 +14191,11 @@ function parsePersonaText(text2, path) {
14085
14191
  return { body: match[2], ...typeof meta.chat_enabled === "boolean" ? { chatEnabled: meta.chat_enabled } : {} };
14086
14192
  }
14087
14193
  function readPersonaFile(path) {
14088
- return parsePersonaText(readFileSync28(path, "utf8"), path);
14194
+ return parsePersonaText(readFileSync29(path, "utf8"), path);
14089
14195
  }
14090
14196
 
14091
14197
  // src/agents.ts
14092
- import { readFileSync as readFileSync29, existsSync as existsSync27 } from "fs";
14198
+ import { readFileSync as readFileSync30, existsSync as existsSync27 } from "fs";
14093
14199
  import { join as join32 } from "path";
14094
14200
  import { TablationClient as TablationClient2, StaleWriteError as StaleWriteError4, TablationApiError as TablationApiError2 } from "@tablation/client";
14095
14201
  var PERSONA_NAME = {
@@ -14110,7 +14216,7 @@ function personaDefaultPrompt(promptsDir, role) {
14110
14216
  if (SELF_CONTAINED_ROLES.has(role)) return brief;
14111
14217
  const commonPath = join32(promptsDir, "personas", "common.md");
14112
14218
  if (!existsSync27(commonPath)) return brief;
14113
- return `${readFileSync29(commonPath, "utf8")}${brief}`;
14219
+ return `${readFileSync30(commonPath, "utf8")}${brief}`;
14114
14220
  }
14115
14221
  function personaChatEnabled(promptsDir, role) {
14116
14222
  const briefPath = join32(promptsDir, "personas", `lane-${role}.md`);
@@ -14600,7 +14706,7 @@ function describeCrewLink(o) {
14600
14706
  var SkillSyncError = class extends Error {
14601
14707
  };
14602
14708
  function parseSkillFile(path) {
14603
- const text2 = readFileSync30(path, "utf8");
14709
+ const text2 = readFileSync31(path, "utf8");
14604
14710
  const match = /^---\n([\s\S]*?)\n---\n([\s\S]*)$/.exec(text2);
14605
14711
  if (!match) throw new SkillSyncError(`${path}: missing YAML frontmatter (expected a leading --- block)`);
14606
14712
  const frontmatter = match[1];
@@ -15268,7 +15374,7 @@ var ALLOWANCE_REFUSAL_MARKER = "AI_ALLOWANCE_EXCEEDED";
15268
15374
  function streamShowsAllowanceRefusal(streamPath) {
15269
15375
  let raw;
15270
15376
  try {
15271
- raw = readFileSync31(streamPath, "utf8");
15377
+ raw = readFileSync32(streamPath, "utf8");
15272
15378
  } catch {
15273
15379
  return false;
15274
15380
  }
@@ -15355,9 +15461,9 @@ function planAgentRun(o) {
15355
15461
  let ageSeconds;
15356
15462
  if (existsSync29(digestPath2)) {
15357
15463
  ageSeconds = Math.floor((now() - statSync9(digestPath2).mtimeMs) / 1e3);
15358
- if (ageSeconds <= DIGEST_MAX_AGE_SECONDS) digest = readFileSync31(digestPath2, "utf8");
15464
+ if (ageSeconds <= DIGEST_MAX_AGE_SECONDS) digest = readFileSync32(digestPath2, "utf8");
15359
15465
  }
15360
- const common = usesCommon ? readFileSync31(commonPath, "utf8") : "";
15466
+ const common = usesCommon ? readFileSync32(commonPath, "utf8") : "";
15361
15467
  const brief = readPersonaFile(briefPath).body;
15362
15468
  const effectiveCommon = o.divergedPrompt ? "" : common;
15363
15469
  const effectiveBrief = appendAdditions(o.divergedPrompt ?? brief, o.personaAdditions);
@@ -15533,7 +15639,7 @@ function updateSidecar(streamPath, patch2) {
15533
15639
  var pidPathFor = (streamPath) => `${streamPath}.pid`;
15534
15640
  function readRunSidecar(streamPath) {
15535
15641
  try {
15536
- const sc = JSON.parse(readFileSync31(pidPathFor(streamPath), "utf8"));
15642
+ const sc = JSON.parse(readFileSync32(pidPathFor(streamPath), "utf8"));
15537
15643
  return typeof sc.pid === "number" && typeof sc.spawnedAt === "string" && typeof sc.role === "string" ? sc : null;
15538
15644
  } catch {
15539
15645
  return null;
@@ -16052,7 +16158,7 @@ function spawnPlanned(plan, emit, hintMoved) {
16052
16158
  closeSync4(streamFd);
16053
16159
  return supervise(begun);
16054
16160
  function supervise({ child, handle, promptDelivered }) {
16055
- return new Promise((resolve8, reject) => {
16161
+ return new Promise((resolve9, reject) => {
16056
16162
  const spawnedAt = (/* @__PURE__ */ new Date()).toISOString();
16057
16163
  const deadline = deadlineFor(spawnedAt, plan.maxRunMinutes);
16058
16164
  if (child.pid !== void 0) {
@@ -16194,7 +16300,7 @@ function spawnPlanned(plan, emit, hintMoved) {
16194
16300
  plan.agentLog?.apiKey,
16195
16301
  hintMoved
16196
16302
  );
16197
- resolve8({ code: code ?? 1, ms: ms3, ...handoffPending ? { handoffPending } : {}, ...killed ? { killed } : {} });
16303
+ resolve9({ code: code ?? 1, ms: ms3, ...handoffPending ? { handoffPending } : {}, ...killed ? { killed } : {} });
16198
16304
  });
16199
16305
  child.stdin?.on("error", (err3) => {
16200
16306
  emit.warn(`agent closed stdin before the prompt was delivered: ${err3.message}`, { step: "agent" });
@@ -16279,7 +16385,7 @@ function runFinished(streamPath) {
16279
16385
  const path = `${streamPath}.meta.json`;
16280
16386
  if (!existsSync30(path)) return false;
16281
16387
  try {
16282
- return JSON.parse(readFileSync32(path, "utf8")).running !== true;
16388
+ return JSON.parse(readFileSync33(path, "utf8")).running !== true;
16283
16389
  } catch {
16284
16390
  return true;
16285
16391
  }
@@ -16348,7 +16454,7 @@ import { existsSync as existsSync32, readdirSync as readdirSync12, statSync as s
16348
16454
  import { join as join38 } from "path";
16349
16455
 
16350
16456
  // src/run-snapshot.ts
16351
- import { closeSync as closeSync5, existsSync as existsSync31, fstatSync, openSync as openSync5, readSync as readSync2, readdirSync as readdirSync11, statSync as statSync10, readFileSync as readFileSync33, writeFileSync as writeFileSync25, renameSync as renameSync6 } from "fs";
16457
+ import { closeSync as closeSync5, existsSync as existsSync31, fstatSync, openSync as openSync5, readSync as readSync2, readdirSync as readdirSync11, statSync as statSync10, readFileSync as readFileSync34, writeFileSync as writeFileSync25, renameSync as renameSync6 } from "fs";
16352
16458
  import { join as join37 } from "path";
16353
16459
  var TAIL_BYTES = 256 * 1024;
16354
16460
  var EXCERPT_CHARS = 280;
@@ -16414,7 +16520,7 @@ function lastRunsBySeat(stateDir) {
16414
16520
  let meta;
16415
16521
  let mtimeMs;
16416
16522
  try {
16417
- meta = JSON.parse(readFileSync33(metaPath, "utf8"));
16523
+ meta = JSON.parse(readFileSync34(metaPath, "utf8"));
16418
16524
  mtimeMs = statSync10(metaPath).mtimeMs;
16419
16525
  } catch {
16420
16526
  continue;
@@ -16439,7 +16545,7 @@ function lastRunsBySeat(stateDir) {
16439
16545
  var notesPathFor = (streamPath) => `${streamPath}.notes.json`;
16440
16546
  function readRunNotes(streamPath) {
16441
16547
  try {
16442
- const parsed = JSON.parse(readFileSync33(notesPathFor(streamPath), "utf8"));
16548
+ const parsed = JSON.parse(readFileSync34(notesPathFor(streamPath), "utf8"));
16443
16549
  return Array.isArray(parsed) ? parsed : [];
16444
16550
  } catch {
16445
16551
  return [];
@@ -17436,10 +17542,10 @@ function formatPushAuth(repo, r) {
17436
17542
  return `${label}FAILED \u2014 ${r.detail}; ${r.hint}
17437
17543
  `;
17438
17544
  }
17439
- async function settleRepos(items, nameOf, resolve8) {
17545
+ async function settleRepos(items, nameOf, resolve9) {
17440
17546
  const out = await Promise.all(items.map(async (t) => {
17441
17547
  try {
17442
- return { ok: true, value: await resolve8(t) };
17548
+ return { ok: true, value: await resolve9(t) };
17443
17549
  } catch (e) {
17444
17550
  return { ok: false, repo: nameOf(t), detail: e.message };
17445
17551
  }
@@ -17509,14 +17615,14 @@ function managedGitIdentityWarnings(kind, identity) {
17509
17615
 
17510
17616
  // src/selftest.ts
17511
17617
  import { spawn as spawn7 } from "child_process";
17512
- import { existsSync as existsSync34, mkdirSync as mkdirSync24, mkdtempSync as mkdtempSync2, readFileSync as readFileSync34, rmSync as rmSync18, writeFileSync as writeFileSync26 } from "fs";
17618
+ import { existsSync as existsSync34, mkdirSync as mkdirSync24, mkdtempSync as mkdtempSync2, readFileSync as readFileSync35, rmSync as rmSync18, writeFileSync as writeFileSync26 } from "fs";
17513
17619
  import { tmpdir as tmpdir6 } from "os";
17514
17620
  import { join as join39 } from "path";
17515
17621
  var SELFTEST_TIMEOUT_MS = 12e4;
17516
17622
  var KEY_VAR = "CREW_API_KEY";
17517
17623
  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: ";
17518
17624
  var realDeps = {
17519
- run: (o) => new Promise((resolve8) => {
17625
+ run: (o) => new Promise((resolve9) => {
17520
17626
  let stdout = "";
17521
17627
  let stderr = "";
17522
17628
  let timedOut = false;
@@ -17524,7 +17630,7 @@ var realDeps = {
17524
17630
  const done = (r) => {
17525
17631
  if (!settled) {
17526
17632
  settled = true;
17527
- resolve8(r);
17633
+ resolve9(r);
17528
17634
  }
17529
17635
  };
17530
17636
  const child = spawn7(o.bin, o.args, { cwd: o.cwd, env: o.env, stdio: ["pipe", "pipe", "pipe"], detached: true });
@@ -17714,7 +17820,7 @@ var fileFor3 = (stateDir) => join39(stateDir, "selftest.json");
17714
17820
  function readSelftest(stateDir) {
17715
17821
  try {
17716
17822
  const p = fileFor3(stateDir);
17717
- return existsSync34(p) ? JSON.parse(readFileSync34(p, "utf8")) : {};
17823
+ return existsSync34(p) ? JSON.parse(readFileSync35(p, "utf8")) : {};
17718
17824
  } catch {
17719
17825
  return {};
17720
17826
  }
@@ -17756,7 +17862,7 @@ ${printed}` : ""}` });
17756
17862
  if (obj.compiled !== own.compiled) return fail2(`the child reports compiled ${JSON.stringify(obj.compiled)}, this process is ${own.compiled}`);
17757
17863
  return { ok: true, message: `self-launch ok: ${own.version}${own.compiled ? " (compiled)" : ""}` };
17758
17864
  }
17759
- var spawnChild = (launch, args, timeoutMs) => new Promise((resolve8) => {
17865
+ var spawnChild = (launch, args, timeoutMs) => new Promise((resolve9) => {
17760
17866
  const child = spawn8(launch.command, [...launch.args, ...args], { stdio: ["ignore", "pipe", "pipe"] });
17761
17867
  let stdout = "";
17762
17868
  let stderr = "";
@@ -17773,11 +17879,11 @@ var spawnChild = (launch, args, timeoutMs) => new Promise((resolve8) => {
17773
17879
  });
17774
17880
  child.on("error", (e) => {
17775
17881
  clearTimeout(timer);
17776
- resolve8({ code: null, stdout, stderr: `${stderr}${e.message}`, timedOut });
17882
+ resolve9({ code: null, stdout, stderr: `${stderr}${e.message}`, timedOut });
17777
17883
  });
17778
17884
  child.on("close", (code) => {
17779
17885
  clearTimeout(timer);
17780
- resolve8({ code, stdout, stderr, timedOut });
17886
+ resolve9({ code, stdout, stderr, timedOut });
17781
17887
  });
17782
17888
  });
17783
17889
  async function runSelfLaunchCheck(own, spawnFn = spawnChild, launch = selfLaunch(), timeoutMs = SELF_LAUNCH_TIMEOUT_MS) {
@@ -17785,7 +17891,7 @@ async function runSelfLaunchCheck(own, spawnFn = spawnChild, launch = selfLaunch
17785
17891
  }
17786
17892
 
17787
17893
  // src/cli.ts
17788
- import { resolve as resolve7, dirname as dirname38, join as join67, basename as basename17 } from "path";
17894
+ import { resolve as resolve8, dirname as dirname38, join as join67, basename as basename17 } from "path";
17789
17895
  import { fileURLToPath as fileURLToPath2 } from "url";
17790
17896
  import { hostname as hostname5, homedir as homedir11, userInfo as userInfo2 } from "os";
17791
17897
  import { spawnSync as spawnSync15 } from "child_process";
@@ -18008,14 +18114,14 @@ function rosterMarkdown(roster, meId) {
18008
18114
  }
18009
18115
 
18010
18116
  // src/connect-resume.ts
18011
- import { mkdirSync as mkdirSync25, readFileSync as readFileSync35, rmSync as rmSync19, writeFileSync as writeFileSync27 } from "fs";
18117
+ import { mkdirSync as mkdirSync25, readFileSync as readFileSync36, rmSync as rmSync19, writeFileSync as writeFileSync27 } from "fs";
18012
18118
  import { dirname as dirname18, join as join40 } from "path";
18013
18119
  function lastSessionFile(stateDir) {
18014
18120
  return join40(stateDir, "connect-session.json");
18015
18121
  }
18016
18122
  function readPointers(stateDir) {
18017
18123
  try {
18018
- const parsed = JSON.parse(readFileSync35(lastSessionFile(stateDir), "utf8"));
18124
+ const parsed = JSON.parse(readFileSync36(lastSessionFile(stateDir), "utf8"));
18019
18125
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return {};
18020
18126
  const out = {};
18021
18127
  for (const [host, v] of Object.entries(parsed)) {
@@ -18115,7 +18221,7 @@ async function signOutSessions(o) {
18115
18221
  }
18116
18222
 
18117
18223
  // src/reset.ts
18118
- import { existsSync as existsSync35, mkdirSync as mkdirSync26, readFileSync as readFileSync36, readdirSync as readdirSync14, rmSync as rmSync20, statSync as statSync12, writeFileSync as writeFileSync28 } from "fs";
18224
+ import { existsSync as existsSync35, mkdirSync as mkdirSync26, readFileSync as readFileSync37, readdirSync as readdirSync14, rmSync as rmSync20, statSync as statSync12, writeFileSync as writeFileSync28 } from "fs";
18119
18225
  import { dirname as dirname19, join as join41 } from "path";
18120
18226
  import { hostFromUrl as hostFromUrl3 } from "@tablation/client";
18121
18227
  function clonedCheckoutsFile(stateDir) {
@@ -18123,7 +18229,7 @@ function clonedCheckoutsFile(stateDir) {
18123
18229
  }
18124
18230
  function readClonedCheckouts(stateDir) {
18125
18231
  try {
18126
- const parsed = JSON.parse(readFileSync36(clonedCheckoutsFile(stateDir), "utf8"));
18232
+ const parsed = JSON.parse(readFileSync37(clonedCheckoutsFile(stateDir), "utf8"));
18127
18233
  return Array.isArray(parsed) ? parsed.filter((d) => typeof d === "string") : [];
18128
18234
  } catch {
18129
18235
  return [];
@@ -18315,7 +18421,7 @@ async function runDeprovision(o, fx, deps) {
18315
18421
  }
18316
18422
 
18317
18423
  // src/pool-member.ts
18318
- import { mkdirSync as mkdirSync27, readFileSync as readFileSync37, renameSync as renameSync7, writeFileSync as writeFileSync29 } from "fs";
18424
+ import { mkdirSync as mkdirSync27, readFileSync as readFileSync38, renameSync as renameSync7, writeFileSync as writeFileSync29 } from "fs";
18319
18425
  import { homedir as homedir8 } from "os";
18320
18426
  import { dirname as dirname20, join as join42 } from "path";
18321
18427
  var POOL_EXIT = { ok: 0, failed: 1, credential: 2 };
@@ -18566,7 +18672,7 @@ function fileMemberStore(dir) {
18566
18672
  return {
18567
18673
  read() {
18568
18674
  try {
18569
- return JSON.parse(readFileSync37(file, "utf8"));
18675
+ return JSON.parse(readFileSync38(file, "utf8"));
18570
18676
  } catch {
18571
18677
  return {};
18572
18678
  }
@@ -18632,7 +18738,7 @@ import { hostname as hostname3 } from "os";
18632
18738
  // src/machine-id.ts
18633
18739
  import { execFileSync as execFileSync12 } from "child_process";
18634
18740
  import { createHash as createHash9 } from "crypto";
18635
- import { existsSync as existsSync36, mkdirSync as mkdirSync28, readFileSync as readFileSync38, writeFileSync as writeFileSync30 } from "fs";
18741
+ import { existsSync as existsSync36, mkdirSync as mkdirSync28, readFileSync as readFileSync39, writeFileSync as writeFileSync30 } from "fs";
18636
18742
  import { dirname as dirname21, join as join43 } from "path";
18637
18743
  function machineIdPathFor(stateDir) {
18638
18744
  return join43(stateDir, "machine-id");
@@ -18649,7 +18755,7 @@ function readRawMachineId(platform2 = process.platform) {
18649
18755
  }
18650
18756
  for (const p of ["/etc/machine-id", "/var/lib/dbus/machine-id"]) {
18651
18757
  if (existsSync36(p)) {
18652
- const id = readFileSync38(p, "utf8").trim();
18758
+ const id = readFileSync39(p, "utf8").trim();
18653
18759
  if (id) return id;
18654
18760
  }
18655
18761
  }
@@ -18661,7 +18767,7 @@ function ensureMachineId(stateDir, opts = {}) {
18661
18767
  if (opts.override?.trim()) return sha256(opts.override.trim());
18662
18768
  const path = machineIdPathFor(stateDir);
18663
18769
  if (existsSync36(path)) {
18664
- const cached = readFileSync38(path, "utf8").trim();
18770
+ const cached = readFileSync39(path, "utf8").trim();
18665
18771
  if (/^[0-9a-f]{64}$/.test(cached)) return cached;
18666
18772
  }
18667
18773
  const raw = (opts.read ?? readRawMachineId)();
@@ -18681,7 +18787,7 @@ function matchShipRows(ships, shipName2, machineId) {
18681
18787
 
18682
18788
  // src/provision.ts
18683
18789
  import { spawnSync as spawnSync10 } from "child_process";
18684
- import { existsSync as existsSync37, readFileSync as readFileSync39, writeFileSync as writeFileSync31 } from "fs";
18790
+ import { existsSync as existsSync37, readFileSync as readFileSync40, writeFileSync as writeFileSync31 } from "fs";
18685
18791
  import { hostname as hostname2 } from "os";
18686
18792
  import { parseDocument as parseDocument3, isMap as isMap2, isScalar } from "yaml";
18687
18793
 
@@ -18690,7 +18796,7 @@ import { parseDocument as parseDocument2 } from "yaml";
18690
18796
 
18691
18797
  // src/repos-cmd.ts
18692
18798
  import { homedir as homedir9 } from "os";
18693
- import { basename as basename10, join as join44, resolve as resolve4 } from "path";
18799
+ import { basename as basename10, join as join44, resolve as resolve5 } from "path";
18694
18800
  import { isMap, isSeq, parseDocument, stringify as stringify2 } from "yaml";
18695
18801
  var ReposError = class extends Error {
18696
18802
  /** A stable reason for a `--json` reader, when the failure has one (CREW-3359). */
@@ -18750,7 +18856,7 @@ function parseAddArgs(args, routes, isDir) {
18750
18856
  }
18751
18857
  function expandDir(p, base) {
18752
18858
  const home = p === "~" ? homedir9() : p.startsWith("~/") ? `${homedir9()}/${p.slice(2)}` : p;
18753
- return resolve4(base, home);
18859
+ return resolve5(base, home);
18754
18860
  }
18755
18861
  function routeMapOf(doc, route2) {
18756
18862
  const routes = doc.get("routes", true);
@@ -19327,7 +19433,7 @@ function realProvisionDeps(crewHome) {
19327
19433
  enableRoute(route2) {
19328
19434
  const file = configFile();
19329
19435
  if (!file) return false;
19330
- const text2 = readFileSync39(file, "utf8");
19436
+ const text2 = readFileSync40(file, "utf8");
19331
19437
  const doc = parseDocument3(text2);
19332
19438
  const routes = doc.get("routes");
19333
19439
  const entry = routes?.items?.find((r) => r.get("route") === route2);
@@ -19353,7 +19459,7 @@ function realProvisionDeps(crewHome) {
19353
19459
  continue;
19354
19460
  }
19355
19461
  for (const p of plan.unitPaths) {
19356
- if (!existsSync37(p) || readFileSync39(p, "utf8") !== plan.unitContent[p]) unitsStale = true;
19462
+ if (!existsSync37(p) || readFileSync40(p, "utf8") !== plan.unitContent[p]) unitsStale = true;
19357
19463
  }
19358
19464
  }
19359
19465
  const label = labelFor(crewHome, "run");
@@ -19377,7 +19483,7 @@ function realProvisionDeps(crewHome) {
19377
19483
  setShipSetting(key, value2) {
19378
19484
  const file = configFile();
19379
19485
  if (!file) return false;
19380
- const doc = parseDocument3(readFileSync39(file, "utf8"));
19486
+ const doc = parseDocument3(readFileSync40(file, "utf8"));
19381
19487
  if (doc.getIn(["ship", key]) === value2) return false;
19382
19488
  doc.setIn(["ship", key], value2);
19383
19489
  writeFileSync31(file, doc.toString());
@@ -19386,7 +19492,7 @@ function realProvisionDeps(crewHome) {
19386
19492
  applyManagedDefaults() {
19387
19493
  const file = configFile();
19388
19494
  if (!file) return [];
19389
- const doc = parseDocument3(readFileSync39(file, "utf8"));
19495
+ const doc = parseDocument3(readFileSync40(file, "utf8"));
19390
19496
  const wrote = applyManagedDefaultsToDoc(doc);
19391
19497
  if (wrote.length) writeFileSync31(file, doc.toString());
19392
19498
  return wrote;
@@ -21294,7 +21400,7 @@ async function markCrewAssistedAtLaunch(tracker, route2, role, ticketId, ticket,
21294
21400
  }
21295
21401
 
21296
21402
  // src/repo-refresh.ts
21297
- import { existsSync as existsSync40, mkdirSync as mkdirSync29, readFileSync as readFileSync40, writeFileSync as writeFileSync33 } from "fs";
21403
+ import { existsSync as existsSync40, mkdirSync as mkdirSync29, readFileSync as readFileSync41, writeFileSync as writeFileSync33 } from "fs";
21298
21404
  import { dirname as dirname23 } from "path";
21299
21405
  var REFRESH_COOLDOWN_MS = 2 * 6e4;
21300
21406
  var UNSERVABLE_PASSES_BEFORE_ATTENTION = 3;
@@ -21325,7 +21431,7 @@ function applyRepoRows(resolved, rows) {
21325
21431
  function persistRepoRows(stateDir, routeName, rows) {
21326
21432
  const path = resolvedPathFor(stateDir, routeName);
21327
21433
  if (!existsSync40(path)) return;
21328
- const raw = JSON.parse(readFileSync40(path, "utf8"));
21434
+ const raw = JSON.parse(readFileSync41(path, "utf8"));
21329
21435
  applyRepoRows(raw, rows);
21330
21436
  mkdirSync29(dirname23(path), { recursive: true });
21331
21437
  writeFileSync33(path, `${JSON.stringify(raw, null, 2)}
@@ -21842,11 +21948,11 @@ function redactValue(v) {
21842
21948
  }
21843
21949
  return v;
21844
21950
  }
21845
- var defaultExec = (bin, args, timeoutMs) => new Promise((resolve8, reject) => {
21951
+ var defaultExec = (bin, args, timeoutMs) => new Promise((resolve9, reject) => {
21846
21952
  execFile4(bin, args, { timeout: timeoutMs, maxBuffer: 4 * 1024 * 1024 }, (e, stdout) => {
21847
21953
  if (e && e.code === "ENOENT") return reject(new Error(`${bin} is not installed`));
21848
21954
  if (e && e.killed) return reject(new Error(`${bin} timed out`));
21849
- resolve8({ stdout: String(stdout), code: typeof e?.code === "number" ? e.code : 0 });
21955
+ resolve9({ stdout: String(stdout), code: typeof e?.code === "number" ? e.code : 0 });
21850
21956
  });
21851
21957
  });
21852
21958
  var clip = (s) => s.length > MAX_SECTION_BYTES ? `${s.slice(0, MAX_SECTION_BYTES)}
@@ -21887,8 +21993,8 @@ async function collectDiagnostics(d) {
21887
21993
  return { runner: d.runner, list: clip(r.stdout).split("\n").filter((l) => l.length), exitCode: r.code };
21888
21994
  }
21889
21995
  };
21890
- const deadline = new Promise((resolve8) => {
21891
- setTimeout(() => resolve8("timeout"), budget).unref();
21996
+ const deadline = new Promise((resolve9) => {
21997
+ setTimeout(() => resolve9("timeout"), budget).unref();
21892
21998
  });
21893
21999
  const entries = await Promise.all(Object.entries(sections).map(async ([name, run4]) => {
21894
22000
  try {
@@ -21903,7 +22009,7 @@ async function collectDiagnostics(d) {
21903
22009
  }
21904
22010
 
21905
22011
  // src/release-run.ts
21906
- import { readFileSync as readFileSync41, writeFileSync as writeFileSync35, existsSync as existsSync42, copyFileSync, mkdirSync as mkdirSync31, mkdtempSync as mkdtempSync3, rmSync as rmSync21 } from "fs";
22012
+ import { readFileSync as readFileSync42, writeFileSync as writeFileSync35, existsSync as existsSync42, copyFileSync, mkdirSync as mkdirSync31, mkdtempSync as mkdtempSync3, rmSync as rmSync21 } from "fs";
21907
22013
  import { dirname as dirname26, join as join49 } from "path";
21908
22014
  import { tmpdir as tmpdir7, hostname as hostname4 } from "os";
21909
22015
 
@@ -22888,7 +22994,7 @@ async function bump(o, size) {
22888
22994
  o.emit.error(`no ${o.repo.release.versionFiles[0]} to read a version from`);
22889
22995
  return null;
22890
22996
  }
22891
- const firstText = readTextAt(first, (p) => readFileSync41(p, "utf8"));
22997
+ const firstText = readTextAt(first, (p) => readFileSync42(p, "utf8"));
22892
22998
  const problem = versionFileProblem(o.repo.release.versionFiles[0], firstText);
22893
22999
  if (problem) {
22894
23000
  o.emit.error(problem);
@@ -22907,7 +23013,7 @@ async function bump(o, size) {
22907
23013
  return version;
22908
23014
  }
22909
23015
  for (const f2 of files) {
22910
- const src = readTextAt(f2, (p) => readFileSync41(p, "utf8"));
23016
+ const src = readTextAt(f2, (p) => readFileSync42(p, "utf8"));
22911
23017
  const out = src.replace(/("version"\s*:\s*")[^"]*(")/, `$1${version}$2`);
22912
23018
  if (out === src) {
22913
23019
  o.emit.error(`no version field in ${f2}`);
@@ -22926,7 +23032,7 @@ function writeChangelog(o, version, entries) {
22926
23032
  o.emit.emit(`would prepend ${entries.length} entr(ies) to ${file}`);
22927
23033
  return;
22928
23034
  }
22929
- const existing = existsAt(path, existsSync42) ? readTextAt(path, (p) => readFileSync41(p, "utf8")) : "# Changelog\n";
23035
+ const existing = existsAt(path, existsSync42) ? readTextAt(path, (p) => readFileSync42(p, "utf8")) : "# Changelog\n";
22930
23036
  writeTextAt(path, insertChangelogSection(existing, section), writeFileSync35);
22931
23037
  }
22932
23038
  async function confirm(o, expected, ci) {
@@ -24153,14 +24259,14 @@ async function runCommentDeliveryPass(deps) {
24153
24259
  }
24154
24260
 
24155
24261
  // src/launchd-start.ts
24156
- import { readFileSync as readFileSync48 } from "fs";
24262
+ import { readFileSync as readFileSync49 } from "fs";
24157
24263
  import { spawnSync as spawnSync13 } from "child_process";
24158
24264
 
24159
24265
  // src/daemon-liveness.ts
24160
- import { existsSync as existsSync49, readFileSync as readFileSync47 } from "fs";
24266
+ import { existsSync as existsSync49, readFileSync as readFileSync48 } from "fs";
24161
24267
 
24162
24268
  // src/daemon.ts
24163
- import { existsSync as existsSync48, mkdirSync as mkdirSync37, readFileSync as readFileSync46, readdirSync as readdirSync15, rmSync as rmSync23, statSync as statSync14, writeFileSync as writeFileSync39 } from "fs";
24269
+ import { existsSync as existsSync48, mkdirSync as mkdirSync37, readFileSync as readFileSync47, readdirSync as readdirSync15, rmSync as rmSync23, statSync as statSync14, writeFileSync as writeFileSync39 } from "fs";
24164
24270
  import { join as join54 } from "path";
24165
24271
  import { randomBytes } from "crypto";
24166
24272
 
@@ -24447,7 +24553,7 @@ function nextRoles(decision, ran) {
24447
24553
  }
24448
24554
 
24449
24555
  // src/noop-runs.ts
24450
- import { existsSync as existsSync43, mkdirSync as mkdirSync32, readFileSync as readFileSync42, renameSync as renameSync8, writeFileSync as writeFileSync36 } from "fs";
24556
+ import { existsSync as existsSync43, mkdirSync as mkdirSync32, readFileSync as readFileSync43, renameSync as renameSync8, writeFileSync as writeFileSync36 } from "fs";
24451
24557
  import { join as join50 } from "path";
24452
24558
  var NOOP_DELAYS_MS = [5, 15, 60].map((m) => m * 6e4);
24453
24559
  var DEFAULT_NOOP_REPEATS = 3;
@@ -24456,7 +24562,7 @@ var noopRunsPath = (stateDir) => join50(stateDir, "noop-runs.json");
24456
24562
  var noopRunsKey = (issueId) => `noop_runs:${issueId}`;
24457
24563
  function readNoopRuns(stateDir) {
24458
24564
  try {
24459
- const v = JSON.parse(readFileSync42(noopRunsPath(stateDir), "utf8"));
24565
+ const v = JSON.parse(readFileSync43(noopRunsPath(stateDir), "utf8"));
24460
24566
  return v && typeof v === "object" && !Array.isArray(v) ? v : {};
24461
24567
  } catch {
24462
24568
  return {};
@@ -24547,7 +24653,7 @@ async function settleNoopRun(o) {
24547
24653
  }
24548
24654
 
24549
24655
  // src/ship-name.ts
24550
- import { existsSync as existsSync44, mkdirSync as mkdirSync33, readFileSync as readFileSync43, renameSync as renameSync9, writeFileSync as writeFileSync37 } from "fs";
24656
+ import { existsSync as existsSync44, mkdirSync as mkdirSync33, readFileSync as readFileSync44, renameSync as renameSync9, writeFileSync as writeFileSync37 } from "fs";
24551
24657
  import { dirname as dirname27 } from "path";
24552
24658
  import { parseDocument as parseDocument4 } from "yaml";
24553
24659
  var ShipNameError = class extends Error {
@@ -24611,7 +24717,7 @@ async function syncRouteName(i) {
24611
24717
  function readSyncedName(resolvedFile) {
24612
24718
  if (!existsSync44(resolvedFile)) return void 0;
24613
24719
  try {
24614
- const v = JSON.parse(readFileSync43(resolvedFile, "utf8")).shipName;
24720
+ const v = JSON.parse(readFileSync44(resolvedFile, "utf8")).shipName;
24615
24721
  return typeof v === "string" ? v : void 0;
24616
24722
  } catch {
24617
24723
  return void 0;
@@ -24621,7 +24727,7 @@ function writeSyncedName(resolvedFile, name) {
24621
24727
  if (!existsSync44(resolvedFile)) return;
24622
24728
  let raw;
24623
24729
  try {
24624
- raw = JSON.parse(readFileSync43(resolvedFile, "utf8"));
24730
+ raw = JSON.parse(readFileSync44(resolvedFile, "utf8"));
24625
24731
  } catch {
24626
24732
  return;
24627
24733
  }
@@ -24636,7 +24742,7 @@ function writeSyncedName(resolvedFile, name) {
24636
24742
  async function reconcileShipName(i) {
24637
24743
  let local = i.ship.name;
24638
24744
  try {
24639
- local = shipNameOfYaml(readFileSync43(i.configFile, "utf8")) ?? local;
24745
+ local = shipNameOfYaml(readFileSync44(i.configFile, "utf8")) ?? local;
24640
24746
  } catch {
24641
24747
  }
24642
24748
  const resolvedFile = resolvedPathFor(i.stateDir, i.route);
@@ -24660,7 +24766,7 @@ async function reconcileShipName(i) {
24660
24766
  }
24661
24767
  if (result.status !== "ok") return result;
24662
24768
  if (result.action === "adopt" || result.action === "row-wins") {
24663
- const text2 = readFileSync43(i.configFile, "utf8");
24769
+ const text2 = readFileSync44(i.configFile, "utf8");
24664
24770
  writeFileSync37(i.configFile, setShipNameInYaml(text2, result.name));
24665
24771
  i.ship.name = result.name;
24666
24772
  if (result.action === "row-wins") {
@@ -24882,7 +24988,7 @@ function seatMissingProblems(route2, probes) {
24882
24988
 
24883
24989
  // src/ssh-keys.ts
24884
24990
  import { execFileSync as execFileSync13 } from "child_process";
24885
- import { existsSync as existsSync46, mkdirSync as mkdirSync35, readFileSync as readFileSync44, chmodSync as chmodSync3 } from "fs";
24991
+ import { existsSync as existsSync46, mkdirSync as mkdirSync35, readFileSync as readFileSync45, chmodSync as chmodSync3 } from "fs";
24886
24992
  import { dirname as dirname29, join as join51 } from "path";
24887
24993
  var SshKeyError = class extends Error {
24888
24994
  };
@@ -24916,7 +25022,7 @@ function ensureShipSshKeypair(stateDir) {
24916
25022
  if (!existsSync46(publicKeyPath)) {
24917
25023
  throw new SshKeyError(`${privateKeyPath} exists but ${publicKeyPath} does not \u2014 regenerate or restore it`);
24918
25024
  }
24919
- const publicKey = readFileSync44(publicKeyPath, "utf8").trim();
25025
+ const publicKey = readFileSync45(publicKeyPath, "utf8").trim();
24920
25026
  return { privateKeyPath, publicKeyPath, publicKey };
24921
25027
  }
24922
25028
  function sshKeygenAvailable() {
@@ -25030,7 +25136,7 @@ async function runPeriscopeIdlePass(d) {
25030
25136
  }
25031
25137
 
25032
25138
  // src/periscope-cmd.ts
25033
- import { existsSync as existsSync47, mkdirSync as mkdirSync36, readFileSync as readFileSync45, rmSync as rmSync22, writeFileSync as writeFileSync38 } from "fs";
25139
+ import { existsSync as existsSync47, mkdirSync as mkdirSync36, readFileSync as readFileSync46, rmSync as rmSync22, writeFileSync as writeFileSync38 } from "fs";
25034
25140
  import { join as join53 } from "path";
25035
25141
  var PeriscopeError = class extends Error {
25036
25142
  };
@@ -25056,7 +25162,7 @@ function writePeriscopePrior(stateDir, ticketRecordId, prior) {
25056
25162
  function readPeriscopePrior(stateDir, ticketRecordId) {
25057
25163
  try {
25058
25164
  const p = priorPath(stateDir, ticketRecordId);
25059
- return existsSync47(p) ? JSON.parse(readFileSync45(p, "utf8")) : void 0;
25165
+ return existsSync47(p) ? JSON.parse(readFileSync46(p, "utf8")) : void 0;
25060
25166
  } catch {
25061
25167
  return void 0;
25062
25168
  }
@@ -25512,7 +25618,7 @@ var DEFAULT_FLOOR_MS = 5e3;
25512
25618
  var DEFAULT_CEILING_MS = INTERVAL_SECONDS * 1e3;
25513
25619
  var ALLOWANCE_PAUSE_MS = 5 * 60 * 1e3;
25514
25620
  var RELOAD_WARN_MS = 10 * 60 * 1e3;
25515
- var defaultSleep = (ms3) => new Promise((resolve8) => setTimeout(resolve8, ms3));
25621
+ var defaultSleep = (ms3) => new Promise((resolve9) => setTimeout(resolve9, ms3));
25516
25622
  async function runDaemonLoop(o) {
25517
25623
  const floor = o.floorMs ?? DEFAULT_FLOOR_MS;
25518
25624
  const ceiling = o.ceilingMs ?? DEFAULT_CEILING_MS;
@@ -25627,7 +25733,7 @@ function noteDaemonStarted(stateDir, now = Date.now()) {
25627
25733
  }
25628
25734
  function readDaemonStarted(stateDir) {
25629
25735
  try {
25630
- const v = JSON.parse(readFileSync46(daemonStampFor(stateDir), "utf8")).startedAt;
25736
+ const v = JSON.parse(readFileSync47(daemonStampFor(stateDir), "utf8")).startedAt;
25631
25737
  return typeof v === "number" ? v : null;
25632
25738
  } catch {
25633
25739
  return null;
@@ -25959,8 +26065,8 @@ async function fillSlots(o, routes, first) {
25959
26065
  }
25960
26066
  let settle = () => {
25961
26067
  };
25962
- const settled = new Promise((resolve8) => {
25963
- settle = resolve8;
26068
+ const settled = new Promise((resolve9) => {
26069
+ settle = resolve9;
25964
26070
  });
25965
26071
  const ready = (tookTicket2) => settle(tookTicket2);
25966
26072
  const run4 = spawn14(role, decision, ctx, { ready }).then(() => {
@@ -26516,7 +26622,7 @@ function parseSystemctlShow(text2) {
26516
26622
  }
26517
26623
  function lastLogLine(path, read = (p) => {
26518
26624
  try {
26519
- return readFileSync47(p, "utf8");
26625
+ return readFileSync48(p, "utf8");
26520
26626
  } catch {
26521
26627
  return null;
26522
26628
  }
@@ -26593,7 +26699,7 @@ function daemonProblem(d, route2) {
26593
26699
  }
26594
26700
  function readDaemonStamp(stateDir) {
26595
26701
  try {
26596
- const v = JSON.parse(readFileSync47(daemonStampFor(stateDir), "utf8"));
26702
+ const v = JSON.parse(readFileSync48(daemonStampFor(stateDir), "utf8"));
26597
26703
  if (typeof v.startedAt !== "number") return null;
26598
26704
  return typeof v.pid === "number" ? { pid: v.pid, startedAt: v.startedAt } : { startedAt: v.startedAt };
26599
26705
  } catch {
@@ -26619,7 +26725,7 @@ function defaultRun(cmd) {
26619
26725
  }
26620
26726
  function defaultReadLog(path) {
26621
26727
  try {
26622
- return readFileSync48(path, "utf8");
26728
+ return readFileSync49(path, "utf8");
26623
26729
  } catch {
26624
26730
  return null;
26625
26731
  }
@@ -26686,7 +26792,7 @@ function startLaunchdDaemon(o) {
26686
26792
  }
26687
26793
 
26688
26794
  // src/daemon-start-failure.ts
26689
- import { existsSync as existsSync50, mkdirSync as mkdirSync38, readFileSync as readFileSync49, unlinkSync as unlinkSync4, writeFileSync as writeFileSync40 } from "fs";
26795
+ import { existsSync as existsSync50, mkdirSync as mkdirSync38, readFileSync as readFileSync50, unlinkSync as unlinkSync4, writeFileSync as writeFileSync40 } from "fs";
26690
26796
  import { dirname as dirname30, join as join55 } from "path";
26691
26797
  var DAEMON_START_FAILED_KEY = "daemon_start_failed";
26692
26798
  var START_FAILURE_BACKOFF_MS = 6e4;
@@ -26694,7 +26800,7 @@ var BACKOFF_AFTER_FAILURES = 2;
26694
26800
  var fileFor4 = (stateDir) => join55(stateDir, ".daemon-start-failure.json");
26695
26801
  function readStartFailure(stateDir) {
26696
26802
  try {
26697
- const parsed = JSON.parse(readFileSync49(fileFor4(stateDir), "utf8"));
26803
+ const parsed = JSON.parse(readFileSync50(fileFor4(stateDir), "utf8"));
26698
26804
  return typeof parsed.reason === "string" && typeof parsed.count === "number" ? { reason: parsed.reason, count: parsed.count, firstAt: String(parsed.firstAt), lastAt: String(parsed.lastAt) } : null;
26699
26805
  } catch {
26700
26806
  return null;
@@ -28227,7 +28333,8 @@ function renderConnection(d, route2, dir, opts = {}) {
28227
28333
  apiKeyVar: ${opts.apiKeyVar}` : "";
28228
28334
  const baseUrlLine = opts.baseUrl && opts.baseUrl.replace(/\/+$/, "") !== DEFAULT_BASE_URL ? ` baseUrl: "${opts.baseUrl}"
28229
28335
  ` : "";
28230
- const keyLines = [apiKeyFileLine, apiKeyVarLine.replace(/^\n/, "")].filter(Boolean).join("\n");
28336
+ const inlineKeyLine = !opts.keychainBacked && opts.inlineApiKey ? ` apiKey: "${opts.inlineApiKey}"` : "";
28337
+ const keyLines = [apiKeyFileLine, apiKeyVarLine.replace(/^\n/, ""), inlineKeyLine].filter(Boolean).join("\n");
28231
28338
  return ` - route: ${route2}
28232
28339
  enabled: false # set to true once \`crew doctor\` is green
28233
28340
  ${opts.area ? ` area: "${opts.area}"
@@ -28326,7 +28433,7 @@ function describeCapability(i) {
28326
28433
  }
28327
28434
 
28328
28435
  // src/persona-avatars.ts
28329
- import { existsSync as existsSync52, readFileSync as readFileSync50 } from "fs";
28436
+ import { existsSync as existsSync52, readFileSync as readFileSync51 } from "fs";
28330
28437
  import { join as join56 } from "path";
28331
28438
  var IMAGE_TYPES = { png: "image/png", svg: "image/svg+xml" };
28332
28439
  function personaAvatarFile(promptsDir, role) {
@@ -28351,7 +28458,7 @@ async function syncPersonaAvatars(route2, agentPersonas, opts) {
28351
28458
  if (!file || !agentId) continue;
28352
28459
  try {
28353
28460
  const form = new FormData();
28354
- form.append("file", new Blob([readFileSync50(file.path)], { type: file.mimeType }), file.name);
28461
+ form.append("file", new Blob([readFileSync51(file.path)], { type: file.mimeType }), file.name);
28355
28462
  const res = await fetch(`${base}/${agentId}/avatar`, {
28356
28463
  method: "PUT",
28357
28464
  headers: { Authorization: `Bearer ${resolveApiKey(route2)}`, "User-Agent": opts.userAgent ?? "Mozilla/5.0 TablationCrewAgent/1.0" },
@@ -28392,14 +28499,14 @@ function avatarFailures(raw) {
28392
28499
  }
28393
28500
  function routeAvatarFailures(stateDir, route2) {
28394
28501
  try {
28395
- return avatarFailures(JSON.parse(readFileSync50(resolvedPathFor(stateDir, route2), "utf8")));
28502
+ return avatarFailures(JSON.parse(readFileSync51(resolvedPathFor(stateDir, route2), "utf8")));
28396
28503
  } catch {
28397
28504
  return [];
28398
28505
  }
28399
28506
  }
28400
28507
 
28401
28508
  // src/agents-sync-run.ts
28402
- import { existsSync as existsSync53, mkdirSync as mkdirSync40, readFileSync as readFileSync51, writeFileSync as writeFileSync42 } from "fs";
28509
+ import { existsSync as existsSync53, mkdirSync as mkdirSync40, readFileSync as readFileSync52, writeFileSync as writeFileSync42 } from "fs";
28403
28510
  import { dirname as dirname32 } from "path";
28404
28511
  async function runAgentsSync(target, o) {
28405
28512
  const dryRun = o.dryRun ?? false;
@@ -28445,7 +28552,7 @@ async function runAgentsSync(target, o) {
28445
28552
  }
28446
28553
  if (!dryRun) {
28447
28554
  const resolvedPath = resolvedPathFor(o.stateDir, target.route);
28448
- const raw = existsSync53(resolvedPath) ? JSON.parse(readFileSync51(resolvedPath, "utf8")) : {};
28555
+ const raw = existsSync53(resolvedPath) ? JSON.parse(readFileSync52(resolvedPath, "utf8")) : {};
28449
28556
  raw.agentPersonas = personaResult.agentPersonas;
28450
28557
  if (skillResult) raw.agentSkills = skillResult.agentSkills;
28451
28558
  if (!readOnly2) raw.avatarSyncFailures = avatarFailures2;
@@ -28587,16 +28694,16 @@ async function showLogEntry(route2, entryId, opts = {}) {
28587
28694
  }
28588
28695
 
28589
28696
  // src/repo-setup-prompt.ts
28590
- import { readFileSync as readFileSync52 } from "fs";
28697
+ import { readFileSync as readFileSync53 } from "fs";
28591
28698
  import { join as join57 } from "path";
28592
28699
  var REPO_SETUP_PROMPT_PATH = join57("docs", "repo-setup-prompt.md");
28593
28700
  function readRepoSetupPrompt(crewHome) {
28594
- return readFileSync52(join57(crewHome, REPO_SETUP_PROMPT_PATH), "utf8");
28701
+ return readFileSync53(join57(crewHome, REPO_SETUP_PROMPT_PATH), "utf8");
28595
28702
  }
28596
28703
 
28597
28704
  // src/repos-check.ts
28598
28705
  import { spawnSync as spawnSync14 } from "child_process";
28599
- import { readFileSync as readFileSync53 } from "fs";
28706
+ import { readFileSync as readFileSync54 } from "fs";
28600
28707
  import { basename as basename12 } from "path";
28601
28708
  var POSIX_SHELL = /^(?:ba|z|da|k|a|mk)?sh$|^fish$/;
28602
28709
  function checkHookSyntax(script, shell) {
@@ -28637,7 +28744,7 @@ function checkRepoSpec(dir, opts = {}) {
28637
28744
  }
28638
28745
  let parsed;
28639
28746
  try {
28640
- parsed = parseRepoConfig(readFileSync53(file, "utf8"), file);
28747
+ parsed = parseRepoConfig(readFileSync54(file, "utf8"), file);
28641
28748
  } catch (e) {
28642
28749
  if (!(e instanceof RepoConfigError)) throw e;
28643
28750
  return { ...empty, file, error: e.message, exitCode: 1 };
@@ -29048,7 +29155,7 @@ async function runAgentSuggest(o) {
29048
29155
  const before = porcelain(o.dir);
29049
29156
  const timeout = AbortSignal.timeout(o.timeoutMs ?? DEFAULT_TIMEOUT_MS);
29050
29157
  const signal = o.signal ? AbortSignal.any([o.signal, timeout]) : timeout;
29051
- const run4 = await new Promise((resolve8) => {
29158
+ const run4 = await new Promise((resolve9) => {
29052
29159
  let out = "";
29053
29160
  let err3 = "";
29054
29161
  const child = spawn9(bin, args, { cwd: o.dir, env, detached: true, stdio: ["pipe", "pipe", "pipe"] });
@@ -29057,7 +29164,7 @@ async function runAgentSuggest(o) {
29057
29164
  if (settled) return;
29058
29165
  settled = true;
29059
29166
  signal.removeEventListener("abort", onAbort);
29060
- resolve8(r);
29167
+ resolve9(r);
29061
29168
  };
29062
29169
  const onAbort = () => {
29063
29170
  try {
@@ -29394,8 +29501,8 @@ function fixPhaseNothingToOffer(o) {
29394
29501
  }
29395
29502
 
29396
29503
  // src/worktree-sweep.ts
29397
- import { existsSync as existsSync54, readFileSync as readFileSync54, readdirSync as readdirSync16 } from "fs";
29398
- import { basename as basename14, dirname as dirname34, join as join59, resolve as resolve5 } from "path";
29504
+ import { existsSync as existsSync54, readFileSync as readFileSync55, readdirSync as readdirSync16 } from "fs";
29505
+ import { basename as basename14, dirname as dirname34, join as join59, resolve as resolve6 } from "path";
29399
29506
  function planWorktreeSweep(target, tickets, contract) {
29400
29507
  const terminal = new Set(contract.statuses.resolved.filter((s) => s !== contract.statuses.verified));
29401
29508
  const verified = contract.statuses.verified;
@@ -29461,7 +29568,7 @@ function worktreeTicketNumbers(target) {
29461
29568
  function siblingWorktreeDirs(target) {
29462
29569
  const parent = dirname34(target.dir.replace(/[/\\]+$/, ""));
29463
29570
  const stem = `${basename14(target.dir.replace(/[/\\]+$/, ""))}-`;
29464
- const registered = new Set(worktrees(target.dir).map((w) => resolve5(w.path)));
29571
+ const registered = new Set(worktrees(target.dir).map((w) => resolve6(w.path)));
29465
29572
  let names;
29466
29573
  try {
29467
29574
  names = readdirSync16(parent);
@@ -29473,7 +29580,7 @@ function siblingWorktreeDirs(target) {
29473
29580
  if (!name.startsWith(stem)) continue;
29474
29581
  const m = DIR_NUMBER_SUFFIXED.exec(name);
29475
29582
  const path = join59(parent, name);
29476
- if (m && !registered.has(resolve5(path))) out.push({ path, number: m[1] });
29583
+ if (m && !registered.has(resolve6(path))) out.push({ path, number: m[1] });
29477
29584
  }
29478
29585
  return out;
29479
29586
  }
@@ -29599,7 +29706,7 @@ function isHandBackMerge(path, base) {
29599
29706
  if (!msgPath) return false;
29600
29707
  let first;
29601
29708
  try {
29602
- first = readFileSync54(resolve5(path, msgPath), "utf8").split("\n")[0] ?? "";
29709
+ first = readFileSync55(resolve6(path, msgPath), "utf8").split("\n")[0] ?? "";
29603
29710
  } catch {
29604
29711
  return false;
29605
29712
  }
@@ -29781,7 +29888,7 @@ function planStateSweep(stateDir, retentionDays, maxBytes, now = Date.now()) {
29781
29888
  }
29782
29889
 
29783
29890
  // src/cli.ts
29784
- import { realpathSync as realpathSync4, readFileSync as readFileSync57, existsSync as existsSync60, mkdirSync as mkdirSync44, writeFileSync as writeFileSync45, rmSync as rmSync27, unlinkSync as unlinkSync6, copyFileSync as copyFileSync2, renameSync as renameSync10, statSync as statSync19, readdirSync as readdirSync22 } from "fs";
29891
+ import { realpathSync as realpathSync4, readFileSync as readFileSync58, existsSync as existsSync60, mkdirSync as mkdirSync44, writeFileSync as writeFileSync45, rmSync as rmSync27, unlinkSync as unlinkSync6, copyFileSync as copyFileSync2, renameSync as renameSync10, statSync as statSync19, readdirSync as readdirSync22 } from "fs";
29785
29892
  import { createInterface } from "readline/promises";
29786
29893
 
29787
29894
  // src/periscope-resume.ts
@@ -29860,7 +29967,7 @@ import { dirname as dirOf2, resolve as resolvePath } from "path";
29860
29967
  import { existsSync as existsSync56, readdirSync as readdirSync18, statSync as statSync17 } from "fs";
29861
29968
  import { join as join61 } from "path";
29862
29969
  function builtVersion() {
29863
- return true ? "0.169.4" : null;
29970
+ return true ? "0.169.6" : null;
29864
29971
  }
29865
29972
  var REBUILD_HINT = "rebuild with npm run build";
29866
29973
  function newestMtime(path) {
@@ -30101,7 +30208,7 @@ async function unregisterEndpoint(workspaceId, info, d) {
30101
30208
  import { createServer as createHttpServer } from "http";
30102
30209
  import { spawn as spawn10 } from "child_process";
30103
30210
  import { randomBytes as randomBytes2 } from "crypto";
30104
- import { existsSync as existsSync57, mkdirSync as mkdirSync41, readFileSync as readFileSync55, writeFileSync as writeFileSync43, unlinkSync as unlinkSync5, readdirSync as readdirSync19 } from "fs";
30211
+ import { existsSync as existsSync57, mkdirSync as mkdirSync41, readFileSync as readFileSync56, writeFileSync as writeFileSync43, unlinkSync as unlinkSync5, readdirSync as readdirSync19 } from "fs";
30105
30212
  import { join as join62 } from "path";
30106
30213
 
30107
30214
  // src/secret-compare.ts
@@ -30201,7 +30308,7 @@ function readPersistedSyncDaemon(stateDir, workspaceId) {
30201
30308
  const path = syncDaemonStatePath(stateDir, workspaceId);
30202
30309
  if (!existsSync57(path)) return void 0;
30203
30310
  try {
30204
- return JSON.parse(readFileSync55(path, "utf8"));
30311
+ return JSON.parse(readFileSync56(path, "utf8"));
30205
30312
  } catch {
30206
30313
  return void 0;
30207
30314
  }
@@ -30623,11 +30730,11 @@ function runProxyFromEnv(dropFile, env = process.env) {
30623
30730
  return server;
30624
30731
  }
30625
30732
  function accepts(host, port, timeoutMs = 500) {
30626
- return new Promise((resolve8) => {
30733
+ return new Promise((resolve9) => {
30627
30734
  const s = netConnect({ host, port });
30628
30735
  const done = (ok) => {
30629
30736
  s.destroy();
30630
- resolve8(ok);
30737
+ resolve9(ok);
30631
30738
  };
30632
30739
  s.setTimeout(timeoutMs, () => done(false));
30633
30740
  s.once("connect", () => done(true));
@@ -30934,7 +31041,7 @@ async function handlePeriscopes(h, q2) {
30934
31041
  ], q2.wantsStream, h.mcp ? async (done) => ({ ...done, ...await h.mcp.onUp(picked, done) }) : void 0);
30935
31042
  }
30936
31043
  function runCrew(args, onLine, timeoutMs = 20 * 6e4) {
30937
- return new Promise((resolve8) => {
31044
+ return new Promise((resolve9) => {
30938
31045
  const self = selfLaunch();
30939
31046
  const child = spawn12(self.command, [...self.args, ...args], { stdio: ["ignore", "pipe", "pipe"] });
30940
31047
  let stdout = "";
@@ -30957,12 +31064,12 @@ function runCrew(args, onLine, timeoutMs = 20 * 6e4) {
30957
31064
  const t = setTimeout(() => child.kill("SIGTERM"), timeoutMs);
30958
31065
  child.on("error", (e) => {
30959
31066
  clearTimeout(t);
30960
- resolve8({ code: 127, stdout, stderr: `${stderr}${e.message}
31067
+ resolve9({ code: 127, stdout, stderr: `${stderr}${e.message}
30961
31068
  ` });
30962
31069
  });
30963
31070
  child.on("close", (code) => {
30964
31071
  clearTimeout(t);
30965
- resolve8({ code: code ?? 1, stdout, stderr });
31072
+ resolve9({ code: code ?? 1, stdout, stderr });
30966
31073
  });
30967
31074
  });
30968
31075
  }
@@ -31146,7 +31253,7 @@ function readTail(live2, opts) {
31146
31253
  };
31147
31254
  }
31148
31255
  function waitForChange(dir, ms3, signal) {
31149
- return new Promise((resolve8) => {
31256
+ return new Promise((resolve9) => {
31150
31257
  let w;
31151
31258
  const done = () => {
31152
31259
  clearTimeout(t);
@@ -31156,7 +31263,7 @@ function waitForChange(dir, ms3, signal) {
31156
31263
  w?.close();
31157
31264
  } catch {
31158
31265
  }
31159
- resolve8();
31266
+ resolve9();
31160
31267
  };
31161
31268
  const t = setTimeout(done, ms3);
31162
31269
  const poll = setInterval(done, 500);
@@ -31367,13 +31474,13 @@ function send2(res, r) {
31367
31474
  }
31368
31475
  async function socketIsStale(path) {
31369
31476
  if (!existsSync58(path)) return false;
31370
- return new Promise((resolve8) => {
31477
+ return new Promise((resolve9) => {
31371
31478
  const c = createConnection(path);
31372
31479
  c.once("connect", () => {
31373
31480
  c.destroy();
31374
- resolve8(false);
31481
+ resolve9(false);
31375
31482
  });
31376
- c.once("error", () => resolve8(true));
31483
+ c.once("error", () => resolve9(true));
31377
31484
  });
31378
31485
  }
31379
31486
  async function startControlServer(deps) {
@@ -31415,10 +31522,10 @@ async function startControlServer(deps) {
31415
31522
  }
31416
31523
  })();
31417
31524
  });
31418
- return new Promise((resolve8) => {
31525
+ return new Promise((resolve9) => {
31419
31526
  server.once("error", (e) => {
31420
31527
  log(`control API not started: ${e.message}`);
31421
- resolve8(null);
31528
+ resolve9(null);
31422
31529
  });
31423
31530
  server.listen(path, () => {
31424
31531
  try {
@@ -31426,7 +31533,7 @@ async function startControlServer(deps) {
31426
31533
  } catch {
31427
31534
  }
31428
31535
  server.on("error", (e) => log(`control API error: ${e.message}`));
31429
- resolve8({
31536
+ resolve9({
31430
31537
  server,
31431
31538
  path,
31432
31539
  close: () => new Promise((done) => {
@@ -31462,36 +31569,36 @@ function stderrTail(stderr, lines2 = 5, maxChars = 600) {
31462
31569
  return tail3.length > maxChars ? `\u2026${tail3.slice(-maxChars)}` : tail3;
31463
31570
  }
31464
31571
  function crewJson(args, timeoutMs = CREW_JSON_TIMEOUT_MS) {
31465
- return new Promise((resolve8) => {
31572
+ return new Promise((resolve9) => {
31466
31573
  const self = selfLaunch();
31467
31574
  execFile6(self.command, [...self.args, ...args], { timeout: timeoutMs, maxBuffer: 16 * 1024 * 1024 }, (e, stdout, stderr) => {
31468
31575
  try {
31469
31576
  const v = JSON.parse(String(stdout));
31470
- if (v && typeof v === "object" && !Array.isArray(v)) return resolve8({ ok: true, doc: v });
31577
+ if (v && typeof v === "object" && !Array.isArray(v)) return resolve9({ ok: true, doc: v });
31471
31578
  } catch {
31472
31579
  }
31473
31580
  const ex = e;
31474
31581
  const tail3 = stderrTail(String(stderr ?? ""));
31475
- if (ex?.killed || ex?.code === "ETIMEDOUT") return resolve8({ ok: false, reason: "timed_out", detail: `no JSON within ${Math.round(timeoutMs / 1e3)}s${tail3 ? `; stderr: ${tail3}` : ""}` });
31582
+ if (ex?.killed || ex?.code === "ETIMEDOUT") return resolve9({ ok: false, reason: "timed_out", detail: `no JSON within ${Math.round(timeoutMs / 1e3)}s${tail3 ? `; stderr: ${tail3}` : ""}` });
31476
31583
  if (ex) {
31477
31584
  const how = typeof ex.code === "number" ? `exit code ${ex.code}` : ex.signal ? `signal ${ex.signal}` : `error ${String(ex.code ?? ex.message)}`;
31478
- return resolve8({ ok: false, reason: "exited", detail: `${how}${tail3 ? `; stderr: ${tail3}` : ""}` });
31585
+ return resolve9({ ok: false, reason: "exited", detail: `${how}${tail3 ? `; stderr: ${tail3}` : ""}` });
31479
31586
  }
31480
- resolve8({ ok: false, reason: "bad_output", detail: `exit 0 but stdout is not a JSON object (${String(stdout).length} bytes)${tail3 ? `; stderr: ${tail3}` : ""}` });
31587
+ resolve9({ ok: false, reason: "bad_output", detail: `exit 0 but stdout is not a JSON object (${String(stdout).length} bytes)${tail3 ? `; stderr: ${tail3}` : ""}` });
31481
31588
  });
31482
31589
  });
31483
31590
  }
31484
31591
 
31485
31592
  // src/periscope-mcp.ts
31486
31593
  import { lstat, mkdir, readdir, readFile, readlink, realpath, rm, stat, writeFile } from "fs/promises";
31487
- import { basename as basename16, dirname as dirname37, isAbsolute as isAbsolute5, join as join66, relative as relative2, resolve as resolve6, sep } from "path";
31594
+ import { basename as basename16, dirname as dirname37, isAbsolute as isAbsolute5, join as join66, relative as relative2, resolve as resolve7, sep } from "path";
31488
31595
  import { z } from "zod";
31489
31596
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
31490
31597
  import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
31491
31598
 
31492
31599
  // src/periscope-endpoints.ts
31493
31600
  import { randomBytes as randomBytes3 } from "crypto";
31494
- import { chmodSync as chmodSync5, existsSync as existsSync59, mkdirSync as mkdirSync43, readdirSync as readdirSync21, readFileSync as readFileSync56, rmSync as rmSync26, writeFileSync as writeFileSync44 } from "fs";
31601
+ import { chmodSync as chmodSync5, existsSync as existsSync59, mkdirSync as mkdirSync43, readdirSync as readdirSync21, readFileSync as readFileSync57, rmSync as rmSync26, writeFileSync as writeFileSync44 } from "fs";
31495
31602
  import { join as join65 } from "path";
31496
31603
  var secretDir = (stateDir) => join65(stateDir, "periscope-mcp");
31497
31604
  var secretFile = (stateDir, id) => join65(secretDir(stateDir), `${id}.json`);
@@ -31508,7 +31615,7 @@ function mintPeriscopeSecret(stateDir, ticketRecordId) {
31508
31615
  }
31509
31616
  function readPeriscopeSecret(stateDir, ticketRecordId) {
31510
31617
  try {
31511
- const v = JSON.parse(readFileSync56(secretFile(stateDir, ticketRecordId), "utf8"));
31618
+ const v = JSON.parse(readFileSync57(secretFile(stateDir, ticketRecordId), "utf8"));
31512
31619
  return typeof v.secret === "string" && v.secret ? v.secret : void 0;
31513
31620
  } catch {
31514
31621
  return void 0;
@@ -31519,7 +31626,7 @@ function removePeriscopeSecret(stateDir, ticketRecordId) {
31519
31626
  }
31520
31627
  function readPeriscopeEndpoint(stateDir, ticketRecordId) {
31521
31628
  try {
31522
- return JSON.parse(readFileSync56(endpointFile(stateDir, ticketRecordId), "utf8"));
31629
+ return JSON.parse(readFileSync57(endpointFile(stateDir, ticketRecordId), "utf8"));
31523
31630
  } catch {
31524
31631
  return void 0;
31525
31632
  }
@@ -31622,7 +31729,7 @@ async function realAncestor(p) {
31622
31729
  }
31623
31730
  if (isLink) {
31624
31731
  if (++hops > 40) throw new PathRefusal(`too many symbolic links resolving ${p}`);
31625
- cur = resolve6(dirname37(cur), await readlink(cur));
31732
+ cur = resolve7(dirname37(cur), await readlink(cur));
31626
31733
  continue;
31627
31734
  }
31628
31735
  const parent = dirname37(cur);
@@ -31636,10 +31743,10 @@ async function resolveInWorktree(root, requested) {
31636
31743
  const realRoot = await realpath(root);
31637
31744
  let abs;
31638
31745
  if (isAbsolute5(requested)) {
31639
- abs = resolve6(requested);
31746
+ abs = resolve7(requested);
31640
31747
  if (isInside(root, abs)) abs = join66(realRoot, relative2(root, abs));
31641
31748
  } else {
31642
- abs = resolve6(realRoot, requested);
31749
+ abs = resolve7(realRoot, requested);
31643
31750
  }
31644
31751
  if (!isInside(realRoot, abs)) throw new PathRefusal(`${requested} is outside this periscope's worktree`);
31645
31752
  const { real, rest } = await realAncestor(abs);
@@ -31898,7 +32005,7 @@ function findPeriscope(sidecars, segment) {
31898
32005
  }
31899
32006
 
31900
32007
  // src/cli.ts
31901
- var CREW_HOME = isCompiledBinary(import.meta.url) ? dirname38(process.execPath) : resolve7(dirname38(fileURLToPath2(import.meta.url)), "..");
32008
+ var CREW_HOME = isCompiledBinary(import.meta.url) ? dirname38(process.execPath) : resolve8(dirname38(fileURLToPath2(import.meta.url)), "..");
31902
32009
  {
31903
32010
  const v = crewVersion(CREW_HOME);
31904
32011
  if (v !== "0.0.0") setRunningCrewVersion(v);
@@ -32310,7 +32417,7 @@ if (command === "provision") {
32310
32417
  process.exit(outcome.code);
32311
32418
  }
32312
32419
  if (command === "pool-member") {
32313
- const pool = poolConfigFrom(argv, process.env, () => readFileSync57(0, "utf8"));
32420
+ const pool = poolConfigFrom(argv, process.env, () => readFileSync58(0, "utf8"));
32314
32421
  if (typeof pool === "string") {
32315
32422
  process.stderr.write(`crew pool-member: ${pool}
32316
32423
  `);
@@ -32678,7 +32785,7 @@ if (command === "passenger-sync-daemon") {
32678
32785
  throw e;
32679
32786
  }
32680
32787
  if (command === "credential") {
32681
- const r = runCredential(positional[1], readFileSync57(0, "utf8"), cfg.ship.forges, cfg.ship.stateDir, process.env, !flag("no-miss"));
32788
+ const r = runCredential(positional[1], readFileSync58(0, "utf8"), cfg.ship.forges, cfg.ship.stateDir, process.env, !flag("no-miss"));
32682
32789
  process.stdout.write(r.out);
32683
32790
  process.stderr.write(r.err);
32684
32791
  process.exit(r.code);
@@ -32690,9 +32797,9 @@ if (command === "passenger-sync-daemon") {
32690
32797
  forges: cfg.ship.forges,
32691
32798
  stateDir: cfg.ship.stateDir,
32692
32799
  configFile: cfg.configFile,
32693
- readFile: (p) => readFileSync57(p, "utf8"),
32800
+ readFile: (p) => readFileSync58(p, "utf8"),
32694
32801
  writeFile: (p, t) => writeFileSync45(p, t),
32695
- stdin: () => readFileSync57(0, "utf8"),
32802
+ stdin: () => readFileSync58(0, "utf8"),
32696
32803
  env: process.env
32697
32804
  }
32698
32805
  );
@@ -33172,7 +33279,7 @@ if (command === "passenger-sync-daemon") {
33172
33279
  changed2.push(`refreshed the connect snapshot for ${a.route} (\`crew connect\`)${rel.status === 0 ? " and reloaded the daemon" : "; `crew reload` failed \u2014 run it by hand"}`);
33173
33280
  } else if (a.kind === "enable") {
33174
33281
  if (prompter && !await prompter.confirm(`Route ${a.route} passes every check \u2014 set enabled: true in ${cfg.configFile}?`, false)) continue;
33175
- writeFileSync45(cfg.configFile, planEnable(readFileSync57(cfg.configFile, "utf8"), a.route));
33282
+ writeFileSync45(cfg.configFile, planEnable(readFileSync58(cfg.configFile, "utf8"), a.route));
33176
33283
  enabledSound.add(a.route);
33177
33284
  changed2.push(`enabled route ${a.route} in ${cfg.configFile}`);
33178
33285
  } else {
@@ -33742,11 +33849,11 @@ ${changed2.map((c) => ` - ${c}
33742
33849
  const prior = ticket.assignee_id ?? null;
33743
33850
  await tracker.postEvent(ticket.id, "release took the ticket while it merges and ships it", seat, RELEASE_CLAIMED_EVENT, { prior_assignee: prior });
33744
33851
  claimed.set(ticket.id, prior);
33745
- await tracker.updateTicket(ticket.id, { [tracker.contract.columns.assignee]: seat });
33852
+ ticket.updated_at = (await tracker.updateTicket(ticket.id, { [tracker.contract.columns.assignee]: seat })).updated_at;
33746
33853
  },
33747
33854
  onUnclaim: async (ticket) => {
33748
33855
  if (!claimed.has(ticket.id)) return;
33749
- await tracker.updateTicket(ticket.id, { [tracker.contract.columns.assignee]: claimed.get(ticket.id) ?? null });
33856
+ ticket.updated_at = (await tracker.updateTicket(ticket.id, { [tracker.contract.columns.assignee]: claimed.get(ticket.id) ?? null })).updated_at;
33750
33857
  claimed.delete(ticket.id);
33751
33858
  },
33752
33859
  onBasePushed: async (merged) => {
@@ -35157,7 +35264,7 @@ ${f2.tail.trimEnd()}
35157
35264
  for (const w of result.warnings) emit.warn(w);
35158
35265
  if (!dryRun) {
35159
35266
  const resolvedPath = resolvedPathFor(cfg.ship.stateDir, target.route);
35160
- const raw = existsSync60(resolvedPath) ? JSON.parse(readFileSync57(resolvedPath, "utf8")) : {};
35267
+ const raw = existsSync60(resolvedPath) ? JSON.parse(readFileSync58(resolvedPath, "utf8")) : {};
35161
35268
  raw.agentSkills = result.agentSkills;
35162
35269
  mkdirSync44(dirOf2(resolvedPath), { recursive: true });
35163
35270
  writeFileSync45(resolvedPath, `${JSON.stringify(raw, null, 2)}
@@ -35181,7 +35288,7 @@ ${f2.tail.trimEnd()}
35181
35288
  throw e;
35182
35289
  }
35183
35290
  const oldName = cfg.ship.name;
35184
- writeFileSync45(cfg.configFile, setShipNameInYaml(readFileSync57(cfg.configFile, "utf8"), newName));
35291
+ writeFileSync45(cfg.configFile, setShipNameInYaml(readFileSync58(cfg.configFile, "utf8"), newName));
35185
35292
  cfg.ship.name = newName;
35186
35293
  let renameMachineId;
35187
35294
  try {
@@ -35228,7 +35335,7 @@ ${f2.tail.trimEnd()}
35228
35335
  process.exit(2);
35229
35336
  };
35230
35337
  if (sub !== "add" && sub !== "list" && sub !== "clone" && sub !== "hooks" && sub !== "check") usage2();
35231
- const configText = readFileSync57(cfg.configFile, "utf8");
35338
+ const configText = readFileSync58(cfg.configFile, "utf8");
35232
35339
  if (sub === "check") {
35233
35340
  try {
35234
35341
  const routeArg = value("route") ?? positional[2];
@@ -35267,7 +35374,7 @@ ${f2.tail.trimEnd()}
35267
35374
  }
35268
35375
  }, read: (r) => {
35269
35376
  try {
35270
- return readFileSync57(resolvePath(dir, r), "utf8");
35377
+ return readFileSync58(resolvePath(dir, r), "utf8");
35271
35378
  } catch {
35272
35379
  return void 0;
35273
35380
  }
@@ -35411,7 +35518,7 @@ ${f2.tail.trimEnd()}
35411
35518
  let resolvedRemotes;
35412
35519
  if (existsSync60(resolvedFile)) {
35413
35520
  try {
35414
- resolvedRemotes = JSON.parse(readFileSync57(resolvedFile, "utf8"));
35521
+ resolvedRemotes = JSON.parse(readFileSync58(resolvedFile, "utf8"));
35415
35522
  } catch {
35416
35523
  }
35417
35524
  }
@@ -35433,7 +35540,7 @@ ${f2.tail.trimEnd()}
35433
35540
  repoHasHooks: (d) => REPO_CONFIG_FILENAMES.some((f2) => {
35434
35541
  try {
35435
35542
  const path = resolvePath(d, f2);
35436
- return Object.keys(parseRepoConfig(readFileSync57(path, "utf8"), path).hooks).length > 0;
35543
+ return Object.keys(parseRepoConfig(readFileSync58(path, "utf8"), path).hooks).length > 0;
35437
35544
  } catch {
35438
35545
  return false;
35439
35546
  }
@@ -35573,7 +35680,7 @@ would need a project first: the tracker has none (\`crew projects add NAME --pre
35573
35680
  process.stdout.write(`created Repos row ${String(rowPayload.name)} (${String(rowPayload.remote)}) ${created.id}
35574
35681
  `);
35575
35682
  if (existsSync60(resolvedFile)) {
35576
- const raw = JSON.parse(readFileSync57(resolvedFile, "utf8"));
35683
+ const raw = JSON.parse(readFileSync58(resolvedFile, "utf8"));
35577
35684
  raw.repoNames = { ...raw.repoNames, [created.id]: String(rowPayload.name) };
35578
35685
  raw.repoRemotes = { ...raw.repoRemotes, [created.id]: String(rowPayload.remote) };
35579
35686
  writeFileSync45(resolvedFile, `${JSON.stringify(raw, null, 2)}
@@ -35715,8 +35822,9 @@ ${reconstruction.prompt}
35715
35822
  let workspace = argWorkspace ?? value("workspace-id") ?? value("workspace") ?? connectChoices.workspace;
35716
35823
  const project = argProject ?? value("project") ?? connectChoices.project;
35717
35824
  const baseUrl = value("base-url") ?? cfg.routes[0]?.baseUrl ?? DEFAULT_BASE_URL;
35718
- let apiKey = value("key") ?? process.env.CREW_CONNECT_KEY ?? cfg.routes.find((c) => c.apiKey)?.apiKey;
35825
+ let apiKey = value("key") ?? process.env.CREW_CONNECT_KEY ?? (workspace ? void 0 : cfg.routes.find((c) => c.apiKey)?.apiKey);
35719
35826
  const givenKeySource = value("key") ?? process.env.CREW_CONNECT_KEY ? "flag" : "config";
35827
+ let siblingKey;
35720
35828
  let store;
35721
35829
  try {
35722
35830
  store = getSessionStore();
@@ -35745,6 +35853,19 @@ ${reconstruction.prompt}
35745
35853
  } catch {
35746
35854
  }
35747
35855
  }
35856
+ if (!apiKey && workspace) {
35857
+ const host = hostFromUrl4(baseUrl);
35858
+ const full = rememberedAddressFor(cfg.ship.stateDir, host, workspace);
35859
+ siblingKey = siblingRouteKey(cfg.routes, host, (w) => w === workspace || w === full, hostFromUrl4);
35860
+ if (siblingKey) {
35861
+ apiKey = siblingKey.apiKey;
35862
+ if (siblingKey.source === "keychain") {
35863
+ keychainBacked = true;
35864
+ sessionAddress = siblingKey.workspace;
35865
+ }
35866
+ routineLine(`Reusing the key of the existing route in ${host}/${workspace}.`);
35867
+ }
35868
+ }
35748
35869
  let signInSource = apiKey ? "key" : "device";
35749
35870
  if (!apiKey && !workspace && store) {
35750
35871
  const resumable = await resumableSessions({
@@ -35932,7 +36053,7 @@ Waiting for approval`
35932
36053
  ${found.problems.map((p) => ` - ${p}`).join("\n")}`, "fix the problems above, then run `crew connect` again");
35933
36054
  }
35934
36055
  if (found.shipNameAdopted && !dryRun) {
35935
- writeFileSync45(cfg.configFile, setShipNameInYaml(readFileSync57(cfg.configFile, "utf8"), found.shipNameAdopted));
36056
+ writeFileSync45(cfg.configFile, setShipNameInYaml(readFileSync58(cfg.configFile, "utf8"), found.shipNameAdopted));
35936
36057
  cfg.ship.name = found.shipNameAdopted;
35937
36058
  }
35938
36059
  if (found.shipRow) {
@@ -35976,7 +36097,7 @@ ${found.problems.map((p) => ` - ${p}`).join("\n")}`, "fix the problems above, t
35976
36097
  const hadPreviousFile = existsSync60(resolvedPath);
35977
36098
  if (hadPreviousFile) {
35978
36099
  try {
35979
- previous = JSON.parse(readFileSync57(resolvedPath, "utf8"));
36100
+ previous = JSON.parse(readFileSync58(resolvedPath, "utf8"));
35980
36101
  } catch {
35981
36102
  }
35982
36103
  }
@@ -36186,7 +36307,9 @@ ${found.problems.map((p) => ` - ${p}`).join("\n")}`, "fix the problems above, t
36186
36307
  }
36187
36308
  }
36188
36309
  }
36189
- if ((mintedFromDevice || firstRunFromFlags || keyFromFlag) && !keychainBacked) {
36310
+ if (siblingKey?.source === "apiKeyFile") {
36311
+ apiKeyFile = siblingKey.apiKeyFile;
36312
+ } else if (!siblingKey && (mintedFromDevice || firstRunFromFlags || keyFromFlag) && !keychainBacked) {
36190
36313
  apiKeyFile = apiKeyPathFor(cfg.ship.stateDir, route3);
36191
36314
  if (dryRun) {
36192
36315
  process.stderr.write(`(dry run) would write the API key to ${apiKeyFile}
@@ -36198,7 +36321,7 @@ ${found.problems.map((p) => ` - ${p}`).join("\n")}`, "fix the problems above, t
36198
36321
  routineLine(`API key written to ${apiKeyFile}`);
36199
36322
  }
36200
36323
  }
36201
- const keyPersisted = keychainBacked || apiKeyFile !== void 0;
36324
+ const keyPersisted = keychainBacked || apiKeyFile !== void 0 || siblingKey !== void 0;
36202
36325
  const wizard = firstRun;
36203
36326
  const writeFirstRun = wizard !== void 0 && !dryRun && keyPersisted;
36204
36327
  const routeDir = value("dir");
@@ -36209,9 +36332,10 @@ ${found.problems.map((p) => ` - ${p}`).join("\n")}`, "fix the problems above, t
36209
36332
  {
36210
36333
  area: value("area"),
36211
36334
  apiKeyFile,
36212
- apiKeyVar: apiKeyFile ? apiKeyVar : void 0,
36335
+ apiKeyVar: apiKeyFile ? siblingKey?.apiKeyVar ?? apiKeyVar : void 0,
36213
36336
  keychainBacked,
36214
36337
  baseUrl,
36338
+ ...siblingKey?.source === "inline" ? { inlineApiKey: siblingKey.apiKey } : {},
36215
36339
  ...writeFirstRun ? { hostPassengers: wizard.answers.hostPassengers } : {}
36216
36340
  }
36217
36341
  );
@@ -37582,7 +37706,7 @@ ${where.join("\n")}`);
37582
37706
  };
37583
37707
  const droppedRoutes = [];
37584
37708
  try {
37585
- const rawCfg = parseYaml3(readFileSync57(cfg.configFile, "utf8"));
37709
+ const rawCfg = parseYaml3(readFileSync58(cfg.configFile, "utf8"));
37586
37710
  for (const r of rawCfg?.routes ?? []) {
37587
37711
  if (typeof r?.route !== "string" || cfg.routes.some((x) => x.route === r.route)) continue;
37588
37712
  try {
@@ -37708,7 +37832,7 @@ ${where.join("\n")}`);
37708
37832
  }
37709
37833
  case "log": {
37710
37834
  try {
37711
- const text2 = readFileSync57(cfg.ship.logFile, "utf8").split("\n");
37835
+ const text2 = readFileSync58(cfg.ship.logFile, "utf8").split("\n");
37712
37836
  process.stdout.write(`${text2.slice(-(Number(value("tail")) || 40)).join("\n")}
37713
37837
  `);
37714
37838
  } catch {
@@ -37732,7 +37856,7 @@ ${where.join("\n")}`);
37732
37856
  };
37733
37857
  if (!route2.resolved) fail2(`route ${route2.route} is not connected \u2014 run \`crew connect\` first`);
37734
37858
  const tracker = new Tracker(route2, cfg.ship);
37735
- const configText = readFileSync57(cfg.configFile, "utf8");
37859
+ const configText = readFileSync58(cfg.configFile, "utf8");
37736
37860
  const cfgBase = dirname38(cfg.configFile);
37737
37861
  const configured2 = configuredRepos(configText, route2.route, cfgBase);
37738
37862
  const dir = configured2.find((r) => r.name === SAMPLE_REPO)?.dir ?? sampleDir(configured2.map((r) => r.dir), route2.reposBasePath, route2.route.split("/")[0]);
@@ -37770,7 +37894,7 @@ ${where.join("\n")}`);
37770
37894
  if (row) {
37771
37895
  await tracker.deleteRepoRow(row.id);
37772
37896
  if (existsSync60(resolvedFile)) {
37773
- const raw = JSON.parse(readFileSync57(resolvedFile, "utf8"));
37897
+ const raw = JSON.parse(readFileSync58(resolvedFile, "utf8"));
37774
37898
  if (raw.repoNames) delete raw.repoNames[row.id];
37775
37899
  if (raw.repoRemotes) delete raw.repoRemotes[row.id];
37776
37900
  writeFileSync45(resolvedFile, `${JSON.stringify(raw, null, 2)}
@@ -37810,7 +37934,7 @@ ${where.join("\n")}`);
37810
37934
  });
37811
37935
  repoId = (await tracker.createRepoRow(payload)).id;
37812
37936
  if (existsSync60(resolvedFile)) {
37813
- const raw = JSON.parse(readFileSync57(resolvedFile, "utf8"));
37937
+ const raw = JSON.parse(readFileSync58(resolvedFile, "utf8"));
37814
37938
  raw.repoNames = { ...raw.repoNames, [repoId]: SAMPLE_REPO };
37815
37939
  raw.repoRemotes = { ...raw.repoRemotes, [repoId]: SAMPLE_REMOTE };
37816
37940
  writeFileSync45(resolvedFile, `${JSON.stringify(raw, null, 2)}
@@ -38452,7 +38576,7 @@ routes: ${cfg.routes.map((c) => c.route).join(", ")}
38452
38576
  const unitPlan = planInstall(cfg.ship, CREW_HOME, host, detectSystemd(), "run", installContext());
38453
38577
  const abandons = unitAbandonsAgents(unitPlan, (p) => {
38454
38578
  try {
38455
- return readFileSync57(p, "utf8");
38579
+ return readFileSync58(p, "utf8");
38456
38580
  } catch {
38457
38581
  return null;
38458
38582
  }
@@ -38467,7 +38591,7 @@ routes: ${cfg.routes.map((c) => c.route).join(", ")}
38467
38591
  const pPlan = planInstall(cfg.ship, CREW_HOME, host, true, "passengers", installContext());
38468
38592
  const keeps = unitAbandonsAgents(pPlan, (p) => {
38469
38593
  try {
38470
- return readFileSync57(p, "utf8");
38594
+ return readFileSync58(p, "utf8");
38471
38595
  } catch {
38472
38596
  return null;
38473
38597
  }