@open-artifacts/bus 0.239.0 → 0.239.2

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.239.0";
14
+ const CLIENT_VERSION = "0.239.2";
15
15
 
16
16
  type Frame = Json & { type: string; id: string };
17
17
  type Ctx = {
@@ -27876,7 +27876,7 @@ var base2 = { v: external_exports.literal(V), id: external_exports.string().min(
27876
27876
  var late = { late: external_exports.array(external_exports.string().min(1)).optional() };
27877
27877
  var isWellFormed2 = (s) => s.isWellFormed();
27878
27878
  var WELL_FORMED = { message: "text is not well-formed unicode" };
27879
- var CLIENT_VERSION = true ? "0.239.0" : "0.0.0";
27879
+ var CLIENT_VERSION = true ? "0.239.2" : "0.0.0";
27880
27880
  var clientVersion = {
27881
27881
  client_version: external_exports.string().min(1).max(64).optional()
27882
27882
  };
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oa-bus",
3
- "version": "0.239.0",
3
+ "version": "0.239.2",
4
4
  "type": "module",
5
5
  "openclaw": {
6
6
  "extensions": [
package/dist/index.js CHANGED
@@ -32905,7 +32905,7 @@ var init_frames = __esm({
32905
32905
  late = { late: external_exports.array(external_exports.string().min(1)).optional() };
32906
32906
  isWellFormed2 = (s) => s.isWellFormed();
32907
32907
  WELL_FORMED = { message: "text is not well-formed unicode" };
32908
- CLIENT_VERSION = true ? "0.239.0" : "0.0.0";
32908
+ CLIENT_VERSION = true ? "0.239.2" : "0.0.0";
32909
32909
  clientVersion = {
32910
32910
  client_version: external_exports.string().min(1).max(64).optional()
32911
32911
  };
@@ -59599,7 +59599,7 @@ var noService = {
59599
59599
  remove: async () => ({}),
59600
59600
  cli: () => ["oa-bus"]
59601
59601
  };
59602
- var VERSION = true ? "0.239.0" : JSON.parse(
59602
+ var VERSION = true ? "0.239.2" : JSON.parse(
59603
59603
  readFileSync23(new URL("../package.json", import.meta.url), "utf8")
59604
59604
  ).version;
59605
59605
  var which = (cmd) => {
@@ -61032,6 +61032,9 @@ var PI_EXTENSION = fileURLToPath4(
61032
61032
  new URL("../assets/oa-bus.ts", import.meta.url)
61033
61033
  );
61034
61034
 
61035
+ // ../shared/src/secrets.ts
61036
+ var hostSlug = (host) => host.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "") || "instance";
61037
+
61035
61038
  // src/steps/claude-proof.ts
61036
61039
  import { lstatSync as lstatSync13, readFileSync as readFileSync24 } from "node:fs";
61037
61040
  import { join as join31, resolve as resolve7 } from "node:path";
@@ -61464,28 +61467,39 @@ function otherSwapped(io, doc, name) {
61464
61467
  const cur = servers2(doc)[m.name];
61465
61468
  return isRecord5(cur) && ourEntry(cur, m.origin) ? m.name : void 0;
61466
61469
  }
61467
- var proxyArgs = (origin, tokenEnv) => [
61470
+ var proxyArgs = (origin, cred) => [
61468
61471
  PROXY_CMD,
61469
61472
  "--instance",
61470
61473
  origin,
61471
61474
  "--for",
61472
61475
  "codex",
61473
- "--token-env",
61474
- tokenEnv
61476
+ ...cred.tokenEnv !== void 0 ? ["--token-env", cred.tokenEnv] : ["--token-file", cred.tokenFile]
61475
61477
  ];
61476
61478
  function ourEntry(e, origin) {
61477
61479
  if (typeof e.command !== "string" || !Array.isArray(e.args)) return void 0;
61478
61480
  const a = e.args;
61479
61481
  const i = a.lastIndexOf(PROXY_CMD);
61480
- if (i < 0 || a[i + 1] !== "--instance" || a[i + 2] !== origin || a[i + 3] !== "--for" || a[i + 4] !== "codex" || a[i + 5] !== "--token-env" || typeof a[i + 6] !== "string")
61482
+ if (i < 0 || a[i + 1] !== "--instance" || a[i + 2] !== origin)
61481
61483
  return void 0;
61482
- return { tokenEnv: a[i + 6] };
61484
+ if (a[i + 3] !== "--for" || a[i + 4] !== "codex") return void 0;
61485
+ if (a[i + 5] === "--token-env" && typeof a[i + 6] === "string")
61486
+ return { tokenEnv: a[i + 6] };
61487
+ if (a[i + 5] === "--token-file" && typeof a[i + 6] === "string")
61488
+ return { tokenFile: a[i + 6] };
61489
+ return void 0;
61483
61490
  }
61484
- function plan(doc, origin) {
61491
+ function plan(doc, origin, patFile) {
61485
61492
  for (const [name, e] of Object.entries(servers2(doc))) {
61486
61493
  if (name === CODEX_ENTRY || !isRecord5(e)) continue;
61487
61494
  const ours2 = ourEntry(e, origin);
61488
- if (ours2) return { kind: "ours", name, entry: e };
61495
+ if (ours2) {
61496
+ if (ours2.tokenFile !== void 0 && !existsSync10(ours2.tokenFile))
61497
+ return {
61498
+ kind: "note",
61499
+ note: `the ${name} entry in the Codex config reaches Open Artifacts through oa-bus, but its PAT file ${ours2.tokenFile} is gone, so Codex has no token and its tools fail. Save a PAT there again, or run ${BUS_CMD} uninstall to put your own entry back.`
61500
+ };
61501
+ return { kind: "ours", name, entry: e };
61502
+ }
61489
61503
  if (!isInstance(e, origin) || e.enabled === false) continue;
61490
61504
  const left = (why2) => ({
61491
61505
  kind: "note",
@@ -61502,17 +61516,24 @@ function plan(doc, origin) {
61502
61516
  return left("it is written in a form oa-bus can't edit.");
61503
61517
  const blocker = BLOCKING.find((k) => e[k] !== void 0);
61504
61518
  const tokenEnv = e.bearer_token_env_var;
61505
- if (blocker !== void 0 || typeof tokenEnv !== "string" || !VAR.test(tokenEnv))
61506
- return left(
61507
- "it signs in with `codex mcp login` or another kind of token that oa-bus can't pass on."
61508
- );
61509
- return { kind: "swap", name, entry: e, tokenEnv };
61519
+ if (typeof tokenEnv === "string" && VAR.test(tokenEnv)) {
61520
+ if (blocker !== void 0)
61521
+ return left(
61522
+ "it signs in with another kind of token that oa-bus can't pass on."
61523
+ );
61524
+ return { kind: "swap", name, entry: e, cred: { tokenEnv } };
61525
+ }
61526
+ if (blocker === void 0 && patFile !== void 0 && existsSync10(patFile))
61527
+ return { kind: "swap", name, entry: e, cred: { tokenFile: patFile } };
61528
+ return left(
61529
+ patFile === void 0 ? "it signs in with `codex mcp login` or another kind of token that oa-bus can't pass on." : `it signs in with \`codex mcp login\` or another kind of token that oa-bus can't pass on, and there is no PAT at ${patFile} for the proxy to use. Save one there (see the connect guide) and run oa-bus install again.`
61530
+ );
61510
61531
  }
61511
61532
  return { kind: "none" };
61512
61533
  }
61513
61534
  function pendingEntry(io, origin) {
61514
61535
  const { doc } = readToml(io.file);
61515
- const p = plan(doc, origin);
61536
+ const p = plan(doc, origin, io.patFile);
61516
61537
  if (p.kind === "swap") {
61517
61538
  const other = otherSwapped(io, doc, p.name);
61518
61539
  if (other !== void 0)
@@ -61524,11 +61545,12 @@ function pendingEntry(io, origin) {
61524
61545
  if (p.kind === "note") return { note: p.note };
61525
61546
  return void 0;
61526
61547
  }
61527
- var wantEntry = (io, origin, tokenEnv) => {
61548
+ var wantEntry = (io, origin, cred) => {
61528
61549
  const add2 = [
61529
61550
  `command = ${str2(io.busBin[0])}`,
61530
- `args = [${[...io.busBin.slice(1), ...proxyArgs(origin, tokenEnv)].map(str2).join(", ")}]`,
61531
- `env_vars = [${str2(tokenEnv)}]`,
61551
+ `args = [${[...io.busBin.slice(1), ...proxyArgs(origin, cred)].map(str2).join(", ")}]`,
61552
+ // A token variable is passed on by name; a PAT file is read by the proxy.
61553
+ ...cred.tokenEnv !== void 0 ? [`env_vars = [${str2(cred.tokenEnv)}]`] : [],
61532
61554
  ...io.busHome ? [`env = { OA_BUS_HOME = ${str2(io.busHome)} }`] : []
61533
61555
  ];
61534
61556
  return add2;
@@ -61552,7 +61574,7 @@ function checked2(file2, before, next, name, entry) {
61552
61574
  var readTomlText = (text3) => parse4(text3);
61553
61575
  function installEntry(io, origin) {
61554
61576
  const { text: text3, doc } = readToml(io.file);
61555
- const p = plan(doc, origin);
61577
+ const p = plan(doc, origin, io.patFile);
61556
61578
  if (p.kind === "note") return { notes: [p.note] };
61557
61579
  if (p.kind === "none") return { notes: [] };
61558
61580
  if (p.kind === "swap") {
@@ -61565,8 +61587,8 @@ function installEntry(io, origin) {
61565
61587
  };
61566
61588
  }
61567
61589
  if (p.kind === "ours") {
61568
- const tokenEnv = ourEntry(p.entry, origin).tokenEnv;
61569
- const e2 = edit(text3, p.name, OURS, wantEntry(io, origin, tokenEnv));
61590
+ const cred = ourEntry(p.entry, origin);
61591
+ const e2 = edit(text3, p.name, OURS, wantEntry(io, origin, cred));
61570
61592
  if (!e2) return { notes: [] };
61571
61593
  if (e2.next === text3) return { notes: [] };
61572
61594
  const m = readMoved(io.moved);
@@ -61574,7 +61596,7 @@ function installEntry(io, origin) {
61574
61596
  for (const k of OURS) delete want2[k];
61575
61597
  const fresh2 = plain(
61576
61598
  readTomlText(`[x]
61577
- ${wantEntry(io, origin, tokenEnv).join("\n")}
61599
+ ${wantEntry(io, origin, cred).join("\n")}
61578
61600
  `).x
61579
61601
  );
61580
61602
  io.write(checked2(io.file, doc, e2.next, p.name, { ...want2, ...fresh2 }));
@@ -61592,8 +61614,9 @@ ${wantEntry(io, origin, tokenEnv).join("\n")}
61592
61614
  ]
61593
61615
  };
61594
61616
  const mine = lines.slice(at.from, at.to).filter((l) => MOVED_KEYS.includes(keyOf(l.text))).map((l) => l.text);
61595
- const e = edit(text3, p.name, MOVED_KEYS, wantEntry(io, origin, p.tokenEnv));
61596
- if (!e || mine.length !== MOVED_KEYS.length)
61617
+ const need = p.cred.tokenEnv !== void 0 ? 2 : 1;
61618
+ const e = edit(text3, p.name, MOVED_KEYS, wantEntry(io, origin, p.cred));
61619
+ if (!e || mine.length !== need)
61597
61620
  return {
61598
61621
  notes: [
61599
61622
  `left the ${p.name} entry in ${io.file} as it is: it is written in a form oa-bus can't edit. Its tools still work, but Codex won't show as its own session on pages.`
@@ -61603,7 +61626,7 @@ ${wantEntry(io, origin, tokenEnv).join("\n")}
61603
61626
  for (const k of MOVED_KEYS) delete want[k];
61604
61627
  const fresh = plain(
61605
61628
  readTomlText(`[x]
61606
- ${wantEntry(io, origin, p.tokenEnv).join("\n")}
61629
+ ${wantEntry(io, origin, p.cred).join("\n")}
61607
61630
  `).x
61608
61631
  );
61609
61632
  const next = checked2(io.file, doc, e.next, p.name, { ...want, ...fresh });
@@ -61614,7 +61637,7 @@ ${wantEntry(io, origin, p.tokenEnv).join("\n")}
61614
61637
  io.write(next);
61615
61638
  return {
61616
61639
  notes: [
61617
- `Codex now reaches Open Artifacts through oa-bus (the ${p.name} entry in ${io.file}). To undo, run ${BUS_CMD} uninstall: it puts your entry back.`
61640
+ `Codex now reaches Open Artifacts through oa-bus (the ${p.name} entry in ${io.file}). ${p.cred.tokenEnv !== void 0 ? `It sends the token in ${p.cred.tokenEnv}.` : `Codex's Pages calls now go out with the PAT in ${p.cred.tokenFile}, not with the sign-in this entry had; that sign-in stays where it is, unused.`} To undo, run ${BUS_CMD} uninstall: it puts your entry back.`
61618
61641
  ]
61619
61642
  };
61620
61643
  }
@@ -63833,8 +63856,15 @@ var cxEntryIo = (deps2) => ({
63833
63856
  write: (text3) => writeAtomic2(paths(deps2).codex, text3),
63834
63857
  writeMoved: (data) => writeAtomic2(paths(deps2).codexEntry, data, 384),
63835
63858
  busBin: deps2.busBin,
63836
- ...movedHome(deps2) ? { busHome: movedHome(deps2) } : {}
63859
+ ...movedHome(deps2) ? { busHome: movedHome(deps2) } : {},
63860
+ // #2954: the PAT the connect guide tells people to save, so an entry that
63861
+ // signs in another way (Codex's own OAuth) can still reach the proxy.
63862
+ ...deps2.hub === void 0 ? {} : { patFile: patTokenFile(deps2) }
63837
63863
  });
63864
+ var patTokenFile = (deps2) => {
63865
+ const host = deps2.hub === void 0 ? "" : new URL(deps2.hub).host;
63866
+ return join37(deps2.home, ".open-artifacts", `${hostSlug(host)}-pat-token`);
63867
+ };
63838
63868
  async function codexEntryStep(deps2, notes) {
63839
63869
  if (deps2.hub === void 0) return;
63840
63870
  try {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@open-artifacts/bus",
3
3
  "type": "module",
4
- "version": "0.239.0",
4
+ "version": "0.239.2",
5
5
  "description": "The Open Artifacts bus: your AI agents reach each other across machines.",
6
6
  "license": "MIT",
7
7
  "repository": {
@@ -29,6 +29,6 @@
29
29
  "typecheck": "tsc --noEmit"
30
30
  },
31
31
  "oaBus": {
32
- "commit": "c866b16c21404e169378981d5514d9aba491e7e2"
32
+ "commit": "2ea6a45a728ac8a105f28b2c749c095788534748"
33
33
  }
34
34
  }