@open-artifacts/bus 0.237.0 → 0.239.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -32905,7 +32905,7 @@ var init_frames = __esm({
32905
32905
  late = { late: external_exports.array(external_exports.string().min(1)).optional() };
32906
32906
  isWellFormed2 = (s) => s.isWellFormed();
32907
32907
  WELL_FORMED = { message: "text is not well-formed unicode" };
32908
- CLIENT_VERSION = true ? "0.237.0" : "0.0.0";
32908
+ CLIENT_VERSION = true ? "0.239.0" : "0.0.0";
32909
32909
  clientVersion = {
32910
32910
  client_version: external_exports.string().min(1).max(64).optional()
32911
32911
  };
@@ -33133,6 +33133,8 @@ var init_frames = __esm({
33133
33133
  namespace: external_exports.string(),
33134
33134
  /** `self` only (#1570). */
33135
33135
  namespace_source: NamespaceSource.optional(),
33136
+ /** Codex self: local delivery attempts awaiting a turn; excludes mail still at the hub. */
33137
+ codex_pending_local: external_exports.number().int().nonnegative().optional(),
33136
33138
  kind: KIND_TOKEN,
33137
33139
  /** `state === "live"`; kept for older adapters. */
33138
33140
  live: external_exports.boolean(),
@@ -34394,7 +34396,10 @@ async function run(name, args, request) {
34394
34396
  if (name === "self") {
34395
34397
  const r = await request({ type: "self", row: true });
34396
34398
  if (r.type !== "agent") return failed(r);
34397
- return text(selfText(r.agent));
34399
+ const entry = selfText(r.agent);
34400
+ return text(
34401
+ r.agent?.kind === "codex" ? entry + "\n\nBus messages arrive in this chat. This response does not count mail still at the hub." : entry
34402
+ );
34398
34403
  }
34399
34404
  return text(`oa-bus: unknown tool ${name}`, true);
34400
34405
  } catch (e) {
@@ -44276,7 +44281,7 @@ var init_stdio2 = __esm({
44276
44281
  // ../bus-adapter-claude-code/src/main.ts
44277
44282
  var main_exports = {};
44278
44283
  import { existsSync as existsSync19 } from "node:fs";
44279
- var SESSIONS, connect4, server, underClaude;
44284
+ var SESSIONS, connect5, server, underClaude;
44280
44285
  var init_main = __esm({
44281
44286
  async "../bus-adapter-claude-code/src/main.ts"() {
44282
44287
  "use strict";
@@ -44289,7 +44294,7 @@ var init_main = __esm({
44289
44294
  init_socket_path();
44290
44295
  init_tools();
44291
44296
  SESSIONS = claudeSessionsDir();
44292
- connect4 = () => {
44297
+ connect5 = () => {
44293
44298
  const HOME3 = busHome();
44294
44299
  const SOCKET3 = daemonSocketPath(HOME3);
44295
44300
  return connectOutcome({
@@ -44325,7 +44330,7 @@ var init_main = __esm({
44325
44330
  tools: [...TOOLS]
44326
44331
  }));
44327
44332
  server.setRequestHandler(CallToolRequestSchema, async (req, extra) => {
44328
- const out = await connect4();
44333
+ const out = await connect5();
44329
44334
  if (out.kind !== "ok") {
44330
44335
  const text3 = noSessionMessage(out, underClaude());
44331
44336
  return { content: [{ type: "text", text: text3 }], isError: true };
@@ -44687,7 +44692,7 @@ import {
44687
44692
  unlinkSync as unlinkSync4,
44688
44693
  writeFileSync as writeFileSync13
44689
44694
  } from "node:fs";
44690
- import { basename as basename7, isAbsolute as isAbsolute8, join as join26 } from "node:path";
44695
+ import { basename as basename7, isAbsolute as isAbsolute8, join as join27 } from "node:path";
44691
44696
 
44692
44697
  // ../bus-adapter-opencode/src/version.ts
44693
44698
  var MIN_PROMPT_ID_VERSION = "2.0.0";
@@ -46875,11 +46880,11 @@ var TakenWatch = class {
46875
46880
  if (!r) return this.#legacy.has(`maybe:${id}`);
46876
46881
  return r.maybe === true;
46877
46882
  }
46878
- /** How many records still wait for a turn. */
46879
- size() {
46883
+ /** How many mail records still wait for a turn, optionally for one chat. */
46884
+ size(thread) {
46880
46885
  let n = 0;
46881
46886
  for (const r of this.#recs.values())
46882
- if (r.head !== void 0 && (r.state === "attempt" || r.state === "queued"))
46887
+ if ((thread === void 0 || r.thread === thread) && r.head !== void 0 && (r.state === "attempt" || r.state === "queued"))
46883
46888
  n++;
46884
46889
  return n;
46885
46890
  }
@@ -49611,6 +49616,7 @@ function routeLocal(frame, hello, reply, ctx) {
49611
49616
  hello.caps?.includes(ADAPTER_CAPS.pending)
49612
49617
  ) ?? [] : [];
49613
49618
  const away = ctx.ownerAwayUntil?.();
49619
+ const localQueue = () => frame.row && agent.kind === "codex" && ctx.codexPendingLocal ? { codex_pending_local: ctx.codexPendingLocal(ref) } : {};
49614
49620
  const self = {
49615
49621
  type: "agent",
49616
49622
  agent: {
@@ -49625,10 +49631,10 @@ function routeLocal(frame, hello, reply, ctx) {
49625
49631
  }
49626
49632
  };
49627
49633
  const own2 = frame.row ? ctx.ownRow?.(ref) : void 0;
49628
- if (!own2) return self;
49634
+ if (!own2) return { ...self, agent: { ...self.agent, ...localQueue() } };
49629
49635
  const answer = (row) => reply({
49630
49636
  ...self,
49631
- agent: { ...self.agent, ...statusOf(row) },
49637
+ agent: { ...self.agent, ...statusOf(row), ...localQueue() },
49632
49638
  v: 1,
49633
49639
  id: frame.id
49634
49640
  });
@@ -50847,7 +50853,7 @@ init_src();
50847
50853
  import { execFile } from "node:child_process";
50848
50854
  import { accessSync, constants as constants4, readFileSync as readFileSync14, statSync as statSync6 } from "node:fs";
50849
50855
  import { readFile } from "node:fs/promises";
50850
- import { delimiter, isAbsolute as isAbsolute7, join as join18 } from "node:path";
50856
+ import { delimiter, isAbsolute as isAbsolute7, join as join19 } from "node:path";
50851
50857
 
50852
50858
  // ../bus-daemon/src/codex-queue-store.ts
50853
50859
  import { join as join17 } from "node:path";
@@ -50890,10 +50896,116 @@ function readQueue(home2, thread, head) {
50890
50896
  }
50891
50897
  }
50892
50898
 
50899
+ // ../bus-daemon/src/transports/codex-steer.ts
50900
+ import { lstat, realpath } from "node:fs/promises";
50901
+ import { connect as connect4 } from "node:net";
50902
+ import { dirname as dirname10, join as join18 } from "node:path";
50903
+ async function trustedParents(path, uid) {
50904
+ const parent = dirname10(path);
50905
+ if (parent !== path && !await trustedParents(parent, uid)) return false;
50906
+ const s = await lstat(path);
50907
+ return s.isDirectory() && (s.uid === uid || s.uid === 0) && ((s.mode & 18) === 0 || (s.mode & 512) !== 0);
50908
+ }
50909
+ async function steerCodex(home2, thread, text3) {
50910
+ const dir = join18(home2, "app-server-control");
50911
+ let path;
50912
+ try {
50913
+ path = await realpath(join18(dir, "app-server-control.sock"));
50914
+ const [directory, targetDir, socket] = await Promise.all([
50915
+ lstat(dir),
50916
+ lstat(dirname10(path)),
50917
+ lstat(path)
50918
+ ]);
50919
+ const uid = process.getuid?.();
50920
+ if (uid === void 0 || !directory.isDirectory() || directory.uid !== uid || (directory.mode & 18) !== 0 || !targetDir.isDirectory() || targetDir.uid !== uid || (targetDir.mode & 18) !== 0 || !socket.isSocket() || socket.uid !== uid || !await trustedParents(dirname10(path), uid))
50921
+ return "fallback";
50922
+ } catch {
50923
+ return "fallback";
50924
+ }
50925
+ return new Promise((resolve19) => {
50926
+ const ws = new wrapper_default("ws://localhost/", {
50927
+ createConnection: () => connect4(path),
50928
+ maxPayload: 128 * 1024,
50929
+ perMessageDeflate: false
50930
+ });
50931
+ let step2 = 1;
50932
+ let turn;
50933
+ const finish = (result) => {
50934
+ clearTimeout(timer);
50935
+ resolve19(result);
50936
+ ws.terminate();
50937
+ };
50938
+ const disconnected = () => finish(step2 === 3 ? "uncertain" : "fallback");
50939
+ const timer = setTimeout(disconnected, 2e3);
50940
+ timer.unref();
50941
+ ws.once("close", disconnected);
50942
+ ws.on("error", disconnected);
50943
+ ws.once(
50944
+ "open",
50945
+ () => ws.send(
50946
+ JSON.stringify({
50947
+ id: 1,
50948
+ method: "initialize",
50949
+ params: { clientInfo: { name: "oa-bus", version: "1" } }
50950
+ })
50951
+ )
50952
+ );
50953
+ ws.on("message", (raw) => {
50954
+ let msg;
50955
+ try {
50956
+ msg = JSON.parse(raw.toString());
50957
+ } catch {
50958
+ return disconnected();
50959
+ }
50960
+ if (msg?.id !== step2) return;
50961
+ if (msg.error) {
50962
+ if (step2 < 3 || [-32600, -32601, -32602, -32001].includes(msg.error.code))
50963
+ return finish("fallback");
50964
+ return disconnected();
50965
+ }
50966
+ if (step2 === 1) {
50967
+ step2 = 2;
50968
+ ws.send(JSON.stringify({ method: "initialized" }));
50969
+ ws.send(
50970
+ JSON.stringify({
50971
+ id: 2,
50972
+ method: "thread/turns/list",
50973
+ params: {
50974
+ threadId: thread,
50975
+ limit: 1,
50976
+ sortDirection: "desc",
50977
+ itemsView: "notLoaded"
50978
+ }
50979
+ })
50980
+ );
50981
+ } else if (step2 === 2) {
50982
+ const latest = msg.result?.data?.[0];
50983
+ if (latest?.status !== "inProgress" || typeof latest.id !== "string" || !latest.id)
50984
+ return finish("fallback");
50985
+ turn = latest.id;
50986
+ step2 = 3;
50987
+ ws.send(
50988
+ JSON.stringify({
50989
+ id: 3,
50990
+ method: "turn/steer",
50991
+ params: {
50992
+ threadId: thread,
50993
+ expectedTurnId: turn,
50994
+ input: [{ type: "text", text: text3 }]
50995
+ }
50996
+ })
50997
+ );
50998
+ } else {
50999
+ finish(msg.result?.turnId === turn ? "accepted" : "uncertain");
51000
+ }
51001
+ });
51002
+ });
51003
+ }
51004
+
50893
51005
  // ../bus-daemon/src/transports/codex.ts
50894
51006
  var CODEX_QUEUE_TIMEOUT_MS = 3e4;
50895
51007
  var CODEX_TEXT_CAP = 64 * 1024;
50896
- var codexBinFile = (busHome2) => join18(busHome2, "codex.json");
51008
+ var codexBinFile = (busHome2) => join19(busHome2, "codex.json");
50897
51009
  var codexBinPin = (bin) => `${JSON.stringify({ bin }, null, 2)}
50898
51010
  `;
50899
51011
  var CODEX_APP = "/Applications/ChatGPT.app";
@@ -50909,11 +51021,11 @@ var executable = (p) => {
50909
51021
  };
50910
51022
  function codexAppBin(app) {
50911
51023
  try {
50912
- const plist = readFileSync14(join18(app, "Contents", "Info.plist"), "utf8");
51024
+ const plist = readFileSync14(join19(app, "Contents", "Info.plist"), "utf8");
50913
51025
  const id = /<key>CFBundleIdentifier<\/key>\s*<string>([^<]*)<\/string>/.exec(
50914
51026
  plist
50915
51027
  )?.[1];
50916
- return id === CODEX_APP_ID ? join18(app, "Contents", "Resources", "codex") : void 0;
51028
+ return id === CODEX_APP_ID ? join19(app, "Contents", "Resources", "codex") : void 0;
50917
51029
  } catch {
50918
51030
  return void 0;
50919
51031
  }
@@ -50928,7 +51040,7 @@ function resolveCodexBin(o) {
50928
51040
  }
50929
51041
  for (const dir of (o.path ?? "").split(delimiter)) {
50930
51042
  if (!isAbsolute7(dir)) continue;
50931
- const p = join18(dir, "codex");
51043
+ const p = join19(dir, "codex");
50932
51044
  if (executable(p)) return { path: p, from: "path" };
50933
51045
  }
50934
51046
  const app = o.app === null ? void 0 : codexAppBin(o.app ?? CODEX_APP);
@@ -51175,6 +51287,17 @@ var CodexTransport = class {
51175
51287
  }
51176
51288
  this.#flight.add(id);
51177
51289
  try {
51290
+ if (watch) {
51291
+ const result = await (this.opts.steer ?? steerCodex)(
51292
+ this.opts.home,
51293
+ ref,
51294
+ text3
51295
+ );
51296
+ if (result !== "fallback") {
51297
+ this.opts.taken.queued(id, result === "uncertain");
51298
+ return result === "accepted" ? { ok: true, how: "spawned" } : { ok: false, taken: "maybe" };
51299
+ }
51300
+ }
51178
51301
  let res2;
51179
51302
  try {
51180
51303
  res2 = await this.opts.run(bin.path, args, {
@@ -51226,7 +51349,7 @@ var codexHostWakes = async (pid) => {
51226
51349
  const args = await processArgs(pid);
51227
51350
  return args !== void 0 && hostWakes(args);
51228
51351
  };
51229
- var CODEX_WAKE_TEXT = `Open Artifacts bus: messages are waiting for this thread. Call the tool ${CODEX_TOOL_NAMESPACE}__self once, by that literal name (do not look it up from a tool list), to receive them.`;
51352
+ var CODEX_WAKE_TEXT = `Open Artifacts bus: messages are waiting for this thread. Call the tool ${CODEX_TOOL_NAMESPACE}__self once, by that literal name (do not look it up from a tool list), to register this thread. The messages then arrive in this chat.`;
51230
51353
 
51231
51354
  // ../bus-daemon/src/transports/opencode.ts
51232
51355
  init_src2();
@@ -51449,14 +51572,14 @@ import {
51449
51572
  symlinkSync,
51450
51573
  writeFileSync as writeFileSync9
51451
51574
  } from "node:fs";
51452
- import { join as join19, relative as relative3, sep as sep3 } from "node:path";
51575
+ import { join as join20, relative as relative3, sep as sep3 } from "node:path";
51453
51576
  var SAFE_VERSION = /^[0-9A-Za-z][0-9A-Za-z._+-]{0,63}$/;
51454
51577
  var isSafeVersion = (v) => typeof v === "string" && SAFE_VERSION.test(v);
51455
- var versionsDir = (home2) => join19(home2, "versions");
51456
- var versionDir = (home2, v) => join19(versionsDir(home2), v);
51457
- var binPath = (home2) => join19(home2, "bin");
51458
- var stateFile = (home2) => join19(home2, "update.json");
51459
- var lstat = (path) => {
51578
+ var versionsDir = (home2) => join20(home2, "versions");
51579
+ var versionDir = (home2, v) => join20(versionsDir(home2), v);
51580
+ var binPath = (home2) => join20(home2, "bin");
51581
+ var stateFile = (home2) => join20(home2, "update.json");
51582
+ var lstat2 = (path) => {
51460
51583
  try {
51461
51584
  return lstatSync7(path);
51462
51585
  } catch {
@@ -51464,7 +51587,7 @@ var lstat = (path) => {
51464
51587
  }
51465
51588
  };
51466
51589
  function unsafeDir(path) {
51467
- const st = lstat(path);
51590
+ const st = lstat2(path);
51468
51591
  if (!st) return void 0;
51469
51592
  if (!st.isDirectory() || st.isSymbolicLink())
51470
51593
  return `${path} is not a folder`;
@@ -51524,24 +51647,24 @@ function writeState(home2, state) {
51524
51647
  }
51525
51648
  function ensureVersions(home2) {
51526
51649
  mkdirSync8(versionsDir(home2), { recursive: true, mode: 448 });
51527
- if (!lstat(versionsDir(home2))?.isSymbolicLink())
51650
+ if (!lstat2(versionsDir(home2))?.isSymbolicLink())
51528
51651
  chmodSync12(versionsDir(home2), 448);
51529
51652
  mustBeSafe(realpathSync7(home2));
51530
51653
  mustBeSafe(versionsDir(home2));
51531
51654
  }
51532
51655
  function migrate(home2, now = Date.now) {
51533
51656
  const bin = binPath(home2);
51534
- const st = lstat(bin);
51657
+ const st = lstat2(bin);
51535
51658
  if (!st?.isDirectory() || st.isSymbolicLink()) return void 0;
51536
51659
  let v;
51537
51660
  try {
51538
- const j = JSON.parse(readFileSync15(join19(bin, "package.json"), "utf8"));
51661
+ const j = JSON.parse(readFileSync15(join20(bin, "package.json"), "utf8"));
51539
51662
  if (isSafeVersion(j?.version)) v = j.version;
51540
51663
  } catch {
51541
51664
  }
51542
51665
  v ??= `unknown-${now()}`;
51543
51666
  ensureVersions(home2);
51544
- if (lstat(versionDir(home2, v)))
51667
+ if (lstat2(versionDir(home2, v)))
51545
51668
  rmSync6(versionDir(home2, v), { recursive: true, force: true });
51546
51669
  renameSync12(bin, versionDir(home2, v));
51547
51670
  chmodSync12(versionDir(home2, v), 448);
@@ -51551,15 +51674,15 @@ function stage(home2, version2, fill) {
51551
51674
  if (!isSafeVersion(version2)) throw new Error("not a version");
51552
51675
  ensureVersions(home2);
51553
51676
  const dest = versionDir(home2, version2);
51554
- const tmp = join19(versionsDir(home2), `.stage.${process.pid}`);
51677
+ const tmp = join20(versionsDir(home2), `.stage.${process.pid}`);
51555
51678
  rmSync6(tmp, { recursive: true, force: true });
51556
51679
  mkdirSync8(tmp, { mode: 448 });
51557
51680
  try {
51558
51681
  fill(tmp);
51559
51682
  chmodSync12(tmp, 448);
51560
51683
  mustBeSafe(tmp);
51561
- if (lstat(dest)) {
51562
- const old = join19(versionsDir(home2), `.old.${process.pid}`);
51684
+ if (lstat2(dest)) {
51685
+ const old = join20(versionsDir(home2), `.old.${process.pid}`);
51563
51686
  rmSync6(old, { recursive: true, force: true });
51564
51687
  renameSync12(dest, old);
51565
51688
  renameSync12(tmp, dest);
@@ -51574,14 +51697,14 @@ function stage(home2, version2, fill) {
51574
51697
  function swap(home2, version2) {
51575
51698
  if (!isSafeVersion(version2)) throw new Error("not a version");
51576
51699
  const target2 = versionDir(home2, version2);
51577
- if (!lstat(target2)?.isDirectory()) throw new Error("no such version folder");
51700
+ if (!lstat2(target2)?.isDirectory()) throw new Error("no such version folder");
51578
51701
  mustBeSafe(target2);
51579
51702
  const bin = binPath(home2);
51580
51703
  const tmp = `${bin}.${process.pid}.new`;
51581
51704
  rmSync6(tmp, { recursive: true, force: true });
51582
51705
  try {
51583
51706
  symlinkSync(
51584
- join19("versions", version2),
51707
+ join20("versions", version2),
51585
51708
  tmp,
51586
51709
  process.platform === "win32" ? "junction" : void 0
51587
51710
  );
@@ -51593,10 +51716,10 @@ function swap(home2, version2) {
51593
51716
  throw e;
51594
51717
  }
51595
51718
  }
51596
- var liveDir = (versionPath) => join19(versionPath, ".live");
51719
+ var liveDir = (versionPath) => join20(versionPath, ".live");
51597
51720
  function inUse(versionPath, alive3 = pidAlive) {
51598
51721
  const dir = liveDir(versionPath);
51599
- const st = lstat(dir);
51722
+ const st = lstat2(dir);
51600
51723
  if (!st) return false;
51601
51724
  if (!st.isDirectory()) return true;
51602
51725
  let names2;
@@ -51608,8 +51731,8 @@ function inUse(versionPath, alive3 = pidAlive) {
51608
51731
  let live = false;
51609
51732
  for (const n of names2) {
51610
51733
  if (!/^\d+$/.test(n)) continue;
51611
- const f = join19(dir, n);
51612
- const k = lstat(f);
51734
+ const f = join20(dir, n);
51735
+ const k = lstat2(f);
51613
51736
  if (k?.isSymbolicLink()) rmSync6(f, { force: true });
51614
51737
  else if (!k?.isFile()) continue;
51615
51738
  else if (alive3(Number(n))) live = true;
@@ -51625,9 +51748,9 @@ function markLive(entryFile, home2, pid = process.pid) {
51625
51748
  const v = rel[0];
51626
51749
  if (rel.length < 2 || v === void 0 || v === ".." || !MARKABLE.test(v))
51627
51750
  return void 0;
51628
- const vdir = join19(root, v);
51751
+ const vdir = join20(root, v);
51629
51752
  mkdirSync8(liveDir(vdir), { recursive: true, mode: 448 });
51630
- const marker = join19(liveDir(vdir), String(pid));
51753
+ const marker = join20(liveDir(vdir), String(pid));
51631
51754
  writeFileSync9(marker, "", { mode: 384 });
51632
51755
  process.once("exit", () => rmSync6(marker, { force: true }));
51633
51756
  return marker;
@@ -51638,22 +51761,22 @@ function markLive(entryFile, home2, pid = process.pid) {
51638
51761
  function prune(home2, keep, opts = {}) {
51639
51762
  const alive3 = opts.alive ?? pidAlive;
51640
51763
  const dir = versionsDir(home2);
51641
- if (unsafeDir(dir) !== void 0 || !lstat(dir)) return [];
51764
+ if (unsafeDir(dir) !== void 0 || !lstat2(dir)) return [];
51642
51765
  const keepSet = new Set(keep.filter((k) => k !== void 0));
51643
51766
  const removed = [];
51644
51767
  for (const name of readdirSync7(dir)) {
51645
51768
  if (keepSet.has(name)) continue;
51646
- const st = lstat(join19(dir, name));
51769
+ const st = lstat2(join20(dir, name));
51647
51770
  if (!st) continue;
51648
51771
  if (st.isSymbolicLink()) {
51649
- rmSync6(join19(dir, name), { force: true });
51772
+ rmSync6(join20(dir, name), { force: true });
51650
51773
  removed.push(name);
51651
51774
  continue;
51652
51775
  }
51653
51776
  if (!st.isDirectory()) continue;
51654
51777
  const m = /^\.(stage|old)\.(\d+)$/.exec(name);
51655
- if (m ? alive3(Number(m[2])) : inUse(join19(dir, name), alive3)) continue;
51656
- rmSync6(join19(dir, name), { recursive: true, force: true });
51778
+ if (m ? alive3(Number(m[2])) : inUse(join20(dir, name), alive3)) continue;
51779
+ rmSync6(join20(dir, name), { recursive: true, force: true });
51657
51780
  removed.push(name);
51658
51781
  }
51659
51782
  return removed;
@@ -51696,7 +51819,7 @@ function hashTree(dir) {
51696
51819
  const walk = (abs, rel) => {
51697
51820
  for (const name of readdirSync7(abs).sort()) {
51698
51821
  if (rel === "" && name === ".live") continue;
51699
- const p = join19(abs, name);
51822
+ const p = join20(abs, name);
51700
51823
  const r = rel === "" ? name : `${rel}/${name}`;
51701
51824
  const st = lstatSync7(p);
51702
51825
  if (st.isDirectory()) walk(p, r);
@@ -51722,8 +51845,8 @@ function treeMatches(dir, manifest) {
51722
51845
 
51723
51846
  // ../bus-daemon/src/update/login-flag.ts
51724
51847
  import { readFileSync as readFileSync16, rmSync as rmSync7, writeFileSync as writeFileSync10 } from "node:fs";
51725
- import { join as join20 } from "node:path";
51726
- var loginFlagFile = (home2) => join20(home2, "login.active");
51848
+ import { join as join21 } from "node:path";
51849
+ var loginFlagFile = (home2) => join21(home2, "login.active");
51727
51850
  var LOGIN_FLAG_MAX_MS = 15 * 6e4;
51728
51851
  var alive2 = (pid) => {
51729
51852
  try {
@@ -51884,9 +52007,9 @@ import {
51884
52007
  rmSync as rmSync8,
51885
52008
  writeFileSync as writeFileSync11
51886
52009
  } from "node:fs";
51887
- import { join as join21 } from "node:path";
52010
+ import { join as join22 } from "node:path";
51888
52011
  var MAX_REPORTS = 50;
51889
- var reportFile = (home2) => join21(home2, "update-reports.json");
52012
+ var reportFile = (home2) => join22(home2, "update-reports.json");
51890
52013
  var EVENTS = /* @__PURE__ */ new Set([
51891
52014
  "updated",
51892
52015
  "stepped_back",
@@ -51940,7 +52063,7 @@ function removeReports(home2, sent) {
51940
52063
  }
51941
52064
  function readRescueVersion(home2) {
51942
52065
  try {
51943
- const head = readFileSync17(join21(home2, "rescue.mjs"), "utf8").slice(0, 200);
52066
+ const head = readFileSync17(join22(home2, "rescue.mjs"), "utf8").slice(0, 200);
51944
52067
  const n = /Rescue shim (\d{1,6})\./.exec(head)?.[1];
51945
52068
  return n === void 0 ? 0 : Number(n);
51946
52069
  } catch {
@@ -51960,7 +52083,7 @@ import {
51960
52083
  rmSync as rmSync9,
51961
52084
  writeFileSync as writeFileSync12
51962
52085
  } from "node:fs";
51963
- import { join as join22 } from "node:path";
52086
+ import { join as join23 } from "node:path";
51964
52087
  function load(home2) {
51965
52088
  let text3;
51966
52089
  try {
@@ -52159,7 +52282,7 @@ var noteRun = (home2, version2) => editPolicy(home2, (s) => {
52159
52282
  if (parseVersion(version2) && (s.newestRun === void 0 || compareVersions2(version2, s.newestRun) === 1))
52160
52283
  s.newestRun = version2;
52161
52284
  });
52162
- var requestFile = (home2) => join22(home2, "update-request.json");
52285
+ var requestFile = (home2) => join23(home2, "update-request.json");
52163
52286
  var REQUEST_STALE_MS = 5 * 6e4;
52164
52287
  function requestInstall(home2, version2, at) {
52165
52288
  if (!parseVersion(version2)) return false;
@@ -52386,7 +52509,7 @@ import {
52386
52509
  readFileSync as readFileSync19,
52387
52510
  rmSync as rmSync10
52388
52511
  } from "node:fs";
52389
- import { join as join24 } from "node:path";
52512
+ import { join as join25 } from "node:path";
52390
52513
 
52391
52514
  // ../bus-daemon/src/update/errors.ts
52392
52515
  var ReleaseError = class extends Error {
@@ -52572,7 +52695,7 @@ import {
52572
52695
  realpathSync as realpathSync8,
52573
52696
  writeSync as writeSync4
52574
52697
  } from "node:fs";
52575
- import { basename as basename6, dirname as dirname10, join as join23, relative as relative4, resolve as resolve4, sep as sep4 } from "node:path";
52698
+ import { basename as basename6, dirname as dirname11, join as join24, relative as relative4, resolve as resolve4, sep as sep4 } from "node:path";
52576
52699
  import { gunzipSync } from "node:zlib";
52577
52700
  var BLOCK = 512;
52578
52701
  var FILE_RE = /^package\/(package\.json|LICENSE|dist\/.+|assets\/.+)$/;
@@ -52697,12 +52820,12 @@ function unpackTo(entries, dest) {
52697
52820
  mkdirSync9(target2, { recursive: true, mode: 448 });
52698
52821
  continue;
52699
52822
  }
52700
- mkdirSync9(dirname10(target2), { recursive: true, mode: 448 });
52701
- const parent = realpathSync8(dirname10(target2));
52823
+ mkdirSync9(dirname11(target2), { recursive: true, mode: 448 });
52824
+ const parent = realpathSync8(dirname11(target2));
52702
52825
  if (parent !== root && !parent.startsWith(root + sep4))
52703
52826
  bad("parent escapes the destination");
52704
52827
  const fd = openSync8(
52705
- join23(parent, basename6(target2)),
52828
+ join24(parent, basename6(target2)),
52706
52829
  constants5.O_WRONLY | constants5.O_CREAT | constants5.O_EXCL | constants5.O_NOFOLLOW,
52707
52830
  384
52708
52831
  );
@@ -53341,16 +53464,16 @@ var Updater = class {
53341
53464
  });
53342
53465
  return { kind: "needs_you" };
53343
53466
  }
53344
- const launcher = join24(versionDir(home2, from), "node");
53467
+ const launcher = join25(versionDir(home2, from), "node");
53345
53468
  let manifest;
53346
53469
  try {
53347
53470
  const dest = stage(home2, i.version, (dir) => {
53348
53471
  unpackTo(verified2.entries, dir);
53349
- if (!existsSync7(join24(dir, "dist", "index.js")))
53472
+ if (!existsSync7(join25(dir, "dist", "index.js")))
53350
53473
  throw new Error("no dist/index.js");
53351
53474
  if (existsSync7(launcher)) {
53352
- copyFileSync(launcher, join24(dir, "node"));
53353
- chmodSync15(join24(dir, "node"), 448);
53475
+ copyFileSync(launcher, join25(dir, "node"));
53476
+ chmodSync15(join25(dir, "node"), 448);
53354
53477
  }
53355
53478
  });
53356
53479
  manifest = hashTree(dest);
@@ -53380,7 +53503,7 @@ var Updater = class {
53380
53503
  try {
53381
53504
  return settingsKinds(
53382
53505
  JSON.parse(
53383
- readFileSync19(join24(versionDir(home2, running), "package.json"), "utf8")
53506
+ readFileSync19(join25(versionDir(home2, running), "package.json"), "utf8")
53384
53507
  )
53385
53508
  );
53386
53509
  } catch {
@@ -53547,8 +53670,8 @@ var Updater = class {
53547
53670
  // ../bus-daemon/src/event-log.ts
53548
53671
  init_src2();
53549
53672
  import { constants as constants6 } from "node:fs";
53550
- import { lstat as lstat2, mkdir, open as open2, rename } from "node:fs/promises";
53551
- import { dirname as dirname11 } from "node:path";
53673
+ import { lstat as lstat3, mkdir, open as open2, rename } from "node:fs/promises";
53674
+ import { dirname as dirname12 } from "node:path";
53552
53675
  var EVENT_LOG_MAX_BYTES = 1e6;
53553
53676
  var FIELDS = /* @__PURE__ */ new Set([
53554
53677
  "name",
@@ -53582,7 +53705,7 @@ function createEventLog(file2, opts = {}) {
53582
53705
  let chain = Promise.resolve();
53583
53706
  let size;
53584
53707
  const checkDir3 = async (dir) => {
53585
- const ls = await lstat2(dir).catch(() => void 0);
53708
+ const ls = await lstat3(dir).catch(() => void 0);
53586
53709
  if (ls && ls.isSymbolicLink()) throw new Error("folder is a symlink");
53587
53710
  if (ls && !ls.isDirectory()) throw new Error("not a folder");
53588
53711
  if (!ls) await mkdir(dir, { recursive: true, mode: 448 });
@@ -53594,7 +53717,7 @@ function createEventLog(file2, opts = {}) {
53594
53717
  const st = await dh.stat();
53595
53718
  if (typeof process.getuid === "function" && st.uid !== process.getuid())
53596
53719
  throw new Error("folder is not yours");
53597
- const again = await lstat2(dir);
53720
+ const again = await lstat3(dir);
53598
53721
  if (again.isSymbolicLink() || again.dev !== st.dev || again.ino !== st.ino)
53599
53722
  throw new Error("folder changed");
53600
53723
  if ((st.mode & 511) !== 448) await dh.chmod(448);
@@ -53604,7 +53727,7 @@ function createEventLog(file2, opts = {}) {
53604
53727
  }
53605
53728
  };
53606
53729
  const sameDir2 = async (dir, id) => {
53607
- const st = await lstat2(dir);
53730
+ const st = await lstat3(dir);
53608
53731
  if (st.isSymbolicLink() || st.dev !== id.dev || st.ino !== id.ino)
53609
53732
  throw new Error("folder changed");
53610
53733
  };
@@ -53625,12 +53748,12 @@ function createEventLog(file2, opts = {}) {
53625
53748
  };
53626
53749
  const write = async (line) => {
53627
53750
  try {
53628
- const dir = dirname11(file2);
53751
+ const dir = dirname12(file2);
53629
53752
  const id = await checkDir3(dir);
53630
53753
  if (size === void 0) {
53631
53754
  size = 0;
53632
53755
  for (const f of [file2, `${file2}.1`]) {
53633
- const st = await lstat2(f).catch(() => void 0);
53756
+ const st = await lstat3(f).catch(() => void 0);
53634
53757
  if (!st) continue;
53635
53758
  const fh2 = await openChecked(f, constants6.O_RDONLY);
53636
53759
  try {
@@ -53697,9 +53820,9 @@ function createEventLog(file2, opts = {}) {
53697
53820
  // ../bus-daemon/src/leads/templates.ts
53698
53821
  init_src();
53699
53822
  import { lstatSync as lstatSync9, readdirSync as readdirSync8, realpathSync as realpathSync9, statSync as statSync7 } from "node:fs";
53700
- import { join as join25 } from "node:path";
53701
- var leadsDir = (h = home()) => join25(h, "leads");
53702
- var leadTemplateFile = (name, h = home()) => join25(leadsDir(h), `${name}.json`);
53823
+ import { join as join26 } from "node:path";
53824
+ var leadsDir = (h = home()) => join26(h, "leads");
53825
+ var leadTemplateFile = (name, h = home()) => join26(leadsDir(h), `${name}.json`);
53703
53826
  var CONTROL_RE = /[\u0000-\u001f\u007f-\u009f]/g;
53704
53827
  var tame = (s) => {
53705
53828
  const t = s.replace(CONTROL_RE, "?");
@@ -54084,7 +54207,7 @@ async function runDaemon(deps2 = {}) {
54084
54207
  within2 = new Set(configPaths(cwd));
54085
54208
  }
54086
54209
  const rr = gitRecordRoot(cwd);
54087
- if (rr) within2.add(join26(rr, ".git"));
54210
+ if (rr) within2.add(join27(rr, ".git"));
54088
54211
  }
54089
54212
  return [
54090
54213
  ...cwd !== void 0 ? notesFor(cwd) : [],
@@ -54123,13 +54246,13 @@ async function runDaemon(deps2 = {}) {
54123
54246
  procStart: cachedProcStart(cl.procStart ?? claudeProcStartOf, running),
54124
54247
  isRunning: running
54125
54248
  };
54126
- const linksFile = cl.linksFile ?? join26(home(), "claude-links.json");
54249
+ const linksFile = cl.linksFile ?? join27(home(), "claude-links.json");
54127
54250
  const sameProc = (pid, procStart) => running(pid) && claudeSessions.procStart(pid, procStart) === procStart;
54128
54251
  let saved = readClaudeLinks(linksFile, void 0, log).filter(
54129
54252
  (e) => sameProc(e.pid, e.procStart)
54130
54253
  );
54131
54254
  let linksWritten = JSON.stringify(saved);
54132
- const stashFile = cl.stashFile ?? join26(home(), "claude-stash.json");
54255
+ const stashFile = cl.stashFile ?? join27(home(), "claude-stash.json");
54133
54256
  const stashLoaded = readClaudeLinks(stashFile, void 0, log).filter(
54134
54257
  (e) => sameProc(e.pid, e.procStart)
54135
54258
  );
@@ -54239,7 +54362,7 @@ async function runDaemon(deps2 = {}) {
54239
54362
  log,
54240
54363
  promptIdSupported: () => promptIdSupported,
54241
54364
  uncertain: new HeldStore(
54242
- oc.uncertainFile ?? join26(home(), "opencode-uncertain.json")
54365
+ oc.uncertainFile ?? join27(home(), "opencode-uncertain.json")
54243
54366
  )
54244
54367
  });
54245
54368
  const codexIndexHome = cx.home ?? codexHome();
@@ -54249,7 +54372,7 @@ async function runDaemon(deps2 = {}) {
54249
54372
  });
54250
54373
  const codexTaken = new TakenWatch({
54251
54374
  home: codexIndexHome,
54252
- file: cx.takenFile ?? join26(home(), "codex-pending.json"),
54375
+ file: cx.takenFile ?? join27(home(), "codex-pending.json"),
54253
54376
  onTaken: (id, unsent) => sendCodexAck(id, unsent),
54254
54377
  log
54255
54378
  });
@@ -54274,7 +54397,7 @@ async function runDaemon(deps2 = {}) {
54274
54397
  },
54275
54398
  ackTimeoutMs: deps2.pi?.ackTimeoutMs
54276
54399
  });
54277
- const sent = new SentStore(deps2.sentFile ?? join26(home(), "sent.json"), {
54400
+ const sent = new SentStore(deps2.sentFile ?? join27(home(), "sent.json"), {
54278
54401
  log
54279
54402
  });
54280
54403
  const receipts = new Receipts(sent, { after: deps2.deliveredTimer });
@@ -54401,8 +54524,8 @@ async function runDaemon(deps2 = {}) {
54401
54524
  socketsDir: returnDir,
54402
54525
  // A deps.socketsDir is the caller's (tests); ours is re-checked before each bind.
54403
54526
  prepareDir: cl.socketsDir ? void 0 : (d) => prepareReturnDir(d),
54404
- heldFile: cl.heldFile ?? join26(home(), "claude-held.json"),
54405
- returnIndexFile: cl.returnIndexFile ?? (cl.heldFile ? cl.heldFile.replace(/(\.json)?$/, ".return.json") : join26(home(), "claude-return.json")),
54527
+ heldFile: cl.heldFile ?? join27(home(), "claude-held.json"),
54528
+ returnIndexFile: cl.returnIndexFile ?? (cl.heldFile ? cl.heldFile.replace(/(\.json)?$/, ".return.json") : join27(home(), "claude-return.json")),
54406
54529
  statusWindowMs: cl.statusWindowMs,
54407
54530
  injectTimeoutMs: cl.injectTimeoutMs,
54408
54531
  log,
@@ -54619,7 +54742,7 @@ async function runDaemon(deps2 = {}) {
54619
54742
  }
54620
54743
  }
54621
54744
  };
54622
- const guestsFile = cl.guestsFile ?? join26(home(), "claude-guests.json");
54745
+ const guestsFile = cl.guestsFile ?? join27(home(), "claude-guests.json");
54623
54746
  const projectsDir = cl.projectsDir ?? claudeProjectsDir();
54624
54747
  const mcpConfigFile = cl.mcpConfigFile ?? claudeConfigFile();
54625
54748
  const GUEST_BODY_MAX = 1024;
@@ -55294,7 +55417,7 @@ async function runDaemon(deps2 = {}) {
55294
55417
  process.exitCode = 1;
55295
55418
  try {
55296
55419
  writeFileSync13(
55297
- deps2.revokedFile ?? join26(home(), "revoked"),
55420
+ deps2.revokedFile ?? join27(home(), "revoked"),
55298
55421
  revokedMarker(cfg.machine_token),
55299
55422
  { mode: 384 }
55300
55423
  );
@@ -55341,7 +55464,7 @@ async function runDaemon(deps2 = {}) {
55341
55464
  })
55342
55465
  );
55343
55466
  const laneFields = (lane) => lane.main ? void 0 : { instance: lane.name };
55344
- const revokedMarkerFile = (lane) => join26(instancesDir(deps2.instancesHome ?? home()), `${lane.name}.revoked`);
55467
+ const revokedMarkerFile = (lane) => join27(instancesDir(deps2.instancesHome ?? home()), `${lane.name}.revoked`);
55345
55468
  const linkDown = (lane) => {
55346
55469
  if (lane.ever) lane.droppedAt ??= Date.now();
55347
55470
  ev("hub_disconnect", laneFields(lane));
@@ -55868,6 +55991,7 @@ async function runDaemon(deps2 = {}) {
55868
55991
  if (rec) renameFromAdapter(rec, name);
55869
55992
  },
55870
55993
  ownerAwayUntil: awayUntil,
55994
+ codexPendingLocal: (ref) => codexTaken.size(ref),
55871
55995
  // The self tool's status: the agent's own row on its roster.
55872
55996
  ownRow: (ref) => {
55873
55997
  const me = agents.byRef(ref);
@@ -55950,7 +56074,7 @@ async function runDaemon(deps2 = {}) {
55950
56074
  deps2.onSocketLost?.();
55951
56075
  }, deps2.socketCheckMs ?? 6e4);
55952
56076
  socketWatch.unref();
55953
- const codexAgentsFile = cx.agentsFile ?? join26(home(), "codex-agents.json");
56077
+ const codexAgentsFile = cx.agentsFile ?? join27(home(), "codex-agents.json");
55954
56078
  let codexSaved;
55955
56079
  const restorePending = /* @__PURE__ */ new Map();
55956
56080
  const persistCodex = () => {
@@ -56079,7 +56203,7 @@ async function runDaemon(deps2 = {}) {
56079
56203
  };
56080
56204
  attempt2(readCodexAgents(codexAgentsFile), 0);
56081
56205
  };
56082
- const awayFile = cx.awayFile ?? join26(home(), "codex-away.json");
56206
+ const awayFile = cx.awayFile ?? join27(home(), "codex-away.json");
56083
56207
  const awayNow = deps2.bindingNow ?? Date.now;
56084
56208
  const HOUR = 36e5;
56085
56209
  const awayRows = new Map(
@@ -56117,7 +56241,7 @@ async function runDaemon(deps2 = {}) {
56117
56241
  }
56118
56242
  };
56119
56243
  const woken = new HeldStore(
56120
- cx.wokenFile ?? join26(home(), "codex-woken.json"),
56244
+ cx.wokenFile ?? join27(home(), "codex-woken.json"),
56121
56245
  { ttlMs: 7 * 24 * HOUR }
56122
56246
  );
56123
56247
  const wakeLogged = /* @__PURE__ */ new Set();
@@ -56125,6 +56249,7 @@ async function runDaemon(deps2 = {}) {
56125
56249
  const wakeUnloadedLogged = /* @__PURE__ */ new Map();
56126
56250
  let waking = false;
56127
56251
  let wakeCheckedAt;
56252
+ const waitingForLoad = /* @__PURE__ */ new Set();
56128
56253
  const wakeSent = /* @__PURE__ */ new Map();
56129
56254
  const wakeWaiting = /* @__PURE__ */ new Map();
56130
56255
  const WAKES_MAX = 3;
@@ -56151,9 +56276,14 @@ async function runDaemon(deps2 = {}) {
56151
56276
  for (const m of [wakeAsked, wakeWaiting])
56152
56277
  for (const k of m.keys())
56153
56278
  if (!away.has(k.split(":")[1] ?? "")) m.delete(k);
56154
- if (!rows.length) return;
56155
- if (wakeCheckedAt !== void 0 && now - wakeCheckedAt < (cx.wakeCheckMs ?? 3e5))
56156
- return;
56279
+ for (const ref of waitingForLoad)
56280
+ if (!away.has(ref)) waitingForLoad.delete(ref);
56281
+ if (!rows.length || !main2.hub.open || main2.version === void 0) return;
56282
+ if (!main2.waitingQuery) waitingForLoad.clear();
56283
+ if (wakeCheckedAt !== void 0 && now - wakeCheckedAt < (cx.wakeCheckMs ?? 3e5)) {
56284
+ if (!waitingForLoad.size || !codexCheck.holders([...waitingForLoad])?.size)
56285
+ return;
56286
+ }
56157
56287
  wakeCheckedAt = now;
56158
56288
  const held2 = codexCheck.holders(rows.map((r) => r.ref));
56159
56289
  if (!held2) return;
@@ -56171,12 +56301,14 @@ async function runDaemon(deps2 = {}) {
56171
56301
  ].map((r) => r.ref).slice(0, MAX_WAITING_QUERY);
56172
56302
  if (refs.length) {
56173
56303
  counts = await hubWaitingCounts(refs);
56174
- if (!counts) log("codex wake skipped: the hub did not answer");
56304
+ if (counts) waitingForLoad.clear();
56305
+ else log("codex wake skipped: the hub did not answer");
56175
56306
  }
56176
56307
  }
56177
56308
  for (const r of rows) {
56178
56309
  const h = held2.get(r.ref);
56179
56310
  if (!h) {
56311
+ if (counts?.[r.ref]) waitingForLoad.add(r.ref);
56180
56312
  const last = wakeUnloadedLogged.get(r.ref);
56181
56313
  if (counts?.[r.ref] && (last === void 0 || now - last >= 36e5)) {
56182
56314
  wakeUnloadedLogged.set(r.ref, now);
@@ -56451,7 +56583,7 @@ async function runDaemon(deps2 = {}) {
56451
56583
  // src/bus-cmd.ts
56452
56584
  init_src();
56453
56585
  import { existsSync as existsSync17 } from "node:fs";
56454
- import { join as join38 } from "node:path";
56586
+ import { join as join39 } from "node:path";
56455
56587
 
56456
56588
  // src/context.ts
56457
56589
  init_src3();
@@ -57696,9 +57828,9 @@ import { tmpdir } from "node:os";
57696
57828
  import {
57697
57829
  basename as basename8,
57698
57830
  delimiter as delimiter2,
57699
- dirname as dirname13,
57831
+ dirname as dirname14,
57700
57832
  isAbsolute as isAbsolute9,
57701
- join as join29,
57833
+ join as join30,
57702
57834
  relative as relative5,
57703
57835
  resolve as resolve6
57704
57836
  } from "node:path";
@@ -57706,7 +57838,7 @@ import { fileURLToPath } from "node:url";
57706
57838
 
57707
57839
  // src/steps/codex.ts
57708
57840
  import { lstatSync as lstatSync11, readFileSync as readFileSync20 } from "node:fs";
57709
- import { join as join27, resolve as resolve5 } from "node:path";
57841
+ import { join as join28, resolve as resolve5 } from "node:path";
57710
57842
 
57711
57843
  // ../../node_modules/.pnpm/smol-toml@1.9.1/node_modules/smol-toml/dist/error.js
57712
57844
  function getLineColFromPtr(string4, ptr) {
@@ -58468,12 +58600,12 @@ var HAS_WELLFORMED = !!"".isWellFormed;
58468
58600
 
58469
58601
  // src/steps/codex.ts
58470
58602
  var CODEX_ENTRY = "oa_bus";
58471
- var codexHome2 = (home2, env2) => env2.CODEX_HOME ? resolve5(env2.CODEX_HOME) : join27(home2, ".codex");
58603
+ var codexHome2 = (home2, env2) => env2.CODEX_HOME ? resolve5(env2.CODEX_HOME) : join28(home2, ".codex");
58472
58604
  function codexHomeEnv(home2, env2) {
58473
58605
  const dir = codexHome2(home2, env2);
58474
- return dir === join27(home2, ".codex") ? {} : { CODEX_HOME: dir };
58606
+ return dir === join28(home2, ".codex") ? {} : { CODEX_HOME: dir };
58475
58607
  }
58476
- var codexConfig = (home2, env2) => join27(codexHome2(home2, env2), "config.toml");
58608
+ var codexConfig = (home2, env2) => join28(codexHome2(home2, env2), "config.toml");
58477
58609
  function hasCodex(o) {
58478
58610
  if (o.which("codex")) return true;
58479
58611
  try {
@@ -58507,7 +58639,7 @@ function codexEntry(busBin, home2, busHome2) {
58507
58639
  return {
58508
58640
  command: busBin[0],
58509
58641
  args: [...busBin.slice(1), "mcp", "codex"],
58510
- ...ob === join27(home2, ".oa-bus") ? {} : { env: { OA_BUS_HOME: ob } },
58642
+ ...ob === join28(home2, ".oa-bus") ? {} : { env: { OA_BUS_HOME: ob } },
58511
58643
  default_tools_approval_mode: "approve"
58512
58644
  };
58513
58645
  }
@@ -58533,7 +58665,7 @@ function sandboxRisk(doc, home2, codexDir) {
58533
58665
  });
58534
58666
  const covers = (root) => {
58535
58667
  const r = resolve5(
58536
- root === "~" ? home2 : root.startsWith("~/") ? join27(home2, root.slice(2)) : root
58668
+ root === "~" ? home2 : root.startsWith("~/") ? join28(home2, root.slice(2)) : root
58537
58669
  );
58538
58670
  return r === "/" || codexDir === r || codexDir.startsWith(`${r}/`) || r.startsWith(`${codexDir}/`);
58539
58671
  };
@@ -58759,10 +58891,10 @@ import {
58759
58891
  rmSync as rmSync11,
58760
58892
  writeFileSync as writeFileSync14
58761
58893
  } from "node:fs";
58762
- import { join as join28 } from "node:path";
58894
+ import { join as join29 } from "node:path";
58763
58895
  var RESCUE_VERSION = 1;
58764
58896
  var RESCUE_MAX_STARTS = 2;
58765
- var rescueOf = (home2) => join28(home2, "rescue");
58897
+ var rescueOf = (home2) => join29(home2, "rescue");
58766
58898
  function rescueShell() {
58767
58899
  return `#!/bin/sh
58768
58900
  # Written by oa-bus install, never by an update. Rescue shim ${RESCUE_VERSION}.
@@ -58866,7 +58998,7 @@ try {
58866
58998
  function writeRescue(home2, launcher) {
58867
58999
  mkdirSync10(home2, { recursive: true, mode: 448 });
58868
59000
  const put2 = (name, text3) => {
58869
- const path = join28(home2, name);
59001
+ const path = join29(home2, name);
58870
59002
  const tmp = `${path}.${process.pid}.tmp`;
58871
59003
  try {
58872
59004
  writeFileSync14(tmp, text3, { mode: 448 });
@@ -58890,7 +59022,7 @@ import {
58890
59022
  renameSync as renameSync16,
58891
59023
  writeFileSync as writeFileSync15
58892
59024
  } from "node:fs";
58893
- import { dirname as dirname12 } from "node:path";
59025
+ import { dirname as dirname13 } from "node:path";
58894
59026
  function readInstallFile(path) {
58895
59027
  try {
58896
59028
  const v = JSON.parse(readFileSync21(path, "utf8"));
@@ -58902,7 +59034,7 @@ function readInstallFile(path) {
58902
59034
  }
58903
59035
  function updateInstallFile(path, patch) {
58904
59036
  const next = { ...readInstallFile(path), ...patch };
58905
- mkdirSync11(dirname12(path), { recursive: true, mode: 448 });
59037
+ mkdirSync11(dirname13(path), { recursive: true, mode: 448 });
58906
59038
  const tmp = `${path}.${process.pid}.tmp`;
58907
59039
  writeFileSync15(tmp, `${JSON.stringify(next, null, 2)}
58908
59040
  `, { mode: 384 });
@@ -58953,7 +59085,7 @@ function servicePath(env2, execPath, platform) {
58953
59085
  "/bin"
58954
59086
  ];
58955
59087
  const mine = (env2.PATH ?? "").split(delimiter2).filter((d) => isAbsolute9(d) && !transient(d));
58956
- const node2 = dirname13(execPath);
59088
+ const node2 = dirname14(execPath);
58957
59089
  if (!mine.includes(node2) && isAbsolute9(node2) && !transient(node2))
58958
59090
  mine.unshift(node2);
58959
59091
  return [.../* @__PURE__ */ new Set([...mine, ...system])].join(delimiter2);
@@ -59020,7 +59152,7 @@ function cliSource() {
59020
59152
  jiti: import.meta.resolve("jiti")
59021
59153
  } : { kind: "bundle", file: here };
59022
59154
  }
59023
- var entryName = (src) => src.kind === "bundle" ? join29(basename8(dirname13(src.file)), basename8(src.file)) : "oa-bus.js";
59155
+ var entryName = (src) => src.kind === "bundle" ? join30(basename8(dirname14(src.file)), basename8(src.file)) : "oa-bus.js";
59024
59156
  var shim = (src) => `// Written by oa-bus install: runs the sources it was installed from.
59025
59157
  import { createJiti } from ${JSON.stringify(src.jiti)};
59026
59158
 
@@ -59075,12 +59207,12 @@ echo "oa-bus: Node.js ${MIN_NODE} or newer not found. Install it, then run: $her
59075
59207
  exit 127
59076
59208
  `;
59077
59209
  }
59078
- var launcherOf = (home2) => join29(home2, "bin", "node");
59210
+ var launcherOf = (home2) => join30(home2, "bin", "node");
59079
59211
  function versionOf(src) {
59080
59212
  if (src.kind === "dev") return "dev";
59081
59213
  try {
59082
59214
  const j = JSON.parse(
59083
- readFileSync22(join29(dirname13(dirname13(src.file)), "package.json"), "utf8")
59215
+ readFileSync22(join30(dirname14(dirname14(src.file)), "package.json"), "utf8")
59084
59216
  );
59085
59217
  if (isSafeVersion(j?.version)) return j.version;
59086
59218
  } catch {
@@ -59095,25 +59227,25 @@ function installCli(home2, src, node2) {
59095
59227
  versionOf(src),
59096
59228
  (tmp) => {
59097
59229
  if (src.kind === "bundle") {
59098
- const pkg = dirname13(dirname13(src.file));
59230
+ const pkg = dirname14(dirname14(src.file));
59099
59231
  for (const name of ["dist", "assets", "package.json"])
59100
- if (existsSync9(join29(pkg, name)))
59101
- cpSync(join29(pkg, name), join29(tmp, name), { recursive: true });
59102
- } else writeFileSync16(join29(tmp, entryName(src)), shim(src));
59232
+ if (existsSync9(join30(pkg, name)))
59233
+ cpSync(join30(pkg, name), join30(tmp, name), { recursive: true });
59234
+ } else writeFileSync16(join30(tmp, entryName(src)), shim(src));
59103
59235
  chmodSync18(tmp, 448);
59104
59236
  if (node2 !== void 0) {
59105
- writeFileSync16(join29(tmp, "node"), launcherText(node2), { mode: 448 });
59106
- chmodSync18(join29(tmp, "node"), 448);
59237
+ writeFileSync16(join30(tmp, "node"), launcherText(node2), { mode: 448 });
59238
+ chmodSync18(join30(tmp, "node"), 448);
59107
59239
  }
59108
- if (!existsSync9(join29(tmp, "package.json")))
59109
- writeFileSync16(join29(tmp, "package.json"), '{ "type": "module" }\n');
59240
+ if (!existsSync9(join30(tmp, "package.json")))
59241
+ writeFileSync16(join30(tmp, "package.json"), '{ "type": "module" }\n');
59110
59242
  },
59111
59243
  // Without the rescue shim (win32, or no launcher) a failed update could
59112
59244
  // not be undone: such an install never arms auto-update (#2552).
59113
59245
  { arm: node2 !== void 0 && process.platform !== "win32" }
59114
59246
  );
59115
59247
  if (node2 !== void 0) writeRescue(home2, launcherText(node2));
59116
- return join29(home2, "bin", entryName(src));
59248
+ return join30(home2, "bin", entryName(src));
59117
59249
  }
59118
59250
  var present = (path) => {
59119
59251
  try {
@@ -59124,7 +59256,7 @@ var present = (path) => {
59124
59256
  }
59125
59257
  };
59126
59258
  function writeReplacing(path, text3) {
59127
- mkdirSync12(dirname13(path), { recursive: true });
59259
+ mkdirSync12(dirname14(path), { recursive: true });
59128
59260
  const tmp = `${path}.${process.pid}.tmp`;
59129
59261
  try {
59130
59262
  writeFileSync16(tmp, text3, { mode: 420 });
@@ -59139,11 +59271,11 @@ var real = (path, native = false) => {
59139
59271
  try {
59140
59272
  return (native ? realpathSync11.native : realpathSync11)(abs);
59141
59273
  } catch {
59142
- const parent = dirname13(abs);
59143
- return parent === abs ? abs : join29(real(parent, native), basename8(abs));
59274
+ const parent = dirname14(abs);
59275
+ return parent === abs ? abs : join30(real(parent, native), basename8(abs));
59144
59276
  }
59145
59277
  };
59146
- var isDefaultHome2 = (home2, userHome) => real(home2) === real(join29(userHome, ".oa-bus"));
59278
+ var isDefaultHome2 = (home2, userHome) => real(home2) === real(join30(userHome, ".oa-bus"));
59147
59279
  function serviceNames(home2, userHome) {
59148
59280
  const suffix = isDefaultHome2(home2, userHome) ? "" : createHash9("sha256").update(real(home2)).digest("hex").slice(0, 8);
59149
59281
  return {
@@ -59172,16 +59304,16 @@ function systemService(d) {
59172
59304
  const names2 = () => serviceNames(home2(), d.userHome);
59173
59305
  const launcherNode = () => d.platform === "win32" ? void 0 : d.execPath;
59174
59306
  const nodeOf = (h) => d.platform === "win32" ? d.execPath : launcherOf(h);
59175
- const entryOf = () => join29(home2(), "bin", entryName(d.source()));
59176
- const installFile2 = () => join29(home2(), "install.json");
59307
+ const entryOf = () => join30(home2(), "bin", entryName(d.source()));
59308
+ const installFile2 = () => join30(home2(), "install.json");
59177
59309
  const record7 = () => {
59178
59310
  const r = readInstallFile(installFile2()).service;
59179
59311
  return typeof r === "object" && r !== null ? r : {};
59180
59312
  };
59181
59313
  const xdg = d.env.XDG_CONFIG_HOME;
59182
- const configHome = xdg && isAbsolute9(xdg) ? xdg : join29(d.userHome, ".config");
59314
+ const configHome = xdg && isAbsolute9(xdg) ? xdg : join30(d.userHome, ".config");
59183
59315
  const fileName = () => manager === "launchd" ? `${names2().label}.plist` : names2().unit;
59184
- const fresh = () => manager === "launchd" ? join29(d.userHome, "Library/LaunchAgents", fileName()) : join29(configHome, "systemd/user", fileName());
59316
+ const fresh = () => manager === "launchd" ? join30(d.userHome, "Library/LaunchAgents", fileName()) : join30(configHome, "systemd/user", fileName());
59185
59317
  const recorded = () => {
59186
59318
  const r = record7().unit;
59187
59319
  return typeof r === "string" && isAbsolute9(r) && basename8(r) === fileName() ? r : void 0;
@@ -59277,10 +59409,10 @@ function systemService(d) {
59277
59409
  }
59278
59410
  const h = home2();
59279
59411
  const src = d.source();
59280
- const logs2 = join29(h, "logs");
59412
+ const logs2 = join30(h, "logs");
59281
59413
  const u = {
59282
59414
  node: nodeOf(h),
59283
- entry: join29(h, "bin", entryName(src)),
59415
+ entry: join30(h, "bin", entryName(src)),
59284
59416
  env: {
59285
59417
  PATH: servicePath(d.env, d.execPath, d.platform),
59286
59418
  ...isDefaultHome2(h, d.userHome) ? {} : { OA_BUS_HOME: h },
@@ -59288,8 +59420,8 @@ function systemService(d) {
59288
59420
  ...codexHomeEnv(d.userHome, d.env)
59289
59421
  },
59290
59422
  // One file: the daemon logs to stderr, and `oa-bus logs` tails it.
59291
- out: join29(logs2, "daemon.log"),
59292
- err: join29(logs2, "daemon.log")
59423
+ out: join30(logs2, "daemon.log"),
59424
+ err: join30(logs2, "daemon.log")
59293
59425
  };
59294
59426
  const unit = {
59295
59427
  ...u,
@@ -59425,7 +59557,7 @@ function systemService(d) {
59425
59557
  },
59426
59558
  others() {
59427
59559
  if (manager === void 0) return [];
59428
- const dir = dirname13(fresh());
59560
+ const dir = dirname14(fresh());
59429
59561
  const own2 = fileName();
59430
59562
  const re = manager === "launchd" ? /^com\.open-artifacts\.bus\.[0-9a-f]{8}\.plist$/ : /^oa-bus-[0-9a-f]{8}\.service$/;
59431
59563
  try {
@@ -59440,7 +59572,7 @@ function systemService(d) {
59440
59572
  const node2 = record7().node;
59441
59573
  if (typeof node2 === "string" && !existsSync9(node2))
59442
59574
  out.push({ kind: "node-missing", node: node2 });
59443
- if (manager === "systemd" && !existsSync9(join29(d.lingerDir ?? "/var/lib/systemd/linger", d.user)))
59575
+ if (manager === "systemd" && !existsSync9(join30(d.lingerDir ?? "/var/lib/systemd/linger", d.user)))
59444
59576
  out.push({ kind: "linger-off" });
59445
59577
  if (d.platform !== "win32" && unitRunsRescue()) {
59446
59578
  const r = rescueOf(home2());
@@ -59467,7 +59599,7 @@ var noService = {
59467
59599
  remove: async () => ({}),
59468
59600
  cli: () => ["oa-bus"]
59469
59601
  };
59470
- var VERSION = true ? "0.237.0" : JSON.parse(
59602
+ var VERSION = true ? "0.239.0" : JSON.parse(
59471
59603
  readFileSync23(new URL("../package.json", import.meta.url), "utf8")
59472
59604
  ).version;
59473
59605
  var which = (cmd) => {
@@ -59658,7 +59790,7 @@ import {
59658
59790
  statSync as statSync9,
59659
59791
  writeFileSync as writeFileSync19
59660
59792
  } from "node:fs";
59661
- import { dirname as dirname17, isAbsolute as isAbsolute14, join as join36, relative as relative7, resolve as resolve13 } from "node:path";
59793
+ import { dirname as dirname18, isAbsolute as isAbsolute14, join as join37, relative as relative7, resolve as resolve13 } from "node:path";
59662
59794
  import { isDeepStrictEqual } from "node:util";
59663
59795
 
59664
59796
  // ../bus-adapter-hermes/src/index.ts
@@ -60902,8 +61034,8 @@ var PI_EXTENSION = fileURLToPath4(
60902
61034
 
60903
61035
  // src/steps/claude-proof.ts
60904
61036
  import { lstatSync as lstatSync13, readFileSync as readFileSync24 } from "node:fs";
60905
- import { join as join30, resolve as resolve7 } from "node:path";
60906
- var claudeConfigFile2 = (home2, env2) => join30(env2.CLAUDE_CONFIG_DIR ?? home2, ".claude.json");
61037
+ import { join as join31, resolve as resolve7 } from "node:path";
61038
+ var claudeConfigFile2 = (home2, env2) => join31(env2.CLAUDE_CONFIG_DIR ?? home2, ".claude.json");
60907
61039
  var PROOF_COMMAND = "mcp-proof";
60908
61040
  var PROOF_INSTANCE_FLAG = "--instance";
60909
61041
  var TOKEN_HELPER = /^T=\$\(cat (.+)\) && printf '\{"Authorization":"Bearer %s"\}' "\$T"$/;
@@ -61548,7 +61680,7 @@ import {
61548
61680
  realpathSync as realpathSync15,
61549
61681
  rmSync as rmSync17
61550
61682
  } from "node:fs";
61551
- import { join as join34, resolve as resolve11, sep as sep5 } from "node:path";
61683
+ import { join as join35, resolve as resolve11, sep as sep5 } from "node:path";
61552
61684
 
61553
61685
  // src/steps/hermes.ts
61554
61686
  import { createHash as createHash11, randomBytes as randomBytes7 } from "node:crypto";
@@ -61567,9 +61699,9 @@ import {
61567
61699
  } from "node:fs";
61568
61700
  import {
61569
61701
  basename as basename9,
61570
- dirname as dirname14,
61702
+ dirname as dirname15,
61571
61703
  isAbsolute as isAbsolute12,
61572
- join as join31,
61704
+ join as join32,
61573
61705
  relative as relative6,
61574
61706
  resolve as resolve8
61575
61707
  } from "node:path";
@@ -61585,9 +61717,9 @@ var real2 = (p) => {
61585
61717
  let cur = p;
61586
61718
  for (; ; ) {
61587
61719
  try {
61588
- return join31(realpathSync12(cur), ...rest.reverse());
61720
+ return join32(realpathSync12(cur), ...rest.reverse());
61589
61721
  } catch {
61590
- const up = dirname14(cur);
61722
+ const up = dirname15(cur);
61591
61723
  if (up === cur) return p;
61592
61724
  rest.push(basename9(cur));
61593
61725
  cur = up;
@@ -61615,7 +61747,7 @@ function sweepStaging(staging, own2, o = {}) {
61615
61747
  }
61616
61748
  for (const name of names2) {
61617
61749
  if (name === own2) continue;
61618
- const path = join31(staging, name);
61750
+ const path = join32(staging, name);
61619
61751
  let old;
61620
61752
  try {
61621
61753
  old = now - lstatSync14(path).mtimeMs > STAGING_STALE_MS;
@@ -61632,24 +61764,24 @@ function sweepStaging(staging, own2, o = {}) {
61632
61764
  }
61633
61765
  }
61634
61766
  var nativeHome = (home2, env2, platform) => {
61635
- if (platform !== "win32") return join31(home2, ".hermes");
61767
+ if (platform !== "win32") return join32(home2, ".hermes");
61636
61768
  const local = env2.LOCALAPPDATA?.trim();
61637
- return join31(local || join31(home2, "AppData", "Local"), "hermes");
61769
+ return join32(local || join32(home2, "AppData", "Local"), "hermes");
61638
61770
  };
61639
- var tilded = (home2, v) => v === "~" ? home2 : resolve8(v.startsWith("~/") ? join31(home2, v.slice(2)) : v);
61771
+ var tilded = (home2, v) => v === "~" ? home2 : resolve8(v.startsWith("~/") ? join32(home2, v.slice(2)) : v);
61640
61772
  function hermesHome(home2, env2, platform = process.platform) {
61641
61773
  const native = nativeHome(home2, env2, platform);
61642
61774
  const v = env2.HERMES_HOME?.trim();
61643
61775
  const given = v ? tilded(home2, v) : void 0;
61644
- if (given !== void 0 && basename9(dirname14(given)) === "profiles")
61776
+ if (given !== void 0 && basename9(dirname15(given)) === "profiles")
61645
61777
  return given;
61646
61778
  const base3 = given ?? native;
61647
61779
  const root = hermesRoot(home2, env2, platform);
61648
61780
  if (env2.HERMES_S6_SUPERVISED_CHILD) return base3;
61649
61781
  try {
61650
- const name = readFileSync26(join31(root, "active_profile"), "utf8").trim().toLowerCase();
61782
+ const name = readFileSync26(join32(root, "active_profile"), "utf8").trim().toLowerCase();
61651
61783
  if (name && name !== "default" && /^[a-z0-9][a-z0-9_-]{0,63}$/.test(name)) {
61652
- const dir = join31(root, "profiles", name);
61784
+ const dir = join32(root, "profiles", name);
61653
61785
  if (lstatSync14(dir).isDirectory()) return dir;
61654
61786
  }
61655
61787
  } catch {
@@ -61661,13 +61793,13 @@ function hermesRoot(home2, env2, platform = process.platform) {
61661
61793
  const v = env2.HERMES_HOME?.trim();
61662
61794
  const given = v ? tilded(home2, v) : void 0;
61663
61795
  if (given === void 0) return native;
61664
- if (basename9(dirname14(given)) === "profiles") return dirname14(dirname14(given));
61796
+ if (basename9(dirname15(given)) === "profiles") return dirname15(dirname15(given));
61665
61797
  const rel = relative6(real2(native), real2(given));
61666
61798
  if (rel === "" || !rel.startsWith("..") && !isAbsolute12(rel)) return native;
61667
61799
  return given;
61668
61800
  }
61669
61801
  function hermesProfilesScan(home2, env2, platform = process.platform) {
61670
- const path = join31(hermesRoot(home2, env2, platform), "profiles");
61802
+ const path = join32(hermesRoot(home2, env2, platform), "profiles");
61671
61803
  let isLink3 = false;
61672
61804
  try {
61673
61805
  isLink3 = lstatSync14(path).isSymbolicLink();
@@ -61678,7 +61810,7 @@ function hermesProfilesScan(home2, env2, platform = process.platform) {
61678
61810
  return realpathSync12(path);
61679
61811
  } catch {
61680
61812
  try {
61681
- return resolve8(dirname14(path), readlinkSync3(path));
61813
+ return resolve8(dirname15(path), readlinkSync3(path));
61682
61814
  } catch {
61683
61815
  return "somewhere else";
61684
61816
  }
@@ -61714,9 +61846,9 @@ function hermesProfilesScan(home2, env2, platform = process.platform) {
61714
61846
  }
61715
61847
  function hermesPluginDirs(home2, env2, platform = process.platform) {
61716
61848
  const root = hermesRoot(home2, env2, platform);
61717
- const out = [join31(root, "plugins", HERMES_PLUGIN_NAME)];
61849
+ const out = [join32(root, "plugins", HERMES_PLUGIN_NAME)];
61718
61850
  for (const name of hermesProfilesScan(home2, env2, platform).names)
61719
- out.push(join31(root, "profiles", name, "plugins", HERMES_PLUGIN_NAME));
61851
+ out.push(join32(root, "profiles", name, "plugins", HERMES_PLUGIN_NAME));
61720
61852
  const active = hermesPluginDir(home2, env2, platform);
61721
61853
  if (!out.includes(active)) out.push(active);
61722
61854
  return out;
@@ -61724,7 +61856,7 @@ function hermesPluginDirs(home2, env2, platform = process.platform) {
61724
61856
  var hermesEnv = (home2, env2, platform = process.platform) => ({
61725
61857
  HERMES_HOME: hermesHome(home2, env2, platform)
61726
61858
  });
61727
- var hermesPluginDir = (home2, env2, platform = process.platform) => join31(hermesHome(home2, env2, platform), "plugins", HERMES_PLUGIN_NAME);
61859
+ var hermesPluginDir = (home2, env2, platform = process.platform) => join32(hermesHome(home2, env2, platform), "plugins", HERMES_PLUGIN_NAME);
61728
61860
  var kind = (path) => {
61729
61861
  try {
61730
61862
  const st = lstatSync14(path);
@@ -61735,11 +61867,11 @@ var kind = (path) => {
61735
61867
  };
61736
61868
  function files(dir, rel = "") {
61737
61869
  const out = [];
61738
- for (const name of readdirSync10(join31(dir, rel)).sort()) {
61870
+ for (const name of readdirSync10(join32(dir, rel)).sort()) {
61739
61871
  if (name === "__pycache__" || name.startsWith(".") || name.endsWith(".pyc") || rel === "" && (name === HERMES_HABITS_MARKER || name === HERMES_ROOTS_FILE))
61740
61872
  continue;
61741
61873
  const r = rel ? `${rel}/${name}` : name;
61742
- if (kind(join31(dir, r)) === "dir") out.push(...files(dir, r));
61874
+ if (kind(join32(dir, r)) === "dir") out.push(...files(dir, r));
61743
61875
  else out.push(r);
61744
61876
  }
61745
61877
  return out;
@@ -61748,7 +61880,7 @@ function pluginHash(dir) {
61748
61880
  const h = createHash11("sha256");
61749
61881
  for (const f of files(dir)) {
61750
61882
  h.update(`${f}\0`);
61751
- h.update(readFileSync26(join31(dir, f)));
61883
+ h.update(readFileSync26(join32(dir, f)));
61752
61884
  h.update("\0");
61753
61885
  }
61754
61886
  return h.digest("hex").slice(0, 16);
@@ -61759,7 +61891,7 @@ function pluginState(dir, shipped) {
61759
61891
  if (k !== "dir") return "foreign";
61760
61892
  let marker;
61761
61893
  try {
61762
- marker = readFileSync26(join31(dir, HERMES_MARKER), "utf8").trim();
61894
+ marker = readFileSync26(join32(dir, HERMES_MARKER), "utf8").trim();
61763
61895
  } catch {
61764
61896
  return "foreign";
61765
61897
  }
@@ -61798,11 +61930,11 @@ async function installHermes(deps2) {
61798
61930
  `${dest} exists and is not Open Artifacts bus's; left it untouched`
61799
61931
  );
61800
61932
  if (state !== "current") {
61801
- const keepHabits = state === "stale" && kind(join31(dest, HERMES_HABITS_MARKER)) === "file";
61802
- const keepRoots = state === "stale" && kind(join31(dest, HERMES_ROOTS_FILE)) === "file" ? readFileSync26(join31(dest, HERMES_ROOTS_FILE)) : void 0;
61803
- const plugins2 = join31(dest, "..");
61933
+ const keepHabits = state === "stale" && kind(join32(dest, HERMES_HABITS_MARKER)) === "file";
61934
+ const keepRoots = state === "stale" && kind(join32(dest, HERMES_ROOTS_FILE)) === "file" ? readFileSync26(join32(dest, HERMES_ROOTS_FILE)) : void 0;
61935
+ const plugins2 = join32(dest, "..");
61804
61936
  mkdirSync13(plugins2, { recursive: true });
61805
- const staging = join31(plugins2, "..", HERMES_STAGING);
61937
+ const staging = join32(plugins2, "..", HERMES_STAGING);
61806
61938
  const own2 = `${process.pid}-${randomBytes7(4).toString("hex")}`;
61807
61939
  const st = lstatSync14(staging, { throwIfNoEntry: false });
61808
61940
  if (st !== void 0 && !st.isDirectory())
@@ -61811,22 +61943,22 @@ async function installHermes(deps2) {
61811
61943
  );
61812
61944
  mkdirSync13(staging, { recursive: true });
61813
61945
  sweepStaging(staging, own2, deps2.staging);
61814
- const tmp = join31(staging, own2);
61946
+ const tmp = join32(staging, own2);
61815
61947
  try {
61816
61948
  mkdirSync13(tmp, { recursive: true });
61817
61949
  for (const f of files(shipped)) {
61818
- mkdirSync13(join31(tmp, f, ".."), { recursive: true });
61819
- cpSync2(join31(shipped, f), join31(tmp, f));
61950
+ mkdirSync13(join32(tmp, f, ".."), { recursive: true });
61951
+ cpSync2(join32(shipped, f), join32(tmp, f));
61820
61952
  }
61821
61953
  writeFileSync17(
61822
- join31(tmp, HERMES_MARKER),
61954
+ join32(tmp, HERMES_MARKER),
61823
61955
  `managed by the Open Artifacts bus installer: edits are replaced on reinstall. ${pluginHash(shipped)}
61824
61956
  `
61825
61957
  );
61826
61958
  if (keepHabits)
61827
- writeFileSync17(join31(tmp, HERMES_HABITS_MARKER), HABITS_MARKER_TEXT);
61959
+ writeFileSync17(join32(tmp, HERMES_HABITS_MARKER), HABITS_MARKER_TEXT);
61828
61960
  if (keepRoots !== void 0)
61829
- writeFileSync17(join31(tmp, HERMES_ROOTS_FILE), keepRoots, { mode: 384 });
61961
+ writeFileSync17(join32(tmp, HERMES_ROOTS_FILE), keepRoots, { mode: 384 });
61830
61962
  if (state === "stale") rmSync14(dest, { recursive: true, force: true });
61831
61963
  renameSync18(tmp, dest);
61832
61964
  } catch (e) {
@@ -61890,7 +62022,7 @@ import {
61890
62022
  realpathSync as realpathSync14,
61891
62023
  rmSync as rmSync16
61892
62024
  } from "node:fs";
61893
- import { join as join33, resolve as resolve10 } from "node:path";
62025
+ import { join as join34, resolve as resolve10 } from "node:path";
61894
62026
  import { fileURLToPath as fileURLToPath5 } from "node:url";
61895
62027
 
61896
62028
  // src/steps/skill.ts
@@ -61909,13 +62041,13 @@ import {
61909
62041
  statSync as statSync8,
61910
62042
  writeFileSync as writeFileSync18
61911
62043
  } from "node:fs";
61912
- import { dirname as dirname15, join as join32, resolve as resolve9 } from "node:path";
62044
+ import { dirname as dirname16, join as join33, resolve as resolve9 } from "node:path";
61913
62045
  var SKILL_MARKER = "<!-- managed by the Open Artifacts bus installer: edits are replaced on reinstall. -->";
61914
62046
  var CODEX_BEGIN = "<!-- BEGIN Open Artifacts skill (managed): edits inside are replaced on reinstall. -->";
61915
62047
  var CODEX_END = "<!-- END Open Artifacts skill -->";
61916
62048
  var CODEX_SKILLS_MIN_VERSION = "0.76.0";
61917
62049
  var MAX_SKILL_BYTES = 256 * 1024;
61918
- var codexSkillFile = (deps2, folder) => join32(codexHome2(deps2.home, env(deps2)), "skills", folder, "SKILL.md");
62050
+ var codexSkillFile = (deps2, folder) => join33(codexHome2(deps2.home, env(deps2)), "skills", folder, "SKILL.md");
61919
62051
  var codexHasSkills = (version2) => version2 !== void 0 && (compareVersions(version2, CODEX_SKILLS_MIN_VERSION) ?? -1) >= 0;
61920
62052
  var blankLine = (l) => l?.replace(/\r$/, "") === "";
61921
62053
  var withoutCodexBlock = (text3) => {
@@ -61953,17 +62085,17 @@ var dropCodexBlock = (agentsPath, notes) => {
61953
62085
  var env = (deps2) => deps2.env ?? {};
61954
62086
  var skillDir = (deps2, h) => {
61955
62087
  const e = env(deps2);
61956
- const opencode = e.OPENCODE_CONFIG_DIR ?? join32(e.XDG_CONFIG_HOME ?? join32(deps2.home, ".config"), "opencode");
61957
- const agents = join32(deps2.home, ".agents", "skills");
62088
+ const opencode = e.OPENCODE_CONFIG_DIR ?? join33(e.XDG_CONFIG_HOME ?? join33(deps2.home, ".config"), "opencode");
62089
+ const agents = join33(deps2.home, ".agents", "skills");
61958
62090
  return {
61959
- claude: join32(e.CLAUDE_CONFIG_DIR ?? join32(deps2.home, ".claude"), "skills"),
61960
- opencode: join32(opencode, "skills"),
62091
+ claude: join33(e.CLAUDE_CONFIG_DIR ?? join33(deps2.home, ".claude"), "skills"),
62092
+ opencode: join33(opencode, "skills"),
61961
62093
  pi: agents,
61962
62094
  omp: agents,
61963
- codex: join32(codexHome2(deps2.home, e), "AGENTS.md"),
61964
- hermes: join32(hermesHome(deps2.home, e), "skills"),
62095
+ codex: join33(codexHome2(deps2.home, e), "AGENTS.md"),
62096
+ hermes: join33(hermesHome(deps2.home, e), "skills"),
61965
62097
  // OpenClaw's managed skills folder, in its state dir.
61966
- openclaw: join32(openclawStateDir(deps2.home, e), "skills")
62098
+ openclaw: join33(openclawStateDir(deps2.home, e), "skills")
61967
62099
  }[h];
61968
62100
  };
61969
62101
  var skillFolder = (text3) => {
@@ -62059,7 +62191,7 @@ var targetOf = (path) => {
62059
62191
  };
62060
62192
  var seq = 0;
62061
62193
  var writeAtomic = (path, text3) => {
62062
- mkdirSync14(dirname15(path), { recursive: true });
62194
+ mkdirSync14(dirname16(path), { recursive: true });
62063
62195
  const tmp = `${path}.oa-${process.pid}-${seq++}.tmp`;
62064
62196
  try {
62065
62197
  let mode;
@@ -62120,13 +62252,13 @@ var placesOf = (p) => {
62120
62252
  const out = [realOrResolved(p)];
62121
62253
  try {
62122
62254
  if (lstatSync15(p).isSymbolicLink())
62123
- out.push(realOrResolved(resolve9(dirname15(p), readlinkSync4(p))));
62255
+ out.push(realOrResolved(resolve9(dirname16(p), readlinkSync4(p))));
62124
62256
  } catch {
62125
62257
  }
62126
62258
  return out;
62127
62259
  };
62128
62260
  var codexSkillsShared = (deps2) => {
62129
- const mine = placesOf(dirname15(dirname15(codexSkillFile(deps2, "x"))));
62261
+ const mine = placesOf(dirname16(dirname16(codexSkillFile(deps2, "x"))));
62130
62262
  const theirs = placesOf(skillDir(deps2, "pi"));
62131
62263
  return mine.some((m) => theirs.includes(m));
62132
62264
  };
@@ -62212,7 +62344,7 @@ var installCodex = (deps2, folder, text3, written, notes) => {
62212
62344
  try {
62213
62345
  rmSync15(targetOf(filePath), { force: true });
62214
62346
  try {
62215
- rmdirSync2(dirname15(filePath));
62347
+ rmdirSync2(dirname16(filePath));
62216
62348
  } catch {
62217
62349
  }
62218
62350
  } catch (e) {
@@ -62252,7 +62384,7 @@ async function installSkill(deps2, origin, harnesses) {
62252
62384
  continue;
62253
62385
  }
62254
62386
  const base3 = skillDir(deps2, h);
62255
- const path = join32(base3, folder, "SKILL.md");
62387
+ const path = join33(base3, folder, "SKILL.md");
62256
62388
  if (brokenLink(path)) {
62257
62389
  notes.push(`Left ${path} alone: it is a broken symlink.`);
62258
62390
  continue;
@@ -62300,8 +62432,8 @@ var uninstallSkill = (deps2, harnesses = [
62300
62432
  return;
62301
62433
  }
62302
62434
  for (const entry of entries) {
62303
- const dir = join32(base3, entry);
62304
- const file2 = join32(dir, "SKILL.md");
62435
+ const dir = join33(base3, entry);
62436
+ const file2 = join33(dir, "SKILL.md");
62305
62437
  try {
62306
62438
  const st = lstatSync15(dir);
62307
62439
  if (st.isSymbolicLink()) {
@@ -62337,7 +62469,7 @@ var uninstallSkill = (deps2, harnesses = [
62337
62469
  } catch (e) {
62338
62470
  fail3(base3, e);
62339
62471
  }
62340
- scan2(join32(dirname15(base3), "skills"));
62472
+ scan2(join33(dirname16(base3), "skills"));
62341
62473
  continue;
62342
62474
  }
62343
62475
  scan2(base3);
@@ -62349,9 +62481,9 @@ var codexSkillState = (deps2) => {
62349
62481
  shared: codexSkillsShared(deps2)
62350
62482
  };
62351
62483
  try {
62352
- const dir = join32(dirname15(skillDir(deps2, "codex")), "skills");
62484
+ const dir = join33(dirname16(skillDir(deps2, "codex")), "skills");
62353
62485
  for (const entry of readdirSync11(dir)) {
62354
- const file2 = join32(dir, entry, "SKILL.md");
62486
+ const file2 = join33(dir, entry, "SKILL.md");
62355
62487
  if (ourSkillFile(file2, entry)) {
62356
62488
  out.file = file2;
62357
62489
  break;
@@ -62380,7 +62512,7 @@ var savedSkill = (deps2, h, folder) => {
62380
62512
  return void 0;
62381
62513
  }
62382
62514
  for (const entry of entries) {
62383
- const file2 = join32(base3, entry, "SKILL.md");
62515
+ const file2 = join33(base3, entry, "SKILL.md");
62384
62516
  if (ourSkillFile(targetOf(file2), entry)) return file2;
62385
62517
  }
62386
62518
  return void 0;
@@ -62411,21 +62543,21 @@ function openclawStateDir(home2, env2) {
62411
62543
  return resolve10(
62412
62544
  override.startsWith("~") ? override.replace(/^~(?=$|[\\/])/, h) : override
62413
62545
  );
62414
- const next = join33(h, ".openclaw");
62546
+ const next = join34(h, ".openclaw");
62415
62547
  if (env2.OPENCLAW_TEST_FAST === "1" || existsSync12(next)) return next;
62416
- const legacy = join33(h, ".clawdbot");
62548
+ const legacy = join34(h, ".clawdbot");
62417
62549
  return existsSync12(legacy) ? legacy : next;
62418
62550
  }
62419
- var openclawPluginDir = (home2, env2) => join33(openclawStateDir(home2, env2), "extensions", OPENCLAW_PLUGIN_ID);
62551
+ var openclawPluginDir = (home2, env2) => join34(openclawStateDir(home2, env2), "extensions", OPENCLAW_PLUGIN_ID);
62420
62552
  function openclawPluginDirs(home2, env2) {
62421
62553
  const h = openclawHome(home2, env2);
62422
- const states = [join33(h, ".openclaw"), join33(h, ".clawdbot")];
62554
+ const states = [join34(h, ".openclaw"), join34(h, ".clawdbot")];
62423
62555
  try {
62424
62556
  for (const name of readdirSync12(h).sort())
62425
- if (name.startsWith(".openclaw-")) states.push(join33(h, name));
62557
+ if (name.startsWith(".openclaw-")) states.push(join34(h, name));
62426
62558
  } catch {
62427
62559
  }
62428
- const out = states.map((s) => join33(s, "extensions", OPENCLAW_PLUGIN_ID));
62560
+ const out = states.map((s) => join34(s, "extensions", OPENCLAW_PLUGIN_ID));
62429
62561
  const active = openclawPluginDir(home2, env2);
62430
62562
  if (!out.includes(active)) out.push(active);
62431
62563
  return out;
@@ -62445,7 +62577,7 @@ var kind2 = (path) => {
62445
62577
  var openclawManifestIsOurs = (dir) => {
62446
62578
  try {
62447
62579
  const m = JSON.parse(
62448
- readFileSync28(join33(dir, "openclaw.plugin.json"), "utf8")
62580
+ readFileSync28(join34(dir, "openclaw.plugin.json"), "utf8")
62449
62581
  );
62450
62582
  return m?.id === OPENCLAW_PLUGIN_ID;
62451
62583
  } catch {
@@ -62466,7 +62598,7 @@ function openclawPluginState(dir, shipped) {
62466
62598
  if (k !== "dir") return "foreign";
62467
62599
  let marker;
62468
62600
  try {
62469
- marker = readFileSync28(join33(dir, OPENCLAW_MARKER), "utf8").trim();
62601
+ marker = readFileSync28(join34(dir, OPENCLAW_MARKER), "utf8").trim();
62470
62602
  } catch {
62471
62603
  return sameAsShipped(dir, shipped) ? "stale" : "foreign";
62472
62604
  }
@@ -62479,7 +62611,7 @@ function openclawPluginState(dir, shipped) {
62479
62611
  return "stale";
62480
62612
  }
62481
62613
  }
62482
- var installFile = (deps2) => join33(deps2.busHome ?? join33(deps2.home, ".oa-bus"), "install.json");
62614
+ var installFile = (deps2) => join34(deps2.busHome ?? join34(deps2.home, ".oa-bus"), "install.json");
62483
62615
  var recordedStateDir = (deps2) => {
62484
62616
  const r = readInstallFile(installFile(deps2)).openclaw;
62485
62617
  const d = r?.stateDir;
@@ -62557,7 +62689,7 @@ async function installOpenclaw(deps2, notes, optedOut) {
62557
62689
  return "absent";
62558
62690
  }
62559
62691
  const shipped = deps2.assets.openclaw;
62560
- if (shipped === void 0 || !existsSync12(join33(shipped, "openclaw.plugin.json")))
62692
+ if (shipped === void 0 || !existsSync12(join34(shipped, "openclaw.plugin.json")))
62561
62693
  throw new Error("the OpenClaw plugin is missing from this install");
62562
62694
  const dest = openclawPluginDir(deps2.home, deps2.env ?? {});
62563
62695
  const state = openclawPluginState(dest, shipped);
@@ -62565,7 +62697,7 @@ async function installOpenclaw(deps2, notes, optedOut) {
62565
62697
  throw new Error(
62566
62698
  `${dest} exists and is not Open Artifacts bus's; left it untouched`
62567
62699
  );
62568
- const habitsFile = join33(dest, OPENCLAW_HABITS_MARKER);
62700
+ const habitsFile = join34(dest, OPENCLAW_HABITS_MARKER);
62569
62701
  const dropHabitsIfOptedOut = () => {
62570
62702
  if (optedOut && kind2(dest) === "dir") rmSync16(habitsFile, { force: true });
62571
62703
  };
@@ -62586,7 +62718,7 @@ async function installOpenclaw(deps2, notes, optedOut) {
62586
62718
  INSTALL_TIMEOUT_MS
62587
62719
  );
62588
62720
  const restore2 = () => {
62589
- if (keepHabits && kind2(dest) === "dir" && kind2(join33(dest, OPENCLAW_MARKER)) === "file")
62721
+ if (keepHabits && kind2(dest) === "dir" && kind2(join34(dest, OPENCLAW_MARKER)) === "file")
62590
62722
  writeAtomic(habitsFile, HABITS_MARKER_TEXT);
62591
62723
  };
62592
62724
  if (r.code !== 0) {
@@ -62598,7 +62730,7 @@ async function installOpenclaw(deps2, notes, optedOut) {
62598
62730
  `\`openclaw plugins install\` finished, but ${dest} is not there`
62599
62731
  );
62600
62732
  writeAtomic(
62601
- join33(dest, OPENCLAW_MARKER),
62733
+ join34(dest, OPENCLAW_MARKER),
62602
62734
  `managed by the Open Artifacts bus installer: edits are replaced on reinstall. ${pluginHash(shipped)}
62603
62735
  `
62604
62736
  );
@@ -62695,21 +62827,21 @@ var habitsBlock = () => [
62695
62827
  ];
62696
62828
  var piAgentDir = (home2, env2) => {
62697
62829
  const d = env2.PI_CODING_AGENT_DIR;
62698
- if (!d) return join34(home2, ".pi", "agent");
62830
+ if (!d) return join35(home2, ".pi", "agent");
62699
62831
  if (d === "~") return home2;
62700
- return resolve11(d.startsWith("~/") ? join34(home2, d.slice(2)) : d);
62832
+ return resolve11(d.startsWith("~/") ? join35(home2, d.slice(2)) : d);
62701
62833
  };
62702
62834
  function habitsFiles(deps2, h) {
62703
62835
  const env2 = deps2.env ?? {};
62704
62836
  const pair = (dir) => {
62705
- const override = join34(dir, "AGENTS.override.md");
62706
- const plain3 = join34(dir, "AGENTS.md");
62837
+ const override = join35(dir, "AGENTS.override.md");
62838
+ const plain3 = join35(dir, "AGENTS.md");
62707
62839
  return existsSync13(override) ? [override, plain3] : [plain3, override];
62708
62840
  };
62709
62841
  switch (h) {
62710
62842
  case "claude":
62711
62843
  return [
62712
- join34(env2.CLAUDE_CONFIG_DIR ?? join34(deps2.home, ".claude"), "CLAUDE.md")
62844
+ join35(env2.CLAUDE_CONFIG_DIR ?? join35(deps2.home, ".claude"), "CLAUDE.md")
62713
62845
  ];
62714
62846
  case "codex":
62715
62847
  return pair(codexHome2(deps2.home, env2));
@@ -62717,8 +62849,8 @@ function habitsFiles(deps2, h) {
62717
62849
  return pair(piAgentDir(deps2.home, env2));
62718
62850
  case "opencode":
62719
62851
  return [
62720
- join34(
62721
- env2.OPENCODE_CONFIG_DIR ?? join34(env2.XDG_CONFIG_HOME ?? join34(deps2.home, ".config"), "opencode"),
62852
+ join35(
62853
+ env2.OPENCODE_CONFIG_DIR ?? join35(env2.XDG_CONFIG_HOME ?? join35(deps2.home, ".config"), "opencode"),
62722
62854
  "AGENTS.md"
62723
62855
  )
62724
62856
  ];
@@ -62799,7 +62931,7 @@ function linkInfo(deps2, path) {
62799
62931
  }
62800
62932
  }
62801
62933
  var record6 = (busHome2) => {
62802
- const raw = busHome2 ? readInstallFile(join34(busHome2, "install.json")).habits : void 0;
62934
+ const raw = busHome2 ? readInstallFile(join35(busHome2, "install.json")).habits : void 0;
62803
62935
  const h = typeof raw === "object" && raw !== null ? raw : {};
62804
62936
  return {
62805
62937
  optedOut: h.optedOut === true,
@@ -62819,7 +62951,7 @@ var pluginDirsOf = (v) => {
62819
62951
  var saveRecord = (busHome2, patch) => {
62820
62952
  if (!busHome2) return;
62821
62953
  const cur = record6(busHome2);
62822
- updateInstallFile(join34(busHome2, "install.json"), {
62954
+ updateInstallFile(join35(busHome2, "install.json"), {
62823
62955
  habits: { ...cur, ...patch }
62824
62956
  });
62825
62957
  };
@@ -62906,7 +63038,7 @@ function removeHabits(deps2, harnesses = HABITS_HARNESSES) {
62906
63038
  const p = setPluginHabits(deps2, PLUGIN_HARNESSES, false);
62907
63039
  files2.push(...p.markers);
62908
63040
  notes.push(...p.notes);
62909
- if (deps2.busHome && existsSync13(join34(deps2.busHome, "install.json")))
63041
+ if (deps2.busHome && existsSync13(join35(deps2.busHome, "install.json")))
62910
63042
  saveRecord(deps2.busHome, { files: kept });
62911
63043
  return {
62912
63044
  files: files2,
@@ -62955,7 +63087,7 @@ var PLUGIN_HARNESSES = [
62955
63087
  ];
62956
63088
  var pluginPaths = (deps2, p) => {
62957
63089
  const dir = p.dir(deps2.home, deps2.env ?? {});
62958
- return { dir, marker: join34(dir, p.marker) };
63090
+ return { dir, marker: join35(dir, p.marker) };
62959
63091
  };
62960
63092
  var pluginOurs = (dir, p) => {
62961
63093
  try {
@@ -62990,7 +63122,7 @@ function setPluginHabits(deps2, plugins2, on) {
62990
63122
  for (const p of plugins2) {
62991
63123
  if (on) {
62992
63124
  const dir = pluginPaths(deps2, p).dir;
62993
- const marker = join34(dir, p.marker);
63125
+ const marker = join35(dir, p.marker);
62994
63126
  try {
62995
63127
  if (isLink(dir) || !pluginOurs(dir, p)) {
62996
63128
  notes.push(
@@ -63035,7 +63167,7 @@ function setPluginHabits(deps2, plugins2, on) {
63035
63167
  else notes.push(scan2.note);
63036
63168
  }
63037
63169
  for (const dir of dirs) {
63038
- const marker = join34(dir, p.marker);
63170
+ const marker = join35(dir, p.marker);
63039
63171
  const d = probe(dir);
63040
63172
  if (d.k === "absent") continue;
63041
63173
  if (d.k === "error") {
@@ -63087,7 +63219,7 @@ function setPluginHabits(deps2, plugins2, on) {
63087
63219
  done.add(dir);
63088
63220
  if (!changed.includes(p)) changed.push(p);
63089
63221
  }
63090
- if (deps2.busHome && existsSync13(join34(deps2.busHome, "install.json"))) {
63222
+ if (deps2.busHome && existsSync13(join35(deps2.busHome, "install.json"))) {
63091
63223
  const { pluginDirs } = record6(deps2.busHome);
63092
63224
  const had = pluginDirs[p.name];
63093
63225
  if (had !== void 0) {
@@ -63135,7 +63267,7 @@ var habitsQuestionLines = (q) => [
63135
63267
 
63136
63268
  // src/steps/opencode-proof.ts
63137
63269
  import { existsSync as existsSync14, readFileSync as readFileSync30, rmSync as rmSync18 } from "node:fs";
63138
- import { dirname as dirname16, isAbsolute as isAbsolute13, join as join35, resolve as resolve12 } from "node:path";
63270
+ import { dirname as dirname17, isAbsolute as isAbsolute13, join as join36, resolve as resolve12 } from "node:path";
63139
63271
  init_src();
63140
63272
  var OPENCODE_ENTRY_FILE = "opencode-mcp-entry.json";
63141
63273
  var isRecord6 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
@@ -63177,8 +63309,8 @@ function tokenFileOf(e) {
63177
63309
  var REMOTE_ONLY = /* @__PURE__ */ new Set(["type", "url", "headers", "oauth"]);
63178
63310
  function resolveTokenFile(x, configFile, home2) {
63179
63311
  if (x === "~") return home2;
63180
- if (x.startsWith("~/")) return join35(home2, x.slice(2));
63181
- return isAbsolute13(x) ? x : resolve12(dirname16(configFile), x);
63312
+ if (x.startsWith("~/")) return join36(home2, x.slice(2));
63313
+ return isAbsolute13(x) ? x : resolve12(dirname17(configFile), x);
63182
63314
  }
63183
63315
  var proxyEntry = (io, origin, tokenFile, entry) => {
63184
63316
  const kept = Object.fromEntries(
@@ -63470,44 +63602,44 @@ var readAssets = () => ({
63470
63602
  var movedHome = (deps2) => {
63471
63603
  if (deps2.busHome === void 0) return void 0;
63472
63604
  const ob = resolve13(deps2.busHome);
63473
- return ob === join36(deps2.home, ".oa-bus") ? void 0 : ob;
63605
+ return ob === join37(deps2.home, ".oa-bus") ? void 0 : ob;
63474
63606
  };
63475
63607
  var homeLine = (ob) => `process.env.OA_BUS_HOME ||= ${JSON.stringify(ob)};`;
63476
63608
  var withHome = (text3, ob) => ob === void 0 ? text3 : `${homeLine(ob)}
63477
63609
  ${text3}`;
63478
63610
  var paths = (deps2) => {
63479
63611
  const env2 = deps2.env ?? {};
63480
- const opencode = env2.OPENCODE_CONFIG_DIR ?? join36(env2.XDG_CONFIG_HOME ?? join36(deps2.home, ".config"), "opencode");
63481
- const busDir = deps2.busHome ?? join36(deps2.home, ".oa-bus");
63612
+ const opencode = env2.OPENCODE_CONFIG_DIR ?? join37(env2.XDG_CONFIG_HOME ?? join37(deps2.home, ".config"), "opencode");
63613
+ const busDir = deps2.busHome ?? join37(deps2.home, ".oa-bus");
63482
63614
  return {
63483
63615
  claude: claudeConfigFile2(deps2.home, env2),
63484
63616
  // OpenCode reads both; edit the one the user has, else create .json.
63485
63617
  opencodeConfigs: [
63486
- join36(opencode, "opencode.json"),
63487
- join36(opencode, "opencode.jsonc")
63618
+ join37(opencode, "opencode.json"),
63619
+ join37(opencode, "opencode.jsonc")
63488
63620
  ],
63489
- opencodeCli: join36(opencode, "cli.json"),
63490
- record: join36(busDir, "install.json"),
63621
+ opencodeCli: join37(opencode, "cli.json"),
63622
+ record: join37(busDir, "install.json"),
63491
63623
  // #1856: where install keeps the OpenCode entry it replaced with the proxy.
63492
- opencodeEntry: join36(busDir, OPENCODE_ENTRY_FILE),
63624
+ opencodeEntry: join37(busDir, OPENCODE_ENTRY_FILE),
63493
63625
  // #1856: Pi's own MCP config, and where install keeps the entry it moved.
63494
- piMcp: join36(
63495
- agentDirEnv(deps2.home, env2) ?? join36(deps2.home, ".pi/agent"),
63626
+ piMcp: join37(
63627
+ agentDirEnv(deps2.home, env2) ?? join37(deps2.home, ".pi/agent"),
63496
63628
  "mcp.json"
63497
63629
  ),
63498
- piEntry: join36(busDir, PI_ENTRY_FILE),
63499
- ompOrigin: join36(busDir, OMP_ORIGIN_FILE),
63630
+ piEntry: join37(busDir, PI_ENTRY_FILE),
63631
+ ompOrigin: join37(busDir, OMP_ORIGIN_FILE),
63500
63632
  // OpenCode registers the folder that holds tui.js.
63501
- opencodePlugin: join36(busDir, "integrations/opencode", NAME),
63502
- pi: join36(
63503
- agentDirEnv(deps2.home, env2) ?? join36(deps2.home, ".pi/agent"),
63633
+ opencodePlugin: join37(busDir, "integrations/opencode", NAME),
63634
+ pi: join37(
63635
+ agentDirEnv(deps2.home, env2) ?? join37(deps2.home, ".pi/agent"),
63504
63636
  "extensions/oa-bus.ts"
63505
63637
  ),
63506
- omp: join36(ompAgentDir(deps2.home, env2), "extensions/oa-bus.ts"),
63638
+ omp: join37(ompAgentDir(deps2.home, env2), "extensions/oa-bus.ts"),
63507
63639
  codex: codexConfig(deps2.home, env2),
63508
63640
  codexBin: codexBinFile(busDir),
63509
63641
  // #1856: where install keeps the Codex entry it swapped for the proxy.
63510
- codexEntry: join36(busDir, CODEX_PROXY_ENTRY_FILE),
63642
+ codexEntry: join37(busDir, CODEX_PROXY_ENTRY_FILE),
63511
63643
  busDir
63512
63644
  };
63513
63645
  };
@@ -63515,9 +63647,9 @@ function agentDirEnv(home2, env2) {
63515
63647
  const dir = env2.PI_CODING_AGENT_DIR;
63516
63648
  if (!dir) return void 0;
63517
63649
  if (dir === "~") return home2;
63518
- return resolve13(dir.startsWith("~/") ? join36(home2, dir.slice(2)) : dir);
63650
+ return resolve13(dir.startsWith("~/") ? join37(home2, dir.slice(2)) : dir);
63519
63651
  }
63520
- var ompRoot = (home2, env2) => join36(home2, env2.PI_CONFIG_DIR || ".omp");
63652
+ var ompRoot = (home2, env2) => join37(home2, env2.PI_CONFIG_DIR || ".omp");
63521
63653
  function ompProfile(env2) {
63522
63654
  const name = (env2.OMP_PROFILE !== void 0 ? env2.OMP_PROFILE : env2.PI_PROFILE)?.trim();
63523
63655
  if (!name || name === "default" || name.endsWith(".")) return void 0;
@@ -63526,14 +63658,14 @@ function ompProfile(env2) {
63526
63658
  function ompAgentDir(home2, env2) {
63527
63659
  const root = ompRoot(home2, env2);
63528
63660
  const profile = ompProfile(env2);
63529
- if (profile) return join36(root, "profiles", profile, "agent");
63661
+ if (profile) return join37(root, "profiles", profile, "agent");
63530
63662
  const piProfile = ompProfile({ PI_PROFILE: env2.PI_PROFILE });
63531
63663
  const dir = agentDirEnv(home2, env2);
63532
- if (dir && !(piProfile && dir === join36(root, "profiles", piProfile, "agent")))
63664
+ if (dir && !(piProfile && dir === join37(root, "profiles", piProfile, "agent")))
63533
63665
  return dir;
63534
- return join36(root, "agent");
63666
+ return join37(root, "agent");
63535
63667
  }
63536
- var hasOmp = (deps2) => deps2.which("omp") || present2(ompRoot(deps2.home, deps2.env ?? {})) || present2(join36(deps2.home, ".bun/bin/omp"));
63668
+ var hasOmp = (deps2) => deps2.which("omp") || present2(ompRoot(deps2.home, deps2.env ?? {})) || present2(join37(deps2.home, ".bun/bin/omp"));
63537
63669
  var sharedFile = (deps2) => paths(deps2).omp === paths(deps2).pi;
63538
63670
  function readDoc(path) {
63539
63671
  let text3;
@@ -63563,19 +63695,19 @@ function target(path) {
63563
63695
  let p = path;
63564
63696
  for (let hops = 0; hops < 40; hops++) {
63565
63697
  if (!present2(p) || !lstatSync18(p).isSymbolicLink()) {
63566
- if (p !== path && !existsSync16(dirname17(p)))
63698
+ if (p !== path && !existsSync16(dirname18(p)))
63567
63699
  throw new Error(
63568
63700
  `${path} is a dangling symlink to ${p}; left it untouched`
63569
63701
  );
63570
63702
  return p;
63571
63703
  }
63572
- p = resolve13(dirname17(p), readlinkSync5(p));
63704
+ p = resolve13(dirname18(p), readlinkSync5(p));
63573
63705
  }
63574
63706
  throw new Error(`${path}: too many symlinks; left it untouched`);
63575
63707
  }
63576
63708
  function writeAtomic2(path, data, mode) {
63577
63709
  const dest = target(path);
63578
- mkdirSync15(dirname17(dest), { recursive: true });
63710
+ mkdirSync15(dirname18(dest), { recursive: true });
63579
63711
  let m = mode ?? 420;
63580
63712
  if (mode === void 0)
63581
63713
  try {
@@ -63655,7 +63787,7 @@ async function run4(deps2, cmd, args) {
63655
63787
  }
63656
63788
  function instanceProofs(deps2) {
63657
63789
  const notes = [];
63658
- const bus = deps2.busHome ?? join36(deps2.home, ".oa-bus");
63790
+ const bus = deps2.busHome ?? join37(deps2.home, ".oa-bus");
63659
63791
  for (const i of listInstances(bus)) {
63660
63792
  if (i.main || i.hub === "") continue;
63661
63793
  notes.push(
@@ -63906,7 +64038,7 @@ var install = {
63906
64038
  if (madeCli.length > 0)
63907
64039
  created[p.opencodeCli] = add2(p.opencodeCli, madeCli);
63908
64040
  writeRecord2(p.record, record7, created);
63909
- const pluginFile = join36(p.opencodePlugin, "tui.js");
64041
+ const pluginFile = join37(p.opencodePlugin, "tui.js");
63910
64042
  const pluginText = withHome(deps2.assets.opencodePlugin, movedHome(deps2));
63911
64043
  let pluginBefore;
63912
64044
  try {
@@ -64224,7 +64356,7 @@ function checkAdapters(deps2) {
64224
64356
  }) && listed(
64225
64357
  parseJsonc(readFileSync32(p.opencodeCli, "utf8"), p.opencodeCli),
64226
64358
  p.opencodePlugin
64227
- ) && homed(join36(p.opencodePlugin, "tui.js"))
64359
+ ) && homed(join37(p.opencodePlugin, "tui.js"))
64228
64360
  ),
64229
64361
  pi: state("pi", () => homed(p.pi)),
64230
64362
  omp: state("omp", () => homed(p.omp)),
@@ -64328,14 +64460,14 @@ import {
64328
64460
  rmSync as rmSync21,
64329
64461
  writeFileSync as writeFileSync20
64330
64462
  } from "node:fs";
64331
- import { delimiter as delimiter3, dirname as dirname18, join as join37, resolve as resolve14, sep as sep6 } from "node:path";
64463
+ import { delimiter as delimiter3, dirname as dirname19, join as join38, resolve as resolve14, sep as sep6 } from "node:path";
64332
64464
  var SHIM_MARKER = "# oa-bus shim: written by oa-bus install";
64333
64465
  var HOME_PREFIX = "# oa-bus home: ";
64334
64466
  var NAME2 = "oa-bus";
64335
64467
  var LOCAL_HINT = 'export PATH="$HOME/.local/bin:$PATH"';
64336
64468
  var isWindows = (platform) => platform.startsWith("win32");
64337
64469
  var pathDirs = (p) => (p ?? "").split(delimiter3).filter((d) => d !== "").map((d) => resolve14(d));
64338
- var candidates2 = (o) => o.platform.startsWith("darwin") ? [join37(o.userHome, ".local", "bin"), join37(o.userHome, "bin")] : [join37(o.userHome, ".local", "bin")];
64470
+ var candidates2 = (o) => o.platform.startsWith("darwin") ? [join38(o.userHome, ".local", "bin"), join38(o.userHome, "bin")] : [join38(o.userHome, ".local", "bin")];
64339
64471
  var shQuote2 = (v) => `'${v.replaceAll("'", `'\\''`)}'`;
64340
64472
  function shimText(o) {
64341
64473
  const moved = resolve14(o.busHome) !== resolve14(o.userHome, ".oa-bus");
@@ -64357,7 +64489,7 @@ function ownerOf(file2, busHome2) {
64357
64489
  }
64358
64490
  if (st.isSymbolicLink()) {
64359
64491
  try {
64360
- const to = resolve14(dirname18(file2), readlinkSync6(file2));
64492
+ const to = resolve14(dirname19(file2), readlinkSync6(file2));
64361
64493
  const home2 = resolve14(busHome2);
64362
64494
  return to === home2 || to.startsWith(`${home2}/`) ? { ours: true, home: home2 } : { ours: false };
64363
64495
  } catch {
@@ -64392,7 +64524,7 @@ function installShim(o) {
64392
64524
  const onPath = new Set(pathDirs(o.env.PATH));
64393
64525
  const list = candidates2(o);
64394
64526
  const dir = list.find((d) => onPath.has(d)) ?? list[0];
64395
- const path = join37(dir, NAME2);
64527
+ const path = join38(dir, NAME2);
64396
64528
  const owner = ownerOf(path, o.busHome);
64397
64529
  if (owner && !owner.ours) return { kind: "foreign", path };
64398
64530
  if (owner?.ours && !sameHome(owner, o.busHome))
@@ -64401,7 +64533,7 @@ function installShim(o) {
64401
64533
  const text3 = shimText(o);
64402
64534
  writeShim(path, text3);
64403
64535
  for (const d of list) {
64404
- const other = join37(d, NAME2);
64536
+ const other = join38(d, NAME2);
64405
64537
  if (d !== dir && sameHome(ownerOf(other, o.busHome), o.busHome))
64406
64538
  writeShim(other, text3);
64407
64539
  }
@@ -64417,7 +64549,7 @@ function removeShim(o) {
64417
64549
  if (isWindows(o.platform)) return void 0;
64418
64550
  let removed;
64419
64551
  for (const dir of candidates2({ ...o, env: {} })) {
64420
- const file2 = join37(dir, NAME2);
64552
+ const file2 = join38(dir, NAME2);
64421
64553
  const owner = ownerOf(file2, o.busHome);
64422
64554
  if (!owner?.ours) continue;
64423
64555
  if (owner.home !== void 0 && owner.home !== resolve14(o.busHome)) continue;
@@ -64440,13 +64572,13 @@ function shimState(o) {
64440
64572
  (d) => !(d.endsWith(`${sep6}node_modules${sep6}.bin`) && d.split(sep6).includes("_npx"))
64441
64573
  );
64442
64574
  for (const dir of dirs) {
64443
- const file2 = join37(dir, NAME2);
64575
+ const file2 = join38(dir, NAME2);
64444
64576
  if (!executable2(file2)) continue;
64445
64577
  const owner = ownerOf(file2, o.busHome);
64446
64578
  return owner?.ours && (owner.home === void 0 || owner.home === resolve14(o.busHome)) ? { kind: "ours", path: file2 } : { kind: "other", path: file2 };
64447
64579
  }
64448
64580
  for (const dir of candidates2(o)) {
64449
- const file2 = join37(dir, NAME2);
64581
+ const file2 = join38(dir, NAME2);
64450
64582
  const owner = ownerOf(file2, o.busHome);
64451
64583
  if (owner?.ours && (owner.home === void 0 || owner.home === resolve14(o.busHome)))
64452
64584
  return { kind: "off-path", path: file2, hint: LOCAL_HINT };
@@ -64463,8 +64595,8 @@ function busCmd(o) {
64463
64595
  return installedForm(o.busHome) ?? BUS_CMD;
64464
64596
  }
64465
64597
  function installedForm(home2) {
64466
- const node2 = join38(home2, "bin", "node");
64467
- const entry = join38(home2, "bin", "dist", "index.js");
64598
+ const node2 = join39(home2, "bin", "node");
64599
+ const entry = join39(home2, "bin", "dist", "index.js");
64468
64600
  if (!existsSync17(node2) || !existsSync17(entry)) return void 0;
64469
64601
  const q = (p) => /[\s"'$`\\]/.test(p) ? JSON.stringify(p) : p;
64470
64602
  return `${q(node2)} ${q(entry)}`;
@@ -64520,7 +64652,7 @@ import {
64520
64652
  unlinkSync as unlinkSync5,
64521
64653
  writeSync as writeSync5
64522
64654
  } from "node:fs";
64523
- import { join as join39 } from "node:path";
64655
+ import { join as join40 } from "node:path";
64524
64656
  init_src();
64525
64657
 
64526
64658
  // src/machine-label.ts
@@ -64571,7 +64703,7 @@ function checkVerificationUri(uri, hub) {
64571
64703
  function writeMachineFile(home2, body) {
64572
64704
  mkdirSync17(home2, { recursive: true, mode: 448 });
64573
64705
  chmodSync22(home2, 448);
64574
- const tmp = join39(home2, `.machine.json.${randomBytes9(8).toString("hex")}.tmp`);
64706
+ const tmp = join40(home2, `.machine.json.${randomBytes9(8).toString("hex")}.tmp`);
64575
64707
  const fd = openSync10(tmp, "wx", 384);
64576
64708
  try {
64577
64709
  writeSync5(fd, body);
@@ -64583,7 +64715,7 @@ function writeMachineFile(home2, body) {
64583
64715
  closeSync10(fd);
64584
64716
  try {
64585
64717
  chmodSync22(tmp, 384);
64586
- renameSync22(tmp, join39(home2, "machine.json"));
64718
+ renameSync22(tmp, join40(home2, "machine.json"));
64587
64719
  } catch (e) {
64588
64720
  unlinkSync5(tmp);
64589
64721
  throw e;
@@ -64733,7 +64865,7 @@ async function loginInner(args) {
64733
64865
  `${JSON.stringify({ hub, label: label2, machine_token: poll.machine_token }, null, 2)}
64734
64866
  `
64735
64867
  );
64736
- rmSync22(join39(args.home, "revoked"), { force: true });
64868
+ rmSync22(join40(args.home, "revoked"), { force: true });
64737
64869
  }
64738
64870
  if (!events?.code) print(`Approved this machine as ${label2}.`);
64739
64871
  return {
@@ -64910,15 +65042,15 @@ async function autoUpdate(opts, ctx) {
64910
65042
 
64911
65043
  // src/commands/daemon.ts
64912
65044
  import { existsSync as existsSync18 } from "node:fs";
64913
- import { join as join42 } from "node:path";
65045
+ import { join as join43 } from "node:path";
64914
65046
  import { fileURLToPath as fileURLToPath6 } from "node:url";
64915
65047
 
64916
65048
  // src/machine.ts
64917
65049
  import { readFileSync as readFileSync34, statSync as statSync10 } from "node:fs";
64918
- import { join as join40 } from "node:path";
65050
+ import { join as join41 } from "node:path";
64919
65051
  init_src();
64920
65052
  function readMachine(home2) {
64921
- const file2 = join40(home2, "machine.json");
65053
+ const file2 = join41(home2, "machine.json");
64922
65054
  let text3;
64923
65055
  let mode;
64924
65056
  try {
@@ -64952,7 +65084,7 @@ var originOf2 = (hub) => {
64952
65084
 
64953
65085
  // src/steps/claude-proof-check.ts
64954
65086
  import { readFileSync as readFileSync35 } from "node:fs";
64955
- import { join as join41 } from "node:path";
65087
+ import { join as join42 } from "node:path";
64956
65088
  var PROOF_EVENT = "claude_proof_applied";
64957
65089
  var DAY_MS = 864e5;
64958
65090
  var safeText = (s, max = 80) => {
@@ -64977,10 +65109,10 @@ function claudeProofChecks(ctx, hub, instance) {
64977
65109
  return [];
64978
65110
  }
64979
65111
  const cc = instance ? `Claude Code (${safeText(instance.name, 32)}):` : "Claude Code:";
64980
- const rec = readRecord(join41(ctx.home, "install.json"));
65112
+ const rec = readRecord(join42(ctx.home, "install.json"));
64981
65113
  const file2 = rec.config ?? claudeConfigFile2(ctx.userHome, ctx.env);
64982
65114
  const r = proofReport(file2, origin, {
64983
- projectFile: join41(ctx.cwd, ".mcp.json"),
65115
+ projectFile: join42(ctx.cwd, ".mcp.json"),
64984
65116
  cwd: ctx.cwd,
64985
65117
  recorded: rec.proofs,
64986
65118
  ...instance ? { instance } : {},
@@ -65100,7 +65232,7 @@ function instanceProofChecks(ctx) {
65100
65232
  function lastAutoFix(ctx) {
65101
65233
  let text3;
65102
65234
  try {
65103
- text3 = readFileSync35(join41(ctx.home, "logs", "events.log"), "utf8");
65235
+ text3 = readFileSync35(join42(ctx.home, "logs", "events.log"), "utf8");
65104
65236
  } catch {
65105
65237
  return void 0;
65106
65238
  }
@@ -65126,12 +65258,12 @@ var lasting = (e) => [...START_ERROR_CODES, "EACCES", "EPERM"].includes(
65126
65258
  );
65127
65259
  async function daemon(ctx, run5 = runDaemon, signals = process) {
65128
65260
  const m = readMachine(ctx.home);
65129
- if (existsSync18(join42(ctx.home, "revoked")) && (m.state !== "ok" || m.revoked)) {
65261
+ if (existsSync18(join43(ctx.home, "revoked")) && (m.state !== "ok" || m.revoked)) {
65130
65262
  sayErr(ctx, ctx.copy.revoked());
65131
65263
  return 0;
65132
65264
  }
65133
- const events = createEventLog(join42(ctx.home, "logs", "events.log"));
65134
- const config2 = readRecord(join42(ctx.home, "install.json")).config;
65265
+ const events = createEventLog(join43(ctx.home, "logs", "events.log"));
65266
+ const config2 = readRecord(join43(ctx.home, "install.json")).config;
65135
65267
  if (m.state === "ok" && config2 !== void 0 && wiredTo(ctx))
65136
65268
  reapplyClaudeProof(
65137
65269
  {
@@ -65185,11 +65317,11 @@ async function daemon(ctx, run5 = runDaemon, signals = process) {
65185
65317
 
65186
65318
  // src/commands/doctor.ts
65187
65319
  import { readFileSync as readFileSync40 } from "node:fs";
65188
- import { join as join50 } from "node:path";
65320
+ import { join as join51 } from "node:path";
65189
65321
 
65190
65322
  // src/steps/claude-plugins.ts
65191
65323
  import { readFileSync as readFileSync37 } from "node:fs";
65192
- import { join as join44 } from "node:path";
65324
+ import { join as join45 } from "node:path";
65193
65325
 
65194
65326
  // src/steps/output-style.ts
65195
65327
  import {
@@ -65199,21 +65331,21 @@ import {
65199
65331
  rmdirSync as rmdirSync3,
65200
65332
  rmSync as rmSync23
65201
65333
  } from "node:fs";
65202
- import { dirname as dirname19, join as join43 } from "node:path";
65334
+ import { dirname as dirname20, join as join44 } from "node:path";
65203
65335
  var OUTPUT_STYLE_FILE = "artifacts-teammate.md";
65204
65336
  var OUTPUT_STYLE_MARKER = "<!-- managed by the Open Artifacts bus installer: edits are replaced on reinstall. -->";
65205
65337
  var OUTPUT_STYLE_NAME = "Artifacts Teammate";
65206
65338
  var OUTPUT_STYLE_PLUGIN_NAME = "open-artifacts:Artifacts Teammate";
65207
65339
  var isOurName = (v) => v === OUTPUT_STYLE_NAME || v === OUTPUT_STYLE_PLUGIN_NAME;
65208
- var claudeSettingsFile = (w) => join43(w.env?.CLAUDE_CONFIG_DIR ?? join43(w.home, ".claude"), "settings.json");
65340
+ var claudeSettingsFile = (w) => join44(w.env?.CLAUDE_CONFIG_DIR ?? join44(w.home, ".claude"), "settings.json");
65209
65341
  var readRecord3 = (busHome2) => {
65210
65342
  if (!busHome2) return void 0;
65211
- const r = readInstallFile(join43(busHome2, "install.json")).outputStyle;
65343
+ const r = readInstallFile(join44(busHome2, "install.json")).outputStyle;
65212
65344
  return typeof r === "object" && r !== null ? r : void 0;
65213
65345
  };
65214
- var writeRecord3 = (busHome2, r) => updateInstallFile(join43(busHome2, "install.json"), { outputStyle: r });
65215
- var styleDir = (w) => join43(w.env?.CLAUDE_CONFIG_DIR ?? join43(w.home, ".claude"), "output-styles");
65216
- var outputStyleFile = (w) => join43(styleDir(w), OUTPUT_STYLE_FILE);
65346
+ var writeRecord3 = (busHome2, r) => updateInstallFile(join44(busHome2, "install.json"), { outputStyle: r });
65347
+ var styleDir = (w) => join44(w.env?.CLAUDE_CONFIG_DIR ?? join44(w.home, ".claude"), "output-styles");
65348
+ var outputStyleFile = (w) => join44(styleDir(w), OUTPUT_STYLE_FILE);
65217
65349
  var isOurs2 = (text3) => {
65218
65350
  const m = /^---\n[\s\S]*?\n---\n/.exec(text3.replace(/\r\n/g, "\n"));
65219
65351
  return m !== null && text3.replace(/\r\n/g, "\n").slice(m[0].length).split("\n", 1)[0] === OUTPUT_STYLE_MARKER;
@@ -65410,7 +65542,7 @@ var outputStyleOn = (deps2) => {
65410
65542
  var outputStyleState = (deps2) => {
65411
65543
  const path = outputStyleFile(deps2);
65412
65544
  try {
65413
- if (isLink2(dirname19(path)) || isLink2(path)) return void 0;
65545
+ if (isLink2(dirname20(path)) || isLink2(path)) return void 0;
65414
65546
  if (!isOurs2(readFileSync36(path, "utf8"))) return void 0;
65415
65547
  const s = readSettings(claudeSettingsFile(deps2));
65416
65548
  return { path, on: s.ok && s.style === OUTPUT_STYLE_NAME };
@@ -65431,10 +65563,10 @@ var SPARSE = [".claude-plugin", "plugins", "packages/claude-code-shortcuts"];
65431
65563
  var CALL_MS = 12e4;
65432
65564
  var MCP_LIST_MS = 2e4;
65433
65565
  var readRecord4 = (busHome2) => {
65434
- const r = readInstallFile(join44(busHome2, "install.json")).claudePlugins;
65566
+ const r = readInstallFile(join45(busHome2, "install.json")).claudePlugins;
65435
65567
  return typeof r === "object" && r !== null ? r : void 0;
65436
65568
  };
65437
- var writeRecord4 = (busHome2, r) => updateInstallFile(join44(busHome2, "install.json"), { claudePlugins: r });
65569
+ var writeRecord4 = (busHome2, r) => updateInstallFile(join45(busHome2, "install.json"), { claudePlugins: r });
65438
65570
  var cmpVersion = (a, b) => {
65439
65571
  const pa = a.split(".").map(Number);
65440
65572
  const pb = b.split(".").map(Number);
@@ -65899,7 +66031,7 @@ function readInstanceUrl(deps2) {
65899
66031
 
65900
66032
  // src/steps/claude-sessions.ts
65901
66033
  import { readFileSync as readFileSync38 } from "node:fs";
65902
- import { join as join45 } from "node:path";
66034
+ import { join as join46 } from "node:path";
65903
66035
  var UNBOUND_EVENT = "mcp_proof_unbound";
65904
66036
  var DAY_MS2 = 864e5;
65905
66037
  function hubOrigin(hub) {
@@ -65931,7 +66063,7 @@ function helperFailures(ctx) {
65931
66063
  const out = /* @__PURE__ */ new Map();
65932
66064
  let text3;
65933
66065
  try {
65934
- text3 = readFileSync38(join45(ctx.home, "logs", "events.log"), "utf8");
66066
+ text3 = readFileSync38(join46(ctx.home, "logs", "events.log"), "utf8");
65935
66067
  } catch {
65936
66068
  return out;
65937
66069
  }
@@ -65977,7 +66109,7 @@ function entryApplies(ctx, origin, cwd) {
65977
66109
  const p = isObj2(doc.projects) ? doc.projects[cwd] : void 0;
65978
66110
  if (isObj2(p) && matching(p.mcpServers, origin).length > 0) return true;
65979
66111
  }
65980
- const proj = read(join45(cwd, ".mcp.json"));
66112
+ const proj = read(join46(cwd, ".mcp.json"));
65981
66113
  return isObj2(proj) && matching(proj.mcpServers, origin).length > 0;
65982
66114
  }
65983
66115
  function sessionChecks(ctx, st, hub) {
@@ -66059,7 +66191,7 @@ var sseCheck = (ctx, name) => ({
66059
66191
 
66060
66192
  // src/commands/habits.ts
66061
66193
  init_src();
66062
- import { join as join46 } from "node:path";
66194
+ import { join as join47 } from "node:path";
66063
66195
  var pluginOn = (p) => `Habits on in the ${p.label} plugin.`;
66064
66196
  var pluginOff = (p) => `Habits off in the ${p.label} plugin.`;
66065
66197
  var deps = (ctx) => ({
@@ -66178,7 +66310,7 @@ async function habitsAfterInstall(ctx, json4) {
66178
66310
  })),
66179
66311
  // A plugin has no block to compare: its marker is there ("current") or not.
66180
66312
  ...plugins2.map((p) => ({
66181
- path: join46(p.dir(ctx.userHome, ctx.env), p.marker),
66313
+ path: join47(p.dir(ctx.userHome, ctx.env), p.marker),
66182
66314
  label: `the ${p.label} plugin`,
66183
66315
  s: {
66184
66316
  state: pluginHabitsState(deps(ctx), p) === "on" ? "current" : "absent"
@@ -66223,7 +66355,7 @@ async function habitsAfterInstall(ctx, json4) {
66223
66355
  const pl = setPluginHabits(
66224
66356
  deps(ctx),
66225
66357
  plugins2.filter(
66226
- (p) => asked.includes(join46(p.dir(ctx.userHome, ctx.env), p.marker))
66358
+ (p) => asked.includes(join47(p.dir(ctx.userHome, ctx.env), p.marker))
66227
66359
  ),
66228
66360
  true
66229
66361
  );
@@ -66286,7 +66418,7 @@ function habitsLine(ctx) {
66286
66418
 
66287
66419
  // src/commands/namespace.ts
66288
66420
  import { realpathSync as realpathSync16, statSync as statSync11 } from "node:fs";
66289
- import { join as join47, resolve as resolve15 } from "node:path";
66421
+ import { join as join48, resolve as resolve15 } from "node:path";
66290
66422
  init_src();
66291
66423
  function shown3(ctx, path) {
66292
66424
  const t = tilde(ctx, path);
@@ -66357,7 +66489,7 @@ async function namespace(opts, ctx) {
66357
66489
  sayErr(ctx, c.nsNotDir(shown3(ctx, real3 ?? given)));
66358
66490
  return 1;
66359
66491
  }
66360
- const cfgFile = join47(real3, CONFIG_FILE);
66492
+ const cfgFile = join48(real3, CONFIG_FILE);
66361
66493
  const own2 = readOwnFile(cfgFile, process.getuid?.(), {
66362
66494
  allowGroupWrite: true
66363
66495
  });
@@ -66436,7 +66568,7 @@ init_src();
66436
66568
 
66437
66569
  // src/commands/install.ts
66438
66570
  init_src3();
66439
- import { dirname as dirname20, join as join49 } from "node:path";
66571
+ import { dirname as dirname21, join as join50 } from "node:path";
66440
66572
  init_src2();
66441
66573
 
66442
66574
  // src/live.ts
@@ -66493,15 +66625,15 @@ import {
66493
66625
  rmdirSync as rmdirSync4,
66494
66626
  rmSync as rmSync24
66495
66627
  } from "node:fs";
66496
- import { join as join48 } from "node:path";
66628
+ import { join as join49 } from "node:path";
66497
66629
  function leftoverTargets(deps2) {
66498
66630
  const env2 = deps2.env ?? {};
66499
66631
  const p = paths(deps2);
66500
- const piDir = agentDirEnv(deps2.home, env2) ?? join48(deps2.home, ".pi/agent");
66632
+ const piDir = agentDirEnv(deps2.home, env2) ?? join49(deps2.home, ".pi/agent");
66501
66633
  const skill2 = (h) => skillDir({ home: deps2.home, env: env2 }, h);
66502
66634
  return {
66503
66635
  files: [
66504
- join48(codexHome2(deps2.home, env2), "AGENTS.md"),
66636
+ join49(codexHome2(deps2.home, env2), "AGENTS.md"),
66505
66637
  p.codex,
66506
66638
  ...p.opencodeConfigs,
66507
66639
  p.opencodeCli
@@ -66510,10 +66642,10 @@ function leftoverTargets(deps2) {
66510
66642
  skill2("claude"),
66511
66643
  skill2("pi"),
66512
66644
  skill2("hermes"),
66513
- join48(hermesHome(deps2.home, env2), "plugins"),
66514
- join48(deps2.home, ".local", "bin"),
66515
- join48(ompAgentDir(deps2.home, env2), "extensions"),
66516
- join48(piDir, "extensions"),
66645
+ join49(hermesHome(deps2.home, env2), "plugins"),
66646
+ join49(deps2.home, ".local", "bin"),
66647
+ join49(ompAgentDir(deps2.home, env2), "extensions"),
66648
+ join49(piDir, "extensions"),
66517
66649
  skill2("opencode"),
66518
66650
  skill2("openclaw")
66519
66651
  ]
@@ -66658,7 +66790,7 @@ async function loginStep(ctx, opts) {
66658
66790
  ctx,
66659
66791
  c.approved(result.label),
66660
66792
  c.tokenSaved(
66661
- tilde(ctx, join49(ctx.home, "machine.json")),
66793
+ tilde(ctx, join50(ctx.home, "machine.json")),
66662
66794
  result.machineToken
66663
66795
  ),
66664
66796
  c.connected(originOf2(result.hub)),
@@ -66787,7 +66919,7 @@ function shownSocket(ctx) {
66787
66919
  const real3 = `${canonicalHome(ctx.home)}/`;
66788
66920
  return tilde(
66789
66921
  ctx,
66790
- path.startsWith(real3) ? join49(ctx.home, path.slice(real3.length)) : path
66922
+ path.startsWith(real3) ? join50(ctx.home, path.slice(real3.length)) : path
66791
66923
  );
66792
66924
  }
66793
66925
  async function waitForDaemon(ctx) {
@@ -66973,7 +67105,7 @@ function reportShim(ctx) {
66973
67105
  if (r.kind === "installed") {
66974
67106
  say(ctx, ctx.copy.shimInstalled(tilde(ctx, r.path)));
66975
67107
  if (!r.onPath && r.hint)
66976
- say(ctx, ctx.copy.shimNotOnPath(tilde(ctx, dirname20(r.path)), r.hint));
67108
+ say(ctx, ctx.copy.shimNotOnPath(tilde(ctx, dirname21(r.path)), r.hint));
66977
67109
  } else if (r.kind === "other-home")
66978
67110
  say(ctx, ctx.copy.shimOtherHome(tilde(ctx, r.path), tilde(ctx, r.home)));
66979
67111
  else if (r.kind === "foreign")
@@ -67039,7 +67171,7 @@ async function installRun(opts, realCtx2) {
67039
67171
  return results.every((r) => r.state === "done") ? 0 : 1;
67040
67172
  }
67041
67173
  const ok = await runSteps(steps, ctx, {
67042
- path: join49(ctx.home, "install.json"),
67174
+ path: join50(ctx.home, "install.json"),
67043
67175
  now: ctx.now
67044
67176
  });
67045
67177
  if (ok && second) say(ctx, "", c.secondBus(ctx.home));
@@ -67347,7 +67479,7 @@ async function doctor(ctx) {
67347
67479
  const node2 = ctx.nodeVersion.replace(/^v/, "");
67348
67480
  if (Number(node2.split(".")[0]) >= MIN_NODE) pass(c.nodeOk(node2));
67349
67481
  else fail3(c.nodeOld(node2));
67350
- const machineFile = tilde(ctx, join50(ctx.home, "machine.json"));
67482
+ const machineFile = tilde(ctx, join51(ctx.home, "machine.json"));
67351
67483
  const m = readMachine(ctx.home);
67352
67484
  if (m.state !== "ok") fail3(c.noCredentials(machineFile));
67353
67485
  else if (m.revoked) fail3(c.revokedCheck());
@@ -67436,8 +67568,8 @@ async function doctor(ctx) {
67436
67568
  pass(c.wired(h, version2));
67437
67569
  else fail3(c.notWired(h));
67438
67570
  if (h === "claude") {
67439
- const settings = join50(
67440
- ctx.env.CLAUDE_CONFIG_DIR ?? join50(ctx.userHome, ".claude"),
67571
+ const settings = join51(
67572
+ ctx.env.CLAUDE_CONFIG_DIR ?? join51(ctx.userHome, ".claude"),
67441
67573
  "settings.json"
67442
67574
  );
67443
67575
  const isolates = claudeIsolates(settings);
@@ -67632,11 +67764,11 @@ async function global(opts, ctx) {
67632
67764
 
67633
67765
  // src/commands/leads.ts
67634
67766
  import { readFileSync as readFileSync41 } from "node:fs";
67635
- import { join as join51 } from "node:path";
67767
+ import { join as join52 } from "node:path";
67636
67768
  function hubOrigin2(ctx) {
67637
67769
  try {
67638
67770
  const raw = JSON.parse(
67639
- readFileSync41(join51(ctx.home, "machine.json"), "utf8")
67771
+ readFileSync41(join52(ctx.home, "machine.json"), "utf8")
67640
67772
  );
67641
67773
  return typeof raw?.hub === "string" ? new URL(raw.hub).origin : void 0;
67642
67774
  } catch {
@@ -67830,7 +67962,7 @@ import {
67830
67962
  openSync as openSync11,
67831
67963
  readFileSync as readFileSync42
67832
67964
  } from "node:fs";
67833
- import { dirname as dirname21, join as join52 } from "node:path";
67965
+ import { dirname as dirname22, join as join53 } from "node:path";
67834
67966
  var TAIL = 50;
67835
67967
  var checkDir2 = (dir) => {
67836
67968
  let fd;
@@ -67864,7 +67996,7 @@ var tail = (path, dir) => {
67864
67996
  constants8.O_RDONLY | constants8.O_NOFOLLOW | constants8.O_NONBLOCK
67865
67997
  );
67866
67998
  if (!fstatSync6(fd).isFile()) return "skipped";
67867
- const after = lstatSync22(dirname21(path));
67999
+ const after = lstatSync22(dirname22(path));
67868
68000
  if (after.isSymbolicLink() || after.dev !== dir.dev || after.ino !== dir.ino)
67869
68001
  return "skipped";
67870
68002
  return readFileSync42(fd, "utf8").replace(/\n$/, "").split("\n").slice(-TAIL);
@@ -67875,9 +68007,9 @@ var tail = (path, dir) => {
67875
68007
  }
67876
68008
  };
67877
68009
  async function logs(ctx) {
67878
- const logDir = join52(ctx.home, "logs");
67879
- const path = join52(logDir, "daemon.log");
67880
- const eventsPath = join52(logDir, "events.log");
68010
+ const logDir = join53(ctx.home, "logs");
68011
+ const path = join53(logDir, "daemon.log");
68012
+ const eventsPath = join53(logDir, "events.log");
67881
68013
  const dir = checkDir2(logDir);
67882
68014
  if (!dir.ok && dir.why !== "missing") {
67883
68015
  say(ctx, `Not reading ${tilde(ctx, logDir)}: ${dir.why}.`);
@@ -67920,7 +68052,7 @@ init_src3();
67920
68052
  import { execFileSync as execFileSync8 } from "node:child_process";
67921
68053
  import { createHash as createHash12, randomBytes as randomBytes10 } from "node:crypto";
67922
68054
  import { readFileSync as readFileSync43, readlinkSync as readlinkSync7 } from "node:fs";
67923
- import { basename as basename10, join as join53 } from "node:path";
68055
+ import { basename as basename10, join as join54 } from "node:path";
67924
68056
  init_src2();
67925
68057
  init_src();
67926
68058
  var LOG_WAIT_MS = 300;
@@ -68016,7 +68148,7 @@ async function mcpProof(opts, ctx, deps2 = {
68016
68148
  say(ctx, JSON.stringify(headers));
68017
68149
  if (why2 !== void 0)
68018
68150
  try {
68019
- const events = createEventLog(join53(ctx.home, "logs", "events.log"));
68151
+ const events = createEventLog(join54(ctx.home, "logs", "events.log"));
68020
68152
  events(UNBOUND_EVENT, {
68021
68153
  reason: why2,
68022
68154
  ...detail !== void 0 ? { code: detail } : {}
@@ -68113,12 +68245,12 @@ async function skill(opts, ctx) {
68113
68245
  }
68114
68246
 
68115
68247
  // src/commands/uninstall.ts
68116
- import { join as join55 } from "node:path";
68248
+ import { join as join56 } from "node:path";
68117
68249
 
68118
68250
  // src/steps/purge.ts
68119
68251
  init_src3();
68120
68252
  import { lstatSync as lstatSync23, readdirSync as readdirSync15, rmdirSync as rmdirSync5, rmSync as rmSync25 } from "node:fs";
68121
- import { join as join54 } from "node:path";
68253
+ import { join as join55 } from "node:path";
68122
68254
  var FILES = [
68123
68255
  "machine.json",
68124
68256
  "install.json",
@@ -68188,14 +68320,14 @@ var rmdirIfEmpty = (path) => {
68188
68320
  };
68189
68321
  function purgeShort(dir, removed) {
68190
68322
  if (kind3(dir) !== "dir" || unsafeSocketDir(dir)) return;
68191
- const ret = join54(dir, "claude-return");
68323
+ const ret = join55(dir, "claude-return");
68192
68324
  for (const [d, ours2] of [
68193
68325
  [ret, (_n, p) => kind3(p) === "socket"],
68194
68326
  [dir, (n) => /^daemon\.sock(\.keep-\d+)?$/.test(n)]
68195
68327
  ]) {
68196
68328
  if (kind3(d) !== "dir") continue;
68197
68329
  for (const name of readdirSync15(d)) {
68198
- const path = join54(d, name);
68330
+ const path = join55(d, name);
68199
68331
  const k = kind3(path);
68200
68332
  if (k === void 0 || k === "dir" || !ours2(name, path)) continue;
68201
68333
  remove2(path, k);
@@ -68220,21 +68352,21 @@ function purge(home2, opts) {
68220
68352
  ...FILES,
68221
68353
  ...entries.filter((n) => TEMP.some((re) => re.test(n)))
68222
68354
  ]) {
68223
- const path = join54(home2, name);
68355
+ const path = join55(home2, name);
68224
68356
  const k = kind3(path);
68225
68357
  if (k === void 0 || k === "dir") continue;
68226
68358
  remove2(path, k);
68227
68359
  removed.push(name);
68228
68360
  }
68229
68361
  for (const folder of FOLDERS) {
68230
- const dir = join54(home2, folder.path);
68362
+ const dir = join55(home2, folder.path);
68231
68363
  if (kind3(dir) !== "dir") continue;
68232
68364
  for (const name of readdirSync15(dir)) {
68233
- const path = join54(dir, name);
68365
+ const path = join55(dir, name);
68234
68366
  const k = kind3(path);
68235
68367
  if (k === void 0 || !folder.ours(name, path)) continue;
68236
68368
  remove2(path, k);
68237
- removed.push(join54(folder.path, name));
68369
+ removed.push(join55(folder.path, name));
68238
68370
  }
68239
68371
  if (rmdirIfEmpty(dir)) removed.push(folder.path);
68240
68372
  }
@@ -68325,7 +68457,7 @@ async function unwire(ctx) {
68325
68457
  say(
68326
68458
  ctx,
68327
68459
  c.hermesNoCli(
68328
- tilde(ctx, join55(hermesHome(ctx.userHome, ctx.env), "config.yaml"))
68460
+ tilde(ctx, join56(hermesHome(ctx.userHome, ctx.env), "config.yaml"))
68329
68461
  )
68330
68462
  );
68331
68463
  if (r.openclawNoCli) say(ctx, c.openclawNoCli());
@@ -68359,7 +68491,7 @@ async function uninstall2(opts, ctx) {
68359
68491
  say(ctx, c.daemonStillRunning(removed.running));
68360
68492
  if (wiredTo(ctx)) await unwire(ctx);
68361
68493
  if (!opts.purge) {
68362
- say(ctx, "", c.kept(tilde(ctx, join55(ctx.home, "machine.json"))));
68494
+ say(ctx, "", c.kept(tilde(ctx, join56(ctx.home, "machine.json"))));
68363
68495
  return 0;
68364
68496
  }
68365
68497
  const home2 = tilde(ctx, ctx.home);
@@ -68369,9 +68501,9 @@ async function uninstall2(opts, ctx) {
68369
68501
  return 1;
68370
68502
  } catch {
68371
68503
  }
68372
- const made = readMade(join55(ctx.home, "install.json"));
68504
+ const made = readMade(join56(ctx.home, "install.json"));
68373
68505
  const out = purge(ctx.home, {
68374
- isDefault: ctx.home === join55(ctx.userHome, ".oa-bus")
68506
+ isDefault: ctx.home === join56(ctx.userHome, ".oa-bus")
68375
68507
  });
68376
68508
  if ("refused" in out) {
68377
68509
  sayErr(ctx, c.purgeRefused(home2));
@@ -68463,7 +68595,7 @@ import {
68463
68595
  rmSync as rmSync26,
68464
68596
  writeFileSync as writeFileSync21
68465
68597
  } from "node:fs";
68466
- import { join as join56 } from "node:path";
68598
+ import { join as join57 } from "node:path";
68467
68599
  var realUpgradeDeps = (ctx) => ({
68468
68600
  fetchRelease,
68469
68601
  verifyRelease,
@@ -68574,30 +68706,30 @@ async function upgrade(ctx, opts, deps2 = realUpgradeDeps(ctx)) {
68574
68706
  );
68575
68707
  return 1;
68576
68708
  }
68577
- const launcher = join56(ctx.home, "bin", "node");
68709
+ const launcher = join57(ctx.home, "bin", "node");
68578
68710
  let dest;
68579
68711
  try {
68580
68712
  dest = stage(ctx.home, target2, (dir) => {
68581
68713
  unpackTo(verified2.entries, dir);
68582
- if (!existsSync20(join56(dir, "dist", "index.js")))
68714
+ if (!existsSync20(join57(dir, "dist", "index.js")))
68583
68715
  throw new Error("the release has no dist/index.js");
68584
68716
  if (existsSync20(launcher)) {
68585
- copyFileSync2(launcher, join56(dir, "node"));
68586
- chmodSync23(join56(dir, "node"), 448);
68717
+ copyFileSync2(launcher, join57(dir, "node"));
68718
+ chmodSync23(join57(dir, "node"), 448);
68587
68719
  }
68588
68720
  });
68589
68721
  } catch {
68590
68722
  sayErr(ctx, c.upgradeRefused(target2, "bad_tar"));
68591
68723
  return 1;
68592
68724
  }
68593
- const marker = join56(dest, ".live", String(process.pid));
68725
+ const marker = join57(dest, ".live", String(process.pid));
68594
68726
  try {
68595
- mkdirSync18(join56(dest, ".live"), { recursive: true, mode: 448 });
68727
+ mkdirSync18(join57(dest, ".live"), { recursive: true, mode: 448 });
68596
68728
  writeFileSync21(marker, "", { mode: 384 });
68597
68729
  } catch {
68598
68730
  }
68599
68731
  deps2.beforeInstall?.(dest);
68600
- const entry = join56(dest, "dist", "index.js");
68732
+ const entry = join57(dest, "dist", "index.js");
68601
68733
  if (!existsSync20(entry)) {
68602
68734
  sayErr(ctx, c.upgradeStaleStage(target2));
68603
68735
  return 1;