@open-bus/cli 0.43.4 → 0.44.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.
Files changed (2) hide show
  1. package/dist/index.js +37 -4
  2. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -21558,6 +21558,10 @@ var init_frames = __esm({
21558
21558
  hub: external_exports.enum(["connected", "connecting"]),
21559
21559
  /** Why the hub link is down: a Node error code, `timeout` or `HTTP 502`. */
21560
21560
  hub_error: external_exports.string().optional(),
21561
+ /** The link has been open at least once since the daemon started. Older daemons omit it. */
21562
+ hub_ever: external_exports.boolean().optional(),
21563
+ /** Ms epoch of the last drop, while the link is down after being up. Older daemons omit it. */
21564
+ hub_since: external_exports.number().optional(),
21561
21565
  /** The namespace `cwd` resolves to, when the request named one. */
21562
21566
  namespace: external_exports.string().optional(),
21563
21567
  /** One roster per namespace: this machine's sessions', or only `cwd`'s. */
@@ -40404,6 +40408,8 @@ async function runDaemon(deps = {}) {
40404
40408
  onClosed: announceSessions,
40405
40409
  log
40406
40410
  });
40411
+ let hubEver = false;
40412
+ let hubDroppedAt;
40407
40413
  const hub = new HubConnection({
40408
40414
  url: `${cfg.hub.replace(/^http/, "ws").replace(/\/$/, "")}/hub`,
40409
40415
  token: cfg.machine_token,
@@ -40519,10 +40525,13 @@ async function runDaemon(deps = {}) {
40519
40525
  },
40520
40526
  // The hub forgets agents with the link; sessions went out with hello.
40521
40527
  onOpen: () => {
40528
+ hubEver = true;
40529
+ hubDroppedAt = void 0;
40522
40530
  for (const rec of agents.all()) if (rec.live) announceUp(rec);
40523
40531
  outbox.flush();
40524
40532
  },
40525
40533
  onClose: () => {
40534
+ if (hubEver) hubDroppedAt ??= Date.now();
40526
40535
  upIds.clear();
40527
40536
  receipts.release();
40528
40537
  resends.dropped();
@@ -40613,6 +40622,8 @@ async function runDaemon(deps = {}) {
40613
40622
  label: cfg.label,
40614
40623
  hub: hub.open ? "connected" : "connecting",
40615
40624
  ...hub.open || !hub.lastError ? {} : { hub_error: hub.lastError },
40625
+ hub_ever: hubEver,
40626
+ ...hub.open || !hubEver || hubDroppedAt === void 0 ? {} : { hub_since: hubDroppedAt },
40616
40627
  ...only === void 0 ? {} : { namespace: only },
40617
40628
  namespaces,
40618
40629
  // Read-only: status never marks a late delivery shown.
@@ -40926,12 +40937,18 @@ function cell(value, width, more = "\u2026") {
40926
40937
  return v + " ".repeat(Math.max(0, width - len(v)));
40927
40938
  }
40928
40939
  var tokenTail = (token, more = "\u2026") => `ob_machine_${more}${token.slice(-4)}`;
40940
+ var minutesSince = (at, now) => Math.floor((now - at) / 6e4);
40929
40941
  function ago(at, now) {
40930
- const mins = Math.floor((now - at) / 6e4);
40942
+ const mins = minutesSince(at, now);
40931
40943
  if (mins < 1) return "now";
40932
40944
  if (mins < 60) return `${mins} min ago`;
40933
40945
  return `${Math.floor(mins / 60)} h ago`;
40934
40946
  }
40947
+ function forHowLong(since, now) {
40948
+ const mins = minutesSince(since, now);
40949
+ if (mins < 1) return void 0;
40950
+ return mins < 60 ? `for ${mins} min` : `for ${Math.floor(mins / 60)} h`;
40951
+ }
40935
40952
  var listing = (names2, last) => names2.length <= 1 ? names2[0] ?? "" : `${names2.slice(0, -1).join(", ")} ${last} ${names2.at(-1)}`;
40936
40953
  function copy(style) {
40937
40954
  const p = (tone, s) => paint(style, tone, s);
@@ -41182,7 +41199,13 @@ function copy(style) {
41182
41199
  next("If it keeps running, run npx @open-bus/cli doctor to see why.")
41183
41200
  ],
41184
41201
  // 7. status
41185
- hubRow: (host) => `Hub ${clip(host, 9)}`,
41202
+ hubRow: (host, link) => {
41203
+ if (!link) return `Hub ${clip(host, 9)}`;
41204
+ const word = `${link.state === "connected" ? g("live") : g("queued")} ${link.state}`;
41205
+ const tone = link.state === "connected" ? "success" : "warning";
41206
+ const dur = link.for ? ` ${p("muted", link.for)}` : "";
41207
+ return `Hub ${clip(host, 9 + 2 + len(word) + (link.for ? 2 + len(link.for) : 0))} ${p(tone, word)}${dur}`;
41208
+ },
41186
41209
  machineRow: (label) => `Machine ${clip(label, 9)}`,
41187
41210
  statusDaemonDown: () => [
41188
41211
  fail("Daemon not running"),
@@ -41791,7 +41814,7 @@ var noService = {
41791
41814
  remove: async () => ({}),
41792
41815
  cli: () => ["open-bus"]
41793
41816
  };
41794
- var VERSION = true ? "0.43.4" : JSON.parse(
41817
+ var VERSION = true ? "0.44.0" : JSON.parse(
41795
41818
  readFileSync9(new URL("../package.json", import.meta.url), "utf8")
41796
41819
  ).version;
41797
41820
  var which = (cmd) => {
@@ -44130,6 +44153,14 @@ var hostOf2 = (hub) => {
44130
44153
  return hub;
44131
44154
  }
44132
44155
  };
44156
+ var linkOf = (st, now) => {
44157
+ if (st.hub === "connected") return { state: "connected" };
44158
+ if (!st.hub_ever) return { state: "connecting" };
44159
+ return {
44160
+ state: "reconnecting",
44161
+ for: st.hub_since === void 0 ? void 0 : forHowLong(st.hub_since, now)
44162
+ };
44163
+ };
44133
44164
  async function status(ctx) {
44134
44165
  const c = ctx.copy;
44135
44166
  say(ctx, c.header(ctx.version), "");
@@ -44139,8 +44170,8 @@ async function status(ctx) {
44139
44170
  return 1;
44140
44171
  }
44141
44172
  const host = hostOf2(m.hub);
44142
- say(ctx, c.hubRow(host), c.machineRow(m.label));
44143
44173
  if (m.revoked) {
44174
+ say(ctx, c.hubRow(host), c.machineRow(m.label));
44144
44175
  sayErr(ctx, c.revoked());
44145
44176
  return 1;
44146
44177
  }
@@ -44148,9 +44179,11 @@ async function status(ctx) {
44148
44179
  try {
44149
44180
  st = await askDaemon(ctx, { timeoutMs: 3e3 });
44150
44181
  } catch {
44182
+ say(ctx, c.hubRow(host), c.machineRow(m.label));
44151
44183
  sayErr(ctx, socketFolderLines(ctx) ?? c.statusDaemonDown());
44152
44184
  return 1;
44153
44185
  }
44186
+ say(ctx, c.hubRow(host, linkOf(st, ctx.now())), c.machineRow(m.label));
44154
44187
  say(ctx, c.daemonRunning(st.pid, ctx.service.kind, ctx.service.fallback));
44155
44188
  if (st.hub !== "connected") {
44156
44189
  sayErr(ctx, c.hubNotReachable(host, st.hub_error, "status"));
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@open-bus/cli",
3
3
  "type": "module",
4
- "version": "0.43.4",
4
+ "version": "0.44.0",
5
5
  "description": "One bus for all your AI coding agents, across machines.",
6
6
  "license": "MIT",
7
7
  "repository": {
@@ -30,13 +30,13 @@
30
30
  "vitest": "^4.1.12",
31
31
  "zod": "^4.1.0",
32
32
  "@ob/adapter-mcp-json": "0.0.0",
33
+ "@ob/daemon": "0.0.0",
33
34
  "@ob/adapter-claude-code": "0.0.0",
34
35
  "@ob/adapter-pi": "0.0.0",
35
- "@ob/daemon": "0.0.0",
36
36
  "@ob/adapter-opencode": "0.0.0",
37
- "@ob/ui": "0.0.0",
37
+ "@ob/ipc": "0.0.0",
38
38
  "@ob/shared": "0.0.0",
39
- "@ob/ipc": "0.0.0"
39
+ "@ob/ui": "0.0.0"
40
40
  },
41
41
  "scripts": {
42
42
  "build": "node scripts/bundle.mjs",