@open-artifacts/bus 0.169.1 → 0.171.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.169.1";
14
+ const CLIENT_VERSION = "0.171.0";
15
15
 
16
16
  type Frame = Json & { type: string; id: string };
17
17
  type Ctx = {
@@ -27744,7 +27744,7 @@ var base2 = { v: external_exports.literal(V), id: external_exports.string().min(
27744
27744
  var late = { late: external_exports.array(external_exports.string().min(1)).optional() };
27745
27745
  var isWellFormed2 = (s) => s.isWellFormed();
27746
27746
  var WELL_FORMED = { message: "text is not well-formed unicode" };
27747
- var CLIENT_VERSION = true ? "0.169.1" : "0.0.0";
27747
+ var CLIENT_VERSION = true ? "0.171.0" : "0.0.0";
27748
27748
  var clientVersion = {
27749
27749
  client_version: external_exports.string().min(1).max(64).optional()
27750
27750
  };
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oa-bus",
3
- "version": "0.169.1",
3
+ "version": "0.171.0",
4
4
  "type": "module",
5
5
  "openclaw": {
6
6
  "extensions": [
package/dist/index.js CHANGED
@@ -21823,7 +21823,7 @@ var init_frames = __esm({
21823
21823
  late = { late: external_exports.array(external_exports.string().min(1)).optional() };
21824
21824
  isWellFormed2 = (s) => s.isWellFormed();
21825
21825
  WELL_FORMED = { message: "text is not well-formed unicode" };
21826
- CLIENT_VERSION = true ? "0.169.1" : "0.0.0";
21826
+ CLIENT_VERSION = true ? "0.171.0" : "0.0.0";
21827
21827
  clientVersion = {
21828
21828
  client_version: external_exports.string().min(1).max(64).optional()
21829
21829
  };
@@ -34550,27 +34550,33 @@ function peerTokenFor(pid, socketPath2, dir, procStart, hash2 = sha256) {
34550
34550
  return null;
34551
34551
  }
34552
34552
  }
34553
- function findSession(pid, deps2) {
34553
+ function lookupSession(pid, deps2) {
34554
34554
  for (const anc of deps2.ancestors(pid)) {
34555
34555
  const file2 = readSessionFile(deps2.sessionsDir, anc);
34556
34556
  if (file2.state === "none") continue;
34557
- if (file2.state === "unreadable") return null;
34557
+ if (file2.state === "unreadable") return { ok: false, reason: "unreadable" };
34558
34558
  const { rec } = file2;
34559
- if (notASession(rec)) return null;
34560
- if (typeof rec.procStart !== "string") return null;
34559
+ if (notASession(rec)) return { ok: false, reason: "not_session" };
34560
+ if (typeof rec.procStart !== "string")
34561
+ return { ok: false, reason: "no_proc_start" };
34561
34562
  const start = deps2.procStart(anc);
34562
- if (!start || rec.procStart !== start) return null;
34563
+ if (!start) return { ok: false, reason: "proc_start_unknown" };
34564
+ if (rec.procStart !== start)
34565
+ return { ok: false, reason: "proc_start_mismatch" };
34563
34566
  const socketPath2 = typeof rec.messagingSocketPath === "string" ? rec.messagingSocketPath : null;
34564
34567
  const peerToken = socketPath2 && peerTokenFor(anc, socketPath2, deps2.sessionsDir, start, deps2.sha256);
34565
34568
  return {
34566
- pid: anc,
34567
- sessionId: rec.sessionId,
34568
- socketPath: socketPath2,
34569
- peerToken,
34570
- name: typeof rec.name === "string" ? rec.name : `claude-${anc}`
34569
+ ok: true,
34570
+ session: {
34571
+ pid: anc,
34572
+ sessionId: rec.sessionId,
34573
+ socketPath: socketPath2,
34574
+ peerToken,
34575
+ name: typeof rec.name === "string" ? rec.name : `claude-${anc}`
34576
+ }
34571
34577
  };
34572
34578
  }
34573
- return null;
34579
+ return { ok: false, reason: "none" };
34574
34580
  }
34575
34581
  function hasClaudeAncestor(pid, deps2) {
34576
34582
  return deps2.ancestors(pid).some((anc) => readSessionFile(deps2.sessionsDir, anc).state !== "none");
@@ -34630,7 +34636,7 @@ function sessionHello(session, pid, cwd) {
34630
34636
  }
34631
34637
  });
34632
34638
  }
34633
- var claudeSessionsDir, busHome, notASession, isHeadlessEntrypoint, nameWasChosen, sha256, NOT_UNDER_CLAUDE, ProcStartUnknownError, PS_TIMEOUT_MS, ps, procStartOf;
34639
+ var claudeSessionsDir, busHome, notASession, isHeadlessEntrypoint, nameWasChosen, sha256, RECOVERABLE_REASONS, NOT_UNDER_CLAUDE, ProcStartUnknownError, PS_TIMEOUT_MS, ps, procStartOf;
34634
34640
  var init_session = __esm({
34635
34641
  "../bus-adapter-claude-code/src/session.ts"() {
34636
34642
  "use strict";
@@ -34641,6 +34647,11 @@ var init_session = __esm({
34641
34647
  isHeadlessEntrypoint = (rec) => typeof rec.entrypoint === "string" && rec.entrypoint !== "cli";
34642
34648
  nameWasChosen = (rec) => rec.nameSource === "user" || rec.nameSource === "peer";
34643
34649
  sha256 = (s) => createHash("sha256").update(s).digest("hex");
34650
+ RECOVERABLE_REASONS = [
34651
+ "unreadable",
34652
+ "proc_start_mismatch",
34653
+ "proc_start_unknown"
34654
+ ];
34644
34655
  NOT_UNDER_CLAUDE = "This MCP server is for Claude Code; use this harness's own bus tools.";
34645
34656
  ProcStartUnknownError = class extends Error {
34646
34657
  constructor(pid) {
@@ -34669,14 +34680,35 @@ var init_session = __esm({
34669
34680
 
34670
34681
  // ../bus-adapter-claude-code/src/connect.ts
34671
34682
  async function connectOutcome(deps2) {
34683
+ const sleep = deps2.sleep ?? ((ms) => new Promise((r) => setTimeout(r, ms)));
34684
+ const waitMs = deps2.waitMs ?? RESTART_WAIT_MS;
34685
+ let seen2 = false;
34686
+ for (let waited = 0; ; waited += RESTART_STEP_MS) {
34687
+ const out = await attempt(deps2);
34688
+ if (out.kind === "no-session") {
34689
+ if (!RECOVERABLE_REASONS.includes(out.reason) || waited >= waitMs)
34690
+ return out;
34691
+ await sleep(RESTART_STEP_MS);
34692
+ continue;
34693
+ }
34694
+ if (out.kind !== "no-socket") return out;
34695
+ seen2 ||= out.seen;
34696
+ if (waited >= waitMs) return { kind: "no-socket", seen: seen2 };
34697
+ await sleep(RESTART_STEP_MS);
34698
+ }
34699
+ }
34700
+ async function attempt(deps2) {
34672
34701
  let session;
34673
34702
  try {
34674
- session = deps2.findSession();
34675
- if (!session || deps2.socketDirProblem()) return { kind: "no-session" };
34703
+ const found2 = deps2.findSession();
34704
+ if (!found2.ok) return { kind: "no-session", reason: found2.reason };
34705
+ session = found2.session;
34706
+ if (deps2.socketDirProblem())
34707
+ return { kind: "no-session", reason: "socket_dir" };
34676
34708
  } catch {
34677
34709
  return { kind: "busy" };
34678
34710
  }
34679
- if (!deps2.socketExists()) return { kind: "no-socket" };
34711
+ if (!deps2.socketExists()) return { kind: "no-socket", seen: false };
34680
34712
  try {
34681
34713
  return { kind: "ok", client: await deps2.connect(session) };
34682
34714
  } catch (e) {
@@ -34684,7 +34716,7 @@ async function connectOutcome(deps2) {
34684
34716
  return { kind: "refused", reason: e.reason ?? e.message };
34685
34717
  const code2 = e?.code;
34686
34718
  if (code2 === "ECONNREFUSED" || code2 === "ENOENT")
34687
- return { kind: "no-socket" };
34719
+ return { kind: "no-socket", seen: true };
34688
34720
  return { kind: "busy" };
34689
34721
  }
34690
34722
  }
@@ -34692,14 +34724,22 @@ function noSessionMessage(out, underClaude2) {
34692
34724
  if (out.kind === "busy") return BUSY_MESSAGE;
34693
34725
  if (out.kind === "refused")
34694
34726
  return `oa-bus: the bus daemon refused: ${out.reason}`;
34727
+ if (out.kind === "no-socket" && out.seen) return RESTARTING_MESSAGE;
34728
+ if (out.kind === "no-session" && out.reason === "socket_dir")
34729
+ return `oa-bus: the bus socket folder isn't safe to use; run \`${BUS_CMD} doctor\`.`;
34730
+ if (out.kind === "no-session" && out.reason !== "none")
34731
+ return underClaude2 ? `oa-bus: this Claude session isn't visible to the bus right now (${out.reason}); retry, or run /mcp and reconnect oa_bus.` : NOT_UNDER_CLAUDE;
34695
34732
  return underClaude2 ? `oa-bus: no Claude session or daemon found. Run \`${BUS_CMD} install\`.` : NOT_UNDER_CLAUDE;
34696
34733
  }
34697
- var BUSY_MESSAGE;
34734
+ var RESTARTING_MESSAGE, RESTART_WAIT_MS, RESTART_STEP_MS, BUSY_MESSAGE;
34698
34735
  var init_connect = __esm({
34699
34736
  "../bus-adapter-claude-code/src/connect.ts"() {
34700
34737
  "use strict";
34701
34738
  init_src2();
34702
34739
  init_session();
34740
+ RESTARTING_MESSAGE = "oa-bus: the bus daemon is restarting; retry in a few seconds. If it keeps failing, run /mcp and reconnect oa_bus.";
34741
+ RESTART_WAIT_MS = 2e3;
34742
+ RESTART_STEP_MS = 200;
34703
34743
  BUSY_MESSAGE = "oa-bus: the bus daemon did not answer in time (busy?). Try again.";
34704
34744
  }
34705
34745
  });
@@ -39030,7 +39070,7 @@ var init_stdio2 = __esm({
39030
39070
  // ../bus-adapter-claude-code/src/main.ts
39031
39071
  var main_exports = {};
39032
39072
  import { existsSync as existsSync13 } from "node:fs";
39033
- var SESSIONS, HOME, SOCKET, connect4, server, underClaude;
39073
+ var SESSIONS, connect4, server, underClaude;
39034
39074
  var init_main = __esm({
39035
39075
  async "../bus-adapter-claude-code/src/main.ts"() {
39036
39076
  "use strict";
@@ -39043,22 +39083,24 @@ var init_main = __esm({
39043
39083
  init_socket_path();
39044
39084
  init_tools();
39045
39085
  SESSIONS = claudeSessionsDir();
39046
- HOME = busHome();
39047
- SOCKET = daemonSocketPath(HOME);
39048
- connect4 = () => connectOutcome({
39049
- findSession: () => findSession(process.pid, {
39050
- sessionsDir: SESSIONS,
39051
- ancestors: ancestorChain,
39052
- procStart: claudeProcStartOf
39053
- }),
39054
- // A short socket folder another user could reach is never dialed.
39055
- socketDirProblem: () => socketDirProblem(HOME),
39056
- socketExists: () => existsSync13(SOCKET),
39057
- connect: (session) => connectDaemon({
39058
- path: SOCKET,
39059
- hello: sessionHello(session, process.pid, process.cwd())
39060
- })
39061
- });
39086
+ connect4 = () => {
39087
+ const HOME3 = busHome();
39088
+ const SOCKET3 = daemonSocketPath(HOME3);
39089
+ return connectOutcome({
39090
+ findSession: () => lookupSession(process.pid, {
39091
+ sessionsDir: SESSIONS,
39092
+ ancestors: ancestorChain,
39093
+ procStart: claudeProcStartOf
39094
+ }),
39095
+ // A short socket folder another user could reach is never dialed.
39096
+ socketDirProblem: () => socketDirProblem(HOME3),
39097
+ socketExists: () => existsSync13(SOCKET3),
39098
+ connect: (session) => connectDaemon({
39099
+ path: SOCKET3,
39100
+ hello: sessionHello(session, process.pid, process.cwd())
39101
+ })
39102
+ });
39103
+ };
39062
39104
  server = new Server(
39063
39105
  { name: "oa_bus", version: "0.1.0" },
39064
39106
  { capabilities: { tools: {} } }
@@ -39100,7 +39142,7 @@ var init_main = __esm({
39100
39142
 
39101
39143
  // ../bus-adapter-opencode/src/main.ts
39102
39144
  var main_exports2 = {};
39103
- var HOME2, SOCKET2, server2;
39145
+ var HOME, SOCKET, server2;
39104
39146
  var init_main2 = __esm({
39105
39147
  async "../bus-adapter-opencode/src/main.ts"() {
39106
39148
  "use strict";
@@ -39111,8 +39153,8 @@ var init_main2 = __esm({
39111
39153
  init_src2();
39112
39154
  init_session2();
39113
39155
  init_tools2();
39114
- HOME2 = busHome();
39115
- SOCKET2 = daemonSocketPath(HOME2);
39156
+ HOME = busHome();
39157
+ SOCKET = daemonSocketPath(HOME);
39116
39158
  server2 = new Server(
39117
39159
  { name: "oa_bus", version: "0.1.0" },
39118
39160
  { capabilities: { tools: {} } }
@@ -39127,8 +39169,8 @@ var init_main2 = __esm({
39127
39169
  args: req.params.arguments ?? {},
39128
39170
  meta: req.params._meta,
39129
39171
  connect: (hello) => {
39130
- const problem = socketDirProblem(HOME2);
39131
- return problem ? Promise.reject(new Error(problem)) : connectDaemon({ path: SOCKET2, hello });
39172
+ const problem = socketDirProblem(HOME);
39173
+ return problem ? Promise.reject(new Error(problem)) : connectDaemon({ path: SOCKET, hello });
39132
39174
  },
39133
39175
  resolve: (id) => rootSession(id, { api: opencodeApi }),
39134
39176
  signal: extra.signal
@@ -39140,7 +39182,7 @@ var init_main2 = __esm({
39140
39182
 
39141
39183
  // ../bus-adapter-claude-code/src/codex-main.ts
39142
39184
  var codex_main_exports = {};
39143
- var HOME3, SOCKET3, server3;
39185
+ var HOME2, SOCKET2, server3;
39144
39186
  var init_codex_main = __esm({
39145
39187
  async "../bus-adapter-claude-code/src/codex-main.ts"() {
39146
39188
  "use strict";
@@ -39149,12 +39191,12 @@ var init_codex_main = __esm({
39149
39191
  init_codex();
39150
39192
  init_session();
39151
39193
  init_socket_path();
39152
- HOME3 = busHome();
39153
- SOCKET3 = daemonSocketPath(HOME3);
39194
+ HOME2 = busHome();
39195
+ SOCKET2 = daemonSocketPath(HOME2);
39154
39196
  server3 = codexServer({
39155
39197
  connect: (hello) => {
39156
- const problem = socketDirProblem(HOME3);
39157
- return problem ? Promise.reject(new Error(problem)) : connectDaemon({ path: SOCKET3, hello });
39198
+ const problem = socketDirProblem(HOME2);
39199
+ return problem ? Promise.reject(new Error(problem)) : connectDaemon({ path: SOCKET2, hello });
39158
39200
  }
39159
39201
  });
39160
39202
  await server3.connect(new StdioServerTransport());
@@ -39783,10 +39825,15 @@ function copy(style, bus = BUS_CMD) {
39783
39825
  fail2(`The instance reports a problem: ${displayKind(problem)}`),
39784
39826
  next("Ask the instance's admin to check it.")
39785
39827
  ],
39786
- daemonTimeout: () => [
39787
- fail2("The daemon did not start within 10 seconds."),
39828
+ daemonTimeout: (seconds) => [
39829
+ fail2(`The daemon did not start within ${seconds} seconds.`),
39788
39830
  next(`Run ${bus} doctor to see why.`)
39789
39831
  ],
39832
+ // The process is up but has not answered yet (a busy machine, #2358).
39833
+ daemonStarting: () => [
39834
+ warn("The daemon is still starting."),
39835
+ next(`Check ${bus} status in a minute.`)
39836
+ ],
39790
39837
  rosterHeader: (namespace2, live, queued) => {
39791
39838
  const n = live + queued;
39792
39839
  const meta3 = queued ? `${live} live ${g("sep")} ${queued} queued` : `${live} live`;
@@ -39844,12 +39891,12 @@ function copy(style, bus = BUS_CMD) {
39844
39891
  fail2(`Code ${code2} expired after 10 minutes.`),
39845
39892
  next(`Run ${bus} again to get a new code.`)
39846
39893
  ],
39847
- unreachable: (host, waitS, attempt, total) => [
39894
+ unreachable: (host, waitS, attempt2, total) => [
39848
39895
  warn(`Couldn't reach ${clip(host, 18)}`),
39849
39896
  next(
39850
39897
  p(
39851
39898
  "muted",
39852
- `Retrying in ${waitS} s${more} attempt ${attempt} of ${total}`
39899
+ `Retrying in ${waitS} s${more} attempt ${attempt2} of ${total}`
39853
39900
  )
39854
39901
  )
39855
39902
  ],
@@ -43726,11 +43773,11 @@ function createDeliver(ctx) {
43726
43773
  chains.delete(msg_id);
43727
43774
  return;
43728
43775
  }
43729
- attempt(frame).catch(fail2(msg_id));
43776
+ attempt2(frame).catch(fail2(msg_id));
43730
43777
  }, delay);
43731
43778
  };
43732
- const deliver = (frame) => attempt(frame).catch(fail2(frame.msg_id));
43733
- const attempt = async (frame) => {
43779
+ const deliver = (frame) => attempt2(frame).catch(fail2(frame.msg_id));
43780
+ const attempt2 = async (frame) => {
43734
43781
  const { msg_id } = frame;
43735
43782
  if (seen2.has(msg_id)) {
43736
43783
  ack(msg_id);
@@ -44213,8 +44260,8 @@ var HubConnection = class {
44213
44260
  });
44214
44261
  }
44215
44262
  };
44216
- function defaultBackoff(attempt) {
44217
- const base3 = Math.min(3e4, 500 * 2 ** attempt);
44263
+ function defaultBackoff(attempt2) {
44264
+ const base3 = Math.min(3e4, 500 * 2 ** attempt2);
44218
44265
  return Math.round(base3 * (0.5 + Math.random() / 2));
44219
44266
  }
44220
44267
 
@@ -48292,7 +48339,7 @@ async function runDaemon(deps2 = {}) {
48292
48339
  const RESTORE_TRIES = 5;
48293
48340
  const restoreCodex = () => {
48294
48341
  if (deps2.attest) return;
48295
- const attempt = (rows, tries) => {
48342
+ const attempt2 = (rows, tries) => {
48296
48343
  const again = [];
48297
48344
  for (const r of rows) {
48298
48345
  if (agents.byRef(r.ref)) {
@@ -48375,12 +48422,12 @@ async function runDaemon(deps2 = {}) {
48375
48422
  const delay = (deps2.restoreRetryMs ?? 1e3) * 2 ** tries;
48376
48423
  const t = setTimeout(() => {
48377
48424
  restoreTimers.delete(t);
48378
- attempt(again, tries + 1);
48425
+ attempt2(again, tries + 1);
48379
48426
  }, delay);
48380
48427
  t.unref();
48381
48428
  restoreTimers.add(t);
48382
48429
  };
48383
- attempt(readCodexAgents(codexAgentsFile), 0);
48430
+ attempt2(readCodexAgents(codexAgentsFile), 0);
48384
48431
  };
48385
48432
  const awayFile = cx.awayFile ?? join18(home(), "codex-away.json");
48386
48433
  const awayNow = deps2.bindingNow ?? Date.now;
@@ -50171,6 +50218,7 @@ function systemService(d) {
50171
50218
  }
50172
50219
  return "started";
50173
50220
  }
50221
+ const skippedNow = () => isolated2() !== void 0;
50174
50222
  return {
50175
50223
  get kind() {
50176
50224
  return installed() ? manager : void 0;
@@ -50308,6 +50356,30 @@ function systemService(d) {
50308
50356
  const e = installed() ? record7().env : void 0;
50309
50357
  return typeof e === "object" && e !== null ? e : {};
50310
50358
  },
50359
+ async alive() {
50360
+ if (skippedNow()) return void 0;
50361
+ if (installed()) {
50362
+ if (manager === "launchd") {
50363
+ const r2 = await d.exec("launchctl", [
50364
+ "print",
50365
+ `${domain2}/${names2().label}`
50366
+ ]);
50367
+ return r2.code === 0 && /\bpid = \d+/.test(r2.stdout);
50368
+ }
50369
+ const r = await systemctl(
50370
+ "show",
50371
+ "-p",
50372
+ "ActiveState,SubState,NRestarts",
50373
+ names2().unit
50374
+ );
50375
+ const v = (k) => r.stdout.match(new RegExp(`^${k}=(.*)$`, "m"))?.[1]?.trim();
50376
+ if (r.code !== 0) return false;
50377
+ if (v("ActiveState") === "active") return true;
50378
+ return v("ActiveState") === "activating" && v("SubState") !== "auto-restart" && Number(v("NRestarts") ?? 0) === 0;
50379
+ }
50380
+ const pid = record7().fallback === true ? record7().pid : void 0;
50381
+ return typeof pid === "number" ? d.processArgs(pid) !== void 0 : void 0;
50382
+ },
50311
50383
  problems() {
50312
50384
  if (!installed()) return [];
50313
50385
  const out = [];
@@ -50327,7 +50399,7 @@ var noService = {
50327
50399
  remove: async () => ({}),
50328
50400
  cli: () => ["oa-bus"]
50329
50401
  };
50330
- var VERSION = true ? "0.169.1" : JSON.parse(
50402
+ var VERSION = true ? "0.171.0" : JSON.parse(
50331
50403
  readFileSync16(new URL("../package.json", import.meta.url), "utf8")
50332
50404
  ).version;
50333
50405
  var which = (cmd) => {
@@ -50459,18 +50531,18 @@ function askDaemon(ctx, opts = {}) {
50459
50531
  var PROBE_RETRY_MS = 500;
50460
50532
  var PROBE_RETRY_TIMEOUT_MS = 1500;
50461
50533
  async function probeDaemon(ctx, opts = {}) {
50462
- for (let attempt = 0; ; attempt++) {
50534
+ for (let attempt2 = 0; ; attempt2++) {
50463
50535
  try {
50464
50536
  return {
50465
50537
  state: "up",
50466
50538
  st: await askDaemon(
50467
50539
  ctx,
50468
- attempt > 0 ? { ...opts, timeoutMs: PROBE_RETRY_TIMEOUT_MS } : opts
50540
+ attempt2 > 0 ? { ...opts, timeoutMs: PROBE_RETRY_TIMEOUT_MS } : opts
50469
50541
  )
50470
50542
  };
50471
50543
  } catch (e) {
50472
50544
  if (!(e instanceof DaemonSilentError)) return { state: "down" };
50473
- if (attempt > 0) return { state: "stalled" };
50545
+ if (attempt2 > 0) return { state: "stalled" };
50474
50546
  await ctx.sleep(PROBE_RETRY_MS);
50475
50547
  }
50476
50548
  }
@@ -55967,7 +56039,7 @@ async function requestCode(args, hub, label) {
55967
56039
  const waits = args.codeRetryMs ?? [];
55968
56040
  const total = waits.length + 1;
55969
56041
  const body = DeviceCodeRequestSchema.parse({ machine_label: label });
55970
- for (let attempt = 1; ; attempt++) {
56042
+ for (let attempt2 = 1; ; attempt2++) {
55971
56043
  let error62;
55972
56044
  try {
55973
56045
  const res = await post(
@@ -55983,14 +56055,14 @@ async function requestCode(args, hub, label) {
55983
56055
  if (total === 1) throw e;
55984
56056
  error62 = errorTail(e);
55985
56057
  }
55986
- const waitMs = waits[attempt - 1];
56058
+ const waitMs = waits[attempt2 - 1];
55987
56059
  if (waitMs === void 0)
55988
56060
  throw new LoginFailed(
55989
56061
  "unreachable",
55990
56062
  `could not reach ${hub} after ${total} attempts: ${error62}`,
55991
56063
  { attempts: total, error: error62 }
55992
56064
  );
55993
- args.events?.retrying?.({ attempt, total, waitMs, error: error62 });
56065
+ args.events?.retrying?.({ attempt: attempt2, total, waitMs, error: error62 });
55994
56066
  await args.sleep(waitMs);
55995
56067
  }
55996
56068
  }
@@ -56251,8 +56323,10 @@ function removeMade(made) {
56251
56323
 
56252
56324
  // src/commands/install.ts
56253
56325
  var CODE_RETRY_MS = [2e3, 4e3, 8e3];
56254
- var DAEMON_WAIT_MS = 1e4;
56326
+ var DAEMON_WAIT_MS = 6e4;
56255
56327
  var DAEMON_POLL_MS = 250;
56328
+ var DAEMON_POLL_MAX_MS = 2e3;
56329
+ var DAEMON_GONE_AFTER_MS = 1e4;
56256
56330
  var ROSTER_ROWS = 20;
56257
56331
  var originOf3 = (hub) => {
56258
56332
  try {
@@ -56303,8 +56377,8 @@ async function loginStep(ctx, opts) {
56303
56377
  now: ctx.now,
56304
56378
  print: ctx.print,
56305
56379
  events: {
56306
- retrying: ({ attempt, total, waitMs }) => {
56307
- const lines = c.unreachable(host, waitMs / 1e3, attempt + 1, total);
56380
+ retrying: ({ attempt: attempt2, total, waitMs }) => {
56381
+ const lines = c.unreachable(host, waitMs / 1e3, attempt2 + 1, total);
56308
56382
  if (tty) live.draw(lines);
56309
56383
  else say(ctx, lines);
56310
56384
  },
@@ -56463,13 +56537,28 @@ function shownSocket(ctx) {
56463
56537
  }
56464
56538
  async function waitForDaemon(ctx) {
56465
56539
  const start = ctx.now();
56540
+ let poll = DAEMON_POLL_MS;
56541
+ let down = 0;
56466
56542
  for (; ; ) {
56467
56543
  try {
56468
- return await askDaemon(ctx, { cwd: ctx.cwd, timeoutMs: 1e3 });
56544
+ return {
56545
+ st: await askDaemon(ctx, { cwd: ctx.cwd, timeoutMs: 1e3 }),
56546
+ gone: false
56547
+ };
56469
56548
  } catch {
56470
56549
  }
56471
- if (ctx.now() - start >= DAEMON_WAIT_MS) return void 0;
56472
- await ctx.sleep(DAEMON_POLL_MS);
56550
+ const waited = ctx.now() - start;
56551
+ if (waited >= DAEMON_GONE_AFTER_MS) {
56552
+ const alive2 = await ctx.service.alive?.().catch(() => void 0);
56553
+ down = alive2 === false ? down + 1 : 0;
56554
+ if (down >= 3) return { gone: true };
56555
+ }
56556
+ if (waited >= DAEMON_WAIT_MS) {
56557
+ const alive2 = await ctx.service.alive?.().catch(() => void 0);
56558
+ return { gone: alive2 !== true };
56559
+ }
56560
+ await ctx.sleep(poll);
56561
+ poll = Math.min(poll * 2, DAEMON_POLL_MAX_MS);
56473
56562
  }
56474
56563
  }
56475
56564
  async function daemonStep(ctx, noService2 = false) {
@@ -56494,11 +56583,19 @@ async function daemonStep(ctx, noService2 = false) {
56494
56583
  return false;
56495
56584
  }
56496
56585
  const unsafe = socketFolderLines(ctx);
56497
- const st = unsafe ? void 0 : await waitForDaemon(ctx);
56498
- if (!st) {
56499
- sayErr(ctx, unsafe ?? c.daemonTimeout());
56586
+ if (unsafe) {
56587
+ sayErr(ctx, unsafe);
56500
56588
  return false;
56501
56589
  }
56590
+ const { st, gone } = await waitForDaemon(ctx);
56591
+ if (!st) {
56592
+ if (gone) {
56593
+ sayErr(ctx, c.daemonTimeout(DAEMON_WAIT_MS / 1e3));
56594
+ return false;
56595
+ }
56596
+ say(ctx, c.daemonStarting());
56597
+ return true;
56598
+ }
56502
56599
  say(ctx, c.daemonRunning(st.pid, ctx.service.kind, ctx.service.fallback), "");
56503
56600
  say(ctx, roster(ctx, st), "", c.statusHint());
56504
56601
  return true;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@open-artifacts/bus",
3
3
  "type": "module",
4
- "version": "0.169.1",
4
+ "version": "0.171.0",
5
5
  "description": "The Open Artifacts bus: your AI agents reach each other across machines.",
6
6
  "license": "MIT",
7
7
  "repository": {