@open-artifacts/bus 0.158.0 → 0.160.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
@@ -1533,8 +1533,8 @@ var init_regexes = __esm({
1533
1533
  _emoji = `^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`;
1534
1534
  ipv4 = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/;
1535
1535
  ipv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;
1536
- mac = (delimiter3) => {
1537
- const escapedDelim = escapeRegex(delimiter3 ?? ":");
1536
+ mac = (delimiter4) => {
1537
+ const escapedDelim = escapeRegex(delimiter4 ?? ":");
1538
1538
  return new RegExp(`^(?:[0-9A-F]{2}${escapedDelim}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${escapedDelim}){5}[0-9a-f]{2}$`);
1539
1539
  };
1540
1540
  cidrv4 = /^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/;
@@ -21787,7 +21787,7 @@ var init_frames = __esm({
21787
21787
  late = { late: external_exports.array(external_exports.string().min(1)).optional() };
21788
21788
  isWellFormed2 = (s) => s.isWellFormed();
21789
21789
  WELL_FORMED = { message: "text is not well-formed unicode" };
21790
- CLIENT_VERSION = true ? "0.158.0" : "0.0.0";
21790
+ CLIENT_VERSION = true ? "0.160.0" : "0.0.0";
21791
21791
  clientVersion = {
21792
21792
  client_version: external_exports.string().min(1).max(64).optional()
21793
21793
  };
@@ -23121,10 +23121,10 @@ var init_server = __esm({
23121
23121
 
23122
23122
  // ../bus-ipc/src/sysbin.ts
23123
23123
  import { existsSync } from "node:fs";
23124
- function systemTool(name, exists2 = existsSync) {
23124
+ function systemTool(name, exists3 = existsSync) {
23125
23125
  const hit = found.get(name);
23126
23126
  if (hit) return hit;
23127
- const path = SYSTEM_DIRS.map((d) => `${d}/${name}`).find(exists2);
23127
+ const path = SYSTEM_DIRS.map((d) => `${d}/${name}`).find(exists3);
23128
23128
  if (path) found.set(name, path);
23129
23129
  return path ?? name;
23130
23130
  }
@@ -30019,49 +30019,49 @@ var require_fast_uri = __commonJS({
30019
30019
  schemelessOptions.skipEscape = true;
30020
30020
  return serialize(resolved, schemelessOptions);
30021
30021
  }
30022
- function resolveComponent(base3, relative3, options, skipNormalization) {
30022
+ function resolveComponent(base3, relative5, options, skipNormalization) {
30023
30023
  const target2 = {};
30024
30024
  if (!skipNormalization) {
30025
30025
  base3 = parse8(serialize(base3, options), options);
30026
- relative3 = parse8(serialize(relative3, options), options);
30026
+ relative5 = parse8(serialize(relative5, options), options);
30027
30027
  }
30028
30028
  options = options || {};
30029
- if (!options.tolerant && relative3.scheme) {
30030
- target2.scheme = relative3.scheme;
30031
- target2.userinfo = relative3.userinfo;
30032
- target2.host = relative3.host;
30033
- target2.port = relative3.port;
30034
- target2.path = removeDotSegments(relative3.path || "");
30035
- target2.query = relative3.query;
30029
+ if (!options.tolerant && relative5.scheme) {
30030
+ target2.scheme = relative5.scheme;
30031
+ target2.userinfo = relative5.userinfo;
30032
+ target2.host = relative5.host;
30033
+ target2.port = relative5.port;
30034
+ target2.path = removeDotSegments(relative5.path || "");
30035
+ target2.query = relative5.query;
30036
30036
  } else {
30037
- if (relative3.userinfo !== void 0 || relative3.host !== void 0 || relative3.port !== void 0) {
30038
- target2.userinfo = relative3.userinfo;
30039
- target2.host = relative3.host;
30040
- target2.port = relative3.port;
30041
- target2.path = removeDotSegments(relative3.path || "");
30042
- target2.query = relative3.query;
30037
+ if (relative5.userinfo !== void 0 || relative5.host !== void 0 || relative5.port !== void 0) {
30038
+ target2.userinfo = relative5.userinfo;
30039
+ target2.host = relative5.host;
30040
+ target2.port = relative5.port;
30041
+ target2.path = removeDotSegments(relative5.path || "");
30042
+ target2.query = relative5.query;
30043
30043
  } else {
30044
- if (!relative3.path) {
30044
+ if (!relative5.path) {
30045
30045
  target2.path = base3.path;
30046
- if (relative3.query !== void 0) {
30047
- target2.query = relative3.query;
30046
+ if (relative5.query !== void 0) {
30047
+ target2.query = relative5.query;
30048
30048
  } else {
30049
30049
  target2.query = base3.query;
30050
30050
  }
30051
30051
  } else {
30052
- if (relative3.path[0] === "/") {
30053
- target2.path = removeDotSegments(relative3.path);
30052
+ if (relative5.path[0] === "/") {
30053
+ target2.path = removeDotSegments(relative5.path);
30054
30054
  } else {
30055
30055
  if ((base3.userinfo !== void 0 || base3.host !== void 0 || base3.port !== void 0) && !base3.path) {
30056
- target2.path = "/" + relative3.path;
30056
+ target2.path = "/" + relative5.path;
30057
30057
  } else if (!base3.path) {
30058
- target2.path = relative3.path;
30058
+ target2.path = relative5.path;
30059
30059
  } else {
30060
- target2.path = base3.path.slice(0, base3.path.lastIndexOf("/") + 1) + relative3.path;
30060
+ target2.path = base3.path.slice(0, base3.path.lastIndexOf("/") + 1) + relative5.path;
30061
30061
  }
30062
30062
  target2.path = removeDotSegments(target2.path);
30063
30063
  }
30064
- target2.query = relative3.query;
30064
+ target2.query = relative5.query;
30065
30065
  }
30066
30066
  target2.userinfo = base3.userinfo;
30067
30067
  target2.host = base3.host;
@@ -30069,7 +30069,7 @@ var require_fast_uri = __commonJS({
30069
30069
  }
30070
30070
  target2.scheme = base3.scheme;
30071
30071
  }
30072
- target2.fragment = relative3.fragment;
30072
+ target2.fragment = relative5.fragment;
30073
30073
  return target2;
30074
30074
  }
30075
30075
  function equal(uriA, uriB, options) {
@@ -39238,13 +39238,13 @@ __export(codex_proxy_main_exports, {
39238
39238
  readTokenFile: () => readTokenFile,
39239
39239
  startCodexProxy: () => startCodexProxy
39240
39240
  });
39241
- import { readFileSync as readFileSync33 } from "node:fs";
39241
+ import { readFileSync as readFileSync34 } from "node:fs";
39242
39242
  import { homedir as homedir4 } from "node:os";
39243
39243
  function readTokenFile(path) {
39244
39244
  if (!path) return void 0;
39245
39245
  try {
39246
39246
  const p = path.startsWith("~/") ? `${homedir4()}${path.slice(1)}` : path;
39247
- return readFileSync33(p, "utf8").trim() || void 0;
39247
+ return readFileSync34(p, "utf8").trim() || void 0;
39248
39248
  } catch {
39249
39249
  return void 0;
39250
39250
  }
@@ -39294,13 +39294,13 @@ __export(proxy_main_exports, {
39294
39294
  readTokenFile: () => readTokenFile2,
39295
39295
  startProxy: () => startProxy
39296
39296
  });
39297
- import { readFileSync as readFileSync34 } from "node:fs";
39297
+ import { readFileSync as readFileSync35 } from "node:fs";
39298
39298
  import { homedir as homedir5 } from "node:os";
39299
39299
  function readTokenFile2(path) {
39300
39300
  if (!path) return void 0;
39301
39301
  try {
39302
39302
  const p = path.startsWith("~/") ? `${homedir5()}${path.slice(1)}` : path;
39303
- return readFileSync34(p, "utf8").trim() || void 0;
39303
+ return readFileSync35(p, "utf8").trim() || void 0;
39304
39304
  } catch {
39305
39305
  return void 0;
39306
39306
  }
@@ -39615,6 +39615,15 @@ function copy(style, bus = BUS_CMD) {
39615
39615
  next(`Install one, then run ${bus} again.`)
39616
39616
  ],
39617
39617
  restarted: () => done("Restarted the OpenCode service to load the plugin"),
39618
+ // Run from inside OpenCode, where a restart would end the session running this.
39619
+ opencodeRestartYourself: (isolated2 = false) => [
39620
+ warn(
39621
+ isolated2 ? "OpenCode was not restarted: this install is not on your account's home" : "OpenCode was not restarted: this ran inside an OpenCode session"
39622
+ ),
39623
+ next(
39624
+ isolated2 ? "To load the plugin, run on your account: opencode service restart" : "Outside OpenCode, in a terminal, run: opencode service restart"
39625
+ )
39626
+ ],
39618
39627
  // After the configured line, when PI_CODING_AGENT_DIR points both at one folder.
39619
39628
  sharedPiFile: () => next(
39620
39629
  p(
@@ -39687,6 +39696,12 @@ function copy(style, bus = BUS_CMD) {
39687
39696
  ]
39688
39697
  ),
39689
39698
  // install --no-service: the service step is skipped, nothing is started.
39699
+ // install: the bus then runs as a plain daemon (daemonRunning says so).
39700
+ serviceOtherHome: (why2, removing = false, plain3 = false) => [
39701
+ warn(
39702
+ `Skipped ${removing ? "removing " : ""}the background service: ${why2 === "home" ? "this HOME isn't your account's home" : why2 === "bus-home" ? "the bus home is outside your account's home" : "XDG_CONFIG_HOME is outside your account's home"}.${removing ? "" : plain3 ? " It never gets a background service there, so the bus runs as a plain daemon." : " Use --no-service to skip it on purpose."}`
39703
+ )
39704
+ ],
39690
39705
  serviceSkipped: () => [
39691
39706
  warn("Skipped the service, so no daemon is running."),
39692
39707
  next(`Start it with ${bus} daemon, and again after a reboot.`)
@@ -39827,7 +39842,41 @@ function copy(style, bus = BUS_CMD) {
39827
39842
  "doctor, global add|rm|list, uninstall, mcp <claude|opencode|pi|codex>"
39828
39843
  ),
39829
39844
  next("or version."),
39830
- next("install takes --no-service to skip the launchd or systemd step.")
39845
+ next(`Run ${bus} --help to list every command and flag.`)
39846
+ ],
39847
+ help: () => [
39848
+ `usage: ${bus} [command] [flags]`,
39849
+ "",
39850
+ "Commands",
39851
+ " install Approve this machine, wire your harnesses, start the daemon (the default)",
39852
+ " login Approve this machine again",
39853
+ " uninstall Remove what install added",
39854
+ " status Who is on the bus, from this folder",
39855
+ " logs The daemon log",
39856
+ " doctor Check the install and say what to fix",
39857
+ " daemon Run the daemon in this terminal",
39858
+ " global add <dir>, rm <dir> or list: folders shared across namespaces",
39859
+ " namespace approve [dir], revoke <dir> or list",
39860
+ " link <dir> <dir> or list; unlink <dir> <dir>",
39861
+ " leads check [name]",
39862
+ " mcp <claude|opencode|codex|pi>: the MCP server a harness runs",
39863
+ " version Print the version",
39864
+ " help This text",
39865
+ "",
39866
+ "Flags",
39867
+ " install --instance <url> the instance to connect to",
39868
+ " --check only report what is set up; change nothing",
39869
+ " --habits | --no-habits | --show-habits",
39870
+ " add, decline or show the always-on habit lines",
39871
+ " --no-service skip the launchd or systemd step",
39872
+ " --no-open do not open a browser for approval",
39873
+ " --json the result as one JSON line on stdout",
39874
+ " --yes, -y answer yes where install asks",
39875
+ " login --instance <url>, --no-open",
39876
+ " daemon --instance <url>",
39877
+ " uninstall --purge also delete the bus home and what install made",
39878
+ " namespace --yes, -y approve without asking (namespace approve)",
39879
+ " every command: --home <dir> (bus home), --no-color, --help, -h, --version, -v"
39831
39880
  ],
39832
39881
  skipped: (h, reason2) => [
39833
39882
  warn(
@@ -39849,8 +39898,17 @@ function copy(style, bus = BUS_CMD) {
39849
39898
  next(`${bus} --instance ${clip(askedUrl, 39)}.`)
39850
39899
  ];
39851
39900
  },
39852
- checkOk: (label) => done(label),
39853
- checkFailed: (label, action) => [fail2(label), next(action)],
39901
+ checkOk: (label, details = []) => [
39902
+ done(label),
39903
+ ...details.map((d) => next(d))
39904
+ ],
39905
+ checkFailed: (label, action, details = []) => [
39906
+ fail2(label),
39907
+ ...details.map((d) => next(d)),
39908
+ next(action)
39909
+ ],
39910
+ // One harness under the harnesses line of `install --check`.
39911
+ checkHarness: (h, state) => `${HARNESS_LABEL[h]}: ${state}`,
39854
39912
  noNamespace: () => p(
39855
39913
  "muted",
39856
39914
  "This folder has no namespace, so there is no roster to show."
@@ -40023,6 +40081,26 @@ function copy(style, bus = BUS_CMD) {
40023
40081
  `Kept the Open Artifacts plugins on ${ref ?? "their default branch"}, as you set them.`
40024
40082
  )
40025
40083
  ],
40084
+ pluginsRolledBack: (state, why2) => [
40085
+ warn(
40086
+ state === "all" ? "Put the previous Open Artifacts plugin source back, so your plugins are as they were. Run the install again to retry the move." : state === "some" ? "Put the previous Open Artifacts plugin source back, but only some of the plugins came back. Run the install again to finish." : `Couldn't put the previous plugin source back either (${why2}), so the Open Artifacts plugins are not installed. Run the install again.`
40087
+ )
40088
+ ],
40089
+ pluginsStyleCleared: () => [
40090
+ warn(
40091
+ "Turned the Artifacts Teammate output style off again, because its plugin is not installed. The install turns it back on."
40092
+ )
40093
+ ],
40094
+ pluginsLostOptions: (mcpServer) => [
40095
+ warn(
40096
+ `The shortcuts' saved server name "${mcpServer}" was lost with the removed plugins. Run: claude plugin configure open-artifacts-shortcuts and enter it again.`
40097
+ )
40098
+ ],
40099
+ pluginsAddUnknown: (why2) => [
40100
+ warn(
40101
+ `Couldn't add the plugin source (${why2}) and couldn't check what is installed, so nothing was changed back. Run the install again.`
40102
+ )
40103
+ ],
40026
40104
  pluginsBadInstance: () => [
40027
40105
  warn(
40028
40106
  "Couldn't read this instance's address, so the shortcuts don't know where your pages are yet."
@@ -40217,11 +40295,10 @@ function copy(style, bus = BUS_CMD) {
40217
40295
  p("muted", `To remove everything, run ${bus} uninstall --purge.`)
40218
40296
  ],
40219
40297
  deleted: (home2) => done(`Deleted ${clip(home2, 35)}, including machine.json`),
40220
- stillListed: (label, host) => [
40298
+ stillListed: (label, origin) => [
40221
40299
  warn(`${clip(label, 30)} is still listed on the bus`),
40222
- next(
40223
- `Revoke it in the dashboard at ${clip(host, 56)} to remove it for good.`
40224
- ),
40300
+ next("Revoke it on the machines page to remove it for good:"),
40301
+ next(clip(`${origin}/settings/machines`, 3)),
40225
40302
  next(`To use this computer again, run ${bus}.`)
40226
40303
  ],
40227
40304
  // 11. global
@@ -48391,7 +48468,16 @@ import {
48391
48468
  rmSync as rmSync6,
48392
48469
  writeFileSync as writeFileSync11
48393
48470
  } from "node:fs";
48394
- import { basename as basename6, dirname as dirname11, isAbsolute as isAbsolute8, join as join20, resolve as resolve5 } from "node:path";
48471
+ import { tmpdir } from "node:os";
48472
+ import {
48473
+ basename as basename6,
48474
+ delimiter as delimiter3,
48475
+ dirname as dirname11,
48476
+ isAbsolute as isAbsolute8,
48477
+ join as join20,
48478
+ relative as relative2,
48479
+ resolve as resolve5
48480
+ } from "node:path";
48395
48481
  import { fileURLToPath } from "node:url";
48396
48482
 
48397
48483
  // src/steps/codex.ts
@@ -49499,7 +49585,24 @@ async function checkSteps(steps, ctx) {
49499
49585
  var LAUNCHD_LABEL = "com.open-artifacts.bus";
49500
49586
  var SYSTEMD_UNIT = "oa-bus.service";
49501
49587
  var REVOKED_EXIT = 78;
49502
- var DEFAULT_PATH = "/usr/local/bin:/usr/bin:/bin";
49588
+ var transient = (dir) => dir.split(/[\\/]/).some(
49589
+ (seg) => seg === "node_modules" || seg === "_npx" || seg === "node-gyp-bin"
49590
+ );
49591
+ function servicePath(env2, execPath, platform) {
49592
+ if (platform !== "darwin" && platform !== "linux")
49593
+ return env2.PATH ?? "/usr/local/bin:/usr/bin:/bin";
49594
+ const system = [
49595
+ "/usr/local/bin",
49596
+ ...platform === "darwin" ? ["/opt/homebrew/bin"] : [],
49597
+ "/usr/bin",
49598
+ "/bin"
49599
+ ];
49600
+ const mine = (env2.PATH ?? "").split(delimiter3).filter((d) => isAbsolute8(d) && !transient(d));
49601
+ const node2 = dirname11(execPath);
49602
+ if (!mine.includes(node2) && isAbsolute8(node2) && !transient(node2))
49603
+ mine.unshift(node2);
49604
+ return [.../* @__PURE__ */ new Set([...mine, ...system])].join(delimiter3);
49605
+ }
49503
49606
  var STOP_WAIT_MS = 5e3;
49504
49607
  var POLL_MS = 250;
49505
49608
  var oneLine = (v) => {
@@ -49661,13 +49764,13 @@ function writeReplacing(path, text3) {
49661
49764
  throw e;
49662
49765
  }
49663
49766
  }
49664
- var real = (path) => {
49767
+ var real = (path, native = false) => {
49665
49768
  const abs = resolve5(path);
49666
49769
  try {
49667
- return realpathSync8(abs);
49770
+ return (native ? realpathSync8.native : realpathSync8)(abs);
49668
49771
  } catch {
49669
49772
  const parent = dirname11(abs);
49670
- return parent === abs ? abs : join20(real(parent), basename6(abs));
49773
+ return parent === abs ? abs : join20(real(parent, native), basename6(abs));
49671
49774
  }
49672
49775
  };
49673
49776
  var isDefaultHome = (home2, userHome) => real(home2) === real(join20(userHome, ".oa-bus"));
@@ -49718,6 +49821,19 @@ function systemService(d) {
49718
49821
  return r && present(r) ? r : fresh();
49719
49822
  };
49720
49823
  const installed = () => manager !== void 0 && present(file2());
49824
+ const fold = (p) => d.platform === "darwin" ? real(p, true).toLowerCase() : real(p, true);
49825
+ const insideAccount = (p) => {
49826
+ if (d.accountHome === void 0) return true;
49827
+ const r = relative2(fold(d.accountHome), fold(p));
49828
+ return r === "" || !r.startsWith("..") && !isAbsolute8(r);
49829
+ };
49830
+ const isolated2 = () => {
49831
+ if (manager === void 0 || d.accountHome === void 0) return void 0;
49832
+ const account = fold(d.accountHome);
49833
+ if (fold(d.userHome) !== account) return "home";
49834
+ if (!insideAccount(home2())) return "bus-home";
49835
+ return manager === "systemd" && !insideAccount(configHome) ? "xdg" : void 0;
49836
+ };
49721
49837
  const domain2 = `gui/${d.uid}`;
49722
49838
  const systemctl = (...args) => d.exec("systemctl", ["--user", ...args]);
49723
49839
  async function quiet() {
@@ -49727,11 +49843,11 @@ function systemService(d) {
49727
49843
  await d.sleep(POLL_MS);
49728
49844
  }
49729
49845
  }
49730
- async function stopDaemon() {
49846
+ async function stopDaemon(strict = false) {
49731
49847
  const pid = await d.daemonPid();
49732
49848
  if (pid === void 0) return void 0;
49733
49849
  const args = d.processArgs(pid);
49734
- const ours2 = args === void 0 ? record7().fallback === true && record7().pid === pid : isOurDaemon(args, entryOf());
49850
+ const ours2 = strict ? record7().fallback === true && record7().pid === pid : args === void 0 ? record7().fallback === true && record7().pid === pid : isOurDaemon(args, entryOf());
49735
49851
  if (!ours2) return pid;
49736
49852
  d.kill(pid);
49737
49853
  return quiet();
@@ -49767,10 +49883,20 @@ function systemService(d) {
49767
49883
  get kind() {
49768
49884
  return installed() ? manager : void 0;
49769
49885
  },
49886
+ get isolated() {
49887
+ return isolated2();
49888
+ },
49770
49889
  get fallback() {
49771
49890
  return !installed() && record7().fallback === true;
49772
49891
  },
49773
49892
  async ensure() {
49893
+ const skipped = isolated2();
49894
+ if (skipped && insideAccount(home2())) return { skipped, idle: true };
49895
+ if (skipped) {
49896
+ const r = relative2(fold(d.tmpDir ?? tmpdir()), fold(home2()));
49897
+ if (r === "" || !r.startsWith("..") && !isAbsolute8(r))
49898
+ return { skipped, idle: true };
49899
+ }
49774
49900
  const h = home2();
49775
49901
  const src = d.source();
49776
49902
  const logs2 = join20(h, "logs");
@@ -49778,7 +49904,7 @@ function systemService(d) {
49778
49904
  node: nodeOf(h),
49779
49905
  entry: join20(h, "bin", entryName(src)),
49780
49906
  env: {
49781
- PATH: d.env.PATH ?? DEFAULT_PATH,
49907
+ PATH: servicePath(d.env, d.execPath, d.platform),
49782
49908
  ...isDefaultHome(h, d.userHome) ? {} : { OA_BUS_HOME: h },
49783
49909
  // Attestation and wake read the Codex home this shell uses (C26e).
49784
49910
  ...codexHomeEnv(d.userHome, d.env)
@@ -49789,21 +49915,22 @@ function systemService(d) {
49789
49915
  };
49790
49916
  const unit = { ...u, env: { ...u.env, OA_BUS_SERVICE: "1" } };
49791
49917
  renderPlist(unit);
49792
- if (manager === "launchd")
49918
+ if (skipped) {
49919
+ } else if (manager === "launchd")
49793
49920
  await d.exec("launchctl", ["bootout", `${domain2}/${names2().label}`]);
49794
49921
  else if (manager === "systemd" && installed())
49795
49922
  await systemctl("stop", names2().unit);
49796
- const left = await stopDaemon();
49923
+ const left = await stopDaemon(skipped !== void 0);
49797
49924
  if (left !== void 0) return { running: left };
49798
49925
  installCli(h, src, launcherNode());
49799
49926
  mkdirSync9(logs2, { recursive: true, mode: 448 });
49800
49927
  const f = fresh();
49801
49928
  const old = recorded();
49802
- if (old && old !== f) {
49929
+ if (!skipped && old && old !== f) {
49803
49930
  if (manager === "systemd") await systemctl("disable", names2().unit);
49804
49931
  rmSync6(old, { force: true });
49805
49932
  }
49806
- const started = manager === "launchd" ? await startLaunchd(f, unit) : manager === "systemd" ? await startSystemd(f, unit) : "failed";
49933
+ const started = skipped ? "failed" : manager === "launchd" ? await startLaunchd(f, unit) : manager === "systemd" ? await startSystemd(f, unit) : "failed";
49807
49934
  if (started === "started") {
49808
49935
  updateInstallFile(installFile2(), {
49809
49936
  service: {
@@ -49817,7 +49944,8 @@ function systemService(d) {
49817
49944
  return {};
49818
49945
  }
49819
49946
  const still = await quiet();
49820
- if (still !== void 0) return { running: still };
49947
+ if (still !== void 0)
49948
+ return { running: still, ...skipped ? { skipped } : {} };
49821
49949
  const pid = d.spawnDaemon(u.node, [u.entry, "daemon"], {
49822
49950
  env: u.env,
49823
49951
  out: u.out,
@@ -49826,9 +49954,13 @@ function systemService(d) {
49826
49954
  updateInstallFile(installFile2(), {
49827
49955
  service: { fallback: true, pid }
49828
49956
  });
49829
- return {};
49957
+ return skipped ? { skipped } : {};
49830
49958
  },
49831
49959
  async remove() {
49960
+ {
49961
+ const why2 = isolated2();
49962
+ if (why2) return { skipped: why2 };
49963
+ }
49832
49964
  if (!installed()) {
49833
49965
  if (await d.daemonPid() === void 0) return {};
49834
49966
  const left2 = await stopDaemon();
@@ -49903,7 +50035,7 @@ var noService = {
49903
50035
  remove: async () => ({}),
49904
50036
  cli: () => ["oa-bus"]
49905
50037
  };
49906
- var VERSION = true ? "0.158.0" : JSON.parse(
50038
+ var VERSION = true ? "0.160.0" : JSON.parse(
49907
50039
  readFileSync16(new URL("../package.json", import.meta.url), "utf8")
49908
50040
  ).version;
49909
50041
  var which = (cmd) => {
@@ -49947,6 +50079,13 @@ var spawnDaemon = (cmd, args, opts) => {
49947
50079
  closeSync7(err);
49948
50080
  }
49949
50081
  };
50082
+ var accountHome = () => {
50083
+ try {
50084
+ return userInfo2().homedir;
50085
+ } catch {
50086
+ return void 0;
50087
+ }
50088
+ };
49950
50089
  var userName = () => {
49951
50090
  try {
49952
50091
  return userInfo2().username;
@@ -49996,6 +50135,7 @@ function realCtx(noColor) {
49996
50135
  ctx.service = systemService({
49997
50136
  platform: process.platform,
49998
50137
  userHome: ctx.userHome,
50138
+ ...accountHome() !== void 0 ? { accountHome: accountHome() } : {},
49999
50139
  home: () => ctx.home,
50000
50140
  env: env2,
50001
50141
  exec: ctx.exec,
@@ -50070,6 +50210,7 @@ var configFileLines = (ctx, files2) => files2.flatMap(
50070
50210
  restart: f.file.endsWith("/.oa-bus.json") || f.file.endsWith("/.git")
50071
50211
  })
50072
50212
  );
50213
+ var isolated = (ctx) => Boolean(ctx.service.isolated);
50073
50214
 
50074
50215
  // src/machine.ts
50075
50216
  import { readFileSync as readFileSync17, statSync as statSync8 } from "node:fs";
@@ -50150,8 +50291,8 @@ async function daemon(ctx, run5 = runDaemon, signals = process) {
50150
50291
  }
50151
50292
 
50152
50293
  // src/commands/doctor.ts
50153
- import { readFileSync as readFileSync29 } from "node:fs";
50154
- import { join as join35 } from "node:path";
50294
+ import { readFileSync as readFileSync30 } from "node:fs";
50295
+ import { join as join36 } from "node:path";
50155
50296
 
50156
50297
  // ../bus-adapter-opencode/src/index.ts
50157
50298
  init_proxy();
@@ -50176,7 +50317,7 @@ import {
50176
50317
  statSync as statSync10,
50177
50318
  writeFileSync as writeFileSync14
50178
50319
  } from "node:fs";
50179
- import { dirname as dirname15, join as join29, resolve as resolve11 } from "node:path";
50320
+ import { dirname as dirname15, isAbsolute as isAbsolute13, join as join29, relative as relative4, resolve as resolve11 } from "node:path";
50180
50321
  import { isDeepStrictEqual } from "node:util";
50181
50322
 
50182
50323
  // ../bus-adapter-hermes/src/index.ts
@@ -51863,7 +52004,7 @@ import {
51863
52004
  dirname as dirname12,
51864
52005
  isAbsolute as isAbsolute11,
51865
52006
  join as join24,
51866
- relative as relative2,
52007
+ relative as relative3,
51867
52008
  resolve as resolve6
51868
52009
  } from "node:path";
51869
52010
  var HERMES_PLUGIN_NAME = "oa-bus";
@@ -51954,7 +52095,7 @@ function hermesRoot(home2, env2, platform = process.platform) {
51954
52095
  const given = v ? tilded(home2, v) : void 0;
51955
52096
  if (given === void 0) return native;
51956
52097
  if (basename7(dirname12(given)) === "profiles") return dirname12(dirname12(given));
51957
- const rel = relative2(real2(native), real2(given));
52098
+ const rel = relative3(real2(native), real2(given));
51958
52099
  if (rel === "" || !rel.startsWith("..") && !isAbsolute11(rel)) return native;
51959
52100
  return given;
51960
52101
  }
@@ -53126,15 +53267,15 @@ function writeHabits(deps2, harnesses, opts = {}) {
53126
53267
  }
53127
53268
  const real3 = targetOf(path);
53128
53269
  try {
53129
- const exists2 = existsSync9(real3);
53130
- const before = exists2 ? readFileSync23(real3, "utf8") : "";
53270
+ const exists3 = existsSync9(real3);
53271
+ const before = exists3 ? readFileSync23(real3, "utf8") : "";
53131
53272
  const fresh = blockState(before).state === "absent";
53132
53273
  const after = withHabits(before, habitsBlock());
53133
53274
  if (after !== before) writeAtomic(real3, after);
53134
53275
  if (fresh)
53135
53276
  files_[path] = {
53136
53277
  added: separatorFor(before),
53137
- created: !exists2 && !link2
53278
+ created: !exists3 && !link2
53138
53279
  };
53139
53280
  files2.push(path);
53140
53281
  } catch (e) {
@@ -53386,11 +53527,12 @@ var probe = (path) => {
53386
53527
  };
53387
53528
  var habitsOptedOut = (busHome2) => record6(busHome2).optedOut;
53388
53529
  var setHabitsOptOut = (busHome2, optedOut, at) => saveRecord(busHome2, { optedOut, at });
53530
+ var OMP_NOTE = "omp: not supported yet";
53389
53531
  var habitsQuestion = (shownFiles, bus = BUS_CMD) => {
53390
53532
  const yes = `${bus} install --habits`;
53391
53533
  const no = `${bus} install --no-habits`;
53392
53534
  const text3 = `The bus would add ${HABITS_LINES.length} habits for sessions on the bus, to ${shownFiles.join(" and ")}:`;
53393
- return { text: text3, lines: HABITS_LINES.slice(), yes, no };
53535
+ return { text: text3, lines: HABITS_LINES.slice(), note: OMP_NOTE, yes, no };
53394
53536
  };
53395
53537
  var habitsQuestionLines = (q) => [
53396
53538
  "Installed. One question for your user before you finish:",
@@ -53398,6 +53540,7 @@ var habitsQuestionLines = (q) => [
53398
53540
  "QUESTION FOR YOUR USER (ask them; don't answer it yourself)",
53399
53541
  q.text,
53400
53542
  ...q.lines.map((l) => ` ${l}`),
53543
+ ` ${q.note}`,
53401
53544
  `Yes: ${q.yes}`,
53402
53545
  `No: ${q.no}`
53403
53546
  ];
@@ -53916,15 +54059,18 @@ function claudeProof(deps2, notes) {
53916
54059
  );
53917
54060
  }
53918
54061
  }
53919
- var ocEntryIo = (deps2) => ({
54062
+ var ocEntryIo = (deps2, touched = { changed: false }) => ({
53920
54063
  files: paths(deps2).opencodeConfigs.filter(present2),
53921
54064
  moved: paths(deps2).opencodeEntry,
53922
54065
  read: readJsonc,
53923
54066
  save: (file2, before, next, ok) => {
53924
54067
  target(file2);
53925
- saveText(file2, before, next, ok);
54068
+ if (saveText(file2, before, next, ok)) touched.changed = true;
54069
+ },
54070
+ writeMoved: (data) => {
54071
+ writeAtomic2(paths(deps2).opencodeEntry, data, 384);
54072
+ touched.changed = true;
53926
54073
  },
53927
- writeMoved: (data) => writeAtomic2(paths(deps2).opencodeEntry, data, 384),
53928
54074
  home: deps2.home,
53929
54075
  busBin: deps2.busBin,
53930
54076
  ...movedHome(deps2) ? { busHome: movedHome(deps2) } : {}
@@ -54035,9 +54181,32 @@ var codexHere = (deps2) => hasCodex({
54035
54181
  which: deps2.which,
54036
54182
  app: deps2.codexApp
54037
54183
  });
54038
- async function restartOpencode(deps2, notes) {
54184
+ var OC_RESTARTED = "opencode service restarted";
54185
+ var OC_MANUAL = "opencode restart left to the user: running inside OpenCode";
54186
+ var OC_ISOLATED = "opencode restart left to the user: isolated install";
54187
+ var insideOpencode = (deps2) => Boolean(
54188
+ deps2.env?.OPENCODE || deps2.env?.OPENCODE_TERMINAL || deps2.env?.OPENCODE_SESSION_ID
54189
+ );
54190
+ var isolatedInstall = (deps2) => {
54191
+ if (deps2.isolated) return true;
54192
+ const dir = deps2.env?.OPENCODE_CONFIG_DIR;
54193
+ if (!dir) return false;
54194
+ const rel = relative4(resolve11(deps2.home), resolve11(dir));
54195
+ return rel.startsWith("..") || isAbsolute13(rel);
54196
+ };
54197
+ async function restartOpencode(deps2, notes, changed) {
54198
+ if (!changed) return;
54199
+ if (isolatedInstall(deps2)) {
54200
+ notes.push(OC_ISOLATED);
54201
+ return;
54202
+ }
54203
+ if (insideOpencode(deps2)) {
54204
+ notes.push(OC_MANUAL);
54205
+ return;
54206
+ }
54039
54207
  const r = await run4(deps2, "opencode", ["service", "restart"]);
54040
54208
  if (r.code !== 0) notes.push(`${RESTART_FAILED}: ${firstLine3(r.stderr)}`);
54209
+ else notes.push(OC_RESTARTED);
54041
54210
  }
54042
54211
  var install = {
54043
54212
  // Claude rewrites ~/.claude.json while it runs, so its own CLI does the edit.
@@ -54117,27 +54286,33 @@ var install = {
54117
54286
  if (madeCli.length > 0)
54118
54287
  created[p.opencodeCli] = add(p.opencodeCli, madeCli);
54119
54288
  writeRecord2(p.record, record7, created);
54120
- writeAtomic2(
54121
- join29(p.opencodePlugin, "tui.js"),
54122
- withHome(deps2.assets.opencodePlugin, movedHome(deps2)),
54123
- 420
54124
- );
54125
- saveText(
54289
+ const pluginFile = join29(p.opencodePlugin, "tui.js");
54290
+ const pluginText = withHome(deps2.assets.opencodePlugin, movedHome(deps2));
54291
+ let pluginBefore;
54292
+ try {
54293
+ pluginBefore = readFileSync26(pluginFile, "utf8");
54294
+ } catch {
54295
+ }
54296
+ const touched = { changed: pluginBefore !== pluginText };
54297
+ writeAtomic2(pluginFile, pluginText, 420);
54298
+ if (saveText(
54126
54299
  configPath,
54127
54300
  config2,
54128
54301
  nextConfig,
54129
54302
  (d) => isDeepStrictEqual(servers3(d)?.[NAME2], server4)
54130
- );
54131
- saveText(p.opencodeCli, cli, nextCli, (d) => listed(d, p.opencodePlugin));
54303
+ ))
54304
+ touched.changed = true;
54305
+ if (saveText(p.opencodeCli, cli, nextCli, (d) => listed(d, p.opencodePlugin)))
54306
+ touched.changed = true;
54132
54307
  if (deps2.hub !== void 0)
54133
54308
  try {
54134
- notes.push(...installEntry2(ocEntryIo(deps2), deps2.hub).notes);
54309
+ notes.push(...installEntry2(ocEntryIo(deps2, touched), deps2.hub).notes);
54135
54310
  } catch (e) {
54136
54311
  notes.push(
54137
54312
  `could not set up the Open Artifacts entry in OpenCode's config: ${e instanceof Error ? e.message : String(e)}`
54138
54313
  );
54139
54314
  }
54140
- await restartOpencode(deps2, notes);
54315
+ await restartOpencode(deps2, notes, touched.changed);
54141
54316
  return "done";
54142
54317
  },
54143
54318
  async pi(deps2, notes) {
@@ -54209,6 +54384,12 @@ var uninstall = {
54209
54384
  `could not take the proof helper off the Claude entry: ${e instanceof Error ? e.message : String(e)}`
54210
54385
  );
54211
54386
  }
54387
+ const path = paths(deps2).claude;
54388
+ try {
54389
+ if (readDoc(path).mcpServers?.[NAME2] === void 0)
54390
+ return "none";
54391
+ } catch {
54392
+ }
54212
54393
  if (deps2.which("claude")) {
54213
54394
  const r = await run4(deps2, "claude", [
54214
54395
  "mcp",
@@ -54219,7 +54400,6 @@ var uninstall = {
54219
54400
  ]);
54220
54401
  if (r.code === 0) return "done";
54221
54402
  }
54222
- const path = paths(deps2).claude;
54223
54403
  const doc = readDoc(path);
54224
54404
  if (!save(path, doc, removeMcpServer(doc, NAME2))) return "none";
54225
54405
  notes.push(`removed oa_bus from ${path} directly`);
@@ -54262,7 +54442,7 @@ var uninstall = {
54262
54442
  const hadPlugin = existsSync12(p.opencodePlugin);
54263
54443
  rmSync14(p.opencodePlugin, { recursive: true, force: true });
54264
54444
  if (!saved.some(Boolean) && !hadPlugin && !restored) return "none";
54265
- if (deps2.which("opencode")) await restartOpencode(deps2, notes);
54445
+ if (deps2.which("opencode")) await restartOpencode(deps2, notes, true);
54266
54446
  return saved.some(Boolean) || restored ? "done" : "folder";
54267
54447
  },
54268
54448
  async pi(deps2, notes) {
@@ -54342,7 +54522,7 @@ async function each(steps, deps2, notes) {
54342
54522
  }
54343
54523
  var unshownNotes = (notes) => notes.filter(
54344
54524
  (n) => n !== CODEX_NO_BIN && n !== HERMES_NO_CLI && n !== OPENCLAW_NO_CLI && n !== OPENCLAW_NIX && // The service line says it, and the removal is already in "Removed from".
54345
- !n.startsWith(RESTART_FAILED) && !n.startsWith("removed oa_bus from ")
54525
+ n !== OC_RESTARTED && n !== OC_MANUAL && n !== OC_ISOLATED && !n.startsWith(RESTART_FAILED) && !n.startsWith("removed oa_bus from ")
54346
54526
  );
54347
54527
  async function installAdapters(deps2) {
54348
54528
  const notes = [];
@@ -54352,7 +54532,9 @@ async function installAdapters(deps2) {
54352
54532
  absent,
54353
54533
  skipped,
54354
54534
  notes,
54355
- opencodeRestarted: done.includes("opencode") && !notes.some((n) => n.startsWith(RESTART_FAILED)),
54535
+ opencodeRestarted: notes.includes(OC_RESTARTED),
54536
+ opencodeRestartByUser: notes.includes(OC_MANUAL) || notes.includes(OC_ISOLATED),
54537
+ opencodeIsolated: notes.includes(OC_ISOLATED),
54356
54538
  ...done.includes("pi") && done.includes("omp") && sharedFile(deps2) ? { sharedPiFile: paths(deps2).pi } : {},
54357
54539
  codexNoWake: done.includes("codex") && notes.includes(CODEX_NO_BIN),
54358
54540
  hermesRestart: done.includes("hermes"),
@@ -54368,7 +54550,9 @@ async function uninstallAdapters(deps2) {
54368
54550
  folderOnly: folder,
54369
54551
  skipped,
54370
54552
  notes,
54371
- opencodeRestarted: [...done, ...folder].includes("opencode") && deps2.which("opencode") && !notes.some((n) => n.startsWith(RESTART_FAILED)),
54553
+ opencodeRestarted: notes.includes(OC_RESTARTED),
54554
+ opencodeRestartByUser: notes.includes(OC_MANUAL) || notes.includes(OC_ISOLATED),
54555
+ opencodeIsolated: notes.includes(OC_ISOLATED),
54372
54556
  hermesNoCli: notes.includes(HERMES_NO_CLI),
54373
54557
  openclawNoCli: notes.includes(OPENCLAW_NO_CLI),
54374
54558
  openclawNix: notes.includes(OPENCLAW_NIX)
@@ -54666,6 +54850,12 @@ function uninstallOutputStyle(deps2) {
54666
54850
  if (gone || setByUs(deps2)) turnOff(deps2, out);
54667
54851
  return out;
54668
54852
  }
54853
+ function clearOutputStyleIfOurs(deps2) {
54854
+ const out = { written: [], notes: [] };
54855
+ if (!setByUs(deps2)) return { ...out, cleared: false };
54856
+ turnOff(deps2, out);
54857
+ return { ...out, cleared: !outputStyleOn(deps2) };
54858
+ }
54669
54859
  function setByUs(deps2) {
54670
54860
  try {
54671
54861
  const rec = deps2.busHome ? readRecord3(deps2.busHome) : void 0;
@@ -54675,6 +54865,10 @@ function setByUs(deps2) {
54675
54865
  return false;
54676
54866
  }
54677
54867
  }
54868
+ var outputStyleOn = (deps2) => {
54869
+ const s = readSettings(claudeSettingsFile(deps2));
54870
+ return s.ok && s.style === OUTPUT_STYLE_PLUGIN_NAME;
54871
+ };
54678
54872
  var outputStyleState = (deps2) => {
54679
54873
  const path = outputStyleFile(deps2);
54680
54874
  try {
@@ -54830,6 +55024,56 @@ async function installClaudePlugins(deps2, harnesses) {
54830
55024
  "--json"
54831
55025
  ]);
54832
55026
  let marketplace = prior?.marketplace ?? false;
55027
+ let repinned = false;
55028
+ const clearStyle = () => {
55029
+ const cleared = clearOutputStyleIfOurs({
55030
+ home: deps2.home,
55031
+ env: deps2.env,
55032
+ busHome: deps2.busHome
55033
+ });
55034
+ out.notes.push(...cleared.notes);
55035
+ if (cleared.cleared) out.notes.push(...copy2.pluginsStyleCleared());
55036
+ };
55037
+ const noteLost = (opts) => {
55038
+ if (opts?.mcpServer && opts.mcpServer !== DEFAULT_MCP_SERVER)
55039
+ out.notes.push(...copy2.pluginsLostOptions(opts.mcpServer));
55040
+ };
55041
+ const rollBack = async (ids, oldRef, opts) => {
55042
+ const back = await claude(exec3, [
55043
+ "plugin",
55044
+ "marketplace",
55045
+ "add",
55046
+ oldRef ? `${PLUGIN_REPO_URL}#${oldRef}` : PLUGIN_REPO_URL,
55047
+ "--sparse",
55048
+ ...SPARSE,
55049
+ "--json"
55050
+ ]);
55051
+ if (!back.ok) {
55052
+ if (await recordIfLanded([]) === void 0)
55053
+ saveRecord2(deps2.busHome, true, []);
55054
+ out.notes.push(...copy2.pluginsRolledBack("none", back.message));
55055
+ noteLost(opts);
55056
+ clearStyle();
55057
+ return;
55058
+ }
55059
+ const restored = [];
55060
+ for (const id of ids) {
55061
+ const cfg = [];
55062
+ if (id === SHORTCUTS_PLUGIN) {
55063
+ if (opts?.instanceUrl)
55064
+ cfg.push("--config", `instanceUrl=${opts.instanceUrl}`);
55065
+ if (opts?.mcpServer)
55066
+ cfg.push("--config", `mcpServer=${opts.mcpServer}`);
55067
+ }
55068
+ const i = await claude(exec3, ["plugin", "install", id, ...cfg, "--json"]);
55069
+ if (i.ok) restored.push(id);
55070
+ else out.notes.push(...copy2.pluginsFailed(`reinstall ${id}`, i.message));
55071
+ }
55072
+ saveRecord2(deps2.busHome, true, restored);
55073
+ const all = restored.length === ids.length;
55074
+ out.notes.push(...copy2.pluginsRolledBack(all ? "all" : "some", ""));
55075
+ if (!restored.includes(STYLE_PLUGIN)) clearStyle();
55076
+ };
54833
55077
  const recordIfLanded = async (plugins2) => {
54834
55078
  const again = await claude(exec3, [
54835
55079
  "plugin",
@@ -54837,8 +55081,12 @@ async function installClaudePlugins(deps2, harnesses) {
54837
55081
  "list",
54838
55082
  "--json"
54839
55083
  ]);
54840
- const landed = again.ok && Array.isArray(again.data) && again.data.some((m) => m.name === MARKETPLACE && isOurs3(m));
55084
+ if (!again.ok || !Array.isArray(again.data)) return void 0;
55085
+ const landed = again.data.some(
55086
+ (m) => m.name === MARKETPLACE && isOurs3(m)
55087
+ );
54841
55088
  if (landed) saveRecord2(deps2.busHome, true, plugins2);
55089
+ return landed;
54842
55090
  };
54843
55091
  let saved;
54844
55092
  if (!there) {
@@ -54869,26 +55117,59 @@ async function installClaudePlugins(deps2, harnesses) {
54869
55117
  out.notes.push(
54870
55118
  ...copy2.pluginsFailed("move the plugin source", gone.message)
54871
55119
  );
55120
+ const now = await listInstalled(exec3);
55121
+ if (now !== void 0)
55122
+ saveRecord2(
55123
+ deps2.busHome,
55124
+ true,
55125
+ (prior?.plugins ?? []).filter((id) => now.includes(id))
55126
+ );
55127
+ if (now === void 0 || !now.includes(STYLE_PLUGIN)) clearStyle();
54872
55128
  return out;
54873
55129
  }
55130
+ repinned = true;
54874
55131
  writeRecord4(deps2.busHome, void 0);
54875
55132
  prior = void 0;
54876
55133
  marketplace = false;
54877
55134
  const r = await addSource();
54878
55135
  if (!r.ok) {
54879
- await recordIfLanded([]);
54880
- out.notes.push(
54881
- ...copy2.pluginsFailed("add the plugin source", r.message)
54882
- );
54883
- return out;
55136
+ const landed = await recordIfLanded([]);
55137
+ if (landed === void 0) {
55138
+ out.notes.push(...copy2.pluginsAddUnknown(r.message));
55139
+ saveRecord2(deps2.busHome, true, []);
55140
+ noteLost(saved);
55141
+ clearStyle();
55142
+ return out;
55143
+ }
55144
+ if (!landed) {
55145
+ out.notes.push(
55146
+ ...copy2.pluginsFailed("add the plugin source", r.message)
55147
+ );
55148
+ await rollBack(fromIt, there.ref, saved);
55149
+ return out;
55150
+ }
54884
55151
  }
54885
55152
  marketplace = true;
54886
55153
  }
54887
55154
  }
55155
+ if (there && !wantRef && !there.ref) {
55156
+ const u = await claude(exec3, [
55157
+ "plugin",
55158
+ "marketplace",
55159
+ "update",
55160
+ MARKETPLACE,
55161
+ "--json"
55162
+ ]);
55163
+ if (!u.ok)
55164
+ out.notes.push(
55165
+ ...copy2.pluginsFailed("refresh the plugin source", u.message)
55166
+ );
55167
+ }
54888
55168
  const before = await listInstalled(exec3);
54889
55169
  if (before === void 0) {
54890
55170
  out.notes.push(...copy2.pluginsFailed("list the plugins", "no list"));
54891
55171
  saveRecord2(deps2.busHome, marketplace, prior?.plugins ?? []);
55172
+ if (repinned) clearStyle();
54892
55173
  return out;
54893
55174
  }
54894
55175
  const mine = new Set(prior?.plugins ?? []);
@@ -54956,6 +55237,7 @@ async function installClaudePlugins(deps2, harnesses) {
54956
55237
  }
54957
55238
  }
54958
55239
  saveRecord2(deps2.busHome, marketplace, [...mine]);
55240
+ if (!live.has(STYLE_PLUGIN) && !before.includes(STYLE_PLUGIN)) clearStyle();
54959
55241
  if (live.has(STYLE_PLUGIN)) {
54960
55242
  try {
54961
55243
  const style = selectOutputStyle({
@@ -55168,7 +55450,8 @@ function disclosure(ctx, pending) {
55168
55450
  if (changed.length === 0)
55169
55451
  return [
55170
55452
  `The bus would add ${HABITS_LINES.length} habits for sessions on the bus, to ${files2.join(" and ")}:`,
55171
- ...HABITS_LINES.map((l) => ` ${l}`)
55453
+ ...HABITS_LINES.map((l) => ` ${l}`),
55454
+ ` ${OMP_NOTE}`
55172
55455
  ];
55173
55456
  const first = changed[0]?.s;
55174
55457
  return [
@@ -55527,7 +55810,7 @@ init_src();
55527
55810
 
55528
55811
  // src/commands/install.ts
55529
55812
  init_src3();
55530
- import { dirname as dirname17, join as join34 } from "node:path";
55813
+ import { dirname as dirname17, join as join35 } from "node:path";
55531
55814
  init_src2();
55532
55815
 
55533
55816
  // src/live.ts
@@ -55576,6 +55859,104 @@ function spinner(ctx) {
55576
55859
  };
55577
55860
  }
55578
55861
 
55862
+ // src/steps/leftovers.ts
55863
+ import {
55864
+ lstatSync as lstatSync17,
55865
+ readdirSync as readdirSync10,
55866
+ readFileSync as readFileSync29,
55867
+ rmdirSync as rmdirSync4,
55868
+ rmSync as rmSync17
55869
+ } from "node:fs";
55870
+ import { join as join34 } from "node:path";
55871
+ function leftoverTargets(deps2) {
55872
+ const env2 = deps2.env ?? {};
55873
+ const p = paths(deps2);
55874
+ const piDir = agentDirEnv(deps2.home, env2) ?? join34(deps2.home, ".pi/agent");
55875
+ const skill = (h) => skillDir({ home: deps2.home, env: env2 }, h);
55876
+ return {
55877
+ files: [
55878
+ join34(codexHome2(deps2.home, env2), "AGENTS.md"),
55879
+ p.codex,
55880
+ ...p.opencodeConfigs,
55881
+ p.opencodeCli
55882
+ ],
55883
+ dirs: [
55884
+ skill("claude"),
55885
+ skill("pi"),
55886
+ skill("hermes"),
55887
+ join34(hermesHome(deps2.home, env2), "plugins"),
55888
+ join34(deps2.home, ".local", "bin"),
55889
+ join34(ompAgentDir(deps2.home, env2), "extensions"),
55890
+ join34(piDir, "extensions"),
55891
+ skill("opencode"),
55892
+ skill("openclaw")
55893
+ ]
55894
+ };
55895
+ }
55896
+ var exists2 = (path) => {
55897
+ try {
55898
+ lstatSync17(path);
55899
+ return true;
55900
+ } catch {
55901
+ return false;
55902
+ }
55903
+ };
55904
+ var madeOf = (installFile2) => {
55905
+ const v = readInstallFile(installFile2).made;
55906
+ return Array.isArray(v) ? v.filter((x) => typeof x === "string") : [];
55907
+ };
55908
+ function noteMade(deps2) {
55909
+ const file2 = paths(deps2).record;
55910
+ const t = leftoverTargets(deps2);
55911
+ const before = madeOf(file2);
55912
+ const made = [
55913
+ .../* @__PURE__ */ new Set([
55914
+ ...before,
55915
+ ...[...t.files, ...t.dirs].filter((x) => !exists2(x))
55916
+ ])
55917
+ ];
55918
+ if (made.length === before.length) return;
55919
+ updateInstallFile(file2, { made });
55920
+ }
55921
+ function pruneMade(deps2) {
55922
+ const file2 = paths(deps2).record;
55923
+ const before = madeOf(file2);
55924
+ if (!Array.isArray(readInstallFile(file2).made)) return;
55925
+ const made = before.filter(exists2);
55926
+ if (made.length === before.length) return;
55927
+ updateInstallFile(file2, { made });
55928
+ }
55929
+ function emptyFile(path) {
55930
+ try {
55931
+ const st = lstatSync17(path);
55932
+ if (!st.isFile()) return false;
55933
+ if (st.size === 0) return true;
55934
+ const doc = JSON.parse(readFileSync29(path, "utf8"));
55935
+ return typeof doc === "object" && doc !== null && !Array.isArray(doc) && Object.keys(doc).length === 0;
55936
+ } catch {
55937
+ return false;
55938
+ }
55939
+ }
55940
+ var readMade = (installFile2) => madeOf(installFile2);
55941
+ function removeMade(made) {
55942
+ const gone = [];
55943
+ for (const path of made) {
55944
+ if (!emptyFile(path)) continue;
55945
+ rmSync17(path, { force: true });
55946
+ gone.push(path);
55947
+ }
55948
+ for (const path of made.filter((x) => !gone.includes(x)).sort((a, b) => b.length - a.length)) {
55949
+ try {
55950
+ if (!lstatSync17(path).isDirectory()) continue;
55951
+ if (readdirSync10(path).length > 0) continue;
55952
+ rmdirSync4(path);
55953
+ gone.push(path);
55954
+ } catch {
55955
+ }
55956
+ }
55957
+ return gone;
55958
+ }
55959
+
55579
55960
  // src/commands/install.ts
55580
55961
  var CODE_RETRY_MS = [2e3, 4e3, 8e3];
55581
55962
  var DAEMON_WAIT_MS = 1e4;
@@ -55656,7 +56037,7 @@ async function loginStep(ctx, opts) {
55656
56037
  ctx,
55657
56038
  c.approved(result.label),
55658
56039
  c.tokenSaved(
55659
- tilde(ctx, join34(ctx.home, "machine.json")),
56040
+ tilde(ctx, join35(ctx.home, "machine.json")),
55660
56041
  result.machineToken
55661
56042
  ),
55662
56043
  c.connected(originOf3(result.hub)),
@@ -55697,7 +56078,8 @@ async function harnessesStep(ctx, hub) {
55697
56078
  assets: readAssets(),
55698
56079
  which: ctx.which,
55699
56080
  exec: ctx.exec,
55700
- codexApp: ctx.codexApp
56081
+ codexApp: ctx.codexApp,
56082
+ isolated: isolated(ctx)
55701
56083
  });
55702
56084
  if (out.installed.length > 0) say(ctx, c.configured(out.installed));
55703
56085
  else if (out.skipped.length === 0) say(ctx, c.noHarness());
@@ -55709,8 +56091,13 @@ async function harnessesStep(ctx, hub) {
55709
56091
  for (const n of unshownNotes(out.notes)) say(ctx, [n]);
55710
56092
  for (const s of out.skipped)
55711
56093
  say(ctx, await skippedLines(ctx, s.harness, s.reason));
55712
- if (out.installed.includes("opencode"))
55713
- say(ctx, out.opencodeRestarted ? c.restarted() : c.opencodeNotRunning());
56094
+ if (out.installed.includes("opencode")) {
56095
+ if (out.opencodeRestartByUser)
56096
+ say(ctx, c.opencodeRestartYourself(out.opencodeIsolated));
56097
+ else if (out.opencodeRestarted) say(ctx, c.restarted());
56098
+ else if (out.notes.some((n) => n.startsWith("opencode service restart failed")))
56099
+ say(ctx, c.opencodeNotRunning());
56100
+ }
55714
56101
  const codexVersion = out.installed.includes("codex") ? await readCodexVersion({
55715
56102
  configFile: codexBinFile(ctx.home),
55716
56103
  exec: ctx.exec,
@@ -55779,7 +56166,7 @@ function shownSocket(ctx) {
55779
56166
  const real3 = `${canonicalHome(ctx.home)}/`;
55780
56167
  return tilde(
55781
56168
  ctx,
55782
- path.startsWith(real3) ? join34(ctx.home, path.slice(real3.length)) : path
56169
+ path.startsWith(real3) ? join35(ctx.home, path.slice(real3.length)) : path
55783
56170
  );
55784
56171
  }
55785
56172
  async function waitForDaemon(ctx) {
@@ -55807,7 +56194,9 @@ async function daemonStep(ctx, noService2 = false) {
55807
56194
  say(ctx, roster(ctx, st2), "", c.statusHint());
55808
56195
  return true;
55809
56196
  }
55810
- const { running } = await ctx.service.ensure();
56197
+ const { running, skipped, idle } = await ctx.service.ensure();
56198
+ if (skipped) say(ctx, c.serviceOtherHome(skipped, false, !idle));
56199
+ if (idle) return daemonStep(ctx, true);
55811
56200
  if (running !== void 0) {
55812
56201
  sayErr(ctx, c.daemonInTheWay(shownSocket(ctx), running));
55813
56202
  return false;
@@ -55858,6 +56247,32 @@ function roster(ctx, st) {
55858
56247
  const ns = st.namespaces.find((n) => n.namespace === st.namespace);
55859
56248
  return ns ? rosters(ctx, [ns]) : [ctx.copy.noNamespace()];
55860
56249
  }
56250
+ var BAD = /* @__PURE__ */ new Set(["missing", "disabled", "not loaded"]);
56251
+ async function harnessStates(ctx) {
56252
+ const wiring = checkAdapters({
56253
+ home: ctx.userHome,
56254
+ busHome: ctx.home,
56255
+ env: ctx.env,
56256
+ which: ctx.which,
56257
+ codexApp: ctx.codexApp,
56258
+ busBin: ctx.service.argv?.()
56259
+ });
56260
+ if (wiring.hermes === "configured" && !await hermesEnabled({
56261
+ home: ctx.userHome,
56262
+ env: ctx.env,
56263
+ exec: ctx.exec
56264
+ }))
56265
+ wiring.hermes = "disabled";
56266
+ if (wiring.openclaw === "configured" && await openclawVerify({
56267
+ home: ctx.userHome,
56268
+ env: ctx.env,
56269
+ exec: ctx.exec
56270
+ }) !== void 0)
56271
+ wiring.openclaw = "not loaded";
56272
+ return Object.fromEntries(
56273
+ Object.entries(wiring).filter(([, st]) => st !== "absent")
56274
+ );
56275
+ }
55861
56276
  var installSteps = (opts, bus = BUS_CMD) => [
55862
56277
  {
55863
56278
  name: "login",
@@ -55876,28 +56291,8 @@ var installSteps = (opts, bus = BUS_CMD) => [
55876
56291
  failed: "Harnesses not configured",
55877
56292
  action: `Run ${bus} to configure them.`,
55878
56293
  check: async (ctx) => {
55879
- const wiring = checkAdapters({
55880
- home: ctx.userHome,
55881
- busHome: ctx.home,
55882
- env: ctx.env,
55883
- which: ctx.which,
55884
- codexApp: ctx.codexApp,
55885
- busBin: ctx.service.argv?.()
55886
- });
55887
- if (Object.values(wiring).includes("missing")) return "todo";
55888
- if (wiring.hermes === "configured" && !await hermesEnabled({
55889
- home: ctx.userHome,
55890
- env: ctx.env,
55891
- exec: ctx.exec
55892
- }))
55893
- return "todo";
55894
- if (wiring.openclaw === "configured" && await openclawVerify({
55895
- home: ctx.userHome,
55896
- env: ctx.env,
55897
- exec: ctx.exec
55898
- }) !== void 0)
55899
- return "todo";
55900
- return "done";
56294
+ const states = await harnessStates(ctx);
56295
+ return Object.values(states).some((st) => BAD.has(st)) ? "todo" : "done";
55901
56296
  },
55902
56297
  apply: (ctx) => harnessesStep(ctx, opts.hub)
55903
56298
  },
@@ -55943,6 +56338,26 @@ function reportShim(ctx) {
55943
56338
  }
55944
56339
  }
55945
56340
  async function install2(opts, realCtx2) {
56341
+ if (opts.check || opts.habits) return installRun(opts, realCtx2);
56342
+ const deps2 = {
56343
+ home: realCtx2.userHome,
56344
+ busHome: realCtx2.home,
56345
+ env: realCtx2.env
56346
+ };
56347
+ try {
56348
+ noteMade(deps2);
56349
+ } catch {
56350
+ }
56351
+ try {
56352
+ return await installRun(opts, realCtx2);
56353
+ } finally {
56354
+ try {
56355
+ pruneMade(deps2);
56356
+ } catch {
56357
+ }
56358
+ }
56359
+ }
56360
+ async function installRun(opts, realCtx2) {
55946
56361
  if (opts.habits) return habitsCommand(opts.habits, realCtx2);
55947
56362
  const json4 = Boolean(opts.json && !opts.check);
55948
56363
  const ctx = json4 ? { ...realCtx2, stdout: realCtx2.stderr } : realCtx2;
@@ -55952,13 +56367,17 @@ async function install2(opts, realCtx2) {
55952
56367
  if (opts.check) {
55953
56368
  const results = await checkSteps(steps, ctx);
55954
56369
  for (const { step: step2, state } of results) {
55955
- if (state === "done") say(ctx, c.checkOk(step2.label));
55956
- else sayErr(ctx, c.checkFailed(step2.failed, step2.action));
56370
+ const states = step2.name === "harnesses" ? await harnessStates(ctx) : {};
56371
+ const details = Object.entries(states).map(
56372
+ ([h, st]) => c.checkHarness(h, st)
56373
+ );
56374
+ if (state === "done") say(ctx, c.checkOk(step2.label, details));
56375
+ else sayErr(ctx, c.checkFailed(step2.failed, step2.action, details));
55957
56376
  }
55958
56377
  return results.every((r) => r.state === "done") ? 0 : 1;
55959
56378
  }
55960
56379
  const ok = await runSteps(steps, ctx, {
55961
- path: join34(ctx.home, "install.json"),
56380
+ path: join35(ctx.home, "install.json"),
55962
56381
  now: ctx.now
55963
56382
  });
55964
56383
  if (ok) {
@@ -56150,7 +56569,7 @@ async function healthz(ctx, hub) {
56150
56569
  function claudeIsolates(path) {
56151
56570
  let text3;
56152
56571
  try {
56153
- text3 = readFileSync29(path, "utf8");
56572
+ text3 = readFileSync30(path, "utf8");
56154
56573
  } catch {
56155
56574
  return void 0;
56156
56575
  }
@@ -56226,7 +56645,7 @@ async function doctor(ctx) {
56226
56645
  const node2 = ctx.nodeVersion.replace(/^v/, "");
56227
56646
  if (Number(node2.split(".")[0]) >= MIN_NODE) pass(c.nodeOk(node2));
56228
56647
  else fail2(c.nodeOld(node2));
56229
- const machineFile = tilde(ctx, join35(ctx.home, "machine.json"));
56648
+ const machineFile = tilde(ctx, join36(ctx.home, "machine.json"));
56230
56649
  const m = readMachine(ctx.home);
56231
56650
  if (m.state !== "ok") fail2(c.noCredentials(machineFile));
56232
56651
  else if (m.revoked) fail2(c.revokedCheck());
@@ -56313,8 +56732,8 @@ async function doctor(ctx) {
56313
56732
  pass(c.wired(h, version2));
56314
56733
  else fail2(c.notWired(h));
56315
56734
  if (h === "claude") {
56316
- const settings = join35(
56317
- ctx.env.CLAUDE_CONFIG_DIR ?? join35(ctx.userHome, ".claude"),
56735
+ const settings = join36(
56736
+ ctx.env.CLAUDE_CONFIG_DIR ?? join36(ctx.userHome, ".claude"),
56318
56737
  "settings.json"
56319
56738
  );
56320
56739
  const isolates = claudeIsolates(settings);
@@ -56464,12 +56883,12 @@ async function global(opts, ctx) {
56464
56883
  }
56465
56884
 
56466
56885
  // src/commands/leads.ts
56467
- import { readFileSync as readFileSync30 } from "node:fs";
56468
- import { join as join36 } from "node:path";
56886
+ import { readFileSync as readFileSync31 } from "node:fs";
56887
+ import { join as join37 } from "node:path";
56469
56888
  function hubOrigin(ctx) {
56470
56889
  try {
56471
56890
  const raw = JSON.parse(
56472
- readFileSync30(join36(ctx.home, "machine.json"), "utf8")
56891
+ readFileSync31(join37(ctx.home, "machine.json"), "utf8")
56473
56892
  );
56474
56893
  return typeof raw?.hub === "string" ? new URL(raw.hub).origin : void 0;
56475
56894
  } catch {
@@ -56627,9 +57046,9 @@ import {
56627
57046
  constants as constants6,
56628
57047
  fstatSync as fstatSync5,
56629
57048
  openSync as openSync9,
56630
- readFileSync as readFileSync31
57049
+ readFileSync as readFileSync32
56631
57050
  } from "node:fs";
56632
- import { join as join37 } from "node:path";
57051
+ import { join as join38 } from "node:path";
56633
57052
  var TAIL = 50;
56634
57053
  var tail = (path) => {
56635
57054
  let fd;
@@ -56639,7 +57058,7 @@ var tail = (path) => {
56639
57058
  constants6.O_RDONLY | constants6.O_NOFOLLOW | constants6.O_NONBLOCK
56640
57059
  );
56641
57060
  if (!fstatSync5(fd).isFile()) return "skipped";
56642
- return readFileSync31(fd, "utf8").replace(/\n$/, "").split("\n").slice(-TAIL);
57061
+ return readFileSync32(fd, "utf8").replace(/\n$/, "").split("\n").slice(-TAIL);
56643
57062
  } catch (e) {
56644
57063
  return e.code === "ELOOP" ? "skipped" : void 0;
56645
57064
  } finally {
@@ -56647,8 +57066,8 @@ var tail = (path) => {
56647
57066
  }
56648
57067
  };
56649
57068
  async function logs(ctx) {
56650
- const path = join37(ctx.home, "logs", "daemon.log");
56651
- const eventsPath = join37(ctx.home, "logs", "events.log");
57069
+ const path = join38(ctx.home, "logs", "daemon.log");
57070
+ const eventsPath = join38(ctx.home, "logs", "events.log");
56652
57071
  const show2 = (p, t) => t === "skipped" ? [`skipped ${tilde(ctx, p)}: not a regular file`] : t;
56653
57072
  const daemon2 = tail(path);
56654
57073
  const events = tail(eventsPath);
@@ -56683,7 +57102,7 @@ init_src2();
56683
57102
  init_src();
56684
57103
  import { execFileSync as execFileSync7 } from "node:child_process";
56685
57104
  import { createHash as createHash9, randomBytes as randomBytes8 } from "node:crypto";
56686
- import { readFileSync as readFileSync32, readlinkSync as readlinkSync6 } from "node:fs";
57105
+ import { readFileSync as readFileSync33, readlinkSync as readlinkSync6 } from "node:fs";
56687
57106
  import { basename as basename8 } from "node:path";
56688
57107
  var isClaude = (name) => name === "claude" || /\/claude\/versions\/[^/]+$/.test(name);
56689
57108
  function parsePs(out) {
@@ -56694,14 +57113,14 @@ function parsePs(out) {
56694
57113
  }
56695
57114
  function readProc(pid) {
56696
57115
  try {
56697
- const stat = readFileSync32(`/proc/${pid}/stat`, "utf8");
57116
+ const stat = readFileSync33(`/proc/${pid}/stat`, "utf8");
56698
57117
  const ppid = Number(stat.slice(stat.lastIndexOf(")") + 1).split(/\s+/)[2]);
56699
57118
  let exe = "";
56700
57119
  try {
56701
57120
  exe = readlinkSync6(`/proc/${pid}/exe`);
56702
57121
  } catch {
56703
57122
  }
56704
- const comm = readFileSync32(`/proc/${pid}/comm`, "utf8").trim();
57123
+ const comm = readFileSync33(`/proc/${pid}/comm`, "utf8").trim();
56705
57124
  return { ppid, name: isClaude(exe) ? exe : comm };
56706
57125
  } catch {
56707
57126
  }
@@ -56729,7 +57148,7 @@ function findClaude(from, proc) {
56729
57148
  function tokenOf(file2) {
56730
57149
  if (!file2) return void 0;
56731
57150
  try {
56732
- return readFileSync32(file2, "utf8").trim() || void 0;
57151
+ return readFileSync33(file2, "utf8").trim() || void 0;
56733
57152
  } catch {
56734
57153
  return void 0;
56735
57154
  }
@@ -56758,7 +57177,7 @@ async function mcpProof(opts, ctx, deps2 = {
56758
57177
 
56759
57178
  // src/commands/namespace.ts
56760
57179
  import { realpathSync as realpathSync14, statSync as statSync13 } from "node:fs";
56761
- import { join as join38, resolve as resolve14 } from "node:path";
57180
+ import { join as join39, resolve as resolve14 } from "node:path";
56762
57181
  init_src();
56763
57182
  function shown4(ctx, path) {
56764
57183
  const t = tilde(ctx, path);
@@ -56812,7 +57231,7 @@ async function namespace(opts, ctx) {
56812
57231
  sayErr(ctx, c.nsNotDir(shown4(ctx, real3 ?? given)));
56813
57232
  return 1;
56814
57233
  }
56815
- const cfgFile = join38(real3, CONFIG_FILE);
57234
+ const cfgFile = join39(real3, CONFIG_FILE);
56816
57235
  const own2 = readOwnFile(cfgFile, process.getuid?.(), {
56817
57236
  allowGroupWrite: true
56818
57237
  });
@@ -56886,12 +57305,12 @@ async function namespace(opts, ctx) {
56886
57305
  }
56887
57306
 
56888
57307
  // src/commands/uninstall.ts
56889
- import { join as join40 } from "node:path";
57308
+ import { join as join41 } from "node:path";
56890
57309
 
56891
57310
  // src/steps/purge.ts
56892
57311
  init_src3();
56893
- import { lstatSync as lstatSync17, readdirSync as readdirSync10, rmdirSync as rmdirSync4, rmSync as rmSync17 } from "node:fs";
56894
- import { join as join39 } from "node:path";
57312
+ import { lstatSync as lstatSync18, readdirSync as readdirSync11, rmdirSync as rmdirSync5, rmSync as rmSync18 } from "node:fs";
57313
+ import { join as join40 } from "node:path";
56895
57314
  var FILES = [
56896
57315
  "machine.json",
56897
57316
  "install.json",
@@ -56924,16 +57343,16 @@ var FOLDERS = [
56924
57343
  ];
56925
57344
  function kind3(path) {
56926
57345
  try {
56927
- const st = lstatSync17(path);
57346
+ const st = lstatSync18(path);
56928
57347
  return st.isDirectory() ? "dir" : st.isSocket() ? "socket" : "other";
56929
57348
  } catch {
56930
57349
  return void 0;
56931
57350
  }
56932
57351
  }
56933
- var remove2 = (path, k) => rmSync17(path, { recursive: k === "dir", force: true });
57352
+ var remove2 = (path, k) => rmSync18(path, { recursive: k === "dir", force: true });
56934
57353
  var rmdirIfEmpty = (path) => {
56935
57354
  try {
56936
- rmdirSync4(path);
57355
+ rmdirSync5(path);
56937
57356
  return true;
56938
57357
  } catch {
56939
57358
  return false;
@@ -56941,14 +57360,14 @@ var rmdirIfEmpty = (path) => {
56941
57360
  };
56942
57361
  function purgeShort(dir, removed) {
56943
57362
  if (kind3(dir) !== "dir" || unsafeSocketDir(dir)) return;
56944
- const ret = join39(dir, "claude-return");
57363
+ const ret = join40(dir, "claude-return");
56945
57364
  for (const [d, ours2] of [
56946
57365
  [ret, (_n, p) => kind3(p) === "socket"],
56947
57366
  [dir, (n) => /^daemon\.sock(\.keep-\d+)?$/.test(n)]
56948
57367
  ]) {
56949
57368
  if (kind3(d) !== "dir") continue;
56950
- for (const name of readdirSync10(d)) {
56951
- const path = join39(d, name);
57369
+ for (const name of readdirSync11(d)) {
57370
+ const path = join40(d, name);
56952
57371
  const k = kind3(path);
56953
57372
  if (k === void 0 || k === "dir" || !ours2(name, path)) continue;
56954
57373
  remove2(path, k);
@@ -56961,7 +57380,7 @@ function purgeShort(dir, removed) {
56961
57380
  function purge(home2, opts) {
56962
57381
  let entries;
56963
57382
  try {
56964
- entries = readdirSync10(home2);
57383
+ entries = readdirSync11(home2);
56965
57384
  } catch {
56966
57385
  return { removed: [], leftDir: false };
56967
57386
  }
@@ -56973,21 +57392,21 @@ function purge(home2, opts) {
56973
57392
  ...FILES,
56974
57393
  ...entries.filter((n) => TEMP.some((re) => re.test(n)))
56975
57394
  ]) {
56976
- const path = join39(home2, name);
57395
+ const path = join40(home2, name);
56977
57396
  const k = kind3(path);
56978
57397
  if (k === void 0 || k === "dir") continue;
56979
57398
  remove2(path, k);
56980
57399
  removed.push(name);
56981
57400
  }
56982
57401
  for (const folder of FOLDERS) {
56983
- const dir = join39(home2, folder.path);
57402
+ const dir = join40(home2, folder.path);
56984
57403
  if (kind3(dir) !== "dir") continue;
56985
- for (const name of readdirSync10(dir)) {
56986
- const path = join39(dir, name);
57404
+ for (const name of readdirSync11(dir)) {
57405
+ const path = join40(dir, name);
56987
57406
  const k = kind3(path);
56988
57407
  if (k === void 0 || !folder.ours(name, path)) continue;
56989
57408
  remove2(path, k);
56990
- removed.push(join39(folder.path, name));
57409
+ removed.push(join40(folder.path, name));
56991
57410
  }
56992
57411
  if (rmdirIfEmpty(dir)) removed.push(folder.path);
56993
57412
  }
@@ -56996,12 +57415,20 @@ function purge(home2, opts) {
56996
57415
  }
56997
57416
 
56998
57417
  // src/commands/uninstall.ts
57418
+ var originOf4 = (hub) => {
57419
+ try {
57420
+ return new URL(hub.replace(/^ws(s?):/, "http$1:")).origin;
57421
+ } catch {
57422
+ return hub;
57423
+ }
57424
+ };
56999
57425
  async function uninstall2(opts, ctx) {
57000
57426
  const c = ctx.copy;
57001
57427
  say(ctx, c.header(ctx.version), "");
57002
57428
  const machine = readMachine(ctx.home);
57003
57429
  const removed = await ctx.service.remove();
57004
- if (removed.unit) say(ctx, c.serviceRemoved(removed.unit));
57430
+ if (removed.skipped) say(ctx, c.serviceOtherHome(removed.skipped, true));
57431
+ else if (removed.unit) say(ctx, c.serviceRemoved(removed.unit));
57005
57432
  else if (removed.stopped) say(ctx, c.daemonStopped());
57006
57433
  else if (removed.running === void 0) say(ctx, c.noService());
57007
57434
  if (removed.running !== void 0)
@@ -57015,7 +57442,8 @@ async function uninstall2(opts, ctx) {
57015
57442
  assets: readAssets(),
57016
57443
  which: ctx.which,
57017
57444
  exec: ctx.exec,
57018
- codexApp: ctx.codexApp
57445
+ codexApp: ctx.codexApp,
57446
+ isolated: isolated(ctx)
57019
57447
  });
57020
57448
  if (r.removed.length > 0) say(ctx, c.removedFrom(r.removed));
57021
57449
  try {
@@ -57078,7 +57506,7 @@ async function uninstall2(opts, ctx) {
57078
57506
  say(
57079
57507
  ctx,
57080
57508
  c.hermesNoCli(
57081
- tilde(ctx, join40(hermesHome(ctx.userHome, ctx.env), "config.yaml"))
57509
+ tilde(ctx, join41(hermesHome(ctx.userHome, ctx.env), "config.yaml"))
57082
57510
  )
57083
57511
  );
57084
57512
  if (r.openclawNoCli) say(ctx, c.openclawNoCli());
@@ -57091,13 +57519,15 @@ async function uninstall2(opts, ctx) {
57091
57519
  ctx,
57092
57520
  c.couldNotRemove(s.harness, tildeReason(ctx, s.harness, s.reason))
57093
57521
  );
57094
- if ([...r.removed, ...r.folderOnly].includes("opencode"))
57095
- say(
57096
- ctx,
57097
- r.opencodeRestarted ? c.restartedUnload() : c.opencodeNotRunningUnload()
57098
- );
57522
+ if ([...r.removed, ...r.folderOnly].includes("opencode")) {
57523
+ if (r.opencodeRestartByUser)
57524
+ say(ctx, c.opencodeRestartYourself(r.opencodeIsolated));
57525
+ else if (r.opencodeRestarted) say(ctx, c.restartedUnload());
57526
+ else if (r.notes.some((n) => n.startsWith("opencode service restart failed")))
57527
+ say(ctx, c.opencodeNotRunningUnload());
57528
+ }
57099
57529
  if (!opts.purge) {
57100
- say(ctx, "", c.kept(tilde(ctx, join40(ctx.home, "machine.json"))));
57530
+ say(ctx, "", c.kept(tilde(ctx, join41(ctx.home, "machine.json"))));
57101
57531
  return 0;
57102
57532
  }
57103
57533
  const home2 = tilde(ctx, ctx.home);
@@ -57107,16 +57537,24 @@ async function uninstall2(opts, ctx) {
57107
57537
  return 1;
57108
57538
  } catch {
57109
57539
  }
57540
+ const made = readMade(join41(ctx.home, "install.json"));
57110
57541
  const out = purge(ctx.home, {
57111
- isDefault: ctx.home === join40(ctx.userHome, ".oa-bus")
57542
+ isDefault: ctx.home === join41(ctx.userHome, ".oa-bus")
57112
57543
  });
57113
57544
  if ("refused" in out) {
57114
57545
  sayErr(ctx, c.purgeRefused(home2));
57115
57546
  return 1;
57116
57547
  }
57548
+ try {
57549
+ removeMade(made);
57550
+ } catch (e) {
57551
+ say(ctx, [
57552
+ `Could not remove the empty files install made: ${e instanceof Error ? e.message : String(e)}`
57553
+ ]);
57554
+ }
57117
57555
  say(ctx, out.leftDir ? c.purgeLeftDir(home2) : c.deleted(home2));
57118
57556
  if (machine.state === "ok")
57119
- say(ctx, "", c.stillListed(machine.label, hostOf2(machine.hub)));
57557
+ say(ctx, "", c.stillListed(machine.label, originOf4(machine.hub)));
57120
57558
  return 0;
57121
57559
  }
57122
57560
 
@@ -57167,6 +57605,10 @@ var FLAGS = {
57167
57605
  namespace: ["yes"]
57168
57606
  };
57169
57607
  function parse7(argv) {
57608
+ const end = argv.indexOf("--");
57609
+ const own2 = end === -1 ? argv : argv.slice(0, end);
57610
+ if (own2.includes("--help") || own2.includes("-h") || argv[0] === "help")
57611
+ return { cmd: "help", noColor: own2.includes("--no-color") };
57170
57612
  const { values, positionals, tokens: tokens2 } = parseArgs({
57171
57613
  args: argv,
57172
57614
  allowPositionals: true,
@@ -57187,10 +57629,13 @@ function parse7(argv) {
57187
57629
  json: { type: "boolean", default: false },
57188
57630
  purge: { type: "boolean", default: false },
57189
57631
  version: { type: "boolean", short: "v", default: false },
57632
+ help: { type: "boolean", short: "h", default: false },
57190
57633
  "no-color": { type: "boolean", default: false }
57191
57634
  }
57192
57635
  });
57193
57636
  const [head, ...rest] = positionals;
57637
+ if (values.help || head === "help")
57638
+ return { cmd: "help", noColor: values["no-color"] };
57194
57639
  const cmd = head ?? "install";
57195
57640
  if (!COMMANDS.has(cmd)) throw new Error(`unknown command: ${cmd}`);
57196
57641
  const tokenFile = values["token-file"];
@@ -57338,7 +57783,8 @@ var TERMINAL = /* @__PURE__ */ new Set([
57338
57783
  "namespace",
57339
57784
  "link",
57340
57785
  "leads",
57341
- "version"
57786
+ "version",
57787
+ "help"
57342
57788
  ]);
57343
57789
  async function main(argv, makeCtx = realCtx) {
57344
57790
  let cmd;
@@ -57435,6 +57881,9 @@ async function dispatch(cmd, ctx) {
57435
57881
  case "version":
57436
57882
  say(ctx, ctx.copy.header(ctx.version));
57437
57883
  return 0;
57884
+ case "help":
57885
+ say(ctx, ctx.copy.help());
57886
+ return 0;
57438
57887
  }
57439
57888
  }
57440
57889