@open-artifacts/bus 0.199.5 → 0.199.6
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 +1 -1
- package/assets/openclaw/index.js +23 -1
- package/assets/openclaw/package.json +1 -1
- package/dist/index.js +362 -86
- package/package.json +2 -2
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.199.
|
|
14
|
+
const CLIENT_VERSION = "0.199.6";
|
|
15
15
|
|
|
16
16
|
type Frame = Json & { type: string; id: string };
|
|
17
17
|
type Ctx = {
|
package/assets/openclaw/index.js
CHANGED
|
@@ -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.199.
|
|
27747
|
+
var CLIENT_VERSION = true ? "0.199.6" : "0.0.0";
|
|
27748
27748
|
var clientVersion = {
|
|
27749
27749
|
client_version: external_exports.string().min(1).max(64).optional()
|
|
27750
27750
|
};
|
|
@@ -28132,6 +28132,28 @@ var StatusReply = external_exports.object({
|
|
|
28132
28132
|
),
|
|
28133
28133
|
/** Config files refused or noted (#1527). Absent from older daemons, and when there are none. */
|
|
28134
28134
|
config_files: external_exports.array(ConfigFile).optional(),
|
|
28135
|
+
/**
|
|
28136
|
+
* #2688: each live Claude session and whether its `mcp-proof` helper linked it.
|
|
28137
|
+
* Names, folders and cause codes only; never a proof, a hash or a header.
|
|
28138
|
+
* Absent from older daemons.
|
|
28139
|
+
*/
|
|
28140
|
+
claude_sessions: external_exports.array(
|
|
28141
|
+
external_exports.object({
|
|
28142
|
+
name: external_exports.string(),
|
|
28143
|
+
cwd: external_exports.string(),
|
|
28144
|
+
/** `linked`, `unlinked`, or `starting` (seen only moments ago, so its helper may not have run yet). Strings, so a newer daemon's new value still parses. */
|
|
28145
|
+
state: external_exports.string(),
|
|
28146
|
+
/** Why an `unlinked` session is: the helper never called, or its proof expired or was refused. */
|
|
28147
|
+
cause: external_exports.string().optional()
|
|
28148
|
+
})
|
|
28149
|
+
).optional(),
|
|
28150
|
+
/** #2688: the daemon's recent `mcp-proof` calls that could not bind a session, newest last (a few). */
|
|
28151
|
+
unbound_proofs: external_exports.array(
|
|
28152
|
+
external_exports.object({
|
|
28153
|
+
at: external_exports.number(),
|
|
28154
|
+
cause: external_exports.string()
|
|
28155
|
+
})
|
|
28156
|
+
).optional(),
|
|
28135
28157
|
/** Messages sent from this machine the hub delivered after the 5 s window, within the last hour. */
|
|
28136
28158
|
late: external_exports.array(
|
|
28137
28159
|
external_exports.object({
|
package/dist/index.js
CHANGED
|
@@ -32729,7 +32729,7 @@ var init_frames = __esm({
|
|
|
32729
32729
|
late = { late: external_exports.array(external_exports.string().min(1)).optional() };
|
|
32730
32730
|
isWellFormed2 = (s) => s.isWellFormed();
|
|
32731
32731
|
WELL_FORMED = { message: "text is not well-formed unicode" };
|
|
32732
|
-
CLIENT_VERSION = true ? "0.199.
|
|
32732
|
+
CLIENT_VERSION = true ? "0.199.6" : "0.0.0";
|
|
32733
32733
|
clientVersion = {
|
|
32734
32734
|
client_version: external_exports.string().min(1).max(64).optional()
|
|
32735
32735
|
};
|
|
@@ -33122,6 +33122,28 @@ var init_frames = __esm({
|
|
|
33122
33122
|
),
|
|
33123
33123
|
/** Config files refused or noted (#1527). Absent from older daemons, and when there are none. */
|
|
33124
33124
|
config_files: external_exports.array(ConfigFile).optional(),
|
|
33125
|
+
/**
|
|
33126
|
+
* #2688: each live Claude session and whether its `mcp-proof` helper linked it.
|
|
33127
|
+
* Names, folders and cause codes only; never a proof, a hash or a header.
|
|
33128
|
+
* Absent from older daemons.
|
|
33129
|
+
*/
|
|
33130
|
+
claude_sessions: external_exports.array(
|
|
33131
|
+
external_exports.object({
|
|
33132
|
+
name: external_exports.string(),
|
|
33133
|
+
cwd: external_exports.string(),
|
|
33134
|
+
/** `linked`, `unlinked`, or `starting` (seen only moments ago, so its helper may not have run yet). Strings, so a newer daemon's new value still parses. */
|
|
33135
|
+
state: external_exports.string(),
|
|
33136
|
+
/** Why an `unlinked` session is: the helper never called, or its proof expired or was refused. */
|
|
33137
|
+
cause: external_exports.string().optional()
|
|
33138
|
+
})
|
|
33139
|
+
).optional(),
|
|
33140
|
+
/** #2688: the daemon's recent `mcp-proof` calls that could not bind a session, newest last (a few). */
|
|
33141
|
+
unbound_proofs: external_exports.array(
|
|
33142
|
+
external_exports.object({
|
|
33143
|
+
at: external_exports.number(),
|
|
33144
|
+
cause: external_exports.string()
|
|
33145
|
+
})
|
|
33146
|
+
).optional(),
|
|
33125
33147
|
/** Messages sent from this machine the hub delivered after the 5 s window, within the last hour. */
|
|
33126
33148
|
late: external_exports.array(
|
|
33127
33149
|
external_exports.object({
|
|
@@ -44290,13 +44312,13 @@ __export(codex_proxy_main_exports, {
|
|
|
44290
44312
|
readTokenFile: () => readTokenFile,
|
|
44291
44313
|
startCodexProxy: () => startCodexProxy
|
|
44292
44314
|
});
|
|
44293
|
-
import { readFileSync as
|
|
44315
|
+
import { readFileSync as readFileSync42 } from "node:fs";
|
|
44294
44316
|
import { homedir as homedir4 } from "node:os";
|
|
44295
44317
|
function readTokenFile(path) {
|
|
44296
44318
|
if (!path) return void 0;
|
|
44297
44319
|
try {
|
|
44298
44320
|
const p = path.startsWith("~/") ? `${homedir4()}${path.slice(1)}` : path;
|
|
44299
|
-
return
|
|
44321
|
+
return readFileSync42(p, "utf8").trim() || void 0;
|
|
44300
44322
|
} catch {
|
|
44301
44323
|
return void 0;
|
|
44302
44324
|
}
|
|
@@ -44346,13 +44368,13 @@ __export(proxy_main_exports, {
|
|
|
44346
44368
|
readTokenFile: () => readTokenFile2,
|
|
44347
44369
|
startProxy: () => startProxy
|
|
44348
44370
|
});
|
|
44349
|
-
import { readFileSync as
|
|
44371
|
+
import { readFileSync as readFileSync43 } from "node:fs";
|
|
44350
44372
|
import { homedir as homedir5 } from "node:os";
|
|
44351
44373
|
function readTokenFile2(path) {
|
|
44352
44374
|
if (!path) return void 0;
|
|
44353
44375
|
try {
|
|
44354
44376
|
const p = path.startsWith("~/") ? `${homedir5()}${path.slice(1)}` : path;
|
|
44355
|
-
return
|
|
44377
|
+
return readFileSync43(p, "utf8").trim() || void 0;
|
|
44356
44378
|
} catch {
|
|
44357
44379
|
return void 0;
|
|
44358
44380
|
}
|
|
@@ -44492,12 +44514,19 @@ var LINK_HASHES_MAX = 4;
|
|
|
44492
44514
|
var withLinkHash = (list, hash2) => [...(list ?? []).filter((h) => h !== hash2), hash2].slice(-LINK_HASHES_MAX);
|
|
44493
44515
|
var AgentTable = class {
|
|
44494
44516
|
#byRef = /* @__PURE__ */ new Map();
|
|
44517
|
+
/** #2688: when each ref was first seen, ms since the epoch. */
|
|
44518
|
+
#firstSeen = /* @__PURE__ */ new Map();
|
|
44495
44519
|
up(rec) {
|
|
44496
44520
|
this.#byRef.set(rec.ref, rec);
|
|
44521
|
+
if (!this.#firstSeen.has(rec.ref)) this.#firstSeen.set(rec.ref, Date.now());
|
|
44497
44522
|
return rec;
|
|
44498
44523
|
}
|
|
44499
44524
|
down(ref) {
|
|
44500
44525
|
this.#byRef.delete(ref);
|
|
44526
|
+
this.#firstSeen.delete(ref);
|
|
44527
|
+
}
|
|
44528
|
+
firstSeen(ref) {
|
|
44529
|
+
return this.#firstSeen.get(ref);
|
|
44501
44530
|
}
|
|
44502
44531
|
byRef(ref) {
|
|
44503
44532
|
return this.#byRef.get(ref);
|
|
@@ -45973,11 +46002,11 @@ import {
|
|
|
45973
46002
|
readFileSync as readFileSync7
|
|
45974
46003
|
} from "node:fs";
|
|
45975
46004
|
import { userInfo } from "node:os";
|
|
45976
|
-
function isPrivateGroup(gid, user,
|
|
46005
|
+
function isPrivateGroup(gid, user, read2 = () => readFileSync7("/etc/group", "utf8"), readPasswd = () => readFileSync7("/etc/passwd", "utf8")) {
|
|
45977
46006
|
let text3;
|
|
45978
46007
|
let passwd;
|
|
45979
46008
|
try {
|
|
45980
|
-
text3 =
|
|
46009
|
+
text3 = read2();
|
|
45981
46010
|
passwd = readPasswd();
|
|
45982
46011
|
} catch {
|
|
45983
46012
|
return false;
|
|
@@ -52635,6 +52664,8 @@ var RENAME_WINDOW_MAX = 3;
|
|
|
52635
52664
|
var LIMITED_RETRY_MS = 5 * 6e4;
|
|
52636
52665
|
var PENDING_PROOF_MS = 6e4;
|
|
52637
52666
|
var PENDING_PROOF_MAX = 64;
|
|
52667
|
+
var LINK_GRACE_MS = 2 * 6e4;
|
|
52668
|
+
var UNBOUND_PROOFS_MAX = 10;
|
|
52638
52669
|
var LATE_WINDOW_MS = 60 * 6e4;
|
|
52639
52670
|
var piLike = (kind4) => kind4 === "pi" || kind4 === "omp" || kind4 === "hermes" || kind4 === "openclaw";
|
|
52640
52671
|
var REF_BOUND = "agent_ref is bound to another live connection";
|
|
@@ -53140,17 +53171,39 @@ async function runDaemon(deps2 = {}) {
|
|
|
53140
53171
|
} else renameIds.delete(id);
|
|
53141
53172
|
};
|
|
53142
53173
|
const pendingProofs = /* @__PURE__ */ new Map();
|
|
53174
|
+
const proofIssues = /* @__PURE__ */ new Map();
|
|
53175
|
+
const unboundProofs = [];
|
|
53176
|
+
const noteUnbound = (cause, pid) => {
|
|
53177
|
+
unboundProofs.push({ at: Date.now(), cause });
|
|
53178
|
+
while (unboundProofs.length > UNBOUND_PROOFS_MAX) unboundProofs.shift();
|
|
53179
|
+
if (pid !== void 0 && cause !== "no_process_start") {
|
|
53180
|
+
proofIssues.delete(pid);
|
|
53181
|
+
proofIssues.set(
|
|
53182
|
+
pid,
|
|
53183
|
+
cause === "no_live_record" ? "proof_timed_out" : "proof_refused"
|
|
53184
|
+
);
|
|
53185
|
+
while (proofIssues.size > PENDING_PROOF_MAX) {
|
|
53186
|
+
const oldest = proofIssues.keys().next().value;
|
|
53187
|
+
if (oldest === void 0) break;
|
|
53188
|
+
proofIssues.delete(oldest);
|
|
53189
|
+
}
|
|
53190
|
+
}
|
|
53191
|
+
};
|
|
53143
53192
|
const claimProofs = () => {
|
|
53144
53193
|
if (pendingProofs.size === 0) return;
|
|
53145
53194
|
const now = Date.now();
|
|
53146
53195
|
for (const [pid, p] of pendingProofs)
|
|
53147
|
-
if (now - p.at > PENDING_PROOF_MS)
|
|
53196
|
+
if (now - p.at > PENDING_PROOF_MS) {
|
|
53197
|
+
pendingProofs.delete(pid);
|
|
53198
|
+
noteUnbound("no_live_record", pid);
|
|
53199
|
+
}
|
|
53148
53200
|
for (const rec of agents.all()) {
|
|
53149
53201
|
if (rec.kind !== "claude-code" || !rec.live || rec.pid === void 0)
|
|
53150
53202
|
continue;
|
|
53151
53203
|
const p = pendingProofs.get(rec.pid);
|
|
53152
53204
|
if (!p || p.procStart !== rec.procStart) continue;
|
|
53153
53205
|
pendingProofs.delete(rec.pid);
|
|
53206
|
+
proofIssues.delete(rec.pid);
|
|
53154
53207
|
rec.linkHashes = withLinkHash(rec.linkHashes, p.hash);
|
|
53155
53208
|
persistLinks();
|
|
53156
53209
|
sendLink(rec, p.hash);
|
|
@@ -53608,7 +53661,10 @@ async function runDaemon(deps2 = {}) {
|
|
|
53608
53661
|
// and start time; an unknown pid binds nothing.
|
|
53609
53662
|
onLinkProof: (req) => {
|
|
53610
53663
|
const start = (cl.procStart ?? claudeProcStartOf)(req.pid);
|
|
53611
|
-
if (start === null || start === void 0)
|
|
53664
|
+
if (start === null || start === void 0) {
|
|
53665
|
+
noteUnbound("no_process_start");
|
|
53666
|
+
return { bound: false };
|
|
53667
|
+
}
|
|
53612
53668
|
const find = () => agents.all().find((a) => a.kind === "claude-code" && a.live && a.pid === req.pid);
|
|
53613
53669
|
let rec = find();
|
|
53614
53670
|
if (!rec || rec.procStart === void 0) {
|
|
@@ -53616,7 +53672,11 @@ async function runDaemon(deps2 = {}) {
|
|
|
53616
53672
|
rec = find();
|
|
53617
53673
|
}
|
|
53618
53674
|
if (rec && rec.procStart !== void 0) {
|
|
53619
|
-
if (rec.procStart !== start)
|
|
53675
|
+
if (rec.procStart !== start) {
|
|
53676
|
+
noteUnbound("process_mismatch", req.pid);
|
|
53677
|
+
return { bound: false };
|
|
53678
|
+
}
|
|
53679
|
+
proofIssues.delete(req.pid);
|
|
53620
53680
|
rec.linkHashes = withLinkHash(rec.linkHashes, req.hash);
|
|
53621
53681
|
persistLinks();
|
|
53622
53682
|
sendLink(rec, req.hash);
|
|
@@ -53638,6 +53698,7 @@ async function runDaemon(deps2 = {}) {
|
|
|
53638
53698
|
// `oa-bus status` and install's "Daemon running": one roster per namespace
|
|
53639
53699
|
// this machine's open sessions are in (or only the cwd's).
|
|
53640
53700
|
onStatus: async (req) => {
|
|
53701
|
+
claimProofs();
|
|
53641
53702
|
let only;
|
|
53642
53703
|
if (req.cwd && isAbsolute7(req.cwd)) {
|
|
53643
53704
|
try {
|
|
@@ -53692,6 +53753,20 @@ async function runDaemon(deps2 = {}) {
|
|
|
53692
53753
|
hub_ever: hubEver,
|
|
53693
53754
|
...hub.open || !hubEver || hubDroppedAt === void 0 ? {} : { hub_since: hubDroppedAt },
|
|
53694
53755
|
link: true,
|
|
53756
|
+
claude_sessions: live.filter((a) => a.kind === "claude-code").map((a) => {
|
|
53757
|
+
const linked = (a.linkHashes?.length ?? 0) > 0;
|
|
53758
|
+
const young = Date.now() - (agents.firstSeen(a.ref) ?? 0) < LINK_GRACE_MS;
|
|
53759
|
+
const state = linked ? "linked" : young ? "starting" : "unlinked";
|
|
53760
|
+
return {
|
|
53761
|
+
name: stripTerminalControls(a.busName),
|
|
53762
|
+
cwd: stripTerminalControls(a.cwd),
|
|
53763
|
+
state,
|
|
53764
|
+
...state === "unlinked" ? {
|
|
53765
|
+
cause: proofIssues.get(a.pid) ?? "no_helper_call"
|
|
53766
|
+
} : {}
|
|
53767
|
+
};
|
|
53768
|
+
}),
|
|
53769
|
+
unbound_proofs: unboundProofs.map((u) => ({ ...u })),
|
|
53695
53770
|
...hubVersion === void 0 ? {} : { hub_version: hubVersion },
|
|
53696
53771
|
...only === void 0 ? {} : { namespace: only },
|
|
53697
53772
|
namespaces,
|
|
@@ -54880,8 +54955,8 @@ function copy(style, bus = BUS_CMD, approve) {
|
|
|
54880
54955
|
// 7. status: messages delivered after send_message stopped waiting.
|
|
54881
54956
|
lateHeader: (n) => `${n} message${n === 1 ? "" : "s"} delivered late ${p("muted", "last hour")}`,
|
|
54882
54957
|
/** Both names are cut in the middle, the longer first, so the row fits in 80. */
|
|
54883
|
-
lateRow: (from, to,
|
|
54884
|
-
const room = WIDTH - len(` ${" to "} ${
|
|
54958
|
+
lateRow: (from, to, when2) => {
|
|
54959
|
+
const room = WIDTH - len(` ${" to "} ${when2}`);
|
|
54885
54960
|
let [f, t] = [from, to];
|
|
54886
54961
|
if (len(f) + len(t) > room) {
|
|
54887
54962
|
const half = Math.floor(room / 2);
|
|
@@ -54890,7 +54965,7 @@ function copy(style, bus = BUS_CMD, approve) {
|
|
|
54890
54965
|
else
|
|
54891
54966
|
[f, t] = [cutMiddle(f, half, more), cutMiddle(t, room - half, more)];
|
|
54892
54967
|
}
|
|
54893
|
-
return ` ${f} to ${t} ${p("muted",
|
|
54968
|
+
return ` ${f} to ${t} ${p("muted", when2)}`;
|
|
54894
54969
|
},
|
|
54895
54970
|
lateQuote: (excerpt) => ` "${excerpt}"`,
|
|
54896
54971
|
// install --home <dir> for a second bus: no harness config is touched.
|
|
@@ -55139,6 +55214,11 @@ function copy(style, bus = BUS_CMD, approve) {
|
|
|
55139
55214
|
wired: (h, version2) => done(
|
|
55140
55215
|
version2 ? `${HARNESS_LABEL[h]} ${clip(version2, 40)} wired` : `${HARNESS_LABEL[h]} wired`
|
|
55141
55216
|
),
|
|
55217
|
+
/** #2688: one doctor or status line with its glyph, then its notes indented 3. */
|
|
55218
|
+
check: (level, head, notes = []) => [
|
|
55219
|
+
level === "pass" ? done(head) : level === "warn" ? warn(head) : level === "fail" ? fail3(head) : head,
|
|
55220
|
+
...notes.map(next)
|
|
55221
|
+
],
|
|
55142
55222
|
notWired: (h) => [
|
|
55143
55223
|
fail3(`${HARNESS_LABEL[h]} is not wired`),
|
|
55144
55224
|
next(`Run ${bus} to wire it.`)
|
|
@@ -57446,7 +57526,7 @@ var noService = {
|
|
|
57446
57526
|
remove: async () => ({}),
|
|
57447
57527
|
cli: () => ["oa-bus"]
|
|
57448
57528
|
};
|
|
57449
|
-
var VERSION = true ? "0.199.
|
|
57529
|
+
var VERSION = true ? "0.199.6" : JSON.parse(
|
|
57450
57530
|
readFileSync21(new URL("../package.json", import.meta.url), "utf8")
|
|
57451
57531
|
).version;
|
|
57452
57532
|
var which = (cmd) => {
|
|
@@ -59002,8 +59082,8 @@ var adoptedOriginal = (helper) => {
|
|
|
59002
59082
|
};
|
|
59003
59083
|
function installProof(io, origin, busBin, busHome2, opts = {}) {
|
|
59004
59084
|
const out = { notes: [], changed: [] };
|
|
59005
|
-
const
|
|
59006
|
-
const text3 =
|
|
59085
|
+
const read2 = io.read ?? readText;
|
|
59086
|
+
const text3 = read2(io.file);
|
|
59007
59087
|
const { rest, proofs, config: config2 } = readRecord(io.record);
|
|
59008
59088
|
if (text3 === "") {
|
|
59009
59089
|
if (!opts.guard && config2 !== io.file)
|
|
@@ -59060,7 +59140,7 @@ function installProof(io, origin, busBin, busHome2, opts = {}) {
|
|
|
59060
59140
|
link2 = lstatSync12(io.file).isSymbolicLink();
|
|
59061
59141
|
} catch {
|
|
59062
59142
|
}
|
|
59063
|
-
if (link2 ||
|
|
59143
|
+
if (link2 || read2(io.file) !== text3)
|
|
59064
59144
|
return { notes: out.notes, changed: [], skipped: true };
|
|
59065
59145
|
}
|
|
59066
59146
|
writeRecord(io, rest, records, io.file);
|
|
@@ -59112,7 +59192,7 @@ function trustOf(doc, dir) {
|
|
|
59112
59192
|
}
|
|
59113
59193
|
function proofReport(file2, origin, opts = {}) {
|
|
59114
59194
|
const report = { entries: [], elsewhere: [], symlink: false };
|
|
59115
|
-
const
|
|
59195
|
+
const read2 = (path) => {
|
|
59116
59196
|
try {
|
|
59117
59197
|
const text3 = readText(path);
|
|
59118
59198
|
return text3 === "" ? void 0 : parseJsonc(text3, path);
|
|
@@ -59120,7 +59200,7 @@ function proofReport(file2, origin, opts = {}) {
|
|
|
59120
59200
|
return void 0;
|
|
59121
59201
|
}
|
|
59122
59202
|
};
|
|
59123
|
-
const doc =
|
|
59203
|
+
const doc = read2(file2);
|
|
59124
59204
|
try {
|
|
59125
59205
|
report.symlink = lstatSync12(file2).isSymbolicLink();
|
|
59126
59206
|
} catch {
|
|
@@ -59150,7 +59230,7 @@ function proofReport(file2, origin, opts = {}) {
|
|
|
59150
59230
|
url: String(f.entry.url)
|
|
59151
59231
|
});
|
|
59152
59232
|
}
|
|
59153
|
-
const proj = opts.projectFile === void 0 ? void 0 :
|
|
59233
|
+
const proj = opts.projectFile === void 0 ? void 0 : read2(opts.projectFile);
|
|
59154
59234
|
if (proj && isRecord3(proj.mcpServers))
|
|
59155
59235
|
for (const [name, entry] of Object.entries(proj.mcpServers)) {
|
|
59156
59236
|
if (!isRecord3(entry)) continue;
|
|
@@ -61248,10 +61328,10 @@ function proxyEntries(text3) {
|
|
|
61248
61328
|
({ entry }) => Array.isArray(entry.command) && entry.command.includes(PROXY_CMD2)
|
|
61249
61329
|
).map(({ name, entry }) => ({ name, entry }));
|
|
61250
61330
|
}
|
|
61251
|
-
function skippedNotes(files2,
|
|
61331
|
+
function skippedNotes(files2, read2, origin) {
|
|
61252
61332
|
const notes = [];
|
|
61253
61333
|
for (const file2 of files2)
|
|
61254
|
-
for (const { name, entry } of candidates(
|
|
61334
|
+
for (const { name, entry } of candidates(read2(file2))) {
|
|
61255
61335
|
if (ourEntry2(entry, origin)) return notes;
|
|
61256
61336
|
if (!isInstance2(entry, origin) || entry.enabled === false) continue;
|
|
61257
61337
|
try {
|
|
@@ -62694,8 +62774,8 @@ async function daemon(ctx, run5 = runDaemon, signals = process) {
|
|
|
62694
62774
|
}
|
|
62695
62775
|
|
|
62696
62776
|
// src/commands/doctor.ts
|
|
62697
|
-
import { readFileSync as
|
|
62698
|
-
import { join as
|
|
62777
|
+
import { readFileSync as readFileSync38 } from "node:fs";
|
|
62778
|
+
import { join as join45 } from "node:path";
|
|
62699
62779
|
|
|
62700
62780
|
// src/steps/claude-plugins.ts
|
|
62701
62781
|
import { readFileSync as readFileSync35 } from "node:fs";
|
|
@@ -63407,9 +63487,165 @@ function readInstanceUrl(deps2) {
|
|
|
63407
63487
|
return o === void 0 ? void 0 : o.instanceUrl ?? "";
|
|
63408
63488
|
}
|
|
63409
63489
|
|
|
63490
|
+
// src/steps/claude-sessions.ts
|
|
63491
|
+
import { readFileSync as readFileSync36 } from "node:fs";
|
|
63492
|
+
import { join as join40 } from "node:path";
|
|
63493
|
+
var UNBOUND_EVENT = "mcp_proof_unbound";
|
|
63494
|
+
var DAY_MS2 = 864e5;
|
|
63495
|
+
function hubOrigin(hub) {
|
|
63496
|
+
try {
|
|
63497
|
+
return new URL(hub.replace(/^ws(s?):/, "http$1:")).origin;
|
|
63498
|
+
} catch {
|
|
63499
|
+
return void 0;
|
|
63500
|
+
}
|
|
63501
|
+
}
|
|
63502
|
+
var CAUSE = {
|
|
63503
|
+
no_helper_call: "its helper never reported to the daemon (the entry has no helper, the entry is an sse one, Claude runs with another CLAUDE_CONFIG_DIR, or the helper could not tell it was under Claude)",
|
|
63504
|
+
proof_timed_out: "its helper's proof arrived before the session was recorded and expired",
|
|
63505
|
+
proof_refused: "the process its helper named did not match this session"
|
|
63506
|
+
};
|
|
63507
|
+
var UNBOUND = {
|
|
63508
|
+
no_live_record: "no live session record appeared for the process in a minute",
|
|
63509
|
+
process_mismatch: "the process behind the call did not match the session",
|
|
63510
|
+
no_process_start: "the process's start time could not be read",
|
|
63511
|
+
no_claude_ancestor: "no Claude process above the helper (a wrapper, an IDE, the SDK, or more than 12 levels)",
|
|
63512
|
+
process_table_error: "the helper could not read the process table",
|
|
63513
|
+
process_not_matched: "the daemon could not match the process to a live session (a reused pid, or an unreadable start time)",
|
|
63514
|
+
daemon_unreachable: "the daemon did not answer in time, or is not running"
|
|
63515
|
+
};
|
|
63516
|
+
function helperFailures(ctx) {
|
|
63517
|
+
const out = /* @__PURE__ */ new Map();
|
|
63518
|
+
let text3;
|
|
63519
|
+
try {
|
|
63520
|
+
text3 = readFileSync36(join40(ctx.home, "logs", "events.log"), "utf8");
|
|
63521
|
+
} catch {
|
|
63522
|
+
return out;
|
|
63523
|
+
}
|
|
63524
|
+
for (const l of text3.split("\n")) {
|
|
63525
|
+
if (!l.includes(` ${UNBOUND_EVENT} `)) continue;
|
|
63526
|
+
const at = l.split(" ")[0] ?? "";
|
|
63527
|
+
if (!(ctx.now() - Date.parse(at) < DAY_MS2)) continue;
|
|
63528
|
+
const reason2 = / reason=(\S+)/.exec(l)?.[1];
|
|
63529
|
+
if (!reason2) continue;
|
|
63530
|
+
const cur = out.get(reason2);
|
|
63531
|
+
out.set(reason2, { n: (cur?.n ?? 0) + 1, at });
|
|
63532
|
+
}
|
|
63533
|
+
return out;
|
|
63534
|
+
}
|
|
63535
|
+
var when = (at) => at.slice(0, 16).replace("T", " ");
|
|
63536
|
+
var read = (path) => {
|
|
63537
|
+
try {
|
|
63538
|
+
return JSON.parse(readFileSync36(path, "utf8"));
|
|
63539
|
+
} catch {
|
|
63540
|
+
return void 0;
|
|
63541
|
+
}
|
|
63542
|
+
};
|
|
63543
|
+
var isObj2 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
63544
|
+
function matching(servers4, origin, sse = false) {
|
|
63545
|
+
if (!isObj2(servers4)) return [];
|
|
63546
|
+
const names2 = [];
|
|
63547
|
+
for (const [name, e] of Object.entries(servers4)) {
|
|
63548
|
+
if (!isObj2(e) || typeof e.url !== "string") continue;
|
|
63549
|
+
if (sse && e.type !== "sse") continue;
|
|
63550
|
+
try {
|
|
63551
|
+
const u = new URL(e.url);
|
|
63552
|
+
if (u.origin === origin && u.pathname.replace(/\/+$/, "") === "/mcp")
|
|
63553
|
+
names2.push(name);
|
|
63554
|
+
} catch {
|
|
63555
|
+
}
|
|
63556
|
+
}
|
|
63557
|
+
return names2;
|
|
63558
|
+
}
|
|
63559
|
+
function entryApplies(ctx, origin, cwd) {
|
|
63560
|
+
const doc = read(claudeConfigFile(ctx.userHome, ctx.env));
|
|
63561
|
+
if (isObj2(doc)) {
|
|
63562
|
+
if (matching(doc.mcpServers, origin).length > 0) return true;
|
|
63563
|
+
const p = isObj2(doc.projects) ? doc.projects[cwd] : void 0;
|
|
63564
|
+
if (isObj2(p) && matching(p.mcpServers, origin).length > 0) return true;
|
|
63565
|
+
}
|
|
63566
|
+
const proj = read(join40(cwd, ".mcp.json"));
|
|
63567
|
+
return isObj2(proj) && matching(proj.mcpServers, origin).length > 0;
|
|
63568
|
+
}
|
|
63569
|
+
function sessionChecks(ctx, st, hub) {
|
|
63570
|
+
const out = [];
|
|
63571
|
+
const origin = hub === void 0 ? void 0 : hubOrigin(hub);
|
|
63572
|
+
if (st?.claude_sessions === void 0 && st !== void 0) {
|
|
63573
|
+
out.push({
|
|
63574
|
+
level: "warn",
|
|
63575
|
+
head: "Claude Code: this daemon is too old to say which sessions are linked.",
|
|
63576
|
+
notes: [`Fix: run ${ctx.busCmd} install to update it`]
|
|
63577
|
+
});
|
|
63578
|
+
} else if (st && origin !== void 0) {
|
|
63579
|
+
const live = st.claude_sessions ?? [];
|
|
63580
|
+
const judged = live.filter((s) => entryApplies(ctx, origin, s.cwd));
|
|
63581
|
+
const skipped = live.length - judged.length;
|
|
63582
|
+
const bad2 = judged.filter((s) => s.state === "unlinked");
|
|
63583
|
+
for (const s of bad2)
|
|
63584
|
+
out.push({
|
|
63585
|
+
level: "fail",
|
|
63586
|
+
head: `Claude Code: the session ${safeText(s.name, 200)} in ${safeText(tilde(ctx, s.cwd), 200)} is not linked.`,
|
|
63587
|
+
notes: [
|
|
63588
|
+
`What it posts can't be tied to it. Likely cause: ${s.cause === void 0 ? CAUSE.no_helper_call : CAUSE[s.cause] ?? `the daemon reports ${safeText(s.cause, 60)}`}.`,
|
|
63589
|
+
`Fix: restart the session; if it stays unlinked, start the bus in that folder, or update the daemon (${ctx.busCmd} install)`
|
|
63590
|
+
]
|
|
63591
|
+
});
|
|
63592
|
+
if (bad2.length > 0)
|
|
63593
|
+
out.push({
|
|
63594
|
+
level: "info",
|
|
63595
|
+
head: "Other causes the daemon can't see: the entry is signed in as a different member than this machine's owner, or CLAUDE_CONFIG_DIR differs between this shell and the chat.",
|
|
63596
|
+
notes: []
|
|
63597
|
+
});
|
|
63598
|
+
const linked = judged.filter((s) => s.state === "linked").length;
|
|
63599
|
+
if (bad2.length === 0 && linked > 0)
|
|
63600
|
+
out.push({
|
|
63601
|
+
level: "pass",
|
|
63602
|
+
head: `Claude Code: ${linked === 1 ? "the live session is" : `all ${linked} live sessions are`} linked.`,
|
|
63603
|
+
notes: []
|
|
63604
|
+
});
|
|
63605
|
+
if (skipped > 0)
|
|
63606
|
+
out.push({
|
|
63607
|
+
level: "info",
|
|
63608
|
+
head: `${skipped === 1 ? "1 live Claude session has" : `${skipped} live Claude sessions have`} no entry for this instance, so ${skipped === 1 ? "it isn't" : "they aren't"} checked.`,
|
|
63609
|
+
notes: []
|
|
63610
|
+
});
|
|
63611
|
+
}
|
|
63612
|
+
const recent = [];
|
|
63613
|
+
for (const u of st?.unbound_proofs ?? [])
|
|
63614
|
+
if (ctx.now() - u.at < DAY_MS2)
|
|
63615
|
+
recent.push(
|
|
63616
|
+
`${when(new Date(u.at).toISOString())}: ${UNBOUND[u.cause] ?? `the daemon reports ${safeText(u.cause, 60)}`}`
|
|
63617
|
+
);
|
|
63618
|
+
for (const [reason2, v] of helperFailures(ctx))
|
|
63619
|
+
recent.push(
|
|
63620
|
+
`${when(v.at)}: ${UNBOUND[reason2] ?? `the helper reports ${safeText(reason2, 60)}`}${v.n > 1 ? ` (${v.n} times)` : ""}`
|
|
63621
|
+
);
|
|
63622
|
+
if (recent.length > 0)
|
|
63623
|
+
out.push({
|
|
63624
|
+
level: "info",
|
|
63625
|
+
head: "Claude Code: recent helper runs that linked nothing:",
|
|
63626
|
+
notes: recent
|
|
63627
|
+
});
|
|
63628
|
+
return out;
|
|
63629
|
+
}
|
|
63630
|
+
function sseEntries(ctx, origin) {
|
|
63631
|
+
const doc = read(claudeConfigFile(ctx.userHome, ctx.env));
|
|
63632
|
+
if (!isObj2(doc)) return [];
|
|
63633
|
+
const names2 = matching(doc.mcpServers, origin, true);
|
|
63634
|
+
if (isObj2(doc.projects)) {
|
|
63635
|
+
for (const p of Object.values(doc.projects))
|
|
63636
|
+
if (isObj2(p)) names2.push(...matching(p.mcpServers, origin, true));
|
|
63637
|
+
}
|
|
63638
|
+
return names2;
|
|
63639
|
+
}
|
|
63640
|
+
var sseCheck = (ctx, name) => ({
|
|
63641
|
+
level: "warn",
|
|
63642
|
+
head: `Claude Code: the ${safeText(name, 80)} entry is an sse entry, which can't be linked.`,
|
|
63643
|
+
notes: [`Fix: re-add it with the http type, then run ${ctx.busCmd} install`]
|
|
63644
|
+
});
|
|
63645
|
+
|
|
63410
63646
|
// src/commands/habits.ts
|
|
63411
63647
|
init_src();
|
|
63412
|
-
import { join as
|
|
63648
|
+
import { join as join41 } from "node:path";
|
|
63413
63649
|
var pluginOn = (p) => `Habits on in the ${p.label} plugin.`;
|
|
63414
63650
|
var pluginOff = (p) => `Habits off in the ${p.label} plugin.`;
|
|
63415
63651
|
var deps = (ctx) => ({
|
|
@@ -63528,7 +63764,7 @@ async function habitsAfterInstall(ctx, json4) {
|
|
|
63528
63764
|
})),
|
|
63529
63765
|
// A plugin has no block to compare: its marker is there ("current") or not.
|
|
63530
63766
|
...plugins2.map((p) => ({
|
|
63531
|
-
path:
|
|
63767
|
+
path: join41(p.dir(ctx.userHome, ctx.env), p.marker),
|
|
63532
63768
|
label: `the ${p.label} plugin`,
|
|
63533
63769
|
s: {
|
|
63534
63770
|
state: pluginHabitsState(deps(ctx), p) === "on" ? "current" : "absent"
|
|
@@ -63573,7 +63809,7 @@ async function habitsAfterInstall(ctx, json4) {
|
|
|
63573
63809
|
const pl = setPluginHabits(
|
|
63574
63810
|
deps(ctx),
|
|
63575
63811
|
plugins2.filter(
|
|
63576
|
-
(p) => asked.includes(
|
|
63812
|
+
(p) => asked.includes(join41(p.dir(ctx.userHome, ctx.env), p.marker))
|
|
63577
63813
|
),
|
|
63578
63814
|
true
|
|
63579
63815
|
);
|
|
@@ -63646,7 +63882,7 @@ import {
|
|
|
63646
63882
|
unlinkSync as unlinkSync3,
|
|
63647
63883
|
writeSync as writeSync4
|
|
63648
63884
|
} from "node:fs";
|
|
63649
|
-
import { join as
|
|
63885
|
+
import { join as join42 } from "node:path";
|
|
63650
63886
|
init_src();
|
|
63651
63887
|
|
|
63652
63888
|
// src/machine-label.ts
|
|
@@ -63695,7 +63931,7 @@ function checkVerificationUri(uri, hub) {
|
|
|
63695
63931
|
function writeMachineFile(home2, body) {
|
|
63696
63932
|
mkdirSync16(home2, { recursive: true, mode: 448 });
|
|
63697
63933
|
chmodSync21(home2, 448);
|
|
63698
|
-
const tmp =
|
|
63934
|
+
const tmp = join42(home2, `.machine.json.${randomBytes7(8).toString("hex")}.tmp`);
|
|
63699
63935
|
const fd = openSync9(tmp, "wx", 384);
|
|
63700
63936
|
try {
|
|
63701
63937
|
writeSync4(fd, body);
|
|
@@ -63707,7 +63943,7 @@ function writeMachineFile(home2, body) {
|
|
|
63707
63943
|
closeSync9(fd);
|
|
63708
63944
|
try {
|
|
63709
63945
|
chmodSync21(tmp, 384);
|
|
63710
|
-
renameSync21(tmp,
|
|
63946
|
+
renameSync21(tmp, join42(home2, "machine.json"));
|
|
63711
63947
|
} catch (e) {
|
|
63712
63948
|
unlinkSync3(tmp);
|
|
63713
63949
|
throw e;
|
|
@@ -63842,7 +64078,7 @@ async function loginInner(args) {
|
|
|
63842
64078
|
`${JSON.stringify({ hub, label: label2, machine_token: poll.machine_token }, null, 2)}
|
|
63843
64079
|
`
|
|
63844
64080
|
);
|
|
63845
|
-
rmSync22(
|
|
64081
|
+
rmSync22(join42(args.home, "revoked"), { force: true });
|
|
63846
64082
|
if (!events?.code) print(`Approved this machine as ${label2}.`);
|
|
63847
64083
|
return {
|
|
63848
64084
|
machineToken: poll.machine_token,
|
|
@@ -63866,7 +64102,7 @@ init_src();
|
|
|
63866
64102
|
|
|
63867
64103
|
// src/commands/install.ts
|
|
63868
64104
|
init_src3();
|
|
63869
|
-
import { dirname as dirname18, join as
|
|
64105
|
+
import { dirname as dirname18, join as join44 } from "node:path";
|
|
63870
64106
|
init_src2();
|
|
63871
64107
|
|
|
63872
64108
|
// src/live.ts
|
|
@@ -63919,19 +64155,19 @@ function spinner(ctx) {
|
|
|
63919
64155
|
import {
|
|
63920
64156
|
lstatSync as lstatSync20,
|
|
63921
64157
|
readdirSync as readdirSync12,
|
|
63922
|
-
readFileSync as
|
|
64158
|
+
readFileSync as readFileSync37,
|
|
63923
64159
|
rmdirSync as rmdirSync4,
|
|
63924
64160
|
rmSync as rmSync23
|
|
63925
64161
|
} from "node:fs";
|
|
63926
|
-
import { join as
|
|
64162
|
+
import { join as join43 } from "node:path";
|
|
63927
64163
|
function leftoverTargets(deps2) {
|
|
63928
64164
|
const env2 = deps2.env ?? {};
|
|
63929
64165
|
const p = paths(deps2);
|
|
63930
|
-
const piDir = agentDirEnv(deps2.home, env2) ??
|
|
64166
|
+
const piDir = agentDirEnv(deps2.home, env2) ?? join43(deps2.home, ".pi/agent");
|
|
63931
64167
|
const skill = (h) => skillDir({ home: deps2.home, env: env2 }, h);
|
|
63932
64168
|
return {
|
|
63933
64169
|
files: [
|
|
63934
|
-
|
|
64170
|
+
join43(codexHome2(deps2.home, env2), "AGENTS.md"),
|
|
63935
64171
|
p.codex,
|
|
63936
64172
|
...p.opencodeConfigs,
|
|
63937
64173
|
p.opencodeCli
|
|
@@ -63940,10 +64176,10 @@ function leftoverTargets(deps2) {
|
|
|
63940
64176
|
skill("claude"),
|
|
63941
64177
|
skill("pi"),
|
|
63942
64178
|
skill("hermes"),
|
|
63943
|
-
|
|
63944
|
-
|
|
63945
|
-
|
|
63946
|
-
|
|
64179
|
+
join43(hermesHome(deps2.home, env2), "plugins"),
|
|
64180
|
+
join43(deps2.home, ".local", "bin"),
|
|
64181
|
+
join43(ompAgentDir(deps2.home, env2), "extensions"),
|
|
64182
|
+
join43(piDir, "extensions"),
|
|
63947
64183
|
skill("opencode"),
|
|
63948
64184
|
skill("openclaw")
|
|
63949
64185
|
]
|
|
@@ -63987,7 +64223,7 @@ function emptyFile(path) {
|
|
|
63987
64223
|
const st = lstatSync20(path);
|
|
63988
64224
|
if (!st.isFile()) return false;
|
|
63989
64225
|
if (st.size === 0) return true;
|
|
63990
|
-
const doc = JSON.parse(
|
|
64226
|
+
const doc = JSON.parse(readFileSync37(path, "utf8"));
|
|
63991
64227
|
return typeof doc === "object" && doc !== null && !Array.isArray(doc) && Object.keys(doc).length === 0;
|
|
63992
64228
|
} catch {
|
|
63993
64229
|
return false;
|
|
@@ -64088,7 +64324,7 @@ async function loginStep(ctx, opts) {
|
|
|
64088
64324
|
ctx,
|
|
64089
64325
|
c.approved(result.label),
|
|
64090
64326
|
c.tokenSaved(
|
|
64091
|
-
tilde(ctx,
|
|
64327
|
+
tilde(ctx, join44(ctx.home, "machine.json")),
|
|
64092
64328
|
result.machineToken
|
|
64093
64329
|
),
|
|
64094
64330
|
c.connected(originOf2(result.hub)),
|
|
@@ -64118,12 +64354,12 @@ async function loginStep(ctx, opts) {
|
|
|
64118
64354
|
}
|
|
64119
64355
|
async function harnessesStep(ctx, hub) {
|
|
64120
64356
|
const c = ctx.copy;
|
|
64121
|
-
const
|
|
64357
|
+
const hubOrigin3 = hub ? originOf2(hub) : machineOrigin(ctx);
|
|
64122
64358
|
const out = await installAdapters({
|
|
64123
64359
|
home: ctx.userHome,
|
|
64124
64360
|
busHome: ctx.home,
|
|
64125
64361
|
env: ctx.env,
|
|
64126
|
-
...
|
|
64362
|
+
...hubOrigin3 ? { hub: hubOrigin3 } : {},
|
|
64127
64363
|
// The service runs this same copy.
|
|
64128
64364
|
busBin: ctx.service.cli(),
|
|
64129
64365
|
assets: readAssets(),
|
|
@@ -64217,7 +64453,7 @@ function shownSocket(ctx) {
|
|
|
64217
64453
|
const real3 = `${canonicalHome(ctx.home)}/`;
|
|
64218
64454
|
return tilde(
|
|
64219
64455
|
ctx,
|
|
64220
|
-
path.startsWith(real3) ?
|
|
64456
|
+
path.startsWith(real3) ? join44(ctx.home, path.slice(real3.length)) : path
|
|
64221
64457
|
);
|
|
64222
64458
|
}
|
|
64223
64459
|
async function waitForDaemon(ctx) {
|
|
@@ -64469,7 +64705,7 @@ async function installRun(opts, realCtx2) {
|
|
|
64469
64705
|
return results.every((r) => r.state === "done") ? 0 : 1;
|
|
64470
64706
|
}
|
|
64471
64707
|
const ok = await runSteps(steps, ctx, {
|
|
64472
|
-
path:
|
|
64708
|
+
path: join44(ctx.home, "install.json"),
|
|
64473
64709
|
now: ctx.now
|
|
64474
64710
|
});
|
|
64475
64711
|
if (ok && second) say(ctx, "", c.secondBus(ctx.home));
|
|
@@ -64619,6 +64855,11 @@ async function status(ctx) {
|
|
|
64619
64855
|
return 1;
|
|
64620
64856
|
}
|
|
64621
64857
|
if (st.namespaces.length > 0) say(ctx, "", rosters(ctx, st.namespaces));
|
|
64858
|
+
for (const chk of sessionChecks(ctx, st, m.hub)) {
|
|
64859
|
+
const ls = c.check(chk.level, chk.head, chk.notes);
|
|
64860
|
+
if (chk.level === "fail") sayErr(ctx, ls);
|
|
64861
|
+
else if (chk.level !== "warn") say(ctx, ls);
|
|
64862
|
+
}
|
|
64622
64863
|
const late2 = [...st.late ?? []].sort((a, b) => b.at - a.at);
|
|
64623
64864
|
if (late2.length > 0)
|
|
64624
64865
|
say(ctx, "", [
|
|
@@ -64659,7 +64900,7 @@ async function healthz(ctx, hub) {
|
|
|
64659
64900
|
function claudeIsolates(path) {
|
|
64660
64901
|
let text3;
|
|
64661
64902
|
try {
|
|
64662
|
-
text3 =
|
|
64903
|
+
text3 = readFileSync38(path, "utf8");
|
|
64663
64904
|
} catch {
|
|
64664
64905
|
return void 0;
|
|
64665
64906
|
}
|
|
@@ -64735,7 +64976,7 @@ async function doctor(ctx) {
|
|
|
64735
64976
|
const node2 = ctx.nodeVersion.replace(/^v/, "");
|
|
64736
64977
|
if (Number(node2.split(".")[0]) >= MIN_NODE) pass(c.nodeOk(node2));
|
|
64737
64978
|
else fail3(c.nodeOld(node2));
|
|
64738
|
-
const machineFile = tilde(ctx,
|
|
64979
|
+
const machineFile = tilde(ctx, join45(ctx.home, "machine.json"));
|
|
64739
64980
|
const m = readMachine(ctx.home);
|
|
64740
64981
|
if (m.state !== "ok") fail3(c.noCredentials(machineFile));
|
|
64741
64982
|
else if (m.revoked) fail3(c.revokedCheck());
|
|
@@ -64824,8 +65065,8 @@ async function doctor(ctx) {
|
|
|
64824
65065
|
pass(c.wired(h, version2));
|
|
64825
65066
|
else fail3(c.notWired(h));
|
|
64826
65067
|
if (h === "claude") {
|
|
64827
|
-
const settings =
|
|
64828
|
-
ctx.env.CLAUDE_CONFIG_DIR ??
|
|
65068
|
+
const settings = join45(
|
|
65069
|
+
ctx.env.CLAUDE_CONFIG_DIR ?? join45(ctx.userHome, ".claude"),
|
|
64829
65070
|
"settings.json"
|
|
64830
65071
|
);
|
|
64831
65072
|
const isolates = claudeIsolates(settings);
|
|
@@ -64858,6 +65099,22 @@ async function doctor(ctx) {
|
|
|
64858
65099
|
const fixed = lastAutoFix(ctx);
|
|
64859
65100
|
if (fixed) say(ctx, fixed);
|
|
64860
65101
|
}
|
|
65102
|
+
if (hub !== void 0)
|
|
65103
|
+
for (const name of sseEntries(ctx, hubOrigin(hub) ?? "")) {
|
|
65104
|
+
const k = sseCheck(ctx, name);
|
|
65105
|
+
warn(c.check(k.level, k.head, k.notes));
|
|
65106
|
+
}
|
|
65107
|
+
for (const chk of sessionChecks(
|
|
65108
|
+
ctx,
|
|
65109
|
+
probe2.state === "up" ? probe2.st : void 0,
|
|
65110
|
+
hub
|
|
65111
|
+
)) {
|
|
65112
|
+
const ls = c.check(chk.level, chk.head, chk.notes);
|
|
65113
|
+
if (chk.level === "pass") pass(ls[0]);
|
|
65114
|
+
else if (chk.level === "warn") warn(ls);
|
|
65115
|
+
else if (chk.level === "info") say(ctx, ls);
|
|
65116
|
+
else fail3(ls);
|
|
65117
|
+
}
|
|
64861
65118
|
}
|
|
64862
65119
|
if (h === "opencode") {
|
|
64863
65120
|
const gone = opencodeProxyProblem({
|
|
@@ -64995,12 +65252,12 @@ async function global(opts, ctx) {
|
|
|
64995
65252
|
}
|
|
64996
65253
|
|
|
64997
65254
|
// src/commands/leads.ts
|
|
64998
|
-
import { readFileSync as
|
|
64999
|
-
import { join as
|
|
65000
|
-
function
|
|
65255
|
+
import { readFileSync as readFileSync39 } from "node:fs";
|
|
65256
|
+
import { join as join46 } from "node:path";
|
|
65257
|
+
function hubOrigin2(ctx) {
|
|
65001
65258
|
try {
|
|
65002
65259
|
const raw = JSON.parse(
|
|
65003
|
-
|
|
65260
|
+
readFileSync39(join46(ctx.home, "machine.json"), "utf8")
|
|
65004
65261
|
);
|
|
65005
65262
|
return typeof raw?.hub === "string" ? new URL(raw.hub).origin : void 0;
|
|
65006
65263
|
} catch {
|
|
@@ -65010,7 +65267,7 @@ function hubOrigin(ctx) {
|
|
|
65010
65267
|
async function leads(opts, ctx) {
|
|
65011
65268
|
const c = ctx.copy;
|
|
65012
65269
|
say(ctx, c.header(ctx.version), "");
|
|
65013
|
-
const origin =
|
|
65270
|
+
const origin = hubOrigin2(ctx);
|
|
65014
65271
|
if (!origin) {
|
|
65015
65272
|
sayErr(ctx, c.leadsNoHub());
|
|
65016
65273
|
return 1;
|
|
@@ -65159,9 +65416,9 @@ import {
|
|
|
65159
65416
|
fstatSync as fstatSync5,
|
|
65160
65417
|
lstatSync as lstatSync21,
|
|
65161
65418
|
openSync as openSync10,
|
|
65162
|
-
readFileSync as
|
|
65419
|
+
readFileSync as readFileSync40
|
|
65163
65420
|
} from "node:fs";
|
|
65164
|
-
import { dirname as dirname19, join as
|
|
65421
|
+
import { dirname as dirname19, join as join47 } from "node:path";
|
|
65165
65422
|
var TAIL = 50;
|
|
65166
65423
|
var checkDir = (dir) => {
|
|
65167
65424
|
let fd;
|
|
@@ -65198,7 +65455,7 @@ var tail = (path, dir) => {
|
|
|
65198
65455
|
const after = lstatSync21(dirname19(path));
|
|
65199
65456
|
if (after.isSymbolicLink() || after.dev !== dir.dev || after.ino !== dir.ino)
|
|
65200
65457
|
return "skipped";
|
|
65201
|
-
return
|
|
65458
|
+
return readFileSync40(fd, "utf8").replace(/\n$/, "").split("\n").slice(-TAIL);
|
|
65202
65459
|
} catch (e) {
|
|
65203
65460
|
return e.code === "ELOOP" ? "skipped" : void 0;
|
|
65204
65461
|
} finally {
|
|
@@ -65206,9 +65463,9 @@ var tail = (path, dir) => {
|
|
|
65206
65463
|
}
|
|
65207
65464
|
};
|
|
65208
65465
|
async function logs(ctx) {
|
|
65209
|
-
const logDir =
|
|
65210
|
-
const path =
|
|
65211
|
-
const eventsPath =
|
|
65466
|
+
const logDir = join47(ctx.home, "logs");
|
|
65467
|
+
const path = join47(logDir, "daemon.log");
|
|
65468
|
+
const eventsPath = join47(logDir, "events.log");
|
|
65212
65469
|
const dir = checkDir(logDir);
|
|
65213
65470
|
if (!dir.ok && dir.why !== "missing") {
|
|
65214
65471
|
say(ctx, `Not reading ${tilde(ctx, logDir)}: ${dir.why}.`);
|
|
@@ -65248,12 +65505,13 @@ async function mcp(harness, ctx, load2 = (h) => MCP_SERVER[h]()) {
|
|
|
65248
65505
|
|
|
65249
65506
|
// src/commands/mcp-proof.ts
|
|
65250
65507
|
init_src3();
|
|
65251
|
-
init_src2();
|
|
65252
|
-
init_src();
|
|
65253
65508
|
import { execFileSync as execFileSync7 } from "node:child_process";
|
|
65254
65509
|
import { createHash as createHash12, randomBytes as randomBytes8 } from "node:crypto";
|
|
65255
|
-
import { readFileSync as
|
|
65256
|
-
import { basename as basename9 } from "node:path";
|
|
65510
|
+
import { readFileSync as readFileSync41, readlinkSync as readlinkSync7 } from "node:fs";
|
|
65511
|
+
import { basename as basename9, join as join48 } from "node:path";
|
|
65512
|
+
init_src2();
|
|
65513
|
+
init_src();
|
|
65514
|
+
var LOG_WAIT_MS = 300;
|
|
65257
65515
|
var isClaude = (name) => name === "claude" || /\/claude\/versions\/[^/]+$/.test(name);
|
|
65258
65516
|
function parsePs(out) {
|
|
65259
65517
|
const m = /^(\d+)\s+(.+)$/.exec(out.trim());
|
|
@@ -65263,14 +65521,14 @@ function parsePs(out) {
|
|
|
65263
65521
|
}
|
|
65264
65522
|
function readProc(pid) {
|
|
65265
65523
|
try {
|
|
65266
|
-
const stat =
|
|
65524
|
+
const stat = readFileSync41(`/proc/${pid}/stat`, "utf8");
|
|
65267
65525
|
const ppid = Number(stat.slice(stat.lastIndexOf(")") + 1).split(/\s+/)[2]);
|
|
65268
65526
|
let exe = "";
|
|
65269
65527
|
try {
|
|
65270
65528
|
exe = readlinkSync7(`/proc/${pid}/exe`);
|
|
65271
65529
|
} catch {
|
|
65272
65530
|
}
|
|
65273
|
-
const comm =
|
|
65531
|
+
const comm = readFileSync41(`/proc/${pid}/comm`, "utf8").trim();
|
|
65274
65532
|
return { ppid, name: isClaude(exe) ? exe : comm };
|
|
65275
65533
|
} catch {
|
|
65276
65534
|
}
|
|
@@ -65298,7 +65556,7 @@ function findClaude(from, proc) {
|
|
|
65298
65556
|
function tokenOf(file2) {
|
|
65299
65557
|
if (!file2) return void 0;
|
|
65300
65558
|
try {
|
|
65301
|
-
return
|
|
65559
|
+
return readFileSync41(file2, "utf8").trim() || void 0;
|
|
65302
65560
|
} catch {
|
|
65303
65561
|
return void 0;
|
|
65304
65562
|
}
|
|
@@ -65312,22 +65570,40 @@ async function mcpProof(opts, ctx, deps2 = {
|
|
|
65312
65570
|
const headers = {};
|
|
65313
65571
|
const token = tokenOf(opts.tokenFile);
|
|
65314
65572
|
if (token) headers.Authorization = `Bearer ${token}`;
|
|
65573
|
+
let why2;
|
|
65574
|
+
let claude2;
|
|
65315
65575
|
try {
|
|
65316
|
-
|
|
65317
|
-
if (claude2
|
|
65576
|
+
claude2 = findClaude(deps2.ppid, deps2.proc);
|
|
65577
|
+
if (claude2 === void 0) why2 = "no_claude_ancestor";
|
|
65578
|
+
} catch {
|
|
65579
|
+
why2 = "process_table_error";
|
|
65580
|
+
}
|
|
65581
|
+
if (claude2 !== void 0)
|
|
65582
|
+
try {
|
|
65318
65583
|
const proof = deps2.random().toString("base64url");
|
|
65319
65584
|
const hash2 = createHash12("sha256").update(proof).digest("hex");
|
|
65320
65585
|
if (await deps2.link(claude2, hash2)) headers[LINK_PROOF_HEADER] = proof;
|
|
65586
|
+
else why2 = "process_not_matched";
|
|
65587
|
+
} catch {
|
|
65588
|
+
why2 = "daemon_unreachable";
|
|
65321
65589
|
}
|
|
65322
|
-
} catch {
|
|
65323
|
-
}
|
|
65324
65590
|
say(ctx, JSON.stringify(headers));
|
|
65591
|
+
if (why2 !== void 0)
|
|
65592
|
+
try {
|
|
65593
|
+
const events = createEventLog(join48(ctx.home, "logs", "events.log"));
|
|
65594
|
+
events(UNBOUND_EVENT, { reason: why2 });
|
|
65595
|
+
await Promise.race([
|
|
65596
|
+
events.flush(),
|
|
65597
|
+
new Promise((r) => setTimeout(r, LOG_WAIT_MS).unref())
|
|
65598
|
+
]);
|
|
65599
|
+
} catch {
|
|
65600
|
+
}
|
|
65325
65601
|
return 0;
|
|
65326
65602
|
}
|
|
65327
65603
|
|
|
65328
65604
|
// src/commands/namespace.ts
|
|
65329
65605
|
import { realpathSync as realpathSync16, statSync as statSync13 } from "node:fs";
|
|
65330
|
-
import { join as
|
|
65606
|
+
import { join as join49, resolve as resolve16 } from "node:path";
|
|
65331
65607
|
init_src();
|
|
65332
65608
|
function shown4(ctx, path) {
|
|
65333
65609
|
const t = tilde(ctx, path);
|
|
@@ -65381,7 +65657,7 @@ async function namespace(opts, ctx) {
|
|
|
65381
65657
|
sayErr(ctx, c.nsNotDir(shown4(ctx, real3 ?? given)));
|
|
65382
65658
|
return 1;
|
|
65383
65659
|
}
|
|
65384
|
-
const cfgFile =
|
|
65660
|
+
const cfgFile = join49(real3, CONFIG_FILE);
|
|
65385
65661
|
const own2 = readOwnFile(cfgFile, process.getuid?.(), {
|
|
65386
65662
|
allowGroupWrite: true
|
|
65387
65663
|
});
|
|
@@ -65455,12 +65731,12 @@ async function namespace(opts, ctx) {
|
|
|
65455
65731
|
}
|
|
65456
65732
|
|
|
65457
65733
|
// src/commands/uninstall.ts
|
|
65458
|
-
import { join as
|
|
65734
|
+
import { join as join51 } from "node:path";
|
|
65459
65735
|
|
|
65460
65736
|
// src/steps/purge.ts
|
|
65461
65737
|
init_src3();
|
|
65462
65738
|
import { lstatSync as lstatSync22, readdirSync as readdirSync13, rmdirSync as rmdirSync5, rmSync as rmSync24 } from "node:fs";
|
|
65463
|
-
import { join as
|
|
65739
|
+
import { join as join50 } from "node:path";
|
|
65464
65740
|
var FILES = [
|
|
65465
65741
|
"machine.json",
|
|
65466
65742
|
"install.json",
|
|
@@ -65530,14 +65806,14 @@ var rmdirIfEmpty = (path) => {
|
|
|
65530
65806
|
};
|
|
65531
65807
|
function purgeShort(dir, removed) {
|
|
65532
65808
|
if (kind3(dir) !== "dir" || unsafeSocketDir(dir)) return;
|
|
65533
|
-
const ret =
|
|
65809
|
+
const ret = join50(dir, "claude-return");
|
|
65534
65810
|
for (const [d, ours2] of [
|
|
65535
65811
|
[ret, (_n, p) => kind3(p) === "socket"],
|
|
65536
65812
|
[dir, (n) => /^daemon\.sock(\.keep-\d+)?$/.test(n)]
|
|
65537
65813
|
]) {
|
|
65538
65814
|
if (kind3(d) !== "dir") continue;
|
|
65539
65815
|
for (const name of readdirSync13(d)) {
|
|
65540
|
-
const path =
|
|
65816
|
+
const path = join50(d, name);
|
|
65541
65817
|
const k = kind3(path);
|
|
65542
65818
|
if (k === void 0 || k === "dir" || !ours2(name, path)) continue;
|
|
65543
65819
|
remove2(path, k);
|
|
@@ -65562,21 +65838,21 @@ function purge(home2, opts) {
|
|
|
65562
65838
|
...FILES,
|
|
65563
65839
|
...entries.filter((n) => TEMP.some((re) => re.test(n)))
|
|
65564
65840
|
]) {
|
|
65565
|
-
const path =
|
|
65841
|
+
const path = join50(home2, name);
|
|
65566
65842
|
const k = kind3(path);
|
|
65567
65843
|
if (k === void 0 || k === "dir") continue;
|
|
65568
65844
|
remove2(path, k);
|
|
65569
65845
|
removed.push(name);
|
|
65570
65846
|
}
|
|
65571
65847
|
for (const folder of FOLDERS) {
|
|
65572
|
-
const dir =
|
|
65848
|
+
const dir = join50(home2, folder.path);
|
|
65573
65849
|
if (kind3(dir) !== "dir") continue;
|
|
65574
65850
|
for (const name of readdirSync13(dir)) {
|
|
65575
|
-
const path =
|
|
65851
|
+
const path = join50(dir, name);
|
|
65576
65852
|
const k = kind3(path);
|
|
65577
65853
|
if (k === void 0 || !folder.ours(name, path)) continue;
|
|
65578
65854
|
remove2(path, k);
|
|
65579
|
-
removed.push(
|
|
65855
|
+
removed.push(join50(folder.path, name));
|
|
65580
65856
|
}
|
|
65581
65857
|
if (rmdirIfEmpty(dir)) removed.push(folder.path);
|
|
65582
65858
|
}
|
|
@@ -65667,7 +65943,7 @@ async function unwire(ctx) {
|
|
|
65667
65943
|
say(
|
|
65668
65944
|
ctx,
|
|
65669
65945
|
c.hermesNoCli(
|
|
65670
|
-
tilde(ctx,
|
|
65946
|
+
tilde(ctx, join51(hermesHome(ctx.userHome, ctx.env), "config.yaml"))
|
|
65671
65947
|
)
|
|
65672
65948
|
);
|
|
65673
65949
|
if (r.openclawNoCli) say(ctx, c.openclawNoCli());
|
|
@@ -65701,7 +65977,7 @@ async function uninstall2(opts, ctx) {
|
|
|
65701
65977
|
say(ctx, c.daemonStillRunning(removed.running));
|
|
65702
65978
|
if (wiredTo(ctx)) await unwire(ctx);
|
|
65703
65979
|
if (!opts.purge) {
|
|
65704
|
-
say(ctx, "", c.kept(tilde(ctx,
|
|
65980
|
+
say(ctx, "", c.kept(tilde(ctx, join51(ctx.home, "machine.json"))));
|
|
65705
65981
|
return 0;
|
|
65706
65982
|
}
|
|
65707
65983
|
const home2 = tilde(ctx, ctx.home);
|
|
@@ -65711,9 +65987,9 @@ async function uninstall2(opts, ctx) {
|
|
|
65711
65987
|
return 1;
|
|
65712
65988
|
} catch {
|
|
65713
65989
|
}
|
|
65714
|
-
const made = readMade(
|
|
65990
|
+
const made = readMade(join51(ctx.home, "install.json"));
|
|
65715
65991
|
const out = purge(ctx.home, {
|
|
65716
|
-
isDefault: ctx.home ===
|
|
65992
|
+
isDefault: ctx.home === join51(ctx.userHome, ".oa-bus")
|
|
65717
65993
|
});
|
|
65718
65994
|
if ("refused" in out) {
|
|
65719
65995
|
sayErr(ctx, c.purgeRefused(home2));
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-artifacts/bus",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.199.
|
|
4
|
+
"version": "0.199.6",
|
|
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": "
|
|
32
|
+
"commit": "96b31685720ff83057264536b408832c842ade18"
|
|
33
33
|
}
|
|
34
34
|
}
|