@tablation/crew 0.144.0 → 0.145.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/cli.js +106 -72
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -14407,10 +14407,13 @@ import { existsSync as existsSync32, readdirSync as readdirSync12, statSync as s
14407
14407
  import { join as join35 } from "path";
14408
14408
 
14409
14409
  // src/run-snapshot.ts
14410
- import { closeSync as closeSync5, existsSync as existsSync31, fstatSync, openSync as openSync5, readSync as readSync2, readdirSync as readdirSync11, statSync as statSync10, readFileSync as readFileSync32 } from "fs";
14410
+ import { closeSync as closeSync5, existsSync as existsSync31, fstatSync, openSync as openSync5, readSync as readSync2, readdirSync as readdirSync11, statSync as statSync10, readFileSync as readFileSync32, writeFileSync as writeFileSync23, renameSync as renameSync5 } from "fs";
14411
14411
  import { join as join34 } from "path";
14412
14412
  var TAIL_BYTES = 256 * 1024;
14413
14413
  var EXCERPT_CHARS = 280;
14414
+ function endsWithQuestion(text2) {
14415
+ return /\?[\s"'”’)\]*_`]*$/.test(text2.trim());
14416
+ }
14414
14417
  function lastStreamEvent(streamPath) {
14415
14418
  let fd;
14416
14419
  try {
@@ -14442,7 +14445,8 @@ function lastStreamEvent(streamPath) {
14442
14445
  const text2 = b.text.replace(/\s+/g, " ").trim();
14443
14446
  return {
14444
14447
  text: text2.length > EXCERPT_CHARS ? `${text2.slice(0, EXCERPT_CHARS - 1)}\u2026` : text2,
14445
- at: new Date(st.mtimeMs).toISOString()
14448
+ at: new Date(st.mtimeMs).toISOString(),
14449
+ question: endsWithQuestion(text2)
14446
14450
  };
14447
14451
  }
14448
14452
  }
@@ -14491,6 +14495,24 @@ function lastRunsBySeat(stateDir) {
14491
14495
  }
14492
14496
  return out;
14493
14497
  }
14498
+ var notesPathFor = (streamPath) => `${streamPath}.notes.json`;
14499
+ function readRunNotes(streamPath) {
14500
+ try {
14501
+ const parsed = JSON.parse(readFileSync32(notesPathFor(streamPath), "utf8"));
14502
+ return Array.isArray(parsed) ? parsed : [];
14503
+ } catch {
14504
+ return [];
14505
+ }
14506
+ }
14507
+ function appendRunNote(streamPath, note) {
14508
+ try {
14509
+ const path = notesPathFor(streamPath);
14510
+ const tmp = `${path}.${process.pid}.tmp`;
14511
+ writeFileSync23(tmp, JSON.stringify([...readRunNotes(streamPath), note]));
14512
+ renameSync5(tmp, path);
14513
+ } catch {
14514
+ }
14515
+ }
14494
14516
 
14495
14517
  // src/live-runs.ts
14496
14518
  function liveRuns(stateDir, isAlive = runIsAlive) {
@@ -14591,6 +14613,10 @@ function describeRun(run4, route2, seatIds, worktreeOf = (d, n) => {
14591
14613
  lastEvent: lastStreamEvent(run4.streamPath),
14592
14614
  // CREW-3247: a live run needs attention when it has outlived its wall-clock limit. A run that
14593
14615
  // failed is finished and reported on its seat's `lastRun` instead.
14616
+ // CREW-3248: operator notes sent to this run through the control API, kept past the pane that sent them.
14617
+ notes: readRunNotes(run4.streamPath),
14618
+ // CREW-3248: the serving periscope preview for this run's ticket, or null when it has none.
14619
+ previewUrl: run4.ticketRecordId ? o.previews?.get(run4.ticketRecordId) ?? null : null,
14594
14620
  attention: run4.deadline && Date.parse(run4.deadline) < (o.now ?? Date.now()) ? "past_deadline" : null
14595
14621
  };
14596
14622
  }
@@ -15520,7 +15546,7 @@ function managedGitIdentityWarnings(kind, identity) {
15520
15546
 
15521
15547
  // src/selftest.ts
15522
15548
  import { spawn as spawn7 } from "child_process";
15523
- import { existsSync as existsSync34, mkdirSync as mkdirSync22, mkdtempSync as mkdtempSync2, readFileSync as readFileSync33, rmSync as rmSync17, writeFileSync as writeFileSync23 } from "fs";
15549
+ import { existsSync as existsSync34, mkdirSync as mkdirSync22, mkdtempSync as mkdtempSync2, readFileSync as readFileSync33, rmSync as rmSync17, writeFileSync as writeFileSync24 } from "fs";
15524
15550
  import { tmpdir as tmpdir5 } from "os";
15525
15551
  import { join as join36 } from "path";
15526
15552
  var SELFTEST_TIMEOUT_MS = 12e4;
@@ -15734,7 +15760,7 @@ function recordSelftest(stateDir, results) {
15734
15760
  const all = readSelftest(stateDir);
15735
15761
  for (const r of results) all[r.toolchain] = r;
15736
15762
  mkdirSync22(stateDir, { recursive: true });
15737
- writeFileSync23(fileFor2(stateDir), `${JSON.stringify(all, null, 2)}
15763
+ writeFileSync24(fileFor2(stateDir), `${JSON.stringify(all, null, 2)}
15738
15764
  `);
15739
15765
  }
15740
15766
  function doctorSelftestLines(stored, toolchains) {
@@ -15955,7 +15981,7 @@ function rosterMarkdown(roster, meId) {
15955
15981
  }
15956
15982
 
15957
15983
  // src/connect-resume.ts
15958
- import { mkdirSync as mkdirSync23, readFileSync as readFileSync34, rmSync as rmSync18, writeFileSync as writeFileSync24 } from "fs";
15984
+ import { mkdirSync as mkdirSync23, readFileSync as readFileSync34, rmSync as rmSync18, writeFileSync as writeFileSync25 } from "fs";
15959
15985
  import { dirname as dirname17, join as join37 } from "path";
15960
15986
  function lastSessionFile(stateDir) {
15961
15987
  return join37(stateDir, "connect-session.json");
@@ -15977,7 +16003,7 @@ function readPointers(stateDir) {
15977
16003
  function writePointers(stateDir, pointers) {
15978
16004
  const file = lastSessionFile(stateDir);
15979
16005
  mkdirSync23(dirname17(file), { recursive: true });
15980
- writeFileSync24(file, `${JSON.stringify(pointers, null, 2)}
16006
+ writeFileSync25(file, `${JSON.stringify(pointers, null, 2)}
15981
16007
  `, { mode: 384 });
15982
16008
  }
15983
16009
  function rememberSession(stateDir, host, workspaceSlug) {
@@ -16062,7 +16088,7 @@ async function signOutSessions(o) {
16062
16088
  }
16063
16089
 
16064
16090
  // src/reset.ts
16065
- import { existsSync as existsSync35, mkdirSync as mkdirSync24, readFileSync as readFileSync35, readdirSync as readdirSync14, rmSync as rmSync19, statSync as statSync12, writeFileSync as writeFileSync25 } from "fs";
16091
+ import { existsSync as existsSync35, mkdirSync as mkdirSync24, readFileSync as readFileSync35, readdirSync as readdirSync14, rmSync as rmSync19, statSync as statSync12, writeFileSync as writeFileSync26 } from "fs";
16066
16092
  import { dirname as dirname18, join as join38 } from "path";
16067
16093
  import { hostFromUrl as hostFromUrl3 } from "@tablation/client";
16068
16094
  function clonedCheckoutsFile(stateDir) {
@@ -16081,7 +16107,7 @@ function recordClonedCheckout(stateDir, dir) {
16081
16107
  if (known.includes(dir)) return;
16082
16108
  const file = clonedCheckoutsFile(stateDir);
16083
16109
  mkdirSync24(dirname18(file), { recursive: true });
16084
- writeFileSync25(file, `${JSON.stringify([...known, dir], null, 2)}
16110
+ writeFileSync26(file, `${JSON.stringify([...known, dir], null, 2)}
16085
16111
  `);
16086
16112
  }
16087
16113
  var mark = (dryRun) => dryRun ? "would-remove" : "removed";
@@ -16262,7 +16288,7 @@ async function runDeprovision(o, fx, deps) {
16262
16288
  }
16263
16289
 
16264
16290
  // src/pool-member.ts
16265
- import { mkdirSync as mkdirSync25, readFileSync as readFileSync36, renameSync as renameSync5, writeFileSync as writeFileSync26 } from "fs";
16291
+ import { mkdirSync as mkdirSync25, readFileSync as readFileSync36, renameSync as renameSync6, writeFileSync as writeFileSync27 } from "fs";
16266
16292
  import { homedir as homedir8 } from "os";
16267
16293
  import { dirname as dirname19, join as join39 } from "path";
16268
16294
  var POOL_EXIT = { ok: 0, failed: 1, credential: 2 };
@@ -16521,9 +16547,9 @@ function fileMemberStore(dir) {
16521
16547
  write(f) {
16522
16548
  mkdirSync25(dirname19(file), { recursive: true, mode: 448 });
16523
16549
  const tmp = `${file}.tmp`;
16524
- writeFileSync26(tmp, `${JSON.stringify(f)}
16550
+ writeFileSync27(tmp, `${JSON.stringify(f)}
16525
16551
  `, { mode: 384 });
16526
- renameSync5(tmp, file);
16552
+ renameSync6(tmp, file);
16527
16553
  }
16528
16554
  };
16529
16555
  }
@@ -16579,7 +16605,7 @@ import { hostname as hostname3 } from "os";
16579
16605
  // src/machine-id.ts
16580
16606
  import { execFileSync as execFileSync12 } from "child_process";
16581
16607
  import { createHash as createHash8 } from "crypto";
16582
- import { existsSync as existsSync36, mkdirSync as mkdirSync26, readFileSync as readFileSync37, writeFileSync as writeFileSync27 } from "fs";
16608
+ import { existsSync as existsSync36, mkdirSync as mkdirSync26, readFileSync as readFileSync37, writeFileSync as writeFileSync28 } from "fs";
16583
16609
  import { dirname as dirname20, join as join40 } from "path";
16584
16610
  function machineIdPathFor(stateDir) {
16585
16611
  return join40(stateDir, "machine-id");
@@ -16615,7 +16641,7 @@ function ensureMachineId(stateDir, opts = {}) {
16615
16641
  if (!raw) return void 0;
16616
16642
  const hashed = sha256(raw);
16617
16643
  mkdirSync26(dirname20(path), { recursive: true });
16618
- writeFileSync27(path, `${hashed}
16644
+ writeFileSync28(path, `${hashed}
16619
16645
  `, { mode: 384 });
16620
16646
  return hashed;
16621
16647
  }
@@ -16628,7 +16654,7 @@ function matchShipRows(ships, shipName2, machineId) {
16628
16654
 
16629
16655
  // src/provision.ts
16630
16656
  import { spawnSync as spawnSync9 } from "child_process";
16631
- import { existsSync as existsSync37, readFileSync as readFileSync38, writeFileSync as writeFileSync28 } from "fs";
16657
+ import { existsSync as existsSync37, readFileSync as readFileSync38, writeFileSync as writeFileSync29 } from "fs";
16632
16658
  import { hostname as hostname2 } from "os";
16633
16659
  import { parseDocument as parseDocument3, isMap as isMap2, isScalar } from "yaml";
16634
16660
 
@@ -17260,7 +17286,7 @@ function realProvisionDeps(crewHome) {
17260
17286
  const entry = routes?.items?.find((r) => r.get("route") === route2);
17261
17287
  if (!entry) throw new Error(`route ${route2} is not in ${file}`);
17262
17288
  if (entry.get("enabled") === true) return false;
17263
- writeFileSync28(file, planEnable(text2, route2));
17289
+ writeFileSync29(file, planEnable(text2, route2));
17264
17290
  return true;
17265
17291
  },
17266
17292
  installState() {
@@ -17307,7 +17333,7 @@ function realProvisionDeps(crewHome) {
17307
17333
  const doc = parseDocument3(readFileSync38(file, "utf8"));
17308
17334
  if (doc.getIn(["ship", key]) === value2) return false;
17309
17335
  doc.setIn(["ship", key], value2);
17310
- writeFileSync28(file, doc.toString());
17336
+ writeFileSync29(file, doc.toString());
17311
17337
  return true;
17312
17338
  },
17313
17339
  applyManagedDefaults() {
@@ -17315,7 +17341,7 @@ function realProvisionDeps(crewHome) {
17315
17341
  if (!file) return [];
17316
17342
  const doc = parseDocument3(readFileSync38(file, "utf8"));
17317
17343
  const wrote = applyManagedDefaultsToDoc(doc);
17318
- if (wrote.length) writeFileSync28(file, doc.toString());
17344
+ if (wrote.length) writeFileSync29(file, doc.toString());
17319
17345
  return wrote;
17320
17346
  },
17321
17347
  ensureGitIdentity(name, email) {
@@ -18473,7 +18499,7 @@ function diskFullStop(state) {
18473
18499
  }
18474
18500
 
18475
18501
  // src/poll.ts
18476
- import { writeFileSync as writeFileSync29 } from "fs";
18502
+ import { writeFileSync as writeFileSync30 } from "fs";
18477
18503
  import { join as join42 } from "path";
18478
18504
 
18479
18505
  // src/stalled.ts
@@ -18876,7 +18902,7 @@ function writeDigest(o, d, role, stateDir, runId, own) {
18876
18902
 
18877
18903
  ${body}` : body;
18878
18904
  const path = digestPath(stateDir, routeSlug(o.route.route), role, runId);
18879
- writeFileSync29(path, text2);
18905
+ writeFileSync30(path, text2);
18880
18906
  o.emit.emit(`queue digest written for ${role} (${Buffer.byteLength(text2)} bytes)`, {
18881
18907
  data: { role, bytes: Buffer.byteLength(text2) }
18882
18908
  });
@@ -18999,7 +19025,7 @@ async function claimStillHeld(tracker, t, buildingStatus, affinity) {
18999
19025
  }
19000
19026
 
19001
19027
  // src/repo-refresh.ts
19002
- import { existsSync as existsSync40, mkdirSync as mkdirSync27, readFileSync as readFileSync39, writeFileSync as writeFileSync30 } from "fs";
19028
+ import { existsSync as existsSync40, mkdirSync as mkdirSync27, readFileSync as readFileSync39, writeFileSync as writeFileSync31 } from "fs";
19003
19029
  import { dirname as dirname22 } from "path";
19004
19030
  var REFRESH_COOLDOWN_MS = 2 * 6e4;
19005
19031
  var UNSERVABLE_PASSES_BEFORE_ATTENTION = 3;
@@ -19033,7 +19059,7 @@ function persistRepoRows(stateDir, routeName, rows) {
19033
19059
  const raw = JSON.parse(readFileSync39(path, "utf8"));
19034
19060
  applyRepoRows(raw, rows);
19035
19061
  mkdirSync27(dirname22(path), { recursive: true });
19036
- writeFileSync30(path, `${JSON.stringify(raw, null, 2)}
19062
+ writeFileSync31(path, `${JSON.stringify(raw, null, 2)}
19037
19063
  `);
19038
19064
  }
19039
19065
  async function refreshUnknownRepos(o) {
@@ -19538,7 +19564,7 @@ function platformStuckNote(repo, required, ship, issueIds) {
19538
19564
 
19539
19565
  // src/connect-wizard.ts
19540
19566
  import { delimiter, dirname as dirname23, join as join44 } from "path";
19541
- import { accessSync as accessSync3, constants as constants3, existsSync as existsSync41, mkdirSync as mkdirSync28, writeFileSync as writeFileSync31 } from "fs";
19567
+ import { accessSync as accessSync3, constants as constants3, existsSync as existsSync41, mkdirSync as mkdirSync28, writeFileSync as writeFileSync32 } from "fs";
19542
19568
  import { stringify as stringify3 } from "yaml";
19543
19569
  var HOST_PASSENGERS_DOCS_URL = "https://crew.tablation.dev/host-passengers";
19544
19570
  function shouldRunWizard(opts) {
@@ -19623,7 +19649,7 @@ ${routeBlock}`;
19623
19649
  function writeNewConfig(path, text2) {
19624
19650
  mkdirSync28(dirname23(path), { recursive: true });
19625
19651
  try {
19626
- writeFileSync31(path, text2, { mode: 384, flag: "wx" });
19652
+ writeFileSync32(path, text2, { mode: 384, flag: "wx" });
19627
19653
  return true;
19628
19654
  } catch (e) {
19629
19655
  if (e.code === "EEXIST") return false;
@@ -19822,7 +19848,7 @@ async function collectDiagnostics(d) {
19822
19848
  }
19823
19849
 
19824
19850
  // src/release-run.ts
19825
- import { readFileSync as readFileSync40, writeFileSync as writeFileSync32, existsSync as existsSync42, copyFileSync, mkdirSync as mkdirSync29, mkdtempSync as mkdtempSync3, rmSync as rmSync20 } from "fs";
19851
+ import { readFileSync as readFileSync40, writeFileSync as writeFileSync33, existsSync as existsSync42, copyFileSync, mkdirSync as mkdirSync29, mkdtempSync as mkdtempSync3, rmSync as rmSync20 } from "fs";
19826
19852
  import { dirname as dirname25, join as join46 } from "path";
19827
19853
  import { tmpdir as tmpdir6, hostname as hostname4 } from "os";
19828
19854
 
@@ -20644,7 +20670,7 @@ async function bump(o, size) {
20644
20670
  o.emit.error(`no version field in ${f}`);
20645
20671
  return null;
20646
20672
  }
20647
- writeTextAt(f, out, writeFileSync32);
20673
+ writeTextAt(f, out, writeFileSync33);
20648
20674
  }
20649
20675
  return version;
20650
20676
  }
@@ -20658,7 +20684,7 @@ function writeChangelog(o, version, entries) {
20658
20684
  return;
20659
20685
  }
20660
20686
  const existing = existsAt(path, existsSync42) ? readTextAt(path, (p) => readFileSync40(p, "utf8")) : "# Changelog\n";
20661
- writeTextAt(path, insertChangelogSection(existing, section), writeFileSync32);
20687
+ writeTextAt(path, insertChangelogSection(existing, section), writeFileSync33);
20662
20688
  }
20663
20689
  async function confirm(o, expected) {
20664
20690
  if (!o.repo.hooks.released) return void 0;
@@ -21591,7 +21617,7 @@ import { spawnSync as spawnSync12 } from "child_process";
21591
21617
  import { existsSync as existsSync49, readFileSync as readFileSync46 } from "fs";
21592
21618
 
21593
21619
  // src/daemon.ts
21594
- import { existsSync as existsSync48, mkdirSync as mkdirSync35, readFileSync as readFileSync45, readdirSync as readdirSync15, rmSync as rmSync22, statSync as statSync14, writeFileSync as writeFileSync36 } from "fs";
21620
+ import { existsSync as existsSync48, mkdirSync as mkdirSync35, readFileSync as readFileSync45, readdirSync as readdirSync15, rmSync as rmSync22, statSync as statSync14, writeFileSync as writeFileSync37 } from "fs";
21595
21621
  import { join as join51 } from "path";
21596
21622
  import { randomBytes } from "crypto";
21597
21623
 
@@ -21682,7 +21708,7 @@ function nextRoles(decision, ran) {
21682
21708
  }
21683
21709
 
21684
21710
  // src/noop-runs.ts
21685
- import { existsSync as existsSync43, mkdirSync as mkdirSync30, readFileSync as readFileSync41, renameSync as renameSync6, writeFileSync as writeFileSync33 } from "fs";
21711
+ import { existsSync as existsSync43, mkdirSync as mkdirSync30, readFileSync as readFileSync41, renameSync as renameSync7, writeFileSync as writeFileSync34 } from "fs";
21686
21712
  import { join as join47 } from "path";
21687
21713
  var NOOP_DELAYS_MS = [5, 15, 60].map((m) => m * 6e4);
21688
21714
  var DEFAULT_NOOP_REPEATS = 3;
@@ -21700,9 +21726,9 @@ function readNoopRuns(stateDir) {
21700
21726
  function writeNoopRuns(stateDir, state) {
21701
21727
  mkdirSync30(stateDir, { recursive: true });
21702
21728
  const file = noopRunsPath(stateDir);
21703
- writeFileSync33(`${file}.tmp`, `${JSON.stringify(state, null, 2)}
21729
+ writeFileSync34(`${file}.tmp`, `${JSON.stringify(state, null, 2)}
21704
21730
  `);
21705
- renameSync6(`${file}.tmp`, file);
21731
+ renameSync7(`${file}.tmp`, file);
21706
21732
  }
21707
21733
  function noopBackedOff(stateDir, recordId, now = Date.now()) {
21708
21734
  const e = readNoopRuns(stateDir)[recordId];
@@ -21777,7 +21803,7 @@ async function settleNoopRun(o) {
21777
21803
  }
21778
21804
 
21779
21805
  // src/ship-name.ts
21780
- import { existsSync as existsSync44, mkdirSync as mkdirSync31, readFileSync as readFileSync42, renameSync as renameSync7, writeFileSync as writeFileSync34 } from "fs";
21806
+ import { existsSync as existsSync44, mkdirSync as mkdirSync31, readFileSync as readFileSync42, renameSync as renameSync8, writeFileSync as writeFileSync35 } from "fs";
21781
21807
  import { dirname as dirname26 } from "path";
21782
21808
  import { parseDocument as parseDocument4 } from "yaml";
21783
21809
  var ShipNameError = class extends Error {
@@ -21859,9 +21885,9 @@ function writeSyncedName(resolvedFile, name) {
21859
21885
  raw.shipName = name;
21860
21886
  mkdirSync31(dirname26(resolvedFile), { recursive: true });
21861
21887
  const tmp = `${resolvedFile}.tmp${process.pid}`;
21862
- writeFileSync34(tmp, `${JSON.stringify(raw, null, 2)}
21888
+ writeFileSync35(tmp, `${JSON.stringify(raw, null, 2)}
21863
21889
  `);
21864
- renameSync7(tmp, resolvedFile);
21890
+ renameSync8(tmp, resolvedFile);
21865
21891
  }
21866
21892
  async function reconcileShipName(i) {
21867
21893
  let local = i.ship.name;
@@ -21891,7 +21917,7 @@ async function reconcileShipName(i) {
21891
21917
  if (result.status !== "ok") return result;
21892
21918
  if (result.action === "adopt" || result.action === "row-wins") {
21893
21919
  const text2 = readFileSync42(i.configFile, "utf8");
21894
- writeFileSync34(i.configFile, setShipNameInYaml(text2, result.name));
21920
+ writeFileSync35(i.configFile, setShipNameInYaml(text2, result.name));
21895
21921
  i.ship.name = result.name;
21896
21922
  if (result.action === "row-wins") {
21897
21923
  i.emit?.warn(
@@ -22206,7 +22232,7 @@ async function runPeriscopeIdlePass(d) {
22206
22232
  }
22207
22233
 
22208
22234
  // src/periscope-cmd.ts
22209
- import { existsSync as existsSync47, mkdirSync as mkdirSync34, readFileSync as readFileSync44, rmSync as rmSync21, writeFileSync as writeFileSync35 } from "fs";
22235
+ import { existsSync as existsSync47, mkdirSync as mkdirSync34, readFileSync as readFileSync44, rmSync as rmSync21, writeFileSync as writeFileSync36 } from "fs";
22210
22236
  import { join as join50 } from "path";
22211
22237
  var PeriscopeError = class extends Error {
22212
22238
  };
@@ -22225,7 +22251,7 @@ function removePeriscopePrior(stateDir, ticketRecordId) {
22225
22251
  function writePeriscopePrior(stateDir, ticketRecordId, prior) {
22226
22252
  try {
22227
22253
  mkdirSync34(priorDir(stateDir), { recursive: true });
22228
- writeFileSync35(priorPath(stateDir, ticketRecordId), JSON.stringify(prior));
22254
+ writeFileSync36(priorPath(stateDir, ticketRecordId), JSON.stringify(prior));
22229
22255
  } catch {
22230
22256
  }
22231
22257
  }
@@ -22829,7 +22855,7 @@ function daemonStampFor(stateDir) {
22829
22855
  function noteDaemonStarted(stateDir, now = Date.now()) {
22830
22856
  mkdirSync35(stateDir, { recursive: true });
22831
22857
  rmSync22(reloadSentinelFor(stateDir), { force: true });
22832
- writeFileSync36(daemonStampFor(stateDir), `${JSON.stringify({ pid: process.pid, startedAt: now })}
22858
+ writeFileSync37(daemonStampFor(stateDir), `${JSON.stringify({ pid: process.pid, startedAt: now })}
22833
22859
  `);
22834
22860
  }
22835
22861
  function readDaemonStarted(stateDir) {
@@ -23864,7 +23890,7 @@ function startLaunchdDaemon(o) {
23864
23890
  }
23865
23891
 
23866
23892
  // src/daemon-start-failure.ts
23867
- import { existsSync as existsSync50, mkdirSync as mkdirSync36, readFileSync as readFileSync48, unlinkSync as unlinkSync4, writeFileSync as writeFileSync37 } from "fs";
23893
+ import { existsSync as existsSync50, mkdirSync as mkdirSync36, readFileSync as readFileSync48, unlinkSync as unlinkSync4, writeFileSync as writeFileSync38 } from "fs";
23868
23894
  import { dirname as dirname29, join as join52 } from "path";
23869
23895
  var DAEMON_START_FAILED_KEY = "daemon_start_failed";
23870
23896
  var START_FAILURE_BACKOFF_MS = 6e4;
@@ -23889,7 +23915,7 @@ function noteStartFailure(stateDir, reason, nowMs = Date.now()) {
23889
23915
  lastAt: nowIso
23890
23916
  };
23891
23917
  mkdirSync36(stateDir, { recursive: true });
23892
- writeFileSync37(fileFor3(stateDir), JSON.stringify(record));
23918
+ writeFileSync38(fileFor3(stateDir), JSON.stringify(record));
23893
23919
  return record;
23894
23920
  }
23895
23921
  function startFailureDelayMs(count) {
@@ -24044,7 +24070,7 @@ function runForge(a, io) {
24044
24070
 
24045
24071
  // src/release-sandbox.ts
24046
24072
  import { execFile as execFile5 } from "child_process";
24047
- import { mkdirSync as mkdirSync37, writeFileSync as writeFileSync38 } from "fs";
24073
+ import { mkdirSync as mkdirSync37, writeFileSync as writeFileSync39 } from "fs";
24048
24074
  import { dirname as dirname30 } from "path";
24049
24075
  import { promisify as promisify4 } from "util";
24050
24076
  var execFileP4 = promisify4(execFile5);
@@ -24092,7 +24118,7 @@ async function openReleaseSandbox(o) {
24092
24118
  generated = generateSandboxPolicy({ mirrorDir: cfg.mirrorDir, workDir: cfg.workDir, ...o.policy });
24093
24119
  policyFile = o.policyFile;
24094
24120
  mkdirSync37(dirname30(policyFile), { recursive: true });
24095
- writeFileSync38(policyFile, generated.yaml, { mode: 384 });
24121
+ writeFileSync39(policyFile, generated.yaml, { mode: 384 });
24096
24122
  }
24097
24123
  const secrets = { ...process.env };
24098
24124
  const secretKeys = [];
@@ -25245,7 +25271,7 @@ function routeAvatarFailures(stateDir, route2) {
25245
25271
  }
25246
25272
 
25247
25273
  // src/agents-sync-run.ts
25248
- import { existsSync as existsSync53, mkdirSync as mkdirSync38, readFileSync as readFileSync50, writeFileSync as writeFileSync39 } from "fs";
25274
+ import { existsSync as existsSync53, mkdirSync as mkdirSync38, readFileSync as readFileSync50, writeFileSync as writeFileSync40 } from "fs";
25249
25275
  import { dirname as dirname31 } from "path";
25250
25276
  async function runAgentsSync(target, o) {
25251
25277
  const dryRun = o.dryRun ?? false;
@@ -25297,7 +25323,7 @@ async function runAgentsSync(target, o) {
25297
25323
  if (!readOnly) raw.avatarSyncFailures = avatarFailures2;
25298
25324
  if (personaResult.releaseAgentId) raw.releaseAgentId = personaResult.releaseAgentId;
25299
25325
  mkdirSync38(dirname31(resolvedPath), { recursive: true });
25300
- writeFileSync39(resolvedPath, `${JSON.stringify(raw, null, 2)}
25326
+ writeFileSync40(resolvedPath, `${JSON.stringify(raw, null, 2)}
25301
25327
  `);
25302
25328
  if (target.resolved) {
25303
25329
  target.resolved.agentPersonas = personaResult.agentPersonas;
@@ -26357,7 +26383,7 @@ function planEventsSweep(stateDir, retentionDays, now = Date.now()) {
26357
26383
  }
26358
26384
 
26359
26385
  // src/cli.ts
26360
- import { realpathSync as realpathSync3, readFileSync as readFileSync55, existsSync as existsSync60, mkdirSync as mkdirSync42, writeFileSync as writeFileSync42, rmSync as rmSync26, unlinkSync as unlinkSync6, copyFileSync as copyFileSync2, renameSync as renameSync8, statSync as statSync19, readdirSync as readdirSync22 } from "fs";
26386
+ import { realpathSync as realpathSync3, readFileSync as readFileSync55, existsSync as existsSync60, mkdirSync as mkdirSync42, writeFileSync as writeFileSync43, rmSync as rmSync26, unlinkSync as unlinkSync6, copyFileSync as copyFileSync2, renameSync as renameSync9, statSync as statSync19, readdirSync as readdirSync22 } from "fs";
26361
26387
  import { createInterface } from "readline/promises";
26362
26388
 
26363
26389
  // src/periscope-resume.ts
@@ -26436,7 +26462,7 @@ import { dirname as dirOf2, resolve as resolvePath } from "path";
26436
26462
  import { existsSync as existsSync56, readdirSync as readdirSync18, statSync as statSync17 } from "fs";
26437
26463
  import { join as join57 } from "path";
26438
26464
  function builtVersion() {
26439
- return true ? "0.144.0" : null;
26465
+ return true ? "0.145.0" : null;
26440
26466
  }
26441
26467
  var REBUILD_HINT = "rebuild with npm run build";
26442
26468
  function newestMtime(path) {
@@ -26626,7 +26652,7 @@ async function unregisterEndpoint(workspaceId, info, d) {
26626
26652
  import { createServer as createHttpServer } from "http";
26627
26653
  import { spawn as spawn9 } from "child_process";
26628
26654
  import { randomBytes as randomBytes2 } from "crypto";
26629
- import { existsSync as existsSync57, mkdirSync as mkdirSync39, readFileSync as readFileSync53, writeFileSync as writeFileSync40, unlinkSync as unlinkSync5, readdirSync as readdirSync19 } from "fs";
26655
+ import { existsSync as existsSync57, mkdirSync as mkdirSync39, readFileSync as readFileSync53, writeFileSync as writeFileSync41, unlinkSync as unlinkSync5, readdirSync as readdirSync19 } from "fs";
26630
26656
  import { join as join58 } from "path";
26631
26657
 
26632
26658
  // src/secret-compare.ts
@@ -26734,7 +26760,7 @@ function readPersistedSyncDaemon(stateDir, workspaceId) {
26734
26760
  function writePersistedSyncDaemon(stateDir, state) {
26735
26761
  const path = syncDaemonStatePath(stateDir, state.workspaceId);
26736
26762
  mkdirSync39(join58(stateDir, "passengers"), { recursive: true });
26737
- writeFileSync40(path, `${JSON.stringify(state, null, 2)}
26763
+ writeFileSync41(path, `${JSON.stringify(state, null, 2)}
26738
26764
  `);
26739
26765
  }
26740
26766
  function removePersistedSyncDaemon(stateDir, workspaceId) {
@@ -27766,6 +27792,13 @@ async function postRunMessage(deps, run4, body) {
27766
27792
  const acceptsInput = input.accepts();
27767
27793
  const state = acceptsInput ? await input.deliver(recorded, body.author || void 0) : "carried_forward";
27768
27794
  if (!acceptsInput) await markMessage(input.target, rowId, recorded.id, "carried_forward");
27795
+ appendRunNote(live2.streamPath, {
27796
+ id: recorded.id,
27797
+ text: text2,
27798
+ author: body.author || null,
27799
+ at: recorded.occurredAt ?? (/* @__PURE__ */ new Date()).toISOString(),
27800
+ state: state === "delivered" ? "delivered" : "carried_forward"
27801
+ });
27769
27802
  return reply2(200, { cycleId: recorded.id, state, acceptsInput });
27770
27803
  } catch (e) {
27771
27804
  return err2(409, `the platform did not take the note: ${e.message}. ${carry}`);
@@ -27966,7 +27999,7 @@ import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/
27966
27999
 
27967
28000
  // src/periscope-endpoints.ts
27968
28001
  import { randomBytes as randomBytes3 } from "crypto";
27969
- import { chmodSync as chmodSync5, existsSync as existsSync59, mkdirSync as mkdirSync41, readdirSync as readdirSync21, readFileSync as readFileSync54, rmSync as rmSync25, writeFileSync as writeFileSync41 } from "fs";
28002
+ import { chmodSync as chmodSync5, existsSync as existsSync59, mkdirSync as mkdirSync41, readdirSync as readdirSync21, readFileSync as readFileSync54, rmSync as rmSync25, writeFileSync as writeFileSync42 } from "fs";
27970
28003
  import { join as join61 } from "path";
27971
28004
  var secretDir = (stateDir) => join61(stateDir, "periscope-mcp");
27972
28005
  var secretFile = (stateDir, id) => join61(secretDir(stateDir), `${id}.json`);
@@ -27976,7 +28009,7 @@ function mintPeriscopeSecret(stateDir, ticketRecordId) {
27976
28009
  mkdirSync41(secretDir(stateDir), { recursive: true, mode: 448 });
27977
28010
  const secret = randomBytes3(32).toString("base64url");
27978
28011
  const file = secretFile(stateDir, ticketRecordId);
27979
- writeFileSync41(file, `${JSON.stringify({ secret })}
28012
+ writeFileSync42(file, `${JSON.stringify({ secret })}
27980
28013
  `, { mode: 384 });
27981
28014
  chmodSync5(file, 384);
27982
28015
  return secret;
@@ -28001,7 +28034,7 @@ function readPeriscopeEndpoint(stateDir, ticketRecordId) {
28001
28034
  }
28002
28035
  function writePeriscopeEndpoint(stateDir, rec) {
28003
28036
  mkdirSync41(endpointDir(stateDir), { recursive: true });
28004
- writeFileSync41(endpointFile(stateDir, rec.ticketRecordId), `${JSON.stringify(rec, null, 2)}
28037
+ writeFileSync42(endpointFile(stateDir, rec.ticketRecordId), `${JSON.stringify(rec, null, 2)}
28005
28038
  `);
28006
28039
  }
28007
28040
  function removePeriscopeEndpointRecord(stateDir, ticketRecordId) {
@@ -29104,7 +29137,7 @@ if (command === "passenger-sync-daemon") {
29104
29137
  stateDir: cfg.ship.stateDir,
29105
29138
  configFile: cfg.configFile,
29106
29139
  readFile: (p) => readFileSync55(p, "utf8"),
29107
- writeFile: (p, t) => writeFileSync42(p, t),
29140
+ writeFile: (p, t) => writeFileSync43(p, t),
29108
29141
  stdin: () => readFileSync55(0, "utf8"),
29109
29142
  env: process.env
29110
29143
  }
@@ -29527,7 +29560,7 @@ if (command === "passenger-sync-daemon") {
29527
29560
  for (const a of plan.actions) {
29528
29561
  if (a.kind === "enable") {
29529
29562
  if (prompter && !await prompter.confirm(`Route ${a.route} passes every check \u2014 set enabled: true in ${cfg.configFile}?`, false)) continue;
29530
- writeFileSync42(cfg.configFile, planEnable(readFileSync55(cfg.configFile, "utf8"), a.route));
29563
+ writeFileSync43(cfg.configFile, planEnable(readFileSync55(cfg.configFile, "utf8"), a.route));
29531
29564
  enabledSound.add(a.route);
29532
29565
  changed2.push(`enabled route ${a.route} in ${cfg.configFile}`);
29533
29566
  } else {
@@ -31364,7 +31397,7 @@ ${f.tail.trimEnd()}
31364
31397
  const raw = existsSync60(resolvedPath) ? JSON.parse(readFileSync55(resolvedPath, "utf8")) : {};
31365
31398
  raw.agentSkills = result.agentSkills;
31366
31399
  mkdirSync42(dirOf2(resolvedPath), { recursive: true });
31367
- writeFileSync42(resolvedPath, `${JSON.stringify(raw, null, 2)}
31400
+ writeFileSync43(resolvedPath, `${JSON.stringify(raw, null, 2)}
31368
31401
  `);
31369
31402
  }
31370
31403
  if (result.outcomes.some((o) => o.action === "diverged")) process.exitCode = 1;
@@ -31387,7 +31420,7 @@ ${f.tail.trimEnd()}
31387
31420
  throw e;
31388
31421
  }
31389
31422
  const oldName = cfg.ship.name;
31390
- writeFileSync42(cfg.configFile, setShipNameInYaml(readFileSync55(cfg.configFile, "utf8"), newName));
31423
+ writeFileSync43(cfg.configFile, setShipNameInYaml(readFileSync55(cfg.configFile, "utf8"), newName));
31391
31424
  cfg.ship.name = newName;
31392
31425
  let renameMachineId;
31393
31426
  try {
@@ -31517,19 +31550,19 @@ ${f.tail.trimEnd()}
31517
31550
  let cleared;
31518
31551
  if (clear2) {
31519
31552
  const plan = clearRouteHooks(configText, a.route, a.name);
31520
- if (plan.removed.length > 0) writeFileSync42(cfg.configFile, plan.text);
31553
+ if (plan.removed.length > 0) writeFileSync43(cfg.configFile, plan.text);
31521
31554
  cleared = { file: cfg.configFile, removed: plan.removed };
31522
31555
  }
31523
31556
  if (write && suggestion.source === null && recipeIds.length === 0 && hookSpecs.length === 0) throw new ReposError(`nothing to write: ${suggestion.notes[0]}`);
31524
31557
  if (write === "route") {
31525
31558
  const plan = planRouteHooks(configText, a.route, a.name, picked.hooks, { replace: flag("replace") });
31526
- writeFileSync42(cfg.configFile, plan.text);
31559
+ writeFileSync43(cfg.configFile, plan.text);
31527
31560
  written = { target: "route", file: cfg.configFile, hooks: plan.written, kept: plan.kept, replaced: plan.replaced };
31528
31561
  } else if (write === "repo") {
31529
31562
  const have = existingRepoConfig(files);
31530
31563
  if (have) throw new ReposError(`${resolvePath(dir, have)} already exists; not overwriting it`);
31531
31564
  const file = resolvePath(dir, ".crew.yaml");
31532
- writeFileSync42(file, starterRepoConfig(picked.hooks, picked.release), { flag: "wx" });
31565
+ writeFileSync43(file, starterRepoConfig(picked.hooks, picked.release), { flag: "wx" });
31533
31566
  written = { target: "repo", file, hooks: Object.keys(picked.hooks), kept: [], replaced: [] };
31534
31567
  }
31535
31568
  if (flag("json")) {
@@ -31697,7 +31730,7 @@ ${f.tail.trimEnd()}
31697
31730
  throw new ReposError(`${e.message}${authHint}
31698
31731
  crew.yaml was not changed`);
31699
31732
  }
31700
- writeFileSync42(cfg.configFile, plan2.text);
31733
+ writeFileSync43(cfg.configFile, plan2.text);
31701
31734
  if (plan2.droppedDir) process.stderr.write(`crew repos: dropped dir: ${plan2.droppedDir} from route ${routeName} \u2014 it is not a checkout (the clone base); checkouts now live under repos:
31702
31735
  `);
31703
31736
  say("attached", { route: routeName, name: plan2.name, dir: plan2.target, mode: plan2.mode }, `cloned and attached ${plan2.target} to ${routeName} as ${plan2.mode === "dir" ? "dir" : `repos.${plan2.name}`} in ${cfg.configFile}`);
@@ -31760,11 +31793,11 @@ ${f.tail.trimEnd()}
31760
31793
  const raw = JSON.parse(readFileSync55(resolvedFile, "utf8"));
31761
31794
  raw.repoNames = { ...raw.repoNames, [created.id]: String(rowPayload.name) };
31762
31795
  raw.repoRemotes = { ...raw.repoRemotes, [created.id]: String(rowPayload.remote) };
31763
- writeFileSync42(resolvedFile, `${JSON.stringify(raw, null, 2)}
31796
+ writeFileSync43(resolvedFile, `${JSON.stringify(raw, null, 2)}
31764
31797
  `);
31765
31798
  }
31766
31799
  }
31767
- writeFileSync42(cfg.configFile, plan.text);
31800
+ writeFileSync43(cfg.configFile, plan.text);
31768
31801
  process.stdout.write(`added ${top} to ${routeName} as ${plan.mode === "dir" ? "dir" : `repos.${plan.name}`} in ${cfg.configFile}
31769
31802
  `);
31770
31803
  } catch (e) {
@@ -32139,7 +32172,7 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
32139
32172
  process.exit(2);
32140
32173
  }
32141
32174
  if (found.shipNameAdopted && !dryRun) {
32142
- writeFileSync42(cfg.configFile, setShipNameInYaml(readFileSync55(cfg.configFile, "utf8"), found.shipNameAdopted));
32175
+ writeFileSync43(cfg.configFile, setShipNameInYaml(readFileSync55(cfg.configFile, "utf8"), found.shipNameAdopted));
32143
32176
  cfg.ship.name = found.shipNameAdopted;
32144
32177
  }
32145
32178
  if (found.shipRow) {
@@ -32318,9 +32351,9 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
32318
32351
  mkdirSync42(dirname37(resolvedPath), { recursive: true });
32319
32352
  if (hadPreviousFile) copyFileSync2(resolvedPath, `${resolvedPath}.bak`);
32320
32353
  const tmpPath = `${resolvedPath}.tmp${process.pid}`;
32321
- writeFileSync42(tmpPath, `${JSON.stringify(resolved, null, 2)}
32354
+ writeFileSync43(tmpPath, `${JSON.stringify(resolved, null, 2)}
32322
32355
  `);
32323
- renameSync8(tmpPath, resolvedPath);
32356
+ renameSync9(tmpPath, resolvedPath);
32324
32357
  process.stderr.write(`Resolved ids written to ${resolvedPath}
32325
32358
  `);
32326
32359
  }
@@ -32365,7 +32398,7 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
32365
32398
  `);
32366
32399
  } else {
32367
32400
  mkdirSync42(dirname37(apiKeyFile), { recursive: true });
32368
- writeFileSync42(apiKeyFile, `${apiKeyVar}=${apiKey}
32401
+ writeFileSync43(apiKeyFile, `${apiKeyVar}=${apiKey}
32369
32402
  `, { mode: 384 });
32370
32403
  process.stderr.write(`API key written to ${apiKeyFile}
32371
32404
  `);
@@ -33792,7 +33825,7 @@ ${where.join("\n")}`);
33792
33825
  break;
33793
33826
  }
33794
33827
  mkdirSync42(cfg.ship.stateDir, { recursive: true });
33795
- writeFileSync42(sentinel, `${(/* @__PURE__ */ new Date()).toISOString()}
33828
+ writeFileSync43(sentinel, `${(/* @__PURE__ */ new Date()).toISOString()}
33796
33829
  `);
33797
33830
  process.stdout.write(
33798
33831
  "crew reload: requested \u2014 the daemon relaunches with the new config once its running agents end (it starts no new work meanwhile); if it is busy, `crew reload --now` forces the relaunch and interrupts them\n"
@@ -33909,7 +33942,7 @@ ${where.join("\n")}`);
33909
33942
  }
33910
33943
  if (configured2.some((r) => r.dir === dir)) {
33911
33944
  try {
33912
- writeFileSync42(cfg.configFile, planRepoRemove(configText, cfgBase, route2.route, dir).text);
33945
+ writeFileSync43(cfg.configFile, planRepoRemove(configText, cfgBase, route2.route, dir).text);
33913
33946
  } catch (e) {
33914
33947
  if (e instanceof ReposError) fail2(e.message);
33915
33948
  throw e;
@@ -33921,7 +33954,7 @@ ${where.join("\n")}`);
33921
33954
  const raw = JSON.parse(readFileSync55(resolvedFile, "utf8"));
33922
33955
  if (raw.repoNames) delete raw.repoNames[row.id];
33923
33956
  if (raw.repoRemotes) delete raw.repoRemotes[row.id];
33924
- writeFileSync42(resolvedFile, `${JSON.stringify(raw, null, 2)}
33957
+ writeFileSync43(resolvedFile, `${JSON.stringify(raw, null, 2)}
33925
33958
  `);
33926
33959
  }
33927
33960
  }
@@ -33938,8 +33971,8 @@ ${where.join("\n")}`);
33938
33971
  }
33939
33972
  if (fresh) {
33940
33973
  mkdirSync42(dir, { recursive: true });
33941
- writeFileSync42(join63(dir, "README.md"), SAMPLE_README);
33942
- writeFileSync42(join63(dir, ".crew.yaml"), SAMPLE_CREW_YAML);
33974
+ writeFileSync43(join63(dir, "README.md"), SAMPLE_README);
33975
+ writeFileSync43(join63(dir, ".crew.yaml"), SAMPLE_CREW_YAML);
33943
33976
  const g = (...a) => {
33944
33977
  const r = spawnSync14("git", a, { cwd: dir, encoding: "utf8" });
33945
33978
  if (r.status !== 0) fail2(`git ${a[0]} failed in ${dir}: ${(r.stderr || r.stdout).trim()}`);
@@ -33961,13 +33994,13 @@ ${where.join("\n")}`);
33961
33994
  const raw = JSON.parse(readFileSync55(resolvedFile, "utf8"));
33962
33995
  raw.repoNames = { ...raw.repoNames, [repoId]: SAMPLE_REPO };
33963
33996
  raw.repoRemotes = { ...raw.repoRemotes, [repoId]: SAMPLE_REMOTE };
33964
- writeFileSync42(resolvedFile, `${JSON.stringify(raw, null, 2)}
33997
+ writeFileSync43(resolvedFile, `${JSON.stringify(raw, null, 2)}
33965
33998
  `);
33966
33999
  }
33967
34000
  }
33968
34001
  if (!configured2.some((r) => r.dir === dir)) {
33969
34002
  try {
33970
- writeFileSync42(cfg.configFile, planRepoAdd({ text: configText, base: cfgBase, route: route2.route, path: dir, name: SAMPLE_REPO }).text);
34003
+ writeFileSync43(cfg.configFile, planRepoAdd({ text: configText, base: cfgBase, route: route2.route, path: dir, name: SAMPLE_REPO }).text);
33971
34004
  } catch (e) {
33972
34005
  if (e instanceof ReposError) fail2(e.message);
33973
34006
  throw e;
@@ -34117,6 +34150,7 @@ ${where.join("\n")}`);
34117
34150
  );
34118
34151
  const lastRuns = lastRunsBySeat(cfg.ship.stateDir);
34119
34152
  const periscopes = await periscopesForStatus(cfg.ship.stateDir);
34153
+ const runPreviews = new Map(periscopes.filter((p) => p.serving).map((p) => [p.ticketRecordId, p.url]));
34120
34154
  if (flag("json")) {
34121
34155
  const nameSync = await reconcileRouteShipName({ route: route2, ship: cfg.ship, configFile: cfg.configFile, readOnly: true });
34122
34156
  const repos = await resolvedRepos(route2);
@@ -34188,7 +34222,7 @@ ${where.join("\n")}`);
34188
34222
  seats: seats2
34189
34223
  },
34190
34224
  // Additive (CREW-2822): every live run on this ship. `version` stays 1.
34191
- runs: runs.map((x) => describeRun(x, route2, seatIds, void 0, { titles: runTitles })),
34225
+ runs: runs.map((x) => describeRun(x, route2, seatIds, void 0, { titles: runTitles, previews: runPreviews })),
34192
34226
  // Additive (CREW-2857): every live periscope on this ship, from its local record. `version` stays 1.
34193
34227
  periscopes,
34194
34228
  watermark: state.watermark(routeSlug(route2.route)),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tablation/crew",
3
- "version": "0.144.0",
3
+ "version": "0.145.0",
4
4
  "description": "A standing team of headless agents that picks work off a Tablation board, does it on a machine you control, and reports back.",
5
5
  "type": "module",
6
6
  "license": "MIT",