@open-artifacts/bus 0.199.4 → 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 +1084 -373
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -4586,7 +4586,7 @@ function isRef(value) {
|
|
|
4586
4586
|
function cloneIssues(issues) {
|
|
4587
4587
|
return issues.map((iss) => iss.path ? { ...iss, path: iss.path.slice() } : { ...iss });
|
|
4588
4588
|
}
|
|
4589
|
-
function isRecursive(inst, stack,
|
|
4589
|
+
function isRecursive(inst, stack, resolve18) {
|
|
4590
4590
|
const cached2 = recursive.get(inst);
|
|
4591
4591
|
if (cached2 !== void 0)
|
|
4592
4592
|
return cached2 ? PROVEN : NONE;
|
|
@@ -4596,7 +4596,7 @@ function isRecursive(inst, stack, resolve17) {
|
|
|
4596
4596
|
let result = NONE;
|
|
4597
4597
|
const check2 = (child) => {
|
|
4598
4598
|
if (result !== PROVEN && child?._zod) {
|
|
4599
|
-
const answer = isRecursive(child, stack,
|
|
4599
|
+
const answer = isRecursive(child, stack, resolve18);
|
|
4600
4600
|
if (answer > result)
|
|
4601
4601
|
result = answer;
|
|
4602
4602
|
}
|
|
@@ -4607,7 +4607,7 @@ function isRecursive(inst, stack, resolve17) {
|
|
|
4607
4607
|
const desc = Object.getOwnPropertyDescriptor(sh, key2);
|
|
4608
4608
|
if (spread && !desc.enumerable)
|
|
4609
4609
|
continue;
|
|
4610
|
-
const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack,
|
|
4610
|
+
const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack, resolve18) : NONE;
|
|
4611
4611
|
if (child > answer)
|
|
4612
4612
|
answer = child;
|
|
4613
4613
|
}
|
|
@@ -4671,7 +4671,7 @@ function isRecursive(inst, stack, resolve17) {
|
|
|
4671
4671
|
break;
|
|
4672
4672
|
// `$ZodLazy` caches its inner on the def, so a resolved edge is followed exactly
|
|
4673
4673
|
case "lazy": {
|
|
4674
|
-
const inner = def._cachedInner ?? (
|
|
4674
|
+
const inner = def._cachedInner ?? (resolve18 ? inst._zod.innerType : void 0);
|
|
4675
4675
|
merge2(inner ? isRecursive(inner, stack, false) : ASSUMED);
|
|
4676
4676
|
break;
|
|
4677
4677
|
}
|
|
@@ -23038,7 +23038,7 @@ var init_protocol = __esm({
|
|
|
23038
23038
|
return;
|
|
23039
23039
|
}
|
|
23040
23040
|
const pollInterval = task2.pollInterval ?? this._options?.defaultTaskPollInterval ?? 1e3;
|
|
23041
|
-
await new Promise((
|
|
23041
|
+
await new Promise((resolve18) => setTimeout(resolve18, pollInterval));
|
|
23042
23042
|
options?.signal?.throwIfAborted();
|
|
23043
23043
|
}
|
|
23044
23044
|
} catch (error62) {
|
|
@@ -23055,7 +23055,7 @@ var init_protocol = __esm({
|
|
|
23055
23055
|
*/
|
|
23056
23056
|
request(request, resultSchema, options) {
|
|
23057
23057
|
const { relatedRequestId, resumptionToken, onresumptiontoken, task, relatedTask } = options ?? {};
|
|
23058
|
-
return new Promise((
|
|
23058
|
+
return new Promise((resolve18, reject) => {
|
|
23059
23059
|
const earlyReject = (error62) => {
|
|
23060
23060
|
reject(error62);
|
|
23061
23061
|
};
|
|
@@ -23133,7 +23133,7 @@ var init_protocol = __esm({
|
|
|
23133
23133
|
if (!parseResult.success) {
|
|
23134
23134
|
reject(parseResult.error);
|
|
23135
23135
|
} else {
|
|
23136
|
-
|
|
23136
|
+
resolve18(parseResult.data);
|
|
23137
23137
|
}
|
|
23138
23138
|
} catch (error62) {
|
|
23139
23139
|
reject(error62);
|
|
@@ -23395,12 +23395,12 @@ var init_protocol = __esm({
|
|
|
23395
23395
|
}
|
|
23396
23396
|
} catch {
|
|
23397
23397
|
}
|
|
23398
|
-
return new Promise((
|
|
23398
|
+
return new Promise((resolve18, reject) => {
|
|
23399
23399
|
if (signal.aborted) {
|
|
23400
23400
|
reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
|
|
23401
23401
|
return;
|
|
23402
23402
|
}
|
|
23403
|
-
const timeoutId = setTimeout(
|
|
23403
|
+
const timeoutId = setTimeout(resolve18, interval);
|
|
23404
23404
|
signal.addEventListener("abort", () => {
|
|
23405
23405
|
clearTimeout(timeoutId);
|
|
23406
23406
|
reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
|
|
@@ -26427,7 +26427,7 @@ var require_compile = __commonJS({
|
|
|
26427
26427
|
const schOrFunc = root.refs[ref];
|
|
26428
26428
|
if (schOrFunc)
|
|
26429
26429
|
return schOrFunc;
|
|
26430
|
-
let _sch =
|
|
26430
|
+
let _sch = resolve18.call(this, root, ref);
|
|
26431
26431
|
if (_sch === void 0) {
|
|
26432
26432
|
const schema = (_a3 = root.localRefs) === null || _a3 === void 0 ? void 0 : _a3[ref];
|
|
26433
26433
|
const { schemaId } = this.opts;
|
|
@@ -26454,7 +26454,7 @@ var require_compile = __commonJS({
|
|
|
26454
26454
|
function sameSchemaEnv(s1, s2) {
|
|
26455
26455
|
return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
|
|
26456
26456
|
}
|
|
26457
|
-
function
|
|
26457
|
+
function resolve18(root, ref) {
|
|
26458
26458
|
let sch;
|
|
26459
26459
|
while (typeof (sch = this.refs[ref]) == "string")
|
|
26460
26460
|
ref = sch;
|
|
@@ -27284,7 +27284,7 @@ var require_fast_uri = __commonJS({
|
|
|
27284
27284
|
}
|
|
27285
27285
|
return uri;
|
|
27286
27286
|
}
|
|
27287
|
-
function
|
|
27287
|
+
function resolve18(baseURI, relativeURI, options) {
|
|
27288
27288
|
const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
|
|
27289
27289
|
const {
|
|
27290
27290
|
parsed: baseParsed,
|
|
@@ -27653,7 +27653,7 @@ var require_fast_uri = __commonJS({
|
|
|
27653
27653
|
var fastUri = {
|
|
27654
27654
|
SCHEMES,
|
|
27655
27655
|
normalize,
|
|
27656
|
-
resolve:
|
|
27656
|
+
resolve: resolve18,
|
|
27657
27657
|
resolveComponent,
|
|
27658
27658
|
equal,
|
|
27659
27659
|
serialize,
|
|
@@ -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({
|
|
@@ -33199,8 +33221,8 @@ import { connect } from "node:net";
|
|
|
33199
33221
|
async function connectDaemon(opts) {
|
|
33200
33222
|
const sock = connect(opts.path);
|
|
33201
33223
|
if (opts.unref) sock.unref();
|
|
33202
|
-
await new Promise((
|
|
33203
|
-
sock.once("connect",
|
|
33224
|
+
await new Promise((resolve18, reject) => {
|
|
33225
|
+
sock.once("connect", resolve18);
|
|
33204
33226
|
sock.once("error", reject);
|
|
33205
33227
|
});
|
|
33206
33228
|
const decoder = new LineDecoder();
|
|
@@ -33267,8 +33289,8 @@ async function connectDaemon(opts) {
|
|
|
33267
33289
|
sock.on("error", (e) => failAll(e));
|
|
33268
33290
|
sock.on("close", () => failAll(new Error("daemon connection closed")));
|
|
33269
33291
|
let timer;
|
|
33270
|
-
const welcomeRaw = await new Promise((
|
|
33271
|
-
waiters.push({ resolve:
|
|
33292
|
+
const welcomeRaw = await new Promise((resolve18, reject) => {
|
|
33293
|
+
waiters.push({ resolve: resolve18, reject });
|
|
33272
33294
|
timer = setTimeout(() => {
|
|
33273
33295
|
reject(new Error("daemon did not answer hello"));
|
|
33274
33296
|
sock.destroy();
|
|
@@ -33290,7 +33312,7 @@ async function connectDaemon(opts) {
|
|
|
33290
33312
|
if (state === "closed")
|
|
33291
33313
|
return Promise.reject(new Error("daemon connection closed"));
|
|
33292
33314
|
const id = partial2.id ?? String(++seq2);
|
|
33293
|
-
return new Promise((
|
|
33315
|
+
return new Promise((resolve18, reject) => {
|
|
33294
33316
|
const ms = opts.requestTimeoutMs ?? 2e4;
|
|
33295
33317
|
const timer2 = setTimeout(() => {
|
|
33296
33318
|
if (pending.delete(id)) {
|
|
@@ -33307,7 +33329,7 @@ async function connectDaemon(opts) {
|
|
|
33307
33329
|
clearTimeout(timer2);
|
|
33308
33330
|
f(...a);
|
|
33309
33331
|
};
|
|
33310
|
-
pending.set(id, { resolve: done(
|
|
33332
|
+
pending.set(id, { resolve: done(resolve18), reject: done(reject) });
|
|
33311
33333
|
holdWhilePending();
|
|
33312
33334
|
sock.write(`${JSON.stringify({ v: 1, ...partial2, id })}
|
|
33313
33335
|
`);
|
|
@@ -33332,7 +33354,7 @@ async function connectDaemon(opts) {
|
|
|
33332
33354
|
};
|
|
33333
33355
|
}
|
|
33334
33356
|
function daemonStatus(opts) {
|
|
33335
|
-
return new Promise((
|
|
33357
|
+
return new Promise((resolve18, reject) => {
|
|
33336
33358
|
const sock = connect(opts.path);
|
|
33337
33359
|
const decoder = new LineDecoder();
|
|
33338
33360
|
const done = (f) => {
|
|
@@ -33369,7 +33391,7 @@ function daemonStatus(opts) {
|
|
|
33369
33391
|
try {
|
|
33370
33392
|
for (const raw of decoder.push(chunk)) {
|
|
33371
33393
|
const f = DaemonFrame.parse(raw);
|
|
33372
|
-
if (f.type === "status") return done(() =>
|
|
33394
|
+
if (f.type === "status") return done(() => resolve18(f));
|
|
33373
33395
|
if (f.type === "error")
|
|
33374
33396
|
return done(
|
|
33375
33397
|
() => reject(
|
|
@@ -33388,7 +33410,7 @@ function daemonStatus(opts) {
|
|
|
33388
33410
|
});
|
|
33389
33411
|
}
|
|
33390
33412
|
function daemonLinkProof(opts) {
|
|
33391
|
-
return new Promise((
|
|
33413
|
+
return new Promise((resolve18, reject) => {
|
|
33392
33414
|
const sock = connect(opts.path);
|
|
33393
33415
|
const decoder = new LineDecoder();
|
|
33394
33416
|
const done = (f) => {
|
|
@@ -33416,7 +33438,7 @@ function daemonLinkProof(opts) {
|
|
|
33416
33438
|
try {
|
|
33417
33439
|
for (const raw of decoder.push(chunk)) {
|
|
33418
33440
|
const f = DaemonFrame.parse(raw);
|
|
33419
|
-
if (f.type === "link_proofed") return done(() =>
|
|
33441
|
+
if (f.type === "link_proofed") return done(() => resolve18(f.bound));
|
|
33420
33442
|
if (f.type === "error")
|
|
33421
33443
|
return done(() => reject(new Error(f.message)));
|
|
33422
33444
|
}
|
|
@@ -33798,13 +33820,13 @@ async function clearStale(path) {
|
|
|
33798
33820
|
code: "ENOTSOCK"
|
|
33799
33821
|
});
|
|
33800
33822
|
}
|
|
33801
|
-
const live = await new Promise((
|
|
33823
|
+
const live = await new Promise((resolve18) => {
|
|
33802
33824
|
const probe2 = connect2(path);
|
|
33803
33825
|
probe2.once("connect", () => {
|
|
33804
33826
|
probe2.destroy();
|
|
33805
|
-
|
|
33827
|
+
resolve18(true);
|
|
33806
33828
|
});
|
|
33807
|
-
probe2.once("error", () =>
|
|
33829
|
+
probe2.once("error", () => resolve18(false));
|
|
33808
33830
|
});
|
|
33809
33831
|
if (live) {
|
|
33810
33832
|
throw Object.assign(new Error(`daemon already listening on ${path}`), {
|
|
@@ -33824,16 +33846,16 @@ async function serveDaemon(opts) {
|
|
|
33824
33846
|
sock.once("close", () => sockets.delete(sock));
|
|
33825
33847
|
handle(sock, opts);
|
|
33826
33848
|
});
|
|
33827
|
-
await new Promise((
|
|
33849
|
+
await new Promise((resolve18, reject) => {
|
|
33828
33850
|
server4.once("error", reject);
|
|
33829
|
-
server4.listen(opts.path, () =>
|
|
33851
|
+
server4.listen(opts.path, () => resolve18());
|
|
33830
33852
|
});
|
|
33831
33853
|
chmodSync(opts.path, 384);
|
|
33832
33854
|
const st = statSync(opts.path);
|
|
33833
33855
|
const mode = st.mode & 511;
|
|
33834
33856
|
return {
|
|
33835
33857
|
mode,
|
|
33836
|
-
close: () => new Promise((
|
|
33858
|
+
close: () => new Promise((resolve18) => {
|
|
33837
33859
|
for (const s of sockets) s.destroy();
|
|
33838
33860
|
let parked;
|
|
33839
33861
|
try {
|
|
@@ -33851,7 +33873,7 @@ async function serveDaemon(opts) {
|
|
|
33851
33873
|
} catch {
|
|
33852
33874
|
}
|
|
33853
33875
|
}
|
|
33854
|
-
|
|
33876
|
+
resolve18();
|
|
33855
33877
|
});
|
|
33856
33878
|
})
|
|
33857
33879
|
};
|
|
@@ -34897,7 +34919,7 @@ ${neutralize(a.text)}
|
|
|
34897
34919
|
};
|
|
34898
34920
|
}
|
|
34899
34921
|
function inject(a) {
|
|
34900
|
-
return new Promise((
|
|
34922
|
+
return new Promise((resolve18, reject) => {
|
|
34901
34923
|
const sock = connect3(a.socketPath);
|
|
34902
34924
|
let connected = false;
|
|
34903
34925
|
const fail3 = (e) => {
|
|
@@ -34921,7 +34943,7 @@ function inject(a) {
|
|
|
34921
34943
|
sock.once("finish", () => {
|
|
34922
34944
|
clearTimeout(timer);
|
|
34923
34945
|
sock.destroy();
|
|
34924
|
-
|
|
34946
|
+
resolve18();
|
|
34925
34947
|
});
|
|
34926
34948
|
sock.end(`${JSON.stringify(frameOf(a))}
|
|
34927
34949
|
`);
|
|
@@ -44026,12 +44048,12 @@ var init_stdio2 = __esm({
|
|
|
44026
44048
|
this.onclose?.();
|
|
44027
44049
|
}
|
|
44028
44050
|
send(message) {
|
|
44029
|
-
return new Promise((
|
|
44051
|
+
return new Promise((resolve18) => {
|
|
44030
44052
|
const json4 = serializeMessage(message);
|
|
44031
44053
|
if (this._stdout.write(json4)) {
|
|
44032
|
-
|
|
44054
|
+
resolve18();
|
|
44033
44055
|
} else {
|
|
44034
|
-
this._stdout.once("drain",
|
|
44056
|
+
this._stdout.once("drain", resolve18);
|
|
44035
44057
|
}
|
|
44036
44058
|
});
|
|
44037
44059
|
}
|
|
@@ -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
|
}
|
|
@@ -44440,7 +44462,7 @@ var harnessSkills = {
|
|
|
44440
44462
|
var harnessNames = Object.keys(harnessSkills);
|
|
44441
44463
|
|
|
44442
44464
|
// src/main.ts
|
|
44443
|
-
import { resolve as
|
|
44465
|
+
import { resolve as resolve17 } from "node:path";
|
|
44444
44466
|
import { fileURLToPath as fileURLToPath7 } from "node:url";
|
|
44445
44467
|
|
|
44446
44468
|
// ../bus-daemon/src/index.ts
|
|
@@ -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;
|
|
@@ -49161,12 +49190,12 @@ var Receipts = class {
|
|
|
49161
49190
|
this.#waiting.delete(msgId);
|
|
49162
49191
|
return Promise.resolve(w.final);
|
|
49163
49192
|
}
|
|
49164
|
-
return new Promise((
|
|
49193
|
+
return new Promise((resolve18) => {
|
|
49165
49194
|
const cancel = this.#after(ms, () => w.done?.(void 0));
|
|
49166
49195
|
w.done = (f) => {
|
|
49167
49196
|
cancel();
|
|
49168
49197
|
this.#waiting.delete(msgId);
|
|
49169
|
-
|
|
49198
|
+
resolve18(f);
|
|
49170
49199
|
};
|
|
49171
49200
|
});
|
|
49172
49201
|
}
|
|
@@ -49503,22 +49532,22 @@ var ClaudeTransport = class {
|
|
|
49503
49532
|
return { ok: false, reason: "closed", cause: st };
|
|
49504
49533
|
}
|
|
49505
49534
|
#waitFor(msgId, ms) {
|
|
49506
|
-
return new Promise((
|
|
49535
|
+
return new Promise((resolve18) => {
|
|
49507
49536
|
const buffered = this.#buffered.get(msgId);
|
|
49508
49537
|
if (buffered !== void 0) {
|
|
49509
49538
|
this.#buffered.delete(msgId);
|
|
49510
|
-
|
|
49539
|
+
resolve18(buffered);
|
|
49511
49540
|
return;
|
|
49512
49541
|
}
|
|
49513
49542
|
const timer = setTimeout(() => {
|
|
49514
49543
|
this.#waiting.delete(msgId);
|
|
49515
|
-
|
|
49544
|
+
resolve18(void 0);
|
|
49516
49545
|
}, ms);
|
|
49517
49546
|
timer.unref();
|
|
49518
49547
|
this.#waiting.set(msgId, (s) => {
|
|
49519
49548
|
clearTimeout(timer);
|
|
49520
49549
|
this.#waiting.delete(msgId);
|
|
49521
|
-
|
|
49550
|
+
resolve18(s);
|
|
49522
49551
|
});
|
|
49523
49552
|
});
|
|
49524
49553
|
}
|
|
@@ -49668,9 +49697,9 @@ var ClaudeTransport = class {
|
|
|
49668
49697
|
);
|
|
49669
49698
|
})
|
|
49670
49699
|
};
|
|
49671
|
-
await new Promise((
|
|
49700
|
+
await new Promise((resolve18, reject) => {
|
|
49672
49701
|
sink.server.once("error", reject);
|
|
49673
|
-
sink.server.listen(path, () =>
|
|
49702
|
+
sink.server.listen(path, () => resolve18());
|
|
49674
49703
|
});
|
|
49675
49704
|
chmodSync10(path, 384);
|
|
49676
49705
|
return sink;
|
|
@@ -49933,7 +49962,7 @@ function splitArgv0(args) {
|
|
|
49933
49962
|
});
|
|
49934
49963
|
return words(args.slice(real3 ?? ends[0]));
|
|
49935
49964
|
}
|
|
49936
|
-
var execText = (cmd, args) => new Promise((
|
|
49965
|
+
var execText = (cmd, args) => new Promise((resolve18) => {
|
|
49937
49966
|
execFile(
|
|
49938
49967
|
cmd,
|
|
49939
49968
|
args,
|
|
@@ -49942,7 +49971,7 @@ var execText = (cmd, args) => new Promise((resolve17) => {
|
|
|
49942
49971
|
timeout: 2e3,
|
|
49943
49972
|
env: { ...process.env, LC_ALL: "C" }
|
|
49944
49973
|
},
|
|
49945
|
-
(err, stdout) =>
|
|
49974
|
+
(err, stdout) => resolve18(err ? void 0 : stdout)
|
|
49946
49975
|
);
|
|
49947
49976
|
});
|
|
49948
49977
|
async function processArgs(pid) {
|
|
@@ -49965,17 +49994,17 @@ async function processArgs(pid) {
|
|
|
49965
49994
|
return args ? splitArgv0(args) : void 0;
|
|
49966
49995
|
}
|
|
49967
49996
|
var START_ERRORS = /* @__PURE__ */ new Set(["ENOENT", "EACCES", "ENOEXEC"]);
|
|
49968
|
-
var execCodex = (timeoutMs = CODEX_QUEUE_TIMEOUT_MS) => (bin, args, env2) => new Promise((
|
|
49997
|
+
var execCodex = (timeoutMs = CODEX_QUEUE_TIMEOUT_MS) => (bin, args, env2) => new Promise((resolve18, reject) => {
|
|
49969
49998
|
execFile(
|
|
49970
49999
|
bin,
|
|
49971
50000
|
args,
|
|
49972
50001
|
{ timeout: timeoutMs, maxBuffer: 64 * 1024, env: env2 },
|
|
49973
50002
|
(err, _stdout, stderr) => {
|
|
49974
|
-
if (!err) return
|
|
50003
|
+
if (!err) return resolve18({ code: 0, stderr });
|
|
49975
50004
|
const e = err;
|
|
49976
50005
|
if (typeof e.code === "string" && START_ERRORS.has(e.code))
|
|
49977
50006
|
return reject(err);
|
|
49978
|
-
|
|
50007
|
+
resolve18({
|
|
49979
50008
|
// A maxBuffer kill is SIGTERM too, but carries its own string code.
|
|
49980
50009
|
code: e.killed && e.signal === "SIGTERM" && typeof e.code !== "string" ? null : typeof e.code === "number" ? e.code : -1,
|
|
49981
50010
|
stderr: String(stderr ?? "")
|
|
@@ -50180,17 +50209,17 @@ var CODEX_WAKE_TEXT = `Open Artifacts bus: messages are waiting for this thread.
|
|
|
50180
50209
|
init_src2();
|
|
50181
50210
|
import { execFile as execFile2 } from "node:child_process";
|
|
50182
50211
|
var START_ERRORS2 = /* @__PURE__ */ new Set(["ENOENT", "EACCES"]);
|
|
50183
|
-
var execSpawn = (timeoutMs, maxBuffer = 1024 * 1024) => (cmd, args) => new Promise((
|
|
50212
|
+
var execSpawn = (timeoutMs, maxBuffer = 1024 * 1024) => (cmd, args) => new Promise((resolve18, reject) => {
|
|
50184
50213
|
execFile2(
|
|
50185
50214
|
cmd,
|
|
50186
50215
|
args,
|
|
50187
50216
|
{ timeout: timeoutMs, maxBuffer },
|
|
50188
50217
|
(err, stdout, stderr) => {
|
|
50189
|
-
if (!err) return
|
|
50218
|
+
if (!err) return resolve18({ code: 0, stdout, stderr });
|
|
50190
50219
|
const e = err;
|
|
50191
50220
|
if (typeof e.code === "string" && START_ERRORS2.has(e.code))
|
|
50192
50221
|
return reject(err);
|
|
50193
|
-
|
|
50222
|
+
resolve18({
|
|
50194
50223
|
code: e.killed || typeof e.code !== "number" ? null : e.code,
|
|
50195
50224
|
stdout,
|
|
50196
50225
|
stderr
|
|
@@ -50307,18 +50336,18 @@ var PiTransport = class {
|
|
|
50307
50336
|
});
|
|
50308
50337
|
if (!pushed) return { ok: false, reason: "closed" };
|
|
50309
50338
|
this.#forget(mail.msg_id);
|
|
50310
|
-
return new Promise((
|
|
50339
|
+
return new Promise((resolve18) => {
|
|
50311
50340
|
const timer = setTimeout(() => {
|
|
50312
50341
|
this.#waiting.delete(mail.msg_id);
|
|
50313
50342
|
this.#remember(mail.msg_id, agent.ref);
|
|
50314
|
-
|
|
50343
|
+
resolve18({ ok: false, reason: "timeout" });
|
|
50315
50344
|
}, this.opts.ackTimeoutMs ?? 1e4);
|
|
50316
50345
|
timer.unref();
|
|
50317
50346
|
this.#waiting.set(mail.msg_id, {
|
|
50318
50347
|
ref: agent.ref,
|
|
50319
50348
|
done: (o) => {
|
|
50320
50349
|
clearTimeout(timer);
|
|
50321
|
-
|
|
50350
|
+
resolve18(o);
|
|
50322
50351
|
}
|
|
50323
50352
|
});
|
|
50324
50353
|
});
|
|
@@ -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);
|
|
@@ -53551,30 +53604,30 @@ async function runDaemon(deps2 = {}) {
|
|
|
53551
53604
|
statusEveryMs: deps2.status?.statusEveryMs
|
|
53552
53605
|
});
|
|
53553
53606
|
const hubRoster = (ref) => new Promise(
|
|
53554
|
-
(
|
|
53607
|
+
(resolve18) => {
|
|
53555
53608
|
const id = pending.open(
|
|
53556
53609
|
"status",
|
|
53557
|
-
(f) =>
|
|
53610
|
+
(f) => resolve18(f.type === "roster" ? f.agents : void 0)
|
|
53558
53611
|
);
|
|
53559
53612
|
const timer = setTimeout(() => {
|
|
53560
53613
|
pending.cancel(id);
|
|
53561
53614
|
hub.cancel(id);
|
|
53562
|
-
|
|
53615
|
+
resolve18(void 0);
|
|
53563
53616
|
}, deps2.statusRosterMs ?? 1500);
|
|
53564
53617
|
timer.unref();
|
|
53565
53618
|
if (!hub.send({ v: 1, id, type: "list", from_ref: ref })) {
|
|
53566
53619
|
clearTimeout(timer);
|
|
53567
53620
|
pending.cancel(id);
|
|
53568
|
-
|
|
53621
|
+
resolve18(void 0);
|
|
53569
53622
|
}
|
|
53570
53623
|
}
|
|
53571
53624
|
);
|
|
53572
|
-
const hubWaitingCounts = (refs) => new Promise((
|
|
53625
|
+
const hubWaitingCounts = (refs) => new Promise((resolve18) => {
|
|
53573
53626
|
const id = frameId();
|
|
53574
53627
|
const done = (c) => {
|
|
53575
53628
|
clearTimeout(timer);
|
|
53576
53629
|
waitingAsks.delete(id);
|
|
53577
|
-
|
|
53630
|
+
resolve18(c);
|
|
53578
53631
|
};
|
|
53579
53632
|
const timer = setTimeout(() => {
|
|
53580
53633
|
hub.cancel(id);
|
|
@@ -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.`)
|
|
@@ -55251,15 +55331,15 @@ function copy(style, bus = BUS_CMD, approve) {
|
|
|
55251
55331
|
`Check that \`claude plugin list\` runs, then run ${bus} doctor again.`
|
|
55252
55332
|
)
|
|
55253
55333
|
],
|
|
55254
|
-
styleFileOld: (
|
|
55334
|
+
styleFileOld: (where2) => [
|
|
55255
55335
|
warn(
|
|
55256
|
-
`An older output style file (${clip(
|
|
55336
|
+
`An older output style file (${clip(where2, 20)}) also lists Artifacts Teammate, so it shows twice.`
|
|
55257
55337
|
),
|
|
55258
55338
|
next(`Run ${bus} to remove the old file.`)
|
|
55259
55339
|
],
|
|
55260
|
-
styleFileOldNoClaude: (
|
|
55340
|
+
styleFileOldNoClaude: (where2, min) => [
|
|
55261
55341
|
warn(
|
|
55262
|
-
`An older output style file (${clip(
|
|
55342
|
+
`An older output style file (${clip(where2, 20)}) is still in use. ${bus} can't replace it until Claude Code ${min} or later is on PATH.`
|
|
55263
55343
|
),
|
|
55264
55344
|
next(`Install or update Claude Code, then run ${bus}.`)
|
|
55265
55345
|
],
|
|
@@ -55273,35 +55353,35 @@ function copy(style, bus = BUS_CMD, approve) {
|
|
|
55273
55353
|
],
|
|
55274
55354
|
pluginsStatus: () => done("Claude Code plugins: session shortcuts, output style"),
|
|
55275
55355
|
// #1626: the `oa-bus` shim on PATH.
|
|
55276
|
-
shimInstalled: (
|
|
55356
|
+
shimInstalled: (where2) => done(`Installed the oa-bus command: ${clip(where2, 30)}`),
|
|
55277
55357
|
shimNotOnPath: (dir, hint) => [
|
|
55278
55358
|
warn(
|
|
55279
55359
|
`${clip(dir, 30)} is not on your PATH, so \`oa-bus\` won't run yet.`
|
|
55280
55360
|
),
|
|
55281
55361
|
next(`To fix it, add this line to your shell profile: ${hint}`)
|
|
55282
55362
|
],
|
|
55283
|
-
shimForeign: (
|
|
55284
|
-
warn(`Left ${clip(
|
|
55363
|
+
shimForeign: (where2) => [
|
|
55364
|
+
warn(`Left ${clip(where2, 30)} alone: it isn't from Open Artifacts.`),
|
|
55285
55365
|
next(
|
|
55286
55366
|
`Typing \`oa-bus\` runs that file, not this install. Remove it, or use \`${BUS_CMD}\`.`
|
|
55287
55367
|
)
|
|
55288
55368
|
],
|
|
55289
|
-
shimOtherHome: (
|
|
55369
|
+
shimOtherHome: (where2, home2) => [
|
|
55290
55370
|
warn(
|
|
55291
|
-
`Left ${clip(
|
|
55371
|
+
`Left ${clip(where2, 30)} alone: it belongs to the install in ${clip(home2, 30)}.`
|
|
55292
55372
|
),
|
|
55293
55373
|
next(
|
|
55294
55374
|
`Typing \`oa-bus\` runs that install, not this one. Use \`${BUS_CMD}\` for this one.`
|
|
55295
55375
|
)
|
|
55296
55376
|
],
|
|
55297
|
-
shimRemoved: (
|
|
55298
|
-
shimDoctorOk: (
|
|
55299
|
-
shimDoctorOffPath: (
|
|
55300
|
-
warn(`oa-bus is not on your PATH (the command is in ${clip(
|
|
55377
|
+
shimRemoved: (where2) => done(`Removed the oa-bus command: ${clip(where2, 30)}`),
|
|
55378
|
+
shimDoctorOk: (where2) => done(`oa-bus on your PATH runs this install (${clip(where2, 30)})`),
|
|
55379
|
+
shimDoctorOffPath: (where2, hint) => [
|
|
55380
|
+
warn(`oa-bus is not on your PATH (the command is in ${clip(where2, 30)})`),
|
|
55301
55381
|
next(`To fix it, add this line to your shell profile: ${hint}`)
|
|
55302
55382
|
],
|
|
55303
|
-
shimDoctorOther: (
|
|
55304
|
-
warn(`oa-bus on your PATH is not this install's (${clip(
|
|
55383
|
+
shimDoctorOther: (where2) => [
|
|
55384
|
+
warn(`oa-bus on your PATH is not this install's (${clip(where2, 30)})`),
|
|
55305
55385
|
next(
|
|
55306
55386
|
`Remove it, or put this install's first. Re-run ${BUS_CMD} install to refresh ours.`
|
|
55307
55387
|
)
|
|
@@ -55310,7 +55390,7 @@ function copy(style, bus = BUS_CMD, approve) {
|
|
|
55310
55390
|
warn("oa-bus is not on your PATH"),
|
|
55311
55391
|
next(`Run ${BUS_CMD} install to add it.`)
|
|
55312
55392
|
],
|
|
55313
|
-
codexSkill: (
|
|
55393
|
+
codexSkill: (where2) => done(`Codex skill installed in ${clip(where2, 20)}`),
|
|
55314
55394
|
codexSkillTwice: (file2, block) => [
|
|
55315
55395
|
warn("The Codex skill is installed twice, so it loads twice"),
|
|
55316
55396
|
next(
|
|
@@ -55600,19 +55680,19 @@ init_src2();
|
|
|
55600
55680
|
import { execFile as execFile3, spawn } from "node:child_process";
|
|
55601
55681
|
import { promisify } from "node:util";
|
|
55602
55682
|
var browserCommand = (platform, url2) => platform === "darwin" ? { cmd: "open", args: [url2] } : platform === "win32" ? { cmd: "rundll32", args: ["url.dll,FileProtocolHandler", url2] } : { cmd: "xdg-open", args: [url2] };
|
|
55603
|
-
var openBrowser = (url2, launcher = browserCommand(process.platform, url2)) => new Promise((
|
|
55683
|
+
var openBrowser = (url2, launcher = browserCommand(process.platform, url2)) => new Promise((resolve18) => {
|
|
55604
55684
|
try {
|
|
55605
55685
|
const child = spawn(launcher.cmd, launcher.args, {
|
|
55606
55686
|
stdio: "ignore",
|
|
55607
55687
|
detached: true
|
|
55608
55688
|
});
|
|
55609
|
-
child.once("error", () =>
|
|
55689
|
+
child.once("error", () => resolve18(false));
|
|
55610
55690
|
child.once("spawn", () => {
|
|
55611
55691
|
child.unref();
|
|
55612
|
-
|
|
55692
|
+
resolve18(true);
|
|
55613
55693
|
});
|
|
55614
55694
|
} catch {
|
|
55615
|
-
|
|
55695
|
+
resolve18(false);
|
|
55616
55696
|
}
|
|
55617
55697
|
});
|
|
55618
55698
|
var EXEC_TIMEOUT_MS = 1e4;
|
|
@@ -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) => {
|
|
@@ -57536,7 +57616,7 @@ function realCtx(noColor) {
|
|
|
57536
57616
|
});
|
|
57537
57617
|
try {
|
|
57538
57618
|
return await new Promise(
|
|
57539
|
-
(
|
|
57619
|
+
(resolve18) => rl.question(question, resolve18)
|
|
57540
57620
|
);
|
|
57541
57621
|
} finally {
|
|
57542
57622
|
rl.close();
|
|
@@ -57628,7 +57708,7 @@ import { randomBytes as randomBytes6 } from "node:crypto";
|
|
|
57628
57708
|
import {
|
|
57629
57709
|
chmodSync as chmodSync19,
|
|
57630
57710
|
existsSync as existsSync14,
|
|
57631
|
-
lstatSync as
|
|
57711
|
+
lstatSync as lstatSync17,
|
|
57632
57712
|
mkdirSync as mkdirSync14,
|
|
57633
57713
|
readFileSync as readFileSync30,
|
|
57634
57714
|
readlinkSync as readlinkSync5,
|
|
@@ -57637,7 +57717,7 @@ import {
|
|
|
57637
57717
|
statSync as statSync9,
|
|
57638
57718
|
writeFileSync as writeFileSync18
|
|
57639
57719
|
} from "node:fs";
|
|
57640
|
-
import { dirname as dirname15, isAbsolute as isAbsolute13, join as join33, relative as relative6, resolve as
|
|
57720
|
+
import { dirname as dirname15, isAbsolute as isAbsolute13, join as join33, relative as relative6, resolve as resolve12 } from "node:path";
|
|
57641
57721
|
import { isDeepStrictEqual } from "node:util";
|
|
57642
57722
|
|
|
57643
57723
|
// ../bus-adapter-hermes/src/index.ts
|
|
@@ -58619,12 +58699,12 @@ var ParseErrorCode;
|
|
|
58619
58699
|
|
|
58620
58700
|
// ../bus-adapter-mcp-json/src/jsonc.ts
|
|
58621
58701
|
var isRecord = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
58622
|
-
function parseJsonc(text3,
|
|
58702
|
+
function parseJsonc(text3, where2) {
|
|
58623
58703
|
if (text3.trim() === "") return {};
|
|
58624
58704
|
const errors = [];
|
|
58625
58705
|
const doc = parse6(text3, errors, { allowTrailingComma: true });
|
|
58626
58706
|
if (errors.length > 0 || !isRecord(doc))
|
|
58627
|
-
throw new Error(`${
|
|
58707
|
+
throw new Error(`${where2} is not a JSON object; left it untouched`);
|
|
58628
58708
|
return doc;
|
|
58629
58709
|
}
|
|
58630
58710
|
var eol = (text3) => text3.includes("\r\n") ? "\r\n" : "\n";
|
|
@@ -58788,9 +58868,9 @@ function verified(text3, path, want) {
|
|
|
58788
58868
|
throw new Error(`editing ${path.join(".")} failed; left it untouched`);
|
|
58789
58869
|
return text3;
|
|
58790
58870
|
}
|
|
58791
|
-
function record4(v,
|
|
58871
|
+
function record4(v, where2) {
|
|
58792
58872
|
if (v === void 0) return void 0;
|
|
58793
|
-
if (!isRecord(v)) throw new Error(`${
|
|
58873
|
+
if (!isRecord(v)) throw new Error(`${where2} is not an object`);
|
|
58794
58874
|
return v;
|
|
58795
58875
|
}
|
|
58796
58876
|
var same2 = (a, b) => JSON.stringify(a) === JSON.stringify(b);
|
|
@@ -58845,10 +58925,10 @@ function removePlugin(text3, pluginPath) {
|
|
|
58845
58925
|
|
|
58846
58926
|
// ../bus-adapter-mcp-json/src/index.ts
|
|
58847
58927
|
var isRecord2 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
58848
|
-
function record5(doc, key2,
|
|
58928
|
+
function record5(doc, key2, where2 = key2) {
|
|
58849
58929
|
const v = doc[key2];
|
|
58850
58930
|
if (v === void 0) return void 0;
|
|
58851
|
-
if (!isRecord2(v)) throw new Error(`${
|
|
58931
|
+
if (!isRecord2(v)) throw new Error(`${where2} is not an object`);
|
|
58852
58932
|
return v;
|
|
58853
58933
|
}
|
|
58854
58934
|
function upsertMcpServer(doc, name, server4) {
|
|
@@ -58880,8 +58960,8 @@ var PI_EXTENSION = fileURLToPath4(
|
|
|
58880
58960
|
);
|
|
58881
58961
|
|
|
58882
58962
|
// src/steps/claude-proof.ts
|
|
58883
|
-
import { readFileSync as readFileSync22 } from "node:fs";
|
|
58884
|
-
import { join as join27 } from "node:path";
|
|
58963
|
+
import { lstatSync as lstatSync12, readFileSync as readFileSync22 } from "node:fs";
|
|
58964
|
+
import { join as join27, resolve as resolve6 } from "node:path";
|
|
58885
58965
|
var claudeConfigFile = (home2, env2) => join27(env2.CLAUDE_CONFIG_DIR ?? home2, ".claude.json");
|
|
58886
58966
|
var PROOF_COMMAND = "mcp-proof";
|
|
58887
58967
|
var TOKEN_HELPER = /^T=\$\(cat (.+)\) && printf '\{"Authorization":"Bearer %s"\}' "\$T"$/;
|
|
@@ -58896,21 +58976,63 @@ function proofHelper(busBin, opts) {
|
|
|
58896
58976
|
return opts.tokenFile ? `T=$(cat ${opts.tokenFile}) && { ${run5} 2>/dev/null || printf '{"Authorization":"Bearer %s"}' "$T"; }` : run5;
|
|
58897
58977
|
}
|
|
58898
58978
|
var isProofHelper = (helper) => typeof helper === "string" && / mcp-proof( |$)/.test(helper);
|
|
58979
|
+
function helperHome(helper) {
|
|
58980
|
+
const m = /(?:^|[ {])OA_BUS_HOME=('(?:[^']|'\\'')*'|\S+)/.exec(helper)?.[1];
|
|
58981
|
+
if (m === void 0) return void 0;
|
|
58982
|
+
return resolve6(
|
|
58983
|
+
m.startsWith("'") ? m.slice(1, -1).replaceAll("'\\''", "'") : m
|
|
58984
|
+
);
|
|
58985
|
+
}
|
|
58986
|
+
var ownedBy = (helper, busHome2) => helperHome(helper) === (busHome2 === void 0 ? void 0 : resolve6(busHome2));
|
|
58899
58987
|
var isRecord3 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
58900
|
-
function
|
|
58901
|
-
|
|
58902
|
-
if (
|
|
58903
|
-
|
|
58904
|
-
|
|
58905
|
-
|
|
58988
|
+
function isInstanceEntry(entry, origin) {
|
|
58989
|
+
if (!isRecord3(entry) || typeof entry.url !== "string") return false;
|
|
58990
|
+
if (entry.type !== void 0 && entry.type !== "http") return false;
|
|
58991
|
+
try {
|
|
58992
|
+
const u = new URL(entry.url);
|
|
58993
|
+
return u.origin === origin && u.pathname.replace(/\/+$/, "") === "/mcp";
|
|
58994
|
+
} catch {
|
|
58995
|
+
return false;
|
|
58996
|
+
}
|
|
58997
|
+
}
|
|
58998
|
+
function allEntries(doc) {
|
|
58999
|
+
const out = [];
|
|
59000
|
+
const add = (servers4, scope, project) => {
|
|
59001
|
+
if (!isRecord3(servers4)) return;
|
|
59002
|
+
for (const [name, entry] of Object.entries(servers4))
|
|
59003
|
+
if (isRecord3(entry))
|
|
59004
|
+
out.push({
|
|
59005
|
+
name,
|
|
59006
|
+
entry,
|
|
59007
|
+
scope,
|
|
59008
|
+
...project === void 0 ? {} : { project },
|
|
59009
|
+
path: project === void 0 ? ["mcpServers", name] : ["projects", project, "mcpServers", name]
|
|
59010
|
+
});
|
|
59011
|
+
};
|
|
59012
|
+
add(doc.mcpServers, "user");
|
|
59013
|
+
if (isRecord3(doc.projects)) {
|
|
59014
|
+
for (const [dir, p] of Object.entries(doc.projects))
|
|
59015
|
+
if (isRecord3(p)) add(p.mcpServers, "local", dir);
|
|
59016
|
+
}
|
|
59017
|
+
return out;
|
|
59018
|
+
}
|
|
59019
|
+
var findEntries = (doc, origin) => allEntries(doc).filter((f) => isInstanceEntry(f.entry, origin));
|
|
59020
|
+
function findElsewhere(doc, origin) {
|
|
59021
|
+
let host;
|
|
59022
|
+
try {
|
|
59023
|
+
host = new URL(origin).hostname;
|
|
59024
|
+
} catch {
|
|
59025
|
+
return [];
|
|
59026
|
+
}
|
|
59027
|
+
return allEntries(doc).filter((f) => {
|
|
59028
|
+
if (typeof f.entry.url !== "string" || isInstanceEntry(f.entry, origin))
|
|
59029
|
+
return false;
|
|
58906
59030
|
try {
|
|
58907
|
-
|
|
58908
|
-
if (u.origin === origin && u.pathname.replace(/\/+$/, "") === "/mcp")
|
|
58909
|
-
return { name, entry };
|
|
59031
|
+
return new URL(f.entry.url).hostname === host;
|
|
58910
59032
|
} catch {
|
|
59033
|
+
return false;
|
|
58911
59034
|
}
|
|
58912
|
-
}
|
|
58913
|
-
return void 0;
|
|
59035
|
+
});
|
|
58914
59036
|
}
|
|
58915
59037
|
var readText = (path) => {
|
|
58916
59038
|
try {
|
|
@@ -58920,79 +59042,216 @@ var readText = (path) => {
|
|
|
58920
59042
|
throw e;
|
|
58921
59043
|
}
|
|
58922
59044
|
};
|
|
59045
|
+
var asRecord = (p) => isRecord3(p) && typeof p.entry === "string" && (p.project === void 0 || typeof p.project === "string") && (p.file === void 0 || typeof p.file === "string") && (typeof p.original === "string" || p.original === null) ? {
|
|
59046
|
+
...typeof p.file === "string" ? { file: p.file } : {},
|
|
59047
|
+
entry: p.entry,
|
|
59048
|
+
...typeof p.project === "string" ? { project: p.project } : {},
|
|
59049
|
+
original: p.original
|
|
59050
|
+
} : void 0;
|
|
58923
59051
|
function readRecord(path) {
|
|
58924
59052
|
try {
|
|
58925
59053
|
const v = JSON.parse(readFileSync22(path, "utf8"));
|
|
58926
59054
|
if (isRecord3(v)) {
|
|
58927
|
-
const { claudeProof: claudeProof2, ...rest } = v;
|
|
58928
|
-
const
|
|
58929
|
-
|
|
58930
|
-
|
|
58931
|
-
|
|
59055
|
+
const { claudeProof: claudeProof2, claudeConfig, ...rest } = v;
|
|
59056
|
+
const list = Array.isArray(claudeProof2) ? claudeProof2 : [claudeProof2];
|
|
59057
|
+
return {
|
|
59058
|
+
rest,
|
|
59059
|
+
proofs: list.map(asRecord).filter((r) => !!r),
|
|
59060
|
+
...typeof claudeConfig === "string" ? { config: claudeConfig } : {}
|
|
59061
|
+
};
|
|
58932
59062
|
}
|
|
58933
59063
|
} catch {
|
|
58934
59064
|
}
|
|
58935
|
-
return { rest: {} };
|
|
59065
|
+
return { rest: {}, proofs: [] };
|
|
58936
59066
|
}
|
|
58937
|
-
function writeRecord(io, rest,
|
|
58938
|
-
const out =
|
|
59067
|
+
function writeRecord(io, rest, proofs, config2) {
|
|
59068
|
+
const out = {
|
|
59069
|
+
...rest,
|
|
59070
|
+
...config2 ? { claudeConfig: config2 } : {},
|
|
59071
|
+
...proofs.length ? { claudeProof: proofs } : {}
|
|
59072
|
+
};
|
|
58939
59073
|
io.write(io.record, `${JSON.stringify(out, null, 2)}
|
|
58940
59074
|
`, 384);
|
|
58941
59075
|
}
|
|
58942
|
-
|
|
58943
|
-
|
|
58944
|
-
|
|
58945
|
-
|
|
58946
|
-
|
|
58947
|
-
|
|
58948
|
-
|
|
58949
|
-
|
|
58950
|
-
|
|
58951
|
-
|
|
58952
|
-
|
|
58953
|
-
|
|
58954
|
-
|
|
58955
|
-
|
|
58956
|
-
|
|
58957
|
-
|
|
58958
|
-
...tokenFile ? { tokenFile } : {},
|
|
58959
|
-
...busHome2 ? { busHome: busHome2 } : {}
|
|
58960
|
-
});
|
|
58961
|
-
if (cur === helper && proof?.entry === found2.name) return void 0;
|
|
58962
|
-
writeRecord(io, rest, { entry: found2.name, original });
|
|
58963
|
-
io.write(
|
|
58964
|
-
io.file,
|
|
58965
|
-
setJsoncValue(text3, ["mcpServers", found2.name, "headersHelper"], helper)
|
|
58966
|
-
);
|
|
58967
|
-
return void 0;
|
|
58968
|
-
}
|
|
58969
|
-
function uninstallProof(io) {
|
|
58970
|
-
const { rest, proof } = readRecord(io.record);
|
|
58971
|
-
if (!proof) return false;
|
|
58972
|
-
const text3 = readText(io.file);
|
|
58973
|
-
const path = ["mcpServers", proof.entry, "headersHelper"];
|
|
58974
|
-
let cur;
|
|
58975
|
-
try {
|
|
58976
|
-
cur = text3 === "" ? void 0 : jsoncValue(text3, path);
|
|
58977
|
-
} catch {
|
|
58978
|
-
cur = void 0;
|
|
59076
|
+
var recordOf = (proofs, file2, name, project) => proofs.findIndex(
|
|
59077
|
+
(r) => (r.file ?? file2) === file2 && r.entry === name && r.project === project
|
|
59078
|
+
);
|
|
59079
|
+
var adoptedOriginal = (helper) => {
|
|
59080
|
+
const f = /^T=\$\(cat (.+?)\) && \{ /.exec(helper)?.[1];
|
|
59081
|
+
return f ? `T=$(cat ${f}) && printf '{"Authorization":"Bearer %s"}' "$T"` : null;
|
|
59082
|
+
};
|
|
59083
|
+
function installProof(io, origin, busBin, busHome2, opts = {}) {
|
|
59084
|
+
const out = { notes: [], changed: [] };
|
|
59085
|
+
const read2 = io.read ?? readText;
|
|
59086
|
+
const text3 = read2(io.file);
|
|
59087
|
+
const { rest, proofs, config: config2 } = readRecord(io.record);
|
|
59088
|
+
if (text3 === "") {
|
|
59089
|
+
if (!opts.guard && config2 !== io.file)
|
|
59090
|
+
writeRecord(io, rest, proofs, io.file);
|
|
59091
|
+
return out;
|
|
58979
59092
|
}
|
|
58980
|
-
|
|
58981
|
-
|
|
58982
|
-
|
|
58983
|
-
|
|
58984
|
-
|
|
58985
|
-
|
|
58986
|
-
|
|
59093
|
+
const records = [...proofs];
|
|
59094
|
+
let next = text3;
|
|
59095
|
+
for (const f of findEntries(parseJsonc(text3, io.file), origin)) {
|
|
59096
|
+
const at = recordOf(records, io.file, f.name, f.project);
|
|
59097
|
+
const rec = records[at];
|
|
59098
|
+
const cur = f.entry.headersHelper;
|
|
59099
|
+
let original;
|
|
59100
|
+
if (typeof cur === "string" && isProofHelper(cur) && !ownedBy(cur, busHome2)) {
|
|
59101
|
+
out.notes.push(
|
|
59102
|
+
`left the headersHelper of ${f.name} (${f.scope} scope) in ${io.file} as it is: it belongs to the bus at ${helperHome(cur) ?? "the default home"}`
|
|
59103
|
+
);
|
|
59104
|
+
continue;
|
|
59105
|
+
}
|
|
59106
|
+
if (isProofHelper(cur) && rec) original = rec.original;
|
|
59107
|
+
else if (isProofHelper(cur) && !opts.guard && typeof cur === "string")
|
|
59108
|
+
original = adoptedOriginal(cur);
|
|
59109
|
+
else if (isProofHelper(cur)) continue;
|
|
59110
|
+
else if (cur === void 0) original = null;
|
|
59111
|
+
else if (typeof cur === "string" && TOKEN_HELPER.test(cur)) original = cur;
|
|
59112
|
+
else {
|
|
59113
|
+
out.notes.push(
|
|
59114
|
+
`left the headersHelper of ${f.name} (${f.scope} scope) in ${io.file} as it is: it is not one oa-bus knows`
|
|
59115
|
+
);
|
|
59116
|
+
continue;
|
|
59117
|
+
}
|
|
59118
|
+
const tokenFile = original?.match(TOKEN_HELPER)?.[1];
|
|
59119
|
+
const helper = proofHelper(busBin, {
|
|
59120
|
+
...tokenFile ? { tokenFile } : {},
|
|
59121
|
+
...busHome2 ? { busHome: busHome2 } : {}
|
|
59122
|
+
});
|
|
59123
|
+
if (cur === helper && rec) continue;
|
|
59124
|
+
const made = {
|
|
59125
|
+
file: io.file,
|
|
59126
|
+
entry: f.name,
|
|
59127
|
+
...f.project === void 0 ? {} : { project: f.project },
|
|
59128
|
+
original
|
|
59129
|
+
};
|
|
59130
|
+
if (at < 0) records.push(made);
|
|
59131
|
+
else records[at] = made;
|
|
59132
|
+
next = setJsoncValue(next, [...f.path, "headersHelper"], helper);
|
|
59133
|
+
out.changed.push({ entry: f.name, scope: f.scope });
|
|
59134
|
+
}
|
|
59135
|
+
const recorded = config2 === io.file;
|
|
59136
|
+
if (out.changed.length === 0 && (recorded || opts.guard)) return out;
|
|
59137
|
+
if (opts.guard) {
|
|
59138
|
+
let link2 = false;
|
|
59139
|
+
try {
|
|
59140
|
+
link2 = lstatSync12(io.file).isSymbolicLink();
|
|
59141
|
+
} catch {
|
|
59142
|
+
}
|
|
59143
|
+
if (link2 || read2(io.file) !== text3)
|
|
59144
|
+
return { notes: out.notes, changed: [], skipped: true };
|
|
59145
|
+
}
|
|
59146
|
+
writeRecord(io, rest, records, io.file);
|
|
59147
|
+
if (out.changed.length > 0) io.write(io.file, next);
|
|
59148
|
+
return out;
|
|
58987
59149
|
}
|
|
58988
|
-
function
|
|
59150
|
+
function uninstallProof(io, busHome2) {
|
|
59151
|
+
const { rest, proofs, config: config2 } = readRecord(io.record);
|
|
59152
|
+
if (proofs.length === 0) {
|
|
59153
|
+
if (config2) writeRecord(io, rest, [], void 0);
|
|
59154
|
+
return false;
|
|
59155
|
+
}
|
|
59156
|
+
const texts = /* @__PURE__ */ new Map();
|
|
59157
|
+
let undone = false;
|
|
59158
|
+
for (const proof of proofs) {
|
|
59159
|
+
const file2 = proof.file ?? io.file;
|
|
59160
|
+
let t = texts.get(file2);
|
|
59161
|
+
if (!t) {
|
|
59162
|
+
const before = (io.read ?? readText)(file2);
|
|
59163
|
+
t = { before, text: before };
|
|
59164
|
+
texts.set(file2, t);
|
|
59165
|
+
}
|
|
59166
|
+
const path = [
|
|
59167
|
+
...proof.project === void 0 ? ["mcpServers"] : ["projects", proof.project, "mcpServers"],
|
|
59168
|
+
proof.entry,
|
|
59169
|
+
"headersHelper"
|
|
59170
|
+
];
|
|
59171
|
+
let cur;
|
|
59172
|
+
try {
|
|
59173
|
+
cur = t.text === "" ? void 0 : jsoncValue(t.text, path);
|
|
59174
|
+
} catch {
|
|
59175
|
+
cur = void 0;
|
|
59176
|
+
}
|
|
59177
|
+
if (typeof cur !== "string" || !isProofHelper(cur) || !ownedBy(cur, busHome2))
|
|
59178
|
+
continue;
|
|
59179
|
+
t.text = proof.original === null ? removeJsoncValue(t.text, path) : setJsoncValue(t.text, path, proof.original);
|
|
59180
|
+
undone = true;
|
|
59181
|
+
}
|
|
59182
|
+
for (const [file2, t] of texts)
|
|
59183
|
+
if (t.text !== t.before) io.write(file2, t.text);
|
|
59184
|
+
writeRecord(io, rest, [], void 0);
|
|
59185
|
+
return undone;
|
|
59186
|
+
}
|
|
59187
|
+
var stateOf = (helper) => helper === void 0 ? "missing" : isProofHelper(helper) ? "helper" : "foreign";
|
|
59188
|
+
function trustOf(doc, dir) {
|
|
59189
|
+
const p = isRecord3(doc.projects) ? doc.projects[dir] : void 0;
|
|
59190
|
+
const t = isRecord3(p) ? p.hasTrustDialogAccepted : void 0;
|
|
59191
|
+
return typeof t === "boolean" ? t : void 0;
|
|
59192
|
+
}
|
|
59193
|
+
function proofReport(file2, origin, opts = {}) {
|
|
59194
|
+
const report = { entries: [], elsewhere: [], symlink: false };
|
|
59195
|
+
const read2 = (path) => {
|
|
59196
|
+
try {
|
|
59197
|
+
const text3 = readText(path);
|
|
59198
|
+
return text3 === "" ? void 0 : parseJsonc(text3, path);
|
|
59199
|
+
} catch {
|
|
59200
|
+
return void 0;
|
|
59201
|
+
}
|
|
59202
|
+
};
|
|
59203
|
+
const doc = read2(file2);
|
|
58989
59204
|
try {
|
|
58990
|
-
|
|
58991
|
-
if (!found2) return "none";
|
|
58992
|
-
return isProofHelper(found2.entry.headersHelper) ? "helper" : "missing";
|
|
59205
|
+
report.symlink = lstatSync12(file2).isSymbolicLink();
|
|
58993
59206
|
} catch {
|
|
58994
|
-
return "none";
|
|
58995
59207
|
}
|
|
59208
|
+
const localNames = /* @__PURE__ */ new Set();
|
|
59209
|
+
if (doc) {
|
|
59210
|
+
for (const f of findEntries(doc, origin)) {
|
|
59211
|
+
const base3 = stateOf(f.entry.headersHelper);
|
|
59212
|
+
const known = opts.recorded === void 0 || recordOf(opts.recorded, file2, f.name, f.project) >= 0;
|
|
59213
|
+
const trusted = trustOf(doc, f.project ?? "");
|
|
59214
|
+
const mine = typeof f.entry.headersHelper !== "string" || !isProofHelper(f.entry.headersHelper) || ownedBy(f.entry.headersHelper, opts.busHome);
|
|
59215
|
+
const owner = typeof f.entry.headersHelper === "string" ? helperHome(f.entry.headersHelper) : void 0;
|
|
59216
|
+
report.entries.push({
|
|
59217
|
+
name: f.name,
|
|
59218
|
+
scope: f.scope,
|
|
59219
|
+
...f.project === void 0 ? {} : { project: f.project },
|
|
59220
|
+
state: !mine ? "other-bus" : base3 === "helper" && !known ? "unrecorded" : base3,
|
|
59221
|
+
...!mine && owner !== void 0 ? { owner } : {},
|
|
59222
|
+
...f.scope === "local" && trusted !== void 0 ? { trusted } : {}
|
|
59223
|
+
});
|
|
59224
|
+
if (f.scope === "local" && f.project === opts.cwd) localNames.add(f.name);
|
|
59225
|
+
}
|
|
59226
|
+
for (const f of findElsewhere(doc, origin))
|
|
59227
|
+
report.elsewhere.push({
|
|
59228
|
+
name: f.name,
|
|
59229
|
+
scope: f.scope,
|
|
59230
|
+
url: String(f.entry.url)
|
|
59231
|
+
});
|
|
59232
|
+
}
|
|
59233
|
+
const proj = opts.projectFile === void 0 ? void 0 : read2(opts.projectFile);
|
|
59234
|
+
if (proj && isRecord3(proj.mcpServers))
|
|
59235
|
+
for (const [name, entry] of Object.entries(proj.mcpServers)) {
|
|
59236
|
+
if (!isRecord3(entry)) continue;
|
|
59237
|
+
if (isInstanceEntry(entry, origin)) {
|
|
59238
|
+
if (localNames.has(name)) continue;
|
|
59239
|
+
const trusted = doc && opts.cwd !== void 0 ? trustOf(doc, opts.cwd) : void 0;
|
|
59240
|
+
report.entries.push({
|
|
59241
|
+
name,
|
|
59242
|
+
scope: "project",
|
|
59243
|
+
state: stateOf(entry.headersHelper),
|
|
59244
|
+
...trusted === void 0 ? {} : { trusted }
|
|
59245
|
+
});
|
|
59246
|
+
} else if (typeof entry.url === "string") {
|
|
59247
|
+
try {
|
|
59248
|
+
if (new URL(entry.url).hostname === new URL(origin).hostname)
|
|
59249
|
+
report.elsewhere.push({ name, scope: "project", url: entry.url });
|
|
59250
|
+
} catch {
|
|
59251
|
+
}
|
|
59252
|
+
}
|
|
59253
|
+
}
|
|
59254
|
+
return report;
|
|
58996
59255
|
}
|
|
58997
59256
|
|
|
58998
59257
|
// src/steps/codex-proof.ts
|
|
@@ -59306,18 +59565,18 @@ function proxyProgramMissing(doc, which2) {
|
|
|
59306
59565
|
init_src();
|
|
59307
59566
|
import {
|
|
59308
59567
|
existsSync as existsSync11,
|
|
59309
|
-
lstatSync as
|
|
59568
|
+
lstatSync as lstatSync16,
|
|
59310
59569
|
readFileSync as readFileSync27,
|
|
59311
59570
|
realpathSync as realpathSync14,
|
|
59312
59571
|
rmSync as rmSync16
|
|
59313
59572
|
} from "node:fs";
|
|
59314
|
-
import { join as join31, resolve as
|
|
59573
|
+
import { join as join31, resolve as resolve10, sep as sep4 } from "node:path";
|
|
59315
59574
|
|
|
59316
59575
|
// src/steps/hermes.ts
|
|
59317
59576
|
import { createHash as createHash11, randomBytes as randomBytes5 } from "node:crypto";
|
|
59318
59577
|
import {
|
|
59319
59578
|
cpSync as cpSync2,
|
|
59320
|
-
lstatSync as
|
|
59579
|
+
lstatSync as lstatSync13,
|
|
59321
59580
|
mkdirSync as mkdirSync12,
|
|
59322
59581
|
readdirSync as readdirSync8,
|
|
59323
59582
|
readFileSync as readFileSync24,
|
|
@@ -59334,7 +59593,7 @@ import {
|
|
|
59334
59593
|
isAbsolute as isAbsolute11,
|
|
59335
59594
|
join as join28,
|
|
59336
59595
|
relative as relative5,
|
|
59337
|
-
resolve as
|
|
59596
|
+
resolve as resolve7
|
|
59338
59597
|
} from "node:path";
|
|
59339
59598
|
var HERMES_PLUGIN_NAME = "oa-bus";
|
|
59340
59599
|
var HERMES_MARKER = ".oa-bus-managed";
|
|
@@ -59381,7 +59640,7 @@ function sweepStaging(staging, own2, o = {}) {
|
|
|
59381
59640
|
const path = join28(staging, name);
|
|
59382
59641
|
let old;
|
|
59383
59642
|
try {
|
|
59384
|
-
old = now -
|
|
59643
|
+
old = now - lstatSync13(path).mtimeMs > STAGING_STALE_MS;
|
|
59385
59644
|
} catch {
|
|
59386
59645
|
continue;
|
|
59387
59646
|
}
|
|
@@ -59399,7 +59658,7 @@ var nativeHome = (home2, env2, platform) => {
|
|
|
59399
59658
|
const local = env2.LOCALAPPDATA?.trim();
|
|
59400
59659
|
return join28(local || join28(home2, "AppData", "Local"), "hermes");
|
|
59401
59660
|
};
|
|
59402
|
-
var tilded = (home2, v) => v === "~" ? home2 :
|
|
59661
|
+
var tilded = (home2, v) => v === "~" ? home2 : resolve7(v.startsWith("~/") ? join28(home2, v.slice(2)) : v);
|
|
59403
59662
|
function hermesHome(home2, env2, platform = process.platform) {
|
|
59404
59663
|
const native = nativeHome(home2, env2, platform);
|
|
59405
59664
|
const v = env2.HERMES_HOME?.trim();
|
|
@@ -59413,7 +59672,7 @@ function hermesHome(home2, env2, platform = process.platform) {
|
|
|
59413
59672
|
const name = readFileSync24(join28(root, "active_profile"), "utf8").trim().toLowerCase();
|
|
59414
59673
|
if (name && name !== "default" && /^[a-z0-9][a-z0-9_-]{0,63}$/.test(name)) {
|
|
59415
59674
|
const dir = join28(root, "profiles", name);
|
|
59416
|
-
if (
|
|
59675
|
+
if (lstatSync13(dir).isDirectory()) return dir;
|
|
59417
59676
|
}
|
|
59418
59677
|
} catch {
|
|
59419
59678
|
}
|
|
@@ -59433,7 +59692,7 @@ function hermesProfilesScan(home2, env2, platform = process.platform) {
|
|
|
59433
59692
|
const path = join28(hermesRoot(home2, env2, platform), "profiles");
|
|
59434
59693
|
let isLink3 = false;
|
|
59435
59694
|
try {
|
|
59436
|
-
isLink3 =
|
|
59695
|
+
isLink3 = lstatSync13(path).isSymbolicLink();
|
|
59437
59696
|
} catch {
|
|
59438
59697
|
}
|
|
59439
59698
|
const target2 = () => {
|
|
@@ -59441,7 +59700,7 @@ function hermesProfilesScan(home2, env2, platform = process.platform) {
|
|
|
59441
59700
|
return realpathSync11(path);
|
|
59442
59701
|
} catch {
|
|
59443
59702
|
try {
|
|
59444
|
-
return
|
|
59703
|
+
return resolve7(dirname12(path), readlinkSync3(path));
|
|
59445
59704
|
} catch {
|
|
59446
59705
|
return "somewhere else";
|
|
59447
59706
|
}
|
|
@@ -59490,7 +59749,7 @@ var hermesEnv = (home2, env2, platform = process.platform) => ({
|
|
|
59490
59749
|
var hermesPluginDir = (home2, env2, platform = process.platform) => join28(hermesHome(home2, env2, platform), "plugins", HERMES_PLUGIN_NAME);
|
|
59491
59750
|
var kind = (path) => {
|
|
59492
59751
|
try {
|
|
59493
|
-
const st =
|
|
59752
|
+
const st = lstatSync13(path);
|
|
59494
59753
|
return st.isSymbolicLink() ? "link" : st.isDirectory() ? "dir" : "file";
|
|
59495
59754
|
} catch {
|
|
59496
59755
|
return void 0;
|
|
@@ -59567,7 +59826,7 @@ async function installHermes(deps2) {
|
|
|
59567
59826
|
mkdirSync12(plugins2, { recursive: true });
|
|
59568
59827
|
const staging = join28(plugins2, "..", HERMES_STAGING);
|
|
59569
59828
|
const own2 = `${process.pid}-${randomBytes5(4).toString("hex")}`;
|
|
59570
|
-
const st =
|
|
59829
|
+
const st = lstatSync13(staging, { throwIfNoEntry: false });
|
|
59571
59830
|
if (st !== void 0 && !st.isDirectory())
|
|
59572
59831
|
throw new Error(
|
|
59573
59832
|
`${staging} is not a plain folder; remove it and run the install again`
|
|
@@ -59647,20 +59906,20 @@ async function hermesEnabled(deps2) {
|
|
|
59647
59906
|
// src/steps/openclaw.ts
|
|
59648
59907
|
import {
|
|
59649
59908
|
existsSync as existsSync10,
|
|
59650
|
-
lstatSync as
|
|
59909
|
+
lstatSync as lstatSync15,
|
|
59651
59910
|
readdirSync as readdirSync10,
|
|
59652
59911
|
readFileSync as readFileSync26,
|
|
59653
59912
|
realpathSync as realpathSync13,
|
|
59654
59913
|
rmSync as rmSync15
|
|
59655
59914
|
} from "node:fs";
|
|
59656
|
-
import { join as join30, resolve as
|
|
59915
|
+
import { join as join30, resolve as resolve9 } from "node:path";
|
|
59657
59916
|
import { fileURLToPath as fileURLToPath5 } from "node:url";
|
|
59658
59917
|
|
|
59659
59918
|
// src/steps/skill.ts
|
|
59660
59919
|
import {
|
|
59661
59920
|
chmodSync as chmodSync18,
|
|
59662
59921
|
existsSync as existsSync9,
|
|
59663
|
-
lstatSync as
|
|
59922
|
+
lstatSync as lstatSync14,
|
|
59664
59923
|
mkdirSync as mkdirSync13,
|
|
59665
59924
|
readdirSync as readdirSync9,
|
|
59666
59925
|
readFileSync as readFileSync25,
|
|
@@ -59672,7 +59931,7 @@ import {
|
|
|
59672
59931
|
statSync as statSync8,
|
|
59673
59932
|
writeFileSync as writeFileSync17
|
|
59674
59933
|
} from "node:fs";
|
|
59675
|
-
import { dirname as dirname13, join as join29, resolve as
|
|
59934
|
+
import { dirname as dirname13, join as join29, resolve as resolve8 } from "node:path";
|
|
59676
59935
|
var SKILL_MARKER = "<!-- managed by the Open Artifacts bus installer: edits are replaced on reinstall. -->";
|
|
59677
59936
|
var CODEX_BEGIN = "<!-- BEGIN Open Artifacts skill (managed): edits inside are replaced on reinstall. -->";
|
|
59678
59937
|
var CODEX_END = "<!-- END Open Artifacts skill -->";
|
|
@@ -59764,7 +60023,7 @@ var quotesMarker = (text3) => {
|
|
|
59764
60023
|
};
|
|
59765
60024
|
var lstatOk = (path) => {
|
|
59766
60025
|
try {
|
|
59767
|
-
|
|
60026
|
+
lstatSync14(path);
|
|
59768
60027
|
return true;
|
|
59769
60028
|
} catch {
|
|
59770
60029
|
return false;
|
|
@@ -59772,7 +60031,7 @@ var lstatOk = (path) => {
|
|
|
59772
60031
|
};
|
|
59773
60032
|
var brokenLink = (path) => {
|
|
59774
60033
|
try {
|
|
59775
|
-
return
|
|
60034
|
+
return lstatSync14(path).isSymbolicLink() && !existsSync9(path);
|
|
59776
60035
|
} catch {
|
|
59777
60036
|
return false;
|
|
59778
60037
|
}
|
|
@@ -59815,7 +60074,7 @@ async function fetchSkillText(doFetch, url2) {
|
|
|
59815
60074
|
}
|
|
59816
60075
|
var targetOf = (path) => {
|
|
59817
60076
|
try {
|
|
59818
|
-
return
|
|
60077
|
+
return lstatSync14(path).isSymbolicLink() ? realpathSync12(path) : path;
|
|
59819
60078
|
} catch {
|
|
59820
60079
|
return path;
|
|
59821
60080
|
}
|
|
@@ -59876,14 +60135,14 @@ var realOrResolved = (p) => {
|
|
|
59876
60135
|
try {
|
|
59877
60136
|
return realpathSync12(p);
|
|
59878
60137
|
} catch {
|
|
59879
|
-
return
|
|
60138
|
+
return resolve8(p);
|
|
59880
60139
|
}
|
|
59881
60140
|
};
|
|
59882
60141
|
var placesOf = (p) => {
|
|
59883
60142
|
const out = [realOrResolved(p)];
|
|
59884
60143
|
try {
|
|
59885
|
-
if (
|
|
59886
|
-
out.push(realOrResolved(
|
|
60144
|
+
if (lstatSync14(p).isSymbolicLink())
|
|
60145
|
+
out.push(realOrResolved(resolve8(dirname13(p), readlinkSync4(p))));
|
|
59887
60146
|
} catch {
|
|
59888
60147
|
}
|
|
59889
60148
|
return out;
|
|
@@ -60066,7 +60325,7 @@ var uninstallSkill = (deps2, harnesses = [
|
|
|
60066
60325
|
const dir = join29(base3, entry);
|
|
60067
60326
|
const file2 = join29(dir, "SKILL.md");
|
|
60068
60327
|
try {
|
|
60069
|
-
const st =
|
|
60328
|
+
const st = lstatSync14(dir);
|
|
60070
60329
|
if (st.isSymbolicLink()) {
|
|
60071
60330
|
if (existsSync9(file2))
|
|
60072
60331
|
notes.push(`Left ${dir} alone: it is a symlinked folder.`);
|
|
@@ -60147,13 +60406,13 @@ var placeholder = (v) => {
|
|
|
60147
60406
|
};
|
|
60148
60407
|
function openclawHome(home2, env2) {
|
|
60149
60408
|
const explicit = placeholder(env2.OPENCLAW_HOME);
|
|
60150
|
-
return
|
|
60409
|
+
return resolve9(explicit ? explicit.replace(/^~(?=$|[\\/])/, home2) : home2);
|
|
60151
60410
|
}
|
|
60152
60411
|
function openclawStateDir(home2, env2) {
|
|
60153
60412
|
const h = openclawHome(home2, env2);
|
|
60154
60413
|
const override = env2.OPENCLAW_STATE_DIR?.trim();
|
|
60155
60414
|
if (override)
|
|
60156
|
-
return
|
|
60415
|
+
return resolve9(
|
|
60157
60416
|
override.startsWith("~") ? override.replace(/^~(?=$|[\\/])/, h) : override
|
|
60158
60417
|
);
|
|
60159
60418
|
const next = join30(h, ".openclaw");
|
|
@@ -60181,7 +60440,7 @@ var openclawEnv = (home2, env2) => ({
|
|
|
60181
60440
|
var openclawNix = (env2) => env2?.OPENCLAW_NIX_MODE === "1";
|
|
60182
60441
|
var kind2 = (path) => {
|
|
60183
60442
|
try {
|
|
60184
|
-
const st =
|
|
60443
|
+
const st = lstatSync15(path);
|
|
60185
60444
|
return st.isSymbolicLink() ? "link" : st.isDirectory() ? "dir" : "file";
|
|
60186
60445
|
} catch {
|
|
60187
60446
|
return void 0;
|
|
@@ -60258,7 +60517,7 @@ var realOrSelf = (p) => {
|
|
|
60258
60517
|
try {
|
|
60259
60518
|
return realpathSync13(p);
|
|
60260
60519
|
} catch {
|
|
60261
|
-
return
|
|
60520
|
+
return resolve9(p);
|
|
60262
60521
|
}
|
|
60263
60522
|
};
|
|
60264
60523
|
var NEED_TOOLS = ["oabus_self", "oabus_send_message", "oabus_fetch"];
|
|
@@ -60442,7 +60701,7 @@ var piAgentDir = (home2, env2) => {
|
|
|
60442
60701
|
const d = env2.PI_CODING_AGENT_DIR;
|
|
60443
60702
|
if (!d) return join31(home2, ".pi", "agent");
|
|
60444
60703
|
if (d === "~") return home2;
|
|
60445
|
-
return
|
|
60704
|
+
return resolve10(d.startsWith("~/") ? join31(home2, d.slice(2)) : d);
|
|
60446
60705
|
};
|
|
60447
60706
|
function habitsFiles(deps2, h) {
|
|
60448
60707
|
const env2 = deps2.env ?? {};
|
|
@@ -60525,7 +60784,7 @@ function withHabits(existing, block, added) {
|
|
|
60525
60784
|
var reason = (e) => e instanceof Error ? e.message : String(e);
|
|
60526
60785
|
var isLink = (path) => {
|
|
60527
60786
|
try {
|
|
60528
|
-
return
|
|
60787
|
+
return lstatSync16(path).isSymbolicLink();
|
|
60529
60788
|
} catch {
|
|
60530
60789
|
return false;
|
|
60531
60790
|
}
|
|
@@ -60704,7 +60963,7 @@ var pluginPaths = (deps2, p) => {
|
|
|
60704
60963
|
};
|
|
60705
60964
|
var pluginOurs = (dir, p) => {
|
|
60706
60965
|
try {
|
|
60707
|
-
return
|
|
60966
|
+
return lstatSync16(dir).isDirectory() && p.ours(dir);
|
|
60708
60967
|
} catch {
|
|
60709
60968
|
return false;
|
|
60710
60969
|
}
|
|
@@ -60713,7 +60972,7 @@ function pluginHabitsState(deps2, p) {
|
|
|
60713
60972
|
const { dir, marker } = pluginPaths(deps2, p);
|
|
60714
60973
|
if (!pluginOurs(dir, p)) return "not installed";
|
|
60715
60974
|
try {
|
|
60716
|
-
return
|
|
60975
|
+
return lstatSync16(marker).isFile() ? "on" : "off";
|
|
60717
60976
|
} catch {
|
|
60718
60977
|
return "off";
|
|
60719
60978
|
}
|
|
@@ -60849,7 +61108,7 @@ function setPluginHabits(deps2, plugins2, on) {
|
|
|
60849
61108
|
}
|
|
60850
61109
|
var probe = (path) => {
|
|
60851
61110
|
try {
|
|
60852
|
-
const st =
|
|
61111
|
+
const st = lstatSync16(path);
|
|
60853
61112
|
return {
|
|
60854
61113
|
k: st.isSymbolicLink() ? "link" : st.isDirectory() ? "dir" : "file"
|
|
60855
61114
|
};
|
|
@@ -60880,7 +61139,7 @@ var habitsQuestionLines = (q) => [
|
|
|
60880
61139
|
|
|
60881
61140
|
// src/steps/opencode-proof.ts
|
|
60882
61141
|
import { existsSync as existsSync12, readFileSync as readFileSync28, rmSync as rmSync17 } from "node:fs";
|
|
60883
|
-
import { dirname as dirname14, isAbsolute as isAbsolute12, join as join32, resolve as
|
|
61142
|
+
import { dirname as dirname14, isAbsolute as isAbsolute12, join as join32, resolve as resolve11 } from "node:path";
|
|
60884
61143
|
init_src();
|
|
60885
61144
|
var OPENCODE_ENTRY_FILE = "opencode-mcp-entry.json";
|
|
60886
61145
|
var isRecord5 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
@@ -60923,7 +61182,7 @@ var REMOTE_ONLY = /* @__PURE__ */ new Set(["type", "url", "headers", "oauth"]);
|
|
|
60923
61182
|
function resolveTokenFile(x, configFile, home2) {
|
|
60924
61183
|
if (x === "~") return home2;
|
|
60925
61184
|
if (x.startsWith("~/")) return join32(home2, x.slice(2));
|
|
60926
|
-
return isAbsolute12(x) ? x :
|
|
61185
|
+
return isAbsolute12(x) ? x : resolve11(dirname14(configFile), x);
|
|
60927
61186
|
}
|
|
60928
61187
|
var proxyEntry = (io, origin, tokenFile, entry) => {
|
|
60929
61188
|
const kept = Object.fromEntries(
|
|
@@ -61069,6 +61328,28 @@ function proxyEntries(text3) {
|
|
|
61069
61328
|
({ entry }) => Array.isArray(entry.command) && entry.command.includes(PROXY_CMD2)
|
|
61070
61329
|
).map(({ name, entry }) => ({ name, entry }));
|
|
61071
61330
|
}
|
|
61331
|
+
function skippedNotes(files2, read2, origin) {
|
|
61332
|
+
const notes = [];
|
|
61333
|
+
for (const file2 of files2)
|
|
61334
|
+
for (const { name, entry } of candidates(read2(file2))) {
|
|
61335
|
+
if (ourEntry2(entry, origin)) return notes;
|
|
61336
|
+
if (!isInstance2(entry, origin) || entry.enabled === false) continue;
|
|
61337
|
+
try {
|
|
61338
|
+
mcpUrl(origin);
|
|
61339
|
+
} catch {
|
|
61340
|
+
notes.push(
|
|
61341
|
+
`left the ${name} entry in ${file2} as it is: oa-bus only passes on https addresses, or http to localhost.`
|
|
61342
|
+
);
|
|
61343
|
+
continue;
|
|
61344
|
+
}
|
|
61345
|
+
if (tokenFileOf(entry) === void 0)
|
|
61346
|
+
notes.push(
|
|
61347
|
+
`left the ${name} entry in ${file2} as it is: it signs in with \`opencode mcp auth\` or another kind of token that oa-bus can't pass on.`
|
|
61348
|
+
);
|
|
61349
|
+
else return notes;
|
|
61350
|
+
}
|
|
61351
|
+
return notes;
|
|
61352
|
+
}
|
|
61072
61353
|
|
|
61073
61354
|
// src/steps/pi-proof.ts
|
|
61074
61355
|
import { existsSync as existsSync13, readFileSync as readFileSync29, rmSync as rmSync18 } from "node:fs";
|
|
@@ -61097,7 +61378,7 @@ var writeConfig = (io, c, servers4) => io.write(
|
|
|
61097
61378
|
`${c.bom ? BOM2 : ""}${JSON.stringify({ ...c.parsed, mcpServers: servers4 }, null, c.indent)}
|
|
61098
61379
|
`
|
|
61099
61380
|
);
|
|
61100
|
-
function
|
|
61381
|
+
function findEntry(servers4, origin) {
|
|
61101
61382
|
for (const [name, e] of Object.entries(servers4)) {
|
|
61102
61383
|
if (!isRecord6(e) || typeof e.url !== "string") continue;
|
|
61103
61384
|
if (e.type !== void 0 && e.type !== "http" && e.type !== "streamable-http")
|
|
@@ -61128,12 +61409,12 @@ function readMoved3(path) {
|
|
|
61128
61409
|
function pendingEntry2(io, origin) {
|
|
61129
61410
|
const c = readConfig2(io.file);
|
|
61130
61411
|
if (!c) return void 0;
|
|
61131
|
-
return
|
|
61412
|
+
return findEntry(c.servers, origin);
|
|
61132
61413
|
}
|
|
61133
61414
|
function moveEntry(io, origin) {
|
|
61134
61415
|
const c = readConfig2(io.file);
|
|
61135
61416
|
if (!c) return false;
|
|
61136
|
-
const name =
|
|
61417
|
+
const name = findEntry(c.servers, origin);
|
|
61137
61418
|
if (name === void 0) return false;
|
|
61138
61419
|
const keys = Object.keys(c.servers);
|
|
61139
61420
|
const moved = {
|
|
@@ -61192,7 +61473,7 @@ var readAssets = () => ({
|
|
|
61192
61473
|
});
|
|
61193
61474
|
var movedHome = (deps2) => {
|
|
61194
61475
|
if (deps2.busHome === void 0) return void 0;
|
|
61195
|
-
const ob =
|
|
61476
|
+
const ob = resolve12(deps2.busHome);
|
|
61196
61477
|
return ob === join33(deps2.home, ".oa-bus") ? void 0 : ob;
|
|
61197
61478
|
};
|
|
61198
61479
|
var homeLine = (ob) => `process.env.OA_BUS_HOME ||= ${JSON.stringify(ob)};`;
|
|
@@ -61238,7 +61519,7 @@ function agentDirEnv(home2, env2) {
|
|
|
61238
61519
|
const dir = env2.PI_CODING_AGENT_DIR;
|
|
61239
61520
|
if (!dir) return void 0;
|
|
61240
61521
|
if (dir === "~") return home2;
|
|
61241
|
-
return
|
|
61522
|
+
return resolve12(dir.startsWith("~/") ? join33(home2, dir.slice(2)) : dir);
|
|
61242
61523
|
}
|
|
61243
61524
|
var ompRoot = (home2, env2) => join33(home2, env2.PI_CONFIG_DIR || ".omp");
|
|
61244
61525
|
function ompProfile(env2) {
|
|
@@ -61276,7 +61557,7 @@ function readDoc(path) {
|
|
|
61276
61557
|
}
|
|
61277
61558
|
function present2(path) {
|
|
61278
61559
|
try {
|
|
61279
|
-
|
|
61560
|
+
lstatSync17(path);
|
|
61280
61561
|
return true;
|
|
61281
61562
|
} catch {
|
|
61282
61563
|
return false;
|
|
@@ -61285,14 +61566,14 @@ function present2(path) {
|
|
|
61285
61566
|
function target(path) {
|
|
61286
61567
|
let p = path;
|
|
61287
61568
|
for (let hops = 0; hops < 40; hops++) {
|
|
61288
|
-
if (!present2(p) || !
|
|
61569
|
+
if (!present2(p) || !lstatSync17(p).isSymbolicLink()) {
|
|
61289
61570
|
if (p !== path && !existsSync14(dirname15(p)))
|
|
61290
61571
|
throw new Error(
|
|
61291
61572
|
`${path} is a dangling symlink to ${p}; left it untouched`
|
|
61292
61573
|
);
|
|
61293
61574
|
return p;
|
|
61294
61575
|
}
|
|
61295
|
-
p =
|
|
61576
|
+
p = resolve12(dirname15(p), readlinkSync5(p));
|
|
61296
61577
|
}
|
|
61297
61578
|
throw new Error(`${path}: too many symlinks; left it untouched`);
|
|
61298
61579
|
}
|
|
@@ -61379,13 +61660,9 @@ async function run4(deps2, cmd, args) {
|
|
|
61379
61660
|
function claudeProof(deps2, notes) {
|
|
61380
61661
|
if (deps2.hub === void 0) return;
|
|
61381
61662
|
try {
|
|
61382
|
-
|
|
61383
|
-
proofIo(deps2),
|
|
61384
|
-
deps2.hub,
|
|
61385
|
-
deps2.busBin,
|
|
61386
|
-
movedHome(deps2)
|
|
61663
|
+
notes.push(
|
|
61664
|
+
...installProof(proofIo(deps2), deps2.hub, deps2.busBin, movedHome(deps2)).notes
|
|
61387
61665
|
);
|
|
61388
|
-
if (note) notes.push(note);
|
|
61389
61666
|
} catch (e) {
|
|
61390
61667
|
notes.push(
|
|
61391
61668
|
`could not add the proof helper to the Claude entry: ${e instanceof Error ? e.message : String(e)}`
|
|
@@ -61524,7 +61801,7 @@ var isolatedInstall = (deps2) => {
|
|
|
61524
61801
|
if (deps2.isolated) return true;
|
|
61525
61802
|
const dir = deps2.env?.OPENCODE_CONFIG_DIR;
|
|
61526
61803
|
if (!dir) return false;
|
|
61527
|
-
const rel = relative6(
|
|
61804
|
+
const rel = relative6(resolve12(deps2.home), resolve12(dir));
|
|
61528
61805
|
return rel.startsWith("..") || isAbsolute13(rel);
|
|
61529
61806
|
};
|
|
61530
61807
|
async function restartOpencode(deps2, notes, changed) {
|
|
@@ -61711,7 +61988,7 @@ var install = {
|
|
|
61711
61988
|
var uninstall = {
|
|
61712
61989
|
async claude(deps2, notes) {
|
|
61713
61990
|
try {
|
|
61714
|
-
uninstallProof(proofIo(deps2));
|
|
61991
|
+
uninstallProof(proofIo(deps2), movedHome(deps2));
|
|
61715
61992
|
} catch (e) {
|
|
61716
61993
|
notes.push(
|
|
61717
61994
|
`could not take the proof helper off the Claude entry: ${e instanceof Error ? e.message : String(e)}`
|
|
@@ -61981,13 +62258,59 @@ function codexProxyProblem(deps2) {
|
|
|
61981
62258
|
return void 0;
|
|
61982
62259
|
}
|
|
61983
62260
|
}
|
|
62261
|
+
function skippedProxyEntries(deps2) {
|
|
62262
|
+
const out = [];
|
|
62263
|
+
const d = { ...deps2, busBin: [] };
|
|
62264
|
+
const p = paths(d);
|
|
62265
|
+
try {
|
|
62266
|
+
if (present2(p.codex)) {
|
|
62267
|
+
const pending = pendingEntry(cxEntryIo(d), deps2.hub);
|
|
62268
|
+
if (pending && "note" in pending)
|
|
62269
|
+
out.push({ harness: "Codex", note: pending.note });
|
|
62270
|
+
}
|
|
62271
|
+
} catch {
|
|
62272
|
+
}
|
|
62273
|
+
try {
|
|
62274
|
+
for (const note of skippedNotes(
|
|
62275
|
+
p.opencodeConfigs.filter(present2),
|
|
62276
|
+
readJsonc,
|
|
62277
|
+
deps2.hub
|
|
62278
|
+
))
|
|
62279
|
+
out.push({ harness: "OpenCode", note });
|
|
62280
|
+
} catch {
|
|
62281
|
+
}
|
|
62282
|
+
return out;
|
|
62283
|
+
}
|
|
62284
|
+
function reapplyClaudeProof(deps2, onWrite) {
|
|
62285
|
+
try {
|
|
62286
|
+
if (deps2.busBin.length === 0) return;
|
|
62287
|
+
const r = installProof(
|
|
62288
|
+
{ ...proofIo(deps2), file: deps2.config },
|
|
62289
|
+
deps2.hub,
|
|
62290
|
+
deps2.busBin,
|
|
62291
|
+
movedHome(deps2),
|
|
62292
|
+
{ guard: true }
|
|
62293
|
+
);
|
|
62294
|
+
for (const c of r.changed) onWrite(c);
|
|
62295
|
+
} catch {
|
|
62296
|
+
}
|
|
62297
|
+
}
|
|
62298
|
+
function recordClaudeProof(deps2) {
|
|
62299
|
+
try {
|
|
62300
|
+
if (deps2.busBin.length === 0) return;
|
|
62301
|
+
const io = proofIo(deps2);
|
|
62302
|
+
if (readRecord(io.record).config !== void 0) return;
|
|
62303
|
+
installProof(io, deps2.hub, deps2.busBin, movedHome(deps2));
|
|
62304
|
+
} catch {
|
|
62305
|
+
}
|
|
62306
|
+
}
|
|
61984
62307
|
|
|
61985
62308
|
// src/steps/path-shim.ts
|
|
61986
62309
|
import {
|
|
61987
62310
|
accessSync as accessSync2,
|
|
61988
62311
|
chmodSync as chmodSync20,
|
|
61989
62312
|
constants as constants6,
|
|
61990
|
-
lstatSync as
|
|
62313
|
+
lstatSync as lstatSync18,
|
|
61991
62314
|
mkdirSync as mkdirSync15,
|
|
61992
62315
|
readFileSync as readFileSync31,
|
|
61993
62316
|
readlinkSync as readlinkSync6,
|
|
@@ -61995,22 +62318,22 @@ import {
|
|
|
61995
62318
|
rmSync as rmSync20,
|
|
61996
62319
|
writeFileSync as writeFileSync19
|
|
61997
62320
|
} from "node:fs";
|
|
61998
|
-
import { delimiter as delimiter3, dirname as dirname16, join as join34, resolve as
|
|
62321
|
+
import { delimiter as delimiter3, dirname as dirname16, join as join34, resolve as resolve13, sep as sep5 } from "node:path";
|
|
61999
62322
|
var SHIM_MARKER = "# oa-bus shim: written by oa-bus install";
|
|
62000
62323
|
var HOME_PREFIX = "# oa-bus home: ";
|
|
62001
62324
|
var NAME2 = "oa-bus";
|
|
62002
62325
|
var LOCAL_HINT = 'export PATH="$HOME/.local/bin:$PATH"';
|
|
62003
62326
|
var isWindows = (platform) => platform.startsWith("win32");
|
|
62004
|
-
var pathDirs = (p) => (p ?? "").split(delimiter3).filter((d) => d !== "").map((d) =>
|
|
62327
|
+
var pathDirs = (p) => (p ?? "").split(delimiter3).filter((d) => d !== "").map((d) => resolve13(d));
|
|
62005
62328
|
var candidates2 = (o) => o.platform.startsWith("darwin") ? [join34(o.userHome, ".local", "bin"), join34(o.userHome, "bin")] : [join34(o.userHome, ".local", "bin")];
|
|
62006
62329
|
var shQuote2 = (v) => `'${v.replaceAll("'", `'\\''`)}'`;
|
|
62007
62330
|
function shimText(o) {
|
|
62008
|
-
const moved =
|
|
62331
|
+
const moved = resolve13(o.busHome) !== resolve13(o.userHome, ".oa-bus");
|
|
62009
62332
|
return [
|
|
62010
62333
|
"#!/bin/sh",
|
|
62011
62334
|
SHIM_MARKER,
|
|
62012
|
-
`${HOME_PREFIX}${
|
|
62013
|
-
...moved ? [`OA_BUS_HOME=${shQuote2(
|
|
62335
|
+
`${HOME_PREFIX}${resolve13(o.busHome)}`,
|
|
62336
|
+
...moved ? [`OA_BUS_HOME=${shQuote2(resolve13(o.busHome))}`, "export OA_BUS_HOME"] : [],
|
|
62014
62337
|
`exec ${o.argv.map(shQuote2).join(" ")} "$@"`,
|
|
62015
62338
|
""
|
|
62016
62339
|
].join("\n");
|
|
@@ -62018,14 +62341,14 @@ function shimText(o) {
|
|
|
62018
62341
|
function ownerOf(file2, busHome2) {
|
|
62019
62342
|
let st;
|
|
62020
62343
|
try {
|
|
62021
|
-
st =
|
|
62344
|
+
st = lstatSync18(file2);
|
|
62022
62345
|
} catch {
|
|
62023
62346
|
return void 0;
|
|
62024
62347
|
}
|
|
62025
62348
|
if (st.isSymbolicLink()) {
|
|
62026
62349
|
try {
|
|
62027
|
-
const to =
|
|
62028
|
-
const home2 =
|
|
62350
|
+
const to = resolve13(dirname16(file2), readlinkSync6(file2));
|
|
62351
|
+
const home2 = resolve13(busHome2);
|
|
62029
62352
|
return to === home2 || to.startsWith(`${home2}/`) ? { ours: true, home: home2 } : { ours: false };
|
|
62030
62353
|
} catch {
|
|
62031
62354
|
return { ours: false };
|
|
@@ -62041,7 +62364,7 @@ function ownerOf(file2, busHome2) {
|
|
|
62041
62364
|
return { ours: false };
|
|
62042
62365
|
}
|
|
62043
62366
|
}
|
|
62044
|
-
var sameHome = (owner, busHome2) => owner?.ours === true && (owner.home === void 0 || owner.home ===
|
|
62367
|
+
var sameHome = (owner, busHome2) => owner?.ours === true && (owner.home === void 0 || owner.home === resolve13(busHome2));
|
|
62045
62368
|
function writeShim(path, text3) {
|
|
62046
62369
|
const tmp = `${path}.${process.pid}.tmp`;
|
|
62047
62370
|
rmSync20(tmp, { force: true });
|
|
@@ -62087,7 +62410,7 @@ function removeShim(o) {
|
|
|
62087
62410
|
const file2 = join34(dir, NAME2);
|
|
62088
62411
|
const owner = ownerOf(file2, o.busHome);
|
|
62089
62412
|
if (!owner?.ours) continue;
|
|
62090
|
-
if (owner.home !== void 0 && owner.home !==
|
|
62413
|
+
if (owner.home !== void 0 && owner.home !== resolve13(o.busHome)) continue;
|
|
62091
62414
|
rmSync20(file2, { force: true });
|
|
62092
62415
|
removed = file2;
|
|
62093
62416
|
}
|
|
@@ -62096,7 +62419,7 @@ function removeShim(o) {
|
|
|
62096
62419
|
var executable2 = (f) => {
|
|
62097
62420
|
try {
|
|
62098
62421
|
accessSync2(f, constants6.X_OK);
|
|
62099
|
-
return
|
|
62422
|
+
return lstatSync18(f).isFile() || lstatSync18(f).isSymbolicLink();
|
|
62100
62423
|
} catch {
|
|
62101
62424
|
return false;
|
|
62102
62425
|
}
|
|
@@ -62110,12 +62433,12 @@ function shimState(o) {
|
|
|
62110
62433
|
const file2 = join34(dir, NAME2);
|
|
62111
62434
|
if (!executable2(file2)) continue;
|
|
62112
62435
|
const owner = ownerOf(file2, o.busHome);
|
|
62113
|
-
return owner?.ours && (owner.home === void 0 || owner.home ===
|
|
62436
|
+
return owner?.ours && (owner.home === void 0 || owner.home === resolve13(o.busHome)) ? { kind: "ours", path: file2 } : { kind: "other", path: file2 };
|
|
62114
62437
|
}
|
|
62115
62438
|
for (const dir of candidates2(o)) {
|
|
62116
62439
|
const file2 = join34(dir, NAME2);
|
|
62117
62440
|
const owner = ownerOf(file2, o.busHome);
|
|
62118
|
-
if (owner?.ours && (owner.home === void 0 || owner.home ===
|
|
62441
|
+
if (owner?.ours && (owner.home === void 0 || owner.home === resolve13(o.busHome)))
|
|
62119
62442
|
return { kind: "off-path", path: file2, hint: LOCAL_HINT };
|
|
62120
62443
|
}
|
|
62121
62444
|
return { kind: "missing" };
|
|
@@ -62192,7 +62515,7 @@ async function autoUpdate(opts, ctx) {
|
|
|
62192
62515
|
|
|
62193
62516
|
// src/commands/daemon.ts
|
|
62194
62517
|
import { existsSync as existsSync15 } from "node:fs";
|
|
62195
|
-
import { join as
|
|
62518
|
+
import { join as join37 } from "node:path";
|
|
62196
62519
|
import { fileURLToPath as fileURLToPath6 } from "node:url";
|
|
62197
62520
|
|
|
62198
62521
|
// src/machine.ts
|
|
@@ -62224,6 +62547,168 @@ function readMachine(home2) {
|
|
|
62224
62547
|
}
|
|
62225
62548
|
return { state: "bad" };
|
|
62226
62549
|
}
|
|
62550
|
+
var originOf2 = (hub) => {
|
|
62551
|
+
try {
|
|
62552
|
+
return new URL(hub.replace(/^ws(s?):/, "http$1:")).origin;
|
|
62553
|
+
} catch {
|
|
62554
|
+
return hub;
|
|
62555
|
+
}
|
|
62556
|
+
};
|
|
62557
|
+
|
|
62558
|
+
// src/steps/claude-proof-check.ts
|
|
62559
|
+
import { readFileSync as readFileSync33 } from "node:fs";
|
|
62560
|
+
import { join as join36 } from "node:path";
|
|
62561
|
+
var PROOF_EVENT = "claude_proof_applied";
|
|
62562
|
+
var DAY_MS = 864e5;
|
|
62563
|
+
var safeText = (s, max = 80) => {
|
|
62564
|
+
const t = s.replace(/[\p{Cc}\p{Cf}\u2028\u2029]/gu, "?");
|
|
62565
|
+
return t.length > max ? `${t.slice(0, max - 1)}\u2026` : t;
|
|
62566
|
+
};
|
|
62567
|
+
var safeUrl = (u) => {
|
|
62568
|
+
try {
|
|
62569
|
+
const x = new URL(u);
|
|
62570
|
+
return safeText(`${x.origin}${x.pathname}`, 120);
|
|
62571
|
+
} catch {
|
|
62572
|
+
return "an address that can't be read";
|
|
62573
|
+
}
|
|
62574
|
+
};
|
|
62575
|
+
var where = (ctx, e) => e.scope === "project" ? "project scope, .mcp.json in this folder" : e.scope === "local" ? `local scope, project ${safeText(tilde(ctx, e.project ?? ""), 120)}` : "user scope";
|
|
62576
|
+
function claudeProofChecks(ctx, hub) {
|
|
62577
|
+
const origin = originOf2(hub);
|
|
62578
|
+
let host;
|
|
62579
|
+
try {
|
|
62580
|
+
host = new URL(origin).host;
|
|
62581
|
+
} catch {
|
|
62582
|
+
return [];
|
|
62583
|
+
}
|
|
62584
|
+
const rec = readRecord(join36(ctx.home, "install.json"));
|
|
62585
|
+
const file2 = rec.config ?? claudeConfigFile(ctx.userHome, ctx.env);
|
|
62586
|
+
const r = proofReport(file2, origin, {
|
|
62587
|
+
projectFile: join36(ctx.cwd, ".mcp.json"),
|
|
62588
|
+
cwd: ctx.cwd,
|
|
62589
|
+
recorded: rec.proofs,
|
|
62590
|
+
...isDefaultHome(ctx.home, ctx.userHome) ? {} : { busHome: ctx.home }
|
|
62591
|
+
});
|
|
62592
|
+
const out = [];
|
|
62593
|
+
const install3 = `run ${ctx.busCmd} install`;
|
|
62594
|
+
for (const e of r.entries) {
|
|
62595
|
+
const at = `the ${safeText(e.name)} entry (${where(ctx, e)})`;
|
|
62596
|
+
if (e.scope === "project") {
|
|
62597
|
+
out.push(
|
|
62598
|
+
e.state === "helper" && e.trusted !== false ? {
|
|
62599
|
+
level: "pass",
|
|
62600
|
+
lines: [`Claude Code: ${at} has the helper.`]
|
|
62601
|
+
} : {
|
|
62602
|
+
level: "warn",
|
|
62603
|
+
lines: [
|
|
62604
|
+
e.state === "helper" ? `Claude Code: ${at} has the helper, but Claude doesn't trust this folder yet, so it won't run it.` : `Claude Code: ${at} is not set up by the bus; it links only if it has our helper and the folder is trusted.`,
|
|
62605
|
+
e.state === "helper" ? " Open Claude Code in this folder and accept the trust prompt." : ` Re-add it at user scope with Claude Code, then ${install3}.`
|
|
62606
|
+
]
|
|
62607
|
+
}
|
|
62608
|
+
);
|
|
62609
|
+
continue;
|
|
62610
|
+
}
|
|
62611
|
+
if (e.state === "helper")
|
|
62612
|
+
out.push(
|
|
62613
|
+
e.trusted === false ? {
|
|
62614
|
+
level: "warn",
|
|
62615
|
+
lines: [
|
|
62616
|
+
`Claude Code: ${at} has the helper, but Claude doesn't trust that folder yet, so it won't run it.`,
|
|
62617
|
+
" Open Claude Code in that folder and accept the trust prompt."
|
|
62618
|
+
]
|
|
62619
|
+
} : {
|
|
62620
|
+
level: "pass",
|
|
62621
|
+
lines: [`Claude Code: ${at} shows as this session on pages.`]
|
|
62622
|
+
}
|
|
62623
|
+
);
|
|
62624
|
+
else if (e.state === "other-bus")
|
|
62625
|
+
out.push({
|
|
62626
|
+
level: "warn",
|
|
62627
|
+
lines: [
|
|
62628
|
+
`Claude Code: ${at} has the helper of another bus (${e.owner === void 0 ? "the default home" : safeText(tilde(ctx, e.owner), 120)}), so this bus left it alone.`,
|
|
62629
|
+
" An entry links one bus; use another entry for this one."
|
|
62630
|
+
]
|
|
62631
|
+
});
|
|
62632
|
+
else if (e.state === "unrecorded")
|
|
62633
|
+
out.push({
|
|
62634
|
+
level: "warn",
|
|
62635
|
+
lines: [
|
|
62636
|
+
`Claude Code: ${at} has the helper, but was set up by another bus or an older install.`,
|
|
62637
|
+
` Fix: ${install3} to adopt it`
|
|
62638
|
+
]
|
|
62639
|
+
});
|
|
62640
|
+
else if (e.state === "missing")
|
|
62641
|
+
out.push({
|
|
62642
|
+
level: "fail",
|
|
62643
|
+
lines: [
|
|
62644
|
+
`Claude Code: ${at} has no session helper, so what it posts can't be tied to this session.`,
|
|
62645
|
+
` Fix: ${install3}`
|
|
62646
|
+
]
|
|
62647
|
+
});
|
|
62648
|
+
else
|
|
62649
|
+
out.push({
|
|
62650
|
+
level: "fail",
|
|
62651
|
+
lines: [
|
|
62652
|
+
`Claude Code: ${at} has a headersHelper that is not oa-bus's, so oa-bus left it alone.`,
|
|
62653
|
+
` Fix: remove that headersHelper from the entry in ${tilde(ctx, file2)}, then ${install3}`
|
|
62654
|
+
]
|
|
62655
|
+
});
|
|
62656
|
+
}
|
|
62657
|
+
if (rec.config === void 0 && wiredTo(ctx) && r.entries.some((e) => e.scope !== "project"))
|
|
62658
|
+
out.push({
|
|
62659
|
+
level: "warn",
|
|
62660
|
+
lines: [
|
|
62661
|
+
"Claude Code: automatic linking is off for this bus.",
|
|
62662
|
+
` Fix: ${install3} once to turn it on`
|
|
62663
|
+
]
|
|
62664
|
+
});
|
|
62665
|
+
if (r.symlink)
|
|
62666
|
+
out.push({
|
|
62667
|
+
level: "warn",
|
|
62668
|
+
lines: [
|
|
62669
|
+
`Claude Code: ${tilde(ctx, file2)} is a symlink, so the daemon doesn't edit it on its own.`,
|
|
62670
|
+
` Fix: ${install3} to link its entries`
|
|
62671
|
+
]
|
|
62672
|
+
});
|
|
62673
|
+
if (r.entries.length === 0)
|
|
62674
|
+
out.push({
|
|
62675
|
+
level: "info",
|
|
62676
|
+
lines: [
|
|
62677
|
+
`No Claude Code entry for ${host}.`,
|
|
62678
|
+
" Agents using a connector or another client aren't checked."
|
|
62679
|
+
]
|
|
62680
|
+
});
|
|
62681
|
+
for (const e of r.elsewhere)
|
|
62682
|
+
out.push({
|
|
62683
|
+
level: "warn",
|
|
62684
|
+
lines: [
|
|
62685
|
+
`Claude Code: the ${safeText(e.name)} entry (${e.scope} scope) points at ${safeUrl(e.url)}, not ${origin}/mcp, so it can't be linked.`
|
|
62686
|
+
]
|
|
62687
|
+
});
|
|
62688
|
+
return out;
|
|
62689
|
+
}
|
|
62690
|
+
function lastAutoFix(ctx) {
|
|
62691
|
+
let text3;
|
|
62692
|
+
try {
|
|
62693
|
+
text3 = readFileSync33(join36(ctx.home, "logs", "events.log"), "utf8");
|
|
62694
|
+
} catch {
|
|
62695
|
+
return void 0;
|
|
62696
|
+
}
|
|
62697
|
+
const hits = text3.split("\n").filter((l) => l.includes(` ${PROOF_EVENT} `)).map((l) => {
|
|
62698
|
+
const [at = ""] = l.split(" ");
|
|
62699
|
+
return {
|
|
62700
|
+
at,
|
|
62701
|
+
name: / name=("[^"]*"|\S+)/.exec(l)?.[1]?.replaceAll('"', "") ?? "",
|
|
62702
|
+
scope: / kind=(\S+)/.exec(l)?.[1] ?? ""
|
|
62703
|
+
};
|
|
62704
|
+
});
|
|
62705
|
+
const last = hits.at(-1);
|
|
62706
|
+
if (!last) return void 0;
|
|
62707
|
+
const t = Date.parse(last.at);
|
|
62708
|
+
if (!(ctx.now() - t < 7 * DAY_MS)) return void 0;
|
|
62709
|
+
const run5 = hits.filter((h) => Math.abs(Date.parse(h.at) - t) < 6e4);
|
|
62710
|
+
return `Claude Code: the last automatic fix (${last.at.slice(0, 16).replace("T", " ")} UTC) added the helper to ${run5.map((h) => `${safeText(h.name)} (${safeText(h.scope, 20)} scope)`).join(", ")}.`;
|
|
62711
|
+
}
|
|
62227
62712
|
|
|
62228
62713
|
// src/commands/daemon.ts
|
|
62229
62714
|
var lasting = (e) => [...START_ERROR_CODES, "EACCES", "EPERM"].includes(
|
|
@@ -62231,11 +62716,25 @@ var lasting = (e) => [...START_ERROR_CODES, "EACCES", "EPERM"].includes(
|
|
|
62231
62716
|
);
|
|
62232
62717
|
async function daemon(ctx, run5 = runDaemon, signals = process) {
|
|
62233
62718
|
const m = readMachine(ctx.home);
|
|
62234
|
-
if (existsSync15(
|
|
62719
|
+
if (existsSync15(join37(ctx.home, "revoked")) && (m.state !== "ok" || m.revoked)) {
|
|
62235
62720
|
sayErr(ctx, ctx.copy.revoked());
|
|
62236
62721
|
return 0;
|
|
62237
62722
|
}
|
|
62238
|
-
|
|
62723
|
+
const events = createEventLog(join37(ctx.home, "logs", "events.log"));
|
|
62724
|
+
const config2 = readRecord(join37(ctx.home, "install.json")).config;
|
|
62725
|
+
if (m.state === "ok" && config2 !== void 0 && wiredTo(ctx))
|
|
62726
|
+
reapplyClaudeProof(
|
|
62727
|
+
{
|
|
62728
|
+
home: ctx.userHome,
|
|
62729
|
+
busHome: ctx.home,
|
|
62730
|
+
env: ctx.env,
|
|
62731
|
+
busBin: ctx.service.argv?.() ?? [],
|
|
62732
|
+
hub: originOf2(m.hub),
|
|
62733
|
+
config: config2
|
|
62734
|
+
},
|
|
62735
|
+
(c) => events(PROOF_EVENT, { name: c.entry, kind: c.scope })
|
|
62736
|
+
);
|
|
62737
|
+
return new Promise((resolve18) => {
|
|
62239
62738
|
let running;
|
|
62240
62739
|
let ended = false;
|
|
62241
62740
|
const end = (code2) => {
|
|
@@ -62243,15 +62742,14 @@ async function daemon(ctx, run5 = runDaemon, signals = process) {
|
|
|
62243
62742
|
ended = true;
|
|
62244
62743
|
signals.off("SIGINT", onSignal);
|
|
62245
62744
|
signals.off("SIGTERM", onSignal);
|
|
62246
|
-
void (running?.stop() ?? Promise.resolve()).finally(() =>
|
|
62745
|
+
void (running?.stop() ?? Promise.resolve()).finally(() => resolve18(code2));
|
|
62247
62746
|
};
|
|
62248
62747
|
const onSignal = () => end(0);
|
|
62249
62748
|
signals.once("SIGINT", onSignal);
|
|
62250
62749
|
signals.once("SIGTERM", onSignal);
|
|
62251
62750
|
run5({
|
|
62252
62751
|
version: ctx.version,
|
|
62253
|
-
|
|
62254
|
-
events: createEventLog(join36(ctx.home, "logs", "events.log")),
|
|
62752
|
+
events,
|
|
62255
62753
|
// Only an older token was revoked: a restart picks up the new one.
|
|
62256
62754
|
onRevoked: (replaced) => end(replaced ? 1 : REVOKED_EXIT),
|
|
62257
62755
|
// Exit non-zero: the service restarts the daemon, which binds again.
|
|
@@ -62276,50 +62774,50 @@ async function daemon(ctx, run5 = runDaemon, signals = process) {
|
|
|
62276
62774
|
}
|
|
62277
62775
|
|
|
62278
62776
|
// src/commands/doctor.ts
|
|
62279
|
-
import { readFileSync as
|
|
62280
|
-
import { join as
|
|
62777
|
+
import { readFileSync as readFileSync38 } from "node:fs";
|
|
62778
|
+
import { join as join45 } from "node:path";
|
|
62281
62779
|
|
|
62282
62780
|
// src/steps/claude-plugins.ts
|
|
62283
|
-
import { readFileSync as
|
|
62284
|
-
import { join as
|
|
62781
|
+
import { readFileSync as readFileSync35 } from "node:fs";
|
|
62782
|
+
import { join as join39 } from "node:path";
|
|
62285
62783
|
|
|
62286
62784
|
// src/steps/output-style.ts
|
|
62287
62785
|
import {
|
|
62288
|
-
lstatSync as
|
|
62786
|
+
lstatSync as lstatSync19,
|
|
62289
62787
|
readdirSync as readdirSync11,
|
|
62290
|
-
readFileSync as
|
|
62788
|
+
readFileSync as readFileSync34,
|
|
62291
62789
|
rmdirSync as rmdirSync3,
|
|
62292
62790
|
rmSync as rmSync21
|
|
62293
62791
|
} from "node:fs";
|
|
62294
|
-
import { dirname as dirname17, join as
|
|
62792
|
+
import { dirname as dirname17, join as join38 } from "node:path";
|
|
62295
62793
|
var OUTPUT_STYLE_FILE = "artifacts-teammate.md";
|
|
62296
62794
|
var OUTPUT_STYLE_MARKER = "<!-- managed by the Open Artifacts bus installer: edits are replaced on reinstall. -->";
|
|
62297
62795
|
var OUTPUT_STYLE_NAME = "Artifacts Teammate";
|
|
62298
62796
|
var OUTPUT_STYLE_PLUGIN_NAME = "open-artifacts:Artifacts Teammate";
|
|
62299
62797
|
var isOurName = (v) => v === OUTPUT_STYLE_NAME || v === OUTPUT_STYLE_PLUGIN_NAME;
|
|
62300
|
-
var claudeSettingsFile = (w) =>
|
|
62798
|
+
var claudeSettingsFile = (w) => join38(w.env?.CLAUDE_CONFIG_DIR ?? join38(w.home, ".claude"), "settings.json");
|
|
62301
62799
|
var readRecord3 = (busHome2) => {
|
|
62302
62800
|
if (!busHome2) return void 0;
|
|
62303
|
-
const r = readInstallFile(
|
|
62801
|
+
const r = readInstallFile(join38(busHome2, "install.json")).outputStyle;
|
|
62304
62802
|
return typeof r === "object" && r !== null ? r : void 0;
|
|
62305
62803
|
};
|
|
62306
|
-
var writeRecord3 = (busHome2, r) => updateInstallFile(
|
|
62307
|
-
var styleDir = (w) =>
|
|
62308
|
-
var outputStyleFile = (w) =>
|
|
62804
|
+
var writeRecord3 = (busHome2, r) => updateInstallFile(join38(busHome2, "install.json"), { outputStyle: r });
|
|
62805
|
+
var styleDir = (w) => join38(w.env?.CLAUDE_CONFIG_DIR ?? join38(w.home, ".claude"), "output-styles");
|
|
62806
|
+
var outputStyleFile = (w) => join38(styleDir(w), OUTPUT_STYLE_FILE);
|
|
62309
62807
|
var isOurs2 = (text3) => {
|
|
62310
62808
|
const m = /^---\n[\s\S]*?\n---\n/.exec(text3.replace(/\r\n/g, "\n"));
|
|
62311
62809
|
return m !== null && text3.replace(/\r\n/g, "\n").slice(m[0].length).split("\n", 1)[0] === OUTPUT_STYLE_MARKER;
|
|
62312
62810
|
};
|
|
62313
62811
|
var isLink2 = (path) => {
|
|
62314
62812
|
try {
|
|
62315
|
-
return
|
|
62813
|
+
return lstatSync19(path).isSymbolicLink();
|
|
62316
62814
|
} catch {
|
|
62317
62815
|
return false;
|
|
62318
62816
|
}
|
|
62319
62817
|
};
|
|
62320
62818
|
var exists = (path) => {
|
|
62321
62819
|
try {
|
|
62322
|
-
|
|
62820
|
+
lstatSync19(path);
|
|
62323
62821
|
return true;
|
|
62324
62822
|
} catch {
|
|
62325
62823
|
return false;
|
|
@@ -62329,7 +62827,7 @@ var readSettings = (path) => {
|
|
|
62329
62827
|
if (isLink2(path)) return { ok: false, why: "it is a symlink" };
|
|
62330
62828
|
if (!exists(path)) return { ok: true, text: void 0, style: void 0 };
|
|
62331
62829
|
try {
|
|
62332
|
-
const text3 =
|
|
62830
|
+
const text3 = readFileSync34(path, "utf8");
|
|
62333
62831
|
parseJsonc(text3, path);
|
|
62334
62832
|
return { ok: true, text: text3, style: jsoncValue(text3, ["outputStyle"]) };
|
|
62335
62833
|
} catch {
|
|
@@ -62390,7 +62888,7 @@ function selectOutputStyle(deps2) {
|
|
|
62390
62888
|
);
|
|
62391
62889
|
} else {
|
|
62392
62890
|
try {
|
|
62393
|
-
if (exists(path) && isOurs2(
|
|
62891
|
+
if (exists(path) && isOurs2(readFileSync34(path, "utf8"))) {
|
|
62394
62892
|
rmSync21(path);
|
|
62395
62893
|
removed = true;
|
|
62396
62894
|
if (readdirSync11(dir).length === 0) rmdirSync3(dir);
|
|
@@ -62462,7 +62960,7 @@ function uninstallOutputStyle(deps2) {
|
|
|
62462
62960
|
);
|
|
62463
62961
|
} else if (!exists(path)) {
|
|
62464
62962
|
gone = true;
|
|
62465
|
-
} else if (!isOurs2(
|
|
62963
|
+
} else if (!isOurs2(readFileSync34(path, "utf8"))) {
|
|
62466
62964
|
out.notes.push(
|
|
62467
62965
|
`Left ${path} alone: it has no Open Artifacts marker, so it is not ours to replace.`
|
|
62468
62966
|
);
|
|
@@ -62503,7 +63001,7 @@ var outputStyleState = (deps2) => {
|
|
|
62503
63001
|
const path = outputStyleFile(deps2);
|
|
62504
63002
|
try {
|
|
62505
63003
|
if (isLink2(dirname17(path)) || isLink2(path)) return void 0;
|
|
62506
|
-
if (!isOurs2(
|
|
63004
|
+
if (!isOurs2(readFileSync34(path, "utf8"))) return void 0;
|
|
62507
63005
|
const s = readSettings(claudeSettingsFile(deps2));
|
|
62508
63006
|
return { path, on: s.ok && s.style === OUTPUT_STYLE_NAME };
|
|
62509
63007
|
} catch {
|
|
@@ -62523,10 +63021,10 @@ var SPARSE = [".claude-plugin", "plugins", "packages/claude-code-shortcuts"];
|
|
|
62523
63021
|
var CALL_MS = 12e4;
|
|
62524
63022
|
var MCP_LIST_MS = 2e4;
|
|
62525
63023
|
var readRecord4 = (busHome2) => {
|
|
62526
|
-
const r = readInstallFile(
|
|
63024
|
+
const r = readInstallFile(join39(busHome2, "install.json")).claudePlugins;
|
|
62527
63025
|
return typeof r === "object" && r !== null ? r : void 0;
|
|
62528
63026
|
};
|
|
62529
|
-
var writeRecord4 = (busHome2, r) => updateInstallFile(
|
|
63027
|
+
var writeRecord4 = (busHome2, r) => updateInstallFile(join39(busHome2, "install.json"), { claudePlugins: r });
|
|
62530
63028
|
var cmpVersion = (a, b) => {
|
|
62531
63029
|
const pa = a.split(".").map(Number);
|
|
62532
63030
|
const pb = b.split(".").map(Number);
|
|
@@ -62593,11 +63091,11 @@ ${r.stderr}`;
|
|
|
62593
63091
|
return { why: /timed out/i.test(text3) ? "timeout" : "error" };
|
|
62594
63092
|
}
|
|
62595
63093
|
const m = /^\s*URL:\s*(\S+)/m.exec(r.stdout);
|
|
62596
|
-
if (m &&
|
|
63094
|
+
if (m && originOf3(m[1]) === origin)
|
|
62597
63095
|
return { name: DEFAULT_MCP_SERVER };
|
|
62598
63096
|
return { why: "none" };
|
|
62599
63097
|
}
|
|
62600
|
-
var
|
|
63098
|
+
var originOf3 = (url2) => {
|
|
62601
63099
|
try {
|
|
62602
63100
|
return new URL(url2).origin;
|
|
62603
63101
|
} catch {
|
|
@@ -62809,7 +63307,7 @@ async function installClaudePlugins(deps2, harnesses) {
|
|
|
62809
63307
|
const ownShortcuts = fresh || mine.has(SHORTCUTS_PLUGIN);
|
|
62810
63308
|
const origin = deps2.origin;
|
|
62811
63309
|
if (!ownShortcuts) {
|
|
62812
|
-
} else if (origin !== void 0 &&
|
|
63310
|
+
} else if (origin !== void 0 && originOf3(origin) !== origin) {
|
|
62813
63311
|
out.notes.push(...copy2.pluginsBadInstance());
|
|
62814
63312
|
} else if (origin) {
|
|
62815
63313
|
config2.push("--config", `instanceUrl=${origin}/mcp`);
|
|
@@ -62966,13 +63464,13 @@ async function claudePluginsState(deps2) {
|
|
|
62966
63464
|
let unconfigured = false;
|
|
62967
63465
|
if (rec.plugins.includes(SHORTCUTS_PLUGIN) && !missing2.includes(SHORTCUTS_PLUGIN)) {
|
|
62968
63466
|
const url2 = readInstanceUrl(deps2);
|
|
62969
|
-
unconfigured = url2 !== void 0 &&
|
|
63467
|
+
unconfigured = url2 !== void 0 && originOf3(url2) === void 0;
|
|
62970
63468
|
}
|
|
62971
63469
|
return { missing: missing2, unconfigured };
|
|
62972
63470
|
}
|
|
62973
63471
|
function readShortcutOptions(deps2) {
|
|
62974
63472
|
try {
|
|
62975
|
-
const text3 =
|
|
63473
|
+
const text3 = readFileSync35(claudeSettingsFile(deps2), "utf8");
|
|
62976
63474
|
const o = JSON.parse(text3);
|
|
62977
63475
|
const opts = o.pluginConfigs?.[SHORTCUTS_PLUGIN]?.options;
|
|
62978
63476
|
const str3 = (v) => typeof v === "string" && v ? v : void 0;
|
|
@@ -62989,9 +63487,165 @@ function readInstanceUrl(deps2) {
|
|
|
62989
63487
|
return o === void 0 ? void 0 : o.instanceUrl ?? "";
|
|
62990
63488
|
}
|
|
62991
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
|
+
|
|
62992
63646
|
// src/commands/habits.ts
|
|
62993
63647
|
init_src();
|
|
62994
|
-
import { join as
|
|
63648
|
+
import { join as join41 } from "node:path";
|
|
62995
63649
|
var pluginOn = (p) => `Habits on in the ${p.label} plugin.`;
|
|
62996
63650
|
var pluginOff = (p) => `Habits off in the ${p.label} plugin.`;
|
|
62997
63651
|
var deps = (ctx) => ({
|
|
@@ -63110,7 +63764,7 @@ async function habitsAfterInstall(ctx, json4) {
|
|
|
63110
63764
|
})),
|
|
63111
63765
|
// A plugin has no block to compare: its marker is there ("current") or not.
|
|
63112
63766
|
...plugins2.map((p) => ({
|
|
63113
|
-
path:
|
|
63767
|
+
path: join41(p.dir(ctx.userHome, ctx.env), p.marker),
|
|
63114
63768
|
label: `the ${p.label} plugin`,
|
|
63115
63769
|
s: {
|
|
63116
63770
|
state: pluginHabitsState(deps(ctx), p) === "on" ? "current" : "absent"
|
|
@@ -63155,7 +63809,7 @@ async function habitsAfterInstall(ctx, json4) {
|
|
|
63155
63809
|
const pl = setPluginHabits(
|
|
63156
63810
|
deps(ctx),
|
|
63157
63811
|
plugins2.filter(
|
|
63158
|
-
(p) => asked.includes(
|
|
63812
|
+
(p) => asked.includes(join41(p.dir(ctx.userHome, ctx.env), p.marker))
|
|
63159
63813
|
),
|
|
63160
63814
|
true
|
|
63161
63815
|
);
|
|
@@ -63228,7 +63882,7 @@ import {
|
|
|
63228
63882
|
unlinkSync as unlinkSync3,
|
|
63229
63883
|
writeSync as writeSync4
|
|
63230
63884
|
} from "node:fs";
|
|
63231
|
-
import { join as
|
|
63885
|
+
import { join as join42 } from "node:path";
|
|
63232
63886
|
init_src();
|
|
63233
63887
|
|
|
63234
63888
|
// src/machine-label.ts
|
|
@@ -63277,7 +63931,7 @@ function checkVerificationUri(uri, hub) {
|
|
|
63277
63931
|
function writeMachineFile(home2, body) {
|
|
63278
63932
|
mkdirSync16(home2, { recursive: true, mode: 448 });
|
|
63279
63933
|
chmodSync21(home2, 448);
|
|
63280
|
-
const tmp =
|
|
63934
|
+
const tmp = join42(home2, `.machine.json.${randomBytes7(8).toString("hex")}.tmp`);
|
|
63281
63935
|
const fd = openSync9(tmp, "wx", 384);
|
|
63282
63936
|
try {
|
|
63283
63937
|
writeSync4(fd, body);
|
|
@@ -63289,7 +63943,7 @@ function writeMachineFile(home2, body) {
|
|
|
63289
63943
|
closeSync9(fd);
|
|
63290
63944
|
try {
|
|
63291
63945
|
chmodSync21(tmp, 384);
|
|
63292
|
-
renameSync21(tmp,
|
|
63946
|
+
renameSync21(tmp, join42(home2, "machine.json"));
|
|
63293
63947
|
} catch (e) {
|
|
63294
63948
|
unlinkSync3(tmp);
|
|
63295
63949
|
throw e;
|
|
@@ -63424,7 +64078,7 @@ async function loginInner(args) {
|
|
|
63424
64078
|
`${JSON.stringify({ hub, label: label2, machine_token: poll.machine_token }, null, 2)}
|
|
63425
64079
|
`
|
|
63426
64080
|
);
|
|
63427
|
-
rmSync22(
|
|
64081
|
+
rmSync22(join42(args.home, "revoked"), { force: true });
|
|
63428
64082
|
if (!events?.code) print(`Approved this machine as ${label2}.`);
|
|
63429
64083
|
return {
|
|
63430
64084
|
machineToken: poll.machine_token,
|
|
@@ -63448,7 +64102,7 @@ init_src();
|
|
|
63448
64102
|
|
|
63449
64103
|
// src/commands/install.ts
|
|
63450
64104
|
init_src3();
|
|
63451
|
-
import { dirname as dirname18, join as
|
|
64105
|
+
import { dirname as dirname18, join as join44 } from "node:path";
|
|
63452
64106
|
init_src2();
|
|
63453
64107
|
|
|
63454
64108
|
// src/live.ts
|
|
@@ -63499,21 +64153,21 @@ function spinner(ctx) {
|
|
|
63499
64153
|
|
|
63500
64154
|
// src/steps/leftovers.ts
|
|
63501
64155
|
import {
|
|
63502
|
-
lstatSync as
|
|
64156
|
+
lstatSync as lstatSync20,
|
|
63503
64157
|
readdirSync as readdirSync12,
|
|
63504
|
-
readFileSync as
|
|
64158
|
+
readFileSync as readFileSync37,
|
|
63505
64159
|
rmdirSync as rmdirSync4,
|
|
63506
64160
|
rmSync as rmSync23
|
|
63507
64161
|
} from "node:fs";
|
|
63508
|
-
import { join as
|
|
64162
|
+
import { join as join43 } from "node:path";
|
|
63509
64163
|
function leftoverTargets(deps2) {
|
|
63510
64164
|
const env2 = deps2.env ?? {};
|
|
63511
64165
|
const p = paths(deps2);
|
|
63512
|
-
const piDir = agentDirEnv(deps2.home, env2) ??
|
|
64166
|
+
const piDir = agentDirEnv(deps2.home, env2) ?? join43(deps2.home, ".pi/agent");
|
|
63513
64167
|
const skill = (h) => skillDir({ home: deps2.home, env: env2 }, h);
|
|
63514
64168
|
return {
|
|
63515
64169
|
files: [
|
|
63516
|
-
|
|
64170
|
+
join43(codexHome2(deps2.home, env2), "AGENTS.md"),
|
|
63517
64171
|
p.codex,
|
|
63518
64172
|
...p.opencodeConfigs,
|
|
63519
64173
|
p.opencodeCli
|
|
@@ -63522,10 +64176,10 @@ function leftoverTargets(deps2) {
|
|
|
63522
64176
|
skill("claude"),
|
|
63523
64177
|
skill("pi"),
|
|
63524
64178
|
skill("hermes"),
|
|
63525
|
-
|
|
63526
|
-
|
|
63527
|
-
|
|
63528
|
-
|
|
64179
|
+
join43(hermesHome(deps2.home, env2), "plugins"),
|
|
64180
|
+
join43(deps2.home, ".local", "bin"),
|
|
64181
|
+
join43(ompAgentDir(deps2.home, env2), "extensions"),
|
|
64182
|
+
join43(piDir, "extensions"),
|
|
63529
64183
|
skill("opencode"),
|
|
63530
64184
|
skill("openclaw")
|
|
63531
64185
|
]
|
|
@@ -63533,7 +64187,7 @@ function leftoverTargets(deps2) {
|
|
|
63533
64187
|
}
|
|
63534
64188
|
var exists2 = (path) => {
|
|
63535
64189
|
try {
|
|
63536
|
-
|
|
64190
|
+
lstatSync20(path);
|
|
63537
64191
|
return true;
|
|
63538
64192
|
} catch {
|
|
63539
64193
|
return false;
|
|
@@ -63566,10 +64220,10 @@ function pruneMade(deps2) {
|
|
|
63566
64220
|
}
|
|
63567
64221
|
function emptyFile(path) {
|
|
63568
64222
|
try {
|
|
63569
|
-
const st =
|
|
64223
|
+
const st = lstatSync20(path);
|
|
63570
64224
|
if (!st.isFile()) return false;
|
|
63571
64225
|
if (st.size === 0) return true;
|
|
63572
|
-
const doc = JSON.parse(
|
|
64226
|
+
const doc = JSON.parse(readFileSync37(path, "utf8"));
|
|
63573
64227
|
return typeof doc === "object" && doc !== null && !Array.isArray(doc) && Object.keys(doc).length === 0;
|
|
63574
64228
|
} catch {
|
|
63575
64229
|
return false;
|
|
@@ -63585,7 +64239,7 @@ function removeMade(made) {
|
|
|
63585
64239
|
}
|
|
63586
64240
|
for (const path of made.filter((x) => !gone.includes(x)).sort((a, b) => b.length - a.length)) {
|
|
63587
64241
|
try {
|
|
63588
|
-
if (!
|
|
64242
|
+
if (!lstatSync20(path).isDirectory()) continue;
|
|
63589
64243
|
if (readdirSync12(path).length > 0) continue;
|
|
63590
64244
|
rmdirSync4(path);
|
|
63591
64245
|
gone.push(path);
|
|
@@ -63602,13 +64256,6 @@ var DAEMON_POLL_MS = 250;
|
|
|
63602
64256
|
var DAEMON_POLL_MAX_MS = 2e3;
|
|
63603
64257
|
var DAEMON_GONE_AFTER_MS = 1e4;
|
|
63604
64258
|
var ROSTER_ROWS = 20;
|
|
63605
|
-
var originOf3 = (hub) => {
|
|
63606
|
-
try {
|
|
63607
|
-
return new URL(hub.replace(/^ws(s?):/, "http$1:")).origin;
|
|
63608
|
-
} catch {
|
|
63609
|
-
return hub;
|
|
63610
|
-
}
|
|
63611
|
-
};
|
|
63612
64259
|
var hostOf = (hub) => {
|
|
63613
64260
|
try {
|
|
63614
64261
|
return new URL(hub).host;
|
|
@@ -63621,7 +64268,7 @@ async function loginStep(ctx, opts) {
|
|
|
63621
64268
|
const machine = readMachine(ctx.home);
|
|
63622
64269
|
const asked = opts.hub ?? ctx.env.OA_BUS_INSTANCE;
|
|
63623
64270
|
if (machine.state === "ok" && !machine.revoked && !opts.force) {
|
|
63624
|
-
if (asked &&
|
|
64271
|
+
if (asked && originOf2(asked) !== originOf2(machine.hub)) {
|
|
63625
64272
|
sayErr(ctx, c.hubMismatch(hostOf(machine.hub), hostOf(asked), asked));
|
|
63626
64273
|
return false;
|
|
63627
64274
|
}
|
|
@@ -63677,10 +64324,10 @@ async function loginStep(ctx, opts) {
|
|
|
63677
64324
|
ctx,
|
|
63678
64325
|
c.approved(result.label),
|
|
63679
64326
|
c.tokenSaved(
|
|
63680
|
-
tilde(ctx,
|
|
64327
|
+
tilde(ctx, join44(ctx.home, "machine.json")),
|
|
63681
64328
|
result.machineToken
|
|
63682
64329
|
),
|
|
63683
|
-
c.connected(
|
|
64330
|
+
c.connected(originOf2(result.hub)),
|
|
63684
64331
|
""
|
|
63685
64332
|
);
|
|
63686
64333
|
return true;
|
|
@@ -63707,12 +64354,12 @@ async function loginStep(ctx, opts) {
|
|
|
63707
64354
|
}
|
|
63708
64355
|
async function harnessesStep(ctx, hub) {
|
|
63709
64356
|
const c = ctx.copy;
|
|
63710
|
-
const
|
|
64357
|
+
const hubOrigin3 = hub ? originOf2(hub) : machineOrigin(ctx);
|
|
63711
64358
|
const out = await installAdapters({
|
|
63712
64359
|
home: ctx.userHome,
|
|
63713
64360
|
busHome: ctx.home,
|
|
63714
64361
|
env: ctx.env,
|
|
63715
|
-
...
|
|
64362
|
+
...hubOrigin3 ? { hub: hubOrigin3 } : {},
|
|
63716
64363
|
// The service runs this same copy.
|
|
63717
64364
|
busBin: ctx.service.cli(),
|
|
63718
64365
|
assets: readAssets(),
|
|
@@ -63751,7 +64398,7 @@ async function harnessesStep(ctx, hub) {
|
|
|
63751
64398
|
codexVersion,
|
|
63752
64399
|
fetchSkill: (url2) => fetchSkillText(ctx.fetch, url2)
|
|
63753
64400
|
},
|
|
63754
|
-
hub ?
|
|
64401
|
+
hub ? originOf2(hub) : machineOrigin(ctx),
|
|
63755
64402
|
out.installed
|
|
63756
64403
|
);
|
|
63757
64404
|
for (const n of skill.notes) say(ctx, [n]);
|
|
@@ -63764,7 +64411,7 @@ async function harnessesStep(ctx, hub) {
|
|
|
63764
64411
|
env: ctx.env,
|
|
63765
64412
|
exec: ctx.exec,
|
|
63766
64413
|
version: ctx.version,
|
|
63767
|
-
origin: hub ?
|
|
64414
|
+
origin: hub ? originOf2(hub) : machineOrigin(ctx),
|
|
63768
64415
|
copy: c
|
|
63769
64416
|
},
|
|
63770
64417
|
out.installed
|
|
@@ -63791,7 +64438,7 @@ function reportSkillFailure(ctx) {
|
|
|
63791
64438
|
}
|
|
63792
64439
|
function machineOrigin(ctx) {
|
|
63793
64440
|
const m = readMachine(ctx.home);
|
|
63794
|
-
return m.state === "ok" ?
|
|
64441
|
+
return m.state === "ok" ? originOf2(m.hub) : void 0;
|
|
63795
64442
|
}
|
|
63796
64443
|
async function skippedLines(ctx, h, reason2) {
|
|
63797
64444
|
if (h !== "opencode") return ctx.copy.skipped(h, tildeReason(ctx, h, reason2));
|
|
@@ -63806,7 +64453,7 @@ function shownSocket(ctx) {
|
|
|
63806
64453
|
const real3 = `${canonicalHome(ctx.home)}/`;
|
|
63807
64454
|
return tilde(
|
|
63808
64455
|
ctx,
|
|
63809
|
-
path.startsWith(real3) ?
|
|
64456
|
+
path.startsWith(real3) ? join44(ctx.home, path.slice(real3.length)) : path
|
|
63810
64457
|
);
|
|
63811
64458
|
}
|
|
63812
64459
|
async function waitForDaemon(ctx) {
|
|
@@ -64058,7 +64705,7 @@ async function installRun(opts, realCtx2) {
|
|
|
64058
64705
|
return results.every((r) => r.state === "done") ? 0 : 1;
|
|
64059
64706
|
}
|
|
64060
64707
|
const ok = await runSteps(steps, ctx, {
|
|
64061
|
-
path:
|
|
64708
|
+
path: join44(ctx.home, "install.json"),
|
|
64062
64709
|
now: ctx.now
|
|
64063
64710
|
});
|
|
64064
64711
|
if (ok && second) say(ctx, "", c.secondBus(ctx.home));
|
|
@@ -64150,19 +64797,11 @@ var updateTarget = async (ctx, st, probe2) => {
|
|
|
64150
64797
|
);
|
|
64151
64798
|
return newest !== void 0 && !semverGte(mine, newest) ? newest : void 0;
|
|
64152
64799
|
};
|
|
64153
|
-
var
|
|
64154
|
-
|
|
64155
|
-
|
|
64156
|
-
|
|
64157
|
-
|
|
64158
|
-
return void 0;
|
|
64159
|
-
}
|
|
64160
|
-
const state = proofState(claudeConfigFile(ctx.userHome, ctx.env), origin);
|
|
64161
|
-
if (state === "none") return void 0;
|
|
64162
|
-
if (state === "missing")
|
|
64163
|
-
return `Claude Code: run ${ctx.busCmd} install to set this entry up to show as this session on pages.`;
|
|
64164
|
-
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.";
|
|
64165
|
-
};
|
|
64800
|
+
var proofLines = (ctx, hub, daemonKnows) => claudeProofChecks(ctx, hub).filter((c) => c.level !== "info").flatMap(
|
|
64801
|
+
(c) => c.level === "pass" && !daemonKnows ? [
|
|
64802
|
+
"Claude Code: update the daemon so these entries can show as this session on pages."
|
|
64803
|
+
] : c.lines
|
|
64804
|
+
);
|
|
64166
64805
|
async function status(ctx) {
|
|
64167
64806
|
const c = ctx.copy;
|
|
64168
64807
|
say(ctx, c.header(ctx.version), "");
|
|
@@ -64202,8 +64841,8 @@ async function status(ctx) {
|
|
|
64202
64841
|
if (habits) say(ctx, habits);
|
|
64203
64842
|
if (readRecord4(ctx.home)?.plugins?.length)
|
|
64204
64843
|
say(ctx, c.pluginsStatus());
|
|
64205
|
-
const proof =
|
|
64206
|
-
if (proof) say(ctx, proof);
|
|
64844
|
+
const proof = [...new Set(proofLines(ctx, m.hub, st.link === true))];
|
|
64845
|
+
if (proof.length) say(ctx, proof);
|
|
64207
64846
|
const ocState = openclawPluginState(
|
|
64208
64847
|
openclawPluginDir(ctx.userHome, ctx.env),
|
|
64209
64848
|
void 0
|
|
@@ -64216,6 +64855,11 @@ async function status(ctx) {
|
|
|
64216
64855
|
return 1;
|
|
64217
64856
|
}
|
|
64218
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
|
+
}
|
|
64219
64863
|
const late2 = [...st.late ?? []].sort((a, b) => b.at - a.at);
|
|
64220
64864
|
if (late2.length > 0)
|
|
64221
64865
|
say(ctx, "", [
|
|
@@ -64237,6 +64881,11 @@ var sameOrigin = (url2, hub) => {
|
|
|
64237
64881
|
return false;
|
|
64238
64882
|
}
|
|
64239
64883
|
};
|
|
64884
|
+
var skipDeps = (ctx) => ({
|
|
64885
|
+
home: ctx.userHome,
|
|
64886
|
+
busHome: ctx.home,
|
|
64887
|
+
env: ctx.env
|
|
64888
|
+
});
|
|
64240
64889
|
async function healthz(ctx, hub) {
|
|
64241
64890
|
try {
|
|
64242
64891
|
const res = await ctx.fetch(`${hub.replace(/\/+$/, "")}/healthz`, {
|
|
@@ -64251,7 +64900,7 @@ async function healthz(ctx, hub) {
|
|
|
64251
64900
|
function claudeIsolates(path) {
|
|
64252
64901
|
let text3;
|
|
64253
64902
|
try {
|
|
64254
|
-
text3 =
|
|
64903
|
+
text3 = readFileSync38(path, "utf8");
|
|
64255
64904
|
} catch {
|
|
64256
64905
|
return void 0;
|
|
64257
64906
|
}
|
|
@@ -64327,7 +64976,7 @@ async function doctor(ctx) {
|
|
|
64327
64976
|
const node2 = ctx.nodeVersion.replace(/^v/, "");
|
|
64328
64977
|
if (Number(node2.split(".")[0]) >= MIN_NODE) pass(c.nodeOk(node2));
|
|
64329
64978
|
else fail3(c.nodeOld(node2));
|
|
64330
|
-
const machineFile = tilde(ctx,
|
|
64979
|
+
const machineFile = tilde(ctx, join45(ctx.home, "machine.json"));
|
|
64331
64980
|
const m = readMachine(ctx.home);
|
|
64332
64981
|
if (m.state !== "ok") fail3(c.noCredentials(machineFile));
|
|
64333
64982
|
else if (m.revoked) fail3(c.revokedCheck());
|
|
@@ -64416,8 +65065,8 @@ async function doctor(ctx) {
|
|
|
64416
65065
|
pass(c.wired(h, version2));
|
|
64417
65066
|
else fail3(c.notWired(h));
|
|
64418
65067
|
if (h === "claude") {
|
|
64419
|
-
const settings =
|
|
64420
|
-
ctx.env.CLAUDE_CONFIG_DIR ??
|
|
65068
|
+
const settings = join45(
|
|
65069
|
+
ctx.env.CLAUDE_CONFIG_DIR ?? join45(ctx.userHome, ".claude"),
|
|
64421
65070
|
"settings.json"
|
|
64422
65071
|
);
|
|
64423
65072
|
const isolates = claudeIsolates(settings);
|
|
@@ -64441,6 +65090,31 @@ async function doctor(ctx) {
|
|
|
64441
65090
|
fail3(c.pluginsDoctorMissing(plugins2.missing));
|
|
64442
65091
|
else if (plugins2?.unconfigured) warn(c.pluginsDoctorUnconfigured());
|
|
64443
65092
|
else if (plugins2) pass(c.pluginsDoctor());
|
|
65093
|
+
if (hub !== void 0) {
|
|
65094
|
+
for (const chk of claudeProofChecks(ctx, hub))
|
|
65095
|
+
if (chk.level === "pass") pass(chk.lines[0]);
|
|
65096
|
+
else if (chk.level === "warn") warn(chk.lines);
|
|
65097
|
+
else if (chk.level === "info") say(ctx, chk.lines);
|
|
65098
|
+
else fail3(chk.lines);
|
|
65099
|
+
const fixed = lastAutoFix(ctx);
|
|
65100
|
+
if (fixed) say(ctx, fixed);
|
|
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
|
+
}
|
|
64444
65118
|
}
|
|
64445
65119
|
if (h === "opencode") {
|
|
64446
65120
|
const gone = opencodeProxyProblem({
|
|
@@ -64450,6 +65124,11 @@ async function doctor(ctx) {
|
|
|
64450
65124
|
which: ctx.which
|
|
64451
65125
|
});
|
|
64452
65126
|
if (gone) fail3(c.opencodeProxyMissing(gone.name, gone.missing));
|
|
65127
|
+
if (hub !== void 0) {
|
|
65128
|
+
for (const k of skippedProxyEntries({ ...skipDeps(ctx), hub }))
|
|
65129
|
+
if (k.harness === "OpenCode")
|
|
65130
|
+
warn([`OpenCode: ${safeText(k.note, 400)}`]);
|
|
65131
|
+
}
|
|
64453
65132
|
}
|
|
64454
65133
|
if (h === "codex") {
|
|
64455
65134
|
codexChecks(ctx, { pass, warn });
|
|
@@ -64460,6 +65139,10 @@ async function doctor(ctx) {
|
|
|
64460
65139
|
which: ctx.which
|
|
64461
65140
|
});
|
|
64462
65141
|
if (gone) fail3(c.codexProxyMissing(gone.name, gone.missing));
|
|
65142
|
+
if (hub !== void 0) {
|
|
65143
|
+
for (const k of skippedProxyEntries({ ...skipDeps(ctx), hub }))
|
|
65144
|
+
if (k.harness === "Codex") warn([`Codex: ${safeText(k.note, 400)}`]);
|
|
65145
|
+
}
|
|
64463
65146
|
}
|
|
64464
65147
|
if (h === "openclaw") say(ctx, c.openclawDmNote());
|
|
64465
65148
|
}
|
|
@@ -64511,7 +65194,7 @@ async function doctor(ctx) {
|
|
|
64511
65194
|
|
|
64512
65195
|
// src/commands/global.ts
|
|
64513
65196
|
import { realpathSync as realpathSync15, statSync as statSync11 } from "node:fs";
|
|
64514
|
-
import { resolve as
|
|
65197
|
+
import { resolve as resolve14 } from "node:path";
|
|
64515
65198
|
function shown3(ctx, path) {
|
|
64516
65199
|
const t = tilde(ctx, path);
|
|
64517
65200
|
if (t !== path) return t;
|
|
@@ -64537,7 +65220,7 @@ async function global(opts, ctx) {
|
|
|
64537
65220
|
);
|
|
64538
65221
|
return 0;
|
|
64539
65222
|
}
|
|
64540
|
-
const given =
|
|
65223
|
+
const given = resolve14(ctx.cwd, opts.dir);
|
|
64541
65224
|
let real3;
|
|
64542
65225
|
try {
|
|
64543
65226
|
real3 = canonicalPath(given);
|
|
@@ -64569,12 +65252,12 @@ async function global(opts, ctx) {
|
|
|
64569
65252
|
}
|
|
64570
65253
|
|
|
64571
65254
|
// src/commands/leads.ts
|
|
64572
|
-
import { readFileSync as
|
|
64573
|
-
import { join as
|
|
64574
|
-
function
|
|
65255
|
+
import { readFileSync as readFileSync39 } from "node:fs";
|
|
65256
|
+
import { join as join46 } from "node:path";
|
|
65257
|
+
function hubOrigin2(ctx) {
|
|
64575
65258
|
try {
|
|
64576
65259
|
const raw = JSON.parse(
|
|
64577
|
-
|
|
65260
|
+
readFileSync39(join46(ctx.home, "machine.json"), "utf8")
|
|
64578
65261
|
);
|
|
64579
65262
|
return typeof raw?.hub === "string" ? new URL(raw.hub).origin : void 0;
|
|
64580
65263
|
} catch {
|
|
@@ -64584,7 +65267,7 @@ function hubOrigin(ctx) {
|
|
|
64584
65267
|
async function leads(opts, ctx) {
|
|
64585
65268
|
const c = ctx.copy;
|
|
64586
65269
|
say(ctx, c.header(ctx.version), "");
|
|
64587
|
-
const origin =
|
|
65270
|
+
const origin = hubOrigin2(ctx);
|
|
64588
65271
|
if (!origin) {
|
|
64589
65272
|
sayErr(ctx, c.leadsNoHub());
|
|
64590
65273
|
return 1;
|
|
@@ -64633,10 +65316,10 @@ async function leads(opts, ctx) {
|
|
|
64633
65316
|
|
|
64634
65317
|
// src/commands/link.ts
|
|
64635
65318
|
import { statSync as statSync12 } from "node:fs";
|
|
64636
|
-
import { resolve as
|
|
65319
|
+
import { resolve as resolve15 } from "node:path";
|
|
64637
65320
|
init_src();
|
|
64638
65321
|
function side(ctx, dir) {
|
|
64639
|
-
const given =
|
|
65322
|
+
const given = resolve15(ctx.cwd, dir);
|
|
64640
65323
|
try {
|
|
64641
65324
|
const real3 = canonicalPath(given);
|
|
64642
65325
|
if (!statSync12(real3).isDirectory()) return void 0;
|
|
@@ -64667,7 +65350,7 @@ async function link(opts, ctx) {
|
|
|
64667
65350
|
for (const d of opts.dirs) {
|
|
64668
65351
|
const s = side(ctx, d);
|
|
64669
65352
|
if (!s) {
|
|
64670
|
-
sayErr(ctx, c.linkNotDir(shq(
|
|
65353
|
+
sayErr(ctx, c.linkNotDir(shq(resolve15(ctx.cwd, d))));
|
|
64671
65354
|
return 1;
|
|
64672
65355
|
}
|
|
64673
65356
|
sides.push(s);
|
|
@@ -64731,16 +65414,16 @@ import {
|
|
|
64731
65414
|
closeSync as closeSync10,
|
|
64732
65415
|
constants as constants7,
|
|
64733
65416
|
fstatSync as fstatSync5,
|
|
64734
|
-
lstatSync as
|
|
65417
|
+
lstatSync as lstatSync21,
|
|
64735
65418
|
openSync as openSync10,
|
|
64736
|
-
readFileSync as
|
|
65419
|
+
readFileSync as readFileSync40
|
|
64737
65420
|
} from "node:fs";
|
|
64738
|
-
import { dirname as dirname19, join as
|
|
65421
|
+
import { dirname as dirname19, join as join47 } from "node:path";
|
|
64739
65422
|
var TAIL = 50;
|
|
64740
65423
|
var checkDir = (dir) => {
|
|
64741
65424
|
let fd;
|
|
64742
65425
|
try {
|
|
64743
|
-
const ls =
|
|
65426
|
+
const ls = lstatSync21(dir);
|
|
64744
65427
|
if (ls.isSymbolicLink()) return { ok: false, why: "it is a symlink" };
|
|
64745
65428
|
if (!ls.isDirectory()) return { ok: false, why: "it is not a folder" };
|
|
64746
65429
|
if (typeof process.getuid === "function" && ls.uid !== process.getuid())
|
|
@@ -64769,10 +65452,10 @@ var tail = (path, dir) => {
|
|
|
64769
65452
|
constants7.O_RDONLY | constants7.O_NOFOLLOW | constants7.O_NONBLOCK
|
|
64770
65453
|
);
|
|
64771
65454
|
if (!fstatSync5(fd).isFile()) return "skipped";
|
|
64772
|
-
const after =
|
|
65455
|
+
const after = lstatSync21(dirname19(path));
|
|
64773
65456
|
if (after.isSymbolicLink() || after.dev !== dir.dev || after.ino !== dir.ino)
|
|
64774
65457
|
return "skipped";
|
|
64775
|
-
return
|
|
65458
|
+
return readFileSync40(fd, "utf8").replace(/\n$/, "").split("\n").slice(-TAIL);
|
|
64776
65459
|
} catch (e) {
|
|
64777
65460
|
return e.code === "ELOOP" ? "skipped" : void 0;
|
|
64778
65461
|
} finally {
|
|
@@ -64780,9 +65463,9 @@ var tail = (path, dir) => {
|
|
|
64780
65463
|
}
|
|
64781
65464
|
};
|
|
64782
65465
|
async function logs(ctx) {
|
|
64783
|
-
const logDir =
|
|
64784
|
-
const path =
|
|
64785
|
-
const eventsPath =
|
|
65466
|
+
const logDir = join47(ctx.home, "logs");
|
|
65467
|
+
const path = join47(logDir, "daemon.log");
|
|
65468
|
+
const eventsPath = join47(logDir, "events.log");
|
|
64786
65469
|
const dir = checkDir(logDir);
|
|
64787
65470
|
if (!dir.ok && dir.why !== "missing") {
|
|
64788
65471
|
say(ctx, `Not reading ${tilde(ctx, logDir)}: ${dir.why}.`);
|
|
@@ -64822,12 +65505,13 @@ async function mcp(harness, ctx, load2 = (h) => MCP_SERVER[h]()) {
|
|
|
64822
65505
|
|
|
64823
65506
|
// src/commands/mcp-proof.ts
|
|
64824
65507
|
init_src3();
|
|
64825
|
-
init_src2();
|
|
64826
|
-
init_src();
|
|
64827
65508
|
import { execFileSync as execFileSync7 } from "node:child_process";
|
|
64828
65509
|
import { createHash as createHash12, randomBytes as randomBytes8 } from "node:crypto";
|
|
64829
|
-
import { readFileSync as
|
|
64830
|
-
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;
|
|
64831
65515
|
var isClaude = (name) => name === "claude" || /\/claude\/versions\/[^/]+$/.test(name);
|
|
64832
65516
|
function parsePs(out) {
|
|
64833
65517
|
const m = /^(\d+)\s+(.+)$/.exec(out.trim());
|
|
@@ -64837,14 +65521,14 @@ function parsePs(out) {
|
|
|
64837
65521
|
}
|
|
64838
65522
|
function readProc(pid) {
|
|
64839
65523
|
try {
|
|
64840
|
-
const stat =
|
|
65524
|
+
const stat = readFileSync41(`/proc/${pid}/stat`, "utf8");
|
|
64841
65525
|
const ppid = Number(stat.slice(stat.lastIndexOf(")") + 1).split(/\s+/)[2]);
|
|
64842
65526
|
let exe = "";
|
|
64843
65527
|
try {
|
|
64844
65528
|
exe = readlinkSync7(`/proc/${pid}/exe`);
|
|
64845
65529
|
} catch {
|
|
64846
65530
|
}
|
|
64847
|
-
const comm =
|
|
65531
|
+
const comm = readFileSync41(`/proc/${pid}/comm`, "utf8").trim();
|
|
64848
65532
|
return { ppid, name: isClaude(exe) ? exe : comm };
|
|
64849
65533
|
} catch {
|
|
64850
65534
|
}
|
|
@@ -64872,7 +65556,7 @@ function findClaude(from, proc) {
|
|
|
64872
65556
|
function tokenOf(file2) {
|
|
64873
65557
|
if (!file2) return void 0;
|
|
64874
65558
|
try {
|
|
64875
|
-
return
|
|
65559
|
+
return readFileSync41(file2, "utf8").trim() || void 0;
|
|
64876
65560
|
} catch {
|
|
64877
65561
|
return void 0;
|
|
64878
65562
|
}
|
|
@@ -64886,22 +65570,40 @@ async function mcpProof(opts, ctx, deps2 = {
|
|
|
64886
65570
|
const headers = {};
|
|
64887
65571
|
const token = tokenOf(opts.tokenFile);
|
|
64888
65572
|
if (token) headers.Authorization = `Bearer ${token}`;
|
|
65573
|
+
let why2;
|
|
65574
|
+
let claude2;
|
|
64889
65575
|
try {
|
|
64890
|
-
|
|
64891
|
-
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 {
|
|
64892
65583
|
const proof = deps2.random().toString("base64url");
|
|
64893
65584
|
const hash2 = createHash12("sha256").update(proof).digest("hex");
|
|
64894
65585
|
if (await deps2.link(claude2, hash2)) headers[LINK_PROOF_HEADER] = proof;
|
|
65586
|
+
else why2 = "process_not_matched";
|
|
65587
|
+
} catch {
|
|
65588
|
+
why2 = "daemon_unreachable";
|
|
64895
65589
|
}
|
|
64896
|
-
} catch {
|
|
64897
|
-
}
|
|
64898
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
|
+
}
|
|
64899
65601
|
return 0;
|
|
64900
65602
|
}
|
|
64901
65603
|
|
|
64902
65604
|
// src/commands/namespace.ts
|
|
64903
65605
|
import { realpathSync as realpathSync16, statSync as statSync13 } from "node:fs";
|
|
64904
|
-
import { join as
|
|
65606
|
+
import { join as join49, resolve as resolve16 } from "node:path";
|
|
64905
65607
|
init_src();
|
|
64906
65608
|
function shown4(ctx, path) {
|
|
64907
65609
|
const t = tilde(ctx, path);
|
|
@@ -64928,7 +65630,7 @@ async function namespace(opts, ctx) {
|
|
|
64928
65630
|
);
|
|
64929
65631
|
return 0;
|
|
64930
65632
|
}
|
|
64931
|
-
const given =
|
|
65633
|
+
const given = resolve16(ctx.cwd, opts.dir);
|
|
64932
65634
|
let real3;
|
|
64933
65635
|
try {
|
|
64934
65636
|
real3 = canonicalPath(given);
|
|
@@ -64955,7 +65657,7 @@ async function namespace(opts, ctx) {
|
|
|
64955
65657
|
sayErr(ctx, c.nsNotDir(shown4(ctx, real3 ?? given)));
|
|
64956
65658
|
return 1;
|
|
64957
65659
|
}
|
|
64958
|
-
const cfgFile =
|
|
65660
|
+
const cfgFile = join49(real3, CONFIG_FILE);
|
|
64959
65661
|
const own2 = readOwnFile(cfgFile, process.getuid?.(), {
|
|
64960
65662
|
allowGroupWrite: true
|
|
64961
65663
|
});
|
|
@@ -65029,12 +65731,12 @@ async function namespace(opts, ctx) {
|
|
|
65029
65731
|
}
|
|
65030
65732
|
|
|
65031
65733
|
// src/commands/uninstall.ts
|
|
65032
|
-
import { join as
|
|
65734
|
+
import { join as join51 } from "node:path";
|
|
65033
65735
|
|
|
65034
65736
|
// src/steps/purge.ts
|
|
65035
65737
|
init_src3();
|
|
65036
|
-
import { lstatSync as
|
|
65037
|
-
import { join as
|
|
65738
|
+
import { lstatSync as lstatSync22, readdirSync as readdirSync13, rmdirSync as rmdirSync5, rmSync as rmSync24 } from "node:fs";
|
|
65739
|
+
import { join as join50 } from "node:path";
|
|
65038
65740
|
var FILES = [
|
|
65039
65741
|
"machine.json",
|
|
65040
65742
|
"install.json",
|
|
@@ -65087,7 +65789,7 @@ var FOLDERS = [
|
|
|
65087
65789
|
];
|
|
65088
65790
|
function kind3(path) {
|
|
65089
65791
|
try {
|
|
65090
|
-
const st =
|
|
65792
|
+
const st = lstatSync22(path);
|
|
65091
65793
|
return st.isDirectory() ? "dir" : st.isSocket() ? "socket" : "other";
|
|
65092
65794
|
} catch {
|
|
65093
65795
|
return void 0;
|
|
@@ -65104,14 +65806,14 @@ var rmdirIfEmpty = (path) => {
|
|
|
65104
65806
|
};
|
|
65105
65807
|
function purgeShort(dir, removed) {
|
|
65106
65808
|
if (kind3(dir) !== "dir" || unsafeSocketDir(dir)) return;
|
|
65107
|
-
const ret =
|
|
65809
|
+
const ret = join50(dir, "claude-return");
|
|
65108
65810
|
for (const [d, ours2] of [
|
|
65109
65811
|
[ret, (_n, p) => kind3(p) === "socket"],
|
|
65110
65812
|
[dir, (n) => /^daemon\.sock(\.keep-\d+)?$/.test(n)]
|
|
65111
65813
|
]) {
|
|
65112
65814
|
if (kind3(d) !== "dir") continue;
|
|
65113
65815
|
for (const name of readdirSync13(d)) {
|
|
65114
|
-
const path =
|
|
65816
|
+
const path = join50(d, name);
|
|
65115
65817
|
const k = kind3(path);
|
|
65116
65818
|
if (k === void 0 || k === "dir" || !ours2(name, path)) continue;
|
|
65117
65819
|
remove2(path, k);
|
|
@@ -65136,21 +65838,21 @@ function purge(home2, opts) {
|
|
|
65136
65838
|
...FILES,
|
|
65137
65839
|
...entries.filter((n) => TEMP.some((re) => re.test(n)))
|
|
65138
65840
|
]) {
|
|
65139
|
-
const path =
|
|
65841
|
+
const path = join50(home2, name);
|
|
65140
65842
|
const k = kind3(path);
|
|
65141
65843
|
if (k === void 0 || k === "dir") continue;
|
|
65142
65844
|
remove2(path, k);
|
|
65143
65845
|
removed.push(name);
|
|
65144
65846
|
}
|
|
65145
65847
|
for (const folder of FOLDERS) {
|
|
65146
|
-
const dir =
|
|
65848
|
+
const dir = join50(home2, folder.path);
|
|
65147
65849
|
if (kind3(dir) !== "dir") continue;
|
|
65148
65850
|
for (const name of readdirSync13(dir)) {
|
|
65149
|
-
const path =
|
|
65851
|
+
const path = join50(dir, name);
|
|
65150
65852
|
const k = kind3(path);
|
|
65151
65853
|
if (k === void 0 || !folder.ours(name, path)) continue;
|
|
65152
65854
|
remove2(path, k);
|
|
65153
|
-
removed.push(
|
|
65855
|
+
removed.push(join50(folder.path, name));
|
|
65154
65856
|
}
|
|
65155
65857
|
if (rmdirIfEmpty(dir)) removed.push(folder.path);
|
|
65156
65858
|
}
|
|
@@ -65241,7 +65943,7 @@ async function unwire(ctx) {
|
|
|
65241
65943
|
say(
|
|
65242
65944
|
ctx,
|
|
65243
65945
|
c.hermesNoCli(
|
|
65244
|
-
tilde(ctx,
|
|
65946
|
+
tilde(ctx, join51(hermesHome(ctx.userHome, ctx.env), "config.yaml"))
|
|
65245
65947
|
)
|
|
65246
65948
|
);
|
|
65247
65949
|
if (r.openclawNoCli) say(ctx, c.openclawNoCli());
|
|
@@ -65275,7 +65977,7 @@ async function uninstall2(opts, ctx) {
|
|
|
65275
65977
|
say(ctx, c.daemonStillRunning(removed.running));
|
|
65276
65978
|
if (wiredTo(ctx)) await unwire(ctx);
|
|
65277
65979
|
if (!opts.purge) {
|
|
65278
|
-
say(ctx, "", c.kept(tilde(ctx,
|
|
65980
|
+
say(ctx, "", c.kept(tilde(ctx, join51(ctx.home, "machine.json"))));
|
|
65279
65981
|
return 0;
|
|
65280
65982
|
}
|
|
65281
65983
|
const home2 = tilde(ctx, ctx.home);
|
|
@@ -65285,9 +65987,9 @@ async function uninstall2(opts, ctx) {
|
|
|
65285
65987
|
return 1;
|
|
65286
65988
|
} catch {
|
|
65287
65989
|
}
|
|
65288
|
-
const made = readMade(
|
|
65990
|
+
const made = readMade(join51(ctx.home, "install.json"));
|
|
65289
65991
|
const out = purge(ctx.home, {
|
|
65290
|
-
isDefault: ctx.home ===
|
|
65992
|
+
isDefault: ctx.home === join51(ctx.userHome, ".oa-bus")
|
|
65291
65993
|
});
|
|
65292
65994
|
if ("refused" in out) {
|
|
65293
65995
|
sayErr(ctx, c.purgeRefused(home2));
|
|
@@ -65337,6 +66039,15 @@ async function update(ctx, installStaged) {
|
|
|
65337
66039
|
return 1;
|
|
65338
66040
|
}
|
|
65339
66041
|
if (!await installStaged(version2)) return 1;
|
|
66042
|
+
const m = readMachine(ctx.home);
|
|
66043
|
+
if (m.state === "ok" && ctx.which("claude") && wiredTo(ctx))
|
|
66044
|
+
recordClaudeProof({
|
|
66045
|
+
home: ctx.userHome,
|
|
66046
|
+
busHome: ctx.home,
|
|
66047
|
+
env: ctx.env,
|
|
66048
|
+
busBin: ctx.service.argv?.() ?? [],
|
|
66049
|
+
hub: originOf2(m.hub)
|
|
66050
|
+
});
|
|
65340
66051
|
say(ctx, c.updateDone(version2));
|
|
65341
66052
|
return 0;
|
|
65342
66053
|
}
|
|
@@ -65615,7 +66326,7 @@ async function main(argv, makeCtx = realCtx) {
|
|
|
65615
66326
|
return 2;
|
|
65616
66327
|
}
|
|
65617
66328
|
const ctx = makeCtx(cmd.noColor);
|
|
65618
|
-
if (cmd.home) ctx.home =
|
|
66329
|
+
if (cmd.home) ctx.home = resolve17(cmd.home);
|
|
65619
66330
|
if (!TERMINAL.has(cmd.cmd) && cmd.cmd !== "install" && cmd.cmd !== "uninstall")
|
|
65620
66331
|
markLive(fileURLToPath7(import.meta.url), ctx.home);
|
|
65621
66332
|
ctx.copy = copyFor(ctx);
|