@open-artifacts/bus 0.143.0 → 0.145.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 +1 -1
- package/assets/openclaw/index.js +483 -97
- package/assets/openclaw/package.json +1 -1
- package/dist/index.js +569 -171
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -32192,7 +32192,7 @@ function decode3(raw, schema, caps) {
|
|
|
32192
32192
|
function decodeServerFrame(raw) {
|
|
32193
32193
|
return decode3(raw, ServerFrameSchema, SERVER_CAPS);
|
|
32194
32194
|
}
|
|
32195
|
-
var PING, PONG, isWellFormed, WellFormedText, FrameIdSchema, base, BodySchema, InlineBodySchema, distinct, Hello, AgentUp, AgentDown, Sessions, Send, Ack, Refuse, List, Fetch, Status, Rename, FollowRefSchema, Follow, Unfollow, Following, LinkProofSchema, LinkProofHashSchema, LinkBind, LinkBound, MAX_FOLLOWS, FollowEntry, Followed, Unfollowed, Follows, HelloOk, AgentOk, Renamed, ReceiptFrame, RosterAgent, Roster, BodyFrame, AGENT_CAP_MESSAGES, ErrorFrame, Notice, Deliver, ReceiptUpdate, RosterChanged, ClientFrameSchema, ServerFrameSchema, FrameSchema, MAX_RAW_FRAME_CHARS, SERVER_CAPS, MAX_OBJECT_TOKENS, ID_PREFIX_RE;
|
|
32195
|
+
var PING, PONG, isWellFormed, WellFormedText, FrameIdSchema, base, BodySchema, InlineBodySchema, distinct, Hello, AgentUp, AgentDown, Sessions, Send, Ack, Refuse, List, Fetch, Status, Rename, FollowRefSchema, Follow, Unfollow, Following, LINK_PROOF_HEADER, LinkProofSchema, LinkProofHashSchema, LinkBind, LinkBound, MAX_FOLLOWS, FollowEntry, Followed, Unfollowed, Follows, HelloOk, AgentOk, Renamed, ReceiptFrame, RosterAgent, Roster, BodyFrame, AGENT_CAP_MESSAGES, ErrorFrame, Notice, Deliver, ReceiptUpdate, RosterChanged, ClientFrameSchema, ServerFrameSchema, FrameSchema, MAX_RAW_FRAME_CHARS, SERVER_CAPS, MAX_OBJECT_TOKENS, ID_PREFIX_RE;
|
|
32196
32196
|
var init_protocol2 = __esm({
|
|
32197
32197
|
"../bus-protocol/src/protocol.ts"() {
|
|
32198
32198
|
"use strict";
|
|
@@ -32346,6 +32346,7 @@ var init_protocol2 = __esm({
|
|
|
32346
32346
|
type: external_exports.literal("following"),
|
|
32347
32347
|
from_ref: AgentRefSchema
|
|
32348
32348
|
});
|
|
32349
|
+
LINK_PROOF_HEADER = "X-OA-Agent-Proof-Token";
|
|
32349
32350
|
LinkProofSchema = external_exports.string().regex(/^[A-Za-z0-9_-]{43}$/);
|
|
32350
32351
|
LinkProofHashSchema = external_exports.string().regex(/^[0-9a-f]{64}$/);
|
|
32351
32352
|
LinkBind = external_exports.strictObject({
|
|
@@ -32622,7 +32623,7 @@ var init_src = __esm({
|
|
|
32622
32623
|
});
|
|
32623
32624
|
|
|
32624
32625
|
// ../bus-ipc/src/frames.ts
|
|
32625
|
-
var V, MAX_BODY_BYTES, MAX_LINE_BYTES, INLINE_CAP_BYTES, KIND, KIND_TOKEN, AGENT_REF, base2, late, isWellFormed2, WELL_FORMED, CLIENT_VERSION, clientVersion, ADAPTER_CAPS, Hello2, SPAWNED_SOURCES, optIn, Send2, List2, Self, Fetch2, Ack2, SetStatus, Rename2, Follow2, Unfollow2, Following2, ProposeReach, StatusRequest, AdapterFrame, ConfigFile, AgentInfo, Welcome, Receipt, Roster2, Agent, StatusSet, FollowEntry2, Followed2, Unfollowed2, Follows2, ReachProposed, Body, Deliver2, Notice2, ErrorFrame2, StatusReply, DaemonFrame;
|
|
32626
|
+
var V, MAX_BODY_BYTES, MAX_LINE_BYTES, INLINE_CAP_BYTES, KIND, KIND_TOKEN, AGENT_REF, base2, late, isWellFormed2, WELL_FORMED, CLIENT_VERSION, clientVersion, ADAPTER_CAPS, Hello2, SPAWNED_SOURCES, optIn, Send2, List2, Self, Fetch2, Ack2, SetStatus, Rename2, Follow2, Unfollow2, Following2, ProposeReach, StatusRequest, LinkProofRequest, AdapterFrame, ConfigFile, AgentInfo, Welcome, Receipt, Roster2, Agent, StatusSet, FollowEntry2, Followed2, Unfollowed2, Follows2, ReachProposed, Body, Deliver2, Notice2, ErrorFrame2, StatusReply, LinkProofed, DaemonFrame;
|
|
32626
32627
|
var init_frames = __esm({
|
|
32627
32628
|
"../bus-ipc/src/frames.ts"() {
|
|
32628
32629
|
"use strict";
|
|
@@ -32639,7 +32640,7 @@ var init_frames = __esm({
|
|
|
32639
32640
|
late = { late: external_exports.array(external_exports.string().min(1)).optional() };
|
|
32640
32641
|
isWellFormed2 = (s) => s.isWellFormed();
|
|
32641
32642
|
WELL_FORMED = { message: "text is not well-formed unicode" };
|
|
32642
|
-
CLIENT_VERSION = true ? "0.
|
|
32643
|
+
CLIENT_VERSION = true ? "0.145.0" : "0.0.0";
|
|
32643
32644
|
clientVersion = {
|
|
32644
32645
|
client_version: external_exports.string().min(1).max(64).optional()
|
|
32645
32646
|
};
|
|
@@ -32809,6 +32810,12 @@ var init_frames = __esm({
|
|
|
32809
32810
|
/** What this client can decode (ADAPTER_CAPS); absent means none. */
|
|
32810
32811
|
caps: external_exports.array(external_exports.string().max(32)).max(16).optional()
|
|
32811
32812
|
});
|
|
32813
|
+
LinkProofRequest = external_exports.object({
|
|
32814
|
+
...base2,
|
|
32815
|
+
type: external_exports.literal("link_proof"),
|
|
32816
|
+
pid: external_exports.number().int().positive(),
|
|
32817
|
+
hash: LinkProofHashSchema
|
|
32818
|
+
});
|
|
32812
32819
|
AdapterFrame = external_exports.discriminatedUnion("type", [
|
|
32813
32820
|
Hello2,
|
|
32814
32821
|
Send2,
|
|
@@ -32974,6 +32981,8 @@ var init_frames = __esm({
|
|
|
32974
32981
|
hub_since: external_exports.number().optional(),
|
|
32975
32982
|
/** The hub's `server_version` from its last `hello_ok`. Absent before one, and from older daemons. */
|
|
32976
32983
|
hub_version: external_exports.string().optional(),
|
|
32984
|
+
/** This daemon takes `link_proof` (#1822). Older daemons omit it. */
|
|
32985
|
+
link: external_exports.boolean().optional(),
|
|
32977
32986
|
/** The namespace `cwd` resolves to, when the request named one. */
|
|
32978
32987
|
namespace: external_exports.string().optional(),
|
|
32979
32988
|
/** One roster per namespace: this machine's sessions', or only `cwd`'s. */
|
|
@@ -33008,7 +33017,13 @@ var init_frames = __esm({
|
|
|
33008
33017
|
})
|
|
33009
33018
|
).optional()
|
|
33010
33019
|
});
|
|
33020
|
+
LinkProofed = external_exports.object({
|
|
33021
|
+
...base2,
|
|
33022
|
+
type: external_exports.literal("link_proofed"),
|
|
33023
|
+
bound: external_exports.boolean()
|
|
33024
|
+
});
|
|
33011
33025
|
DaemonFrame = external_exports.discriminatedUnion("type", [
|
|
33026
|
+
LinkProofed,
|
|
33012
33027
|
Welcome,
|
|
33013
33028
|
Receipt,
|
|
33014
33029
|
Roster2,
|
|
@@ -33255,6 +33270,45 @@ function daemonStatus(opts) {
|
|
|
33255
33270
|
});
|
|
33256
33271
|
});
|
|
33257
33272
|
}
|
|
33273
|
+
function daemonLinkProof(opts) {
|
|
33274
|
+
return new Promise((resolve13, reject) => {
|
|
33275
|
+
const sock = connect(opts.path);
|
|
33276
|
+
const decoder = new LineDecoder();
|
|
33277
|
+
const done = (f) => {
|
|
33278
|
+
clearTimeout(timer);
|
|
33279
|
+
sock.destroy();
|
|
33280
|
+
f();
|
|
33281
|
+
};
|
|
33282
|
+
const timer = setTimeout(
|
|
33283
|
+
() => done(() => reject(new Error("daemon did not answer link_proof"))),
|
|
33284
|
+
opts.timeoutMs ?? 2e3
|
|
33285
|
+
);
|
|
33286
|
+
sock.once("error", (e) => done(() => reject(e)));
|
|
33287
|
+
sock.once(
|
|
33288
|
+
"close",
|
|
33289
|
+
() => done(() => reject(new Error("daemon connection closed")))
|
|
33290
|
+
);
|
|
33291
|
+
sock.once(
|
|
33292
|
+
"connect",
|
|
33293
|
+
() => sock.write(
|
|
33294
|
+
`${JSON.stringify({ v: 1, id: "link", type: "link_proof", pid: opts.pid, hash: opts.hash })}
|
|
33295
|
+
`
|
|
33296
|
+
)
|
|
33297
|
+
);
|
|
33298
|
+
sock.on("data", (chunk) => {
|
|
33299
|
+
try {
|
|
33300
|
+
for (const raw of decoder.push(chunk)) {
|
|
33301
|
+
const f = DaemonFrame.parse(raw);
|
|
33302
|
+
if (f.type === "link_proofed") return done(() => resolve13(f.bound));
|
|
33303
|
+
if (f.type === "error")
|
|
33304
|
+
return done(() => reject(new Error(f.message)));
|
|
33305
|
+
}
|
|
33306
|
+
} catch (e) {
|
|
33307
|
+
done(() => reject(e instanceof Error ? e : new Error(String(e))));
|
|
33308
|
+
}
|
|
33309
|
+
});
|
|
33310
|
+
});
|
|
33311
|
+
}
|
|
33258
33312
|
var HelloRefused, DaemonSilentError, NOT_LISTENING;
|
|
33259
33313
|
var init_client = __esm({
|
|
33260
33314
|
"../bus-ipc/src/client.ts"() {
|
|
@@ -33296,7 +33350,7 @@ function fitLine(text3, value) {
|
|
|
33296
33350
|
);
|
|
33297
33351
|
}
|
|
33298
33352
|
function receiptText(r, sentTo, namespaces, excerpt, movedTo2, linkedNs) {
|
|
33299
|
-
const
|
|
33353
|
+
const quote2 = excerpt ? `"${excerpt}"` : void 0;
|
|
33300
33354
|
const to = sentTo;
|
|
33301
33355
|
switch (r.state) {
|
|
33302
33356
|
case "pending":
|
|
@@ -33309,8 +33363,8 @@ function receiptText(r, sentTo, namespaces, excerpt, movedTo2, linkedNs) {
|
|
|
33309
33363
|
case "expired": {
|
|
33310
33364
|
const tail = (v) => r.reason === "recipient_closed" ? `was not delivered because ${v} closed first.` : `was not confirmed as delivered. Mail waits at most ${RETAIN}.`;
|
|
33311
33365
|
const head = (v) => `\xD7 Expired: your message to ${v}`;
|
|
33312
|
-
if (!
|
|
33313
|
-
return fitLine((v) => quoted(head(v),
|
|
33366
|
+
if (!quote2) return fitLine((v) => `${head(v)} ${tail(v)}`, to);
|
|
33367
|
+
return fitLine((v) => quoted(head(v), quote2, tail(v)), to);
|
|
33314
33368
|
}
|
|
33315
33369
|
case "refused": {
|
|
33316
33370
|
const copy2 = r.reason ? refusals[r.reason] : void 0;
|
|
@@ -33319,9 +33373,9 @@ function receiptText(r, sentTo, namespaces, excerpt, movedTo2, linkedNs) {
|
|
|
33319
33373
|
const [detail, hint] = moved ? [null, null] : copy2 ?? [null, "Message another agent."];
|
|
33320
33374
|
const said = (v) => moved ? `${v} moved; try ${moved}.` : typeof detail === "function" ? detail(namespaces, v) : detail;
|
|
33321
33375
|
const lines = (v) => [
|
|
33322
|
-
|
|
33376
|
+
quote2 ? quoted(
|
|
33323
33377
|
`\xD7 ${label}: your message to ${v}`,
|
|
33324
|
-
|
|
33378
|
+
quote2,
|
|
33325
33379
|
"was not delivered."
|
|
33326
33380
|
) : `\xD7 ${label}: your message to ${v} was not delivered.`,
|
|
33327
33381
|
...said(v) ? [` ${said(v)}`] : [],
|
|
@@ -33504,14 +33558,14 @@ var init_copy = __esm({
|
|
|
33504
33558
|
"Run the oa_bus list_agents tool and message the agent you mean by name."
|
|
33505
33559
|
]
|
|
33506
33560
|
};
|
|
33507
|
-
quoted = (head,
|
|
33508
|
-
const one2 = `${head}, ${
|
|
33561
|
+
quoted = (head, quote2, tail) => {
|
|
33562
|
+
const one2 = `${head}, ${quote2},`;
|
|
33509
33563
|
if (one2.length <= MAX_COLS) return `${one2}
|
|
33510
33564
|
${tail}`;
|
|
33511
|
-
const own2 = ` ${
|
|
33565
|
+
const own2 = ` ${quote2}, ${tail}`;
|
|
33512
33566
|
return own2.length <= MAX_COLS ? `${head},
|
|
33513
33567
|
${own2}` : `${head},
|
|
33514
|
-
${
|
|
33568
|
+
${quote2},
|
|
33515
33569
|
${tail}`;
|
|
33516
33570
|
};
|
|
33517
33571
|
TERMINAL_CONTROLS = new RegExp(
|
|
@@ -33733,6 +33787,19 @@ function handle(sock, opts) {
|
|
|
33733
33787
|
if (!helloed) return;
|
|
33734
33788
|
continue;
|
|
33735
33789
|
}
|
|
33790
|
+
const proof = !hello && opts.onLinkProof ? LinkProofRequest.safeParse(raw) : void 0;
|
|
33791
|
+
if (proof?.success && opts.onLinkProof) {
|
|
33792
|
+
answered = true;
|
|
33793
|
+
sock.pause();
|
|
33794
|
+
let bound = false;
|
|
33795
|
+
try {
|
|
33796
|
+
bound = opts.onLinkProof(proof.data).bound;
|
|
33797
|
+
} catch {
|
|
33798
|
+
}
|
|
33799
|
+
send({ type: "link_proofed", id: proof.data.id, bound });
|
|
33800
|
+
sock.end();
|
|
33801
|
+
return;
|
|
33802
|
+
}
|
|
33736
33803
|
const parsed = AdapterFrame.safeParse(raw);
|
|
33737
33804
|
if (!parsed.success) {
|
|
33738
33805
|
const r = raw;
|
|
@@ -36869,7 +36936,7 @@ var require_websocket = __commonJS({
|
|
|
36869
36936
|
var http = __require("http");
|
|
36870
36937
|
var net = __require("net");
|
|
36871
36938
|
var tls = __require("tls");
|
|
36872
|
-
var { randomBytes:
|
|
36939
|
+
var { randomBytes: randomBytes7, createHash: createHash8 } = __require("crypto");
|
|
36873
36940
|
var { Duplex, Readable } = __require("stream");
|
|
36874
36941
|
var { URL: URL2 } = __require("url");
|
|
36875
36942
|
var PerMessageDeflate2 = require_permessage_deflate();
|
|
@@ -37407,7 +37474,7 @@ var require_websocket = __commonJS({
|
|
|
37407
37474
|
}
|
|
37408
37475
|
}
|
|
37409
37476
|
const defaultPort = isSecure ? 443 : 80;
|
|
37410
|
-
const key2 =
|
|
37477
|
+
const key2 = randomBytes7(16).toString("base64");
|
|
37411
37478
|
const request = isSecure ? https.request : http.request;
|
|
37412
37479
|
const protocolSet = /* @__PURE__ */ new Set();
|
|
37413
37480
|
let perMessageDeflate;
|
|
@@ -37537,7 +37604,7 @@ var require_websocket = __commonJS({
|
|
|
37537
37604
|
abortHandshake(websocket, socket, "Invalid Upgrade header");
|
|
37538
37605
|
return;
|
|
37539
37606
|
}
|
|
37540
|
-
const digest =
|
|
37607
|
+
const digest = createHash8("sha1").update(key2 + GUID).digest("base64");
|
|
37541
37608
|
if (res.headers["sec-websocket-accept"] !== digest) {
|
|
37542
37609
|
abortHandshake(websocket, socket, "Invalid Sec-WebSocket-Accept header");
|
|
37543
37610
|
return;
|
|
@@ -37906,7 +37973,7 @@ var require_websocket_server = __commonJS({
|
|
|
37906
37973
|
var EventEmitter = __require("events");
|
|
37907
37974
|
var http = __require("http");
|
|
37908
37975
|
var { Duplex } = __require("stream");
|
|
37909
|
-
var { createHash:
|
|
37976
|
+
var { createHash: createHash8 } = __require("crypto");
|
|
37910
37977
|
var extension2 = require_extension();
|
|
37911
37978
|
var PerMessageDeflate2 = require_permessage_deflate();
|
|
37912
37979
|
var subprotocol2 = require_subprotocol();
|
|
@@ -38213,7 +38280,7 @@ var require_websocket_server = __commonJS({
|
|
|
38213
38280
|
);
|
|
38214
38281
|
}
|
|
38215
38282
|
if (this._state > RUNNING) return abortHandshake(socket, 503);
|
|
38216
|
-
const digest =
|
|
38283
|
+
const digest = createHash8("sha1").update(key2 + GUID).digest("base64");
|
|
38217
38284
|
const headers = [
|
|
38218
38285
|
"HTTP/1.1 101 Switching Protocols",
|
|
38219
38286
|
"Upgrade: websocket",
|
|
@@ -40873,7 +40940,13 @@ var HubConnection = class {
|
|
|
40873
40940
|
// Reply ids: the hub then names each sender's agent (deliver.from_id).
|
|
40874
40941
|
// Mailboxes: the hub then sends queued/since, away rows and the new
|
|
40875
40942
|
// refusals, and honours agent_up.replaces (#1295).
|
|
40876
|
-
caps: [
|
|
40943
|
+
caps: [
|
|
40944
|
+
BUS_CAPS.ids,
|
|
40945
|
+
BUS_CAPS.mailbox,
|
|
40946
|
+
BUS_CAPS.links,
|
|
40947
|
+
BUS_CAPS.follow,
|
|
40948
|
+
BUS_CAPS.link
|
|
40949
|
+
]
|
|
40877
40950
|
});
|
|
40878
40951
|
this.#guard("sessions", () => {
|
|
40879
40952
|
this.send({
|
|
@@ -43232,6 +43305,8 @@ var RENAME_HOLD_MS = 60 * 6e4;
|
|
|
43232
43305
|
var RENAME_WINDOW_MS = 6e4;
|
|
43233
43306
|
var RENAME_WINDOW_MAX = 3;
|
|
43234
43307
|
var LIMITED_RETRY_MS = 5 * 6e4;
|
|
43308
|
+
var PENDING_PROOF_MS = 6e4;
|
|
43309
|
+
var PENDING_PROOF_MAX = 64;
|
|
43235
43310
|
var LATE_WINDOW_MS = 60 * 6e4;
|
|
43236
43311
|
var piLike = (kind4) => kind4 === "pi" || kind4 === "omp" || kind4 === "hermes" || kind4 === "openclaw";
|
|
43237
43312
|
async function runDaemon(deps2 = {}) {
|
|
@@ -43292,6 +43367,16 @@ async function runDaemon(deps2 = {}) {
|
|
|
43292
43367
|
if (sent2) rec.sentName = rec.proposedName;
|
|
43293
43368
|
return sent2;
|
|
43294
43369
|
};
|
|
43370
|
+
const sendLink = (rec) => {
|
|
43371
|
+
if (!hubLink || !rec.live || rec.linkHash === void 0) return;
|
|
43372
|
+
hub.send({
|
|
43373
|
+
v: 1,
|
|
43374
|
+
id: frameId(),
|
|
43375
|
+
type: "link_bind",
|
|
43376
|
+
agent_ref: rec.ref,
|
|
43377
|
+
hash: rec.linkHash
|
|
43378
|
+
});
|
|
43379
|
+
};
|
|
43295
43380
|
const markLimited = (ref, message) => {
|
|
43296
43381
|
if (!limited.has(ref))
|
|
43297
43382
|
log(`the hub refused to register ${ref}: too many agents (rate limited)`);
|
|
@@ -43595,6 +43680,22 @@ async function runDaemon(deps2 = {}) {
|
|
|
43595
43680
|
recent.push(now);
|
|
43596
43681
|
} else renameIds.delete(id);
|
|
43597
43682
|
};
|
|
43683
|
+
const pendingProofs = /* @__PURE__ */ new Map();
|
|
43684
|
+
const claimProofs = () => {
|
|
43685
|
+
if (pendingProofs.size === 0) return;
|
|
43686
|
+
const now = Date.now();
|
|
43687
|
+
for (const [pid, p] of pendingProofs)
|
|
43688
|
+
if (now - p.at > PENDING_PROOF_MS) pendingProofs.delete(pid);
|
|
43689
|
+
for (const rec of agents.all()) {
|
|
43690
|
+
if (rec.kind !== "claude-code" || !rec.live || rec.pid === void 0)
|
|
43691
|
+
continue;
|
|
43692
|
+
const p = pendingProofs.get(rec.pid);
|
|
43693
|
+
if (!p || p.procStart !== rec.procStart) continue;
|
|
43694
|
+
pendingProofs.delete(rec.pid);
|
|
43695
|
+
rec.linkHash = p.hash;
|
|
43696
|
+
sendLink(rec);
|
|
43697
|
+
}
|
|
43698
|
+
};
|
|
43598
43699
|
const renameCodexThreads = () => {
|
|
43599
43700
|
const live = agents.all().filter((a) => a.kind === "codex" && a.live);
|
|
43600
43701
|
if (!live.length) return;
|
|
@@ -43647,6 +43748,8 @@ async function runDaemon(deps2 = {}) {
|
|
|
43647
43748
|
global: ns.global,
|
|
43648
43749
|
pid: s.pid,
|
|
43649
43750
|
procStart: s.procStart,
|
|
43751
|
+
// The same process keeps its proof across /clear; agent_ok rebinds it.
|
|
43752
|
+
...old?.linkHash !== void 0 ? { linkHash: old.linkHash } : {},
|
|
43650
43753
|
sessionName: s.name,
|
|
43651
43754
|
cwd: s.cwd,
|
|
43652
43755
|
live: true
|
|
@@ -43655,6 +43758,7 @@ async function runDaemon(deps2 = {}) {
|
|
|
43655
43758
|
void claude.revive(s.ref);
|
|
43656
43759
|
tellOwed(s.ref);
|
|
43657
43760
|
}
|
|
43761
|
+
claimProofs();
|
|
43658
43762
|
let closed = false;
|
|
43659
43763
|
for (const a of agents.all()) {
|
|
43660
43764
|
if (a.kind !== "claude-code" || !a.live || liveRefs.has(a.ref)) continue;
|
|
@@ -43703,6 +43807,7 @@ async function runDaemon(deps2 = {}) {
|
|
|
43703
43807
|
let hubIds = false;
|
|
43704
43808
|
let hubMailbox = false;
|
|
43705
43809
|
let hubFollow = false;
|
|
43810
|
+
let hubLink = false;
|
|
43706
43811
|
let hubHelloed = false;
|
|
43707
43812
|
let hubVersion;
|
|
43708
43813
|
const hub = new HubConnection({
|
|
@@ -43726,6 +43831,7 @@ async function runDaemon(deps2 = {}) {
|
|
|
43726
43831
|
agent.busName = frame.bus_name;
|
|
43727
43832
|
delete agent.replaces;
|
|
43728
43833
|
flushRename(agent);
|
|
43834
|
+
sendLink(agent);
|
|
43729
43835
|
}
|
|
43730
43836
|
resends.up(frame.agent_ref);
|
|
43731
43837
|
return;
|
|
@@ -43810,6 +43916,8 @@ async function runDaemon(deps2 = {}) {
|
|
|
43810
43916
|
case "follows":
|
|
43811
43917
|
pending.settle(frame);
|
|
43812
43918
|
return;
|
|
43919
|
+
case "link_bound":
|
|
43920
|
+
return;
|
|
43813
43921
|
case "body":
|
|
43814
43922
|
pending.settle({ ...frame, body: stripTerminalControls(frame.body) });
|
|
43815
43923
|
return;
|
|
@@ -43818,6 +43926,7 @@ async function runDaemon(deps2 = {}) {
|
|
|
43818
43926
|
hubIds = frame.caps?.includes(BUS_CAPS.ids) ?? false;
|
|
43819
43927
|
hubMailbox = frame.caps?.includes(BUS_CAPS.mailbox) ?? false;
|
|
43820
43928
|
hubFollow = frame.caps?.includes(BUS_CAPS.follow) ?? false;
|
|
43929
|
+
hubLink = frame.caps?.includes(BUS_CAPS.link) ?? false;
|
|
43821
43930
|
hubHelloed = true;
|
|
43822
43931
|
for (const rec of agents.all())
|
|
43823
43932
|
if (rec.live && rec.replaces !== void 0) announceUp(rec);
|
|
@@ -43870,6 +43979,7 @@ async function runDaemon(deps2 = {}) {
|
|
|
43870
43979
|
hubIds = false;
|
|
43871
43980
|
hubMailbox = false;
|
|
43872
43981
|
hubFollow = false;
|
|
43982
|
+
hubLink = false;
|
|
43873
43983
|
hubHelloed = false;
|
|
43874
43984
|
statusRelay.dropped();
|
|
43875
43985
|
receipts.release();
|
|
@@ -43930,6 +44040,39 @@ async function runDaemon(deps2 = {}) {
|
|
|
43930
44040
|
// A codex hello proves one call id, so it buys one request: `hello.pid`
|
|
43931
44041
|
// is a claim (no peer credentials), and a won race must not become a session.
|
|
43932
44042
|
oneRequest: (h) => h.kind === "codex",
|
|
44043
|
+
// #1822: `oa-bus mcp-proof` names the Claude process it runs under. The pid
|
|
44044
|
+
// in the request is the caller's claim, not attested (no peer credentials):
|
|
44045
|
+
// any process of this OS user can bind. The owner accepted that. What the
|
|
44046
|
+
// daemon checks is that a live Claude record it attested has that very pid
|
|
44047
|
+
// and start time; an unknown pid binds nothing.
|
|
44048
|
+
onLinkProof: (req) => {
|
|
44049
|
+
const start = (cl.procStart ?? claudeProcStartOf)(req.pid);
|
|
44050
|
+
if (start === null || start === void 0) return { bound: false };
|
|
44051
|
+
const find = () => agents.all().find((a) => a.kind === "claude-code" && a.live && a.pid === req.pid);
|
|
44052
|
+
let rec = find();
|
|
44053
|
+
if (!rec || rec.procStart === void 0) {
|
|
44054
|
+
syncClaude();
|
|
44055
|
+
rec = find();
|
|
44056
|
+
}
|
|
44057
|
+
if (rec && rec.procStart !== void 0) {
|
|
44058
|
+
if (rec.procStart !== start) return { bound: false };
|
|
44059
|
+
rec.linkHash = req.hash;
|
|
44060
|
+
sendLink(rec);
|
|
44061
|
+
return { bound: true };
|
|
44062
|
+
}
|
|
44063
|
+
pendingProofs.delete(req.pid);
|
|
44064
|
+
pendingProofs.set(req.pid, {
|
|
44065
|
+
procStart: start,
|
|
44066
|
+
hash: req.hash,
|
|
44067
|
+
at: Date.now()
|
|
44068
|
+
});
|
|
44069
|
+
while (pendingProofs.size > PENDING_PROOF_MAX) {
|
|
44070
|
+
const oldest = pendingProofs.keys().next().value;
|
|
44071
|
+
if (oldest === void 0) break;
|
|
44072
|
+
pendingProofs.delete(oldest);
|
|
44073
|
+
}
|
|
44074
|
+
return { bound: true };
|
|
44075
|
+
},
|
|
43933
44076
|
// `oa-bus status` and install's "Daemon running": one roster per namespace
|
|
43934
44077
|
// this machine's open sessions are in (or only the cwd's).
|
|
43935
44078
|
onStatus: async (req) => {
|
|
@@ -43981,6 +44124,7 @@ async function runDaemon(deps2 = {}) {
|
|
|
43981
44124
|
...hub.open || !hub.lastError ? {} : { hub_error: hub.lastError },
|
|
43982
44125
|
hub_ever: hubEver,
|
|
43983
44126
|
...hub.open || !hubEver || hubDroppedAt === void 0 ? {} : { hub_since: hubDroppedAt },
|
|
44127
|
+
link: true,
|
|
43984
44128
|
...hubVersion === void 0 ? {} : { hub_version: hubVersion },
|
|
43985
44129
|
...only === void 0 ? {} : { namespace: only },
|
|
43986
44130
|
namespaces,
|
|
@@ -44099,6 +44243,8 @@ async function runDaemon(deps2 = {}) {
|
|
|
44099
44243
|
pid,
|
|
44100
44244
|
...mine ? { procStart: mine.procStart } : {},
|
|
44101
44245
|
...mine ? { sessionName: mine.name } : {},
|
|
44246
|
+
// Claude's MCP server reconnects per tool call: the proof stays.
|
|
44247
|
+
...(prev?.linkHash ?? old?.linkHash) !== void 0 ? { linkHash: prev?.linkHash ?? old?.linkHash } : {},
|
|
44102
44248
|
...codexName !== void 0 ? { sessionName: codexName } : {},
|
|
44103
44249
|
cwd,
|
|
44104
44250
|
live: true
|
|
@@ -44107,6 +44253,7 @@ async function runDaemon(deps2 = {}) {
|
|
|
44107
44253
|
if (rec.kind === "codex") persistCodex();
|
|
44108
44254
|
if (rec.kind === "claude-code") void claude.revive(rec.ref);
|
|
44109
44255
|
conns.set(rec.ref, (conns.get(rec.ref) ?? 0) + 1);
|
|
44256
|
+
claimProofs();
|
|
44110
44257
|
announceUp(rec);
|
|
44111
44258
|
if (!piLike(hello.kind)) tellOwed(rec.ref);
|
|
44112
44259
|
return {
|
|
@@ -46760,7 +46907,7 @@ var noService = {
|
|
|
46760
46907
|
remove: async () => ({}),
|
|
46761
46908
|
cli: () => ["oa-bus"]
|
|
46762
46909
|
};
|
|
46763
|
-
var VERSION = true ? "0.
|
|
46910
|
+
var VERSION = true ? "0.145.0" : JSON.parse(
|
|
46764
46911
|
readFileSync13(new URL("../package.json", import.meta.url), "utf8")
|
|
46765
46912
|
).version;
|
|
46766
46913
|
var which = (cmd) => {
|
|
@@ -47004,8 +47151,8 @@ async function daemon(ctx, run4 = runDaemon, signals = process) {
|
|
|
47004
47151
|
}
|
|
47005
47152
|
|
|
47006
47153
|
// src/commands/doctor.ts
|
|
47007
|
-
import { readFileSync as
|
|
47008
|
-
import { join as
|
|
47154
|
+
import { readFileSync as readFileSync21 } from "node:fs";
|
|
47155
|
+
import { join as join28 } from "node:path";
|
|
47009
47156
|
|
|
47010
47157
|
// ../bus-adapter-opencode/src/index.ts
|
|
47011
47158
|
init_session2();
|
|
@@ -47022,14 +47169,14 @@ import {
|
|
|
47022
47169
|
existsSync as existsSync8,
|
|
47023
47170
|
lstatSync as lstatSync14,
|
|
47024
47171
|
mkdirSync as mkdirSync11,
|
|
47025
|
-
readFileSync as
|
|
47172
|
+
readFileSync as readFileSync20,
|
|
47026
47173
|
readlinkSync,
|
|
47027
47174
|
renameSync as renameSync12,
|
|
47028
47175
|
rmSync as rmSync9,
|
|
47029
47176
|
statSync as statSync11,
|
|
47030
47177
|
writeFileSync as writeFileSync10
|
|
47031
47178
|
} from "node:fs";
|
|
47032
|
-
import { dirname as dirname11, join as
|
|
47179
|
+
import { dirname as dirname11, join as join24, resolve as resolve8 } from "node:path";
|
|
47033
47180
|
import { isDeepStrictEqual } from "node:util";
|
|
47034
47181
|
|
|
47035
47182
|
// ../bus-adapter-hermes/src/index.ts
|
|
@@ -48146,6 +48293,12 @@ function removeAt(text3, path) {
|
|
|
48146
48293
|
cuts.push([from, to]);
|
|
48147
48294
|
return cuts.sort((x, y) => y[0] - x[0]).reduce((out, [a, b]) => splice(out, a, b), text3);
|
|
48148
48295
|
}
|
|
48296
|
+
function setJsoncValue(text3, path, value) {
|
|
48297
|
+
return verified(insert(text3, path, value), path, value);
|
|
48298
|
+
}
|
|
48299
|
+
function removeJsoncValue(text3, path) {
|
|
48300
|
+
return verified(removeAt(text3, path), path, void 0);
|
|
48301
|
+
}
|
|
48149
48302
|
function jsoncValue(text3, path) {
|
|
48150
48303
|
let v = parseJsonc(text3, "config");
|
|
48151
48304
|
for (const k of path) {
|
|
@@ -48256,16 +48409,132 @@ var PI_EXTENSION = fileURLToPath4(
|
|
|
48256
48409
|
new URL("../assets/oa-bus.ts", import.meta.url)
|
|
48257
48410
|
);
|
|
48258
48411
|
|
|
48412
|
+
// src/steps/claude-proof.ts
|
|
48413
|
+
import { readFileSync as readFileSync15 } from "node:fs";
|
|
48414
|
+
import { join as join19 } from "node:path";
|
|
48415
|
+
var claudeConfigFile = (home2, env2) => join19(env2.CLAUDE_CONFIG_DIR ?? home2, ".claude.json");
|
|
48416
|
+
var PROOF_COMMAND = "mcp-proof";
|
|
48417
|
+
var TOKEN_HELPER = /^T=\$\(cat (.+)\) && printf '\{"Authorization":"Bearer %s"\}' "\$T"$/;
|
|
48418
|
+
var quote = (s) => /^[A-Za-z0-9_./:@%+=,-]+$/.test(s) ? s : `'${s.replaceAll("'", `'\\''`)}'`;
|
|
48419
|
+
function proofHelper(busBin, opts) {
|
|
48420
|
+
const run4 = [
|
|
48421
|
+
...opts.busHome ? [`OA_BUS_HOME=${quote(opts.busHome)}`] : [],
|
|
48422
|
+
...busBin.map(quote),
|
|
48423
|
+
PROOF_COMMAND,
|
|
48424
|
+
...opts.tokenFile ? ["--token-file", opts.tokenFile] : []
|
|
48425
|
+
].join(" ");
|
|
48426
|
+
return opts.tokenFile ? `T=$(cat ${opts.tokenFile}) && { ${run4} 2>/dev/null || printf '{"Authorization":"Bearer %s"}' "$T"; }` : run4;
|
|
48427
|
+
}
|
|
48428
|
+
var isProofHelper = (helper) => typeof helper === "string" && / mcp-proof( |$)/.test(helper);
|
|
48429
|
+
var isRecord3 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
48430
|
+
function findEntry(doc, origin) {
|
|
48431
|
+
const servers3 = doc.mcpServers;
|
|
48432
|
+
if (!isRecord3(servers3)) return void 0;
|
|
48433
|
+
for (const [name, entry] of Object.entries(servers3)) {
|
|
48434
|
+
if (!isRecord3(entry) || typeof entry.url !== "string") continue;
|
|
48435
|
+
if (entry.type !== void 0 && entry.type !== "http") continue;
|
|
48436
|
+
try {
|
|
48437
|
+
const u = new URL(entry.url);
|
|
48438
|
+
if (u.origin === origin && u.pathname.replace(/\/+$/, "") === "/mcp")
|
|
48439
|
+
return { name, entry };
|
|
48440
|
+
} catch {
|
|
48441
|
+
}
|
|
48442
|
+
}
|
|
48443
|
+
return void 0;
|
|
48444
|
+
}
|
|
48445
|
+
var readText = (path) => {
|
|
48446
|
+
try {
|
|
48447
|
+
return readFileSync15(path, "utf8");
|
|
48448
|
+
} catch (e) {
|
|
48449
|
+
if (e.code === "ENOENT") return "";
|
|
48450
|
+
throw e;
|
|
48451
|
+
}
|
|
48452
|
+
};
|
|
48453
|
+
function readRecord(path) {
|
|
48454
|
+
try {
|
|
48455
|
+
const v = JSON.parse(readFileSync15(path, "utf8"));
|
|
48456
|
+
if (isRecord3(v)) {
|
|
48457
|
+
const { claudeProof: claudeProof2, ...rest } = v;
|
|
48458
|
+
const p = claudeProof2;
|
|
48459
|
+
if (isRecord3(p) && typeof p.entry === "string" && (typeof p.original === "string" || p.original === null))
|
|
48460
|
+
return { rest, proof: { entry: p.entry, original: p.original } };
|
|
48461
|
+
return { rest };
|
|
48462
|
+
}
|
|
48463
|
+
} catch {
|
|
48464
|
+
}
|
|
48465
|
+
return { rest: {} };
|
|
48466
|
+
}
|
|
48467
|
+
function writeRecord(io, rest, proof) {
|
|
48468
|
+
const out = proof ? { ...rest, claudeProof: proof } : rest;
|
|
48469
|
+
io.write(io.record, `${JSON.stringify(out, null, 2)}
|
|
48470
|
+
`, 384);
|
|
48471
|
+
}
|
|
48472
|
+
function installProof(io, origin, busBin, busHome2) {
|
|
48473
|
+
const text3 = readText(io.file);
|
|
48474
|
+
if (text3 === "") return void 0;
|
|
48475
|
+
const found2 = findEntry(parseJsonc(text3, io.file), origin);
|
|
48476
|
+
if (!found2) return void 0;
|
|
48477
|
+
const cur = found2.entry.headersHelper;
|
|
48478
|
+
const { rest, proof } = readRecord(io.record);
|
|
48479
|
+
let original;
|
|
48480
|
+
if (isProofHelper(cur) && proof?.entry === found2.name)
|
|
48481
|
+
original = proof.original;
|
|
48482
|
+
else if (cur === void 0) original = null;
|
|
48483
|
+
else if (typeof cur === "string" && TOKEN_HELPER.test(cur)) original = cur;
|
|
48484
|
+
else
|
|
48485
|
+
return `left the headersHelper of ${found2.name} in ${io.file} as it is: it is not one oa-bus knows`;
|
|
48486
|
+
const tokenFile = original?.match(TOKEN_HELPER)?.[1];
|
|
48487
|
+
const helper = proofHelper(busBin, {
|
|
48488
|
+
...tokenFile ? { tokenFile } : {},
|
|
48489
|
+
...busHome2 ? { busHome: busHome2 } : {}
|
|
48490
|
+
});
|
|
48491
|
+
if (cur === helper && proof?.entry === found2.name) return void 0;
|
|
48492
|
+
writeRecord(io, rest, { entry: found2.name, original });
|
|
48493
|
+
io.write(
|
|
48494
|
+
io.file,
|
|
48495
|
+
setJsoncValue(text3, ["mcpServers", found2.name, "headersHelper"], helper)
|
|
48496
|
+
);
|
|
48497
|
+
return void 0;
|
|
48498
|
+
}
|
|
48499
|
+
function uninstallProof(io) {
|
|
48500
|
+
const { rest, proof } = readRecord(io.record);
|
|
48501
|
+
if (!proof) return false;
|
|
48502
|
+
const text3 = readText(io.file);
|
|
48503
|
+
const path = ["mcpServers", proof.entry, "headersHelper"];
|
|
48504
|
+
let cur;
|
|
48505
|
+
try {
|
|
48506
|
+
cur = text3 === "" ? void 0 : jsoncValue(text3, path);
|
|
48507
|
+
} catch {
|
|
48508
|
+
cur = void 0;
|
|
48509
|
+
}
|
|
48510
|
+
if (isProofHelper(cur))
|
|
48511
|
+
io.write(
|
|
48512
|
+
io.file,
|
|
48513
|
+
proof.original === null ? removeJsoncValue(text3, path) : setJsoncValue(text3, path, proof.original)
|
|
48514
|
+
);
|
|
48515
|
+
writeRecord(io, rest);
|
|
48516
|
+
return isProofHelper(cur);
|
|
48517
|
+
}
|
|
48518
|
+
function proofState(file2, origin) {
|
|
48519
|
+
try {
|
|
48520
|
+
const found2 = findEntry(parseJsonc(readText(file2), file2), origin);
|
|
48521
|
+
if (!found2) return "none";
|
|
48522
|
+
return isProofHelper(found2.entry.headersHelper) ? "helper" : "missing";
|
|
48523
|
+
} catch {
|
|
48524
|
+
return "none";
|
|
48525
|
+
}
|
|
48526
|
+
}
|
|
48527
|
+
|
|
48259
48528
|
// src/steps/habits.ts
|
|
48260
48529
|
init_src();
|
|
48261
48530
|
import {
|
|
48262
48531
|
existsSync as existsSync7,
|
|
48263
48532
|
lstatSync as lstatSync13,
|
|
48264
|
-
readFileSync as
|
|
48533
|
+
readFileSync as readFileSync19,
|
|
48265
48534
|
realpathSync as realpathSync12,
|
|
48266
48535
|
rmSync as rmSync8
|
|
48267
48536
|
} from "node:fs";
|
|
48268
|
-
import { join as
|
|
48537
|
+
import { join as join23, resolve as resolve7, sep as sep2 } from "node:path";
|
|
48269
48538
|
|
|
48270
48539
|
// src/steps/hermes.ts
|
|
48271
48540
|
import { createHash as createHash6, randomBytes as randomBytes3 } from "node:crypto";
|
|
@@ -48274,7 +48543,7 @@ import {
|
|
|
48274
48543
|
lstatSync as lstatSync10,
|
|
48275
48544
|
mkdirSync as mkdirSync9,
|
|
48276
48545
|
readdirSync as readdirSync5,
|
|
48277
|
-
readFileSync as
|
|
48546
|
+
readFileSync as readFileSync16,
|
|
48278
48547
|
realpathSync as realpathSync9,
|
|
48279
48548
|
renameSync as renameSync10,
|
|
48280
48549
|
rmdirSync,
|
|
@@ -48285,7 +48554,7 @@ import {
|
|
|
48285
48554
|
basename as basename7,
|
|
48286
48555
|
dirname as dirname9,
|
|
48287
48556
|
isAbsolute as isAbsolute9,
|
|
48288
|
-
join as
|
|
48557
|
+
join as join20,
|
|
48289
48558
|
relative,
|
|
48290
48559
|
resolve as resolve5
|
|
48291
48560
|
} from "node:path";
|
|
@@ -48300,7 +48569,7 @@ var real2 = (p) => {
|
|
|
48300
48569
|
let cur = p;
|
|
48301
48570
|
for (; ; ) {
|
|
48302
48571
|
try {
|
|
48303
|
-
return
|
|
48572
|
+
return join20(realpathSync9(cur), ...rest.reverse());
|
|
48304
48573
|
} catch {
|
|
48305
48574
|
const up = dirname9(cur);
|
|
48306
48575
|
if (up === cur) return p;
|
|
@@ -48330,7 +48599,7 @@ function sweepStaging(staging, own2, o = {}) {
|
|
|
48330
48599
|
}
|
|
48331
48600
|
for (const name of names2) {
|
|
48332
48601
|
if (name === own2) continue;
|
|
48333
|
-
const path =
|
|
48602
|
+
const path = join20(staging, name);
|
|
48334
48603
|
let old;
|
|
48335
48604
|
try {
|
|
48336
48605
|
old = now - lstatSync10(path).mtimeMs > STAGING_STALE_MS;
|
|
@@ -48347,11 +48616,11 @@ function sweepStaging(staging, own2, o = {}) {
|
|
|
48347
48616
|
}
|
|
48348
48617
|
}
|
|
48349
48618
|
var nativeHome = (home2, env2, platform) => {
|
|
48350
|
-
if (platform !== "win32") return
|
|
48619
|
+
if (platform !== "win32") return join20(home2, ".hermes");
|
|
48351
48620
|
const local = env2.LOCALAPPDATA?.trim();
|
|
48352
|
-
return
|
|
48621
|
+
return join20(local || join20(home2, "AppData", "Local"), "hermes");
|
|
48353
48622
|
};
|
|
48354
|
-
var tilded = (home2, v) => v === "~" ? home2 : resolve5(v.startsWith("~/") ?
|
|
48623
|
+
var tilded = (home2, v) => v === "~" ? home2 : resolve5(v.startsWith("~/") ? join20(home2, v.slice(2)) : v);
|
|
48355
48624
|
function hermesHome(home2, env2, platform = process.platform) {
|
|
48356
48625
|
const native = nativeHome(home2, env2, platform);
|
|
48357
48626
|
const v = env2.HERMES_HOME?.trim();
|
|
@@ -48362,9 +48631,9 @@ function hermesHome(home2, env2, platform = process.platform) {
|
|
|
48362
48631
|
const root = hermesRoot(home2, env2, platform);
|
|
48363
48632
|
if (env2.HERMES_S6_SUPERVISED_CHILD) return base3;
|
|
48364
48633
|
try {
|
|
48365
|
-
const name =
|
|
48634
|
+
const name = readFileSync16(join20(root, "active_profile"), "utf8").trim().toLowerCase();
|
|
48366
48635
|
if (name && name !== "default" && /^[a-z0-9][a-z0-9_-]{0,63}$/.test(name)) {
|
|
48367
|
-
const dir =
|
|
48636
|
+
const dir = join20(root, "profiles", name);
|
|
48368
48637
|
if (lstatSync10(dir).isDirectory()) return dir;
|
|
48369
48638
|
}
|
|
48370
48639
|
} catch {
|
|
@@ -48383,10 +48652,10 @@ function hermesRoot(home2, env2, platform = process.platform) {
|
|
|
48383
48652
|
}
|
|
48384
48653
|
function hermesPluginDirs(home2, env2, platform = process.platform) {
|
|
48385
48654
|
const root = hermesRoot(home2, env2, platform);
|
|
48386
|
-
const out = [
|
|
48655
|
+
const out = [join20(root, "plugins", HERMES_PLUGIN_NAME)];
|
|
48387
48656
|
try {
|
|
48388
|
-
for (const name of readdirSync5(
|
|
48389
|
-
out.push(
|
|
48657
|
+
for (const name of readdirSync5(join20(root, "profiles")).sort())
|
|
48658
|
+
out.push(join20(root, "profiles", name, "plugins", HERMES_PLUGIN_NAME));
|
|
48390
48659
|
} catch {
|
|
48391
48660
|
}
|
|
48392
48661
|
const active = hermesPluginDir(home2, env2, platform);
|
|
@@ -48396,7 +48665,7 @@ function hermesPluginDirs(home2, env2, platform = process.platform) {
|
|
|
48396
48665
|
var hermesEnv = (home2, env2, platform = process.platform) => ({
|
|
48397
48666
|
HERMES_HOME: hermesHome(home2, env2, platform)
|
|
48398
48667
|
});
|
|
48399
|
-
var hermesPluginDir = (home2, env2, platform = process.platform) =>
|
|
48668
|
+
var hermesPluginDir = (home2, env2, platform = process.platform) => join20(hermesHome(home2, env2, platform), "plugins", HERMES_PLUGIN_NAME);
|
|
48400
48669
|
var kind = (path) => {
|
|
48401
48670
|
try {
|
|
48402
48671
|
const st = lstatSync10(path);
|
|
@@ -48407,11 +48676,11 @@ var kind = (path) => {
|
|
|
48407
48676
|
};
|
|
48408
48677
|
function files(dir, rel = "") {
|
|
48409
48678
|
const out = [];
|
|
48410
|
-
for (const name of readdirSync5(
|
|
48679
|
+
for (const name of readdirSync5(join20(dir, rel)).sort()) {
|
|
48411
48680
|
if (name === "__pycache__" || name.startsWith(".") || name.endsWith(".pyc") || rel === "" && name === HERMES_HABITS_MARKER)
|
|
48412
48681
|
continue;
|
|
48413
48682
|
const r = rel ? `${rel}/${name}` : name;
|
|
48414
|
-
if (kind(
|
|
48683
|
+
if (kind(join20(dir, r)) === "dir") out.push(...files(dir, r));
|
|
48415
48684
|
else out.push(r);
|
|
48416
48685
|
}
|
|
48417
48686
|
return out;
|
|
@@ -48420,7 +48689,7 @@ function pluginHash(dir) {
|
|
|
48420
48689
|
const h = createHash6("sha256");
|
|
48421
48690
|
for (const f of files(dir)) {
|
|
48422
48691
|
h.update(`${f}\0`);
|
|
48423
|
-
h.update(
|
|
48692
|
+
h.update(readFileSync16(join20(dir, f)));
|
|
48424
48693
|
h.update("\0");
|
|
48425
48694
|
}
|
|
48426
48695
|
return h.digest("hex").slice(0, 16);
|
|
@@ -48431,7 +48700,7 @@ function pluginState(dir, shipped) {
|
|
|
48431
48700
|
if (k !== "dir") return "foreign";
|
|
48432
48701
|
let marker;
|
|
48433
48702
|
try {
|
|
48434
|
-
marker =
|
|
48703
|
+
marker = readFileSync16(join20(dir, HERMES_MARKER), "utf8").trim();
|
|
48435
48704
|
} catch {
|
|
48436
48705
|
return "foreign";
|
|
48437
48706
|
}
|
|
@@ -48470,10 +48739,10 @@ async function installHermes(deps2) {
|
|
|
48470
48739
|
`${dest} exists and is not Open Artifacts bus's; left it untouched`
|
|
48471
48740
|
);
|
|
48472
48741
|
if (state !== "current") {
|
|
48473
|
-
const keepHabits = state === "stale" && kind(
|
|
48474
|
-
const plugins2 =
|
|
48742
|
+
const keepHabits = state === "stale" && kind(join20(dest, HERMES_HABITS_MARKER)) === "file";
|
|
48743
|
+
const plugins2 = join20(dest, "..");
|
|
48475
48744
|
mkdirSync9(plugins2, { recursive: true });
|
|
48476
|
-
const staging =
|
|
48745
|
+
const staging = join20(plugins2, "..", HERMES_STAGING);
|
|
48477
48746
|
const own2 = `${process.pid}-${randomBytes3(4).toString("hex")}`;
|
|
48478
48747
|
const st = lstatSync10(staging, { throwIfNoEntry: false });
|
|
48479
48748
|
if (st !== void 0 && !st.isDirectory())
|
|
@@ -48482,20 +48751,20 @@ async function installHermes(deps2) {
|
|
|
48482
48751
|
);
|
|
48483
48752
|
mkdirSync9(staging, { recursive: true });
|
|
48484
48753
|
sweepStaging(staging, own2, deps2.staging);
|
|
48485
|
-
const tmp =
|
|
48754
|
+
const tmp = join20(staging, own2);
|
|
48486
48755
|
try {
|
|
48487
48756
|
mkdirSync9(tmp, { recursive: true });
|
|
48488
48757
|
for (const f of files(shipped)) {
|
|
48489
|
-
mkdirSync9(
|
|
48490
|
-
cpSync2(
|
|
48758
|
+
mkdirSync9(join20(tmp, f, ".."), { recursive: true });
|
|
48759
|
+
cpSync2(join20(shipped, f), join20(tmp, f));
|
|
48491
48760
|
}
|
|
48492
48761
|
writeFileSync8(
|
|
48493
|
-
|
|
48762
|
+
join20(tmp, HERMES_MARKER),
|
|
48494
48763
|
`managed by the Open Artifacts bus installer: edits are replaced on reinstall. ${pluginHash(shipped)}
|
|
48495
48764
|
`
|
|
48496
48765
|
);
|
|
48497
48766
|
if (keepHabits)
|
|
48498
|
-
writeFileSync8(
|
|
48767
|
+
writeFileSync8(join20(tmp, HERMES_HABITS_MARKER), HABITS_MARKER_TEXT);
|
|
48499
48768
|
if (state === "stale") rmSync5(dest, { recursive: true, force: true });
|
|
48500
48769
|
renameSync10(tmp, dest);
|
|
48501
48770
|
} catch (e) {
|
|
@@ -48555,11 +48824,11 @@ import {
|
|
|
48555
48824
|
existsSync as existsSync6,
|
|
48556
48825
|
lstatSync as lstatSync12,
|
|
48557
48826
|
readdirSync as readdirSync7,
|
|
48558
|
-
readFileSync as
|
|
48827
|
+
readFileSync as readFileSync18,
|
|
48559
48828
|
realpathSync as realpathSync11,
|
|
48560
48829
|
rmSync as rmSync7
|
|
48561
48830
|
} from "node:fs";
|
|
48562
|
-
import { join as
|
|
48831
|
+
import { join as join22, resolve as resolve6 } from "node:path";
|
|
48563
48832
|
import { fileURLToPath as fileURLToPath5 } from "node:url";
|
|
48564
48833
|
|
|
48565
48834
|
// src/steps/skill.ts
|
|
@@ -48569,7 +48838,7 @@ import {
|
|
|
48569
48838
|
lstatSync as lstatSync11,
|
|
48570
48839
|
mkdirSync as mkdirSync10,
|
|
48571
48840
|
readdirSync as readdirSync6,
|
|
48572
|
-
readFileSync as
|
|
48841
|
+
readFileSync as readFileSync17,
|
|
48573
48842
|
realpathSync as realpathSync10,
|
|
48574
48843
|
renameSync as renameSync11,
|
|
48575
48844
|
rmdirSync as rmdirSync2,
|
|
@@ -48577,7 +48846,7 @@ import {
|
|
|
48577
48846
|
statSync as statSync10,
|
|
48578
48847
|
writeFileSync as writeFileSync9
|
|
48579
48848
|
} from "node:fs";
|
|
48580
|
-
import { dirname as dirname10, join as
|
|
48849
|
+
import { dirname as dirname10, join as join21 } from "node:path";
|
|
48581
48850
|
var SKILL_MARKER = "<!-- managed by the Open Artifacts bus installer: edits are replaced on reinstall. -->";
|
|
48582
48851
|
var CODEX_BEGIN = "<!-- BEGIN Open Artifacts skill (managed): edits inside are replaced on reinstall. -->";
|
|
48583
48852
|
var CODEX_END = "<!-- END Open Artifacts skill -->";
|
|
@@ -48585,17 +48854,17 @@ var MAX_SKILL_BYTES = 256 * 1024;
|
|
|
48585
48854
|
var env = (deps2) => deps2.env ?? {};
|
|
48586
48855
|
var skillDir = (deps2, h) => {
|
|
48587
48856
|
const e = env(deps2);
|
|
48588
|
-
const opencode = e.OPENCODE_CONFIG_DIR ??
|
|
48589
|
-
const agents =
|
|
48857
|
+
const opencode = e.OPENCODE_CONFIG_DIR ?? join21(e.XDG_CONFIG_HOME ?? join21(deps2.home, ".config"), "opencode");
|
|
48858
|
+
const agents = join21(deps2.home, ".agents", "skills");
|
|
48590
48859
|
return {
|
|
48591
|
-
claude:
|
|
48592
|
-
opencode:
|
|
48860
|
+
claude: join21(e.CLAUDE_CONFIG_DIR ?? join21(deps2.home, ".claude"), "skills"),
|
|
48861
|
+
opencode: join21(opencode, "skills"),
|
|
48593
48862
|
pi: agents,
|
|
48594
48863
|
omp: agents,
|
|
48595
|
-
codex:
|
|
48596
|
-
hermes:
|
|
48864
|
+
codex: join21(codexHome2(deps2.home, e), "AGENTS.md"),
|
|
48865
|
+
hermes: join21(hermesHome(deps2.home, e), "skills"),
|
|
48597
48866
|
// OpenClaw's managed skills folder, in its state dir.
|
|
48598
|
-
openclaw:
|
|
48867
|
+
openclaw: join21(openclawStateDir(deps2.home, e), "skills")
|
|
48599
48868
|
}[h];
|
|
48600
48869
|
};
|
|
48601
48870
|
var skillFolder = (text3) => {
|
|
@@ -48756,7 +49025,7 @@ async function installSkill(deps2, origin, harnesses) {
|
|
|
48756
49025
|
failedUrl: url2
|
|
48757
49026
|
};
|
|
48758
49027
|
const base3 = skillDir(deps2, h);
|
|
48759
|
-
const path = harnessSkills[h].agentsMd ? base3 :
|
|
49028
|
+
const path = harnessSkills[h].agentsMd ? base3 : join21(base3, folder, "SKILL.md");
|
|
48760
49029
|
if (brokenLink(path)) {
|
|
48761
49030
|
notes.push(`Left ${path} alone: it is a broken symlink.`);
|
|
48762
49031
|
continue;
|
|
@@ -48764,7 +49033,7 @@ async function installSkill(deps2, origin, harnesses) {
|
|
|
48764
49033
|
const writing = targetOf(path);
|
|
48765
49034
|
try {
|
|
48766
49035
|
if (harnessSkills[h].agentsMd) {
|
|
48767
|
-
const before = existsSync5(writing) ?
|
|
49036
|
+
const before = existsSync5(writing) ? readFileSync17(writing, "utf8") : "";
|
|
48768
49037
|
if (codexBroken(before)) {
|
|
48769
49038
|
notes.push(
|
|
48770
49039
|
`Left ${writing} alone: its Open Artifacts block has no END marker. Fix or remove the block, then rerun the install.`
|
|
@@ -48773,7 +49042,7 @@ async function installSkill(deps2, origin, harnesses) {
|
|
|
48773
49042
|
}
|
|
48774
49043
|
writeAtomic(writing, withCodexBlock(before, text3));
|
|
48775
49044
|
} else {
|
|
48776
|
-
if (existsSync5(writing) && !isOurs(
|
|
49045
|
+
if (existsSync5(writing) && !isOurs(readFileSync17(writing, "utf8"), folder)) {
|
|
48777
49046
|
notes.push(
|
|
48778
49047
|
`Left ${writing} alone: it has no Open Artifacts marker, so it is not ours to replace.`
|
|
48779
49048
|
);
|
|
@@ -48812,7 +49081,7 @@ var uninstallSkill = (deps2, harnesses = [
|
|
|
48812
49081
|
if (harnessSkills[h].agentsMd) {
|
|
48813
49082
|
try {
|
|
48814
49083
|
if (brokenLink(base3) || !existsSync5(base3)) continue;
|
|
48815
|
-
const text3 =
|
|
49084
|
+
const text3 = readFileSync17(base3, "utf8");
|
|
48816
49085
|
if (codexBroken(text3)) {
|
|
48817
49086
|
notes.push(
|
|
48818
49087
|
`Left ${base3} alone: its Open Artifacts block has no END marker. Fix or remove the block, then rerun the install.`
|
|
@@ -48842,8 +49111,8 @@ var uninstallSkill = (deps2, harnesses = [
|
|
|
48842
49111
|
continue;
|
|
48843
49112
|
}
|
|
48844
49113
|
for (const entry of entries) {
|
|
48845
|
-
const dir =
|
|
48846
|
-
const file2 =
|
|
49114
|
+
const dir = join21(base3, entry);
|
|
49115
|
+
const file2 = join21(dir, "SKILL.md");
|
|
48847
49116
|
try {
|
|
48848
49117
|
const st = lstatSync11(dir);
|
|
48849
49118
|
if (st.isSymbolicLink()) {
|
|
@@ -48852,7 +49121,7 @@ var uninstallSkill = (deps2, harnesses = [
|
|
|
48852
49121
|
continue;
|
|
48853
49122
|
}
|
|
48854
49123
|
if (!st.isDirectory() || !lstatOk(file2)) continue;
|
|
48855
|
-
if (!isOurs(
|
|
49124
|
+
if (!isOurs(readFileSync17(targetOf(file2), "utf8"), entry)) {
|
|
48856
49125
|
notes.push(
|
|
48857
49126
|
`Left ${file2} alone: it is not an Open Artifacts skill file.`
|
|
48858
49127
|
);
|
|
@@ -48896,21 +49165,21 @@ function openclawStateDir(home2, env2) {
|
|
|
48896
49165
|
return resolve6(
|
|
48897
49166
|
override.startsWith("~") ? override.replace(/^~(?=$|[\\/])/, h) : override
|
|
48898
49167
|
);
|
|
48899
|
-
const next =
|
|
49168
|
+
const next = join22(h, ".openclaw");
|
|
48900
49169
|
if (env2.OPENCLAW_TEST_FAST === "1" || existsSync6(next)) return next;
|
|
48901
|
-
const legacy =
|
|
49170
|
+
const legacy = join22(h, ".clawdbot");
|
|
48902
49171
|
return existsSync6(legacy) ? legacy : next;
|
|
48903
49172
|
}
|
|
48904
|
-
var openclawPluginDir = (home2, env2) =>
|
|
49173
|
+
var openclawPluginDir = (home2, env2) => join22(openclawStateDir(home2, env2), "extensions", OPENCLAW_PLUGIN_ID);
|
|
48905
49174
|
function openclawPluginDirs(home2, env2) {
|
|
48906
49175
|
const h = openclawHome(home2, env2);
|
|
48907
|
-
const states = [
|
|
49176
|
+
const states = [join22(h, ".openclaw"), join22(h, ".clawdbot")];
|
|
48908
49177
|
try {
|
|
48909
49178
|
for (const name of readdirSync7(h).sort())
|
|
48910
|
-
if (name.startsWith(".openclaw-")) states.push(
|
|
49179
|
+
if (name.startsWith(".openclaw-")) states.push(join22(h, name));
|
|
48911
49180
|
} catch {
|
|
48912
49181
|
}
|
|
48913
|
-
const out = states.map((s) =>
|
|
49182
|
+
const out = states.map((s) => join22(s, "extensions", OPENCLAW_PLUGIN_ID));
|
|
48914
49183
|
const active = openclawPluginDir(home2, env2);
|
|
48915
49184
|
if (!out.includes(active)) out.push(active);
|
|
48916
49185
|
return out;
|
|
@@ -48930,7 +49199,7 @@ var kind2 = (path) => {
|
|
|
48930
49199
|
var openclawManifestIsOurs = (dir) => {
|
|
48931
49200
|
try {
|
|
48932
49201
|
const m = JSON.parse(
|
|
48933
|
-
|
|
49202
|
+
readFileSync18(join22(dir, "openclaw.plugin.json"), "utf8")
|
|
48934
49203
|
);
|
|
48935
49204
|
return m?.id === OPENCLAW_PLUGIN_ID;
|
|
48936
49205
|
} catch {
|
|
@@ -48951,7 +49220,7 @@ function openclawPluginState(dir, shipped) {
|
|
|
48951
49220
|
if (k !== "dir") return "foreign";
|
|
48952
49221
|
let marker;
|
|
48953
49222
|
try {
|
|
48954
|
-
marker =
|
|
49223
|
+
marker = readFileSync18(join22(dir, OPENCLAW_MARKER), "utf8").trim();
|
|
48955
49224
|
} catch {
|
|
48956
49225
|
return sameAsShipped(dir, shipped) ? "stale" : "foreign";
|
|
48957
49226
|
}
|
|
@@ -49028,7 +49297,7 @@ async function installOpenclaw(deps2, notes, optedOut) {
|
|
|
49028
49297
|
return "absent";
|
|
49029
49298
|
}
|
|
49030
49299
|
const shipped = deps2.assets.openclaw;
|
|
49031
|
-
if (shipped === void 0 || !existsSync6(
|
|
49300
|
+
if (shipped === void 0 || !existsSync6(join22(shipped, "openclaw.plugin.json")))
|
|
49032
49301
|
throw new Error("the OpenClaw plugin is missing from this install");
|
|
49033
49302
|
const dest = openclawPluginDir(deps2.home, deps2.env ?? {});
|
|
49034
49303
|
const state = openclawPluginState(dest, shipped);
|
|
@@ -49036,7 +49305,7 @@ async function installOpenclaw(deps2, notes, optedOut) {
|
|
|
49036
49305
|
throw new Error(
|
|
49037
49306
|
`${dest} exists and is not Open Artifacts bus's; left it untouched`
|
|
49038
49307
|
);
|
|
49039
|
-
const habitsFile =
|
|
49308
|
+
const habitsFile = join22(dest, OPENCLAW_HABITS_MARKER);
|
|
49040
49309
|
const dropHabitsIfOptedOut = () => {
|
|
49041
49310
|
if (optedOut && kind2(dest) === "dir") rmSync7(habitsFile, { force: true });
|
|
49042
49311
|
};
|
|
@@ -49056,7 +49325,7 @@ async function installOpenclaw(deps2, notes, optedOut) {
|
|
|
49056
49325
|
INSTALL_TIMEOUT_MS
|
|
49057
49326
|
);
|
|
49058
49327
|
const restore = () => {
|
|
49059
|
-
if (keepHabits && kind2(dest) === "dir" && kind2(
|
|
49328
|
+
if (keepHabits && kind2(dest) === "dir" && kind2(join22(dest, OPENCLAW_MARKER)) === "file")
|
|
49060
49329
|
writeAtomic(habitsFile, HABITS_MARKER_TEXT);
|
|
49061
49330
|
};
|
|
49062
49331
|
if (r.code !== 0) {
|
|
@@ -49068,7 +49337,7 @@ async function installOpenclaw(deps2, notes, optedOut) {
|
|
|
49068
49337
|
`\`openclaw plugins install\` finished, but ${dest} is not there`
|
|
49069
49338
|
);
|
|
49070
49339
|
writeAtomic(
|
|
49071
|
-
|
|
49340
|
+
join22(dest, OPENCLAW_MARKER),
|
|
49072
49341
|
`managed by the Open Artifacts bus installer: edits are replaced on reinstall. ${pluginHash(shipped)}
|
|
49073
49342
|
`
|
|
49074
49343
|
);
|
|
@@ -49146,21 +49415,21 @@ var habitsBlock = () => [
|
|
|
49146
49415
|
];
|
|
49147
49416
|
var piAgentDir = (home2, env2) => {
|
|
49148
49417
|
const d = env2.PI_CODING_AGENT_DIR;
|
|
49149
|
-
if (!d) return
|
|
49418
|
+
if (!d) return join23(home2, ".pi", "agent");
|
|
49150
49419
|
if (d === "~") return home2;
|
|
49151
|
-
return resolve7(d.startsWith("~/") ?
|
|
49420
|
+
return resolve7(d.startsWith("~/") ? join23(home2, d.slice(2)) : d);
|
|
49152
49421
|
};
|
|
49153
49422
|
function habitsFiles(deps2, h) {
|
|
49154
49423
|
const env2 = deps2.env ?? {};
|
|
49155
49424
|
const pair = (dir) => {
|
|
49156
|
-
const override =
|
|
49157
|
-
const plain3 =
|
|
49425
|
+
const override = join23(dir, "AGENTS.override.md");
|
|
49426
|
+
const plain3 = join23(dir, "AGENTS.md");
|
|
49158
49427
|
return existsSync7(override) ? [override, plain3] : [plain3, override];
|
|
49159
49428
|
};
|
|
49160
49429
|
switch (h) {
|
|
49161
49430
|
case "claude":
|
|
49162
49431
|
return [
|
|
49163
|
-
|
|
49432
|
+
join23(env2.CLAUDE_CONFIG_DIR ?? join23(deps2.home, ".claude"), "CLAUDE.md")
|
|
49164
49433
|
];
|
|
49165
49434
|
case "codex":
|
|
49166
49435
|
return pair(codexHome2(deps2.home, env2));
|
|
@@ -49168,8 +49437,8 @@ function habitsFiles(deps2, h) {
|
|
|
49168
49437
|
return pair(piAgentDir(deps2.home, env2));
|
|
49169
49438
|
case "opencode":
|
|
49170
49439
|
return [
|
|
49171
|
-
|
|
49172
|
-
env2.OPENCODE_CONFIG_DIR ??
|
|
49440
|
+
join23(
|
|
49441
|
+
env2.OPENCODE_CONFIG_DIR ?? join23(env2.XDG_CONFIG_HOME ?? join23(deps2.home, ".config"), "opencode"),
|
|
49173
49442
|
"AGENTS.md"
|
|
49174
49443
|
)
|
|
49175
49444
|
];
|
|
@@ -49250,7 +49519,7 @@ function linkInfo(deps2, path) {
|
|
|
49250
49519
|
}
|
|
49251
49520
|
}
|
|
49252
49521
|
var record6 = (busHome2) => {
|
|
49253
|
-
const raw = busHome2 ? readInstallFile(
|
|
49522
|
+
const raw = busHome2 ? readInstallFile(join23(busHome2, "install.json")).habits : void 0;
|
|
49254
49523
|
const h = typeof raw === "object" && raw !== null ? raw : {};
|
|
49255
49524
|
return {
|
|
49256
49525
|
optedOut: h.optedOut === true,
|
|
@@ -49270,7 +49539,7 @@ var pluginDirsOf = (v) => {
|
|
|
49270
49539
|
var saveRecord = (busHome2, patch) => {
|
|
49271
49540
|
if (!busHome2) return;
|
|
49272
49541
|
const cur = record6(busHome2);
|
|
49273
|
-
updateInstallFile(
|
|
49542
|
+
updateInstallFile(join23(busHome2, "install.json"), {
|
|
49274
49543
|
habits: { ...cur, ...patch }
|
|
49275
49544
|
});
|
|
49276
49545
|
};
|
|
@@ -49279,7 +49548,7 @@ function habitsFileState(deps2, h) {
|
|
|
49279
49548
|
try {
|
|
49280
49549
|
if (brokenLink(path)) return { state: "broken", path };
|
|
49281
49550
|
if (!existsSync7(path)) return { state: "absent", path };
|
|
49282
|
-
return { ...blockState(
|
|
49551
|
+
return { ...blockState(readFileSync19(targetOf(path), "utf8")), path };
|
|
49283
49552
|
} catch {
|
|
49284
49553
|
return { state: "broken", path };
|
|
49285
49554
|
}
|
|
@@ -49307,7 +49576,7 @@ function writeHabits(deps2, harnesses, opts = {}) {
|
|
|
49307
49576
|
const real3 = targetOf(path);
|
|
49308
49577
|
try {
|
|
49309
49578
|
const exists = existsSync7(real3);
|
|
49310
|
-
const before = exists ?
|
|
49579
|
+
const before = exists ? readFileSync19(real3, "utf8") : "";
|
|
49311
49580
|
const fresh = blockState(before).state === "absent";
|
|
49312
49581
|
const after = withHabits(before, habitsBlock());
|
|
49313
49582
|
if (after !== before) writeAtomic(real3, after);
|
|
@@ -49338,7 +49607,7 @@ function removeHabits(deps2, harnesses = HABITS_HARNESSES) {
|
|
|
49338
49607
|
try {
|
|
49339
49608
|
if (brokenLink(path) || !existsSync7(path)) continue;
|
|
49340
49609
|
const real3 = targetOf(path);
|
|
49341
|
-
const before =
|
|
49610
|
+
const before = readFileSync19(real3, "utf8");
|
|
49342
49611
|
if (blockState(before).state === "absent") continue;
|
|
49343
49612
|
const rec = kept[path];
|
|
49344
49613
|
const after = withHabits(before, null, rec?.added);
|
|
@@ -49357,7 +49626,7 @@ function removeHabits(deps2, harnesses = HABITS_HARNESSES) {
|
|
|
49357
49626
|
const p = setPluginHabits(deps2, PLUGIN_HARNESSES, false);
|
|
49358
49627
|
files2.push(...p.markers);
|
|
49359
49628
|
notes.push(...p.notes);
|
|
49360
|
-
if (deps2.busHome && existsSync7(
|
|
49629
|
+
if (deps2.busHome && existsSync7(join23(deps2.busHome, "install.json")))
|
|
49361
49630
|
saveRecord(deps2.busHome, { files: kept });
|
|
49362
49631
|
return {
|
|
49363
49632
|
files: files2,
|
|
@@ -49376,7 +49645,7 @@ function habitsOn(deps2) {
|
|
|
49376
49645
|
seen2.add(path);
|
|
49377
49646
|
try {
|
|
49378
49647
|
if (brokenLink(path) || !existsSync7(path)) continue;
|
|
49379
|
-
const s = blockState(
|
|
49648
|
+
const s = blockState(readFileSync19(targetOf(path), "utf8")).state;
|
|
49380
49649
|
if (s === "current" || s === "changed") out.push(path);
|
|
49381
49650
|
} catch {
|
|
49382
49651
|
}
|
|
@@ -49405,7 +49674,7 @@ var PLUGIN_HARNESSES = [
|
|
|
49405
49674
|
];
|
|
49406
49675
|
var pluginPaths = (deps2, p) => {
|
|
49407
49676
|
const dir = p.dir(deps2.home, deps2.env ?? {});
|
|
49408
|
-
return { dir, marker:
|
|
49677
|
+
return { dir, marker: join23(dir, p.marker) };
|
|
49409
49678
|
};
|
|
49410
49679
|
var pluginOurs = (dir, p) => {
|
|
49411
49680
|
try {
|
|
@@ -49440,7 +49709,7 @@ function setPluginHabits(deps2, plugins2, on) {
|
|
|
49440
49709
|
for (const p of plugins2) {
|
|
49441
49710
|
if (on) {
|
|
49442
49711
|
const dir = pluginPaths(deps2, p).dir;
|
|
49443
|
-
const marker =
|
|
49712
|
+
const marker = join23(dir, p.marker);
|
|
49444
49713
|
try {
|
|
49445
49714
|
if (isLink(dir) || !pluginOurs(dir, p)) {
|
|
49446
49715
|
notes.push(
|
|
@@ -49480,7 +49749,7 @@ function setPluginHabits(deps2, plugins2, on) {
|
|
|
49480
49749
|
incomplete = true;
|
|
49481
49750
|
};
|
|
49482
49751
|
for (const dir of dirs) {
|
|
49483
|
-
const marker =
|
|
49752
|
+
const marker = join23(dir, p.marker);
|
|
49484
49753
|
const d = probe(dir);
|
|
49485
49754
|
if (d.k === "absent") continue;
|
|
49486
49755
|
if (d.k === "error") {
|
|
@@ -49532,7 +49801,7 @@ function setPluginHabits(deps2, plugins2, on) {
|
|
|
49532
49801
|
done.add(dir);
|
|
49533
49802
|
if (!changed.includes(p)) changed.push(p);
|
|
49534
49803
|
}
|
|
49535
|
-
if (deps2.busHome && existsSync7(
|
|
49804
|
+
if (deps2.busHome && existsSync7(join23(deps2.busHome, "install.json"))) {
|
|
49536
49805
|
const { pluginDirs } = record6(deps2.busHome);
|
|
49537
49806
|
const had = pluginDirs[p.name];
|
|
49538
49807
|
if (had !== void 0) {
|
|
@@ -49589,8 +49858,8 @@ var HARNESSES = [
|
|
|
49589
49858
|
"openclaw"
|
|
49590
49859
|
];
|
|
49591
49860
|
var readAssets = () => ({
|
|
49592
|
-
pi:
|
|
49593
|
-
opencodePlugin:
|
|
49861
|
+
pi: readFileSync20(PI_EXTENSION, "utf8"),
|
|
49862
|
+
opencodePlugin: readFileSync20(OPENCODE_TUI_PLUGIN, "utf8"),
|
|
49594
49863
|
// A folder, not text: the plugin is several Python files.
|
|
49595
49864
|
hermes: HERMES_PLUGIN,
|
|
49596
49865
|
// Built from packages/bus-adapter-openclaw (the CLI's bundle step does it).
|
|
@@ -49599,31 +49868,31 @@ var readAssets = () => ({
|
|
|
49599
49868
|
var movedHome = (deps2) => {
|
|
49600
49869
|
if (deps2.busHome === void 0) return void 0;
|
|
49601
49870
|
const ob = resolve8(deps2.busHome);
|
|
49602
|
-
return ob ===
|
|
49871
|
+
return ob === join24(deps2.home, ".oa-bus") ? void 0 : ob;
|
|
49603
49872
|
};
|
|
49604
49873
|
var homeLine = (ob) => `process.env.OA_BUS_HOME ||= ${JSON.stringify(ob)};`;
|
|
49605
49874
|
var withHome = (text3, ob) => ob === void 0 ? text3 : `${homeLine(ob)}
|
|
49606
49875
|
${text3}`;
|
|
49607
49876
|
var paths = (deps2) => {
|
|
49608
49877
|
const env2 = deps2.env ?? {};
|
|
49609
|
-
const opencode = env2.OPENCODE_CONFIG_DIR ??
|
|
49610
|
-
const busDir = deps2.busHome ??
|
|
49878
|
+
const opencode = env2.OPENCODE_CONFIG_DIR ?? join24(env2.XDG_CONFIG_HOME ?? join24(deps2.home, ".config"), "opencode");
|
|
49879
|
+
const busDir = deps2.busHome ?? join24(deps2.home, ".oa-bus");
|
|
49611
49880
|
return {
|
|
49612
|
-
claude:
|
|
49881
|
+
claude: claudeConfigFile(deps2.home, env2),
|
|
49613
49882
|
// OpenCode reads both; edit the one the user has, else create .json.
|
|
49614
49883
|
opencodeConfigs: [
|
|
49615
|
-
|
|
49616
|
-
|
|
49884
|
+
join24(opencode, "opencode.json"),
|
|
49885
|
+
join24(opencode, "opencode.jsonc")
|
|
49617
49886
|
],
|
|
49618
|
-
opencodeCli:
|
|
49619
|
-
record:
|
|
49887
|
+
opencodeCli: join24(opencode, "cli.json"),
|
|
49888
|
+
record: join24(busDir, "install.json"),
|
|
49620
49889
|
// OpenCode registers the folder that holds tui.js.
|
|
49621
|
-
opencodePlugin:
|
|
49622
|
-
pi:
|
|
49623
|
-
agentDirEnv(deps2.home, env2) ??
|
|
49890
|
+
opencodePlugin: join24(busDir, "integrations/opencode", NAME),
|
|
49891
|
+
pi: join24(
|
|
49892
|
+
agentDirEnv(deps2.home, env2) ?? join24(deps2.home, ".pi/agent"),
|
|
49624
49893
|
"extensions/oa-bus.ts"
|
|
49625
49894
|
),
|
|
49626
|
-
omp:
|
|
49895
|
+
omp: join24(ompAgentDir(deps2.home, env2), "extensions/oa-bus.ts"),
|
|
49627
49896
|
codex: codexConfig(deps2.home, env2),
|
|
49628
49897
|
codexBin: codexBinFile(busDir),
|
|
49629
49898
|
busDir
|
|
@@ -49633,9 +49902,9 @@ function agentDirEnv(home2, env2) {
|
|
|
49633
49902
|
const dir = env2.PI_CODING_AGENT_DIR;
|
|
49634
49903
|
if (!dir) return void 0;
|
|
49635
49904
|
if (dir === "~") return home2;
|
|
49636
|
-
return resolve8(dir.startsWith("~/") ?
|
|
49905
|
+
return resolve8(dir.startsWith("~/") ? join24(home2, dir.slice(2)) : dir);
|
|
49637
49906
|
}
|
|
49638
|
-
var ompRoot = (home2, env2) =>
|
|
49907
|
+
var ompRoot = (home2, env2) => join24(home2, env2.PI_CONFIG_DIR || ".omp");
|
|
49639
49908
|
function ompProfile(env2) {
|
|
49640
49909
|
const name = (env2.OMP_PROFILE !== void 0 ? env2.OMP_PROFILE : env2.PI_PROFILE)?.trim();
|
|
49641
49910
|
if (!name || name === "default" || name.endsWith(".")) return void 0;
|
|
@@ -49644,19 +49913,19 @@ function ompProfile(env2) {
|
|
|
49644
49913
|
function ompAgentDir(home2, env2) {
|
|
49645
49914
|
const root = ompRoot(home2, env2);
|
|
49646
49915
|
const profile = ompProfile(env2);
|
|
49647
|
-
if (profile) return
|
|
49916
|
+
if (profile) return join24(root, "profiles", profile, "agent");
|
|
49648
49917
|
const piProfile = ompProfile({ PI_PROFILE: env2.PI_PROFILE });
|
|
49649
49918
|
const dir = agentDirEnv(home2, env2);
|
|
49650
|
-
if (dir && !(piProfile && dir ===
|
|
49919
|
+
if (dir && !(piProfile && dir === join24(root, "profiles", piProfile, "agent")))
|
|
49651
49920
|
return dir;
|
|
49652
|
-
return
|
|
49921
|
+
return join24(root, "agent");
|
|
49653
49922
|
}
|
|
49654
|
-
var hasOmp = (deps2) => deps2.which("omp") || present2(ompRoot(deps2.home, deps2.env ?? {})) || present2(
|
|
49923
|
+
var hasOmp = (deps2) => deps2.which("omp") || present2(ompRoot(deps2.home, deps2.env ?? {})) || present2(join24(deps2.home, ".bun/bin/omp"));
|
|
49655
49924
|
var sharedFile = (deps2) => paths(deps2).omp === paths(deps2).pi;
|
|
49656
49925
|
function readDoc(path) {
|
|
49657
49926
|
let text3;
|
|
49658
49927
|
try {
|
|
49659
|
-
text3 =
|
|
49928
|
+
text3 = readFileSync20(path, "utf8");
|
|
49660
49929
|
} catch (e) {
|
|
49661
49930
|
if (e.code === "ENOENT") return {};
|
|
49662
49931
|
throw e;
|
|
@@ -49713,7 +49982,7 @@ function writeAtomic2(path, data, mode) {
|
|
|
49713
49982
|
function readJsonc(path) {
|
|
49714
49983
|
let text3;
|
|
49715
49984
|
try {
|
|
49716
|
-
text3 =
|
|
49985
|
+
text3 = readFileSync20(path, "utf8");
|
|
49717
49986
|
} catch (e) {
|
|
49718
49987
|
if (e.code === "ENOENT") return "";
|
|
49719
49988
|
throw e;
|
|
@@ -49728,20 +49997,20 @@ function saveText(path, before, next, ok) {
|
|
|
49728
49997
|
writeAtomic2(path, next);
|
|
49729
49998
|
return true;
|
|
49730
49999
|
}
|
|
49731
|
-
function
|
|
50000
|
+
function readRecord2(path) {
|
|
49732
50001
|
try {
|
|
49733
|
-
const v = JSON.parse(
|
|
50002
|
+
const v = JSON.parse(readFileSync20(path, "utf8"));
|
|
49734
50003
|
const c = v?.created;
|
|
49735
50004
|
if (typeof c === "object" && c !== null) return c;
|
|
49736
50005
|
} catch {
|
|
49737
50006
|
}
|
|
49738
50007
|
return {};
|
|
49739
50008
|
}
|
|
49740
|
-
function
|
|
50009
|
+
function writeRecord2(path, before, created) {
|
|
49741
50010
|
if (isDeepStrictEqual(before, created)) return;
|
|
49742
50011
|
let rest = {};
|
|
49743
50012
|
try {
|
|
49744
|
-
const v = JSON.parse(
|
|
50013
|
+
const v = JSON.parse(readFileSync20(path, "utf8"));
|
|
49745
50014
|
if (typeof v === "object" && v !== null && !Array.isArray(v))
|
|
49746
50015
|
rest = v;
|
|
49747
50016
|
} catch {
|
|
@@ -49771,6 +50040,27 @@ async function run3(deps2, cmd, args) {
|
|
|
49771
50040
|
};
|
|
49772
50041
|
}
|
|
49773
50042
|
}
|
|
50043
|
+
function claudeProof(deps2, notes) {
|
|
50044
|
+
if (deps2.hub === void 0) return;
|
|
50045
|
+
try {
|
|
50046
|
+
const note = installProof(
|
|
50047
|
+
proofIo(deps2),
|
|
50048
|
+
deps2.hub,
|
|
50049
|
+
deps2.busBin,
|
|
50050
|
+
movedHome(deps2)
|
|
50051
|
+
);
|
|
50052
|
+
if (note) notes.push(note);
|
|
50053
|
+
} catch (e) {
|
|
50054
|
+
notes.push(
|
|
50055
|
+
`could not add the proof helper to the Claude entry: ${e instanceof Error ? e.message : String(e)}`
|
|
50056
|
+
);
|
|
50057
|
+
}
|
|
50058
|
+
}
|
|
50059
|
+
var proofIo = (deps2) => ({
|
|
50060
|
+
file: paths(deps2).claude,
|
|
50061
|
+
record: paths(deps2).record,
|
|
50062
|
+
write: writeAtomic2
|
|
50063
|
+
});
|
|
49774
50064
|
var firstLine3 = (s) => s.trim().split("\n")[0] ?? "";
|
|
49775
50065
|
var RESTART_FAILED = "opencode service restart failed";
|
|
49776
50066
|
var CODEX_NO_BIN = "no codex binary found; Codex threads are not woken";
|
|
@@ -49803,7 +50093,10 @@ var install = {
|
|
|
49803
50093
|
"mcp",
|
|
49804
50094
|
"claude"
|
|
49805
50095
|
]);
|
|
49806
|
-
if (add.code === 0)
|
|
50096
|
+
if (add.code === 0) {
|
|
50097
|
+
claudeProof(deps2, notes);
|
|
50098
|
+
return "done";
|
|
50099
|
+
}
|
|
49807
50100
|
const path = paths(deps2).claude;
|
|
49808
50101
|
const doc = readDoc(path);
|
|
49809
50102
|
save(
|
|
@@ -49819,6 +50112,7 @@ var install = {
|
|
|
49819
50112
|
notes.push(
|
|
49820
50113
|
`claude mcp add failed (${firstLine3(add.stderr)}); wrote ${path} directly`
|
|
49821
50114
|
);
|
|
50115
|
+
claudeProof(deps2, notes);
|
|
49822
50116
|
return "done";
|
|
49823
50117
|
},
|
|
49824
50118
|
async opencode(deps2, notes) {
|
|
@@ -49843,7 +50137,7 @@ var install = {
|
|
|
49843
50137
|
const nextCli = upsertPlugin(cli, p.opencodePlugin);
|
|
49844
50138
|
target(configPath);
|
|
49845
50139
|
target(p.opencodeCli);
|
|
49846
|
-
const record7 =
|
|
50140
|
+
const record7 = readRecord2(p.record);
|
|
49847
50141
|
const add = (file2, made) => {
|
|
49848
50142
|
const all = [...record7[file2] ?? [], ...made];
|
|
49849
50143
|
return all.filter(
|
|
@@ -49857,9 +50151,9 @@ var install = {
|
|
|
49857
50151
|
created[configPath] = add(configPath, madeConfig);
|
|
49858
50152
|
if (madeCli.length > 0)
|
|
49859
50153
|
created[p.opencodeCli] = add(p.opencodeCli, madeCli);
|
|
49860
|
-
|
|
50154
|
+
writeRecord2(p.record, record7, created);
|
|
49861
50155
|
writeAtomic2(
|
|
49862
|
-
|
|
50156
|
+
join24(p.opencodePlugin, "tui.js"),
|
|
49863
50157
|
withHome(deps2.assets.opencodePlugin, movedHome(deps2)),
|
|
49864
50158
|
420
|
|
49865
50159
|
);
|
|
@@ -49911,7 +50205,7 @@ var install = {
|
|
|
49911
50205
|
const pin = codexBinPin(bin);
|
|
49912
50206
|
let had = "";
|
|
49913
50207
|
try {
|
|
49914
|
-
had =
|
|
50208
|
+
had = readFileSync20(p.codexBin, "utf8");
|
|
49915
50209
|
} catch {
|
|
49916
50210
|
}
|
|
49917
50211
|
if (had !== pin) writeAtomic2(p.codexBin, pin, 384);
|
|
@@ -49932,6 +50226,13 @@ var install = {
|
|
|
49932
50226
|
};
|
|
49933
50227
|
var uninstall = {
|
|
49934
50228
|
async claude(deps2, notes) {
|
|
50229
|
+
try {
|
|
50230
|
+
uninstallProof(proofIo(deps2));
|
|
50231
|
+
} catch (e) {
|
|
50232
|
+
notes.push(
|
|
50233
|
+
`could not take the proof helper off the Claude entry: ${e instanceof Error ? e.message : String(e)}`
|
|
50234
|
+
);
|
|
50235
|
+
}
|
|
49935
50236
|
if (deps2.which("claude")) {
|
|
49936
50237
|
const r = await run3(deps2, "claude", [
|
|
49937
50238
|
"mcp",
|
|
@@ -49950,7 +50251,7 @@ var uninstall = {
|
|
|
49950
50251
|
},
|
|
49951
50252
|
async opencode(deps2, notes) {
|
|
49952
50253
|
const p = paths(deps2);
|
|
49953
|
-
const record7 =
|
|
50254
|
+
const record7 = readRecord2(p.record);
|
|
49954
50255
|
const prune = (file2, text3) => [...record7[file2] ?? []].sort((a, b) => b.length - a.length).reduce(removeIfEmpty, text3);
|
|
49955
50256
|
const edits = [...p.opencodeConfigs.filter(present2), p.opencodeCli].map(
|
|
49956
50257
|
(file2) => {
|
|
@@ -49972,7 +50273,7 @@ var uninstall = {
|
|
|
49972
50273
|
);
|
|
49973
50274
|
const left = { ...record7 };
|
|
49974
50275
|
for (const { file: file2 } of edits) delete left[file2];
|
|
49975
|
-
|
|
50276
|
+
writeRecord2(p.record, record7, left);
|
|
49976
50277
|
const hadPlugin = existsSync8(p.opencodePlugin);
|
|
49977
50278
|
rmSync9(p.opencodePlugin, { recursive: true, force: true });
|
|
49978
50279
|
if (!saved.some(Boolean) && !hadPlugin) return "none";
|
|
@@ -50076,7 +50377,7 @@ function checkAdapters(deps2) {
|
|
|
50076
50377
|
const homeOf = (env2) => typeof env2 === "object" && env2 !== null ? env2.OA_BUS_HOME : void 0;
|
|
50077
50378
|
const homed = (file2) => {
|
|
50078
50379
|
if (!existsSync8(file2)) return false;
|
|
50079
|
-
const first =
|
|
50380
|
+
const first = readFileSync20(file2, "utf8").split("\n", 1)[0] ?? "";
|
|
50080
50381
|
const ob = movedHome(deps2);
|
|
50081
50382
|
return ob === void 0 ? !first.startsWith("process.env.OA_BUS_HOME ||=") : first === homeLine(ob);
|
|
50082
50383
|
};
|
|
@@ -50092,13 +50393,13 @@ function checkAdapters(deps2) {
|
|
|
50092
50393
|
opencode: state(
|
|
50093
50394
|
"opencode",
|
|
50094
50395
|
() => p.opencodeConfigs.filter(present2).some((f) => {
|
|
50095
|
-
const d = parseJsonc(
|
|
50396
|
+
const d = parseJsonc(readFileSync20(f, "utf8"), f);
|
|
50096
50397
|
const e = servers2(d)?.[NAME] ?? d.mcp?.[NAME];
|
|
50097
50398
|
return e !== void 0 && homeOf(e.environment) === movedHome(deps2);
|
|
50098
50399
|
}) && listed(
|
|
50099
|
-
parseJsonc(
|
|
50400
|
+
parseJsonc(readFileSync20(p.opencodeCli, "utf8"), p.opencodeCli),
|
|
50100
50401
|
p.opencodePlugin
|
|
50101
|
-
) && homed(
|
|
50402
|
+
) && homed(join24(p.opencodePlugin, "tui.js"))
|
|
50102
50403
|
),
|
|
50103
50404
|
pi: state("pi", () => homed(p.pi)),
|
|
50104
50405
|
omp: state("omp", () => homed(p.omp)),
|
|
@@ -50136,7 +50437,7 @@ function checkAdapters(deps2) {
|
|
|
50136
50437
|
|
|
50137
50438
|
// src/commands/habits.ts
|
|
50138
50439
|
init_src();
|
|
50139
|
-
import { join as
|
|
50440
|
+
import { join as join25 } from "node:path";
|
|
50140
50441
|
var pluginOn = (p) => `Habits on in the ${p.label} plugin.`;
|
|
50141
50442
|
var pluginOff = (p) => `Habits off in the ${p.label} plugin.`;
|
|
50142
50443
|
var deps = (ctx) => ({
|
|
@@ -50254,7 +50555,7 @@ async function habitsAfterInstall(ctx, json3) {
|
|
|
50254
50555
|
})),
|
|
50255
50556
|
// A plugin has no block to compare: its marker is there ("current") or not.
|
|
50256
50557
|
...plugins2.map((p) => ({
|
|
50257
|
-
path:
|
|
50558
|
+
path: join25(p.dir(ctx.userHome, ctx.env), p.marker),
|
|
50258
50559
|
label: `the ${p.label} plugin`,
|
|
50259
50560
|
s: {
|
|
50260
50561
|
state: pluginHabitsState(deps(ctx), p) === "on" ? "current" : "absent"
|
|
@@ -50297,7 +50598,7 @@ async function habitsAfterInstall(ctx, json3) {
|
|
|
50297
50598
|
const pl = setPluginHabits(
|
|
50298
50599
|
deps(ctx),
|
|
50299
50600
|
plugins2.filter(
|
|
50300
|
-
(p) => asked.includes(
|
|
50601
|
+
(p) => asked.includes(join25(p.dir(ctx.userHome, ctx.env), p.marker))
|
|
50301
50602
|
),
|
|
50302
50603
|
true
|
|
50303
50604
|
);
|
|
@@ -50371,7 +50672,7 @@ import {
|
|
|
50371
50672
|
unlinkSync as unlinkSync3,
|
|
50372
50673
|
writeSync as writeSync3
|
|
50373
50674
|
} from "node:fs";
|
|
50374
|
-
import { join as
|
|
50675
|
+
import { join as join26 } from "node:path";
|
|
50375
50676
|
|
|
50376
50677
|
// src/machine-label.ts
|
|
50377
50678
|
import { hostname as osHostname } from "node:os";
|
|
@@ -50419,7 +50720,7 @@ function checkVerificationUri(uri, hub) {
|
|
|
50419
50720
|
function writeMachineFile(home2, body) {
|
|
50420
50721
|
mkdirSync12(home2, { recursive: true, mode: 448 });
|
|
50421
50722
|
chmodSync13(home2, 448);
|
|
50422
|
-
const tmp =
|
|
50723
|
+
const tmp = join26(home2, `.machine.json.${randomBytes5(8).toString("hex")}.tmp`);
|
|
50423
50724
|
const fd = openSync7(tmp, "wx", 384);
|
|
50424
50725
|
try {
|
|
50425
50726
|
writeSync3(fd, body);
|
|
@@ -50431,7 +50732,7 @@ function writeMachineFile(home2, body) {
|
|
|
50431
50732
|
closeSync7(fd);
|
|
50432
50733
|
try {
|
|
50433
50734
|
chmodSync13(tmp, 384);
|
|
50434
|
-
renameSync13(tmp,
|
|
50735
|
+
renameSync13(tmp, join26(home2, "machine.json"));
|
|
50435
50736
|
} catch (e) {
|
|
50436
50737
|
unlinkSync3(tmp);
|
|
50437
50738
|
throw e;
|
|
@@ -50558,7 +50859,7 @@ async function login(args) {
|
|
|
50558
50859
|
`${JSON.stringify({ hub, label, machine_token: poll.machine_token }, null, 2)}
|
|
50559
50860
|
`
|
|
50560
50861
|
);
|
|
50561
|
-
rmSync10(
|
|
50862
|
+
rmSync10(join26(args.home, "revoked"), { force: true });
|
|
50562
50863
|
if (!events?.code) print(`Approved this machine as ${label}.`);
|
|
50563
50864
|
return {
|
|
50564
50865
|
machineToken: poll.machine_token,
|
|
@@ -50582,7 +50883,7 @@ init_src();
|
|
|
50582
50883
|
|
|
50583
50884
|
// src/commands/install.ts
|
|
50584
50885
|
init_src3();
|
|
50585
|
-
import { join as
|
|
50886
|
+
import { join as join27 } from "node:path";
|
|
50586
50887
|
init_src2();
|
|
50587
50888
|
|
|
50588
50889
|
// src/live.ts
|
|
@@ -50711,7 +51012,7 @@ async function loginStep(ctx, opts) {
|
|
|
50711
51012
|
ctx,
|
|
50712
51013
|
c.approved(result.label),
|
|
50713
51014
|
c.tokenSaved(
|
|
50714
|
-
tilde(ctx,
|
|
51015
|
+
tilde(ctx, join27(ctx.home, "machine.json")),
|
|
50715
51016
|
result.machineToken
|
|
50716
51017
|
),
|
|
50717
51018
|
c.connected(originOf2(result.hub)),
|
|
@@ -50741,10 +51042,12 @@ async function loginStep(ctx, opts) {
|
|
|
50741
51042
|
}
|
|
50742
51043
|
async function harnessesStep(ctx, hub) {
|
|
50743
51044
|
const c = ctx.copy;
|
|
51045
|
+
const hubOrigin2 = hub ? originOf2(hub) : machineOrigin(ctx);
|
|
50744
51046
|
const out = await installAdapters({
|
|
50745
51047
|
home: ctx.userHome,
|
|
50746
51048
|
busHome: ctx.home,
|
|
50747
51049
|
env: ctx.env,
|
|
51050
|
+
...hubOrigin2 ? { hub: hubOrigin2 } : {},
|
|
50748
51051
|
// The service runs this same copy.
|
|
50749
51052
|
busBin: ctx.service.cli(),
|
|
50750
51053
|
assets: readAssets(),
|
|
@@ -50803,7 +51106,7 @@ function shownSocket(ctx) {
|
|
|
50803
51106
|
const real3 = `${canonicalHome(ctx.home)}/`;
|
|
50804
51107
|
return tilde(
|
|
50805
51108
|
ctx,
|
|
50806
|
-
path.startsWith(real3) ?
|
|
51109
|
+
path.startsWith(real3) ? join27(ctx.home, path.slice(real3.length)) : path
|
|
50807
51110
|
);
|
|
50808
51111
|
}
|
|
50809
51112
|
async function waitForDaemon(ctx) {
|
|
@@ -50956,7 +51259,7 @@ async function install2(opts, realCtx2) {
|
|
|
50956
51259
|
return results.every((r) => r.state === "done") ? 0 : 1;
|
|
50957
51260
|
}
|
|
50958
51261
|
const ok = await runSteps(steps, ctx, {
|
|
50959
|
-
path:
|
|
51262
|
+
path: join27(ctx.home, "install.json"),
|
|
50960
51263
|
now: ctx.now
|
|
50961
51264
|
});
|
|
50962
51265
|
const skillFailed = reportSkillFailure(ctx);
|
|
@@ -51043,6 +51346,19 @@ var updateTarget = async (ctx, st, probe2) => {
|
|
|
51043
51346
|
);
|
|
51044
51347
|
return newest !== void 0 && !semverGte(mine, newest) ? newest : void 0;
|
|
51045
51348
|
};
|
|
51349
|
+
var proofLine = (ctx, hub, daemonKnows) => {
|
|
51350
|
+
let origin;
|
|
51351
|
+
try {
|
|
51352
|
+
origin = new URL(hub).origin;
|
|
51353
|
+
} catch {
|
|
51354
|
+
return void 0;
|
|
51355
|
+
}
|
|
51356
|
+
const state = proofState(claudeConfigFile(ctx.userHome, ctx.env), origin);
|
|
51357
|
+
if (state === "none") return void 0;
|
|
51358
|
+
if (state === "missing")
|
|
51359
|
+
return `Claude Code: run ${BUS_CMD} install to set this entry up to show as this session on pages.`;
|
|
51360
|
+
return daemonKnows ? "Claude Code: this entry is set up to show as this session on pages." : "Claude Code: update the daemon so this entry can show as this session on pages.";
|
|
51361
|
+
};
|
|
51046
51362
|
async function status(ctx) {
|
|
51047
51363
|
const c = ctx.copy;
|
|
51048
51364
|
say(ctx, c.header(ctx.version), "");
|
|
@@ -51080,6 +51396,8 @@ async function status(ctx) {
|
|
|
51080
51396
|
if (update) say(ctx, c.updateAvailable(update, st.version));
|
|
51081
51397
|
const habits = habitsLine(ctx);
|
|
51082
51398
|
if (habits) say(ctx, habits);
|
|
51399
|
+
const proof = proofLine(ctx, m.hub, st.link === true);
|
|
51400
|
+
if (proof) say(ctx, proof);
|
|
51083
51401
|
const ocState = openclawPluginState(
|
|
51084
51402
|
openclawPluginDir(ctx.userHome, ctx.env),
|
|
51085
51403
|
void 0
|
|
@@ -51127,7 +51445,7 @@ async function healthz(ctx, hub) {
|
|
|
51127
51445
|
function claudeIsolates(path) {
|
|
51128
51446
|
let text3;
|
|
51129
51447
|
try {
|
|
51130
|
-
text3 =
|
|
51448
|
+
text3 = readFileSync21(path, "utf8");
|
|
51131
51449
|
} catch {
|
|
51132
51450
|
return void 0;
|
|
51133
51451
|
}
|
|
@@ -51194,7 +51512,7 @@ async function doctor(ctx) {
|
|
|
51194
51512
|
const node2 = ctx.nodeVersion.replace(/^v/, "");
|
|
51195
51513
|
if (Number(node2.split(".")[0]) >= MIN_NODE) pass(c.nodeOk(node2));
|
|
51196
51514
|
else fail2(c.nodeOld(node2));
|
|
51197
|
-
const machineFile = tilde(ctx,
|
|
51515
|
+
const machineFile = tilde(ctx, join28(ctx.home, "machine.json"));
|
|
51198
51516
|
const m = readMachine(ctx.home);
|
|
51199
51517
|
if (m.state !== "ok") fail2(c.noCredentials(machineFile));
|
|
51200
51518
|
else if (m.revoked) fail2(c.revokedCheck());
|
|
@@ -51281,8 +51599,8 @@ async function doctor(ctx) {
|
|
|
51281
51599
|
pass(c.wired(h, version2));
|
|
51282
51600
|
else fail2(c.notWired(h));
|
|
51283
51601
|
if (h === "claude") {
|
|
51284
|
-
const settings =
|
|
51285
|
-
ctx.env.CLAUDE_CONFIG_DIR ??
|
|
51602
|
+
const settings = join28(
|
|
51603
|
+
ctx.env.CLAUDE_CONFIG_DIR ?? join28(ctx.userHome, ".claude"),
|
|
51286
51604
|
"settings.json"
|
|
51287
51605
|
);
|
|
51288
51606
|
const isolates = claudeIsolates(settings);
|
|
@@ -51370,12 +51688,12 @@ async function global(opts, ctx) {
|
|
|
51370
51688
|
}
|
|
51371
51689
|
|
|
51372
51690
|
// src/commands/leads.ts
|
|
51373
|
-
import { readFileSync as
|
|
51374
|
-
import { join as
|
|
51691
|
+
import { readFileSync as readFileSync22 } from "node:fs";
|
|
51692
|
+
import { join as join29 } from "node:path";
|
|
51375
51693
|
function hubOrigin(ctx) {
|
|
51376
51694
|
try {
|
|
51377
51695
|
const raw = JSON.parse(
|
|
51378
|
-
|
|
51696
|
+
readFileSync22(join29(ctx.home, "machine.json"), "utf8")
|
|
51379
51697
|
);
|
|
51380
51698
|
return typeof raw?.hub === "string" ? new URL(raw.hub).origin : void 0;
|
|
51381
51699
|
} catch {
|
|
@@ -51526,14 +51844,14 @@ async function link(opts, ctx) {
|
|
|
51526
51844
|
}
|
|
51527
51845
|
|
|
51528
51846
|
// src/commands/logs.ts
|
|
51529
|
-
import { readFileSync as
|
|
51530
|
-
import { join as
|
|
51847
|
+
import { readFileSync as readFileSync23 } from "node:fs";
|
|
51848
|
+
import { join as join30 } from "node:path";
|
|
51531
51849
|
var TAIL = 50;
|
|
51532
51850
|
async function logs(ctx) {
|
|
51533
|
-
const path =
|
|
51851
|
+
const path = join30(ctx.home, "logs", "daemon.log");
|
|
51534
51852
|
let text3;
|
|
51535
51853
|
try {
|
|
51536
|
-
text3 =
|
|
51854
|
+
text3 = readFileSync23(path, "utf8");
|
|
51537
51855
|
} catch {
|
|
51538
51856
|
say(ctx, ctx.copy.noLog(tilde(ctx, path)));
|
|
51539
51857
|
return 1;
|
|
@@ -51558,9 +51876,83 @@ async function mcp(harness, ctx, load = (h) => MCP_SERVER[h]()) {
|
|
|
51558
51876
|
return void 0;
|
|
51559
51877
|
}
|
|
51560
51878
|
|
|
51879
|
+
// src/commands/mcp-proof.ts
|
|
51880
|
+
init_src3();
|
|
51881
|
+
init_src2();
|
|
51882
|
+
init_src();
|
|
51883
|
+
import { execFileSync as execFileSync6 } from "node:child_process";
|
|
51884
|
+
import { createHash as createHash7, randomBytes as randomBytes6 } from "node:crypto";
|
|
51885
|
+
import { readFileSync as readFileSync24, readlinkSync as readlinkSync2 } from "node:fs";
|
|
51886
|
+
import { basename as basename8 } from "node:path";
|
|
51887
|
+
var isClaude = (name) => name === "claude" || /\/claude\/versions\/[^/]+$/.test(name);
|
|
51888
|
+
function readProc(pid) {
|
|
51889
|
+
try {
|
|
51890
|
+
const stat = readFileSync24(`/proc/${pid}/stat`, "utf8");
|
|
51891
|
+
const ppid = Number(stat.slice(stat.lastIndexOf(")") + 1).split(/\s+/)[2]);
|
|
51892
|
+
let exe = "";
|
|
51893
|
+
try {
|
|
51894
|
+
exe = readlinkSync2(`/proc/${pid}/exe`);
|
|
51895
|
+
} catch {
|
|
51896
|
+
}
|
|
51897
|
+
const comm = readFileSync24(`/proc/${pid}/comm`, "utf8").trim();
|
|
51898
|
+
return { ppid, name: isClaude(exe) ? exe : comm };
|
|
51899
|
+
} catch {
|
|
51900
|
+
}
|
|
51901
|
+
try {
|
|
51902
|
+
const out = execFileSync6(
|
|
51903
|
+
systemTool("ps"),
|
|
51904
|
+
["-o", "ppid=,comm=", "-p", String(pid)],
|
|
51905
|
+
{ encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }
|
|
51906
|
+
).trim();
|
|
51907
|
+
const m = /^(\d+)\s+(.+)$/.exec(out);
|
|
51908
|
+
return m ? { ppid: Number(m[1]), name: basename8(m[2]) } : null;
|
|
51909
|
+
} catch {
|
|
51910
|
+
return null;
|
|
51911
|
+
}
|
|
51912
|
+
}
|
|
51913
|
+
function findClaude(from, proc) {
|
|
51914
|
+
let pid = from;
|
|
51915
|
+
for (let i = 0; i < 12 && pid > 1; i += 1) {
|
|
51916
|
+
const p = proc(pid);
|
|
51917
|
+
if (!p) return void 0;
|
|
51918
|
+
if (isClaude(p.name)) return pid;
|
|
51919
|
+
pid = p.ppid;
|
|
51920
|
+
}
|
|
51921
|
+
return void 0;
|
|
51922
|
+
}
|
|
51923
|
+
function tokenOf(file2) {
|
|
51924
|
+
if (!file2) return void 0;
|
|
51925
|
+
try {
|
|
51926
|
+
return readFileSync24(file2, "utf8").trim() || void 0;
|
|
51927
|
+
} catch {
|
|
51928
|
+
return void 0;
|
|
51929
|
+
}
|
|
51930
|
+
}
|
|
51931
|
+
async function mcpProof(opts, ctx, deps2 = {
|
|
51932
|
+
proc: readProc,
|
|
51933
|
+
link: (pid, hash2) => daemonLinkProof({ path: daemonSocketPath(ctx.home), pid, hash: hash2 }),
|
|
51934
|
+
random: () => randomBytes6(32),
|
|
51935
|
+
ppid: process.ppid
|
|
51936
|
+
}) {
|
|
51937
|
+
const headers = {};
|
|
51938
|
+
const token = tokenOf(opts.tokenFile);
|
|
51939
|
+
if (token) headers.Authorization = `Bearer ${token}`;
|
|
51940
|
+
try {
|
|
51941
|
+
const claude = findClaude(deps2.ppid, deps2.proc);
|
|
51942
|
+
if (claude !== void 0) {
|
|
51943
|
+
const proof = deps2.random().toString("base64url");
|
|
51944
|
+
const hash2 = createHash7("sha256").update(proof).digest("hex");
|
|
51945
|
+
if (await deps2.link(claude, hash2)) headers[LINK_PROOF_HEADER] = proof;
|
|
51946
|
+
}
|
|
51947
|
+
} catch {
|
|
51948
|
+
}
|
|
51949
|
+
say(ctx, JSON.stringify(headers));
|
|
51950
|
+
return 0;
|
|
51951
|
+
}
|
|
51952
|
+
|
|
51561
51953
|
// src/commands/namespace.ts
|
|
51562
51954
|
import { realpathSync as realpathSync14, statSync as statSync14 } from "node:fs";
|
|
51563
|
-
import { join as
|
|
51955
|
+
import { join as join31, resolve as resolve11 } from "node:path";
|
|
51564
51956
|
init_src();
|
|
51565
51957
|
function shown4(ctx, path) {
|
|
51566
51958
|
const t = tilde(ctx, path);
|
|
@@ -51614,7 +52006,7 @@ async function namespace(opts, ctx) {
|
|
|
51614
52006
|
sayErr(ctx, c.nsNotDir(shown4(ctx, real3 ?? given)));
|
|
51615
52007
|
return 1;
|
|
51616
52008
|
}
|
|
51617
|
-
const cfgFile =
|
|
52009
|
+
const cfgFile = join31(real3, CONFIG_FILE);
|
|
51618
52010
|
const own2 = readOwnFile(cfgFile, process.getuid?.(), {
|
|
51619
52011
|
allowGroupWrite: true
|
|
51620
52012
|
});
|
|
@@ -51671,12 +52063,12 @@ async function namespace(opts, ctx) {
|
|
|
51671
52063
|
}
|
|
51672
52064
|
|
|
51673
52065
|
// src/commands/uninstall.ts
|
|
51674
|
-
import { join as
|
|
52066
|
+
import { join as join33 } from "node:path";
|
|
51675
52067
|
|
|
51676
52068
|
// src/steps/purge.ts
|
|
51677
52069
|
init_src3();
|
|
51678
52070
|
import { lstatSync as lstatSync15, readdirSync as readdirSync8, rmdirSync as rmdirSync3, rmSync as rmSync11 } from "node:fs";
|
|
51679
|
-
import { join as
|
|
52071
|
+
import { join as join32 } from "node:path";
|
|
51680
52072
|
var FILES = [
|
|
51681
52073
|
"machine.json",
|
|
51682
52074
|
"install.json",
|
|
@@ -51725,14 +52117,14 @@ var rmdirIfEmpty = (path) => {
|
|
|
51725
52117
|
};
|
|
51726
52118
|
function purgeShort(dir, removed) {
|
|
51727
52119
|
if (kind3(dir) !== "dir" || unsafeSocketDir(dir)) return;
|
|
51728
|
-
const ret =
|
|
52120
|
+
const ret = join32(dir, "claude-return");
|
|
51729
52121
|
for (const [d, ours2] of [
|
|
51730
52122
|
[ret, (_n, p) => kind3(p) === "socket"],
|
|
51731
52123
|
[dir, (n) => /^daemon\.sock(\.keep-\d+)?$/.test(n)]
|
|
51732
52124
|
]) {
|
|
51733
52125
|
if (kind3(d) !== "dir") continue;
|
|
51734
52126
|
for (const name of readdirSync8(d)) {
|
|
51735
|
-
const path =
|
|
52127
|
+
const path = join32(d, name);
|
|
51736
52128
|
const k = kind3(path);
|
|
51737
52129
|
if (k === void 0 || k === "dir" || !ours2(name, path)) continue;
|
|
51738
52130
|
remove2(path, k);
|
|
@@ -51757,21 +52149,21 @@ function purge(home2, opts) {
|
|
|
51757
52149
|
...FILES,
|
|
51758
52150
|
...entries.filter((n) => TEMP.some((re) => re.test(n)))
|
|
51759
52151
|
]) {
|
|
51760
|
-
const path =
|
|
52152
|
+
const path = join32(home2, name);
|
|
51761
52153
|
const k = kind3(path);
|
|
51762
52154
|
if (k === void 0 || k === "dir") continue;
|
|
51763
52155
|
remove2(path, k);
|
|
51764
52156
|
removed.push(name);
|
|
51765
52157
|
}
|
|
51766
52158
|
for (const folder of FOLDERS) {
|
|
51767
|
-
const dir =
|
|
52159
|
+
const dir = join32(home2, folder.path);
|
|
51768
52160
|
if (kind3(dir) !== "dir") continue;
|
|
51769
52161
|
for (const name of readdirSync8(dir)) {
|
|
51770
|
-
const path =
|
|
52162
|
+
const path = join32(dir, name);
|
|
51771
52163
|
const k = kind3(path);
|
|
51772
52164
|
if (k === void 0 || !folder.ours(name, path)) continue;
|
|
51773
52165
|
remove2(path, k);
|
|
51774
|
-
removed.push(
|
|
52166
|
+
removed.push(join32(folder.path, name));
|
|
51775
52167
|
}
|
|
51776
52168
|
if (rmdirIfEmpty(dir)) removed.push(folder.path);
|
|
51777
52169
|
}
|
|
@@ -51826,7 +52218,7 @@ async function uninstall2(opts, ctx) {
|
|
|
51826
52218
|
say(
|
|
51827
52219
|
ctx,
|
|
51828
52220
|
c.hermesNoCli(
|
|
51829
|
-
tilde(ctx,
|
|
52221
|
+
tilde(ctx, join33(hermesHome(ctx.userHome, ctx.env), "config.yaml"))
|
|
51830
52222
|
)
|
|
51831
52223
|
);
|
|
51832
52224
|
if (r.openclawNoCli) say(ctx, c.openclawNoCli());
|
|
@@ -51844,7 +52236,7 @@ async function uninstall2(opts, ctx) {
|
|
|
51844
52236
|
r.opencodeRestarted ? c.restartedUnload() : c.opencodeNotRunningUnload()
|
|
51845
52237
|
);
|
|
51846
52238
|
if (!opts.purge) {
|
|
51847
|
-
say(ctx, "", c.kept(tilde(ctx,
|
|
52239
|
+
say(ctx, "", c.kept(tilde(ctx, join33(ctx.home, "machine.json"))));
|
|
51848
52240
|
return 0;
|
|
51849
52241
|
}
|
|
51850
52242
|
const home2 = tilde(ctx, ctx.home);
|
|
@@ -51855,7 +52247,7 @@ async function uninstall2(opts, ctx) {
|
|
|
51855
52247
|
} catch {
|
|
51856
52248
|
}
|
|
51857
52249
|
const out = purge(ctx.home, {
|
|
51858
|
-
isDefault: ctx.home ===
|
|
52250
|
+
isDefault: ctx.home === join33(ctx.userHome, ".oa-bus")
|
|
51859
52251
|
});
|
|
51860
52252
|
if ("refused" in out) {
|
|
51861
52253
|
sayErr(ctx, c.purgeRefused(home2));
|
|
@@ -51875,6 +52267,7 @@ var COMMANDS = /* @__PURE__ */ new Set([
|
|
|
51875
52267
|
"login",
|
|
51876
52268
|
"daemon",
|
|
51877
52269
|
"mcp",
|
|
52270
|
+
"mcp-proof",
|
|
51878
52271
|
"status",
|
|
51879
52272
|
"logs",
|
|
51880
52273
|
"doctor",
|
|
@@ -51907,6 +52300,7 @@ var FLAGS = {
|
|
|
51907
52300
|
login: ["instance", "no-open"],
|
|
51908
52301
|
daemon: ["instance"],
|
|
51909
52302
|
uninstall: ["purge"],
|
|
52303
|
+
"mcp-proof": ["token-file"],
|
|
51910
52304
|
namespace: ["yes"]
|
|
51911
52305
|
};
|
|
51912
52306
|
function parse7(argv) {
|
|
@@ -51917,6 +52311,7 @@ function parse7(argv) {
|
|
|
51917
52311
|
options: {
|
|
51918
52312
|
instance: { type: "string" },
|
|
51919
52313
|
home: { type: "string" },
|
|
52314
|
+
"token-file": { type: "string" },
|
|
51920
52315
|
"no-open": { type: "boolean", default: false },
|
|
51921
52316
|
yes: { type: "boolean", short: "y", default: false },
|
|
51922
52317
|
check: { type: "boolean", default: false },
|
|
@@ -51933,6 +52328,7 @@ function parse7(argv) {
|
|
|
51933
52328
|
const [head, ...rest] = positionals;
|
|
51934
52329
|
const cmd = head ?? "install";
|
|
51935
52330
|
if (!COMMANDS.has(cmd)) throw new Error(`unknown command: ${cmd}`);
|
|
52331
|
+
const tokenFile = values["token-file"];
|
|
51936
52332
|
const takes = cmd === "mcp" ? 1 : cmd === "global" ? rest[0] === "list" ? 1 : 2 : 0;
|
|
51937
52333
|
if (cmd === "mcp" && rest.length === 0)
|
|
51938
52334
|
throw new Error(`usage: ${BUS_CMD} mcp <claude|opencode|codex|pi>`);
|
|
@@ -51970,7 +52366,7 @@ function parse7(argv) {
|
|
|
51970
52366
|
const home2 = values.home;
|
|
51971
52367
|
if (values.version)
|
|
51972
52368
|
return { cmd: "version", noColor, ...home2 ? { home: home2 } : {} };
|
|
51973
|
-
const parsed = route(cmd, values, rest);
|
|
52369
|
+
const parsed = cmd === "mcp-proof" ? { cmd, ...tokenFile ? { tokenFile } : {} } : route(cmd, values, rest);
|
|
51974
52370
|
return { ...parsed, noColor, ...home2 ? { home: home2 } : {} };
|
|
51975
52371
|
}
|
|
51976
52372
|
function route(cmd, values, positionals) {
|
|
@@ -52103,6 +52499,8 @@ async function dispatch(cmd, ctx) {
|
|
|
52103
52499
|
case "mcp":
|
|
52104
52500
|
if (cmd.home) process.env.OA_BUS_HOME = ctx.home;
|
|
52105
52501
|
return mcp(cmd.harness, ctx);
|
|
52502
|
+
case "mcp-proof":
|
|
52503
|
+
return mcpProof({ tokenFile: cmd.tokenFile }, ctx);
|
|
52106
52504
|
case "status":
|
|
52107
52505
|
return status(ctx);
|
|
52108
52506
|
case "logs":
|