lobstah 0.8.5 → 0.8.7

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/runner.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // packages/runner/src/index.ts
2
- import * as fs39 from "node:fs";
2
+ import * as fs40 from "node:fs";
3
3
  import * as path35 from "node:path";
4
4
 
5
5
  // packages/core/dist/types.js
@@ -75,7 +75,7 @@ function evidencePath(id, lane) {
75
75
  }
76
76
 
77
77
  // packages/core/dist/config.js
78
- import * as fs28 from "node:fs";
78
+ import * as fs29 from "node:fs";
79
79
 
80
80
  // packages/core/dist/configured-traps.js
81
81
  import * as fs2 from "node:fs";
@@ -133,7 +133,7 @@ function parseConfiguredTraps(raw, grounds) {
133
133
 
134
134
  // packages/core/dist/config.js
135
135
  import * as os4 from "node:os";
136
- import * as path24 from "node:path";
136
+ import * as path25 from "node:path";
137
137
 
138
138
  // node_modules/.pnpm/smol-toml@1.8.0/node_modules/smol-toml/dist/date.js
139
139
  var DATE_TIME_RE = /^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|[-+]\d{2}:\d{2})?$/i;
@@ -826,8 +826,8 @@ function firstMeaningfulLine(...outputs) {
826
826
  }
827
827
 
828
828
  // packages/core/dist/pr-poll.js
829
- import * as fs27 from "node:fs";
830
- import * as path23 from "node:path";
829
+ import * as fs28 from "node:fs";
830
+ import * as path24 from "node:path";
831
831
 
832
832
  // packages/core/dist/dir-lock.js
833
833
  import fs3 from "node:fs";
@@ -991,12 +991,12 @@ function readPrs() {
991
991
  }
992
992
 
993
993
  // packages/core/dist/watch.js
994
- import fs26 from "node:fs";
995
- import * as path22 from "node:path";
994
+ import fs27 from "node:fs";
995
+ import * as path23 from "node:path";
996
996
 
997
997
  // packages/core/dist/notices.js
998
- import fs24 from "node:fs";
999
- import * as path20 from "node:path";
998
+ import fs25 from "node:fs";
999
+ import * as path21 from "node:path";
1000
1000
 
1001
1001
  // packages/core/dist/attachments.js
1002
1002
  function attachmentBlock(attachments) {
@@ -1009,6 +1009,47 @@ function attachmentBlock(attachments) {
1009
1009
  ].join("\n");
1010
1010
  }
1011
1011
 
1012
+ // packages/core/dist/reports.js
1013
+ import * as fs5 from "node:fs";
1014
+ import * as path5 from "node:path";
1015
+ var REPORT_MD = "report.md";
1016
+ var REPORT_JSON = "report.json";
1017
+ function helmReportsRoot() {
1018
+ return path5.join(lobstahHome(), "reports");
1019
+ }
1020
+ function dispatchReportKey(id, lane) {
1021
+ return `report:${lane}:${id}`;
1022
+ }
1023
+ var GROUNDS_RE = /^[A-Za-z0-9._-]+$/;
1024
+ var RID_RE = /^[a-f0-9]{8}$/;
1025
+ function reportDir(key) {
1026
+ const d = /^report:(work|chore):([A-Za-z0-9-]+)$/.exec(key);
1027
+ if (d)
1028
+ return path5.join(laneDirs(d[1]).state, d[2]);
1029
+ const h = /^report:helm:([^:]+):([^:]+)$/.exec(key);
1030
+ if (h && GROUNDS_RE.test(h[1]) && !h[1].startsWith(".") && RID_RE.test(h[2]))
1031
+ return path5.join(helmReportsRoot(), h[1], h[2]);
1032
+ return void 0;
1033
+ }
1034
+ function readReportAt(dir) {
1035
+ try {
1036
+ const meta = JSON.parse(fs5.readFileSync(path5.join(dir, REPORT_JSON), "utf8"));
1037
+ return typeof meta.key === "string" && typeof meta.filedAt === "string" ? meta : void 0;
1038
+ } catch {
1039
+ return void 0;
1040
+ }
1041
+ }
1042
+ function readReport(key) {
1043
+ const dir = reportDir(key);
1044
+ const meta = dir ? readReportAt(dir) : void 0;
1045
+ return meta?.key === key ? meta : void 0;
1046
+ }
1047
+ function reportMarkdownPath(key) {
1048
+ const dir = reportDir(key);
1049
+ const file2 = dir && path5.join(dir, REPORT_MD);
1050
+ return file2 && readReport(key) && fs5.existsSync(file2) ? file2 : void 0;
1051
+ }
1052
+
1012
1053
  // packages/core/dist/decisions.js
1013
1054
  var DECISION_DETAIL_MAX = 64 * 1024;
1014
1055
  var ANSWER_TYPES = {
@@ -1033,19 +1074,19 @@ var ANSWER_TYPES = {
1033
1074
  var ANSWER_EXTENSIONS = Object.keys(ANSWER_TYPES);
1034
1075
 
1035
1076
  // packages/core/dist/roster.js
1036
- import * as fs5 from "node:fs";
1037
- import * as path5 from "node:path";
1077
+ import * as fs6 from "node:fs";
1078
+ import * as path6 from "node:path";
1038
1079
  function rosterDir() {
1039
- return path5.join(lobstahHome(), "roster");
1080
+ return path6.join(lobstahHome(), "roster");
1040
1081
  }
1041
1082
  function rosterPath(trapId) {
1042
- return path5.join(rosterDir(), `${trapId}.json`);
1083
+ return path6.join(rosterDir(), `${trapId}.json`);
1043
1084
  }
1044
1085
  function readRoster(trapId) {
1045
1086
  if (!/^[a-z0-9-]+$/.test(trapId))
1046
1087
  return void 0;
1047
1088
  try {
1048
- const parsed = JSON.parse(fs5.readFileSync(rosterPath(trapId), "utf8"));
1089
+ const parsed = JSON.parse(fs6.readFileSync(rosterPath(trapId), "utf8"));
1049
1090
  return parsed.trapId === trapId && typeof parsed.name === "string" ? parsed : void 0;
1050
1091
  } catch {
1051
1092
  return void 0;
@@ -1054,7 +1095,7 @@ function readRoster(trapId) {
1054
1095
  function listRoster() {
1055
1096
  let files;
1056
1097
  try {
1057
- files = fs5.readdirSync(rosterDir()).filter((f) => f.endsWith(".json"));
1098
+ files = fs6.readdirSync(rosterDir()).filter((f) => f.endsWith(".json"));
1058
1099
  } catch {
1059
1100
  return [];
1060
1101
  }
@@ -1062,14 +1103,14 @@ function listRoster() {
1062
1103
  }
1063
1104
 
1064
1105
  // packages/core/dist/desktop-lease.js
1065
- import fs6 from "node:fs";
1066
- import path6 from "node:path";
1106
+ import fs7 from "node:fs";
1107
+ import path7 from "node:path";
1067
1108
  function desktopLeaseFile() {
1068
- return path6.join(lobstahHome(), "desktop-lease.json");
1109
+ return path7.join(lobstahHome(), "desktop-lease.json");
1069
1110
  }
1070
1111
  function readDesktopLease() {
1071
1112
  try {
1072
- return JSON.parse(fs6.readFileSync(desktopLeaseFile(), "utf8"));
1113
+ return JSON.parse(fs7.readFileSync(desktopLeaseFile(), "utf8"));
1073
1114
  } catch {
1074
1115
  return void 0;
1075
1116
  }
@@ -1079,7 +1120,7 @@ function withDesktopLeaseLock(action) {
1079
1120
  }
1080
1121
  function writeDesktopLease(registration, now2) {
1081
1122
  const file2 = desktopLeaseFile(), temporary = uniqueTempPath(file2);
1082
- fs6.writeFileSync(temporary, JSON.stringify({ trapId: registration.trapId, sessionId: registration.sessionId, expiresAt: now2 + loadConfig().soak.ttlSecs * 1e3 }));
1123
+ fs7.writeFileSync(temporary, JSON.stringify({ trapId: registration.trapId, sessionId: registration.sessionId, expiresAt: now2 + loadConfig().soak.ttlSecs * 1e3 }));
1083
1124
  atomicRenameSync(temporary, file2);
1084
1125
  }
1085
1126
  function acquireDesktopLease(registration, now2 = Date.now()) {
@@ -1099,18 +1140,18 @@ function acquireDesktopLease(registration, now2 = Date.now()) {
1099
1140
  function releaseDesktopLease(trapId) {
1100
1141
  withDesktopLeaseLock(() => {
1101
1142
  if (readDesktopLease()?.trapId === trapId)
1102
- fs6.rmSync(desktopLeaseFile(), { force: true });
1143
+ fs7.rmSync(desktopLeaseFile(), { force: true });
1103
1144
  });
1104
1145
  }
1105
1146
 
1106
1147
  // packages/core/dist/soak.js
1107
- import * as fs20 from "node:fs";
1108
- import * as path17 from "node:path";
1148
+ import * as fs21 from "node:fs";
1149
+ import * as path18 from "node:path";
1109
1150
 
1110
1151
  // packages/core/dist/heavy.js
1111
1152
  import { execFileSync as execFileSync2 } from "node:child_process";
1112
- import fs7 from "node:fs";
1113
- import * as path7 from "node:path";
1153
+ import fs8 from "node:fs";
1154
+ import * as path8 from "node:path";
1114
1155
 
1115
1156
  // packages/core/dist/harness-process.js
1116
1157
  import { execFileSync } from "node:child_process";
@@ -1134,12 +1175,12 @@ var HEAVY_WAITER_GRACE_MS = 5 * 6e4;
1134
1175
  var UNVERIFIED_SEEN_MS = 30 * 6e4;
1135
1176
  var START_CACHE_MS = 2e4;
1136
1177
  var HISTORY_MAX_BYTES = 1024 * 1024;
1137
- var heavyDir = () => path7.join(lobstahHome(), "heavy");
1138
- var lineDir = () => path7.join(heavyDir(), "line");
1139
- var ticketFile = (seq) => path7.join(lineDir(), `${String(seq).padStart(10, "0")}.json`);
1178
+ var heavyDir = () => path8.join(lobstahHome(), "heavy");
1179
+ var lineDir = () => path8.join(heavyDir(), "line");
1180
+ var ticketFile = (seq) => path8.join(lineDir(), `${String(seq).padStart(10, "0")}.json`);
1140
1181
  function withLine(action) {
1141
- fs7.mkdirSync(lineDir(), { recursive: true });
1142
- return withDirLock(path7.join(heavyDir(), "lock"), action, {
1182
+ fs8.mkdirSync(lineDir(), { recursive: true });
1183
+ return withDirLock(path8.join(heavyDir(), "lock"), action, {
1143
1184
  staleMs: 3e4,
1144
1185
  waitMs: 15e3,
1145
1186
  pauseMs: 25,
@@ -1149,27 +1190,27 @@ function withLine(action) {
1149
1190
  function writeTicket(ticket) {
1150
1191
  const file2 = ticketFile(ticket.seq);
1151
1192
  const tmp = uniqueTempPath(file2);
1152
- fs7.writeFileSync(tmp, JSON.stringify(ticket, null, 2));
1193
+ fs8.writeFileSync(tmp, JSON.stringify(ticket, null, 2));
1153
1194
  atomicRenameSync(tmp, file2);
1154
1195
  }
1155
1196
  function readLine() {
1156
1197
  let names;
1157
1198
  try {
1158
- names = fs7.readdirSync(lineDir());
1199
+ names = fs8.readdirSync(lineDir());
1159
1200
  } catch {
1160
1201
  return [];
1161
1202
  }
1162
1203
  const out = [];
1163
1204
  for (const name of names.filter((n) => n.endsWith(".json"))) {
1164
- const file2 = path7.join(lineDir(), name);
1205
+ const file2 = path8.join(lineDir(), name);
1165
1206
  try {
1166
- const t = JSON.parse(fs7.readFileSync(file2, "utf8"));
1207
+ const t = JSON.parse(fs8.readFileSync(file2, "utf8"));
1167
1208
  if (!Number.isInteger(t.seq) || !Number.isInteger(t.pid))
1168
1209
  throw new Error("not a ticket");
1169
1210
  out.push(t);
1170
1211
  } catch (err) {
1171
1212
  if (err.code !== "ENOENT")
1172
- fs7.rmSync(file2, { force: true });
1213
+ fs8.rmSync(file2, { force: true });
1173
1214
  }
1174
1215
  }
1175
1216
  return out.sort((a, b) => a.seq - b.seq);
@@ -1239,16 +1280,17 @@ function dropHeavyTickets(match, reason) {
1239
1280
  function liveHeavyTickets(match, now2 = Date.now()) {
1240
1281
  return readLine().filter((t) => (match.dispatch !== void 0 && t.dispatch === match.dispatch || match.trap !== void 0 && t.trap === match.trap) && (t.state === "waiting" ? t.deadAt === void 0 && ownerAlive(t, now2) : t.state !== "cancelled" && (ownerAlive(t, now2) || groupAlive(t))));
1241
1282
  }
1283
+ var HISTORY_TAIL_BYTES = 64 * 1024;
1242
1284
 
1243
1285
  // packages/core/dist/remote-link.js
1244
1286
  var CHUNK = 1 << 20;
1245
1287
 
1246
1288
  // packages/core/dist/status.js
1247
- import * as fs18 from "node:fs";
1289
+ import * as fs19 from "node:fs";
1248
1290
 
1249
1291
  // packages/core/dist/activity.js
1250
- import * as fs8 from "node:fs";
1251
- import * as path8 from "node:path";
1292
+ import * as fs9 from "node:fs";
1293
+ import * as path9 from "node:path";
1252
1294
  var ACTIVITY_KINDS = ["tool", "message", "thinking", "waiting"];
1253
1295
  var ACTIVITY_SUMMARY_MAX = 80;
1254
1296
  var SECRET_PATTERNS = [
@@ -1302,7 +1344,7 @@ function relativeTarget(p, root) {
1302
1344
  if (!root)
1303
1345
  return baseName(p);
1304
1346
  const win = isWindowsPath(p) || isWindowsPath(root);
1305
- const lib = win ? path8.win32 : path8.posix;
1347
+ const lib = win ? path9.win32 : path9.posix;
1306
1348
  if (!lib.isAbsolute(p))
1307
1349
  return p.replace(/\\/g, "/");
1308
1350
  const rel = lib.relative(win ? root : root.replace(/\\/g, "/"), p);
@@ -1371,7 +1413,7 @@ function activityFromEvent(ev, root) {
1371
1413
  }
1372
1414
  function atomicWrite(file2, content) {
1373
1415
  const tmp = uniqueTempPath(file2);
1374
- fs8.writeFileSync(tmp, content);
1416
+ fs9.writeFileSync(tmp, content);
1375
1417
  atomicRenameSync(tmp, file2);
1376
1418
  }
1377
1419
  function writeActivity(id, lane, a) {
@@ -1380,7 +1422,7 @@ function writeActivity(id, lane, a) {
1380
1422
  }
1381
1423
  function readActivity(id, lane) {
1382
1424
  try {
1383
- const parsed = JSON.parse(fs8.readFileSync(activityPath(id, lane), "utf8"));
1425
+ const parsed = JSON.parse(fs9.readFileSync(activityPath(id, lane), "utf8"));
1384
1426
  if (typeof parsed.at !== "string" || typeof parsed.summary !== "string")
1385
1427
  return void 0;
1386
1428
  if (!ACTIVITY_KINDS.includes(parsed.kind))
@@ -1454,8 +1496,8 @@ var ActivityTracker = class {
1454
1496
  };
1455
1497
 
1456
1498
  // packages/core/dist/stats.js
1457
- import * as fs15 from "node:fs";
1458
- import * as path13 from "node:path";
1499
+ import * as fs16 from "node:fs";
1500
+ import * as path14 from "node:path";
1459
1501
 
1460
1502
  // packages/core/dist/worker-metadata.js
1461
1503
  var WORKER_EFFORTS = ["none", "minimal", "low", "medium", "high", "xhigh", "max", "ultra"];
@@ -1548,18 +1590,18 @@ function sanitizeWorker(value) {
1548
1590
  }
1549
1591
 
1550
1592
  // packages/core/dist/catch-context.js
1551
- import * as fs14 from "node:fs";
1552
- import * as path12 from "node:path";
1593
+ import * as fs15 from "node:fs";
1594
+ import * as path13 from "node:path";
1553
1595
 
1554
1596
  // packages/core/dist/helm.js
1555
- import * as fs13 from "node:fs";
1556
- import * as path11 from "node:path";
1597
+ import * as fs14 from "node:fs";
1598
+ import * as path12 from "node:path";
1557
1599
 
1558
1600
  // packages/core/dist/disk.js
1559
- import * as fs9 from "node:fs";
1601
+ import * as fs10 from "node:fs";
1560
1602
  var GB = 1024 ** 3;
1561
1603
  var statfsFreeBytes = (dir) => {
1562
- const s = fs9.statfsSync(dir);
1604
+ const s = fs10.statfsSync(dir);
1563
1605
  return Number(s.bavail) * Number(s.bsize);
1564
1606
  };
1565
1607
  function formatGB(bytes) {
@@ -1567,18 +1609,18 @@ function formatGB(bytes) {
1567
1609
  }
1568
1610
 
1569
1611
  // packages/core/dist/pools.js
1570
- import * as fs12 from "node:fs";
1571
- import * as path10 from "node:path";
1612
+ import * as fs13 from "node:fs";
1613
+ import * as path11 from "node:path";
1572
1614
 
1573
1615
  // packages/core/dist/worktrees.js
1574
- import * as fs11 from "node:fs";
1575
- import * as path9 from "node:path";
1616
+ import * as fs12 from "node:fs";
1617
+ import * as path10 from "node:path";
1576
1618
 
1577
1619
  // packages/core/dist/evidence.js
1578
- import * as fs10 from "node:fs";
1620
+ import * as fs11 from "node:fs";
1579
1621
  function readEvidence(id, lane) {
1580
1622
  try {
1581
- return JSON.parse(fs10.readFileSync(evidencePath(id, lane), "utf8"));
1623
+ return JSON.parse(fs11.readFileSync(evidencePath(id, lane), "utf8"));
1582
1624
  } catch {
1583
1625
  return {};
1584
1626
  }
@@ -1586,26 +1628,26 @@ function readEvidence(id, lane) {
1586
1628
  function mergeEvidence(id, lane, patch) {
1587
1629
  const file2 = evidencePath(id, lane);
1588
1630
  const tmp = uniqueTempPath(file2);
1589
- fs10.writeFileSync(tmp, JSON.stringify({ ...readEvidence(id, lane), ...patch }, null, 2));
1631
+ fs11.writeFileSync(tmp, JSON.stringify({ ...readEvidence(id, lane), ...patch }, null, 2));
1590
1632
  atomicRenameSync(tmp, file2);
1591
1633
  }
1592
1634
 
1593
1635
  // packages/core/dist/worktrees.js
1594
1636
  var LANES = ["work", "chore"];
1595
1637
  function worktreePath(id) {
1596
- return path9.join(lobstahHome(), "worktrees", id);
1638
+ return path10.join(lobstahHome(), "worktrees", id);
1597
1639
  }
1598
1640
  function readRecord(file2) {
1599
1641
  try {
1600
- const r = JSON.parse(fs11.readFileSync(file2, "utf8"));
1642
+ const r = JSON.parse(fs12.readFileSync(file2, "utf8"));
1601
1643
  return typeof r.path === "string" ? r : void 0;
1602
1644
  } catch {
1603
1645
  return void 0;
1604
1646
  }
1605
1647
  }
1606
1648
  function ownerOfPath(p) {
1607
- const rel = path9.relative(path9.join(lobstahHome(), "worktrees"), p);
1608
- if (!rel || rel.startsWith("..") || path9.isAbsolute(rel))
1649
+ const rel = path10.relative(path10.join(lobstahHome(), "worktrees"), p);
1650
+ if (!rel || rel.startsWith("..") || path10.isAbsolute(rel))
1609
1651
  return void 0;
1610
1652
  return rel.split(/[\\/]/)[0];
1611
1653
  }
@@ -1618,7 +1660,7 @@ function dispatchWorktree(id, lane) {
1618
1660
  }
1619
1661
  const dirs = laneDirs(l);
1620
1662
  for (const dir of [dirs.active, dirs.done]) {
1621
- const rec = readRecord(path9.join(dir, id, "worktree.json"));
1663
+ const rec = readRecord(path10.join(dir, id, "worktree.json"));
1622
1664
  if (rec) {
1623
1665
  const owner = rec.of ?? ownerOfPath(rec.path) ?? id;
1624
1666
  return { path: rec.path, owner, reused: owner !== id };
@@ -1630,7 +1672,7 @@ function dispatchWorktree(id, lane) {
1630
1672
  function laneOf(id) {
1631
1673
  for (const l of LANES) {
1632
1674
  const d = laneDirs(l);
1633
- if (fs11.existsSync(path9.join(d.queue, `${id}.json`)) || fs11.existsSync(path9.join(d.active, id)) || fs11.existsSync(path9.join(d.done, id))) {
1675
+ if (fs12.existsSync(path10.join(d.queue, `${id}.json`)) || fs12.existsSync(path10.join(d.active, id)) || fs12.existsSync(path10.join(d.done, id))) {
1634
1676
  return l;
1635
1677
  }
1636
1678
  }
@@ -1650,7 +1692,7 @@ function followUpAncestors(id, lane) {
1650
1692
  function chainWorktree(followUp) {
1651
1693
  for (const id of [followUp, ...followUpAncestors(followUp)]) {
1652
1694
  const wt = dispatchWorktree(id, laneOf(id));
1653
- if (fs11.existsSync(wt.path))
1695
+ if (fs12.existsSync(wt.path))
1654
1696
  return { ...wt, from: id };
1655
1697
  }
1656
1698
  return void 0;
@@ -1665,27 +1707,27 @@ function processAlive(pid) {
1665
1707
  }
1666
1708
  }
1667
1709
  function worktreeGitDir(wt) {
1668
- const dotGit = path9.join(wt, ".git");
1710
+ const dotGit = path10.join(wt, ".git");
1669
1711
  try {
1670
- const st = fs11.statSync(dotGit);
1712
+ const st = fs12.statSync(dotGit);
1671
1713
  if (st.isDirectory())
1672
1714
  return dotGit;
1673
- const m = /^gitdir:\s*(.+?)\s*$/m.exec(fs11.readFileSync(dotGit, "utf8"));
1674
- return m ? path9.resolve(wt, m[1]) : void 0;
1715
+ const m = /^gitdir:\s*(.+?)\s*$/m.exec(fs12.readFileSync(dotGit, "utf8"));
1716
+ return m ? path10.resolve(wt, m[1]) : void 0;
1675
1717
  } catch {
1676
1718
  return void 0;
1677
1719
  }
1678
1720
  }
1679
1721
  function worktreeLockFile(wt) {
1680
1722
  const gitDir = worktreeGitDir(wt);
1681
- return gitDir ? path9.join(gitDir, "lobstah.lock") : void 0;
1723
+ return gitDir ? path10.join(gitDir, "lobstah.lock") : void 0;
1682
1724
  }
1683
1725
  function readWorktreeLock(wt) {
1684
1726
  const file2 = worktreeLockFile(wt);
1685
1727
  if (!file2)
1686
1728
  return void 0;
1687
1729
  try {
1688
- return JSON.parse(fs11.readFileSync(file2, "utf8"));
1730
+ return JSON.parse(fs12.readFileSync(file2, "utf8"));
1689
1731
  } catch {
1690
1732
  return void 0;
1691
1733
  }
@@ -1693,7 +1735,7 @@ function readWorktreeLock(wt) {
1693
1735
  function lockIsLive(lock) {
1694
1736
  if (lock.kind === "warm")
1695
1737
  return processAlive(lock.pid) && Date.now() - (Date.parse(lock.at) || 0) < WARM_LOCK_MAX_MS;
1696
- return fs11.existsSync(path9.join(laneDirs(lock.lane).active, lock.id));
1738
+ return fs12.existsSync(path10.join(laneDirs(lock.lane).active, lock.id));
1697
1739
  }
1698
1740
  function worktreeHolder(wt) {
1699
1741
  const lock = readWorktreeLock(wt);
@@ -1706,7 +1748,7 @@ function acquireWorktreeLock(wt, id, lane, kind) {
1706
1748
  return { id: "(no git dir)", lane, pid: 0, at: mine.at };
1707
1749
  for (let attempt2 = 0; attempt2 < 3; attempt2++) {
1708
1750
  try {
1709
- fs11.writeFileSync(file2, JSON.stringify(mine, null, 2), { flag: "wx" });
1751
+ fs12.writeFileSync(file2, JSON.stringify(mine, null, 2), { flag: "wx" });
1710
1752
  return void 0;
1711
1753
  } catch (err) {
1712
1754
  if (err.code !== "EEXIST")
@@ -1714,7 +1756,7 @@ function acquireWorktreeLock(wt, id, lane, kind) {
1714
1756
  }
1715
1757
  let raw;
1716
1758
  try {
1717
- raw = fs11.readFileSync(file2, "utf8");
1759
+ raw = fs12.readFileSync(file2, "utf8");
1718
1760
  } catch {
1719
1761
  continue;
1720
1762
  }
@@ -1725,14 +1767,14 @@ function acquireWorktreeLock(wt, id, lane, kind) {
1725
1767
  held2 = void 0;
1726
1768
  }
1727
1769
  if (held2?.id === id) {
1728
- fs11.writeFileSync(file2, JSON.stringify(mine, null, 2));
1770
+ fs12.writeFileSync(file2, JSON.stringify(mine, null, 2));
1729
1771
  return void 0;
1730
1772
  }
1731
1773
  if (held2 && lockIsLive(held2))
1732
1774
  return held2;
1733
1775
  try {
1734
- if (fs11.readFileSync(file2, "utf8") === raw)
1735
- fs11.rmSync(file2, { force: true });
1776
+ if (fs12.readFileSync(file2, "utf8") === raw)
1777
+ fs12.rmSync(file2, { force: true });
1736
1778
  } catch {
1737
1779
  }
1738
1780
  }
@@ -1744,7 +1786,7 @@ function releaseWorktreeLock(wt, id) {
1744
1786
  if (!file2)
1745
1787
  return;
1746
1788
  if (readWorktreeLock(wt)?.id === id)
1747
- fs11.rmSync(file2, { force: true });
1789
+ fs12.rmSync(file2, { force: true });
1748
1790
  }
1749
1791
 
1750
1792
  // packages/core/dist/slots.js
@@ -1758,28 +1800,28 @@ function isFinished(id, lane) {
1758
1800
 
1759
1801
  // packages/core/dist/pools.js
1760
1802
  function poolsRoot() {
1761
- return path10.join(lobstahHome(), "pools");
1803
+ return path11.join(lobstahHome(), "pools");
1762
1804
  }
1763
1805
  function poolDir(pool) {
1764
- return path10.join(poolsRoot(), pool);
1806
+ return path11.join(poolsRoot(), pool);
1765
1807
  }
1766
1808
  function poolSlotPath(pool, slot) {
1767
- return path10.join(poolDir(pool), String(slot));
1809
+ return path11.join(poolDir(pool), String(slot));
1768
1810
  }
1769
1811
  function slotsDir(pool) {
1770
- return path10.join(poolDir(pool), ".slots");
1812
+ return path11.join(poolDir(pool), ".slots");
1771
1813
  }
1772
1814
  function poolSlotOf(p) {
1773
1815
  const real = (x) => {
1774
1816
  try {
1775
- return fs12.realpathSync.native(x);
1817
+ return fs13.realpathSync.native(x);
1776
1818
  } catch {
1777
- return path10.resolve(x);
1819
+ return path11.resolve(x);
1778
1820
  }
1779
1821
  };
1780
- for (const [rootDir, dir] of [[poolsRoot(), path10.resolve(p)], [real(poolsRoot()), real(p)]]) {
1781
- const rel = path10.relative(rootDir, dir);
1782
- if (!rel || rel.startsWith("..") || path10.isAbsolute(rel))
1822
+ for (const [rootDir, dir] of [[poolsRoot(), path11.resolve(p)], [real(poolsRoot()), real(p)]]) {
1823
+ const rel = path11.relative(rootDir, dir);
1824
+ if (!rel || rel.startsWith("..") || path11.isAbsolute(rel))
1783
1825
  continue;
1784
1826
  const parts = rel.split(/[\\/]/);
1785
1827
  if (parts.length !== 2 || !/^[1-9][0-9]*$/.test(parts[1]))
@@ -1793,20 +1835,20 @@ function poolSlotLabel(pool, slot) {
1793
1835
  }
1794
1836
  function readJson(file2) {
1795
1837
  try {
1796
- return JSON.parse(fs12.readFileSync(file2, "utf8"));
1838
+ return JSON.parse(fs13.readFileSync(file2, "utf8"));
1797
1839
  } catch {
1798
1840
  return void 0;
1799
1841
  }
1800
1842
  }
1801
1843
  function writeJson(file2, value) {
1802
- fs12.mkdirSync(path10.dirname(file2), { recursive: true });
1844
+ fs13.mkdirSync(path11.dirname(file2), { recursive: true });
1803
1845
  const tmp = uniqueTempPath(file2);
1804
- fs12.writeFileSync(tmp, JSON.stringify(value, null, 2));
1846
+ fs13.writeFileSync(tmp, JSON.stringify(value, null, 2));
1805
1847
  atomicRenameSync(tmp, file2);
1806
1848
  }
1807
- var metaFile = (pool, slot) => path10.join(slotsDir(pool), `${slot}.json`);
1808
- var claimFile = (pool, slot) => path10.join(slotsDir(pool), `${slot}.claim.json`);
1809
- var outFile = (pool, slot) => path10.join(slotsDir(pool), `${slot}.out.json`);
1849
+ var metaFile = (pool, slot) => path11.join(slotsDir(pool), `${slot}.json`);
1850
+ var claimFile = (pool, slot) => path11.join(slotsDir(pool), `${slot}.claim.json`);
1851
+ var outFile = (pool, slot) => path11.join(slotsDir(pool), `${slot}.out.json`);
1810
1852
  function readSlotMeta(pool, slot) {
1811
1853
  return readJson(metaFile(pool, slot)) ?? {};
1812
1854
  }
@@ -1826,7 +1868,7 @@ function writeSlotOut(pool, slot, out) {
1826
1868
  writeJson(outFile(pool, slot), out);
1827
1869
  }
1828
1870
  function clearSlotOut(pool, slot) {
1829
- fs12.rmSync(outFile(pool, slot), { force: true });
1871
+ fs13.rmSync(outFile(pool, slot), { force: true });
1830
1872
  }
1831
1873
  function dispatchHolder(dir) {
1832
1874
  const lock = readWorktreeLock(dir);
@@ -1836,7 +1878,7 @@ function poolSlotView(pool, slot) {
1836
1878
  const dir = poolSlotPath(pool, slot);
1837
1879
  const lastClaim = readSlotClaim(pool, slot)?.id;
1838
1880
  const base = { slot, path: dir, ...lastClaim ? { lastClaim } : {} };
1839
- if (!fs12.existsSync(dir)) {
1881
+ if (!fs13.existsSync(dir)) {
1840
1882
  const meta2 = readSlotMeta(pool, slot);
1841
1883
  return { ...base, state: "missing", ...meta2.error ? { reason: meta2.error } : {} };
1842
1884
  }
@@ -1851,8 +1893,8 @@ function poolSlotView(pool, slot) {
1851
1893
  return { ...base, state: "warming", ...meta.error ? { reason: meta.error } : {} };
1852
1894
  return { ...base, state: "free" };
1853
1895
  }
1854
- var warmStateFile = (pool) => path10.join(poolDir(pool), ".warm-state.json");
1855
- var warmLockFile = (pool) => path10.join(poolDir(pool), ".warm.lock");
1896
+ var warmStateFile = (pool) => path11.join(poolDir(pool), ".warm-state.json");
1897
+ var warmLockFile = (pool) => path11.join(poolDir(pool), ".warm.lock");
1856
1898
  var POOL_WARM_MAX_MS = 60 * 6e4;
1857
1899
  function readPoolWarmState(pool) {
1858
1900
  return readJson(warmStateFile(pool)) ?? {};
@@ -1874,15 +1916,15 @@ function poolWarmRunning(pool, now2 = Date.now()) {
1874
1916
  }
1875
1917
  function takePoolWarmLock(pool) {
1876
1918
  const file2 = warmLockFile(pool);
1877
- fs12.mkdirSync(path10.dirname(file2), { recursive: true });
1919
+ fs13.mkdirSync(path11.dirname(file2), { recursive: true });
1878
1920
  const mine = JSON.stringify({ pid: process.pid, at: (/* @__PURE__ */ new Date()).toISOString() });
1879
1921
  for (let attempt2 = 0; attempt2 < 2; attempt2++) {
1880
1922
  try {
1881
- fs12.writeFileSync(file2, mine, { flag: "wx" });
1923
+ fs13.writeFileSync(file2, mine, { flag: "wx" });
1882
1924
  return () => {
1883
1925
  try {
1884
- if (fs12.readFileSync(file2, "utf8") === mine)
1885
- fs12.rmSync(file2, { force: true });
1926
+ if (fs13.readFileSync(file2, "utf8") === mine)
1927
+ fs13.rmSync(file2, { force: true });
1886
1928
  } catch {
1887
1929
  }
1888
1930
  };
@@ -1892,7 +1934,7 @@ function takePoolWarmLock(pool) {
1892
1934
  }
1893
1935
  if (poolWarmRunning(pool))
1894
1936
  return void 0;
1895
- fs12.rmSync(file2, { force: true });
1937
+ fs13.rmSync(file2, { force: true });
1896
1938
  }
1897
1939
  return void 0;
1898
1940
  }
@@ -1902,11 +1944,11 @@ var POOL_RECHECK_MS = 5 * 6e4;
1902
1944
 
1903
1945
  // packages/core/dist/helm.js
1904
1946
  function helmDir() {
1905
- return path11.join(lobstahHome(), "helm");
1947
+ return path12.join(lobstahHome(), "helm");
1906
1948
  }
1907
1949
  function listHelms() {
1908
1950
  try {
1909
- return fs13.readdirSync(helmDir()).filter((f) => f.endsWith(".json")).map((f) => JSON.parse(fs13.readFileSync(path11.join(helmDir(), f), "utf8")));
1951
+ return fs14.readdirSync(helmDir()).filter((f) => f.endsWith(".json")).map((f) => JSON.parse(fs14.readFileSync(path12.join(helmDir(), f), "utf8")));
1910
1952
  } catch {
1911
1953
  return [];
1912
1954
  }
@@ -1918,7 +1960,7 @@ function liveHelms(ttlMs, now2 = Date.now()) {
1918
1960
  // packages/core/dist/catch-context.js
1919
1961
  function readCatchContext(dir, id) {
1920
1962
  try {
1921
- return JSON.parse(fs14.readFileSync(path12.join(dir, `${id}.catch-context`), "utf8"));
1963
+ return JSON.parse(fs15.readFileSync(path13.join(dir, `${id}.catch-context`), "utf8"));
1922
1964
  } catch {
1923
1965
  return {};
1924
1966
  }
@@ -1931,19 +1973,19 @@ function observeLocalCatch(id, lane, phase, now2 = Date.now()) {
1931
1973
  const helms = liveHelms(cfg.helm.ttlSecs * 1e3, now2);
1932
1974
  const present = descriptor?.target ? helms.some((helm) => helm.grounds === descriptor.target.grounds) : repo ? helms.some((h) => h.repos.includes(repo)) : null;
1933
1975
  const next = phase === "claim" ? { claimHelm: present, location: "local" } : { ...old, location: "local", helm: old.claimHelm === true || present === true ? true : old.claimHelm === false && present === false ? false : null };
1934
- const file2 = path12.join(dir, `${id}.catch-context`), tmp = uniqueTempPath(file2);
1976
+ const file2 = path13.join(dir, `${id}.catch-context`), tmp = uniqueTempPath(file2);
1935
1977
  try {
1936
- fs14.writeFileSync(tmp, JSON.stringify(next));
1937
- fs14.renameSync(tmp, file2);
1978
+ fs15.writeFileSync(tmp, JSON.stringify(next));
1979
+ fs15.renameSync(tmp, file2);
1938
1980
  } finally {
1939
- fs14.rmSync(tmp, { force: true });
1981
+ fs15.rmSync(tmp, { force: true });
1940
1982
  }
1941
1983
  }
1942
1984
 
1943
1985
  // packages/core/dist/stats.js
1944
1986
  var DAILY_RETENTION_DAYS = 400;
1945
1987
  function statsPath() {
1946
- return path13.join(lobstahHome(), "stats.json");
1988
+ return path14.join(lobstahHome(), "stats.json");
1947
1989
  }
1948
1990
  function shiftDay(day, days) {
1949
1991
  const [y, m, d] = day.split("-").map(Number);
@@ -1956,7 +1998,7 @@ function localDay(at = Date.now()) {
1956
1998
  function readCatchFacts(stateDir, id) {
1957
1999
  let last;
1958
2000
  try {
1959
- for (const line of fs15.readFileSync(path13.join(stateDir, `${id}.status`), "utf8").split("\n")) {
2001
+ for (const line of fs16.readFileSync(path14.join(stateDir, `${id}.status`), "utf8").split("\n")) {
1960
2002
  if (!line.trim())
1961
2003
  continue;
1962
2004
  try {
@@ -1972,7 +2014,7 @@ function readCatchFacts(stateDir, id) {
1972
2014
  let trap;
1973
2015
  let worker = workerProfile();
1974
2016
  try {
1975
- const evidence = JSON.parse(fs15.readFileSync(path13.join(stateDir, `${id}.evidence`), "utf8"));
2017
+ const evidence = JSON.parse(fs16.readFileSync(path14.join(stateDir, `${id}.evidence`), "utf8"));
1976
2018
  const to = evidence.deliveredTo;
1977
2019
  if (typeof to === "string" && to.startsWith("wt:"))
1978
2020
  trap = to;
@@ -2055,7 +2097,7 @@ function add(store, facts, now2) {
2055
2097
  }
2056
2098
  function backfillSources() {
2057
2099
  const live = ["work", "chore"].map((lane) => ({ dir: laneDirs(lane).state, live: true }));
2058
- const backups = readDirIfPresent(lobstahHome()).filter((name) => name.startsWith("state-backup-")).sort().map((name) => ({ dir: path13.join(lobstahHome(), name), live: false })).filter((s) => fs15.statSync(s.dir).isDirectory());
2100
+ const backups = readDirIfPresent(lobstahHome()).filter((name) => name.startsWith("state-backup-")).sort().map((name) => ({ dir: path14.join(lobstahHome(), name), live: false })).filter((s) => fs16.statSync(s.dir).isDirectory());
2059
2101
  return [...live, ...backups];
2060
2102
  }
2061
2103
  function backfillStats(now2 = Date.now(), alreadyCounted) {
@@ -2127,13 +2169,13 @@ function parseStore(text) {
2127
2169
  var complete = (s) => !!s && s.daily !== void 0;
2128
2170
  function writeStore(store) {
2129
2171
  const file2 = statsPath();
2130
- fs15.mkdirSync(path13.dirname(file2), { recursive: true });
2172
+ fs16.mkdirSync(path14.dirname(file2), { recursive: true });
2131
2173
  const tmp = uniqueTempPath(file2);
2132
- fs15.writeFileSync(tmp, JSON.stringify(store));
2174
+ fs16.writeFileSync(tmp, JSON.stringify(store));
2133
2175
  atomicRenameSync(tmp, file2);
2134
2176
  }
2135
2177
  function withStatsLock(action) {
2136
- fs15.mkdirSync(lobstahHome(), { recursive: true });
2178
+ fs16.mkdirSync(lobstahHome(), { recursive: true });
2137
2179
  return withDirLock(`${statsPath()}.lock`, action, {
2138
2180
  staleMs: 12e4,
2139
2181
  waitMs: 1e4,
@@ -2143,7 +2185,7 @@ function withStatsLock(action) {
2143
2185
  function loadOrBackfill(now2) {
2144
2186
  let text;
2145
2187
  try {
2146
- text = fs15.readFileSync(statsPath(), "utf8");
2188
+ text = fs16.readFileSync(statsPath(), "utf8");
2147
2189
  } catch (err) {
2148
2190
  if (err.code !== "ENOENT")
2149
2191
  throw err;
@@ -2170,7 +2212,7 @@ function loadOrBackfill(now2) {
2170
2212
  return store2;
2171
2213
  }
2172
2214
  if (text !== void 0)
2173
- fs15.renameSync(statsPath(), `${statsPath()}.unreadable-${now2}`);
2215
+ fs16.renameSync(statsPath(), `${statsPath()}.unreadable-${now2}`);
2174
2216
  const store = backfillStats(now2);
2175
2217
  writeStore(store);
2176
2218
  return store;
@@ -2190,18 +2232,18 @@ function recordCatch(id, lane, now2 = Date.now()) {
2190
2232
  }
2191
2233
 
2192
2234
  // packages/core/dist/cache-paths.js
2193
- import * as fs16 from "node:fs";
2194
- import * as path14 from "node:path";
2235
+ import * as fs17 from "node:fs";
2236
+ import * as path15 from "node:path";
2195
2237
  var heldCacheLocks = /* @__PURE__ */ new Set();
2196
2238
  function validCacheGlob(pattern) {
2197
- return pattern.length > 0 && !/[\\\0:]/.test(pattern) && !path14.posix.isAbsolute(pattern) && !pattern.split("/").some((part) => !part || part === "." || part === ".." || part.toLowerCase() === ".git");
2239
+ return pattern.length > 0 && !/[\\\0:]/.test(pattern) && !path15.posix.isAbsolute(pattern) && !pattern.split("/").some((part) => !part || part === "." || part === ".." || part.toLowerCase() === ".git");
2198
2240
  }
2199
2241
  function withTrapCacheLock(trapId, action) {
2200
2242
  if (heldCacheLocks.has(trapId))
2201
2243
  return action();
2202
- const dir = path14.join(lobstahHome(), "cache-locks");
2203
- fs16.mkdirSync(dir, { recursive: true });
2204
- return withDirLock(path14.join(dir, `trap-${encodeURIComponent(trapId)}`), () => {
2244
+ const dir = path15.join(lobstahHome(), "cache-locks");
2245
+ fs17.mkdirSync(dir, { recursive: true });
2246
+ return withDirLock(path15.join(dir, `trap-${encodeURIComponent(trapId)}`), () => {
2205
2247
  heldCacheLocks.add(trapId);
2206
2248
  try {
2207
2249
  return action();
@@ -2244,10 +2286,10 @@ function cacheDirectories(root, patterns) {
2244
2286
  if (part === "**")
2245
2287
  walk(dir, parts, index + 1);
2246
2288
  const matcher = segmentPattern(part);
2247
- for (const entry of fs16.readdirSync(dir, { withFileTypes: true })) {
2289
+ for (const entry of fs17.readdirSync(dir, { withFileTypes: true })) {
2248
2290
  if (!entry.isDirectory() || entry.isSymbolicLink() || entry.name.toLowerCase() === ".git")
2249
2291
  continue;
2250
- const child = path14.join(dir, entry.name);
2292
+ const child = path15.join(dir, entry.name);
2251
2293
  if (part === "**")
2252
2294
  walk(child, parts, index);
2253
2295
  else if (matcher.test(entry.name))
@@ -2259,12 +2301,12 @@ function cacheDirectories(root, patterns) {
2259
2301
  continue;
2260
2302
  walk(root, pattern.split("/"), 0);
2261
2303
  }
2262
- return [...matches].sort().filter((dir, _i, dirs) => !dirs.some((parent) => dir !== parent && dir.startsWith(parent + path14.sep)));
2304
+ return [...matches].sort().filter((dir, _i, dirs) => !dirs.some((parent) => dir !== parent && dir.startsWith(parent + path15.sep)));
2263
2305
  }
2264
2306
 
2265
2307
  // packages/core/dist/cache-cleanup.js
2266
- import * as fs17 from "node:fs";
2267
- import * as path15 from "node:path";
2308
+ import * as fs18 from "node:fs";
2309
+ import * as path16 from "node:path";
2268
2310
  import { execFileSync as execFileSync3 } from "node:child_process";
2269
2311
  var git = (dir, args) => execFileSync3("git", ["-C", dir, ...args], {
2270
2312
  encoding: "utf8",
@@ -2290,52 +2332,52 @@ function cacheTrapIdle(trap) {
2290
2332
  }
2291
2333
  function cacheWorktree(root, repoPath) {
2292
2334
  const canonical = (dir) => {
2293
- const real = fs17.realpathSync.native(dir);
2335
+ const real = fs18.realpathSync.native(dir);
2294
2336
  return process.platform === "win32" ? real.toLowerCase() : real;
2295
2337
  };
2296
- if (fs17.lstatSync(root).isSymbolicLink())
2338
+ if (fs18.lstatSync(root).isSymbolicLink())
2297
2339
  return false;
2298
2340
  const top = git(root, ["rev-parse", "--show-toplevel"]).trim();
2299
- const common = path15.resolve(root, git(root, ["rev-parse", "--git-common-dir"]).trim());
2341
+ const common = path16.resolve(root, git(root, ["rev-parse", "--git-common-dir"]).trim());
2300
2342
  const privateGit = git(root, ["rev-parse", "--absolute-git-dir"]).trim();
2301
- const repoCommon = path15.resolve(repoPath, git(repoPath, ["rev-parse", "--git-common-dir"]).trim());
2343
+ const repoCommon = path16.resolve(repoPath, git(repoPath, ["rev-parse", "--git-common-dir"]).trim());
2302
2344
  return canonical(root) === canonical(top) && canonical(common) !== canonical(privateGit) && canonical(common) === canonical(repoCommon);
2303
2345
  }
2304
2346
  function safeCacheTarget(root, target, tracked) {
2305
- const relative7 = path15.relative(root, target);
2306
- if (fs17.lstatSync(root).isSymbolicLink())
2347
+ const relative7 = path16.relative(root, target);
2348
+ if (fs18.lstatSync(root).isSymbolicLink())
2307
2349
  return false;
2308
- if (!relative7 || relative7.startsWith("..") || path15.isAbsolute(relative7))
2350
+ if (!relative7 || relative7.startsWith("..") || path16.isAbsolute(relative7))
2309
2351
  return false;
2310
2352
  let current = root;
2311
- for (const part of relative7.split(path15.sep)) {
2312
- current = path15.join(current, part);
2313
- if (part.toLowerCase() === ".git" || fs17.lstatSync(current).isSymbolicLink())
2353
+ for (const part of relative7.split(path16.sep)) {
2354
+ current = path16.join(current, part);
2355
+ if (part.toLowerCase() === ".git" || fs18.lstatSync(current).isSymbolicLink())
2314
2356
  return false;
2315
2357
  }
2316
- const name = relative7.split(path15.sep).join("/").toLowerCase();
2358
+ const name = relative7.split(path16.sep).join("/").toLowerCase();
2317
2359
  return !tracked.some((trackedPath) => {
2318
2360
  const file2 = trackedPath.toLowerCase();
2319
2361
  return file2 === name || file2.startsWith(name + "/") || name.startsWith(file2 + "/");
2320
2362
  });
2321
2363
  }
2322
2364
  function cacheBytes(target) {
2323
- const stat = fs17.lstatSync(target);
2365
+ const stat = fs18.lstatSync(target);
2324
2366
  if (stat.isSymbolicLink())
2325
2367
  return 0;
2326
2368
  if (!stat.isDirectory())
2327
2369
  return process.platform === "win32" || stat.blocks === void 0 ? stat.size : stat.blocks * 512;
2328
- const entries = fs17.readdirSync(target);
2370
+ const entries = fs18.readdirSync(target);
2329
2371
  if (entries.some((name) => name.toLowerCase() === ".git"))
2330
2372
  throw new Error("nested repository is not a cache");
2331
- return entries.reduce((bytes, name) => bytes + cacheBytes(path15.join(target, name)), 0);
2373
+ return entries.reduce((bytes, name) => bytes + cacheBytes(path16.join(target, name)), 0);
2332
2374
  }
2333
2375
  function planTrapCache(trap, cfg) {
2334
2376
  const repo = trap.repo ? cfg.repos[trap.repo] : void 0;
2335
2377
  if (!repo?.cacheDirs?.length || !cacheTrapIdle(trap))
2336
2378
  return void 0;
2337
2379
  try {
2338
- const root = fs17.realpathSync.native(trap.worktree);
2380
+ const root = fs18.realpathSync.native(trap.worktree);
2339
2381
  if (!cacheWorktree(trap.worktree, repo.path))
2340
2382
  return void 0;
2341
2383
  const tracked = git(root, ["ls-files", "-z"]).split("\0").filter(Boolean);
@@ -2377,7 +2419,7 @@ function clearTrapCaches(trap, cfg = loadConfig()) {
2377
2419
  if (!cacheTrapIdle(trap) || !safeCacheTarget(plan.worktree, target, tracked))
2378
2420
  continue;
2379
2421
  const size = cacheBytes(target);
2380
- fs17.rmSync(target, { recursive: true, force: true });
2422
+ fs18.rmSync(target, { recursive: true, force: true });
2381
2423
  bytes += size;
2382
2424
  } catch {
2383
2425
  }
@@ -2426,12 +2468,12 @@ function recoverTrapCaches(cfg, volume, readFree = statfsFreeBytes, log = () =>
2426
2468
  return 0;
2427
2469
  let bytes = 0;
2428
2470
  let traps = 0;
2429
- const device = fs17.statSync(volume).dev;
2471
+ const device = fs18.statSync(volume).dev;
2430
2472
  for (const plan of planTrapCaches(cfg)) {
2431
2473
  if (readFree(volume) >= threshold)
2432
2474
  break;
2433
2475
  try {
2434
- if (fs17.statSync(plan.worktree).dev !== device)
2476
+ if (fs18.statSync(plan.worktree).dev !== device)
2435
2477
  continue;
2436
2478
  const removed = clearTrapCaches(plan, cfg);
2437
2479
  if (removed > 0) {
@@ -2505,7 +2547,7 @@ function waitingFields(verb, w, now2 = Date.now()) {
2505
2547
  }
2506
2548
  return out;
2507
2549
  }
2508
- function appendStatus(id, lane, verb, note, at, waiting, reported = false) {
2550
+ function appendStatus(id, lane, verb, note, at, waiting, reported = false, permissionRequest = false) {
2509
2551
  if (!isVerb(verb)) {
2510
2552
  throw new Error(`invalid status verb "${verb}" \u2014 must be one of: ${VERBS.join(", ")}`);
2511
2553
  }
@@ -2515,7 +2557,8 @@ function appendStatus(id, lane, verb, note, at, waiting, reported = false) {
2515
2557
  verb,
2516
2558
  ...note ? { note } : {},
2517
2559
  ...extra,
2518
- ...reported ? { reported: true } : {}
2560
+ ...reported ? { reported: true } : {},
2561
+ ...permissionRequest ? { permissionRequest: true } : {}
2519
2562
  };
2520
2563
  if (verb === "done") {
2521
2564
  try {
@@ -2528,7 +2571,7 @@ function appendStatus(id, lane, verb, note, at, waiting, reported = false) {
2528
2571
  if (trap?.configured?.surface === "claude-desktop" && verb === "working" && !acquireDesktopLease(trap))
2529
2572
  throw new Error("another configured desk owns the host UI; retry working when it finishes");
2530
2573
  const write = () => {
2531
- fs18.appendFileSync(statusPath(id, lane), `${JSON.stringify(entry)}
2574
+ fs19.appendFileSync(statusPath(id, lane), `${JSON.stringify(entry)}
2532
2575
  `);
2533
2576
  };
2534
2577
  if (trap && repoCachesConfigured(trap.repo))
@@ -2551,9 +2594,9 @@ function appendStatus(id, lane, verb, note, at, waiting, reported = false) {
2551
2594
  }
2552
2595
  function readStatusLog(id, lane) {
2553
2596
  const file2 = statusPath(id, lane);
2554
- if (!fs18.existsSync(file2))
2597
+ if (!fs19.existsSync(file2))
2555
2598
  return [];
2556
- return fs18.readFileSync(file2, "utf8").split("\n").filter(Boolean).flatMap((line) => {
2599
+ return fs19.readFileSync(file2, "utf8").split("\n").filter(Boolean).flatMap((line) => {
2557
2600
  try {
2558
2601
  const parsed = JSON.parse(line);
2559
2602
  return isVerb(parsed.verb) ? [parsed] : [];
@@ -2567,8 +2610,8 @@ function pausedWaiting(entry) {
2567
2610
  }
2568
2611
 
2569
2612
  // packages/core/dist/pushes.js
2570
- import * as fs19 from "node:fs";
2571
- import * as path16 from "node:path";
2613
+ import * as fs20 from "node:fs";
2614
+ import * as path17 from "node:path";
2572
2615
  var MAX_PUSHES = 20;
2573
2616
  var PUSH_HEAD = "HEAD";
2574
2617
  var VALUE_OPTIONS = /* @__PURE__ */ new Set(["-o", "--push-option", "--repo", "--receive-pack", "--exec"]);
@@ -2623,18 +2666,18 @@ function gitPushTargets(command) {
2623
2666
  return found ? [...new Set(targets)] : void 0;
2624
2667
  }
2625
2668
  function gitDirAt(dir) {
2626
- let at = path16.resolve(dir);
2669
+ let at = path17.resolve(dir);
2627
2670
  for (; ; ) {
2628
- const dotGit = path16.join(at, ".git");
2671
+ const dotGit = path17.join(at, ".git");
2629
2672
  try {
2630
- const stat = fs19.statSync(dotGit);
2673
+ const stat = fs20.statSync(dotGit);
2631
2674
  if (stat.isDirectory())
2632
2675
  return dotGit;
2633
- const m = /^gitdir:\s*(.+)$/m.exec(fs19.readFileSync(dotGit, "utf8"));
2634
- return m ? path16.resolve(at, m[1].trim()) : void 0;
2676
+ const m = /^gitdir:\s*(.+)$/m.exec(fs20.readFileSync(dotGit, "utf8"));
2677
+ return m ? path17.resolve(at, m[1].trim()) : void 0;
2635
2678
  } catch {
2636
2679
  }
2637
- const up = path16.dirname(at);
2680
+ const up = path17.dirname(at);
2638
2681
  if (up === at)
2639
2682
  return void 0;
2640
2683
  at = up;
@@ -2645,7 +2688,7 @@ function currentBranchAt(dir) {
2645
2688
  if (!gitDir)
2646
2689
  return void 0;
2647
2690
  try {
2648
- const m = /^ref:\s*refs\/heads\/(.+)$/m.exec(fs19.readFileSync(path16.join(gitDir, "HEAD"), "utf8"));
2691
+ const m = /^ref:\s*refs\/heads\/(.+)$/m.exec(fs20.readFileSync(path17.join(gitDir, "HEAD"), "utf8"));
2649
2692
  return m ? m[1].trim() : void 0;
2650
2693
  } catch {
2651
2694
  return void 0;
@@ -2665,28 +2708,28 @@ function recordPush(id, lane, branches, at = (/* @__PURE__ */ new Date()).toISOS
2665
2708
 
2666
2709
  // packages/core/dist/soak.js
2667
2710
  function regPath(trapId) {
2668
- return path17.join(soakingDir(), `${trapId}.json`);
2711
+ return path18.join(soakingDir(), `${trapId}.json`);
2669
2712
  }
2670
2713
  function readTrap(trapId) {
2671
2714
  try {
2672
- return JSON.parse(fs20.readFileSync(regPath(trapId), "utf8"));
2715
+ return JSON.parse(fs21.readFileSync(regPath(trapId), "utf8"));
2673
2716
  } catch {
2674
2717
  return void 0;
2675
2718
  }
2676
2719
  }
2677
2720
  function listTraps() {
2678
2721
  try {
2679
- return fs20.readdirSync(soakingDir()).filter((f) => f.endsWith(".json")).map((f) => JSON.parse(fs20.readFileSync(path17.join(soakingDir(), f), "utf8"))).filter((r) => typeof r.trapId === "string");
2722
+ return fs21.readdirSync(soakingDir()).filter((f) => f.endsWith(".json")).map((f) => JSON.parse(fs21.readFileSync(path18.join(soakingDir(), f), "utf8"))).filter((r) => typeof r.trapId === "string");
2680
2723
  } catch {
2681
2724
  return [];
2682
2725
  }
2683
2726
  }
2684
2727
  function claimPath(id, lane) {
2685
- return path17.join(laneDirs(lane).active, id, "claim.json");
2728
+ return path18.join(laneDirs(lane).active, id, "claim.json");
2686
2729
  }
2687
2730
  function readSessionClaim(id, lane) {
2688
2731
  try {
2689
- return JSON.parse(fs20.readFileSync(claimPath(id, lane), "utf8"));
2732
+ return JSON.parse(fs21.readFileSync(claimPath(id, lane), "utf8"));
2690
2733
  } catch {
2691
2734
  return void 0;
2692
2735
  }
@@ -2695,46 +2738,46 @@ function hasOpenCatch(reg) {
2695
2738
  if (!reg.claimed)
2696
2739
  return false;
2697
2740
  const lane = laneOf(reg.claimed);
2698
- if (!lane || !fs20.existsSync(path17.join(laneDirs(lane).active, reg.claimed)))
2741
+ if (!lane || !fs21.existsSync(path18.join(laneDirs(lane).active, reg.claimed)))
2699
2742
  return false;
2700
2743
  const last = readStatusLog(reg.claimed, lane).at(-1)?.verb;
2701
2744
  return last === void 0 || !TERMINAL_VERBS.includes(last);
2702
2745
  }
2703
2746
 
2704
2747
  // packages/core/dist/events.js
2705
- import * as fs21 from "node:fs";
2748
+ import * as fs22 from "node:fs";
2706
2749
  function appendEvent(id, lane, ev) {
2707
- fs21.appendFileSync(eventsPath(id, lane), `${JSON.stringify(ev)}
2750
+ fs22.appendFileSync(eventsPath(id, lane), `${JSON.stringify(ev)}
2708
2751
  `);
2709
2752
  }
2710
2753
  function touchEvents(id, lane, at = /* @__PURE__ */ new Date()) {
2711
2754
  const file2 = eventsPath(id, lane);
2712
2755
  try {
2713
- fs21.utimesSync(file2, at, at);
2756
+ fs22.utimesSync(file2, at, at);
2714
2757
  } catch {
2715
- fs21.appendFileSync(file2, "");
2716
- fs21.utimesSync(file2, at, at);
2758
+ fs22.appendFileSync(file2, "");
2759
+ fs22.utimesSync(file2, at, at);
2717
2760
  }
2718
2761
  }
2719
2762
 
2720
2763
  // packages/core/dist/inbox.js
2721
- import * as fs22 from "node:fs";
2722
- import * as path18 from "node:path";
2764
+ import * as fs23 from "node:fs";
2765
+ import * as path19 from "node:path";
2723
2766
  var metaName = (file2) => file2.replace(/\.msg$/, ".meta.json");
2724
2767
  function inboxDir(id, lane) {
2725
- return path18.join(laneDirs(lane).inbox, id);
2768
+ return path19.join(laneDirs(lane).inbox, id);
2726
2769
  }
2727
2770
  function withInboxWrite(id, lane, action) {
2728
2771
  const directory = inboxDir(id, lane);
2729
- fs22.mkdirSync(directory, { recursive: true });
2730
- return withDirLock(path18.join(directory, ".write-lock"), action, { staleMs: 3e4, waitMs: 1e3, busy: () => new Error(`inbox ${id} is busy; retry`) });
2772
+ fs23.mkdirSync(directory, { recursive: true });
2773
+ return withDirLock(path19.join(directory, ".write-lock"), action, { staleMs: 3e4, waitMs: 1e3, busy: () => new Error(`inbox ${id} is busy; retry`) });
2731
2774
  }
2732
2775
  function sendMessageOnce(id, lane, deliveryId, text, from, attachments = []) {
2733
2776
  if (!/^[A-Za-z0-9_-]{1,128}$/.test(deliveryId))
2734
2777
  throw new Error("invalid inbox delivery id");
2735
2778
  return withInboxWrite(id, lane, () => {
2736
2779
  const directory = inboxDir(id, lane);
2737
- for (const folder of [directory, path18.join(directory, "handled")])
2780
+ for (const folder of [directory, path19.join(directory, "handled")])
2738
2781
  for (const file2 of readDirIfPresent(folder).filter((name) => name.endsWith(".msg"))) {
2739
2782
  const metadata = readMessageMeta(id, lane, file2, folder !== directory);
2740
2783
  if (metadata?.deliveryId === deliveryId)
@@ -2743,49 +2786,55 @@ function sendMessageOnce(id, lane, deliveryId, text, from, attachments = []) {
2743
2786
  return appendMessage(id, lane, text, from, attachments, deliveryId);
2744
2787
  });
2745
2788
  }
2746
- function appendMessage(id, lane, text, from, attachments = [], deliveryId) {
2789
+ function appendMessage(id, lane, text, from, attachments = [], deliveryId, permissionCard) {
2747
2790
  const dir = inboxDir(id, lane);
2748
- fs22.mkdirSync(path18.join(dir, "handled"), { recursive: true });
2749
- const existing = fs22.readdirSync(dir).filter((f) => f.endsWith(".msg")).length;
2750
- const handled = fs22.readdirSync(path18.join(dir, "handled")).filter((f) => f.endsWith(".msg")).length;
2791
+ fs23.mkdirSync(path19.join(dir, "handled"), { recursive: true });
2792
+ const existing = fs23.readdirSync(dir).filter((f) => f.endsWith(".msg")).length;
2793
+ const handled = fs23.readdirSync(path19.join(dir, "handled")).filter((f) => f.endsWith(".msg")).length;
2751
2794
  const name = `${String(existing + handled + 1).padStart(3, "0")}.msg`;
2752
- const tmp = uniqueTempPath(path18.join(dir, name));
2795
+ const tmp = uniqueTempPath(path19.join(dir, name));
2753
2796
  if (from !== void 0 || attachments.length > 0) {
2754
- const meta = { ...deliveryId ? { deliveryId } : {}, from: from ?? "unknown", at: (/* @__PURE__ */ new Date()).toISOString(), ...attachments.length ? { attachments } : {} };
2797
+ const meta = {
2798
+ ...deliveryId ? { deliveryId } : {},
2799
+ from: from ?? "unknown",
2800
+ at: (/* @__PURE__ */ new Date()).toISOString(),
2801
+ ...attachments.length ? { attachments } : {},
2802
+ ...permissionCard ? { permissionCard } : {}
2803
+ };
2755
2804
  const metaTmp = `${tmp}.meta`;
2756
- fs22.writeFileSync(metaTmp, JSON.stringify(meta, null, 2));
2757
- atomicRenameSync(metaTmp, path18.join(dir, metaName(name)));
2805
+ fs23.writeFileSync(metaTmp, JSON.stringify(meta, null, 2));
2806
+ atomicRenameSync(metaTmp, path19.join(dir, metaName(name)));
2758
2807
  }
2759
- fs22.writeFileSync(tmp, text);
2760
- atomicRenameSync(tmp, path18.join(dir, name));
2808
+ fs23.writeFileSync(tmp, text);
2809
+ atomicRenameSync(tmp, path19.join(dir, name));
2761
2810
  return name;
2762
2811
  }
2763
2812
  function readMessageMeta(id, lane, file2, handled = false) {
2764
- const dir = path18.join(inboxDir(id, lane), ...handled ? ["handled"] : []);
2813
+ const dir = path19.join(inboxDir(id, lane), ...handled ? ["handled"] : []);
2765
2814
  try {
2766
- return JSON.parse(fs22.readFileSync(path18.join(dir, metaName(file2)), "utf8"));
2815
+ return JSON.parse(fs23.readFileSync(path19.join(dir, metaName(file2)), "utf8"));
2767
2816
  } catch {
2768
2817
  return void 0;
2769
2818
  }
2770
2819
  }
2771
2820
  function unhandled(id, lane) {
2772
2821
  const dir = inboxDir(id, lane);
2773
- return readDirIfPresent(dir).filter((f) => f.endsWith(".msg")).sort().map((f) => ({ file: f, text: fs22.readFileSync(path18.join(dir, f), "utf8") }));
2822
+ return readDirIfPresent(dir).filter((f) => f.endsWith(".msg")).sort().map((f) => ({ file: f, text: fs23.readFileSync(path19.join(dir, f), "utf8") }));
2774
2823
  }
2775
2824
  function acknowledge(id, lane, file2) {
2776
2825
  const dir = inboxDir(id, lane);
2777
- fs22.mkdirSync(path18.join(dir, "handled"), { recursive: true });
2778
- fs22.renameSync(path18.join(dir, file2), path18.join(dir, "handled", file2));
2826
+ fs23.mkdirSync(path19.join(dir, "handled"), { recursive: true });
2827
+ fs23.renameSync(path19.join(dir, file2), path19.join(dir, "handled", file2));
2779
2828
  try {
2780
- fs22.renameSync(path18.join(dir, metaName(file2)), path18.join(dir, "handled", metaName(file2)));
2829
+ fs23.renameSync(path19.join(dir, metaName(file2)), path19.join(dir, "handled", metaName(file2)));
2781
2830
  } catch {
2782
2831
  }
2783
2832
  }
2784
2833
 
2785
2834
  // packages/core/dist/resume.js
2786
- import * as fs23 from "node:fs";
2835
+ import * as fs24 from "node:fs";
2787
2836
  import * as os3 from "node:os";
2788
- import * as path19 from "node:path";
2837
+ import * as path20 from "node:path";
2789
2838
  import { spawnSync } from "node:child_process";
2790
2839
  var UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-([0-9a-f])[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
2791
2840
  function harnessFromSessionId(sessionId) {
@@ -2796,7 +2845,7 @@ function claimOf(id, lane) {
2796
2845
  const dirs = laneDirs(lane);
2797
2846
  for (const dir of [dirs.active, dirs.done]) {
2798
2847
  try {
2799
- return JSON.parse(fs23.readFileSync(path19.join(dir, id, "claim.json"), "utf8"));
2848
+ return JSON.parse(fs24.readFileSync(path20.join(dir, id, "claim.json"), "utf8"));
2800
2849
  } catch {
2801
2850
  }
2802
2851
  }
@@ -2846,7 +2895,7 @@ function isUnresumable(error) {
2846
2895
  return error !== void 0 && UNRESUMABLE.test(error);
2847
2896
  }
2848
2897
  function worktreeProgress(worktree, trunk) {
2849
- if (!worktree || !fs23.existsSync(worktree))
2898
+ if (!worktree || !fs24.existsSync(worktree))
2850
2899
  return "No worktree progress recorded.";
2851
2900
  const git3 = (...a) => spawnSync("git", a, { cwd: worktree, encoding: "utf8" }).stdout?.trim() ?? "";
2852
2901
  const commits = trunk ? git3("log", "--oneline", `origin/${trunk}..HEAD`) : git3("log", "--oneline", "-15");
@@ -2879,31 +2928,31 @@ function handoffNote(fromHarness, progress, why) {
2879
2928
  ${progress}`;
2880
2929
  }
2881
2930
  function codexHome(env = process.env) {
2882
- return env.CODEX_HOME ?? path19.join(os3.homedir(), ".codex");
2931
+ return env.CODEX_HOME ?? path20.join(os3.homedir(), ".codex");
2883
2932
  }
2884
2933
  function codexRolloutFile(threadId, home = codexHome()) {
2885
2934
  const suffix = `-${threadId}.jsonl`;
2886
2935
  const walk = (dir, depth) => {
2887
2936
  let entries;
2888
2937
  try {
2889
- entries = fs23.readdirSync(dir, { withFileTypes: true });
2938
+ entries = fs24.readdirSync(dir, { withFileTypes: true });
2890
2939
  } catch {
2891
2940
  return void 0;
2892
2941
  }
2893
2942
  for (const e of entries) {
2894
2943
  if (e.isFile() && e.name.startsWith("rollout-") && e.name.endsWith(suffix))
2895
- return path19.join(dir, e.name);
2944
+ return path20.join(dir, e.name);
2896
2945
  }
2897
2946
  if (depth === 0)
2898
2947
  return void 0;
2899
2948
  for (const e of entries.filter((x) => x.isDirectory()).sort((a, b) => b.name.localeCompare(a.name))) {
2900
- const hit = walk(path19.join(dir, e.name), depth - 1);
2949
+ const hit = walk(path20.join(dir, e.name), depth - 1);
2901
2950
  if (hit)
2902
2951
  return hit;
2903
2952
  }
2904
2953
  return void 0;
2905
2954
  };
2906
- return walk(path19.join(home, "sessions"), 3) ?? walk(path19.join(home, "archived_sessions"), 0);
2955
+ return walk(path20.join(home, "sessions"), 3) ?? walk(path20.join(home, "archived_sessions"), 0);
2907
2956
  }
2908
2957
  function codexDesktopThread(threadId, home = codexHome()) {
2909
2958
  const file2 = codexRolloutFile(threadId, home);
@@ -2911,12 +2960,12 @@ function codexDesktopThread(threadId, home = codexHome()) {
2911
2960
  return void 0;
2912
2961
  let head = "";
2913
2962
  try {
2914
- const fd = fs23.openSync(file2, "r");
2963
+ const fd = fs24.openSync(file2, "r");
2915
2964
  try {
2916
2965
  const buf = Buffer.alloc(4096);
2917
- head = buf.subarray(0, fs23.readSync(fd, buf, 0, buf.length, 0)).toString("utf8");
2966
+ head = buf.subarray(0, fs24.readSync(fd, buf, 0, buf.length, 0)).toString("utf8");
2918
2967
  } finally {
2919
- fs23.closeSync(fd);
2968
+ fs24.closeSync(fd);
2920
2969
  }
2921
2970
  } catch {
2922
2971
  return void 0;
@@ -2930,16 +2979,16 @@ var CODEX_DESKTOP_THREAD = "Codex desktop thread; not resumable from the CLI";
2930
2979
 
2931
2980
  // packages/core/dist/notices.js
2932
2981
  function noticesDir() {
2933
- return path20.join(lobstahHome(), "notices");
2982
+ return path21.join(lobstahHome(), "notices");
2934
2983
  }
2935
2984
  var counter = 0;
2936
2985
  function postNotice(n) {
2937
2986
  const dir = noticesDir();
2938
- fs24.mkdirSync(dir, { recursive: true });
2987
+ fs25.mkdirSync(dir, { recursive: true });
2939
2988
  if (n.dedupeKey) {
2940
- const marker = path20.join(dir, `.dedupe-${n.dedupeKey.replace(/[^A-Za-z0-9_-]/g, "_")}`);
2989
+ const marker = path21.join(dir, `.dedupe-${n.dedupeKey.replace(/[^A-Za-z0-9_-]/g, "_")}`);
2941
2990
  try {
2942
- fs24.writeFileSync(marker, "", { flag: "wx" });
2991
+ fs25.writeFileSync(marker, "", { flag: "wx" });
2943
2992
  } catch {
2944
2993
  return void 0;
2945
2994
  }
@@ -2958,20 +3007,20 @@ function postNotice(n) {
2958
3007
  ...n.quiet ? { quiet: true } : {},
2959
3008
  ...n.stateHash ? { stateHash: n.stateHash } : {}
2960
3009
  };
2961
- const file2 = path20.join(dir, `${seq}.json`);
3010
+ const file2 = path21.join(dir, `${seq}.json`);
2962
3011
  const tmp = uniqueTempPath(file2);
2963
- fs24.writeFileSync(tmp, JSON.stringify(notice, null, 2));
3012
+ fs25.writeFileSync(tmp, JSON.stringify(notice, null, 2));
2964
3013
  atomicRenameSync(tmp, file2);
2965
3014
  return notice;
2966
3015
  }
2967
3016
 
2968
3017
  // packages/core/dist/github-budget.js
2969
- import * as fs25 from "node:fs";
2970
- import * as path21 from "node:path";
2971
- var file = () => path21.join(lobstahHome(), "github-budget.json");
3018
+ import * as fs26 from "node:fs";
3019
+ import * as path22 from "node:path";
3020
+ var file = () => path22.join(lobstahHome(), "github-budget.json");
2972
3021
  function read() {
2973
3022
  try {
2974
- return JSON.parse(fs25.readFileSync(file(), "utf8"));
3023
+ return JSON.parse(fs26.readFileSync(file(), "utf8"));
2975
3024
  } catch {
2976
3025
  return { resources: {} };
2977
3026
  }
@@ -2985,27 +3034,27 @@ function githubBlockedUntil(now2 = Date.now()) {
2985
3034
 
2986
3035
  // packages/core/dist/watch.js
2987
3036
  function watchesDir() {
2988
- return path22.join(lobstahHome(), "watches");
3037
+ return path23.join(lobstahHome(), "watches");
2989
3038
  }
2990
3039
  function slug(key) {
2991
3040
  return key.replace(/[^A-Za-z0-9._-]+/g, "-");
2992
3041
  }
2993
3042
  function watchPath(key) {
2994
- return path22.join(watchesDir(), `${slug(key)}.json`);
3043
+ return path23.join(watchesDir(), `${slug(key)}.json`);
2995
3044
  }
2996
3045
  function readWatch(key) {
2997
3046
  try {
2998
- return JSON.parse(fs26.readFileSync(watchPath(key), "utf8"));
3047
+ return JSON.parse(fs27.readFileSync(watchPath(key), "utf8"));
2999
3048
  } catch {
3000
3049
  return void 0;
3001
3050
  }
3002
3051
  }
3003
3052
 
3004
3053
  // packages/core/dist/pr-poll.js
3005
- var cycleFile = (repo) => path23.join(lobstahHome(), "pr-polls", `${repo.replace(/[^\w.-]/g, "_")}.json`);
3054
+ var cycleFile = (repo) => path24.join(lobstahHome(), "pr-polls", `${repo.replace(/[^\w.-]/g, "_")}.json`);
3006
3055
  var readCycle = (repo) => {
3007
3056
  try {
3008
- return JSON.parse(fs27.readFileSync(cycleFile(repo), "utf8"));
3057
+ return JSON.parse(fs28.readFileSync(cycleFile(repo), "utf8"));
3009
3058
  } catch {
3010
3059
  return void 0;
3011
3060
  }
@@ -3420,6 +3469,13 @@ var DEFAULT_HELM = {
3420
3469
  goalsNudgeSecs: 7200
3421
3470
  };
3422
3471
  var DEFAULT_GLASS = { port: 4949 };
3472
+ function glassConfig(raw, wharves) {
3473
+ const glass = { ...DEFAULT_GLASS, ...raw ?? {} };
3474
+ if (glass.mirror !== void 0 && (typeof glass.mirror !== "string" || !Object.hasOwn(wharves, glass.mirror))) {
3475
+ throw new Error(`[glass] mirror must name a wharf in [wharves]; ${JSON.stringify(glass.mirror)} is not one`);
3476
+ }
3477
+ return glass;
3478
+ }
3423
3479
  var DEFAULT_WAIT = { baseTimeoutSecs: 900, baseRepeats: 3, maxTimeoutSecs: 14400 };
3424
3480
  var DEFAULT_WATCH = { maxForksPerCycle: 3, autoRepair: true, conflicts: true, checks: true, maxRepairsPerPr: 2, maxRepairsWithoutProgress: 2, repairSettleSecs: 600, repairCooldownSecs: 0, repairTrapWaitSecs: 600 };
3425
3481
  var DEFAULT_LIMITS = {
@@ -3449,14 +3505,14 @@ function withConfigPath(parse2) {
3449
3505
  }
3450
3506
  }
3451
3507
  function configPath() {
3452
- return path24.join(lobstahHome(), "config.toml");
3508
+ return path25.join(lobstahHome(), "config.toml");
3453
3509
  }
3454
3510
  function expandHome(p) {
3455
- return p.startsWith("~/") ? path24.join(os4.homedir(), p.slice(2)) : p;
3511
+ return p.startsWith("~/") ? path25.join(os4.homedir(), p.slice(2)) : p;
3456
3512
  }
3457
3513
  function loadConfig() {
3458
3514
  const file2 = configPath();
3459
- const raw = fs28.existsSync(file2) ? parse(fs28.readFileSync(file2, "utf8")) : {};
3515
+ const raw = fs29.existsSync(file2) ? parse(fs29.readFileSync(file2, "utf8")) : {};
3460
3516
  const cacheMinFreeGB = raw.limits?.cacheMinFreeGB ?? DEFAULT_LIMITS.cacheMinFreeGB;
3461
3517
  if (typeof cacheMinFreeGB !== "number" || !Number.isFinite(cacheMinFreeGB) || cacheMinFreeGB < 0)
3462
3518
  throw new Error("[limits].cacheMinFreeGB must be a non-negative number");
@@ -3551,7 +3607,7 @@ function loadConfig() {
3551
3607
  heavy: parseHeavy(raw.heavy),
3552
3608
  helm,
3553
3609
  wait,
3554
- glass: { ...DEFAULT_GLASS, ...raw.glass ?? {} },
3610
+ glass: glassConfig(raw.glass, wharves),
3555
3611
  pet: { open: petOpen },
3556
3612
  watch,
3557
3613
  grounds,
@@ -3587,47 +3643,6 @@ function resolveDispatch(d, cfg) {
3587
3643
  };
3588
3644
  }
3589
3645
 
3590
- // packages/core/dist/reports.js
3591
- import * as fs29 from "node:fs";
3592
- import * as path25 from "node:path";
3593
- var REPORT_MD = "report.md";
3594
- var REPORT_JSON = "report.json";
3595
- function helmReportsRoot() {
3596
- return path25.join(lobstahHome(), "reports");
3597
- }
3598
- function dispatchReportKey(id, lane) {
3599
- return `report:${lane}:${id}`;
3600
- }
3601
- var GROUNDS_RE = /^[A-Za-z0-9._-]+$/;
3602
- var RID_RE = /^[a-f0-9]{8}$/;
3603
- function reportDir(key) {
3604
- const d = /^report:(work|chore):([A-Za-z0-9-]+)$/.exec(key);
3605
- if (d)
3606
- return path25.join(laneDirs(d[1]).state, d[2]);
3607
- const h = /^report:helm:([^:]+):([^:]+)$/.exec(key);
3608
- if (h && GROUNDS_RE.test(h[1]) && !h[1].startsWith(".") && RID_RE.test(h[2]))
3609
- return path25.join(helmReportsRoot(), h[1], h[2]);
3610
- return void 0;
3611
- }
3612
- function readReportAt(dir) {
3613
- try {
3614
- const meta = JSON.parse(fs29.readFileSync(path25.join(dir, REPORT_JSON), "utf8"));
3615
- return typeof meta.key === "string" && typeof meta.filedAt === "string" ? meta : void 0;
3616
- } catch {
3617
- return void 0;
3618
- }
3619
- }
3620
- function readReport(key) {
3621
- const dir = reportDir(key);
3622
- const meta = dir ? readReportAt(dir) : void 0;
3623
- return meta?.key === key ? meta : void 0;
3624
- }
3625
- function reportMarkdownPath(key) {
3626
- const dir = reportDir(key);
3627
- const file2 = dir && path25.join(dir, REPORT_MD);
3628
- return file2 && readReport(key) && fs29.existsSync(file2) ? file2 : void 0;
3629
- }
3630
-
3631
3646
  // packages/core/dist/assistance.js
3632
3647
  function assistanceDirectory() {
3633
3648
  return path26.join(lobstahHome(), "assistance");
@@ -3755,6 +3770,10 @@ function cancelRequested(id, lane) {
3755
3770
  return fs31.existsSync(path27.join(laneDirs(lane).active, id, "cancel"));
3756
3771
  }
3757
3772
 
3773
+ // packages/core/dist/backend-model.js
3774
+ var MIRROR_SNAPSHOT_MAX_BYTES = 2 * 1024 * 1024;
3775
+ var MIRROR_SNAPSHOT_MAX_JSON_BYTES = 16 * 1024 * 1024;
3776
+
3758
3777
  // packages/core/dist/backend.js
3759
3778
  function parseBackendLocation(raw) {
3760
3779
  if (raw === void 0)
@@ -3777,8 +3796,23 @@ var CLOSED_KEEP_MS = 30 * 24 * 3600 * 1e3;
3777
3796
  // packages/core/dist/grants.js
3778
3797
  var ONCE_TTL_MS = 60 * 60 * 1e3;
3779
3798
 
3780
- // packages/core/dist/harness.js
3799
+ // packages/core/dist/version.js
3781
3800
  import * as fs32 from "node:fs";
3801
+ function installedVersion() {
3802
+ if (process.env.LOBSTAH_BUILD_VERSION)
3803
+ return process.env.LOBSTAH_BUILD_VERSION;
3804
+ try {
3805
+ const pkg = JSON.parse(fs32.readFileSync(new URL("../package.json", import.meta.url), "utf8"));
3806
+ if (pkg.name === "lobstah" && typeof pkg.version === "string")
3807
+ return pkg.version;
3808
+ } catch {
3809
+ }
3810
+ return "0.0.0-dev";
3811
+ }
3812
+ var VERSION = installedVersion();
3813
+
3814
+ // packages/core/dist/harness.js
3815
+ import * as fs33 from "node:fs";
3782
3816
  import * as path28 from "node:path";
3783
3817
  import { createRequire } from "node:module";
3784
3818
  function resolveOnPath(bin, pathVar = process.env.PATH) {
@@ -3791,8 +3825,8 @@ function resolveOnPath(bin, pathVar = process.env.PATH) {
3791
3825
  for (const name of names) {
3792
3826
  const candidate = path28.join(dir, name);
3793
3827
  try {
3794
- fs32.accessSync(candidate, fs32.constants.X_OK);
3795
- if (fs32.statSync(candidate).isFile())
3828
+ fs33.accessSync(candidate, fs33.constants.X_OK);
3829
+ if (fs33.statSync(candidate).isFile())
3796
3830
  return candidate;
3797
3831
  } catch {
3798
3832
  }
@@ -3814,7 +3848,7 @@ function codexInvocation(argv) {
3814
3848
  }
3815
3849
  for (const dir of require_.resolve.paths("@openai/codex") ?? []) {
3816
3850
  const cli = path28.join(dir, "@openai", "codex", "bin", "codex.js");
3817
- if (fs32.existsSync(cli))
3851
+ if (fs33.existsSync(cli))
3818
3852
  return { file: process.execPath, argv: [cli, ...argv] };
3819
3853
  }
3820
3854
  return void 0;
@@ -3822,7 +3856,7 @@ function codexInvocation(argv) {
3822
3856
 
3823
3857
  // packages/core/dist/heavy-hooks.js
3824
3858
  import { execFileSync as execFileSync4 } from "node:child_process";
3825
- import fs33 from "node:fs";
3859
+ import fs34 from "node:fs";
3826
3860
  import * as path29 from "node:path";
3827
3861
  var HOOK_NAMES = [
3828
3862
  "applypatch-msg",
@@ -3869,30 +3903,30 @@ exec "$real" "$@"
3869
3903
  var heavyHooksDir = () => path29.join(heavyDir(), "hooks");
3870
3904
  function ensureHeavyHooks() {
3871
3905
  const dir = heavyHooksDir();
3872
- fs33.mkdirSync(dir, { recursive: true });
3906
+ fs34.mkdirSync(dir, { recursive: true });
3873
3907
  const shim = path29.join(dir, SHIM_FILE);
3874
3908
  let current;
3875
3909
  try {
3876
- current = fs33.readFileSync(shim, "utf8");
3910
+ current = fs34.readFileSync(shim, "utf8");
3877
3911
  } catch {
3878
3912
  }
3879
3913
  if (current !== SHIM) {
3880
3914
  const tmp = uniqueTempPath(shim);
3881
- fs33.writeFileSync(tmp, SHIM, { mode: 493 });
3915
+ fs34.writeFileSync(tmp, SHIM, { mode: 493 });
3882
3916
  atomicRenameSync(tmp, shim);
3883
3917
  }
3884
3918
  for (const name of HOOK_NAMES) {
3885
3919
  const link = path29.join(dir, name);
3886
3920
  try {
3887
- if (fs33.readlinkSync(link) === SHIM_FILE)
3921
+ if (fs34.readlinkSync(link) === SHIM_FILE)
3888
3922
  continue;
3889
- fs33.rmSync(link, { force: true });
3923
+ fs34.rmSync(link, { force: true });
3890
3924
  } catch (err) {
3891
3925
  if (err.code !== "ENOENT")
3892
- fs33.rmSync(link, { force: true });
3926
+ fs34.rmSync(link, { force: true });
3893
3927
  }
3894
3928
  try {
3895
- fs33.symlinkSync(SHIM_FILE, link);
3929
+ fs34.symlinkSync(SHIM_FILE, link);
3896
3930
  } catch (err) {
3897
3931
  if (err.code !== "EEXIST")
3898
3932
  throw err;
@@ -4001,8 +4035,11 @@ function droppedModelNote(harness, dropped) {
4001
4035
  return `model ${dropped.model} is a ${dropped.owner} model \u2014 dropped, using ${harness}'s default`;
4002
4036
  }
4003
4037
 
4038
+ // packages/core/dist/mirror-status.js
4039
+ var MIRROR_FRESH_MS = 6 * 6e4;
4040
+
4004
4041
  // packages/runner/src/run.ts
4005
- import * as fs38 from "node:fs";
4042
+ import * as fs39 from "node:fs";
4006
4043
  import * as path34 from "node:path";
4007
4044
  import { execFileSync as execFileSync6 } from "node:child_process";
4008
4045
  import { fileURLToPath as fileURLToPath2 } from "node:url";
@@ -4299,31 +4336,31 @@ function createClaudeAdapter() {
4299
4336
  }
4300
4337
 
4301
4338
  // packages/adapters/dist/codex.js
4302
- import * as fs34 from "node:fs";
4339
+ import * as fs35 from "node:fs";
4303
4340
  import * as os5 from "node:os";
4304
4341
  import * as path30 from "node:path";
4305
4342
  import { spawn as spawn2 } from "node:child_process";
4306
4343
  function isolatedCodexHome() {
4307
4344
  const dir = path30.join(lobstahHome(), "codex-home");
4308
- fs34.mkdirSync(dir, { recursive: true });
4345
+ fs35.mkdirSync(dir, { recursive: true });
4309
4346
  const auth = path30.join(dir, "auth.json");
4310
4347
  const realAuth = path30.join(os5.homedir(), ".codex", "auth.json");
4311
- if (!fs34.existsSync(auth) && fs34.existsSync(realAuth)) {
4348
+ if (!fs35.existsSync(auth) && fs35.existsSync(realAuth)) {
4312
4349
  try {
4313
- fs34.symlinkSync(realAuth, auth);
4350
+ fs35.symlinkSync(realAuth, auth);
4314
4351
  } catch {
4315
- fs34.copyFileSync(realAuth, auth);
4352
+ fs35.copyFileSync(realAuth, auth);
4316
4353
  }
4317
4354
  }
4318
4355
  const cfg = path30.join(dir, "config.toml");
4319
- if (!fs34.existsSync(cfg)) {
4320
- fs34.writeFileSync(cfg, "# lobstah-managed: auth inherited from ~/.codex, interactive config not\n");
4356
+ if (!fs35.existsSync(cfg)) {
4357
+ fs35.writeFileSync(cfg, "# lobstah-managed: auth inherited from ~/.codex, interactive config not\n");
4321
4358
  }
4322
4359
  return dir;
4323
4360
  }
4324
4361
  function heavyLineDir() {
4325
4362
  const dir = heavyDir();
4326
- fs34.mkdirSync(dir, { recursive: true });
4363
+ fs35.mkdirSync(dir, { recursive: true });
4327
4364
  return dir;
4328
4365
  }
4329
4366
  function pumpCodexEvent(ev, push, onSession) {
@@ -4526,14 +4563,14 @@ function loadAdapter(name) {
4526
4563
  }
4527
4564
 
4528
4565
  // packages/worktree/dist/index.js
4529
- import * as fs36 from "node:fs";
4566
+ import * as fs37 from "node:fs";
4530
4567
  import * as path32 from "node:path";
4531
4568
  import { createHash } from "node:crypto";
4532
4569
  import { exec, execFile as execFile2, execFileSync as execFileSync5 } from "node:child_process";
4533
4570
  import { promisify as promisify2 } from "node:util";
4534
4571
 
4535
4572
  // packages/worktree/dist/pool.js
4536
- import * as fs35 from "node:fs";
4573
+ import * as fs36 from "node:fs";
4537
4574
  import * as path31 from "node:path";
4538
4575
  import { execFile } from "node:child_process";
4539
4576
  import { promisify } from "node:util";
@@ -4596,7 +4633,7 @@ function takeOut(name, pool, slot, reason, dispatch, notice = true) {
4596
4633
  function trapIn(dir) {
4597
4634
  const real = (p) => {
4598
4635
  try {
4599
- return fs35.realpathSync.native(p);
4636
+ return fs36.realpathSync.native(p);
4600
4637
  } catch {
4601
4638
  return path31.resolve(p);
4602
4639
  }
@@ -4614,7 +4651,7 @@ async function claimPoolSlot(input) {
4614
4651
  const refused = [];
4615
4652
  for (let slot = 1; slot <= pool.size; slot++) {
4616
4653
  const dir = poolSlotPath(name, slot);
4617
- if (fs35.existsSync(dir) && readWorktreeLock(dir)?.id === id && readWorktreeLock(dir)?.kind !== "warm") {
4654
+ if (fs36.existsSync(dir) && readWorktreeLock(dir)?.id === id && readWorktreeLock(dir)?.kind !== "warm") {
4618
4655
  writeSlotClaim(name, slot, { id, lane, at: (/* @__PURE__ */ new Date()).toISOString() });
4619
4656
  return { claimed: true, dir, slot, label: poolSlotLabel(name, slot) };
4620
4657
  }
@@ -4662,7 +4699,7 @@ async function resetPoolWorktree(repo, dir, id, fromRemoteBranch = repo.trunk) {
4662
4699
  }
4663
4700
  var WARM_ID = "pool-warm";
4664
4701
  async function createSlot(repo, dir) {
4665
- fs35.mkdirSync(path31.dirname(dir), { recursive: true });
4702
+ fs36.mkdirSync(path31.dirname(dir), { recursive: true });
4666
4703
  await oneAtATime(repo.path, async () => {
4667
4704
  await tryGit(repo.path, "worktree", "prune");
4668
4705
  await gitShared(repo.path, "worktree", "add", "--detach", dir, `origin/${repo.trunk}`);
@@ -4684,7 +4721,7 @@ async function warmPool(name, opts = {}) {
4684
4721
  if (!release)
4685
4722
  return false;
4686
4723
  try {
4687
- if (!fs35.existsSync(repo.path)) {
4724
+ if (!fs36.existsSync(repo.path)) {
4688
4725
  if (!repo.origin)
4689
4726
  throw new Error(`repo path ${repo.path} missing and no origin configured`);
4690
4727
  await run("git", ["clone", repo.origin, repo.path], { env: process.env });
@@ -4697,8 +4734,8 @@ async function warmPool(name, opts = {}) {
4697
4734
  const dir = poolSlotPath(name, slot);
4698
4735
  const label = poolSlotLabel(name, slot);
4699
4736
  const meta = readSlotMeta(name, slot);
4700
- if (!fs35.existsSync(dir)) {
4701
- fs35.mkdirSync(poolsRoot(), { recursive: true });
4737
+ if (!fs36.existsSync(dir)) {
4738
+ fs36.mkdirSync(poolsRoot(), { recursive: true });
4702
4739
  recoverTrapCaches(cfg, poolsRoot(), read2, log);
4703
4740
  let free = Infinity;
4704
4741
  try {
@@ -4842,7 +4879,7 @@ function pidAlive3(pid) {
4842
4879
  var BUSY = /* @__PURE__ */ new Set(["EPERM", "EACCES", "EBUSY"]);
4843
4880
  function takeRepoLock(file2, mine) {
4844
4881
  try {
4845
- fs36.writeFileSync(file2, mine, { flag: "wx" });
4882
+ fs37.writeFileSync(file2, mine, { flag: "wx" });
4846
4883
  return { state: "held" };
4847
4884
  } catch (err) {
4848
4885
  const code2 = err.code ?? "";
@@ -4852,8 +4889,8 @@ function takeRepoLock(file2, mine) {
4852
4889
  let raw = "";
4853
4890
  let age = 0;
4854
4891
  try {
4855
- raw = fs36.readFileSync(file2, "utf8");
4856
- age = Date.now() - fs36.statSync(file2).mtimeMs;
4892
+ raw = fs37.readFileSync(file2, "utf8");
4893
+ age = Date.now() - fs37.statSync(file2).mtimeMs;
4857
4894
  } catch {
4858
4895
  return { state: "retry" };
4859
4896
  }
@@ -4866,8 +4903,8 @@ function takeRepoLock(file2, mine) {
4866
4903
  const stale = age > REPO_LOCK_WAIT_MS || (holder ? !pidAlive3(holder.pid) : age > 5e3);
4867
4904
  if (stale) {
4868
4905
  try {
4869
- if (fs36.readFileSync(file2, "utf8") === raw)
4870
- fs36.rmSync(file2, { force: true });
4906
+ if (fs37.readFileSync(file2, "utf8") === raw)
4907
+ fs37.rmSync(file2, { force: true });
4871
4908
  } catch {
4872
4909
  }
4873
4910
  return { state: "retry" };
@@ -4876,8 +4913,8 @@ function takeRepoLock(file2, mine) {
4876
4913
  }
4877
4914
  function releaseRepoLock(file2, mine) {
4878
4915
  try {
4879
- if (fs36.readFileSync(file2, "utf8") === mine)
4880
- fs36.rmSync(file2, { force: true, recursive: true, maxRetries: 5 });
4916
+ if (fs37.readFileSync(file2, "utf8") === mine)
4917
+ fs37.rmSync(file2, { force: true, recursive: true, maxRetries: 5 });
4881
4918
  } catch {
4882
4919
  }
4883
4920
  }
@@ -4918,7 +4955,7 @@ async function oneAtATime(cwd, fn) {
4918
4955
  }
4919
4956
  function fetchStamps(common) {
4920
4957
  try {
4921
- return JSON.parse(fs36.readFileSync(path32.join(common, "lobstah-fetch.json"), "utf8"));
4958
+ return JSON.parse(fs37.readFileSync(path32.join(common, "lobstah-fetch.json"), "utf8"));
4922
4959
  } catch {
4923
4960
  return {};
4924
4961
  }
@@ -4932,15 +4969,15 @@ async function fetchShared(cwd, remote, ref) {
4932
4969
  const started = Date.now();
4933
4970
  await gitShared(cwd, "fetch", remote, ref);
4934
4971
  const stamps = { ...fetchStamps(common), [key]: started };
4935
- fs36.writeFileSync(path32.join(common, "lobstah-fetch.json"), JSON.stringify(stamps, null, 2));
4972
+ fs37.writeFileSync(path32.join(common, "lobstah-fetch.json"), JSON.stringify(stamps, null, 2));
4936
4973
  });
4937
4974
  }
4938
4975
  async function allocate(repo, id, fromRemoteBranch = repo.trunk) {
4939
4976
  const dir = worktreePath(id);
4940
- if (fs36.existsSync(dir)) {
4977
+ if (fs37.existsSync(dir)) {
4941
4978
  throw new Error(`worktree for ${id} already exists at ${dir} \u2014 never allocate a second`);
4942
4979
  }
4943
- if (!fs36.existsSync(repo.path)) {
4980
+ if (!fs37.existsSync(repo.path)) {
4944
4981
  if (!repo.origin)
4945
4982
  throw new Error(`repo path ${repo.path} missing and no origin configured`);
4946
4983
  await run2("git", ["clone", repo.origin, repo.path], { env: process.env });
@@ -4955,7 +4992,7 @@ async function allocate(repo, id, fromRemoteBranch = repo.trunk) {
4955
4992
  async function recoverWorktree(repo, id) {
4956
4993
  const dir = worktreePath(id);
4957
4994
  try {
4958
- if (fs36.statSync(path32.join(dir, ".git")).isFile()) {
4995
+ if (fs37.statSync(path32.join(dir, ".git")).isFile()) {
4959
4996
  const branch = await git2(dir, "symbolic-ref", "--quiet", "HEAD");
4960
4997
  const root = await git2(dir, "rev-parse", "--show-toplevel");
4961
4998
  const common = await git2(dir, "rev-parse", "--path-format=absolute", "--git-common-dir");
@@ -5022,10 +5059,10 @@ function setupHash(repo, dir) {
5022
5059
  h.update(JSON.stringify(repo.setup ?? []));
5023
5060
  for (const name of LOCKFILES) {
5024
5061
  const file2 = path32.join(dir, name);
5025
- if (!fs36.existsSync(file2))
5062
+ if (!fs37.existsSync(file2))
5026
5063
  continue;
5027
5064
  h.update(`\0${name}\0`);
5028
- h.update(fs36.readFileSync(file2));
5065
+ h.update(fs37.readFileSync(file2));
5029
5066
  }
5030
5067
  return h.digest("hex");
5031
5068
  }
@@ -5036,12 +5073,12 @@ function setupRecordFile(dir) {
5036
5073
  function recordSetup(repo, dir) {
5037
5074
  const file2 = setupRecordFile(dir);
5038
5075
  if (file2)
5039
- fs36.writeFileSync(file2, JSON.stringify({ hash: setupHash(repo, dir), at: (/* @__PURE__ */ new Date()).toISOString() }, null, 2));
5076
+ fs37.writeFileSync(file2, JSON.stringify({ hash: setupHash(repo, dir), at: (/* @__PURE__ */ new Date()).toISOString() }, null, 2));
5040
5077
  }
5041
5078
  function recordedSetupHash(dir) {
5042
5079
  const file2 = setupRecordFile(dir);
5043
5080
  try {
5044
- return file2 ? JSON.parse(fs36.readFileSync(file2, "utf8")).hash : void 0;
5081
+ return file2 ? JSON.parse(fs37.readFileSync(file2, "utf8")).hash : void 0;
5045
5082
  } catch {
5046
5083
  return void 0;
5047
5084
  }
@@ -5054,7 +5091,7 @@ function poolReused(slot, by) {
5054
5091
  function realpath(p) {
5055
5092
  let r;
5056
5093
  try {
5057
- r = fs36.realpathSync.native(p);
5094
+ r = fs37.realpathSync.native(p);
5058
5095
  } catch {
5059
5096
  r = path32.resolve(p);
5060
5097
  }
@@ -5548,7 +5585,7 @@ function startWallClock(opts) {
5548
5585
  import { execFile as execFile3 } from "node:child_process";
5549
5586
  import { promisify as promisify3 } from "node:util";
5550
5587
  import { fileURLToPath } from "node:url";
5551
- import * as fs37 from "node:fs";
5588
+ import * as fs38 from "node:fs";
5552
5589
  import * as path33 from "node:path";
5553
5590
  var exec2 = promisify3(execFile3);
5554
5591
  function firstLine(err) {
@@ -5582,7 +5619,7 @@ function keepRemote(opts) {
5582
5619
  const root = path33.resolve(path33.dirname(fileURLToPath(import.meta.url)), "..", "..", "..");
5583
5620
  const localCli = path33.join(root, "apps", "cli", "dist", "main.js");
5584
5621
  const args = ["watch", "add", url, "--for", id];
5585
- if (fs37.existsSync(localCli)) await command(process.execPath, [localCli, ...args], 15e3);
5622
+ if (fs38.existsSync(localCli)) await command(process.execPath, [localCli, ...args], 15e3);
5586
5623
  else await command("lobstah", args, 15e3);
5587
5624
  };
5588
5625
  let lastSeenHead;
@@ -5778,13 +5815,13 @@ async function main(activeDir, lane, seams = {}) {
5778
5815
  if (isTrapCatch(id, lane)) throw new Error(`refusing headless runner for trap catch ${id}`);
5779
5816
  const status = (verb, note) => appendStatus(id, lane, verb, note);
5780
5817
  const cfg = loadConfig();
5781
- const descriptor = JSON.parse(fs38.readFileSync(path34.join(activeDir, "descriptor.json"), "utf8"));
5818
+ const descriptor = JSON.parse(fs39.readFileSync(path34.join(activeDir, "descriptor.json"), "utf8"));
5782
5819
  if (descriptor.target || !descriptor.repo) throw new Error("configured trap work cannot launch headless");
5783
5820
  const resolved = resolveDispatch(descriptor, cfg);
5784
5821
  const repo = cfg.repos[descriptor.repo];
5785
5822
  const briefFile = path34.join(activeDir, "brief.md");
5786
- if (!fs38.existsSync(briefFile)) fs38.writeFileSync(briefFile, descriptor.brief);
5787
- const brief = fs38.readFileSync(briefFile, "utf8");
5823
+ if (!fs39.existsSync(briefFile)) fs39.writeFileSync(briefFile, descriptor.brief);
5824
+ const brief = fs39.readFileSync(briefFile, "utf8");
5788
5825
  const attempts = Number(process.env.LOBSTAH_ATTEMPTS ?? "1");
5789
5826
  const wake = process.env.LOBSTAH_WAKE;
5790
5827
  const runnerInfo = {
@@ -5792,7 +5829,7 @@ async function main(activeDir, lane, seams = {}) {
5792
5829
  startedAt: (/* @__PURE__ */ new Date()).toISOString(),
5793
5830
  attempts
5794
5831
  };
5795
- fs38.writeFileSync(path34.join(activeDir, "runner.json"), JSON.stringify(runnerInfo, null, 2));
5832
+ fs39.writeFileSync(path34.join(activeDir, "runner.json"), JSON.stringify(runnerInfo, null, 2));
5796
5833
  if (descriptor.systemRepair && descriptor.pr?.url) {
5797
5834
  const state = deps.prState(descriptor.pr.url) ?? readPr(parsePrRef(descriptor.pr.url)?.key ?? "")?.state;
5798
5835
  if (state === "MERGED" || state === "CLOSED") {
@@ -5813,10 +5850,10 @@ async function main(activeDir, lane, seams = {}) {
5813
5850
  let recorded;
5814
5851
  let recovered = false;
5815
5852
  let choice3;
5816
- if (fs38.existsSync(wtFile)) {
5817
- recorded = JSON.parse(fs38.readFileSync(wtFile, "utf8")).path;
5818
- if (!fs38.existsSync(recorded)) throw new Error(`recorded worktree ${recorded} is gone`);
5819
- } else if (fs38.existsSync(worktreePath(id))) {
5853
+ if (fs39.existsSync(wtFile)) {
5854
+ recorded = JSON.parse(fs39.readFileSync(wtFile, "utf8")).path;
5855
+ if (!fs39.existsSync(recorded)) throw new Error(`recorded worktree ${recorded} is gone`);
5856
+ } else if (fs39.existsSync(worktreePath(id))) {
5820
5857
  recorded = await recoverWorktree(repo, id);
5821
5858
  recovered = true;
5822
5859
  } else if (descriptor.followUp && cfg.limits.reuseWorktree !== false) {
@@ -5871,7 +5908,7 @@ async function main(activeDir, lane, seams = {}) {
5871
5908
  if (held) throw new Error(`worktree at ${cwd} is in use by ${held.id} \u2014 wait for that dispatch to release it before retrying`);
5872
5909
  if (recovered) {
5873
5910
  await deps.prepareReuse(repo, cwd);
5874
- fs38.writeFileSync(wtFile, JSON.stringify({ path: cwd }, null, 2));
5911
+ fs39.writeFileSync(wtFile, JSON.stringify({ path: cwd }, null, 2));
5875
5912
  }
5876
5913
  } else if (choice3?.reuse) {
5877
5914
  cwd = choice3.path;
@@ -5882,17 +5919,17 @@ async function main(activeDir, lane, seams = {}) {
5882
5919
  type: "runner",
5883
5920
  data: { worktree: cwd, worktreeOf: choice3.owner, setupRan }
5884
5921
  });
5885
- fs38.writeFileSync(wtFile, JSON.stringify({ path: cwd, of: choice3.owner }, null, 2));
5922
+ fs39.writeFileSync(wtFile, JSON.stringify({ path: cwd, of: choice3.owner }, null, 2));
5886
5923
  } else if (poolClaim) {
5887
5924
  cwd = poolClaim.dir;
5888
5925
  await deps.resetPool(repo, cwd, id, descriptor.systemRepair ? descriptor.pr?.headRefName : void 0);
5889
- fs38.writeFileSync(wtFile, JSON.stringify({ path: cwd, pool: poolClaim.label }, null, 2));
5926
+ fs39.writeFileSync(wtFile, JSON.stringify({ path: cwd, pool: poolClaim.label }, null, 2));
5890
5927
  } else {
5891
5928
  cwd = await deps.allocate(repo, id, descriptor.systemRepair ? descriptor.pr?.headRefName : void 0);
5892
5929
  acquireWorktreeLock(cwd, id, lane);
5893
- fs38.writeFileSync(wtFile, JSON.stringify({ path: cwd }, null, 2));
5930
+ fs39.writeFileSync(wtFile, JSON.stringify({ path: cwd }, null, 2));
5894
5931
  }
5895
- const worktreeOf = JSON.parse(fs38.readFileSync(wtFile, "utf8")).of;
5932
+ const worktreeOf = JSON.parse(fs39.readFileSync(wtFile, "utf8")).of;
5896
5933
  const inPool = poolSlotOf(cwd);
5897
5934
  mergeEvidence(id, lane, { worktree: cwd, worktreeOf, ...inPool ? { pool: poolSlotLabel(inPool.pool, inPool.slot) } : {} });
5898
5935
  const existingPr = boundPr(descriptor, lane);
@@ -5921,13 +5958,13 @@ async function main(activeDir, lane, seams = {}) {
5921
5958
  const planNudge = plan.cold && !envNudge ? coldNote(plan.cold, cwd, repo.trunk) : void 0;
5922
5959
  const promptWith = (nudge) => buildPrompt(brief, { id, nudge, attachments: descriptor.attachments, existingPr });
5923
5960
  const binDir = path34.resolve(path34.dirname(fileURLToPath2(import.meta.url)), "..", "..", "..", "bin");
5924
- const workerPath = fs38.existsSync(path34.join(binDir, "lobstah")) ? `${binDir}${path34.delimiter}${process.env.PATH ?? ""}` : void 0;
5961
+ const workerPath = fs39.existsSync(path34.join(binDir, "lobstah")) ? `${binDir}${path34.delimiter}${process.env.PATH ?? ""}` : void 0;
5925
5962
  let wallClockHit = false;
5926
5963
  let current;
5927
5964
  const wallFile = path34.join(activeDir, "wallclock.json");
5928
5965
  const wallState = (() => {
5929
5966
  try {
5930
- return JSON.parse(fs38.readFileSync(wallFile, "utf8"));
5967
+ return JSON.parse(fs39.readFileSync(wallFile, "utf8"));
5931
5968
  } catch {
5932
5969
  return { elapsedMs: 0, windowMs: resolved.limits.wallClockSecs * 1e3 };
5933
5970
  }
@@ -5946,8 +5983,8 @@ async function main(activeDir, lane, seams = {}) {
5946
5983
  ) * 1e3;
5947
5984
  const persistWall = (elapsedMs, windowMs) => {
5948
5985
  const tmp = uniqueTempPath(wallFile);
5949
- fs38.writeFileSync(tmp, JSON.stringify({ ...wallState, elapsedMs, windowMs }));
5950
- fs38.renameSync(tmp, wallFile);
5986
+ fs39.writeFileSync(tmp, JSON.stringify({ ...wallState, elapsedMs, windowMs }));
5987
+ fs39.renameSync(tmp, wallFile);
5951
5988
  };
5952
5989
  const madeProgress = () => {
5953
5990
  const activity = readActivity(id, lane);
@@ -6258,7 +6295,7 @@ function runRunner(activeDirArg2, laneArg2) {
6258
6295
  if (!isFinished(id, lane)) {
6259
6296
  appendStatus(id, lane, "failed", String(err instanceof Error ? err.message : err).slice(0, 500));
6260
6297
  }
6261
- fs39.renameSync(activeDirArg2, path35.join(laneDirs(lane).done, id));
6298
+ fs40.renameSync(activeDirArg2, path35.join(laneDirs(lane).done, id));
6262
6299
  } catch {
6263
6300
  }
6264
6301
  process.exitCode = 1;