@open-artifacts/bus 0.249.1 → 0.251.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
@@ -32925,7 +32925,7 @@ var init_frames = __esm({
32925
32925
  late = { late: external_exports.array(external_exports.string().min(1)).optional() };
32926
32926
  isWellFormed2 = (s) => s.isWellFormed();
32927
32927
  WELL_FORMED = { message: "text is not well-formed unicode" };
32928
- CLIENT_VERSION = true ? "0.249.1" : "0.0.0";
32928
+ CLIENT_VERSION = true ? "0.251.0" : "0.0.0";
32929
32929
  clientVersion = {
32930
32930
  client_version: external_exports.string().min(1).max(64).optional()
32931
32931
  };
@@ -44225,7 +44225,7 @@ var init_proxy = __esm({
44225
44225
  // ../bus-adapter-opencode/src/session.ts
44226
44226
  import { execFile as execFile4 } from "node:child_process";
44227
44227
  import { isAbsolute as isAbsolute10 } from "node:path";
44228
- import { promisify as promisify2 } from "node:util";
44228
+ import { promisify } from "node:util";
44229
44229
  function directoryOf(s) {
44230
44230
  const loc = s.location;
44231
44231
  const dir = s.directory ?? loc?.directory;
@@ -44265,7 +44265,7 @@ var run3, opencodeApi, MAX_DEPTH, ROOTS;
44265
44265
  var init_session2 = __esm({
44266
44266
  "../bus-adapter-opencode/src/session.ts"() {
44267
44267
  "use strict";
44268
- run3 = promisify2(execFile4);
44268
+ run3 = promisify(execFile4);
44269
44269
  opencodeApi = async (op, params) => {
44270
44270
  const args = ["api", op];
44271
44271
  for (const [k, v] of Object.entries(params))
@@ -44688,13 +44688,13 @@ __export(codex_proxy_main_exports, {
44688
44688
  readTokenFile: () => readTokenFile,
44689
44689
  startCodexProxy: () => startCodexProxy
44690
44690
  });
44691
- import { readFileSync as readFileSync45 } from "node:fs";
44691
+ import { readFileSync as readFileSync46 } from "node:fs";
44692
44692
  import { homedir as homedir5 } from "node:os";
44693
44693
  function readTokenFile(path) {
44694
44694
  if (!path) return void 0;
44695
44695
  try {
44696
44696
  const p = path.startsWith("~/") ? `${homedir5()}${path.slice(1)}` : path;
44697
- return readFileSync45(p, "utf8").trim() || void 0;
44697
+ return readFileSync46(p, "utf8").trim() || void 0;
44698
44698
  } catch {
44699
44699
  return void 0;
44700
44700
  }
@@ -44744,13 +44744,13 @@ __export(proxy_main_exports, {
44744
44744
  readTokenFile: () => readTokenFile2,
44745
44745
  startProxy: () => startProxy
44746
44746
  });
44747
- import { readFileSync as readFileSync46 } from "node:fs";
44747
+ import { readFileSync as readFileSync47 } from "node:fs";
44748
44748
  import { homedir as homedir6 } from "node:os";
44749
44749
  function readTokenFile2(path) {
44750
44750
  if (!path) return void 0;
44751
44751
  try {
44752
44752
  const p = path.startsWith("~/") ? `${homedir6()}${path.slice(1)}` : path;
44753
- return readFileSync46(p, "utf8").trim() || void 0;
44753
+ return readFileSync47(p, "utf8").trim() || void 0;
44754
44754
  } catch {
44755
44755
  return void 0;
44756
44756
  }
@@ -44849,9 +44849,9 @@ import {
44849
44849
  lstatSync as lstatSync10,
44850
44850
  realpathSync as realpathSync10,
44851
44851
  unlinkSync as unlinkSync4,
44852
- writeFileSync as writeFileSync14
44852
+ writeFileSync as writeFileSync15
44853
44853
  } from "node:fs";
44854
- import { basename as basename7, isAbsolute as isAbsolute8, join as join28 } from "node:path";
44854
+ import { basename as basename7, isAbsolute as isAbsolute8, join as join29 } from "node:path";
44855
44855
 
44856
44856
  // ../bus-adapter-opencode/src/version.ts
44857
44857
  var MIN_PROMPT_ID_VERSION = "2.0.0";
@@ -51650,8 +51650,8 @@ var execSpawn = (timeoutMs, maxBuffer = 1024 * 1024) => (cmd, args) => new Promi
51650
51650
  }
51651
51651
  );
51652
51652
  });
51653
- var spawnExec = (spawn3) => async (cmd, args) => {
51654
- const r = await spawn3(cmd, args);
51653
+ var spawnExec = (spawn4) => async (cmd, args) => {
51654
+ const r = await spawn4(cmd, args);
51655
51655
  return { ...r, code: r.code ?? -1 };
51656
51656
  };
51657
51657
  var goneSession = (detail, ref) => /not ?found/i.test(detail) && (/session/i.test(detail) || detail.includes(ref));
@@ -54223,6 +54223,119 @@ function listLeadTemplateNames(h = home()) {
54223
54223
  return entries.filter((f) => f.endsWith(".json") && f !== "config.json").map((f) => f.slice(0, -".json".length)).sort();
54224
54224
  }
54225
54225
 
54226
+ // ../bus-daemon/src/skill-refresh.ts
54227
+ import { spawn } from "node:child_process";
54228
+ import { mkdirSync as mkdirSync10, renameSync as renameSync16, rmSync as rmSync12, writeFileSync as writeFileSync14 } from "node:fs";
54229
+ import { dirname as dirname13, join as join28 } from "node:path";
54230
+ var LANE_NAME_RE = /^[a-z0-9][a-z0-9_-]{0,62}$/;
54231
+ function readSkillVersion(file2) {
54232
+ const f = readOwnFile(file2, process.getuid?.(), { maxBytes: 1024 });
54233
+ if (f.state !== "ok") return void 0;
54234
+ const v = f.text.trim();
54235
+ return v || void 0;
54236
+ }
54237
+ function writeSkillVersion(file2, version2) {
54238
+ mkdirSync10(dirname13(file2), { recursive: true, mode: 448 });
54239
+ const tmp = `${file2}.${process.pid}.tmp`;
54240
+ rmSync12(tmp, { force: true });
54241
+ try {
54242
+ writeFileSync14(tmp, `${version2}
54243
+ `, { mode: 384, flag: "wx" });
54244
+ renameSync16(tmp, file2);
54245
+ } catch (e) {
54246
+ rmSync12(tmp, { force: true });
54247
+ throw e;
54248
+ }
54249
+ }
54250
+ var SKILL_VERSION_RE = /^[0-9A-Za-z][0-9A-Za-z.+-]{0,63}$/;
54251
+ var SKILL_REFRESH_DEADLINE_MS = 6e4;
54252
+ function runSkillCommand(execPath, entry, hub, deadlineMs = SKILL_REFRESH_DEADLINE_MS) {
54253
+ if (!entry) return Promise.resolve(1);
54254
+ return new Promise((resolve19) => {
54255
+ const child = spawn(
54256
+ execPath,
54257
+ [entry, "skill", "--refresh", "--instance", hub],
54258
+ {
54259
+ stdio: "ignore",
54260
+ shell: false,
54261
+ env: process.env
54262
+ }
54263
+ );
54264
+ let settled = false;
54265
+ const done = (code2) => {
54266
+ if (settled) return;
54267
+ settled = true;
54268
+ clearTimeout(timer);
54269
+ resolve19(code2);
54270
+ };
54271
+ const timer = setTimeout(() => {
54272
+ child.kill("SIGKILL");
54273
+ done(124);
54274
+ }, deadlineMs);
54275
+ timer.unref?.();
54276
+ child.once("error", () => done(1));
54277
+ child.once("exit", (code2) => done(code2 ?? 1));
54278
+ });
54279
+ }
54280
+ function createSkillRefresher(deps2) {
54281
+ let inFlight = false;
54282
+ const failed2 = /* @__PURE__ */ new Set();
54283
+ const refresh = async (serverVersion2) => {
54284
+ const version2 = serverVersion2?.trim();
54285
+ if (!version2 || !SKILL_VERSION_RE.test(version2) || inFlight) return;
54286
+ if (failed2.has(version2) || deps2.readStored() === version2) return;
54287
+ inFlight = true;
54288
+ try {
54289
+ const code2 = await deps2.run();
54290
+ if (code2 === 0) {
54291
+ deps2.writeStored(version2);
54292
+ } else {
54293
+ failed2.add(version2);
54294
+ deps2.log(
54295
+ `skill refresh failed (exit ${code2}) for instance version ${version2}`
54296
+ );
54297
+ }
54298
+ } catch (e) {
54299
+ failed2.add(version2);
54300
+ const msg = (e instanceof Error ? e.message : String(e)).split("").map(
54301
+ (ch) => ch.charCodeAt(0) < 32 || ch.charCodeAt(0) === 127 ? " " : ch
54302
+ ).join("").slice(0, 200);
54303
+ deps2.log(`skill refresh failed (${msg}) for instance version ${version2}`);
54304
+ } finally {
54305
+ inFlight = false;
54306
+ }
54307
+ };
54308
+ return { refresh };
54309
+ }
54310
+ function createLaneSkillRefresher(make) {
54311
+ const byName = /* @__PURE__ */ new Map();
54312
+ return {
54313
+ onHello: (lane, serverVersion2) => {
54314
+ if (!lane.main && !LANE_NAME_RE.test(lane.name)) return Promise.resolve();
54315
+ let r = byName.get(lane.name);
54316
+ if (!r) {
54317
+ r = make(lane);
54318
+ byName.set(lane.name, r);
54319
+ }
54320
+ return r.refresh(serverVersion2);
54321
+ }
54322
+ };
54323
+ }
54324
+ function defaultSkillRefresher(busHomeDir, log, entry) {
54325
+ return createLaneSkillRefresher((lane) => {
54326
+ const file2 = join28(
54327
+ busHomeDir,
54328
+ lane.main ? "skill-version" : `skill-version.${lane.name}`
54329
+ );
54330
+ return createSkillRefresher({
54331
+ readStored: () => readSkillVersion(file2),
54332
+ writeStored: (v) => writeSkillVersion(file2, v),
54333
+ run: () => runSkillCommand(process.execPath, entry, lane.hub),
54334
+ log: (m) => log(lane.main ? m : `${m} (${lane.name})`)
54335
+ });
54336
+ });
54337
+ }
54338
+
54226
54339
  // ../bus-daemon/src/index.ts
54227
54340
  var NOTICE_RETRY_MS = 3e4;
54228
54341
  var SWITCH_ACK_MS = 5e3;
@@ -54253,6 +54366,7 @@ var agentFields = (a, reason2) => ({
54253
54366
  async function runDaemon(deps2 = {}) {
54254
54367
  const cfg = deps2.config ?? readConfig();
54255
54368
  const log = deps2.log ?? ((msg) => console.error(`oa-bus: ${msg}`));
54369
+ const skillRefresh = deps2.skillRefresh;
54256
54370
  const debug = deps2.debug ?? process.env.OA_BUS_DEBUG === "1";
54257
54371
  const lanes = new Lanes();
54258
54372
  const main2 = new Lane(MAIN_INSTANCE, cfg);
@@ -54371,7 +54485,7 @@ async function runDaemon(deps2 = {}) {
54371
54485
  closed: agents.closedRefs().filter(mine)
54372
54486
  };
54373
54487
  };
54374
- const announcedFile = deps2.announcedFile ?? join28(home(), "announced.json");
54488
+ const announcedFile = deps2.announcedFile ?? join29(home(), "announced.json");
54375
54489
  let announcedWritten;
54376
54490
  const persistAnnounced = () => {
54377
54491
  const rows = agents.all().map((a) => ({
@@ -54510,7 +54624,7 @@ async function runDaemon(deps2 = {}) {
54510
54624
  within2 = new Set(configPaths(cwd));
54511
54625
  }
54512
54626
  const rr = gitRecordRoot(cwd);
54513
- if (rr) within2.add(join28(rr, ".git"));
54627
+ if (rr) within2.add(join29(rr, ".git"));
54514
54628
  }
54515
54629
  return [
54516
54630
  ...cwd !== void 0 ? notesFor(cwd) : [],
@@ -54549,13 +54663,13 @@ async function runDaemon(deps2 = {}) {
54549
54663
  procStart: cachedProcStart(cl.procStart ?? claudeProcStartOf, running),
54550
54664
  isRunning: running
54551
54665
  };
54552
- const linksFile = cl.linksFile ?? join28(home(), "claude-links.json");
54666
+ const linksFile = cl.linksFile ?? join29(home(), "claude-links.json");
54553
54667
  const sameProc = (pid, procStart) => running(pid) && claudeSessions.procStart(pid, procStart) === procStart;
54554
54668
  let saved = readClaudeLinks(linksFile, void 0, log).filter(
54555
54669
  (e) => sameProc(e.pid, e.procStart)
54556
54670
  );
54557
54671
  let linksWritten = JSON.stringify(saved);
54558
- const stashFile = cl.stashFile ?? join28(home(), "claude-stash.json");
54672
+ const stashFile = cl.stashFile ?? join29(home(), "claude-stash.json");
54559
54673
  const stashLoaded = readClaudeLinks(stashFile, void 0, log).filter(
54560
54674
  (e) => sameProc(e.pid, e.procStart)
54561
54675
  );
@@ -54665,7 +54779,7 @@ async function runDaemon(deps2 = {}) {
54665
54779
  log,
54666
54780
  promptIdSupported: () => promptIdSupported,
54667
54781
  uncertain: new HeldStore(
54668
- oc.uncertainFile ?? join28(home(), "opencode-uncertain.json")
54782
+ oc.uncertainFile ?? join29(home(), "opencode-uncertain.json")
54669
54783
  )
54670
54784
  });
54671
54785
  const codexIndexHome = cx.home ?? codexHome();
@@ -54675,7 +54789,7 @@ async function runDaemon(deps2 = {}) {
54675
54789
  });
54676
54790
  const codexTaken = new TakenWatch({
54677
54791
  home: codexIndexHome,
54678
- file: cx.takenFile ?? join28(home(), "codex-pending.json"),
54792
+ file: cx.takenFile ?? join29(home(), "codex-pending.json"),
54679
54793
  onTaken: (id, unsent) => sendCodexAck(id, unsent),
54680
54794
  log
54681
54795
  });
@@ -54700,7 +54814,7 @@ async function runDaemon(deps2 = {}) {
54700
54814
  },
54701
54815
  ackTimeoutMs: deps2.pi?.ackTimeoutMs
54702
54816
  });
54703
- const sent = new SentStore(deps2.sentFile ?? join28(home(), "sent.json"), {
54817
+ const sent = new SentStore(deps2.sentFile ?? join29(home(), "sent.json"), {
54704
54818
  log
54705
54819
  });
54706
54820
  const receipts = new Receipts(sent, { after: deps2.deliveredTimer });
@@ -54827,8 +54941,8 @@ async function runDaemon(deps2 = {}) {
54827
54941
  socketsDir: returnDir,
54828
54942
  // A deps.socketsDir is the caller's (tests); ours is re-checked before each bind.
54829
54943
  prepareDir: cl.socketsDir ? void 0 : (d) => prepareReturnDir(d),
54830
- heldFile: cl.heldFile ?? join28(home(), "claude-held.json"),
54831
- returnIndexFile: cl.returnIndexFile ?? (cl.heldFile ? cl.heldFile.replace(/(\.json)?$/, ".return.json") : join28(home(), "claude-return.json")),
54944
+ heldFile: cl.heldFile ?? join29(home(), "claude-held.json"),
54945
+ returnIndexFile: cl.returnIndexFile ?? (cl.heldFile ? cl.heldFile.replace(/(\.json)?$/, ".return.json") : join29(home(), "claude-return.json")),
54832
54946
  statusWindowMs: cl.statusWindowMs,
54833
54947
  injectTimeoutMs: cl.injectTimeoutMs,
54834
54948
  onLineHandled: cl.onLineHandled,
@@ -55048,7 +55162,7 @@ async function runDaemon(deps2 = {}) {
55048
55162
  }
55049
55163
  }
55050
55164
  };
55051
- const guestsFile = cl.guestsFile ?? join28(home(), "claude-guests.json");
55165
+ const guestsFile = cl.guestsFile ?? join29(home(), "claude-guests.json");
55052
55166
  const projectsDir = cl.projectsDir ?? claudeProjectsDir();
55053
55167
  const mcpConfigFile = cl.mcpConfigFile ?? claudeConfigFile();
55054
55168
  const GUEST_BODY_MAX = 1024;
@@ -55651,6 +55765,10 @@ async function runDaemon(deps2 = {}) {
55651
55765
  for (const g of guestSet.values())
55652
55766
  if (g.instance === lane.name) announceGuest(g);
55653
55767
  if (lane.main) ownerAwayUntil = frame.owner_away_until ?? void 0;
55768
+ void skillRefresh?.onHello(
55769
+ { name: lane.name, main: lane.main, hub: lane.cfg.hub },
55770
+ frame.server_version
55771
+ );
55654
55772
  if (lane.main && lane.runCap) {
55655
55773
  if (takesInstance()) {
55656
55774
  if (frame.run_version === null) updaterRef?.clearNamed();
@@ -55699,7 +55817,7 @@ async function runDaemon(deps2 = {}) {
55699
55817
  linkDown(lane);
55700
55818
  lane.hub.stop();
55701
55819
  try {
55702
- writeFileSync14(
55820
+ writeFileSync15(
55703
55821
  revokedMarkerFile(lane),
55704
55822
  revokedMarker(lane.cfg.machine_token),
55705
55823
  { mode: 384 }
@@ -55723,8 +55841,8 @@ async function runDaemon(deps2 = {}) {
55723
55841
  log(`this machine was revoked; run \`${BUS_CMD} install\``);
55724
55842
  process.exitCode = 1;
55725
55843
  try {
55726
- writeFileSync14(
55727
- deps2.revokedFile ?? join28(home(), "revoked"),
55844
+ writeFileSync15(
55845
+ deps2.revokedFile ?? join29(home(), "revoked"),
55728
55846
  revokedMarker(cfg.machine_token),
55729
55847
  { mode: 384 }
55730
55848
  );
@@ -55771,7 +55889,7 @@ async function runDaemon(deps2 = {}) {
55771
55889
  })
55772
55890
  );
55773
55891
  const laneFields = (lane) => lane.main ? void 0 : { instance: lane.name };
55774
- const revokedMarkerFile = (lane) => join28(instancesDir(deps2.instancesHome ?? home()), `${lane.name}.revoked`);
55892
+ const revokedMarkerFile = (lane) => join29(instancesDir(deps2.instancesHome ?? home()), `${lane.name}.revoked`);
55775
55893
  const linkDown = (lane) => {
55776
55894
  if (lane.ever) lane.droppedAt ??= Date.now();
55777
55895
  ev("hub_disconnect", laneFields(lane));
@@ -56383,7 +56501,7 @@ async function runDaemon(deps2 = {}) {
56383
56501
  deps2.onSocketLost?.();
56384
56502
  }, deps2.socketCheckMs ?? 6e4);
56385
56503
  socketWatch.unref();
56386
- const codexAgentsFile = cx.agentsFile ?? join28(home(), "codex-agents.json");
56504
+ const codexAgentsFile = cx.agentsFile ?? join29(home(), "codex-agents.json");
56387
56505
  let codexSaved;
56388
56506
  const restorePending = /* @__PURE__ */ new Map();
56389
56507
  const persistCodex = () => {
@@ -56512,7 +56630,7 @@ async function runDaemon(deps2 = {}) {
56512
56630
  };
56513
56631
  attempt2(readCodexAgents(codexAgentsFile), 0);
56514
56632
  };
56515
- const awayFile = cx.awayFile ?? join28(home(), "codex-away.json");
56633
+ const awayFile = cx.awayFile ?? join29(home(), "codex-away.json");
56516
56634
  const awayNow = deps2.bindingNow ?? Date.now;
56517
56635
  const HOUR = 36e5;
56518
56636
  const awayRows = new Map(
@@ -56550,7 +56668,7 @@ async function runDaemon(deps2 = {}) {
56550
56668
  }
56551
56669
  };
56552
56670
  const woken = new HeldStore(
56553
- cx.wokenFile ?? join28(home(), "codex-woken.json"),
56671
+ cx.wokenFile ?? join29(home(), "codex-woken.json"),
56554
56672
  { ttlMs: 7 * 24 * HOUR }
56555
56673
  );
56556
56674
  const wakeLogged = /* @__PURE__ */ new Set();
@@ -56912,11 +57030,11 @@ async function runDaemon(deps2 = {}) {
56912
57030
  // src/bus-cmd.ts
56913
57031
  init_src();
56914
57032
  import { existsSync as existsSync17 } from "node:fs";
56915
- import { join as join39 } from "node:path";
57033
+ import { join as join40 } from "node:path";
56916
57034
 
56917
57035
  // src/context.ts
56918
57036
  init_src3();
56919
- import { execFileSync as execFileSync7, spawn as spawn2 } from "node:child_process";
57037
+ import { execFileSync as execFileSync7, spawn as spawn3 } from "node:child_process";
56920
57038
  import { closeSync as closeSync10, openSync as openSync10, readFileSync as readFileSync24 } from "node:fs";
56921
57039
  import { homedir as homedir4, userInfo as userInfo2 } from "node:os";
56922
57040
  import { createInterface as createInterface3 } from "node:readline";
@@ -58092,12 +58210,11 @@ function copy(style, bus = BUS_CMD, approve) {
58092
58210
 
58093
58211
  // src/deps.ts
58094
58212
  init_src2();
58095
- import { execFile as execFile3, spawn } from "node:child_process";
58096
- import { promisify } from "node:util";
58213
+ import { execFile as execFile3, spawn as spawn2 } from "node:child_process";
58097
58214
  var browserCommand = (platform, url2) => platform === "darwin" ? { cmd: "open", args: [url2] } : platform === "win32" ? { cmd: "rundll32", args: ["url.dll,FileProtocolHandler", url2] } : { cmd: "xdg-open", args: [url2] };
58098
58215
  var openBrowser = (url2, launcher = browserCommand(process.platform, url2)) => new Promise((resolve19) => {
58099
58216
  try {
58100
- const child = spawn(launcher.cmd, launcher.args, {
58217
+ const child = spawn2(launcher.cmd, launcher.args, {
58101
58218
  stdio: "ignore",
58102
58219
  detached: true
58103
58220
  });
@@ -58118,29 +58235,53 @@ function guardServiceManager(cmd, args = [], env2 = process.env) {
58118
58235
  }
58119
58236
  var SYSTEM_TOOLS = /* @__PURE__ */ new Set(["launchctl", "systemctl"]);
58120
58237
  var resolveCmd = (cmd) => SYSTEM_TOOLS.has(cmd) ? systemTool(cmd) : cmd;
58121
- var makeExec = (timeoutMs) => async (cmd, args, opts) => {
58238
+ var makeExec = (timeoutMs) => (cmd, args, opts) => new Promise((resolve19) => {
58122
58239
  guardServiceManager(cmd, args);
58240
+ const ms = opts?.timeoutMs ?? timeoutMs;
58241
+ let timedOut = false;
58242
+ if (!Number.isInteger(ms) || ms < 0 || ms > Number.MAX_SAFE_INTEGER) {
58243
+ const e = Object.assign(
58244
+ new RangeError(
58245
+ `The value of "timeout" is out of range. It must be ${Number.isInteger(ms) ? ">= 0 && <= 9007199254740991" : "an integer"}. Received ${ms}`
58246
+ ),
58247
+ { code: "ERR_OUT_OF_RANGE" }
58248
+ );
58249
+ return resolve19({ code: 1, stdout: "", stderr: String(e) });
58250
+ }
58251
+ let child;
58123
58252
  try {
58124
- const run5 = promisify(execFile3)(resolveCmd(cmd), args, {
58125
- ...opts?.env ? { env: { ...process.env, ...opts.env } } : {},
58126
- maxBuffer: 8 * 1024 * 1024,
58127
- timeout: opts?.timeoutMs ?? timeoutMs,
58128
- killSignal: "SIGKILL"
58129
- });
58130
- run5.child.stdin?.on("error", () => {
58131
- });
58132
- run5.child.stdin?.end(opts?.input ?? "");
58133
- const r = await run5;
58134
- return { code: 0, stdout: r.stdout, stderr: r.stderr };
58253
+ child = execFile3(
58254
+ resolveCmd(cmd),
58255
+ args,
58256
+ {
58257
+ ...opts?.env ? { env: { ...process.env, ...opts.env } } : {},
58258
+ maxBuffer: 8 * 1024 * 1024,
58259
+ killSignal: "SIGKILL"
58260
+ },
58261
+ (e, stdout, stderr) => {
58262
+ clearTimeout(timer);
58263
+ if (!e) return resolve19({ code: 0, stdout, stderr });
58264
+ const err = e;
58265
+ resolve19({
58266
+ code: typeof err.code === "number" ? err.code : 1,
58267
+ stdout: stdout ?? "",
58268
+ stderr: timedOut ? `timed out after ${ms} ms` : stderr ?? String(e)
58269
+ });
58270
+ }
58271
+ );
58135
58272
  } catch (e) {
58136
- const err = e;
58137
- return {
58138
- code: typeof err.code === "number" ? err.code : 1,
58139
- stdout: err.stdout ?? "",
58140
- stderr: err.killed ? `timed out after ${opts?.timeoutMs ?? timeoutMs} ms` : err.stderr ?? String(e)
58141
- };
58273
+ return resolve19({ code: 1, stdout: "", stderr: String(e) });
58142
58274
  }
58143
- };
58275
+ const timer = ms > 0 ? setTimeout(() => {
58276
+ timedOut = true;
58277
+ child.stdout?.destroy();
58278
+ child.stderr?.destroy();
58279
+ child.kill("SIGKILL");
58280
+ }, ms) : void 0;
58281
+ child.stdin?.on("error", () => {
58282
+ });
58283
+ child.stdin?.end(opts?.input ?? "");
58284
+ });
58144
58285
  var realDeps = {
58145
58286
  fetch,
58146
58287
  print: (line) => console.log(line),
@@ -58157,21 +58298,21 @@ import {
58157
58298
  cpSync,
58158
58299
  existsSync as existsSync9,
58159
58300
  lstatSync as lstatSync12,
58160
- mkdirSync as mkdirSync12,
58301
+ mkdirSync as mkdirSync13,
58161
58302
  readdirSync as readdirSync9,
58162
58303
  readFileSync as readFileSync23,
58163
58304
  realpathSync as realpathSync11,
58164
- renameSync as renameSync18,
58165
- rmSync as rmSync13,
58166
- writeFileSync as writeFileSync17
58305
+ renameSync as renameSync19,
58306
+ rmSync as rmSync14,
58307
+ writeFileSync as writeFileSync18
58167
58308
  } from "node:fs";
58168
58309
  import { tmpdir } from "node:os";
58169
58310
  import {
58170
58311
  basename as basename8,
58171
58312
  delimiter as delimiter2,
58172
- dirname as dirname14,
58313
+ dirname as dirname15,
58173
58314
  isAbsolute as isAbsolute9,
58174
- join as join31,
58315
+ join as join32,
58175
58316
  relative as relative5,
58176
58317
  resolve as resolve6
58177
58318
  } from "node:path";
@@ -58179,7 +58320,7 @@ import { fileURLToPath } from "node:url";
58179
58320
 
58180
58321
  // src/steps/codex.ts
58181
58322
  import { lstatSync as lstatSync11, readFileSync as readFileSync21 } from "node:fs";
58182
- import { join as join29, resolve as resolve5 } from "node:path";
58323
+ import { join as join30, resolve as resolve5 } from "node:path";
58183
58324
 
58184
58325
  // ../../node_modules/.pnpm/smol-toml@1.9.1/node_modules/smol-toml/dist/error.js
58185
58326
  function getLineColFromPtr(string4, ptr) {
@@ -58941,12 +59082,12 @@ var HAS_WELLFORMED = !!"".isWellFormed;
58941
59082
 
58942
59083
  // src/steps/codex.ts
58943
59084
  var CODEX_ENTRY = "oa_bus";
58944
- var codexHome2 = (home2, env2) => env2.CODEX_HOME ? resolve5(env2.CODEX_HOME) : join29(home2, ".codex");
59085
+ var codexHome2 = (home2, env2) => env2.CODEX_HOME ? resolve5(env2.CODEX_HOME) : join30(home2, ".codex");
58945
59086
  function codexHomeEnv(home2, env2) {
58946
59087
  const dir = codexHome2(home2, env2);
58947
- return dir === join29(home2, ".codex") ? {} : { CODEX_HOME: dir };
59088
+ return dir === join30(home2, ".codex") ? {} : { CODEX_HOME: dir };
58948
59089
  }
58949
- var codexConfig = (home2, env2) => join29(codexHome2(home2, env2), "config.toml");
59090
+ var codexConfig = (home2, env2) => join30(codexHome2(home2, env2), "config.toml");
58950
59091
  function hasCodex(o) {
58951
59092
  if (o.which("codex")) return true;
58952
59093
  try {
@@ -58980,7 +59121,7 @@ function codexEntry(busBin, home2, busHome2) {
58980
59121
  return {
58981
59122
  command: busBin[0],
58982
59123
  args: [...busBin.slice(1), "mcp", "codex"],
58983
- ...ob === join29(home2, ".oa-bus") ? {} : { env: { OA_BUS_HOME: ob } },
59124
+ ...ob === join30(home2, ".oa-bus") ? {} : { env: { OA_BUS_HOME: ob } },
58984
59125
  default_tools_approval_mode: "approve"
58985
59126
  };
58986
59127
  }
@@ -59006,7 +59147,7 @@ function sandboxRisk(doc, home2, codexDir) {
59006
59147
  });
59007
59148
  const covers = (root) => {
59008
59149
  const r = resolve5(
59009
- root === "~" ? home2 : root.startsWith("~/") ? join29(home2, root.slice(2)) : root
59150
+ root === "~" ? home2 : root.startsWith("~/") ? join30(home2, root.slice(2)) : root
59010
59151
  );
59011
59152
  return r === "/" || codexDir === r || codexDir.startsWith(`${r}/`) || r.startsWith(`${codexDir}/`);
59012
59153
  };
@@ -59227,15 +59368,15 @@ async function readCodexVersion(o) {
59227
59368
  // src/steps/rescue.ts
59228
59369
  import {
59229
59370
  chmodSync as chmodSync16,
59230
- mkdirSync as mkdirSync10,
59231
- renameSync as renameSync16,
59232
- rmSync as rmSync12,
59233
- writeFileSync as writeFileSync15
59371
+ mkdirSync as mkdirSync11,
59372
+ renameSync as renameSync17,
59373
+ rmSync as rmSync13,
59374
+ writeFileSync as writeFileSync16
59234
59375
  } from "node:fs";
59235
- import { join as join30 } from "node:path";
59376
+ import { join as join31 } from "node:path";
59236
59377
  var RESCUE_VERSION = 1;
59237
59378
  var RESCUE_MAX_STARTS = 2;
59238
- var rescueOf = (home2) => join30(home2, "rescue");
59379
+ var rescueOf = (home2) => join31(home2, "rescue");
59239
59380
  function rescueShell() {
59240
59381
  return `#!/bin/sh
59241
59382
  # Written by oa-bus install, never by an update. Rescue shim ${RESCUE_VERSION}.
@@ -59337,16 +59478,16 @@ try {
59337
59478
  `;
59338
59479
  }
59339
59480
  function writeRescue(home2, launcher) {
59340
- mkdirSync10(home2, { recursive: true, mode: 448 });
59481
+ mkdirSync11(home2, { recursive: true, mode: 448 });
59341
59482
  const put2 = (name, text3) => {
59342
- const path = join30(home2, name);
59483
+ const path = join31(home2, name);
59343
59484
  const tmp = `${path}.${process.pid}.tmp`;
59344
59485
  try {
59345
- writeFileSync15(tmp, text3, { mode: 448 });
59486
+ writeFileSync16(tmp, text3, { mode: 448 });
59346
59487
  chmodSync16(tmp, 448);
59347
- renameSync16(tmp, path);
59488
+ renameSync17(tmp, path);
59348
59489
  } catch (e) {
59349
- rmSync12(tmp, { force: true });
59490
+ rmSync13(tmp, { force: true });
59350
59491
  throw e;
59351
59492
  }
59352
59493
  };
@@ -59358,12 +59499,12 @@ function writeRescue(home2, launcher) {
59358
59499
  // src/steps/step.ts
59359
59500
  import {
59360
59501
  chmodSync as chmodSync17,
59361
- mkdirSync as mkdirSync11,
59502
+ mkdirSync as mkdirSync12,
59362
59503
  readFileSync as readFileSync22,
59363
- renameSync as renameSync17,
59364
- writeFileSync as writeFileSync16
59504
+ renameSync as renameSync18,
59505
+ writeFileSync as writeFileSync17
59365
59506
  } from "node:fs";
59366
- import { dirname as dirname13 } from "node:path";
59507
+ import { dirname as dirname14 } from "node:path";
59367
59508
  function readInstallFile(path) {
59368
59509
  try {
59369
59510
  const v = JSON.parse(readFileSync22(path, "utf8"));
@@ -59375,12 +59516,12 @@ function readInstallFile(path) {
59375
59516
  }
59376
59517
  function updateInstallFile(path, patch) {
59377
59518
  const next = { ...readInstallFile(path), ...patch };
59378
- mkdirSync11(dirname13(path), { recursive: true, mode: 448 });
59519
+ mkdirSync12(dirname14(path), { recursive: true, mode: 448 });
59379
59520
  const tmp = `${path}.${process.pid}.tmp`;
59380
- writeFileSync16(tmp, `${JSON.stringify(next, null, 2)}
59521
+ writeFileSync17(tmp, `${JSON.stringify(next, null, 2)}
59381
59522
  `, { mode: 384 });
59382
59523
  chmodSync17(tmp, 384);
59383
- renameSync17(tmp, path);
59524
+ renameSync18(tmp, path);
59384
59525
  }
59385
59526
  async function runSteps(steps, ctx, record7) {
59386
59527
  for (const step2 of steps) {
@@ -59426,7 +59567,7 @@ function servicePath(env2, execPath, platform) {
59426
59567
  "/bin"
59427
59568
  ];
59428
59569
  const mine = (env2.PATH ?? "").split(delimiter2).filter((d) => isAbsolute9(d) && !transient(d));
59429
- const node2 = dirname14(execPath);
59570
+ const node2 = dirname15(execPath);
59430
59571
  if (!mine.includes(node2) && isAbsolute9(node2) && !transient(node2))
59431
59572
  mine.unshift(node2);
59432
59573
  return [.../* @__PURE__ */ new Set([...mine, ...system])].join(delimiter2);
@@ -59493,7 +59634,7 @@ function cliSource() {
59493
59634
  jiti: import.meta.resolve("jiti")
59494
59635
  } : { kind: "bundle", file: here };
59495
59636
  }
59496
- var entryName = (src) => src.kind === "bundle" ? join31(basename8(dirname14(src.file)), basename8(src.file)) : "oa-bus.js";
59637
+ var entryName = (src) => src.kind === "bundle" ? join32(basename8(dirname15(src.file)), basename8(src.file)) : "oa-bus.js";
59497
59638
  var shim = (src) => `// Written by oa-bus install: runs the sources it was installed from.
59498
59639
  import { createJiti } from ${JSON.stringify(src.jiti)};
59499
59640
 
@@ -59548,12 +59689,12 @@ echo "oa-bus: Node.js ${MIN_NODE} or newer not found. Install it, then run: $her
59548
59689
  exit 127
59549
59690
  `;
59550
59691
  }
59551
- var launcherOf = (home2) => join31(home2, "bin", "node");
59692
+ var launcherOf = (home2) => join32(home2, "bin", "node");
59552
59693
  function versionOf(src) {
59553
59694
  if (src.kind === "dev") return "dev";
59554
59695
  try {
59555
59696
  const j = JSON.parse(
59556
- readFileSync23(join31(dirname14(dirname14(src.file)), "package.json"), "utf8")
59697
+ readFileSync23(join32(dirname15(dirname15(src.file)), "package.json"), "utf8")
59557
59698
  );
59558
59699
  if (isSafeVersion(j?.version)) return j.version;
59559
59700
  } catch {
@@ -59561,32 +59702,32 @@ function versionOf(src) {
59561
59702
  return `unknown-${Date.now()}`;
59562
59703
  }
59563
59704
  function installCli(home2, src, node2) {
59564
- mkdirSync12(home2, { recursive: true, mode: 448 });
59705
+ mkdirSync13(home2, { recursive: true, mode: 448 });
59565
59706
  chmodSync18(home2, 448);
59566
59707
  installVersion(
59567
59708
  home2,
59568
59709
  versionOf(src),
59569
59710
  (tmp) => {
59570
59711
  if (src.kind === "bundle") {
59571
- const pkg = dirname14(dirname14(src.file));
59712
+ const pkg = dirname15(dirname15(src.file));
59572
59713
  for (const name of ["dist", "assets", "package.json"])
59573
- if (existsSync9(join31(pkg, name)))
59574
- cpSync(join31(pkg, name), join31(tmp, name), { recursive: true });
59575
- } else writeFileSync17(join31(tmp, entryName(src)), shim(src));
59714
+ if (existsSync9(join32(pkg, name)))
59715
+ cpSync(join32(pkg, name), join32(tmp, name), { recursive: true });
59716
+ } else writeFileSync18(join32(tmp, entryName(src)), shim(src));
59576
59717
  chmodSync18(tmp, 448);
59577
59718
  if (node2 !== void 0) {
59578
- writeFileSync17(join31(tmp, "node"), launcherText(node2), { mode: 448 });
59579
- chmodSync18(join31(tmp, "node"), 448);
59719
+ writeFileSync18(join32(tmp, "node"), launcherText(node2), { mode: 448 });
59720
+ chmodSync18(join32(tmp, "node"), 448);
59580
59721
  }
59581
- if (!existsSync9(join31(tmp, "package.json")))
59582
- writeFileSync17(join31(tmp, "package.json"), '{ "type": "module" }\n');
59722
+ if (!existsSync9(join32(tmp, "package.json")))
59723
+ writeFileSync18(join32(tmp, "package.json"), '{ "type": "module" }\n');
59583
59724
  },
59584
59725
  // Without the rescue shim (win32, or no launcher) a failed update could
59585
59726
  // not be undone: such an install never arms auto-update (#2552).
59586
59727
  { arm: node2 !== void 0 && process.platform !== "win32" }
59587
59728
  );
59588
59729
  if (node2 !== void 0) writeRescue(home2, launcherText(node2));
59589
- return join31(home2, "bin", entryName(src));
59730
+ return join32(home2, "bin", entryName(src));
59590
59731
  }
59591
59732
  var present = (path) => {
59592
59733
  try {
@@ -59597,13 +59738,13 @@ var present = (path) => {
59597
59738
  }
59598
59739
  };
59599
59740
  function writeReplacing(path, text3) {
59600
- mkdirSync12(dirname14(path), { recursive: true });
59741
+ mkdirSync13(dirname15(path), { recursive: true });
59601
59742
  const tmp = `${path}.${process.pid}.tmp`;
59602
59743
  try {
59603
- writeFileSync17(tmp, text3, { mode: 420 });
59604
- renameSync18(tmp, path);
59744
+ writeFileSync18(tmp, text3, { mode: 420 });
59745
+ renameSync19(tmp, path);
59605
59746
  } catch (e) {
59606
- rmSync13(tmp, { force: true });
59747
+ rmSync14(tmp, { force: true });
59607
59748
  throw e;
59608
59749
  }
59609
59750
  }
@@ -59612,11 +59753,11 @@ var real = (path, native = false) => {
59612
59753
  try {
59613
59754
  return (native ? realpathSync11.native : realpathSync11)(abs);
59614
59755
  } catch {
59615
- const parent = dirname14(abs);
59616
- return parent === abs ? abs : join31(real(parent, native), basename8(abs));
59756
+ const parent = dirname15(abs);
59757
+ return parent === abs ? abs : join32(real(parent, native), basename8(abs));
59617
59758
  }
59618
59759
  };
59619
- var isDefaultHome2 = (home2, userHome) => real(home2) === real(join31(userHome, ".oa-bus"));
59760
+ var isDefaultHome2 = (home2, userHome) => real(home2) === real(join32(userHome, ".oa-bus"));
59620
59761
  function serviceNames(home2, userHome) {
59621
59762
  const suffix = isDefaultHome2(home2, userHome) ? "" : createHash9("sha256").update(real(home2)).digest("hex").slice(0, 8);
59622
59763
  return {
@@ -59645,16 +59786,16 @@ function systemService(d) {
59645
59786
  const names2 = () => serviceNames(home2(), d.userHome);
59646
59787
  const launcherNode = () => d.platform === "win32" ? void 0 : d.execPath;
59647
59788
  const nodeOf = (h) => d.platform === "win32" ? d.execPath : launcherOf(h);
59648
- const entryOf = () => join31(home2(), "bin", entryName(d.source()));
59649
- const installFile3 = () => join31(home2(), "install.json");
59789
+ const entryOf = () => join32(home2(), "bin", entryName(d.source()));
59790
+ const installFile3 = () => join32(home2(), "install.json");
59650
59791
  const record7 = () => {
59651
59792
  const r = readInstallFile(installFile3()).service;
59652
59793
  return typeof r === "object" && r !== null ? r : {};
59653
59794
  };
59654
59795
  const xdg = d.env.XDG_CONFIG_HOME;
59655
- const configHome = xdg && isAbsolute9(xdg) ? xdg : join31(d.userHome, ".config");
59796
+ const configHome = xdg && isAbsolute9(xdg) ? xdg : join32(d.userHome, ".config");
59656
59797
  const fileName = () => manager === "launchd" ? `${names2().label}.plist` : names2().unit;
59657
- const fresh = () => manager === "launchd" ? join31(d.userHome, "Library/LaunchAgents", fileName()) : join31(configHome, "systemd/user", fileName());
59798
+ const fresh = () => manager === "launchd" ? join32(d.userHome, "Library/LaunchAgents", fileName()) : join32(configHome, "systemd/user", fileName());
59658
59799
  const recorded = () => {
59659
59800
  const r = record7().unit;
59660
59801
  return typeof r === "string" && isAbsolute9(r) && basename8(r) === fileName() ? r : void 0;
@@ -59709,7 +59850,7 @@ function systemService(d) {
59709
59850
  return "started";
59710
59851
  await d.sleep(1e3);
59711
59852
  }
59712
- rmSync13(f, { force: true });
59853
+ rmSync14(f, { force: true });
59713
59854
  return "failed";
59714
59855
  }
59715
59856
  async function startSystemd(f, u) {
@@ -59723,7 +59864,7 @@ function systemService(d) {
59723
59864
  ]) {
59724
59865
  if ((await systemctl(...args)).code === 0) continue;
59725
59866
  if (args[0] !== "daemon-reload") await systemctl("disable", unit);
59726
- rmSync13(f, { force: true });
59867
+ rmSync14(f, { force: true });
59727
59868
  if (args[0] !== "daemon-reload") await systemctl("daemon-reload");
59728
59869
  return "failed";
59729
59870
  }
@@ -59750,10 +59891,10 @@ function systemService(d) {
59750
59891
  }
59751
59892
  const h = home2();
59752
59893
  const src = d.source();
59753
- const logs2 = join31(h, "logs");
59894
+ const logs2 = join32(h, "logs");
59754
59895
  const u = {
59755
59896
  node: nodeOf(h),
59756
- entry: join31(h, "bin", entryName(src)),
59897
+ entry: join32(h, "bin", entryName(src)),
59757
59898
  env: {
59758
59899
  PATH: servicePath(d.env, d.execPath, d.platform),
59759
59900
  ...isDefaultHome2(h, d.userHome) ? {} : { OA_BUS_HOME: h },
@@ -59761,8 +59902,8 @@ function systemService(d) {
59761
59902
  ...codexHomeEnv(d.userHome, d.env)
59762
59903
  },
59763
59904
  // One file: the daemon logs to stderr, and `oa-bus logs` tails it.
59764
- out: join31(logs2, "daemon.log"),
59765
- err: join31(logs2, "daemon.log")
59905
+ out: join32(logs2, "daemon.log"),
59906
+ err: join32(logs2, "daemon.log")
59766
59907
  };
59767
59908
  const unit = {
59768
59909
  ...u,
@@ -59779,12 +59920,12 @@ function systemService(d) {
59779
59920
  const left = await stopDaemon(skipped !== void 0);
59780
59921
  if (left !== void 0) return { running: left };
59781
59922
  installCli(h, src, launcherNode());
59782
- mkdirSync12(logs2, { recursive: true, mode: 448 });
59923
+ mkdirSync13(logs2, { recursive: true, mode: 448 });
59783
59924
  const f = fresh();
59784
59925
  const old = recorded();
59785
59926
  if (!skipped && old && old !== f) {
59786
59927
  if (manager === "systemd") await systemctl("disable", names2().unit);
59787
- rmSync13(old, { force: true });
59928
+ rmSync14(old, { force: true });
59788
59929
  }
59789
59930
  const started = skipped ? "failed" : manager === "launchd" ? await startLaunchd(f, unit) : manager === "systemd" ? await startSystemd(f, unit) : "failed";
59790
59931
  if (started === "started") {
@@ -59829,7 +59970,7 @@ function systemService(d) {
59829
59970
  if (manager === "launchd")
59830
59971
  await d.exec("launchctl", ["bootout", `${domain2}/${label2}`]);
59831
59972
  else await systemctl("disable", "--now", unit);
59832
- rmSync13(f, { force: true });
59973
+ rmSync14(f, { force: true });
59833
59974
  if (manager === "systemd") await systemctl("daemon-reload");
59834
59975
  const left = await quiet();
59835
59976
  if (left !== void 0) return { unit: manager, running: left };
@@ -59898,7 +60039,7 @@ function systemService(d) {
59898
60039
  },
59899
60040
  others() {
59900
60041
  if (manager === void 0) return [];
59901
- const dir = dirname14(fresh());
60042
+ const dir = dirname15(fresh());
59902
60043
  const own2 = fileName();
59903
60044
  const re = manager === "launchd" ? /^com\.open-artifacts\.bus\.[0-9a-f]{8}\.plist$/ : /^oa-bus-[0-9a-f]{8}\.service$/;
59904
60045
  try {
@@ -59913,7 +60054,7 @@ function systemService(d) {
59913
60054
  const node2 = record7().node;
59914
60055
  if (typeof node2 === "string" && !existsSync9(node2))
59915
60056
  out.push({ kind: "node-missing", node: node2 });
59916
- if (manager === "systemd" && !existsSync9(join31(d.lingerDir ?? "/var/lib/systemd/linger", d.user)))
60057
+ if (manager === "systemd" && !existsSync9(join32(d.lingerDir ?? "/var/lib/systemd/linger", d.user)))
59917
60058
  out.push({ kind: "linger-off" });
59918
60059
  if (d.platform !== "win32" && unitRunsRescue()) {
59919
60060
  const r = rescueOf(home2());
@@ -59940,7 +60081,7 @@ var noService = {
59940
60081
  remove: async () => ({}),
59941
60082
  cli: () => ["oa-bus"]
59942
60083
  };
59943
- var VERSION = true ? "0.249.1" : JSON.parse(
60084
+ var VERSION = true ? "0.251.0" : JSON.parse(
59944
60085
  readFileSync24(new URL("../package.json", import.meta.url), "utf8")
59945
60086
  ).version;
59946
60087
  var which = (cmd) => {
@@ -59972,7 +60113,7 @@ var spawnDaemon = (cmd, args, opts) => {
59972
60113
  const out = openSync10(opts.out, "a", 384);
59973
60114
  const err = openSync10(opts.err, "a", 384);
59974
60115
  try {
59975
- const child = spawn2(cmd, args, {
60116
+ const child = spawn3(cmd, args, {
59976
60117
  detached: true,
59977
60118
  stdio: ["ignore", out, err],
59978
60119
  env: { ...process.env, ...opts.env }
@@ -60123,15 +60264,15 @@ import {
60123
60264
  chmodSync as chmodSync20,
60124
60265
  existsSync as existsSync16,
60125
60266
  lstatSync as lstatSync17,
60126
- mkdirSync as mkdirSync15,
60267
+ mkdirSync as mkdirSync16,
60127
60268
  readFileSync as readFileSync32,
60128
60269
  readlinkSync as readlinkSync5,
60129
- renameSync as renameSync21,
60130
- rmSync as rmSync20,
60270
+ renameSync as renameSync22,
60271
+ rmSync as rmSync21,
60131
60272
  statSync as statSync9,
60132
- writeFileSync as writeFileSync20
60273
+ writeFileSync as writeFileSync21
60133
60274
  } from "node:fs";
60134
- import { dirname as dirname18, isAbsolute as isAbsolute14, join as join37, relative as relative7, resolve as resolve12 } from "node:path";
60275
+ import { dirname as dirname19, isAbsolute as isAbsolute14, join as join38, relative as relative7, resolve as resolve12 } from "node:path";
60135
60276
  import { isDeepStrictEqual } from "node:util";
60136
60277
 
60137
60278
  // ../bus-adapter-hermes/src/index.ts
@@ -61436,8 +61577,8 @@ var hostSlug = (host) => host.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(
61436
61577
  // src/steps/claude-proof.ts
61437
61578
  init_src3();
61438
61579
  import { existsSync as existsSync10, lstatSync as lstatSync13, readFileSync as readFileSync25 } from "node:fs";
61439
- import { join as join32, resolve as resolve7 } from "node:path";
61440
- var claudeConfigFile2 = (home2, env2) => join32(env2.CLAUDE_CONFIG_DIR ?? home2, ".claude.json");
61580
+ import { join as join33, resolve as resolve7 } from "node:path";
61581
+ var claudeConfigFile2 = (home2, env2) => join33(env2.CLAUDE_CONFIG_DIR ?? home2, ".claude.json");
61441
61582
  var PROOF_COMMAND = "mcp-proof";
61442
61583
  var PROOF_INSTANCE_FLAG = "--instance";
61443
61584
  var TOKEN_HELPER = /^T=\$\(cat (.+)\) && printf '\{"Authorization":"Bearer %s"\}' "\$T"$/;
@@ -61467,11 +61608,11 @@ function helperHome(helper) {
61467
61608
  }
61468
61609
  var ownedBy = (helper, busHome2) => helperHome(helper) === (busHome2 === void 0 ? void 0 : resolve7(busHome2));
61469
61610
  function busStopped(owner, userHome, opts = {}) {
61470
- const home2 = owner ?? join32(userHome, ".oa-bus");
61611
+ const home2 = owner ?? join33(userHome, ".oa-bus");
61471
61612
  try {
61472
61613
  if (!existsSync10(home2)) return true;
61473
61614
  if (existsSync10(daemonSocketPath(home2))) return false;
61474
- return !opts.retired || !existsSync10(join32(home2, "install.json"));
61615
+ return !opts.retired || !existsSync10(join33(home2, "install.json"));
61475
61616
  } catch {
61476
61617
  return false;
61477
61618
  }
@@ -61787,7 +61928,7 @@ function addInstanceProof(io, target2, busBin, busHome2, stopped) {
61787
61928
  // src/steps/codex-proof.ts
61788
61929
  init_src3();
61789
61930
  init_src();
61790
- import { existsSync as existsSync11, readFileSync as readFileSync26, rmSync as rmSync14 } from "node:fs";
61931
+ import { existsSync as existsSync11, readFileSync as readFileSync26, rmSync as rmSync15 } from "node:fs";
61791
61932
  import { isAbsolute as isAbsolute11 } from "node:path";
61792
61933
  var CODEX_MIN_VERSION = "0.123.0";
61793
61934
  var PROXY_CMD = "mcp-proxy";
@@ -62087,7 +62228,7 @@ ${m.lines.join("\n")}
62087
62228
  put2 = true;
62088
62229
  }
62089
62230
  }
62090
- rmSync14(io.moved, { force: true });
62231
+ rmSync15(io.moved, { force: true });
62091
62232
  return put2;
62092
62233
  }
62093
62234
  function linesOf(text3) {
@@ -62116,21 +62257,21 @@ import { createHash as createHash11, randomBytes as randomBytes7 } from "node:cr
62116
62257
  import {
62117
62258
  cpSync as cpSync2,
62118
62259
  lstatSync as lstatSync14,
62119
- mkdirSync as mkdirSync13,
62260
+ mkdirSync as mkdirSync14,
62120
62261
  readdirSync as readdirSync10,
62121
62262
  readFileSync as readFileSync27,
62122
62263
  readlinkSync as readlinkSync3,
62123
62264
  realpathSync as realpathSync12,
62124
- renameSync as renameSync19,
62265
+ renameSync as renameSync20,
62125
62266
  rmdirSync,
62126
- rmSync as rmSync15,
62127
- writeFileSync as writeFileSync18
62267
+ rmSync as rmSync16,
62268
+ writeFileSync as writeFileSync19
62128
62269
  } from "node:fs";
62129
62270
  import {
62130
62271
  basename as basename9,
62131
- dirname as dirname15,
62272
+ dirname as dirname16,
62132
62273
  isAbsolute as isAbsolute12,
62133
- join as join33,
62274
+ join as join34,
62134
62275
  relative as relative6,
62135
62276
  resolve as resolve8
62136
62277
  } from "node:path";
@@ -62145,9 +62286,9 @@ var real2 = (p) => {
62145
62286
  let cur = p;
62146
62287
  for (; ; ) {
62147
62288
  try {
62148
- return join33(realpathSync12(cur), ...rest.reverse());
62289
+ return join34(realpathSync12(cur), ...rest.reverse());
62149
62290
  } catch {
62150
- const up = dirname15(cur);
62291
+ const up = dirname16(cur);
62151
62292
  if (up === cur) return p;
62152
62293
  rest.push(basename9(cur));
62153
62294
  cur = up;
@@ -62175,7 +62316,7 @@ function sweepStaging(staging, own2, o = {}) {
62175
62316
  }
62176
62317
  for (const name of names2) {
62177
62318
  if (name === own2) continue;
62178
- const path = join33(staging, name);
62319
+ const path = join34(staging, name);
62179
62320
  let old;
62180
62321
  try {
62181
62322
  old = now - lstatSync14(path).mtimeMs > STAGING_STALE_MS;
@@ -62185,31 +62326,31 @@ function sweepStaging(staging, own2, o = {}) {
62185
62326
  const m = STAGE_NAME.exec(name);
62186
62327
  if (m ? old || !alive3(Number(m[1])) : old) {
62187
62328
  try {
62188
- rmSync15(path, { recursive: true, force: true });
62329
+ rmSync16(path, { recursive: true, force: true });
62189
62330
  } catch {
62190
62331
  }
62191
62332
  }
62192
62333
  }
62193
62334
  }
62194
62335
  var nativeHome = (home2, env2, platform) => {
62195
- if (platform !== "win32") return join33(home2, ".hermes");
62336
+ if (platform !== "win32") return join34(home2, ".hermes");
62196
62337
  const local = env2.LOCALAPPDATA?.trim();
62197
- return join33(local || join33(home2, "AppData", "Local"), "hermes");
62338
+ return join34(local || join34(home2, "AppData", "Local"), "hermes");
62198
62339
  };
62199
- var tilded = (home2, v) => v === "~" ? home2 : resolve8(v.startsWith("~/") ? join33(home2, v.slice(2)) : v);
62340
+ var tilded = (home2, v) => v === "~" ? home2 : resolve8(v.startsWith("~/") ? join34(home2, v.slice(2)) : v);
62200
62341
  function hermesHome(home2, env2, platform = process.platform) {
62201
62342
  const native = nativeHome(home2, env2, platform);
62202
62343
  const v = env2.HERMES_HOME?.trim();
62203
62344
  const given = v ? tilded(home2, v) : void 0;
62204
- if (given !== void 0 && basename9(dirname15(given)) === "profiles")
62345
+ if (given !== void 0 && basename9(dirname16(given)) === "profiles")
62205
62346
  return given;
62206
62347
  const base3 = given ?? native;
62207
62348
  const root = hermesRoot(home2, env2, platform);
62208
62349
  if (env2.HERMES_S6_SUPERVISED_CHILD) return base3;
62209
62350
  try {
62210
- const name = readFileSync27(join33(root, "active_profile"), "utf8").trim().toLowerCase();
62351
+ const name = readFileSync27(join34(root, "active_profile"), "utf8").trim().toLowerCase();
62211
62352
  if (name && name !== "default" && /^[a-z0-9][a-z0-9_-]{0,63}$/.test(name)) {
62212
- const dir = join33(root, "profiles", name);
62353
+ const dir = join34(root, "profiles", name);
62213
62354
  if (lstatSync14(dir).isDirectory()) return dir;
62214
62355
  }
62215
62356
  } catch {
@@ -62221,13 +62362,13 @@ function hermesRoot(home2, env2, platform = process.platform) {
62221
62362
  const v = env2.HERMES_HOME?.trim();
62222
62363
  const given = v ? tilded(home2, v) : void 0;
62223
62364
  if (given === void 0) return native;
62224
- if (basename9(dirname15(given)) === "profiles") return dirname15(dirname15(given));
62365
+ if (basename9(dirname16(given)) === "profiles") return dirname16(dirname16(given));
62225
62366
  const rel = relative6(real2(native), real2(given));
62226
62367
  if (rel === "" || !rel.startsWith("..") && !isAbsolute12(rel)) return native;
62227
62368
  return given;
62228
62369
  }
62229
62370
  function hermesProfilesScan(home2, env2, platform = process.platform) {
62230
- const path = join33(hermesRoot(home2, env2, platform), "profiles");
62371
+ const path = join34(hermesRoot(home2, env2, platform), "profiles");
62231
62372
  let isLink3 = false;
62232
62373
  try {
62233
62374
  isLink3 = lstatSync14(path).isSymbolicLink();
@@ -62238,7 +62379,7 @@ function hermesProfilesScan(home2, env2, platform = process.platform) {
62238
62379
  return realpathSync12(path);
62239
62380
  } catch {
62240
62381
  try {
62241
- return resolve8(dirname15(path), readlinkSync3(path));
62382
+ return resolve8(dirname16(path), readlinkSync3(path));
62242
62383
  } catch {
62243
62384
  return "somewhere else";
62244
62385
  }
@@ -62274,9 +62415,9 @@ function hermesProfilesScan(home2, env2, platform = process.platform) {
62274
62415
  }
62275
62416
  function hermesPluginDirs(home2, env2, platform = process.platform) {
62276
62417
  const root = hermesRoot(home2, env2, platform);
62277
- const out = [join33(root, "plugins", HERMES_PLUGIN_NAME)];
62418
+ const out = [join34(root, "plugins", HERMES_PLUGIN_NAME)];
62278
62419
  for (const name of hermesProfilesScan(home2, env2, platform).names)
62279
- out.push(join33(root, "profiles", name, "plugins", HERMES_PLUGIN_NAME));
62420
+ out.push(join34(root, "profiles", name, "plugins", HERMES_PLUGIN_NAME));
62280
62421
  const active = hermesPluginDir(home2, env2, platform);
62281
62422
  if (!out.includes(active)) out.push(active);
62282
62423
  return out;
@@ -62284,7 +62425,7 @@ function hermesPluginDirs(home2, env2, platform = process.platform) {
62284
62425
  var hermesEnv = (home2, env2, platform = process.platform) => ({
62285
62426
  HERMES_HOME: hermesHome(home2, env2, platform)
62286
62427
  });
62287
- var hermesPluginDir = (home2, env2, platform = process.platform) => join33(hermesHome(home2, env2, platform), "plugins", HERMES_PLUGIN_NAME);
62428
+ var hermesPluginDir = (home2, env2, platform = process.platform) => join34(hermesHome(home2, env2, platform), "plugins", HERMES_PLUGIN_NAME);
62288
62429
  var kind = (path) => {
62289
62430
  try {
62290
62431
  const st = lstatSync14(path);
@@ -62295,11 +62436,11 @@ var kind = (path) => {
62295
62436
  };
62296
62437
  function files(dir, rel = "") {
62297
62438
  const out = [];
62298
- for (const name of readdirSync10(join33(dir, rel)).sort()) {
62439
+ for (const name of readdirSync10(join34(dir, rel)).sort()) {
62299
62440
  if (name === "__pycache__" || name.startsWith(".") || name.endsWith(".pyc") || rel === "" && (name === HERMES_HABITS_MARKER || name === HERMES_ROOTS_FILE))
62300
62441
  continue;
62301
62442
  const r = rel ? `${rel}/${name}` : name;
62302
- if (kind(join33(dir, r)) === "dir") out.push(...files(dir, r));
62443
+ if (kind(join34(dir, r)) === "dir") out.push(...files(dir, r));
62303
62444
  else out.push(r);
62304
62445
  }
62305
62446
  return out;
@@ -62308,7 +62449,7 @@ function pluginHash(dir) {
62308
62449
  const h = createHash11("sha256");
62309
62450
  for (const f of files(dir)) {
62310
62451
  h.update(`${f}\0`);
62311
- h.update(readFileSync27(join33(dir, f)));
62452
+ h.update(readFileSync27(join34(dir, f)));
62312
62453
  h.update("\0");
62313
62454
  }
62314
62455
  return h.digest("hex").slice(0, 16);
@@ -62319,7 +62460,7 @@ function pluginState(dir, shipped) {
62319
62460
  if (k !== "dir") return "foreign";
62320
62461
  let marker;
62321
62462
  try {
62322
- marker = readFileSync27(join33(dir, HERMES_MARKER), "utf8").trim();
62463
+ marker = readFileSync27(join34(dir, HERMES_MARKER), "utf8").trim();
62323
62464
  } catch {
62324
62465
  return "foreign";
62325
62466
  }
@@ -62358,40 +62499,40 @@ async function installHermes(deps2) {
62358
62499
  `${dest} exists and is not Open Artifacts bus's; left it untouched`
62359
62500
  );
62360
62501
  if (state === "current") {
62361
- const marker = join33(dest, HERMES_HABITS_MARKER);
62502
+ const marker = join34(dest, HERMES_HABITS_MARKER);
62362
62503
  const mk = kind(marker);
62363
- if (mk === "file" || mk === "link") rmSync15(marker, { force: true });
62504
+ if (mk === "file" || mk === "link") rmSync16(marker, { force: true });
62364
62505
  } else {
62365
- const keepRoots = state === "stale" && kind(join33(dest, HERMES_ROOTS_FILE)) === "file" ? readFileSync27(join33(dest, HERMES_ROOTS_FILE)) : void 0;
62366
- const plugins2 = join33(dest, "..");
62367
- mkdirSync13(plugins2, { recursive: true });
62368
- const staging = join33(plugins2, "..", HERMES_STAGING);
62506
+ const keepRoots = state === "stale" && kind(join34(dest, HERMES_ROOTS_FILE)) === "file" ? readFileSync27(join34(dest, HERMES_ROOTS_FILE)) : void 0;
62507
+ const plugins2 = join34(dest, "..");
62508
+ mkdirSync14(plugins2, { recursive: true });
62509
+ const staging = join34(plugins2, "..", HERMES_STAGING);
62369
62510
  const own2 = `${process.pid}-${randomBytes7(4).toString("hex")}`;
62370
62511
  const st = lstatSync14(staging, { throwIfNoEntry: false });
62371
62512
  if (st !== void 0 && !st.isDirectory())
62372
62513
  throw new Error(
62373
62514
  `${staging} is not a plain folder; remove it and run the install again`
62374
62515
  );
62375
- mkdirSync13(staging, { recursive: true });
62516
+ mkdirSync14(staging, { recursive: true });
62376
62517
  sweepStaging(staging, own2, deps2.staging);
62377
- const tmp = join33(staging, own2);
62518
+ const tmp = join34(staging, own2);
62378
62519
  try {
62379
- mkdirSync13(tmp, { recursive: true });
62520
+ mkdirSync14(tmp, { recursive: true });
62380
62521
  for (const f of files(shipped)) {
62381
- mkdirSync13(join33(tmp, f, ".."), { recursive: true });
62382
- cpSync2(join33(shipped, f), join33(tmp, f));
62522
+ mkdirSync14(join34(tmp, f, ".."), { recursive: true });
62523
+ cpSync2(join34(shipped, f), join34(tmp, f));
62383
62524
  }
62384
- writeFileSync18(
62385
- join33(tmp, HERMES_MARKER),
62525
+ writeFileSync19(
62526
+ join34(tmp, HERMES_MARKER),
62386
62527
  `managed by the Open Artifacts bus installer: edits are replaced on reinstall. ${pluginHash(shipped)}
62387
62528
  `
62388
62529
  );
62389
62530
  if (keepRoots !== void 0)
62390
- writeFileSync18(join33(tmp, HERMES_ROOTS_FILE), keepRoots, { mode: 384 });
62391
- if (state === "stale") rmSync15(dest, { recursive: true, force: true });
62392
- renameSync19(tmp, dest);
62531
+ writeFileSync19(join34(tmp, HERMES_ROOTS_FILE), keepRoots, { mode: 384 });
62532
+ if (state === "stale") rmSync16(dest, { recursive: true, force: true });
62533
+ renameSync20(tmp, dest);
62393
62534
  } catch (e) {
62394
- rmSync15(tmp, { recursive: true, force: true });
62535
+ rmSync16(tmp, { recursive: true, force: true });
62395
62536
  throw e;
62396
62537
  } finally {
62397
62538
  try {
@@ -62426,7 +62567,7 @@ async function uninstallHermes(deps2, notes) {
62426
62567
  `\`hermes plugins disable ${HERMES_PLUGIN_NAME}\` failed (${firstLine(r.stderr) || firstLine(r.stdout) || `exit ${r.code}`}); left the plugin folder, rerun once Hermes works`
62427
62568
  );
62428
62569
  } else notes.push(HERMES_NO_CLI);
62429
- rmSync15(dest, { recursive: true, force: true });
62570
+ rmSync16(dest, { recursive: true, force: true });
62430
62571
  return "done";
62431
62572
  }
62432
62573
  async function hermesEnabled(deps2) {
@@ -62449,9 +62590,9 @@ import {
62449
62590
  readdirSync as readdirSync12,
62450
62591
  readFileSync as readFileSync29,
62451
62592
  realpathSync as realpathSync14,
62452
- rmSync as rmSync17
62593
+ rmSync as rmSync18
62453
62594
  } from "node:fs";
62454
- import { join as join35, resolve as resolve10 } from "node:path";
62595
+ import { join as join36, resolve as resolve10 } from "node:path";
62455
62596
  import { fileURLToPath as fileURLToPath5 } from "node:url";
62456
62597
 
62457
62598
  // src/steps/skill.ts
@@ -62459,24 +62600,24 @@ import {
62459
62600
  chmodSync as chmodSync19,
62460
62601
  existsSync as existsSync12,
62461
62602
  lstatSync as lstatSync15,
62462
- mkdirSync as mkdirSync14,
62603
+ mkdirSync as mkdirSync15,
62463
62604
  readdirSync as readdirSync11,
62464
62605
  readFileSync as readFileSync28,
62465
62606
  readlinkSync as readlinkSync4,
62466
62607
  realpathSync as realpathSync13,
62467
- renameSync as renameSync20,
62608
+ renameSync as renameSync21,
62468
62609
  rmdirSync as rmdirSync2,
62469
- rmSync as rmSync16,
62610
+ rmSync as rmSync17,
62470
62611
  statSync as statSync8,
62471
- writeFileSync as writeFileSync19
62612
+ writeFileSync as writeFileSync20
62472
62613
  } from "node:fs";
62473
- import { dirname as dirname16, join as join34, resolve as resolve9 } from "node:path";
62614
+ import { dirname as dirname17, join as join35, resolve as resolve9 } from "node:path";
62474
62615
  var SKILL_MARKER = "<!-- managed by the Open Artifacts bus installer: edits are replaced on reinstall. -->";
62475
62616
  var CODEX_BEGIN = "<!-- BEGIN Open Artifacts skill (managed): edits inside are replaced on reinstall. -->";
62476
62617
  var CODEX_END = "<!-- END Open Artifacts skill -->";
62477
62618
  var CODEX_SKILLS_MIN_VERSION = "0.76.0";
62478
62619
  var MAX_SKILL_BYTES = 256 * 1024;
62479
- var codexSkillFile = (deps2, folder) => join34(codexHome2(deps2.home, env(deps2)), "skills", folder, "SKILL.md");
62620
+ var codexSkillFile = (deps2, folder) => join35(codexHome2(deps2.home, env(deps2)), "skills", folder, "SKILL.md");
62480
62621
  var codexHasSkills = (version2) => version2 !== void 0 && (compareVersions(version2, CODEX_SKILLS_MIN_VERSION) ?? -1) >= 0;
62481
62622
  var blankLine = (l) => l?.replace(/\r$/, "") === "";
62482
62623
  var withoutCodexBlock = (text3) => {
@@ -62514,17 +62655,17 @@ var dropCodexBlock = (agentsPath, notes) => {
62514
62655
  var env = (deps2) => deps2.env ?? {};
62515
62656
  var skillDir = (deps2, h) => {
62516
62657
  const e = env(deps2);
62517
- const opencode = e.OPENCODE_CONFIG_DIR ?? join34(e.XDG_CONFIG_HOME ?? join34(deps2.home, ".config"), "opencode");
62518
- const agents = join34(deps2.home, ".agents", "skills");
62658
+ const opencode = e.OPENCODE_CONFIG_DIR ?? join35(e.XDG_CONFIG_HOME ?? join35(deps2.home, ".config"), "opencode");
62659
+ const agents = join35(deps2.home, ".agents", "skills");
62519
62660
  return {
62520
- claude: join34(e.CLAUDE_CONFIG_DIR ?? join34(deps2.home, ".claude"), "skills"),
62521
- opencode: join34(opencode, "skills"),
62661
+ claude: join35(e.CLAUDE_CONFIG_DIR ?? join35(deps2.home, ".claude"), "skills"),
62662
+ opencode: join35(opencode, "skills"),
62522
62663
  pi: agents,
62523
62664
  omp: agents,
62524
- codex: join34(codexHome2(deps2.home, e), "AGENTS.md"),
62525
- hermes: join34(hermesHome(deps2.home, e), "skills"),
62665
+ codex: join35(codexHome2(deps2.home, e), "AGENTS.md"),
62666
+ hermes: join35(hermesHome(deps2.home, e), "skills"),
62526
62667
  // OpenClaw's managed skills folder, in its state dir.
62527
- openclaw: join34(openclawStateDir(deps2.home, e), "skills")
62668
+ openclaw: join35(openclawStateDir(deps2.home, e), "skills")
62528
62669
  }[h];
62529
62670
  };
62530
62671
  var skillFolder = (text3) => {
@@ -62532,6 +62673,22 @@ var skillFolder = (text3) => {
62532
62673
  const name = m?.[1] ? /^name:\s*"?([^"\n]+)"?\s*$/m.exec(m[1])?.[1] : void 0;
62533
62674
  return name && /^[a-z0-9][a-z0-9-]{0,62}$/.test(name) ? name : void 0;
62534
62675
  };
62676
+ var skillVersion = (text3) => {
62677
+ const t = text3.replace(/\r\n/g, "\n");
62678
+ let src = t;
62679
+ const lines = t.split("\n");
62680
+ const start = lineIndex(lines, CODEX_BEGIN);
62681
+ if (start !== -1) {
62682
+ const end = lineIndex(lines, CODEX_END, start + 1);
62683
+ if (end !== -1) src = lines.slice(start + 1, end).join("\n");
62684
+ }
62685
+ const fm = /^---\n([\s\S]*?)\n---(?:\n|$)/.exec(src);
62686
+ if (!fm?.[1]) return void 0;
62687
+ const m = /^\s*version:\s*(.+?)\s*$/m.exec(fm[1]);
62688
+ if (!m?.[1]) return void 0;
62689
+ const v = m[1].replace(/^["']|["']$/g, "").trim();
62690
+ return v || void 0;
62691
+ };
62535
62692
  var withMarker = (text3) => {
62536
62693
  const end = text3.startsWith("---\n") ? text3.indexOf("\n---\n", 3) : -1;
62537
62694
  if (end === -1) return `${text3.trimEnd()}
@@ -62620,7 +62777,7 @@ var targetOf = (path) => {
62620
62777
  };
62621
62778
  var seq = 0;
62622
62779
  var writeAtomic = (path, text3) => {
62623
- mkdirSync14(dirname16(path), { recursive: true });
62780
+ mkdirSync15(dirname17(path), { recursive: true });
62624
62781
  const tmp = `${path}.oa-${process.pid}-${seq++}.tmp`;
62625
62782
  try {
62626
62783
  let mode;
@@ -62628,12 +62785,12 @@ var writeAtomic = (path, text3) => {
62628
62785
  mode = statSync8(path).mode & 4095;
62629
62786
  } catch {
62630
62787
  }
62631
- writeFileSync19(tmp, text3);
62788
+ writeFileSync20(tmp, text3);
62632
62789
  if (mode !== void 0) chmodSync19(tmp, mode);
62633
- renameSync20(tmp, path);
62790
+ renameSync21(tmp, path);
62634
62791
  } catch (e) {
62635
62792
  try {
62636
- rmSync16(tmp, { force: true });
62793
+ rmSync17(tmp, { force: true });
62637
62794
  } catch {
62638
62795
  }
62639
62796
  throw e;
@@ -62681,13 +62838,13 @@ var placesOf = (p) => {
62681
62838
  const out = [realOrResolved(p)];
62682
62839
  try {
62683
62840
  if (lstatSync15(p).isSymbolicLink())
62684
- out.push(realOrResolved(resolve9(dirname16(p), readlinkSync4(p))));
62841
+ out.push(realOrResolved(resolve9(dirname17(p), readlinkSync4(p))));
62685
62842
  } catch {
62686
62843
  }
62687
62844
  return out;
62688
62845
  };
62689
62846
  var codexSkillsShared = (deps2) => {
62690
- const mine = placesOf(dirname16(dirname16(codexSkillFile(deps2, "x"))));
62847
+ const mine = placesOf(dirname17(dirname17(codexSkillFile(deps2, "x"))));
62691
62848
  const theirs = placesOf(skillDir(deps2, "pi"));
62692
62849
  return mine.some((m) => theirs.includes(m));
62693
62850
  };
@@ -62771,9 +62928,9 @@ var installCodex = (deps2, folder, text3, written, notes) => {
62771
62928
  written.push(agentsPath);
62772
62929
  if (ourFile && !shared) {
62773
62930
  try {
62774
- rmSync16(targetOf(filePath), { force: true });
62931
+ rmSync17(targetOf(filePath), { force: true });
62775
62932
  try {
62776
- rmdirSync2(dirname16(filePath));
62933
+ rmdirSync2(dirname17(filePath));
62777
62934
  } catch {
62778
62935
  }
62779
62936
  } catch (e) {
@@ -62816,7 +62973,7 @@ async function installSkill(deps2, origin, harnesses) {
62816
62973
  continue;
62817
62974
  }
62818
62975
  const base3 = skillDir(deps2, h);
62819
- const path = join34(base3, folder, "SKILL.md");
62976
+ const path = join35(base3, folder, "SKILL.md");
62820
62977
  if (brokenLink(path)) {
62821
62978
  notes.push(`Left ${path} alone: it is a broken symlink.`);
62822
62979
  continue;
@@ -62864,8 +63021,8 @@ var uninstallSkill = (deps2, harnesses = [
62864
63021
  return;
62865
63022
  }
62866
63023
  for (const entry of entries) {
62867
- const dir = join34(base3, entry);
62868
- const file2 = join34(dir, "SKILL.md");
63024
+ const dir = join35(base3, entry);
63025
+ const file2 = join35(dir, "SKILL.md");
62869
63026
  try {
62870
63027
  const st = lstatSync15(dir);
62871
63028
  if (st.isSymbolicLink()) {
@@ -62880,7 +63037,7 @@ var uninstallSkill = (deps2, harnesses = [
62880
63037
  );
62881
63038
  continue;
62882
63039
  }
62883
- rmSync16(targetOf(file2), { force: true });
63040
+ rmSync17(targetOf(file2), { force: true });
62884
63041
  try {
62885
63042
  rmdirSync2(dir);
62886
63043
  } catch {
@@ -62901,7 +63058,7 @@ var uninstallSkill = (deps2, harnesses = [
62901
63058
  } catch (e) {
62902
63059
  fail3(base3, e);
62903
63060
  }
62904
- scan2(join34(dirname16(base3), "skills"));
63061
+ scan2(join35(dirname17(base3), "skills"));
62905
63062
  continue;
62906
63063
  }
62907
63064
  scan2(base3);
@@ -62913,9 +63070,9 @@ var codexSkillState = (deps2) => {
62913
63070
  shared: codexSkillsShared(deps2)
62914
63071
  };
62915
63072
  try {
62916
- const dir = join34(dirname16(skillDir(deps2, "codex")), "skills");
63073
+ const dir = join35(dirname17(skillDir(deps2, "codex")), "skills");
62917
63074
  for (const entry of readdirSync11(dir)) {
62918
- const file2 = join34(dir, entry, "SKILL.md");
63075
+ const file2 = join35(dir, entry, "SKILL.md");
62919
63076
  if (ourSkillFile(file2, entry)) {
62920
63077
  out.file = file2;
62921
63078
  break;
@@ -62945,7 +63102,7 @@ var savedSkill = (deps2, h, folder) => {
62945
63102
  return void 0;
62946
63103
  }
62947
63104
  for (const entry of entries) {
62948
- const file2 = join34(base3, entry, "SKILL.md");
63105
+ const file2 = join35(base3, entry, "SKILL.md");
62949
63106
  if (ourSkillFile(targetOf(file2), entry)) return file2;
62950
63107
  }
62951
63108
  return void 0;
@@ -62976,21 +63133,21 @@ function openclawStateDir(home2, env2) {
62976
63133
  return resolve10(
62977
63134
  override.startsWith("~") ? override.replace(/^~(?=$|[\\/])/, h) : override
62978
63135
  );
62979
- const next = join35(h, ".openclaw");
63136
+ const next = join36(h, ".openclaw");
62980
63137
  if (env2.OPENCLAW_TEST_FAST === "1" || existsSync13(next)) return next;
62981
- const legacy = join35(h, ".clawdbot");
63138
+ const legacy = join36(h, ".clawdbot");
62982
63139
  return existsSync13(legacy) ? legacy : next;
62983
63140
  }
62984
- var openclawPluginDir = (home2, env2) => join35(openclawStateDir(home2, env2), "extensions", OPENCLAW_PLUGIN_ID);
63141
+ var openclawPluginDir = (home2, env2) => join36(openclawStateDir(home2, env2), "extensions", OPENCLAW_PLUGIN_ID);
62985
63142
  function openclawPluginDirs(home2, env2) {
62986
63143
  const h = openclawHome(home2, env2);
62987
- const states = [join35(h, ".openclaw"), join35(h, ".clawdbot")];
63144
+ const states = [join36(h, ".openclaw"), join36(h, ".clawdbot")];
62988
63145
  try {
62989
63146
  for (const name of readdirSync12(h).sort())
62990
- if (name.startsWith(".openclaw-")) states.push(join35(h, name));
63147
+ if (name.startsWith(".openclaw-")) states.push(join36(h, name));
62991
63148
  } catch {
62992
63149
  }
62993
- const out = states.map((s) => join35(s, "extensions", OPENCLAW_PLUGIN_ID));
63150
+ const out = states.map((s) => join36(s, "extensions", OPENCLAW_PLUGIN_ID));
62994
63151
  const active = openclawPluginDir(home2, env2);
62995
63152
  if (!out.includes(active)) out.push(active);
62996
63153
  return out;
@@ -63010,7 +63167,7 @@ var kind2 = (path) => {
63010
63167
  var openclawManifestIsOurs = (dir) => {
63011
63168
  try {
63012
63169
  const m = JSON.parse(
63013
- readFileSync29(join35(dir, "openclaw.plugin.json"), "utf8")
63170
+ readFileSync29(join36(dir, "openclaw.plugin.json"), "utf8")
63014
63171
  );
63015
63172
  return m?.id === OPENCLAW_PLUGIN_ID;
63016
63173
  } catch {
@@ -63031,7 +63188,7 @@ function openclawPluginState(dir, shipped) {
63031
63188
  if (k !== "dir") return "foreign";
63032
63189
  let marker;
63033
63190
  try {
63034
- marker = readFileSync29(join35(dir, OPENCLAW_MARKER), "utf8").trim();
63191
+ marker = readFileSync29(join36(dir, OPENCLAW_MARKER), "utf8").trim();
63035
63192
  } catch {
63036
63193
  return sameAsShipped(dir, shipped) ? "stale" : "foreign";
63037
63194
  }
@@ -63044,7 +63201,7 @@ function openclawPluginState(dir, shipped) {
63044
63201
  return "stale";
63045
63202
  }
63046
63203
  }
63047
- var installFile2 = (deps2) => join35(deps2.busHome ?? join35(deps2.home, ".oa-bus"), "install.json");
63204
+ var installFile2 = (deps2) => join36(deps2.busHome ?? join36(deps2.home, ".oa-bus"), "install.json");
63048
63205
  var recordedStateDir = (deps2) => {
63049
63206
  const r = readInstallFile(installFile2(deps2)).openclaw;
63050
63207
  const d = r?.stateDir;
@@ -63122,7 +63279,7 @@ async function installOpenclaw(deps2, notes) {
63122
63279
  return "absent";
63123
63280
  }
63124
63281
  const shipped = deps2.assets.openclaw;
63125
- if (shipped === void 0 || !existsSync13(join35(shipped, "openclaw.plugin.json")))
63282
+ if (shipped === void 0 || !existsSync13(join36(shipped, "openclaw.plugin.json")))
63126
63283
  throw new Error("the OpenClaw plugin is missing from this install");
63127
63284
  const dest = openclawPluginDir(deps2.home, deps2.env ?? {});
63128
63285
  const state = openclawPluginState(dest, shipped);
@@ -63130,10 +63287,10 @@ async function installOpenclaw(deps2, notes) {
63130
63287
  throw new Error(
63131
63288
  `${dest} exists and is not Open Artifacts bus's; left it untouched`
63132
63289
  );
63133
- const habitsFile = join35(dest, OPENCLAW_HABITS_MARKER);
63290
+ const habitsFile = join36(dest, OPENCLAW_HABITS_MARKER);
63134
63291
  const dropLegacyHabitsMarker = () => {
63135
63292
  const mk = kind2(habitsFile);
63136
- if (mk === "file" || mk === "link") rmSync17(habitsFile, { force: true });
63293
+ if (mk === "file" || mk === "link") rmSync18(habitsFile, { force: true });
63137
63294
  };
63138
63295
  if (state === "current") {
63139
63296
  rememberInstall(deps2);
@@ -63157,7 +63314,7 @@ async function installOpenclaw(deps2, notes) {
63157
63314
  `\`openclaw plugins install\` finished, but ${dest} is not there`
63158
63315
  );
63159
63316
  writeAtomic(
63160
- join35(dest, OPENCLAW_MARKER),
63317
+ join36(dest, OPENCLAW_MARKER),
63161
63318
  `managed by the Open Artifacts bus installer: edits are replaced on reinstall. ${pluginHash(shipped)}
63162
63319
  `
63163
63320
  );
@@ -63211,7 +63368,7 @@ async function uninstallOpenclaw(deps2, notes) {
63211
63368
  `\`openclaw plugins uninstall ${OPENCLAW_PLUGIN_ID}\` failed (${why(r)}); left the plugin folder, rerun once OpenClaw works`
63212
63369
  );
63213
63370
  } else notes.push(OPENCLAW_NO_CLI);
63214
- rmSync17(dest, { recursive: true, force: true });
63371
+ rmSync18(dest, { recursive: true, force: true });
63215
63372
  forgetInstall(deps2);
63216
63373
  return "done";
63217
63374
  }
@@ -63226,8 +63383,8 @@ var OPENCLAW_PLUGIN = (() => {
63226
63383
  })();
63227
63384
 
63228
63385
  // src/steps/opencode-proof.ts
63229
- import { existsSync as existsSync14, readFileSync as readFileSync30, rmSync as rmSync18 } from "node:fs";
63230
- import { dirname as dirname17, isAbsolute as isAbsolute13, join as join36, resolve as resolve11 } from "node:path";
63386
+ import { existsSync as existsSync14, readFileSync as readFileSync30, rmSync as rmSync19 } from "node:fs";
63387
+ import { dirname as dirname18, isAbsolute as isAbsolute13, join as join37, resolve as resolve11 } from "node:path";
63231
63388
  init_src();
63232
63389
  var OPENCODE_ENTRY_FILE = "opencode-mcp-entry.json";
63233
63390
  var isRecord6 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
@@ -63269,8 +63426,8 @@ function tokenFileOf(e) {
63269
63426
  var REMOTE_ONLY = /* @__PURE__ */ new Set(["type", "url", "headers", "oauth"]);
63270
63427
  function resolveTokenFile(x, configFile, home2) {
63271
63428
  if (x === "~") return home2;
63272
- if (x.startsWith("~/")) return join36(home2, x.slice(2));
63273
- return isAbsolute13(x) ? x : resolve11(dirname17(configFile), x);
63429
+ if (x.startsWith("~/")) return join37(home2, x.slice(2));
63430
+ return isAbsolute13(x) ? x : resolve11(dirname18(configFile), x);
63274
63431
  }
63275
63432
  var proxyEntry = (io, origin, tokenFile, entry) => {
63276
63433
  const kept = Object.fromEntries(
@@ -63395,7 +63552,7 @@ function restoreEntry2(io) {
63395
63552
  put2 = true;
63396
63553
  }
63397
63554
  }
63398
- rmSync18(io.moved, { force: true });
63555
+ rmSync19(io.moved, { force: true });
63399
63556
  return put2;
63400
63557
  }
63401
63558
  function proxyProgramMissing2(entry, origin, which2) {
@@ -63440,7 +63597,7 @@ function skippedNotes(files2, read2, origin) {
63440
63597
  }
63441
63598
 
63442
63599
  // src/steps/pi-proof.ts
63443
- import { existsSync as existsSync15, readFileSync as readFileSync31, rmSync as rmSync19 } from "node:fs";
63600
+ import { existsSync as existsSync15, readFileSync as readFileSync31, rmSync as rmSync20 } from "node:fs";
63444
63601
  var PI_ENTRY_FILE = "pi-mcp-entry.json";
63445
63602
  var OMP_ORIGIN_FILE = "omp-mcp-origin.json";
63446
63603
  var PI_MIN_VERSION = "1.5.0";
@@ -63535,7 +63692,7 @@ function restoreEntry3(io) {
63535
63692
  );
63536
63693
  put2 = true;
63537
63694
  }
63538
- rmSync19(io.moved, { force: true });
63695
+ rmSync20(io.moved, { force: true });
63539
63696
  return put2;
63540
63697
  }
63541
63698
 
@@ -63554,7 +63711,7 @@ var HARNESSES = [
63554
63711
  ];
63555
63712
  var AGY_FLAG = "OA_BUS_EXPERIMENTAL_AGY";
63556
63713
  var agyOn = (env2) => env2?.[AGY_FLAG] === "1";
63557
- var hasAgy = (deps2) => deps2.which("agy") || present2(join37(deps2.home, ".gemini", "antigravity-cli")) || present2(join37(deps2.home, ".gemini", "antigravity"));
63714
+ var hasAgy = (deps2) => deps2.which("agy") || present2(join38(deps2.home, ".gemini", "antigravity-cli")) || present2(join38(deps2.home, ".gemini", "antigravity"));
63558
63715
  var agyServer = (busBin) => ({
63559
63716
  command: busBin[0],
63560
63717
  args: [...busBin.slice(1), "mcp", "antigravity"]
@@ -63570,47 +63727,47 @@ var readAssets = () => ({
63570
63727
  var movedHome = (deps2) => {
63571
63728
  if (deps2.busHome === void 0) return void 0;
63572
63729
  const ob = resolve12(deps2.busHome);
63573
- return ob === join37(deps2.home, ".oa-bus") ? void 0 : ob;
63730
+ return ob === join38(deps2.home, ".oa-bus") ? void 0 : ob;
63574
63731
  };
63575
63732
  var homeLine = (ob) => `process.env.OA_BUS_HOME ||= ${JSON.stringify(ob)};`;
63576
63733
  var withHome = (text3, ob) => ob === void 0 ? text3 : `${homeLine(ob)}
63577
63734
  ${text3}`;
63578
63735
  var paths = (deps2) => {
63579
63736
  const env2 = deps2.env ?? {};
63580
- const opencode = env2.OPENCODE_CONFIG_DIR ?? join37(env2.XDG_CONFIG_HOME ?? join37(deps2.home, ".config"), "opencode");
63581
- const busDir = deps2.busHome ?? join37(deps2.home, ".oa-bus");
63737
+ const opencode = env2.OPENCODE_CONFIG_DIR ?? join38(env2.XDG_CONFIG_HOME ?? join38(deps2.home, ".config"), "opencode");
63738
+ const busDir = deps2.busHome ?? join38(deps2.home, ".oa-bus");
63582
63739
  return {
63583
63740
  claude: claudeConfigFile2(deps2.home, env2),
63584
63741
  // OpenCode reads both; edit the one the user has, else create .json.
63585
63742
  opencodeConfigs: [
63586
- join37(opencode, "opencode.json"),
63587
- join37(opencode, "opencode.jsonc")
63743
+ join38(opencode, "opencode.json"),
63744
+ join38(opencode, "opencode.jsonc")
63588
63745
  ],
63589
- opencodeCli: join37(opencode, "cli.json"),
63590
- record: join37(busDir, "install.json"),
63746
+ opencodeCli: join38(opencode, "cli.json"),
63747
+ record: join38(busDir, "install.json"),
63591
63748
  // #1856: where install keeps the OpenCode entry it replaced with the proxy.
63592
- opencodeEntry: join37(busDir, OPENCODE_ENTRY_FILE),
63749
+ opencodeEntry: join38(busDir, OPENCODE_ENTRY_FILE),
63593
63750
  // #1856: Pi's own MCP config, and where install keeps the entry it moved.
63594
- piMcp: join37(
63595
- agentDirEnv(deps2.home, env2) ?? join37(deps2.home, ".pi/agent"),
63751
+ piMcp: join38(
63752
+ agentDirEnv(deps2.home, env2) ?? join38(deps2.home, ".pi/agent"),
63596
63753
  "mcp.json"
63597
63754
  ),
63598
- piEntry: join37(busDir, PI_ENTRY_FILE),
63599
- ompOrigin: join37(busDir, OMP_ORIGIN_FILE),
63755
+ piEntry: join38(busDir, PI_ENTRY_FILE),
63756
+ ompOrigin: join38(busDir, OMP_ORIGIN_FILE),
63600
63757
  // OpenCode registers the folder that holds tui.js.
63601
- opencodePlugin: join37(busDir, "integrations/opencode", NAME),
63602
- pi: join37(
63603
- agentDirEnv(deps2.home, env2) ?? join37(deps2.home, ".pi/agent"),
63758
+ opencodePlugin: join38(busDir, "integrations/opencode", NAME),
63759
+ pi: join38(
63760
+ agentDirEnv(deps2.home, env2) ?? join38(deps2.home, ".pi/agent"),
63604
63761
  "extensions/oa-bus.ts"
63605
63762
  ),
63606
- omp: join37(ompAgentDir(deps2.home, env2), "extensions/oa-bus.ts"),
63763
+ omp: join38(ompAgentDir(deps2.home, env2), "extensions/oa-bus.ts"),
63607
63764
  codex: codexConfig(deps2.home, env2),
63608
63765
  codexBin: codexBinFile(busDir),
63609
63766
  // #1856: where install keeps the Codex entry it swapped for the proxy.
63610
- codexEntry: join37(busDir, CODEX_PROXY_ENTRY_FILE),
63767
+ codexEntry: join38(busDir, CODEX_PROXY_ENTRY_FILE),
63611
63768
  // agy 1.5's user-level MCP config (`agy mcp add` writes it; the older
63612
63769
  // ~/.gemini/antigravity/mcp_config.json is the legacy path it migrated from).
63613
- agyMcp: join37(deps2.home, ".gemini", "config", "mcp_config.json"),
63770
+ agyMcp: join38(deps2.home, ".gemini", "config", "mcp_config.json"),
63614
63771
  busDir
63615
63772
  };
63616
63773
  };
@@ -63618,9 +63775,9 @@ function agentDirEnv(home2, env2) {
63618
63775
  const dir = env2.PI_CODING_AGENT_DIR;
63619
63776
  if (!dir) return void 0;
63620
63777
  if (dir === "~") return home2;
63621
- return resolve12(dir.startsWith("~/") ? join37(home2, dir.slice(2)) : dir);
63778
+ return resolve12(dir.startsWith("~/") ? join38(home2, dir.slice(2)) : dir);
63622
63779
  }
63623
- var ompRoot = (home2, env2) => join37(home2, env2.PI_CONFIG_DIR || ".omp");
63780
+ var ompRoot = (home2, env2) => join38(home2, env2.PI_CONFIG_DIR || ".omp");
63624
63781
  function ompProfile(env2) {
63625
63782
  const name = (env2.OMP_PROFILE !== void 0 ? env2.OMP_PROFILE : env2.PI_PROFILE)?.trim();
63626
63783
  if (!name || name === "default" || name.endsWith(".")) return void 0;
@@ -63629,14 +63786,14 @@ function ompProfile(env2) {
63629
63786
  function ompAgentDir(home2, env2) {
63630
63787
  const root = ompRoot(home2, env2);
63631
63788
  const profile = ompProfile(env2);
63632
- if (profile) return join37(root, "profiles", profile, "agent");
63789
+ if (profile) return join38(root, "profiles", profile, "agent");
63633
63790
  const piProfile = ompProfile({ PI_PROFILE: env2.PI_PROFILE });
63634
63791
  const dir = agentDirEnv(home2, env2);
63635
- if (dir && !(piProfile && dir === join37(root, "profiles", piProfile, "agent")))
63792
+ if (dir && !(piProfile && dir === join38(root, "profiles", piProfile, "agent")))
63636
63793
  return dir;
63637
- return join37(root, "agent");
63794
+ return join38(root, "agent");
63638
63795
  }
63639
- var hasOmp = (deps2) => deps2.which("omp") || present2(ompRoot(deps2.home, deps2.env ?? {})) || present2(join37(deps2.home, ".bun/bin/omp"));
63796
+ var hasOmp = (deps2) => deps2.which("omp") || present2(ompRoot(deps2.home, deps2.env ?? {})) || present2(join38(deps2.home, ".bun/bin/omp"));
63640
63797
  var sharedFile = (deps2) => paths(deps2).omp === paths(deps2).pi;
63641
63798
  function readDoc(path) {
63642
63799
  let text3;
@@ -63666,19 +63823,19 @@ function target(path) {
63666
63823
  let p = path;
63667
63824
  for (let hops = 0; hops < 40; hops++) {
63668
63825
  if (!present2(p) || !lstatSync17(p).isSymbolicLink()) {
63669
- if (p !== path && !existsSync16(dirname18(p)))
63826
+ if (p !== path && !existsSync16(dirname19(p)))
63670
63827
  throw new Error(
63671
63828
  `${path} is a dangling symlink to ${p}; left it untouched`
63672
63829
  );
63673
63830
  return p;
63674
63831
  }
63675
- p = resolve12(dirname18(p), readlinkSync5(p));
63832
+ p = resolve12(dirname19(p), readlinkSync5(p));
63676
63833
  }
63677
63834
  throw new Error(`${path}: too many symlinks; left it untouched`);
63678
63835
  }
63679
63836
  function writeAtomic2(path, data, mode) {
63680
63837
  const dest = target(path);
63681
- mkdirSync15(dirname18(dest), { recursive: true });
63838
+ mkdirSync16(dirname19(dest), { recursive: true });
63682
63839
  let m = mode ?? 420;
63683
63840
  if (mode === void 0)
63684
63841
  try {
@@ -63687,11 +63844,11 @@ function writeAtomic2(path, data, mode) {
63687
63844
  }
63688
63845
  const tmp = `${dest}.${process.pid}.${randomBytes8(4).toString("hex")}.tmp`;
63689
63846
  try {
63690
- writeFileSync20(tmp, data, { mode: m, flag: "wx" });
63847
+ writeFileSync21(tmp, data, { mode: m, flag: "wx" });
63691
63848
  chmodSync20(tmp, m);
63692
- renameSync21(tmp, dest);
63849
+ renameSync22(tmp, dest);
63693
63850
  } catch (e) {
63694
- rmSync20(tmp, { force: true });
63851
+ rmSync21(tmp, { force: true });
63695
63852
  throw e;
63696
63853
  }
63697
63854
  }
@@ -63787,7 +63944,7 @@ async function run4(deps2, cmd, args) {
63787
63944
  var stoppedBus = (deps2, retired) => (owner) => busStopped(owner, deps2.home, { retired });
63788
63945
  function instanceProofs(deps2, opts = {}) {
63789
63946
  const out = [];
63790
- const bus = deps2.busHome ?? join37(deps2.home, ".oa-bus");
63947
+ const bus = deps2.busHome ?? join38(deps2.home, ".oa-bus");
63791
63948
  const io = proofIo(deps2);
63792
63949
  for (const i of listInstances(bus)) {
63793
63950
  if (i.main || i.hub === "") continue;
@@ -63851,7 +64008,7 @@ var cxEntryIo = (deps2) => ({
63851
64008
  });
63852
64009
  var patTokenFile = (deps2) => {
63853
64010
  const host = deps2.hub === void 0 ? "" : new URL(deps2.hub).host;
63854
- return join37(deps2.home, ".open-artifacts", `${hostSlug(host)}-pat-token`);
64011
+ return join38(deps2.home, ".open-artifacts", `${hostSlug(host)}-pat-token`);
63855
64012
  };
63856
64013
  async function codexEntryStep(deps2, notes) {
63857
64014
  if (deps2.hub === void 0) return;
@@ -64056,7 +64213,7 @@ var install = {
64056
64213
  if (madeCli.length > 0)
64057
64214
  created[p.opencodeCli] = add2(p.opencodeCli, madeCli);
64058
64215
  writeRecord2(p.record, record7, created);
64059
- const pluginFile = join37(p.opencodePlugin, "tui.js");
64216
+ const pluginFile = join38(p.opencodePlugin, "tui.js");
64060
64217
  const pluginText = withHome(deps2.assets.opencodePlugin, movedHome(deps2));
64061
64218
  let pluginBefore;
64062
64219
  try {
@@ -64130,7 +64287,7 @@ var install = {
64130
64287
  }
64131
64288
  if (had !== pin) writeAtomic2(p.codexBin, pin, 384);
64132
64289
  } else {
64133
- rmSync20(p.codexBin, { force: true });
64290
+ rmSync21(p.codexBin, { force: true });
64134
64291
  notes.push(CODEX_NO_BIN);
64135
64292
  }
64136
64293
  await codexEntryStep(deps2, notes);
@@ -64227,7 +64384,7 @@ var uninstall = {
64227
64384
  for (const { file: file2 } of edits) delete left[file2];
64228
64385
  writeRecord2(p.record, record7, left);
64229
64386
  const hadPlugin = existsSync16(p.opencodePlugin);
64230
- rmSync20(p.opencodePlugin, { recursive: true, force: true });
64387
+ rmSync21(p.opencodePlugin, { recursive: true, force: true });
64231
64388
  if (!saved.some(Boolean) && !hadPlugin && !restored) return "none";
64232
64389
  if (deps2.which("opencode")) await restartOpencode(deps2, notes, true);
64233
64390
  return saved.some(Boolean) || restored ? "done" : "folder";
@@ -64245,16 +64402,16 @@ var uninstall = {
64245
64402
  }
64246
64403
  const path = paths(deps2).pi;
64247
64404
  if (!existsSync16(path)) return restored ? "done" : "none";
64248
- rmSync20(path, { force: true });
64405
+ rmSync21(path, { force: true });
64249
64406
  return "done";
64250
64407
  },
64251
64408
  async omp(deps2, _notes, done) {
64252
- rmSync20(paths(deps2).ompOrigin, { force: true });
64409
+ rmSync21(paths(deps2).ompOrigin, { force: true });
64253
64410
  if (sharedFile(deps2) && done.includes("pi")) return "done";
64254
64411
  if (sharedFile(deps2) && existsSync16(paths(deps2).piEntry)) return "none";
64255
64412
  const path = paths(deps2).omp;
64256
64413
  if (!existsSync16(path)) return "none";
64257
- rmSync20(path, { force: true });
64414
+ rmSync21(path, { force: true });
64258
64415
  return "done";
64259
64416
  },
64260
64417
  async codex(deps2, notes) {
@@ -64277,7 +64434,7 @@ var uninstall = {
64277
64434
  }
64278
64435
  }
64279
64436
  const pinned = present2(p.codexBin);
64280
- rmSync20(p.codexBin, { force: true });
64437
+ rmSync21(p.codexBin, { force: true });
64281
64438
  return saved || pinned ? "done" : "none";
64282
64439
  },
64283
64440
  async hermes(deps2, notes) {
@@ -64412,7 +64569,7 @@ function checkAdapters(deps2) {
64412
64569
  }) && listed(
64413
64570
  parseJsonc(readFileSync32(p.opencodeCli, "utf8"), p.opencodeCli),
64414
64571
  p.opencodePlugin
64415
- ) && homed(join37(p.opencodePlugin, "tui.js"))
64572
+ ) && homed(join38(p.opencodePlugin, "tui.js"))
64416
64573
  ),
64417
64574
  pi: state("pi", () => homed(p.pi)),
64418
64575
  omp: state("omp", () => homed(p.omp)),
@@ -64536,21 +64693,21 @@ import {
64536
64693
  chmodSync as chmodSync21,
64537
64694
  constants as constants8,
64538
64695
  lstatSync as lstatSync18,
64539
- mkdirSync as mkdirSync16,
64696
+ mkdirSync as mkdirSync17,
64540
64697
  readFileSync as readFileSync33,
64541
64698
  readlinkSync as readlinkSync6,
64542
- renameSync as renameSync22,
64543
- rmSync as rmSync21,
64544
- writeFileSync as writeFileSync21
64699
+ renameSync as renameSync23,
64700
+ rmSync as rmSync22,
64701
+ writeFileSync as writeFileSync22
64545
64702
  } from "node:fs";
64546
- import { delimiter as delimiter3, dirname as dirname19, join as join38, resolve as resolve13, sep as sep5 } from "node:path";
64703
+ import { delimiter as delimiter3, dirname as dirname20, join as join39, resolve as resolve13, sep as sep5 } from "node:path";
64547
64704
  var SHIM_MARKER = "# oa-bus shim: written by oa-bus install";
64548
64705
  var HOME_PREFIX = "# oa-bus home: ";
64549
64706
  var NAME2 = "oa-bus";
64550
64707
  var LOCAL_HINT = 'export PATH="$HOME/.local/bin:$PATH"';
64551
64708
  var isWindows = (platform) => platform.startsWith("win32");
64552
64709
  var pathDirs = (p) => (p ?? "").split(delimiter3).filter((d) => d !== "").map((d) => resolve13(d));
64553
- var candidates2 = (o) => o.platform.startsWith("darwin") ? [join38(o.userHome, ".local", "bin"), join38(o.userHome, "bin")] : [join38(o.userHome, ".local", "bin")];
64710
+ var candidates2 = (o) => o.platform.startsWith("darwin") ? [join39(o.userHome, ".local", "bin"), join39(o.userHome, "bin")] : [join39(o.userHome, ".local", "bin")];
64554
64711
  var shQuote2 = (v) => `'${v.replaceAll("'", `'\\''`)}'`;
64555
64712
  function shimText(o) {
64556
64713
  const moved = resolve13(o.busHome) !== resolve13(o.userHome, ".oa-bus");
@@ -64572,7 +64729,7 @@ function ownerOf(file2, busHome2) {
64572
64729
  }
64573
64730
  if (st.isSymbolicLink()) {
64574
64731
  try {
64575
- const to = resolve13(dirname19(file2), readlinkSync6(file2));
64732
+ const to = resolve13(dirname20(file2), readlinkSync6(file2));
64576
64733
  const home2 = resolve13(busHome2);
64577
64734
  return to === home2 || to.startsWith(`${home2}/`) ? { ours: true, home: home2 } : { ours: false };
64578
64735
  } catch {
@@ -64592,13 +64749,13 @@ function ownerOf(file2, busHome2) {
64592
64749
  var sameHome = (owner, busHome2) => owner?.ours === true && (owner.home === void 0 || owner.home === resolve13(busHome2));
64593
64750
  function writeShim(path, text3) {
64594
64751
  const tmp = `${path}.${process.pid}.tmp`;
64595
- rmSync21(tmp, { force: true });
64752
+ rmSync22(tmp, { force: true });
64596
64753
  try {
64597
- writeFileSync21(tmp, text3, { mode: 493, flag: "wx" });
64754
+ writeFileSync22(tmp, text3, { mode: 493, flag: "wx" });
64598
64755
  chmodSync21(tmp, 493);
64599
- renameSync22(tmp, path);
64756
+ renameSync23(tmp, path);
64600
64757
  } catch (e) {
64601
- rmSync21(tmp, { force: true });
64758
+ rmSync22(tmp, { force: true });
64602
64759
  throw e;
64603
64760
  }
64604
64761
  }
@@ -64607,16 +64764,16 @@ function installShim(o) {
64607
64764
  const onPath = new Set(pathDirs(o.env.PATH));
64608
64765
  const list = candidates2(o);
64609
64766
  const dir = list.find((d) => onPath.has(d)) ?? list[0];
64610
- const path = join38(dir, NAME2);
64767
+ const path = join39(dir, NAME2);
64611
64768
  const owner = ownerOf(path, o.busHome);
64612
64769
  if (owner && !owner.ours) return { kind: "foreign", path };
64613
64770
  if (owner?.ours && !sameHome(owner, o.busHome))
64614
64771
  return { kind: "other-home", path, home: owner.home };
64615
- mkdirSync16(dir, { recursive: true });
64772
+ mkdirSync17(dir, { recursive: true });
64616
64773
  const text3 = shimText(o);
64617
64774
  writeShim(path, text3);
64618
64775
  for (const d of list) {
64619
- const other = join38(d, NAME2);
64776
+ const other = join39(d, NAME2);
64620
64777
  if (d !== dir && sameHome(ownerOf(other, o.busHome), o.busHome))
64621
64778
  writeShim(other, text3);
64622
64779
  }
@@ -64632,11 +64789,11 @@ function removeShim(o) {
64632
64789
  if (isWindows(o.platform)) return void 0;
64633
64790
  let removed;
64634
64791
  for (const dir of candidates2({ ...o, env: {} })) {
64635
- const file2 = join38(dir, NAME2);
64792
+ const file2 = join39(dir, NAME2);
64636
64793
  const owner = ownerOf(file2, o.busHome);
64637
64794
  if (!owner?.ours) continue;
64638
64795
  if (owner.home !== void 0 && owner.home !== resolve13(o.busHome)) continue;
64639
- rmSync21(file2, { force: true });
64796
+ rmSync22(file2, { force: true });
64640
64797
  removed = file2;
64641
64798
  }
64642
64799
  return removed;
@@ -64655,13 +64812,13 @@ function shimState(o) {
64655
64812
  (d) => !(d.endsWith(`${sep5}node_modules${sep5}.bin`) && d.split(sep5).includes("_npx"))
64656
64813
  );
64657
64814
  for (const dir of dirs) {
64658
- const file2 = join38(dir, NAME2);
64815
+ const file2 = join39(dir, NAME2);
64659
64816
  if (!executable2(file2)) continue;
64660
64817
  const owner = ownerOf(file2, o.busHome);
64661
64818
  return owner?.ours && (owner.home === void 0 || owner.home === resolve13(o.busHome)) ? { kind: "ours", path: file2 } : { kind: "other", path: file2 };
64662
64819
  }
64663
64820
  for (const dir of candidates2(o)) {
64664
- const file2 = join38(dir, NAME2);
64821
+ const file2 = join39(dir, NAME2);
64665
64822
  const owner = ownerOf(file2, o.busHome);
64666
64823
  if (owner?.ours && (owner.home === void 0 || owner.home === resolve13(o.busHome)))
64667
64824
  return { kind: "off-path", path: file2, hint: LOCAL_HINT };
@@ -64678,8 +64835,8 @@ function busCmd(o) {
64678
64835
  return installedForm(o.busHome) ?? BUS_CMD;
64679
64836
  }
64680
64837
  function installedForm(home2) {
64681
- const node2 = join39(home2, "bin", "node");
64682
- const entry = join39(home2, "bin", "dist", "index.js");
64838
+ const node2 = join40(home2, "bin", "node");
64839
+ const entry = join40(home2, "bin", "dist", "index.js");
64683
64840
  if (!existsSync17(node2) || !existsSync17(entry)) return void 0;
64684
64841
  const q = (p) => /[\s"'$`\\]/.test(p) ? JSON.stringify(p) : p;
64685
64842
  return `${q(node2)} ${q(entry)}`;
@@ -64728,14 +64885,14 @@ import { randomBytes as randomBytes9 } from "node:crypto";
64728
64885
  import {
64729
64886
  chmodSync as chmodSync22,
64730
64887
  closeSync as closeSync11,
64731
- mkdirSync as mkdirSync17,
64888
+ mkdirSync as mkdirSync18,
64732
64889
  openSync as openSync11,
64733
- renameSync as renameSync23,
64734
- rmSync as rmSync22,
64890
+ renameSync as renameSync24,
64891
+ rmSync as rmSync23,
64735
64892
  unlinkSync as unlinkSync5,
64736
64893
  writeSync as writeSync5
64737
64894
  } from "node:fs";
64738
- import { join as join40 } from "node:path";
64895
+ import { join as join41 } from "node:path";
64739
64896
  init_src();
64740
64897
 
64741
64898
  // src/machine-label.ts
@@ -64784,9 +64941,9 @@ function checkVerificationUri(uri, hub) {
64784
64941
  return uri;
64785
64942
  }
64786
64943
  function writeMachineFile(home2, body) {
64787
- mkdirSync17(home2, { recursive: true, mode: 448 });
64944
+ mkdirSync18(home2, { recursive: true, mode: 448 });
64788
64945
  chmodSync22(home2, 448);
64789
- const tmp = join40(home2, `.machine.json.${randomBytes9(8).toString("hex")}.tmp`);
64946
+ const tmp = join41(home2, `.machine.json.${randomBytes9(8).toString("hex")}.tmp`);
64790
64947
  const fd = openSync11(tmp, "wx", 384);
64791
64948
  try {
64792
64949
  writeSync5(fd, body);
@@ -64798,7 +64955,7 @@ function writeMachineFile(home2, body) {
64798
64955
  closeSync11(fd);
64799
64956
  try {
64800
64957
  chmodSync22(tmp, 384);
64801
- renameSync23(tmp, join40(home2, "machine.json"));
64958
+ renameSync24(tmp, join41(home2, "machine.json"));
64802
64959
  } catch (e) {
64803
64960
  unlinkSync5(tmp);
64804
64961
  throw e;
@@ -64948,7 +65105,7 @@ async function loginInner(args) {
64948
65105
  `${JSON.stringify({ hub, label: label2, machine_token: poll.machine_token }, null, 2)}
64949
65106
  `
64950
65107
  );
64951
- rmSync22(join40(args.home, "revoked"), { force: true });
65108
+ rmSync23(join41(args.home, "revoked"), { force: true });
64952
65109
  }
64953
65110
  if (!events?.code) print(`Approved this machine as ${label2}.`);
64954
65111
  return {
@@ -65126,15 +65283,15 @@ async function autoUpdate(opts, ctx) {
65126
65283
 
65127
65284
  // src/commands/daemon.ts
65128
65285
  import { existsSync as existsSync19 } from "node:fs";
65129
- import { join as join44 } from "node:path";
65286
+ import { join as join45 } from "node:path";
65130
65287
  import { fileURLToPath as fileURLToPath6 } from "node:url";
65131
65288
 
65132
65289
  // src/machine.ts
65133
65290
  import { readFileSync as readFileSync34, statSync as statSync10 } from "node:fs";
65134
- import { join as join41 } from "node:path";
65291
+ import { join as join42 } from "node:path";
65135
65292
  init_src();
65136
65293
  function readMachine(home2) {
65137
- const file2 = join41(home2, "machine.json");
65294
+ const file2 = join42(home2, "machine.json");
65138
65295
  let text3;
65139
65296
  let mode;
65140
65297
  try {
@@ -65168,7 +65325,7 @@ var originOf2 = (hub) => {
65168
65325
 
65169
65326
  // src/steps/claude-proof-check.ts
65170
65327
  import { readFileSync as readFileSync35 } from "node:fs";
65171
- import { join as join42 } from "node:path";
65328
+ import { join as join43 } from "node:path";
65172
65329
  var PROOF_EVENT = "claude_proof_applied";
65173
65330
  var DAY_MS = 864e5;
65174
65331
  var safeText = (s, max = 80) => {
@@ -65193,10 +65350,10 @@ function claudeProofChecks(ctx, hub, instance) {
65193
65350
  return [];
65194
65351
  }
65195
65352
  const cc = instance ? `Claude Code (${safeText(instance.name, 32)}):` : "Claude Code:";
65196
- const rec = readRecord(join42(ctx.home, "install.json"));
65353
+ const rec = readRecord(join43(ctx.home, "install.json"));
65197
65354
  const file2 = rec.config ?? claudeConfigFile2(ctx.userHome, ctx.env);
65198
65355
  const r = proofReport(file2, origin, {
65199
- projectFile: join42(ctx.cwd, ".mcp.json"),
65356
+ projectFile: join43(ctx.cwd, ".mcp.json"),
65200
65357
  cwd: ctx.cwd,
65201
65358
  recorded: rec.proofs,
65202
65359
  ...instance ? { instance } : {},
@@ -65324,7 +65481,7 @@ function instanceProofChecks(ctx) {
65324
65481
  function lastAutoFix(ctx) {
65325
65482
  let text3;
65326
65483
  try {
65327
- text3 = readFileSync35(join42(ctx.home, "logs", "events.log"), "utf8");
65484
+ text3 = readFileSync35(join43(ctx.home, "logs", "events.log"), "utf8");
65328
65485
  } catch {
65329
65486
  return void 0;
65330
65487
  }
@@ -65345,8 +65502,8 @@ function lastAutoFix(ctx) {
65345
65502
  }
65346
65503
 
65347
65504
  // src/steps/habits.ts
65348
- import { existsSync as existsSync18, lstatSync as lstatSync19, readFileSync as readFileSync36, rmSync as rmSync23 } from "node:fs";
65349
- import { join as join43, resolve as resolve14 } from "node:path";
65505
+ import { existsSync as existsSync18, lstatSync as lstatSync19, readFileSync as readFileSync36, rmSync as rmSync24 } from "node:fs";
65506
+ import { join as join44, resolve as resolve14 } from "node:path";
65350
65507
  var HABITS_HARNESSES = [
65351
65508
  "claude",
65352
65509
  "codex",
@@ -65357,21 +65514,21 @@ var HABITS_BEGIN = "<!-- BEGIN Open Artifacts bus habits (managed). Written by `
65357
65514
  var HABITS_END = "<!-- END Open Artifacts bus habits -->";
65358
65515
  var piAgentDir = (home2, env2) => {
65359
65516
  const d = env2.PI_CODING_AGENT_DIR;
65360
- if (!d) return join43(home2, ".pi", "agent");
65517
+ if (!d) return join44(home2, ".pi", "agent");
65361
65518
  if (d === "~") return home2;
65362
- return resolve14(d.startsWith("~/") ? join43(home2, d.slice(2)) : d);
65519
+ return resolve14(d.startsWith("~/") ? join44(home2, d.slice(2)) : d);
65363
65520
  };
65364
65521
  function habitsFiles(deps2, h) {
65365
65522
  const env2 = deps2.env ?? {};
65366
65523
  const pair = (dir) => {
65367
- const override = join43(dir, "AGENTS.override.md");
65368
- const plain3 = join43(dir, "AGENTS.md");
65524
+ const override = join44(dir, "AGENTS.override.md");
65525
+ const plain3 = join44(dir, "AGENTS.md");
65369
65526
  return existsSync18(override) ? [override, plain3] : [plain3, override];
65370
65527
  };
65371
65528
  switch (h) {
65372
65529
  case "claude":
65373
65530
  return [
65374
- join43(env2.CLAUDE_CONFIG_DIR ?? join43(deps2.home, ".claude"), "CLAUDE.md")
65531
+ join44(env2.CLAUDE_CONFIG_DIR ?? join44(deps2.home, ".claude"), "CLAUDE.md")
65375
65532
  ];
65376
65533
  case "codex":
65377
65534
  return pair(codexHome2(deps2.home, env2));
@@ -65379,8 +65536,8 @@ function habitsFiles(deps2, h) {
65379
65536
  return pair(piAgentDir(deps2.home, env2));
65380
65537
  case "opencode":
65381
65538
  return [
65382
- join43(
65383
- env2.OPENCODE_CONFIG_DIR ?? join43(env2.XDG_CONFIG_HOME ?? join43(deps2.home, ".config"), "opencode"),
65539
+ join44(
65540
+ env2.OPENCODE_CONFIG_DIR ?? join44(env2.XDG_CONFIG_HOME ?? join44(deps2.home, ".config"), "opencode"),
65384
65541
  "AGENTS.md"
65385
65542
  )
65386
65543
  ];
@@ -65420,7 +65577,7 @@ var isLink = (path) => {
65420
65577
  }
65421
65578
  };
65422
65579
  var record6 = (busHome2) => {
65423
- const raw = busHome2 ? readInstallFile(join43(busHome2, "install.json")).habits : void 0;
65580
+ const raw = busHome2 ? readInstallFile(join44(busHome2, "install.json")).habits : void 0;
65424
65581
  const h = typeof raw === "object" && raw !== null ? raw : {};
65425
65582
  return {
65426
65583
  optedOut: h.optedOut === true,
@@ -65442,7 +65599,7 @@ var pluginDirsOf = (v) => {
65442
65599
  var saveRecord = (busHome2, patch) => {
65443
65600
  if (!busHome2) return;
65444
65601
  const cur = record6(busHome2);
65445
- updateInstallFile(join43(busHome2, "install.json"), {
65602
+ updateInstallFile(join44(busHome2, "install.json"), {
65446
65603
  habits: { ...cur, ...patch }
65447
65604
  });
65448
65605
  };
@@ -65482,7 +65639,7 @@ function removeProjectHabits(deps2, only) {
65482
65639
  continue;
65483
65640
  }
65484
65641
  const after = withoutHabits(before, rec?.added);
65485
- if (rec?.created && after.trim() === "") rmSync23(path, { force: true });
65642
+ if (rec?.created && after.trim() === "") rmSync24(path, { force: true });
65486
65643
  else writeAtomic(path, after);
65487
65644
  delete kept[path];
65488
65645
  cleaned.add(path);
@@ -65509,7 +65666,7 @@ function removeProjectHabits(deps2, only) {
65509
65666
  exclude.splice(exclude.indexOf(e), 1);
65510
65667
  }
65511
65668
  }
65512
- if (deps2.busHome && existsSync18(join43(deps2.busHome, "install.json")))
65669
+ if (deps2.busHome && existsSync18(join44(deps2.busHome, "install.json")))
65513
65670
  saveRecord(deps2.busHome, { project: { files: kept, exclude } });
65514
65671
  return { files: files2, notes };
65515
65672
  }
@@ -65532,7 +65689,7 @@ function removeHabits(deps2, harnesses = HABITS_HARNESSES, opts = {}) {
65532
65689
  const rec = kept[path];
65533
65690
  const after = withoutHabits(before, rec?.added);
65534
65691
  if (rec?.created && !isLink(path) && after.trim() === "")
65535
- rmSync23(real3, { force: true });
65692
+ rmSync24(real3, { force: true });
65536
65693
  else writeAtomic(real3, after);
65537
65694
  delete kept[path];
65538
65695
  files2.push(path);
@@ -65552,7 +65709,7 @@ function removeHabits(deps2, harnesses = HABITS_HARNESSES, opts = {}) {
65552
65709
  files2.push(...p.markers);
65553
65710
  notes.push(...p.notes);
65554
65711
  }
65555
- if (deps2.busHome && existsSync18(join43(deps2.busHome, "install.json")))
65712
+ if (deps2.busHome && existsSync18(join44(deps2.busHome, "install.json")))
65556
65713
  saveRecord(deps2.busHome, { files: kept });
65557
65714
  return {
65558
65715
  files: files2,
@@ -65614,7 +65771,7 @@ function removePluginHabits(deps2, plugins2 = PLUGIN_HARNESSES) {
65614
65771
  else notes.push(scan2.note);
65615
65772
  }
65616
65773
  for (const dir of dirs) {
65617
- const marker = join43(dir, p.marker);
65774
+ const marker = join44(dir, p.marker);
65618
65775
  const d = probe(dir);
65619
65776
  if (d.k === "absent") continue;
65620
65777
  if (d.k === "error") {
@@ -65649,7 +65806,7 @@ function removePluginHabits(deps2, plugins2 = PLUGIN_HARNESSES) {
65649
65806
  continue;
65650
65807
  }
65651
65808
  try {
65652
- rmSync23(marker, { force: true });
65809
+ rmSync24(marker, { force: true });
65653
65810
  } catch (e) {
65654
65811
  left(
65655
65812
  `Could not remove ${marker} (${reason(e)}): ${p.label} habits are still on there. Delete it, then rerun.`
@@ -65666,7 +65823,7 @@ function removePluginHabits(deps2, plugins2 = PLUGIN_HARNESSES) {
65666
65823
  done.add(dir);
65667
65824
  if (!changed.includes(p)) changed.push(p);
65668
65825
  }
65669
- if (deps2.busHome && existsSync18(join43(deps2.busHome, "install.json"))) {
65826
+ if (deps2.busHome && existsSync18(join44(deps2.busHome, "install.json"))) {
65670
65827
  const { pluginDirs } = record6(deps2.busHome);
65671
65828
  const had = pluginDirs[p.name];
65672
65829
  if (had !== void 0) {
@@ -65775,12 +65932,12 @@ var lasting = (e) => [...START_ERROR_CODES, "EACCES", "EPERM"].includes(
65775
65932
  );
65776
65933
  async function daemon(ctx, run5 = runDaemon, signals = process) {
65777
65934
  const m = readMachine(ctx.home);
65778
- if (existsSync19(join44(ctx.home, "revoked")) && (m.state !== "ok" || m.revoked)) {
65935
+ if (existsSync19(join45(ctx.home, "revoked")) && (m.state !== "ok" || m.revoked)) {
65779
65936
  sayErr(ctx, ctx.copy.revoked());
65780
65937
  return 0;
65781
65938
  }
65782
- const events = createEventLog(join44(ctx.home, "logs", "events.log"));
65783
- const config2 = readRecord(join44(ctx.home, "install.json")).config;
65939
+ const events = createEventLog(join45(ctx.home, "logs", "events.log"));
65940
+ const config2 = readRecord(join45(ctx.home, "install.json")).config;
65784
65941
  if (m.state === "ok" && config2 !== void 0 && wiredTo(ctx))
65785
65942
  reapplyClaudeProof(
65786
65943
  {
@@ -65828,7 +65985,13 @@ async function daemon(ctx, run5 = runDaemon, signals = process) {
65828
65985
  // Exit non-zero: the service restarts the daemon, which binds again.
65829
65986
  onSocketLost: () => end(1),
65830
65987
  // #2552: the updater ends the daemon non-zero to restart it from a new `bin`.
65831
- update: { entryFile: fileURLToPath6(import.meta.url), exit: end }
65988
+ update: { entryFile: fileURLToPath6(import.meta.url), exit: end },
65989
+ // #3203: a new instance release rewrites the installed skills.
65990
+ skillRefresh: defaultSkillRefresher(
65991
+ ctx.home,
65992
+ (msg) => sayErr(ctx, msg),
65993
+ fileURLToPath6(import.meta.url)
65994
+ )
65832
65995
  }).then(
65833
65996
  (d) => {
65834
65997
  running = d;
@@ -65848,11 +66011,11 @@ async function daemon(ctx, run5 = runDaemon, signals = process) {
65848
66011
 
65849
66012
  // src/commands/doctor.ts
65850
66013
  import { readFileSync as readFileSync41 } from "node:fs";
65851
- import { join as join51 } from "node:path";
66014
+ import { join as join52 } from "node:path";
65852
66015
 
65853
66016
  // src/steps/claude-plugins.ts
65854
66017
  import { readFileSync as readFileSync38 } from "node:fs";
65855
- import { join as join46 } from "node:path";
66018
+ import { join as join47 } from "node:path";
65856
66019
 
65857
66020
  // src/steps/output-style.ts
65858
66021
  import {
@@ -65860,23 +66023,23 @@ import {
65860
66023
  readdirSync as readdirSync13,
65861
66024
  readFileSync as readFileSync37,
65862
66025
  rmdirSync as rmdirSync3,
65863
- rmSync as rmSync24
66026
+ rmSync as rmSync25
65864
66027
  } from "node:fs";
65865
- import { dirname as dirname20, join as join45 } from "node:path";
66028
+ import { dirname as dirname21, join as join46 } from "node:path";
65866
66029
  var OUTPUT_STYLE_FILE = "artifacts-teammate.md";
65867
66030
  var OUTPUT_STYLE_MARKER = "<!-- managed by the Open Artifacts bus installer: edits are replaced on reinstall. -->";
65868
66031
  var OUTPUT_STYLE_NAME = "Artifacts Teammate";
65869
66032
  var OUTPUT_STYLE_PLUGIN_NAME = "open-artifacts:Artifacts Teammate";
65870
66033
  var isOurName = (v) => v === OUTPUT_STYLE_NAME || v === OUTPUT_STYLE_PLUGIN_NAME;
65871
- var claudeSettingsFile = (w) => join45(w.env?.CLAUDE_CONFIG_DIR ?? join45(w.home, ".claude"), "settings.json");
66034
+ var claudeSettingsFile = (w) => join46(w.env?.CLAUDE_CONFIG_DIR ?? join46(w.home, ".claude"), "settings.json");
65872
66035
  var readRecord3 = (busHome2) => {
65873
66036
  if (!busHome2) return void 0;
65874
- const r = readInstallFile(join45(busHome2, "install.json")).outputStyle;
66037
+ const r = readInstallFile(join46(busHome2, "install.json")).outputStyle;
65875
66038
  return typeof r === "object" && r !== null ? r : void 0;
65876
66039
  };
65877
- var writeRecord3 = (busHome2, r) => updateInstallFile(join45(busHome2, "install.json"), { outputStyle: r });
65878
- var styleDir = (w) => join45(w.env?.CLAUDE_CONFIG_DIR ?? join45(w.home, ".claude"), "output-styles");
65879
- var outputStyleFile = (w) => join45(styleDir(w), OUTPUT_STYLE_FILE);
66040
+ var writeRecord3 = (busHome2, r) => updateInstallFile(join46(busHome2, "install.json"), { outputStyle: r });
66041
+ var styleDir = (w) => join46(w.env?.CLAUDE_CONFIG_DIR ?? join46(w.home, ".claude"), "output-styles");
66042
+ var outputStyleFile = (w) => join46(styleDir(w), OUTPUT_STYLE_FILE);
65880
66043
  var isOurs2 = (text3) => {
65881
66044
  const m = /^---\n[\s\S]*?\n---\n/.exec(text3.replace(/\r\n/g, "\n"));
65882
66045
  return m !== null && text3.replace(/\r\n/g, "\n").slice(m[0].length).split("\n", 1)[0] === OUTPUT_STYLE_MARKER;
@@ -65962,7 +66125,7 @@ function selectOutputStyle(deps2) {
65962
66125
  } else {
65963
66126
  try {
65964
66127
  if (exists(path) && isOurs2(readFileSync37(path, "utf8"))) {
65965
- rmSync24(path);
66128
+ rmSync25(path);
65966
66129
  removed = true;
65967
66130
  if (readdirSync13(dir).length === 0) rmdirSync3(dir);
65968
66131
  } else if (exists(path)) {
@@ -66011,7 +66174,7 @@ function turnOff2(deps2, out) {
66011
66174
  const was = rec?.set ? rec.before : void 0;
66012
66175
  const next = was?.state === "null" ? setJsoncValue(cur.text, ["outputStyle"], null) : was?.state === "empty" ? setJsoncValue(cur.text, ["outputStyle"], was.value) : removeJsoncValue(cur.text, ["outputStyle"]);
66013
66176
  if (rec?.set && rec.createdFile && (cur.text === createdText() || cur.text === createdText(OUTPUT_STYLE_NAME)))
66014
- rmSync24(path);
66177
+ rmSync25(path);
66015
66178
  else writeAtomic(path, next);
66016
66179
  }
66017
66180
  if (busHome2 && rec) writeRecord3(busHome2, void 0);
@@ -66038,7 +66201,7 @@ function uninstallOutputStyle(deps2) {
66038
66201
  `Left ${path} alone: it has no Open Artifacts marker, so it is not ours to replace.`
66039
66202
  );
66040
66203
  } else {
66041
- rmSync24(path);
66204
+ rmSync25(path);
66042
66205
  out.written.push(path);
66043
66206
  gone = true;
66044
66207
  if (readdirSync13(dir).length === 0) rmdirSync3(dir);
@@ -66073,7 +66236,7 @@ var outputStyleOn = (deps2) => {
66073
66236
  var outputStyleState = (deps2) => {
66074
66237
  const path = outputStyleFile(deps2);
66075
66238
  try {
66076
- if (isLink2(dirname20(path)) || isLink2(path)) return void 0;
66239
+ if (isLink2(dirname21(path)) || isLink2(path)) return void 0;
66077
66240
  if (!isOurs2(readFileSync37(path, "utf8"))) return void 0;
66078
66241
  const s = readSettings(claudeSettingsFile(deps2));
66079
66242
  return { path, on: s.ok && s.style === OUTPUT_STYLE_NAME };
@@ -66094,10 +66257,10 @@ var SPARSE = [".claude-plugin", "plugins", "packages/claude-code-shortcuts"];
66094
66257
  var CALL_MS = 12e4;
66095
66258
  var MCP_LIST_MS = 2e4;
66096
66259
  var readRecord4 = (busHome2) => {
66097
- const r = readInstallFile(join46(busHome2, "install.json")).claudePlugins;
66260
+ const r = readInstallFile(join47(busHome2, "install.json")).claudePlugins;
66098
66261
  return typeof r === "object" && r !== null ? r : void 0;
66099
66262
  };
66100
- var writeRecord4 = (busHome2, r) => updateInstallFile(join46(busHome2, "install.json"), { claudePlugins: r });
66263
+ var writeRecord4 = (busHome2, r) => updateInstallFile(join47(busHome2, "install.json"), { claudePlugins: r });
66101
66264
  var cmpVersion = (a, b) => {
66102
66265
  const pa = a.split(".").map(Number);
66103
66266
  const pb = b.split(".").map(Number);
@@ -66562,7 +66725,7 @@ function readInstanceUrl(deps2) {
66562
66725
 
66563
66726
  // src/steps/claude-sessions.ts
66564
66727
  import { readFileSync as readFileSync39 } from "node:fs";
66565
- import { join as join47 } from "node:path";
66728
+ import { join as join48 } from "node:path";
66566
66729
  var UNBOUND_EVENT = "mcp_proof_unbound";
66567
66730
  var DAY_MS2 = 864e5;
66568
66731
  function hubOrigin(hub) {
@@ -66594,7 +66757,7 @@ function helperFailures(ctx) {
66594
66757
  const out = /* @__PURE__ */ new Map();
66595
66758
  let text3;
66596
66759
  try {
66597
- text3 = readFileSync39(join47(ctx.home, "logs", "events.log"), "utf8");
66760
+ text3 = readFileSync39(join48(ctx.home, "logs", "events.log"), "utf8");
66598
66761
  } catch {
66599
66762
  return out;
66600
66763
  }
@@ -66640,7 +66803,7 @@ function entryApplies(ctx, origin, cwd) {
66640
66803
  const p = isObj2(doc.projects) ? doc.projects[cwd] : void 0;
66641
66804
  if (isObj2(p) && matching(p.mcpServers, origin).length > 0) return true;
66642
66805
  }
66643
- const proj = read(join47(cwd, ".mcp.json"));
66806
+ const proj = read(join48(cwd, ".mcp.json"));
66644
66807
  return isObj2(proj) && matching(proj.mcpServers, origin).length > 0;
66645
66808
  }
66646
66809
  function sessionChecks(ctx, st, hub) {
@@ -66722,7 +66885,7 @@ var sseCheck = (ctx, name) => ({
66722
66885
 
66723
66886
  // src/commands/namespace.ts
66724
66887
  import { realpathSync as realpathSync15, statSync as statSync11 } from "node:fs";
66725
- import { join as join48, resolve as resolve15 } from "node:path";
66888
+ import { join as join49, resolve as resolve15 } from "node:path";
66726
66889
  init_src();
66727
66890
  function shown2(ctx, path) {
66728
66891
  const t = tilde(ctx, path);
@@ -66793,7 +66956,7 @@ async function namespace(opts, ctx) {
66793
66956
  sayErr(ctx, c.nsNotDir(shown2(ctx, real3 ?? given)));
66794
66957
  return 1;
66795
66958
  }
66796
- const cfgFile = join48(real3, CONFIG_FILE);
66959
+ const cfgFile = join49(real3, CONFIG_FILE);
66797
66960
  const own2 = readOwnFile(cfgFile, process.getuid?.(), {
66798
66961
  allowGroupWrite: true
66799
66962
  });
@@ -66872,7 +67035,7 @@ init_src();
66872
67035
 
66873
67036
  // src/commands/install.ts
66874
67037
  init_src3();
66875
- import { dirname as dirname21, join as join50 } from "node:path";
67038
+ import { dirname as dirname22, join as join51 } from "node:path";
66876
67039
  init_src2();
66877
67040
 
66878
67041
  // src/live.ts
@@ -66927,17 +67090,17 @@ import {
66927
67090
  readdirSync as readdirSync14,
66928
67091
  readFileSync as readFileSync40,
66929
67092
  rmdirSync as rmdirSync4,
66930
- rmSync as rmSync25
67093
+ rmSync as rmSync26
66931
67094
  } from "node:fs";
66932
- import { join as join49 } from "node:path";
67095
+ import { join as join50 } from "node:path";
66933
67096
  function leftoverTargets(deps2) {
66934
67097
  const env2 = deps2.env ?? {};
66935
67098
  const p = paths(deps2);
66936
- const piDir = agentDirEnv(deps2.home, env2) ?? join49(deps2.home, ".pi/agent");
67099
+ const piDir = agentDirEnv(deps2.home, env2) ?? join50(deps2.home, ".pi/agent");
66937
67100
  const skill2 = (h) => skillDir({ home: deps2.home, env: env2 }, h);
66938
67101
  return {
66939
67102
  files: [
66940
- join49(codexHome2(deps2.home, env2), "AGENTS.md"),
67103
+ join50(codexHome2(deps2.home, env2), "AGENTS.md"),
66941
67104
  p.codex,
66942
67105
  ...p.opencodeConfigs,
66943
67106
  p.opencodeCli,
@@ -66947,15 +67110,15 @@ function leftoverTargets(deps2) {
66947
67110
  skill2("claude"),
66948
67111
  skill2("pi"),
66949
67112
  skill2("hermes"),
66950
- join49(hermesHome(deps2.home, env2), "plugins"),
66951
- join49(deps2.home, ".local", "bin"),
66952
- join49(ompAgentDir(deps2.home, env2), "extensions"),
66953
- join49(piDir, "extensions"),
67113
+ join50(hermesHome(deps2.home, env2), "plugins"),
67114
+ join50(deps2.home, ".local", "bin"),
67115
+ join50(ompAgentDir(deps2.home, env2), "extensions"),
67116
+ join50(piDir, "extensions"),
66954
67117
  skill2("opencode"),
66955
67118
  skill2("openclaw"),
66956
67119
  // agy's config folders, when install made them for its mcp_config.json.
66957
- join49(deps2.home, ".gemini", "config"),
66958
- join49(deps2.home, ".gemini")
67120
+ join50(deps2.home, ".gemini", "config"),
67121
+ join50(deps2.home, ".gemini")
66959
67122
  ]
66960
67123
  };
66961
67124
  }
@@ -67008,7 +67171,7 @@ function removeMade(made) {
67008
67171
  const gone = [];
67009
67172
  for (const path of made) {
67010
67173
  if (!emptyFile(path)) continue;
67011
- rmSync25(path, { force: true });
67174
+ rmSync26(path, { force: true });
67012
67175
  gone.push(path);
67013
67176
  }
67014
67177
  for (const path of made.filter((x) => !gone.includes(x)).sort((a, b) => b.length - a.length)) {
@@ -67098,7 +67261,7 @@ async function loginStep(ctx, opts) {
67098
67261
  ctx,
67099
67262
  c.approved(result.label),
67100
67263
  c.tokenSaved(
67101
- tilde(ctx, join50(ctx.home, "machine.json")),
67264
+ tilde(ctx, join51(ctx.home, "machine.json")),
67102
67265
  result.machineToken
67103
67266
  ),
67104
67267
  c.connected(originOf2(result.hub)),
@@ -67227,7 +67390,7 @@ function shownSocket(ctx) {
67227
67390
  const real3 = `${canonicalHome(ctx.home)}/`;
67228
67391
  return tilde(
67229
67392
  ctx,
67230
- path.startsWith(real3) ? join50(ctx.home, path.slice(real3.length)) : path
67393
+ path.startsWith(real3) ? join51(ctx.home, path.slice(real3.length)) : path
67231
67394
  );
67232
67395
  }
67233
67396
  async function waitForDaemon(ctx) {
@@ -67413,7 +67576,7 @@ function reportShim(ctx) {
67413
67576
  if (r.kind === "installed") {
67414
67577
  say(ctx, ctx.copy.shimInstalled(tilde(ctx, r.path)));
67415
67578
  if (!r.onPath && r.hint)
67416
- say(ctx, ctx.copy.shimNotOnPath(tilde(ctx, dirname21(r.path)), r.hint));
67579
+ say(ctx, ctx.copy.shimNotOnPath(tilde(ctx, dirname22(r.path)), r.hint));
67417
67580
  } else if (r.kind === "other-home")
67418
67581
  say(ctx, ctx.copy.shimOtherHome(tilde(ctx, r.path), tilde(ctx, r.home)));
67419
67582
  else if (r.kind === "foreign")
@@ -67484,7 +67647,7 @@ async function installRun(opts, realCtx2) {
67484
67647
  busHome: ctx.home
67485
67648
  }) : void 0;
67486
67649
  const ok = await runSteps(steps, ctx, {
67487
- path: join50(ctx.home, "install.json"),
67650
+ path: join51(ctx.home, "install.json"),
67488
67651
  now: ctx.now
67489
67652
  });
67490
67653
  if (ok && second) say(ctx, "", c.secondBus(ctx.home));
@@ -67790,7 +67953,7 @@ async function doctor(ctx) {
67790
67953
  const node2 = ctx.nodeVersion.replace(/^v/, "");
67791
67954
  if (Number(node2.split(".")[0]) >= MIN_NODE) pass(c.nodeOk(node2));
67792
67955
  else fail3(c.nodeOld(node2));
67793
- const machineFile = tilde(ctx, join51(ctx.home, "machine.json"));
67956
+ const machineFile = tilde(ctx, join52(ctx.home, "machine.json"));
67794
67957
  const m = readMachine(ctx.home);
67795
67958
  if (m.state !== "ok") fail3(c.noCredentials(machineFile));
67796
67959
  else if (m.revoked) fail3(c.revokedCheck());
@@ -67894,8 +68057,8 @@ async function doctor(ctx) {
67894
68057
  pass(c.wired(h, version2));
67895
68058
  else fail3(c.notWired(h));
67896
68059
  if (h === "claude") {
67897
- const settings = join51(
67898
- ctx.env.CLAUDE_CONFIG_DIR ?? join51(ctx.userHome, ".claude"),
68060
+ const settings = join52(
68061
+ ctx.env.CLAUDE_CONFIG_DIR ?? join52(ctx.userHome, ".claude"),
67899
68062
  "settings.json"
67900
68063
  );
67901
68064
  const isolates = claudeIsolates(settings);
@@ -68089,11 +68252,11 @@ async function global(opts, ctx) {
68089
68252
 
68090
68253
  // src/commands/leads.ts
68091
68254
  import { readFileSync as readFileSync42 } from "node:fs";
68092
- import { join as join52 } from "node:path";
68255
+ import { join as join53 } from "node:path";
68093
68256
  function hubOrigin2(ctx) {
68094
68257
  try {
68095
68258
  const raw = JSON.parse(
68096
- readFileSync42(join52(ctx.home, "machine.json"), "utf8")
68259
+ readFileSync42(join53(ctx.home, "machine.json"), "utf8")
68097
68260
  );
68098
68261
  return typeof raw?.hub === "string" ? new URL(raw.hub).origin : void 0;
68099
68262
  } catch {
@@ -68287,7 +68450,7 @@ import {
68287
68450
  openSync as openSync12,
68288
68451
  readFileSync as readFileSync43
68289
68452
  } from "node:fs";
68290
- import { dirname as dirname22, join as join53 } from "node:path";
68453
+ import { dirname as dirname23, join as join54 } from "node:path";
68291
68454
  var TAIL = 50;
68292
68455
  var checkDir2 = (dir) => {
68293
68456
  let fd;
@@ -68321,7 +68484,7 @@ var tail = (path, dir) => {
68321
68484
  constants9.O_RDONLY | constants9.O_NOFOLLOW | constants9.O_NONBLOCK
68322
68485
  );
68323
68486
  if (!fstatSync7(fd).isFile()) return "skipped";
68324
- const after = lstatSync22(dirname22(path));
68487
+ const after = lstatSync22(dirname23(path));
68325
68488
  if (after.isSymbolicLink() || after.dev !== dir.dev || after.ino !== dir.ino)
68326
68489
  return "skipped";
68327
68490
  return readFileSync43(fd, "utf8").replace(/\n$/, "").split("\n").slice(-TAIL);
@@ -68332,9 +68495,9 @@ var tail = (path, dir) => {
68332
68495
  }
68333
68496
  };
68334
68497
  async function logs(ctx) {
68335
- const logDir = join53(ctx.home, "logs");
68336
- const path = join53(logDir, "daemon.log");
68337
- const eventsPath = join53(logDir, "events.log");
68498
+ const logDir = join54(ctx.home, "logs");
68499
+ const path = join54(logDir, "daemon.log");
68500
+ const eventsPath = join54(logDir, "events.log");
68338
68501
  const dir = checkDir2(logDir);
68339
68502
  if (!dir.ok && dir.why !== "missing") {
68340
68503
  say(ctx, `Not reading ${tilde(ctx, logDir)}: ${dir.why}.`);
@@ -68378,7 +68541,7 @@ init_src3();
68378
68541
  import { execFileSync as execFileSync8 } from "node:child_process";
68379
68542
  import { createHash as createHash12, randomBytes as randomBytes10 } from "node:crypto";
68380
68543
  import { readFileSync as readFileSync44, readlinkSync as readlinkSync7 } from "node:fs";
68381
- import { basename as basename10, join as join54 } from "node:path";
68544
+ import { basename as basename10, join as join55 } from "node:path";
68382
68545
  init_src2();
68383
68546
  init_src();
68384
68547
  var LOG_WAIT_MS = 300;
@@ -68474,7 +68637,7 @@ async function mcpProof(opts, ctx, deps2 = {
68474
68637
  say(ctx, JSON.stringify(headers));
68475
68638
  if (why2 !== void 0)
68476
68639
  try {
68477
- const events = createEventLog(join54(ctx.home, "logs", "events.log"));
68640
+ const events = createEventLog(join55(ctx.home, "logs", "events.log"));
68478
68641
  events(UNBOUND_EVENT, {
68479
68642
  reason: why2,
68480
68643
  ...detail !== void 0 ? { code: detail } : {}
@@ -68489,6 +68652,7 @@ async function mcpProof(opts, ctx, deps2 = {
68489
68652
  }
68490
68653
 
68491
68654
  // src/commands/skill.ts
68655
+ import { readFileSync as readFileSync45 } from "node:fs";
68492
68656
  var detected = (ctx) => Object.entries(
68493
68657
  checkAdapters({
68494
68658
  home: ctx.userHome,
@@ -68510,7 +68674,29 @@ async function skill(opts, ctx) {
68510
68674
  ]);
68511
68675
  return 1;
68512
68676
  }
68513
- const harnesses = detected(ctx);
68677
+ let harnesses = detected(ctx);
68678
+ if (opts.refresh && harnesses.length > 0) {
68679
+ let liveFolder;
68680
+ try {
68681
+ liveFolder = skillFolder(
68682
+ await fetchSkillText(ctx.fetch, `${origin}/skill.md`)
68683
+ );
68684
+ } catch {
68685
+ liveFolder = void 0;
68686
+ }
68687
+ if (!liveFolder) {
68688
+ sayErr(
68689
+ ctx,
68690
+ `Could not read this instance's skill from ${origin}/skill.md.`
68691
+ );
68692
+ return 1;
68693
+ }
68694
+ const folder2 = liveFolder;
68695
+ harnesses = harnesses.filter(
68696
+ (h) => savedSkill({ home: ctx.userHome, env: ctx.env }, h, folder2) !== void 0
68697
+ );
68698
+ if (harnesses.length === 0) return 0;
68699
+ }
68514
68700
  if (harnesses.length === 0) {
68515
68701
  sayErr(ctx, [
68516
68702
  "No harness the bus knows was found here.",
@@ -68536,9 +68722,11 @@ async function skill(opts, ctx) {
68536
68722
  failedUrl = r.failedUrl;
68537
68723
  if (failedUrl) sayErr(ctx, `Could not fetch the skill from ${failedUrl}.`);
68538
68724
  }
68725
+ let liveText;
68539
68726
  let folder;
68540
68727
  try {
68541
- folder = skillFolder(await deps2.fetchSkill(`${origin}/skill.md`));
68728
+ liveText = await deps2.fetchSkill(`${origin}/skill.md`);
68729
+ folder = skillFolder(liveText);
68542
68730
  if (!folder) throw new Error("no skill name in the file");
68543
68731
  } catch (e) {
68544
68732
  sayErr(
@@ -68547,14 +68735,31 @@ async function skill(opts, ctx) {
68547
68735
  );
68548
68736
  return 1;
68549
68737
  }
68738
+ const liveVersion = skillVersion(liveText);
68550
68739
  const where2 = Object.fromEntries(
68551
68740
  harnesses.map((h) => [h, savedSkill(deps2, h, folder)])
68552
68741
  );
68553
68742
  let ok = !failedUrl;
68554
68743
  for (const h of harnesses) {
68555
68744
  const path = where2[h];
68556
- if (path) log(ctx, `${h}: skill saved at ${tilde(ctx, path)}`);
68557
- else {
68745
+ if (path) {
68746
+ let savedVersion;
68747
+ if (liveVersion) {
68748
+ try {
68749
+ savedVersion = skillVersion(readFileSync45(path, "utf8"));
68750
+ } catch {
68751
+ }
68752
+ }
68753
+ if (liveVersion && savedVersion && savedVersion !== liveVersion) {
68754
+ ok = false;
68755
+ sayErr(
68756
+ ctx,
68757
+ `${h}: skill at ${tilde(ctx, path)} is ${savedVersion}, the instance has ${liveVersion}. Run ${ctx.busCmd} skill to update it.`
68758
+ );
68759
+ } else {
68760
+ log(ctx, `${h}: skill saved at ${tilde(ctx, path)}`);
68761
+ }
68762
+ } else {
68558
68763
  ok = false;
68559
68764
  sayErr(
68560
68765
  ctx,
@@ -68571,12 +68776,12 @@ async function skill(opts, ctx) {
68571
68776
  }
68572
68777
 
68573
68778
  // src/commands/uninstall.ts
68574
- import { join as join56 } from "node:path";
68779
+ import { join as join57 } from "node:path";
68575
68780
 
68576
68781
  // src/steps/purge.ts
68577
68782
  init_src3();
68578
- import { lstatSync as lstatSync23, readdirSync as readdirSync15, rmdirSync as rmdirSync5, rmSync as rmSync26 } from "node:fs";
68579
- import { join as join55 } from "node:path";
68783
+ import { lstatSync as lstatSync23, readdirSync as readdirSync15, rmdirSync as rmdirSync5, rmSync as rmSync27 } from "node:fs";
68784
+ import { join as join56 } from "node:path";
68580
68785
  var FILES = [
68581
68786
  "machine.json",
68582
68787
  "install.json",
@@ -68635,7 +68840,7 @@ function kind3(path) {
68635
68840
  return void 0;
68636
68841
  }
68637
68842
  }
68638
- var remove2 = (path, k) => rmSync26(path, { recursive: k === "dir", force: true });
68843
+ var remove2 = (path, k) => rmSync27(path, { recursive: k === "dir", force: true });
68639
68844
  var rmdirIfEmpty = (path) => {
68640
68845
  try {
68641
68846
  rmdirSync5(path);
@@ -68646,14 +68851,14 @@ var rmdirIfEmpty = (path) => {
68646
68851
  };
68647
68852
  function purgeShort(dir, removed) {
68648
68853
  if (kind3(dir) !== "dir" || unsafeSocketDir(dir)) return;
68649
- const ret = join55(dir, "claude-return");
68854
+ const ret = join56(dir, "claude-return");
68650
68855
  for (const [d, ours2] of [
68651
68856
  [ret, (_n, p) => kind3(p) === "socket"],
68652
68857
  [dir, (n) => /^daemon\.sock(\.keep-\d+)?$/.test(n)]
68653
68858
  ]) {
68654
68859
  if (kind3(d) !== "dir") continue;
68655
68860
  for (const name of readdirSync15(d)) {
68656
- const path = join55(d, name);
68861
+ const path = join56(d, name);
68657
68862
  const k = kind3(path);
68658
68863
  if (k === void 0 || k === "dir" || !ours2(name, path)) continue;
68659
68864
  remove2(path, k);
@@ -68678,21 +68883,21 @@ function purge(home2, opts) {
68678
68883
  ...FILES,
68679
68884
  ...entries.filter((n) => TEMP.some((re) => re.test(n)))
68680
68885
  ]) {
68681
- const path = join55(home2, name);
68886
+ const path = join56(home2, name);
68682
68887
  const k = kind3(path);
68683
68888
  if (k === void 0 || k === "dir") continue;
68684
68889
  remove2(path, k);
68685
68890
  removed.push(name);
68686
68891
  }
68687
68892
  for (const folder of FOLDERS) {
68688
- const dir = join55(home2, folder.path);
68893
+ const dir = join56(home2, folder.path);
68689
68894
  if (kind3(dir) !== "dir") continue;
68690
68895
  for (const name of readdirSync15(dir)) {
68691
- const path = join55(dir, name);
68896
+ const path = join56(dir, name);
68692
68897
  const k = kind3(path);
68693
68898
  if (k === void 0 || !folder.ours(name, path)) continue;
68694
68899
  remove2(path, k);
68695
- removed.push(join55(folder.path, name));
68900
+ removed.push(join56(folder.path, name));
68696
68901
  }
68697
68902
  if (rmdirIfEmpty(dir)) removed.push(folder.path);
68698
68903
  }
@@ -68795,7 +69000,7 @@ async function unwire(ctx) {
68795
69000
  say(
68796
69001
  ctx,
68797
69002
  c.hermesNoCli(
68798
- tilde(ctx, join56(hermesHome(ctx.userHome, ctx.env), "config.yaml"))
69003
+ tilde(ctx, join57(hermesHome(ctx.userHome, ctx.env), "config.yaml"))
68799
69004
  )
68800
69005
  );
68801
69006
  if (r.openclawNoCli) say(ctx, c.openclawNoCli());
@@ -68829,7 +69034,7 @@ async function uninstall2(opts, ctx) {
68829
69034
  say(ctx, c.daemonStillRunning(removed.running));
68830
69035
  if (wiredTo(ctx)) await unwire(ctx);
68831
69036
  if (!opts.purge) {
68832
- say(ctx, "", c.kept(tilde(ctx, join56(ctx.home, "machine.json"))));
69037
+ say(ctx, "", c.kept(tilde(ctx, join57(ctx.home, "machine.json"))));
68833
69038
  return 0;
68834
69039
  }
68835
69040
  const home2 = tilde(ctx, ctx.home);
@@ -68839,9 +69044,9 @@ async function uninstall2(opts, ctx) {
68839
69044
  return 1;
68840
69045
  } catch {
68841
69046
  }
68842
- const made = readMade(join56(ctx.home, "install.json"));
69047
+ const made = readMade(join57(ctx.home, "install.json"));
68843
69048
  const out = purge(ctx.home, {
68844
- isDefault: ctx.home === join56(ctx.userHome, ".oa-bus")
69049
+ isDefault: ctx.home === join57(ctx.userHome, ".oa-bus")
68845
69050
  });
68846
69051
  if ("refused" in out) {
68847
69052
  sayErr(ctx, c.purgeRefused(home2));
@@ -68929,11 +69134,11 @@ import {
68929
69134
  chmodSync as chmodSync23,
68930
69135
  copyFileSync as copyFileSync2,
68931
69136
  existsSync as existsSync21,
68932
- mkdirSync as mkdirSync18,
68933
- rmSync as rmSync27,
68934
- writeFileSync as writeFileSync22
69137
+ mkdirSync as mkdirSync19,
69138
+ rmSync as rmSync28,
69139
+ writeFileSync as writeFileSync23
68935
69140
  } from "node:fs";
68936
- import { join as join57 } from "node:path";
69141
+ import { join as join58 } from "node:path";
68937
69142
  var realUpgradeDeps = (ctx) => ({
68938
69143
  fetchRelease,
68939
69144
  verifyRelease,
@@ -69044,30 +69249,30 @@ async function upgrade(ctx, opts, deps2 = realUpgradeDeps(ctx)) {
69044
69249
  );
69045
69250
  return 1;
69046
69251
  }
69047
- const launcher = join57(ctx.home, "bin", "node");
69252
+ const launcher = join58(ctx.home, "bin", "node");
69048
69253
  let dest;
69049
69254
  try {
69050
69255
  dest = stage(ctx.home, target2, (dir) => {
69051
69256
  unpackTo(verified2.entries, dir);
69052
- if (!existsSync21(join57(dir, "dist", "index.js")))
69257
+ if (!existsSync21(join58(dir, "dist", "index.js")))
69053
69258
  throw new Error("the release has no dist/index.js");
69054
69259
  if (existsSync21(launcher)) {
69055
- copyFileSync2(launcher, join57(dir, "node"));
69056
- chmodSync23(join57(dir, "node"), 448);
69260
+ copyFileSync2(launcher, join58(dir, "node"));
69261
+ chmodSync23(join58(dir, "node"), 448);
69057
69262
  }
69058
69263
  });
69059
69264
  } catch {
69060
69265
  sayErr(ctx, c.upgradeRefused(target2, "bad_tar"));
69061
69266
  return 1;
69062
69267
  }
69063
- const marker = join57(dest, ".live", String(process.pid));
69268
+ const marker = join58(dest, ".live", String(process.pid));
69064
69269
  try {
69065
- mkdirSync18(join57(dest, ".live"), { recursive: true, mode: 448 });
69066
- writeFileSync22(marker, "", { mode: 384 });
69270
+ mkdirSync19(join58(dest, ".live"), { recursive: true, mode: 448 });
69271
+ writeFileSync23(marker, "", { mode: 384 });
69067
69272
  } catch {
69068
69273
  }
69069
69274
  deps2.beforeInstall?.(dest);
69070
- const entry = join57(dest, "dist", "index.js");
69275
+ const entry = join58(dest, "dist", "index.js");
69071
69276
  if (!existsSync21(entry)) {
69072
69277
  sayErr(ctx, c.upgradeStaleStage(target2));
69073
69278
  return 1;
@@ -69079,7 +69284,7 @@ async function upgrade(ctx, opts, deps2 = realUpgradeDeps(ctx)) {
69079
69284
  args.push("--no-service");
69080
69285
  setPending(ctx.home, { from: runBase, to: target2, startedAt: ctx.now() });
69081
69286
  const code2 = deps2.runInstaller(entry, args);
69082
- rmSync27(marker, { force: true });
69287
+ rmSync28(marker, { force: true });
69083
69288
  if (code2 !== 0) {
69084
69289
  clearPending(ctx.home);
69085
69290
  sayErr(ctx, c.upgradeInstallFailed(target2, code2));
@@ -69269,7 +69474,7 @@ var FLAGS = {
69269
69474
  login: ["instance", "no-open"],
69270
69475
  add: ["name", "no-open"],
69271
69476
  use: ["none"],
69272
- skill: ["instance", "check", "json"],
69477
+ skill: ["instance", "check", "json", "refresh"],
69273
69478
  daemon: ["instance"],
69274
69479
  uninstall: ["purge"],
69275
69480
  "mcp-proof": ["token-file", "instance"],
@@ -69297,6 +69502,7 @@ function parse7(argv) {
69297
69502
  none: { type: "boolean", default: false },
69298
69503
  yes: { type: "boolean", short: "y", default: false },
69299
69504
  check: { type: "boolean", default: false },
69505
+ refresh: { type: "boolean", default: false },
69300
69506
  "no-service": { type: "boolean", default: false },
69301
69507
  alongside: { type: "boolean", default: false },
69302
69508
  habits: { type: "boolean", default: false },
@@ -69417,7 +69623,8 @@ function route(cmd, values, positionals) {
69417
69623
  cmd,
69418
69624
  hub: values.instance,
69419
69625
  check: values.check,
69420
- ...values.json ? { json: true } : {}
69626
+ ...values.json ? { json: true } : {},
69627
+ ...values.refresh ? { refresh: true } : {}
69421
69628
  };
69422
69629
  case "daemon":
69423
69630
  return { cmd, hub: values.instance };