@tablation/crew 0.138.0 → 0.140.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -1673,9 +1673,12 @@ var claudeAdapter = {
1673
1673
  "the write profile (QA) withholds the Edit tool, not file writes \u2014 Bash can still write files",
1674
1674
  "git push is not blocked, only forced pushes"
1675
1675
  ],
1676
+ // CREW-3118: with `--input-format stream-json` stdin is NDJSON user messages, so a note can follow the prompt.
1677
+ userMessageLine: (text2) => JSON.stringify({ type: "user", message: { role: "user", content: [{ type: "text", text: text2 }] } }) + "\n",
1676
1678
  invocation(spec, o) {
1677
1679
  const args = [
1678
1680
  "-p",
1681
+ ...o.streamInput ? ["--input-format", "stream-json"] : [],
1679
1682
  "--allowedTools",
1680
1683
  ...allowedTools(o.role),
1681
1684
  "--disallowedTools",
@@ -8879,6 +8882,16 @@ var BeforeFirstEditTracker = class {
8879
8882
  }
8880
8883
  };
8881
8884
 
8885
+ // src/run-input.ts
8886
+ var live = /* @__PURE__ */ new Map();
8887
+ var registerRunInput = (run4, input) => {
8888
+ live.set(run4, input);
8889
+ };
8890
+ var unregisterRunInput = (run4) => {
8891
+ live.delete(run4);
8892
+ };
8893
+ var runInputFor = (run4) => live.get(run4);
8894
+
8882
8895
  // src/agent-log.ts
8883
8896
  import { existsSync as existsSync25, mkdirSync as mkdirSync18, readdirSync as readdirSync8, readFileSync as readFileSync25, rmSync as rmSync14, writeFileSync as writeFileSync19 } from "fs";
8884
8897
  import { join as join27 } from "path";
@@ -11018,6 +11031,58 @@ async function updateStartedRow(target, rowId, body) {
11018
11031
  throw e;
11019
11032
  }
11020
11033
  }
11034
+ async function markMessage(target, rowId, messageId, state) {
11035
+ try {
11036
+ await send(target, "PATCH", `/agents/log/${rowId}/messages/${messageId}`, { deliveryState: state });
11037
+ return true;
11038
+ } catch {
11039
+ return false;
11040
+ }
11041
+ }
11042
+ async function postMessage(target, rowId, text2) {
11043
+ return post(target, `/agents/log/${rowId}/messages`, { text: text2 });
11044
+ }
11045
+ async function fetchPendingMessages(target, workItem) {
11046
+ try {
11047
+ const res = await request(
11048
+ target,
11049
+ "GET",
11050
+ `/workspaces/${target.workspaceId}/agents/log/pending-messages?workItem=${encodeURIComponent(`${workItem.table}:${workItem.recordId}`)}`
11051
+ );
11052
+ return Array.isArray(res.messages) ? res.messages : [];
11053
+ } catch {
11054
+ return [];
11055
+ }
11056
+ }
11057
+ async function memberNames(target) {
11058
+ const names = /* @__PURE__ */ new Map();
11059
+ try {
11060
+ const rows = await request(target, "GET", `/workspaces/${target.workspaceId}/members`);
11061
+ for (const m of Array.isArray(rows) ? rows : []) {
11062
+ const n = m.name || m.email;
11063
+ if (n) names.set(m.id, n);
11064
+ }
11065
+ } catch {
11066
+ }
11067
+ return names;
11068
+ }
11069
+ function frameNote(m, author2) {
11070
+ return `Note from ${author2 ?? "the operator"} (operator): ${m.text}`;
11071
+ }
11072
+ function operatorNotesSection(notes, names) {
11073
+ if (notes.length === 0) return "";
11074
+ const lines2 = notes.map((m) => {
11075
+ const who2 = m.authorId && names.get(m.authorId) || "the operator";
11076
+ return `- ${m.occurredAt ?? "earlier"} \u2014 ${who2}: ${m.text.replace(/\n/g, "\n ")}`;
11077
+ });
11078
+ return [
11079
+ "## Operator notes since the last run",
11080
+ "",
11081
+ "A person responsible for this work left these notes while no run could read them. They carry the operator's authority, within the limits of your persona and the rules above; acknowledge them in your first text turn.",
11082
+ "",
11083
+ ...lines2
11084
+ ].join("\n");
11085
+ }
11021
11086
  var CYCLE_BODY_LIMIT_BYTES = 2048;
11022
11087
  var CYCLE_TRUNCATION_MARKER = " \u2026[truncated]";
11023
11088
  var MAX_CYCLES_PER_BATCH = 200;
@@ -11034,6 +11099,7 @@ var LiveRunReporter = class {
11034
11099
  live = true;
11035
11100
  nextIndex = 0;
11036
11101
  pending = [];
11102
+ seenMessages = /* @__PURE__ */ new Set();
11037
11103
  lastSent = Date.now();
11038
11104
  timer;
11039
11105
  inFlight = Promise.resolve();
@@ -11075,12 +11141,22 @@ var LiveRunReporter = class {
11075
11141
  this.timer = void 0;
11076
11142
  await this.inFlight;
11077
11143
  }
11144
+ /** Passes the response's not-yet-seen notes to `onMessages`. A failing callback never disturbs reporting. */
11145
+ async handOver(res) {
11146
+ const fresh = (Array.isArray(res?.pendingMessages) ? res.pendingMessages : []).filter((m) => m && typeof m.id === "string" && !this.seenMessages.has(m.id));
11147
+ if (fresh.length === 0 || !this.o.onMessages) return;
11148
+ for (const m of fresh) this.seenMessages.add(m.id);
11149
+ try {
11150
+ await this.o.onMessages(fresh);
11151
+ } catch {
11152
+ }
11153
+ }
11078
11154
  async step() {
11079
11155
  if (!this.live) return;
11080
11156
  try {
11081
11157
  if (this.pending.length > 0) {
11082
11158
  const batch = this.pending.slice(0, MAX_CYCLES_PER_BATCH);
11083
- await post(this.target, `/agents/log/${this.rowId}/cycles`, batch.map((c) => ({
11159
+ const res = await post(this.target, `/agents/log/${this.rowId}/cycles`, batch.map((c) => ({
11084
11160
  cycleIndex: c.cycleIndex,
11085
11161
  occurredAt: c.occurredAt,
11086
11162
  thinking: c.thinking,
@@ -11090,9 +11166,11 @@ var LiveRunReporter = class {
11090
11166
  this.posted = batch[batch.length - 1].cycleIndex + 1;
11091
11167
  this.lastSent = Date.now();
11092
11168
  this.o.onPosted?.(this.posted);
11169
+ await this.handOver(res);
11093
11170
  } else if (Date.now() - this.lastSent >= this.heartbeatMs) {
11094
- await send(this.target, "PATCH", `/agents/log/${this.rowId}`, {});
11171
+ const res = await send(this.target, "PATCH", `/agents/log/${this.rowId}`, {});
11095
11172
  this.lastSent = Date.now();
11173
+ await this.handOver(res);
11096
11174
  }
11097
11175
  } catch (e) {
11098
11176
  if (e instanceof AgentLogHttpError && e.status < 500) {
@@ -13269,8 +13347,10 @@ function planAgentRun(o) {
13269
13347
  const sandboxChoice = o.ship.runner === "sandbox" ? sandboxImageOf(o.route, o.repo, o.stateDir, o.repoContract) : void 0;
13270
13348
  const sandboxImage = sandboxChoice?.image;
13271
13349
  const sandboxFiles = [...code?.files ?? [], ...sandboxLsp?.files ?? []];
13350
+ const streamInput = adapter.userMessageLine !== void 0 && o.ship.runner !== "sandbox";
13272
13351
  const invocation = adapter.invocation(toolchain, {
13273
13352
  code,
13353
+ streamInput,
13274
13354
  role: o.role,
13275
13355
  model,
13276
13356
  pluginDirs: adapter.harness !== "claude" ? void 0 : sandboxLsp ? [sandboxLsp.dir] : lspPluginDirsFor(o.route, o.repo, o.stateDir),
@@ -13331,6 +13411,7 @@ function planAgentRun(o) {
13331
13411
  } : {},
13332
13412
  resolution: { toolchain: seat.toolchainWhy, model: seat.modelWhy },
13333
13413
  warnings: [...seat.warnings ?? [], ...expanded.warnings],
13414
+ ...streamInput ? { acceptsInput: true } : {},
13334
13415
  prompt,
13335
13416
  promptBytes: Buffer.byteLength(prompt, "utf8"),
13336
13417
  unsetEnv: adapter.unsetEnv,
@@ -13503,6 +13584,8 @@ var RunObserver = class {
13503
13584
  * ticket the run actually claims (CREW-1776); `id.ticket` stays the hint.
13504
13585
  */
13505
13586
  liveTicket;
13587
+ /** CREW-3118: called when the stream first carries the harness's final result, e.g. to close a streaming stdin. */
13588
+ onResult;
13506
13589
  /** Called after `liveTicket` changes, so the sidecar can be rewritten. */
13507
13590
  onClaim;
13508
13591
  buf = "";
@@ -13551,7 +13634,11 @@ var RunObserver = class {
13551
13634
  const got = this.adapter.extractResult(parsed);
13552
13635
  if (got) {
13553
13636
  this.result = { ...this.result, ...Object.fromEntries(Object.entries(got).filter(([, v]) => v !== void 0)) };
13554
- if (got.numTurns !== void 0 || got.costUsd !== void 0) this.sawResult = true;
13637
+ if (got.numTurns !== void 0 || got.costUsd !== void 0) {
13638
+ const first = !this.sawResult;
13639
+ this.sawResult = true;
13640
+ if (first && !this.muted) this.onResult?.();
13641
+ }
13555
13642
  }
13556
13643
  this.handoff.feed(parsed);
13557
13644
  this.consume(parsed, this.mapper.map(parsed));
@@ -13820,7 +13907,36 @@ async function finishRun(id, obs, emit, startedAt, end, agentLogKey, hintMoved)
13820
13907
  }
13821
13908
  return { ms: ms3, ticket: attributedTicket, handoffPending: !!pending };
13822
13909
  }
13910
+ async function deliverNotes(target, rowId, msgs, write) {
13911
+ const names = await memberNames(target);
13912
+ for (const m of msgs) {
13913
+ const landed = await write(frameNote(m, m.authorId && names.get(m.authorId) || void 0));
13914
+ await markMessage(target, rowId, m.id, landed ? "delivered" : "carried_forward");
13915
+ }
13916
+ }
13917
+ async function withOperatorNotes(plan) {
13918
+ const log = plan.agentLog;
13919
+ const issues = log?.tickets?.issuesModelId;
13920
+ if (!log || !issues || !plan.ticketRecordId) return plan;
13921
+ const notes = await fetchPendingMessages(log, { table: issues, recordId: plan.ticketRecordId });
13922
+ if (notes.length === 0) return plan;
13923
+ const section = operatorNotesSection(notes, await memberNames(log));
13924
+ const prompt = `${plan.prompt}
13925
+
13926
+ ${section}
13927
+ `;
13928
+ await Promise.all(notes.map((m) => m.agentLogId ? markMessage(log, m.agentLogId, m.id, "delivered") : Promise.resolve(false)));
13929
+ return { ...plan, prompt, promptBytes: Buffer.byteLength(prompt, "utf8") };
13930
+ }
13931
+ function streamsInput(plan) {
13932
+ const i = plan.args.indexOf("--input-format");
13933
+ return !!plan.acceptsInput && i >= 0 && plan.args[i + 1] === "stream-json";
13934
+ }
13823
13935
  function spawnAgent(plan, emit, hintMoved) {
13936
+ if (!plan.agentLog?.tickets || !plan.ticketRecordId) return spawnPlanned(plan, emit, hintMoved);
13937
+ return withOperatorNotes(plan).catch(() => plan).then((p) => spawnPlanned(p, emit, hintMoved));
13938
+ }
13939
+ function spawnPlanned(plan, emit, hintMoved) {
13824
13940
  const adapter = adapterFor(plan.harness ?? LEGACY_TOOLCHAIN_HARNESS);
13825
13941
  const runner = runnerFor(plan.runner, plan.sandboxConfig);
13826
13942
  const started = Date.now();
@@ -13886,7 +14002,8 @@ function spawnAgent(plan, emit, hintMoved) {
13886
14002
  agentLog: id.agentLog,
13887
14003
  promptVersion: plan.promptVersion,
13888
14004
  promptSha: plan.promptSha,
13889
- ...plan.workspaceRunId ? { workspaceRunId: plan.workspaceRunId } : {}
14005
+ ...plan.workspaceRunId ? { workspaceRunId: plan.workspaceRunId } : {},
14006
+ ...streamsInput(plan) && !promptDelivered && adapter.userMessageLine ? { acceptsInput: true } : {}
13890
14007
  };
13891
14008
  try {
13892
14009
  writeFileSync22(pidPathFor(plan.streamPath), JSON.stringify(sidecar));
@@ -13894,6 +14011,43 @@ function spawnAgent(plan, emit, hintMoved) {
13894
14011
  }
13895
14012
  }
13896
14013
  const obs = new RunObserver(id, adapter, eventsSink, emit.cycle);
14014
+ let inputOpen = streamsInput(plan) && !promptDelivered && !!adapter.userMessageLine;
14015
+ const closeInput = () => {
14016
+ if (!inputOpen) return;
14017
+ inputOpen = false;
14018
+ updateSidecar(plan.streamPath, { acceptsInput: false });
14019
+ child.stdin?.end();
14020
+ };
14021
+ if (inputOpen) obs.onResult = closeInput;
14022
+ const handled2 = /* @__PURE__ */ new Set();
14023
+ const writeNote = (text2) => new Promise((done) => {
14024
+ const stdin = child.stdin;
14025
+ if (!inputOpen || !stdin || !stdin.writable) {
14026
+ done(false);
14027
+ return;
14028
+ }
14029
+ try {
14030
+ stdin.write(adapter.userMessageLine(text2), (err3) => done(!err3));
14031
+ } catch {
14032
+ done(false);
14033
+ }
14034
+ });
14035
+ const runName = basename9(plan.streamPath).replace(/\.jsonl$/, "");
14036
+ if (inputOpen) {
14037
+ registerRunInput(runName, {
14038
+ accepts: () => inputOpen,
14039
+ agentLogRowId: () => id.agentLogRowId,
14040
+ ...plan.agentLog ? { target: plan.agentLog } : {},
14041
+ deliver: async (note, author2) => {
14042
+ if (handled2.has(note.id)) return "delivered";
14043
+ handled2.add(note.id);
14044
+ const landed = await writeNote(frameNote(note, author2));
14045
+ const rowId = id.agentLogRowId;
14046
+ if (plan.agentLog && rowId) await markMessage(plan.agentLog, rowId, note.id, landed ? "delivered" : "carried_forward");
14047
+ return landed ? "delivered" : "carried_forward";
14048
+ }
14049
+ });
14050
+ }
13897
14051
  const startedRow = plan.agentLog ? startAgentRunRow(plan.agentLog, {
13898
14052
  runId: plan.workspaceRunId,
13899
14053
  ticketReference: plan.ticket ?? void 0,
@@ -13910,7 +14064,12 @@ function spawnAgent(plan, emit, hintMoved) {
13910
14064
  updateSidecar(plan.streamPath, { agentLogRowId: row.id });
13911
14065
  if (row.live && plan.agentLog) {
13912
14066
  const reporter = new LiveRunReporter(plan.agentLog, row.id, {
13913
- onPosted: (n) => updateSidecar(plan.streamPath, { cyclesPosted: n })
14067
+ onPosted: (n) => updateSidecar(plan.streamPath, { cyclesPosted: n }),
14068
+ onMessages: (msgs) => {
14069
+ const fresh = msgs.filter((m) => !handled2.has(m.id));
14070
+ for (const m of fresh) handled2.add(m.id);
14071
+ return deliverNotes(plan.agentLog, row.id, fresh, writeNote);
14072
+ }
13914
14073
  });
13915
14074
  obs.attachReporter(reporter);
13916
14075
  reporter.start();
@@ -13930,12 +14089,15 @@ function spawnAgent(plan, emit, hintMoved) {
13930
14089
  let spawnFailed = false;
13931
14090
  child.on("error", (err3) => {
13932
14091
  spawnFailed = true;
14092
+ unregisterRunInput(runName);
13933
14093
  clearInterval(timer);
13934
14094
  clearTimeout(limitTimer);
13935
14095
  void runner.release(handle, emit);
13936
14096
  reject(new AgentSpawnError(`cannot run ${plan.bin}: ${err3.message}`));
13937
14097
  });
13938
14098
  child.on("close", async (code) => {
14099
+ inputOpen = false;
14100
+ unregisterRunInput(runName);
13939
14101
  clearInterval(timer);
13940
14102
  clearTimeout(limitTimer);
13941
14103
  obs.feed(tail3.poll());
@@ -13963,7 +14125,9 @@ function spawnAgent(plan, emit, hintMoved) {
13963
14125
  emit.warn(`agent closed stdin before the prompt was delivered: ${err3.message}`, { step: "agent" });
13964
14126
  });
13965
14127
  if (promptDelivered) child.stdin?.end();
13966
- else child.stdin?.end(plan.prompt);
14128
+ else if (inputOpen) {
14129
+ child.stdin?.write(adapter.userMessageLine(plan.prompt));
14130
+ } else child.stdin?.end(plan.prompt);
13967
14131
  });
13968
14132
  }
13969
14133
  }
@@ -13978,8 +14142,11 @@ async function reattachRun(streamPath, sc, emit, o = {}) {
13978
14142
  obs.feed(tail3.poll());
13979
14143
  obs.muted = false;
13980
14144
  if (sc.agentLogRowId && sc.agentLog && o.agentLogKey) {
13981
- const reporter = new LiveRunReporter({ ...sc.agentLog, apiKey: o.agentLogKey }, sc.agentLogRowId, {
13982
- onPosted: (n) => updateSidecar(streamPath, { cyclesPosted: n })
14145
+ const logTarget = { ...sc.agentLog, apiKey: o.agentLogKey };
14146
+ const reporter = new LiveRunReporter(logTarget, sc.agentLogRowId, {
14147
+ onPosted: (n) => updateSidecar(streamPath, { cyclesPosted: n }),
14148
+ // CREW-3118: the adopted run's stdin belongs to the process that died, so a note can only be carried forward.
14149
+ onMessages: (msgs) => deliverNotes(logTarget, sc.agentLogRowId, msgs, async () => false)
13983
14150
  }, sc.cyclesPosted ?? 0);
13984
14151
  obs.attachReporter(reporter);
13985
14152
  reporter.start();
@@ -14164,6 +14331,14 @@ async function settleRunEnd(o) {
14164
14331
  emit.warn(`could not beat ship idle: ${e.message}`, { step: "agent" });
14165
14332
  }
14166
14333
  }
14334
+ function pidAlive2(pid) {
14335
+ try {
14336
+ process.kill(pid, 0);
14337
+ return true;
14338
+ } catch (e) {
14339
+ return e.code === "EPERM";
14340
+ }
14341
+ }
14167
14342
  function describeRun(run4, route2, seatIds, worktreeOf = (d, n) => {
14168
14343
  try {
14169
14344
  return worktreeForNumber(d, n)?.path ?? null;
@@ -14184,7 +14359,10 @@ function describeRun(run4, route2, seatIds, worktreeOf = (d, n) => {
14184
14359
  stream: run4.streamPath,
14185
14360
  pid: run4.pid,
14186
14361
  startedAt: run4.spawnedAt,
14187
- deadline: run4.deadline ?? null
14362
+ deadline: run4.deadline ?? null,
14363
+ // CREW-3119: the harness still reads notes, and the process holding its stdin is alive.
14364
+ acceptsInput: !!run4.acceptsInput && pidAlive2(run4.ownerPid),
14365
+ agentLogId: run4.agentLogRowId ?? null
14188
14366
  };
14189
14367
  }
14190
14368
 
@@ -15339,7 +15517,7 @@ function doctorSelftestLines(stored, toolchains) {
15339
15517
  }
15340
15518
 
15341
15519
  // src/cli.ts
15342
- import { resolve as resolve7, dirname as dirname37, join as join60, basename as basename16 } from "path";
15520
+ import { resolve as resolve7, dirname as dirname37, join as join61, basename as basename16 } from "path";
15343
15521
  import { fileURLToPath as fileURLToPath2 } from "url";
15344
15522
  import { hostname as hostname5, homedir as homedir11, userInfo as userInfo2 } from "os";
15345
15523
  import { spawnSync as spawnSync13 } from "child_process";
@@ -19997,11 +20175,11 @@ async function confirmExternalReleased(o, closures) {
19997
20175
  }
19998
20176
  const { timeoutSeconds, intervalSeconds } = o.repo.release.verify;
19999
20177
  const deadline = Date.now() + timeoutSeconds * 1e3;
20000
- let live = "";
20178
+ let live2 = "";
20001
20179
  for (; ; ) {
20002
20180
  const r = await hook(o, "released");
20003
- live = r?.output.trim().split("\n").filter(Boolean).pop() ?? "";
20004
- if (live) break;
20181
+ live2 = r?.output.trim().split("\n").filter(Boolean).pop() ?? "";
20182
+ if (live2) break;
20005
20183
  if (Date.now() >= deadline) {
20006
20184
  o.emit.warn(`not confirmed within ${timeoutSeconds}s \u2014 the released hook reported nothing`);
20007
20185
  return closures;
@@ -20010,13 +20188,13 @@ async function confirmExternalReleased(o, closures) {
20010
20188
  }
20011
20189
  return closures.map((c) => {
20012
20190
  if (c.closure.state !== "merged" || !c.closure.mergedAt) return c;
20013
- const confirmed = isAncestor(o.cwd, c.closure.mergedAt, live);
20191
+ const confirmed = isAncestor(o.cwd, c.closure.mergedAt, live2);
20014
20192
  if (!confirmed) {
20015
- o.emit.emit(`not yet carried by ${live.slice(0, 12)}`, { ticket: c.ticket.issue_id });
20193
+ o.emit.emit(`not yet carried by ${live2.slice(0, 12)}`, { ticket: c.ticket.issue_id });
20016
20194
  return { ...c, confirmed };
20017
20195
  }
20018
20196
  const version = o.repo.release.versioning === "none" || !o.repo.release.versionFiles[0] ? void 0 : (() => {
20019
- const content = fileAtRef(o.cwd, live, o.repo.release.versionFiles[0]);
20197
+ const content = fileAtRef(o.cwd, live2, o.repo.release.versionFiles[0]);
20020
20198
  if (!content) return void 0;
20021
20199
  try {
20022
20200
  return JSON.parse(content).version;
@@ -20024,7 +20202,7 @@ async function confirmExternalReleased(o, closures) {
20024
20202
  return void 0;
20025
20203
  }
20026
20204
  })();
20027
- o.emit.emit(`confirmed shipped in ${live.slice(0, 12)}`, { ticket: c.ticket.issue_id, data: { version } });
20205
+ o.emit.emit(`confirmed shipped in ${live2.slice(0, 12)}`, { ticket: c.ticket.issue_id, data: { version } });
20028
20206
  return { ...c, confirmed, version };
20029
20207
  });
20030
20208
  }
@@ -20179,14 +20357,14 @@ async function confirm(o, expected) {
20179
20357
  const deadline = Date.now() + timeoutSeconds * 1e3;
20180
20358
  for (; ; ) {
20181
20359
  const r = await hook(o, "released");
20182
- const live = r?.output.trim().split("\n").filter(Boolean).pop() ?? "";
20183
- const hit = match === "commit" ? live.startsWith(expected.slice(0, 7)) || expected.startsWith(live.slice(0, 7)) : live === expected;
20184
- if (live && hit) {
20185
- o.emit.emit(`confirmed live: ${live.slice(0, 12)}`);
20360
+ const live2 = r?.output.trim().split("\n").filter(Boolean).pop() ?? "";
20361
+ const hit = match === "commit" ? live2.startsWith(expected.slice(0, 7)) || expected.startsWith(live2.slice(0, 7)) : live2 === expected;
20362
+ if (live2 && hit) {
20363
+ o.emit.emit(`confirmed live: ${live2.slice(0, 12)}`);
20186
20364
  return true;
20187
20365
  }
20188
20366
  if (Date.now() >= deadline) {
20189
- o.emit.warn(`not confirmed within ${timeoutSeconds}s \u2014 target reports ${live || "nothing"}`);
20367
+ o.emit.warn(`not confirmed within ${timeoutSeconds}s \u2014 target reports ${live2 || "nothing"}`);
20190
20368
  return false;
20191
20369
  }
20192
20370
  await new Promise((r2) => setTimeout(r2, intervalSeconds * 1e3));
@@ -21624,9 +21802,9 @@ var PeriscopeError = class extends Error {
21624
21802
  };
21625
21803
  var LivePeriscopeError = class extends PeriscopeError {
21626
21804
  data;
21627
- constructor(tag, number, live) {
21628
- super(`${tag} already has a live periscope on ${live.ship}: ${live.url} (worktree ${live.worktree}) \u2014 run \`crew periscope down ${number} --keep|--discard\` on ${live.ship}, or resume it there with \`crew periscope up --resume ${number}\``);
21629
- this.data = { refused: "live_periscope_exists", ...live };
21805
+ constructor(tag, number, live2) {
21806
+ super(`${tag} already has a live periscope on ${live2.ship}: ${live2.url} (worktree ${live2.worktree}) \u2014 run \`crew periscope down ${number} --keep|--discard\` on ${live2.ship}, or resume it there with \`crew periscope up --resume ${number}\``);
21807
+ this.data = { refused: "live_periscope_exists", ...live2 };
21630
21808
  }
21631
21809
  };
21632
21810
  var priorDir = (stateDir) => join49(stateDir, "periscope-priors");
@@ -21698,8 +21876,8 @@ function periscopeCaps(l) {
21698
21876
  };
21699
21877
  }
21700
21878
  async function assertNoLivePeriscope(e, t, number) {
21701
- const live = (await e.liveRows(t.id))[0];
21702
- if (live) throw new LivePeriscopeError(t.tag, number, live);
21879
+ const live2 = (await e.liveRows(t.id))[0];
21880
+ if (live2) throw new LivePeriscopeError(t.tag, number, live2);
21703
21881
  }
21704
21882
  async function existingRefusal(e, t) {
21705
21883
  if (t.closed) return `${t.tag} is ${t.status}; a closed ticket cannot be periscoped`;
@@ -21748,9 +21926,9 @@ async function periscopePreflight(d, repo) {
21748
21926
  if (!d.hasPeriscopesTable) {
21749
21927
  throw new PeriscopeError("this workspace has no Periscopes table \u2014 update the Issues template and run `crew connect`");
21750
21928
  }
21751
- const live = await d.liveCount();
21752
- if (live >= d.caps.max) {
21753
- throw new PeriscopeError(`this ship already hosts ${live} live periscope(s) (ship.maxPeriscopes is ${d.caps.max}) \u2014 discard one first`);
21929
+ const live2 = await d.liveCount();
21930
+ if (live2 >= d.caps.max) {
21931
+ throw new PeriscopeError(`this ship already hosts ${live2} live periscope(s) (ship.maxPeriscopes is ${d.caps.max}) \u2014 discard one first`);
21754
21932
  }
21755
21933
  }
21756
21934
  async function runPeriscopeUp(d, args) {
@@ -22490,23 +22668,23 @@ async function runFleetPass(o) {
22490
22668
  decide: (c) => decide({ ...ctxs.get(c.route.route), emit: c.emit })
22491
22669
  });
22492
22670
  if (fleet.entries.length && fleet.entries.every((e) => e.error)) throw new Error(fleet.entries[0].error);
22493
- const live = [];
22671
+ const live2 = [];
22494
22672
  for (const e of fleet.entries) {
22495
22673
  const ctx = ctxs.get(e.route.route);
22496
22674
  if (e.error || !e.decision) continue;
22497
22675
  await applyRouteDecision(perRoute(e.route), ctx, e.decision);
22498
- live.push({ ctx, decision: e.decision, roles: e.decision.selection.pending });
22676
+ live2.push({ ctx, decision: e.decision, roles: e.decision.selection.pending });
22499
22677
  }
22500
- await Promise.all(live.map(async ({ ctx }) => {
22678
+ await Promise.all(live2.map(async ({ ctx }) => {
22501
22679
  try {
22502
22680
  await new Tracker(ctx.route, o.ship).beatShip(o.ship.name);
22503
22681
  } catch (e) {
22504
22682
  ctx.emit.warn(`could not beat ship for ${ctx.route.route}: ${e.message}`, { step: "poll" });
22505
22683
  }
22506
22684
  }));
22507
- const { started, skipped } = await fillSlots(o, live, fleet.winner && { route: fleet.winner.route.route, role: fleet.winner.role });
22508
- for (const { ctx } of live) await publishShipAttention(o.state, ctx.route, o.ship);
22509
- return { pending: [...new Set(live.flatMap((l) => l.roles))], started, skipped };
22685
+ const { started, skipped } = await fillSlots(o, live2, fleet.winner && { route: fleet.winner.route.route, role: fleet.winner.role });
22686
+ for (const { ctx } of live2) await publishShipAttention(o.state, ctx.route, o.ship);
22687
+ return { pending: [...new Set(live2.flatMap((l) => l.roles))], started, skipped };
22510
22688
  } catch (e) {
22511
22689
  if (!isUpgradeRequired(e)) throw e;
22512
22690
  const route2 = routes[0];
@@ -22525,10 +22703,10 @@ async function fillSlots(o, routes, first) {
22525
22703
  const started = [];
22526
22704
  const skipped = [];
22527
22705
  const roleCap = (role) => TICKET_ROLES.has(role) ? o.roleConcurrency?.[role] ?? 1 : 1;
22528
- const live = new Map(order.map((c) => [c, 0]));
22529
- while (live.size) {
22706
+ const live2 = new Map(order.map((c) => [c, 0]));
22707
+ while (live2.size) {
22530
22708
  for (const cand of order) {
22531
- const count = live.get(cand);
22709
+ const count = live2.get(cand);
22532
22710
  if (count === void 0) continue;
22533
22711
  const { role, ctx, decision } = cand;
22534
22712
  const skip = (reason) => {
@@ -22537,20 +22715,20 @@ async function fillSlots(o, routes, first) {
22537
22715
  if (openShipAttention(state).some((i) => i.key === seatCannotWriteKey(role))) {
22538
22716
  if (await (o.seatWriteRefused ?? ((r) => seatWriteStillRefused(ctx.route, r, { userAgent: o.ship.userAgent })))(role)) {
22539
22717
  skip("seat role cannot write the hand-off fields \u2014 see attention");
22540
- live.delete(cand);
22718
+ live2.delete(cand);
22541
22719
  continue;
22542
22720
  }
22543
22721
  clearShipAttention(state, seatCannotWriteKey(role));
22544
22722
  }
22545
22723
  if (!breaker.allows(role)) {
22546
22724
  skip("agent recently failed to start \u2014 waiting before retry");
22547
- live.delete(cand);
22725
+ live2.delete(cand);
22548
22726
  continue;
22549
22727
  }
22550
22728
  const lock = state.acquireRun(role, o.maxConcurrentAgents, roleCap(role));
22551
22729
  if (!lock.ok) {
22552
22730
  skip(lock.reason);
22553
- live.delete(cand);
22731
+ live2.delete(cand);
22554
22732
  continue;
22555
22733
  }
22556
22734
  let settle = () => {
@@ -22621,11 +22799,11 @@ async function fillSlots(o, routes, first) {
22621
22799
  const tookTicket = reported2 !== false;
22622
22800
  if (tookTicket) started.push(role);
22623
22801
  if (roleCap(role) <= 1) {
22624
- live.delete(cand);
22802
+ live2.delete(cand);
22625
22803
  continue;
22626
22804
  }
22627
- if (tookTicket && count + 1 < roleCap(role)) live.set(cand, count + 1);
22628
- else live.delete(cand);
22805
+ if (tookTicket && count + 1 < roleCap(role)) live2.set(cand, count + 1);
22806
+ else live2.delete(cand);
22629
22807
  }
22630
22808
  }
22631
22809
  return { started, skipped };
@@ -23574,10 +23752,10 @@ function nonReleaserNote(repo, releaser) {
23574
23752
  }
23575
23753
  function missingReleaserWarning(repo, release, ships, now = Date.now()) {
23576
23754
  if (release.ship || release.mode !== "local" && release.mode !== "integrate") return null;
23577
- const live = ships.filter((s) => s.last_seen && now - Date.parse(s.last_seen) <= DAY_MS);
23578
- if (live.length < 2) return null;
23579
- const names = live.map((s) => s.name ?? "?").join(", ");
23580
- return `${repo}: release.mode "${release.mode}" with no release.ship, and ${live.length} ships seen in the last day (${names}) \u2014 every one of them will try to release it. Set release.ship in .crew.yaml.`;
23755
+ const live2 = ships.filter((s) => s.last_seen && now - Date.parse(s.last_seen) <= DAY_MS);
23756
+ if (live2.length < 2) return null;
23757
+ const names = live2.map((s) => s.name ?? "?").join(", ");
23758
+ return `${repo}: release.mode "${release.mode}" with no release.ship, and ${live2.length} ships seen in the last day (${names}) \u2014 every one of them will try to release it. Set release.ship in .crew.yaml.`;
23581
23759
  }
23582
23760
 
23583
23761
  // src/watch.ts
@@ -24452,8 +24630,77 @@ function describeCapability(i) {
24452
24630
  return `missing ${missLine(i)}`;
24453
24631
  }
24454
24632
 
24633
+ // src/persona-avatars.ts
24634
+ import { existsSync as existsSync51, readFileSync as readFileSync47 } from "fs";
24635
+ import { join as join52 } from "path";
24636
+ var IMAGE_TYPES = { png: "image/png", svg: "image/svg+xml" };
24637
+ function personaAvatarFile(promptsDir, role) {
24638
+ for (const ext of ["png", "svg"]) {
24639
+ const name = `lane-${role}.${ext}`;
24640
+ const path = join52(promptsDir, "personas", name);
24641
+ if (existsSync51(path)) return { path, mimeType: IMAGE_TYPES[ext], name };
24642
+ }
24643
+ return void 0;
24644
+ }
24645
+ async function syncPersonaAvatars(route2, agentPersonas, opts) {
24646
+ if (!route2.resolved) return [];
24647
+ const base = `${route2.baseUrl.replace(/\/+$/, "")}/api/workspaces/${route2.resolved.workspaceId}/agents/personas`;
24648
+ const outcomes = [];
24649
+ for (const role of ROLE_NAMES) {
24650
+ const file = personaAvatarFile(route2.promptsDir, role);
24651
+ const agentId = agentPersonas[role]?.agentId;
24652
+ if (!file || !agentId) continue;
24653
+ try {
24654
+ const form = new FormData();
24655
+ form.append("file", new Blob([readFileSync47(file.path)], { type: file.mimeType }), file.name);
24656
+ const res = await fetch(`${base}/${agentId}/avatar`, {
24657
+ method: "PUT",
24658
+ headers: { Authorization: `Bearer ${resolveApiKey(route2)}`, "User-Agent": opts.userAgent ?? "Mozilla/5.0 TablationCrewAgent/1.0" },
24659
+ body: form
24660
+ });
24661
+ if (!res.ok) {
24662
+ outcomes.push({ role, status: "failed", detail: `${res.status} ${(await res.text()).slice(0, 200)}`.trim() });
24663
+ continue;
24664
+ }
24665
+ const body = await res.json();
24666
+ if (body.status === "updated" || body.status === "unchanged" || body.status === "skipped") {
24667
+ outcomes.push({ role, status: body.status, ...body.reason ? { detail: body.reason } : {} });
24668
+ } else {
24669
+ outcomes.push({ role, status: "failed", detail: "unrecognised response" });
24670
+ }
24671
+ } catch (e) {
24672
+ outcomes.push({ role, status: "failed", detail: e instanceof Error ? e.message : String(e) });
24673
+ }
24674
+ }
24675
+ return outcomes;
24676
+ }
24677
+ function describeAvatarOutcome(o, label) {
24678
+ switch (o.status) {
24679
+ case "updated":
24680
+ return `${label}: avatar uploaded`;
24681
+ case "unchanged":
24682
+ return `${label}: avatar already current`;
24683
+ case "skipped":
24684
+ return `${label}: avatar left alone${o.detail ? ` (${o.detail})` : ""}`;
24685
+ case "failed":
24686
+ return `${label}: avatar upload failed \u2014 ${o.detail ?? "unknown error"}`;
24687
+ }
24688
+ }
24689
+ function avatarFailures(raw) {
24690
+ const map = raw?.avatarSyncFailures;
24691
+ if (!map || typeof map !== "object") return [];
24692
+ return Object.entries(map).map(([role, detail]) => ({ role, detail: String(detail) }));
24693
+ }
24694
+ function routeAvatarFailures(stateDir, route2) {
24695
+ try {
24696
+ return avatarFailures(JSON.parse(readFileSync47(resolvedPathFor(stateDir, route2), "utf8")));
24697
+ } catch {
24698
+ return [];
24699
+ }
24700
+ }
24701
+
24455
24702
  // src/agents-sync-run.ts
24456
- import { existsSync as existsSync51, mkdirSync as mkdirSync38, readFileSync as readFileSync47, writeFileSync as writeFileSync39 } from "fs";
24703
+ import { existsSync as existsSync52, mkdirSync as mkdirSync38, readFileSync as readFileSync48, writeFileSync as writeFileSync39 } from "fs";
24457
24704
  import { dirname as dirname31 } from "path";
24458
24705
  async function runAgentsSync(target, o) {
24459
24706
  const dryRun = o.dryRun ?? false;
@@ -24487,11 +24734,22 @@ async function runAgentsSync(target, o) {
24487
24734
  }
24488
24735
  for (const s of skillResult?.outcomes ?? []) o.say(describeSkillSyncOutcome(s));
24489
24736
  for (const w of skillResult?.warnings ?? []) o.warn(`warning: ${w}`);
24737
+ const avatarFailures2 = {};
24738
+ if (!readOnly && !dryRun) {
24739
+ for (const a of await syncPersonaAvatars(target, personaResult.agentPersonas, { userAgent: o.userAgent })) {
24740
+ const line = describeAvatarOutcome(a, PERSONA_NAME[a.role]);
24741
+ if (a.status === "failed") {
24742
+ o.warn(`warning: ${line}`);
24743
+ avatarFailures2[a.role] = a.detail ?? "unknown error";
24744
+ } else o.say(line);
24745
+ }
24746
+ }
24490
24747
  if (!dryRun) {
24491
24748
  const resolvedPath = resolvedPathFor(o.stateDir, target.route);
24492
- const raw = existsSync51(resolvedPath) ? JSON.parse(readFileSync47(resolvedPath, "utf8")) : {};
24749
+ const raw = existsSync52(resolvedPath) ? JSON.parse(readFileSync48(resolvedPath, "utf8")) : {};
24493
24750
  raw.agentPersonas = personaResult.agentPersonas;
24494
24751
  if (skillResult) raw.agentSkills = skillResult.agentSkills;
24752
+ if (!readOnly) raw.avatarSyncFailures = avatarFailures2;
24495
24753
  if (personaResult.releaseAgentId) raw.releaseAgentId = personaResult.releaseAgentId;
24496
24754
  mkdirSync38(dirname31(resolvedPath), { recursive: true });
24497
24755
  writeFileSync39(resolvedPath, `${JSON.stringify(raw, null, 2)}
@@ -24631,7 +24889,7 @@ async function showLogEntry(route2, entryId, opts = {}) {
24631
24889
 
24632
24890
  // src/repos-check.ts
24633
24891
  import { spawnSync as spawnSync12 } from "child_process";
24634
- import { readFileSync as readFileSync48 } from "fs";
24892
+ import { readFileSync as readFileSync49 } from "fs";
24635
24893
  import { basename as basename11 } from "path";
24636
24894
  var POSIX_SHELL = /^(?:ba|z|da|k|a|mk)?sh$|^fish$/;
24637
24895
  function checkHookSyntax(script, shell) {
@@ -24672,7 +24930,7 @@ function checkRepoSpec(dir, opts = {}) {
24672
24930
  }
24673
24931
  let parsed;
24674
24932
  try {
24675
- parsed = parseRepoConfig(readFileSync48(file, "utf8"), file);
24933
+ parsed = parseRepoConfig(readFileSync49(file, "utf8"), file);
24676
24934
  } catch (e) {
24677
24935
  if (!(e instanceof RepoConfigError)) throw e;
24678
24936
  return { ...empty, file, error: e.message, exitCode: 1 };
@@ -25136,7 +25394,7 @@ ${run4.err}` });
25136
25394
  }
25137
25395
 
25138
25396
  // src/sample-ticket.ts
25139
- import { basename as basename12, dirname as dirname32, join as join52 } from "path";
25397
+ import { basename as basename12, dirname as dirname32, join as join53 } from "path";
25140
25398
  var SAMPLE_REPO = "crew-sample";
25141
25399
  var SAMPLE_REMOTE = `local/${SAMPLE_REPO}`;
25142
25400
  var SAMPLE_MARKER = "sample: true";
@@ -25159,8 +25417,8 @@ has something safe to work on: its test and build hooks always pass, it has no
25159
25417
  remote, and \`crew sample-ticket --remove\` deletes it.
25160
25418
  `;
25161
25419
  function sampleDir(existing, reposBase, workspace) {
25162
- if (existing.length > 0) return join52(dirname32(existing[0]), SAMPLE_REPO);
25163
- return join52(reposBase, workspace, SAMPLE_REPO);
25420
+ if (existing.length > 0) return join53(dirname32(existing[0]), SAMPLE_REPO);
25421
+ return join53(reposBase, workspace, SAMPLE_REPO);
25164
25422
  }
25165
25423
  var SAMPLE_TITLE = "Sample: add a documented `greet` function with a test";
25166
25424
  function sampleDescription() {
@@ -25204,8 +25462,8 @@ function planSampleTicket(i) {
25204
25462
  }
25205
25463
 
25206
25464
  // src/worktree-sweep.ts
25207
- import { existsSync as existsSync52, readFileSync as readFileSync49, readdirSync as readdirSync15 } from "fs";
25208
- import { basename as basename13, dirname as dirname33, join as join53, resolve as resolve5 } from "path";
25465
+ import { existsSync as existsSync53, readFileSync as readFileSync50, readdirSync as readdirSync15 } from "fs";
25466
+ import { basename as basename13, dirname as dirname33, join as join54, resolve as resolve5 } from "path";
25209
25467
  function planWorktreeSweep(target, tickets, contract) {
25210
25468
  const terminal = new Set(contract.statuses.resolved.filter((s) => s !== contract.statuses.verified));
25211
25469
  const verified = contract.statuses.verified;
@@ -25282,7 +25540,7 @@ function siblingWorktreeDirs(target) {
25282
25540
  for (const name of names) {
25283
25541
  if (!name.startsWith(stem)) continue;
25284
25542
  const m = DIR_NUMBER_SUFFIXED.exec(name);
25285
- const path = join53(parent, name);
25543
+ const path = join54(parent, name);
25286
25544
  if (m && !registered.has(resolve5(path))) out.push({ path, number: m[1] });
25287
25545
  }
25288
25546
  return out;
@@ -25317,7 +25575,7 @@ async function applyWorktreeSweep(cwd, actions, dryRun, log, remote = "origin",
25317
25575
  let removed = 0;
25318
25576
  let keptBranches = 0;
25319
25577
  for (const a of actions) {
25320
- if (!dryRun && base && !a.keepBranch && existsSync52(a.path) && isHandBackMerge(a.path, base)) {
25578
+ if (!dryRun && base && !a.keepBranch && existsSync53(a.path) && isHandBackMerge(a.path, base)) {
25321
25579
  if (gitOk(a.path, ["merge", "--abort"]) !== null) {
25322
25580
  log.emit(
25323
25581
  `abandoned the hand-back merge of ${base} in ${a.path}: ${a.ticket.issue_id} deployed without it`,
@@ -25325,7 +25583,7 @@ async function applyWorktreeSweep(cwd, actions, dryRun, log, remote = "origin",
25325
25583
  );
25326
25584
  }
25327
25585
  }
25328
- if (!dryRun && existsSync52(a.path)) {
25586
+ if (!dryRun && existsSync53(a.path)) {
25329
25587
  let dirty = false;
25330
25588
  try {
25331
25589
  dirty = status(a.path).length > 0;
@@ -25336,7 +25594,7 @@ async function applyWorktreeSweep(cwd, actions, dryRun, log, remote = "origin",
25336
25594
  continue;
25337
25595
  }
25338
25596
  }
25339
- if (!dryRun && a.requirePushed && a.branch && existsSync52(a.path) && remoteConfigured(cwd, remote) && worktreeHoldsUnpushed(a.path, remote)) {
25597
+ if (!dryRun && a.requirePushed && a.branch && existsSync53(a.path) && remoteConfigured(cwd, remote) && worktreeHoldsUnpushed(a.path, remote)) {
25340
25598
  refuse2(a, "unpushed commits", `${a.branch} has commits that are not on ${remote}`);
25341
25599
  continue;
25342
25600
  }
@@ -25385,7 +25643,7 @@ function isHandBackMerge(path, base) {
25385
25643
  if (!msgPath) return false;
25386
25644
  let first;
25387
25645
  try {
25388
- first = readFileSync49(resolve5(path, msgPath), "utf8").split("\n")[0] ?? "";
25646
+ first = readFileSync50(resolve5(path, msgPath), "utf8").split("\n")[0] ?? "";
25389
25647
  } catch {
25390
25648
  return false;
25391
25649
  }
@@ -25490,14 +25748,14 @@ function applyRemoteBranchCleanup(cwd, remote, branches2, dryRun, log) {
25490
25748
  }
25491
25749
 
25492
25750
  // src/stream-sweep.ts
25493
- import { existsSync as existsSync53, readdirSync as readdirSync16, rmSync as rmSync23, statSync as statSync15 } from "fs";
25494
- import { join as join54 } from "path";
25751
+ import { existsSync as existsSync54, readdirSync as readdirSync16, rmSync as rmSync23, statSync as statSync15 } from "fs";
25752
+ import { join as join55 } from "path";
25495
25753
  var DAY_MS2 = 24 * 60 * 60 * 1e3;
25496
25754
  function planStreamSweep(stateDir, retentionDays, now = Date.now()) {
25497
- const dir = join54(stateDir, "streams");
25498
- if (!existsSync53(dir)) return [];
25755
+ const dir = join55(stateDir, "streams");
25756
+ if (!existsSync54(dir)) return [];
25499
25757
  const cutoff = now - retentionDays * DAY_MS2;
25500
- return readdirSync16(dir).map((name) => join54(dir, name)).filter((path) => {
25758
+ return readdirSync16(dir).map((name) => join55(dir, name)).filter((path) => {
25501
25759
  try {
25502
25760
  return statSync15(path).mtimeMs < cutoff;
25503
25761
  } catch {
@@ -25523,9 +25781,9 @@ function applyStreamSweep(paths, dryRun, log) {
25523
25781
  return removed;
25524
25782
  }
25525
25783
  function planEventsSweep(stateDir, retentionDays, now = Date.now()) {
25526
- if (!existsSync53(stateDir)) return [];
25784
+ if (!existsSync54(stateDir)) return [];
25527
25785
  const cutoff = now - retentionDays * DAY_MS2;
25528
- return readdirSync16(stateDir).filter((name) => ROTATED_EVENTS_RE.test(name)).map((name) => join54(stateDir, name)).filter((path) => {
25786
+ return readdirSync16(stateDir).filter((name) => ROTATED_EVENTS_RE.test(name)).map((name) => join55(stateDir, name)).filter((path) => {
25529
25787
  try {
25530
25788
  return statSync15(path).mtimeMs < cutoff;
25531
25789
  } catch {
@@ -25535,7 +25793,7 @@ function planEventsSweep(stateDir, retentionDays, now = Date.now()) {
25535
25793
  }
25536
25794
 
25537
25795
  // src/cli.ts
25538
- import { realpathSync as realpathSync3, readFileSync as readFileSync52, existsSync as existsSync57, mkdirSync as mkdirSync42, writeFileSync as writeFileSync42, rmSync as rmSync26, unlinkSync as unlinkSync6, copyFileSync as copyFileSync2, renameSync as renameSync8, statSync as statSync17, readdirSync as readdirSync20 } from "fs";
25796
+ import { realpathSync as realpathSync3, readFileSync as readFileSync53, existsSync as existsSync58, mkdirSync as mkdirSync42, writeFileSync as writeFileSync42, rmSync as rmSync26, unlinkSync as unlinkSync6, copyFileSync as copyFileSync2, renameSync as renameSync8, statSync as statSync17, readdirSync as readdirSync20 } from "fs";
25539
25797
  import { createInterface } from "readline/promises";
25540
25798
 
25541
25799
  // src/periscope-resume.ts
@@ -25762,8 +26020,8 @@ async function unregisterEndpoint(workspaceId, info, d) {
25762
26020
  import { createServer as createHttpServer } from "http";
25763
26021
  import { spawn as spawn9 } from "child_process";
25764
26022
  import { randomBytes as randomBytes2 } from "crypto";
25765
- import { existsSync as existsSync54, mkdirSync as mkdirSync39, readFileSync as readFileSync50, writeFileSync as writeFileSync40, unlinkSync as unlinkSync5, readdirSync as readdirSync17 } from "fs";
25766
- import { join as join55 } from "path";
26023
+ import { existsSync as existsSync55, mkdirSync as mkdirSync39, readFileSync as readFileSync51, writeFileSync as writeFileSync40, unlinkSync as unlinkSync5, readdirSync as readdirSync17 } from "fs";
26024
+ import { join as join56 } from "path";
25767
26025
 
25768
26026
  // src/secret-compare.ts
25769
26027
  import { timingSafeEqual } from "crypto";
@@ -25856,20 +26114,20 @@ var defaultSpawn2 = (cmd, args, env) => {
25856
26114
  return child;
25857
26115
  };
25858
26116
  function syncDaemonStatePath(stateDir, workspaceId) {
25859
- return join55(stateDir, "passengers", `${workspaceId}-sync.json`);
26117
+ return join56(stateDir, "passengers", `${workspaceId}-sync.json`);
25860
26118
  }
25861
26119
  function readPersistedSyncDaemon(stateDir, workspaceId) {
25862
26120
  const path = syncDaemonStatePath(stateDir, workspaceId);
25863
- if (!existsSync54(path)) return void 0;
26121
+ if (!existsSync55(path)) return void 0;
25864
26122
  try {
25865
- return JSON.parse(readFileSync50(path, "utf8"));
26123
+ return JSON.parse(readFileSync51(path, "utf8"));
25866
26124
  } catch {
25867
26125
  return void 0;
25868
26126
  }
25869
26127
  }
25870
26128
  function writePersistedSyncDaemon(stateDir, state) {
25871
26129
  const path = syncDaemonStatePath(stateDir, state.workspaceId);
25872
- mkdirSync39(join55(stateDir, "passengers"), { recursive: true });
26130
+ mkdirSync39(join56(stateDir, "passengers"), { recursive: true });
25873
26131
  writeFileSync40(path, `${JSON.stringify(state, null, 2)}
25874
26132
  `);
25875
26133
  }
@@ -25890,8 +26148,8 @@ function waitForExit(pid, alive, timeoutMs = 5e3) {
25890
26148
  }
25891
26149
  }
25892
26150
  function readAllPersistedSyncWorkspaceIds(stateDir) {
25893
- const dir = join55(stateDir, "passengers");
25894
- if (!existsSync54(dir)) return [];
26151
+ const dir = join56(stateDir, "passengers");
26152
+ if (!existsSync55(dir)) return [];
25895
26153
  const suffix = "-sync.json";
25896
26154
  return readdirSync17(dir).filter((f) => f.endsWith(suffix)).map((f) => f.slice(0, -suffix.length));
25897
26155
  }
@@ -26357,7 +26615,7 @@ async function startWorktreeIntel(d) {
26357
26615
  }
26358
26616
 
26359
26617
  // src/contract-refusal.ts
26360
- import { join as join56 } from "path";
26618
+ import { join as join57 } from "path";
26361
26619
  function contractFixers(dir, baseRef, tickets, locate) {
26362
26620
  const out = [];
26363
26621
  for (const t of tickets) {
@@ -26369,7 +26627,7 @@ function contractFixers(dir, baseRef, tickets, locate) {
26369
26627
  const text2 = gitOk(dir, ["show", `${branch}:${file}`]);
26370
26628
  if (text2 === null) continue;
26371
26629
  try {
26372
- parseRepoConfig(text2, join56(dir, file));
26630
+ parseRepoConfig(text2, join57(dir, file));
26373
26631
  } catch (e) {
26374
26632
  if (e instanceof RepoConfigError) continue;
26375
26633
  throw e;
@@ -26384,7 +26642,7 @@ import { createHash as createHash11 } from "crypto";
26384
26642
  import {
26385
26643
  chmodSync as chmodSync4,
26386
26644
  closeSync as closeSync6,
26387
- existsSync as existsSync55,
26645
+ existsSync as existsSync56,
26388
26646
  fstatSync,
26389
26647
  openSync as openSync6,
26390
26648
  readSync as readSync3,
@@ -26395,7 +26653,7 @@ import {
26395
26653
  } from "fs";
26396
26654
  import { createConnection } from "net";
26397
26655
  import { createServer as createServer2 } from "http";
26398
- import { basename as basename14, dirname as dirname35, join as join57 } from "path";
26656
+ import { basename as basename14, dirname as dirname35, join as join58 } from "path";
26399
26657
  import { execFile as execFile6, spawn as spawn12 } from "child_process";
26400
26658
 
26401
26659
  // src/periscope-control.ts
@@ -26573,11 +26831,11 @@ async function handlePeriscopes(h, q2) {
26573
26831
  for (const v of [repo, topic, requestedBy]) if (isErr(v)) return err(400, v.error);
26574
26832
  if (b.isolate !== void 0 && typeof b.isolate !== "boolean") return err(400, "isolate must be a boolean");
26575
26833
  if (!h.previewHost && !h.relayPreviews) return err(409, "this ship has no ship.previewHost, so a Passenger could not reach a periscope");
26576
- const live = await h.run(["periscope", "list", picked.route, "--json"], () => {
26834
+ const live2 = await h.run(["periscope", "list", picked.route, "--json"], () => {
26577
26835
  });
26578
- if (live.code === 0) {
26836
+ if (live2.code === 0) {
26579
26837
  try {
26580
- const n = JSON.parse(live.stdout).length;
26838
+ const n = JSON.parse(live2.stdout).length;
26581
26839
  if (n >= h.maxPeriscopes) return err(409, `this ship already hosts ${n} live periscope(s) (ship.maxPeriscopes is ${h.maxPeriscopes}) \u2014 discard one first`);
26582
26840
  } catch {
26583
26841
  }
@@ -26632,7 +26890,7 @@ function runCrew(args, onLine, timeoutMs = 20 * 6e4) {
26632
26890
  // src/control-api.ts
26633
26891
  var PAUSABLE = ["dev", "design", "qa"];
26634
26892
  var CONTROL_SOCKET_NAME = "control.sock";
26635
- var controlSocketFor = (stateDir) => join57(stateDir, CONTROL_SOCKET_NAME);
26893
+ var controlSocketFor = (stateDir) => join58(stateDir, CONTROL_SOCKET_NAME);
26636
26894
  var MAX_SOCKET_PATH = 100;
26637
26895
  var MAX_TAIL_BYTES = 1024 * 1024;
26638
26896
  var MAX_WAIT_SECONDS = 30;
@@ -26715,11 +26973,11 @@ function decodeCursor(s) {
26715
26973
  }
26716
26974
  return null;
26717
26975
  }
26718
- function candidates(live, rotated) {
26719
- const out = [live];
26976
+ function candidates(live2, rotated) {
26977
+ const out = [live2];
26720
26978
  if (!rotated) return out;
26721
26979
  try {
26722
- for (const n of readdirSync18(dirname35(live))) if (ROTATED_EVENTS_RE.test(n)) out.push(join57(dirname35(live), n));
26980
+ for (const n of readdirSync18(dirname35(live2))) if (ROTATED_EVENTS_RE.test(n)) out.push(join58(dirname35(live2), n));
26723
26981
  } catch {
26724
26982
  }
26725
26983
  return out;
@@ -26761,20 +27019,20 @@ function lastLines2(path, n) {
26761
27019
  } else lines2.pop();
26762
27020
  return { lines: lines2.slice(-n).filter((l) => l.length), cursor: cursorAt(end), reset: false };
26763
27021
  }
26764
- function readTail(live, opts) {
27022
+ function readTail(live2, opts) {
26765
27023
  const max = opts.maxBytes ?? MAX_TAIL_BYTES;
26766
- if (!existsSync55(live)) {
27024
+ if (!existsSync56(live2)) {
26767
27025
  return { lines: [], cursor: opts.after ?? encodeCursor({ dev: 0, ino: 0, off: 0 }), reset: false };
26768
27026
  }
26769
27027
  const cur = opts.after ? decodeCursor(opts.after) : null;
26770
- if (!opts.after) return lastLines2(live, opts.tail ?? DEFAULT_TAIL_LINES);
27028
+ if (!opts.after) return lastLines2(live2, opts.tail ?? DEFAULT_TAIL_LINES);
26771
27029
  let reset = false;
26772
- let path = live;
27030
+ let path = live2;
26773
27031
  let off = 0;
26774
27032
  if (!cur) {
26775
27033
  reset = true;
26776
27034
  } else {
26777
- const found = candidates(live, opts.rotated ?? false).find((p) => {
27035
+ const found = candidates(live2, opts.rotated ?? false).find((p) => {
26778
27036
  try {
26779
27037
  const s = statSync16(p);
26780
27038
  return s.ino === cur.ino && s.dev === cur.dev;
@@ -26792,8 +27050,8 @@ function readTail(live, opts) {
26792
27050
  off = 0;
26793
27051
  reset = true;
26794
27052
  }
26795
- if (off >= size && path !== live) {
26796
- path = live;
27053
+ if (off >= size && path !== live2) {
27054
+ path = live2;
26797
27055
  off = 0;
26798
27056
  size = statSync16(path).size;
26799
27057
  }
@@ -26884,6 +27142,29 @@ async function tailReply(path, q2, rotated, abort) {
26884
27142
  }
26885
27143
  return reply2(200, r);
26886
27144
  }
27145
+ var NOTE_MAX_CHARS = 4e3;
27146
+ async function postRunMessage(deps, run4, body) {
27147
+ if (!RUN_NAME_RE.test(run4) || run4.includes("..")) return err2(400, "not a run name");
27148
+ const live2 = liveRuns(deps.stateDir).find((r) => basename14(r.streamPath, ".jsonl") === run4.replace(/\.jsonl$/, ""));
27149
+ const carry = "A note for the work item posted from the platform is carried forward into its next run's brief.";
27150
+ if (!live2) return err2(404, `no live run ${run4}: it is unknown or has finished. ${carry}`);
27151
+ if (!body) return err2(400, "body must be a small JSON object");
27152
+ const text2 = typeof body.text === "string" ? body.text.trim() : "";
27153
+ if (!text2 || text2.length > NOTE_MAX_CHARS) return err2(400, `text must be a string of 1 to ${NOTE_MAX_CHARS} characters`);
27154
+ if (body.author !== void 0 && typeof body.author !== "string") return err2(400, "author must be a string");
27155
+ const input = runInputFor(basename14(live2.streamPath, ".jsonl"));
27156
+ const rowId = input?.agentLogRowId();
27157
+ if (!input?.target || !rowId) return err2(409, `run ${run4} is live but this daemon cannot record a note on it (it did not start the run, or the run has no Agent Log row). ${carry}`);
27158
+ try {
27159
+ const recorded = await postMessage(input.target, rowId, text2);
27160
+ const acceptsInput = input.accepts();
27161
+ const state = acceptsInput ? await input.deliver(recorded, body.author || void 0) : "carried_forward";
27162
+ if (!acceptsInput) await markMessage(input.target, rowId, recorded.id, "carried_forward");
27163
+ return reply2(200, { cycleId: recorded.id, state, acceptsInput });
27164
+ } catch (e) {
27165
+ return err2(409, `the platform did not take the note: ${e.message}. ${carry}`);
27166
+ }
27167
+ }
26887
27168
  async function route(deps, method, url, req, abort) {
26888
27169
  const p = url.pathname.replace(/\/+$/, "") || "/";
26889
27170
  const get2 = method === "GET";
@@ -26919,10 +27200,12 @@ async function route(deps, method, url, req, abort) {
26919
27200
  if (p.startsWith("/streams/") && get2) {
26920
27201
  const run4 = decodeURIComponent(p.slice("/streams/".length));
26921
27202
  if (!RUN_NAME_RE.test(run4) || run4.includes("..") || /\.(pid|meta\.json|events\.jsonl)$/.test(run4)) return err2(400, "not a run name");
26922
- const file = join57(deps.stateDir, "streams", run4.endsWith(".jsonl") ? run4 : `${run4}.jsonl`);
26923
- if (!existsSync55(file)) return err2(404, "no such run");
27203
+ const file = join58(deps.stateDir, "streams", run4.endsWith(".jsonl") ? run4 : `${run4}.jsonl`);
27204
+ if (!existsSync56(file)) return err2(404, "no such run");
26924
27205
  return tailReply(file, url.searchParams, false, abort);
26925
27206
  }
27207
+ const note = /^\/streams\/([^/]+)\/messages$/.exec(p);
27208
+ if (note && post3) return postRunMessage(deps, decodeURIComponent(note[1]), await readJsonBody(req));
26926
27209
  if ((p === "/pause" || p === "/resume") && post3) {
26927
27210
  const body = await readJsonBody(req);
26928
27211
  if (!body) return err2(400, "body must be a small JSON object");
@@ -26965,7 +27248,7 @@ function send2(res, r) {
26965
27248
  res.end(body);
26966
27249
  }
26967
27250
  async function socketIsStale(path) {
26968
- if (!existsSync55(path)) return false;
27251
+ if (!existsSync56(path)) return false;
26969
27252
  return new Promise((resolve8) => {
26970
27253
  const c = createConnection(path);
26971
27254
  c.once("connect", () => {
@@ -26984,7 +27267,7 @@ async function startControlServer(deps) {
26984
27267
  return null;
26985
27268
  }
26986
27269
  if (await socketIsStale(path)) rmSync24(path, { force: true });
26987
- else if (existsSync55(path)) {
27270
+ else if (existsSync56(path)) {
26988
27271
  log(`control API not started: ${path} is in use by another process`);
26989
27272
  return null;
26990
27273
  }
@@ -27070,19 +27353,19 @@ function crewJson(args, timeoutMs = 6e4) {
27070
27353
 
27071
27354
  // src/periscope-mcp.ts
27072
27355
  import { lstat, mkdir, readdir, readFile, readlink, realpath, rm, stat, writeFile } from "fs/promises";
27073
- import { basename as basename15, dirname as dirname36, isAbsolute as isAbsolute5, join as join59, relative as relative2, resolve as resolve6, sep } from "path";
27356
+ import { basename as basename15, dirname as dirname36, isAbsolute as isAbsolute5, join as join60, relative as relative2, resolve as resolve6, sep } from "path";
27074
27357
  import { z } from "zod";
27075
27358
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
27076
27359
  import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
27077
27360
 
27078
27361
  // src/periscope-endpoints.ts
27079
27362
  import { randomBytes as randomBytes3 } from "crypto";
27080
- import { chmodSync as chmodSync5, existsSync as existsSync56, mkdirSync as mkdirSync41, readdirSync as readdirSync19, readFileSync as readFileSync51, rmSync as rmSync25, writeFileSync as writeFileSync41 } from "fs";
27081
- import { join as join58 } from "path";
27082
- var secretDir = (stateDir) => join58(stateDir, "periscope-mcp");
27083
- var secretFile = (stateDir, id) => join58(secretDir(stateDir), `${id}.json`);
27084
- var endpointDir = (stateDir) => join58(stateDir, "periscope-endpoints");
27085
- var endpointFile = (stateDir, id) => join58(endpointDir(stateDir), `${id}.json`);
27363
+ import { chmodSync as chmodSync5, existsSync as existsSync57, mkdirSync as mkdirSync41, readdirSync as readdirSync19, readFileSync as readFileSync52, rmSync as rmSync25, writeFileSync as writeFileSync41 } from "fs";
27364
+ import { join as join59 } from "path";
27365
+ var secretDir = (stateDir) => join59(stateDir, "periscope-mcp");
27366
+ var secretFile = (stateDir, id) => join59(secretDir(stateDir), `${id}.json`);
27367
+ var endpointDir = (stateDir) => join59(stateDir, "periscope-endpoints");
27368
+ var endpointFile = (stateDir, id) => join59(endpointDir(stateDir), `${id}.json`);
27086
27369
  function mintPeriscopeSecret(stateDir, ticketRecordId) {
27087
27370
  mkdirSync41(secretDir(stateDir), { recursive: true, mode: 448 });
27088
27371
  const secret = randomBytes3(32).toString("base64url");
@@ -27094,7 +27377,7 @@ function mintPeriscopeSecret(stateDir, ticketRecordId) {
27094
27377
  }
27095
27378
  function readPeriscopeSecret(stateDir, ticketRecordId) {
27096
27379
  try {
27097
- const v = JSON.parse(readFileSync51(secretFile(stateDir, ticketRecordId), "utf8"));
27380
+ const v = JSON.parse(readFileSync52(secretFile(stateDir, ticketRecordId), "utf8"));
27098
27381
  return typeof v.secret === "string" && v.secret ? v.secret : void 0;
27099
27382
  } catch {
27100
27383
  return void 0;
@@ -27105,7 +27388,7 @@ function removePeriscopeSecret(stateDir, ticketRecordId) {
27105
27388
  }
27106
27389
  function readPeriscopeEndpoint(stateDir, ticketRecordId) {
27107
27390
  try {
27108
- return JSON.parse(readFileSync51(endpointFile(stateDir, ticketRecordId), "utf8"));
27391
+ return JSON.parse(readFileSync52(endpointFile(stateDir, ticketRecordId), "utf8"));
27109
27392
  } catch {
27110
27393
  return void 0;
27111
27394
  }
@@ -27120,7 +27403,7 @@ function removePeriscopeEndpointRecord(stateDir, ticketRecordId) {
27120
27403
  }
27121
27404
  function listPeriscopeEndpoints(stateDir) {
27122
27405
  const dir = endpointDir(stateDir);
27123
- if (!existsSync56(dir)) return [];
27406
+ if (!existsSync57(dir)) return [];
27124
27407
  const out = [];
27125
27408
  for (const name of readdirSync19(dir)) {
27126
27409
  if (!name.endsWith(".json")) continue;
@@ -27223,13 +27506,13 @@ async function resolveInWorktree(root, requested) {
27223
27506
  let abs;
27224
27507
  if (isAbsolute5(requested)) {
27225
27508
  abs = resolve6(requested);
27226
- if (isInside(root, abs)) abs = join59(realRoot, relative2(root, abs));
27509
+ if (isInside(root, abs)) abs = join60(realRoot, relative2(root, abs));
27227
27510
  } else {
27228
27511
  abs = resolve6(realRoot, requested);
27229
27512
  }
27230
27513
  if (!isInside(realRoot, abs)) throw new PathRefusal(`${requested} is outside this periscope's worktree`);
27231
27514
  const { real, rest } = await realAncestor(abs);
27232
- const final = rest ? join59(real, rest) : real;
27515
+ const final = rest ? join60(real, rest) : real;
27233
27516
  if (!isInside(realRoot, final)) throw new PathRefusal(`${requested} is outside this periscope's worktree`);
27234
27517
  if (relative2(realRoot, final).split(sep).includes(".git")) throw new PathRefusal(".git is not reachable from a periscope");
27235
27518
  return final;
@@ -27297,7 +27580,7 @@ function createPeriscopeMcpServer(d, sc) {
27297
27580
  const entries = (await readdir(abs, { withFileTypes: true })).filter((e) => e.name !== ".git");
27298
27581
  const lines2 = await Promise.all(entries.map(async (e) => {
27299
27582
  if (e.isDirectory()) return `[DIR] ${e.name}`;
27300
- const size = (await lstat(join59(abs, e.name))).size;
27583
+ const size = (await lstat(join60(abs, e.name))).size;
27301
27584
  return `[FILE] ${e.name} (${size} bytes)`;
27302
27585
  }));
27303
27586
  return text(lines2.join("\n") || "(empty)");
@@ -27363,7 +27646,7 @@ function createPeriscopeMcpServer(d, sc) {
27363
27646
  annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: false }
27364
27647
  }, async ({ path }) => {
27365
27648
  const parent = await inTree(dirname36(path) === "" ? "." : dirname36(path));
27366
- const abs = join59(parent, basename15(path));
27649
+ const abs = join60(parent, basename15(path));
27367
27650
  if (basename15(path) === ".git" || abs === parent) return text("path must name a file", true);
27368
27651
  const st = await lstat(abs).catch(() => void 0);
27369
27652
  if (!st) return text(`${path} does not exist`, true);
@@ -27854,7 +28137,7 @@ if (command === "provision") {
27854
28137
  process.exit(outcome.code);
27855
28138
  }
27856
28139
  if (command === "pool-member") {
27857
- const pool = poolConfigFrom(argv, process.env, () => readFileSync52(0, "utf8"));
28140
+ const pool = poolConfigFrom(argv, process.env, () => readFileSync53(0, "utf8"));
27858
28141
  if (typeof pool === "string") {
27859
28142
  process.stderr.write(`crew pool-member: ${pool}
27860
28143
  `);
@@ -28175,7 +28458,7 @@ if (command === "passenger-sync-daemon") {
28175
28458
  } else {
28176
28459
  const toleratesNoRoutes = command === "credential" || command === "forge" || command === "repos" || command === "ship" || command === "disconnect" && flag("reset") || command === "deprovision" || command === "connect" && flag("sign-out");
28177
28460
  const configless = command === "connect" && flag("sign-out") || command === "disconnect" && flag("reset") || command === "deprovision";
28178
- if (configless && !existsSync57(findConfigFile(CREW_HOME))) {
28461
+ if (configless && !existsSync58(findConfigFile(CREW_HOME))) {
28179
28462
  cfg = loadConfig(CREW_HOME, firstRunConfigPath(), { text: "ship: {}\n", allowNoRoutes: true });
28180
28463
  } else {
28181
28464
  cfg = loadConfig(CREW_HOME, void 0, toleratesNoRoutes ? { allowNoRoutes: true } : {});
@@ -28198,7 +28481,7 @@ if (command === "passenger-sync-daemon") {
28198
28481
  throw e;
28199
28482
  }
28200
28483
  if (command === "credential") {
28201
- const r = runCredential(positional[1], readFileSync52(0, "utf8"), cfg.ship.forges, cfg.ship.stateDir, process.env, !flag("no-miss"));
28484
+ const r = runCredential(positional[1], readFileSync53(0, "utf8"), cfg.ship.forges, cfg.ship.stateDir, process.env, !flag("no-miss"));
28202
28485
  process.stdout.write(r.out);
28203
28486
  process.stderr.write(r.err);
28204
28487
  process.exit(r.code);
@@ -28210,9 +28493,9 @@ if (command === "passenger-sync-daemon") {
28210
28493
  forges: cfg.ship.forges,
28211
28494
  stateDir: cfg.ship.stateDir,
28212
28495
  configFile: cfg.configFile,
28213
- readFile: (p) => readFileSync52(p, "utf8"),
28496
+ readFile: (p) => readFileSync53(p, "utf8"),
28214
28497
  writeFile: (p, t) => writeFileSync42(p, t),
28215
- stdin: () => readFileSync52(0, "utf8"),
28498
+ stdin: () => readFileSync53(0, "utf8"),
28216
28499
  env: process.env
28217
28500
  }
28218
28501
  );
@@ -28546,8 +28829,8 @@ if (command === "passenger-sync-daemon") {
28546
28829
  }
28547
28830
  if (host === "linux" && hasSystemd) {
28548
28831
  const label = labelFor(CREW_HOME, "run");
28549
- const staleTimer = join60(homedir11(), ".config", "systemd", "user", `${label}.timer`);
28550
- if (existsSync57(staleTimer)) {
28832
+ const staleTimer = join61(homedir11(), ".config", "systemd", "user", `${label}.timer`);
28833
+ if (existsSync58(staleTimer)) {
28551
28834
  process.stdout.write(
28552
28835
  `removing stale run timer from before the persistent-service cutover: ${staleTimer}${dryRun ? " (dry run)" : ""}
28553
28836
  `
@@ -28576,7 +28859,7 @@ if (command === "passenger-sync-daemon") {
28576
28859
  const { settled: doctorRepos, errors: refusedRepos } = await settleRepos(reposOf(c), (t) => t.name, (t) => resolveOneRepo(c, t));
28577
28860
  for (const e of refusedRepos) problems.push(`repo ${e.repo}: ${e.detail}`);
28578
28861
  for (const r of doctorRepos) {
28579
- if (!existsSync57(r.dir)) problems.push(`repo ${r.name}: ${r.dir} is missing on disk`);
28862
+ if (!existsSync58(r.dir)) problems.push(`repo ${r.name}: ${r.dir} is missing on disk`);
28580
28863
  if (!satisfies(host, r.config.platform)) problems.push(`repo ${r.name}: requires ${r.config.platform}, this host is ${host}`);
28581
28864
  readiness.push(...validateEffective(r.config).map((p) => `repo ${r.name}: ${p}`));
28582
28865
  }
@@ -28611,7 +28894,7 @@ if (command === "passenger-sync-daemon") {
28611
28894
  }
28612
28895
  async function doctorFix(o) {
28613
28896
  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))));
28614
- const unitExists = (p) => existsSync57(p);
28897
+ const unitExists = (p) => existsSync58(p);
28615
28898
  const crontab = o.host === "linux" ? spawnSync13("crontab", ["-l"], { encoding: "utf8" }).stdout ?? "" : "";
28616
28899
  const schedulerAbsent = o.host !== "windows" ? !schedulerInstalled(planInstall(cfg.ship, CREW_HOME, o.host, detectSystemd(), "run", installContext()), unitExists, crontab) : true;
28617
28900
  const plan = planFix({ routes, schedulerAbsent, host: o.host });
@@ -28628,7 +28911,7 @@ if (command === "passenger-sync-daemon") {
28628
28911
  for (const a of plan.actions) {
28629
28912
  if (a.kind === "enable") {
28630
28913
  if (prompter && !await prompter.confirm(`Route ${a.route} passes every check \u2014 set enabled: true in ${cfg.configFile}?`, false)) continue;
28631
- writeFileSync42(cfg.configFile, planEnable(readFileSync52(cfg.configFile, "utf8"), a.route));
28914
+ writeFileSync42(cfg.configFile, planEnable(readFileSync53(cfg.configFile, "utf8"), a.route));
28632
28915
  enabledSound.add(a.route);
28633
28916
  changed2.push(`enabled route ${a.route} in ${cfg.configFile}`);
28634
28917
  } else {
@@ -28857,7 +29140,7 @@ ${changed2.map((c) => ` - ${c}
28857
29140
  harnessBin: "claude",
28858
29141
  ...contract.sandboxNetwork ? { extraHosts: contract.sandboxNetwork.hosts, toolchains: contract.sandboxNetwork.toolchains } : {}
28859
29142
  },
28860
- policyFile: join60(cfg.ship.stateDir, "release", `${target.name}.policy.yaml`),
29143
+ policyFile: join61(cfg.ship.stateDir, "release", `${target.name}.policy.yaml`),
28861
29144
  repo: mirror,
28862
29145
  origin: forgeDescriptorFor(forgeHost).httpsUrl(mirror.host, mirror.path),
28863
29146
  base: effective.branch.base,
@@ -30059,7 +30342,7 @@ ${cu.tail.trimEnd()}
30059
30342
  logFile: cfg.ship.logFile
30060
30343
  });
30061
30344
  }
30062
- const watchPaths = isCompiledBinary(import.meta.url) ? [process.execPath] : [join60(CREW_HOME, "src"), join60(CREW_HOME, "dist"), join60(CREW_HOME, "bin")];
30345
+ const watchPaths = isCompiledBinary(import.meta.url) ? [process.execPath] : [join61(CREW_HOME, "src"), join61(CREW_HOME, "dist"), join61(CREW_HOME, "bin")];
30063
30346
  const configPaths = daemonConfigPaths(cfg);
30064
30347
  watchPaths.push(...configPaths);
30065
30348
  noteDaemonStarted(cfg.ship.stateDir);
@@ -30377,7 +30660,7 @@ ${cu.tail.trimEnd()}
30377
30660
  `);
30378
30661
  if (!dryRun) {
30379
30662
  const resolvedPath = resolvedPathFor(cfg.ship.stateDir, target.route);
30380
- const raw = existsSync57(resolvedPath) ? JSON.parse(readFileSync52(resolvedPath, "utf8")) : {};
30663
+ const raw = existsSync58(resolvedPath) ? JSON.parse(readFileSync53(resolvedPath, "utf8")) : {};
30381
30664
  raw.agentSkills = result.agentSkills;
30382
30665
  mkdirSync42(dirOf2(resolvedPath), { recursive: true });
30383
30666
  writeFileSync42(resolvedPath, `${JSON.stringify(raw, null, 2)}
@@ -30403,7 +30686,7 @@ ${cu.tail.trimEnd()}
30403
30686
  throw e;
30404
30687
  }
30405
30688
  const oldName = cfg.ship.name;
30406
- writeFileSync42(cfg.configFile, setShipNameInYaml(readFileSync52(cfg.configFile, "utf8"), newName));
30689
+ writeFileSync42(cfg.configFile, setShipNameInYaml(readFileSync53(cfg.configFile, "utf8"), newName));
30407
30690
  cfg.ship.name = newName;
30408
30691
  let renameMachineId;
30409
30692
  try {
@@ -30450,7 +30733,7 @@ ${cu.tail.trimEnd()}
30450
30733
  process.exit(2);
30451
30734
  };
30452
30735
  if (sub !== "add" && sub !== "list" && sub !== "clone" && sub !== "hooks" && sub !== "check") usage2();
30453
- const configText = readFileSync52(cfg.configFile, "utf8");
30736
+ const configText = readFileSync53(cfg.configFile, "utf8");
30454
30737
  if (sub === "check") {
30455
30738
  try {
30456
30739
  const routeArg = value("route") ?? positional[2];
@@ -30482,8 +30765,8 @@ ${cu.tail.trimEnd()}
30482
30765
  try {
30483
30766
  const a = parseHooksArgs(positional.slice(2), routeNamesOf(configText));
30484
30767
  const dir = repoDirOf(configText, dirname37(cfg.configFile), a.route, a.name);
30485
- if (!existsSync57(dir)) throw new ReposError(`${dir} does not exist on disk`);
30486
- const files = { exists: (r) => existsSync57(resolvePath(dir, r)), list: (r) => {
30768
+ if (!existsSync58(dir)) throw new ReposError(`${dir} does not exist on disk`);
30769
+ const files = { exists: (r) => existsSync58(resolvePath(dir, r)), list: (r) => {
30487
30770
  try {
30488
30771
  return readdirSync20(resolvePath(dir, r));
30489
30772
  } catch {
@@ -30491,7 +30774,7 @@ ${cu.tail.trimEnd()}
30491
30774
  }
30492
30775
  }, read: (r) => {
30493
30776
  try {
30494
- return readFileSync52(resolvePath(dir, r), "utf8");
30777
+ return readFileSync53(resolvePath(dir, r), "utf8");
30495
30778
  } catch {
30496
30779
  return void 0;
30497
30780
  }
@@ -30601,7 +30884,7 @@ ${cu.tail.trimEnd()}
30601
30884
  if (sub === "list" && !routeName) usage2();
30602
30885
  if (sub === "add") {
30603
30886
  try {
30604
- const a = parseAddArgs(positional.slice(2), routeNamesOf(configText), (p) => existsSync57(resolvePath(p.replace(/^~(?=\/|$)/, homedir11()))));
30887
+ const a = parseAddArgs(positional.slice(2), routeNamesOf(configText), (p) => existsSync58(resolvePath(p.replace(/^~(?=\/|$)/, homedir11()))));
30605
30888
  routeName = a.route;
30606
30889
  addPath = a.path;
30607
30890
  addName = a.name;
@@ -30631,7 +30914,7 @@ ${cu.tail.trimEnd()}
30631
30914
  const resolvedFile = resolvedPathFor(cfg.ship.stateDir, routeName);
30632
30915
  if (sub === "list" || sub === "add") {
30633
30916
  const liveRoute = cfg.routes.find((r) => r.route === routeName);
30634
- if (liveRoute?.resolved?.reposModelId && existsSync57(resolvedFile) && !dryRun) {
30917
+ if (liveRoute?.resolved?.reposModelId && existsSync58(resolvedFile) && !dryRun) {
30635
30918
  try {
30636
30919
  await hydrateApiKeys([liveRoute]);
30637
30920
  persistRepoRows(cfg.ship.stateDir, liveRoute.route, await new Tracker(liveRoute, cfg.ship).repoRowsForMap());
@@ -30640,16 +30923,16 @@ ${cu.tail.trimEnd()}
30640
30923
  }
30641
30924
  }
30642
30925
  let resolvedRemotes;
30643
- if (existsSync57(resolvedFile)) {
30926
+ if (existsSync58(resolvedFile)) {
30644
30927
  try {
30645
- resolvedRemotes = JSON.parse(readFileSync52(resolvedFile, "utf8"));
30928
+ resolvedRemotes = JSON.parse(readFileSync53(resolvedFile, "utf8"));
30646
30929
  } catch {
30647
30930
  }
30648
30931
  }
30649
30932
  const originOf = (dir) => gitOk(dir, ["remote", "get-url", "origin"]) ?? void 0;
30650
30933
  const text2 = configText;
30651
30934
  const base = dirname37(cfg.configFile);
30652
- const isCheckout = (d) => existsSync57(`${d}/.git`);
30935
+ const isCheckout = (d) => existsSync58(`${d}/.git`);
30653
30936
  try {
30654
30937
  if (sub === "list") {
30655
30938
  if (flag("json")) {
@@ -30659,12 +30942,12 @@ ${cu.tail.trimEnd()}
30659
30942
  base,
30660
30943
  resolved: resolvedRemotes,
30661
30944
  originOf,
30662
- exists: (d) => existsSync57(d),
30945
+ exists: (d) => existsSync58(d),
30663
30946
  isCheckout,
30664
30947
  repoHasHooks: (d) => REPO_CONFIG_FILENAMES.some((f) => {
30665
30948
  try {
30666
30949
  const path = resolvePath(d, f);
30667
- return Object.keys(parseRepoConfig(readFileSync52(path, "utf8"), path).hooks).length > 0;
30950
+ return Object.keys(parseRepoConfig(readFileSync53(path, "utf8"), path).hooks).length > 0;
30668
30951
  } catch {
30669
30952
  return false;
30670
30953
  }
@@ -30681,7 +30964,7 @@ ${cu.tail.trimEnd()}
30681
30964
  for (const r of repos) {
30682
30965
  const origin2 = originOf(r.dir);
30683
30966
  const row = matchRepoName(origin2, resolvedRemotes);
30684
- const note = !existsSync57(r.dir) ? "missing on disk" : row ? `Repos row: ${row}` : `no Repos row matches ${normalizeRemote2(origin2) ?? "this checkout (no origin remote)"}`;
30967
+ const note = !existsSync58(r.dir) ? "missing on disk" : row ? `Repos row: ${row}` : `no Repos row matches ${normalizeRemote2(origin2) ?? "this checkout (no origin remote)"}`;
30685
30968
  process.stdout.write(`${r.name} ${r.dir} ${note}
30686
30969
  `);
30687
30970
  }
@@ -30693,9 +30976,9 @@ ${cu.tail.trimEnd()}
30693
30976
  ` : `${human}
30694
30977
  `);
30695
30978
  const plan2 = planRepoClone({ text: text2, base, route: routeName, name: addName, resolved: resolvedRemotes, dir: value("dir"), isCheckout });
30696
- if (existsSync57(plan2.target) && (existsSync57(`${plan2.target}/.git`) || readdirSync20(plan2.target).length > 0)) {
30979
+ if (existsSync58(plan2.target) && (existsSync58(`${plan2.target}/.git`) || readdirSync20(plan2.target).length > 0)) {
30697
30980
  throw new ReposError(
30698
- existsSync57(`${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`
30981
+ existsSync58(`${plan2.target}/.git`) ? `${plan2.target} is already a checkout \u2014 attach it with \`crew repos add ${routeName} ${plan2.name} ${plan2.target}\`` : `${plan2.target} exists and is not empty \u2014 pass --dir to clone somewhere else`
30699
30982
  );
30700
30983
  }
30701
30984
  if (dryRun) {
@@ -30720,7 +31003,7 @@ ${cu.tail.trimEnd()}
30720
31003
  break;
30721
31004
  }
30722
31005
  const target = resolvePath(addPath.replace(/^~(?=\/|$)/, homedir11()));
30723
- const top = existsSync57(target) ? gitOk(target, ["rev-parse", "--show-toplevel"]) : null;
31006
+ const top = existsSync58(target) ? gitOk(target, ["rev-parse", "--show-toplevel"]) : null;
30724
31007
  if (!top) throw new ReposError(`${target} is not a git checkout`);
30725
31008
  const origin = originOf(top);
30726
31009
  const plan = planRepoAdd({
@@ -30772,8 +31055,8 @@ ${cu.tail.trimEnd()}
30772
31055
  const created = await rowTracker.createRepoRow(rowPayload);
30773
31056
  process.stdout.write(`created Repos row ${String(rowPayload.name)} (${String(rowPayload.remote)}) ${created.id}
30774
31057
  `);
30775
- if (existsSync57(resolvedFile)) {
30776
- const raw = JSON.parse(readFileSync52(resolvedFile, "utf8"));
31058
+ if (existsSync58(resolvedFile)) {
31059
+ const raw = JSON.parse(readFileSync53(resolvedFile, "utf8"));
30777
31060
  raw.repoNames = { ...raw.repoNames, [created.id]: String(rowPayload.name) };
30778
31061
  raw.repoRemotes = { ...raw.repoRemotes, [created.id]: String(rowPayload.remote) };
30779
31062
  writeFileSync42(resolvedFile, `${JSON.stringify(raw, null, 2)}
@@ -31155,7 +31438,7 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
31155
31438
  process.exit(2);
31156
31439
  }
31157
31440
  if (found.shipNameAdopted && !dryRun) {
31158
- writeFileSync42(cfg.configFile, setShipNameInYaml(readFileSync52(cfg.configFile, "utf8"), found.shipNameAdopted));
31441
+ writeFileSync42(cfg.configFile, setShipNameInYaml(readFileSync53(cfg.configFile, "utf8"), found.shipNameAdopted));
31159
31442
  cfg.ship.name = found.shipNameAdopted;
31160
31443
  }
31161
31444
  if (found.shipRow) {
@@ -31198,10 +31481,10 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
31198
31481
  }
31199
31482
  }
31200
31483
  let previous;
31201
- const hadPreviousFile = existsSync57(resolvedPath);
31484
+ const hadPreviousFile = existsSync58(resolvedPath);
31202
31485
  if (hadPreviousFile) {
31203
31486
  try {
31204
- previous = JSON.parse(readFileSync52(resolvedPath, "utf8"));
31487
+ previous = JSON.parse(readFileSync53(resolvedPath, "utf8"));
31205
31488
  } catch {
31206
31489
  }
31207
31490
  }
@@ -31672,9 +31955,9 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
31672
31955
  break;
31673
31956
  }
31674
31957
  for (const r of rows) {
31675
- const live = worktreeExistsIn(where, r.t.n);
31958
+ const live2 = worktreeExistsIn(where, r.t.n);
31676
31959
  process.stdout.write(
31677
- `${String(r.port).padEnd(6)} ${r.t.role.padEnd(9)} ISSUE-${String(r.t.n).padEnd(5)} pid ${String(r.pid).padEnd(7)} ${live ? "worktree present" : "ORPHAN \u2014 worktree gone"}
31960
+ `${String(r.port).padEnd(6)} ${r.t.role.padEnd(9)} ISSUE-${String(r.t.n).padEnd(5)} pid ${String(r.pid).padEnd(7)} ${live2 ? "worktree present" : "ORPHAN \u2014 worktree gone"}
31678
31961
  `
31679
31962
  );
31680
31963
  }
@@ -32096,10 +32379,10 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
32096
32379
  startupSeconds: cfg.ship.intelStartupSeconds,
32097
32380
  prepare: async (path) => {
32098
32381
  for (const f of repoWt.config.worktrees.copy) {
32099
- const src = join60(repoWt.dir, f);
32100
- if (!existsSync57(src) || existsSync57(join60(path, f))) continue;
32101
- mkdirSync42(dirOf2(join60(path, f)), { recursive: true });
32102
- copyFileSync2(src, join60(path, f));
32382
+ const src = join61(repoWt.dir, f);
32383
+ if (!existsSync58(src) || existsSync58(join61(path, f))) continue;
32384
+ mkdirSync42(dirOf2(join61(path, f)), { recursive: true });
32385
+ copyFileSync2(src, join61(path, f));
32103
32386
  }
32104
32387
  const setup = repoWt.config.hooks.setup;
32105
32388
  return setup ? runScript(setup, { cwd: path, shell: shellWt }) : null;
@@ -32325,7 +32608,7 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
32325
32608
  const shellR = hit && resolveShell(hit.repo.config.shell ?? cfg.ship.shell);
32326
32609
  const resumed = await runPeriscopeResume({
32327
32610
  find: async () => hit && { row: hit.row, tag: hit.tag },
32328
- worktreeExists: (p) => existsSync57(p),
32611
+ worktreeExists: (p) => existsSync58(p),
32329
32612
  prepareDropFile,
32330
32613
  startProxy: (wt, url, n) => launchProxy(crewInvocation(CREW_HOME), wt, url, Number(n), { host: hit.row.host || "localhost", inject: hit.repo.config.periscope?.inspector !== "repo" }),
32331
32614
  relay: hit && previewRelayFor(hit.route) && {
@@ -32428,10 +32711,10 @@ ${where.join("\n")}`);
32428
32711
  },
32429
32712
  prepare: async (path) => {
32430
32713
  for (const f of repoP.config.worktrees.copy) {
32431
- const src = join60(repoP.dir, f);
32432
- if (!existsSync57(src)) continue;
32433
- mkdirSync42(dirOf2(join60(path, f)), { recursive: true });
32434
- copyFileSync2(src, join60(path, f));
32714
+ const src = join61(repoP.dir, f);
32715
+ if (!existsSync58(src)) continue;
32716
+ mkdirSync42(dirOf2(join61(path, f)), { recursive: true });
32717
+ copyFileSync2(src, join61(path, f));
32435
32718
  }
32436
32719
  const setup = repoP.config.hooks.setup;
32437
32720
  return setup ? runScript(setup, { cwd: path, shell: shellP, onLine: (l) => {
@@ -32743,7 +33026,7 @@ ${where.join("\n")}`);
32743
33026
  };
32744
33027
  const droppedRoutes = [];
32745
33028
  try {
32746
- const rawCfg = parseYaml3(readFileSync52(cfg.configFile, "utf8"));
33029
+ const rawCfg = parseYaml3(readFileSync53(cfg.configFile, "utf8"));
32747
33030
  for (const r of rawCfg?.routes ?? []) {
32748
33031
  if (typeof r?.route !== "string" || cfg.routes.some((x) => x.route === r.route)) continue;
32749
33032
  try {
@@ -32873,7 +33156,7 @@ ${where.join("\n")}`);
32873
33156
  }
32874
33157
  case "log": {
32875
33158
  try {
32876
- const text2 = readFileSync52(cfg.ship.logFile, "utf8").split("\n");
33159
+ const text2 = readFileSync53(cfg.ship.logFile, "utf8").split("\n");
32877
33160
  process.stdout.write(`${text2.slice(-(Number(value("tail")) || 40)).join("\n")}
32878
33161
  `);
32879
33162
  } catch {
@@ -32896,7 +33179,7 @@ ${where.join("\n")}`);
32896
33179
  };
32897
33180
  if (!route2.resolved) fail2(`route ${route2.route} is not connected \u2014 run \`crew connect\` first`);
32898
33181
  const tracker = new Tracker(route2, cfg.ship);
32899
- const configText = readFileSync52(cfg.configFile, "utf8");
33182
+ const configText = readFileSync53(cfg.configFile, "utf8");
32900
33183
  const cfgBase = dirname37(cfg.configFile);
32901
33184
  const configured2 = configuredRepos(configText, route2.route, cfgBase);
32902
33185
  const dir = configured2.find((r) => r.name === SAMPLE_REPO)?.dir ?? sampleDir(configured2.map((r) => r.dir), route2.reposBasePath, route2.route.split("/")[0]);
@@ -32933,29 +33216,29 @@ ${where.join("\n")}`);
32933
33216
  }
32934
33217
  if (row) {
32935
33218
  await tracker.deleteRepoRow(row.id);
32936
- if (existsSync57(resolvedFile)) {
32937
- const raw = JSON.parse(readFileSync52(resolvedFile, "utf8"));
33219
+ if (existsSync58(resolvedFile)) {
33220
+ const raw = JSON.parse(readFileSync53(resolvedFile, "utf8"));
32938
33221
  if (raw.repoNames) delete raw.repoNames[row.id];
32939
33222
  if (raw.repoRemotes) delete raw.repoRemotes[row.id];
32940
33223
  writeFileSync42(resolvedFile, `${JSON.stringify(raw, null, 2)}
32941
33224
  `);
32942
33225
  }
32943
33226
  }
32944
- if (existsSync57(join60(dir, ".git")) && basename16(dir) === SAMPLE_REPO) rmSync26(dir, { recursive: true, force: true });
33227
+ if (existsSync58(join61(dir, ".git")) && basename16(dir) === SAMPLE_REPO) rmSync26(dir, { recursive: true, force: true });
32945
33228
  say("removed", { dir, closed }, `removed the sample repo${closed.length ? `, closed ${closed.join(", ")}` : ""}`);
32946
33229
  break;
32947
33230
  }
32948
33231
  const projectId = route2.resolved.areaId ?? resolveRepoProject(await tracker.projectRows(), value("project"));
32949
- const fresh = !existsSync57(join60(dir, ".git"));
32950
- if (existsSync57(dir) && fresh && readdirSync20(dir).length > 0) fail2(`${dir} exists and is not a git checkout \u2014 move it aside`);
33232
+ const fresh = !existsSync58(join61(dir, ".git"));
33233
+ if (existsSync58(dir) && fresh && readdirSync20(dir).length > 0) fail2(`${dir} exists and is not a git checkout \u2014 move it aside`);
32951
33234
  if (dryRun) {
32952
33235
  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`);
32953
33236
  break;
32954
33237
  }
32955
33238
  if (fresh) {
32956
33239
  mkdirSync42(dir, { recursive: true });
32957
- writeFileSync42(join60(dir, "README.md"), SAMPLE_README);
32958
- writeFileSync42(join60(dir, ".crew.yaml"), SAMPLE_CREW_YAML);
33240
+ writeFileSync42(join61(dir, "README.md"), SAMPLE_README);
33241
+ writeFileSync42(join61(dir, ".crew.yaml"), SAMPLE_CREW_YAML);
32959
33242
  const g = (...a) => {
32960
33243
  const r = spawnSync13("git", a, { cwd: dir, encoding: "utf8" });
32961
33244
  if (r.status !== 0) fail2(`git ${a[0]} failed in ${dir}: ${(r.stderr || r.stdout).trim()}`);
@@ -32973,8 +33256,8 @@ ${where.join("\n")}`);
32973
33256
  spec: { platform: "unix", releaseMode: "integrate", ciProvider: "none" }
32974
33257
  });
32975
33258
  repoId = (await tracker.createRepoRow(payload)).id;
32976
- if (existsSync57(resolvedFile)) {
32977
- const raw = JSON.parse(readFileSync52(resolvedFile, "utf8"));
33259
+ if (existsSync58(resolvedFile)) {
33260
+ const raw = JSON.parse(readFileSync53(resolvedFile, "utf8"));
32978
33261
  raw.repoNames = { ...raw.repoNames, [repoId]: SAMPLE_REPO };
32979
33262
  raw.repoRemotes = { ...raw.repoRemotes, [repoId]: SAMPLE_REMOTE };
32980
33263
  writeFileSync42(resolvedFile, `${JSON.stringify(raw, null, 2)}
@@ -33352,7 +33635,7 @@ watermark: ${state.watermark(routeSlug(route2.route))}
33352
33635
  plan,
33353
33636
  label,
33354
33637
  uid: process.getuid?.() ?? 0,
33355
- system: plan.mechanism === "systemd" && existsSync57(systemUnitPathFor(label)),
33638
+ system: plan.mechanism === "systemd" && existsSync58(systemUnitPathFor(label)),
33356
33639
  stamp: readDaemonStamp(cfg.ship.stateDir)
33357
33640
  });
33358
33641
  })();
@@ -33368,7 +33651,7 @@ watermark: ${state.watermark(routeSlug(route2.route))}
33368
33651
  }
33369
33652
  for (const r of repos) {
33370
33653
  const remote = r.config.branch.remote;
33371
- if (existsSync57(r.dir)) {
33654
+ if (existsSync58(r.dir)) {
33372
33655
  pushAuth.push({
33373
33656
  route: c.route,
33374
33657
  repo: r.name,
@@ -33445,12 +33728,13 @@ watermark: ${state.watermark(routeSlug(route2.route))}
33445
33728
  }
33446
33729
  }
33447
33730
  for (const message of roleCapWarnings(cfg.ship)) problems.push({ severity: "note", kind: "role_cap_above_ship_cap", message });
33731
+ for (const f of routeAvatarFailures(cfg.ship.stateDir, route2.route)) problems.push({ severity: "note", kind: "persona_avatar_upload_failed", route: route2.route, message: `${f.role} persona avatar failed to upload: ${f.detail}`, remedy: "run `crew agents sync` again" });
33448
33732
  if (daemonLiveness) {
33449
33733
  const dp = daemonProblem(daemonLiveness, route2.route);
33450
33734
  if (dp) problems.push(dp);
33451
33735
  else passed++;
33452
33736
  }
33453
- const runtimeDir = runtimeDirWarning(process.platform, process.getuid?.() ?? null, existsSync57, userInfo2().username);
33737
+ const runtimeDir = runtimeDirWarning(process.platform, process.getuid?.() ?? null, existsSync58, userInfo2().username);
33454
33738
  if (runtimeDir) problems.push({ severity: "attention", kind: "runtime_dir_missing", message: runtimeDir });
33455
33739
  if (!flag("offline")) {
33456
33740
  const shipKind = await doctorShipKind(route2, cfg.ship);
@@ -33497,6 +33781,8 @@ routes: ${cfg.routes.map((c) => c.route).join(", ")}
33497
33781
  `
33498
33782
  );
33499
33783
  for (const w of roleCapWarnings(cfg.ship)) process.stdout.write(`role concurrency: WARN ${w}
33784
+ `);
33785
+ for (const r of cfg.routes) for (const f of routeAvatarFailures(cfg.ship.stateDir, r.route)) process.stdout.write(`persona avatar: WARN ${r.route}: ${f.role} avatar failed to upload (${f.detail}); run \`crew agents sync\` again
33500
33786
  `);
33501
33787
  for (const t of rejectedTunnels(cfg.ship.stateDir)) process.stdout.write(`relay tunnel: ATTENTION ${tunnelRejectedMessage(t.workspaceId, t.quickExits)}
33502
33788
  `);
@@ -33515,7 +33801,7 @@ routes: ${cfg.routes.map((c) => c.route).join(", ")}
33515
33801
  }
33516
33802
  try {
33517
33803
  const evFile = eventFileFor(cfg.ship.stateDir);
33518
- const evSize = existsSync57(evFile) ? statSync17(evFile).size : 0;
33804
+ const evSize = existsSync58(evFile) ? statSync17(evFile).size : 0;
33519
33805
  process.stdout.write(
33520
33806
  evSize > cfg.ship.eventsRotateBytes * 4 ? `events log: WARN ${evFile} is ${Math.round(evSize / 1048576)} MB (> 4x eventsRotateBytes); run \`crew reap\` to rotate it
33521
33807
  ` : "events log: ok\n"
@@ -33526,7 +33812,7 @@ routes: ${cfg.routes.map((c) => c.route).join(", ")}
33526
33812
  const unitPlan = planInstall(cfg.ship, CREW_HOME, host, detectSystemd(), "run", installContext());
33527
33813
  const abandons = unitAbandonsAgents(unitPlan, (p) => {
33528
33814
  try {
33529
- return readFileSync52(p, "utf8");
33815
+ return readFileSync53(p, "utf8");
33530
33816
  } catch {
33531
33817
  return null;
33532
33818
  }
@@ -33541,7 +33827,7 @@ routes: ${cfg.routes.map((c) => c.route).join(", ")}
33541
33827
  const pPlan = planInstall(cfg.ship, CREW_HOME, host, true, "passengers", installContext());
33542
33828
  const keeps = unitAbandonsAgents(pPlan, (p) => {
33543
33829
  try {
33544
- return readFileSync52(p, "utf8");
33830
+ return readFileSync53(p, "utf8");
33545
33831
  } catch {
33546
33832
  return null;
33547
33833
  }
@@ -33555,7 +33841,7 @@ routes: ${cfg.routes.map((c) => c.route).join(", ")}
33555
33841
  if (host === "linux" && detectSystemd()) {
33556
33842
  const ctl = planDaemonControl(CREW_HOME, host, true);
33557
33843
  const unitPlan = planInstall(cfg.ship, CREW_HOME, host, true, "run", installContext());
33558
- if (ctl.statusCommand && unitPlan.unitPaths.some((p) => existsSync57(p))) {
33844
+ if (ctl.statusCommand && unitPlan.unitPaths.some((p) => existsSync58(p))) {
33559
33845
  const st = spawnSync13(ctl.statusCommand[0], ctl.statusCommand.slice(1), { cwd: CREW_HOME, encoding: "utf8" });
33560
33846
  if (!st.error && st.status !== 0) {
33561
33847
  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");