pi-straw-boss 0.75.1 → 0.75.2

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.
@@ -208,7 +208,7 @@ import {
208
208
  writeStartError,
209
209
  writerAlive,
210
210
  yardPath
211
- } from "./chunk-SDNV6G3O.mjs";
211
+ } from "./chunk-PQZBUOCK.mjs";
212
212
 
213
213
  // src/server/main.ts
214
214
  import { homedir as homedir14 } from "node:os";
@@ -2528,7 +2528,7 @@ function createAsks(slot, now = Date.now) {
2528
2528
 
2529
2529
  // src/server/guihost.ts
2530
2530
  import { spawn as spawn2 } from "node:child_process";
2531
- import { readFileSync as readFileSync16 } from "node:fs";
2531
+ import { readFileSync as readFileSync17 } from "node:fs";
2532
2532
  import { join as join29 } from "node:path";
2533
2533
 
2534
2534
  // src/music.ts
@@ -2600,7 +2600,7 @@ import { fileURLToPath } from "node:url";
2600
2600
 
2601
2601
  // src/stash.ts
2602
2602
  import { randomUUID as randomUUID4 } from "node:crypto";
2603
- import { existsSync as existsSync3, linkSync, mkdirSync as mkdirSync5, readdirSync as readdirSync4, readFileSync as readFileSync7, renameSync as renameSync4, rmSync as rmSync4, statSync as statSync5, writeFileSync as writeFileSync4 } from "node:fs";
2603
+ import { existsSync as existsSync4, linkSync, mkdirSync as mkdirSync5, readdirSync as readdirSync5, readFileSync as readFileSync8, renameSync as renameSync4, rmSync as rmSync4, statSync as statSync5, writeFileSync as writeFileSync4 } from "node:fs";
2604
2604
  import { dirname as dirname4, join as join13 } from "node:path";
2605
2605
 
2606
2606
  // src/trust/settings.ts
@@ -2610,12 +2610,20 @@ import { join as join11 } from "node:path";
2610
2610
 
2611
2611
  // src/trust/found.ts
2612
2612
  import { createHash as createHash4 } from "node:crypto";
2613
+ import { closeSync as closeSync3, constants as constants2, existsSync as existsSync3, fstatSync, lstatSync as lstatSync2, openSync as openSync3, readdirSync as readdirSync3, readFileSync as readFileSync6, realpathSync as realpathSync3 } from "node:fs";
2613
2614
  var MAX_ITEMS = 20;
2614
2615
  var MAX_ITEM = 120;
2615
2616
  var MAX_FOUND = 32768;
2616
2617
  var MAX_READ = 262144;
2617
2618
  var clean3 = (text10) => text10.replace(/[\u0000-\u001f\u007f-\u009f]/g, "").replace(new RegExp("\\p{Cf}", "gu"), "\uFFFD");
2618
2619
  var cleanGroup = (g) => ({ ...g, kind: clean3(g.kind), path: clean3(g.path), items: g.items.map(clean3) });
2620
+ var canonical = (path) => {
2621
+ try {
2622
+ return realpathSync3(path);
2623
+ } catch {
2624
+ return path;
2625
+ }
2626
+ };
2619
2627
  var digestOf = (cwd, found) => createHash4("sha256").update(JSON.stringify(["pi-trust/1", cwd, found])).digest("hex");
2620
2628
 
2621
2629
  // src/trust/settings.ts
@@ -2737,7 +2745,7 @@ async function assertSettingsSafe(dirs, what, run3) {
2737
2745
  }
2738
2746
 
2739
2747
  // src/trust/files.ts
2740
- import { chmodSync as chmodSync4, lstatSync as lstatSync2, realpathSync as realpathSync3, mkdirSync as mkdirSync4, readdirSync as readdirSync3, readFileSync as readFileSync6, renameSync as renameSync3, rmSync as rmSync3, writeFileSync as writeFileSync3 } from "node:fs";
2748
+ import { chmodSync as chmodSync4, lstatSync as lstatSync3, realpathSync as realpathSync4, mkdirSync as mkdirSync4, readdirSync as readdirSync4, readFileSync as readFileSync7, renameSync as renameSync3, rmSync as rmSync3, writeFileSync as writeFileSync3 } from "node:fs";
2741
2749
  import { homedir as homedir5 } from "node:os";
2742
2750
  import { join as join12, relative as relative2, isAbsolute as isAbsolute3 } from "node:path";
2743
2751
 
@@ -2766,10 +2774,10 @@ function ensureDir2(dir, ids = process.getuid !== void 0, home = homedir5()) {
2766
2774
  try {
2767
2775
  mkdirSync4(join12(dir, ".."), { recursive: true, mode: 448 });
2768
2776
  mkdirSync4(dir, { recursive: true, mode: 448 });
2769
- const st = lstatSync2(dir);
2777
+ const st = lstatSync3(dir);
2770
2778
  if (!st.isDirectory() || st.isSymbolicLink() || ids && st.uid !== uid()) return false;
2771
2779
  if (!ids) {
2772
- const inside2 = relative2(realpathSync3.native(home), realpathSync3.native(dir));
2780
+ const inside2 = relative2(realpathSync4.native(home), realpathSync4.native(dir));
2773
2781
  if (inside2.startsWith("..") || isAbsolute3(inside2)) return false;
2774
2782
  }
2775
2783
  if (process.platform !== "win32" && (st.mode & 63) !== 0) chmodSync4(dir, 448);
@@ -2798,9 +2806,9 @@ function writeAtomic(dir, name2, value) {
2798
2806
  }
2799
2807
  function readJson2(file2, max = MAX_FILE) {
2800
2808
  try {
2801
- const st = lstatSync2(file2);
2809
+ const st = lstatSync3(file2);
2802
2810
  if (!st.isFile() || st.size > max || uid() !== void 0 && st.uid !== uid()) return void 0;
2803
- return { value: JSON.parse(readFileSync6(file2, "utf8")), mtime: st.mtimeMs };
2811
+ return { value: JSON.parse(readFileSync7(file2, "utf8")), mtime: st.mtimeMs };
2804
2812
  } catch {
2805
2813
  return void 0;
2806
2814
  }
@@ -2830,7 +2838,7 @@ var remove = (dir, ...names) => names.forEach((n) => rmSync3(join12(dir, n), { f
2830
2838
  function listRequests(dir, alive2 = lives) {
2831
2839
  let names;
2832
2840
  try {
2833
- names = readdirSync3(dir);
2841
+ names = readdirSync4(dir);
2834
2842
  } catch {
2835
2843
  return [];
2836
2844
  }
@@ -2846,7 +2854,7 @@ function listRequests(dir, alive2 = lives) {
2846
2854
  function sweep(dir, now = Date.now(), alive2 = lives) {
2847
2855
  let names;
2848
2856
  try {
2849
- names = readdirSync3(dir);
2857
+ names = readdirSync4(dir);
2850
2858
  } catch {
2851
2859
  return;
2852
2860
  }
@@ -2868,7 +2876,7 @@ function sweep(dir, now = Date.now(), alive2 = lives) {
2868
2876
  }
2869
2877
  var lstatMtime = (file2) => {
2870
2878
  try {
2871
- return lstatSync2(file2).mtimeMs;
2879
+ return lstatSync3(file2).mtimeMs;
2872
2880
  } catch {
2873
2881
  return void 0;
2874
2882
  }
@@ -2905,7 +2913,7 @@ var dirOf = (stateDir) => join13(stateDir, "stash");
2905
2913
  var stashFile = (stateDir, name2) => join13(dirOf(stateDir), `${name2}.json`);
2906
2914
  function nameFor(label, stateDir) {
2907
2915
  const base = label.replace(/[/\\\p{Cc}]/gu, "-").trim().replace(/^\.+/, "").slice(0, MAX_NAME - 4).trim() || "base";
2908
- for (let n = 1; ; n++) if (!existsSync3(stashFile(stateDir, n > 1 ? `${base} ${n}` : base))) return n > 1 ? `${base} ${n}` : base;
2916
+ for (let n = 1; ; n++) if (!existsSync4(stashFile(stateDir, n > 1 ? `${base} ${n}` : base))) return n > 1 ? `${base} ${n}` : base;
2909
2917
  }
2910
2918
  function stashedList(stateDir) {
2911
2919
  return listStashes(stateDir).flatMap((name2) => {
@@ -2919,7 +2927,7 @@ function stashedList(stateDir) {
2919
2927
  }
2920
2928
  function listStashes(stateDir) {
2921
2929
  try {
2922
- return readdirSync4(dirOf(stateDir)).filter((f) => f.endsWith(".json")).map((f) => f.slice(0, -5)).filter(nameOk).sort((a, b) => a.localeCompare(b));
2930
+ return readdirSync5(dirOf(stateDir)).filter((f) => f.endsWith(".json")).map((f) => f.slice(0, -5)).filter(nameOk).sort((a, b) => a.localeCompare(b));
2923
2931
  } catch {
2924
2932
  return [];
2925
2933
  }
@@ -2934,7 +2942,7 @@ function readStash(stateDir, name2, file2 = stashFile(stateDir, name2)) {
2934
2942
  if (!nameOk(name2)) throw new Error(`"${name2}" is not a stash name`);
2935
2943
  let st;
2936
2944
  try {
2937
- st = JSON.parse(readFileSync7(file2, "utf8"));
2945
+ st = JSON.parse(readFileSync8(file2, "utf8"));
2938
2946
  } catch (error) {
2939
2947
  throw new Error(error.code === "ENOENT" ? `Nothing is stashed as "${name2}"` : `The stash "${name2}" cannot be read: ${error.message}`);
2940
2948
  }
@@ -2989,7 +2997,7 @@ async function survey(run3, workspaceId, live, resume2 = true, serviced = false)
2989
2997
  else if (!ROLES2.has(role)) reasons.push(`${who2} is a subagent or outside the net`);
2990
2998
  if (p.agent !== "pi" || !ROLES2.has(role)) continue;
2991
2999
  if (!SETTLED.has(p.agent_status ?? "")) reasons.push(`${who2} is ${p.agent_status ?? "in an unknown state"}`);
2992
- const named = p.agent_session?.value, file2 = named && existsSync3(named) ? named : void 0;
3000
+ const named = p.agent_session?.value, file2 = named && existsSync4(named) ? named : void 0;
2993
3001
  if (!named && resume2) reasons.push(`${who2} has no session file Herdr knows of`);
2994
3002
  if (!cwd2 && resume2) reasons.push(`${who2} has no folder Herdr knows of`);
2995
3003
  if (session) agents.push(session);
@@ -3044,7 +3052,7 @@ async function closeAll(d, me, closeBase, refresh, by, workspace) {
3044
3052
  async function stashBase(d, json3, closeBase, refresh) {
3045
3053
  if (!str2(json3.workspace) || json3.workspace.length > 200) return no2(400, "bad_request", "A base is named by its workspace.");
3046
3054
  if (json3.name !== void 0 && !nameOk(json3.name)) return no2(400, "bad_request", `A stash name has at most ${MAX_NAME} characters, no slash, backslash, or control character, and does not start with a dot.`);
3047
- if (typeof json3.name === "string" && existsSync3(stashFile(d.stateDir, json3.name))) return no2(409, "exists", `Something is stashed as "${json3.name}" already; pop it or pick another name.`);
3055
+ if (typeof json3.name === "string" && existsSync4(stashFile(d.stateDir, json3.name))) return no2(409, "exists", `Something is stashed as "${json3.name}" already; pop it or pick another name.`);
3048
3056
  const sv = await survey(d.run, json3.workspace, await d.sessions(), true, d.service?.(json3.workspace));
3049
3057
  if (!sv) return no2(404, "not_found", "That base is not open any more.");
3050
3058
  const reasons = [...sv.reasons, ...await askSessions(d, sv.agents, refresh)];
@@ -3093,7 +3101,7 @@ async function popBase(d, name2) {
3093
3101
  renameSync4(claimed2, join13(dirOf(d.stateDir), "popped", `${name2}-${(d.now?.() ?? /* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-")}.json`));
3094
3102
  return r;
3095
3103
  } catch (error) {
3096
- const back = existsSync3(stashFile(d.stateDir, name2)) ? nameFor(name2, d.stateDir) : name2;
3104
+ const back = existsSync4(stashFile(d.stateDir, name2)) ? nameFor(name2, d.stateDir) : name2;
3097
3105
  linkSync(claimed2, stashFile(d.stateDir, back));
3098
3106
  rmSync4(claimed2, { force: true });
3099
3107
  throw back === name2 ? error : new Error(`${error.message}; it is stashed again as "${back}", since "${name2}" was taken meanwhile`);
@@ -3107,7 +3115,7 @@ async function open2(d, name2, file2) {
3107
3115
  }
3108
3116
  const all = st.tabs.flatMap((t) => t.panes);
3109
3117
  const envOf = (kind) => [...roleEnv(kind), ...d.agentDir ? [`PI_CODING_AGENT_DIR=${d.agentDir}`] : []];
3110
- const gone = [.../* @__PURE__ */ new Set([...all.filter((p) => p.session && !existsSync3(p.session)).map((p) => p.session), ...all.map((p) => p.cwd).filter((c) => !statSync5(c, { throwIfNoEntry: false })?.isDirectory())])];
3118
+ const gone = [.../* @__PURE__ */ new Set([...all.filter((p) => p.session && !existsSync4(p.session)).map((p) => p.session), ...all.map((p) => p.cwd).filter((c) => !statSync5(c, { throwIfNoEntry: false })?.isDirectory())])];
3111
3119
  if (gone.length) throw new Error(`Nothing was opened: ${gone.join(", ")} no longer exist${gone.length > 1 ? "" : "s"}`);
3112
3120
  await assertSettingsSafe(all.filter((p) => p.kind !== "shell").map((p) => p.cwd), "The stash");
3113
3121
  const root = st.tabs[0].panes[0];
@@ -3311,7 +3319,7 @@ import { randomUUID as randomUUID6 } from "node:crypto";
3311
3319
  import { open as open4, stat as stat2 } from "node:fs/promises";
3312
3320
 
3313
3321
  // src/netdata.ts
3314
- import { readdirSync as readdirSync5, readFileSync as readFileSync8, statSync as statSync6 } from "node:fs";
3322
+ import { readdirSync as readdirSync6, readFileSync as readFileSync9, statSync as statSync6 } from "node:fs";
3315
3323
  import { basename as basename2, dirname as dirname5, join as join14 } from "node:path";
3316
3324
  var HERDR_MARK = { working: "working", blocked: "waiting", idle: "idle", done: "done" };
3317
3325
  var RECENT_MS = 10 * 6e4;
@@ -3325,7 +3333,7 @@ var commanding = (mark2, subs, monitoring = false) => mark2 === "idle" && (monit
3325
3333
  var artifacts = (file2) => join14(dirname5(file2), "artifacts", basename2(file2, ".jsonl").split("_").pop());
3326
3334
  function readJson3(path) {
3327
3335
  try {
3328
- return JSON.parse(readFileSync8(path, "utf8"));
3336
+ return JSON.parse(readFileSync9(path, "utf8"));
3329
3337
  } catch {
3330
3338
  return {};
3331
3339
  }
@@ -3357,7 +3365,7 @@ function listed(dir) {
3357
3365
  try {
3358
3366
  const stat6 = statSync6(dir, { bigint: true }), cached2 = listings.get(dir);
3359
3367
  if (cached2?.mtime === stat6.mtimeNs && cached2.readAt - Number(stat6.mtimeNs / 1000000n) > RACY_MS) return cached2.names;
3360
- const readAt = Date.now(), names = readdirSync5(dir);
3368
+ const readAt = Date.now(), names = readdirSync6(dir);
3361
3369
  if (listings.size > 200) listings.clear();
3362
3370
  listings.set(dir, { mtime: stat6.mtimeNs, readAt, names });
3363
3371
  return names;
@@ -3370,7 +3378,7 @@ function scriptRead(path) {
3370
3378
  try {
3371
3379
  const { mtimeMs } = statSync6(path), cached2 = scripts.get(path);
3372
3380
  if (cached2?.mtimeMs === mtimeMs) return cached2;
3373
- const text10 = readFileSync8(path, "utf8"), read4 = { mtimeMs, session: text10.match(/PI_SUBAGENT_SESSION='([^']+)'/)?.[1], persistent: /\bPI_SUBAGENT_PERSISTENT=1\b/.test(text10), agent: text10.match(/\bPI_SUBAGENT_AGENT='([^']+)'/)?.[1] };
3381
+ const text10 = readFileSync9(path, "utf8"), read4 = { mtimeMs, session: text10.match(/PI_SUBAGENT_SESSION='([^']+)'/)?.[1], persistent: /\bPI_SUBAGENT_PERSISTENT=1\b/.test(text10), agent: text10.match(/\bPI_SUBAGENT_AGENT='([^']+)'/)?.[1] };
3374
3382
  if (scripts.size > 500) scripts.clear();
3375
3383
  scripts.set(path, read4);
3376
3384
  return read4;
@@ -3780,7 +3788,7 @@ ${id}`, cap = caps.get(k) ?? randomBytes4(16).toString("hex");
3780
3788
  }
3781
3789
 
3782
3790
  // src/history.ts
3783
- import { constants as constants2, realpathSync as realpathSync4, watch } from "node:fs";
3791
+ import { constants as constants3, realpathSync as realpathSync5, watch } from "node:fs";
3784
3792
  import { lstat as lstat2, open as openFile, stat as stat3 } from "node:fs/promises";
3785
3793
  import { basename as basename4, dirname as dirname6, join as join15, resolve as resolve3 } from "node:path";
3786
3794
  var CHUNK2 = 1 << 20;
@@ -3789,20 +3797,20 @@ var TAIL3 = 400;
3789
3797
  var BIG = 16384;
3790
3798
  var PAGE = 150;
3791
3799
  var HIDDEN2 = /* @__PURE__ */ new Set(["session", "custom", "label", "usage", "context_edit"]);
3792
- function canonical(path) {
3800
+ function canonical2(path) {
3793
3801
  if (!path) return void 0;
3794
3802
  for (let dir = resolve3(path), rest = ""; ; rest = join15(basename4(dir), rest), dir = dirname6(dir)) {
3795
3803
  try {
3796
- return join15(realpathSync4(dir), rest);
3804
+ return join15(realpathSync5(dir), rest);
3797
3805
  } catch {
3798
3806
  if (dir === dirname6(dir)) return resolve3(path);
3799
3807
  }
3800
3808
  }
3801
3809
  }
3802
3810
  async function open5(file2) {
3803
- const nofollow = constants2.O_NOFOLLOW ?? 0;
3811
+ const nofollow = constants3.O_NOFOLLOW ?? 0;
3804
3812
  if (!nofollow && (await lstat2(file2)).isSymbolicLink()) throw Object.assign(new Error(`ELOOP: ${file2} is a symbolic link`), { code: "ELOOP" });
3805
- return openFile(file2, constants2.O_RDONLY | nofollow);
3813
+ return openFile(file2, constants3.O_RDONLY | nofollow);
3806
3814
  }
3807
3815
  function openReader(file2, pollMs = 1e3) {
3808
3816
  let ents = [], byId = /* @__PURE__ */ new Map(), path = [], bad2 = 0, size2 = 0, ino = -1, headText = "", head;
@@ -4410,7 +4418,7 @@ function createHub(pi, me, local, onAllow) {
4410
4418
  const hub = {
4411
4419
  receive,
4412
4420
  /** Whether the bridge bound to `key` relays an open dialog of `owner` (a signal from the runtime that owns the approval, not from the session file). With `at` (the unit's pane and file) the bridges are read directly too, so a dialog relayed since the last net reading counts at once. */
4413
- has: (key2, owner2, at) => Boolean(bound2.get(key2)?.b.dialogs.some((d) => d.owner === owner2)) || Boolean(at?.pane && at.file && [...bridges.values()].some((b) => b.pane === at.pane && canonical(b.file ?? void 0) === canonical(at.file) && b.dialogs.some((d) => d.owner === owner2))),
4421
+ has: (key2, owner2, at) => Boolean(bound2.get(key2)?.b.dialogs.some((d) => d.owner === owner2)) || Boolean(at?.pane && at.file && [...bridges.values()].some((b) => b.pane === at.pane && canonical2(b.file ?? void 0) === canonical2(at.file) && b.dialogs.some((d) => d.owner === owner2))),
4414
4422
  get running() {
4415
4423
  return active;
4416
4424
  },
@@ -4460,7 +4468,7 @@ function createHub(pi, me, local, onAllow) {
4460
4468
  [bound2, targets, reach] = [/* @__PURE__ */ new Map(), /* @__PURE__ */ new Map(), /* @__PURE__ */ new Map()];
4461
4469
  const shelved = [], cut7 = /* @__PURE__ */ new Set(), queues = /* @__PURE__ */ new Map(), mons = /* @__PURE__ */ new Map(), todos = /* @__PURE__ */ new Map();
4462
4470
  for (const [from, b] of bridges) {
4463
- const file2 = sessions.find((s2) => s2.id === from)?.herdrLocation?.paneId === b.pane ? canonical(b.file ?? void 0) : void 0;
4471
+ const file2 = sessions.find((s2) => s2.id === from)?.herdrLocation?.paneId === b.pane ? canonical2(b.file ?? void 0) : void 0;
4464
4472
  const ref = file2 && [...refs.values()].find((r) => r.pane === b.pane && r.file === file2);
4465
4473
  if (ref) reach.set(ref.key, { from, bridgeId: b.bridgeId }), shelved.push({ key: ref.key, from, bridgeId: b.bridgeId, docs: b.documents ?? [] }), b.docsCut && cut7.add(ref.key);
4466
4474
  if (ref && b.queued?.length) queues.set(ref.key, b.queued);
@@ -5374,7 +5382,7 @@ var localOnlyText = (text10) => {
5374
5382
  var LOCAL_ONLY = "Pairing, remote access, Wi-Fi, the server, the default view, deciding a join request, and answering another session's dialog are managed on this computer's own page or terminal, not from a paired device.";
5375
5383
  var GUARDED = "A /boss send is held to the guards of a remote write (the session it runs in may be driven from elsewhere): this needs this computer's own page, or type it in that session's own terminal.";
5376
5384
  var LINK_LOCAL = "While it waits on a link request, a paired device can only send Escape; approve it on this computer's own page or terminal.";
5377
- function createControl({ auto, board, bridge, lan, overlay, link, server: panel, lookup, call, csrf, canonical: canonical2, pair, remoteOn, remoteOff, paired, saveFailed, spawn: spawn3, close, dismiss, dismissAll, stop, mirrors, grants, secret = async () => true, linkRequest: linkRequest3 = async () => false, answers: answers2, trust, tower, docs, answered }) {
5385
+ function createControl({ auto, board, bridge, lan, overlay, link, server: panel, lookup, call, csrf, canonical: canonical3, pair, remoteOn, remoteOff, paired, saveFailed, spawn: spawn3, close, dismiss, dismissAll, stop, mirrors, grants, secret = async () => true, linkRequest: linkRequest3 = async () => false, answers: answers2, trust, tower, docs, answered }) {
5378
5386
  const busy = /* @__PURE__ */ new Set();
5379
5387
  const lost = () => {
5380
5388
  const reason = paired?.unsaved();
@@ -5648,14 +5656,14 @@ function createControl({ auto, board, bridge, lan, overlay, link, server: panel,
5648
5656
  async function live(found) {
5649
5657
  const { pane } = await call("pane.get", { pane_id: found.pane });
5650
5658
  if (pane.agent !== "pi") throw no8(409, "not_pi", "The pane no longer runs pi.");
5651
- if (canonical2(pane.agent_session?.value) !== found.file) throw no8(409, "moved", "The pane moved to another session.");
5659
+ if (canonical3(pane.agent_session?.value) !== found.file) throw no8(409, "moved", "The pane moved to another session.");
5652
5660
  return pane;
5653
5661
  }
5654
5662
  }
5655
5663
 
5656
5664
  // src/docs.ts
5657
5665
  import { createHash as createHash7, randomBytes as randomBytes6 } from "node:crypto";
5658
- import { createReadStream, readFileSync as readFileSync9, realpathSync as realpathSync5, statSync as statSync7 } from "node:fs";
5666
+ import { createReadStream, readFileSync as readFileSync10, realpathSync as realpathSync6, statSync as statSync7 } from "node:fs";
5659
5667
  import { pipeline } from "node:stream";
5660
5668
  import { dirname as dirname7, extname as extname2, resolve as resolve4, sep as sep3 } from "node:path";
5661
5669
 
@@ -5744,11 +5752,11 @@ function createDocs(hub, name2, { answered = createAnswered({ load: () => void 0
5744
5752
  const body2 = async (doc2) => {
5745
5753
  if (doc2.v === 2) return (await pull(doc2.capability, MAX_DOC))?.toString("utf8");
5746
5754
  const real3 = file2(doc2.path, MAX_DOC);
5747
- return real3 ? readFileSync9(real3, "utf8") : void 0;
5755
+ return real3 ? readFileSync10(real3, "utf8") : void 0;
5748
5756
  };
5749
5757
  const file2 = (path, max, under2) => {
5750
5758
  try {
5751
- const real3 = realpathSync5(path), root = under2 && realpathSync5(under2);
5759
+ const real3 = realpathSync6(path), root = under2 && realpathSync6(under2);
5752
5760
  return (root ? real3.startsWith(root + sep3) : real3 === path) && statSync7(real3).isFile() && statSync7(real3).size <= max ? real3 : void 0;
5753
5761
  } catch {
5754
5762
  return void 0;
@@ -6788,10 +6796,10 @@ function createEntry(access, token, headers) {
6788
6796
  import { pipeline as pipeline2 } from "node:stream";
6789
6797
 
6790
6798
  // src/guithemes.ts
6791
- import { readdirSync as readdirSync6, readFileSync as readFileSync10, statSync as statSync8 } from "node:fs";
6799
+ import { readdirSync as readdirSync7, readFileSync as readFileSync11, statSync as statSync8 } from "node:fs";
6792
6800
  import { join as join17 } from "node:path";
6793
6801
  function listBundle(dir) {
6794
- const bundle = new Map(readdirSync6(dir, { recursive: true, encoding: "utf8" }).filter((f) => statSync8(join17(dir, f)).isFile()).map((f) => [f.split("\\").join("/"), readFileSync10(join17(dir, f))]));
6802
+ const bundle = new Map(readdirSync7(dir, { recursive: true, encoding: "utf8" }).filter((f) => statSync8(join17(dir, f)).isFile()).map((f) => [f.split("\\").join("/"), readFileSync11(join17(dir, f))]));
6795
6803
  const map = (() => {
6796
6804
  try {
6797
6805
  return JSON.parse(bundle.get("themes.json")?.toString("utf8") ?? "{}");
@@ -6889,7 +6897,7 @@ async function startGui({ auto, board, read: read4, net, call, hub, answered = c
6889
6897
  if (net2 !== "tailnet") docs?.revoke(device);
6890
6898
  }, paired, { ...lan ? { file: lan.file } : {}, ...lan?.notify ? { notify: lan.notify } : {}, ...lan?.log ? { log: lan.log } : {} });
6891
6899
  const pair = (code = access.pair(), host2 = access.remote?.host, url = `https://${host2}/${token}/pair/${code}`) => code && host2 ? { url, rows: qr(url).map((row2) => row2.map(Number).join("")), code: access.pairCode() } : void 0;
6892
- const entry = createEntry(access, token, HEADERS), grants = call && createGrants({ call }), mirrors = createMirrors({ call, lookup: (key2) => net?.lookup(key2), secret: waitsForSecret, canonical }), docs = hub && createDocs(hub, (key2) => net?.lookup(key2)?.name ?? key2, { answered });
6900
+ const entry = createEntry(access, token, HEADERS), grants = call && createGrants({ call }), mirrors = createMirrors({ call, lookup: (key2) => net?.lookup(key2), secret: waitsForSecret, canonical: canonical2 }), docs = hub && createDocs(hub, (key2) => net?.lookup(key2)?.name ?? key2, { answered });
6893
6901
  const stop = (asked3) => refuseTake && asked3.take ? false : (setTimeout(() => onStop ? onStop(asked3) : void halt(), 10), true);
6894
6902
  const dismissAll = async () => {
6895
6903
  const n = net?.dismissAll?.() ?? 0;
@@ -6904,7 +6912,7 @@ async function startGui({ auto, board, read: read4, net, call, hub, answered = c
6904
6912
  const done2 = await tower.memory(ws, json3);
6905
6913
  await tick();
6906
6914
  return done2;
6907
- } } : tower, lookup: (key2) => net?.lookup(key2), call, csrf, canonical, pair, remoteOn: onRemote, remoteOff: onRemoteOff, paired: { on: () => Boolean(access.remote), ...access.devices, unsaved: access.unsaved }, saveFailed: onSaveFailed, spawn: spawn3, close: close && (async (kind, json3) => (await tick(), close(kind, json3, tick))), dismiss: async (key2) => typeof key2 === "string" && Boolean(net?.dismiss?.(key2)) && (await tick(), true), dismissAll, mirrors, stop, secret: waitsForSecret, linkRequest: waitsForLinkRequest, trust: trust?.answer, answers: hub && { has: hub.has, replay: hub.replay, ended: hub.ended, send: hub.send, probe: hub.probe, commands: hub.commands, pull: hub.pull, target: async (key2) => (await tick(), hub.target(key2)) }, docs, answered });
6915
+ } } : tower, lookup: (key2) => net?.lookup(key2), call, csrf, canonical: canonical2, pair, remoteOn: onRemote, remoteOff: onRemoteOff, paired: { on: () => Boolean(access.remote), ...access.devices, unsaved: access.unsaved }, saveFailed: onSaveFailed, spawn: spawn3, close: close && (async (kind, json3) => (await tick(), close(kind, json3, tick))), dismiss: async (key2) => typeof key2 === "string" && Boolean(net?.dismiss?.(key2)) && (await tick(), true), dismissAll, mirrors, stop, secret: waitsForSecret, linkRequest: waitsForLinkRequest, trust: trust?.answer, answers: hub && { has: hub.has, replay: hub.replay, ended: hub.ended, send: hub.send, probe: hub.probe, commands: hub.commands, pull: hub.pull, target: async (key2) => (await tick(), hub.target(key2)) }, docs, answered });
6908
6916
  let last, problem, inflight, local;
6909
6917
  let poll, beat;
6910
6918
  const send = (to, data, event) => to.writableEnded || to.write(`${event ? `event: ${event}
@@ -7179,7 +7187,7 @@ var joinedRole = (token) => token === "main" || token === "member" || token ===
7179
7187
  var RECENT_MS2 = 10 * 6e4;
7180
7188
  var raiserView = ({ id, ...rest }, keys) => ({ ...rest, ...id && keys.get(id) ? { key: keys.get(id) } : {} });
7181
7189
  function buildNet({ sessions, panes: ps, workspaces: all, children: children2, services, head, sessionDir = join19(process.env.PI_CODING_AGENT_DIR ?? join19(homedir6(), ".pi", "agent"), "sessions") }, refs = /* @__PURE__ */ new Map()) {
7182
- const root = canonical(sessionDir), readable2 = (file2, id, real3 = file2?.endsWith(".jsonl") ? canonical(file2) : void 0) => real3 && real3.startsWith(root + sep4) && (!id || basename6(real3).endsWith(`_${id}.jsonl`)) ? real3 : void 0;
7190
+ const root = canonical2(sessionDir), readable2 = (file2, id, real3 = file2?.endsWith(".jsonl") ? canonical2(file2) : void 0) => real3 && real3.startsWith(root + sep4) && (!id || basename6(real3).endsWith(`_${id}.jsonl`)) ? real3 : void 0;
7183
7191
  const piFile = (pane, id) => readable2(pane?.agent === "pi" ? pane.agent_session?.value : void 0, id);
7184
7192
  const paneOf = (s2) => ps.find((p) => p.pane_id === s2.herdrLocation?.paneId);
7185
7193
  const note = (mark2, status) => ({ working: status, waiting: "waiting on a question" })[mark2];
@@ -7290,7 +7298,7 @@ function netSource(env) {
7290
7298
  }
7291
7299
 
7292
7300
  // src/openings.ts
7293
- import { mkdirSync as mkdirSync6, readFileSync as readFileSync12 } from "node:fs";
7301
+ import { mkdirSync as mkdirSync6, readFileSync as readFileSync13 } from "node:fs";
7294
7302
  import { dirname as dirname8 } from "node:path";
7295
7303
  var KEPT2 = 64;
7296
7304
  var str7 = (v) => typeof v === "string" && v.length > 0;
@@ -7298,7 +7306,7 @@ var DELIVERY = ["none", "pending", "sending", "sent"];
7298
7306
  function createOpenings(file2) {
7299
7307
  const kept = /* @__PURE__ */ new Map();
7300
7308
  try {
7301
- const saved = file2 ? JSON.parse(readFileSync12(file2, "utf8")) : void 0;
7309
+ const saved = file2 ? JSON.parse(readFileSync13(file2, "utf8")) : void 0;
7302
7310
  if (saved && typeof saved === "object") {
7303
7311
  for (const [id, o] of Object.entries(saved)) {
7304
7312
  if (str7(o?.workspace) && str7(o.tab) && str7(o.pane) && str7(o.dir) && str7(o.label) && DELIVERY.includes(o.delivery)) kept.set(id, { workspace: o.workspace, tab: o.tab, pane: o.pane, dir: o.dir, label: o.label, delivery: o.delivery });
@@ -7331,6 +7339,19 @@ function createOpenings(file2) {
7331
7339
  };
7332
7340
  }
7333
7341
 
7342
+ // src/trust/intent.ts
7343
+ function createIntents() {
7344
+ const live = /* @__PURE__ */ new Set();
7345
+ return {
7346
+ grant(pane, cwd) {
7347
+ const entry = { pane, cwd: canonical(cwd) };
7348
+ live.add(entry);
7349
+ return () => void live.delete(entry);
7350
+ },
7351
+ has: (pane, cwd) => typeof cwd === "string" && [...live].some((e) => e.pane === pane && e.cwd === canonical(cwd))
7352
+ };
7353
+ }
7354
+
7334
7355
  // src/spawn.ts
7335
7356
  import { randomUUID as randomUUID8 } from "node:crypto";
7336
7357
  import { mkdir as mkdir2, readdir as readdir3, realpath as realpath2, rmdir, stat as stat5 } from "node:fs/promises";
@@ -7429,7 +7450,7 @@ async function makeDir(parent, name2, home = homedir7(), hidden = platformHidden
7429
7450
  });
7430
7451
  return real3 ? { status: 200, body: { path: real3, created: made } } : no10(409, "not_a_folder", `${clean6} exists here and is not a folder you can pick.`);
7431
7452
  }
7432
- function createSpawn({ run: run3, sleep: sleep2, call, live, sessionAt, home = homedir7(), hidden = platformHidden, deploys = createDeploys(), trustDir: trustDir2, openings = createOpenings(), note, lock = { busy: false } }) {
7453
+ function createSpawn({ run: run3, sleep: sleep2, call, live, sessionAt, home = homedir7(), hidden = platformHidden, deploys = createDeploys(), trustDir: trustDir2, openings = createOpenings(), intents, note, lock = { busy: false } }) {
7433
7454
  const pick2 = (path) => pickable(path, home, hidden);
7434
7455
  const keep2 = (id, opening3) => {
7435
7456
  try {
@@ -7495,11 +7516,16 @@ function createSpawn({ run: run3, sleep: sleep2, call, live, sessionAt, home = h
7495
7516
  } catch {
7496
7517
  }
7497
7518
  }
7498
- async function boot(d, paneId, name2, prompt, role, joinWaitMs = JOIN_WAIT_MS, track) {
7519
+ async function boot(d, paneId, name2, prompt, role, joinWaitMs = JOIN_WAIT_MS, track, intent) {
7499
7520
  d.go("start");
7500
7521
  d.pane = paneId;
7501
- await startPi(run3, sleep2, `${role ?? "member"}-${randomUUID8().slice(0, 8)}`, paneId, ["--name", name2]);
7502
- await awaitJoin(d, paneId, joinWaitMs, role);
7522
+ const release = intent ? intents?.grant(paneId, intent) : void 0;
7523
+ try {
7524
+ await startPi(run3, sleep2, `${role ?? "member"}-${randomUUID8().slice(0, 8)}`, paneId, ["--name", name2]);
7525
+ await awaitJoin(d, paneId, joinWaitMs, role);
7526
+ } finally {
7527
+ release?.();
7528
+ }
7503
7529
  if (prompt) return deliver(d, paneId, prompt, track);
7504
7530
  }
7505
7531
  const orClose = async (close, open8) => {
@@ -7580,7 +7606,7 @@ function createSpawn({ run: run3, sleep: sleep2, call, live, sessionAt, home = h
7580
7606
  if (id) {
7581
7607
  keep2(id, { ...record2, delivery });
7582
7608
  }
7583
- return boot(d, paneId, `member \xB7 ${basename7(dir) || dir}`, prompt, void 0, joinWaitMs, id ? (state) => void keep2(id, { ...record2, delivery: delivery = state }) : (state) => void (delivery = state));
7609
+ return boot(d, paneId, `member \xB7 ${basename7(dir) || dir}`, prompt, void 0, joinWaitMs, id ? (state) => void keep2(id, { ...record2, delivery: delivery = state }) : (state) => void (delivery = state), dir);
7584
7610
  }).catch((error) => {
7585
7611
  if (id) try {
7586
7612
  openings.drop(id);
@@ -7730,24 +7756,24 @@ function createTrustServe(d) {
7730
7756
  }
7731
7757
 
7732
7758
  // src/server/answeredfile.ts
7733
- import { closeSync as closeSync3, constants as constants3, fstatSync, lstatSync as lstatSync3, openSync as openSync3, readFileSync as readFileSync13, renameSync as renameSync5 } from "node:fs";
7759
+ import { closeSync as closeSync4, constants as constants4, fstatSync as fstatSync2, lstatSync as lstatSync4, openSync as openSync4, readFileSync as readFileSync14, renameSync as renameSync5 } from "node:fs";
7734
7760
  var MAX_BYTES = 32 * 1024 * 1024;
7735
7761
  function readOwnedStrict(file2) {
7736
7762
  let fd;
7737
7763
  try {
7738
- if (lstatSync3(file2).isSymbolicLink()) throw new Error("the record is a link");
7739
- fd = openSync3(file2, process.platform === "win32" ? constants3.O_RDONLY : constants3.O_RDONLY | constants3.O_NOFOLLOW);
7764
+ if (lstatSync4(file2).isSymbolicLink()) throw new Error("the record is a link");
7765
+ fd = openSync4(file2, process.platform === "win32" ? constants4.O_RDONLY : constants4.O_RDONLY | constants4.O_NOFOLLOW);
7740
7766
  } catch (error) {
7741
7767
  if (error.code === "ENOENT") return void 0;
7742
7768
  throw error;
7743
7769
  }
7744
7770
  try {
7745
- const info = fstatSync(fd);
7771
+ const info = fstatSync2(fd);
7746
7772
  if (!info.isFile() || info.size > MAX_BYTES) throw new Error("the record is not a regular file of a sane size");
7747
7773
  if (process.getuid && info.uid !== process.getuid()) throw new Error("the record belongs to another account");
7748
- return readFileSync13(fd, "utf8");
7774
+ return readFileSync14(fd, "utf8");
7749
7775
  } finally {
7750
- closeSync3(fd);
7776
+ closeSync4(fd);
7751
7777
  }
7752
7778
  }
7753
7779
  var answeredFileDeps = (file2) => ({
@@ -7762,7 +7788,7 @@ import { join as join23 } from "node:path";
7762
7788
 
7763
7789
  // src/lan/ca.ts
7764
7790
  import { createHash as createHash10, createPrivateKey as createPrivateKey3, randomBytes as randomBytes10, X509Certificate } from "node:crypto";
7765
- import { closeSync as closeSync4, constants as constants4, fstatSync as fstatSync2, lstatSync as lstatSync4, mkdirSync as mkdirSync7, openSync as openSync4, readFileSync as readFileSync14, rmSync as rmSync5, writeSync as writeSync3 } from "node:fs";
7791
+ import { closeSync as closeSync5, constants as constants5, fstatSync as fstatSync3, lstatSync as lstatSync5, mkdirSync as mkdirSync7, openSync as openSync5, readFileSync as readFileSync15, rmSync as rmSync5, writeSync as writeSync3 } from "node:fs";
7766
7792
  import { hostname as hostname2 } from "node:os";
7767
7793
  import { join as join22 } from "node:path";
7768
7794
 
@@ -7954,7 +7980,7 @@ function localName(deps = {}) {
7954
7980
  const platform = deps.platform ?? process.platform;
7955
7981
  let raw;
7956
7982
  try {
7957
- raw = platform === "darwin" ? (deps.run ?? ((program, args) => String(execFileSyncExe(program, args, { encoding: "utf8", timeout: 3e3, stdio: ["ignore", "pipe", "ignore"] }))))("/usr/sbin/scutil", ["--get", "LocalHostName"]) : (deps.hostname ?? hostname2)();
7983
+ raw = platform === "darwin" ? (deps.run ?? ((program, args) => String(execFileSyncExe(program, args, { encoding: "utf8", timeout: 3e3, killSignal: "SIGKILL", stdio: ["ignore", "pipe", "ignore"] }))))("/usr/sbin/scutil", ["--get", "LocalHostName"]) : (deps.hostname ?? hostname2)();
7958
7984
  } catch (error) {
7959
7985
  return { unreadable: error instanceof Error ? error.message : String(error) };
7960
7986
  }
@@ -8060,18 +8086,18 @@ function readCa(dir, deps = {}) {
8060
8086
  let fd;
8061
8087
  try {
8062
8088
  try {
8063
- if (lstatSync4(file2).isSymbolicLink()) return { lost: "corrupt" };
8064
- fd = openSync4(file2, platform === "win32" ? constants4.O_RDONLY : constants4.O_RDONLY | constants4.O_NOFOLLOW);
8089
+ if (lstatSync5(file2).isSymbolicLink()) return { lost: "corrupt" };
8090
+ fd = openSync5(file2, platform === "win32" ? constants5.O_RDONLY : constants5.O_RDONLY | constants5.O_NOFOLLOW);
8065
8091
  } catch (error) {
8066
8092
  return { lost: error.code === "ENOENT" ? "missing" : "corrupt" };
8067
8093
  }
8068
- const info = fstatSync2(fd);
8094
+ const info = fstatSync3(fd);
8069
8095
  if (!info.isFile() || uid2 !== void 0 && info.uid !== uid2 || platform !== "win32" && (info.mode & 63) !== 0) return { lost: "corrupt" };
8070
- return shaped(JSON.parse(readFileSync14(fd, "utf8")));
8096
+ return shaped(JSON.parse(readFileSync15(fd, "utf8")));
8071
8097
  } catch {
8072
8098
  return { lost: "corrupt" };
8073
8099
  } finally {
8074
- if (fd !== void 0) closeSync4(fd);
8100
+ if (fd !== void 0) closeSync5(fd);
8075
8101
  }
8076
8102
  }
8077
8103
  function shaped(value) {
@@ -8086,13 +8112,13 @@ function shaped(value) {
8086
8112
  return { ca: { v: 1, name: name2, key: key2, cert, created } };
8087
8113
  }
8088
8114
  function timeMachineExclude(path, platform = process.platform) {
8089
- if (platform === "darwin") execFileSyncExe("/usr/bin/tmutil", ["addexclusion", path], { stdio: "ignore", timeout: 1e4 });
8115
+ if (platform === "darwin") execFileSyncExe("/usr/bin/tmutil", ["addexclusion", path], { stdio: "ignore", timeout: 1e4, killSignal: "SIGKILL" });
8090
8116
  }
8091
8117
  var temps2 = 0;
8092
8118
  function writeCa(dir, ca, deps = {}) {
8093
8119
  mkdirSync7(dir, { recursive: true, mode: 448 });
8094
8120
  const file2 = join22(dir, CA_FILE), temp = `${file2}.${process.pid}.${temps2++}.${randomBytes10(4).toString("hex")}.tmp`;
8095
- const fd = openSync4(temp, "wx", 384);
8121
+ const fd = openSync5(temp, "wx", 384);
8096
8122
  try {
8097
8123
  try {
8098
8124
  (deps.exclude ?? timeMachineExclude)(temp);
@@ -8101,11 +8127,11 @@ function writeCa(dir, ca, deps = {}) {
8101
8127
  deps.log?.("lan-ca-exclude", { code: e.code ?? e.status ?? "failed" });
8102
8128
  }
8103
8129
  writeSync3(fd, JSON.stringify(ca));
8104
- closeSync4(fd);
8130
+ closeSync5(fd);
8105
8131
  renameInto(temp, file2);
8106
8132
  } catch (error) {
8107
8133
  try {
8108
- closeSync4(fd);
8134
+ closeSync5(fd);
8109
8135
  } catch {
8110
8136
  }
8111
8137
  rmSync5(temp, { force: true });
@@ -8184,14 +8210,14 @@ function createFaces(now = Date.now) {
8184
8210
  }
8185
8211
 
8186
8212
  // src/lan/firewall.ts
8187
- import { realpathSync as realpathSync6 } from "node:fs";
8213
+ import { realpathSync as realpathSync7 } from "node:fs";
8188
8214
  import { win32 as win322 } from "node:path";
8189
8215
  var fw = (code, text10, params) => ({ text: text10, code, ...params ? { params } : {} });
8190
8216
  var texts = (list2) => list2.map((n) => n.text);
8191
8217
  var READ_MS = 6e4;
8192
8218
  var MAX_BUFFER = 32 * 1024 * 1024;
8193
- var run2 = (file2, args, options) => new Promise((resolve10, reject) => {
8194
- execFileExe(file2, args, { ...options, encoding: "utf8", windowsHide: true, maxBuffer: MAX_BUFFER }, (error, stdout, stderr) => {
8219
+ var run2 = (file2, args, { timeout, ...options }) => new Promise((resolve10, reject) => {
8220
+ execFileExe(file2, args, { ...options, deadline: timeout, encoding: "utf8", windowsHide: true, maxBuffer: MAX_BUFFER }, (error, stdout, stderr) => {
8195
8221
  if (!error) return resolve10(stdout);
8196
8222
  reject(Object.assign(error, { stderr, stdout }));
8197
8223
  });
@@ -8204,7 +8230,7 @@ var reasonOf = (error, timeoutMs) => {
8204
8230
  async function readFirewall(input, deps = {}) {
8205
8231
  const platform = deps.platform ?? process.platform, execPath = deps.execPath ?? process.execPath, exec = deps.exec ?? run2, env = deps.env ?? process.env;
8206
8232
  if (platform === "darwin") return readMac(execPath, exec, env);
8207
- if (platform === "win32") return readWindows(input, execPath, exec, env, deps.realpath ?? ((p) => realpathSync6.native(p)));
8233
+ if (platform === "win32") return readWindows(input, execPath, exec, env, deps.realpath ?? ((p) => realpathSync7.native(p)));
8208
8234
  return { notes: [], summary: "no firewall check on this platform" };
8209
8235
  }
8210
8236
  var SOCKETFILTERFW = "/usr/libexec/ApplicationFirewall/socketfilterfw";
@@ -9561,14 +9587,14 @@ function storedIs(dir, view) {
9561
9587
  var writeView = (dir, view) => writeJson(join24(dir, PREFS_FILE), { v: 1, view });
9562
9588
 
9563
9589
  // src/server/guisecrets.ts
9564
- import { lstatSync as lstatSync5, rmSync as rmSync7 } from "node:fs";
9590
+ import { lstatSync as lstatSync6, rmSync as rmSync7 } from "node:fs";
9565
9591
  import { join as join25 } from "node:path";
9566
9592
  var SECRETS_FILE = "gui-secrets.json";
9567
9593
  var HEX = /^[0-9a-f]{32}$/;
9568
9594
  var port = (v) => typeof v === "number" && Number.isInteger(v) && v > 0 && v < 65536;
9569
9595
  var present = (file2) => {
9570
9596
  try {
9571
- return Boolean(lstatSync5(file2));
9597
+ return Boolean(lstatSync6(file2));
9572
9598
  } catch {
9573
9599
  return false;
9574
9600
  }
@@ -9589,12 +9615,12 @@ var keepSecrets = (dir, secrets) => writeJson(join25(dir, SECRETS_FILE), { v: 1,
9589
9615
  var dropSecrets = (dir) => rmSync7(join25(dir, SECRETS_FILE), { force: true });
9590
9616
 
9591
9617
  // src/server/trainyard.ts
9592
- import { readdirSync as readdirSync9 } from "node:fs";
9618
+ import { readdirSync as readdirSync10 } from "node:fs";
9593
9619
  import { availableParallelism, loadavg } from "node:os";
9594
9620
  import { dirname as dirname10, join as join27 } from "node:path";
9595
9621
 
9596
9622
  // src/trainswitch.ts
9597
- import { mkdirSync as mkdirSync9, readdirSync as readdirSync8, readFileSync as readFileSync15, renameSync as renameSync6, rmSync as rmSync8, writeFileSync as writeFileSync6 } from "node:fs";
9623
+ import { mkdirSync as mkdirSync9, readdirSync as readdirSync9, readFileSync as readFileSync16, renameSync as renameSync6, rmSync as rmSync8, writeFileSync as writeFileSync6 } from "node:fs";
9598
9624
  import { join as join26 } from "node:path";
9599
9625
  var SWITCH = "STRAW_BOSS_INTEGRATION";
9600
9626
  var ON = /* @__PURE__ */ new Set(["on", "true", "1", "yes"]);
@@ -9613,7 +9639,7 @@ function switchState(env, stateDir) {
9613
9639
  const file2 = join26(stateDir, "config.json");
9614
9640
  let text10;
9615
9641
  try {
9616
- text10 = readFileSync15(file2, "utf8");
9642
+ text10 = readFileSync16(file2, "utf8");
9617
9643
  } catch (error) {
9618
9644
  if (error.code !== "ENOENT") return { off: true, problem: `${file2} cannot be read (${error.message}); integration is off` };
9619
9645
  }
@@ -9659,7 +9685,7 @@ function reasonKind(reason) {
9659
9685
  var text5 = (stateDir) => (value, max) => plain(value.split(stateDir).join("<state>"), max);
9660
9686
  var listDirs2 = (path) => {
9661
9687
  try {
9662
- return { names: readdirSync9(path, { withFileTypes: true }).filter((e) => e.isDirectory() && isName(e.name)).map((e) => e.name).sort() };
9688
+ return { names: readdirSync10(path, { withFileTypes: true }).filter((e) => e.isDirectory() && isName(e.name)).map((e) => e.name).sort() };
9663
9689
  } catch (error) {
9664
9690
  const code = error.code;
9665
9691
  return code === "ENOENT" || code === "ENOTDIR" ? { names: [] } : { names: [], failed: `cannot list ${path}: ${code ?? error.message}` };
@@ -9669,7 +9695,7 @@ function nodsOf(folder, clean6, budget) {
9669
9695
  const out = /* @__PURE__ */ new Map();
9670
9696
  let names = [];
9671
9697
  try {
9672
- names = readdirSync9(folder).filter((n) => /^car-\d{1,3}\.json$/.test(n)).sort().slice(0, MAX_EVIDENCE_COPIES);
9698
+ names = readdirSync10(folder).filter((n) => /^car-\d{1,3}\.json$/.test(n)).sort().slice(0, MAX_EVIDENCE_COPIES);
9673
9699
  } catch {
9674
9700
  return out;
9675
9701
  }
@@ -9854,7 +9880,7 @@ function trainyardSeam(o) {
9854
9880
  }
9855
9881
 
9856
9882
  // src/boardview.ts
9857
- import { statSync as statSync10, readdirSync as readdirSync10 } from "node:fs";
9883
+ import { statSync as statSync10, readdirSync as readdirSync11 } from "node:fs";
9858
9884
  import { join as join28 } from "node:path";
9859
9885
  var MAX_ENDED = 100;
9860
9886
  function mainsOfNet(net) {
@@ -9902,7 +9928,7 @@ function cachedEntries(read4 = readEntries) {
9902
9928
  return (dir) => {
9903
9929
  let sig;
9904
9930
  try {
9905
- sig = readdirSync10(dir).filter((n) => n.endsWith(".json")).sort().map((n) => {
9931
+ sig = readdirSync11(dir).filter((n) => n.endsWith(".json")).sort().map((n) => {
9906
9932
  const st = statSync10(join28(dir, n));
9907
9933
  return `${n}:${st.size}:${st.mtimeMs}:${st.ino}`;
9908
9934
  }).join("|");
@@ -9960,7 +9986,7 @@ function createGuiHost(o) {
9960
9986
  let lan;
9961
9987
  let remoteNote;
9962
9988
  let rotating;
9963
- const deploys = createDeploys(), openings = createOpenings(join29(slot.stateDir, "openings.json")), lock = { busy: false }, trust = createTrustServe({ dir: trustDir(slot.stateDir), herdr: slot.herdr, world: () => cfg.world(), opening: deploys.openingOf });
9989
+ const deploys = createDeploys(), openings = createOpenings(join29(slot.stateDir, "openings.json")), intents = createIntents(), lock = { busy: false }, trust = createTrustServe({ dir: trustDir(slot.stateDir), herdr: slot.herdr, world: () => cfg.world(), opening: deploys.openingOf });
9964
9990
  const answered = createAnswered(answeredFileDeps(join29(dir, "answered.json")));
9965
9991
  const live = async (session) => (await o.sessions()).some((x) => x.id === session);
9966
9992
  const theHub = () => hub ??= createHub(kit.pi, id, NO_BRIDGE, o.onAllow);
@@ -10074,7 +10100,7 @@ function createGuiHost(o) {
10074
10100
  onSaveFailed: (reason) => log.line("error", { code: "paired", text: phrase(reason, 200) }),
10075
10101
  onRemote: async () => void (await switchRemote(running, true, dir, ts), remoteNote = void 0, log.line("remote-on", { how: "page" })),
10076
10102
  onRemoteOff: async () => void (await switchRemote(running, false, dir, ts), remoteNote = void 0, log.line("remote-off", { why: "page" })),
10077
- spawn: createSpawn({ run: cfg.run, sleep: cfg.sleep, call: cfg.call, deploys, lock, trustDir: trustDir(slot.stateDir), openings, note: (event, facts) => log.line(event, facts), live, sessionAt: async (pane) => (await sessions()).find((x) => x.herdrLocation?.paneId === pane)?.id }),
10103
+ spawn: createSpawn({ run: cfg.run, sleep: cfg.sleep, call: cfg.call, deploys, lock, trustDir: trustDir(slot.stateDir), openings, intents, note: (event, facts) => log.line(event, facts), live, sessionAt: async (pane) => (await sessions()).find((x) => x.herdrLocation?.paneId === pane)?.id }),
10078
10104
  close: createCloser({
10079
10105
  run: cfg.run,
10080
10106
  sleep: cfg.sleep,
@@ -10161,7 +10187,7 @@ function createGuiHost(o) {
10161
10187
  const lanFile = () => join29(dir, "lan.json");
10162
10188
  const savedLan = () => {
10163
10189
  try {
10164
- const saved = JSON.parse(readFileSync16(lanFile(), "utf8"));
10190
+ const saved = JSON.parse(readFileSync17(lanFile(), "utf8"));
10165
10191
  return saved?.v === 1 ? saved : void 0;
10166
10192
  } catch {
10167
10193
  return void 0;
@@ -10253,6 +10279,7 @@ function createGuiHost(o) {
10253
10279
  },
10254
10280
  /** The control requests that concern the GUI; undefined for any other. */
10255
10281
  async handle(request) {
10282
+ if (request.cmd === "open-intent") return { ok: true, opened: intents.has(request.pane, request.cwd) };
10256
10283
  if (o.listen === false || !["gui", "gui-stop", "gui-remote", "gui-pair", "gui-rotate", "gui-view", ...LAN_CMDS].includes(request.cmd)) return void 0;
10257
10284
  if (closing) return { ok: false, error: "restarting" };
10258
10285
  while (rotating) {
@@ -10338,7 +10365,7 @@ function spawnRestart(cli, reason, by, env, cwd, start = spawn2) {
10338
10365
  var cliBeside = (from = import.meta.url) => fileURLToPath(new URL(from.endsWith(".ts") ? "./cli.ts" : "./cli.mjs", from));
10339
10366
 
10340
10367
  // src/server/intercom.ts
10341
- import { existsSync as existsSync4, readFileSync as readFileSync17 } from "node:fs";
10368
+ import { existsSync as existsSync5, readFileSync as readFileSync18 } from "node:fs";
10342
10369
  import { createRequire } from "node:module";
10343
10370
  import { dirname as dirname11, join as join30 } from "node:path";
10344
10371
  import { fileURLToPath as fileURLToPath2, pathToFileURL } from "node:url";
@@ -10361,17 +10388,17 @@ function findTsx(from = import.meta.url) {
10361
10388
  }
10362
10389
  let exp;
10363
10390
  try {
10364
- exp = JSON.parse(readFileSync17(manifest, "utf8")).exports?.["./esm/api"];
10391
+ exp = JSON.parse(readFileSync18(manifest, "utf8")).exports?.["./esm/api"];
10365
10392
  } catch {
10366
10393
  }
10367
10394
  const entry = typeof exp === "string" ? exp : exp?.import?.default;
10368
10395
  const file2 = typeof entry === "string" ? join30(dirname11(manifest), entry) : void 0;
10369
- if (file2 && existsSync4(file2)) return file2;
10396
+ if (file2 && existsSync5(file2)) return file2;
10370
10397
  throw new LoaderError("loader", `tsx at ${dirname11(manifest)} has no ESM entry for tsx/esm/api: pi-straw-boss needs tsx ^4.23.15`);
10371
10398
  }
10372
10399
  function intercomVersion(dir) {
10373
10400
  try {
10374
- const version = JSON.parse(readFileSync17(join30(dir, "package.json"), "utf8")).version;
10401
+ const version = JSON.parse(readFileSync18(join30(dir, "package.json"), "utf8")).version;
10375
10402
  return typeof version === "string" ? version : void 0;
10376
10403
  } catch {
10377
10404
  return void 0;
@@ -10788,7 +10815,7 @@ function unitLabel(found) {
10788
10815
  }
10789
10816
 
10790
10817
  // src/server/opentower.ts
10791
- import { realpathSync as realpathSync7 } from "node:fs";
10818
+ import { realpathSync as realpathSync8 } from "node:fs";
10792
10819
  import { basename as basename8 } from "node:path";
10793
10820
  var OpenTowerError = class extends Error {
10794
10821
  code;
@@ -10804,7 +10831,7 @@ var labelOf = (root) => {
10804
10831
  async function openTowerFor(d, project, toWorkspace, existing = false) {
10805
10832
  let root;
10806
10833
  try {
10807
- root = realpathSync7.native(project);
10834
+ root = realpathSync8.native(project);
10808
10835
  } catch {
10809
10836
  throw new OpenTowerError(`The project ${project} does not exist`, "project");
10810
10837
  }
@@ -10835,7 +10862,7 @@ async function openTowerFor(d, project, toWorkspace, existing = false) {
10835
10862
  }
10836
10863
  var realpathOr = (path) => {
10837
10864
  try {
10838
- return realpathSync7.native(path);
10865
+ return realpathSync8.native(path);
10839
10866
  } catch {
10840
10867
  return void 0;
10841
10868
  }
@@ -10858,12 +10885,12 @@ function towerOpener(d) {
10858
10885
  }
10859
10886
 
10860
10887
  // src/server/trainsweep.ts
10861
- import { lstatSync as lstatSync6, rmSync as rmSync9, unlinkSync } from "node:fs";
10888
+ import { lstatSync as lstatSync7, rmSync as rmSync9, unlinkSync } from "node:fs";
10862
10889
  import { dirname as dirname12, join as join31 } from "node:path";
10863
10890
  var headsOf = (board) => [...board.cars.map((c) => c.head), ...(board.removed ?? []).flatMap((r) => r.head ? [r.head] : [])];
10864
10891
  var isFolder = (path) => {
10865
10892
  try {
10866
- return lstatSync6(path).isDirectory();
10893
+ return lstatSync7(path).isDirectory();
10867
10894
  } catch {
10868
10895
  return false;
10869
10896
  }
@@ -10942,7 +10969,7 @@ function startTrainSweep(o) {
10942
10969
  }
10943
10970
 
10944
10971
  // src/link/service.ts
10945
- import { readFileSync as readFileSync20 } from "node:fs";
10972
+ import { readFileSync as readFileSync21 } from "node:fs";
10946
10973
  import { homedir as homedir8 } from "node:os";
10947
10974
  import { join as join34 } from "node:path";
10948
10975
 
@@ -11621,13 +11648,13 @@ function checkJoiner(o) {
11621
11648
  }
11622
11649
 
11623
11650
  // src/link/joinfile.ts
11624
- import { constants as constants5, fstatSync as fstatSync3, lstatSync as lstatSync7, openSync as openSync5, readFileSync as readFileSync18, closeSync as closeSync5, unlinkSync as unlinkSync2 } from "node:fs";
11651
+ import { constants as constants6, fstatSync as fstatSync4, lstatSync as lstatSync8, openSync as openSync6, readFileSync as readFileSync19, closeSync as closeSync6, unlinkSync as unlinkSync2 } from "node:fs";
11625
11652
  import { join as join32 } from "node:path";
11626
11653
  var JOIN_FILE = "join.txt";
11627
11654
  var joinFilePath = (linkDir) => join32(linkDir, JOIN_FILE);
11628
11655
  function fileMark(path) {
11629
11656
  try {
11630
- const st = lstatSync7(path);
11657
+ const st = lstatSync8(path);
11631
11658
  return `${st.dev}:${st.ino}:${st.mtimeMs}`;
11632
11659
  } catch {
11633
11660
  return void 0;
@@ -11637,7 +11664,7 @@ function readJoinFile(path, d = {}) {
11637
11664
  const uid2 = d.uid ?? process.getuid?.();
11638
11665
  if (uid2 === void 0) return { state: "refused", reason: "this platform has no user ids, so the owner of join.txt cannot be checked" };
11639
11666
  try {
11640
- const st = lstatSync7(path);
11667
+ const st = lstatSync8(path);
11641
11668
  if (st.isSymbolicLink()) return { state: "refused", reason: "join.txt is a symlink" };
11642
11669
  if (!st.isFile()) return { state: "refused", reason: "join.txt is not a regular file" };
11643
11670
  } catch (error) {
@@ -11645,17 +11672,17 @@ function readJoinFile(path, d = {}) {
11645
11672
  }
11646
11673
  let fd;
11647
11674
  try {
11648
- fd = openSync5(path, constants5.O_RDONLY | constants5.O_NOFOLLOW | constants5.O_NONBLOCK);
11649
- const st = fstatSync3(fd);
11675
+ fd = openSync6(path, constants6.O_RDONLY | constants6.O_NOFOLLOW | constants6.O_NONBLOCK);
11676
+ const st = fstatSync4(fd);
11650
11677
  if (!st.isFile()) return { state: "refused", reason: "join.txt is not a regular file" };
11651
11678
  if (st.uid !== uid2) return { state: "refused", reason: "join.txt is not owned by this device's own user" };
11652
11679
  if ((st.mode & 511) !== 384) return { state: "refused", reason: `join.txt has mode ${(st.mode & 511).toString(8)}; it has to be 600` };
11653
- return { state: "text", text: readFileSync18(fd, "utf8") };
11680
+ return { state: "text", text: readFileSync19(fd, "utf8") };
11654
11681
  } catch (error) {
11655
11682
  const code = error.code;
11656
11683
  return code === "ENOENT" ? { state: "absent" } : { state: "refused", reason: `join.txt cannot be read: ${code ?? "error"}` };
11657
11684
  } finally {
11658
- if (fd !== void 0) closeSync5(fd);
11685
+ if (fd !== void 0) closeSync6(fd);
11659
11686
  }
11660
11687
  }
11661
11688
  function removeJoinFile(path) {
@@ -12576,13 +12603,13 @@ var Requests = class {
12576
12603
  };
12577
12604
 
12578
12605
  // src/server/towerruns.ts
12579
- import { readFileSync as readFileSync19 } from "node:fs";
12606
+ import { readFileSync as readFileSync20 } from "node:fs";
12580
12607
  import { join as join33 } from "node:path";
12581
12608
  var DEFAULT_MAX = 4;
12582
12609
  function readTowerRuns(stateDir) {
12583
12610
  let section, problem;
12584
12611
  try {
12585
- section = JSON.parse(readFileSync19(join33(stateDir, "config.json"), "utf8")).towerRuns;
12612
+ section = JSON.parse(readFileSync20(join33(stateDir, "config.json"), "utf8")).towerRuns;
12586
12613
  } catch (cause) {
12587
12614
  if (cause.code !== "ENOENT") problem = `${join33(stateDir, "config.json")} cannot be read (${cause.message.slice(0, 120)}), so towerRuns.enabled and max are the defaults: the tower service is on`;
12588
12615
  }
@@ -14716,7 +14743,7 @@ function createLinkService({ kit, stateDir, version, started, pid = process.pid,
14716
14743
  const attended = () => policy().mode === "attended";
14717
14744
  const guiOwner = () => {
14718
14745
  try {
14719
- return JSON.parse(readFileSync20(join34(stateDir, "gui.json"), "utf8")).ownerSession || void 0;
14746
+ return JSON.parse(readFileSync21(join34(stateDir, "gui.json"), "utf8")).ownerSession || void 0;
14720
14747
  } catch {
14721
14748
  return void 0;
14722
14749
  }
@@ -15965,11 +15992,11 @@ function createOperateHost(deps) {
15965
15992
  }
15966
15993
 
15967
15994
  // src/server/operateoff.ts
15968
- import { chmodSync as chmodSync5, lstatSync as lstatSync8, mkdirSync as mkdirSync10, readFileSync as readFileSync21, rmSync as rmSync10 } from "node:fs";
15995
+ import { chmodSync as chmodSync5, lstatSync as lstatSync9, mkdirSync as mkdirSync10, readFileSync as readFileSync22, rmSync as rmSync10 } from "node:fs";
15969
15996
  import { dirname as dirname13 } from "node:path";
15970
15997
  var present2 = (path) => {
15971
15998
  try {
15972
- lstatSync8(path);
15999
+ lstatSync9(path);
15973
16000
  return true;
15974
16001
  } catch (error) {
15975
16002
  return error?.code !== "ENOENT";
@@ -15978,7 +16005,7 @@ var present2 = (path) => {
15978
16005
  function operateOff(file2, now) {
15979
16006
  let since;
15980
16007
  try {
15981
- const text10 = readFileSync21(file2, "utf8"), found = JSON.parse(text10)?.since;
16008
+ const text10 = readFileSync22(file2, "utf8"), found = JSON.parse(text10)?.since;
15982
16009
  since = typeof found === "number" && Number.isSafeInteger(found) && found >= 0 ? found : now();
15983
16010
  } catch (error) {
15984
16011
  since = error?.code === "ENOENT" && !present2(file2) ? void 0 : now();
@@ -16014,7 +16041,7 @@ import { homedir as homedir9 } from "node:os";
16014
16041
  import { join as join37 } from "node:path";
16015
16042
 
16016
16043
  // src/server/allyroute.ts
16017
- import { readFileSync as readFileSync22 } from "node:fs";
16044
+ import { readFileSync as readFileSync23 } from "node:fs";
16018
16045
  import { join as join35 } from "node:path";
16019
16046
  var ROUTES2 = ALLY_FILES[0];
16020
16047
  var ANSWERS = ALLY_FILES[1];
@@ -16028,7 +16055,7 @@ var DEAD_GRACE_MS = 10 * 6e4;
16028
16055
  var OPENED_KEEP_MS = 7 * KEEP_MS2;
16029
16056
  var read2 = (slot, workspace, file2, now) => {
16030
16057
  try {
16031
- const found = JSON.parse(readFileSync22(join35(towerDir(slot, workspace), file2), "utf8"));
16058
+ const found = JSON.parse(readFileSync23(join35(towerDir(slot, workspace), file2), "utf8"));
16032
16059
  return (Array.isArray(found.entries) ? found.entries : []).filter((e) => typeof e?.at === "number" && now - e.at <= (e.kind === "opened" ? OPENED_KEEP_MS : KEEP_MS2));
16033
16060
  } catch {
16034
16061
  return [];
@@ -16110,14 +16137,14 @@ function removeAnswer(slot, workspace, id, now) {
16110
16137
  }
16111
16138
 
16112
16139
  // src/server/towerrunstore.ts
16113
- import { appendFileSync as appendFileSync2, readdirSync as readdirSync11, readFileSync as readFileSync23, rmSync as rmSync11 } from "node:fs";
16140
+ import { appendFileSync as appendFileSync2, readdirSync as readdirSync12, readFileSync as readFileSync24, rmSync as rmSync11 } from "node:fs";
16114
16141
  import { join as join36 } from "node:path";
16115
16142
  var KEEP_RUNS = 50;
16116
16143
  var KEEP_NOTES = 10;
16117
16144
  var runsDir = (slot, workspace) => join36(towerDir(slot, workspace), "runs");
16118
16145
  var readJson4 = (file2) => {
16119
16146
  try {
16120
- return JSON.parse(readFileSync23(file2, "utf8"));
16147
+ return JSON.parse(readFileSync24(file2, "utf8"));
16121
16148
  } catch {
16122
16149
  return void 0;
16123
16150
  }
@@ -16131,7 +16158,7 @@ var readRun = (slot, workspace, id) => readJson4(join36(runsDir(slot, workspace)
16131
16158
  function listRuns(slot, workspace) {
16132
16159
  let names = [];
16133
16160
  try {
16134
- names = readdirSync11(runsDir(slot, workspace)).filter((n) => n.endsWith(".json"));
16161
+ names = readdirSync12(runsDir(slot, workspace)).filter((n) => n.endsWith(".json"));
16135
16162
  } catch {
16136
16163
  return [];
16137
16164
  }
@@ -16147,7 +16174,7 @@ function pruneRuns(slot, workspace) {
16147
16174
  var notesFile = (slot, workspace) => join36(towerDir(slot, workspace), "notes.jsonl");
16148
16175
  function readNotes(slot, workspace) {
16149
16176
  try {
16150
- return readFileSync23(notesFile(slot, workspace), "utf8").split("\n").flatMap((line3) => {
16177
+ return readFileSync24(notesFile(slot, workspace), "utf8").split("\n").flatMap((line3) => {
16151
16178
  try {
16152
16179
  const row2 = JSON.parse(line3);
16153
16180
  return typeof row2?.note === "string" && (row2.kind === "local" || row2.kind === "ally") ? [row2] : [];
@@ -16835,7 +16862,7 @@ function createOperateBox(d) {
16835
16862
 
16836
16863
  // src/server/operateledger.ts
16837
16864
  import { createHash as createHash13 } from "node:crypto";
16838
- import { appendFileSync as appendFileSync3, chmodSync as chmodSync6, closeSync as closeSync6, constants as constants6, fstatSync as fstatSync4, mkdirSync as mkdirSync11, openSync as openSync6, readFileSync as readFileSync24, statSync as statSync11 } from "node:fs";
16865
+ import { appendFileSync as appendFileSync3, chmodSync as chmodSync6, closeSync as closeSync7, constants as constants7, fstatSync as fstatSync5, mkdirSync as mkdirSync11, openSync as openSync7, readFileSync as readFileSync25, statSync as statSync11 } from "node:fs";
16839
16866
  import { dirname as dirname14, sep as sep6 } from "node:path";
16840
16867
  var KEEP_MS7 = 30 * 24 * 36e5;
16841
16868
  var MAX_ROWS2 = 2e3;
@@ -16874,17 +16901,17 @@ function fold(source) {
16874
16901
  }
16875
16902
  var order = (a, b) => b.last - a.last || (a.id < b.id ? 1 : a.id > b.id ? -1 : 0);
16876
16903
  function readable(file2, root) {
16877
- const real3 = canonical(file2), top = canonical(root);
16904
+ const real3 = canonical2(file2), top = canonical2(root);
16878
16905
  if (!real3 || !top || !real3.endsWith(".jsonl") || !real3.startsWith(top + sep6)) return void 0;
16879
16906
  let fd;
16880
16907
  try {
16881
- fd = openSync6(real3, constants6.O_RDONLY | constants6.O_NONBLOCK | (constants6.O_NOFOLLOW ?? 0));
16882
- const s2 = fstatSync4(fd), at = statSync11(real3);
16908
+ fd = openSync7(real3, constants7.O_RDONLY | constants7.O_NONBLOCK | (constants7.O_NOFOLLOW ?? 0));
16909
+ const s2 = fstatSync5(fd), at = statSync11(real3);
16883
16910
  return s2.isFile() && s2.nlink === 1 && s2.dev === at.dev && s2.ino === at.ino ? { real: real3, size: s2.size } : void 0;
16884
16911
  } catch {
16885
16912
  return void 0;
16886
16913
  } finally {
16887
- if (fd !== void 0) closeSync6(fd);
16914
+ if (fd !== void 0) closeSync7(fd);
16888
16915
  }
16889
16916
  }
16890
16917
  function openLedger(d) {
@@ -16892,7 +16919,7 @@ function openLedger(d) {
16892
16919
  });
16893
16920
  let source = "";
16894
16921
  try {
16895
- source = readFileSync24(d.file, "utf8");
16922
+ source = readFileSync25(d.file, "utf8");
16896
16923
  } catch {
16897
16924
  }
16898
16925
  const { rows, lines } = fold(source), at = d.now();
@@ -16930,7 +16957,7 @@ function openLedger(d) {
16930
16957
  const at2 = d.now(), live = /* @__PURE__ */ new Set();
16931
16958
  for (const u of units) {
16932
16959
  if (!u.file || u.role === HEAD2) continue;
16933
- const file2 = canonical(u.file) ?? u.file, id = idOf2(file2), old = book.get(id), over = u.live === false;
16960
+ const file2 = canonical2(u.file) ?? u.file, id = idOf2(file2), old = book.get(id), over = u.live === false;
16934
16961
  if (!old) {
16935
16962
  const prior = owners.get(id), mine = u.owner && ("team" in u.owner ? u.owner.team : BOX2);
16936
16963
  if (!prior && !mine) continue;
@@ -17114,13 +17141,13 @@ function operateWire(o) {
17114
17141
  }
17115
17142
 
17116
17143
  // src/server/carops.ts
17117
- import { existsSync as existsSync5, readFileSync as readFileSync26 } from "node:fs";
17144
+ import { existsSync as existsSync6, readFileSync as readFileSync27 } from "node:fs";
17118
17145
  import { homedir as homedir10 } from "node:os";
17119
17146
  import { join as join39, parse as parse4, resolve as resolve6 } from "node:path";
17120
17147
 
17121
17148
  // src/server/carbook.ts
17122
17149
  import { randomBytes as randomBytes17 } from "node:crypto";
17123
- import { lstatSync as lstatSync9, mkdirSync as mkdirSync12, mkdtempSync, readdirSync as readdirSync12, readFileSync as readFileSync25, rmSync as rmSync12, writeFileSync as writeFileSync7 } from "node:fs";
17150
+ import { lstatSync as lstatSync10, mkdirSync as mkdirSync12, mkdtempSync, readdirSync as readdirSync13, readFileSync as readFileSync26, rmSync as rmSync12, writeFileSync as writeFileSync7 } from "node:fs";
17124
17151
  import { hostname as hostname3 } from "node:os";
17125
17152
  import { isAbsolute as isAbsolute7, join as join38, parse as parse3 } from "node:path";
17126
17153
  var KEEP_MS8 = 24 * 36e5;
@@ -17172,7 +17199,7 @@ function sshCommand(knownHosts) {
17172
17199
  }
17173
17200
  var kindOf2 = (path) => {
17174
17201
  try {
17175
- const st = lstatSync9(path);
17202
+ const st = lstatSync10(path);
17176
17203
  return st.isSymbolicLink() ? "link" : st.isDirectory() ? "dir" : st.isFile() ? "file" : "other";
17177
17204
  } catch {
17178
17205
  return "none";
@@ -17180,7 +17207,7 @@ var kindOf2 = (path) => {
17180
17207
  };
17181
17208
  var entries = (path) => {
17182
17209
  try {
17183
- return readdirSync12(path).sort();
17210
+ return readdirSync13(path).sort();
17184
17211
  } catch {
17185
17212
  return [];
17186
17213
  }
@@ -17228,12 +17255,12 @@ function inspectMirror(dir, code, stage, before) {
17228
17255
  if (stage !== "init" && !refFiles.includes(wanted[0])) bad2.push(`refs/${wanted[0]} (missing)`);
17229
17256
  if (bad2.length) return { problems: bad2 };
17230
17257
  if (stage === "init") {
17231
- const odd = strangeConfig(readFileSync25(join38(dir, "config"), "utf8"));
17258
+ const odd = strangeConfig(readFileSync26(join38(dir, "config"), "utf8"));
17232
17259
  if (odd) return { problems: [`config: ${odd}`] };
17233
- if (!/^ref: refs\/heads\/[A-Za-z0-9._/-]+\r?\n?$/.test(readFileSync25(join38(dir, "HEAD"), "utf8"))) return { problems: ["HEAD"] };
17260
+ if (!/^ref: refs\/heads\/[A-Za-z0-9._/-]+\r?\n?$/.test(readFileSync26(join38(dir, "HEAD"), "utf8"))) return { problems: ["HEAD"] };
17234
17261
  }
17235
- const refValue = refFiles.length ? refFiles.map((f) => readFileSync25(join38(refs, f), "latin1")).join("|") : "";
17236
- const look3 = { refs: refValue, config: readFileSync25(join38(dir, "config")).toString("latin1"), head: readFileSync25(join38(dir, "HEAD")).toString("latin1"), packs: packs.map((n) => `${n}:${lstatSync9(join38(packDir, n)).size}`).join(",") };
17262
+ const refValue = refFiles.length ? refFiles.map((f) => readFileSync26(join38(refs, f), "latin1")).join("|") : "";
17263
+ const look3 = { refs: refValue, config: readFileSync26(join38(dir, "config")).toString("latin1"), head: readFileSync26(join38(dir, "HEAD")).toString("latin1"), packs: packs.map((n) => `${n}:${lstatSync10(join38(packDir, n)).size}`).join(",") };
17237
17264
  if (before) {
17238
17265
  if (look3.config !== before.config) bad2.push("config (changed)");
17239
17266
  if (look3.head !== before.head) bad2.push("HEAD (changed)");
@@ -17737,7 +17764,7 @@ function runGit(cwd, args, extra = {}) {
17737
17764
  for (const [key2, value] of Object.entries(process.env)) if (value !== void 0 && KEEP_ENV.test(key2)) env[key2] = value;
17738
17765
  Object.assign(env, { GIT_CONFIG_NOSYSTEM: "1", GIT_CONFIG_GLOBAL: "/dev/null", GIT_TERMINAL_PROMPT: "0", GIT_OPTIONAL_LOCKS: "0", GIT_CEILING_DIRECTORIES: parse4(resolve6(cwd)).root, ...extra });
17739
17766
  const isolation = ["-c", "core.fsmonitor=", "-c", "core.hooksPath=/dev/null", "-c", "protocol.ext.allow=never", "-c", "submodule.recurse=false", "--no-replace-objects"];
17740
- return new Promise((resolvePromise, reject) => execFileExe("git", [...isolation, "-C", cwd, ...args], { encoding: "utf8", timeout: 6e4, env, windowsHide: true }, (error, stdout, stderr) => error ? reject(Object.assign(error, { stderr })) : resolvePromise(String(stdout).trim())));
17767
+ return new Promise((resolvePromise, reject) => execFileExe("git", [...isolation, "-C", cwd, ...args], { encoding: "utf8", deadline: 6e4, env, windowsHide: true }, (error, stdout, stderr) => error ? reject(Object.assign(error, { stderr })) : resolvePromise(String(stdout).trim())));
17741
17768
  }
17742
17769
  var reply2 = (error) => ({ ok: false, error: error.message });
17743
17770
  function carsReply(cars, request) {
@@ -17777,7 +17804,7 @@ async function look2(o, session) {
17777
17804
  }
17778
17805
  function knownHostsOfUser() {
17779
17806
  try {
17780
- return readFileSync26(join39(homedir10(), ".ssh", "known_hosts"), "utf8").slice(0, 4e6);
17807
+ return readFileSync27(join39(homedir10(), ".ssh", "known_hosts"), "utf8").slice(0, 4e6);
17781
17808
  } catch {
17782
17809
  return "";
17783
17810
  }
@@ -17792,7 +17819,7 @@ function startCars(o) {
17792
17819
  look: (session) => look2(o, session),
17793
17820
  git: runGit,
17794
17821
  knownHosts: knownHostsOfUser(),
17795
- exists: existsSync5,
17822
+ exists: existsSync6,
17796
17823
  log: o.log,
17797
17824
  startOf: o.startOf,
17798
17825
  onChange: () => notices?.kick(),
@@ -17809,11 +17836,11 @@ import { join as join42 } from "node:path";
17809
17836
  import { homedir as homedir11 } from "node:os";
17810
17837
 
17811
17838
  // src/server/procs.ts
17812
- import { existsSync as existsSync6, mkdirSync as mkdirSync13, readdirSync as readdirSync13, readFileSync as readFileSync29, renameSync as renameSync7 } from "node:fs";
17839
+ import { existsSync as existsSync7, mkdirSync as mkdirSync13, readdirSync as readdirSync14, readFileSync as readFileSync30, renameSync as renameSync7 } from "node:fs";
17813
17840
  import { join as join41 } from "node:path";
17814
17841
 
17815
17842
  // src/procs/worktree.ts
17816
- import { readFileSync as readFileSync27, realpathSync as realpathSync8, statSync as statSync12 } from "node:fs";
17843
+ import { readFileSync as readFileSync28, realpathSync as realpathSync9, statSync as statSync12 } from "node:fs";
17817
17844
  import { basename as basename11, dirname as dirname15, join as join40, relative as relative4, isAbsolute as isAbsolute8, resolve as resolve7 } from "node:path";
17818
17845
  var realDisk = {
17819
17846
  kind: (path) => {
@@ -17825,7 +17852,7 @@ var realDisk = {
17825
17852
  },
17826
17853
  read: (path) => {
17827
17854
  try {
17828
- return readFileSync27(path, "utf8");
17855
+ return readFileSync28(path, "utf8");
17829
17856
  } catch {
17830
17857
  return void 0;
17831
17858
  }
@@ -17835,7 +17862,7 @@ function physical(path) {
17835
17862
  const abs = resolve7(path), tail = [];
17836
17863
  for (let dir = abs; ; dir = dirname15(dir)) {
17837
17864
  try {
17838
- return join40(realpathSync8.native(dir), ...tail.reverse());
17865
+ return join40(realpathSync9.native(dir), ...tail.reverse());
17839
17866
  } catch {
17840
17867
  if (dirname15(dir) === dir) return abs;
17841
17868
  tail.push(basename11(dir));
@@ -17943,7 +17970,7 @@ function killSet({ owner, live, table, places, markers, protect, reapers, self,
17943
17970
  }
17944
17971
 
17945
17972
  // src/procs/marker.ts
17946
- import { readFileSync as readFileSync28 } from "node:fs";
17973
+ import { readFileSync as readFileSync29 } from "node:fs";
17947
17974
  var OWNER_KEY = "STRAW_BOSS_OWNER";
17948
17975
  var ID3 = /^[A-Za-z0-9._-]{1,64}$/;
17949
17976
  var WORD2 = new RegExp(`(?:^|\\s)${OWNER_KEY}=([^\\s]*)(?=\\s|$)`, "g");
@@ -17962,7 +17989,7 @@ function parseOwnerRows(text10, wanted) {
17962
17989
  return out;
17963
17990
  }
17964
17991
  var CHUNK3 = 100;
17965
- async function readOwners(pids, { run: ask = run, platform = process.platform, environ = (pid) => readFileSync28(`/proc/${pid}/environ`) } = {}) {
17992
+ async function readOwners(pids, { run: ask = run, platform = process.platform, environ = (pid) => readFileSync29(`/proc/${pid}/environ`) } = {}) {
17966
17993
  const out = /* @__PURE__ */ new Map();
17967
17994
  if (platform === "win32") return out;
17968
17995
  if (platform === "linux") {
@@ -18003,7 +18030,7 @@ function createProcs(d) {
18003
18030
  const folder = join41(d.dir, "procs"), file2 = join41(folder, OWNERS_FILE);
18004
18031
  const read4 = d.read ?? (() => readTable()), cwdsOf = d.cwds ?? ((pids) => readCwds(pids)), markersOf = d.markers ?? ((pids) => readOwners(pids));
18005
18032
  const inode = d.inode ?? inodeOnDisk, checkout = d.checkout ?? checkoutOf, probe = d.startOf ?? startOf, reap2 = d.reap ?? ((refs) => reap(refs));
18006
- const platform = d.platform ?? process.platform, self = d.self ?? [process.pid], real3 = d.real ?? physical, exists = d.exists ?? existsSync6;
18033
+ const platform = d.platform ?? process.platform, self = d.self ?? [process.pid], real3 = d.real ?? physical, exists = d.exists ?? existsSync7;
18007
18034
  const owners = /* @__PURE__ */ new Map();
18008
18035
  const pending = /* @__PURE__ */ new Set();
18009
18036
  const linked = /* @__PURE__ */ new Map();
@@ -18020,7 +18047,7 @@ function createProcs(d) {
18020
18047
  };
18021
18048
  const load2 = () => {
18022
18049
  try {
18023
- const parsed = JSON.parse(readFileSync29(file2, "utf8"));
18050
+ const parsed = JSON.parse(readFileSync30(file2, "utf8"));
18024
18051
  for (const r of Array.isArray(parsed.owners) ? parsed.owners : []) {
18025
18052
  const o = r;
18026
18053
  if (typeof o?.id === "string" && ID4.test(o.id) && Number.isSafeInteger(o.pid) && typeof o.started === "string" && Array.isArray(o.roots) && Array.isArray(o.snapshot)) {
@@ -18316,13 +18343,13 @@ function createProcs(d) {
18316
18343
  function serverPids(stateDir) {
18317
18344
  const files = [join41(stateDir, "server.json")];
18318
18345
  try {
18319
- for (const hash of readdirSync13(join41(stateDir, "servers"))) files.push(join41(stateDir, "servers", hash, "server.json"));
18346
+ for (const hash of readdirSync14(join41(stateDir, "servers"))) files.push(join41(stateDir, "servers", hash, "server.json"));
18320
18347
  } catch {
18321
18348
  }
18322
18349
  const found = [];
18323
18350
  for (const f of files) {
18324
18351
  try {
18325
- const { pid, started } = JSON.parse(readFileSync29(f, "utf8"));
18352
+ const { pid, started } = JSON.parse(readFileSync30(f, "utf8"));
18326
18353
  if (typeof pid === "number" && Number.isSafeInteger(pid) && pid > 1) found.push({ pid, ...typeof started === "string" && started ? { started } : {} });
18327
18354
  } catch {
18328
18355
  }
@@ -18334,7 +18361,7 @@ async function protectedSet(table, { run: run3, stateDir, agentDir, self }) {
18334
18361
  for (const p of table) if (baseName(p.comm) === "herdr") out.push({ pid: p.pid, started: p.started, why: "herdr" });
18335
18362
  for (const server of serverPids(stateDir)) out.push({ ...server, why: "sb-server", tree: true });
18336
18363
  try {
18337
- const pid = Number(readFileSync29(join41(agentDir, "intercom", "broker.pid"), "utf8").trim());
18364
+ const pid = Number(readFileSync30(join41(agentDir, "intercom", "broker.pid"), "utf8").trim());
18338
18365
  if (Number.isSafeInteger(pid) && pid > 1) out.push({ pid, why: "intercom-broker", tree: true });
18339
18366
  } catch {
18340
18367
  }
@@ -18547,7 +18574,7 @@ function createUnitStop(d) {
18547
18574
 
18548
18575
  // src/server/towers.ts
18549
18576
  import { createHash as createHash20 } from "node:crypto";
18550
- import { mkdirSync as mkdirSync15, readdirSync as readdirSync15, readFileSync as readFileSync36, rmSync as rmSync14 } from "node:fs";
18577
+ import { mkdirSync as mkdirSync15, readdirSync as readdirSync16, readFileSync as readFileSync37, rmSync as rmSync14 } from "node:fs";
18551
18578
  import { join as join53 } from "node:path";
18552
18579
 
18553
18580
  // src/closemain.ts
@@ -18672,11 +18699,11 @@ function createDigest(run3, now) {
18672
18699
 
18673
18700
  // src/opener.ts
18674
18701
  import { createHash as createHash16, randomUUID as randomUUID11 } from "node:crypto";
18675
- import { existsSync as existsSync8 } from "node:fs";
18702
+ import { existsSync as existsSync9 } from "node:fs";
18676
18703
  import { join as join44 } from "node:path";
18677
18704
 
18678
18705
  // src/integrator.ts
18679
- import { existsSync as existsSync7, readdirSync as readdirSync14 } from "node:fs";
18706
+ import { existsSync as existsSync8, readdirSync as readdirSync15 } from "node:fs";
18680
18707
  import { join as join43 } from "node:path";
18681
18708
  var INTEGRATOR = "integrator";
18682
18709
  var MAX_OPENED_INTEGRATORS = 2;
@@ -18688,7 +18715,7 @@ var integratorOf = (token) => {
18688
18715
  };
18689
18716
  function ledgerProjects(stateDir, app) {
18690
18717
  try {
18691
- return readdirSync14(join43(stateDir, "trains")).filter((project) => isName(project) && existsSync7(join43(stateDir, "trains", project, `${app}.json`)));
18718
+ return readdirSync15(join43(stateDir, "trains")).filter((project) => isName(project) && existsSync8(join43(stateDir, "trains", project, `${app}.json`)));
18692
18719
  } catch {
18693
18720
  return [];
18694
18721
  }
@@ -18821,7 +18848,7 @@ function opener(env) {
18821
18848
  const everywhere = await panes(run3);
18822
18849
  const codes = new Set(everywhere.flatMap((p) => ((t) => t && t.project === train.project ? [t.code] : [])(trainFromToken(p.tokens?.sb_train))));
18823
18850
  if (codes.has(train.code)) throw new OpenLimitError(`The ${trainLabel(train.code)} of project ${train.project} is already open; a code is used once`);
18824
- if (env.stateDir && existsSync8(join44(trainboardDir(env.stateDir), train.project, train.code))) throw new OpenLimitError(`The ${trainLabel(train.code)} of project ${train.project} was already used (its trainboard is kept); a code is used once, so the next train takes a new code`);
18851
+ if (env.stateDir && existsSync9(join44(trainboardDir(env.stateDir), train.project, train.code))) throw new OpenLimitError(`The ${trainLabel(train.code)} of project ${train.project} was already used (its trainboard is kept); a code is used once, so the next train takes a new code`);
18825
18852
  const max = (env.maxTrains ?? readMaxTrains)(dir);
18826
18853
  if (typeof max !== "number") throw new OpenLimitError(max.refusal);
18827
18854
  const config = (env.appsRefusal ?? openRefusal)(dir, appFromRequest(request));
@@ -18959,7 +18986,7 @@ import { randomUUID as randomUUID12 } from "node:crypto";
18959
18986
 
18960
18987
  // src/autostate.ts
18961
18988
  import { createHash as createHash18 } from "node:crypto";
18962
- import { readFileSync as readFileSync30 } from "node:fs";
18989
+ import { readFileSync as readFileSync31 } from "node:fs";
18963
18990
  import { join as join45 } from "node:path";
18964
18991
  var AUTO_FILE = "auto.json";
18965
18992
  var OWN_FILE = "auto-own.json";
@@ -19013,7 +19040,7 @@ function parseOwn(raw) {
19013
19040
  }
19014
19041
  var read3 = (dir, name2) => {
19015
19042
  try {
19016
- return readFileSync30(join45(dir, name2), "utf8");
19043
+ return readFileSync31(join45(dir, name2), "utf8");
19017
19044
  } catch {
19018
19045
  return void 0;
19019
19046
  }
@@ -19066,7 +19093,7 @@ var clock = (iso5) => {
19066
19093
  var REPORT_FILE = "auto-report.json";
19067
19094
  function reportSummary(dir) {
19068
19095
  try {
19069
- const r = JSON.parse(readFileSync30(join45(dir, REPORT_FILE), "utf8"));
19096
+ const r = JSON.parse(readFileSync31(join45(dir, REPORT_FILE), "utf8"));
19070
19097
  if (r.v !== 1 || typeof r.since !== "string" || typeof r.until !== "string" || !Array.isArray(r.parked) || !Array.isArray(r.lines)) return void 0;
19071
19098
  return { since: r.since, until: r.until, off: String(r.off ?? ""), parked: r.parked.length, towers: new Set(r.parked.map((p) => p.workspace)).size, cancels: r.lines.filter((l) => l.kind !== "re-asked").reduce((n, l) => n + (l.count ?? 1), 0), decided: r.decided?.length ?? 0, stillWaiting: r.stillWaiting?.length ?? 0 };
19072
19099
  } catch {
@@ -19449,7 +19476,7 @@ function createHead(d) {
19449
19476
  }
19450
19477
 
19451
19478
  // src/server/headasks.ts
19452
- import { readFileSync as readFileSync31 } from "node:fs";
19479
+ import { readFileSync as readFileSync32 } from "node:fs";
19453
19480
  import { join as join47 } from "node:path";
19454
19481
  var ASK_OPEN_MS = 24 * 36e5;
19455
19482
  var ASK_CAP = 40;
@@ -19473,7 +19500,7 @@ function clean5(a) {
19473
19500
  }
19474
19501
  function load(slot) {
19475
19502
  try {
19476
- const f = JSON.parse(readFileSync31(fileOf2(slot), "utf8"));
19503
+ const f = JSON.parse(readFileSync32(fileOf2(slot), "utf8"));
19477
19504
  const asks = Array.isArray(f.asks) ? f.asks.filter(valid2).map(clean5) : [];
19478
19505
  return { next: Number.isInteger(f.next) && f.next >= 1 ? f.next : 1 + Math.max(0, ...asks.map((a) => Number(a.id.slice(1)))), asks };
19479
19506
  } catch {
@@ -19768,7 +19795,7 @@ function headGate({ text: text10, senderWorkspace, isOpen: isOpen3 }) {
19768
19795
  }
19769
19796
 
19770
19797
  // src/server/towermemory.ts
19771
- import { readFileSync as readFileSync32 } from "node:fs";
19798
+ import { readFileSync as readFileSync33 } from "node:fs";
19772
19799
  import { join as join48 } from "node:path";
19773
19800
 
19774
19801
  // src/server/waitcard.ts
@@ -19971,7 +19998,7 @@ var isProposal = (e) => {
19971
19998
  function loadMemory(slot, workspace) {
19972
19999
  let text10;
19973
20000
  try {
19974
- text10 = readFileSync32(fileOf3(slot, workspace), "utf8");
20001
+ text10 = readFileSync33(fileOf3(slot, workspace), "utf8");
19975
20002
  } catch (cause) {
19976
20003
  return cause.code === "ENOENT" ? { memory: emptyMemory() } : { memory: emptyMemory(), problem: `memory.json cannot be read (${cause.code ?? "unknown"})` };
19977
20004
  }
@@ -21063,11 +21090,11 @@ function createRevoker(d) {
21063
21090
 
21064
21091
  // src/server/runs.ts
21065
21092
  import { randomBytes as randomBytes19 } from "node:crypto";
21066
- import { lstatSync as lstatSync11, realpathSync as realpathSync10 } from "node:fs";
21093
+ import { lstatSync as lstatSync12, realpathSync as realpathSync11 } from "node:fs";
21067
21094
  import { basename as basename12, resolve as resolve9, sep as sep8 } from "node:path";
21068
21095
 
21069
21096
  // src/server/bossconv.ts
21070
- import { lstatSync as lstatSync10, readFileSync as readFileSync33, realpathSync as realpathSync9, rmSync as rmSync13 } from "node:fs";
21097
+ import { lstatSync as lstatSync11, readFileSync as readFileSync34, realpathSync as realpathSync10, rmSync as rmSync13 } from "node:fs";
21071
21098
  import { homedir as homedir13 } from "node:os";
21072
21099
  import { isAbsolute as isAbsolute9, join as join50, relative as relative5, resolve as resolve8, sep as sep7 } from "node:path";
21073
21100
  var BOSS_FILE_MAX = 4 * 1024 * 1024;
@@ -21075,7 +21102,7 @@ var BOSS_FILE_DAYS = 7;
21075
21102
  var pointerFile = (slot, workspace) => join50(towerDir(slot, workspace), "boss-session.json");
21076
21103
  function readPointer(slot, workspace) {
21077
21104
  try {
21078
- const p = JSON.parse(readFileSync33(pointerFile(slot, workspace), "utf8"));
21105
+ const p = JSON.parse(readFileSync34(pointerFile(slot, workspace), "utf8"));
21079
21106
  return typeof p.file === "string" && typeof p.run === "string" && typeof p.startedAt === "string" && typeof p.lastAt === "string" && Number.isFinite(Date.parse(p.lastAt)) && Number.isInteger(p.turns) && p.turns >= 0 ? { file: p.file, run: p.run, startedAt: p.startedAt, lastAt: p.lastAt, turns: p.turns, ...p.fresh === true ? { fresh: true } : {} } : void 0;
21080
21107
  } catch {
21081
21108
  return void 0;
@@ -21088,7 +21115,7 @@ function writePointer(slot, workspace, pointer) {
21088
21115
  var sessionsRoot = (env = process.env) => join50(env.PI_CODING_AGENT_DIR || join50(homedir13(), ".pi", "agent"), "sessions");
21089
21116
  var real2 = (path) => {
21090
21117
  try {
21091
- return realpathSync9(path);
21118
+ return realpathSync10(path);
21092
21119
  } catch {
21093
21120
  return void 0;
21094
21121
  }
@@ -21108,7 +21135,7 @@ function linkIn(file2, root) {
21108
21135
  for (const part3 of rel.split(sep7)) {
21109
21136
  at = join50(at, part3);
21110
21137
  try {
21111
- if (lstatSync10(at).isSymbolicLink()) return true;
21138
+ if (lstatSync11(at).isSymbolicLink()) return true;
21112
21139
  } catch {
21113
21140
  return false;
21114
21141
  }
@@ -21127,7 +21154,7 @@ function resumable(pointer, e) {
21127
21154
  if (!path) return { ok: false, why: "the last session file is gone, or not under pi's sessions folder" };
21128
21155
  let stat6;
21129
21156
  try {
21130
- stat6 = lstatSync10(path);
21157
+ stat6 = lstatSync11(path);
21131
21158
  } catch {
21132
21159
  return { ok: false, why: "the last session file is gone" };
21133
21160
  }
@@ -21229,7 +21256,7 @@ var readProcs = (platform = process.platform) => (runId) => {
21229
21256
  const { file: file2, args, options } = cimCommand(runId);
21230
21257
  execFile2(file2, args, options, (error, stdout) => done2(error ? void 0 : parseCim(String(stdout))));
21231
21258
  } else {
21232
- execFileExe("ps", ["-A", "-ww", "-o", "pid=,ppid=,lstart=,command="], { encoding: "utf8", timeout: 5e3, maxBuffer: 16 * 1024 * 1024, env: { ...process.env, LC_ALL: "C", TZ: "UTC" } }, (error, stdout) => done2(error ? void 0 : parsePs(String(stdout), runId)));
21259
+ execFileExe("ps", ["-A", "-ww", "-o", "pid=,ppid=,lstart=,command="], { encoding: "utf8", deadline: 5e3, maxBuffer: 16 * 1024 * 1024, env: { ...process.env, LC_ALL: "C", TZ: "UTC" } }, (error, stdout) => done2(error ? void 0 : parsePs(String(stdout), runId)));
21233
21260
  }
21234
21261
  } catch {
21235
21262
  done2(void 0);
@@ -21248,7 +21275,7 @@ var HEAD_ALLOWED = new Set(HEAD_RUN_TOOLS);
21248
21275
 
21249
21276
  // src/server/headchapters.ts
21250
21277
  import { open as open7 } from "node:fs/promises";
21251
- import { readFileSync as readFileSync34 } from "node:fs";
21278
+ import { readFileSync as readFileSync35 } from "node:fs";
21252
21279
  import { join as join51 } from "node:path";
21253
21280
  var HEAD_CHAPTER_MAX = 8 * 1024 * 1024;
21254
21281
  var KEEP3 = 50;
@@ -21258,7 +21285,7 @@ var TAIL_BYTES = 262144;
21258
21285
  var chaptersFile = (slot) => join51(towerDir(slot, HEAD_KEY), "chapters.json");
21259
21286
  function readChapters(slot) {
21260
21287
  try {
21261
- const list2 = JSON.parse(readFileSync34(chaptersFile(slot), "utf8"));
21288
+ const list2 = JSON.parse(readFileSync35(chaptersFile(slot), "utf8"));
21262
21289
  return Array.isArray(list2) ? list2.filter((c) => Number.isInteger(c?.n) && typeof c.file === "string" && typeof c.from === "string" && typeof c.why === "string") : [];
21263
21290
  } catch {
21264
21291
  return [];
@@ -21320,7 +21347,7 @@ var PROMPT_WAKE_MS = 5 * 6e4;
21320
21347
  var RUNS_SHOWN = 6;
21321
21348
  var onDisk = (file2) => {
21322
21349
  try {
21323
- lstatSync11(file2);
21350
+ lstatSync12(file2);
21324
21351
  return true;
21325
21352
  } catch {
21326
21353
  return false;
@@ -21330,7 +21357,7 @@ var mayAppear = (file2, root) => {
21330
21357
  if (!file2.endsWith(".jsonl")) return false;
21331
21358
  const abs = resolve9(file2), bases = [resolve9(root)];
21332
21359
  try {
21333
- bases.push(realpathSync10(root));
21360
+ bases.push(realpathSync11(root));
21334
21361
  } catch {
21335
21362
  }
21336
21363
  return bases.some((b) => abs.startsWith(b + sep8));
@@ -22791,7 +22818,7 @@ async function pressRequest(d, workspace, json3, via = "pi") {
22791
22818
 
22792
22819
  // src/server/towerseen.ts
22793
22820
  import { createHash as createHash19 } from "node:crypto";
22794
- import { appendFileSync as appendFileSync4, readFileSync as readFileSync35 } from "node:fs";
22821
+ import { appendFileSync as appendFileSync4, readFileSync as readFileSync36 } from "node:fs";
22795
22822
  import { join as join52 } from "node:path";
22796
22823
  var SEEN_KEEP_MS = 48 * 36e5;
22797
22824
  var SEEN_MAX = 5e3;
@@ -22814,7 +22841,7 @@ function openSeen(slot, workspace, now) {
22814
22841
  const rows = /* @__PURE__ */ new Map();
22815
22842
  let text10 = "", lines = 0;
22816
22843
  try {
22817
- text10 = readFileSync35(file2, "utf8");
22844
+ text10 = readFileSync36(file2, "utf8");
22818
22845
  } catch {
22819
22846
  }
22820
22847
  for (const line3 of text10.split("\n")) {
@@ -23425,7 +23452,7 @@ function createTowers(o) {
23425
23452
  const dir = join53(slot.stateDir, "roles");
23426
23453
  let names = [];
23427
23454
  try {
23428
- names = readdirSync15(dir).filter((name2) => name2.endsWith(".json"));
23455
+ names = readdirSync16(dir).filter((name2) => name2.endsWith(".json"));
23429
23456
  } catch {
23430
23457
  return;
23431
23458
  }
@@ -23433,7 +23460,7 @@ function createTowers(o) {
23433
23460
  for (const name2 of names) {
23434
23461
  let record2;
23435
23462
  try {
23436
- record2 = JSON.parse(readFileSync36(join53(dir, name2), "utf8"));
23463
+ record2 = JSON.parse(readFileSync37(join53(dir, name2), "utf8"));
23437
23464
  } catch {
23438
23465
  continue;
23439
23466
  }
@@ -24055,7 +24082,7 @@ async function headCommand(t, cmd, text10, extra = {}) {
24055
24082
 
24056
24083
  // src/server/automode.ts
24057
24084
  import { randomBytes as randomBytes20 } from "node:crypto";
24058
- import { mkdirSync as mkdirSync16, readFileSync as readFileSync37, renameSync as renameSync8, writeFileSync as writeFileSync8 } from "node:fs";
24085
+ import { mkdirSync as mkdirSync16, readFileSync as readFileSync38, renameSync as renameSync8, writeFileSync as writeFileSync8 } from "node:fs";
24059
24086
  import { join as join54 } from "node:path";
24060
24087
  var PENDING_MS2 = 10 * 6e4;
24061
24088
  var USED_MAX = 500;
@@ -24072,7 +24099,7 @@ var gistOf = (v) => {
24072
24099
  };
24073
24100
  function readReportFile(dir) {
24074
24101
  try {
24075
- const j = JSON.parse(readFileSync37(join54(dir, REPORT_FILE), "utf8"));
24102
+ const j = JSON.parse(readFileSync38(join54(dir, REPORT_FILE), "utf8"));
24076
24103
  return j.v === 1 && typeof j.since === "string" && Array.isArray(j.parked) && Array.isArray(j.lines) ? j : void 0;
24077
24104
  } catch {
24078
24105
  return void 0;
@@ -24087,7 +24114,7 @@ function createAutoMode(d) {
24087
24114
  const listeners = /* @__PURE__ */ new Set();
24088
24115
  const readPeriod = () => {
24089
24116
  try {
24090
- const j = JSON.parse(readFileSync37(join54(d.dir, PERIOD_FILE), "utf8"));
24117
+ const j = JSON.parse(readFileSync38(join54(d.dir, PERIOD_FILE), "utf8"));
24091
24118
  return typeof j.since === "string" && Array.isArray(j.notes) ? { since: j.since, notes: j.notes.slice(-NOTES_MAX), foreign: Array.isArray(j.foreign) ? j.foreign : [], decided: Array.isArray(j.decided) ? j.decided : [] } : void 0;
24092
24119
  } catch {
24093
24120
  return void 0;
@@ -24423,7 +24450,7 @@ function createBackstop(d) {
24423
24450
  }
24424
24451
 
24425
24452
  // src/server/headnet.ts
24426
- import { closeSync as closeSync7, openSync as openSync7, readSync, statSync as statSync13 } from "node:fs";
24453
+ import { closeSync as closeSync8, openSync as openSync8, readSync, statSync as statSync13 } from "node:fs";
24427
24454
  var ASKS = 60;
24428
24455
  var TEXTS = 24e3;
24429
24456
  var TAIL4 = 65536;
@@ -24431,7 +24458,7 @@ var LINE = 160;
24431
24458
  function lastWords(file2) {
24432
24459
  let fd;
24433
24460
  try {
24434
- fd = openSync7(file2, "r");
24461
+ fd = openSync8(file2, "r");
24435
24462
  const { size: size2 } = statSync13(file2), start = Math.max(0, size2 - TAIL4), buf = Buffer.alloc(size2 - start);
24436
24463
  readSync(fd, buf, 0, buf.length, start);
24437
24464
  const rows = buf.toString("utf8").split("\n");
@@ -24445,7 +24472,7 @@ function lastWords(file2) {
24445
24472
  }
24446
24473
  } catch {
24447
24474
  } finally {
24448
- if (fd !== void 0) closeSync7(fd);
24475
+ if (fd !== void 0) closeSync8(fd);
24449
24476
  }
24450
24477
  return {};
24451
24478
  }