@open-artifacts/bus 0.153.0 → 0.154.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.153.0";
14
+ const CLIENT_VERSION = "0.154.0";
15
15
 
16
16
  type Frame = Json & { type: string; id: string };
17
17
  type Ctx = {
@@ -27550,6 +27550,11 @@ var RosterAgent = external_exports.strictObject({
27550
27550
  * either refuses the row, and with it the whole roster.
27551
27551
  */
27552
27552
  since: IsoTimeSchema.optional(),
27553
+ /**
27554
+ * #2029: mail pending to an `away` agent, counted up to 100. Only on away
27555
+ * rows, which only a `BUS_CAPS.mailbox` socket sees.
27556
+ */
27557
+ waiting: external_exports.number().int().min(1).max(100).optional(),
27553
27558
  /** The agent's machine label. */
27554
27559
  machine_label: MachineLabelSchema.optional(),
27555
27560
  /** Self-reported ("agent says"); cleared on close. */
@@ -27704,7 +27709,7 @@ var base2 = { v: external_exports.literal(V), id: external_exports.string().min(
27704
27709
  var late = { late: external_exports.array(external_exports.string().min(1)).optional() };
27705
27710
  var isWellFormed2 = (s) => s.isWellFormed();
27706
27711
  var WELL_FORMED = { message: "text is not well-formed unicode" };
27707
- var CLIENT_VERSION = true ? "0.153.0" : "0.0.0";
27712
+ var CLIENT_VERSION = true ? "0.154.0" : "0.0.0";
27708
27713
  var clientVersion = {
27709
27714
  client_version: external_exports.string().min(1).max(64).optional()
27710
27715
  };
@@ -27931,6 +27936,8 @@ var AgentInfo = external_exports.object({
27931
27936
  state: external_exports.enum(["live", "queued", "away"]).optional(),
27932
27937
  /** When an `away` agent closed. */
27933
27938
  since: IsoTimeSchema.optional(),
27939
+ /** #2029: mail pending to an `away` agent, capped at 100. */
27940
+ waiting: external_exports.number().int().min(1).max(100).optional(),
27934
27941
  global: external_exports.boolean(),
27935
27942
  /** The agent's machine (B13); absent when the hub is older. */
27936
27943
  machine_label: MachineLabelSchema.optional(),
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oa-bus",
3
- "version": "0.153.0",
3
+ "version": "0.154.0",
4
4
  "type": "module",
5
5
  "openclaw": {
6
6
  "extensions": [
package/dist/index.js CHANGED
@@ -20536,6 +20536,13 @@ var init_caps = __esm({
20536
20536
  * only when the hub listed both `link` and this.
20537
20537
  */
20538
20538
  linkArg: "link_arg",
20539
+ /**
20540
+ * Waiting mail (#2029): the client decodes roster `waiting` on `away` rows.
20541
+ * The hub sends it only to a socket whose hello listed it (with `mailbox`),
20542
+ * and lists it in `hello_ok.caps`: a strict decoder without it would refuse
20543
+ * the whole roster.
20544
+ */
20545
+ waiting: "waiting",
20539
20546
  /**
20540
20547
  * Notice acks (#1752): a daemon listing it sends the existing `ack` frame
20541
20548
  * with a notice deliver frame's `msg_id` only once the harness took the
@@ -21539,6 +21546,11 @@ var init_protocol = __esm({
21539
21546
  * either refuses the row, and with it the whole roster.
21540
21547
  */
21541
21548
  since: IsoTimeSchema.optional(),
21549
+ /**
21550
+ * #2029: mail pending to an `away` agent, counted up to 100. Only on away
21551
+ * rows, which only a `BUS_CAPS.mailbox` socket sees.
21552
+ */
21553
+ waiting: external_exports.number().int().min(1).max(100).optional(),
21542
21554
  /** The agent's machine label. */
21543
21555
  machine_label: MachineLabelSchema.optional(),
21544
21556
  /** Self-reported ("agent says"); cleared on close. */
@@ -21752,7 +21764,7 @@ var init_frames = __esm({
21752
21764
  late = { late: external_exports.array(external_exports.string().min(1)).optional() };
21753
21765
  isWellFormed2 = (s) => s.isWellFormed();
21754
21766
  WELL_FORMED = { message: "text is not well-formed unicode" };
21755
- CLIENT_VERSION = true ? "0.153.0" : "0.0.0";
21767
+ CLIENT_VERSION = true ? "0.154.0" : "0.0.0";
21756
21768
  clientVersion = {
21757
21769
  client_version: external_exports.string().min(1).max(64).optional()
21758
21770
  };
@@ -21984,6 +21996,8 @@ var init_frames = __esm({
21984
21996
  state: external_exports.enum(["live", "queued", "away"]).optional(),
21985
21997
  /** When an `away` agent closed. */
21986
21998
  since: IsoTimeSchema.optional(),
21999
+ /** #2029: mail pending to an `away` agent, capped at 100. */
22000
+ waiting: external_exports.number().int().min(1).max(100).optional(),
21987
22001
  global: external_exports.boolean(),
21988
22002
  /** The agent's machine (B13); absent when the hub is older. */
21989
22003
  machine_label: MachineLabelSchema.optional(),
@@ -40429,7 +40443,7 @@ import { join as join20 } from "node:path";
40429
40443
  // ../bus-daemon/src/index.ts
40430
40444
  init_src3();
40431
40445
  import { randomBytes as randomBytes3 } from "node:crypto";
40432
- import { lstatSync as lstatSync8, realpathSync as realpathSync7, writeFileSync as writeFileSync7 } from "node:fs";
40446
+ import { lstatSync as lstatSync8, realpathSync as realpathSync7, writeFileSync as writeFileSync8 } from "node:fs";
40433
40447
  import { basename as basename5, isAbsolute as isAbsolute7, join as join16 } from "node:path";
40434
40448
 
40435
40449
  // ../bus-adapter-opencode/src/version.ts
@@ -40733,16 +40747,18 @@ function lstartEpoch(lstart) {
40733
40747
  }
40734
40748
 
40735
40749
  // ../bus-daemon/src/codex-attest.ts
40750
+ var CODEX_TOOL_NAMESPACE = "mcp__oa_bus";
40736
40751
  var CODEX_REFUSALS = {
40737
40752
  notCodex: "it is not running under Codex.",
40738
40753
  restarted: "Codex restarted. Call the tool again.",
40739
40754
  notLoaded: "Codex does not have this thread loaded.",
40740
40755
  callNotFound: "this call is not an open Open Artifacts bus call in the thread. Call the tool again.",
40756
+ /** An open code-mode exec in this turn that did not name an Open Artifacts bus tool literally (a lookup such as `tools[name]`). */
40757
+ dynamicLookup: `Call the bus tool by its exact name, for example tools.${CODEX_TOOL_NAMESPACE}__self(), not through a dynamic lookup.`,
40741
40758
  subagent: "only the main Codex thread can use Open Artifacts bus, not a subagent.",
40742
40759
  /** DRAFT (C27), pending Design. */
40743
40760
  oneExec: "this exec already made an Open Artifacts bus call. Make each Open Artifacts bus call in its own exec."
40744
40761
  };
40745
- var CODEX_TOOL_NAMESPACE = "mcp__oa_bus";
40746
40762
  var CODEX_PROXY_ENTRY_FILE = "codex-mcp-entry.json";
40747
40763
  function codexProxyNamespaces(busHome2) {
40748
40764
  try {
@@ -40765,6 +40781,7 @@ var EXEC_CALL = /^exec-[0-9a-f-]{36}$/;
40765
40781
  var seen = () => ({
40766
40782
  open: /* @__PURE__ */ new Map(),
40767
40783
  execs: /* @__PURE__ */ new Map(),
40784
+ lookups: /* @__PURE__ */ new Map(),
40768
40785
  latest: void 0,
40769
40786
  done: /* @__PURE__ */ new Set()
40770
40787
  });
@@ -40875,6 +40892,14 @@ function codexAttestor(deps2 = {}) {
40875
40892
  const e = sc2.execs.get(item);
40876
40893
  return e !== void 0 && e.at >= since && e.turn === cx.turn_id && sc2.latest === e.turn && !sc2.done.has(cx.call_id);
40877
40894
  };
40895
+ const lookupOpen = (sc2) => {
40896
+ if (!item || !cx.turn_id || !EXEC_CALL.test(cx.call_id)) return false;
40897
+ const e = sc2.lookups.get(item);
40898
+ return e !== void 0 && e.at >= since && e.turn === cx.turn_id && sc2.latest === e.turn && !sc2.done.has(cx.call_id);
40899
+ };
40900
+ const missing2 = (sc2) => no(
40901
+ lookupOpen(sc2) ? CODEX_REFUSALS.dynamicLookup : CODEX_REFUSALS.callNotFound
40902
+ );
40878
40903
  const itemUsed = () => item !== void 0 && (usedItems.get(thread)?.has(item) ?? false);
40879
40904
  const ok = { ok: true, cwd: proof.cwd, pid: p };
40880
40905
  const okFor = (sc2) => sc2.open.get(cx.call_id)?.proxied ? { ...ok, linkOnly: true } : ok;
@@ -40891,14 +40916,14 @@ function codexAttestor(deps2 = {}) {
40891
40916
  }
40892
40917
  if (itemUsed()) return no(CODEX_REFUSALS.oneExec);
40893
40918
  if (execOpen(scan2)) return admitExec();
40894
- if (!retry || retryMs <= 0) return no(CODEX_REFUSALS.callNotFound);
40919
+ if (!retry || retryMs <= 0) return missing2(scan2);
40895
40920
  spend(thread, cx.call_id);
40896
40921
  const sc = scan2;
40897
40922
  return sleep(retryMs).then(() => {
40898
40923
  advance(sc, ns);
40899
40924
  if (isOpen(sc)) return okFor(sc);
40900
40925
  if (itemUsed()) return no(CODEX_REFUSALS.oneExec);
40901
- return execOpen(sc) ? admitExec() : no(CODEX_REFUSALS.callNotFound);
40926
+ return execOpen(sc) ? admitExec() : missing2(sc);
40902
40927
  });
40903
40928
  };
40904
40929
  const sweep = (live, relock) => {
@@ -40963,7 +40988,42 @@ function codexAttestor(deps2 = {}) {
40963
40988
  pinned.delete(pid);
40964
40989
  return void 0;
40965
40990
  };
40991
+ const isUserThread = (home2, thread) => {
40992
+ const row = threadRow(home2, thread);
40993
+ const rollout = row?.rollout_path ?? globRollout(home2, thread);
40994
+ if (!rollout || !plainFile(rollout)) return false;
40995
+ const meta3 = metaOf2(rollout, thread);
40996
+ if (!meta3) return false;
40997
+ return !(isSubagent(row ? row.source : meta3.source) || isSubagent(meta3.source) || SPAWNED_SOURCES.has(String(meta3.thread_source)));
40998
+ };
40999
+ const holders = (threads) => {
41000
+ const home2 = deps2.home ?? codexHome();
41001
+ const files2 = threads.filter((t) => plainFile(lockOf(home2, t)));
41002
+ if (!files2.length) return /* @__PURE__ */ new Map();
41003
+ const held = (deps2.holdersOf ?? lsofHolders)(
41004
+ files2.map((t) => lockOf(home2, t))
41005
+ );
41006
+ if (!held) return void 0;
41007
+ const pids = /* @__PURE__ */ new Set();
41008
+ for (const t of files2)
41009
+ for (const p of held.get(lockOf(home2, t)) ?? []) pids.add(p);
41010
+ const rows = pids.size ? procs([...pids]) : /* @__PURE__ */ new Map();
41011
+ if (!rows) return void 0;
41012
+ const out = /* @__PURE__ */ new Map();
41013
+ for (const t of files2) {
41014
+ if (!isUserThread(home2, t)) continue;
41015
+ for (const pid of held.get(lockOf(home2, t)) ?? []) {
41016
+ const row = rows.get(pid);
41017
+ if (!row || basename2(row.comm) !== "codex") continue;
41018
+ if (proofs.has(`${pid}\0${row.start}\0${t}`)) continue;
41019
+ out.set(t, { pid, start: row.start });
41020
+ break;
41021
+ }
41022
+ }
41023
+ return out;
41024
+ };
40966
41025
  return {
41026
+ holders,
40967
41027
  attest: (hello) => check2(hello, true),
40968
41028
  attestNow: (hello) => check2(hello, false),
40969
41029
  sweep,
@@ -41042,7 +41102,7 @@ var TURN_ENDS = /* @__PURE__ */ new Set([
41042
41102
  function visitLine(st, text3, namespaces = [CODEX_TOOL_NAMESPACE]) {
41043
41103
  if (!/call|task_complete|turn_aborted|task_started|item_completed/.test(text3))
41044
41104
  return;
41045
- const { open: open2, execs } = st;
41105
+ const { open: open2, execs, lookups } = st;
41046
41106
  let line;
41047
41107
  try {
41048
41108
  line = record3(JSON.parse(text3));
@@ -41060,9 +41120,10 @@ function visitLine(st, text3, namespaces = [CODEX_TOOL_NAMESPACE]) {
41060
41120
  for (const [id, c] of open2)
41061
41121
  if (turn === void 0 || c.turn === void 0 || c.turn === turn)
41062
41122
  open2.delete(id);
41063
- for (const [id, c] of execs)
41064
- if (turn === void 0 || c.turn === void 0 || c.turn === turn)
41065
- execs.delete(id);
41123
+ for (const m of [execs, lookups])
41124
+ for (const [id, c] of m)
41125
+ if (turn === void 0 || c.turn === void 0 || c.turn === turn)
41126
+ m.delete(id);
41066
41127
  return;
41067
41128
  }
41068
41129
  if (p.type === "item_completed") {
@@ -41080,12 +41141,16 @@ function visitLine(st, text3, namespaces = [CODEX_TOOL_NAMESPACE]) {
41080
41141
  if (typeof p.call_id !== "string") return;
41081
41142
  if (line?.type === "response_item" && p.type === "custom_tool_call") {
41082
41143
  const turn = record3(p.internal_chat_message_metadata_passthrough)?.turn_id;
41083
- if (p.name === "exec" && p.namespace === void 0 && typeof p.id === "string" && typeof p.input === "string" && p.input.includes(`${CODEX_TOOL_NAMESPACE}__`))
41084
- execs.set(p.id, {
41144
+ if (p.name === "exec" && p.namespace === void 0 && typeof p.id === "string" && typeof p.input === "string") {
41145
+ const entry = {
41085
41146
  call: p.call_id,
41086
41147
  at: Date.parse(String(line.timestamp)),
41087
41148
  turn: typeof turn === "string" ? turn : void 0
41088
- });
41149
+ };
41150
+ if (p.input.includes(`${CODEX_TOOL_NAMESPACE}__`))
41151
+ execs.set(p.id, entry);
41152
+ else lookups.set(p.id, entry);
41153
+ }
41089
41154
  return;
41090
41155
  }
41091
41156
  if (line?.type === "response_item" && p.type === "function_call") {
@@ -41103,7 +41168,8 @@ function visitLine(st, text3, namespaces = [CODEX_TOOL_NAMESPACE]) {
41103
41168
  }
41104
41169
  if (p.type.endsWith("_output") || p.type.endsWith("_end")) {
41105
41170
  open2.delete(p.call_id);
41106
- for (const [id, e] of execs) if (e.call === p.call_id) execs.delete(id);
41171
+ for (const m of [execs, lookups])
41172
+ for (const [id, e] of m) if (e.call === p.call_id) m.delete(id);
41107
41173
  }
41108
41174
  }
41109
41175
  var record3 = (v) => v && typeof v === "object" && !Array.isArray(v) ? v : void 0;
@@ -41266,6 +41332,37 @@ function holdingFiles(pairs) {
41266
41332
  return r !== void 0 && (holders.get(r)?.has(pid2) ?? false);
41267
41333
  });
41268
41334
  }
41335
+ function lsofHolders(files2) {
41336
+ let out;
41337
+ try {
41338
+ out = execFileSync2(systemTool("lsof"), ["-F", "pn", ...files2], {
41339
+ encoding: "utf8",
41340
+ stdio: ["ignore", "pipe", "ignore"],
41341
+ timeout: 2e3
41342
+ });
41343
+ } catch (e) {
41344
+ if (!exitedOne(e)) return void 0;
41345
+ out = String(e.stdout ?? "");
41346
+ }
41347
+ const byReal = /* @__PURE__ */ new Map();
41348
+ let pid = 0;
41349
+ for (const l of out.split("\n")) {
41350
+ if (l.startsWith("p")) pid = Number(l.slice(1));
41351
+ else if (l.startsWith("n") && pid > 0) {
41352
+ const list = byReal.get(l.slice(1)) ?? [];
41353
+ list.push(pid);
41354
+ byReal.set(l.slice(1), list);
41355
+ }
41356
+ }
41357
+ const res = /* @__PURE__ */ new Map();
41358
+ for (const f of files2) {
41359
+ try {
41360
+ res.set(f, byReal.get(realpathSync2(f)) ?? []);
41361
+ } catch {
41362
+ }
41363
+ }
41364
+ return res;
41365
+ }
41269
41366
  function devParts(dev) {
41270
41367
  return {
41271
41368
  major: dev >> 8n & 0xfffn | dev >> 32n & ~0xfffn,
@@ -41713,6 +41810,52 @@ function writeCodexAgents(file2, agents) {
41713
41810
  renameSync4(tmp, file2);
41714
41811
  }
41715
41812
 
41813
+ // ../bus-daemon/src/codex-away.ts
41814
+ init_src();
41815
+ init_zod();
41816
+ import { chmodSync as chmodSync5, renameSync as renameSync5, writeFileSync as writeFileSync4 } from "node:fs";
41817
+ var AWAY_IDLE_MS = 24 * 36e5;
41818
+ var AWAY_MAX = 64;
41819
+ var CodexAwaySchema = external_exports.strictObject({
41820
+ ref: AgentRefSchema,
41821
+ name: external_exports.string().min(1).max(200),
41822
+ namespace: WireNamespaceSchema,
41823
+ /** When the thread was last live (ms), to the hour. */
41824
+ lastLive: external_exports.number().int().nonnegative()
41825
+ });
41826
+ var FileSchema3 = external_exports.strictObject({
41827
+ v: external_exports.literal(1),
41828
+ rows: external_exports.array(external_exports.unknown())
41829
+ });
41830
+ function trimAway(rows, now) {
41831
+ return rows.filter((r) => now - r.lastLive <= AWAY_IDLE_MS).sort((a, b) => b.lastLive - a.lastLive).slice(0, Math.min(AWAY_MAX, LIMITS.maxAgentsPerMachine));
41832
+ }
41833
+ function readCodexAway(file2, now, uid = process.getuid?.()) {
41834
+ try {
41835
+ const f = readOwnFile(file2, uid);
41836
+ if (f.state !== "ok") return [];
41837
+ const top = FileSchema3.safeParse(JSON.parse(f.text));
41838
+ if (!top.success) return [];
41839
+ const seen2 = /* @__PURE__ */ new Set();
41840
+ const out = [];
41841
+ for (const raw of top.data.rows) {
41842
+ const one2 = CodexAwaySchema.safeParse(raw);
41843
+ if (!one2.success || seen2.has(one2.data.ref)) continue;
41844
+ seen2.add(one2.data.ref);
41845
+ out.push(one2.data);
41846
+ }
41847
+ return trimAway(out, now);
41848
+ } catch {
41849
+ return [];
41850
+ }
41851
+ }
41852
+ function writeCodexAway(file2, rows) {
41853
+ const tmp = `${file2}.${process.pid}.tmp`;
41854
+ writeFileSync4(tmp, JSON.stringify({ v: 1, rows }), { mode: 384 });
41855
+ chmodSync5(tmp, 384);
41856
+ renameSync5(tmp, file2);
41857
+ }
41858
+
41716
41859
  // ../bus-daemon/src/codex-names.ts
41717
41860
  import { closeSync as closeSync3, constants as constants3, fstatSync as fstatSync3, openSync as openSync3, readSync as readSync2 } from "node:fs";
41718
41861
  import { join as join8 } from "node:path";
@@ -41783,13 +41926,13 @@ import { dirname as dirname6, join as join12 } from "node:path";
41783
41926
  // ../bus-daemon/src/global.ts
41784
41927
  import { randomBytes } from "node:crypto";
41785
41928
  import {
41786
- chmodSync as chmodSync5,
41929
+ chmodSync as chmodSync6,
41787
41930
  closeSync as closeSync4,
41788
41931
  lstatSync as lstatSync5,
41789
41932
  mkdirSync as mkdirSync5,
41790
41933
  openSync as openSync4,
41791
41934
  realpathSync as realpathSync3,
41792
- renameSync as renameSync5,
41935
+ renameSync as renameSync6,
41793
41936
  statSync as statSync5,
41794
41937
  unlinkSync,
41795
41938
  writeSync
@@ -41862,7 +42005,7 @@ function sameDir(entry, dir) {
41862
42005
  }
41863
42006
  function writeGlobalDirs(dirs, h = home()) {
41864
42007
  mkdirSync5(h, { recursive: true, mode: 448 });
41865
- chmodSync5(h, 448);
42008
+ chmodSync6(h, 448);
41866
42009
  const tmp = join9(h, `.global.json.${randomBytes(8).toString("hex")}.tmp`);
41867
42010
  const fd = openSync4(tmp, "wx", 384);
41868
42011
  try {
@@ -41875,8 +42018,8 @@ function writeGlobalDirs(dirs, h = home()) {
41875
42018
  }
41876
42019
  closeSync4(fd);
41877
42020
  try {
41878
- chmodSync5(tmp, 384);
41879
- renameSync5(tmp, globalFile(h));
42021
+ chmodSync6(tmp, 384);
42022
+ renameSync6(tmp, globalFile(h));
41880
42023
  } catch (e) {
41881
42024
  unlinkSync(tmp);
41882
42025
  throw e;
@@ -41900,11 +42043,11 @@ import {
41900
42043
  import { randomBytes as randomBytes2 } from "node:crypto";
41901
42044
  import {
41902
42045
  appendFileSync,
41903
- chmodSync as chmodSync6,
42046
+ chmodSync as chmodSync7,
41904
42047
  closeSync as closeSync5,
41905
42048
  mkdirSync as mkdirSync6,
41906
42049
  openSync as openSync5,
41907
- renameSync as renameSync6,
42050
+ renameSync as renameSync7,
41908
42051
  unlinkSync as unlinkSync2,
41909
42052
  writeSync as writeSync2
41910
42053
  } from "node:fs";
@@ -41956,7 +42099,7 @@ function writeRemotes(entries, h = home()) {
41956
42099
  }
41957
42100
  function writePrivate(h, name, body) {
41958
42101
  mkdirSync6(h, { recursive: true, mode: 448 });
41959
- chmodSync6(h, 448);
42102
+ chmodSync7(h, 448);
41960
42103
  const tmp = join10(h, `.${name}.${randomBytes2(8).toString("hex")}.tmp`);
41961
42104
  const fd = openSync5(tmp, "wx", 384);
41962
42105
  try {
@@ -41969,8 +42112,8 @@ function writePrivate(h, name, body) {
41969
42112
  }
41970
42113
  closeSync5(fd);
41971
42114
  try {
41972
- chmodSync6(tmp, 384);
41973
- renameSync6(tmp, join10(h, name));
42115
+ chmodSync7(tmp, 384);
42116
+ renameSync7(tmp, join10(h, name));
41974
42117
  } catch (e) {
41975
42118
  unlinkSync2(tmp);
41976
42119
  throw e;
@@ -41983,7 +42126,7 @@ function logApproval(entry, h = home(), now = /* @__PURE__ */ new Date()) {
41983
42126
  const line = `${now.toISOString()} ${entry.action} dir=${JSON.stringify(entry.dir)} namespace=${JSON.stringify(entry.namespace)} tty=${entry.tty ? "yes" : "no"}
41984
42127
  `;
41985
42128
  appendFileSync(file2, line, { mode: 384 });
41986
- chmodSync6(file2, 384);
42129
+ chmodSync7(file2, 384);
41987
42130
  }
41988
42131
 
41989
42132
  // ../bus-daemon/src/namespace.ts
@@ -42776,6 +42919,14 @@ var FramePacer = class {
42776
42919
  };
42777
42920
 
42778
42921
  // ../bus-daemon/src/hub.ts
42922
+ var HUB_HELLO_CAPS = [
42923
+ BUS_CAPS.ids,
42924
+ BUS_CAPS.mailbox,
42925
+ BUS_CAPS.links,
42926
+ BUS_CAPS.follow,
42927
+ BUS_CAPS.link,
42928
+ BUS_CAPS.waiting
42929
+ ];
42779
42930
  var HubConnection = class {
42780
42931
  constructor(opts) {
42781
42932
  this.opts = opts;
@@ -42898,13 +43049,7 @@ var HubConnection = class {
42898
43049
  // Reply ids: the hub then names each sender's agent (deliver.from_id).
42899
43050
  // Mailboxes: the hub then sends queued/since, away rows and the new
42900
43051
  // refusals, and honours agent_up.replaces (#1295).
42901
- caps: [
42902
- BUS_CAPS.ids,
42903
- BUS_CAPS.mailbox,
42904
- BUS_CAPS.links,
42905
- BUS_CAPS.follow,
42906
- BUS_CAPS.link
42907
- ]
43052
+ caps: [...HUB_HELLO_CAPS]
42908
43053
  });
42909
43054
  this.#guard("sessions", () => {
42910
43055
  this.send({
@@ -43723,11 +43868,11 @@ function routeLocal(frame, hello, reply, ctx) {
43723
43868
  init_src2();
43724
43869
  init_src();
43725
43870
  import {
43726
- chmodSync as chmodSync7,
43871
+ chmodSync as chmodSync8,
43727
43872
  readFileSync as readFileSync8,
43728
- renameSync as renameSync7,
43873
+ renameSync as renameSync8,
43729
43874
  rmSync as rmSync4,
43730
- writeFileSync as writeFileSync4
43875
+ writeFileSync as writeFileSync5
43731
43876
  } from "node:fs";
43732
43877
  var metaOf = ({
43733
43878
  at: _,
@@ -44017,12 +44162,12 @@ var SentStore = class {
44017
44162
  const tmp = `${this.file}.${process.pid}.tmp`;
44018
44163
  try {
44019
44164
  rmSync4(tmp, { force: true });
44020
- writeFileSync4(tmp, JSON.stringify(Object.fromEntries(this.#all)), {
44165
+ writeFileSync5(tmp, JSON.stringify(Object.fromEntries(this.#all)), {
44021
44166
  mode: 384,
44022
44167
  flag: "wx"
44023
44168
  });
44024
- chmodSync7(tmp, 384);
44025
- renameSync7(tmp, this.file);
44169
+ chmodSync8(tmp, 384);
44170
+ renameSync8(tmp, this.file);
44026
44171
  } catch (e) {
44027
44172
  this.#log?.(
44028
44173
  `sent file write failed: ${e instanceof Error ? e.message : String(e)}`
@@ -44211,20 +44356,20 @@ init_src3();
44211
44356
  init_src();
44212
44357
  import { createHash as createHash4, randomUUID } from "node:crypto";
44213
44358
  import {
44214
- chmodSync as chmodSync9,
44359
+ chmodSync as chmodSync10,
44215
44360
  lstatSync as lstatSync6,
44216
44361
  mkdirSync as mkdirSync7,
44217
44362
  readFileSync as readFileSync10,
44218
- renameSync as renameSync9,
44363
+ renameSync as renameSync10,
44219
44364
  rmSync as rmSync5,
44220
- writeFileSync as writeFileSync6
44365
+ writeFileSync as writeFileSync7
44221
44366
  } from "node:fs";
44222
44367
  import { createServer as createServer2 } from "node:net";
44223
44368
  import { dirname as dirname7, join as join13 } from "node:path";
44224
44369
  import { createInterface } from "node:readline";
44225
44370
 
44226
44371
  // ../bus-daemon/src/transports/held.ts
44227
- import { chmodSync as chmodSync8, readFileSync as readFileSync9, renameSync as renameSync8, writeFileSync as writeFileSync5 } from "node:fs";
44372
+ import { chmodSync as chmodSync9, readFileSync as readFileSync9, renameSync as renameSync9, writeFileSync as writeFileSync6 } from "node:fs";
44228
44373
  var HeldStore = class {
44229
44374
  constructor(file2, opts = {}) {
44230
44375
  this.file = file2;
@@ -44237,6 +44382,10 @@ var HeldStore = class {
44237
44382
  has(msgId) {
44238
44383
  return msgId in this.#read();
44239
44384
  }
44385
+ /** When `msgId` was added (ms), if it is held. */
44386
+ at(msgId) {
44387
+ return this.#read()[msgId];
44388
+ }
44240
44389
  add(msgId) {
44241
44390
  this.#write({ ...this.#read(), [msgId]: this.#now() });
44242
44391
  }
@@ -44262,9 +44411,9 @@ var HeldStore = class {
44262
44411
  }
44263
44412
  #write(all) {
44264
44413
  const tmp = `${this.file}.${process.pid}.tmp`;
44265
- writeFileSync5(tmp, JSON.stringify(all), { mode: 384 });
44266
- chmodSync8(tmp, 384);
44267
- renameSync8(tmp, this.file);
44414
+ writeFileSync6(tmp, JSON.stringify(all), { mode: 384 });
44415
+ chmodSync9(tmp, 384);
44416
+ renameSync9(tmp, this.file);
44268
44417
  }
44269
44418
  };
44270
44419
 
@@ -44601,7 +44750,7 @@ var ClaudeTransport = class {
44601
44750
  if (unsafe) throw new UnsafeDir(unsafe);
44602
44751
  } else {
44603
44752
  mkdirSync7(this.opts.socketsDir, { recursive: true, mode: 448 });
44604
- chmodSync9(this.opts.socketsDir, 448);
44753
+ chmodSync10(this.opts.socketsDir, 448);
44605
44754
  }
44606
44755
  rmSync5(path, { force: true });
44607
44756
  this.#paths.set(key2, path);
@@ -44633,7 +44782,7 @@ var ClaudeTransport = class {
44633
44782
  sink.server.once("error", reject);
44634
44783
  sink.server.listen(path, () => resolve16());
44635
44784
  });
44636
- chmodSync9(path, 384);
44785
+ chmodSync10(path, 384);
44637
44786
  return sink;
44638
44787
  }
44639
44788
  /** Paths of the sinks bound or binding now, by key. */
@@ -44673,9 +44822,9 @@ var ClaudeTransport = class {
44673
44822
  const out = /* @__PURE__ */ Object.create(null);
44674
44823
  for (const [k, v] of keep) out[k] = v;
44675
44824
  const tmp = `${file2}.${process.pid}.tmp`;
44676
- writeFileSync6(tmp, JSON.stringify(out), { mode: 384 });
44677
- chmodSync9(tmp, 384);
44678
- renameSync9(tmp, file2);
44825
+ writeFileSync7(tmp, JSON.stringify(out), { mode: 384 });
44826
+ chmodSync10(tmp, 384);
44827
+ renameSync10(tmp, file2);
44679
44828
  return out;
44680
44829
  } catch (e) {
44681
44830
  this.opts.log?.(
@@ -44933,16 +45082,34 @@ var CodexTransport = class {
44933
45082
  }
44934
45083
  async deliver(agent, mail) {
44935
45084
  if (!await this.#wakes(agent)) return { ok: false, reason: "queued" };
44936
- const r = await this.#queue(agent, mail.msg_id, codexText(agent, mail));
45085
+ const r = await this.#queue(agent.ref, mail.msg_id, codexText(agent, mail));
44937
45086
  if (r.ok) return { ok: true };
44938
45087
  return { ok: false, reason: r.taken === "no" ? "timeout" : "queued" };
44939
45088
  }
44940
45089
  /** An Open Artifacts bus notice about mail `msgId` (expired or refused); never a message from a peer. */
44941
45090
  async notify(agent, text3, msgId) {
44942
45091
  if (!await this.#wakes(agent)) return false;
44943
- const r = await this.#queue(agent, `notice:${msgId}`, `[oa-bus] ${text3}`);
45092
+ const r = await this.#queue(
45093
+ agent.ref,
45094
+ `notice:${msgId}`,
45095
+ `[oa-bus] ${text3}`
45096
+ );
44944
45097
  return r.ok || r.taken === "maybe";
44945
45098
  }
45099
+ /**
45100
+ * #2029: one fixed bus-written text into a thread that is not admitted, as
45101
+ * `id` (once per id, even after a failure). Only to a host that wakes on a
45102
+ * queued message (`pid` is that host); admission is not touched.
45103
+ */
45104
+ canWake(pid) {
45105
+ return this.opts.wakes(pid);
45106
+ }
45107
+ async wake(ref, pid, id, text3) {
45108
+ if (!await this.opts.wakes(pid)) return "no_host";
45109
+ const r = await this.#queue(ref, id, text3);
45110
+ if (r.ok) return "sent";
45111
+ return r.taken === "maybe" ? "maybe" : "failed";
45112
+ }
44946
45113
  #wakes(agent) {
44947
45114
  return agent.live ? this.opts.wakes(agent.pid) : Promise.resolve(false);
44948
45115
  }
@@ -44963,7 +45130,7 @@ var CodexTransport = class {
44963
45130
  return false;
44964
45131
  }
44965
45132
  }
44966
- async #queue(agent, id, text3) {
45133
+ async #queue(ref, id, text3) {
44967
45134
  if (this.#has(id)) return { ok: true };
44968
45135
  if (this.#has(`maybe:${id}`)) return { ok: false, taken: "maybe" };
44969
45136
  this.#bin ??= this.opts.resolve();
@@ -44977,7 +45144,7 @@ var CodexTransport = class {
44977
45144
  return { ok: false, taken: "nobin" };
44978
45145
  }
44979
45146
  this.#missingLogged = false;
44980
- const args = ["queue", `--thread=${agent.ref}`, `--message=${text3}`];
45147
+ const args = ["queue", `--thread=${ref}`, `--message=${text3}`];
44981
45148
  let res;
44982
45149
  try {
44983
45150
  res = await this.opts.run(bin.path, args, {
@@ -44996,14 +45163,12 @@ var CodexTransport = class {
44996
45163
  }
44997
45164
  if (res.code === null) {
44998
45165
  this.#keep(`maybe:${id}`);
44999
- this.opts.log?.(
45000
- `codex queue for ${agent.ref} timed out; not queued again`
45001
- );
45166
+ this.opts.log?.(`codex queue for ${ref} timed out; not queued again`);
45002
45167
  return { ok: false, taken: "maybe" };
45003
45168
  }
45004
45169
  this.#bin = void 0;
45005
45170
  this.opts.log?.(
45006
- `codex queue for ${agent.ref} exited ${res.code}: ${stripTerminalControls(res.stderr.trim()).slice(0, 300)}`
45171
+ `codex queue for ${ref} exited ${res.code}: ${stripTerminalControls(res.stderr.trim()).slice(0, 300)}`
45007
45172
  );
45008
45173
  return { ok: false, taken: "no" };
45009
45174
  }
@@ -45012,6 +45177,7 @@ var codexHostWakes = async (pid) => {
45012
45177
  const args = await processArgs(pid);
45013
45178
  return args !== void 0 && hostWakes(args);
45014
45179
  };
45180
+ var CODEX_WAKE_TEXT = `Open Artifacts bus: messages are waiting for this thread. Call the tool ${CODEX_TOOL_NAMESPACE}__self once, by that literal name (do not look it up from a tool list), to receive them.`;
45015
45181
 
45016
45182
  // ../bus-daemon/src/transports/opencode.ts
45017
45183
  init_src2();
@@ -45948,6 +46114,7 @@ async function runDaemon(deps2 = {}) {
45948
46114
  let hubLinkArg = false;
45949
46115
  let hubHelloed = false;
45950
46116
  let hubVersion;
46117
+ let hubWaiting = false;
45951
46118
  const hub = new HubConnection({
45952
46119
  url: `${cfg.hub.replace(/^http/, "ws").replace(/\/+$/, "")}${BUS_ROUTES.connect}`,
45953
46120
  token: cfg.machine_token,
@@ -46064,6 +46231,7 @@ async function runDaemon(deps2 = {}) {
46064
46231
  hubIds = frame.caps?.includes(BUS_CAPS.ids) ?? false;
46065
46232
  hubMailbox = frame.caps?.includes(BUS_CAPS.mailbox) ?? false;
46066
46233
  hubFollow = frame.caps?.includes(BUS_CAPS.follow) ?? false;
46234
+ hubWaiting = frame.caps?.includes(BUS_CAPS.waiting) ?? false;
46067
46235
  hubLink = frame.caps?.includes(BUS_CAPS.link) ?? false;
46068
46236
  hubLinkArg = frame.caps?.includes(BUS_CAPS.linkArg) ?? false;
46069
46237
  hubHelloed = true;
@@ -46092,7 +46260,7 @@ async function runDaemon(deps2 = {}) {
46092
46260
  log(`this machine was revoked; run \`${BUS_CMD} install\``);
46093
46261
  process.exitCode = 1;
46094
46262
  try {
46095
- writeFileSync7(
46263
+ writeFileSync8(
46096
46264
  deps2.revokedFile ?? join16(home(), "revoked"),
46097
46265
  revokedMarker(cfg.machine_token),
46098
46266
  { mode: 384 }
@@ -46420,7 +46588,10 @@ async function runDaemon(deps2 = {}) {
46420
46588
  live: true
46421
46589
  });
46422
46590
  if (rec.kind === "opencode") ocServiceStart.set(rec.ref, ocStart(pid));
46423
- if (rec.kind === "codex") persistCodex();
46591
+ if (rec.kind === "codex") {
46592
+ persistCodex();
46593
+ trackAway();
46594
+ }
46424
46595
  if (rec.kind === "claude-code") {
46425
46596
  seedLinks(rec);
46426
46597
  void claude.revive(rec.ref);
@@ -46636,10 +46807,185 @@ async function runDaemon(deps2 = {}) {
46636
46807
  if (debug) log(`restored codex thread ${r.ref.slice(0, 8)} pid ${r.pid}`);
46637
46808
  }
46638
46809
  };
46810
+ const awayFile = cx.awayFile ?? join16(home(), "codex-away.json");
46811
+ const awayNow = deps2.bindingNow ?? Date.now;
46812
+ const HOUR = 36e5;
46813
+ const awayRows = new Map(
46814
+ readCodexAway(awayFile, awayNow()).map((r) => [r.ref, r])
46815
+ );
46816
+ let awaySaved;
46817
+ const trackAway = () => {
46818
+ const now = awayNow();
46819
+ for (const a of agents.all()) {
46820
+ if (a.kind !== "codex") continue;
46821
+ const prev = awayRows.get(a.ref);
46822
+ const lastLive = a.live ? Math.floor(now / HOUR) * HOUR : prev?.lastLive ?? Math.floor(now / HOUR) * HOUR;
46823
+ if (!WireNamespaceSchema.safeParse(a.namespace).success || !AgentRefSchema.safeParse(a.ref).success)
46824
+ continue;
46825
+ awayRows.set(a.ref, {
46826
+ ref: a.ref,
46827
+ name: a.busName,
46828
+ namespace: a.namespace,
46829
+ lastLive
46830
+ });
46831
+ }
46832
+ const kept = trimAway([...awayRows.values()], now);
46833
+ awayRows.clear();
46834
+ for (const r of kept) awayRows.set(r.ref, r);
46835
+ const text3 = JSON.stringify(kept);
46836
+ if (awaySaved === void 0 ? kept.length === 0 : text3 === awaySaved)
46837
+ return;
46838
+ try {
46839
+ writeCodexAway(awayFile, kept);
46840
+ awaySaved = text3;
46841
+ } catch (e) {
46842
+ log(
46843
+ `could not save the Codex away threads: ${e instanceof Error ? e.message : String(e)}`
46844
+ );
46845
+ }
46846
+ };
46847
+ const woken = new HeldStore(
46848
+ cx.wokenFile ?? join16(home(), "codex-woken.json"),
46849
+ { ttlMs: 7 * 24 * HOUR }
46850
+ );
46851
+ const wakeLogged = /* @__PURE__ */ new Set();
46852
+ const wakeAsked = /* @__PURE__ */ new Map();
46853
+ let waking = false;
46854
+ let wakeCheckedAt;
46855
+ const wakeSent = /* @__PURE__ */ new Map();
46856
+ const wakeWaiting = /* @__PURE__ */ new Map();
46857
+ const WAKES_MAX = 3;
46858
+ const wakeAway = async () => {
46859
+ if (waking) return;
46860
+ waking = true;
46861
+ try {
46862
+ const now = awayNow();
46863
+ for (const [k, w] of wakeSent) {
46864
+ if (agents.byRef(w.ref)?.live) wakeSent.delete(k);
46865
+ else if (!w.logged && now - w.at >= (cx.wakeAnswerMs ?? 3e5)) {
46866
+ w.logged = true;
46867
+ log(`codex wake ${w.ref.slice(0, 8)} wake_unanswered`);
46868
+ }
46869
+ }
46870
+ const rows = [...awayRows.values()].filter(
46871
+ (r) => now - r.lastLive <= AWAY_IDLE_MS && !agents.byRef(r.ref)?.live
46872
+ );
46873
+ const away = new Set(rows.map((r) => r.ref));
46874
+ for (const [k, w] of wakeSent) if (!away.has(w.ref)) wakeSent.delete(k);
46875
+ for (const m of [wakeAsked, wakeWaiting])
46876
+ for (const k of m.keys())
46877
+ if (!away.has(k.split(":")[1] ?? "")) m.delete(k);
46878
+ if (!rows.length) return;
46879
+ if (wakeCheckedAt !== void 0 && now - wakeCheckedAt < (cx.wakeCheckMs ?? 3e5))
46880
+ return;
46881
+ wakeCheckedAt = now;
46882
+ const held2 = codexCheck.holders(rows.map((r) => r.ref));
46883
+ if (!held2) return;
46884
+ const once2 = (key2, msg) => {
46885
+ if (wakeLogged.has(key2 + msg)) return;
46886
+ wakeLogged.add(key2 + msg);
46887
+ if (wakeLogged.size > 500) wakeLogged.clear();
46888
+ log(msg);
46889
+ };
46890
+ for (const r of rows) {
46891
+ const h = held2.get(r.ref);
46892
+ if (!h) continue;
46893
+ const key2 = `wake:${r.ref}:${h.pid}:${h.start.replace(/\s+/g, "_")}`;
46894
+ const who = `codex wake ${r.ref.slice(0, 8)} pid ${h.pid}`;
46895
+ let n = 1;
46896
+ while (n <= WAKES_MAX && woken.has(`${key2}#${n}`)) n++;
46897
+ if (n > WAKES_MAX) continue;
46898
+ const againAfter = n > 1 ? woken.at(`${key2}#${n - 1}`) ?? now : void 0;
46899
+ if (againAfter !== void 0) {
46900
+ if (now - againAfter < (cx.wakeAgainMs ?? 36e5) || !wakeWaiting.has(key2))
46901
+ continue;
46902
+ }
46903
+ const asker = agents.all().find((a) => a.live);
46904
+ if (!asker || !hub.open || hubVersion === void 0) {
46905
+ once2(key2, `${who} skipped: no live agent to ask the hub`);
46906
+ continue;
46907
+ }
46908
+ if (!hubWaiting) {
46909
+ once2(key2, `${who} skipped: the hub does not report waiting mail`);
46910
+ continue;
46911
+ }
46912
+ const last = wakeAsked.get(key2);
46913
+ if (last !== void 0 && now - last < (cx.wakeAskMs ?? 3e5))
46914
+ continue;
46915
+ wakeAsked.set(key2, now);
46916
+ const roster2 = await hubRoster(asker.ref);
46917
+ if (!roster2) {
46918
+ once2(key2 + now, `${who} skipped: the hub did not answer`);
46919
+ continue;
46920
+ }
46921
+ const row = roster2.find(
46922
+ (a) => a.state === "away" && a.name === r.name && a.namespace === r.namespace && (a.machine_label === void 0 || a.machine_label === cfg.label)
46923
+ );
46924
+ if (!row?.waiting) {
46925
+ once2(key2, `${who} skipped: no mail waiting`);
46926
+ continue;
46927
+ }
46928
+ if (n > 1 && row.waiting === wakeWaiting.get(key2) && row.waiting < 100) {
46929
+ once2(
46930
+ key2 + n,
46931
+ `${who} skipped: the mail count has not changed since the last wake`
46932
+ );
46933
+ continue;
46934
+ }
46935
+ if (!await codex.canWake(h.pid)) {
46936
+ once2(
46937
+ key2,
46938
+ `${who} skipped: the process does not wake on a queued message`
46939
+ );
46940
+ continue;
46941
+ }
46942
+ try {
46943
+ woken.add(`${key2}#${n}`);
46944
+ } catch (e) {
46945
+ once2(
46946
+ key2,
46947
+ `${who} skipped: could not record the wake (${e instanceof Error ? e.message : String(e)})`
46948
+ );
46949
+ continue;
46950
+ }
46951
+ const res = await codex.wake(
46952
+ r.ref,
46953
+ h.pid,
46954
+ `${key2}#${n}`,
46955
+ CODEX_WAKE_TEXT
46956
+ );
46957
+ wakeWaiting.set(key2, row.waiting);
46958
+ if (res === "failed" || res === "maybe")
46959
+ try {
46960
+ for (let m = n + 1; m <= WAKES_MAX; m++) woken.add(`${key2}#${m}`);
46961
+ } catch {
46962
+ }
46963
+ if (res === "sent")
46964
+ wakeSent.set(key2, { ref: r.ref, at: now, logged: false });
46965
+ log(
46966
+ res === "sent" ? `${who} sent` : res === "no_host" ? `${who} skipped: the process does not wake on a queued message` : `${who} failed: ${res}`
46967
+ );
46968
+ }
46969
+ } catch (e) {
46970
+ log(`codex wake failed: ${e instanceof Error ? e.message : String(e)}`);
46971
+ } finally {
46972
+ waking = false;
46973
+ }
46974
+ };
46639
46975
  const syncCodex = () => {
46976
+ try {
46977
+ syncCodexInner();
46978
+ } finally {
46979
+ trackAway();
46980
+ if (!deps2.attest && relockTickNow) void wakeAway();
46981
+ }
46982
+ };
46983
+ let relockTickNow = false;
46984
+ const syncCodexInner = () => {
46640
46985
  renameCodexThreads();
46641
46986
  codexTicks = (codexTicks + 1) % relockEvery;
46642
46987
  const relockTick = codexTicks === 0;
46988
+ relockTickNow = relockTick;
46643
46989
  const all = agents.all().filter((a) => a.kind === "codex" && (a.live || relockTick)).map((a) => ({ thread: a.ref, pid: a.pid, live: a.live }));
46644
46990
  if (!all.length || deps2.attest) return persistCodex();
46645
46991
  const still = codexCheck.sweep(all, relockTick);
@@ -46780,15 +47126,15 @@ var realDeps = {
46780
47126
  init_src();
46781
47127
  import { createHash as createHash5 } from "node:crypto";
46782
47128
  import {
46783
- chmodSync as chmodSync11,
47129
+ chmodSync as chmodSync12,
46784
47130
  cpSync,
46785
47131
  existsSync as existsSync4,
46786
47132
  lstatSync as lstatSync10,
46787
47133
  mkdirSync as mkdirSync9,
46788
47134
  realpathSync as realpathSync8,
46789
- renameSync as renameSync11,
47135
+ renameSync as renameSync12,
46790
47136
  rmSync as rmSync6,
46791
- writeFileSync as writeFileSync9
47137
+ writeFileSync as writeFileSync10
46792
47138
  } from "node:fs";
46793
47139
  import { basename as basename6, dirname as dirname9, isAbsolute as isAbsolute8, join as join18, resolve as resolve5 } from "node:path";
46794
47140
  import { fileURLToPath } from "node:url";
@@ -47842,11 +48188,11 @@ async function readCodexVersion(o) {
47842
48188
 
47843
48189
  // src/steps/step.ts
47844
48190
  import {
47845
- chmodSync as chmodSync10,
48191
+ chmodSync as chmodSync11,
47846
48192
  mkdirSync as mkdirSync8,
47847
48193
  readFileSync as readFileSync13,
47848
- renameSync as renameSync10,
47849
- writeFileSync as writeFileSync8
48194
+ renameSync as renameSync11,
48195
+ writeFileSync as writeFileSync9
47850
48196
  } from "node:fs";
47851
48197
  import { dirname as dirname8 } from "node:path";
47852
48198
  function readInstallFile(path) {
@@ -47862,10 +48208,10 @@ function updateInstallFile(path, patch) {
47862
48208
  const next = { ...readInstallFile(path), ...patch };
47863
48209
  mkdirSync8(dirname8(path), { recursive: true, mode: 448 });
47864
48210
  const tmp = `${path}.${process.pid}.tmp`;
47865
- writeFileSync8(tmp, `${JSON.stringify(next, null, 2)}
48211
+ writeFileSync9(tmp, `${JSON.stringify(next, null, 2)}
47866
48212
  `, { mode: 384 });
47867
- chmodSync10(tmp, 384);
47868
- renameSync10(tmp, path);
48213
+ chmodSync11(tmp, 384);
48214
+ renameSync11(tmp, path);
47869
48215
  }
47870
48216
  async function runSteps(steps, ctx, record7) {
47871
48217
  for (const step2 of steps) {
@@ -48021,7 +48367,7 @@ function installCli(home2, src, node2) {
48021
48367
  const bin = join18(home2, "bin");
48022
48368
  const tmp = `${bin}.${process.pid}.tmp`;
48023
48369
  mkdirSync9(home2, { recursive: true, mode: 448 });
48024
- chmodSync11(home2, 448);
48370
+ chmodSync12(home2, 448);
48025
48371
  rmSync6(tmp, { recursive: true, force: true });
48026
48372
  mkdirSync9(tmp);
48027
48373
  if (src.kind === "bundle") {
@@ -48029,16 +48375,16 @@ function installCli(home2, src, node2) {
48029
48375
  for (const name of ["dist", "assets", "package.json"])
48030
48376
  if (existsSync4(join18(pkg, name)))
48031
48377
  cpSync(join18(pkg, name), join18(tmp, name), { recursive: true });
48032
- } else writeFileSync9(join18(tmp, entryName(src)), shim(src));
48033
- chmodSync11(tmp, 448);
48378
+ } else writeFileSync10(join18(tmp, entryName(src)), shim(src));
48379
+ chmodSync12(tmp, 448);
48034
48380
  if (node2 !== void 0) {
48035
- writeFileSync9(join18(tmp, "node"), launcherText(node2), { mode: 448 });
48036
- chmodSync11(join18(tmp, "node"), 448);
48381
+ writeFileSync10(join18(tmp, "node"), launcherText(node2), { mode: 448 });
48382
+ chmodSync12(join18(tmp, "node"), 448);
48037
48383
  }
48038
48384
  if (!existsSync4(join18(tmp, "package.json")))
48039
- writeFileSync9(join18(tmp, "package.json"), '{ "type": "module" }\n');
48385
+ writeFileSync10(join18(tmp, "package.json"), '{ "type": "module" }\n');
48040
48386
  rmSync6(bin, { recursive: true, force: true });
48041
- renameSync11(tmp, bin);
48387
+ renameSync12(tmp, bin);
48042
48388
  return join18(bin, entryName(src));
48043
48389
  }
48044
48390
  var present = (path) => {
@@ -48053,8 +48399,8 @@ function writeReplacing(path, text3) {
48053
48399
  mkdirSync9(dirname9(path), { recursive: true });
48054
48400
  const tmp = `${path}.${process.pid}.tmp`;
48055
48401
  try {
48056
- writeFileSync9(tmp, text3, { mode: 420 });
48057
- renameSync11(tmp, path);
48402
+ writeFileSync10(tmp, text3, { mode: 420 });
48403
+ renameSync12(tmp, path);
48058
48404
  } catch (e) {
48059
48405
  rmSync6(tmp, { force: true });
48060
48406
  throw e;
@@ -48302,7 +48648,7 @@ var noService = {
48302
48648
  remove: async () => ({}),
48303
48649
  cli: () => ["oa-bus"]
48304
48650
  };
48305
- var VERSION = true ? "0.153.0" : JSON.parse(
48651
+ var VERSION = true ? "0.154.0" : JSON.parse(
48306
48652
  readFileSync14(new URL("../package.json", import.meta.url), "utf8")
48307
48653
  ).version;
48308
48654
  var which = (cmd) => {
@@ -48562,16 +48908,16 @@ var OPENCODE_TUI_PLUGIN = fileURLToPath2(
48562
48908
  // src/steps/adapters.ts
48563
48909
  import { randomBytes as randomBytes6 } from "node:crypto";
48564
48910
  import {
48565
- chmodSync as chmodSync13,
48911
+ chmodSync as chmodSync14,
48566
48912
  existsSync as existsSync12,
48567
48913
  lstatSync as lstatSync15,
48568
48914
  mkdirSync as mkdirSync12,
48569
48915
  readFileSync as readFileSync24,
48570
48916
  readlinkSync as readlinkSync4,
48571
- renameSync as renameSync14,
48917
+ renameSync as renameSync15,
48572
48918
  rmSync as rmSync14,
48573
48919
  statSync as statSync10,
48574
- writeFileSync as writeFileSync12
48920
+ writeFileSync as writeFileSync13
48575
48921
  } from "node:fs";
48576
48922
  import { dirname as dirname13, join as join27, resolve as resolve11 } from "node:path";
48577
48923
  import { isDeepStrictEqual } from "node:util";
@@ -50250,10 +50596,10 @@ import {
50250
50596
  readFileSync as readFileSync18,
50251
50597
  readlinkSync as readlinkSync2,
50252
50598
  realpathSync as realpathSync9,
50253
- renameSync as renameSync12,
50599
+ renameSync as renameSync13,
50254
50600
  rmdirSync,
50255
50601
  rmSync as rmSync8,
50256
- writeFileSync as writeFileSync10
50602
+ writeFileSync as writeFileSync11
50257
50603
  } from "node:fs";
50258
50604
  import {
50259
50605
  basename as basename7,
@@ -50506,15 +50852,15 @@ async function installHermes(deps2) {
50506
50852
  mkdirSync10(join22(tmp, f, ".."), { recursive: true });
50507
50853
  cpSync2(join22(shipped, f), join22(tmp, f));
50508
50854
  }
50509
- writeFileSync10(
50855
+ writeFileSync11(
50510
50856
  join22(tmp, HERMES_MARKER),
50511
50857
  `managed by the Open Artifacts bus installer: edits are replaced on reinstall. ${pluginHash(shipped)}
50512
50858
  `
50513
50859
  );
50514
50860
  if (keepHabits)
50515
- writeFileSync10(join22(tmp, HERMES_HABITS_MARKER), HABITS_MARKER_TEXT);
50861
+ writeFileSync11(join22(tmp, HERMES_HABITS_MARKER), HABITS_MARKER_TEXT);
50516
50862
  if (state === "stale") rmSync8(dest, { recursive: true, force: true });
50517
- renameSync12(tmp, dest);
50863
+ renameSync13(tmp, dest);
50518
50864
  } catch (e) {
50519
50865
  rmSync8(tmp, { recursive: true, force: true });
50520
50866
  throw e;
@@ -50581,7 +50927,7 @@ import { fileURLToPath as fileURLToPath5 } from "node:url";
50581
50927
 
50582
50928
  // src/steps/skill.ts
50583
50929
  import {
50584
- chmodSync as chmodSync12,
50930
+ chmodSync as chmodSync13,
50585
50931
  existsSync as existsSync7,
50586
50932
  lstatSync as lstatSync12,
50587
50933
  mkdirSync as mkdirSync11,
@@ -50589,11 +50935,11 @@ import {
50589
50935
  readFileSync as readFileSync19,
50590
50936
  readlinkSync as readlinkSync3,
50591
50937
  realpathSync as realpathSync10,
50592
- renameSync as renameSync13,
50938
+ renameSync as renameSync14,
50593
50939
  rmdirSync as rmdirSync2,
50594
50940
  rmSync as rmSync9,
50595
50941
  statSync as statSync9,
50596
- writeFileSync as writeFileSync11
50942
+ writeFileSync as writeFileSync12
50597
50943
  } from "node:fs";
50598
50944
  import { dirname as dirname11, join as join23, resolve as resolve7 } from "node:path";
50599
50945
  var SKILL_MARKER = "<!-- managed by the Open Artifacts bus installer: edits are replaced on reinstall. -->";
@@ -50753,9 +51099,9 @@ var writeAtomic = (path, text3) => {
50753
51099
  mode = statSync9(path).mode & 4095;
50754
51100
  } catch {
50755
51101
  }
50756
- writeFileSync11(tmp, text3);
50757
- if (mode !== void 0) chmodSync12(tmp, mode);
50758
- renameSync13(tmp, path);
51102
+ writeFileSync12(tmp, text3);
51103
+ if (mode !== void 0) chmodSync13(tmp, mode);
51104
+ renameSync14(tmp, path);
50759
51105
  } catch (e) {
50760
51106
  try {
50761
51107
  rmSync9(tmp, { force: true });
@@ -52228,9 +52574,9 @@ function writeAtomic2(path, data, mode) {
52228
52574
  }
52229
52575
  const tmp = `${dest}.${process.pid}.${randomBytes6(4).toString("hex")}.tmp`;
52230
52576
  try {
52231
- writeFileSync12(tmp, data, { mode: m, flag: "wx" });
52232
- chmodSync13(tmp, m);
52233
- renameSync14(tmp, dest);
52577
+ writeFileSync13(tmp, data, { mode: m, flag: "wx" });
52578
+ chmodSync14(tmp, m);
52579
+ renameSync15(tmp, dest);
52234
52580
  } catch (e) {
52235
52581
  rmSync14(tmp, { force: true });
52236
52582
  throw e;
@@ -53299,11 +53645,11 @@ function habitsLine(ctx) {
53299
53645
  init_src();
53300
53646
  import { randomBytes as randomBytes7 } from "node:crypto";
53301
53647
  import {
53302
- chmodSync as chmodSync14,
53648
+ chmodSync as chmodSync15,
53303
53649
  closeSync as closeSync7,
53304
53650
  mkdirSync as mkdirSync13,
53305
53651
  openSync as openSync7,
53306
- renameSync as renameSync15,
53652
+ renameSync as renameSync16,
53307
53653
  rmSync as rmSync16,
53308
53654
  unlinkSync as unlinkSync3,
53309
53655
  writeSync as writeSync3
@@ -53355,7 +53701,7 @@ function checkVerificationUri(uri, hub) {
53355
53701
  }
53356
53702
  function writeMachineFile(home2, body) {
53357
53703
  mkdirSync13(home2, { recursive: true, mode: 448 });
53358
- chmodSync14(home2, 448);
53704
+ chmodSync15(home2, 448);
53359
53705
  const tmp = join30(home2, `.machine.json.${randomBytes7(8).toString("hex")}.tmp`);
53360
53706
  const fd = openSync7(tmp, "wx", 384);
53361
53707
  try {
@@ -53367,8 +53713,8 @@ function writeMachineFile(home2, body) {
53367
53713
  }
53368
53714
  closeSync7(fd);
53369
53715
  try {
53370
- chmodSync14(tmp, 384);
53371
- renameSync15(tmp, join30(home2, "machine.json"));
53716
+ chmodSync15(tmp, 384);
53717
+ renameSync16(tmp, join30(home2, "machine.json"));
53372
53718
  } catch (e) {
53373
53719
  unlinkSync3(tmp);
53374
53720
  throw e;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@open-artifacts/bus",
3
3
  "type": "module",
4
- "version": "0.153.0",
4
+ "version": "0.154.0",
5
5
  "description": "The Open Artifacts bus: your AI agents reach each other across machines.",
6
6
  "license": "MIT",
7
7
  "repository": {