@open-artifacts/bus 0.216.0 → 0.218.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
@@ -4586,7 +4586,7 @@ function isRef(value) {
4586
4586
  function cloneIssues(issues) {
4587
4587
  return issues.map((iss) => iss.path ? { ...iss, path: iss.path.slice() } : { ...iss });
4588
4588
  }
4589
- function isRecursive(inst, stack, resolve18) {
4589
+ function isRecursive(inst, stack, resolve19) {
4590
4590
  const cached2 = recursive.get(inst);
4591
4591
  if (cached2 !== void 0)
4592
4592
  return cached2 ? PROVEN : NONE;
@@ -4596,7 +4596,7 @@ function isRecursive(inst, stack, resolve18) {
4596
4596
  let result = NONE;
4597
4597
  const check2 = (child) => {
4598
4598
  if (result !== PROVEN && child?._zod) {
4599
- const answer = isRecursive(child, stack, resolve18);
4599
+ const answer = isRecursive(child, stack, resolve19);
4600
4600
  if (answer > result)
4601
4601
  result = answer;
4602
4602
  }
@@ -4607,7 +4607,7 @@ function isRecursive(inst, stack, resolve18) {
4607
4607
  const desc = Object.getOwnPropertyDescriptor(sh, key2);
4608
4608
  if (spread && !desc.enumerable)
4609
4609
  continue;
4610
- const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack, resolve18) : NONE;
4610
+ const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack, resolve19) : NONE;
4611
4611
  if (child > answer)
4612
4612
  answer = child;
4613
4613
  }
@@ -4671,7 +4671,7 @@ function isRecursive(inst, stack, resolve18) {
4671
4671
  break;
4672
4672
  // `$ZodLazy` caches its inner on the def, so a resolved edge is followed exactly
4673
4673
  case "lazy": {
4674
- const inner = def._cachedInner ?? (resolve18 ? inst._zod.innerType : void 0);
4674
+ const inner = def._cachedInner ?? (resolve19 ? inst._zod.innerType : void 0);
4675
4675
  merge2(inner ? isRecursive(inner, stack, false) : ASSUMED);
4676
4676
  break;
4677
4677
  }
@@ -23038,7 +23038,7 @@ var init_protocol = __esm({
23038
23038
  return;
23039
23039
  }
23040
23040
  const pollInterval = task2.pollInterval ?? this._options?.defaultTaskPollInterval ?? 1e3;
23041
- await new Promise((resolve18) => setTimeout(resolve18, pollInterval));
23041
+ await new Promise((resolve19) => setTimeout(resolve19, pollInterval));
23042
23042
  options?.signal?.throwIfAborted();
23043
23043
  }
23044
23044
  } catch (error62) {
@@ -23055,7 +23055,7 @@ var init_protocol = __esm({
23055
23055
  */
23056
23056
  request(request, resultSchema, options) {
23057
23057
  const { relatedRequestId, resumptionToken, onresumptiontoken, task, relatedTask } = options ?? {};
23058
- return new Promise((resolve18, reject) => {
23058
+ return new Promise((resolve19, reject) => {
23059
23059
  const earlyReject = (error62) => {
23060
23060
  reject(error62);
23061
23061
  };
@@ -23133,7 +23133,7 @@ var init_protocol = __esm({
23133
23133
  if (!parseResult.success) {
23134
23134
  reject(parseResult.error);
23135
23135
  } else {
23136
- resolve18(parseResult.data);
23136
+ resolve19(parseResult.data);
23137
23137
  }
23138
23138
  } catch (error62) {
23139
23139
  reject(error62);
@@ -23395,12 +23395,12 @@ var init_protocol = __esm({
23395
23395
  }
23396
23396
  } catch {
23397
23397
  }
23398
- return new Promise((resolve18, reject) => {
23398
+ return new Promise((resolve19, reject) => {
23399
23399
  if (signal.aborted) {
23400
23400
  reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
23401
23401
  return;
23402
23402
  }
23403
- const timeoutId = setTimeout(resolve18, interval);
23403
+ const timeoutId = setTimeout(resolve19, interval);
23404
23404
  signal.addEventListener("abort", () => {
23405
23405
  clearTimeout(timeoutId);
23406
23406
  reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
@@ -26427,7 +26427,7 @@ var require_compile = __commonJS({
26427
26427
  const schOrFunc = root.refs[ref];
26428
26428
  if (schOrFunc)
26429
26429
  return schOrFunc;
26430
- let _sch = resolve18.call(this, root, ref);
26430
+ let _sch = resolve19.call(this, root, ref);
26431
26431
  if (_sch === void 0) {
26432
26432
  const schema = (_a3 = root.localRefs) === null || _a3 === void 0 ? void 0 : _a3[ref];
26433
26433
  const { schemaId } = this.opts;
@@ -26454,7 +26454,7 @@ var require_compile = __commonJS({
26454
26454
  function sameSchemaEnv(s1, s2) {
26455
26455
  return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
26456
26456
  }
26457
- function resolve18(root, ref) {
26457
+ function resolve19(root, ref) {
26458
26458
  let sch;
26459
26459
  while (typeof (sch = this.refs[ref]) == "string")
26460
26460
  ref = sch;
@@ -27284,7 +27284,7 @@ var require_fast_uri = __commonJS({
27284
27284
  }
27285
27285
  return uri;
27286
27286
  }
27287
- function resolve18(baseURI, relativeURI, options) {
27287
+ function resolve19(baseURI, relativeURI, options) {
27288
27288
  const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
27289
27289
  const {
27290
27290
  parsed: baseParsed,
@@ -27317,49 +27317,49 @@ var require_fast_uri = __commonJS({
27317
27317
  schemelessOptions.skipEscape = true;
27318
27318
  return serialize(resolved, schemelessOptions);
27319
27319
  }
27320
- function resolveComponent(base3, relative7, options, skipNormalization) {
27320
+ function resolveComponent(base3, relative8, options, skipNormalization) {
27321
27321
  const target2 = {};
27322
27322
  if (!skipNormalization) {
27323
27323
  base3 = parse8(serialize(base3, options), options);
27324
- relative7 = parse8(serialize(relative7, options), options);
27324
+ relative8 = parse8(serialize(relative8, options), options);
27325
27325
  }
27326
27326
  options = options || {};
27327
- if (!options.tolerant && relative7.scheme) {
27328
- target2.scheme = relative7.scheme;
27329
- target2.userinfo = relative7.userinfo;
27330
- target2.host = relative7.host;
27331
- target2.port = relative7.port;
27332
- target2.path = removeDotSegments(relative7.path || "");
27333
- target2.query = relative7.query;
27327
+ if (!options.tolerant && relative8.scheme) {
27328
+ target2.scheme = relative8.scheme;
27329
+ target2.userinfo = relative8.userinfo;
27330
+ target2.host = relative8.host;
27331
+ target2.port = relative8.port;
27332
+ target2.path = removeDotSegments(relative8.path || "");
27333
+ target2.query = relative8.query;
27334
27334
  } else {
27335
- if (relative7.userinfo !== void 0 || relative7.host !== void 0 || relative7.port !== void 0) {
27336
- target2.userinfo = relative7.userinfo;
27337
- target2.host = relative7.host;
27338
- target2.port = relative7.port;
27339
- target2.path = removeDotSegments(relative7.path || "");
27340
- target2.query = relative7.query;
27335
+ if (relative8.userinfo !== void 0 || relative8.host !== void 0 || relative8.port !== void 0) {
27336
+ target2.userinfo = relative8.userinfo;
27337
+ target2.host = relative8.host;
27338
+ target2.port = relative8.port;
27339
+ target2.path = removeDotSegments(relative8.path || "");
27340
+ target2.query = relative8.query;
27341
27341
  } else {
27342
- if (!relative7.path) {
27342
+ if (!relative8.path) {
27343
27343
  target2.path = base3.path;
27344
- if (relative7.query !== void 0) {
27345
- target2.query = relative7.query;
27344
+ if (relative8.query !== void 0) {
27345
+ target2.query = relative8.query;
27346
27346
  } else {
27347
27347
  target2.query = base3.query;
27348
27348
  }
27349
27349
  } else {
27350
- if (relative7.path[0] === "/") {
27351
- target2.path = removeDotSegments(relative7.path);
27350
+ if (relative8.path[0] === "/") {
27351
+ target2.path = removeDotSegments(relative8.path);
27352
27352
  } else {
27353
27353
  if ((base3.userinfo !== void 0 || base3.host !== void 0 || base3.port !== void 0) && !base3.path) {
27354
- target2.path = "/" + relative7.path;
27354
+ target2.path = "/" + relative8.path;
27355
27355
  } else if (!base3.path) {
27356
- target2.path = relative7.path;
27356
+ target2.path = relative8.path;
27357
27357
  } else {
27358
- target2.path = base3.path.slice(0, base3.path.lastIndexOf("/") + 1) + relative7.path;
27358
+ target2.path = base3.path.slice(0, base3.path.lastIndexOf("/") + 1) + relative8.path;
27359
27359
  }
27360
27360
  target2.path = removeDotSegments(target2.path);
27361
27361
  }
27362
- target2.query = relative7.query;
27362
+ target2.query = relative8.query;
27363
27363
  }
27364
27364
  target2.userinfo = base3.userinfo;
27365
27365
  target2.host = base3.host;
@@ -27367,7 +27367,7 @@ var require_fast_uri = __commonJS({
27367
27367
  }
27368
27368
  target2.scheme = base3.scheme;
27369
27369
  }
27370
- target2.fragment = relative7.fragment;
27370
+ target2.fragment = relative8.fragment;
27371
27371
  return target2;
27372
27372
  }
27373
27373
  function equal(uriA, uriB, options) {
@@ -27653,7 +27653,7 @@ var require_fast_uri = __commonJS({
27653
27653
  var fastUri = {
27654
27654
  SCHEMES,
27655
27655
  normalize,
27656
- resolve: resolve18,
27656
+ resolve: resolve19,
27657
27657
  resolveComponent,
27658
27658
  equal,
27659
27659
  serialize,
@@ -31690,19 +31690,31 @@ function mergeConfigs(configs) {
31690
31690
  out.namespace = c.namespace;
31691
31691
  if (out.global === void 0 && c.global !== void 0)
31692
31692
  out.global = c.global;
31693
+ if (out.instance === void 0 && c.instance !== void 0)
31694
+ out.instance = c.instance;
31693
31695
  }
31694
31696
  return out;
31695
31697
  }
31696
- var CONFIG_FILE, BusConfigSchema;
31698
+ var CONFIG_FILE, InstanceHintSchema, BusConfigSchema;
31697
31699
  var init_config = __esm({
31698
31700
  "../bus-protocol/src/config.ts"() {
31699
31701
  "use strict";
31700
31702
  init_zod();
31701
31703
  init_namespace();
31702
31704
  CONFIG_FILE = ".oa-bus.json";
31705
+ InstanceHintSchema = external_exports.string().refine((raw) => {
31706
+ if (/[?#@\\\s]/.test(raw)) return false;
31707
+ try {
31708
+ const u = new URL(raw);
31709
+ return u.protocol === "https:" && !u.username && !u.password && !u.search && !u.hash && (u.pathname === "/" || u.pathname === "") && u.host !== "";
31710
+ } catch {
31711
+ return false;
31712
+ }
31713
+ }, "an instance must be one https address: host and port only");
31703
31714
  BusConfigSchema = external_exports.strictObject({
31704
31715
  namespace: NamespaceSchema.optional(),
31705
- global: external_exports.boolean().optional()
31716
+ global: external_exports.boolean().optional(),
31717
+ instance: InstanceHintSchema.optional()
31706
31718
  });
31707
31719
  }
31708
31720
  });
@@ -31882,9 +31894,9 @@ var init_device = __esm({
31882
31894
  BAD_LABEL_CHARS = new RegExp(BAD_NS_CHARS.source, "gu");
31883
31895
  MAX_LABEL_UNITS = 2 * LIMITS.maxLabelChars;
31884
31896
  newMachineLabel = (hostname3) => {
31885
- const clean = hostname3.normalize("NFC").replace(BAD_LABEL_CHARS, "").normalize("NFC");
31897
+ const clean2 = hostname3.normalize("NFC").replace(BAD_LABEL_CHARS, "").normalize("NFC");
31886
31898
  let out = "";
31887
- for (const ch of clean) {
31899
+ for (const ch of clean2) {
31888
31900
  if (out.length + ch.length > MAX_LABEL_UNITS) break;
31889
31901
  out += ch;
31890
31902
  }
@@ -32854,7 +32866,7 @@ var init_frames = __esm({
32854
32866
  late = { late: external_exports.array(external_exports.string().min(1)).optional() };
32855
32867
  isWellFormed2 = (s) => s.isWellFormed();
32856
32868
  WELL_FORMED = { message: "text is not well-formed unicode" };
32857
- CLIENT_VERSION = true ? "0.216.0" : "0.0.0";
32869
+ CLIENT_VERSION = true ? "0.218.0" : "0.0.0";
32858
32870
  clientVersion = {
32859
32871
  client_version: external_exports.string().min(1).max(64).optional()
32860
32872
  };
@@ -33352,8 +33364,8 @@ import { connect } from "node:net";
33352
33364
  async function connectDaemon(opts) {
33353
33365
  const sock = connect(opts.path);
33354
33366
  if (opts.unref) sock.unref();
33355
- await new Promise((resolve18, reject) => {
33356
- sock.once("connect", resolve18);
33367
+ await new Promise((resolve19, reject) => {
33368
+ sock.once("connect", resolve19);
33357
33369
  sock.once("error", reject);
33358
33370
  });
33359
33371
  const decoder = new LineDecoder();
@@ -33420,8 +33432,8 @@ async function connectDaemon(opts) {
33420
33432
  sock.on("error", (e) => failAll(e));
33421
33433
  sock.on("close", () => failAll(new Error("daemon connection closed")));
33422
33434
  let timer;
33423
- const welcomeRaw = await new Promise((resolve18, reject) => {
33424
- waiters.push({ resolve: resolve18, reject });
33435
+ const welcomeRaw = await new Promise((resolve19, reject) => {
33436
+ waiters.push({ resolve: resolve19, reject });
33425
33437
  timer = setTimeout(() => {
33426
33438
  reject(new Error("daemon did not answer hello"));
33427
33439
  sock.destroy();
@@ -33443,7 +33455,7 @@ async function connectDaemon(opts) {
33443
33455
  if (state === "closed")
33444
33456
  return Promise.reject(new Error("daemon connection closed"));
33445
33457
  const id = partial2.id ?? String(++seq2);
33446
- return new Promise((resolve18, reject) => {
33458
+ return new Promise((resolve19, reject) => {
33447
33459
  const ms = opts.requestTimeoutMs ?? 2e4;
33448
33460
  const timer2 = setTimeout(() => {
33449
33461
  if (pending.delete(id)) {
@@ -33460,7 +33472,7 @@ async function connectDaemon(opts) {
33460
33472
  clearTimeout(timer2);
33461
33473
  f(...a);
33462
33474
  };
33463
- pending.set(id, { resolve: done(resolve18), reject: done(reject) });
33475
+ pending.set(id, { resolve: done(resolve19), reject: done(reject) });
33464
33476
  holdWhilePending();
33465
33477
  sock.write(`${JSON.stringify({ v: 1, ...partial2, id })}
33466
33478
  `);
@@ -33485,7 +33497,7 @@ async function connectDaemon(opts) {
33485
33497
  };
33486
33498
  }
33487
33499
  function daemonStatus(opts) {
33488
- return new Promise((resolve18, reject) => {
33500
+ return new Promise((resolve19, reject) => {
33489
33501
  const sock = connect(opts.path);
33490
33502
  const decoder = new LineDecoder();
33491
33503
  const done = (f) => {
@@ -33522,7 +33534,7 @@ function daemonStatus(opts) {
33522
33534
  try {
33523
33535
  for (const raw of decoder.push(chunk)) {
33524
33536
  const f = DaemonFrame.parse(raw);
33525
- if (f.type === "status") return done(() => resolve18(f));
33537
+ if (f.type === "status") return done(() => resolve19(f));
33526
33538
  if (f.type === "error")
33527
33539
  return done(
33528
33540
  () => reject(
@@ -33541,7 +33553,7 @@ function daemonStatus(opts) {
33541
33553
  });
33542
33554
  }
33543
33555
  function daemonLinkProof(opts) {
33544
- return new Promise((resolve18, reject) => {
33556
+ return new Promise((resolve19, reject) => {
33545
33557
  const sock = connect(opts.path);
33546
33558
  const decoder = new LineDecoder();
33547
33559
  const done = (f) => {
@@ -33569,7 +33581,7 @@ function daemonLinkProof(opts) {
33569
33581
  try {
33570
33582
  for (const raw of decoder.push(chunk)) {
33571
33583
  const f = DaemonFrame.parse(raw);
33572
- if (f.type === "link_proofed") return done(() => resolve18(f.bound));
33584
+ if (f.type === "link_proofed") return done(() => resolve19(f.bound));
33573
33585
  if (f.type === "error")
33574
33586
  return done(() => reject(new Error(f.message)));
33575
33587
  }
@@ -33961,13 +33973,13 @@ async function clearStale(path) {
33961
33973
  code: "ENOTSOCK"
33962
33974
  });
33963
33975
  }
33964
- const live = await new Promise((resolve18) => {
33976
+ const live = await new Promise((resolve19) => {
33965
33977
  const probe2 = connect2(path);
33966
33978
  probe2.once("connect", () => {
33967
33979
  probe2.destroy();
33968
- resolve18(true);
33980
+ resolve19(true);
33969
33981
  });
33970
- probe2.once("error", () => resolve18(false));
33982
+ probe2.once("error", () => resolve19(false));
33971
33983
  });
33972
33984
  if (live) {
33973
33985
  throw Object.assign(new Error(`daemon already listening on ${path}`), {
@@ -33987,16 +33999,16 @@ async function serveDaemon(opts) {
33987
33999
  sock.once("close", () => sockets.delete(sock));
33988
34000
  handle(sock, opts);
33989
34001
  });
33990
- await new Promise((resolve18, reject) => {
34002
+ await new Promise((resolve19, reject) => {
33991
34003
  server4.once("error", reject);
33992
- server4.listen(opts.path, () => resolve18());
34004
+ server4.listen(opts.path, () => resolve19());
33993
34005
  });
33994
34006
  chmodSync(opts.path, 384);
33995
34007
  const st = statSync(opts.path);
33996
34008
  const mode = st.mode & 511;
33997
34009
  return {
33998
34010
  mode,
33999
- close: () => new Promise((resolve18) => {
34011
+ close: () => new Promise((resolve19) => {
34000
34012
  for (const s of sockets) s.destroy();
34001
34013
  let parked;
34002
34014
  try {
@@ -34014,7 +34026,7 @@ async function serveDaemon(opts) {
34014
34026
  } catch {
34015
34027
  }
34016
34028
  }
34017
- resolve18();
34029
+ resolve19();
34018
34030
  });
34019
34031
  })
34020
34032
  };
@@ -35060,7 +35072,7 @@ ${neutralize(a.text)}
35060
35072
  };
35061
35073
  }
35062
35074
  function inject(a) {
35063
- return new Promise((resolve18, reject) => {
35075
+ return new Promise((resolve19, reject) => {
35064
35076
  const sock = connect3(a.socketPath);
35065
35077
  let connected = false;
35066
35078
  const fail3 = (e) => {
@@ -35084,7 +35096,7 @@ function inject(a) {
35084
35096
  sock.once("finish", () => {
35085
35097
  clearTimeout(timer);
35086
35098
  sock.destroy();
35087
- resolve18();
35099
+ resolve19();
35088
35100
  });
35089
35101
  sock.end(`${JSON.stringify(frameOf(a))}
35090
35102
  `);
@@ -44030,12 +44042,12 @@ var init_proxy = __esm({
44030
44042
 
44031
44043
  // ../bus-adapter-opencode/src/session.ts
44032
44044
  import { execFile as execFile4 } from "node:child_process";
44033
- import { isAbsolute as isAbsolute9 } from "node:path";
44045
+ import { isAbsolute as isAbsolute10 } from "node:path";
44034
44046
  import { promisify as promisify2 } from "node:util";
44035
44047
  function directoryOf(s) {
44036
44048
  const loc = s.location;
44037
44049
  const dir = s.directory ?? loc?.directory;
44038
- return typeof dir === "string" && isAbsolute9(dir) ? dir : null;
44050
+ return typeof dir === "string" && isAbsolute10(dir) ? dir : null;
44039
44051
  }
44040
44052
  async function rootSession(sessionId, deps2) {
44041
44053
  const cache = deps2.cache ?? ROOTS;
@@ -44189,12 +44201,12 @@ var init_stdio2 = __esm({
44189
44201
  this.onclose?.();
44190
44202
  }
44191
44203
  send(message) {
44192
- return new Promise((resolve18) => {
44204
+ return new Promise((resolve19) => {
44193
44205
  const json4 = serializeMessage(message);
44194
44206
  if (this._stdout.write(json4)) {
44195
- resolve18();
44207
+ resolve19();
44196
44208
  } else {
44197
- this._stdout.once("drain", resolve18);
44209
+ this._stdout.once("drain", resolve19);
44198
44210
  }
44199
44211
  });
44200
44212
  }
@@ -44603,14 +44615,14 @@ var harnessSkills = {
44603
44615
  var harnessNames = Object.keys(harnessSkills);
44604
44616
 
44605
44617
  // src/main.ts
44606
- import { resolve as resolve17 } from "node:path";
44618
+ import { resolve as resolve18 } from "node:path";
44607
44619
  import { fileURLToPath as fileURLToPath7 } from "node:url";
44608
44620
 
44609
44621
  // ../bus-daemon/src/index.ts
44610
44622
  init_src3();
44611
44623
  import { randomBytes as randomBytes4 } from "node:crypto";
44612
- import { existsSync as existsSync7, lstatSync as lstatSync9, realpathSync as realpathSync9, writeFileSync as writeFileSync12 } from "node:fs";
44613
- import { basename as basename6, isAbsolute as isAbsolute7, join as join24 } from "node:path";
44624
+ import { existsSync as existsSync7, lstatSync as lstatSync9, realpathSync as realpathSync10, writeFileSync as writeFileSync12 } from "node:fs";
44625
+ import { basename as basename7, isAbsolute as isAbsolute8, join as join25 } from "node:path";
44614
44626
 
44615
44627
  // ../bus-adapter-opencode/src/version.ts
44616
44628
  var MIN_PROMPT_ID_VERSION = "2.0.0";
@@ -46893,7 +46905,7 @@ var TakenWatch = class {
46893
46905
  // ../bus-daemon/src/config-issues.ts
46894
46906
  init_src();
46895
46907
  import { realpathSync as realpathSync5 } from "node:fs";
46896
- import { dirname as dirname6, join as join12 } from "node:path";
46908
+ import { dirname as dirname6, join as join13 } from "node:path";
46897
46909
 
46898
46910
  // ../bus-daemon/src/global.ts
46899
46911
  import { randomBytes } from "node:crypto";
@@ -47001,30 +47013,175 @@ function writeGlobalDirs(dirs, h = home()) {
47001
47013
  // ../bus-daemon/src/namespace.ts
47002
47014
  init_src();
47003
47015
  import { execFileSync as execFileSync5 } from "node:child_process";
47004
- import { existsSync as existsSync3, realpathSync as realpathSync4 } from "node:fs";
47016
+ import { existsSync as existsSync4, realpathSync as realpathSync4 } from "node:fs";
47005
47017
  import {
47006
- basename as basename4,
47018
+ basename as basename5,
47007
47019
  dirname as dirname5,
47008
47020
  isAbsolute as isAbsolute5,
47009
- join as join11,
47021
+ join as join12,
47010
47022
  relative,
47011
47023
  resolve as resolve2
47012
47024
  } from "node:path";
47013
47025
 
47014
47026
  // ../bus-daemon/src/namespaces.ts
47015
- import { randomBytes as randomBytes2 } from "node:crypto";
47027
+ import { randomBytes as randomBytes3 } from "node:crypto";
47016
47028
  import {
47017
47029
  appendFileSync,
47030
+ chmodSync as chmodSync8,
47031
+ closeSync as closeSync7,
47032
+ mkdirSync as mkdirSync6,
47033
+ openSync as openSync7,
47034
+ renameSync as renameSync7,
47035
+ unlinkSync as unlinkSync3,
47036
+ writeSync as writeSync3
47037
+ } from "node:fs";
47038
+ import { basename as basename4, isAbsolute as isAbsolute4, join as join11 } from "node:path";
47039
+
47040
+ // ../bus-daemon/src/instances.ts
47041
+ import { randomBytes as randomBytes2 } from "node:crypto";
47042
+ import {
47018
47043
  chmodSync as chmodSync7,
47019
47044
  closeSync as closeSync6,
47045
+ existsSync as existsSync3,
47046
+ linkSync as linkSync2,
47020
47047
  mkdirSync as mkdirSync5,
47021
47048
  openSync as openSync6,
47022
- renameSync as renameSync7,
47049
+ readdirSync as readdirSync5,
47050
+ readFileSync as readFileSync9,
47051
+ statSync as statSync6,
47023
47052
  unlinkSync as unlinkSync2,
47024
47053
  writeSync as writeSync2
47025
47054
  } from "node:fs";
47026
- import { isAbsolute as isAbsolute4, join as join10 } from "node:path";
47027
- var namespacesFile = (h = home()) => join10(h, "namespaces.json");
47055
+ import { join as join10 } from "node:path";
47056
+ var MAIN_INSTANCE = "main";
47057
+ var NAME_RE2 = /^[a-z0-9-]{1,32}$/;
47058
+ function nameProblem(name) {
47059
+ if (name === MAIN_INSTANCE) return `"${MAIN_INSTANCE}" is reserved`;
47060
+ if (!NAME_RE2.test(name))
47061
+ return "a name uses lowercase letters, digits and dashes, 1 to 32 characters";
47062
+ return void 0;
47063
+ }
47064
+ var instancesDir = (h = home()) => join10(h, "instances");
47065
+ var instanceFile = (name, h = home()) => join10(instancesDir(h), `${name}.json`);
47066
+ function canonicalAddress(address) {
47067
+ try {
47068
+ const u = new URL(address.replace(/^ws(s?):/, "http$1:"));
47069
+ return `${u.origin}${u.pathname.replace(/\/+$/, "")}`;
47070
+ } catch {
47071
+ return void 0;
47072
+ }
47073
+ }
47074
+ function mainAddress(h) {
47075
+ try {
47076
+ const r = JSON.parse(readFileSync9(join10(h, "machine.json"), "utf8"));
47077
+ return typeof r.hub === "string" ? r.hub : void 0;
47078
+ } catch {
47079
+ return void 0;
47080
+ }
47081
+ }
47082
+ function addedNames(h) {
47083
+ let files2;
47084
+ try {
47085
+ files2 = readdirSync5(instancesDir(h));
47086
+ } catch {
47087
+ return [];
47088
+ }
47089
+ return files2.filter((f) => f.endsWith(".json")).map((f) => f.slice(0, -".json".length)).filter((n) => NAME_RE2.test(n) && n !== MAIN_INSTANCE).sort();
47090
+ }
47091
+ function listInstances(h = home()) {
47092
+ const list = [];
47093
+ const main2 = mainAddress(h);
47094
+ const added = addedNames(h);
47095
+ if (main2 !== void 0 || added.length === 0)
47096
+ list.push({ name: MAIN_INSTANCE, hub: main2 ?? "", main: true });
47097
+ for (const name of added) {
47098
+ let hub = "";
47099
+ try {
47100
+ const r = JSON.parse(readFileSync9(instanceFile(name, h), "utf8"));
47101
+ if (typeof r.hub === "string") hub = r.hub;
47102
+ } catch {
47103
+ }
47104
+ list.push({ name, hub, main: false });
47105
+ }
47106
+ return list;
47107
+ }
47108
+ function addProblem(name, address, h = home()) {
47109
+ const bad2 = nameProblem(name);
47110
+ if (bad2) return bad2;
47111
+ if (existsSync3(instanceFile(name, h)))
47112
+ return `an instance named ${name} already exists`;
47113
+ const want = canonicalAddress(address);
47114
+ const main2 = mainAddress(h);
47115
+ if (want !== void 0 && main2 !== void 0 && canonicalAddress(main2) === want)
47116
+ return `that address is already this machine's main instance`;
47117
+ for (const i of listInstances(h))
47118
+ if (!i.main && want !== void 0 && canonicalAddress(i.hub) === want)
47119
+ return `that address is already the instance ${i.name}`;
47120
+ return void 0;
47121
+ }
47122
+ function suggestName(address, h = home()) {
47123
+ let base3 = "instance";
47124
+ try {
47125
+ const host = new URL(address).hostname.split(".")[0] ?? "";
47126
+ const fit = host.toLowerCase().replace(/[^a-z0-9-]/g, "-").replace(/^-+|-+$/g, "").slice(0, 28);
47127
+ if (fit && fit !== MAIN_INSTANCE) base3 = fit;
47128
+ } catch {
47129
+ }
47130
+ let name = base3;
47131
+ for (let n = 2; existsSync3(instanceFile(name, h)); n++) name = `${base3}-${n}`;
47132
+ return name;
47133
+ }
47134
+ function saveInstance(c, h = home()) {
47135
+ const problem = addProblem(c.name, c.hub, h);
47136
+ if (problem) throw new Error(problem);
47137
+ checkHub(c.hub);
47138
+ const dir = instancesDir(h);
47139
+ mkdirSync5(h, { recursive: true, mode: 448 });
47140
+ mkdirSync5(dir, { recursive: true, mode: 448 });
47141
+ chmodSync7(dir, 448);
47142
+ const tmp = join10(dir, `.${c.name}.${randomBytes2(8).toString("hex")}.tmp`);
47143
+ const fd = openSync6(tmp, "wx", 384);
47144
+ try {
47145
+ writeSync2(
47146
+ fd,
47147
+ `${JSON.stringify(
47148
+ {
47149
+ name: c.name,
47150
+ hub: c.hub,
47151
+ machine_id: c.machine_id,
47152
+ label: c.label,
47153
+ machine_token: c.machine_token
47154
+ },
47155
+ null,
47156
+ 2
47157
+ )}
47158
+ `
47159
+ );
47160
+ } catch (e) {
47161
+ closeSync6(fd);
47162
+ unlinkSync2(tmp);
47163
+ throw e;
47164
+ }
47165
+ closeSync6(fd);
47166
+ try {
47167
+ chmodSync7(tmp, 384);
47168
+ linkSync2(tmp, instanceFile(c.name, h));
47169
+ } catch (e) {
47170
+ unlinkSync2(tmp);
47171
+ throw e;
47172
+ }
47173
+ unlinkSync2(tmp);
47174
+ }
47175
+
47176
+ // ../bus-daemon/src/namespaces.ts
47177
+ var namespacesFile = (h = home(), instance = MAIN_INSTANCE) => {
47178
+ if (instance !== MAIN_INSTANCE && nameProblem(instance))
47179
+ throw new Error(`not an instance name: ${instance}`);
47180
+ return join11(
47181
+ h,
47182
+ instance === MAIN_INSTANCE ? "namespaces.json" : `namespaces.${instance}.json`
47183
+ );
47184
+ };
47028
47185
  function readApprovals(file2 = namespacesFile()) {
47029
47186
  const own2 = readOwnFile(file2);
47030
47187
  if (own2.state === "none") return { entries: [] };
@@ -47045,10 +47202,12 @@ function readApprovals(file2 = namespacesFile()) {
47045
47202
  function isApproved(dir, namespace2, entries) {
47046
47203
  return entries.some((e) => e.namespace === namespace2 && sameDir(e.dir, dir));
47047
47204
  }
47048
- function writeApprovals(entries, h = home()) {
47049
- writePrivate(h, "namespaces.json", { approved: entries });
47205
+ function writeApprovals(entries, h = home(), instance = MAIN_INSTANCE) {
47206
+ writePrivate(h, basename4(namespacesFile(h, instance)), {
47207
+ approved: entries
47208
+ });
47050
47209
  }
47051
- var remotesFile = (h = home()) => join10(h, "remotes.json");
47210
+ var remotesFile = (h = home()) => join11(h, "remotes.json");
47052
47211
  function readRemotes(file2 = remotesFile()) {
47053
47212
  const own2 = readOwnFile(file2);
47054
47213
  if (own2.state === "none") return { entries: [] };
@@ -47070,35 +47229,35 @@ function writeRemotes(entries, h = home()) {
47070
47229
  writePrivate(h, "remotes.json", { recorded: entries });
47071
47230
  }
47072
47231
  function writePrivate(h, name, body) {
47073
- mkdirSync5(h, { recursive: true, mode: 448 });
47074
- chmodSync7(h, 448);
47075
- const tmp = join10(h, `.${name}.${randomBytes2(8).toString("hex")}.tmp`);
47076
- const fd = openSync6(tmp, "wx", 384);
47232
+ mkdirSync6(h, { recursive: true, mode: 448 });
47233
+ chmodSync8(h, 448);
47234
+ const tmp = join11(h, `.${name}.${randomBytes3(8).toString("hex")}.tmp`);
47235
+ const fd = openSync7(tmp, "wx", 384);
47077
47236
  try {
47078
- writeSync2(fd, `${JSON.stringify(body, null, 2)}
47237
+ writeSync3(fd, `${JSON.stringify(body, null, 2)}
47079
47238
  `);
47080
47239
  } catch (e) {
47081
- closeSync6(fd);
47082
- unlinkSync2(tmp);
47240
+ closeSync7(fd);
47241
+ unlinkSync3(tmp);
47083
47242
  throw e;
47084
47243
  }
47085
- closeSync6(fd);
47244
+ closeSync7(fd);
47086
47245
  try {
47087
- chmodSync7(tmp, 384);
47088
- renameSync7(tmp, join10(h, name));
47246
+ chmodSync8(tmp, 384);
47247
+ renameSync7(tmp, join11(h, name));
47089
47248
  } catch (e) {
47090
- unlinkSync2(tmp);
47249
+ unlinkSync3(tmp);
47091
47250
  throw e;
47092
47251
  }
47093
47252
  }
47094
47253
  function logApproval(entry, h = home(), now = /* @__PURE__ */ new Date()) {
47095
- const dir = join10(h, "logs");
47096
- mkdirSync5(dir, { recursive: true, mode: 448 });
47097
- const file2 = join10(dir, "approvals.log");
47254
+ const dir = join11(h, "logs");
47255
+ mkdirSync6(dir, { recursive: true, mode: 448 });
47256
+ const file2 = join11(dir, "approvals.log");
47098
47257
  const line = `${now.toISOString()} ${entry.action} dir=${JSON.stringify(entry.dir)} namespace=${JSON.stringify(entry.namespace)} tty=${entry.tty ? "yes" : "no"}
47099
47258
  `;
47100
47259
  appendFileSync(file2, line, { mode: 384 });
47101
- chmodSync7(file2, 384);
47260
+ chmodSync8(file2, 384);
47102
47261
  }
47103
47262
 
47104
47263
  // ../bus-daemon/src/namespace.ts
@@ -47135,7 +47294,7 @@ function resolveNamespace(start, deps2 = {}) {
47135
47294
  const root = (deps2.gitRoot ?? gitRoot)(cwd);
47136
47295
  let derived2 = namespaceFrom({
47137
47296
  remoteUrl,
47138
- gitRootName: root ? basename4(root) : null,
47297
+ gitRootName: root ? basename5(root) : null,
47139
47298
  cwd
47140
47299
  });
47141
47300
  const source = remoteUrl && normalizeRemote(remoteUrl) ? "git" : root ? "dir" : "cwd";
@@ -47191,12 +47350,12 @@ function pinRemote(rootPath, cwd, derived2, deps2, quiet) {
47191
47350
  const odd = oddGit(rootPath, cwd);
47192
47351
  const prior = priors.find((e) => e.namespace !== derived2) ?? priors[0];
47193
47352
  const root = prior?.dir ?? roots[0] ?? rootPath;
47194
- const marker = join11(root, ".git");
47353
+ const marker = join12(root, ".git");
47195
47354
  const write = (entries) => {
47196
47355
  if (deps2.recordRemote === false) return;
47197
47356
  try {
47198
47357
  writeRemotes(
47199
- entries.filter((e) => priors.includes(e) || existsSync3(e.dir)),
47358
+ entries.filter((e) => priors.includes(e) || existsSync4(e.dir)),
47200
47359
  dirname5(recordFile)
47201
47360
  );
47202
47361
  } catch (e) {
@@ -47221,7 +47380,7 @@ function pinRemote(rootPath, cwd, derived2, deps2, quiet) {
47221
47380
  deps2.issues?.setPending(marker, uid, void 0);
47222
47381
  return derived2;
47223
47382
  }
47224
- if (approved(join11(root, "x"), derived2, deps2)) {
47383
+ if (approved(join12(root, "x"), derived2, deps2)) {
47225
47384
  write([
47226
47385
  ...list.entries.map(
47227
47386
  (e) => priors.includes(e) ? { ...e, namespace: derived2 } : e
@@ -47258,7 +47417,7 @@ function recordRoots(root, cwd, deps2) {
47258
47417
  if (!common) return [real3];
47259
47418
  try {
47260
47419
  const c = realpathSync4(resolve2(cwd, common));
47261
- const key2 = basename4(c) === ".git" ? dirname5(c) : c;
47420
+ const key2 = basename5(c) === ".git" ? dirname5(c) : c;
47262
47421
  return key2 === real3 ? [real3] : [key2, real3];
47263
47422
  } catch {
47264
47423
  return [real3];
@@ -47577,7 +47736,7 @@ function scanConfigFiles(cwd, opts = {}) {
47577
47736
  function configPaths(cwd) {
47578
47737
  const out = [];
47579
47738
  for (let dir = cwd; ; dir = dirname6(dir)) {
47580
- out.push(join12(dir, CONFIG_FILE));
47739
+ out.push(join13(dir, CONFIG_FILE));
47581
47740
  if (dirname6(dir) === dir) return out;
47582
47741
  }
47583
47742
  }
@@ -48930,8 +49089,8 @@ function routeLocal(frame, hello, reply, ctx) {
48930
49089
  init_src2();
48931
49090
  init_src();
48932
49091
  import {
48933
- chmodSync as chmodSync8,
48934
- readFileSync as readFileSync9,
49092
+ chmodSync as chmodSync9,
49093
+ readFileSync as readFileSync10,
48935
49094
  renameSync as renameSync8,
48936
49095
  rmSync as rmSync3,
48937
49096
  writeFileSync as writeFileSync5
@@ -49162,7 +49321,7 @@ var SentStore = class {
49162
49321
  if (!this.file) return;
49163
49322
  let raw;
49164
49323
  try {
49165
- raw = JSON.parse(readFileSync9(this.file, "utf8"));
49324
+ raw = JSON.parse(readFileSync10(this.file, "utf8"));
49166
49325
  } catch {
49167
49326
  return;
49168
49327
  }
@@ -49228,7 +49387,7 @@ var SentStore = class {
49228
49387
  mode: 384,
49229
49388
  flag: "wx"
49230
49389
  });
49231
- chmodSync8(tmp, 384);
49390
+ chmodSync9(tmp, 384);
49232
49391
  renameSync8(tmp, this.file);
49233
49392
  } catch (e) {
49234
49393
  this.#log?.(
@@ -49349,12 +49508,12 @@ var Receipts = class {
49349
49508
  this.#waiting.delete(msgId);
49350
49509
  return Promise.resolve(w.final);
49351
49510
  }
49352
- return new Promise((resolve18) => {
49511
+ return new Promise((resolve19) => {
49353
49512
  const cancel = this.#after(ms, () => w.done?.(void 0));
49354
49513
  w.done = (f) => {
49355
49514
  cancel();
49356
49515
  this.#waiting.delete(msgId);
49357
- resolve18(f);
49516
+ resolve19(f);
49358
49517
  };
49359
49518
  });
49360
49519
  }
@@ -49418,20 +49577,20 @@ init_src3();
49418
49577
  init_src();
49419
49578
  import { createHash as createHash5, randomUUID } from "node:crypto";
49420
49579
  import {
49421
- chmodSync as chmodSync10,
49580
+ chmodSync as chmodSync11,
49422
49581
  lstatSync as lstatSync5,
49423
- mkdirSync as mkdirSync6,
49424
- readFileSync as readFileSync11,
49582
+ mkdirSync as mkdirSync7,
49583
+ readFileSync as readFileSync12,
49425
49584
  renameSync as renameSync10,
49426
49585
  rmSync as rmSync4,
49427
49586
  writeFileSync as writeFileSync7
49428
49587
  } from "node:fs";
49429
49588
  import { createServer as createServer2 } from "node:net";
49430
- import { dirname as dirname7, join as join13 } from "node:path";
49589
+ import { dirname as dirname7, join as join14 } from "node:path";
49431
49590
  import { createInterface } from "node:readline";
49432
49591
 
49433
49592
  // ../bus-daemon/src/transports/held.ts
49434
- import { chmodSync as chmodSync9, readFileSync as readFileSync10, renameSync as renameSync9, writeFileSync as writeFileSync6 } from "node:fs";
49593
+ import { chmodSync as chmodSync10, readFileSync as readFileSync11, renameSync as renameSync9, writeFileSync as writeFileSync6 } from "node:fs";
49435
49594
  var HeldStore = class {
49436
49595
  constructor(file2, opts = {}) {
49437
49596
  this.file = file2;
@@ -49460,7 +49619,7 @@ var HeldStore = class {
49460
49619
  #read() {
49461
49620
  let raw;
49462
49621
  try {
49463
- raw = JSON.parse(readFileSync10(this.file, "utf8"));
49622
+ raw = JSON.parse(readFileSync11(this.file, "utf8"));
49464
49623
  } catch {
49465
49624
  return {};
49466
49625
  }
@@ -49474,7 +49633,7 @@ var HeldStore = class {
49474
49633
  #write(all) {
49475
49634
  const tmp = `${this.file}.${process.pid}.tmp`;
49476
49635
  writeFileSync6(tmp, JSON.stringify(all), { mode: 384 });
49477
- chmodSync9(tmp, 384);
49636
+ chmodSync10(tmp, 384);
49478
49637
  renameSync9(tmp, this.file);
49479
49638
  }
49480
49639
  };
@@ -49521,7 +49680,7 @@ function returnKey(agentRef, namespace2, peerName, fromId) {
49521
49680
  function readReturnIndex(file2) {
49522
49681
  let raw;
49523
49682
  try {
49524
- raw = JSON.parse(readFileSync11(file2, "utf8"));
49683
+ raw = JSON.parse(readFileSync12(file2, "utf8"));
49525
49684
  } catch {
49526
49685
  return /* @__PURE__ */ Object.create(null);
49527
49686
  }
@@ -49558,7 +49717,7 @@ var ClaudeTransport = class {
49558
49717
  this.opts = opts;
49559
49718
  this.#held = opts.heldFile ? new HeldStore(opts.heldFile) : void 0;
49560
49719
  this.#injected = opts.heldFile ? new HeldStore(opts.heldFile.replace(/(\.json)?$/, ".injected.json")) : void 0;
49561
- const sample = join13(opts.socketsDir, "00000000.sock");
49720
+ const sample = join14(opts.socketsDir, "00000000.sock");
49562
49721
  if (Buffer.byteLength(sample) > MAX_SOCKET_PATH) {
49563
49722
  this.#disabled = `claude delivery disabled: return socket paths are too long for a unix socket (${Buffer.byteLength(sample)} > ${MAX_SOCKET_PATH} bytes under ${opts.socketsDir}); use a shorter OA_BUS_HOME`;
49564
49723
  opts.log?.(this.#disabled);
@@ -49691,22 +49850,22 @@ var ClaudeTransport = class {
49691
49850
  return { ok: false, reason: "closed", cause: st };
49692
49851
  }
49693
49852
  #waitFor(msgId, ms) {
49694
- return new Promise((resolve18) => {
49853
+ return new Promise((resolve19) => {
49695
49854
  const buffered = this.#buffered.get(msgId);
49696
49855
  if (buffered !== void 0) {
49697
49856
  this.#buffered.delete(msgId);
49698
- resolve18(buffered);
49857
+ resolve19(buffered);
49699
49858
  return;
49700
49859
  }
49701
49860
  const timer = setTimeout(() => {
49702
49861
  this.#waiting.delete(msgId);
49703
- resolve18(void 0);
49862
+ resolve19(void 0);
49704
49863
  }, ms);
49705
49864
  timer.unref();
49706
49865
  this.#waiting.set(msgId, (s) => {
49707
49866
  clearTimeout(timer);
49708
49867
  this.#waiting.delete(msgId);
49709
- resolve18(s);
49868
+ resolve19(s);
49710
49869
  });
49711
49870
  });
49712
49871
  }
@@ -49819,7 +49978,7 @@ var ClaudeTransport = class {
49819
49978
  return sink;
49820
49979
  }
49821
49980
  async #listen(key2, agentRef, namespace2, peerName, notice = false, revived, fromId) {
49822
- const path = join13(
49981
+ const path = join14(
49823
49982
  this.opts.socketsDir,
49824
49983
  `${notice ? randomUUID().slice(0, 8) : returnName(key2, this.#pathsInUse())}.sock`
49825
49984
  );
@@ -49827,8 +49986,8 @@ var ClaudeTransport = class {
49827
49986
  const unsafe = this.opts.prepareDir(this.opts.socketsDir);
49828
49987
  if (unsafe) throw new UnsafeDir(unsafe);
49829
49988
  } else {
49830
- mkdirSync6(this.opts.socketsDir, { recursive: true, mode: 448 });
49831
- chmodSync10(this.opts.socketsDir, 448);
49989
+ mkdirSync7(this.opts.socketsDir, { recursive: true, mode: 448 });
49990
+ chmodSync11(this.opts.socketsDir, 448);
49832
49991
  }
49833
49992
  rmSync4(path, { force: true });
49834
49993
  this.#paths.set(key2, path);
@@ -49856,11 +50015,11 @@ var ClaudeTransport = class {
49856
50015
  );
49857
50016
  })
49858
50017
  };
49859
- await new Promise((resolve18, reject) => {
50018
+ await new Promise((resolve19, reject) => {
49860
50019
  sink.server.once("error", reject);
49861
- sink.server.listen(path, () => resolve18());
50020
+ sink.server.listen(path, () => resolve19());
49862
50021
  });
49863
- chmodSync10(path, 384);
50022
+ chmodSync11(path, 384);
49864
50023
  return sink;
49865
50024
  }
49866
50025
  /** Paths of the sinks bound or binding now, by key. */
@@ -49901,7 +50060,7 @@ var ClaudeTransport = class {
49901
50060
  for (const [k, v] of keep) out[k] = v;
49902
50061
  const tmp = `${file2}.${process.pid}.tmp`;
49903
50062
  writeFileSync7(tmp, JSON.stringify(out), { mode: 384 });
49904
- chmodSync10(tmp, 384);
50063
+ chmodSync11(tmp, 384);
49905
50064
  renameSync10(tmp, file2);
49906
50065
  return out;
49907
50066
  } catch (e) {
@@ -49981,12 +50140,12 @@ async function shut(sink) {
49981
50140
  init_src2();
49982
50141
  init_src();
49983
50142
  import { execFile } from "node:child_process";
49984
- import { accessSync, constants as constants3, readFileSync as readFileSync12, statSync as statSync6 } from "node:fs";
50143
+ import { accessSync, constants as constants3, readFileSync as readFileSync13, statSync as statSync7 } from "node:fs";
49985
50144
  import { readFile } from "node:fs/promises";
49986
- import { delimiter, isAbsolute as isAbsolute6, join as join15 } from "node:path";
50145
+ import { delimiter, isAbsolute as isAbsolute6, join as join16 } from "node:path";
49987
50146
 
49988
50147
  // ../bus-daemon/src/codex-queue-store.ts
49989
- import { join as join14 } from "node:path";
50148
+ import { join as join15 } from "node:path";
49990
50149
  function sqliteReadOnlyHolds(version2) {
49991
50150
  const [major = 0, minor = 0] = version2.split(".").map(Number);
49992
50151
  return major > 22 || major === 22 && minor >= 13;
@@ -49996,7 +50155,7 @@ function readQueue(home2, thread, head) {
49996
50155
  if (!sqliteReadOnlyHolds(process.versions.node)) return void 0;
49997
50156
  const sqlite = process.getBuiltinModule?.("node:sqlite");
49998
50157
  if (!sqlite) return void 0;
49999
- const db = new sqlite.DatabaseSync(join14(home2, "queue_1.sqlite"), {
50158
+ const db = new sqlite.DatabaseSync(join15(home2, "queue_1.sqlite"), {
50000
50159
  readOnly: true
50001
50160
  });
50002
50161
  try {
@@ -50029,14 +50188,14 @@ function readQueue(home2, thread, head) {
50029
50188
  // ../bus-daemon/src/transports/codex.ts
50030
50189
  var CODEX_QUEUE_TIMEOUT_MS = 3e4;
50031
50190
  var CODEX_TEXT_CAP = 64 * 1024;
50032
- var codexBinFile = (busHome2) => join15(busHome2, "codex.json");
50191
+ var codexBinFile = (busHome2) => join16(busHome2, "codex.json");
50033
50192
  var codexBinPin = (bin) => `${JSON.stringify({ bin }, null, 2)}
50034
50193
  `;
50035
50194
  var CODEX_APP = "/Applications/ChatGPT.app";
50036
50195
  var CODEX_APP_ID = "com.openai.codex";
50037
50196
  var executable = (p) => {
50038
50197
  try {
50039
- if (!statSync6(p).isFile()) return false;
50198
+ if (!statSync7(p).isFile()) return false;
50040
50199
  accessSync(p, constants3.X_OK);
50041
50200
  return true;
50042
50201
  } catch {
@@ -50045,11 +50204,11 @@ var executable = (p) => {
50045
50204
  };
50046
50205
  function codexAppBin(app) {
50047
50206
  try {
50048
- const plist = readFileSync12(join15(app, "Contents", "Info.plist"), "utf8");
50207
+ const plist = readFileSync13(join16(app, "Contents", "Info.plist"), "utf8");
50049
50208
  const id = /<key>CFBundleIdentifier<\/key>\s*<string>([^<]*)<\/string>/.exec(
50050
50209
  plist
50051
50210
  )?.[1];
50052
- return id === CODEX_APP_ID ? join15(app, "Contents", "Resources", "codex") : void 0;
50211
+ return id === CODEX_APP_ID ? join16(app, "Contents", "Resources", "codex") : void 0;
50053
50212
  } catch {
50054
50213
  return void 0;
50055
50214
  }
@@ -50057,14 +50216,14 @@ function codexAppBin(app) {
50057
50216
  function resolveCodexBin(o) {
50058
50217
  if (o.configFile)
50059
50218
  try {
50060
- const raw = JSON.parse(readFileSync12(o.configFile, "utf8"));
50219
+ const raw = JSON.parse(readFileSync13(o.configFile, "utf8"));
50061
50220
  if (typeof raw.bin === "string" && isAbsolute6(raw.bin) && executable(raw.bin))
50062
50221
  return { path: raw.bin, from: "config" };
50063
50222
  } catch {
50064
50223
  }
50065
50224
  for (const dir of (o.path ?? "").split(delimiter)) {
50066
50225
  if (!isAbsolute6(dir)) continue;
50067
- const p = join15(dir, "codex");
50226
+ const p = join16(dir, "codex");
50068
50227
  if (executable(p)) return { path: p, from: "path" };
50069
50228
  }
50070
50229
  const app = o.app === null ? void 0 : codexAppBin(o.app ?? CODEX_APP);
@@ -50114,14 +50273,14 @@ function splitArgv0(args) {
50114
50273
  const real3 = ends.find((e) => {
50115
50274
  const p = args.slice(0, e);
50116
50275
  try {
50117
- return isAbsolute6(p) && statSync6(p).isFile();
50276
+ return isAbsolute6(p) && statSync7(p).isFile();
50118
50277
  } catch {
50119
50278
  return false;
50120
50279
  }
50121
50280
  });
50122
50281
  return words(args.slice(real3 ?? ends[0]));
50123
50282
  }
50124
- var execText = (cmd, args) => new Promise((resolve18) => {
50283
+ var execText = (cmd, args) => new Promise((resolve19) => {
50125
50284
  execFile(
50126
50285
  cmd,
50127
50286
  args,
@@ -50130,7 +50289,7 @@ var execText = (cmd, args) => new Promise((resolve18) => {
50130
50289
  timeout: 2e3,
50131
50290
  env: { ...process.env, LC_ALL: "C" }
50132
50291
  },
50133
- (err, stdout) => resolve18(err ? void 0 : stdout)
50292
+ (err, stdout) => resolve19(err ? void 0 : stdout)
50134
50293
  );
50135
50294
  });
50136
50295
  async function processArgs(pid) {
@@ -50153,17 +50312,17 @@ async function processArgs(pid) {
50153
50312
  return args ? splitArgv0(args) : void 0;
50154
50313
  }
50155
50314
  var START_ERRORS = /* @__PURE__ */ new Set(["ENOENT", "EACCES", "ENOEXEC"]);
50156
- var execCodex = (timeoutMs = CODEX_QUEUE_TIMEOUT_MS) => (bin, args, env2) => new Promise((resolve18, reject) => {
50315
+ var execCodex = (timeoutMs = CODEX_QUEUE_TIMEOUT_MS) => (bin, args, env2) => new Promise((resolve19, reject) => {
50157
50316
  execFile(
50158
50317
  bin,
50159
50318
  args,
50160
50319
  { timeout: timeoutMs, maxBuffer: 64 * 1024, env: env2 },
50161
50320
  (err, _stdout, stderr) => {
50162
- if (!err) return resolve18({ code: 0, stderr });
50321
+ if (!err) return resolve19({ code: 0, stderr });
50163
50322
  const e = err;
50164
50323
  if (typeof e.code === "string" && START_ERRORS.has(e.code))
50165
50324
  return reject(err);
50166
- resolve18({
50325
+ resolve19({
50167
50326
  // A maxBuffer kill is SIGTERM too, but carries its own string code.
50168
50327
  code: e.killed && e.signal === "SIGTERM" && typeof e.code !== "string" ? null : typeof e.code === "number" ? e.code : -1,
50169
50328
  stderr: String(stderr ?? "")
@@ -50368,17 +50527,17 @@ var CODEX_WAKE_TEXT = `Open Artifacts bus: messages are waiting for this thread.
50368
50527
  init_src2();
50369
50528
  import { execFile as execFile2 } from "node:child_process";
50370
50529
  var START_ERRORS2 = /* @__PURE__ */ new Set(["ENOENT", "EACCES"]);
50371
- var execSpawn = (timeoutMs, maxBuffer = 1024 * 1024) => (cmd, args) => new Promise((resolve18, reject) => {
50530
+ var execSpawn = (timeoutMs, maxBuffer = 1024 * 1024) => (cmd, args) => new Promise((resolve19, reject) => {
50372
50531
  execFile2(
50373
50532
  cmd,
50374
50533
  args,
50375
50534
  { timeout: timeoutMs, maxBuffer },
50376
50535
  (err, stdout, stderr) => {
50377
- if (!err) return resolve18({ code: 0, stdout, stderr });
50536
+ if (!err) return resolve19({ code: 0, stdout, stderr });
50378
50537
  const e = err;
50379
50538
  if (typeof e.code === "string" && START_ERRORS2.has(e.code))
50380
50539
  return reject(err);
50381
- resolve18({
50540
+ resolve19({
50382
50541
  code: e.killed || typeof e.code !== "number" ? null : e.code,
50383
50542
  stdout,
50384
50543
  stderr
@@ -50496,18 +50655,18 @@ var PiTransport = class {
50496
50655
  });
50497
50656
  if (!pushed) return { ok: false, reason: "closed" };
50498
50657
  this.#forget(mail.msg_id);
50499
- return new Promise((resolve18) => {
50658
+ return new Promise((resolve19) => {
50500
50659
  const timer = setTimeout(() => {
50501
50660
  this.#waiting.delete(mail.msg_id);
50502
50661
  this.#remember(mail.msg_id, agent.ref);
50503
- resolve18({ ok: false, reason: "timeout" });
50662
+ resolve19({ ok: false, reason: "timeout" });
50504
50663
  }, this.opts.ackTimeoutMs ?? 1e4);
50505
50664
  timer.unref();
50506
50665
  this.#waiting.set(mail.msg_id, {
50507
50666
  ref: agent.ref,
50508
50667
  done: (o) => {
50509
50668
  clearTimeout(timer);
50510
- resolve18(o);
50669
+ resolve19(o);
50511
50670
  }
50512
50671
  });
50513
50672
  });
@@ -50573,11 +50732,11 @@ var PiTransport = class {
50573
50732
  // ../bus-daemon/src/update/layout.ts
50574
50733
  import { createHash as createHash6 } from "node:crypto";
50575
50734
  import {
50576
- chmodSync as chmodSync11,
50735
+ chmodSync as chmodSync12,
50577
50736
  lstatSync as lstatSync6,
50578
- mkdirSync as mkdirSync7,
50579
- readdirSync as readdirSync5,
50580
- readFileSync as readFileSync13,
50737
+ mkdirSync as mkdirSync8,
50738
+ readdirSync as readdirSync6,
50739
+ readFileSync as readFileSync14,
50581
50740
  readlinkSync as readlinkSync2,
50582
50741
  realpathSync as realpathSync6,
50583
50742
  renameSync as renameSync11,
@@ -50585,13 +50744,13 @@ import {
50585
50744
  symlinkSync,
50586
50745
  writeFileSync as writeFileSync8
50587
50746
  } from "node:fs";
50588
- import { join as join16, relative as relative2, sep as sep2 } from "node:path";
50747
+ import { join as join17, relative as relative2, sep as sep2 } from "node:path";
50589
50748
  var SAFE_VERSION = /^[0-9A-Za-z][0-9A-Za-z._+-]{0,63}$/;
50590
50749
  var isSafeVersion = (v) => typeof v === "string" && SAFE_VERSION.test(v);
50591
- var versionsDir = (home2) => join16(home2, "versions");
50592
- var versionDir = (home2, v) => join16(versionsDir(home2), v);
50593
- var binPath = (home2) => join16(home2, "bin");
50594
- var stateFile = (home2) => join16(home2, "update.json");
50750
+ var versionsDir = (home2) => join17(home2, "versions");
50751
+ var versionDir = (home2, v) => join17(versionsDir(home2), v);
50752
+ var binPath = (home2) => join17(home2, "bin");
50753
+ var stateFile = (home2) => join17(home2, "update.json");
50595
50754
  var lstat = (path) => {
50596
50755
  try {
50597
50756
  return lstatSync6(path);
@@ -50625,7 +50784,7 @@ function currentVersion(home2) {
50625
50784
  }
50626
50785
  function readState(home2) {
50627
50786
  try {
50628
- const j = JSON.parse(readFileSync13(stateFile(home2), "utf8"));
50787
+ const j = JSON.parse(readFileSync14(stateFile(home2), "utf8"));
50629
50788
  return {
50630
50789
  armed: j.armed === true,
50631
50790
  ...isSafeVersion(j.current) ? { current: j.current } : {},
@@ -50638,7 +50797,7 @@ function readState(home2) {
50638
50797
  function writeState(home2, state) {
50639
50798
  let rest = {};
50640
50799
  try {
50641
- const old = JSON.parse(readFileSync13(stateFile(home2), "utf8"));
50800
+ const old = JSON.parse(readFileSync14(stateFile(home2), "utf8"));
50642
50801
  if (old !== null && typeof old === "object" && !Array.isArray(old))
50643
50802
  rest = old;
50644
50803
  } catch {
@@ -50651,7 +50810,7 @@ function writeState(home2, state) {
50651
50810
  try {
50652
50811
  writeFileSync8(tmp, `${JSON.stringify(next, null, 2)}
50653
50812
  `, { mode: 384 });
50654
- chmodSync11(tmp, 384);
50813
+ chmodSync12(tmp, 384);
50655
50814
  renameSync11(tmp, stateFile(home2));
50656
50815
  } catch (e) {
50657
50816
  rmSync5(tmp, { force: true });
@@ -50659,9 +50818,9 @@ function writeState(home2, state) {
50659
50818
  }
50660
50819
  }
50661
50820
  function ensureVersions(home2) {
50662
- mkdirSync7(versionsDir(home2), { recursive: true, mode: 448 });
50821
+ mkdirSync8(versionsDir(home2), { recursive: true, mode: 448 });
50663
50822
  if (!lstat(versionsDir(home2))?.isSymbolicLink())
50664
- chmodSync11(versionsDir(home2), 448);
50823
+ chmodSync12(versionsDir(home2), 448);
50665
50824
  mustBeSafe(realpathSync6(home2));
50666
50825
  mustBeSafe(versionsDir(home2));
50667
50826
  }
@@ -50671,7 +50830,7 @@ function migrate(home2, now = Date.now) {
50671
50830
  if (!st?.isDirectory() || st.isSymbolicLink()) return void 0;
50672
50831
  let v;
50673
50832
  try {
50674
- const j = JSON.parse(readFileSync13(join16(bin, "package.json"), "utf8"));
50833
+ const j = JSON.parse(readFileSync14(join17(bin, "package.json"), "utf8"));
50675
50834
  if (isSafeVersion(j?.version)) v = j.version;
50676
50835
  } catch {
50677
50836
  }
@@ -50680,22 +50839,22 @@ function migrate(home2, now = Date.now) {
50680
50839
  if (lstat(versionDir(home2, v)))
50681
50840
  rmSync5(versionDir(home2, v), { recursive: true, force: true });
50682
50841
  renameSync11(bin, versionDir(home2, v));
50683
- chmodSync11(versionDir(home2, v), 448);
50842
+ chmodSync12(versionDir(home2, v), 448);
50684
50843
  return v;
50685
50844
  }
50686
50845
  function stage(home2, version2, fill) {
50687
50846
  if (!isSafeVersion(version2)) throw new Error("not a version");
50688
50847
  ensureVersions(home2);
50689
50848
  const dest = versionDir(home2, version2);
50690
- const tmp = join16(versionsDir(home2), `.stage.${process.pid}`);
50849
+ const tmp = join17(versionsDir(home2), `.stage.${process.pid}`);
50691
50850
  rmSync5(tmp, { recursive: true, force: true });
50692
- mkdirSync7(tmp, { mode: 448 });
50851
+ mkdirSync8(tmp, { mode: 448 });
50693
50852
  try {
50694
50853
  fill(tmp);
50695
- chmodSync11(tmp, 448);
50854
+ chmodSync12(tmp, 448);
50696
50855
  mustBeSafe(tmp);
50697
50856
  if (lstat(dest)) {
50698
- const old = join16(versionsDir(home2), `.old.${process.pid}`);
50857
+ const old = join17(versionsDir(home2), `.old.${process.pid}`);
50699
50858
  rmSync5(old, { recursive: true, force: true });
50700
50859
  renameSync11(dest, old);
50701
50860
  renameSync11(tmp, dest);
@@ -50717,7 +50876,7 @@ function swap(home2, version2) {
50717
50876
  rmSync5(tmp, { recursive: true, force: true });
50718
50877
  try {
50719
50878
  symlinkSync(
50720
- join16("versions", version2),
50879
+ join17("versions", version2),
50721
50880
  tmp,
50722
50881
  process.platform === "win32" ? "junction" : void 0
50723
50882
  );
@@ -50729,7 +50888,7 @@ function swap(home2, version2) {
50729
50888
  throw e;
50730
50889
  }
50731
50890
  }
50732
- var liveDir = (versionPath) => join16(versionPath, ".live");
50891
+ var liveDir = (versionPath) => join17(versionPath, ".live");
50733
50892
  function inUse(versionPath, alive3 = pidAlive) {
50734
50893
  const dir = liveDir(versionPath);
50735
50894
  const st = lstat(dir);
@@ -50737,14 +50896,14 @@ function inUse(versionPath, alive3 = pidAlive) {
50737
50896
  if (!st.isDirectory()) return true;
50738
50897
  let names2;
50739
50898
  try {
50740
- names2 = readdirSync5(dir);
50899
+ names2 = readdirSync6(dir);
50741
50900
  } catch {
50742
50901
  return true;
50743
50902
  }
50744
50903
  let live = false;
50745
50904
  for (const n of names2) {
50746
50905
  if (!/^\d+$/.test(n)) continue;
50747
- const f = join16(dir, n);
50906
+ const f = join17(dir, n);
50748
50907
  const k = lstat(f);
50749
50908
  if (k?.isSymbolicLink()) rmSync5(f, { force: true });
50750
50909
  else if (!k?.isFile()) continue;
@@ -50761,9 +50920,9 @@ function markLive(entryFile, home2, pid = process.pid) {
50761
50920
  const v = rel[0];
50762
50921
  if (rel.length < 2 || v === void 0 || v === ".." || !MARKABLE.test(v))
50763
50922
  return void 0;
50764
- const vdir = join16(root, v);
50765
- mkdirSync7(liveDir(vdir), { recursive: true, mode: 448 });
50766
- const marker = join16(liveDir(vdir), String(pid));
50923
+ const vdir = join17(root, v);
50924
+ mkdirSync8(liveDir(vdir), { recursive: true, mode: 448 });
50925
+ const marker = join17(liveDir(vdir), String(pid));
50767
50926
  writeFileSync8(marker, "", { mode: 384 });
50768
50927
  process.once("exit", () => rmSync5(marker, { force: true }));
50769
50928
  return marker;
@@ -50777,19 +50936,19 @@ function prune(home2, keep, opts = {}) {
50777
50936
  if (unsafeDir(dir) !== void 0 || !lstat(dir)) return [];
50778
50937
  const keepSet = new Set(keep.filter((k) => k !== void 0));
50779
50938
  const removed = [];
50780
- for (const name of readdirSync5(dir)) {
50939
+ for (const name of readdirSync6(dir)) {
50781
50940
  if (keepSet.has(name)) continue;
50782
- const st = lstat(join16(dir, name));
50941
+ const st = lstat(join17(dir, name));
50783
50942
  if (!st) continue;
50784
50943
  if (st.isSymbolicLink()) {
50785
- rmSync5(join16(dir, name), { force: true });
50944
+ rmSync5(join17(dir, name), { force: true });
50786
50945
  removed.push(name);
50787
50946
  continue;
50788
50947
  }
50789
50948
  if (!st.isDirectory()) continue;
50790
50949
  const m = /^\.(stage|old)\.(\d+)$/.exec(name);
50791
- if (m ? alive3(Number(m[2])) : inUse(join16(dir, name), alive3)) continue;
50792
- rmSync5(join16(dir, name), { recursive: true, force: true });
50950
+ if (m ? alive3(Number(m[2])) : inUse(join17(dir, name), alive3)) continue;
50951
+ rmSync5(join17(dir, name), { recursive: true, force: true });
50793
50952
  removed.push(name);
50794
50953
  }
50795
50954
  return removed;
@@ -50830,16 +50989,16 @@ var MAX_TREE_FILES = 5e3;
50830
50989
  function hashTree(dir) {
50831
50990
  const out = {};
50832
50991
  const walk = (abs, rel) => {
50833
- for (const name of readdirSync5(abs).sort()) {
50992
+ for (const name of readdirSync6(abs).sort()) {
50834
50993
  if (rel === "" && name === ".live") continue;
50835
- const p = join16(abs, name);
50994
+ const p = join17(abs, name);
50836
50995
  const r = rel === "" ? name : `${rel}/${name}`;
50837
50996
  const st = lstatSync6(p);
50838
50997
  if (st.isDirectory()) walk(p, r);
50839
50998
  else if (st.isFile()) {
50840
50999
  if (Object.keys(out).length >= MAX_TREE_FILES)
50841
51000
  throw new Error("too many files");
50842
- out[r] = createHash6("sha256").update(readFileSync13(p)).digest("hex");
51001
+ out[r] = createHash6("sha256").update(readFileSync14(p)).digest("hex");
50843
51002
  } else throw new Error(`${r} is not a plain file`);
50844
51003
  }
50845
51004
  };
@@ -50857,9 +51016,9 @@ function treeMatches(dir, manifest) {
50857
51016
  }
50858
51017
 
50859
51018
  // ../bus-daemon/src/update/login-flag.ts
50860
- import { readFileSync as readFileSync14, rmSync as rmSync6, writeFileSync as writeFileSync9 } from "node:fs";
50861
- import { join as join17 } from "node:path";
50862
- var loginFlagFile = (home2) => join17(home2, "login.active");
51019
+ import { readFileSync as readFileSync15, rmSync as rmSync6, writeFileSync as writeFileSync9 } from "node:fs";
51020
+ import { join as join18 } from "node:path";
51021
+ var loginFlagFile = (home2) => join18(home2, "login.active");
50863
51022
  var LOGIN_FLAG_MAX_MS = 15 * 6e4;
50864
51023
  var alive2 = (pid) => {
50865
51024
  try {
@@ -50883,7 +51042,7 @@ function markLoginActive(home2, now = Date.now) {
50883
51042
  }
50884
51043
  function loginActive(home2, now = Date.now, isAlive = alive2) {
50885
51044
  try {
50886
- const [pid, at] = readFileSync14(loginFlagFile(home2), "utf8").trim().split(" ").map(Number);
51045
+ const [pid, at] = readFileSync15(loginFlagFile(home2), "utf8").trim().split(" ").map(Number);
50887
51046
  return Number.isInteger(pid) && Number.isFinite(at) && Math.abs(now() - at) < LOGIN_FLAG_MAX_MS && isAlive(pid);
50888
51047
  } catch {
50889
51048
  return false;
@@ -51014,15 +51173,15 @@ function label(s, now) {
51014
51173
 
51015
51174
  // ../bus-daemon/src/update/reports.ts
51016
51175
  import {
51017
- chmodSync as chmodSync12,
51018
- readFileSync as readFileSync15,
51176
+ chmodSync as chmodSync13,
51177
+ readFileSync as readFileSync16,
51019
51178
  renameSync as renameSync12,
51020
51179
  rmSync as rmSync7,
51021
51180
  writeFileSync as writeFileSync10
51022
51181
  } from "node:fs";
51023
- import { join as join18 } from "node:path";
51182
+ import { join as join19 } from "node:path";
51024
51183
  var MAX_REPORTS = 50;
51025
- var reportFile = (home2) => join18(home2, "update-reports.json");
51184
+ var reportFile = (home2) => join19(home2, "update-reports.json");
51026
51185
  var EVENTS = /* @__PURE__ */ new Set([
51027
51186
  "updated",
51028
51187
  "stepped_back",
@@ -51033,7 +51192,7 @@ var EVENTS = /* @__PURE__ */ new Set([
51033
51192
  var REASON = /^[a-z0-9_]{1,40}$/;
51034
51193
  function readReports(home2) {
51035
51194
  try {
51036
- const j = JSON.parse(readFileSync15(reportFile(home2), "utf8"));
51195
+ const j = JSON.parse(readFileSync16(reportFile(home2), "utf8"));
51037
51196
  if (!Array.isArray(j)) return [];
51038
51197
  return j.filter(
51039
51198
  (r) => r !== null && typeof r === "object" && EVENTS.has(r.event) && typeof r.from === "string" && typeof r.to === "string" && REASON.test(r.reason) && typeof r.at === "number"
@@ -51049,7 +51208,7 @@ function queueReport(home2, r) {
51049
51208
  const list = [...readReports(home2), r].slice(-MAX_REPORTS);
51050
51209
  writeFileSync10(tmp, `${JSON.stringify(list)}
51051
51210
  `, { mode: 384 });
51052
- chmodSync12(tmp, 384);
51211
+ chmodSync13(tmp, 384);
51053
51212
  renameSync12(tmp, reportFile(home2));
51054
51213
  } catch {
51055
51214
  rmSync7(tmp, { force: true });
@@ -51068,7 +51227,7 @@ function removeReports(home2, sent) {
51068
51227
  }
51069
51228
  writeFileSync10(tmp, `${JSON.stringify(left)}
51070
51229
  `, { mode: 384 });
51071
- chmodSync12(tmp, 384);
51230
+ chmodSync13(tmp, 384);
51072
51231
  renameSync12(tmp, reportFile(home2));
51073
51232
  } catch {
51074
51233
  rmSync7(tmp, { force: true });
@@ -51076,7 +51235,7 @@ function removeReports(home2, sent) {
51076
51235
  }
51077
51236
  function readRescueVersion(home2) {
51078
51237
  try {
51079
- const head = readFileSync15(join18(home2, "rescue.mjs"), "utf8").slice(0, 200);
51238
+ const head = readFileSync16(join19(home2, "rescue.mjs"), "utf8").slice(0, 200);
51080
51239
  const n = /Rescue shim (\d{1,6})\./.exec(head)?.[1];
51081
51240
  return n === void 0 ? 0 : Number(n);
51082
51241
  } catch {
@@ -51085,22 +51244,22 @@ function readRescueVersion(home2) {
51085
51244
  }
51086
51245
 
51087
51246
  // ../bus-daemon/src/update/selfcheck.ts
51088
- import { existsSync as existsSync4 } from "node:fs";
51247
+ import { existsSync as existsSync5 } from "node:fs";
51089
51248
 
51090
51249
  // ../bus-daemon/src/update/state.ts
51091
51250
  import {
51092
- chmodSync as chmodSync13,
51251
+ chmodSync as chmodSync14,
51093
51252
  lstatSync as lstatSync7,
51094
- readFileSync as readFileSync16,
51253
+ readFileSync as readFileSync17,
51095
51254
  renameSync as renameSync13,
51096
51255
  rmSync as rmSync8,
51097
51256
  writeFileSync as writeFileSync11
51098
51257
  } from "node:fs";
51099
- import { join as join19 } from "node:path";
51258
+ import { join as join20 } from "node:path";
51100
51259
  function load(home2) {
51101
51260
  let text3;
51102
51261
  try {
51103
- text3 = readFileSync16(stateFile(home2), "utf8");
51262
+ text3 = readFileSync17(stateFile(home2), "utf8");
51104
51263
  } catch (e) {
51105
51264
  return e.code === "ENOENT" ? { kind: "missing" } : { kind: "bad" };
51106
51265
  }
@@ -51189,7 +51348,7 @@ function put(home2, next) {
51189
51348
  try {
51190
51349
  writeFileSync11(tmp, `${JSON.stringify(next, null, 2)}
51191
51350
  `, { mode: 384 });
51192
- chmodSync13(tmp, 384);
51351
+ chmodSync14(tmp, 384);
51193
51352
  renameSync13(tmp, stateFile(home2));
51194
51353
  } catch (e) {
51195
51354
  rmSync8(tmp, { force: true });
@@ -51295,7 +51454,7 @@ var noteRun = (home2, version2) => editPolicy(home2, (s) => {
51295
51454
  if (parseVersion(version2) && (s.newestRun === void 0 || compareVersions2(version2, s.newestRun) === 1))
51296
51455
  s.newestRun = version2;
51297
51456
  });
51298
- var requestFile = (home2) => join19(home2, "update-request.json");
51457
+ var requestFile = (home2) => join20(home2, "update-request.json");
51299
51458
  var REQUEST_STALE_MS = 5 * 6e4;
51300
51459
  function requestInstall(home2, version2, at) {
51301
51460
  if (!parseVersion(version2)) return false;
@@ -51337,7 +51496,7 @@ function requestOk(path) {
51337
51496
  function readInstallRequest(home2) {
51338
51497
  if (!requestOk(requestFile(home2))) return void 0;
51339
51498
  try {
51340
- return parseRequest(readFileSync16(requestFile(home2), "utf8"));
51499
+ return parseRequest(readFileSync17(requestFile(home2), "utf8"));
51341
51500
  } catch {
51342
51501
  return void 0;
51343
51502
  }
@@ -51351,7 +51510,7 @@ function takeInstallRequest(home2) {
51351
51510
  }
51352
51511
  try {
51353
51512
  if (!requestOk(taken)) return void 0;
51354
- return parseRequest(readFileSync16(taken, "utf8"));
51513
+ return parseRequest(readFileSync17(taken, "utf8"));
51355
51514
  } catch {
51356
51515
  return void 0;
51357
51516
  } finally {
@@ -51393,7 +51552,7 @@ function completeUpdate(home2, p, now) {
51393
51552
  }
51394
51553
  function abandonUpdate(home2, p, now, reason2, blame = "failed") {
51395
51554
  let back = false;
51396
- if (isSafeVersion(p.from) && existsSync4(versionDir(home2, p.from))) {
51555
+ if (isSafeVersion(p.from) && existsSync5(versionDir(home2, p.from))) {
51397
51556
  try {
51398
51557
  swap(home2, p.from);
51399
51558
  const st = readState(home2);
@@ -51516,13 +51675,13 @@ function startSelfCheck(d) {
51516
51675
 
51517
51676
  // ../bus-daemon/src/update/updater.ts
51518
51677
  import {
51519
- chmodSync as chmodSync14,
51678
+ chmodSync as chmodSync15,
51520
51679
  copyFileSync,
51521
- existsSync as existsSync5,
51522
- readFileSync as readFileSync17,
51680
+ existsSync as existsSync6,
51681
+ readFileSync as readFileSync18,
51523
51682
  rmSync as rmSync9
51524
51683
  } from "node:fs";
51525
- import { join as join21 } from "node:path";
51684
+ import { join as join22 } from "node:path";
51526
51685
 
51527
51686
  // ../bus-daemon/src/update/errors.ts
51528
51687
  var ReleaseError = class extends Error {
@@ -51701,14 +51860,14 @@ async function fetchRelease(version2, doFetch = globalThis.fetch) {
51701
51860
 
51702
51861
  // ../bus-daemon/src/update/tar.ts
51703
51862
  import {
51704
- closeSync as closeSync7,
51863
+ closeSync as closeSync8,
51705
51864
  constants as constants4,
51706
- mkdirSync as mkdirSync8,
51707
- openSync as openSync7,
51865
+ mkdirSync as mkdirSync9,
51866
+ openSync as openSync8,
51708
51867
  realpathSync as realpathSync7,
51709
- writeSync as writeSync3
51868
+ writeSync as writeSync4
51710
51869
  } from "node:fs";
51711
- import { basename as basename5, dirname as dirname8, join as join20, relative as relative3, resolve as resolve3, sep as sep3 } from "node:path";
51870
+ import { basename as basename6, dirname as dirname8, join as join21, relative as relative3, resolve as resolve3, sep as sep3 } from "node:path";
51712
51871
  import { gunzipSync } from "node:zlib";
51713
51872
  var BLOCK = 512;
51714
51873
  var FILE_RE = /^package\/(package\.json|LICENSE|dist\/.+|assets\/.+)$/;
@@ -51781,14 +51940,14 @@ function readTarball(gz) {
51781
51940
  else return bad(`entry type ${JSON.stringify(typeflag)} not allowed`);
51782
51941
  if (type === "dir" && size !== 0) bad("directory with data");
51783
51942
  if (entries.length >= LIMITS2.maxEntries) bad("too many entries");
51784
- const clean = type === "dir" && name.endsWith("/") ? name.slice(0, -1) : name;
51785
- checkName(clean);
51786
- if (type === "file" ? !FILE_RE.test(clean) : !DIR_RE.test(clean))
51943
+ const clean2 = type === "dir" && name.endsWith("/") ? name.slice(0, -1) : name;
51944
+ checkName(clean2);
51945
+ if (type === "file" ? !FILE_RE.test(clean2) : !DIR_RE.test(clean2))
51787
51946
  bad("path not allowed");
51788
- if (seen2.has(clean)) bad("duplicate entry");
51789
- const folded = clean.toLowerCase();
51947
+ if (seen2.has(clean2)) bad("duplicate entry");
51948
+ const folded = clean2.toLowerCase();
51790
51949
  if (seenFolded.has(folded)) bad("case-colliding entry");
51791
- seen2.add(clean);
51950
+ seen2.add(clean2);
51792
51951
  seenFolded.add(folded);
51793
51952
  if (size > LIMITS2.maxFileBytes) bad("file too large");
51794
51953
  total += size;
@@ -51797,7 +51956,7 @@ function readTarball(gz) {
51797
51956
  const end = start + size;
51798
51957
  if (end > tar.length) bad("truncated data");
51799
51958
  entries.push({
51800
- path: clean,
51959
+ path: clean2,
51801
51960
  type,
51802
51961
  data: Buffer.from(tar.subarray(start, end))
51803
51962
  });
@@ -51830,23 +51989,23 @@ function unpackTo(entries, dest) {
51830
51989
  if (rel === "") continue;
51831
51990
  const target2 = within2(rel);
51832
51991
  if (e.type === "dir") {
51833
- mkdirSync8(target2, { recursive: true, mode: 448 });
51992
+ mkdirSync9(target2, { recursive: true, mode: 448 });
51834
51993
  continue;
51835
51994
  }
51836
- mkdirSync8(dirname8(target2), { recursive: true, mode: 448 });
51995
+ mkdirSync9(dirname8(target2), { recursive: true, mode: 448 });
51837
51996
  const parent = realpathSync7(dirname8(target2));
51838
51997
  if (parent !== root && !parent.startsWith(root + sep3))
51839
51998
  bad("parent escapes the destination");
51840
- const fd = openSync7(
51841
- join20(parent, basename5(target2)),
51999
+ const fd = openSync8(
52000
+ join21(parent, basename6(target2)),
51842
52001
  constants4.O_WRONLY | constants4.O_CREAT | constants4.O_EXCL | constants4.O_NOFOLLOW,
51843
52002
  384
51844
52003
  );
51845
52004
  try {
51846
52005
  let n = 0;
51847
- while (n < e.data.length) n += writeSync3(fd, e.data, n);
52006
+ while (n < e.data.length) n += writeSync4(fd, e.data, n);
51848
52007
  } finally {
51849
- closeSync7(fd);
52008
+ closeSync8(fd);
51850
52009
  }
51851
52010
  }
51852
52011
  }
@@ -52477,16 +52636,16 @@ var Updater = class {
52477
52636
  });
52478
52637
  return { kind: "needs_you" };
52479
52638
  }
52480
- const launcher = join21(versionDir(home2, from), "node");
52639
+ const launcher = join22(versionDir(home2, from), "node");
52481
52640
  let manifest;
52482
52641
  try {
52483
52642
  const dest = stage(home2, i.version, (dir) => {
52484
52643
  unpackTo(verified2.entries, dir);
52485
- if (!existsSync5(join21(dir, "dist", "index.js")))
52644
+ if (!existsSync6(join22(dir, "dist", "index.js")))
52486
52645
  throw new Error("no dist/index.js");
52487
- if (existsSync5(launcher)) {
52488
- copyFileSync(launcher, join21(dir, "node"));
52489
- chmodSync14(join21(dir, "node"), 448);
52646
+ if (existsSync6(launcher)) {
52647
+ copyFileSync(launcher, join22(dir, "node"));
52648
+ chmodSync15(join22(dir, "node"), 448);
52490
52649
  }
52491
52650
  });
52492
52651
  manifest = hashTree(dest);
@@ -52516,7 +52675,7 @@ var Updater = class {
52516
52675
  try {
52517
52676
  return settingsKinds(
52518
52677
  JSON.parse(
52519
- readFileSync17(join21(versionDir(home2, running), "package.json"), "utf8")
52678
+ readFileSync18(join22(versionDir(home2, running), "package.json"), "utf8")
52520
52679
  )
52521
52680
  );
52522
52681
  } catch {
@@ -52621,7 +52780,7 @@ var Updater = class {
52621
52780
  clearStaged(home2);
52622
52781
  return { kind: "refused", reason: "not_forward" };
52623
52782
  }
52624
- } else if (!existsSync5(versionDir(home2, version2))) {
52783
+ } else if (!existsSync6(versionDir(home2, version2))) {
52625
52784
  return { kind: "refused", reason: "nothing_staged" };
52626
52785
  }
52627
52786
  const proven = s.staged?.manifest;
@@ -52830,148 +52989,133 @@ function createEventLog(file2, opts = {}) {
52830
52989
  return log;
52831
52990
  }
52832
52991
 
52833
- // ../bus-daemon/src/instances.ts
52834
- import { randomBytes as randomBytes3 } from "node:crypto";
52835
- import {
52836
- chmodSync as chmodSync15,
52837
- closeSync as closeSync8,
52838
- existsSync as existsSync6,
52839
- linkSync as linkSync2,
52840
- mkdirSync as mkdirSync9,
52841
- openSync as openSync8,
52842
- readdirSync as readdirSync6,
52843
- readFileSync as readFileSync18,
52844
- statSync as statSync7,
52845
- unlinkSync as unlinkSync3,
52846
- writeSync as writeSync4
52847
- } from "node:fs";
52848
- import { join as join22 } from "node:path";
52849
- var MAIN_INSTANCE = "main";
52850
- var NAME_RE2 = /^[a-z0-9-]{1,32}$/;
52851
- function nameProblem(name) {
52852
- if (name === MAIN_INSTANCE) return `"${MAIN_INSTANCE}" is reserved`;
52853
- if (!NAME_RE2.test(name))
52854
- return "a name uses lowercase letters, digits and dashes, 1 to 32 characters";
52855
- return void 0;
52856
- }
52857
- var instancesDir = (h = home()) => join22(h, "instances");
52858
- var instanceFile = (name, h = home()) => join22(instancesDir(h), `${name}.json`);
52859
- function canonicalAddress(address) {
52992
+ // ../bus-daemon/src/folders.ts
52993
+ init_src();
52994
+ import { execFileSync as execFileSync6 } from "node:child_process";
52995
+ import { realpathSync as realpathSync8 } from "node:fs";
52996
+ import { dirname as dirname10, isAbsolute as isAbsolute7, join as join23, relative as relative4, resolve as resolve4, sep as sep4 } from "node:path";
52997
+ var foldersFile = (h = home()) => join23(h, "folders.json");
52998
+ var strMap = (v) => {
52999
+ if (v === void 0) return {};
53000
+ if (typeof v !== "object" || v === null || Array.isArray(v)) return void 0;
53001
+ const out = {};
53002
+ for (const [k, x] of Object.entries(v)) {
53003
+ if (typeof x !== "string" || !isAbsolute7(k)) return void 0;
53004
+ out[k] = x;
53005
+ }
53006
+ return out;
53007
+ };
53008
+ function inspectFolders(h = home()) {
53009
+ const none2 = { map: {}, no: {}, seen: {} };
53010
+ const own2 = readOwnFile(foldersFile(h));
53011
+ if (own2.state === "none") return { folders: none2, unusable: false };
53012
+ if (own2.state !== "ok") return { folders: none2, unusable: true };
52860
53013
  try {
52861
- const u = new URL(address.replace(/^ws(s?):/, "http$1:"));
52862
- return `${u.origin}${u.pathname.replace(/\/+$/, "")}`;
53014
+ const raw = JSON.parse(own2.text);
53015
+ if (!raw || typeof raw !== "object" || Array.isArray(raw))
53016
+ return { folders: none2, unusable: true };
53017
+ const map2 = strMap(raw.map);
53018
+ const no2 = strMap(raw.no);
53019
+ const seen2 = strMap(raw.seen);
53020
+ return map2 && no2 && seen2 ? { folders: { map: map2, no: no2, seen: seen2 }, unusable: false } : { folders: none2, unusable: true };
52863
53021
  } catch {
52864
- return void 0;
53022
+ return { folders: none2, unusable: true };
52865
53023
  }
52866
53024
  }
52867
- function mainAddress(h) {
53025
+ var readFolders = (h = home()) => inspectFolders(h).folders;
53026
+ function writeFolders(f, h = home()) {
53027
+ writePrivate(h, "folders.json", f);
53028
+ }
53029
+ var git2 = (cwd) => {
52868
53030
  try {
52869
- const r = JSON.parse(readFileSync18(join22(h, "machine.json"), "utf8"));
52870
- return typeof r.hub === "string" ? r.hub : void 0;
53031
+ return execFileSync6("git", ["-C", cwd, "rev-parse", "--show-toplevel"], {
53032
+ encoding: "utf8",
53033
+ stdio: ["ignore", "pipe", "ignore"]
53034
+ }).trim() || null;
52871
53035
  } catch {
52872
- return void 0;
53036
+ return null;
52873
53037
  }
52874
- }
52875
- function addedNames(h) {
52876
- let files2;
53038
+ };
53039
+ function folderKey(cwd, gitRoot2 = git2) {
53040
+ let real3;
52877
53041
  try {
52878
- files2 = readdirSync6(instancesDir(h));
53042
+ real3 = realpathSync8(cwd);
52879
53043
  } catch {
52880
- return [];
53044
+ real3 = resolve4(cwd);
52881
53045
  }
52882
- return files2.filter((f) => f.endsWith(".json")).map((f) => f.slice(0, -".json".length)).filter((n) => NAME_RE2.test(n) && n !== MAIN_INSTANCE).sort();
52883
- }
52884
- function listInstances(h = home()) {
52885
- const list = [];
52886
- const main2 = mainAddress(h);
52887
- const added = addedNames(h);
52888
- if (main2 !== void 0 || added.length === 0)
52889
- list.push({ name: MAIN_INSTANCE, hub: main2 ?? "", main: true });
52890
- for (const name of added) {
52891
- let hub = "";
53046
+ const root = gitRoot2(real3);
53047
+ if (root) {
52892
53048
  try {
52893
- const r = JSON.parse(readFileSync18(instanceFile(name, h), "utf8"));
52894
- if (typeof r.hub === "string") hub = r.hub;
53049
+ const r = realpathSync8(root);
53050
+ if (inside(r, real3)) return r;
52895
53051
  } catch {
52896
53052
  }
52897
- list.push({ name, hub, main: false });
52898
53053
  }
52899
- return list;
53054
+ return real3;
52900
53055
  }
52901
- function addProblem(name, address, h = home()) {
52902
- const bad2 = nameProblem(name);
52903
- if (bad2) return bad2;
52904
- if (existsSync6(instanceFile(name, h)))
52905
- return `an instance named ${name} already exists`;
52906
- const want = canonicalAddress(address);
52907
- const main2 = mainAddress(h);
52908
- if (want !== void 0 && main2 !== void 0 && canonicalAddress(main2) === want)
52909
- return `that address is already this machine's main instance`;
52910
- for (const i of listInstances(h))
52911
- if (!i.main && want !== void 0 && canonicalAddress(i.hub) === want)
52912
- return `that address is already the instance ${i.name}`;
52913
- return void 0;
53056
+ function inside(dir, path) {
53057
+ const rel = relative4(dir, path);
53058
+ return rel === "" || rel !== ".." && !rel.startsWith(`..${sep4}`) && !isAbsolute7(rel);
52914
53059
  }
52915
- function suggestName(address, h = home()) {
52916
- let base3 = "instance";
52917
- try {
52918
- const host = new URL(address).hostname.split(".")[0] ?? "";
52919
- const fit = host.toLowerCase().replace(/[^a-z0-9-]/g, "-").replace(/^-+|-+$/g, "").slice(0, 28);
52920
- if (fit && fit !== MAIN_INSTANCE) base3 = fit;
52921
- } catch {
52922
- }
52923
- let name = base3;
52924
- for (let n = 2; existsSync6(instanceFile(name, h)); n++) name = `${base3}-${n}`;
52925
- return name;
53060
+ function coveringEntry(f, real3) {
53061
+ let best;
53062
+ for (const [dir, name] of Object.entries(f.map))
53063
+ if (inside(dir, real3) && (!best || dir.length > best.dir.length))
53064
+ best = { dir, name };
53065
+ return best;
52926
53066
  }
52927
- function saveInstance(c, h = home()) {
52928
- const problem = addProblem(c.name, c.hub, h);
52929
- if (problem) throw new Error(problem);
52930
- checkHub(c.hub);
52931
- const dir = instancesDir(h);
52932
- mkdirSync9(h, { recursive: true, mode: 448 });
52933
- mkdirSync9(dir, { recursive: true, mode: 448 });
52934
- chmodSync15(dir, 448);
52935
- const tmp = join22(dir, `.${c.name}.${randomBytes3(8).toString("hex")}.tmp`);
52936
- const fd = openSync8(tmp, "wx", 384);
53067
+ function folderHomeLookup(h = home()) {
53068
+ return (cwd) => {
53069
+ const list = listInstances(h);
53070
+ if (list.length === 1 && list[0]?.main) return { instance: MAIN_INSTANCE };
53071
+ let real3;
53072
+ try {
53073
+ real3 = realpathSync8(cwd);
53074
+ } catch {
53075
+ real3 = resolve4(cwd);
53076
+ }
53077
+ const hit = coveringEntry(readFolders(h), real3);
53078
+ if (hit && list.some((i) => i.name === hit.name))
53079
+ return { instance: hit.name };
53080
+ return { unmapped: true };
53081
+ };
53082
+ }
53083
+ function readSuggestion(cwd, opts = {}) {
53084
+ let dir;
52937
53085
  try {
52938
- writeSync4(
52939
- fd,
52940
- `${JSON.stringify(
52941
- {
52942
- name: c.name,
52943
- hub: c.hub,
52944
- machine_id: c.machine_id,
52945
- label: c.label,
52946
- machine_token: c.machine_token
52947
- },
52948
- null,
52949
- 2
52950
- )}
52951
- `
52952
- );
52953
- } catch (e) {
52954
- closeSync8(fd);
52955
- unlinkSync3(tmp);
52956
- throw e;
53086
+ dir = realpathSync8(cwd);
53087
+ } catch {
53088
+ return void 0;
52957
53089
  }
52958
- closeSync8(fd);
52959
- try {
52960
- chmodSync15(tmp, 384);
52961
- linkSync2(tmp, instanceFile(c.name, h));
52962
- } catch (e) {
52963
- unlinkSync3(tmp);
52964
- throw e;
53090
+ const uid = opts.uid ?? process.getuid?.();
53091
+ for (let d = dir; ; d = dirname10(d)) {
53092
+ const deeper = opts.below !== void 0 && !inside(d, opts.below);
53093
+ if (!deeper) {
53094
+ const own2 = readOwnFile(join23(d, CONFIG_FILE), uid, {
53095
+ allowGroupWrite: true
53096
+ });
53097
+ if (own2.state === "ok") {
53098
+ try {
53099
+ const parsed = BusConfigSchema.safeParse(JSON.parse(own2.text));
53100
+ if (parsed.success && parsed.data.instance !== void 0)
53101
+ return canonicalAddress(parsed.data.instance);
53102
+ } catch {
53103
+ }
53104
+ }
53105
+ }
53106
+ if (dirname10(d) === d) return void 0;
52965
53107
  }
52966
- unlinkSync3(tmp);
53108
+ }
53109
+ function instanceAt(address, list) {
53110
+ return list.find((i) => canonicalAddress(i.hub) === address);
52967
53111
  }
52968
53112
 
52969
53113
  // ../bus-daemon/src/leads/templates.ts
52970
53114
  init_src();
52971
- import { lstatSync as lstatSync8, readdirSync as readdirSync7, realpathSync as realpathSync8, statSync as statSync8 } from "node:fs";
52972
- import { join as join23 } from "node:path";
52973
- var leadsDir = (h = home()) => join23(h, "leads");
52974
- var leadTemplateFile = (name, h = home()) => join23(leadsDir(h), `${name}.json`);
53115
+ import { lstatSync as lstatSync8, readdirSync as readdirSync7, realpathSync as realpathSync9, statSync as statSync8 } from "node:fs";
53116
+ import { join as join24 } from "node:path";
53117
+ var leadsDir = (h = home()) => join24(h, "leads");
53118
+ var leadTemplateFile = (name, h = home()) => join24(leadsDir(h), `${name}.json`);
52975
53119
  var CONTROL_RE = /[\u0000-\u001f\u007f-\u009f]/g;
52976
53120
  var tame = (s) => {
52977
53121
  const t = s.replace(CONTROL_RE, "?");
@@ -53003,7 +53147,7 @@ function checkRealDir(path, label2, uid, group) {
53003
53147
  if (path === "/") return `${label2} is the root folder`;
53004
53148
  let real3;
53005
53149
  try {
53006
- real3 = realpathSync8.native(path);
53150
+ real3 = realpathSync9.native(path);
53007
53151
  } catch {
53008
53152
  return `${label2} does not exist`;
53009
53153
  }
@@ -53242,12 +53386,12 @@ async function runDaemon(deps2 = {}) {
53242
53386
  let within2;
53243
53387
  if (cwd !== void 0) {
53244
53388
  try {
53245
- within2 = new Set(configPaths(realpathSync9(cwd)));
53389
+ within2 = new Set(configPaths(realpathSync10(cwd)));
53246
53390
  } catch {
53247
53391
  within2 = new Set(configPaths(cwd));
53248
53392
  }
53249
53393
  const rr = gitRecordRoot(cwd);
53250
- if (rr) within2.add(join24(rr, ".git"));
53394
+ if (rr) within2.add(join25(rr, ".git"));
53251
53395
  }
53252
53396
  return [
53253
53397
  ...configIssues.list(within2, { pending: pending2 }),
@@ -53275,7 +53419,7 @@ async function runDaemon(deps2 = {}) {
53275
53419
  procStart: cachedProcStart(cl.procStart ?? claudeProcStartOf, running),
53276
53420
  isRunning: running
53277
53421
  };
53278
- const linksFile = cl.linksFile ?? join24(home(), "claude-links.json");
53422
+ const linksFile = cl.linksFile ?? join25(home(), "claude-links.json");
53279
53423
  const sameProc = (pid, procStart) => running(pid) && claudeSessions.procStart(pid, procStart) === procStart;
53280
53424
  let saved = readClaudeLinks(linksFile, void 0, log).filter(
53281
53425
  (e) => sameProc(e.pid, e.procStart)
@@ -53328,7 +53472,7 @@ async function runDaemon(deps2 = {}) {
53328
53472
  const ocServiceGone = (ref, pid) => {
53329
53473
  if (!ocRunning(pid)) return true;
53330
53474
  const comm = ocComm(pid);
53331
- if (comm !== null && basename6(comm) !== "opencode") return true;
53475
+ if (comm !== null && basename7(comm) !== "opencode") return true;
53332
53476
  const start = ocServiceStart.get(ref);
53333
53477
  if (start == null) return false;
53334
53478
  const now = ocStart(pid);
@@ -53361,7 +53505,7 @@ async function runDaemon(deps2 = {}) {
53361
53505
  log,
53362
53506
  promptIdSupported: () => promptIdSupported,
53363
53507
  uncertain: new HeldStore(
53364
- oc.uncertainFile ?? join24(home(), "opencode-uncertain.json")
53508
+ oc.uncertainFile ?? join25(home(), "opencode-uncertain.json")
53365
53509
  )
53366
53510
  });
53367
53511
  const codexIndexHome = cx.home ?? codexHome();
@@ -53371,7 +53515,7 @@ async function runDaemon(deps2 = {}) {
53371
53515
  });
53372
53516
  const codexTaken = new TakenWatch({
53373
53517
  home: codexIndexHome,
53374
- file: cx.takenFile ?? join24(home(), "codex-pending.json"),
53518
+ file: cx.takenFile ?? join25(home(), "codex-pending.json"),
53375
53519
  onTaken: (id, unsent) => sendCodexAck(id, unsent),
53376
53520
  log
53377
53521
  });
@@ -53396,7 +53540,7 @@ async function runDaemon(deps2 = {}) {
53396
53540
  },
53397
53541
  ackTimeoutMs: deps2.pi?.ackTimeoutMs
53398
53542
  });
53399
- const sent = new SentStore(deps2.sentFile ?? join24(home(), "sent.json"), {
53543
+ const sent = new SentStore(deps2.sentFile ?? join25(home(), "sent.json"), {
53400
53544
  log
53401
53545
  });
53402
53546
  const receipts = new Receipts(sent, { after: deps2.deliveredTimer });
@@ -53516,8 +53660,8 @@ async function runDaemon(deps2 = {}) {
53516
53660
  socketsDir: returnDir,
53517
53661
  // A deps.socketsDir is the caller's (tests); ours is re-checked before each bind.
53518
53662
  prepareDir: cl.socketsDir ? void 0 : (d) => prepareReturnDir(d),
53519
- heldFile: cl.heldFile ?? join24(home(), "claude-held.json"),
53520
- returnIndexFile: cl.returnIndexFile ?? (cl.heldFile ? cl.heldFile.replace(/(\.json)?$/, ".return.json") : join24(home(), "claude-return.json")),
53663
+ heldFile: cl.heldFile ?? join25(home(), "claude-held.json"),
53664
+ returnIndexFile: cl.returnIndexFile ?? (cl.heldFile ? cl.heldFile.replace(/(\.json)?$/, ".return.json") : join25(home(), "claude-return.json")),
53521
53665
  statusWindowMs: cl.statusWindowMs,
53522
53666
  injectTimeoutMs: cl.injectTimeoutMs,
53523
53667
  log,
@@ -53705,7 +53849,7 @@ async function runDaemon(deps2 = {}) {
53705
53849
  continue;
53706
53850
  reopenedAt.set(s.ref, Date.now());
53707
53851
  }
53708
- if (!isAbsolute7(s.cwd)) continue;
53852
+ if (!isAbsolute8(s.cwd)) continue;
53709
53853
  let ns;
53710
53854
  try {
53711
53855
  ns = resolveNs(s.cwd, true);
@@ -54050,7 +54194,7 @@ async function runDaemon(deps2 = {}) {
54050
54194
  process.exitCode = 1;
54051
54195
  try {
54052
54196
  writeFileSync12(
54053
- deps2.revokedFile ?? join24(home(), "revoked"),
54197
+ deps2.revokedFile ?? join25(home(), "revoked"),
54054
54198
  revokedMarker(cfg.machine_token),
54055
54199
  { mode: 384 }
54056
54200
  );
@@ -54114,30 +54258,30 @@ async function runDaemon(deps2 = {}) {
54114
54258
  statusEveryMs: deps2.status?.statusEveryMs
54115
54259
  });
54116
54260
  const hubRoster = (ref) => new Promise(
54117
- (resolve18) => {
54261
+ (resolve19) => {
54118
54262
  const id = pending.open(
54119
54263
  "status",
54120
- (f) => resolve18(f.type === "roster" ? f.agents : void 0)
54264
+ (f) => resolve19(f.type === "roster" ? f.agents : void 0)
54121
54265
  );
54122
54266
  const timer = setTimeout(() => {
54123
54267
  pending.cancel(id);
54124
54268
  hub.cancel(id);
54125
- resolve18(void 0);
54269
+ resolve19(void 0);
54126
54270
  }, deps2.statusRosterMs ?? 1500);
54127
54271
  timer.unref();
54128
54272
  if (!hub.send({ v: 1, id, type: "list", from_ref: ref })) {
54129
54273
  clearTimeout(timer);
54130
54274
  pending.cancel(id);
54131
- resolve18(void 0);
54275
+ resolve19(void 0);
54132
54276
  }
54133
54277
  }
54134
54278
  );
54135
- const hubWaitingCounts = (refs) => new Promise((resolve18) => {
54279
+ const hubWaitingCounts = (refs) => new Promise((resolve19) => {
54136
54280
  const id = frameId();
54137
54281
  const done = (c) => {
54138
54282
  clearTimeout(timer);
54139
54283
  waitingAsks.delete(id);
54140
- resolve18(c);
54284
+ resolve19(c);
54141
54285
  };
54142
54286
  const timer = setTimeout(() => {
54143
54287
  hub.cancel(id);
@@ -54210,7 +54354,7 @@ async function runDaemon(deps2 = {}) {
54210
54354
  onStatus: async (req) => {
54211
54355
  claimProofs();
54212
54356
  let only;
54213
- if (req.cwd && isAbsolute7(req.cwd)) {
54357
+ if (req.cwd && isAbsolute8(req.cwd)) {
54214
54358
  try {
54215
54359
  only = resolveNs(req.cwd, true).namespace;
54216
54360
  } catch {
@@ -54386,7 +54530,7 @@ async function runDaemon(deps2 = {}) {
54386
54530
  };
54387
54531
  }
54388
54532
  const cwd = check2.cwd ?? hello.cwd;
54389
- if (!cwd || !isAbsolute7(cwd)) return { error: "cwd must be absolute" };
54533
+ if (!cwd || !isAbsolute8(cwd)) return { error: "cwd must be absolute" };
54390
54534
  let ns;
54391
54535
  try {
54392
54536
  ns = resolveNs(cwd, check2.cwd !== void 0);
@@ -54592,7 +54736,7 @@ async function runDaemon(deps2 = {}) {
54592
54736
  deps2.onSocketLost?.();
54593
54737
  }, deps2.socketCheckMs ?? 6e4);
54594
54738
  socketWatch.unref();
54595
- const codexAgentsFile = cx.agentsFile ?? join24(home(), "codex-agents.json");
54739
+ const codexAgentsFile = cx.agentsFile ?? join25(home(), "codex-agents.json");
54596
54740
  let codexSaved;
54597
54741
  const restorePending = /* @__PURE__ */ new Map();
54598
54742
  const persistCodex = () => {
@@ -54718,7 +54862,7 @@ async function runDaemon(deps2 = {}) {
54718
54862
  };
54719
54863
  attempt2(readCodexAgents(codexAgentsFile), 0);
54720
54864
  };
54721
- const awayFile = cx.awayFile ?? join24(home(), "codex-away.json");
54865
+ const awayFile = cx.awayFile ?? join25(home(), "codex-away.json");
54722
54866
  const awayNow = deps2.bindingNow ?? Date.now;
54723
54867
  const HOUR = 36e5;
54724
54868
  const awayRows = new Map(
@@ -54756,7 +54900,7 @@ async function runDaemon(deps2 = {}) {
54756
54900
  }
54757
54901
  };
54758
54902
  const woken = new HeldStore(
54759
- cx.wokenFile ?? join24(home(), "codex-woken.json"),
54903
+ cx.wokenFile ?? join25(home(), "codex-woken.json"),
54760
54904
  { ttlMs: 7 * 24 * HOUR }
54761
54905
  );
54762
54906
  const wakeLogged = /* @__PURE__ */ new Set();
@@ -55090,7 +55234,7 @@ init_src();
55090
55234
 
55091
55235
  // src/context.ts
55092
55236
  init_src3();
55093
- import { execFileSync as execFileSync6, spawn as spawn2 } from "node:child_process";
55237
+ import { execFileSync as execFileSync7, spawn as spawn2 } from "node:child_process";
55094
55238
  import { closeSync as closeSync9, openSync as openSync9, readFileSync as readFileSync22 } from "node:fs";
55095
55239
  import { homedir as homedir3, userInfo as userInfo2 } from "node:os";
55096
55240
  import { createInterface as createInterface2 } from "node:readline";
@@ -55591,6 +55735,7 @@ function copy(style, bus = BUS_CMD, approve) {
55591
55735
  " install Approve this machine, wire your harnesses, start the daemon (the default)",
55592
55736
  " login Approve this machine again",
55593
55737
  " add <address> [--name <name>]: connect a second instance from a terminal",
55738
+ " use [name] or --none: tie this folder to one of your instances",
55594
55739
  " skill Save this instance's skill for your harnesses (--check only reports)",
55595
55740
  " uninstall Remove what install added",
55596
55741
  " status Who is on the bus, from this folder",
@@ -55621,6 +55766,7 @@ function copy(style, bus = BUS_CMD, approve) {
55621
55766
  " login --instance <url>, --no-open",
55622
55767
  " add --name <name> the local name for the instance (default: from its address)",
55623
55768
  " --no-open do not open a browser for approval",
55769
+ " use --none turn down the instance this repo suggests",
55624
55770
  " daemon --instance <url>",
55625
55771
  " uninstall --purge also delete the bus home and what install made",
55626
55772
  " namespace --yes, -y approve without asking (namespace approve)",
@@ -56239,19 +56385,19 @@ init_src2();
56239
56385
  import { execFile as execFile3, spawn } from "node:child_process";
56240
56386
  import { promisify } from "node:util";
56241
56387
  var browserCommand = (platform, url2) => platform === "darwin" ? { cmd: "open", args: [url2] } : platform === "win32" ? { cmd: "rundll32", args: ["url.dll,FileProtocolHandler", url2] } : { cmd: "xdg-open", args: [url2] };
56242
- var openBrowser = (url2, launcher = browserCommand(process.platform, url2)) => new Promise((resolve18) => {
56388
+ var openBrowser = (url2, launcher = browserCommand(process.platform, url2)) => new Promise((resolve19) => {
56243
56389
  try {
56244
56390
  const child = spawn(launcher.cmd, launcher.args, {
56245
56391
  stdio: "ignore",
56246
56392
  detached: true
56247
56393
  });
56248
- child.once("error", () => resolve18(false));
56394
+ child.once("error", () => resolve19(false));
56249
56395
  child.once("spawn", () => {
56250
56396
  child.unref();
56251
- resolve18(true);
56397
+ resolve19(true);
56252
56398
  });
56253
56399
  } catch {
56254
- resolve18(false);
56400
+ resolve19(false);
56255
56401
  }
56256
56402
  });
56257
56403
  var EXEC_TIMEOUT_MS = 1e4;
@@ -56304,27 +56450,27 @@ import {
56304
56450
  mkdirSync as mkdirSync12,
56305
56451
  readdirSync as readdirSync8,
56306
56452
  readFileSync as readFileSync21,
56307
- realpathSync as realpathSync10,
56453
+ realpathSync as realpathSync11,
56308
56454
  renameSync as renameSync16,
56309
56455
  rmSync as rmSync11,
56310
56456
  writeFileSync as writeFileSync15
56311
56457
  } from "node:fs";
56312
56458
  import { tmpdir } from "node:os";
56313
56459
  import {
56314
- basename as basename7,
56460
+ basename as basename8,
56315
56461
  delimiter as delimiter2,
56316
- dirname as dirname11,
56317
- isAbsolute as isAbsolute8,
56318
- join as join27,
56319
- relative as relative4,
56320
- resolve as resolve5
56462
+ dirname as dirname12,
56463
+ isAbsolute as isAbsolute9,
56464
+ join as join28,
56465
+ relative as relative5,
56466
+ resolve as resolve6
56321
56467
  } from "node:path";
56322
56468
  import { fileURLToPath } from "node:url";
56323
56469
  init_src();
56324
56470
 
56325
56471
  // src/steps/codex.ts
56326
56472
  import { lstatSync as lstatSync10, readFileSync as readFileSync19 } from "node:fs";
56327
- import { join as join25, resolve as resolve4 } from "node:path";
56473
+ import { join as join26, resolve as resolve5 } from "node:path";
56328
56474
 
56329
56475
  // ../../node_modules/.pnpm/smol-toml@1.9.1/node_modules/smol-toml/dist/error.js
56330
56476
  function getLineColFromPtr(string4, ptr) {
@@ -57086,12 +57232,12 @@ var HAS_WELLFORMED = !!"".isWellFormed;
57086
57232
 
57087
57233
  // src/steps/codex.ts
57088
57234
  var CODEX_ENTRY = "oa_bus";
57089
- var codexHome2 = (home2, env2) => env2.CODEX_HOME ? resolve4(env2.CODEX_HOME) : join25(home2, ".codex");
57235
+ var codexHome2 = (home2, env2) => env2.CODEX_HOME ? resolve5(env2.CODEX_HOME) : join26(home2, ".codex");
57090
57236
  function codexHomeEnv(home2, env2) {
57091
57237
  const dir = codexHome2(home2, env2);
57092
- return dir === join25(home2, ".codex") ? {} : { CODEX_HOME: dir };
57238
+ return dir === join26(home2, ".codex") ? {} : { CODEX_HOME: dir };
57093
57239
  }
57094
- var codexConfig = (home2, env2) => join25(codexHome2(home2, env2), "config.toml");
57240
+ var codexConfig = (home2, env2) => join26(codexHome2(home2, env2), "config.toml");
57095
57241
  function hasCodex(o) {
57096
57242
  if (o.which("codex")) return true;
57097
57243
  try {
@@ -57121,11 +57267,11 @@ var plain = (v) => v === void 0 ? void 0 : JSON.parse(JSON.stringify(v));
57121
57267
  var servers = (doc) => doc.mcp_servers;
57122
57268
  var codexEntryOf = (doc) => plain(servers(doc)?.[CODEX_ENTRY]);
57123
57269
  function codexEntry(busBin, home2, busHome2) {
57124
- const ob = resolve4(busHome2);
57270
+ const ob = resolve5(busHome2);
57125
57271
  return {
57126
57272
  command: busBin[0],
57127
57273
  args: [...busBin.slice(1), "mcp", "codex"],
57128
- ...ob === join25(home2, ".oa-bus") ? {} : { env: { OA_BUS_HOME: ob } },
57274
+ ...ob === join26(home2, ".oa-bus") ? {} : { env: { OA_BUS_HOME: ob } },
57129
57275
  default_tools_approval_mode: "approve"
57130
57276
  };
57131
57277
  }
@@ -57150,8 +57296,8 @@ function sandboxRisk(doc, home2, codexDir) {
57150
57296
  return Array.isArray(r) ? r.filter((x) => typeof x === "string") : [];
57151
57297
  });
57152
57298
  const covers = (root) => {
57153
- const r = resolve4(
57154
- root === "~" ? home2 : root.startsWith("~/") ? join25(home2, root.slice(2)) : root
57299
+ const r = resolve5(
57300
+ root === "~" ? home2 : root.startsWith("~/") ? join26(home2, root.slice(2)) : root
57155
57301
  );
57156
57302
  return r === "/" || codexDir === r || codexDir.startsWith(`${r}/`) || r.startsWith(`${codexDir}/`);
57157
57303
  };
@@ -57336,8 +57482,8 @@ function upsert(path, text3, doc, entry) {
57336
57482
  );
57337
57483
  const eol2 = eolOf(lines);
57338
57484
  const ended = lines.at(-1)?.text === "" && lines.length > 1;
57339
- const sep6 = text3 === "" ? "" : ended ? blank(lines.at(-2)) ? "" : eol2 : eol2 + eol2;
57340
- next = `${text3}${sep6}${block.join(eol2)}${eol2}`;
57485
+ const sep7 = text3 === "" ? "" : ended ? blank(lines.at(-2)) ? "" : eol2 : eol2 + eol2;
57486
+ next = `${text3}${sep7}${block.join(eol2)}${eol2}`;
57341
57487
  }
57342
57488
  return checked(path, doc, next, entry);
57343
57489
  }
@@ -57377,10 +57523,10 @@ import {
57377
57523
  rmSync as rmSync10,
57378
57524
  writeFileSync as writeFileSync13
57379
57525
  } from "node:fs";
57380
- import { join as join26 } from "node:path";
57526
+ import { join as join27 } from "node:path";
57381
57527
  var RESCUE_VERSION = 1;
57382
57528
  var RESCUE_MAX_STARTS = 2;
57383
- var rescueOf = (home2) => join26(home2, "rescue");
57529
+ var rescueOf = (home2) => join27(home2, "rescue");
57384
57530
  function rescueShell() {
57385
57531
  return `#!/bin/sh
57386
57532
  # Written by oa-bus install, never by an update. Rescue shim ${RESCUE_VERSION}.
@@ -57484,7 +57630,7 @@ try {
57484
57630
  function writeRescue(home2, launcher) {
57485
57631
  mkdirSync10(home2, { recursive: true, mode: 448 });
57486
57632
  const put2 = (name, text3) => {
57487
- const path = join26(home2, name);
57633
+ const path = join27(home2, name);
57488
57634
  const tmp = `${path}.${process.pid}.tmp`;
57489
57635
  try {
57490
57636
  writeFileSync13(tmp, text3, { mode: 448 });
@@ -57508,7 +57654,7 @@ import {
57508
57654
  renameSync as renameSync15,
57509
57655
  writeFileSync as writeFileSync14
57510
57656
  } from "node:fs";
57511
- import { dirname as dirname10 } from "node:path";
57657
+ import { dirname as dirname11 } from "node:path";
57512
57658
  function readInstallFile(path) {
57513
57659
  try {
57514
57660
  const v = JSON.parse(readFileSync20(path, "utf8"));
@@ -57520,7 +57666,7 @@ function readInstallFile(path) {
57520
57666
  }
57521
57667
  function updateInstallFile(path, patch) {
57522
57668
  const next = { ...readInstallFile(path), ...patch };
57523
- mkdirSync11(dirname10(path), { recursive: true, mode: 448 });
57669
+ mkdirSync11(dirname11(path), { recursive: true, mode: 448 });
57524
57670
  const tmp = `${path}.${process.pid}.tmp`;
57525
57671
  writeFileSync14(tmp, `${JSON.stringify(next, null, 2)}
57526
57672
  `, { mode: 384 });
@@ -57570,9 +57716,9 @@ function servicePath(env2, execPath, platform) {
57570
57716
  "/usr/bin",
57571
57717
  "/bin"
57572
57718
  ];
57573
- const mine = (env2.PATH ?? "").split(delimiter2).filter((d) => isAbsolute8(d) && !transient(d));
57574
- const node2 = dirname11(execPath);
57575
- if (!mine.includes(node2) && isAbsolute8(node2) && !transient(node2))
57719
+ const mine = (env2.PATH ?? "").split(delimiter2).filter((d) => isAbsolute9(d) && !transient(d));
57720
+ const node2 = dirname12(execPath);
57721
+ if (!mine.includes(node2) && isAbsolute9(node2) && !transient(node2))
57576
57722
  mine.unshift(node2);
57577
57723
  return [.../* @__PURE__ */ new Set([...mine, ...system])].join(delimiter2);
57578
57724
  }
@@ -57638,7 +57784,7 @@ function cliSource() {
57638
57784
  jiti: import.meta.resolve("jiti")
57639
57785
  } : { kind: "bundle", file: here };
57640
57786
  }
57641
- var entryName = (src) => src.kind === "bundle" ? join27(basename7(dirname11(src.file)), basename7(src.file)) : "oa-bus.js";
57787
+ var entryName = (src) => src.kind === "bundle" ? join28(basename8(dirname12(src.file)), basename8(src.file)) : "oa-bus.js";
57642
57788
  var shim = (src) => `// Written by oa-bus install: runs the sources it was installed from.
57643
57789
  import { createJiti } from ${JSON.stringify(src.jiti)};
57644
57790
 
@@ -57693,12 +57839,12 @@ echo "oa-bus: Node.js ${MIN_NODE} or newer not found. Install it, then run: ${BU
57693
57839
  exit 127
57694
57840
  `;
57695
57841
  }
57696
- var launcherOf = (home2) => join27(home2, "bin", "node");
57842
+ var launcherOf = (home2) => join28(home2, "bin", "node");
57697
57843
  function versionOf(src) {
57698
57844
  if (src.kind === "dev") return "dev";
57699
57845
  try {
57700
57846
  const j = JSON.parse(
57701
- readFileSync21(join27(dirname11(dirname11(src.file)), "package.json"), "utf8")
57847
+ readFileSync21(join28(dirname12(dirname12(src.file)), "package.json"), "utf8")
57702
57848
  );
57703
57849
  if (isSafeVersion(j?.version)) return j.version;
57704
57850
  } catch {
@@ -57713,25 +57859,25 @@ function installCli(home2, src, node2) {
57713
57859
  versionOf(src),
57714
57860
  (tmp) => {
57715
57861
  if (src.kind === "bundle") {
57716
- const pkg = dirname11(dirname11(src.file));
57862
+ const pkg = dirname12(dirname12(src.file));
57717
57863
  for (const name of ["dist", "assets", "package.json"])
57718
- if (existsSync8(join27(pkg, name)))
57719
- cpSync(join27(pkg, name), join27(tmp, name), { recursive: true });
57720
- } else writeFileSync15(join27(tmp, entryName(src)), shim(src));
57864
+ if (existsSync8(join28(pkg, name)))
57865
+ cpSync(join28(pkg, name), join28(tmp, name), { recursive: true });
57866
+ } else writeFileSync15(join28(tmp, entryName(src)), shim(src));
57721
57867
  chmodSync18(tmp, 448);
57722
57868
  if (node2 !== void 0) {
57723
- writeFileSync15(join27(tmp, "node"), launcherText(node2), { mode: 448 });
57724
- chmodSync18(join27(tmp, "node"), 448);
57869
+ writeFileSync15(join28(tmp, "node"), launcherText(node2), { mode: 448 });
57870
+ chmodSync18(join28(tmp, "node"), 448);
57725
57871
  }
57726
- if (!existsSync8(join27(tmp, "package.json")))
57727
- writeFileSync15(join27(tmp, "package.json"), '{ "type": "module" }\n');
57872
+ if (!existsSync8(join28(tmp, "package.json")))
57873
+ writeFileSync15(join28(tmp, "package.json"), '{ "type": "module" }\n');
57728
57874
  },
57729
57875
  // Without the rescue shim (win32, or no launcher) a failed update could
57730
57876
  // not be undone: such an install never arms auto-update (#2552).
57731
57877
  { arm: node2 !== void 0 && process.platform !== "win32" }
57732
57878
  );
57733
57879
  if (node2 !== void 0) writeRescue(home2, launcherText(node2));
57734
- return join27(home2, "bin", entryName(src));
57880
+ return join28(home2, "bin", entryName(src));
57735
57881
  }
57736
57882
  var present = (path) => {
57737
57883
  try {
@@ -57742,7 +57888,7 @@ var present = (path) => {
57742
57888
  }
57743
57889
  };
57744
57890
  function writeReplacing(path, text3) {
57745
- mkdirSync12(dirname11(path), { recursive: true });
57891
+ mkdirSync12(dirname12(path), { recursive: true });
57746
57892
  const tmp = `${path}.${process.pid}.tmp`;
57747
57893
  try {
57748
57894
  writeFileSync15(tmp, text3, { mode: 420 });
@@ -57753,15 +57899,15 @@ function writeReplacing(path, text3) {
57753
57899
  }
57754
57900
  }
57755
57901
  var real = (path, native = false) => {
57756
- const abs = resolve5(path);
57902
+ const abs = resolve6(path);
57757
57903
  try {
57758
- return (native ? realpathSync10.native : realpathSync10)(abs);
57904
+ return (native ? realpathSync11.native : realpathSync11)(abs);
57759
57905
  } catch {
57760
- const parent = dirname11(abs);
57761
- return parent === abs ? abs : join27(real(parent, native), basename7(abs));
57906
+ const parent = dirname12(abs);
57907
+ return parent === abs ? abs : join28(real(parent, native), basename8(abs));
57762
57908
  }
57763
57909
  };
57764
- var isDefaultHome2 = (home2, userHome) => real(home2) === real(join27(userHome, ".oa-bus"));
57910
+ var isDefaultHome2 = (home2, userHome) => real(home2) === real(join28(userHome, ".oa-bus"));
57765
57911
  function serviceNames(home2, userHome) {
57766
57912
  const suffix = isDefaultHome2(home2, userHome) ? "" : createHash9("sha256").update(real(home2)).digest("hex").slice(0, 8);
57767
57913
  return {
@@ -57786,23 +57932,23 @@ function isOurDaemon(args, entry) {
57786
57932
  }
57787
57933
  function systemService(d) {
57788
57934
  const manager = d.platform === "darwin" ? "launchd" : d.platform === "linux" ? "systemd" : void 0;
57789
- const home2 = () => resolve5(d.home());
57935
+ const home2 = () => resolve6(d.home());
57790
57936
  const names2 = () => serviceNames(home2(), d.userHome);
57791
57937
  const launcherNode = () => d.platform === "win32" ? void 0 : d.execPath;
57792
57938
  const nodeOf = (h) => d.platform === "win32" ? d.execPath : launcherOf(h);
57793
- const entryOf = () => join27(home2(), "bin", entryName(d.source()));
57794
- const installFile2 = () => join27(home2(), "install.json");
57939
+ const entryOf = () => join28(home2(), "bin", entryName(d.source()));
57940
+ const installFile2 = () => join28(home2(), "install.json");
57795
57941
  const record7 = () => {
57796
57942
  const r = readInstallFile(installFile2()).service;
57797
57943
  return typeof r === "object" && r !== null ? r : {};
57798
57944
  };
57799
57945
  const xdg = d.env.XDG_CONFIG_HOME;
57800
- const configHome = xdg && isAbsolute8(xdg) ? xdg : join27(d.userHome, ".config");
57946
+ const configHome = xdg && isAbsolute9(xdg) ? xdg : join28(d.userHome, ".config");
57801
57947
  const fileName = () => manager === "launchd" ? `${names2().label}.plist` : names2().unit;
57802
- const fresh = () => manager === "launchd" ? join27(d.userHome, "Library/LaunchAgents", fileName()) : join27(configHome, "systemd/user", fileName());
57948
+ const fresh = () => manager === "launchd" ? join28(d.userHome, "Library/LaunchAgents", fileName()) : join28(configHome, "systemd/user", fileName());
57803
57949
  const recorded = () => {
57804
57950
  const r = record7().unit;
57805
- return typeof r === "string" && isAbsolute8(r) && basename7(r) === fileName() ? r : void 0;
57951
+ return typeof r === "string" && isAbsolute9(r) && basename8(r) === fileName() ? r : void 0;
57806
57952
  };
57807
57953
  const file2 = () => {
57808
57954
  const r = recorded();
@@ -57819,8 +57965,8 @@ function systemService(d) {
57819
57965
  const fold = (p) => d.platform === "darwin" ? real(p, true).toLowerCase() : real(p, true);
57820
57966
  const insideAccount = (p) => {
57821
57967
  if (d.accountHome === void 0) return true;
57822
- const r = relative4(fold(d.accountHome), fold(p));
57823
- return r === "" || !r.startsWith("..") && !isAbsolute8(r);
57968
+ const r = relative5(fold(d.accountHome), fold(p));
57969
+ return r === "" || !r.startsWith("..") && !isAbsolute9(r);
57824
57970
  };
57825
57971
  const isolated2 = () => {
57826
57972
  if (manager === void 0 || d.accountHome === void 0) return void 0;
@@ -57889,16 +58035,16 @@ function systemService(d) {
57889
58035
  const skipped = isolated2();
57890
58036
  if (skipped && insideAccount(home2())) return { skipped, idle: true };
57891
58037
  if (skipped) {
57892
- const r = relative4(fold(d.tmpDir ?? tmpdir()), fold(home2()));
57893
- if (r === "" || !r.startsWith("..") && !isAbsolute8(r))
58038
+ const r = relative5(fold(d.tmpDir ?? tmpdir()), fold(home2()));
58039
+ if (r === "" || !r.startsWith("..") && !isAbsolute9(r))
57894
58040
  return { skipped, idle: true };
57895
58041
  }
57896
58042
  const h = home2();
57897
58043
  const src = d.source();
57898
- const logs2 = join27(h, "logs");
58044
+ const logs2 = join28(h, "logs");
57899
58045
  const u = {
57900
58046
  node: nodeOf(h),
57901
- entry: join27(h, "bin", entryName(src)),
58047
+ entry: join28(h, "bin", entryName(src)),
57902
58048
  env: {
57903
58049
  PATH: servicePath(d.env, d.execPath, d.platform),
57904
58050
  ...isDefaultHome2(h, d.userHome) ? {} : { OA_BUS_HOME: h },
@@ -57906,8 +58052,8 @@ function systemService(d) {
57906
58052
  ...codexHomeEnv(d.userHome, d.env)
57907
58053
  },
57908
58054
  // One file: the daemon logs to stderr, and `oa-bus logs` tails it.
57909
- out: join27(logs2, "daemon.log"),
57910
- err: join27(logs2, "daemon.log")
58055
+ out: join28(logs2, "daemon.log"),
58056
+ err: join28(logs2, "daemon.log")
57911
58057
  };
57912
58058
  const unit = {
57913
58059
  ...u,
@@ -58043,7 +58189,7 @@ function systemService(d) {
58043
58189
  },
58044
58190
  others() {
58045
58191
  if (manager === void 0) return [];
58046
- const dir = dirname11(fresh());
58192
+ const dir = dirname12(fresh());
58047
58193
  const own2 = fileName();
58048
58194
  const re = manager === "launchd" ? /^com\.open-artifacts\.bus\.[0-9a-f]{8}\.plist$/ : /^oa-bus-[0-9a-f]{8}\.service$/;
58049
58195
  try {
@@ -58058,7 +58204,7 @@ function systemService(d) {
58058
58204
  const node2 = record7().node;
58059
58205
  if (typeof node2 === "string" && !existsSync8(node2))
58060
58206
  out.push({ kind: "node-missing", node: node2 });
58061
- if (manager === "systemd" && !existsSync8(join27(d.lingerDir ?? "/var/lib/systemd/linger", d.user)))
58207
+ if (manager === "systemd" && !existsSync8(join28(d.lingerDir ?? "/var/lib/systemd/linger", d.user)))
58062
58208
  out.push({ kind: "linger-off" });
58063
58209
  if (d.platform !== "win32" && unitRunsRescue()) {
58064
58210
  const r = rescueOf(home2());
@@ -58085,19 +58231,19 @@ var noService = {
58085
58231
  remove: async () => ({}),
58086
58232
  cli: () => ["oa-bus"]
58087
58233
  };
58088
- var VERSION = true ? "0.216.0" : JSON.parse(
58234
+ var VERSION = true ? "0.218.0" : JSON.parse(
58089
58235
  readFileSync22(new URL("../package.json", import.meta.url), "utf8")
58090
58236
  ).version;
58091
58237
  var which = (cmd) => {
58092
58238
  try {
58093
- execFileSync6("which", [cmd], { stdio: "ignore" });
58239
+ execFileSync7("which", [cmd], { stdio: "ignore" });
58094
58240
  return true;
58095
58241
  } catch {
58096
58242
  return false;
58097
58243
  }
58098
58244
  };
58099
58245
  function processArgs2(pid, io = {
58100
- ps: (pid2) => execFileSync6(systemTool("ps"), ["-o", "args=", "-p", String(pid2)], {
58246
+ ps: (pid2) => execFileSync7(systemTool("ps"), ["-o", "args=", "-p", String(pid2)], {
58101
58247
  encoding: "utf8",
58102
58248
  stdio: ["ignore", "pipe", "ignore"]
58103
58249
  }),
@@ -58175,7 +58321,7 @@ function realCtx(noColor) {
58175
58321
  });
58176
58322
  try {
58177
58323
  return await new Promise(
58178
- (resolve18) => rl.question(question, resolve18)
58324
+ (resolve19) => rl.question(question, resolve19)
58179
58325
  );
58180
58326
  } finally {
58181
58327
  rl.close();
@@ -58276,7 +58422,7 @@ import {
58276
58422
  statSync as statSync10,
58277
58423
  writeFileSync as writeFileSync18
58278
58424
  } from "node:fs";
58279
- import { dirname as dirname15, isAbsolute as isAbsolute13, join as join34, relative as relative6, resolve as resolve12 } from "node:path";
58425
+ import { dirname as dirname16, isAbsolute as isAbsolute14, join as join35, relative as relative7, resolve as resolve13 } from "node:path";
58280
58426
  import { isDeepStrictEqual } from "node:util";
58281
58427
 
58282
58428
  // ../bus-adapter-hermes/src/index.ts
@@ -58824,11 +58970,11 @@ function parseTree(text3, errors = [], options = ParseOptions.DEFAULT) {
58824
58970
  onValue({ type: getNodeType(value), offset, length, parent: currentParent, value });
58825
58971
  ensurePropertyComplete(offset + length);
58826
58972
  },
58827
- onSeparator: (sep6, offset, length) => {
58973
+ onSeparator: (sep7, offset, length) => {
58828
58974
  if (currentParent.type === "property") {
58829
- if (sep6 === ":") {
58975
+ if (sep7 === ":") {
58830
58976
  currentParent.colonOffset = offset;
58831
- } else if (sep6 === ",") {
58977
+ } else if (sep7 === ",") {
58832
58978
  ensurePropertyComplete(offset);
58833
58979
  }
58834
58980
  }
@@ -59520,8 +59666,8 @@ var PI_EXTENSION = fileURLToPath4(
59520
59666
 
59521
59667
  // src/steps/claude-proof.ts
59522
59668
  import { lstatSync as lstatSync12, readFileSync as readFileSync23 } from "node:fs";
59523
- import { join as join28, resolve as resolve6 } from "node:path";
59524
- var claudeConfigFile = (home2, env2) => join28(env2.CLAUDE_CONFIG_DIR ?? home2, ".claude.json");
59669
+ import { join as join29, resolve as resolve7 } from "node:path";
59670
+ var claudeConfigFile = (home2, env2) => join29(env2.CLAUDE_CONFIG_DIR ?? home2, ".claude.json");
59525
59671
  var PROOF_COMMAND = "mcp-proof";
59526
59672
  var TOKEN_HELPER = /^T=\$\(cat (.+)\) && printf '\{"Authorization":"Bearer %s"\}' "\$T"$/;
59527
59673
  var quote = (s) => /^[A-Za-z0-9_./:@%+=,-]+$/.test(s) ? s : `'${s.replaceAll("'", `'\\''`)}'`;
@@ -59538,11 +59684,11 @@ var isProofHelper = (helper) => typeof helper === "string" && / mcp-proof( |$)/.
59538
59684
  function helperHome(helper) {
59539
59685
  const m = /(?:^|[ {])OA_BUS_HOME=('(?:[^']|'\\'')*'|\S+)/.exec(helper)?.[1];
59540
59686
  if (m === void 0) return void 0;
59541
- return resolve6(
59687
+ return resolve7(
59542
59688
  m.startsWith("'") ? m.slice(1, -1).replaceAll("'\\''", "'") : m
59543
59689
  );
59544
59690
  }
59545
- var ownedBy = (helper, busHome2) => helperHome(helper) === (busHome2 === void 0 ? void 0 : resolve6(busHome2));
59691
+ var ownedBy = (helper, busHome2) => helperHome(helper) === (busHome2 === void 0 ? void 0 : resolve7(busHome2));
59546
59692
  var isRecord3 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
59547
59693
  function isInstanceEntry(entry, origin) {
59548
59694
  if (!isRecord3(entry) || typeof entry.url !== "string") return false;
@@ -59817,7 +59963,7 @@ function proofReport(file2, origin, opts = {}) {
59817
59963
  init_src3();
59818
59964
  init_src();
59819
59965
  import { existsSync as existsSync9, readFileSync as readFileSync24, rmSync as rmSync12 } from "node:fs";
59820
- import { isAbsolute as isAbsolute10 } from "node:path";
59966
+ import { isAbsolute as isAbsolute11 } from "node:path";
59821
59967
  var CODEX_MIN_VERSION = "0.123.0";
59822
59968
  var PROXY_CMD = "mcp-proxy";
59823
59969
  var OURS = ["command", "args", "env", "env_vars"];
@@ -60113,7 +60259,7 @@ function proxyProgramMissing(doc, which2) {
60113
60259
  if (i < 0 || a[i + 3] !== "--for" || a[i + 4] !== "codex") continue;
60114
60260
  for (const part of [e.command, ...a.slice(0, i)]) {
60115
60261
  if (typeof part !== "string") continue;
60116
- if (isAbsolute10(part) ? !existsSync9(part) : !which2(part))
60262
+ if (isAbsolute11(part) ? !existsSync9(part) : !which2(part))
60117
60263
  return { name, missing: part };
60118
60264
  }
60119
60265
  }
@@ -60126,10 +60272,10 @@ import {
60126
60272
  existsSync as existsSync12,
60127
60273
  lstatSync as lstatSync16,
60128
60274
  readFileSync as readFileSync28,
60129
- realpathSync as realpathSync14,
60275
+ realpathSync as realpathSync15,
60130
60276
  rmSync as rmSync16
60131
60277
  } from "node:fs";
60132
- import { join as join32, resolve as resolve10, sep as sep4 } from "node:path";
60278
+ import { join as join33, resolve as resolve11, sep as sep5 } from "node:path";
60133
60279
 
60134
60280
  // src/steps/hermes.ts
60135
60281
  import { createHash as createHash11, randomBytes as randomBytes6 } from "node:crypto";
@@ -60140,19 +60286,19 @@ import {
60140
60286
  readdirSync as readdirSync9,
60141
60287
  readFileSync as readFileSync25,
60142
60288
  readlinkSync as readlinkSync3,
60143
- realpathSync as realpathSync11,
60289
+ realpathSync as realpathSync12,
60144
60290
  renameSync as renameSync17,
60145
60291
  rmdirSync,
60146
60292
  rmSync as rmSync13,
60147
60293
  writeFileSync as writeFileSync16
60148
60294
  } from "node:fs";
60149
60295
  import {
60150
- basename as basename8,
60151
- dirname as dirname12,
60152
- isAbsolute as isAbsolute11,
60153
- join as join29,
60154
- relative as relative5,
60155
- resolve as resolve7
60296
+ basename as basename9,
60297
+ dirname as dirname13,
60298
+ isAbsolute as isAbsolute12,
60299
+ join as join30,
60300
+ relative as relative6,
60301
+ resolve as resolve8
60156
60302
  } from "node:path";
60157
60303
  var HERMES_PLUGIN_NAME = "oa-bus";
60158
60304
  var HERMES_MARKER = ".oa-bus-managed";
@@ -60166,11 +60312,11 @@ var real2 = (p) => {
60166
60312
  let cur = p;
60167
60313
  for (; ; ) {
60168
60314
  try {
60169
- return join29(realpathSync11(cur), ...rest.reverse());
60315
+ return join30(realpathSync12(cur), ...rest.reverse());
60170
60316
  } catch {
60171
- const up = dirname12(cur);
60317
+ const up = dirname13(cur);
60172
60318
  if (up === cur) return p;
60173
- rest.push(basename8(cur));
60319
+ rest.push(basename9(cur));
60174
60320
  cur = up;
60175
60321
  }
60176
60322
  }
@@ -60196,7 +60342,7 @@ function sweepStaging(staging, own2, o = {}) {
60196
60342
  }
60197
60343
  for (const name of names2) {
60198
60344
  if (name === own2) continue;
60199
- const path = join29(staging, name);
60345
+ const path = join30(staging, name);
60200
60346
  let old;
60201
60347
  try {
60202
60348
  old = now - lstatSync13(path).mtimeMs > STAGING_STALE_MS;
@@ -60213,24 +60359,24 @@ function sweepStaging(staging, own2, o = {}) {
60213
60359
  }
60214
60360
  }
60215
60361
  var nativeHome = (home2, env2, platform) => {
60216
- if (platform !== "win32") return join29(home2, ".hermes");
60362
+ if (platform !== "win32") return join30(home2, ".hermes");
60217
60363
  const local = env2.LOCALAPPDATA?.trim();
60218
- return join29(local || join29(home2, "AppData", "Local"), "hermes");
60364
+ return join30(local || join30(home2, "AppData", "Local"), "hermes");
60219
60365
  };
60220
- var tilded = (home2, v) => v === "~" ? home2 : resolve7(v.startsWith("~/") ? join29(home2, v.slice(2)) : v);
60366
+ var tilded = (home2, v) => v === "~" ? home2 : resolve8(v.startsWith("~/") ? join30(home2, v.slice(2)) : v);
60221
60367
  function hermesHome(home2, env2, platform = process.platform) {
60222
60368
  const native = nativeHome(home2, env2, platform);
60223
60369
  const v = env2.HERMES_HOME?.trim();
60224
60370
  const given = v ? tilded(home2, v) : void 0;
60225
- if (given !== void 0 && basename8(dirname12(given)) === "profiles")
60371
+ if (given !== void 0 && basename9(dirname13(given)) === "profiles")
60226
60372
  return given;
60227
60373
  const base3 = given ?? native;
60228
60374
  const root = hermesRoot(home2, env2, platform);
60229
60375
  if (env2.HERMES_S6_SUPERVISED_CHILD) return base3;
60230
60376
  try {
60231
- const name = readFileSync25(join29(root, "active_profile"), "utf8").trim().toLowerCase();
60377
+ const name = readFileSync25(join30(root, "active_profile"), "utf8").trim().toLowerCase();
60232
60378
  if (name && name !== "default" && /^[a-z0-9][a-z0-9_-]{0,63}$/.test(name)) {
60233
- const dir = join29(root, "profiles", name);
60379
+ const dir = join30(root, "profiles", name);
60234
60380
  if (lstatSync13(dir).isDirectory()) return dir;
60235
60381
  }
60236
60382
  } catch {
@@ -60242,13 +60388,13 @@ function hermesRoot(home2, env2, platform = process.platform) {
60242
60388
  const v = env2.HERMES_HOME?.trim();
60243
60389
  const given = v ? tilded(home2, v) : void 0;
60244
60390
  if (given === void 0) return native;
60245
- if (basename8(dirname12(given)) === "profiles") return dirname12(dirname12(given));
60246
- const rel = relative5(real2(native), real2(given));
60247
- if (rel === "" || !rel.startsWith("..") && !isAbsolute11(rel)) return native;
60391
+ if (basename9(dirname13(given)) === "profiles") return dirname13(dirname13(given));
60392
+ const rel = relative6(real2(native), real2(given));
60393
+ if (rel === "" || !rel.startsWith("..") && !isAbsolute12(rel)) return native;
60248
60394
  return given;
60249
60395
  }
60250
60396
  function hermesProfilesScan(home2, env2, platform = process.platform) {
60251
- const path = join29(hermesRoot(home2, env2, platform), "profiles");
60397
+ const path = join30(hermesRoot(home2, env2, platform), "profiles");
60252
60398
  let isLink3 = false;
60253
60399
  try {
60254
60400
  isLink3 = lstatSync13(path).isSymbolicLink();
@@ -60256,10 +60402,10 @@ function hermesProfilesScan(home2, env2, platform = process.platform) {
60256
60402
  }
60257
60403
  const target2 = () => {
60258
60404
  try {
60259
- return realpathSync11(path);
60405
+ return realpathSync12(path);
60260
60406
  } catch {
60261
60407
  try {
60262
- return resolve7(dirname12(path), readlinkSync3(path));
60408
+ return resolve8(dirname13(path), readlinkSync3(path));
60263
60409
  } catch {
60264
60410
  return "somewhere else";
60265
60411
  }
@@ -60295,9 +60441,9 @@ function hermesProfilesScan(home2, env2, platform = process.platform) {
60295
60441
  }
60296
60442
  function hermesPluginDirs(home2, env2, platform = process.platform) {
60297
60443
  const root = hermesRoot(home2, env2, platform);
60298
- const out = [join29(root, "plugins", HERMES_PLUGIN_NAME)];
60444
+ const out = [join30(root, "plugins", HERMES_PLUGIN_NAME)];
60299
60445
  for (const name of hermesProfilesScan(home2, env2, platform).names)
60300
- out.push(join29(root, "profiles", name, "plugins", HERMES_PLUGIN_NAME));
60446
+ out.push(join30(root, "profiles", name, "plugins", HERMES_PLUGIN_NAME));
60301
60447
  const active = hermesPluginDir(home2, env2, platform);
60302
60448
  if (!out.includes(active)) out.push(active);
60303
60449
  return out;
@@ -60305,7 +60451,7 @@ function hermesPluginDirs(home2, env2, platform = process.platform) {
60305
60451
  var hermesEnv = (home2, env2, platform = process.platform) => ({
60306
60452
  HERMES_HOME: hermesHome(home2, env2, platform)
60307
60453
  });
60308
- var hermesPluginDir = (home2, env2, platform = process.platform) => join29(hermesHome(home2, env2, platform), "plugins", HERMES_PLUGIN_NAME);
60454
+ var hermesPluginDir = (home2, env2, platform = process.platform) => join30(hermesHome(home2, env2, platform), "plugins", HERMES_PLUGIN_NAME);
60309
60455
  var kind = (path) => {
60310
60456
  try {
60311
60457
  const st = lstatSync13(path);
@@ -60316,11 +60462,11 @@ var kind = (path) => {
60316
60462
  };
60317
60463
  function files(dir, rel = "") {
60318
60464
  const out = [];
60319
- for (const name of readdirSync9(join29(dir, rel)).sort()) {
60465
+ for (const name of readdirSync9(join30(dir, rel)).sort()) {
60320
60466
  if (name === "__pycache__" || name.startsWith(".") || name.endsWith(".pyc") || rel === "" && (name === HERMES_HABITS_MARKER || name === HERMES_ROOTS_FILE))
60321
60467
  continue;
60322
60468
  const r = rel ? `${rel}/${name}` : name;
60323
- if (kind(join29(dir, r)) === "dir") out.push(...files(dir, r));
60469
+ if (kind(join30(dir, r)) === "dir") out.push(...files(dir, r));
60324
60470
  else out.push(r);
60325
60471
  }
60326
60472
  return out;
@@ -60329,7 +60475,7 @@ function pluginHash(dir) {
60329
60475
  const h = createHash11("sha256");
60330
60476
  for (const f of files(dir)) {
60331
60477
  h.update(`${f}\0`);
60332
- h.update(readFileSync25(join29(dir, f)));
60478
+ h.update(readFileSync25(join30(dir, f)));
60333
60479
  h.update("\0");
60334
60480
  }
60335
60481
  return h.digest("hex").slice(0, 16);
@@ -60340,7 +60486,7 @@ function pluginState(dir, shipped) {
60340
60486
  if (k !== "dir") return "foreign";
60341
60487
  let marker;
60342
60488
  try {
60343
- marker = readFileSync25(join29(dir, HERMES_MARKER), "utf8").trim();
60489
+ marker = readFileSync25(join30(dir, HERMES_MARKER), "utf8").trim();
60344
60490
  } catch {
60345
60491
  return "foreign";
60346
60492
  }
@@ -60379,11 +60525,11 @@ async function installHermes(deps2) {
60379
60525
  `${dest} exists and is not Open Artifacts bus's; left it untouched`
60380
60526
  );
60381
60527
  if (state !== "current") {
60382
- const keepHabits = state === "stale" && kind(join29(dest, HERMES_HABITS_MARKER)) === "file";
60383
- const keepRoots = state === "stale" && kind(join29(dest, HERMES_ROOTS_FILE)) === "file" ? readFileSync25(join29(dest, HERMES_ROOTS_FILE)) : void 0;
60384
- const plugins2 = join29(dest, "..");
60528
+ const keepHabits = state === "stale" && kind(join30(dest, HERMES_HABITS_MARKER)) === "file";
60529
+ const keepRoots = state === "stale" && kind(join30(dest, HERMES_ROOTS_FILE)) === "file" ? readFileSync25(join30(dest, HERMES_ROOTS_FILE)) : void 0;
60530
+ const plugins2 = join30(dest, "..");
60385
60531
  mkdirSync13(plugins2, { recursive: true });
60386
- const staging = join29(plugins2, "..", HERMES_STAGING);
60532
+ const staging = join30(plugins2, "..", HERMES_STAGING);
60387
60533
  const own2 = `${process.pid}-${randomBytes6(4).toString("hex")}`;
60388
60534
  const st = lstatSync13(staging, { throwIfNoEntry: false });
60389
60535
  if (st !== void 0 && !st.isDirectory())
@@ -60392,22 +60538,22 @@ async function installHermes(deps2) {
60392
60538
  );
60393
60539
  mkdirSync13(staging, { recursive: true });
60394
60540
  sweepStaging(staging, own2, deps2.staging);
60395
- const tmp = join29(staging, own2);
60541
+ const tmp = join30(staging, own2);
60396
60542
  try {
60397
60543
  mkdirSync13(tmp, { recursive: true });
60398
60544
  for (const f of files(shipped)) {
60399
- mkdirSync13(join29(tmp, f, ".."), { recursive: true });
60400
- cpSync2(join29(shipped, f), join29(tmp, f));
60545
+ mkdirSync13(join30(tmp, f, ".."), { recursive: true });
60546
+ cpSync2(join30(shipped, f), join30(tmp, f));
60401
60547
  }
60402
60548
  writeFileSync16(
60403
- join29(tmp, HERMES_MARKER),
60549
+ join30(tmp, HERMES_MARKER),
60404
60550
  `managed by the Open Artifacts bus installer: edits are replaced on reinstall. ${pluginHash(shipped)}
60405
60551
  `
60406
60552
  );
60407
60553
  if (keepHabits)
60408
- writeFileSync16(join29(tmp, HERMES_HABITS_MARKER), HABITS_MARKER_TEXT);
60554
+ writeFileSync16(join30(tmp, HERMES_HABITS_MARKER), HABITS_MARKER_TEXT);
60409
60555
  if (keepRoots !== void 0)
60410
- writeFileSync16(join29(tmp, HERMES_ROOTS_FILE), keepRoots, { mode: 384 });
60556
+ writeFileSync16(join30(tmp, HERMES_ROOTS_FILE), keepRoots, { mode: 384 });
60411
60557
  if (state === "stale") rmSync13(dest, { recursive: true, force: true });
60412
60558
  renameSync17(tmp, dest);
60413
60559
  } catch (e) {
@@ -60468,10 +60614,10 @@ import {
60468
60614
  lstatSync as lstatSync15,
60469
60615
  readdirSync as readdirSync11,
60470
60616
  readFileSync as readFileSync27,
60471
- realpathSync as realpathSync13,
60617
+ realpathSync as realpathSync14,
60472
60618
  rmSync as rmSync15
60473
60619
  } from "node:fs";
60474
- import { join as join31, resolve as resolve9 } from "node:path";
60620
+ import { join as join32, resolve as resolve10 } from "node:path";
60475
60621
  import { fileURLToPath as fileURLToPath5 } from "node:url";
60476
60622
 
60477
60623
  // src/steps/skill.ts
@@ -60483,20 +60629,20 @@ import {
60483
60629
  readdirSync as readdirSync10,
60484
60630
  readFileSync as readFileSync26,
60485
60631
  readlinkSync as readlinkSync4,
60486
- realpathSync as realpathSync12,
60632
+ realpathSync as realpathSync13,
60487
60633
  renameSync as renameSync18,
60488
60634
  rmdirSync as rmdirSync2,
60489
60635
  rmSync as rmSync14,
60490
60636
  statSync as statSync9,
60491
60637
  writeFileSync as writeFileSync17
60492
60638
  } from "node:fs";
60493
- import { dirname as dirname13, join as join30, resolve as resolve8 } from "node:path";
60639
+ import { dirname as dirname14, join as join31, resolve as resolve9 } from "node:path";
60494
60640
  var SKILL_MARKER = "<!-- managed by the Open Artifacts bus installer: edits are replaced on reinstall. -->";
60495
60641
  var CODEX_BEGIN = "<!-- BEGIN Open Artifacts skill (managed): edits inside are replaced on reinstall. -->";
60496
60642
  var CODEX_END = "<!-- END Open Artifacts skill -->";
60497
60643
  var CODEX_SKILLS_MIN_VERSION = "0.76.0";
60498
60644
  var MAX_SKILL_BYTES = 256 * 1024;
60499
- var codexSkillFile = (deps2, folder) => join30(codexHome2(deps2.home, env(deps2)), "skills", folder, "SKILL.md");
60645
+ var codexSkillFile = (deps2, folder) => join31(codexHome2(deps2.home, env(deps2)), "skills", folder, "SKILL.md");
60500
60646
  var codexHasSkills = (version2) => version2 !== void 0 && (compareVersions(version2, CODEX_SKILLS_MIN_VERSION) ?? -1) >= 0;
60501
60647
  var blankLine = (l) => l?.replace(/\r$/, "") === "";
60502
60648
  var withoutCodexBlock = (text3) => {
@@ -60534,17 +60680,17 @@ var dropCodexBlock = (agentsPath, notes) => {
60534
60680
  var env = (deps2) => deps2.env ?? {};
60535
60681
  var skillDir = (deps2, h) => {
60536
60682
  const e = env(deps2);
60537
- const opencode = e.OPENCODE_CONFIG_DIR ?? join30(e.XDG_CONFIG_HOME ?? join30(deps2.home, ".config"), "opencode");
60538
- const agents = join30(deps2.home, ".agents", "skills");
60683
+ const opencode = e.OPENCODE_CONFIG_DIR ?? join31(e.XDG_CONFIG_HOME ?? join31(deps2.home, ".config"), "opencode");
60684
+ const agents = join31(deps2.home, ".agents", "skills");
60539
60685
  return {
60540
- claude: join30(e.CLAUDE_CONFIG_DIR ?? join30(deps2.home, ".claude"), "skills"),
60541
- opencode: join30(opencode, "skills"),
60686
+ claude: join31(e.CLAUDE_CONFIG_DIR ?? join31(deps2.home, ".claude"), "skills"),
60687
+ opencode: join31(opencode, "skills"),
60542
60688
  pi: agents,
60543
60689
  omp: agents,
60544
- codex: join30(codexHome2(deps2.home, e), "AGENTS.md"),
60545
- hermes: join30(hermesHome(deps2.home, e), "skills"),
60690
+ codex: join31(codexHome2(deps2.home, e), "AGENTS.md"),
60691
+ hermes: join31(hermesHome(deps2.home, e), "skills"),
60546
60692
  // OpenClaw's managed skills folder, in its state dir.
60547
- openclaw: join30(openclawStateDir(deps2.home, e), "skills")
60693
+ openclaw: join31(openclawStateDir(deps2.home, e), "skills")
60548
60694
  }[h];
60549
60695
  };
60550
60696
  var skillFolder = (text3) => {
@@ -60633,14 +60779,14 @@ async function fetchSkillText(doFetch, url2) {
60633
60779
  }
60634
60780
  var targetOf = (path) => {
60635
60781
  try {
60636
- return lstatSync14(path).isSymbolicLink() ? realpathSync12(path) : path;
60782
+ return lstatSync14(path).isSymbolicLink() ? realpathSync13(path) : path;
60637
60783
  } catch {
60638
60784
  return path;
60639
60785
  }
60640
60786
  };
60641
60787
  var seq = 0;
60642
60788
  var writeAtomic = (path, text3) => {
60643
- mkdirSync14(dirname13(path), { recursive: true });
60789
+ mkdirSync14(dirname14(path), { recursive: true });
60644
60790
  const tmp = `${path}.oa-${process.pid}-${seq++}.tmp`;
60645
60791
  try {
60646
60792
  let mode;
@@ -60692,22 +60838,22 @@ var codexBroken = (text3) => {
60692
60838
  };
60693
60839
  var realOrResolved = (p) => {
60694
60840
  try {
60695
- return realpathSync12(p);
60841
+ return realpathSync13(p);
60696
60842
  } catch {
60697
- return resolve8(p);
60843
+ return resolve9(p);
60698
60844
  }
60699
60845
  };
60700
60846
  var placesOf = (p) => {
60701
60847
  const out = [realOrResolved(p)];
60702
60848
  try {
60703
60849
  if (lstatSync14(p).isSymbolicLink())
60704
- out.push(realOrResolved(resolve8(dirname13(p), readlinkSync4(p))));
60850
+ out.push(realOrResolved(resolve9(dirname14(p), readlinkSync4(p))));
60705
60851
  } catch {
60706
60852
  }
60707
60853
  return out;
60708
60854
  };
60709
60855
  var codexSkillsShared = (deps2) => {
60710
- const mine = placesOf(dirname13(dirname13(codexSkillFile(deps2, "x"))));
60856
+ const mine = placesOf(dirname14(dirname14(codexSkillFile(deps2, "x"))));
60711
60857
  const theirs = placesOf(skillDir(deps2, "pi"));
60712
60858
  return mine.some((m) => theirs.includes(m));
60713
60859
  };
@@ -60793,7 +60939,7 @@ var installCodex = (deps2, folder, text3, written, notes) => {
60793
60939
  try {
60794
60940
  rmSync14(targetOf(filePath), { force: true });
60795
60941
  try {
60796
- rmdirSync2(dirname13(filePath));
60942
+ rmdirSync2(dirname14(filePath));
60797
60943
  } catch {
60798
60944
  }
60799
60945
  } catch (e) {
@@ -60833,7 +60979,7 @@ async function installSkill(deps2, origin, harnesses) {
60833
60979
  continue;
60834
60980
  }
60835
60981
  const base3 = skillDir(deps2, h);
60836
- const path = join30(base3, folder, "SKILL.md");
60982
+ const path = join31(base3, folder, "SKILL.md");
60837
60983
  if (brokenLink(path)) {
60838
60984
  notes.push(`Left ${path} alone: it is a broken symlink.`);
60839
60985
  continue;
@@ -60881,8 +61027,8 @@ var uninstallSkill = (deps2, harnesses = [
60881
61027
  return;
60882
61028
  }
60883
61029
  for (const entry of entries) {
60884
- const dir = join30(base3, entry);
60885
- const file2 = join30(dir, "SKILL.md");
61030
+ const dir = join31(base3, entry);
61031
+ const file2 = join31(dir, "SKILL.md");
60886
61032
  try {
60887
61033
  const st = lstatSync14(dir);
60888
61034
  if (st.isSymbolicLink()) {
@@ -60918,7 +61064,7 @@ var uninstallSkill = (deps2, harnesses = [
60918
61064
  } catch (e) {
60919
61065
  fail3(base3, e);
60920
61066
  }
60921
- scan2(join30(dirname13(base3), "skills"));
61067
+ scan2(join31(dirname14(base3), "skills"));
60922
61068
  continue;
60923
61069
  }
60924
61070
  scan2(base3);
@@ -60930,9 +61076,9 @@ var codexSkillState = (deps2) => {
60930
61076
  shared: codexSkillsShared(deps2)
60931
61077
  };
60932
61078
  try {
60933
- const dir = join30(dirname13(skillDir(deps2, "codex")), "skills");
61079
+ const dir = join31(dirname14(skillDir(deps2, "codex")), "skills");
60934
61080
  for (const entry of readdirSync10(dir)) {
60935
- const file2 = join30(dir, entry, "SKILL.md");
61081
+ const file2 = join31(dir, entry, "SKILL.md");
60936
61082
  if (ourSkillFile(file2, entry)) {
60937
61083
  out.file = file2;
60938
61084
  break;
@@ -60961,7 +61107,7 @@ var savedSkill = (deps2, h, folder) => {
60961
61107
  return void 0;
60962
61108
  }
60963
61109
  for (const entry of entries) {
60964
- const file2 = join30(base3, entry, "SKILL.md");
61110
+ const file2 = join31(base3, entry, "SKILL.md");
60965
61111
  if (ourSkillFile(targetOf(file2), entry)) return file2;
60966
61112
  }
60967
61113
  return void 0;
@@ -60983,30 +61129,30 @@ var placeholder = (v) => {
60983
61129
  };
60984
61130
  function openclawHome(home2, env2) {
60985
61131
  const explicit = placeholder(env2.OPENCLAW_HOME);
60986
- return resolve9(explicit ? explicit.replace(/^~(?=$|[\\/])/, home2) : home2);
61132
+ return resolve10(explicit ? explicit.replace(/^~(?=$|[\\/])/, home2) : home2);
60987
61133
  }
60988
61134
  function openclawStateDir(home2, env2) {
60989
61135
  const h = openclawHome(home2, env2);
60990
61136
  const override = env2.OPENCLAW_STATE_DIR?.trim();
60991
61137
  if (override)
60992
- return resolve9(
61138
+ return resolve10(
60993
61139
  override.startsWith("~") ? override.replace(/^~(?=$|[\\/])/, h) : override
60994
61140
  );
60995
- const next = join31(h, ".openclaw");
61141
+ const next = join32(h, ".openclaw");
60996
61142
  if (env2.OPENCLAW_TEST_FAST === "1" || existsSync11(next)) return next;
60997
- const legacy = join31(h, ".clawdbot");
61143
+ const legacy = join32(h, ".clawdbot");
60998
61144
  return existsSync11(legacy) ? legacy : next;
60999
61145
  }
61000
- var openclawPluginDir = (home2, env2) => join31(openclawStateDir(home2, env2), "extensions", OPENCLAW_PLUGIN_ID);
61146
+ var openclawPluginDir = (home2, env2) => join32(openclawStateDir(home2, env2), "extensions", OPENCLAW_PLUGIN_ID);
61001
61147
  function openclawPluginDirs(home2, env2) {
61002
61148
  const h = openclawHome(home2, env2);
61003
- const states = [join31(h, ".openclaw"), join31(h, ".clawdbot")];
61149
+ const states = [join32(h, ".openclaw"), join32(h, ".clawdbot")];
61004
61150
  try {
61005
61151
  for (const name of readdirSync11(h).sort())
61006
- if (name.startsWith(".openclaw-")) states.push(join31(h, name));
61152
+ if (name.startsWith(".openclaw-")) states.push(join32(h, name));
61007
61153
  } catch {
61008
61154
  }
61009
- const out = states.map((s) => join31(s, "extensions", OPENCLAW_PLUGIN_ID));
61155
+ const out = states.map((s) => join32(s, "extensions", OPENCLAW_PLUGIN_ID));
61010
61156
  const active = openclawPluginDir(home2, env2);
61011
61157
  if (!out.includes(active)) out.push(active);
61012
61158
  return out;
@@ -61026,7 +61172,7 @@ var kind2 = (path) => {
61026
61172
  var openclawManifestIsOurs = (dir) => {
61027
61173
  try {
61028
61174
  const m = JSON.parse(
61029
- readFileSync27(join31(dir, "openclaw.plugin.json"), "utf8")
61175
+ readFileSync27(join32(dir, "openclaw.plugin.json"), "utf8")
61030
61176
  );
61031
61177
  return m?.id === OPENCLAW_PLUGIN_ID;
61032
61178
  } catch {
@@ -61047,7 +61193,7 @@ function openclawPluginState(dir, shipped) {
61047
61193
  if (k !== "dir") return "foreign";
61048
61194
  let marker;
61049
61195
  try {
61050
- marker = readFileSync27(join31(dir, OPENCLAW_MARKER), "utf8").trim();
61196
+ marker = readFileSync27(join32(dir, OPENCLAW_MARKER), "utf8").trim();
61051
61197
  } catch {
61052
61198
  return sameAsShipped(dir, shipped) ? "stale" : "foreign";
61053
61199
  }
@@ -61060,7 +61206,7 @@ function openclawPluginState(dir, shipped) {
61060
61206
  return "stale";
61061
61207
  }
61062
61208
  }
61063
- var installFile = (deps2) => join31(deps2.busHome ?? join31(deps2.home, ".oa-bus"), "install.json");
61209
+ var installFile = (deps2) => join32(deps2.busHome ?? join32(deps2.home, ".oa-bus"), "install.json");
61064
61210
  var recordedStateDir = (deps2) => {
61065
61211
  const r = readInstallFile(installFile(deps2)).openclaw;
61066
61212
  const d = r?.stateDir;
@@ -61092,9 +61238,9 @@ var firstLine2 = (s) => s.trim().split("\n")[0] ?? "";
61092
61238
  var why = (r) => firstLine2(r.stderr) || firstLine2(r.stdout) || `exit ${r.code}`;
61093
61239
  var realOrSelf = (p) => {
61094
61240
  try {
61095
- return realpathSync13(p);
61241
+ return realpathSync14(p);
61096
61242
  } catch {
61097
- return resolve9(p);
61243
+ return resolve10(p);
61098
61244
  }
61099
61245
  };
61100
61246
  var NEED_TOOLS = ["oabus_self", "oabus_send_message", "oabus_fetch"];
@@ -61138,7 +61284,7 @@ async function installOpenclaw(deps2, notes, optedOut) {
61138
61284
  return "absent";
61139
61285
  }
61140
61286
  const shipped = deps2.assets.openclaw;
61141
- if (shipped === void 0 || !existsSync11(join31(shipped, "openclaw.plugin.json")))
61287
+ if (shipped === void 0 || !existsSync11(join32(shipped, "openclaw.plugin.json")))
61142
61288
  throw new Error("the OpenClaw plugin is missing from this install");
61143
61289
  const dest = openclawPluginDir(deps2.home, deps2.env ?? {});
61144
61290
  const state = openclawPluginState(dest, shipped);
@@ -61146,7 +61292,7 @@ async function installOpenclaw(deps2, notes, optedOut) {
61146
61292
  throw new Error(
61147
61293
  `${dest} exists and is not Open Artifacts bus's; left it untouched`
61148
61294
  );
61149
- const habitsFile = join31(dest, OPENCLAW_HABITS_MARKER);
61295
+ const habitsFile = join32(dest, OPENCLAW_HABITS_MARKER);
61150
61296
  const dropHabitsIfOptedOut = () => {
61151
61297
  if (optedOut && kind2(dest) === "dir") rmSync15(habitsFile, { force: true });
61152
61298
  };
@@ -61167,7 +61313,7 @@ async function installOpenclaw(deps2, notes, optedOut) {
61167
61313
  INSTALL_TIMEOUT_MS
61168
61314
  );
61169
61315
  const restore2 = () => {
61170
- if (keepHabits && kind2(dest) === "dir" && kind2(join31(dest, OPENCLAW_MARKER)) === "file")
61316
+ if (keepHabits && kind2(dest) === "dir" && kind2(join32(dest, OPENCLAW_MARKER)) === "file")
61171
61317
  writeAtomic(habitsFile, HABITS_MARKER_TEXT);
61172
61318
  };
61173
61319
  if (r.code !== 0) {
@@ -61179,7 +61325,7 @@ async function installOpenclaw(deps2, notes, optedOut) {
61179
61325
  `\`openclaw plugins install\` finished, but ${dest} is not there`
61180
61326
  );
61181
61327
  writeAtomic(
61182
- join31(dest, OPENCLAW_MARKER),
61328
+ join32(dest, OPENCLAW_MARKER),
61183
61329
  `managed by the Open Artifacts bus installer: edits are replaced on reinstall. ${pluginHash(shipped)}
61184
61330
  `
61185
61331
  );
@@ -61276,21 +61422,21 @@ var habitsBlock = () => [
61276
61422
  ];
61277
61423
  var piAgentDir = (home2, env2) => {
61278
61424
  const d = env2.PI_CODING_AGENT_DIR;
61279
- if (!d) return join32(home2, ".pi", "agent");
61425
+ if (!d) return join33(home2, ".pi", "agent");
61280
61426
  if (d === "~") return home2;
61281
- return resolve10(d.startsWith("~/") ? join32(home2, d.slice(2)) : d);
61427
+ return resolve11(d.startsWith("~/") ? join33(home2, d.slice(2)) : d);
61282
61428
  };
61283
61429
  function habitsFiles(deps2, h) {
61284
61430
  const env2 = deps2.env ?? {};
61285
61431
  const pair = (dir) => {
61286
- const override = join32(dir, "AGENTS.override.md");
61287
- const plain3 = join32(dir, "AGENTS.md");
61432
+ const override = join33(dir, "AGENTS.override.md");
61433
+ const plain3 = join33(dir, "AGENTS.md");
61288
61434
  return existsSync12(override) ? [override, plain3] : [plain3, override];
61289
61435
  };
61290
61436
  switch (h) {
61291
61437
  case "claude":
61292
61438
  return [
61293
- join32(env2.CLAUDE_CONFIG_DIR ?? join32(deps2.home, ".claude"), "CLAUDE.md")
61439
+ join33(env2.CLAUDE_CONFIG_DIR ?? join33(deps2.home, ".claude"), "CLAUDE.md")
61294
61440
  ];
61295
61441
  case "codex":
61296
61442
  return pair(codexHome2(deps2.home, env2));
@@ -61298,8 +61444,8 @@ function habitsFiles(deps2, h) {
61298
61444
  return pair(piAgentDir(deps2.home, env2));
61299
61445
  case "opencode":
61300
61446
  return [
61301
- join32(
61302
- env2.OPENCODE_CONFIG_DIR ?? join32(env2.XDG_CONFIG_HOME ?? join32(deps2.home, ".config"), "opencode"),
61447
+ join33(
61448
+ env2.OPENCODE_CONFIG_DIR ?? join33(env2.XDG_CONFIG_HOME ?? join33(deps2.home, ".config"), "opencode"),
61303
61449
  "AGENTS.md"
61304
61450
  )
61305
61451
  ];
@@ -61325,10 +61471,10 @@ function blockState(existing) {
61325
61471
  var separatorFor = (existing) => {
61326
61472
  if (existing === "") return "";
61327
61473
  const eol2 = existing.includes("\r\n") ? "\r\n" : "\n";
61328
- let sep6 = "";
61329
- if (!existing.endsWith("\n")) sep6 += eol2;
61330
- if (!/\n\r?\n$/.test(existing + sep6)) sep6 += eol2;
61331
- return sep6;
61474
+ let sep7 = "";
61475
+ if (!existing.endsWith("\n")) sep7 += eol2;
61476
+ if (!/\n\r?\n$/.test(existing + sep7)) sep7 += eol2;
61477
+ return sep7;
61332
61478
  };
61333
61479
  function withHabits(existing, block, added) {
61334
61480
  const lines = existing.split("\n");
@@ -61369,18 +61515,18 @@ var isLink = (path) => {
61369
61515
  function linkInfo(deps2, path) {
61370
61516
  try {
61371
61517
  if (!isLink(path)) return void 0;
61372
- const target2 = realpathSync14(path);
61373
- const homes = [deps2.home, realpathSync14(deps2.home)];
61518
+ const target2 = realpathSync15(path);
61519
+ const homes = [deps2.home, realpathSync15(deps2.home)];
61374
61520
  return {
61375
61521
  target: target2,
61376
- outside: !homes.some((h) => target2.startsWith(`${h}${sep4}`))
61522
+ outside: !homes.some((h) => target2.startsWith(`${h}${sep5}`))
61377
61523
  };
61378
61524
  } catch {
61379
61525
  return void 0;
61380
61526
  }
61381
61527
  }
61382
61528
  var record6 = (busHome2) => {
61383
- const raw = busHome2 ? readInstallFile(join32(busHome2, "install.json")).habits : void 0;
61529
+ const raw = busHome2 ? readInstallFile(join33(busHome2, "install.json")).habits : void 0;
61384
61530
  const h = typeof raw === "object" && raw !== null ? raw : {};
61385
61531
  return {
61386
61532
  optedOut: h.optedOut === true,
@@ -61400,7 +61546,7 @@ var pluginDirsOf = (v) => {
61400
61546
  var saveRecord = (busHome2, patch) => {
61401
61547
  if (!busHome2) return;
61402
61548
  const cur = record6(busHome2);
61403
- updateInstallFile(join32(busHome2, "install.json"), {
61549
+ updateInstallFile(join33(busHome2, "install.json"), {
61404
61550
  habits: { ...cur, ...patch }
61405
61551
  });
61406
61552
  };
@@ -61487,7 +61633,7 @@ function removeHabits(deps2, harnesses = HABITS_HARNESSES) {
61487
61633
  const p = setPluginHabits(deps2, PLUGIN_HARNESSES, false);
61488
61634
  files2.push(...p.markers);
61489
61635
  notes.push(...p.notes);
61490
- if (deps2.busHome && existsSync12(join32(deps2.busHome, "install.json")))
61636
+ if (deps2.busHome && existsSync12(join33(deps2.busHome, "install.json")))
61491
61637
  saveRecord(deps2.busHome, { files: kept });
61492
61638
  return {
61493
61639
  files: files2,
@@ -61536,7 +61682,7 @@ var PLUGIN_HARNESSES = [
61536
61682
  ];
61537
61683
  var pluginPaths = (deps2, p) => {
61538
61684
  const dir = p.dir(deps2.home, deps2.env ?? {});
61539
- return { dir, marker: join32(dir, p.marker) };
61685
+ return { dir, marker: join33(dir, p.marker) };
61540
61686
  };
61541
61687
  var pluginOurs = (dir, p) => {
61542
61688
  try {
@@ -61571,7 +61717,7 @@ function setPluginHabits(deps2, plugins2, on) {
61571
61717
  for (const p of plugins2) {
61572
61718
  if (on) {
61573
61719
  const dir = pluginPaths(deps2, p).dir;
61574
- const marker = join32(dir, p.marker);
61720
+ const marker = join33(dir, p.marker);
61575
61721
  try {
61576
61722
  if (isLink(dir) || !pluginOurs(dir, p)) {
61577
61723
  notes.push(
@@ -61616,7 +61762,7 @@ function setPluginHabits(deps2, plugins2, on) {
61616
61762
  else notes.push(scan2.note);
61617
61763
  }
61618
61764
  for (const dir of dirs) {
61619
- const marker = join32(dir, p.marker);
61765
+ const marker = join33(dir, p.marker);
61620
61766
  const d = probe(dir);
61621
61767
  if (d.k === "absent") continue;
61622
61768
  if (d.k === "error") {
@@ -61668,7 +61814,7 @@ function setPluginHabits(deps2, plugins2, on) {
61668
61814
  done.add(dir);
61669
61815
  if (!changed.includes(p)) changed.push(p);
61670
61816
  }
61671
- if (deps2.busHome && existsSync12(join32(deps2.busHome, "install.json"))) {
61817
+ if (deps2.busHome && existsSync12(join33(deps2.busHome, "install.json"))) {
61672
61818
  const { pluginDirs } = record6(deps2.busHome);
61673
61819
  const had = pluginDirs[p.name];
61674
61820
  if (had !== void 0) {
@@ -61716,7 +61862,7 @@ var habitsQuestionLines = (q) => [
61716
61862
 
61717
61863
  // src/steps/opencode-proof.ts
61718
61864
  import { existsSync as existsSync13, readFileSync as readFileSync29, rmSync as rmSync17 } from "node:fs";
61719
- import { dirname as dirname14, isAbsolute as isAbsolute12, join as join33, resolve as resolve11 } from "node:path";
61865
+ import { dirname as dirname15, isAbsolute as isAbsolute13, join as join34, resolve as resolve12 } from "node:path";
61720
61866
  init_src();
61721
61867
  var OPENCODE_ENTRY_FILE = "opencode-mcp-entry.json";
61722
61868
  var isRecord5 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
@@ -61758,8 +61904,8 @@ function tokenFileOf(e) {
61758
61904
  var REMOTE_ONLY = /* @__PURE__ */ new Set(["type", "url", "headers", "oauth"]);
61759
61905
  function resolveTokenFile(x, configFile, home2) {
61760
61906
  if (x === "~") return home2;
61761
- if (x.startsWith("~/")) return join33(home2, x.slice(2));
61762
- return isAbsolute12(x) ? x : resolve11(dirname14(configFile), x);
61907
+ if (x.startsWith("~/")) return join34(home2, x.slice(2));
61908
+ return isAbsolute13(x) ? x : resolve12(dirname15(configFile), x);
61763
61909
  }
61764
61910
  var proxyEntry = (io, origin, tokenFile, entry) => {
61765
61911
  const kept = Object.fromEntries(
@@ -61896,7 +62042,7 @@ function proxyProgramMissing2(entry, origin, which2) {
61896
62042
  if (origin !== void 0 && c[i + 2] !== origin) return void 0;
61897
62043
  for (const part of c.slice(0, i)) {
61898
62044
  if (typeof part !== "string") continue;
61899
- if (isAbsolute12(part) ? !existsSync13(part) : !which2(part)) return part;
62045
+ if (isAbsolute13(part) ? !existsSync13(part) : !which2(part)) return part;
61900
62046
  }
61901
62047
  return void 0;
61902
62048
  }
@@ -62050,45 +62196,45 @@ var readAssets = () => ({
62050
62196
  });
62051
62197
  var movedHome = (deps2) => {
62052
62198
  if (deps2.busHome === void 0) return void 0;
62053
- const ob = resolve12(deps2.busHome);
62054
- return ob === join34(deps2.home, ".oa-bus") ? void 0 : ob;
62199
+ const ob = resolve13(deps2.busHome);
62200
+ return ob === join35(deps2.home, ".oa-bus") ? void 0 : ob;
62055
62201
  };
62056
62202
  var homeLine = (ob) => `process.env.OA_BUS_HOME ||= ${JSON.stringify(ob)};`;
62057
62203
  var withHome = (text3, ob) => ob === void 0 ? text3 : `${homeLine(ob)}
62058
62204
  ${text3}`;
62059
62205
  var paths = (deps2) => {
62060
62206
  const env2 = deps2.env ?? {};
62061
- const opencode = env2.OPENCODE_CONFIG_DIR ?? join34(env2.XDG_CONFIG_HOME ?? join34(deps2.home, ".config"), "opencode");
62062
- const busDir = deps2.busHome ?? join34(deps2.home, ".oa-bus");
62207
+ const opencode = env2.OPENCODE_CONFIG_DIR ?? join35(env2.XDG_CONFIG_HOME ?? join35(deps2.home, ".config"), "opencode");
62208
+ const busDir = deps2.busHome ?? join35(deps2.home, ".oa-bus");
62063
62209
  return {
62064
62210
  claude: claudeConfigFile(deps2.home, env2),
62065
62211
  // OpenCode reads both; edit the one the user has, else create .json.
62066
62212
  opencodeConfigs: [
62067
- join34(opencode, "opencode.json"),
62068
- join34(opencode, "opencode.jsonc")
62213
+ join35(opencode, "opencode.json"),
62214
+ join35(opencode, "opencode.jsonc")
62069
62215
  ],
62070
- opencodeCli: join34(opencode, "cli.json"),
62071
- record: join34(busDir, "install.json"),
62216
+ opencodeCli: join35(opencode, "cli.json"),
62217
+ record: join35(busDir, "install.json"),
62072
62218
  // #1856: where install keeps the OpenCode entry it replaced with the proxy.
62073
- opencodeEntry: join34(busDir, OPENCODE_ENTRY_FILE),
62219
+ opencodeEntry: join35(busDir, OPENCODE_ENTRY_FILE),
62074
62220
  // #1856: Pi's own MCP config, and where install keeps the entry it moved.
62075
- piMcp: join34(
62076
- agentDirEnv(deps2.home, env2) ?? join34(deps2.home, ".pi/agent"),
62221
+ piMcp: join35(
62222
+ agentDirEnv(deps2.home, env2) ?? join35(deps2.home, ".pi/agent"),
62077
62223
  "mcp.json"
62078
62224
  ),
62079
- piEntry: join34(busDir, PI_ENTRY_FILE),
62080
- ompOrigin: join34(busDir, OMP_ORIGIN_FILE),
62225
+ piEntry: join35(busDir, PI_ENTRY_FILE),
62226
+ ompOrigin: join35(busDir, OMP_ORIGIN_FILE),
62081
62227
  // OpenCode registers the folder that holds tui.js.
62082
- opencodePlugin: join34(busDir, "integrations/opencode", NAME),
62083
- pi: join34(
62084
- agentDirEnv(deps2.home, env2) ?? join34(deps2.home, ".pi/agent"),
62228
+ opencodePlugin: join35(busDir, "integrations/opencode", NAME),
62229
+ pi: join35(
62230
+ agentDirEnv(deps2.home, env2) ?? join35(deps2.home, ".pi/agent"),
62085
62231
  "extensions/oa-bus.ts"
62086
62232
  ),
62087
- omp: join34(ompAgentDir(deps2.home, env2), "extensions/oa-bus.ts"),
62233
+ omp: join35(ompAgentDir(deps2.home, env2), "extensions/oa-bus.ts"),
62088
62234
  codex: codexConfig(deps2.home, env2),
62089
62235
  codexBin: codexBinFile(busDir),
62090
62236
  // #1856: where install keeps the Codex entry it swapped for the proxy.
62091
- codexEntry: join34(busDir, CODEX_PROXY_ENTRY_FILE),
62237
+ codexEntry: join35(busDir, CODEX_PROXY_ENTRY_FILE),
62092
62238
  busDir
62093
62239
  };
62094
62240
  };
@@ -62096,9 +62242,9 @@ function agentDirEnv(home2, env2) {
62096
62242
  const dir = env2.PI_CODING_AGENT_DIR;
62097
62243
  if (!dir) return void 0;
62098
62244
  if (dir === "~") return home2;
62099
- return resolve12(dir.startsWith("~/") ? join34(home2, dir.slice(2)) : dir);
62245
+ return resolve13(dir.startsWith("~/") ? join35(home2, dir.slice(2)) : dir);
62100
62246
  }
62101
- var ompRoot = (home2, env2) => join34(home2, env2.PI_CONFIG_DIR || ".omp");
62247
+ var ompRoot = (home2, env2) => join35(home2, env2.PI_CONFIG_DIR || ".omp");
62102
62248
  function ompProfile(env2) {
62103
62249
  const name = (env2.OMP_PROFILE !== void 0 ? env2.OMP_PROFILE : env2.PI_PROFILE)?.trim();
62104
62250
  if (!name || name === "default" || name.endsWith(".")) return void 0;
@@ -62107,14 +62253,14 @@ function ompProfile(env2) {
62107
62253
  function ompAgentDir(home2, env2) {
62108
62254
  const root = ompRoot(home2, env2);
62109
62255
  const profile = ompProfile(env2);
62110
- if (profile) return join34(root, "profiles", profile, "agent");
62256
+ if (profile) return join35(root, "profiles", profile, "agent");
62111
62257
  const piProfile = ompProfile({ PI_PROFILE: env2.PI_PROFILE });
62112
62258
  const dir = agentDirEnv(home2, env2);
62113
- if (dir && !(piProfile && dir === join34(root, "profiles", piProfile, "agent")))
62259
+ if (dir && !(piProfile && dir === join35(root, "profiles", piProfile, "agent")))
62114
62260
  return dir;
62115
- return join34(root, "agent");
62261
+ return join35(root, "agent");
62116
62262
  }
62117
- var hasOmp = (deps2) => deps2.which("omp") || present2(ompRoot(deps2.home, deps2.env ?? {})) || present2(join34(deps2.home, ".bun/bin/omp"));
62263
+ var hasOmp = (deps2) => deps2.which("omp") || present2(ompRoot(deps2.home, deps2.env ?? {})) || present2(join35(deps2.home, ".bun/bin/omp"));
62118
62264
  var sharedFile = (deps2) => paths(deps2).omp === paths(deps2).pi;
62119
62265
  function readDoc(path) {
62120
62266
  let text3;
@@ -62144,19 +62290,19 @@ function target(path) {
62144
62290
  let p = path;
62145
62291
  for (let hops = 0; hops < 40; hops++) {
62146
62292
  if (!present2(p) || !lstatSync17(p).isSymbolicLink()) {
62147
- if (p !== path && !existsSync15(dirname15(p)))
62293
+ if (p !== path && !existsSync15(dirname16(p)))
62148
62294
  throw new Error(
62149
62295
  `${path} is a dangling symlink to ${p}; left it untouched`
62150
62296
  );
62151
62297
  return p;
62152
62298
  }
62153
- p = resolve12(dirname15(p), readlinkSync5(p));
62299
+ p = resolve13(dirname16(p), readlinkSync5(p));
62154
62300
  }
62155
62301
  throw new Error(`${path}: too many symlinks; left it untouched`);
62156
62302
  }
62157
62303
  function writeAtomic2(path, data, mode) {
62158
62304
  const dest = target(path);
62159
- mkdirSync15(dirname15(dest), { recursive: true });
62305
+ mkdirSync15(dirname16(dest), { recursive: true });
62160
62306
  let m = mode ?? 420;
62161
62307
  if (mode === void 0)
62162
62308
  try {
@@ -62378,8 +62524,8 @@ var isolatedInstall = (deps2) => {
62378
62524
  if (deps2.isolated) return true;
62379
62525
  const dir = deps2.env?.OPENCODE_CONFIG_DIR;
62380
62526
  if (!dir) return false;
62381
- const rel = relative6(resolve12(deps2.home), resolve12(dir));
62382
- return rel.startsWith("..") || isAbsolute13(rel);
62527
+ const rel = relative7(resolve13(deps2.home), resolve13(dir));
62528
+ return rel.startsWith("..") || isAbsolute14(rel);
62383
62529
  };
62384
62530
  async function restartOpencode(deps2, notes, changed) {
62385
62531
  if (!changed) return;
@@ -62473,7 +62619,7 @@ var install = {
62473
62619
  if (madeCli.length > 0)
62474
62620
  created[p.opencodeCli] = add2(p.opencodeCli, madeCli);
62475
62621
  writeRecord2(p.record, record7, created);
62476
- const pluginFile = join34(p.opencodePlugin, "tui.js");
62622
+ const pluginFile = join35(p.opencodePlugin, "tui.js");
62477
62623
  const pluginText = withHome(deps2.assets.opencodePlugin, movedHome(deps2));
62478
62624
  let pluginBefore;
62479
62625
  try {
@@ -62791,7 +62937,7 @@ function checkAdapters(deps2) {
62791
62937
  }) && listed(
62792
62938
  parseJsonc(readFileSync31(p.opencodeCli, "utf8"), p.opencodeCli),
62793
62939
  p.opencodePlugin
62794
- ) && homed(join34(p.opencodePlugin, "tui.js"))
62940
+ ) && homed(join35(p.opencodePlugin, "tui.js"))
62795
62941
  ),
62796
62942
  pi: state("pi", () => homed(p.pi)),
62797
62943
  omp: state("omp", () => homed(p.omp)),
@@ -62895,22 +63041,22 @@ import {
62895
63041
  rmSync as rmSync20,
62896
63042
  writeFileSync as writeFileSync19
62897
63043
  } from "node:fs";
62898
- import { delimiter as delimiter3, dirname as dirname16, join as join35, resolve as resolve13, sep as sep5 } from "node:path";
63044
+ import { delimiter as delimiter3, dirname as dirname17, join as join36, resolve as resolve14, sep as sep6 } from "node:path";
62899
63045
  var SHIM_MARKER = "# oa-bus shim: written by oa-bus install";
62900
63046
  var HOME_PREFIX = "# oa-bus home: ";
62901
63047
  var NAME2 = "oa-bus";
62902
63048
  var LOCAL_HINT = 'export PATH="$HOME/.local/bin:$PATH"';
62903
63049
  var isWindows = (platform) => platform.startsWith("win32");
62904
- var pathDirs = (p) => (p ?? "").split(delimiter3).filter((d) => d !== "").map((d) => resolve13(d));
62905
- var candidates2 = (o) => o.platform.startsWith("darwin") ? [join35(o.userHome, ".local", "bin"), join35(o.userHome, "bin")] : [join35(o.userHome, ".local", "bin")];
63050
+ var pathDirs = (p) => (p ?? "").split(delimiter3).filter((d) => d !== "").map((d) => resolve14(d));
63051
+ var candidates2 = (o) => o.platform.startsWith("darwin") ? [join36(o.userHome, ".local", "bin"), join36(o.userHome, "bin")] : [join36(o.userHome, ".local", "bin")];
62906
63052
  var shQuote2 = (v) => `'${v.replaceAll("'", `'\\''`)}'`;
62907
63053
  function shimText(o) {
62908
- const moved = resolve13(o.busHome) !== resolve13(o.userHome, ".oa-bus");
63054
+ const moved = resolve14(o.busHome) !== resolve14(o.userHome, ".oa-bus");
62909
63055
  return [
62910
63056
  "#!/bin/sh",
62911
63057
  SHIM_MARKER,
62912
- `${HOME_PREFIX}${resolve13(o.busHome)}`,
62913
- ...moved ? [`OA_BUS_HOME=${shQuote2(resolve13(o.busHome))}`, "export OA_BUS_HOME"] : [],
63058
+ `${HOME_PREFIX}${resolve14(o.busHome)}`,
63059
+ ...moved ? [`OA_BUS_HOME=${shQuote2(resolve14(o.busHome))}`, "export OA_BUS_HOME"] : [],
62914
63060
  `exec ${o.argv.map(shQuote2).join(" ")} "$@"`,
62915
63061
  ""
62916
63062
  ].join("\n");
@@ -62924,8 +63070,8 @@ function ownerOf(file2, busHome2) {
62924
63070
  }
62925
63071
  if (st.isSymbolicLink()) {
62926
63072
  try {
62927
- const to = resolve13(dirname16(file2), readlinkSync6(file2));
62928
- const home2 = resolve13(busHome2);
63073
+ const to = resolve14(dirname17(file2), readlinkSync6(file2));
63074
+ const home2 = resolve14(busHome2);
62929
63075
  return to === home2 || to.startsWith(`${home2}/`) ? { ours: true, home: home2 } : { ours: false };
62930
63076
  } catch {
62931
63077
  return { ours: false };
@@ -62941,7 +63087,7 @@ function ownerOf(file2, busHome2) {
62941
63087
  return { ours: false };
62942
63088
  }
62943
63089
  }
62944
- var sameHome = (owner, busHome2) => owner?.ours === true && (owner.home === void 0 || owner.home === resolve13(busHome2));
63090
+ var sameHome = (owner, busHome2) => owner?.ours === true && (owner.home === void 0 || owner.home === resolve14(busHome2));
62945
63091
  function writeShim(path, text3) {
62946
63092
  const tmp = `${path}.${process.pid}.tmp`;
62947
63093
  rmSync20(tmp, { force: true });
@@ -62959,7 +63105,7 @@ function installShim(o) {
62959
63105
  const onPath = new Set(pathDirs(o.env.PATH));
62960
63106
  const list = candidates2(o);
62961
63107
  const dir = list.find((d) => onPath.has(d)) ?? list[0];
62962
- const path = join35(dir, NAME2);
63108
+ const path = join36(dir, NAME2);
62963
63109
  const owner = ownerOf(path, o.busHome);
62964
63110
  if (owner && !owner.ours) return { kind: "foreign", path };
62965
63111
  if (owner?.ours && !sameHome(owner, o.busHome))
@@ -62968,7 +63114,7 @@ function installShim(o) {
62968
63114
  const text3 = shimText(o);
62969
63115
  writeShim(path, text3);
62970
63116
  for (const d of list) {
62971
- const other = join35(d, NAME2);
63117
+ const other = join36(d, NAME2);
62972
63118
  if (d !== dir && sameHome(ownerOf(other, o.busHome), o.busHome))
62973
63119
  writeShim(other, text3);
62974
63120
  }
@@ -62984,10 +63130,10 @@ function removeShim(o) {
62984
63130
  if (isWindows(o.platform)) return void 0;
62985
63131
  let removed;
62986
63132
  for (const dir of candidates2({ ...o, env: {} })) {
62987
- const file2 = join35(dir, NAME2);
63133
+ const file2 = join36(dir, NAME2);
62988
63134
  const owner = ownerOf(file2, o.busHome);
62989
63135
  if (!owner?.ours) continue;
62990
- if (owner.home !== void 0 && owner.home !== resolve13(o.busHome)) continue;
63136
+ if (owner.home !== void 0 && owner.home !== resolve14(o.busHome)) continue;
62991
63137
  rmSync20(file2, { force: true });
62992
63138
  removed = file2;
62993
63139
  }
@@ -63004,18 +63150,18 @@ var executable2 = (f) => {
63004
63150
  function shimState(o) {
63005
63151
  if (isWindows(o.platform)) return void 0;
63006
63152
  const dirs = pathDirs(o.env.PATH).filter(
63007
- (d) => !(d.endsWith(`${sep5}node_modules${sep5}.bin`) && d.split(sep5).includes("_npx"))
63153
+ (d) => !(d.endsWith(`${sep6}node_modules${sep6}.bin`) && d.split(sep6).includes("_npx"))
63008
63154
  );
63009
63155
  for (const dir of dirs) {
63010
- const file2 = join35(dir, NAME2);
63156
+ const file2 = join36(dir, NAME2);
63011
63157
  if (!executable2(file2)) continue;
63012
63158
  const owner = ownerOf(file2, o.busHome);
63013
- return owner?.ours && (owner.home === void 0 || owner.home === resolve13(o.busHome)) ? { kind: "ours", path: file2 } : { kind: "other", path: file2 };
63159
+ return owner?.ours && (owner.home === void 0 || owner.home === resolve14(o.busHome)) ? { kind: "ours", path: file2 } : { kind: "other", path: file2 };
63014
63160
  }
63015
63161
  for (const dir of candidates2(o)) {
63016
- const file2 = join35(dir, NAME2);
63162
+ const file2 = join36(dir, NAME2);
63017
63163
  const owner = ownerOf(file2, o.busHome);
63018
- if (owner?.ours && (owner.home === void 0 || owner.home === resolve13(o.busHome)))
63164
+ if (owner?.ours && (owner.home === void 0 || owner.home === resolve14(o.busHome)))
63019
63165
  return { kind: "off-path", path: file2, hint: LOCAL_HINT };
63020
63166
  }
63021
63167
  return { kind: "missing" };
@@ -63080,7 +63226,7 @@ import {
63080
63226
  unlinkSync as unlinkSync4,
63081
63227
  writeSync as writeSync5
63082
63228
  } from "node:fs";
63083
- import { join as join36 } from "node:path";
63229
+ import { join as join37 } from "node:path";
63084
63230
  init_src();
63085
63231
 
63086
63232
  // src/machine-label.ts
@@ -63131,7 +63277,7 @@ function checkVerificationUri(uri, hub) {
63131
63277
  function writeMachineFile(home2, body) {
63132
63278
  mkdirSync17(home2, { recursive: true, mode: 448 });
63133
63279
  chmodSync22(home2, 448);
63134
- const tmp = join36(home2, `.machine.json.${randomBytes8(8).toString("hex")}.tmp`);
63280
+ const tmp = join37(home2, `.machine.json.${randomBytes8(8).toString("hex")}.tmp`);
63135
63281
  const fd = openSync10(tmp, "wx", 384);
63136
63282
  try {
63137
63283
  writeSync5(fd, body);
@@ -63143,7 +63289,7 @@ function writeMachineFile(home2, body) {
63143
63289
  closeSync10(fd);
63144
63290
  try {
63145
63291
  chmodSync22(tmp, 384);
63146
- renameSync21(tmp, join36(home2, "machine.json"));
63292
+ renameSync21(tmp, join37(home2, "machine.json"));
63147
63293
  } catch (e) {
63148
63294
  unlinkSync4(tmp);
63149
63295
  throw e;
@@ -63293,7 +63439,7 @@ async function loginInner(args) {
63293
63439
  `${JSON.stringify({ hub, label: label2, machine_token: poll.machine_token }, null, 2)}
63294
63440
  `
63295
63441
  );
63296
- rmSync21(join36(args.home, "revoked"), { force: true });
63442
+ rmSync21(join37(args.home, "revoked"), { force: true });
63297
63443
  }
63298
63444
  if (!events?.code) print(`Approved this machine as ${label2}.`);
63299
63445
  return {
@@ -63431,15 +63577,15 @@ async function autoUpdate(opts, ctx) {
63431
63577
 
63432
63578
  // src/commands/daemon.ts
63433
63579
  import { existsSync as existsSync16 } from "node:fs";
63434
- import { join as join39 } from "node:path";
63580
+ import { join as join40 } from "node:path";
63435
63581
  import { fileURLToPath as fileURLToPath6 } from "node:url";
63436
63582
 
63437
63583
  // src/machine.ts
63438
63584
  import { readFileSync as readFileSync33, statSync as statSync11 } from "node:fs";
63439
- import { join as join37 } from "node:path";
63585
+ import { join as join38 } from "node:path";
63440
63586
  init_src();
63441
63587
  function readMachine(home2) {
63442
- const file2 = join37(home2, "machine.json");
63588
+ const file2 = join38(home2, "machine.json");
63443
63589
  let text3;
63444
63590
  let mode;
63445
63591
  try {
@@ -63473,7 +63619,7 @@ var originOf2 = (hub) => {
63473
63619
 
63474
63620
  // src/steps/claude-proof-check.ts
63475
63621
  import { readFileSync as readFileSync34 } from "node:fs";
63476
- import { join as join38 } from "node:path";
63622
+ import { join as join39 } from "node:path";
63477
63623
  var PROOF_EVENT = "claude_proof_applied";
63478
63624
  var DAY_MS = 864e5;
63479
63625
  var safeText = (s, max = 80) => {
@@ -63497,10 +63643,10 @@ function claudeProofChecks(ctx, hub) {
63497
63643
  } catch {
63498
63644
  return [];
63499
63645
  }
63500
- const rec = readRecord(join38(ctx.home, "install.json"));
63646
+ const rec = readRecord(join39(ctx.home, "install.json"));
63501
63647
  const file2 = rec.config ?? claudeConfigFile(ctx.userHome, ctx.env);
63502
63648
  const r = proofReport(file2, origin, {
63503
- projectFile: join38(ctx.cwd, ".mcp.json"),
63649
+ projectFile: join39(ctx.cwd, ".mcp.json"),
63504
63650
  cwd: ctx.cwd,
63505
63651
  recorded: rec.proofs,
63506
63652
  ...isDefaultHome2(ctx.home, ctx.userHome) ? {} : { busHome: ctx.home }
@@ -63606,7 +63752,7 @@ function claudeProofChecks(ctx, hub) {
63606
63752
  function lastAutoFix(ctx) {
63607
63753
  let text3;
63608
63754
  try {
63609
- text3 = readFileSync34(join38(ctx.home, "logs", "events.log"), "utf8");
63755
+ text3 = readFileSync34(join39(ctx.home, "logs", "events.log"), "utf8");
63610
63756
  } catch {
63611
63757
  return void 0;
63612
63758
  }
@@ -63632,12 +63778,12 @@ var lasting = (e) => [...START_ERROR_CODES, "EACCES", "EPERM"].includes(
63632
63778
  );
63633
63779
  async function daemon(ctx, run5 = runDaemon, signals = process) {
63634
63780
  const m = readMachine(ctx.home);
63635
- if (existsSync16(join39(ctx.home, "revoked")) && (m.state !== "ok" || m.revoked)) {
63781
+ if (existsSync16(join40(ctx.home, "revoked")) && (m.state !== "ok" || m.revoked)) {
63636
63782
  sayErr(ctx, ctx.copy.revoked());
63637
63783
  return 0;
63638
63784
  }
63639
- const events = createEventLog(join39(ctx.home, "logs", "events.log"));
63640
- const config2 = readRecord(join39(ctx.home, "install.json")).config;
63785
+ const events = createEventLog(join40(ctx.home, "logs", "events.log"));
63786
+ const config2 = readRecord(join40(ctx.home, "install.json")).config;
63641
63787
  if (m.state === "ok" && config2 !== void 0 && wiredTo(ctx))
63642
63788
  reapplyClaudeProof(
63643
63789
  {
@@ -63650,7 +63796,7 @@ async function daemon(ctx, run5 = runDaemon, signals = process) {
63650
63796
  },
63651
63797
  (c) => events(PROOF_EVENT, { name: c.entry, kind: c.scope })
63652
63798
  );
63653
- return new Promise((resolve18) => {
63799
+ return new Promise((resolve19) => {
63654
63800
  let running;
63655
63801
  let ended = false;
63656
63802
  const end = (code2) => {
@@ -63658,7 +63804,7 @@ async function daemon(ctx, run5 = runDaemon, signals = process) {
63658
63804
  ended = true;
63659
63805
  signals.off("SIGINT", onSignal);
63660
63806
  signals.off("SIGTERM", onSignal);
63661
- void (running?.stop() ?? Promise.resolve()).finally(() => resolve18(code2));
63807
+ void (running?.stop() ?? Promise.resolve()).finally(() => resolve19(code2));
63662
63808
  };
63663
63809
  const onSignal = () => end(0);
63664
63810
  signals.once("SIGINT", onSignal);
@@ -63691,11 +63837,11 @@ async function daemon(ctx, run5 = runDaemon, signals = process) {
63691
63837
 
63692
63838
  // src/commands/doctor.ts
63693
63839
  import { readFileSync as readFileSync39 } from "node:fs";
63694
- import { join as join46 } from "node:path";
63840
+ import { join as join48 } from "node:path";
63695
63841
 
63696
63842
  // src/steps/claude-plugins.ts
63697
63843
  import { readFileSync as readFileSync36 } from "node:fs";
63698
- import { join as join41 } from "node:path";
63844
+ import { join as join42 } from "node:path";
63699
63845
 
63700
63846
  // src/steps/output-style.ts
63701
63847
  import {
@@ -63705,21 +63851,21 @@ import {
63705
63851
  rmdirSync as rmdirSync3,
63706
63852
  rmSync as rmSync22
63707
63853
  } from "node:fs";
63708
- import { dirname as dirname17, join as join40 } from "node:path";
63854
+ import { dirname as dirname18, join as join41 } from "node:path";
63709
63855
  var OUTPUT_STYLE_FILE = "artifacts-teammate.md";
63710
63856
  var OUTPUT_STYLE_MARKER = "<!-- managed by the Open Artifacts bus installer: edits are replaced on reinstall. -->";
63711
63857
  var OUTPUT_STYLE_NAME = "Artifacts Teammate";
63712
63858
  var OUTPUT_STYLE_PLUGIN_NAME = "open-artifacts:Artifacts Teammate";
63713
63859
  var isOurName = (v) => v === OUTPUT_STYLE_NAME || v === OUTPUT_STYLE_PLUGIN_NAME;
63714
- var claudeSettingsFile = (w) => join40(w.env?.CLAUDE_CONFIG_DIR ?? join40(w.home, ".claude"), "settings.json");
63860
+ var claudeSettingsFile = (w) => join41(w.env?.CLAUDE_CONFIG_DIR ?? join41(w.home, ".claude"), "settings.json");
63715
63861
  var readRecord3 = (busHome2) => {
63716
63862
  if (!busHome2) return void 0;
63717
- const r = readInstallFile(join40(busHome2, "install.json")).outputStyle;
63863
+ const r = readInstallFile(join41(busHome2, "install.json")).outputStyle;
63718
63864
  return typeof r === "object" && r !== null ? r : void 0;
63719
63865
  };
63720
- var writeRecord3 = (busHome2, r) => updateInstallFile(join40(busHome2, "install.json"), { outputStyle: r });
63721
- var styleDir = (w) => join40(w.env?.CLAUDE_CONFIG_DIR ?? join40(w.home, ".claude"), "output-styles");
63722
- var outputStyleFile = (w) => join40(styleDir(w), OUTPUT_STYLE_FILE);
63866
+ var writeRecord3 = (busHome2, r) => updateInstallFile(join41(busHome2, "install.json"), { outputStyle: r });
63867
+ var styleDir = (w) => join41(w.env?.CLAUDE_CONFIG_DIR ?? join41(w.home, ".claude"), "output-styles");
63868
+ var outputStyleFile = (w) => join41(styleDir(w), OUTPUT_STYLE_FILE);
63723
63869
  var isOurs2 = (text3) => {
63724
63870
  const m = /^---\n[\s\S]*?\n---\n/.exec(text3.replace(/\r\n/g, "\n"));
63725
63871
  return m !== null && text3.replace(/\r\n/g, "\n").slice(m[0].length).split("\n", 1)[0] === OUTPUT_STYLE_MARKER;
@@ -63916,7 +64062,7 @@ var outputStyleOn = (deps2) => {
63916
64062
  var outputStyleState = (deps2) => {
63917
64063
  const path = outputStyleFile(deps2);
63918
64064
  try {
63919
- if (isLink2(dirname17(path)) || isLink2(path)) return void 0;
64065
+ if (isLink2(dirname18(path)) || isLink2(path)) return void 0;
63920
64066
  if (!isOurs2(readFileSync35(path, "utf8"))) return void 0;
63921
64067
  const s = readSettings(claudeSettingsFile(deps2));
63922
64068
  return { path, on: s.ok && s.style === OUTPUT_STYLE_NAME };
@@ -63937,10 +64083,10 @@ var SPARSE = [".claude-plugin", "plugins", "packages/claude-code-shortcuts"];
63937
64083
  var CALL_MS = 12e4;
63938
64084
  var MCP_LIST_MS = 2e4;
63939
64085
  var readRecord4 = (busHome2) => {
63940
- const r = readInstallFile(join41(busHome2, "install.json")).claudePlugins;
64086
+ const r = readInstallFile(join42(busHome2, "install.json")).claudePlugins;
63941
64087
  return typeof r === "object" && r !== null ? r : void 0;
63942
64088
  };
63943
- var writeRecord4 = (busHome2, r) => updateInstallFile(join41(busHome2, "install.json"), { claudePlugins: r });
64089
+ var writeRecord4 = (busHome2, r) => updateInstallFile(join42(busHome2, "install.json"), { claudePlugins: r });
63944
64090
  var cmpVersion = (a, b) => {
63945
64091
  const pa = a.split(".").map(Number);
63946
64092
  const pb = b.split(".").map(Number);
@@ -64405,7 +64551,7 @@ function readInstanceUrl(deps2) {
64405
64551
 
64406
64552
  // src/steps/claude-sessions.ts
64407
64553
  import { readFileSync as readFileSync37 } from "node:fs";
64408
- import { join as join42 } from "node:path";
64554
+ import { join as join43 } from "node:path";
64409
64555
  var UNBOUND_EVENT = "mcp_proof_unbound";
64410
64556
  var DAY_MS2 = 864e5;
64411
64557
  function hubOrigin(hub) {
@@ -64433,7 +64579,7 @@ function helperFailures(ctx) {
64433
64579
  const out = /* @__PURE__ */ new Map();
64434
64580
  let text3;
64435
64581
  try {
64436
- text3 = readFileSync37(join42(ctx.home, "logs", "events.log"), "utf8");
64582
+ text3 = readFileSync37(join43(ctx.home, "logs", "events.log"), "utf8");
64437
64583
  } catch {
64438
64584
  return out;
64439
64585
  }
@@ -64479,7 +64625,7 @@ function entryApplies(ctx, origin, cwd) {
64479
64625
  const p = isObj2(doc.projects) ? doc.projects[cwd] : void 0;
64480
64626
  if (isObj2(p) && matching(p.mcpServers, origin).length > 0) return true;
64481
64627
  }
64482
- const proj = read(join42(cwd, ".mcp.json"));
64628
+ const proj = read(join43(cwd, ".mcp.json"));
64483
64629
  return isObj2(proj) && matching(proj.mcpServers, origin).length > 0;
64484
64630
  }
64485
64631
  function sessionChecks(ctx, st, hub) {
@@ -64561,7 +64707,7 @@ var sseCheck = (ctx, name) => ({
64561
64707
 
64562
64708
  // src/commands/habits.ts
64563
64709
  init_src();
64564
- import { join as join43 } from "node:path";
64710
+ import { join as join44 } from "node:path";
64565
64711
  var pluginOn = (p) => `Habits on in the ${p.label} plugin.`;
64566
64712
  var pluginOff = (p) => `Habits off in the ${p.label} plugin.`;
64567
64713
  var deps = (ctx) => ({
@@ -64680,7 +64826,7 @@ async function habitsAfterInstall(ctx, json4) {
64680
64826
  })),
64681
64827
  // A plugin has no block to compare: its marker is there ("current") or not.
64682
64828
  ...plugins2.map((p) => ({
64683
- path: join43(p.dir(ctx.userHome, ctx.env), p.marker),
64829
+ path: join44(p.dir(ctx.userHome, ctx.env), p.marker),
64684
64830
  label: `the ${p.label} plugin`,
64685
64831
  s: {
64686
64832
  state: pluginHabitsState(deps(ctx), p) === "on" ? "current" : "absent"
@@ -64725,7 +64871,7 @@ async function habitsAfterInstall(ctx, json4) {
64725
64871
  const pl = setPluginHabits(
64726
64872
  deps(ctx),
64727
64873
  plugins2.filter(
64728
- (p) => asked.includes(join43(p.dir(ctx.userHome, ctx.env), p.marker))
64874
+ (p) => asked.includes(join44(p.dir(ctx.userHome, ctx.env), p.marker))
64729
64875
  ),
64730
64876
  true
64731
64877
  );
@@ -64786,13 +64932,159 @@ function habitsLine(ctx) {
64786
64932
  return void 0;
64787
64933
  }
64788
64934
 
64935
+ // src/commands/namespace.ts
64936
+ import { realpathSync as realpathSync16, statSync as statSync12 } from "node:fs";
64937
+ import { join as join45, resolve as resolve15 } from "node:path";
64938
+ init_src();
64939
+ function shown3(ctx, path) {
64940
+ const t = tilde(ctx, path);
64941
+ if (t !== path) return t;
64942
+ try {
64943
+ return tilde({ userHome: realpathSync16(ctx.userHome) }, path);
64944
+ } catch {
64945
+ return path;
64946
+ }
64947
+ }
64948
+ function approvalsInstance(ctx, dir) {
64949
+ const r = folderHomeLookup(ctx.home)(resolve15(ctx.cwd, dir));
64950
+ return "instance" in r ? r.instance : void 0;
64951
+ }
64952
+ function approvalsFileFor(ctx, dir) {
64953
+ return namespacesFile(ctx.home, approvalsInstance(ctx, dir) ?? MAIN_INSTANCE);
64954
+ }
64955
+ async function namespace(opts, ctx) {
64956
+ const c = ctx.copy;
64957
+ say(ctx, c.header(ctx.version), "");
64958
+ const target2 = opts.sub === "list" ? "." : opts.dir;
64959
+ const instance = approvalsInstance(ctx, target2);
64960
+ if (instance === void 0) {
64961
+ sayErr(
64962
+ ctx,
64963
+ `Nothing changed: this folder isn't tied to an instance yet. Run ${ctx.busCmd} use here first.`
64964
+ );
64965
+ return 1;
64966
+ }
64967
+ const at = instance === MAIN_INSTANCE ? "" : ` on ${plain2(instance)}`;
64968
+ const file2 = namespacesFile(ctx.home, instance);
64969
+ const { entries, error: error62 } = readApprovals(file2);
64970
+ if (error62) {
64971
+ sayErr(ctx, c.nsUnusable(tilde(ctx, file2), error62));
64972
+ return 1;
64973
+ }
64974
+ if (opts.sub === "list") {
64975
+ say(
64976
+ ctx,
64977
+ entries.length ? c.nsList(entries.map((e) => ({ ...e, dir: shown3(ctx, e.dir) }))) : c.nsNone()
64978
+ );
64979
+ return 0;
64980
+ }
64981
+ const given = resolve15(ctx.cwd, opts.dir);
64982
+ let real3;
64983
+ try {
64984
+ real3 = canonicalPath(given);
64985
+ } catch {
64986
+ }
64987
+ if (opts.sub === "revoke") {
64988
+ const keep = entries.filter(
64989
+ (e) => e.dir !== given && e.dir !== real3 && !(real3 && sameDir(e.dir, real3))
64990
+ );
64991
+ if (keep.length === entries.length) {
64992
+ say(ctx, c.nsNotListed(shown3(ctx, real3 ?? given)));
64993
+ return 0;
64994
+ }
64995
+ writeApprovals(keep, ctx.home, instance);
64996
+ for (const e of entries.filter((x) => !keep.includes(x)))
64997
+ logApproval(
64998
+ { action: "revoke", ...e, tty: Boolean(ctx.stdinIsTTY) },
64999
+ ctx.home
65000
+ );
65001
+ say(ctx, c.nsRevoked(shown3(ctx, real3 ?? given) + at));
65002
+ return 0;
65003
+ }
65004
+ if (!real3 || !statSync12(real3).isDirectory()) {
65005
+ sayErr(ctx, c.nsNotDir(shown3(ctx, real3 ?? given)));
65006
+ return 1;
65007
+ }
65008
+ const cfgFile = join45(real3, CONFIG_FILE);
65009
+ const own2 = readOwnFile(cfgFile, process.getuid?.(), {
65010
+ allowGroupWrite: true
65011
+ });
65012
+ let ns;
65013
+ if (own2.state === "ok") {
65014
+ try {
65015
+ const parsed = BusConfigSchema.safeParse(JSON.parse(own2.text));
65016
+ if (parsed.success) ns = parsed.data.namespace;
65017
+ } catch {
65018
+ }
65019
+ }
65020
+ let remote;
65021
+ if (!ns) {
65022
+ const change = remoteChange(real3, {
65023
+ remotesFile: remotesFile(ctx.home),
65024
+ namespacesFile: file2
65025
+ });
65026
+ if (change) {
65027
+ real3 = change.root;
65028
+ ns = change.namespace;
65029
+ remote = change;
65030
+ }
65031
+ }
65032
+ if (!ns) {
65033
+ if (own2.state === "none") {
65034
+ sayErr(ctx, c.nsNoFile(shown3(ctx, real3)));
65035
+ return 1;
65036
+ }
65037
+ if (own2.state === "unsafe") {
65038
+ sayErr(ctx, c.nsFileUnusable(shown3(ctx, cfgFile), own2.why));
65039
+ return 1;
65040
+ }
65041
+ say(ctx, c.nsNoNamespace(shown3(ctx, cfgFile)));
65042
+ return 1;
65043
+ }
65044
+ if (isApproved(real3, ns, entries)) {
65045
+ say(ctx, c.nsAlready(shown3(ctx, real3), plain2(ns) + at));
65046
+ return 0;
65047
+ }
65048
+ if (!opts.yes) {
65049
+ if (!ctx.stdinIsTTY || !ctx.readLine) {
65050
+ sayErr(ctx, c.nsNeedTty(approveCommand(real3)));
65051
+ return 1;
65052
+ }
65053
+ say(
65054
+ ctx,
65055
+ remote ? c.nsAskRemote(shown3(ctx, real3), plain2(ns), plain2(remote.recorded)) : c.nsAsk(shown3(ctx, real3), plain2(ns) + at)
65056
+ );
65057
+ const answer = (await ctx.readLine(c.nsPrompt())).trim().toLowerCase();
65058
+ if (answer !== "y" && answer !== "yes") {
65059
+ say(ctx, c.nsDeclined());
65060
+ return 1;
65061
+ }
65062
+ }
65063
+ const next = [
65064
+ ...entries.filter((e) => !sameDir(e.dir, real3)),
65065
+ { dir: real3, namespace: ns }
65066
+ ];
65067
+ writeApprovals(next, ctx.home, instance);
65068
+ logApproval(
65069
+ {
65070
+ action: "approve",
65071
+ dir: real3,
65072
+ namespace: ns,
65073
+ tty: Boolean(ctx.stdinIsTTY)
65074
+ },
65075
+ ctx.home
65076
+ );
65077
+ say(ctx, c.nsApproved(shown3(ctx, real3), plain2(ns) + at));
65078
+ return 0;
65079
+ }
65080
+
64789
65081
  // src/commands/status.ts
64790
65082
  init_src2();
64791
65083
  init_src();
64792
65084
 
64793
65085
  // src/commands/install.ts
64794
65086
  init_src3();
64795
- import { dirname as dirname18, join as join45 } from "node:path";
65087
+ import { dirname as dirname19, join as join47 } from "node:path";
64796
65088
  init_src2();
64797
65089
 
64798
65090
  // src/live.ts
@@ -64849,15 +65141,15 @@ import {
64849
65141
  rmdirSync as rmdirSync4,
64850
65142
  rmSync as rmSync23
64851
65143
  } from "node:fs";
64852
- import { join as join44 } from "node:path";
65144
+ import { join as join46 } from "node:path";
64853
65145
  function leftoverTargets(deps2) {
64854
65146
  const env2 = deps2.env ?? {};
64855
65147
  const p = paths(deps2);
64856
- const piDir = agentDirEnv(deps2.home, env2) ?? join44(deps2.home, ".pi/agent");
65148
+ const piDir = agentDirEnv(deps2.home, env2) ?? join46(deps2.home, ".pi/agent");
64857
65149
  const skill2 = (h) => skillDir({ home: deps2.home, env: env2 }, h);
64858
65150
  return {
64859
65151
  files: [
64860
- join44(codexHome2(deps2.home, env2), "AGENTS.md"),
65152
+ join46(codexHome2(deps2.home, env2), "AGENTS.md"),
64861
65153
  p.codex,
64862
65154
  ...p.opencodeConfigs,
64863
65155
  p.opencodeCli
@@ -64866,10 +65158,10 @@ function leftoverTargets(deps2) {
64866
65158
  skill2("claude"),
64867
65159
  skill2("pi"),
64868
65160
  skill2("hermes"),
64869
- join44(hermesHome(deps2.home, env2), "plugins"),
64870
- join44(deps2.home, ".local", "bin"),
64871
- join44(ompAgentDir(deps2.home, env2), "extensions"),
64872
- join44(piDir, "extensions"),
65161
+ join46(hermesHome(deps2.home, env2), "plugins"),
65162
+ join46(deps2.home, ".local", "bin"),
65163
+ join46(ompAgentDir(deps2.home, env2), "extensions"),
65164
+ join46(piDir, "extensions"),
64873
65165
  skill2("opencode"),
64874
65166
  skill2("openclaw")
64875
65167
  ]
@@ -65014,7 +65306,7 @@ async function loginStep(ctx, opts) {
65014
65306
  ctx,
65015
65307
  c.approved(result.label),
65016
65308
  c.tokenSaved(
65017
- tilde(ctx, join45(ctx.home, "machine.json")),
65309
+ tilde(ctx, join47(ctx.home, "machine.json")),
65018
65310
  result.machineToken
65019
65311
  ),
65020
65312
  c.connected(originOf2(result.hub)),
@@ -65143,7 +65435,7 @@ function shownSocket(ctx) {
65143
65435
  const real3 = `${canonicalHome(ctx.home)}/`;
65144
65436
  return tilde(
65145
65437
  ctx,
65146
- path.startsWith(real3) ? join45(ctx.home, path.slice(real3.length)) : path
65438
+ path.startsWith(real3) ? join47(ctx.home, path.slice(real3.length)) : path
65147
65439
  );
65148
65440
  }
65149
65441
  async function waitForDaemon(ctx) {
@@ -65329,7 +65621,7 @@ function reportShim(ctx) {
65329
65621
  if (r.kind === "installed") {
65330
65622
  say(ctx, ctx.copy.shimInstalled(tilde(ctx, r.path)));
65331
65623
  if (!r.onPath && r.hint)
65332
- say(ctx, ctx.copy.shimNotOnPath(tilde(ctx, dirname18(r.path)), r.hint));
65624
+ say(ctx, ctx.copy.shimNotOnPath(tilde(ctx, dirname19(r.path)), r.hint));
65333
65625
  } else if (r.kind === "other-home")
65334
65626
  say(ctx, ctx.copy.shimOtherHome(tilde(ctx, r.path), tilde(ctx, r.home)));
65335
65627
  else if (r.kind === "foreign")
@@ -65395,7 +65687,7 @@ async function installRun(opts, realCtx2) {
65395
65687
  return results.every((r) => r.state === "done") ? 0 : 1;
65396
65688
  }
65397
65689
  const ok = await runSteps(steps, ctx, {
65398
- path: join45(ctx.home, "install.json"),
65690
+ path: join47(ctx.home, "install.json"),
65399
65691
  now: ctx.now
65400
65692
  });
65401
65693
  if (ok && second) say(ctx, "", c.secondBus(ctx.home));
@@ -65666,7 +65958,7 @@ async function doctor(ctx) {
65666
65958
  const node2 = ctx.nodeVersion.replace(/^v/, "");
65667
65959
  if (Number(node2.split(".")[0]) >= MIN_NODE) pass(c.nodeOk(node2));
65668
65960
  else fail3(c.nodeOld(node2));
65669
- const machineFile = tilde(ctx, join46(ctx.home, "machine.json"));
65961
+ const machineFile = tilde(ctx, join48(ctx.home, "machine.json"));
65670
65962
  const m = readMachine(ctx.home);
65671
65963
  if (m.state !== "ok") fail3(c.noCredentials(machineFile));
65672
65964
  else if (m.revoked) fail3(c.revokedCheck());
@@ -65755,8 +66047,8 @@ async function doctor(ctx) {
65755
66047
  pass(c.wired(h, version2));
65756
66048
  else fail3(c.notWired(h));
65757
66049
  if (h === "claude") {
65758
- const settings = join46(
65759
- ctx.env.CLAUDE_CONFIG_DIR ?? join46(ctx.userHome, ".claude"),
66050
+ const settings = join48(
66051
+ ctx.env.CLAUDE_CONFIG_DIR ?? join48(ctx.userHome, ".claude"),
65760
66052
  "settings.json"
65761
66053
  );
65762
66054
  const isolates = claudeIsolates(settings);
@@ -65859,7 +66151,7 @@ async function doctor(ctx) {
65859
66151
  try {
65860
66152
  const ns = resolveNamespace(ctx.cwd, {
65861
66153
  globalFile: allow,
65862
- namespacesFile: namespacesFile(ctx.home),
66154
+ namespacesFile: approvalsFileFor(ctx, "."),
65863
66155
  remotesFile: remotesFile(ctx.home),
65864
66156
  recordRemote: false,
65865
66157
  allowMissing: true
@@ -65870,7 +66162,7 @@ async function doctor(ctx) {
65870
66162
  }
65871
66163
  const files2 = scanConfigFiles(ctx.cwd, {
65872
66164
  globalFile: allow,
65873
- namespacesFile: namespacesFile(ctx.home),
66165
+ namespacesFile: approvalsFileFor(ctx, "."),
65874
66166
  remotesFile: remotesFile(ctx.home)
65875
66167
  }).filter((f) => f.file !== allow);
65876
66168
  if (files2.length > 0) {
@@ -65883,13 +66175,13 @@ async function doctor(ctx) {
65883
66175
  }
65884
66176
 
65885
66177
  // src/commands/global.ts
65886
- import { realpathSync as realpathSync15, statSync as statSync12 } from "node:fs";
65887
- import { resolve as resolve14 } from "node:path";
65888
- function shown3(ctx, path) {
66178
+ import { realpathSync as realpathSync17, statSync as statSync13 } from "node:fs";
66179
+ import { resolve as resolve16 } from "node:path";
66180
+ function shown4(ctx, path) {
65889
66181
  const t = tilde(ctx, path);
65890
66182
  if (t !== path) return t;
65891
66183
  try {
65892
- return tilde({ userHome: realpathSync15(ctx.userHome) }, path);
66184
+ return tilde({ userHome: realpathSync17(ctx.userHome) }, path);
65893
66185
  } catch {
65894
66186
  return path;
65895
66187
  }
@@ -65906,48 +66198,48 @@ async function global(opts, ctx) {
65906
66198
  if (opts.sub === "list") {
65907
66199
  say(
65908
66200
  ctx,
65909
- dirs.length ? c.globalList(dirs.map((d) => shown3(ctx, d))) : c.globalNone()
66201
+ dirs.length ? c.globalList(dirs.map((d) => shown4(ctx, d))) : c.globalNone()
65910
66202
  );
65911
66203
  return 0;
65912
66204
  }
65913
- const given = resolve14(ctx.cwd, opts.dir);
66205
+ const given = resolve16(ctx.cwd, opts.dir);
65914
66206
  let real3;
65915
66207
  try {
65916
66208
  real3 = canonicalPath(given);
65917
66209
  } catch {
65918
66210
  }
65919
66211
  if (opts.sub === "add") {
65920
- if (!real3 || !statSync12(real3).isDirectory()) {
65921
- sayErr(ctx, c.globalNotDir(shown3(ctx, real3 ?? given)));
66212
+ if (!real3 || !statSync13(real3).isDirectory()) {
66213
+ sayErr(ctx, c.globalNotDir(shown4(ctx, real3 ?? given)));
65922
66214
  return 1;
65923
66215
  }
65924
66216
  if (isGlobalDir(real3, dirs)) {
65925
- say(ctx, c.globalAlready(shown3(ctx, real3)));
66217
+ say(ctx, c.globalAlready(shown4(ctx, real3)));
65926
66218
  return 0;
65927
66219
  }
65928
66220
  writeGlobalDirs([...dirs, real3], ctx.home);
65929
- say(ctx, c.globalAdded(shown3(ctx, real3)));
66221
+ say(ctx, c.globalAdded(shown4(ctx, real3)));
65930
66222
  return 0;
65931
66223
  }
65932
66224
  const keep = dirs.filter(
65933
66225
  (d) => d !== given && d !== real3 && !(real3 && sameDir(d, real3))
65934
66226
  );
65935
66227
  if (keep.length === dirs.length) {
65936
- say(ctx, c.globalNotListed(shown3(ctx, real3 ?? given)));
66228
+ say(ctx, c.globalNotListed(shown4(ctx, real3 ?? given)));
65937
66229
  return 0;
65938
66230
  }
65939
66231
  writeGlobalDirs(keep, ctx.home);
65940
- say(ctx, c.globalRemoved(shown3(ctx, real3 ?? given)));
66232
+ say(ctx, c.globalRemoved(shown4(ctx, real3 ?? given)));
65941
66233
  return 0;
65942
66234
  }
65943
66235
 
65944
66236
  // src/commands/leads.ts
65945
66237
  import { readFileSync as readFileSync40 } from "node:fs";
65946
- import { join as join47 } from "node:path";
66238
+ import { join as join49 } from "node:path";
65947
66239
  function hubOrigin2(ctx) {
65948
66240
  try {
65949
66241
  const raw = JSON.parse(
65950
- readFileSync40(join47(ctx.home, "machine.json"), "utf8")
66242
+ readFileSync40(join49(ctx.home, "machine.json"), "utf8")
65951
66243
  );
65952
66244
  return typeof raw?.hub === "string" ? new URL(raw.hub).origin : void 0;
65953
66245
  } catch {
@@ -66005,17 +66297,17 @@ async function leads(opts, ctx) {
66005
66297
  }
66006
66298
 
66007
66299
  // src/commands/link.ts
66008
- import { statSync as statSync13 } from "node:fs";
66009
- import { resolve as resolve15 } from "node:path";
66300
+ import { statSync as statSync14 } from "node:fs";
66301
+ import { resolve as resolve17 } from "node:path";
66010
66302
  init_src();
66011
66303
  function side(ctx, dir) {
66012
- const given = resolve15(ctx.cwd, dir);
66304
+ const given = resolve17(ctx.cwd, dir);
66013
66305
  try {
66014
66306
  const real3 = canonicalPath(given);
66015
- if (!statSync13(real3).isDirectory()) return void 0;
66307
+ if (!statSync14(real3).isDirectory()) return void 0;
66016
66308
  const ns = resolveNamespace(real3, {
66017
66309
  globalFile: globalFile(ctx.home),
66018
- namespacesFile: namespacesFile(ctx.home),
66310
+ namespacesFile: approvalsFileFor(ctx, real3),
66019
66311
  remotesFile: remotesFile(ctx.home),
66020
66312
  recordRemote: false
66021
66313
  });
@@ -66040,7 +66332,7 @@ async function link(opts, ctx) {
66040
66332
  for (const d of opts.dirs) {
66041
66333
  const s = side(ctx, d);
66042
66334
  if (!s) {
66043
- sayErr(ctx, c.linkNotDir(shq(resolve15(ctx.cwd, d))));
66335
+ sayErr(ctx, c.linkNotDir(shq(resolve17(ctx.cwd, d))));
66044
66336
  return 1;
66045
66337
  }
66046
66338
  sides.push(s);
@@ -66108,7 +66400,7 @@ import {
66108
66400
  openSync as openSync11,
66109
66401
  readFileSync as readFileSync41
66110
66402
  } from "node:fs";
66111
- import { dirname as dirname19, join as join48 } from "node:path";
66403
+ import { dirname as dirname20, join as join50 } from "node:path";
66112
66404
  var TAIL = 50;
66113
66405
  var checkDir = (dir) => {
66114
66406
  let fd;
@@ -66142,7 +66434,7 @@ var tail = (path, dir) => {
66142
66434
  constants7.O_RDONLY | constants7.O_NOFOLLOW | constants7.O_NONBLOCK
66143
66435
  );
66144
66436
  if (!fstatSync5(fd).isFile()) return "skipped";
66145
- const after = lstatSync21(dirname19(path));
66437
+ const after = lstatSync21(dirname20(path));
66146
66438
  if (after.isSymbolicLink() || after.dev !== dir.dev || after.ino !== dir.ino)
66147
66439
  return "skipped";
66148
66440
  return readFileSync41(fd, "utf8").replace(/\n$/, "").split("\n").slice(-TAIL);
@@ -66153,9 +66445,9 @@ var tail = (path, dir) => {
66153
66445
  }
66154
66446
  };
66155
66447
  async function logs(ctx) {
66156
- const logDir = join48(ctx.home, "logs");
66157
- const path = join48(logDir, "daemon.log");
66158
- const eventsPath = join48(logDir, "events.log");
66448
+ const logDir = join50(ctx.home, "logs");
66449
+ const path = join50(logDir, "daemon.log");
66450
+ const eventsPath = join50(logDir, "events.log");
66159
66451
  const dir = checkDir(logDir);
66160
66452
  if (!dir.ok && dir.why !== "missing") {
66161
66453
  say(ctx, `Not reading ${tilde(ctx, logDir)}: ${dir.why}.`);
@@ -66195,10 +66487,10 @@ async function mcp(harness, ctx, load2 = (h) => MCP_SERVER[h]()) {
66195
66487
 
66196
66488
  // src/commands/mcp-proof.ts
66197
66489
  init_src3();
66198
- import { execFileSync as execFileSync7 } from "node:child_process";
66490
+ import { execFileSync as execFileSync8 } from "node:child_process";
66199
66491
  import { createHash as createHash12, randomBytes as randomBytes9 } from "node:crypto";
66200
66492
  import { readFileSync as readFileSync42, readlinkSync as readlinkSync7 } from "node:fs";
66201
- import { basename as basename9, join as join49 } from "node:path";
66493
+ import { basename as basename10, join as join51 } from "node:path";
66202
66494
  init_src2();
66203
66495
  init_src();
66204
66496
  var LOG_WAIT_MS = 300;
@@ -66207,7 +66499,7 @@ function parsePs(out) {
66207
66499
  const m = /^(\d+)\s+(.+)$/.exec(out.trim());
66208
66500
  if (!m) return null;
66209
66501
  const comm = m[2];
66210
- return { ppid: Number(m[1]), name: isClaude(comm) ? comm : basename9(comm) };
66502
+ return { ppid: Number(m[1]), name: isClaude(comm) ? comm : basename10(comm) };
66211
66503
  }
66212
66504
  function readProc(pid) {
66213
66505
  try {
@@ -66223,7 +66515,7 @@ function readProc(pid) {
66223
66515
  } catch {
66224
66516
  }
66225
66517
  try {
66226
- const out = execFileSync7(
66518
+ const out = execFileSync8(
66227
66519
  systemTool("ps"),
66228
66520
  ["-o", "ppid=,comm=", "-p", String(pid)],
66229
66521
  { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }
@@ -66280,7 +66572,7 @@ async function mcpProof(opts, ctx, deps2 = {
66280
66572
  say(ctx, JSON.stringify(headers));
66281
66573
  if (why2 !== void 0)
66282
66574
  try {
66283
- const events = createEventLog(join49(ctx.home, "logs", "events.log"));
66575
+ const events = createEventLog(join51(ctx.home, "logs", "events.log"));
66284
66576
  events(UNBOUND_EVENT, { reason: why2 });
66285
66577
  await Promise.race([
66286
66578
  events.flush(),
@@ -66291,135 +66583,6 @@ async function mcpProof(opts, ctx, deps2 = {
66291
66583
  return 0;
66292
66584
  }
66293
66585
 
66294
- // src/commands/namespace.ts
66295
- import { realpathSync as realpathSync16, statSync as statSync14 } from "node:fs";
66296
- import { join as join50, resolve as resolve16 } from "node:path";
66297
- init_src();
66298
- function shown4(ctx, path) {
66299
- const t = tilde(ctx, path);
66300
- if (t !== path) return t;
66301
- try {
66302
- return tilde({ userHome: realpathSync16(ctx.userHome) }, path);
66303
- } catch {
66304
- return path;
66305
- }
66306
- }
66307
- async function namespace(opts, ctx) {
66308
- const c = ctx.copy;
66309
- say(ctx, c.header(ctx.version), "");
66310
- const file2 = namespacesFile(ctx.home);
66311
- const { entries, error: error62 } = readApprovals(file2);
66312
- if (error62) {
66313
- sayErr(ctx, c.nsUnusable(tilde(ctx, file2), error62));
66314
- return 1;
66315
- }
66316
- if (opts.sub === "list") {
66317
- say(
66318
- ctx,
66319
- entries.length ? c.nsList(entries.map((e) => ({ ...e, dir: shown4(ctx, e.dir) }))) : c.nsNone()
66320
- );
66321
- return 0;
66322
- }
66323
- const given = resolve16(ctx.cwd, opts.dir);
66324
- let real3;
66325
- try {
66326
- real3 = canonicalPath(given);
66327
- } catch {
66328
- }
66329
- if (opts.sub === "revoke") {
66330
- const keep = entries.filter(
66331
- (e) => e.dir !== given && e.dir !== real3 && !(real3 && sameDir(e.dir, real3))
66332
- );
66333
- if (keep.length === entries.length) {
66334
- say(ctx, c.nsNotListed(shown4(ctx, real3 ?? given)));
66335
- return 0;
66336
- }
66337
- writeApprovals(keep, ctx.home);
66338
- for (const e of entries.filter((x) => !keep.includes(x)))
66339
- logApproval(
66340
- { action: "revoke", ...e, tty: Boolean(ctx.stdinIsTTY) },
66341
- ctx.home
66342
- );
66343
- say(ctx, c.nsRevoked(shown4(ctx, real3 ?? given)));
66344
- return 0;
66345
- }
66346
- if (!real3 || !statSync14(real3).isDirectory()) {
66347
- sayErr(ctx, c.nsNotDir(shown4(ctx, real3 ?? given)));
66348
- return 1;
66349
- }
66350
- const cfgFile = join50(real3, CONFIG_FILE);
66351
- const own2 = readOwnFile(cfgFile, process.getuid?.(), {
66352
- allowGroupWrite: true
66353
- });
66354
- let ns;
66355
- if (own2.state === "ok") {
66356
- try {
66357
- const parsed = BusConfigSchema.safeParse(JSON.parse(own2.text));
66358
- if (parsed.success) ns = parsed.data.namespace;
66359
- } catch {
66360
- }
66361
- }
66362
- let remote;
66363
- if (!ns) {
66364
- const change = remoteChange(real3, {
66365
- remotesFile: remotesFile(ctx.home),
66366
- namespacesFile: file2
66367
- });
66368
- if (change) {
66369
- real3 = change.root;
66370
- ns = change.namespace;
66371
- remote = change;
66372
- }
66373
- }
66374
- if (!ns) {
66375
- if (own2.state === "none") {
66376
- sayErr(ctx, c.nsNoFile(shown4(ctx, real3)));
66377
- return 1;
66378
- }
66379
- if (own2.state === "unsafe") {
66380
- sayErr(ctx, c.nsFileUnusable(shown4(ctx, cfgFile), own2.why));
66381
- return 1;
66382
- }
66383
- say(ctx, c.nsNoNamespace(shown4(ctx, cfgFile)));
66384
- return 1;
66385
- }
66386
- if (isApproved(real3, ns, entries)) {
66387
- say(ctx, c.nsAlready(shown4(ctx, real3), plain2(ns)));
66388
- return 0;
66389
- }
66390
- if (!opts.yes) {
66391
- if (!ctx.stdinIsTTY || !ctx.readLine) {
66392
- sayErr(ctx, c.nsNeedTty(approveCommand(real3)));
66393
- return 1;
66394
- }
66395
- say(
66396
- ctx,
66397
- remote ? c.nsAskRemote(shown4(ctx, real3), plain2(ns), plain2(remote.recorded)) : c.nsAsk(shown4(ctx, real3), plain2(ns))
66398
- );
66399
- const answer = (await ctx.readLine(c.nsPrompt())).trim().toLowerCase();
66400
- if (answer !== "y" && answer !== "yes") {
66401
- say(ctx, c.nsDeclined());
66402
- return 1;
66403
- }
66404
- }
66405
- const next = [
66406
- ...entries.filter((e) => !sameDir(e.dir, real3)),
66407
- { dir: real3, namespace: ns }
66408
- ];
66409
- writeApprovals(next, ctx.home);
66410
- logApproval(
66411
- {
66412
- action: "approve",
66413
- dir: real3,
66414
- namespace: ns,
66415
- tty: Boolean(ctx.stdinIsTTY)
66416
- },
66417
- ctx.home
66418
- );
66419
- say(ctx, c.nsApproved(shown4(ctx, real3), plain2(ns)));
66420
- return 0;
66421
- }
66422
-
66423
66586
  // src/commands/skill.ts
66424
66587
  var detected = (ctx) => Object.entries(
66425
66588
  checkAdapters({
@@ -66503,12 +66666,12 @@ async function skill(opts, ctx) {
66503
66666
  }
66504
66667
 
66505
66668
  // src/commands/uninstall.ts
66506
- import { join as join52 } from "node:path";
66669
+ import { join as join53 } from "node:path";
66507
66670
 
66508
66671
  // src/steps/purge.ts
66509
66672
  init_src3();
66510
66673
  import { lstatSync as lstatSync22, readdirSync as readdirSync14, rmdirSync as rmdirSync5, rmSync as rmSync24 } from "node:fs";
66511
- import { join as join51 } from "node:path";
66674
+ import { join as join52 } from "node:path";
66512
66675
  var FILES = [
66513
66676
  "machine.json",
66514
66677
  "install.json",
@@ -66578,14 +66741,14 @@ var rmdirIfEmpty = (path) => {
66578
66741
  };
66579
66742
  function purgeShort(dir, removed) {
66580
66743
  if (kind3(dir) !== "dir" || unsafeSocketDir(dir)) return;
66581
- const ret = join51(dir, "claude-return");
66744
+ const ret = join52(dir, "claude-return");
66582
66745
  for (const [d, ours2] of [
66583
66746
  [ret, (_n, p) => kind3(p) === "socket"],
66584
66747
  [dir, (n) => /^daemon\.sock(\.keep-\d+)?$/.test(n)]
66585
66748
  ]) {
66586
66749
  if (kind3(d) !== "dir") continue;
66587
66750
  for (const name of readdirSync14(d)) {
66588
- const path = join51(d, name);
66751
+ const path = join52(d, name);
66589
66752
  const k = kind3(path);
66590
66753
  if (k === void 0 || k === "dir" || !ours2(name, path)) continue;
66591
66754
  remove2(path, k);
@@ -66610,21 +66773,21 @@ function purge(home2, opts) {
66610
66773
  ...FILES,
66611
66774
  ...entries.filter((n) => TEMP.some((re) => re.test(n)))
66612
66775
  ]) {
66613
- const path = join51(home2, name);
66776
+ const path = join52(home2, name);
66614
66777
  const k = kind3(path);
66615
66778
  if (k === void 0 || k === "dir") continue;
66616
66779
  remove2(path, k);
66617
66780
  removed.push(name);
66618
66781
  }
66619
66782
  for (const folder of FOLDERS) {
66620
- const dir = join51(home2, folder.path);
66783
+ const dir = join52(home2, folder.path);
66621
66784
  if (kind3(dir) !== "dir") continue;
66622
66785
  for (const name of readdirSync14(dir)) {
66623
- const path = join51(dir, name);
66786
+ const path = join52(dir, name);
66624
66787
  const k = kind3(path);
66625
66788
  if (k === void 0 || !folder.ours(name, path)) continue;
66626
66789
  remove2(path, k);
66627
- removed.push(join51(folder.path, name));
66790
+ removed.push(join52(folder.path, name));
66628
66791
  }
66629
66792
  if (rmdirIfEmpty(dir)) removed.push(folder.path);
66630
66793
  }
@@ -66715,7 +66878,7 @@ async function unwire(ctx) {
66715
66878
  say(
66716
66879
  ctx,
66717
66880
  c.hermesNoCli(
66718
- tilde(ctx, join52(hermesHome(ctx.userHome, ctx.env), "config.yaml"))
66881
+ tilde(ctx, join53(hermesHome(ctx.userHome, ctx.env), "config.yaml"))
66719
66882
  )
66720
66883
  );
66721
66884
  if (r.openclawNoCli) say(ctx, c.openclawNoCli());
@@ -66749,7 +66912,7 @@ async function uninstall2(opts, ctx) {
66749
66912
  say(ctx, c.daemonStillRunning(removed.running));
66750
66913
  if (wiredTo(ctx)) await unwire(ctx);
66751
66914
  if (!opts.purge) {
66752
- say(ctx, "", c.kept(tilde(ctx, join52(ctx.home, "machine.json"))));
66915
+ say(ctx, "", c.kept(tilde(ctx, join53(ctx.home, "machine.json"))));
66753
66916
  return 0;
66754
66917
  }
66755
66918
  const home2 = tilde(ctx, ctx.home);
@@ -66759,9 +66922,9 @@ async function uninstall2(opts, ctx) {
66759
66922
  return 1;
66760
66923
  } catch {
66761
66924
  }
66762
- const made = readMade(join52(ctx.home, "install.json"));
66925
+ const made = readMade(join53(ctx.home, "install.json"));
66763
66926
  const out = purge(ctx.home, {
66764
- isDefault: ctx.home === join52(ctx.userHome, ".oa-bus")
66927
+ isDefault: ctx.home === join53(ctx.userHome, ".oa-bus")
66765
66928
  });
66766
66929
  if ("refused" in out) {
66767
66930
  sayErr(ctx, c.purgeRefused(home2));
@@ -66843,6 +67006,136 @@ async function installViaDaemon(ctx, version2, waitMs = INSTALL_WAIT_MS) {
66843
67006
  return false;
66844
67007
  }
66845
67008
 
67009
+ // src/commands/use.ts
67010
+ var SHOWN_MAX2 = 120;
67011
+ var clean = showAddress;
67012
+ async function use(opts, ctx) {
67013
+ if (!ctx.stdinIsTTY || !ctx.stdout.isTTY) {
67014
+ sayErr(
67015
+ ctx,
67016
+ "Nothing changed: use needs a real terminal; run it yourself, not from a script or an agent."
67017
+ );
67018
+ return 1;
67019
+ }
67020
+ const list = listInstances(ctx.home);
67021
+ if (list.length === 1 && list[0]?.main) {
67022
+ say(
67023
+ ctx,
67024
+ `Only the main instance is set up on this computer, so every folder uses it. Add another with ${ctx.busCmd} add <address>.`
67025
+ );
67026
+ return 0;
67027
+ }
67028
+ const key2 = folderKey(ctx.cwd);
67029
+ const { folders: f, unusable } = inspectFolders(ctx.home);
67030
+ if (unusable) {
67031
+ sayErr(
67032
+ ctx,
67033
+ `Nothing changed: ${tilde(ctx, foldersFile(ctx.home))} can't be read safely, so it is left as it is. Fix or remove it, then run ${ctx.busCmd} use again.`
67034
+ );
67035
+ return 1;
67036
+ }
67037
+ const covering = coveringEntry(f, key2);
67038
+ const found2 = readSuggestion(
67039
+ ctx.cwd,
67040
+ covering ? { below: covering.dir } : {}
67041
+ );
67042
+ const suggestion = found2 !== void 0 && showAddress(found2).length <= SHOWN_MAX2 ? found2 : void 0;
67043
+ if (found2 !== void 0 && suggestion === void 0)
67044
+ say(
67045
+ ctx,
67046
+ "This repo suggests an address that is too long to show. Ignored."
67047
+ );
67048
+ const answered = covering !== void 0 || f.no[key2] !== void 0;
67049
+ const save2 = (next) => writeFolders(next, ctx.home);
67050
+ if (suggestion !== void 0 && answered && f.seen[key2] !== suggestion) {
67051
+ say(
67052
+ ctx,
67053
+ `This repo now suggests ${showAddress(suggestion)}. Nothing changed: this folder keeps its answer.`
67054
+ );
67055
+ f.seen[key2] = suggestion;
67056
+ save2(f);
67057
+ }
67058
+ const open3 = suggestion !== void 0 && !answered && f.no[key2] !== suggestion ? suggestion : void 0;
67059
+ if (opts.none) {
67060
+ if (open3 === void 0) {
67061
+ say(ctx, "This repo has no suggestion waiting. Nothing changed.");
67062
+ return 0;
67063
+ }
67064
+ f.no[key2] = open3;
67065
+ f.seen[key2] = open3;
67066
+ save2(f);
67067
+ say(ctx, "Noted. This repo's suggestion will not be offered here again.");
67068
+ return 0;
67069
+ }
67070
+ const added = open3 === void 0 ? void 0 : instanceAt(open3, list);
67071
+ if (open3 !== void 0 && !added)
67072
+ say(
67073
+ ctx,
67074
+ `This repo suggests ${showAddress(open3)}, which this computer hasn't added. Run ${ctx.busCmd} add yourself if you trust it.`
67075
+ );
67076
+ const pick2 = (name) => {
67077
+ f.map[key2] = name;
67078
+ if (open3 !== void 0) f.seen[key2] = open3;
67079
+ delete f.no[key2];
67080
+ save2(f);
67081
+ say(ctx, `Done. ${clean(key2)} now uses ${name}.`);
67082
+ return 0;
67083
+ };
67084
+ if (opts.name !== void 0) {
67085
+ if (!list.some((i) => i.name === opts.name)) {
67086
+ sayErr(
67087
+ ctx,
67088
+ `Nothing changed: there is no instance named ${opts.name} on this computer. Run ${ctx.busCmd} use to see them.`
67089
+ );
67090
+ return 1;
67091
+ }
67092
+ const named = list.find((i) => i.name === opts.name);
67093
+ if (named && canonicalAddress(named.hub) === void 0) {
67094
+ sayErr(
67095
+ ctx,
67096
+ `Nothing changed: the address of ${opts.name} can't be read, so it can't connect. Run ${ctx.busCmd} add again.`
67097
+ );
67098
+ return 1;
67099
+ }
67100
+ return pick2(opts.name);
67101
+ }
67102
+ const shown5 = list.map((i) => {
67103
+ const canon = canonicalAddress(i.hub);
67104
+ return canon === void 0 ? "(address unreadable)" : showAddress(canon);
67105
+ });
67106
+ if (shown5.some((s) => s.length > SHOWN_MAX2)) {
67107
+ sayErr(
67108
+ ctx,
67109
+ "Nothing changed: an address is too long to show in full, so it is not offered."
67110
+ );
67111
+ return 1;
67112
+ }
67113
+ say(ctx, `Which instance should ${clean(key2)} use?`, "");
67114
+ list.forEach((i, n) => {
67115
+ const mark = added && i.name === added.name ? " (suggested by this repo)" : "";
67116
+ say(ctx, ` ${n + 1}. ${i.name} ${shown5[n]}${mark}`);
67117
+ });
67118
+ say(ctx, "");
67119
+ const answer = (await (ctx.readLine?.("Number, or Enter to change nothing: ") ?? Promise.resolve(""))).trim();
67120
+ if (answer === "") {
67121
+ say(ctx, "Nothing changed.");
67122
+ return 0;
67123
+ }
67124
+ const chosen = /^\d{1,3}$/.test(answer) ? list[Number(answer) - 1] : void 0;
67125
+ if (!chosen) {
67126
+ sayErr(ctx, "That is not on the list. Nothing changed.");
67127
+ return 1;
67128
+ }
67129
+ if (canonicalAddress(chosen.hub) === void 0) {
67130
+ sayErr(
67131
+ ctx,
67132
+ `Nothing changed: the address of ${chosen.name} can't be read, so it can't connect. Run ${ctx.busCmd} add again.`
67133
+ );
67134
+ return 1;
67135
+ }
67136
+ return pick2(chosen.name);
67137
+ }
67138
+
66846
67139
  // src/index.ts
66847
67140
  init_src();
66848
67141
  import { parseArgs } from "node:util";
@@ -66850,6 +67143,7 @@ var COMMANDS = /* @__PURE__ */ new Set([
66850
67143
  "install",
66851
67144
  "login",
66852
67145
  "add",
67146
+ "use",
66853
67147
  "skill",
66854
67148
  "daemon",
66855
67149
  "mcp",
@@ -66890,6 +67184,7 @@ var FLAGS = {
66890
67184
  ],
66891
67185
  login: ["instance", "no-open"],
66892
67186
  add: ["name", "no-open"],
67187
+ use: ["none"],
66893
67188
  skill: ["instance", "check", "json"],
66894
67189
  daemon: ["instance"],
66895
67190
  uninstall: ["purge"],
@@ -66914,6 +67209,7 @@ function parse7(argv) {
66914
67209
  "token-env": { type: "string" },
66915
67210
  for: { type: "string" },
66916
67211
  "no-open": { type: "boolean", default: false },
67212
+ none: { type: "boolean", default: false },
66917
67213
  yes: { type: "boolean", short: "y", default: false },
66918
67214
  check: { type: "boolean", default: false },
66919
67215
  "no-service": { type: "boolean", default: false },
@@ -66934,11 +67230,13 @@ function parse7(argv) {
66934
67230
  const cmd = head ?? "install";
66935
67231
  if (!COMMANDS.has(cmd)) throw new Error(`unknown command: ${cmd}`);
66936
67232
  const tokenFile = values["token-file"];
66937
- const takes = cmd === "mcp" || cmd === "add" ? 1 : cmd === "global" ? rest[0] === "list" ? 1 : 2 : 0;
67233
+ const takes = cmd === "mcp" || cmd === "add" || cmd === "use" ? 1 : cmd === "global" ? rest[0] === "list" ? 1 : 2 : 0;
66938
67234
  if (cmd === "mcp" && rest.length === 0)
66939
67235
  throw new Error(`usage: ${BUS_CMD} mcp <claude|opencode|codex|pi>`);
66940
67236
  if (cmd === "add" && rest.length === 0)
66941
67237
  throw new Error(`usage: ${BUS_CMD} add <address> [--name <name>]`);
67238
+ if (cmd === "use" && rest[0] !== void 0 && values.none)
67239
+ throw new Error(`usage: ${BUS_CMD} use [name], or ${BUS_CMD} use --none`);
66942
67240
  if (cmd === "global" && rest.length < takes) throw new Error(GLOBAL_USAGE);
66943
67241
  if (cmd === "namespace") {
66944
67242
  const sub = rest[0];
@@ -67012,6 +67310,12 @@ function route(cmd, values, positionals) {
67012
67310
  ...values.name ? { name: values.name } : {},
67013
67311
  noOpen: values["no-open"]
67014
67312
  };
67313
+ case "use":
67314
+ return {
67315
+ cmd,
67316
+ ...positionals[0] ? { name: positionals[0] } : {},
67317
+ none: values.none
67318
+ };
67015
67319
  case "skill":
67016
67320
  return {
67017
67321
  cmd,
@@ -67098,6 +67402,7 @@ function habitsMode(v) {
67098
67402
  var TERMINAL = /* @__PURE__ */ new Set([
67099
67403
  "login",
67100
67404
  "add",
67405
+ "use",
67101
67406
  "skill",
67102
67407
  "status",
67103
67408
  "logs",
@@ -67121,7 +67426,7 @@ async function main(argv, makeCtx = realCtx) {
67121
67426
  return 2;
67122
67427
  }
67123
67428
  const ctx = makeCtx(cmd.noColor);
67124
- if (cmd.home) ctx.home = resolve17(cmd.home);
67429
+ if (cmd.home) ctx.home = resolve18(cmd.home);
67125
67430
  if (!TERMINAL.has(cmd.cmd) && cmd.cmd !== "install" && cmd.cmd !== "uninstall")
67126
67431
  markLive(fileURLToPath7(import.meta.url), ctx.home);
67127
67432
  ctx.copy = copyFor(ctx);
@@ -67166,6 +67471,8 @@ async function dispatch(cmd, ctx) {
67166
67471
  }
67167
67472
  case "add":
67168
67473
  return add(cmd, ctx);
67474
+ case "use":
67475
+ return use(cmd, ctx);
67169
67476
  case "skill":
67170
67477
  return skill(cmd, ctx);
67171
67478
  case "daemon":