@open-artifacts/bus 0.222.0 → 0.224.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/assets/oa-bus.ts CHANGED
@@ -11,7 +11,7 @@ import { StringDecoder } from "node:string_decoder";
11
11
  type Json = Record<string, unknown>;
12
12
 
13
13
  /** The IPC marker (CONTRACT.md): the package version, stamped by the CLI's bundler. */
14
- const CLIENT_VERSION = "0.222.0";
14
+ const CLIENT_VERSION = "0.224.0";
15
15
 
16
16
  type Frame = Json & { type: string; id: string };
17
17
  type Ctx = {
@@ -27846,7 +27846,7 @@ var base2 = { v: external_exports.literal(V), id: external_exports.string().min(
27846
27846
  var late = { late: external_exports.array(external_exports.string().min(1)).optional() };
27847
27847
  var isWellFormed2 = (s) => s.isWellFormed();
27848
27848
  var WELL_FORMED = { message: "text is not well-formed unicode" };
27849
- var CLIENT_VERSION = true ? "0.222.0" : "0.0.0";
27849
+ var CLIENT_VERSION = true ? "0.224.0" : "0.0.0";
27850
27850
  var clientVersion = {
27851
27851
  client_version: external_exports.string().min(1).max(64).optional()
27852
27852
  };
@@ -28246,6 +28246,18 @@ var StatusReply = external_exports.object({
28246
28246
  ),
28247
28247
  /** Config files refused or noted (#1527). Absent from older daemons, and when there are none. */
28248
28248
  config_files: external_exports.array(ConfigFile).optional(),
28249
+ /**
28250
+ * #2793: one row per instance link, only while the daemon runs more than
28251
+ * one. `agents` counts the live sessions registered on that hub.
28252
+ */
28253
+ instances: external_exports.array(
28254
+ external_exports.object({
28255
+ name: external_exports.string().max(64),
28256
+ link: external_exports.enum(["connected", "not_connected"]),
28257
+ revoked: external_exports.boolean(),
28258
+ agents: external_exports.number().int().min(0)
28259
+ })
28260
+ ).max(64).optional(),
28249
28261
  /**
28250
28262
  * #2688: each live Claude session and whether its `mcp-proof` helper linked it.
28251
28263
  * Names, folders and cause codes only; never a proof, a hash or a header.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oa-bus",
3
- "version": "0.222.0",
3
+ "version": "0.224.0",
4
4
  "type": "module",
5
5
  "openclaw": {
6
6
  "extensions": [
package/dist/index.js CHANGED
@@ -32866,7 +32866,7 @@ var init_frames = __esm({
32866
32866
  late = { late: external_exports.array(external_exports.string().min(1)).optional() };
32867
32867
  isWellFormed2 = (s) => s.isWellFormed();
32868
32868
  WELL_FORMED = { message: "text is not well-formed unicode" };
32869
- CLIENT_VERSION = true ? "0.222.0" : "0.0.0";
32869
+ CLIENT_VERSION = true ? "0.224.0" : "0.0.0";
32870
32870
  clientVersion = {
32871
32871
  client_version: external_exports.string().min(1).max(64).optional()
32872
32872
  };
@@ -33271,6 +33271,18 @@ var init_frames = __esm({
33271
33271
  ),
33272
33272
  /** Config files refused or noted (#1527). Absent from older daemons, and when there are none. */
33273
33273
  config_files: external_exports.array(ConfigFile).optional(),
33274
+ /**
33275
+ * #2793: one row per instance link, only while the daemon runs more than
33276
+ * one. `agents` counts the live sessions registered on that hub.
33277
+ */
33278
+ instances: external_exports.array(
33279
+ external_exports.object({
33280
+ name: external_exports.string().max(64),
33281
+ link: external_exports.enum(["connected", "not_connected"]),
33282
+ revoked: external_exports.boolean(),
33283
+ agents: external_exports.number().int().min(0)
33284
+ })
33285
+ ).max(64).optional(),
33274
33286
  /**
33275
33287
  * #2688: each live Claude session and whether its `mcp-proof` helper linked it.
33276
33288
  * Names, folders and cause codes only; never a proof, a hash or a header.
@@ -38137,8 +38149,8 @@ var require_websocket = __commonJS({
38137
38149
  websocket.emit("upgrade", res);
38138
38150
  if (websocket.readyState !== WebSocket2.CONNECTING) return;
38139
38151
  req = websocket._req = null;
38140
- const upgrade = res.headers.upgrade;
38141
- if (upgrade === void 0 || upgrade.toLowerCase() !== "websocket") {
38152
+ const upgrade2 = res.headers.upgrade;
38153
+ if (upgrade2 === void 0 || upgrade2.toLowerCase() !== "websocket") {
38142
38154
  abortHandshake(websocket, socket, "Invalid Upgrade header");
38143
38155
  return;
38144
38156
  }
@@ -38711,14 +38723,14 @@ var require_websocket_server = __commonJS({
38711
38723
  handleUpgrade(req, socket, head, cb) {
38712
38724
  socket.on("error", socketOnError);
38713
38725
  const key2 = req.headers["sec-websocket-key"];
38714
- const upgrade = req.headers.upgrade;
38726
+ const upgrade2 = req.headers.upgrade;
38715
38727
  const version2 = +req.headers["sec-websocket-version"];
38716
38728
  if (req.method !== "GET") {
38717
38729
  const message = "Invalid HTTP method";
38718
38730
  abortHandshakeOrEmitwsClientError(this, req, socket, 405, message);
38719
38731
  return;
38720
38732
  }
38721
- if (upgrade === void 0 || upgrade.toLowerCase() !== "websocket") {
38733
+ if (upgrade2 === void 0 || upgrade2.toLowerCase() !== "websocket") {
38722
38734
  const message = "Invalid Upgrade header";
38723
38735
  abortHandshakeOrEmitwsClientError(this, req, socket, 400, message);
38724
38736
  return;
@@ -44222,7 +44234,7 @@ var init_stdio2 = __esm({
44222
44234
 
44223
44235
  // ../bus-adapter-claude-code/src/main.ts
44224
44236
  var main_exports = {};
44225
- import { existsSync as existsSync17 } from "node:fs";
44237
+ import { existsSync as existsSync18 } from "node:fs";
44226
44238
  var SESSIONS, connect4, server, underClaude;
44227
44239
  var init_main = __esm({
44228
44240
  async "../bus-adapter-claude-code/src/main.ts"() {
@@ -44247,7 +44259,7 @@ var init_main = __esm({
44247
44259
  }),
44248
44260
  // A short socket folder another user could reach is never dialed.
44249
44261
  socketDirProblem: () => socketDirProblem(HOME3),
44250
- socketExists: () => existsSync17(SOCKET3),
44262
+ socketExists: () => existsSync18(SOCKET3),
44251
44263
  connect: (session) => connectDaemon({
44252
44264
  path: SOCKET3,
44253
44265
  hello: sessionHello(session, process.pid, process.cwd())
@@ -48184,6 +48196,16 @@ function folderHomeLookup(h = home()) {
48184
48196
  return { unmapped: true };
48185
48197
  };
48186
48198
  }
48199
+ var SEEN_MAX = 1e3;
48200
+ var noted = /* @__PURE__ */ new Set();
48201
+ function unmappedFolderNote(cwd, h = home(), known) {
48202
+ if (!("unmapped" in folderHomeLookup(h)(cwd))) return void 0;
48203
+ const key2 = `${h}\0${known ?? folderKey(cwd)}`;
48204
+ if (noted.has(key2)) return void 0;
48205
+ if (noted.size >= SEEN_MAX) noted.clear();
48206
+ noted.add(key2);
48207
+ return `This folder isn't tied to an instance yet. Run ${BUS_CMD} use in this folder.`;
48208
+ }
48187
48209
  function readSuggestion(cwd, opts = {}) {
48188
48210
  let dir;
48189
48211
  try {
@@ -48213,6 +48235,24 @@ function readSuggestion(cwd, opts = {}) {
48213
48235
  function instanceAt(address, list) {
48214
48236
  return list.find((i) => canonicalAddress(i.hub) === address);
48215
48237
  }
48238
+ var suggested = /* @__PURE__ */ new Set();
48239
+ var ADDRESS_SHOWN_MAX = 120;
48240
+ function changedSuggestionNote(cwd, h = home(), known) {
48241
+ const { folders: f, unusable } = inspectFolders(h);
48242
+ if (unusable) return void 0;
48243
+ const key2 = known ?? folderKey(cwd);
48244
+ const covering = coveringEntry(f, key2);
48245
+ if (covering === void 0 && f.no[key2] === void 0) return void 0;
48246
+ const found2 = readSuggestion(cwd, covering ? { below: covering.dir } : {});
48247
+ if (found2 === void 0 || found2 === f.seen[key2]) return void 0;
48248
+ const shown5 = found2.replace(/[\u0000-\u001f\u007f-\u009f\u2028\u2029]/g, "");
48249
+ if (shown5 !== found2 || shown5.length > ADDRESS_SHOWN_MAX) return void 0;
48250
+ const once2 = `${h}\0${key2}\0${found2}`;
48251
+ if (suggested.has(once2)) return void 0;
48252
+ if (suggested.size >= SEEN_MAX) suggested.clear();
48253
+ suggested.add(once2);
48254
+ return `This repo now suggests ${shown5}. Nothing changed: this folder keeps its answer.`;
48255
+ }
48216
48256
 
48217
48257
  // ../bus-daemon/src/hub.ts
48218
48258
  init_src();
@@ -48794,9 +48834,9 @@ var Lane = class {
48794
48834
  return this.name === MAIN_INSTANCE;
48795
48835
  }
48796
48836
  /** What a hello_ok says this hub supports. */
48797
- applyHello(caps, serverVersion) {
48837
+ applyHello(caps, serverVersion2) {
48798
48838
  const has = (c) => caps?.includes(c) ?? false;
48799
- this.version = serverVersion;
48839
+ this.version = serverVersion2;
48800
48840
  this.ids = has(BUS_CAPS.ids);
48801
48841
  this.mailbox = has(BUS_CAPS.mailbox);
48802
48842
  this.nameChosen = has(BUS_CAPS.nameChosen);
@@ -51534,7 +51574,7 @@ function rateLimited(s, now) {
51534
51574
  return Math.max(now, s.lastAt) - s.lastAt < SIX_HOURS_MS;
51535
51575
  }
51536
51576
  function accept(s, i, now, o = {}) {
51537
- const serverVersion = o.server;
51577
+ const serverVersion2 = o.server;
51538
51578
  if (parseVersion(i.version) === void 0) return no("bad_version");
51539
51579
  if (s.unreadable) return no("unreadable");
51540
51580
  if (!s.armed) return no("not_armed");
@@ -51549,7 +51589,7 @@ function accept(s, i, now, o = {}) {
51549
51589
  if (base3 !== void 0 && compareVersions2(i.version, base3) !== 1)
51550
51590
  return no("not_forward");
51551
51591
  }
51552
- if (serverVersion !== void 0 && parseVersion(serverVersion) !== void 0 && compareVersions2(i.version, serverVersion) === 1)
51592
+ if (serverVersion2 !== void 0 && parseVersion(serverVersion2) !== void 0 && compareVersions2(i.version, serverVersion2) === 1)
51553
51593
  return no("ahead_of_server");
51554
51594
  if (!isStepBack && rateLimited(s, now)) return no("rate_limited");
51555
51595
  return yes;
@@ -53632,8 +53672,7 @@ async function runDaemon(deps2 = {}) {
53632
53672
  for (const l of lanes.all()) any2 = l.hub.cancel(id) || any2;
53633
53673
  return any2;
53634
53674
  };
53635
- const onlyMain = instHome === void 0 || listInstances(instHome).every((i) => i.main);
53636
- const lookup = deps2.homeLookup ?? (instHome !== void 0 ? folderHomeLookup(instHome) : () => onlyMain ? { instance: MAIN_INSTANCE } : { unmapped: true });
53675
+ const lookup = deps2.homeLookup ?? (instHome === void 0 ? () => ({ instance: MAIN_INSTANCE }) : folderHomeLookup(instHome));
53637
53676
  const unmappedNoted = /* @__PURE__ */ new Set();
53638
53677
  const homeInstance = (cwd) => {
53639
53678
  const r = lookup(cwd);
@@ -53760,6 +53799,44 @@ async function runDaemon(deps2 = {}) {
53760
53799
  caps.delete(ref);
53761
53800
  };
53762
53801
  const configIssues = new ConfigIssues();
53802
+ const folderNotes = /* @__PURE__ */ new Map();
53803
+ const keyCache = new BoundedMap(1e3);
53804
+ const keyOf2 = (cwd) => {
53805
+ let k = keyCache.get(cwd);
53806
+ if (k === void 0) {
53807
+ k = folderKey(cwd);
53808
+ keyCache.set(cwd, k);
53809
+ }
53810
+ return k;
53811
+ };
53812
+ const noteFolder = (cwd) => {
53813
+ if (instHome === void 0 || deps2.homeLookup) return;
53814
+ if (listInstances(instHome).length < 2) return;
53815
+ const key2 = keyOf2(cwd);
53816
+ const unmapped = unmappedFolderNote(cwd, instHome, key2);
53817
+ const changed = unmapped ? void 0 : changedSuggestionNote(cwd, instHome, key2);
53818
+ const text3 = unmapped ?? changed;
53819
+ if (text3 !== void 0 && (folderNotes.size < 1e3 || folderNotes.has(key2)))
53820
+ folderNotes.set(key2, {
53821
+ file: key2,
53822
+ state: "noted",
53823
+ reason: text3,
53824
+ fix: unmapped ? `${BUS_CMD} use` : `optional: run ${BUS_CMD} use`
53825
+ });
53826
+ };
53827
+ const notesFor = (cwd) => {
53828
+ if (folderNotes.size === 0) return [];
53829
+ const key2 = keyOf2(cwd);
53830
+ const n = folderNotes.get(key2);
53831
+ if (!n) return [];
53832
+ if (n.fix === `${BUS_CMD} use`) {
53833
+ if ("unmapped" in lookup(cwd)) return [n];
53834
+ folderNotes.delete(key2);
53835
+ return [];
53836
+ }
53837
+ folderNotes.delete(key2);
53838
+ return [n];
53839
+ };
53763
53840
  const configFiles = (cwd, pending2 = false) => {
53764
53841
  const g = inspectGlobal();
53765
53842
  const a = inspectApprovals();
@@ -53775,18 +53852,29 @@ async function runDaemon(deps2 = {}) {
53775
53852
  if (rr) within2.add(join25(rr, ".git"));
53776
53853
  }
53777
53854
  return [
53855
+ ...cwd !== void 0 ? notesFor(cwd) : [],
53778
53856
  ...configIssues.list(within2, { pending: pending2 }),
53779
53857
  ...a ? [a] : [],
53780
53858
  ...rm ? [rm] : [],
53781
53859
  ...g ? [g] : []
53782
53860
  ];
53783
53861
  };
53784
- const resolveNs = (cwd, allowMissing) => (deps2.resolveNamespace ?? ((dir) => resolveNamespace(dir, {
53785
- log,
53786
- allowMissing,
53787
- issues: configIssues,
53788
- remotesFile: remotesFile()
53789
- })))(cwd);
53862
+ const resolveNs = (cwd, allowMissing, on) => {
53863
+ let name;
53864
+ if (on !== void 0) name = on.instance;
53865
+ else {
53866
+ const r = lookup(cwd);
53867
+ name = "instance" in r ? r.instance : void 0;
53868
+ }
53869
+ const approvals = instHome !== void 0 && name !== void 0 && name !== MAIN_INSTANCE ? namespacesFile(instHome, name) : void 0;
53870
+ return (deps2.resolveNamespace ?? ((dir) => resolveNamespace(dir, {
53871
+ log,
53872
+ allowMissing,
53873
+ issues: configIssues,
53874
+ remotesFile: remotesFile(),
53875
+ ...approvals !== void 0 ? { namespacesFile: approvals } : {}
53876
+ })))(cwd);
53877
+ };
53790
53878
  const cl = deps2.claude ?? {};
53791
53879
  const listenPath = deps2.socketPath ?? socketPath();
53792
53880
  const returnDir = cl.socketsDir ?? claudeReturnDir2();
@@ -54316,14 +54404,15 @@ async function runDaemon(deps2 = {}) {
54316
54404
  reopenedAt.set(s.ref, Date.now());
54317
54405
  }
54318
54406
  if (!isAbsolute8(s.cwd)) continue;
54407
+ const instance = prev && prev.pid === s.pid && prev.procStart === s.procStart ? prev.instance ?? homeInstance(s.cwd) : homeInstance(s.cwd);
54319
54408
  let ns;
54320
54409
  try {
54321
- ns = resolveNs(s.cwd, true);
54410
+ ns = resolveNs(s.cwd, true, { instance });
54322
54411
  } catch {
54323
54412
  continue;
54324
54413
  }
54325
54414
  if (!WireNamespaceSchema.safeParse(ns.namespace).success) continue;
54326
- const instance = homeInstance(s.cwd);
54415
+ noteFolder(s.cwd);
54327
54416
  seenAt.set(s.ref, ++seenSeq);
54328
54417
  const old = prev ? void 0 : clearedFrom(s.ref, s.pid, s.procStart, liveRefs);
54329
54418
  if (old) takenOver.add(old.ref);
@@ -54970,6 +55059,14 @@ async function runDaemon(deps2 = {}) {
54970
55059
  version: version2,
54971
55060
  label: cfg.label,
54972
55061
  ...config_files.length > 0 ? { config_files } : {},
55062
+ ...lanes.multi ? {
55063
+ instances: lanes.all().map((l) => ({
55064
+ name: l.name,
55065
+ link: l.hub.open ? "connected" : "not_connected",
55066
+ revoked: l.revoked,
55067
+ agents: live.filter((a) => a.instance === l.name).length
55068
+ }))
55069
+ } : {},
54973
55070
  hub: hub.open ? "connected" : "connecting",
54974
55071
  ...hub.open || !hub.lastError ? {} : { hub_error: hub.lastError },
54975
55072
  hub_ever: main2.ever,
@@ -55099,9 +55196,10 @@ async function runDaemon(deps2 = {}) {
55099
55196
  }
55100
55197
  const cwd = check2.cwd ?? hello.cwd;
55101
55198
  if (!cwd || !isAbsolute8(cwd)) return { error: "cwd must be absolute" };
55199
+ const instance = homeInstance(cwd);
55102
55200
  let ns;
55103
55201
  try {
55104
- ns = resolveNs(cwd, check2.cwd !== void 0);
55202
+ ns = resolveNs(cwd, check2.cwd !== void 0, { instance });
55105
55203
  } catch {
55106
55204
  return { error: `cwd does not resolve: ${cwd}` };
55107
55205
  }
@@ -55110,7 +55208,7 @@ async function runDaemon(deps2 = {}) {
55110
55208
  error: `namespace is not valid on the wire: ${ns.namespace}`
55111
55209
  };
55112
55210
  attested(pid);
55113
- const instance = homeInstance(cwd);
55211
+ noteFolder(cwd);
55114
55212
  const codexName = hello.kind === "codex" ? codexThreadNames(codexIndexHome).get(hello.agent_ref) : void 0;
55115
55213
  const proposedName = codexName ?? hello.proposed_name ?? hello.agent_ref;
55116
55214
  const files2 = hello.kind === "claude-code" ? liveClaudeSessions(
@@ -55396,9 +55494,10 @@ async function runDaemon(deps2 = {}) {
55396
55494
  continue;
55397
55495
  }
55398
55496
  const proven = res;
55497
+ const instance = homeInstance(proven.cwd);
55399
55498
  let ns;
55400
55499
  try {
55401
- ns = resolveNs(proven.cwd, true);
55500
+ ns = resolveNs(proven.cwd, true, { instance });
55402
55501
  } catch {
55403
55502
  drop("no_namespace");
55404
55503
  continue;
@@ -55407,7 +55506,7 @@ async function runDaemon(deps2 = {}) {
55407
55506
  drop("no_namespace");
55408
55507
  continue;
55409
55508
  }
55410
- const instance = homeInstance(proven.cwd);
55509
+ noteFolder(proven.cwd);
55411
55510
  agents.up({
55412
55511
  ref: r.ref,
55413
55512
  kind: "codex",
@@ -55822,6 +55921,8 @@ async function runDaemon(deps2 = {}) {
55822
55921
 
55823
55922
  // src/bus-cmd.ts
55824
55923
  init_src();
55924
+ import { existsSync as existsSync16 } from "node:fs";
55925
+ import { join as join37 } from "node:path";
55825
55926
 
55826
55927
  // src/context.ts
55827
55928
  init_src3();
@@ -56338,6 +56439,7 @@ function copy(style, bus = BUS_CMD, approve) {
56338
56439
  " link <dir> <dir> or list; unlink <dir> <dir>",
56339
56440
  " leads check [name]",
56340
56441
  " auto-update off, on or status: whether the bus keeps itself up to date",
56442
+ " upgrade [x.y.z] Install a newer bus, after checking its release proof",
56341
56443
  " update Install the update that is waiting",
56342
56444
  " mcp <claude|opencode|codex|pi>: the MCP server a harness runs",
56343
56445
  " version Print the version",
@@ -56349,8 +56451,9 @@ function copy(style, bus = BUS_CMD, approve) {
56349
56451
  " --habits | --no-habits | --show-habits",
56350
56452
  " add, decline or show the always-on habit lines",
56351
56453
  " --no-service skip the launchd or systemd step",
56352
- " --alongside with --home <dir>: set up this bus next to your main one,",
56353
- " and leave every harness setting alone",
56454
+ " --alongside with --home <dir>: set up a separate bus next to your main one,",
56455
+ " and leave every harness setting alone. To use a second",
56456
+ " instance with your main bus, run add <address>, then use in a folder",
56354
56457
  " --no-open do not open a browser for approval",
56355
56458
  " --json the result as one JSON line on stdout",
56356
56459
  " --yes, -y answer yes where install asks",
@@ -56659,7 +56762,7 @@ function copy(style, bus = BUS_CMD, approve) {
56659
56762
  shimForeign: (where2) => [
56660
56763
  warn(`Left ${clip(where2, 30)} alone: it isn't from Open Artifacts.`),
56661
56764
  next(
56662
- `Typing \`oa-bus\` runs that file, not this install. Remove it, or use \`${BUS_CMD}\`.`
56765
+ `Typing \`oa-bus\` runs that file, not this install. Remove it, or use \`${bus}\`.`
56663
56766
  )
56664
56767
  ],
56665
56768
  shimOtherHome: (where2, home2) => [
@@ -56667,7 +56770,7 @@ function copy(style, bus = BUS_CMD, approve) {
56667
56770
  `Left ${clip(where2, 30)} alone: it belongs to the install in ${clip(home2, 30)}.`
56668
56771
  ),
56669
56772
  next(
56670
- `Typing \`oa-bus\` runs that install, not this one. Use \`${BUS_CMD}\` for this one.`
56773
+ `Typing \`oa-bus\` runs that install, not this one. Use \`${bus}\` for this one.`
56671
56774
  )
56672
56775
  ],
56673
56776
  shimRemoved: (where2) => done(`Removed the oa-bus command: ${clip(where2, 30)}`),
@@ -56679,12 +56782,12 @@ function copy(style, bus = BUS_CMD, approve) {
56679
56782
  shimDoctorOther: (where2) => [
56680
56783
  warn(`oa-bus on your PATH is not this install's (${clip(where2, 30)})`),
56681
56784
  next(
56682
- `Remove it, or put this install's first. Re-run ${BUS_CMD} install to refresh ours.`
56785
+ `Remove it, or put this install's first. Re-run ${bus} install to refresh ours.`
56683
56786
  )
56684
56787
  ],
56685
56788
  shimDoctorMissing: () => [
56686
56789
  warn("oa-bus is not on your PATH"),
56687
- next(`Run ${BUS_CMD} install to add it.`)
56790
+ next(`Run ${bus} install to add it.`)
56688
56791
  ],
56689
56792
  codexSkill: (where2) => done(`Codex skill installed in ${clip(where2, 20)}`),
56690
56793
  codexSkillTwice: (file2, block) => [
@@ -56829,6 +56932,20 @@ function copy(style, bus = BUS_CMD, approve) {
56829
56932
  updatePrompt: (v) => `Install ${v} now? The bus restarts for a few seconds. Type yes to continue: `,
56830
56933
  updateDeclined: () => "Nothing was installed.",
56831
56934
  updateDone: (v) => `Installed ${v}.`,
56935
+ // `upgrade` (#2543): a hand upgrade through the installed bus. New strings, for Product.
56936
+ upgradeUsage: () => `usage: ${bus} upgrade [x.y.z] [--allow-failed]`,
56937
+ upgradeFailedVersion: (v) => `${v} failed on this machine before. To try it anyway, run ${bus} upgrade ${v} --allow-failed.`,
56938
+ upgradeStaleStage: (v) => `The unpacked ${v} went missing before it could install. Nothing was installed; run ${bus} upgrade again.`,
56939
+ upgradeNotInstalled: () => `There is no bus on this machine to upgrade. Run the "Install the bus" step of your instance's llms.txt.`,
56940
+ upgradeNoServerVersion: () => "Couldn't read the instance's version, so the bus can't tell which release to install. Try again when the instance is reachable.",
56941
+ upgradePreRelease: (server4) => `This instance runs a pre-release (${server4}). Name the release: ${bus} upgrade x.y.z`,
56942
+ upgradeAhead: (v, server4) => `${v} is newer than the instance (${server4}), so it won't be installed.`,
56943
+ upgradeCurrent: (v) => `The bus is already at ${v}.`,
56944
+ upgradeNotForward: (v, running) => `${v} is older than this bus (${running}), so it won't be installed.`,
56945
+ upgradeChecking: (v) => `Checking the bus ${v} against its release proof...`,
56946
+ upgradeRefused: (v, code2) => `The bus ${v} did not pass its release proof (${code2}), so nothing was installed.`,
56947
+ upgradeInstalling: (v) => `The proof passed. Installing ${v}...`,
56948
+ upgradeInstallFailed: (v, code2) => `The installer for ${v} stopped with exit code ${code2}.`,
56832
56949
  // New in PR 4, not in the issue's copy: for Product.
56833
56950
  updateBusy: () => "A login or an approval is in progress. Try again when it is done.",
56834
56951
  updateNotInstalled: (v) => `${v} was not installed. Run ${bus} status to see why.`,
@@ -57057,7 +57174,6 @@ import {
57057
57174
  resolve as resolve6
57058
57175
  } from "node:path";
57059
57176
  import { fileURLToPath } from "node:url";
57060
- init_src();
57061
57177
 
57062
57178
  // src/steps/codex.ts
57063
57179
  import { lstatSync as lstatSync11, readFileSync as readFileSync19 } from "node:fs";
@@ -58426,7 +58542,7 @@ if [ "$noglob" = 0 ]; then set +f; fi
58426
58542
  for d in ${usual.join(" ")}; do
58427
58543
  if ok "$d/node"; then exec "$d/node" "$@"; fi
58428
58544
  done
58429
- echo "oa-bus: Node.js ${MIN_NODE} or newer not found. Install it, then run: ${BUS_CMD} install" >&2
58545
+ echo "oa-bus: Node.js ${MIN_NODE} or newer not found. Install it, then run: $here/node $here/dist/index.js install" >&2
58430
58546
  exit 127
58431
58547
  `;
58432
58548
  }
@@ -58822,7 +58938,7 @@ var noService = {
58822
58938
  remove: async () => ({}),
58823
58939
  cli: () => ["oa-bus"]
58824
58940
  };
58825
- var VERSION = true ? "0.222.0" : JSON.parse(
58941
+ var VERSION = true ? "0.224.0" : JSON.parse(
58826
58942
  readFileSync22(new URL("../package.json", import.meta.url), "utf8")
58827
58943
  ).version;
58828
58944
  var which = (cmd) => {
@@ -63812,10 +63928,17 @@ function shimState(o) {
63812
63928
  // src/bus-cmd.ts
63813
63929
  function busCmd(o) {
63814
63930
  try {
63815
- return shimState(o)?.kind === "ours" ? "oa-bus" : BUS_CMD;
63931
+ if (shimState(o)?.kind === "ours") return "oa-bus";
63816
63932
  } catch {
63817
- return BUS_CMD;
63818
63933
  }
63934
+ return installedForm(o.busHome) ?? BUS_CMD;
63935
+ }
63936
+ function installedForm(home2) {
63937
+ const node2 = join37(home2, "bin", "node");
63938
+ const entry = join37(home2, "bin", "dist", "index.js");
63939
+ if (!existsSync16(node2) || !existsSync16(entry)) return void 0;
63940
+ const q = (p) => /[\s"'$`\\]/.test(p) ? JSON.stringify(p) : p;
63941
+ return `${q(node2)} ${q(entry)}`;
63819
63942
  }
63820
63943
  function wiredTo(ctx) {
63821
63944
  if (isDefaultHome2(ctx.home, ctx.userHome)) return true;
@@ -63868,7 +63991,7 @@ import {
63868
63991
  unlinkSync as unlinkSync5,
63869
63992
  writeSync as writeSync5
63870
63993
  } from "node:fs";
63871
- import { join as join37 } from "node:path";
63994
+ import { join as join38 } from "node:path";
63872
63995
  init_src();
63873
63996
 
63874
63997
  // src/machine-label.ts
@@ -63919,7 +64042,7 @@ function checkVerificationUri(uri, hub) {
63919
64042
  function writeMachineFile(home2, body) {
63920
64043
  mkdirSync17(home2, { recursive: true, mode: 448 });
63921
64044
  chmodSync22(home2, 448);
63922
- const tmp = join37(home2, `.machine.json.${randomBytes8(8).toString("hex")}.tmp`);
64045
+ const tmp = join38(home2, `.machine.json.${randomBytes8(8).toString("hex")}.tmp`);
63923
64046
  const fd = openSync10(tmp, "wx", 384);
63924
64047
  try {
63925
64048
  writeSync5(fd, body);
@@ -63931,7 +64054,7 @@ function writeMachineFile(home2, body) {
63931
64054
  closeSync10(fd);
63932
64055
  try {
63933
64056
  chmodSync22(tmp, 384);
63934
- renameSync21(tmp, join37(home2, "machine.json"));
64057
+ renameSync21(tmp, join38(home2, "machine.json"));
63935
64058
  } catch (e) {
63936
64059
  unlinkSync5(tmp);
63937
64060
  throw e;
@@ -64081,7 +64204,7 @@ async function loginInner(args) {
64081
64204
  `${JSON.stringify({ hub, label: label2, machine_token: poll.machine_token }, null, 2)}
64082
64205
  `
64083
64206
  );
64084
- rmSync21(join37(args.home, "revoked"), { force: true });
64207
+ rmSync21(join38(args.home, "revoked"), { force: true });
64085
64208
  }
64086
64209
  if (!events?.code) print(`Approved this machine as ${label2}.`);
64087
64210
  return {
@@ -64189,6 +64312,12 @@ async function add(opts, ctx) {
64189
64312
  throw e;
64190
64313
  }
64191
64314
  say(ctx, `Added ${name}.`);
64315
+ say(
64316
+ ctx,
64317
+ `The running bus connects to ${name} the next time it restarts (after an update, or when you restart the service). Until then, folders you map to it stay off every hub.`,
64318
+ "",
64319
+ `Heads up: after that restart, which can be an automatic update, every folder that is not mapped stops going to your main instance and sits on none. To keep your current folders on main, run ${ctx.busCmd} use main in a parent folder such as ~ (it covers everything below it).`
64320
+ );
64192
64321
  claudeEntries(name, parsed.hub, ctx);
64193
64322
  return 0;
64194
64323
  }
@@ -64251,16 +64380,16 @@ async function autoUpdate(opts, ctx) {
64251
64380
  }
64252
64381
 
64253
64382
  // src/commands/daemon.ts
64254
- import { existsSync as existsSync16 } from "node:fs";
64255
- import { join as join40 } from "node:path";
64383
+ import { existsSync as existsSync17 } from "node:fs";
64384
+ import { join as join41 } from "node:path";
64256
64385
  import { fileURLToPath as fileURLToPath6 } from "node:url";
64257
64386
 
64258
64387
  // src/machine.ts
64259
64388
  import { readFileSync as readFileSync33, statSync as statSync10 } from "node:fs";
64260
- import { join as join38 } from "node:path";
64389
+ import { join as join39 } from "node:path";
64261
64390
  init_src();
64262
64391
  function readMachine(home2) {
64263
- const file2 = join38(home2, "machine.json");
64392
+ const file2 = join39(home2, "machine.json");
64264
64393
  let text3;
64265
64394
  let mode;
64266
64395
  try {
@@ -64294,7 +64423,7 @@ var originOf2 = (hub) => {
64294
64423
 
64295
64424
  // src/steps/claude-proof-check.ts
64296
64425
  import { readFileSync as readFileSync34 } from "node:fs";
64297
- import { join as join39 } from "node:path";
64426
+ import { join as join40 } from "node:path";
64298
64427
  var PROOF_EVENT = "claude_proof_applied";
64299
64428
  var DAY_MS = 864e5;
64300
64429
  var safeText = (s, max = 80) => {
@@ -64319,10 +64448,10 @@ function claudeProofChecks(ctx, hub, instance) {
64319
64448
  return [];
64320
64449
  }
64321
64450
  const cc = instance ? `Claude Code (${safeText(instance.name, 32)}):` : "Claude Code:";
64322
- const rec = readRecord(join39(ctx.home, "install.json"));
64451
+ const rec = readRecord(join40(ctx.home, "install.json"));
64323
64452
  const file2 = rec.config ?? claudeConfigFile(ctx.userHome, ctx.env);
64324
64453
  const r = proofReport(file2, origin, {
64325
- projectFile: join39(ctx.cwd, ".mcp.json"),
64454
+ projectFile: join40(ctx.cwd, ".mcp.json"),
64326
64455
  cwd: ctx.cwd,
64327
64456
  recorded: rec.proofs,
64328
64457
  ...instance ? { instance } : {},
@@ -64442,7 +64571,7 @@ function instanceProofChecks(ctx) {
64442
64571
  function lastAutoFix(ctx) {
64443
64572
  let text3;
64444
64573
  try {
64445
- text3 = readFileSync34(join39(ctx.home, "logs", "events.log"), "utf8");
64574
+ text3 = readFileSync34(join40(ctx.home, "logs", "events.log"), "utf8");
64446
64575
  } catch {
64447
64576
  return void 0;
64448
64577
  }
@@ -64468,12 +64597,12 @@ var lasting = (e) => [...START_ERROR_CODES, "EACCES", "EPERM"].includes(
64468
64597
  );
64469
64598
  async function daemon(ctx, run5 = runDaemon, signals = process) {
64470
64599
  const m = readMachine(ctx.home);
64471
- if (existsSync16(join40(ctx.home, "revoked")) && (m.state !== "ok" || m.revoked)) {
64600
+ if (existsSync17(join41(ctx.home, "revoked")) && (m.state !== "ok" || m.revoked)) {
64472
64601
  sayErr(ctx, ctx.copy.revoked());
64473
64602
  return 0;
64474
64603
  }
64475
- const events = createEventLog(join40(ctx.home, "logs", "events.log"));
64476
- const config2 = readRecord(join40(ctx.home, "install.json")).config;
64604
+ const events = createEventLog(join41(ctx.home, "logs", "events.log"));
64605
+ const config2 = readRecord(join41(ctx.home, "install.json")).config;
64477
64606
  if (m.state === "ok" && config2 !== void 0 && wiredTo(ctx))
64478
64607
  reapplyClaudeProof(
64479
64608
  {
@@ -64527,11 +64656,11 @@ async function daemon(ctx, run5 = runDaemon, signals = process) {
64527
64656
 
64528
64657
  // src/commands/doctor.ts
64529
64658
  import { readFileSync as readFileSync39 } from "node:fs";
64530
- import { join as join48 } from "node:path";
64659
+ import { join as join49 } from "node:path";
64531
64660
 
64532
64661
  // src/steps/claude-plugins.ts
64533
64662
  import { readFileSync as readFileSync36 } from "node:fs";
64534
- import { join as join42 } from "node:path";
64663
+ import { join as join43 } from "node:path";
64535
64664
 
64536
64665
  // src/steps/output-style.ts
64537
64666
  import {
@@ -64541,21 +64670,21 @@ import {
64541
64670
  rmdirSync as rmdirSync3,
64542
64671
  rmSync as rmSync22
64543
64672
  } from "node:fs";
64544
- import { dirname as dirname19, join as join41 } from "node:path";
64673
+ import { dirname as dirname19, join as join42 } from "node:path";
64545
64674
  var OUTPUT_STYLE_FILE = "artifacts-teammate.md";
64546
64675
  var OUTPUT_STYLE_MARKER = "<!-- managed by the Open Artifacts bus installer: edits are replaced on reinstall. -->";
64547
64676
  var OUTPUT_STYLE_NAME = "Artifacts Teammate";
64548
64677
  var OUTPUT_STYLE_PLUGIN_NAME = "open-artifacts:Artifacts Teammate";
64549
64678
  var isOurName = (v) => v === OUTPUT_STYLE_NAME || v === OUTPUT_STYLE_PLUGIN_NAME;
64550
- var claudeSettingsFile = (w) => join41(w.env?.CLAUDE_CONFIG_DIR ?? join41(w.home, ".claude"), "settings.json");
64679
+ var claudeSettingsFile = (w) => join42(w.env?.CLAUDE_CONFIG_DIR ?? join42(w.home, ".claude"), "settings.json");
64551
64680
  var readRecord3 = (busHome2) => {
64552
64681
  if (!busHome2) return void 0;
64553
- const r = readInstallFile(join41(busHome2, "install.json")).outputStyle;
64682
+ const r = readInstallFile(join42(busHome2, "install.json")).outputStyle;
64554
64683
  return typeof r === "object" && r !== null ? r : void 0;
64555
64684
  };
64556
- var writeRecord3 = (busHome2, r) => updateInstallFile(join41(busHome2, "install.json"), { outputStyle: r });
64557
- var styleDir = (w) => join41(w.env?.CLAUDE_CONFIG_DIR ?? join41(w.home, ".claude"), "output-styles");
64558
- var outputStyleFile = (w) => join41(styleDir(w), OUTPUT_STYLE_FILE);
64685
+ var writeRecord3 = (busHome2, r) => updateInstallFile(join42(busHome2, "install.json"), { outputStyle: r });
64686
+ var styleDir = (w) => join42(w.env?.CLAUDE_CONFIG_DIR ?? join42(w.home, ".claude"), "output-styles");
64687
+ var outputStyleFile = (w) => join42(styleDir(w), OUTPUT_STYLE_FILE);
64559
64688
  var isOurs2 = (text3) => {
64560
64689
  const m = /^---\n[\s\S]*?\n---\n/.exec(text3.replace(/\r\n/g, "\n"));
64561
64690
  return m !== null && text3.replace(/\r\n/g, "\n").slice(m[0].length).split("\n", 1)[0] === OUTPUT_STYLE_MARKER;
@@ -64773,10 +64902,10 @@ var SPARSE = [".claude-plugin", "plugins", "packages/claude-code-shortcuts"];
64773
64902
  var CALL_MS = 12e4;
64774
64903
  var MCP_LIST_MS = 2e4;
64775
64904
  var readRecord4 = (busHome2) => {
64776
- const r = readInstallFile(join42(busHome2, "install.json")).claudePlugins;
64905
+ const r = readInstallFile(join43(busHome2, "install.json")).claudePlugins;
64777
64906
  return typeof r === "object" && r !== null ? r : void 0;
64778
64907
  };
64779
- var writeRecord4 = (busHome2, r) => updateInstallFile(join42(busHome2, "install.json"), { claudePlugins: r });
64908
+ var writeRecord4 = (busHome2, r) => updateInstallFile(join43(busHome2, "install.json"), { claudePlugins: r });
64780
64909
  var cmpVersion = (a, b) => {
64781
64910
  const pa = a.split(".").map(Number);
64782
64911
  const pb = b.split(".").map(Number);
@@ -65241,7 +65370,7 @@ function readInstanceUrl(deps2) {
65241
65370
 
65242
65371
  // src/steps/claude-sessions.ts
65243
65372
  import { readFileSync as readFileSync37 } from "node:fs";
65244
- import { join as join43 } from "node:path";
65373
+ import { join as join44 } from "node:path";
65245
65374
  var UNBOUND_EVENT = "mcp_proof_unbound";
65246
65375
  var DAY_MS2 = 864e5;
65247
65376
  function hubOrigin(hub) {
@@ -65273,7 +65402,7 @@ function helperFailures(ctx) {
65273
65402
  const out = /* @__PURE__ */ new Map();
65274
65403
  let text3;
65275
65404
  try {
65276
- text3 = readFileSync37(join43(ctx.home, "logs", "events.log"), "utf8");
65405
+ text3 = readFileSync37(join44(ctx.home, "logs", "events.log"), "utf8");
65277
65406
  } catch {
65278
65407
  return out;
65279
65408
  }
@@ -65319,7 +65448,7 @@ function entryApplies(ctx, origin, cwd) {
65319
65448
  const p = isObj2(doc.projects) ? doc.projects[cwd] : void 0;
65320
65449
  if (isObj2(p) && matching(p.mcpServers, origin).length > 0) return true;
65321
65450
  }
65322
- const proj = read(join43(cwd, ".mcp.json"));
65451
+ const proj = read(join44(cwd, ".mcp.json"));
65323
65452
  return isObj2(proj) && matching(proj.mcpServers, origin).length > 0;
65324
65453
  }
65325
65454
  function sessionChecks(ctx, st, hub) {
@@ -65401,7 +65530,7 @@ var sseCheck = (ctx, name) => ({
65401
65530
 
65402
65531
  // src/commands/habits.ts
65403
65532
  init_src();
65404
- import { join as join44 } from "node:path";
65533
+ import { join as join45 } from "node:path";
65405
65534
  var pluginOn = (p) => `Habits on in the ${p.label} plugin.`;
65406
65535
  var pluginOff = (p) => `Habits off in the ${p.label} plugin.`;
65407
65536
  var deps = (ctx) => ({
@@ -65520,7 +65649,7 @@ async function habitsAfterInstall(ctx, json4) {
65520
65649
  })),
65521
65650
  // A plugin has no block to compare: its marker is there ("current") or not.
65522
65651
  ...plugins2.map((p) => ({
65523
- path: join44(p.dir(ctx.userHome, ctx.env), p.marker),
65652
+ path: join45(p.dir(ctx.userHome, ctx.env), p.marker),
65524
65653
  label: `the ${p.label} plugin`,
65525
65654
  s: {
65526
65655
  state: pluginHabitsState(deps(ctx), p) === "on" ? "current" : "absent"
@@ -65565,7 +65694,7 @@ async function habitsAfterInstall(ctx, json4) {
65565
65694
  const pl = setPluginHabits(
65566
65695
  deps(ctx),
65567
65696
  plugins2.filter(
65568
- (p) => asked.includes(join44(p.dir(ctx.userHome, ctx.env), p.marker))
65697
+ (p) => asked.includes(join45(p.dir(ctx.userHome, ctx.env), p.marker))
65569
65698
  ),
65570
65699
  true
65571
65700
  );
@@ -65628,7 +65757,7 @@ function habitsLine(ctx) {
65628
65757
 
65629
65758
  // src/commands/namespace.ts
65630
65759
  import { realpathSync as realpathSync16, statSync as statSync11 } from "node:fs";
65631
- import { join as join45, resolve as resolve15 } from "node:path";
65760
+ import { join as join46, resolve as resolve15 } from "node:path";
65632
65761
  init_src();
65633
65762
  function shown3(ctx, path) {
65634
65763
  const t = tilde(ctx, path);
@@ -65699,7 +65828,7 @@ async function namespace(opts, ctx) {
65699
65828
  sayErr(ctx, c.nsNotDir(shown3(ctx, real3 ?? given)));
65700
65829
  return 1;
65701
65830
  }
65702
- const cfgFile = join45(real3, CONFIG_FILE);
65831
+ const cfgFile = join46(real3, CONFIG_FILE);
65703
65832
  const own2 = readOwnFile(cfgFile, process.getuid?.(), {
65704
65833
  allowGroupWrite: true
65705
65834
  });
@@ -65778,7 +65907,7 @@ init_src();
65778
65907
 
65779
65908
  // src/commands/install.ts
65780
65909
  init_src3();
65781
- import { dirname as dirname20, join as join47 } from "node:path";
65910
+ import { dirname as dirname20, join as join48 } from "node:path";
65782
65911
  init_src2();
65783
65912
 
65784
65913
  // src/live.ts
@@ -65835,15 +65964,15 @@ import {
65835
65964
  rmdirSync as rmdirSync4,
65836
65965
  rmSync as rmSync23
65837
65966
  } from "node:fs";
65838
- import { join as join46 } from "node:path";
65967
+ import { join as join47 } from "node:path";
65839
65968
  function leftoverTargets(deps2) {
65840
65969
  const env2 = deps2.env ?? {};
65841
65970
  const p = paths(deps2);
65842
- const piDir = agentDirEnv(deps2.home, env2) ?? join46(deps2.home, ".pi/agent");
65971
+ const piDir = agentDirEnv(deps2.home, env2) ?? join47(deps2.home, ".pi/agent");
65843
65972
  const skill2 = (h) => skillDir({ home: deps2.home, env: env2 }, h);
65844
65973
  return {
65845
65974
  files: [
65846
- join46(codexHome2(deps2.home, env2), "AGENTS.md"),
65975
+ join47(codexHome2(deps2.home, env2), "AGENTS.md"),
65847
65976
  p.codex,
65848
65977
  ...p.opencodeConfigs,
65849
65978
  p.opencodeCli
@@ -65852,10 +65981,10 @@ function leftoverTargets(deps2) {
65852
65981
  skill2("claude"),
65853
65982
  skill2("pi"),
65854
65983
  skill2("hermes"),
65855
- join46(hermesHome(deps2.home, env2), "plugins"),
65856
- join46(deps2.home, ".local", "bin"),
65857
- join46(ompAgentDir(deps2.home, env2), "extensions"),
65858
- join46(piDir, "extensions"),
65984
+ join47(hermesHome(deps2.home, env2), "plugins"),
65985
+ join47(deps2.home, ".local", "bin"),
65986
+ join47(ompAgentDir(deps2.home, env2), "extensions"),
65987
+ join47(piDir, "extensions"),
65859
65988
  skill2("opencode"),
65860
65989
  skill2("openclaw")
65861
65990
  ]
@@ -66000,7 +66129,7 @@ async function loginStep(ctx, opts) {
66000
66129
  ctx,
66001
66130
  c.approved(result.label),
66002
66131
  c.tokenSaved(
66003
- tilde(ctx, join47(ctx.home, "machine.json")),
66132
+ tilde(ctx, join48(ctx.home, "machine.json")),
66004
66133
  result.machineToken
66005
66134
  ),
66006
66135
  c.connected(originOf2(result.hub)),
@@ -66129,7 +66258,7 @@ function shownSocket(ctx) {
66129
66258
  const real3 = `${canonicalHome(ctx.home)}/`;
66130
66259
  return tilde(
66131
66260
  ctx,
66132
- path.startsWith(real3) ? join47(ctx.home, path.slice(real3.length)) : path
66261
+ path.startsWith(real3) ? join48(ctx.home, path.slice(real3.length)) : path
66133
66262
  );
66134
66263
  }
66135
66264
  async function waitForDaemon(ctx) {
@@ -66381,7 +66510,7 @@ async function installRun(opts, realCtx2) {
66381
66510
  return results.every((r) => r.state === "done") ? 0 : 1;
66382
66511
  }
66383
66512
  const ok = await runSteps(steps, ctx, {
66384
- path: join47(ctx.home, "install.json"),
66513
+ path: join48(ctx.home, "install.json"),
66385
66514
  now: ctx.now
66386
66515
  });
66387
66516
  if (ok && second) say(ctx, "", c.secondBus(ctx.home));
@@ -66429,6 +66558,7 @@ var core = (v) => {
66429
66558
  return semverGte(v, v) && semverGte(c, c) ? c : void 0;
66430
66559
  };
66431
66560
  var UPDATE_PROBE_MS = 1500;
66561
+ var HIDDEN2 = /[\p{Cc}\p{Cf}\u2028\u2029]/gu;
66432
66562
  var healthzBody = async (res) => {
66433
66563
  try {
66434
66564
  const reader = res.body?.getReader();
@@ -66478,6 +66608,35 @@ var proofLines = (ctx, hub, daemonKnows) => claudeProofChecks(ctx, hub).filter((
66478
66608
  "Claude Code: update the daemon so these entries can show as this session on pages."
66479
66609
  ] : c.lines
66480
66610
  );
66611
+ var FOLDERS_SHOWN = 50;
66612
+ function instanceBlocks(ctx, rows) {
66613
+ const list = listInstances(ctx.home);
66614
+ if (list.length < 2) return [];
66615
+ const clean2 = (t) => stripTerminalControls(t).replace(HIDDEN2, "");
66616
+ const inst = [
66617
+ "Instances",
66618
+ ...list.map((i) => {
66619
+ const r = rows.find((x) => x.name === i.name);
66620
+ const state = r?.revoked ? "revoked" : r?.link === "connected" ? "connected" : "not connected";
66621
+ const addr = clean2(canonicalAddress(i.hub) ?? "(address unreadable)");
66622
+ const n = r?.agents ?? 0;
66623
+ return ` ${clean2(i.name)}${i.main ? " (main)" : ""} ${addr} ${state} ${n} ${n === 1 ? "agent" : "agents"}`;
66624
+ })
66625
+ ];
66626
+ const map2 = Object.entries(readFolders(ctx.home).map).sort(
66627
+ ([a], [b]) => a < b ? -1 : 1
66628
+ );
66629
+ const folders = map2.length === 0 ? [] : [
66630
+ [
66631
+ "Folders",
66632
+ ...map2.slice(0, FOLDERS_SHOWN).map(
66633
+ ([dir, name]) => ` ${clean2(tilde(ctx, dir))} -> ${clean2(name)}`
66634
+ ),
66635
+ ...map2.length > FOLDERS_SHOWN ? [` and ${map2.length - FOLDERS_SHOWN} more`] : []
66636
+ ]
66637
+ ];
66638
+ return [inst, ...folders];
66639
+ }
66481
66640
  async function status(ctx) {
66482
66641
  const c = ctx.copy;
66483
66642
  say(ctx, c.header(ctx.version), "");
@@ -66526,6 +66685,8 @@ async function status(ctx) {
66526
66685
  if (ocState === "stale" || ocState === "current")
66527
66686
  say(ctx, c.openclawDmNote());
66528
66687
  if (st.config_files?.length) say(ctx, configFileLines(ctx, st.config_files));
66688
+ for (const block of instanceBlocks(ctx, st.instances ?? []))
66689
+ say(ctx, "", block);
66529
66690
  if (st.hub !== "connected") {
66530
66691
  sayErr(ctx, c.hubNotReachable(host, st.hub_error, "status"));
66531
66692
  return 1;
@@ -66550,6 +66711,7 @@ async function status(ctx) {
66550
66711
 
66551
66712
  // src/commands/doctor.ts
66552
66713
  var HEALTHZ_TIMEOUT_MS = 1e4;
66714
+ var INSTANCE_KEY_MIN_VERSION = "0.218.0";
66553
66715
  var sameOrigin = (url2, hub) => {
66554
66716
  try {
66555
66717
  return url2 === "" || new URL(url2).origin === new URL(hub).origin;
@@ -66652,7 +66814,7 @@ async function doctor(ctx) {
66652
66814
  const node2 = ctx.nodeVersion.replace(/^v/, "");
66653
66815
  if (Number(node2.split(".")[0]) >= MIN_NODE) pass(c.nodeOk(node2));
66654
66816
  else fail3(c.nodeOld(node2));
66655
- const machineFile = tilde(ctx, join48(ctx.home, "machine.json"));
66817
+ const machineFile = tilde(ctx, join49(ctx.home, "machine.json"));
66656
66818
  const m = readMachine(ctx.home);
66657
66819
  if (m.state !== "ok") fail3(c.noCredentials(machineFile));
66658
66820
  else if (m.revoked) fail3(c.revokedCheck());
@@ -66741,8 +66903,8 @@ async function doctor(ctx) {
66741
66903
  pass(c.wired(h, version2));
66742
66904
  else fail3(c.notWired(h));
66743
66905
  if (h === "claude") {
66744
- const settings = join48(
66745
- ctx.env.CLAUDE_CONFIG_DIR ?? join48(ctx.userHome, ".claude"),
66906
+ const settings = join49(
66907
+ ctx.env.CLAUDE_CONFIG_DIR ?? join49(ctx.userHome, ".claude"),
66746
66908
  "settings.json"
66747
66909
  );
66748
66910
  const isolates = claudeIsolates(settings);
@@ -66866,6 +67028,11 @@ async function doctor(ctx) {
66866
67028
  n.warnings += files2.length;
66867
67029
  say(ctx, configFileLines(ctx, files2));
66868
67030
  }
67031
+ if (readSuggestion(ctx.cwd) !== void 0)
67032
+ say(
67033
+ ctx,
67034
+ `This repo's .oa-bus.json has an instance key. This version reads it; oa-bus before ${INSTANCE_KEY_MIN_VERSION} refuses the whole file.`
67035
+ );
66869
67036
  if (asksForGlobal(ctx, list.dirs)) warn(c.globalAsked());
66870
67037
  say(ctx, "", c.summary(n.failed, n.warnings, n.passed));
66871
67038
  return n.failed > 0 ? 1 : 0;
@@ -66932,11 +67099,11 @@ async function global(opts, ctx) {
66932
67099
 
66933
67100
  // src/commands/leads.ts
66934
67101
  import { readFileSync as readFileSync40 } from "node:fs";
66935
- import { join as join49 } from "node:path";
67102
+ import { join as join50 } from "node:path";
66936
67103
  function hubOrigin2(ctx) {
66937
67104
  try {
66938
67105
  const raw = JSON.parse(
66939
- readFileSync40(join49(ctx.home, "machine.json"), "utf8")
67106
+ readFileSync40(join50(ctx.home, "machine.json"), "utf8")
66940
67107
  );
66941
67108
  return typeof raw?.hub === "string" ? new URL(raw.hub).origin : void 0;
66942
67109
  } catch {
@@ -67008,7 +67175,11 @@ function side(ctx, dir) {
67008
67175
  remotesFile: remotesFile(ctx.home),
67009
67176
  recordRemote: false
67010
67177
  });
67011
- return { dir: real3, namespace: ns.namespace };
67178
+ return {
67179
+ dir: real3,
67180
+ namespace: ns.namespace,
67181
+ instance: approvalsInstance(ctx, real3)
67182
+ };
67012
67183
  } catch {
67013
67184
  return void 0;
67014
67185
  }
@@ -67039,11 +67210,40 @@ async function link(opts, ctx) {
67039
67210
  sayErr(ctx, c.linkSame(shq(a.dir), shq(b.dir), plain2(a.namespace)));
67040
67211
  return 1;
67041
67212
  }
67213
+ if (a.instance === void 0 || b.instance === void 0) {
67214
+ sayErr(
67215
+ ctx,
67216
+ `Nothing changed: a folder isn't tied to an instance yet. Run ${ctx.busCmd} use there first.`
67217
+ );
67218
+ return 1;
67219
+ }
67220
+ if (a.instance !== b.instance) {
67221
+ sayErr(
67222
+ ctx,
67223
+ `Nothing changed: these folders use different instances (${plain2(a.instance)} and ${plain2(b.instance)}). A link is made on one instance; put both folders on the same one with ${ctx.busCmd} use.`
67224
+ );
67225
+ return 1;
67226
+ }
67227
+ let hubUrl = m.hub;
67228
+ let token = m.token;
67229
+ if (a.instance !== MAIN_INSTANCE) {
67230
+ try {
67231
+ const cred = credentialsFor(a.instance, ctx.home);
67232
+ hubUrl = cred.hub;
67233
+ token = cred.machine_token;
67234
+ } catch {
67235
+ sayErr(
67236
+ ctx,
67237
+ `Nothing changed: the instance ${plain2(a.instance)} can't be used (its key is missing or was revoked). Run ${ctx.busCmd} add again.`
67238
+ );
67239
+ return 1;
67240
+ }
67241
+ }
67042
67242
  const action = opts.sub === "add" ? "link" : "unlink";
67043
- const res = await ctx.fetch(new URL(BUS_ROUTES.linkProposals, m.hub), {
67243
+ const res = await ctx.fetch(new URL(BUS_ROUTES.linkProposals, hubUrl), {
67044
67244
  method: "POST",
67045
67245
  headers: {
67046
- authorization: `Bearer ${m.token}`,
67246
+ authorization: `Bearer ${token}`,
67047
67247
  "content-type": "application/json"
67048
67248
  },
67049
67249
  body: JSON.stringify({ action, a: a.namespace, b: b.namespace })
@@ -67067,7 +67267,7 @@ async function link(opts, ctx) {
67067
67267
  const j = await res.json();
67068
67268
  if (typeof j.confirmUrl === "string") {
67069
67269
  const u = new URL(j.confirmUrl);
67070
- if (u.origin === new URL(m.hub).origin && u.pathname === "/bus/links/confirm" && !u.search && /^#[A-Za-z0-9_-]{43}$/.test(u.hash))
67270
+ if (u.origin === new URL(hubUrl).origin && u.pathname === "/bus/links/confirm" && !u.search && /^#[A-Za-z0-9_-]{43}$/.test(u.hash))
67071
67271
  url2 = u.href;
67072
67272
  }
67073
67273
  } catch {
@@ -67097,7 +67297,7 @@ import {
67097
67297
  openSync as openSync11,
67098
67298
  readFileSync as readFileSync41
67099
67299
  } from "node:fs";
67100
- import { dirname as dirname21, join as join50 } from "node:path";
67300
+ import { dirname as dirname21, join as join51 } from "node:path";
67101
67301
  var TAIL = 50;
67102
67302
  var checkDir2 = (dir) => {
67103
67303
  let fd;
@@ -67142,9 +67342,9 @@ var tail = (path, dir) => {
67142
67342
  }
67143
67343
  };
67144
67344
  async function logs(ctx) {
67145
- const logDir = join50(ctx.home, "logs");
67146
- const path = join50(logDir, "daemon.log");
67147
- const eventsPath = join50(logDir, "events.log");
67345
+ const logDir = join51(ctx.home, "logs");
67346
+ const path = join51(logDir, "daemon.log");
67347
+ const eventsPath = join51(logDir, "events.log");
67148
67348
  const dir = checkDir2(logDir);
67149
67349
  if (!dir.ok && dir.why !== "missing") {
67150
67350
  say(ctx, `Not reading ${tilde(ctx, logDir)}: ${dir.why}.`);
@@ -67187,7 +67387,7 @@ init_src3();
67187
67387
  import { execFileSync as execFileSync8 } from "node:child_process";
67188
67388
  import { createHash as createHash12, randomBytes as randomBytes9 } from "node:crypto";
67189
67389
  import { readFileSync as readFileSync42, readlinkSync as readlinkSync7 } from "node:fs";
67190
- import { basename as basename10, join as join51 } from "node:path";
67390
+ import { basename as basename10, join as join52 } from "node:path";
67191
67391
  init_src2();
67192
67392
  init_src();
67193
67393
  var LOG_WAIT_MS = 300;
@@ -67283,7 +67483,7 @@ async function mcpProof(opts, ctx, deps2 = {
67283
67483
  say(ctx, JSON.stringify(headers));
67284
67484
  if (why2 !== void 0)
67285
67485
  try {
67286
- const events = createEventLog(join51(ctx.home, "logs", "events.log"));
67486
+ const events = createEventLog(join52(ctx.home, "logs", "events.log"));
67287
67487
  events(UNBOUND_EVENT, {
67288
67488
  reason: why2,
67289
67489
  ...detail !== void 0 ? { code: detail } : {}
@@ -67380,12 +67580,12 @@ async function skill(opts, ctx) {
67380
67580
  }
67381
67581
 
67382
67582
  // src/commands/uninstall.ts
67383
- import { join as join53 } from "node:path";
67583
+ import { join as join54 } from "node:path";
67384
67584
 
67385
67585
  // src/steps/purge.ts
67386
67586
  init_src3();
67387
67587
  import { lstatSync as lstatSync23, readdirSync as readdirSync14, rmdirSync as rmdirSync5, rmSync as rmSync24 } from "node:fs";
67388
- import { join as join52 } from "node:path";
67588
+ import { join as join53 } from "node:path";
67389
67589
  var FILES = [
67390
67590
  "machine.json",
67391
67591
  "install.json",
@@ -67455,14 +67655,14 @@ var rmdirIfEmpty = (path) => {
67455
67655
  };
67456
67656
  function purgeShort(dir, removed) {
67457
67657
  if (kind3(dir) !== "dir" || unsafeSocketDir(dir)) return;
67458
- const ret = join52(dir, "claude-return");
67658
+ const ret = join53(dir, "claude-return");
67459
67659
  for (const [d, ours2] of [
67460
67660
  [ret, (_n, p) => kind3(p) === "socket"],
67461
67661
  [dir, (n) => /^daemon\.sock(\.keep-\d+)?$/.test(n)]
67462
67662
  ]) {
67463
67663
  if (kind3(d) !== "dir") continue;
67464
67664
  for (const name of readdirSync14(d)) {
67465
- const path = join52(d, name);
67665
+ const path = join53(d, name);
67466
67666
  const k = kind3(path);
67467
67667
  if (k === void 0 || k === "dir" || !ours2(name, path)) continue;
67468
67668
  remove2(path, k);
@@ -67487,21 +67687,21 @@ function purge(home2, opts) {
67487
67687
  ...FILES,
67488
67688
  ...entries.filter((n) => TEMP.some((re) => re.test(n)))
67489
67689
  ]) {
67490
- const path = join52(home2, name);
67690
+ const path = join53(home2, name);
67491
67691
  const k = kind3(path);
67492
67692
  if (k === void 0 || k === "dir") continue;
67493
67693
  remove2(path, k);
67494
67694
  removed.push(name);
67495
67695
  }
67496
67696
  for (const folder of FOLDERS) {
67497
- const dir = join52(home2, folder.path);
67697
+ const dir = join53(home2, folder.path);
67498
67698
  if (kind3(dir) !== "dir") continue;
67499
67699
  for (const name of readdirSync14(dir)) {
67500
- const path = join52(dir, name);
67700
+ const path = join53(dir, name);
67501
67701
  const k = kind3(path);
67502
67702
  if (k === void 0 || !folder.ours(name, path)) continue;
67503
67703
  remove2(path, k);
67504
- removed.push(join52(folder.path, name));
67704
+ removed.push(join53(folder.path, name));
67505
67705
  }
67506
67706
  if (rmdirIfEmpty(dir)) removed.push(folder.path);
67507
67707
  }
@@ -67592,7 +67792,7 @@ async function unwire(ctx) {
67592
67792
  say(
67593
67793
  ctx,
67594
67794
  c.hermesNoCli(
67595
- tilde(ctx, join53(hermesHome(ctx.userHome, ctx.env), "config.yaml"))
67795
+ tilde(ctx, join54(hermesHome(ctx.userHome, ctx.env), "config.yaml"))
67596
67796
  )
67597
67797
  );
67598
67798
  if (r.openclawNoCli) say(ctx, c.openclawNoCli());
@@ -67626,7 +67826,7 @@ async function uninstall2(opts, ctx) {
67626
67826
  say(ctx, c.daemonStillRunning(removed.running));
67627
67827
  if (wiredTo(ctx)) await unwire(ctx);
67628
67828
  if (!opts.purge) {
67629
- say(ctx, "", c.kept(tilde(ctx, join53(ctx.home, "machine.json"))));
67829
+ say(ctx, "", c.kept(tilde(ctx, join54(ctx.home, "machine.json"))));
67630
67830
  return 0;
67631
67831
  }
67632
67832
  const home2 = tilde(ctx, ctx.home);
@@ -67636,9 +67836,9 @@ async function uninstall2(opts, ctx) {
67636
67836
  return 1;
67637
67837
  } catch {
67638
67838
  }
67639
- const made = readMade(join53(ctx.home, "install.json"));
67839
+ const made = readMade(join54(ctx.home, "install.json"));
67640
67840
  const out = purge(ctx.home, {
67641
- isDefault: ctx.home === join53(ctx.userHome, ".oa-bus")
67841
+ isDefault: ctx.home === join54(ctx.userHome, ".oa-bus")
67642
67842
  });
67643
67843
  if ("refused" in out) {
67644
67844
  sayErr(ctx, c.purgeRefused(home2));
@@ -67720,6 +67920,171 @@ async function installViaDaemon(ctx, version2, waitMs = INSTALL_WAIT_MS) {
67720
67920
  return false;
67721
67921
  }
67722
67922
 
67923
+ // src/commands/upgrade.ts
67924
+ import { spawnSync as spawnSync2 } from "node:child_process";
67925
+ import {
67926
+ chmodSync as chmodSync23,
67927
+ copyFileSync as copyFileSync2,
67928
+ existsSync as existsSync19,
67929
+ mkdirSync as mkdirSync18,
67930
+ rmSync as rmSync25,
67931
+ writeFileSync as writeFileSync20
67932
+ } from "node:fs";
67933
+ import { join as join55 } from "node:path";
67934
+ var realUpgradeDeps = (ctx) => ({
67935
+ fetchRelease,
67936
+ verifyRelease,
67937
+ runInstaller: (entry, args) => spawnSync2(process.execPath, [entry, ...args], {
67938
+ stdio: "inherit",
67939
+ env: { ...process.env, OA_BUS_HOME: ctx.home }
67940
+ }).status ?? 1
67941
+ });
67942
+ async function serverVersion(ctx, hub) {
67943
+ try {
67944
+ const res = await ctx.fetch(`${hub.replace(/\/+$/, "")}/healthz`, {
67945
+ signal: AbortSignal.timeout(5e3)
67946
+ });
67947
+ if (!res.ok) return void 0;
67948
+ if (new URL(res.url || hub).origin !== new URL(hub).origin)
67949
+ return void 0;
67950
+ return (await healthzBody(res)).version;
67951
+ } catch {
67952
+ return void 0;
67953
+ }
67954
+ }
67955
+ async function upgrade(ctx, opts, deps2 = realUpgradeDeps(ctx)) {
67956
+ const c = ctx.copy;
67957
+ const m = readMachine(ctx.home);
67958
+ if (m.state !== "ok") {
67959
+ sayErr(ctx, c.upgradeNotInstalled());
67960
+ return 1;
67961
+ }
67962
+ if (opts.version !== void 0 && parseVersion(opts.version) === void 0) {
67963
+ sayErr(ctx, c.upgradeUsage());
67964
+ return 2;
67965
+ }
67966
+ const server4 = await serverVersion(ctx, m.hub);
67967
+ if (server4 === void 0) {
67968
+ sayErr(ctx, c.upgradeNoServerVersion());
67969
+ return 1;
67970
+ }
67971
+ const policy = readPolicy(ctx.home);
67972
+ const running = ctx.version;
67973
+ if (policy.unreadable) {
67974
+ sayErr(ctx, c.updateOff());
67975
+ return 1;
67976
+ }
67977
+ if (policy.off) {
67978
+ sayErr(ctx, c.updateOff());
67979
+ return 1;
67980
+ }
67981
+ if (ctx.stdinIsTTY !== true || ctx.stdout.isTTY !== true) {
67982
+ sayErr(ctx, c.updateNotATerminal());
67983
+ return 2;
67984
+ }
67985
+ let target2 = opts.version;
67986
+ if (target2 === void 0) {
67987
+ if (parseVersion(server4) === void 0) {
67988
+ sayErr(ctx, c.upgradePreRelease(server4));
67989
+ return 1;
67990
+ }
67991
+ target2 = server4;
67992
+ }
67993
+ const named = opts.version !== void 0;
67994
+ const base3 = server4.split(/[-+]/)[0] ?? server4;
67995
+ const preRelease = parseVersion(server4) === void 0;
67996
+ if (parseVersion(base3) === void 0 || compareVersions2(target2, base3) > 0 || preRelease && compareVersions2(target2, base3) === 0) {
67997
+ sayErr(ctx, c.upgradeAhead(target2, server4));
67998
+ return 1;
67999
+ }
68000
+ const isPrevious = named && policy.previous === target2;
68001
+ if (policy.failed.includes(target2) && opts.allowFailed !== true) {
68002
+ sayErr(ctx, c.upgradeFailedVersion(target2));
68003
+ return 1;
68004
+ }
68005
+ const runBase = running.split(/[-+]/)[0] ?? running;
68006
+ if (parseVersion(runBase) === void 0) {
68007
+ sayErr(ctx, c.upgradeNotForward(target2, running));
68008
+ return 1;
68009
+ }
68010
+ {
68011
+ const cmp = compareVersions2(target2, runBase);
68012
+ if (cmp === 0 && runBase === running) {
68013
+ say(ctx, c.upgradeCurrent(running));
68014
+ return 0;
68015
+ }
68016
+ if (cmp < 0 && !isPrevious) {
68017
+ sayErr(ctx, c.upgradeNotForward(target2, running));
68018
+ return 1;
68019
+ }
68020
+ }
68021
+ if (loginActive(ctx.home)) {
68022
+ sayErr(ctx, c.updateBusy());
68023
+ return 1;
68024
+ }
68025
+ const answer = await ctx.readLine?.(c.updatePrompt(target2)) ?? "";
68026
+ if (answer.trim().toLowerCase() !== "yes") {
68027
+ say(ctx, c.updateDeclined());
68028
+ return 1;
68029
+ }
68030
+ say(ctx, c.upgradeChecking(target2));
68031
+ let verified2;
68032
+ try {
68033
+ verified2 = deps2.verifyRelease(await deps2.fetchRelease(target2));
68034
+ } catch (e) {
68035
+ sayErr(
68036
+ ctx,
68037
+ c.upgradeRefused(
68038
+ target2,
68039
+ e instanceof ReleaseError ? e.code : "fetch_failed"
68040
+ )
68041
+ );
68042
+ return 1;
68043
+ }
68044
+ const launcher = join55(ctx.home, "bin", "node");
68045
+ let dest;
68046
+ try {
68047
+ dest = stage(ctx.home, target2, (dir) => {
68048
+ unpackTo(verified2.entries, dir);
68049
+ if (!existsSync19(join55(dir, "dist", "index.js")))
68050
+ throw new Error("the release has no dist/index.js");
68051
+ if (existsSync19(launcher)) {
68052
+ copyFileSync2(launcher, join55(dir, "node"));
68053
+ chmodSync23(join55(dir, "node"), 448);
68054
+ }
68055
+ });
68056
+ } catch {
68057
+ sayErr(ctx, c.upgradeRefused(target2, "bad_tar"));
68058
+ return 1;
68059
+ }
68060
+ const marker = join55(dest, ".live", String(process.pid));
68061
+ try {
68062
+ mkdirSync18(join55(dest, ".live"), { recursive: true, mode: 448 });
68063
+ writeFileSync20(marker, "", { mode: 384 });
68064
+ } catch {
68065
+ }
68066
+ deps2.beforeInstall?.(dest);
68067
+ const entry = join55(dest, "dist", "index.js");
68068
+ if (!existsSync19(entry)) {
68069
+ sayErr(ctx, c.upgradeStaleStage(target2));
68070
+ return 1;
68071
+ }
68072
+ say(ctx, c.upgradeInstalling(target2));
68073
+ const args = ["install", "--instance", m.hub];
68074
+ if (!isDefaultHome2(ctx.home, ctx.userHome)) args.push("--home", ctx.home);
68075
+ if (ctx.service.kind === void 0 && !ctx.service.fallback)
68076
+ args.push("--no-service");
68077
+ setPending(ctx.home, { from: runBase, to: target2, startedAt: ctx.now() });
68078
+ const code2 = deps2.runInstaller(entry, args);
68079
+ rmSync25(marker, { force: true });
68080
+ if (code2 !== 0) {
68081
+ clearPending(ctx.home);
68082
+ sayErr(ctx, c.upgradeInstallFailed(target2, code2));
68083
+ return code2;
68084
+ }
68085
+ return 0;
68086
+ }
68087
+
67723
68088
  // src/commands/use.ts
67724
68089
  var SHOWN_MAX2 = 120;
67725
68090
  var clean = showAddress;
@@ -67825,8 +68190,9 @@ async function use(opts, ctx) {
67825
68190
  return 1;
67826
68191
  }
67827
68192
  say(ctx, `Which instance should ${clean(key2)} use?`, "");
68193
+ const marked = added ?? (suggestion !== void 0 && f.no[key2] !== suggestion ? instanceAt(suggestion, list) : void 0);
67828
68194
  list.forEach((i, n) => {
67829
- const mark = added && i.name === added.name ? " (suggested by this repo)" : "";
68195
+ const mark = marked && i.name === marked.name ? " (suggested by this repo)" : "";
67830
68196
  say(ctx, ` ${n + 1}. ${i.name} ${shown5[n]}${mark}`);
67831
68197
  });
67832
68198
  say(ctx, "");
@@ -67874,6 +68240,7 @@ var COMMANDS = /* @__PURE__ */ new Set([
67874
68240
  "leads",
67875
68241
  "auto-update",
67876
68242
  "update",
68243
+ "upgrade",
67877
68244
  "version"
67878
68245
  ]);
67879
68246
  var HARNESSES2 = ["claude", "opencode", "codex", "pi"];
@@ -67904,7 +68271,8 @@ var FLAGS = {
67904
68271
  uninstall: ["purge"],
67905
68272
  "mcp-proof": ["token-file", "instance"],
67906
68273
  "mcp-proxy": ["instance", "token-file", "token-env", "for"],
67907
- namespace: ["yes"]
68274
+ namespace: ["yes"],
68275
+ upgrade: ["allow-failed"]
67908
68276
  };
67909
68277
  function parse7(argv) {
67910
68278
  const end = argv.indexOf("--");
@@ -67933,6 +68301,7 @@ function parse7(argv) {
67933
68301
  "show-habits": { type: "boolean", default: false },
67934
68302
  json: { type: "boolean", default: false },
67935
68303
  purge: { type: "boolean", default: false },
68304
+ "allow-failed": { type: "boolean", default: false },
67936
68305
  version: { type: "boolean", short: "v", default: false },
67937
68306
  help: { type: "boolean", short: "h", default: false },
67938
68307
  "no-color": { type: "boolean", default: false }
@@ -67972,13 +68341,19 @@ function parse7(argv) {
67972
68341
  if (rest[1] !== void 0)
67973
68342
  throw new Error(`unexpected argument: ${rest[1]}`);
67974
68343
  }
68344
+ if (cmd === "upgrade") {
68345
+ if (rest[1] !== void 0)
68346
+ throw new Error(`unexpected argument: ${rest[1]}`);
68347
+ if (rest[0] !== void 0 && !/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/.test(rest[0]))
68348
+ throw new Error(`usage: ${BUS_CMD} upgrade [x.y.z]`);
68349
+ }
67975
68350
  if (cmd === "link" || cmd === "unlink") {
67976
68351
  const n = cmd === "link" && rest[0] === "list" ? 1 : 2;
67977
68352
  if (rest.length < n) throw new Error(LINK_USAGE);
67978
68353
  if (rest[n] !== void 0)
67979
68354
  throw new Error(`unexpected argument: ${rest[n]}`);
67980
68355
  }
67981
- const extra = cmd === "namespace" || cmd === "link" || cmd === "unlink" || cmd === "leads" || cmd === "auto-update" ? void 0 : rest[takes];
68356
+ const extra = cmd === "namespace" || cmd === "link" || cmd === "unlink" || cmd === "leads" || cmd === "upgrade" || cmd === "auto-update" ? void 0 : rest[takes];
67982
68357
  if (extra !== void 0) throw new Error(`unexpected argument: ${extra}`);
67983
68358
  for (const name of ["home", "instance", "name"])
67984
68359
  if (values[name] === "") throw new Error(`--${name} needs a value`);
@@ -68071,6 +68446,12 @@ function route(cmd, values, positionals) {
68071
68446
  }
68072
68447
  case "auto-update":
68073
68448
  return { cmd, sub: positionals[0] };
68449
+ case "upgrade":
68450
+ return {
68451
+ cmd,
68452
+ allowFailed: values["allow-failed"],
68453
+ ...positionals[0] ? { version: positionals[0] } : {}
68454
+ };
68074
68455
  case "link":
68075
68456
  case "unlink": {
68076
68457
  if (cmd === "link" && positionals[0] === "list")
@@ -68131,6 +68512,7 @@ var TERMINAL = /* @__PURE__ */ new Set([
68131
68512
  "leads",
68132
68513
  "auto-update",
68133
68514
  "update",
68515
+ "upgrade",
68134
68516
  "version",
68135
68517
  "help"
68136
68518
  ]);
@@ -68244,6 +68626,11 @@ async function dispatch(cmd, ctx) {
68244
68626
  return autoUpdate(cmd, ctx);
68245
68627
  case "update":
68246
68628
  return update(ctx, (v) => installViaDaemon(ctx, v));
68629
+ case "upgrade":
68630
+ return upgrade(ctx, {
68631
+ allowFailed: cmd.allowFailed,
68632
+ ...cmd.version ? { version: cmd.version } : {}
68633
+ });
68247
68634
  case "link":
68248
68635
  return link(cmd, ctx);
68249
68636
  case "version":
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@open-artifacts/bus",
3
3
  "type": "module",
4
- "version": "0.222.0",
4
+ "version": "0.224.0",
5
5
  "description": "The Open Artifacts bus: your AI agents reach each other across machines.",
6
6
  "license": "MIT",
7
7
  "repository": {
@@ -29,6 +29,6 @@
29
29
  "typecheck": "tsc --noEmit"
30
30
  },
31
31
  "oaBus": {
32
- "commit": "788fe3328da40879bcae64123390d7e1051e5365"
32
+ "commit": "d857ae918f7c531802bb4d07483f0dda384a954d"
33
33
  }
34
34
  }