@open-artifacts/bus 0.214.1 → 0.216.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/oa-bus.ts +1 -1
- package/assets/openclaw/index.js +1 -1
- package/assets/openclaw/package.json +1 -1
- package/dist/index.js +938 -671
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -32854,7 +32854,7 @@ var init_frames = __esm({
|
|
|
32854
32854
|
late = { late: external_exports.array(external_exports.string().min(1)).optional() };
|
|
32855
32855
|
isWellFormed2 = (s) => s.isWellFormed();
|
|
32856
32856
|
WELL_FORMED = { message: "text is not well-formed unicode" };
|
|
32857
|
-
CLIENT_VERSION = true ? "0.
|
|
32857
|
+
CLIENT_VERSION = true ? "0.216.0" : "0.0.0";
|
|
32858
32858
|
clientVersion = {
|
|
32859
32859
|
client_version: external_exports.string().min(1).max(64).optional()
|
|
32860
32860
|
};
|
|
@@ -37456,7 +37456,7 @@ var require_websocket = __commonJS({
|
|
|
37456
37456
|
var http = __require("http");
|
|
37457
37457
|
var net = __require("net");
|
|
37458
37458
|
var tls = __require("tls");
|
|
37459
|
-
var { randomBytes:
|
|
37459
|
+
var { randomBytes: randomBytes11, createHash: createHash14 } = __require("crypto");
|
|
37460
37460
|
var { Duplex, Readable } = __require("stream");
|
|
37461
37461
|
var { URL: URL2 } = __require("url");
|
|
37462
37462
|
var PerMessageDeflate2 = require_permessage_deflate();
|
|
@@ -37994,7 +37994,7 @@ var require_websocket = __commonJS({
|
|
|
37994
37994
|
}
|
|
37995
37995
|
}
|
|
37996
37996
|
const defaultPort = isSecure ? 443 : 80;
|
|
37997
|
-
const key2 =
|
|
37997
|
+
const key2 = randomBytes11(16).toString("base64");
|
|
37998
37998
|
const request = isSecure ? https.request : http.request;
|
|
37999
37999
|
const protocolSet = /* @__PURE__ */ new Set();
|
|
38000
38000
|
let perMessageDeflate;
|
|
@@ -43925,7 +43925,7 @@ var init_tools2 = __esm({
|
|
|
43925
43925
|
});
|
|
43926
43926
|
|
|
43927
43927
|
// ../bus-adapter-opencode/src/proxy.ts
|
|
43928
|
-
import { createHash as createHash10, randomBytes as
|
|
43928
|
+
import { createHash as createHash10, randomBytes as randomBytes5 } from "node:crypto";
|
|
43929
43929
|
var OpenCodeProxy;
|
|
43930
43930
|
var init_proxy = __esm({
|
|
43931
43931
|
"../bus-adapter-opencode/src/proxy.ts"() {
|
|
@@ -43967,7 +43967,7 @@ var init_proxy = __esm({
|
|
|
43967
43967
|
proofFor(root) {
|
|
43968
43968
|
let p = this.proofs.get(root);
|
|
43969
43969
|
if (p === void 0) {
|
|
43970
|
-
p = (this.deps.random?.() ??
|
|
43970
|
+
p = (this.deps.random?.() ?? randomBytes5(32)).toString("base64url");
|
|
43971
43971
|
if (this.proofs.size >= PROOFS_MAX) {
|
|
43972
43972
|
const oldest = this.proofs.keys().next().value;
|
|
43973
43973
|
if (oldest !== void 0) this.proofs.delete(oldest);
|
|
@@ -44204,7 +44204,7 @@ var init_stdio2 = __esm({
|
|
|
44204
44204
|
|
|
44205
44205
|
// ../bus-adapter-claude-code/src/main.ts
|
|
44206
44206
|
var main_exports = {};
|
|
44207
|
-
import { existsSync as
|
|
44207
|
+
import { existsSync as existsSync17 } from "node:fs";
|
|
44208
44208
|
var SESSIONS, connect4, server, underClaude;
|
|
44209
44209
|
var init_main = __esm({
|
|
44210
44210
|
async "../bus-adapter-claude-code/src/main.ts"() {
|
|
@@ -44229,7 +44229,7 @@ var init_main = __esm({
|
|
|
44229
44229
|
}),
|
|
44230
44230
|
// A short socket folder another user could reach is never dialed.
|
|
44231
44231
|
socketDirProblem: () => socketDirProblem(HOME3),
|
|
44232
|
-
socketExists: () =>
|
|
44232
|
+
socketExists: () => existsSync17(SOCKET3),
|
|
44233
44233
|
connect: (session) => connectDaemon({
|
|
44234
44234
|
path: SOCKET3,
|
|
44235
44235
|
hello: sessionHello(session, process.pid, process.cwd())
|
|
@@ -44339,7 +44339,7 @@ var init_codex_main = __esm({
|
|
|
44339
44339
|
});
|
|
44340
44340
|
|
|
44341
44341
|
// ../bus-adapter-claude-code/src/codex-proxy.ts
|
|
44342
|
-
import { createHash as createHash13, randomBytes as
|
|
44342
|
+
import { createHash as createHash13, randomBytes as randomBytes10 } from "node:crypto";
|
|
44343
44343
|
var EXEC_CALL2, CodexProxy;
|
|
44344
44344
|
var init_codex_proxy = __esm({
|
|
44345
44345
|
"../bus-adapter-claude-code/src/codex-proxy.ts"() {
|
|
@@ -44378,7 +44378,7 @@ var init_codex_proxy = __esm({
|
|
|
44378
44378
|
proofFor(thread) {
|
|
44379
44379
|
let p = this.proofs.get(thread);
|
|
44380
44380
|
if (p === void 0) {
|
|
44381
|
-
p = (this.deps.random?.() ??
|
|
44381
|
+
p = (this.deps.random?.() ?? randomBytes10(32)).toString("base64url");
|
|
44382
44382
|
if (this.proofs.size >= PROOFS_MAX) {
|
|
44383
44383
|
const oldest = this.proofs.keys().next().value;
|
|
44384
44384
|
if (oldest !== void 0) this.proofs.delete(oldest);
|
|
@@ -44453,13 +44453,13 @@ __export(codex_proxy_main_exports, {
|
|
|
44453
44453
|
readTokenFile: () => readTokenFile,
|
|
44454
44454
|
startCodexProxy: () => startCodexProxy
|
|
44455
44455
|
});
|
|
44456
|
-
import { readFileSync as
|
|
44456
|
+
import { readFileSync as readFileSync43 } from "node:fs";
|
|
44457
44457
|
import { homedir as homedir4 } from "node:os";
|
|
44458
44458
|
function readTokenFile(path) {
|
|
44459
44459
|
if (!path) return void 0;
|
|
44460
44460
|
try {
|
|
44461
44461
|
const p = path.startsWith("~/") ? `${homedir4()}${path.slice(1)}` : path;
|
|
44462
|
-
return
|
|
44462
|
+
return readFileSync43(p, "utf8").trim() || void 0;
|
|
44463
44463
|
} catch {
|
|
44464
44464
|
return void 0;
|
|
44465
44465
|
}
|
|
@@ -44509,13 +44509,13 @@ __export(proxy_main_exports, {
|
|
|
44509
44509
|
readTokenFile: () => readTokenFile2,
|
|
44510
44510
|
startProxy: () => startProxy
|
|
44511
44511
|
});
|
|
44512
|
-
import { readFileSync as
|
|
44512
|
+
import { readFileSync as readFileSync44 } from "node:fs";
|
|
44513
44513
|
import { homedir as homedir5 } from "node:os";
|
|
44514
44514
|
function readTokenFile2(path) {
|
|
44515
44515
|
if (!path) return void 0;
|
|
44516
44516
|
try {
|
|
44517
44517
|
const p = path.startsWith("~/") ? `${homedir5()}${path.slice(1)}` : path;
|
|
44518
|
-
return
|
|
44518
|
+
return readFileSync44(p, "utf8").trim() || void 0;
|
|
44519
44519
|
} catch {
|
|
44520
44520
|
return void 0;
|
|
44521
44521
|
}
|
|
@@ -44608,9 +44608,9 @@ import { fileURLToPath as fileURLToPath7 } from "node:url";
|
|
|
44608
44608
|
|
|
44609
44609
|
// ../bus-daemon/src/index.ts
|
|
44610
44610
|
init_src3();
|
|
44611
|
-
import { randomBytes as
|
|
44612
|
-
import { existsSync as
|
|
44613
|
-
import { basename as basename6, isAbsolute as isAbsolute7, join as
|
|
44611
|
+
import { randomBytes as randomBytes4 } from "node:crypto";
|
|
44612
|
+
import { existsSync as existsSync7, lstatSync as lstatSync9, realpathSync as realpathSync9, writeFileSync as writeFileSync12 } from "node:fs";
|
|
44613
|
+
import { basename as basename6, isAbsolute as isAbsolute7, join as join24 } from "node:path";
|
|
44614
44614
|
|
|
44615
44615
|
// ../bus-adapter-opencode/src/version.ts
|
|
44616
44616
|
var MIN_PROMPT_ID_VERSION = "2.0.0";
|
|
@@ -44651,7 +44651,7 @@ init_src2();
|
|
|
44651
44651
|
init_src();
|
|
44652
44652
|
|
|
44653
44653
|
// ../bus-daemon/src/agents.ts
|
|
44654
|
-
var LINK_HASHES_MAX =
|
|
44654
|
+
var LINK_HASHES_MAX = 16;
|
|
44655
44655
|
var withLinkHash = (list, hash2) => [...(list ?? []).filter((h) => h !== hash2), hash2].slice(-LINK_HASHES_MAX);
|
|
44656
44656
|
var AgentTable = class {
|
|
44657
44657
|
#byRef = /* @__PURE__ */ new Map();
|
|
@@ -44835,8 +44835,8 @@ function savedToken(h = home()) {
|
|
|
44835
44835
|
return void 0;
|
|
44836
44836
|
}
|
|
44837
44837
|
}
|
|
44838
|
-
function readConfig() {
|
|
44839
|
-
const file2 = join3(
|
|
44838
|
+
function readConfig(h = home()) {
|
|
44839
|
+
const file2 = join3(h, "machine.json");
|
|
44840
44840
|
let text3;
|
|
44841
44841
|
try {
|
|
44842
44842
|
if (process.platform !== "win32" && statSync2(file2).mode & 63) {
|
|
@@ -44868,7 +44868,7 @@ function readConfig() {
|
|
|
44868
44868
|
const r = raw;
|
|
44869
44869
|
if (typeof r.hub !== "string" || !r.hub || r.machine_token === void 0)
|
|
44870
44870
|
throw notLoggedIn();
|
|
44871
|
-
if (revokedFor(String(r.machine_token)))
|
|
44871
|
+
if (revokedFor(String(r.machine_token), h))
|
|
44872
44872
|
throw new StartError(
|
|
44873
44873
|
"REVOKED",
|
|
44874
44874
|
`this machine was revoked; run \`${BUS_CMD} install\``
|
|
@@ -52830,12 +52830,148 @@ function createEventLog(file2, opts = {}) {
|
|
|
52830
52830
|
return log;
|
|
52831
52831
|
}
|
|
52832
52832
|
|
|
52833
|
+
// ../bus-daemon/src/instances.ts
|
|
52834
|
+
import { randomBytes as randomBytes3 } from "node:crypto";
|
|
52835
|
+
import {
|
|
52836
|
+
chmodSync as chmodSync15,
|
|
52837
|
+
closeSync as closeSync8,
|
|
52838
|
+
existsSync as existsSync6,
|
|
52839
|
+
linkSync as linkSync2,
|
|
52840
|
+
mkdirSync as mkdirSync9,
|
|
52841
|
+
openSync as openSync8,
|
|
52842
|
+
readdirSync as readdirSync6,
|
|
52843
|
+
readFileSync as readFileSync18,
|
|
52844
|
+
statSync as statSync7,
|
|
52845
|
+
unlinkSync as unlinkSync3,
|
|
52846
|
+
writeSync as writeSync4
|
|
52847
|
+
} from "node:fs";
|
|
52848
|
+
import { join as join22 } from "node:path";
|
|
52849
|
+
var MAIN_INSTANCE = "main";
|
|
52850
|
+
var NAME_RE2 = /^[a-z0-9-]{1,32}$/;
|
|
52851
|
+
function nameProblem(name) {
|
|
52852
|
+
if (name === MAIN_INSTANCE) return `"${MAIN_INSTANCE}" is reserved`;
|
|
52853
|
+
if (!NAME_RE2.test(name))
|
|
52854
|
+
return "a name uses lowercase letters, digits and dashes, 1 to 32 characters";
|
|
52855
|
+
return void 0;
|
|
52856
|
+
}
|
|
52857
|
+
var instancesDir = (h = home()) => join22(h, "instances");
|
|
52858
|
+
var instanceFile = (name, h = home()) => join22(instancesDir(h), `${name}.json`);
|
|
52859
|
+
function canonicalAddress(address) {
|
|
52860
|
+
try {
|
|
52861
|
+
const u = new URL(address.replace(/^ws(s?):/, "http$1:"));
|
|
52862
|
+
return `${u.origin}${u.pathname.replace(/\/+$/, "")}`;
|
|
52863
|
+
} catch {
|
|
52864
|
+
return void 0;
|
|
52865
|
+
}
|
|
52866
|
+
}
|
|
52867
|
+
function mainAddress(h) {
|
|
52868
|
+
try {
|
|
52869
|
+
const r = JSON.parse(readFileSync18(join22(h, "machine.json"), "utf8"));
|
|
52870
|
+
return typeof r.hub === "string" ? r.hub : void 0;
|
|
52871
|
+
} catch {
|
|
52872
|
+
return void 0;
|
|
52873
|
+
}
|
|
52874
|
+
}
|
|
52875
|
+
function addedNames(h) {
|
|
52876
|
+
let files2;
|
|
52877
|
+
try {
|
|
52878
|
+
files2 = readdirSync6(instancesDir(h));
|
|
52879
|
+
} catch {
|
|
52880
|
+
return [];
|
|
52881
|
+
}
|
|
52882
|
+
return files2.filter((f) => f.endsWith(".json")).map((f) => f.slice(0, -".json".length)).filter((n) => NAME_RE2.test(n) && n !== MAIN_INSTANCE).sort();
|
|
52883
|
+
}
|
|
52884
|
+
function listInstances(h = home()) {
|
|
52885
|
+
const list = [];
|
|
52886
|
+
const main2 = mainAddress(h);
|
|
52887
|
+
const added = addedNames(h);
|
|
52888
|
+
if (main2 !== void 0 || added.length === 0)
|
|
52889
|
+
list.push({ name: MAIN_INSTANCE, hub: main2 ?? "", main: true });
|
|
52890
|
+
for (const name of added) {
|
|
52891
|
+
let hub = "";
|
|
52892
|
+
try {
|
|
52893
|
+
const r = JSON.parse(readFileSync18(instanceFile(name, h), "utf8"));
|
|
52894
|
+
if (typeof r.hub === "string") hub = r.hub;
|
|
52895
|
+
} catch {
|
|
52896
|
+
}
|
|
52897
|
+
list.push({ name, hub, main: false });
|
|
52898
|
+
}
|
|
52899
|
+
return list;
|
|
52900
|
+
}
|
|
52901
|
+
function addProblem(name, address, h = home()) {
|
|
52902
|
+
const bad2 = nameProblem(name);
|
|
52903
|
+
if (bad2) return bad2;
|
|
52904
|
+
if (existsSync6(instanceFile(name, h)))
|
|
52905
|
+
return `an instance named ${name} already exists`;
|
|
52906
|
+
const want = canonicalAddress(address);
|
|
52907
|
+
const main2 = mainAddress(h);
|
|
52908
|
+
if (want !== void 0 && main2 !== void 0 && canonicalAddress(main2) === want)
|
|
52909
|
+
return `that address is already this machine's main instance`;
|
|
52910
|
+
for (const i of listInstances(h))
|
|
52911
|
+
if (!i.main && want !== void 0 && canonicalAddress(i.hub) === want)
|
|
52912
|
+
return `that address is already the instance ${i.name}`;
|
|
52913
|
+
return void 0;
|
|
52914
|
+
}
|
|
52915
|
+
function suggestName(address, h = home()) {
|
|
52916
|
+
let base3 = "instance";
|
|
52917
|
+
try {
|
|
52918
|
+
const host = new URL(address).hostname.split(".")[0] ?? "";
|
|
52919
|
+
const fit = host.toLowerCase().replace(/[^a-z0-9-]/g, "-").replace(/^-+|-+$/g, "").slice(0, 28);
|
|
52920
|
+
if (fit && fit !== MAIN_INSTANCE) base3 = fit;
|
|
52921
|
+
} catch {
|
|
52922
|
+
}
|
|
52923
|
+
let name = base3;
|
|
52924
|
+
for (let n = 2; existsSync6(instanceFile(name, h)); n++) name = `${base3}-${n}`;
|
|
52925
|
+
return name;
|
|
52926
|
+
}
|
|
52927
|
+
function saveInstance(c, h = home()) {
|
|
52928
|
+
const problem = addProblem(c.name, c.hub, h);
|
|
52929
|
+
if (problem) throw new Error(problem);
|
|
52930
|
+
checkHub(c.hub);
|
|
52931
|
+
const dir = instancesDir(h);
|
|
52932
|
+
mkdirSync9(h, { recursive: true, mode: 448 });
|
|
52933
|
+
mkdirSync9(dir, { recursive: true, mode: 448 });
|
|
52934
|
+
chmodSync15(dir, 448);
|
|
52935
|
+
const tmp = join22(dir, `.${c.name}.${randomBytes3(8).toString("hex")}.tmp`);
|
|
52936
|
+
const fd = openSync8(tmp, "wx", 384);
|
|
52937
|
+
try {
|
|
52938
|
+
writeSync4(
|
|
52939
|
+
fd,
|
|
52940
|
+
`${JSON.stringify(
|
|
52941
|
+
{
|
|
52942
|
+
name: c.name,
|
|
52943
|
+
hub: c.hub,
|
|
52944
|
+
machine_id: c.machine_id,
|
|
52945
|
+
label: c.label,
|
|
52946
|
+
machine_token: c.machine_token
|
|
52947
|
+
},
|
|
52948
|
+
null,
|
|
52949
|
+
2
|
|
52950
|
+
)}
|
|
52951
|
+
`
|
|
52952
|
+
);
|
|
52953
|
+
} catch (e) {
|
|
52954
|
+
closeSync8(fd);
|
|
52955
|
+
unlinkSync3(tmp);
|
|
52956
|
+
throw e;
|
|
52957
|
+
}
|
|
52958
|
+
closeSync8(fd);
|
|
52959
|
+
try {
|
|
52960
|
+
chmodSync15(tmp, 384);
|
|
52961
|
+
linkSync2(tmp, instanceFile(c.name, h));
|
|
52962
|
+
} catch (e) {
|
|
52963
|
+
unlinkSync3(tmp);
|
|
52964
|
+
throw e;
|
|
52965
|
+
}
|
|
52966
|
+
unlinkSync3(tmp);
|
|
52967
|
+
}
|
|
52968
|
+
|
|
52833
52969
|
// ../bus-daemon/src/leads/templates.ts
|
|
52834
52970
|
init_src();
|
|
52835
|
-
import { lstatSync as lstatSync8, readdirSync as
|
|
52836
|
-
import { join as
|
|
52837
|
-
var leadsDir = (h = home()) =>
|
|
52838
|
-
var leadTemplateFile = (name, h = home()) =>
|
|
52971
|
+
import { lstatSync as lstatSync8, readdirSync as readdirSync7, realpathSync as realpathSync8, statSync as statSync8 } from "node:fs";
|
|
52972
|
+
import { join as join23 } from "node:path";
|
|
52973
|
+
var leadsDir = (h = home()) => join23(h, "leads");
|
|
52974
|
+
var leadTemplateFile = (name, h = home()) => join23(leadsDir(h), `${name}.json`);
|
|
52839
52975
|
var CONTROL_RE = /[\u0000-\u001f\u007f-\u009f]/g;
|
|
52840
52976
|
var tame = (s) => {
|
|
52841
52977
|
const t = s.replace(CONTROL_RE, "?");
|
|
@@ -52874,7 +53010,7 @@ function checkRealDir(path, label2, uid, group) {
|
|
|
52874
53010
|
if (real3 !== path)
|
|
52875
53011
|
return `${label2} is not its own real path (a symlink or alias)`;
|
|
52876
53012
|
try {
|
|
52877
|
-
const st =
|
|
53013
|
+
const st = statSync8(real3);
|
|
52878
53014
|
if (!st.isDirectory()) return `${label2} is not a folder`;
|
|
52879
53015
|
if (uid !== void 0 && st.uid !== uid)
|
|
52880
53016
|
return `${label2} belongs to another user`;
|
|
@@ -52889,7 +53025,7 @@ function checkRealDir(path, label2, uid, group) {
|
|
|
52889
53025
|
}
|
|
52890
53026
|
function checkBinary(path, uid) {
|
|
52891
53027
|
try {
|
|
52892
|
-
const st =
|
|
53028
|
+
const st = statSync8(path);
|
|
52893
53029
|
if (!st.isFile()) return "binary is not a regular file";
|
|
52894
53030
|
if (uid !== void 0 && st.uid !== uid && st.uid !== 0)
|
|
52895
53031
|
return "binary belongs to another user";
|
|
@@ -52952,7 +53088,7 @@ function listLeadTemplateNames(h = home()) {
|
|
|
52952
53088
|
if (state !== void 0) return [];
|
|
52953
53089
|
let entries;
|
|
52954
53090
|
try {
|
|
52955
|
-
entries =
|
|
53091
|
+
entries = readdirSync7(dir);
|
|
52956
53092
|
} catch {
|
|
52957
53093
|
return [];
|
|
52958
53094
|
}
|
|
@@ -52970,7 +53106,7 @@ var RENAME_HOLD_MS = 60 * 6e4;
|
|
|
52970
53106
|
var RENAME_WINDOW_MS = 6e4;
|
|
52971
53107
|
var RENAME_WINDOW_MAX = 3;
|
|
52972
53108
|
var LIMITED_RETRY_MS = 5 * 6e4;
|
|
52973
|
-
var PENDING_PROOF_MS = 6e4;
|
|
53109
|
+
var PENDING_PROOF_MS = 10 * 6e4;
|
|
52974
53110
|
var PENDING_PROOF_MAX = 64;
|
|
52975
53111
|
var LINK_GRACE_MS = 2 * 6e4;
|
|
52976
53112
|
var UNBOUND_PROOFS_MAX = 10;
|
|
@@ -53111,7 +53247,7 @@ async function runDaemon(deps2 = {}) {
|
|
|
53111
53247
|
within2 = new Set(configPaths(cwd));
|
|
53112
53248
|
}
|
|
53113
53249
|
const rr = gitRecordRoot(cwd);
|
|
53114
|
-
if (rr) within2.add(
|
|
53250
|
+
if (rr) within2.add(join24(rr, ".git"));
|
|
53115
53251
|
}
|
|
53116
53252
|
return [
|
|
53117
53253
|
...configIssues.list(within2, { pending: pending2 }),
|
|
@@ -53139,7 +53275,7 @@ async function runDaemon(deps2 = {}) {
|
|
|
53139
53275
|
procStart: cachedProcStart(cl.procStart ?? claudeProcStartOf, running),
|
|
53140
53276
|
isRunning: running
|
|
53141
53277
|
};
|
|
53142
|
-
const linksFile = cl.linksFile ??
|
|
53278
|
+
const linksFile = cl.linksFile ?? join24(home(), "claude-links.json");
|
|
53143
53279
|
const sameProc = (pid, procStart) => running(pid) && claudeSessions.procStart(pid, procStart) === procStart;
|
|
53144
53280
|
let saved = readClaudeLinks(linksFile, void 0, log).filter(
|
|
53145
53281
|
(e) => sameProc(e.pid, e.procStart)
|
|
@@ -53225,7 +53361,7 @@ async function runDaemon(deps2 = {}) {
|
|
|
53225
53361
|
log,
|
|
53226
53362
|
promptIdSupported: () => promptIdSupported,
|
|
53227
53363
|
uncertain: new HeldStore(
|
|
53228
|
-
oc.uncertainFile ??
|
|
53364
|
+
oc.uncertainFile ?? join24(home(), "opencode-uncertain.json")
|
|
53229
53365
|
)
|
|
53230
53366
|
});
|
|
53231
53367
|
const codexIndexHome = cx.home ?? codexHome();
|
|
@@ -53235,7 +53371,7 @@ async function runDaemon(deps2 = {}) {
|
|
|
53235
53371
|
});
|
|
53236
53372
|
const codexTaken = new TakenWatch({
|
|
53237
53373
|
home: codexIndexHome,
|
|
53238
|
-
file: cx.takenFile ??
|
|
53374
|
+
file: cx.takenFile ?? join24(home(), "codex-pending.json"),
|
|
53239
53375
|
onTaken: (id, unsent) => sendCodexAck(id, unsent),
|
|
53240
53376
|
log
|
|
53241
53377
|
});
|
|
@@ -53260,7 +53396,7 @@ async function runDaemon(deps2 = {}) {
|
|
|
53260
53396
|
},
|
|
53261
53397
|
ackTimeoutMs: deps2.pi?.ackTimeoutMs
|
|
53262
53398
|
});
|
|
53263
|
-
const sent = new SentStore(deps2.sentFile ??
|
|
53399
|
+
const sent = new SentStore(deps2.sentFile ?? join24(home(), "sent.json"), {
|
|
53264
53400
|
log
|
|
53265
53401
|
});
|
|
53266
53402
|
const receipts = new Receipts(sent, { after: deps2.deliveredTimer });
|
|
@@ -53380,8 +53516,8 @@ async function runDaemon(deps2 = {}) {
|
|
|
53380
53516
|
socketsDir: returnDir,
|
|
53381
53517
|
// A deps.socketsDir is the caller's (tests); ours is re-checked before each bind.
|
|
53382
53518
|
prepareDir: cl.socketsDir ? void 0 : (d) => prepareReturnDir(d),
|
|
53383
|
-
heldFile: cl.heldFile ??
|
|
53384
|
-
returnIndexFile: cl.returnIndexFile ?? (cl.heldFile ? cl.heldFile.replace(/(\.json)?$/, ".return.json") :
|
|
53519
|
+
heldFile: cl.heldFile ?? join24(home(), "claude-held.json"),
|
|
53520
|
+
returnIndexFile: cl.returnIndexFile ?? (cl.heldFile ? cl.heldFile.replace(/(\.json)?$/, ".return.json") : join24(home(), "claude-return.json")),
|
|
53385
53521
|
statusWindowMs: cl.statusWindowMs,
|
|
53386
53522
|
injectTimeoutMs: cl.injectTimeoutMs,
|
|
53387
53523
|
log,
|
|
@@ -53914,7 +54050,7 @@ async function runDaemon(deps2 = {}) {
|
|
|
53914
54050
|
process.exitCode = 1;
|
|
53915
54051
|
try {
|
|
53916
54052
|
writeFileSync12(
|
|
53917
|
-
deps2.revokedFile ??
|
|
54053
|
+
deps2.revokedFile ?? join24(home(), "revoked"),
|
|
53918
54054
|
revokedMarker(cfg.machine_token),
|
|
53919
54055
|
{ mode: 384 }
|
|
53920
54056
|
);
|
|
@@ -54207,7 +54343,7 @@ async function runDaemon(deps2 = {}) {
|
|
|
54207
54343
|
if (held2 && (held2.kind !== hello.kind || !piLike(hello.kind) || held2.token !== hello.bind_token))
|
|
54208
54344
|
return { error: REF_BOUND };
|
|
54209
54345
|
if (piLike(hello.kind))
|
|
54210
|
-
bindToken = held2?.token ??
|
|
54346
|
+
bindToken = held2?.token ?? randomBytes4(24).toString("base64url");
|
|
54211
54347
|
const bound2 = () => {
|
|
54212
54348
|
if (bindToken === void 0) return {};
|
|
54213
54349
|
bindings.set(hello.agent_ref, {
|
|
@@ -54456,7 +54592,7 @@ async function runDaemon(deps2 = {}) {
|
|
|
54456
54592
|
deps2.onSocketLost?.();
|
|
54457
54593
|
}, deps2.socketCheckMs ?? 6e4);
|
|
54458
54594
|
socketWatch.unref();
|
|
54459
|
-
const codexAgentsFile = cx.agentsFile ??
|
|
54595
|
+
const codexAgentsFile = cx.agentsFile ?? join24(home(), "codex-agents.json");
|
|
54460
54596
|
let codexSaved;
|
|
54461
54597
|
const restorePending = /* @__PURE__ */ new Map();
|
|
54462
54598
|
const persistCodex = () => {
|
|
@@ -54582,7 +54718,7 @@ async function runDaemon(deps2 = {}) {
|
|
|
54582
54718
|
};
|
|
54583
54719
|
attempt2(readCodexAgents(codexAgentsFile), 0);
|
|
54584
54720
|
};
|
|
54585
|
-
const awayFile = cx.awayFile ??
|
|
54721
|
+
const awayFile = cx.awayFile ?? join24(home(), "codex-away.json");
|
|
54586
54722
|
const awayNow = deps2.bindingNow ?? Date.now;
|
|
54587
54723
|
const HOUR = 36e5;
|
|
54588
54724
|
const awayRows = new Map(
|
|
@@ -54620,7 +54756,7 @@ async function runDaemon(deps2 = {}) {
|
|
|
54620
54756
|
}
|
|
54621
54757
|
};
|
|
54622
54758
|
const woken = new HeldStore(
|
|
54623
|
-
cx.wokenFile ??
|
|
54759
|
+
cx.wokenFile ?? join24(home(), "codex-woken.json"),
|
|
54624
54760
|
{ ttlMs: 7 * 24 * HOUR }
|
|
54625
54761
|
);
|
|
54626
54762
|
const wakeLogged = /* @__PURE__ */ new Set();
|
|
@@ -54858,7 +54994,7 @@ async function runDaemon(deps2 = {}) {
|
|
|
54858
54994
|
running: runVersion,
|
|
54859
54995
|
hub: () => hub.open && hubHelloed,
|
|
54860
54996
|
// Socket bound, and every live session announced and answered.
|
|
54861
|
-
local: () =>
|
|
54997
|
+
local: () => existsSync7(listenPath) && upIds.size === 0,
|
|
54862
54998
|
exit: upd.exit,
|
|
54863
54999
|
log,
|
|
54864
55000
|
...upd.every ? { every: upd.every } : {},
|
|
@@ -54955,7 +55091,7 @@ init_src();
|
|
|
54955
55091
|
// src/context.ts
|
|
54956
55092
|
init_src3();
|
|
54957
55093
|
import { execFileSync as execFileSync6, spawn as spawn2 } from "node:child_process";
|
|
54958
|
-
import { closeSync as
|
|
55094
|
+
import { closeSync as closeSync9, openSync as openSync9, readFileSync as readFileSync22 } from "node:fs";
|
|
54959
55095
|
import { homedir as homedir3, userInfo as userInfo2 } from "node:os";
|
|
54960
55096
|
import { createInterface as createInterface2 } from "node:readline";
|
|
54961
55097
|
init_src2();
|
|
@@ -55454,6 +55590,7 @@ function copy(style, bus = BUS_CMD, approve) {
|
|
|
55454
55590
|
"Commands",
|
|
55455
55591
|
" install Approve this machine, wire your harnesses, start the daemon (the default)",
|
|
55456
55592
|
" login Approve this machine again",
|
|
55593
|
+
" add <address> [--name <name>]: connect a second instance from a terminal",
|
|
55457
55594
|
" skill Save this instance's skill for your harnesses (--check only reports)",
|
|
55458
55595
|
" uninstall Remove what install added",
|
|
55459
55596
|
" status Who is on the bus, from this folder",
|
|
@@ -55482,6 +55619,8 @@ function copy(style, bus = BUS_CMD, approve) {
|
|
|
55482
55619
|
" --json the result as one JSON line on stdout",
|
|
55483
55620
|
" --yes, -y answer yes where install asks",
|
|
55484
55621
|
" login --instance <url>, --no-open",
|
|
55622
|
+
" add --name <name> the local name for the instance (default: from its address)",
|
|
55623
|
+
" --no-open do not open a browser for approval",
|
|
55485
55624
|
" daemon --instance <url>",
|
|
55486
55625
|
" uninstall --purge also delete the bus home and what install made",
|
|
55487
55626
|
" namespace --yes, -y approve without asking (namespace approve)",
|
|
@@ -56158,13 +56297,13 @@ var realDeps = {
|
|
|
56158
56297
|
// src/steps/service.ts
|
|
56159
56298
|
import { createHash as createHash9 } from "node:crypto";
|
|
56160
56299
|
import {
|
|
56161
|
-
chmodSync as
|
|
56300
|
+
chmodSync as chmodSync18,
|
|
56162
56301
|
cpSync,
|
|
56163
|
-
existsSync as
|
|
56302
|
+
existsSync as existsSync8,
|
|
56164
56303
|
lstatSync as lstatSync11,
|
|
56165
|
-
mkdirSync as
|
|
56166
|
-
readdirSync as
|
|
56167
|
-
readFileSync as
|
|
56304
|
+
mkdirSync as mkdirSync12,
|
|
56305
|
+
readdirSync as readdirSync8,
|
|
56306
|
+
readFileSync as readFileSync21,
|
|
56168
56307
|
realpathSync as realpathSync10,
|
|
56169
56308
|
renameSync as renameSync16,
|
|
56170
56309
|
rmSync as rmSync11,
|
|
@@ -56176,7 +56315,7 @@ import {
|
|
|
56176
56315
|
delimiter as delimiter2,
|
|
56177
56316
|
dirname as dirname11,
|
|
56178
56317
|
isAbsolute as isAbsolute8,
|
|
56179
|
-
join as
|
|
56318
|
+
join as join27,
|
|
56180
56319
|
relative as relative4,
|
|
56181
56320
|
resolve as resolve5
|
|
56182
56321
|
} from "node:path";
|
|
@@ -56184,8 +56323,8 @@ import { fileURLToPath } from "node:url";
|
|
|
56184
56323
|
init_src();
|
|
56185
56324
|
|
|
56186
56325
|
// src/steps/codex.ts
|
|
56187
|
-
import { lstatSync as lstatSync10, readFileSync as
|
|
56188
|
-
import { join as
|
|
56326
|
+
import { lstatSync as lstatSync10, readFileSync as readFileSync19 } from "node:fs";
|
|
56327
|
+
import { join as join25, resolve as resolve4 } from "node:path";
|
|
56189
56328
|
|
|
56190
56329
|
// ../../node_modules/.pnpm/smol-toml@1.9.1/node_modules/smol-toml/dist/error.js
|
|
56191
56330
|
function getLineColFromPtr(string4, ptr) {
|
|
@@ -56947,12 +57086,12 @@ var HAS_WELLFORMED = !!"".isWellFormed;
|
|
|
56947
57086
|
|
|
56948
57087
|
// src/steps/codex.ts
|
|
56949
57088
|
var CODEX_ENTRY = "oa_bus";
|
|
56950
|
-
var codexHome2 = (home2, env2) => env2.CODEX_HOME ? resolve4(env2.CODEX_HOME) :
|
|
57089
|
+
var codexHome2 = (home2, env2) => env2.CODEX_HOME ? resolve4(env2.CODEX_HOME) : join25(home2, ".codex");
|
|
56951
57090
|
function codexHomeEnv(home2, env2) {
|
|
56952
57091
|
const dir = codexHome2(home2, env2);
|
|
56953
|
-
return dir ===
|
|
57092
|
+
return dir === join25(home2, ".codex") ? {} : { CODEX_HOME: dir };
|
|
56954
57093
|
}
|
|
56955
|
-
var codexConfig = (home2, env2) =>
|
|
57094
|
+
var codexConfig = (home2, env2) => join25(codexHome2(home2, env2), "config.toml");
|
|
56956
57095
|
function hasCodex(o) {
|
|
56957
57096
|
if (o.which("codex")) return true;
|
|
56958
57097
|
try {
|
|
@@ -56966,7 +57105,7 @@ var findCodexBin = (o) => resolveCodexBin({ ...o, app: o.app ?? null })?.path;
|
|
|
56966
57105
|
function readToml(path) {
|
|
56967
57106
|
let text3;
|
|
56968
57107
|
try {
|
|
56969
|
-
text3 =
|
|
57108
|
+
text3 = readFileSync19(path, "utf8");
|
|
56970
57109
|
} catch (e) {
|
|
56971
57110
|
if (e.code === "ENOENT")
|
|
56972
57111
|
return { text: "", doc: {} };
|
|
@@ -56986,7 +57125,7 @@ function codexEntry(busBin, home2, busHome2) {
|
|
|
56986
57125
|
return {
|
|
56987
57126
|
command: busBin[0],
|
|
56988
57127
|
args: [...busBin.slice(1), "mcp", "codex"],
|
|
56989
|
-
...ob ===
|
|
57128
|
+
...ob === join25(home2, ".oa-bus") ? {} : { env: { OA_BUS_HOME: ob } },
|
|
56990
57129
|
default_tools_approval_mode: "approve"
|
|
56991
57130
|
};
|
|
56992
57131
|
}
|
|
@@ -57012,7 +57151,7 @@ function sandboxRisk(doc, home2, codexDir) {
|
|
|
57012
57151
|
});
|
|
57013
57152
|
const covers = (root) => {
|
|
57014
57153
|
const r = resolve4(
|
|
57015
|
-
root === "~" ? home2 : root.startsWith("~/") ?
|
|
57154
|
+
root === "~" ? home2 : root.startsWith("~/") ? join25(home2, root.slice(2)) : root
|
|
57016
57155
|
);
|
|
57017
57156
|
return r === "/" || codexDir === r || codexDir.startsWith(`${r}/`) || r.startsWith(`${codexDir}/`);
|
|
57018
57157
|
};
|
|
@@ -57232,16 +57371,16 @@ async function readCodexVersion(o) {
|
|
|
57232
57371
|
|
|
57233
57372
|
// src/steps/rescue.ts
|
|
57234
57373
|
import {
|
|
57235
|
-
chmodSync as
|
|
57236
|
-
mkdirSync as
|
|
57374
|
+
chmodSync as chmodSync16,
|
|
57375
|
+
mkdirSync as mkdirSync10,
|
|
57237
57376
|
renameSync as renameSync14,
|
|
57238
57377
|
rmSync as rmSync10,
|
|
57239
57378
|
writeFileSync as writeFileSync13
|
|
57240
57379
|
} from "node:fs";
|
|
57241
|
-
import { join as
|
|
57380
|
+
import { join as join26 } from "node:path";
|
|
57242
57381
|
var RESCUE_VERSION = 1;
|
|
57243
57382
|
var RESCUE_MAX_STARTS = 2;
|
|
57244
|
-
var rescueOf = (home2) =>
|
|
57383
|
+
var rescueOf = (home2) => join26(home2, "rescue");
|
|
57245
57384
|
function rescueShell() {
|
|
57246
57385
|
return `#!/bin/sh
|
|
57247
57386
|
# Written by oa-bus install, never by an update. Rescue shim ${RESCUE_VERSION}.
|
|
@@ -57343,13 +57482,13 @@ try {
|
|
|
57343
57482
|
`;
|
|
57344
57483
|
}
|
|
57345
57484
|
function writeRescue(home2, launcher) {
|
|
57346
|
-
|
|
57485
|
+
mkdirSync10(home2, { recursive: true, mode: 448 });
|
|
57347
57486
|
const put2 = (name, text3) => {
|
|
57348
|
-
const path =
|
|
57487
|
+
const path = join26(home2, name);
|
|
57349
57488
|
const tmp = `${path}.${process.pid}.tmp`;
|
|
57350
57489
|
try {
|
|
57351
57490
|
writeFileSync13(tmp, text3, { mode: 448 });
|
|
57352
|
-
|
|
57491
|
+
chmodSync16(tmp, 448);
|
|
57353
57492
|
renameSync14(tmp, path);
|
|
57354
57493
|
} catch (e) {
|
|
57355
57494
|
rmSync10(tmp, { force: true });
|
|
@@ -57363,16 +57502,16 @@ function writeRescue(home2, launcher) {
|
|
|
57363
57502
|
|
|
57364
57503
|
// src/steps/step.ts
|
|
57365
57504
|
import {
|
|
57366
|
-
chmodSync as
|
|
57367
|
-
mkdirSync as
|
|
57368
|
-
readFileSync as
|
|
57505
|
+
chmodSync as chmodSync17,
|
|
57506
|
+
mkdirSync as mkdirSync11,
|
|
57507
|
+
readFileSync as readFileSync20,
|
|
57369
57508
|
renameSync as renameSync15,
|
|
57370
57509
|
writeFileSync as writeFileSync14
|
|
57371
57510
|
} from "node:fs";
|
|
57372
57511
|
import { dirname as dirname10 } from "node:path";
|
|
57373
57512
|
function readInstallFile(path) {
|
|
57374
57513
|
try {
|
|
57375
|
-
const v = JSON.parse(
|
|
57514
|
+
const v = JSON.parse(readFileSync20(path, "utf8"));
|
|
57376
57515
|
if (typeof v === "object" && v !== null && !Array.isArray(v))
|
|
57377
57516
|
return v;
|
|
57378
57517
|
} catch {
|
|
@@ -57381,11 +57520,11 @@ function readInstallFile(path) {
|
|
|
57381
57520
|
}
|
|
57382
57521
|
function updateInstallFile(path, patch) {
|
|
57383
57522
|
const next = { ...readInstallFile(path), ...patch };
|
|
57384
|
-
|
|
57523
|
+
mkdirSync11(dirname10(path), { recursive: true, mode: 448 });
|
|
57385
57524
|
const tmp = `${path}.${process.pid}.tmp`;
|
|
57386
57525
|
writeFileSync14(tmp, `${JSON.stringify(next, null, 2)}
|
|
57387
57526
|
`, { mode: 384 });
|
|
57388
|
-
|
|
57527
|
+
chmodSync17(tmp, 384);
|
|
57389
57528
|
renameSync15(tmp, path);
|
|
57390
57529
|
}
|
|
57391
57530
|
async function runSteps(steps, ctx, record7) {
|
|
@@ -57499,7 +57638,7 @@ function cliSource() {
|
|
|
57499
57638
|
jiti: import.meta.resolve("jiti")
|
|
57500
57639
|
} : { kind: "bundle", file: here };
|
|
57501
57640
|
}
|
|
57502
|
-
var entryName = (src) => src.kind === "bundle" ?
|
|
57641
|
+
var entryName = (src) => src.kind === "bundle" ? join27(basename7(dirname11(src.file)), basename7(src.file)) : "oa-bus.js";
|
|
57503
57642
|
var shim = (src) => `// Written by oa-bus install: runs the sources it was installed from.
|
|
57504
57643
|
import { createJiti } from ${JSON.stringify(src.jiti)};
|
|
57505
57644
|
|
|
@@ -57554,12 +57693,12 @@ echo "oa-bus: Node.js ${MIN_NODE} or newer not found. Install it, then run: ${BU
|
|
|
57554
57693
|
exit 127
|
|
57555
57694
|
`;
|
|
57556
57695
|
}
|
|
57557
|
-
var launcherOf = (home2) =>
|
|
57696
|
+
var launcherOf = (home2) => join27(home2, "bin", "node");
|
|
57558
57697
|
function versionOf(src) {
|
|
57559
57698
|
if (src.kind === "dev") return "dev";
|
|
57560
57699
|
try {
|
|
57561
57700
|
const j = JSON.parse(
|
|
57562
|
-
|
|
57701
|
+
readFileSync21(join27(dirname11(dirname11(src.file)), "package.json"), "utf8")
|
|
57563
57702
|
);
|
|
57564
57703
|
if (isSafeVersion(j?.version)) return j.version;
|
|
57565
57704
|
} catch {
|
|
@@ -57567,8 +57706,8 @@ function versionOf(src) {
|
|
|
57567
57706
|
return `unknown-${Date.now()}`;
|
|
57568
57707
|
}
|
|
57569
57708
|
function installCli(home2, src, node2) {
|
|
57570
|
-
|
|
57571
|
-
|
|
57709
|
+
mkdirSync12(home2, { recursive: true, mode: 448 });
|
|
57710
|
+
chmodSync18(home2, 448);
|
|
57572
57711
|
installVersion(
|
|
57573
57712
|
home2,
|
|
57574
57713
|
versionOf(src),
|
|
@@ -57576,23 +57715,23 @@ function installCli(home2, src, node2) {
|
|
|
57576
57715
|
if (src.kind === "bundle") {
|
|
57577
57716
|
const pkg = dirname11(dirname11(src.file));
|
|
57578
57717
|
for (const name of ["dist", "assets", "package.json"])
|
|
57579
|
-
if (
|
|
57580
|
-
cpSync(
|
|
57581
|
-
} else writeFileSync15(
|
|
57582
|
-
|
|
57718
|
+
if (existsSync8(join27(pkg, name)))
|
|
57719
|
+
cpSync(join27(pkg, name), join27(tmp, name), { recursive: true });
|
|
57720
|
+
} else writeFileSync15(join27(tmp, entryName(src)), shim(src));
|
|
57721
|
+
chmodSync18(tmp, 448);
|
|
57583
57722
|
if (node2 !== void 0) {
|
|
57584
|
-
writeFileSync15(
|
|
57585
|
-
|
|
57723
|
+
writeFileSync15(join27(tmp, "node"), launcherText(node2), { mode: 448 });
|
|
57724
|
+
chmodSync18(join27(tmp, "node"), 448);
|
|
57586
57725
|
}
|
|
57587
|
-
if (!
|
|
57588
|
-
writeFileSync15(
|
|
57726
|
+
if (!existsSync8(join27(tmp, "package.json")))
|
|
57727
|
+
writeFileSync15(join27(tmp, "package.json"), '{ "type": "module" }\n');
|
|
57589
57728
|
},
|
|
57590
57729
|
// Without the rescue shim (win32, or no launcher) a failed update could
|
|
57591
57730
|
// not be undone: such an install never arms auto-update (#2552).
|
|
57592
57731
|
{ arm: node2 !== void 0 && process.platform !== "win32" }
|
|
57593
57732
|
);
|
|
57594
57733
|
if (node2 !== void 0) writeRescue(home2, launcherText(node2));
|
|
57595
|
-
return
|
|
57734
|
+
return join27(home2, "bin", entryName(src));
|
|
57596
57735
|
}
|
|
57597
57736
|
var present = (path) => {
|
|
57598
57737
|
try {
|
|
@@ -57603,7 +57742,7 @@ var present = (path) => {
|
|
|
57603
57742
|
}
|
|
57604
57743
|
};
|
|
57605
57744
|
function writeReplacing(path, text3) {
|
|
57606
|
-
|
|
57745
|
+
mkdirSync12(dirname11(path), { recursive: true });
|
|
57607
57746
|
const tmp = `${path}.${process.pid}.tmp`;
|
|
57608
57747
|
try {
|
|
57609
57748
|
writeFileSync15(tmp, text3, { mode: 420 });
|
|
@@ -57619,10 +57758,10 @@ var real = (path, native = false) => {
|
|
|
57619
57758
|
return (native ? realpathSync10.native : realpathSync10)(abs);
|
|
57620
57759
|
} catch {
|
|
57621
57760
|
const parent = dirname11(abs);
|
|
57622
|
-
return parent === abs ? abs :
|
|
57761
|
+
return parent === abs ? abs : join27(real(parent, native), basename7(abs));
|
|
57623
57762
|
}
|
|
57624
57763
|
};
|
|
57625
|
-
var isDefaultHome2 = (home2, userHome) => real(home2) === real(
|
|
57764
|
+
var isDefaultHome2 = (home2, userHome) => real(home2) === real(join27(userHome, ".oa-bus"));
|
|
57626
57765
|
function serviceNames(home2, userHome) {
|
|
57627
57766
|
const suffix = isDefaultHome2(home2, userHome) ? "" : createHash9("sha256").update(real(home2)).digest("hex").slice(0, 8);
|
|
57628
57767
|
return {
|
|
@@ -57651,16 +57790,16 @@ function systemService(d) {
|
|
|
57651
57790
|
const names2 = () => serviceNames(home2(), d.userHome);
|
|
57652
57791
|
const launcherNode = () => d.platform === "win32" ? void 0 : d.execPath;
|
|
57653
57792
|
const nodeOf = (h) => d.platform === "win32" ? d.execPath : launcherOf(h);
|
|
57654
|
-
const entryOf = () =>
|
|
57655
|
-
const installFile2 = () =>
|
|
57793
|
+
const entryOf = () => join27(home2(), "bin", entryName(d.source()));
|
|
57794
|
+
const installFile2 = () => join27(home2(), "install.json");
|
|
57656
57795
|
const record7 = () => {
|
|
57657
57796
|
const r = readInstallFile(installFile2()).service;
|
|
57658
57797
|
return typeof r === "object" && r !== null ? r : {};
|
|
57659
57798
|
};
|
|
57660
57799
|
const xdg = d.env.XDG_CONFIG_HOME;
|
|
57661
|
-
const configHome = xdg && isAbsolute8(xdg) ? xdg :
|
|
57800
|
+
const configHome = xdg && isAbsolute8(xdg) ? xdg : join27(d.userHome, ".config");
|
|
57662
57801
|
const fileName = () => manager === "launchd" ? `${names2().label}.plist` : names2().unit;
|
|
57663
|
-
const fresh = () => manager === "launchd" ?
|
|
57802
|
+
const fresh = () => manager === "launchd" ? join27(d.userHome, "Library/LaunchAgents", fileName()) : join27(configHome, "systemd/user", fileName());
|
|
57664
57803
|
const recorded = () => {
|
|
57665
57804
|
const r = record7().unit;
|
|
57666
57805
|
return typeof r === "string" && isAbsolute8(r) && basename7(r) === fileName() ? r : void 0;
|
|
@@ -57672,7 +57811,7 @@ function systemService(d) {
|
|
|
57672
57811
|
const installed = () => manager !== void 0 && present(file2());
|
|
57673
57812
|
const unitRunsRescue = () => {
|
|
57674
57813
|
try {
|
|
57675
|
-
return
|
|
57814
|
+
return readFileSync21(file2(), "utf8").includes(rescueOf(home2()));
|
|
57676
57815
|
} catch {
|
|
57677
57816
|
return false;
|
|
57678
57817
|
}
|
|
@@ -57756,10 +57895,10 @@ function systemService(d) {
|
|
|
57756
57895
|
}
|
|
57757
57896
|
const h = home2();
|
|
57758
57897
|
const src = d.source();
|
|
57759
|
-
const logs2 =
|
|
57898
|
+
const logs2 = join27(h, "logs");
|
|
57760
57899
|
const u = {
|
|
57761
57900
|
node: nodeOf(h),
|
|
57762
|
-
entry:
|
|
57901
|
+
entry: join27(h, "bin", entryName(src)),
|
|
57763
57902
|
env: {
|
|
57764
57903
|
PATH: servicePath(d.env, d.execPath, d.platform),
|
|
57765
57904
|
...isDefaultHome2(h, d.userHome) ? {} : { OA_BUS_HOME: h },
|
|
@@ -57767,8 +57906,8 @@ function systemService(d) {
|
|
|
57767
57906
|
...codexHomeEnv(d.userHome, d.env)
|
|
57768
57907
|
},
|
|
57769
57908
|
// One file: the daemon logs to stderr, and `oa-bus logs` tails it.
|
|
57770
|
-
out:
|
|
57771
|
-
err:
|
|
57909
|
+
out: join27(logs2, "daemon.log"),
|
|
57910
|
+
err: join27(logs2, "daemon.log")
|
|
57772
57911
|
};
|
|
57773
57912
|
const unit = {
|
|
57774
57913
|
...u,
|
|
@@ -57785,7 +57924,7 @@ function systemService(d) {
|
|
|
57785
57924
|
const left = await stopDaemon(skipped !== void 0);
|
|
57786
57925
|
if (left !== void 0) return { running: left };
|
|
57787
57926
|
installCli(h, src, launcherNode());
|
|
57788
|
-
|
|
57927
|
+
mkdirSync12(logs2, { recursive: true, mode: 448 });
|
|
57789
57928
|
const f = fresh();
|
|
57790
57929
|
const old = recorded();
|
|
57791
57930
|
if (!skipped && old && old !== f) {
|
|
@@ -57908,7 +58047,7 @@ function systemService(d) {
|
|
|
57908
58047
|
const own2 = fileName();
|
|
57909
58048
|
const re = manager === "launchd" ? /^com\.open-artifacts\.bus\.[0-9a-f]{8}\.plist$/ : /^oa-bus-[0-9a-f]{8}\.service$/;
|
|
57910
58049
|
try {
|
|
57911
|
-
return
|
|
58050
|
+
return readdirSync8(dir).filter((f) => re.test(f) && f !== own2).map((f) => f.replace(/\.(plist|service)$/, "")).sort();
|
|
57912
58051
|
} catch {
|
|
57913
58052
|
return [];
|
|
57914
58053
|
}
|
|
@@ -57917,9 +58056,9 @@ function systemService(d) {
|
|
|
57917
58056
|
if (!installed()) return [];
|
|
57918
58057
|
const out = [];
|
|
57919
58058
|
const node2 = record7().node;
|
|
57920
|
-
if (typeof node2 === "string" && !
|
|
58059
|
+
if (typeof node2 === "string" && !existsSync8(node2))
|
|
57921
58060
|
out.push({ kind: "node-missing", node: node2 });
|
|
57922
|
-
if (manager === "systemd" && !
|
|
58061
|
+
if (manager === "systemd" && !existsSync8(join27(d.lingerDir ?? "/var/lib/systemd/linger", d.user)))
|
|
57923
58062
|
out.push({ kind: "linger-off" });
|
|
57924
58063
|
if (d.platform !== "win32" && unitRunsRescue()) {
|
|
57925
58064
|
const r = rescueOf(home2());
|
|
@@ -57946,8 +58085,8 @@ var noService = {
|
|
|
57946
58085
|
remove: async () => ({}),
|
|
57947
58086
|
cli: () => ["oa-bus"]
|
|
57948
58087
|
};
|
|
57949
|
-
var VERSION = true ? "0.
|
|
57950
|
-
|
|
58088
|
+
var VERSION = true ? "0.216.0" : JSON.parse(
|
|
58089
|
+
readFileSync22(new URL("../package.json", import.meta.url), "utf8")
|
|
57951
58090
|
).version;
|
|
57952
58091
|
var which = (cmd) => {
|
|
57953
58092
|
try {
|
|
@@ -57962,7 +58101,7 @@ function processArgs2(pid, io = {
|
|
|
57962
58101
|
encoding: "utf8",
|
|
57963
58102
|
stdio: ["ignore", "pipe", "ignore"]
|
|
57964
58103
|
}),
|
|
57965
|
-
proc: (path) =>
|
|
58104
|
+
proc: (path) => readFileSync22(path, "utf8")
|
|
57966
58105
|
}) {
|
|
57967
58106
|
try {
|
|
57968
58107
|
return io.ps(pid).trim() || void 0;
|
|
@@ -57975,8 +58114,8 @@ function processArgs2(pid, io = {
|
|
|
57975
58114
|
}
|
|
57976
58115
|
}
|
|
57977
58116
|
var spawnDaemon = (cmd, args, opts) => {
|
|
57978
|
-
const out =
|
|
57979
|
-
const err =
|
|
58117
|
+
const out = openSync9(opts.out, "a", 384);
|
|
58118
|
+
const err = openSync9(opts.err, "a", 384);
|
|
57980
58119
|
try {
|
|
57981
58120
|
const child = spawn2(cmd, args, {
|
|
57982
58121
|
detached: true,
|
|
@@ -57986,8 +58125,8 @@ var spawnDaemon = (cmd, args, opts) => {
|
|
|
57986
58125
|
child.unref();
|
|
57987
58126
|
return child.pid;
|
|
57988
58127
|
} finally {
|
|
57989
|
-
|
|
57990
|
-
|
|
58128
|
+
closeSync9(out);
|
|
58129
|
+
closeSync9(err);
|
|
57991
58130
|
}
|
|
57992
58131
|
};
|
|
57993
58132
|
var accountHome = () => {
|
|
@@ -58124,20 +58263,20 @@ var configFileLines = (ctx, files2) => files2.flatMap(
|
|
|
58124
58263
|
var isolated = (ctx) => Boolean(ctx.service.isolated);
|
|
58125
58264
|
|
|
58126
58265
|
// src/steps/adapters.ts
|
|
58127
|
-
import { randomBytes as
|
|
58266
|
+
import { randomBytes as randomBytes7 } from "node:crypto";
|
|
58128
58267
|
import {
|
|
58129
|
-
chmodSync as
|
|
58130
|
-
existsSync as
|
|
58268
|
+
chmodSync as chmodSync20,
|
|
58269
|
+
existsSync as existsSync15,
|
|
58131
58270
|
lstatSync as lstatSync17,
|
|
58132
|
-
mkdirSync as
|
|
58133
|
-
readFileSync as
|
|
58271
|
+
mkdirSync as mkdirSync15,
|
|
58272
|
+
readFileSync as readFileSync31,
|
|
58134
58273
|
readlinkSync as readlinkSync5,
|
|
58135
58274
|
renameSync as renameSync19,
|
|
58136
58275
|
rmSync as rmSync19,
|
|
58137
|
-
statSync as
|
|
58276
|
+
statSync as statSync10,
|
|
58138
58277
|
writeFileSync as writeFileSync18
|
|
58139
58278
|
} from "node:fs";
|
|
58140
|
-
import { dirname as dirname15, isAbsolute as isAbsolute13, join as
|
|
58279
|
+
import { dirname as dirname15, isAbsolute as isAbsolute13, join as join34, relative as relative6, resolve as resolve12 } from "node:path";
|
|
58141
58280
|
import { isDeepStrictEqual } from "node:util";
|
|
58142
58281
|
|
|
58143
58282
|
// ../bus-adapter-hermes/src/index.ts
|
|
@@ -59380,9 +59519,9 @@ var PI_EXTENSION = fileURLToPath4(
|
|
|
59380
59519
|
);
|
|
59381
59520
|
|
|
59382
59521
|
// src/steps/claude-proof.ts
|
|
59383
|
-
import { lstatSync as lstatSync12, readFileSync as
|
|
59384
|
-
import { join as
|
|
59385
|
-
var claudeConfigFile = (home2, env2) =>
|
|
59522
|
+
import { lstatSync as lstatSync12, readFileSync as readFileSync23 } from "node:fs";
|
|
59523
|
+
import { join as join28, resolve as resolve6 } from "node:path";
|
|
59524
|
+
var claudeConfigFile = (home2, env2) => join28(env2.CLAUDE_CONFIG_DIR ?? home2, ".claude.json");
|
|
59386
59525
|
var PROOF_COMMAND = "mcp-proof";
|
|
59387
59526
|
var TOKEN_HELPER = /^T=\$\(cat (.+)\) && printf '\{"Authorization":"Bearer %s"\}' "\$T"$/;
|
|
59388
59527
|
var quote = (s) => /^[A-Za-z0-9_./:@%+=,-]+$/.test(s) ? s : `'${s.replaceAll("'", `'\\''`)}'`;
|
|
@@ -59417,7 +59556,7 @@ function isInstanceEntry(entry, origin) {
|
|
|
59417
59556
|
}
|
|
59418
59557
|
function allEntries(doc) {
|
|
59419
59558
|
const out = [];
|
|
59420
|
-
const
|
|
59559
|
+
const add2 = (servers4, scope, project) => {
|
|
59421
59560
|
if (!isRecord3(servers4)) return;
|
|
59422
59561
|
for (const [name, entry] of Object.entries(servers4))
|
|
59423
59562
|
if (isRecord3(entry))
|
|
@@ -59429,10 +59568,10 @@ function allEntries(doc) {
|
|
|
59429
59568
|
path: project === void 0 ? ["mcpServers", name] : ["projects", project, "mcpServers", name]
|
|
59430
59569
|
});
|
|
59431
59570
|
};
|
|
59432
|
-
|
|
59571
|
+
add2(doc.mcpServers, "user");
|
|
59433
59572
|
if (isRecord3(doc.projects)) {
|
|
59434
59573
|
for (const [dir, p] of Object.entries(doc.projects))
|
|
59435
|
-
if (isRecord3(p))
|
|
59574
|
+
if (isRecord3(p)) add2(p.mcpServers, "local", dir);
|
|
59436
59575
|
}
|
|
59437
59576
|
return out;
|
|
59438
59577
|
}
|
|
@@ -59456,7 +59595,7 @@ function findElsewhere(doc, origin) {
|
|
|
59456
59595
|
}
|
|
59457
59596
|
var readText = (path) => {
|
|
59458
59597
|
try {
|
|
59459
|
-
return
|
|
59598
|
+
return readFileSync23(path, "utf8");
|
|
59460
59599
|
} catch (e) {
|
|
59461
59600
|
if (e.code === "ENOENT") return "";
|
|
59462
59601
|
throw e;
|
|
@@ -59470,7 +59609,7 @@ var asRecord = (p) => isRecord3(p) && typeof p.entry === "string" && (p.project
|
|
|
59470
59609
|
} : void 0;
|
|
59471
59610
|
function readRecord(path) {
|
|
59472
59611
|
try {
|
|
59473
|
-
const v = JSON.parse(
|
|
59612
|
+
const v = JSON.parse(readFileSync23(path, "utf8"));
|
|
59474
59613
|
if (isRecord3(v)) {
|
|
59475
59614
|
const { claudeProof: claudeProof2, claudeConfig, ...rest } = v;
|
|
59476
59615
|
const list = Array.isArray(claudeProof2) ? claudeProof2 : [claudeProof2];
|
|
@@ -59677,7 +59816,7 @@ function proofReport(file2, origin, opts = {}) {
|
|
|
59677
59816
|
// src/steps/codex-proof.ts
|
|
59678
59817
|
init_src3();
|
|
59679
59818
|
init_src();
|
|
59680
|
-
import { existsSync as
|
|
59819
|
+
import { existsSync as existsSync9, readFileSync as readFileSync24, rmSync as rmSync12 } from "node:fs";
|
|
59681
59820
|
import { isAbsolute as isAbsolute10 } from "node:path";
|
|
59682
59821
|
var CODEX_MIN_VERSION = "0.123.0";
|
|
59683
59822
|
var PROXY_CMD = "mcp-proxy";
|
|
@@ -59700,7 +59839,7 @@ var BLOCKING = [
|
|
|
59700
59839
|
var isRecord4 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
59701
59840
|
function readMoved(path) {
|
|
59702
59841
|
try {
|
|
59703
|
-
const v = JSON.parse(
|
|
59842
|
+
const v = JSON.parse(readFileSync24(path, "utf8"));
|
|
59704
59843
|
if (isRecord4(v) && typeof v.name === "string" && typeof v.origin === "string" && Array.isArray(v.lines) && v.lines.every((l) => typeof l === "string") && typeof v.original === "string" && typeof v.swapped === "string")
|
|
59705
59844
|
return v;
|
|
59706
59845
|
} catch {
|
|
@@ -59744,7 +59883,7 @@ function ownLines(lines, name) {
|
|
|
59744
59883
|
while (end > header + 1 && kinds[end - 1] === "blank") end--;
|
|
59745
59884
|
return { header, from: header + 1, to: end };
|
|
59746
59885
|
}
|
|
59747
|
-
function edit(text3, name, remove3,
|
|
59886
|
+
function edit(text3, name, remove3, add2) {
|
|
59748
59887
|
const lines = splitLines(text3);
|
|
59749
59888
|
const at = ownLines(lines, name);
|
|
59750
59889
|
if (typeof at === "string") return void 0;
|
|
@@ -59754,7 +59893,7 @@ function edit(text3, name, remove3, add) {
|
|
|
59754
59893
|
const k = keyOf(l.text);
|
|
59755
59894
|
return k === void 0 || !remove3.includes(k);
|
|
59756
59895
|
});
|
|
59757
|
-
const fresh =
|
|
59896
|
+
const fresh = add2.map((t) => ({ text: t, eol: eol2 }));
|
|
59758
59897
|
const span = (ls) => joinLines(lines.slice(at.header, at.header + 1).concat(ls));
|
|
59759
59898
|
const out = [
|
|
59760
59899
|
...lines.slice(0, at.header + 1),
|
|
@@ -59835,13 +59974,13 @@ function pendingEntry(io, origin) {
|
|
|
59835
59974
|
return void 0;
|
|
59836
59975
|
}
|
|
59837
59976
|
var wantEntry = (io, origin, tokenEnv) => {
|
|
59838
|
-
const
|
|
59977
|
+
const add2 = [
|
|
59839
59978
|
`command = ${str2(io.busBin[0])}`,
|
|
59840
59979
|
`args = [${[...io.busBin.slice(1), ...proxyArgs(origin, tokenEnv)].map(str2).join(", ")}]`,
|
|
59841
59980
|
`env_vars = [${str2(tokenEnv)}]`,
|
|
59842
59981
|
...io.busHome ? [`env = { OA_BUS_HOME = ${str2(io.busHome)} }`] : []
|
|
59843
59982
|
];
|
|
59844
|
-
return
|
|
59983
|
+
return add2;
|
|
59845
59984
|
};
|
|
59846
59985
|
function checked2(file2, before, next, name, entry) {
|
|
59847
59986
|
let doc;
|
|
@@ -59932,7 +60071,7 @@ function restoreEntry(io) {
|
|
|
59932
60071
|
const m = readMoved(io.moved);
|
|
59933
60072
|
if (!m) return false;
|
|
59934
60073
|
let put2 = false;
|
|
59935
|
-
if (
|
|
60074
|
+
if (existsSync9(io.file)) {
|
|
59936
60075
|
const { text: text3, doc } = readToml(io.file);
|
|
59937
60076
|
const cur = servers2(doc)[m.name];
|
|
59938
60077
|
const lines = splitLines(text3);
|
|
@@ -59974,7 +60113,7 @@ function proxyProgramMissing(doc, which2) {
|
|
|
59974
60113
|
if (i < 0 || a[i + 3] !== "--for" || a[i + 4] !== "codex") continue;
|
|
59975
60114
|
for (const part of [e.command, ...a.slice(0, i)]) {
|
|
59976
60115
|
if (typeof part !== "string") continue;
|
|
59977
|
-
if (isAbsolute10(part) ? !
|
|
60116
|
+
if (isAbsolute10(part) ? !existsSync9(part) : !which2(part))
|
|
59978
60117
|
return { name, missing: part };
|
|
59979
60118
|
}
|
|
59980
60119
|
}
|
|
@@ -59984,22 +60123,22 @@ function proxyProgramMissing(doc, which2) {
|
|
|
59984
60123
|
// src/steps/habits.ts
|
|
59985
60124
|
init_src();
|
|
59986
60125
|
import {
|
|
59987
|
-
existsSync as
|
|
60126
|
+
existsSync as existsSync12,
|
|
59988
60127
|
lstatSync as lstatSync16,
|
|
59989
|
-
readFileSync as
|
|
60128
|
+
readFileSync as readFileSync28,
|
|
59990
60129
|
realpathSync as realpathSync14,
|
|
59991
60130
|
rmSync as rmSync16
|
|
59992
60131
|
} from "node:fs";
|
|
59993
|
-
import { join as
|
|
60132
|
+
import { join as join32, resolve as resolve10, sep as sep4 } from "node:path";
|
|
59994
60133
|
|
|
59995
60134
|
// src/steps/hermes.ts
|
|
59996
|
-
import { createHash as createHash11, randomBytes as
|
|
60135
|
+
import { createHash as createHash11, randomBytes as randomBytes6 } from "node:crypto";
|
|
59997
60136
|
import {
|
|
59998
60137
|
cpSync as cpSync2,
|
|
59999
60138
|
lstatSync as lstatSync13,
|
|
60000
|
-
mkdirSync as
|
|
60001
|
-
readdirSync as
|
|
60002
|
-
readFileSync as
|
|
60139
|
+
mkdirSync as mkdirSync13,
|
|
60140
|
+
readdirSync as readdirSync9,
|
|
60141
|
+
readFileSync as readFileSync25,
|
|
60003
60142
|
readlinkSync as readlinkSync3,
|
|
60004
60143
|
realpathSync as realpathSync11,
|
|
60005
60144
|
renameSync as renameSync17,
|
|
@@ -60011,7 +60150,7 @@ import {
|
|
|
60011
60150
|
basename as basename8,
|
|
60012
60151
|
dirname as dirname12,
|
|
60013
60152
|
isAbsolute as isAbsolute11,
|
|
60014
|
-
join as
|
|
60153
|
+
join as join29,
|
|
60015
60154
|
relative as relative5,
|
|
60016
60155
|
resolve as resolve7
|
|
60017
60156
|
} from "node:path";
|
|
@@ -60027,7 +60166,7 @@ var real2 = (p) => {
|
|
|
60027
60166
|
let cur = p;
|
|
60028
60167
|
for (; ; ) {
|
|
60029
60168
|
try {
|
|
60030
|
-
return
|
|
60169
|
+
return join29(realpathSync11(cur), ...rest.reverse());
|
|
60031
60170
|
} catch {
|
|
60032
60171
|
const up = dirname12(cur);
|
|
60033
60172
|
if (up === cur) return p;
|
|
@@ -60051,13 +60190,13 @@ function sweepStaging(staging, own2, o = {}) {
|
|
|
60051
60190
|
const alive3 = o.alive ?? pidAlive2;
|
|
60052
60191
|
let names2;
|
|
60053
60192
|
try {
|
|
60054
|
-
names2 =
|
|
60193
|
+
names2 = readdirSync9(staging);
|
|
60055
60194
|
} catch {
|
|
60056
60195
|
return;
|
|
60057
60196
|
}
|
|
60058
60197
|
for (const name of names2) {
|
|
60059
60198
|
if (name === own2) continue;
|
|
60060
|
-
const path =
|
|
60199
|
+
const path = join29(staging, name);
|
|
60061
60200
|
let old;
|
|
60062
60201
|
try {
|
|
60063
60202
|
old = now - lstatSync13(path).mtimeMs > STAGING_STALE_MS;
|
|
@@ -60074,11 +60213,11 @@ function sweepStaging(staging, own2, o = {}) {
|
|
|
60074
60213
|
}
|
|
60075
60214
|
}
|
|
60076
60215
|
var nativeHome = (home2, env2, platform) => {
|
|
60077
|
-
if (platform !== "win32") return
|
|
60216
|
+
if (platform !== "win32") return join29(home2, ".hermes");
|
|
60078
60217
|
const local = env2.LOCALAPPDATA?.trim();
|
|
60079
|
-
return
|
|
60218
|
+
return join29(local || join29(home2, "AppData", "Local"), "hermes");
|
|
60080
60219
|
};
|
|
60081
|
-
var tilded = (home2, v) => v === "~" ? home2 : resolve7(v.startsWith("~/") ?
|
|
60220
|
+
var tilded = (home2, v) => v === "~" ? home2 : resolve7(v.startsWith("~/") ? join29(home2, v.slice(2)) : v);
|
|
60082
60221
|
function hermesHome(home2, env2, platform = process.platform) {
|
|
60083
60222
|
const native = nativeHome(home2, env2, platform);
|
|
60084
60223
|
const v = env2.HERMES_HOME?.trim();
|
|
@@ -60089,9 +60228,9 @@ function hermesHome(home2, env2, platform = process.platform) {
|
|
|
60089
60228
|
const root = hermesRoot(home2, env2, platform);
|
|
60090
60229
|
if (env2.HERMES_S6_SUPERVISED_CHILD) return base3;
|
|
60091
60230
|
try {
|
|
60092
|
-
const name =
|
|
60231
|
+
const name = readFileSync25(join29(root, "active_profile"), "utf8").trim().toLowerCase();
|
|
60093
60232
|
if (name && name !== "default" && /^[a-z0-9][a-z0-9_-]{0,63}$/.test(name)) {
|
|
60094
|
-
const dir =
|
|
60233
|
+
const dir = join29(root, "profiles", name);
|
|
60095
60234
|
if (lstatSync13(dir).isDirectory()) return dir;
|
|
60096
60235
|
}
|
|
60097
60236
|
} catch {
|
|
@@ -60109,7 +60248,7 @@ function hermesRoot(home2, env2, platform = process.platform) {
|
|
|
60109
60248
|
return given;
|
|
60110
60249
|
}
|
|
60111
60250
|
function hermesProfilesScan(home2, env2, platform = process.platform) {
|
|
60112
|
-
const path =
|
|
60251
|
+
const path = join29(hermesRoot(home2, env2, platform), "profiles");
|
|
60113
60252
|
let isLink3 = false;
|
|
60114
60253
|
try {
|
|
60115
60254
|
isLink3 = lstatSync13(path).isSymbolicLink();
|
|
@@ -60127,7 +60266,7 @@ function hermesProfilesScan(home2, env2, platform = process.platform) {
|
|
|
60127
60266
|
}
|
|
60128
60267
|
};
|
|
60129
60268
|
try {
|
|
60130
|
-
const names2 =
|
|
60269
|
+
const names2 = readdirSync9(path).sort();
|
|
60131
60270
|
return {
|
|
60132
60271
|
names: names2,
|
|
60133
60272
|
incomplete: false,
|
|
@@ -60156,9 +60295,9 @@ function hermesProfilesScan(home2, env2, platform = process.platform) {
|
|
|
60156
60295
|
}
|
|
60157
60296
|
function hermesPluginDirs(home2, env2, platform = process.platform) {
|
|
60158
60297
|
const root = hermesRoot(home2, env2, platform);
|
|
60159
|
-
const out = [
|
|
60298
|
+
const out = [join29(root, "plugins", HERMES_PLUGIN_NAME)];
|
|
60160
60299
|
for (const name of hermesProfilesScan(home2, env2, platform).names)
|
|
60161
|
-
out.push(
|
|
60300
|
+
out.push(join29(root, "profiles", name, "plugins", HERMES_PLUGIN_NAME));
|
|
60162
60301
|
const active = hermesPluginDir(home2, env2, platform);
|
|
60163
60302
|
if (!out.includes(active)) out.push(active);
|
|
60164
60303
|
return out;
|
|
@@ -60166,7 +60305,7 @@ function hermesPluginDirs(home2, env2, platform = process.platform) {
|
|
|
60166
60305
|
var hermesEnv = (home2, env2, platform = process.platform) => ({
|
|
60167
60306
|
HERMES_HOME: hermesHome(home2, env2, platform)
|
|
60168
60307
|
});
|
|
60169
|
-
var hermesPluginDir = (home2, env2, platform = process.platform) =>
|
|
60308
|
+
var hermesPluginDir = (home2, env2, platform = process.platform) => join29(hermesHome(home2, env2, platform), "plugins", HERMES_PLUGIN_NAME);
|
|
60170
60309
|
var kind = (path) => {
|
|
60171
60310
|
try {
|
|
60172
60311
|
const st = lstatSync13(path);
|
|
@@ -60177,11 +60316,11 @@ var kind = (path) => {
|
|
|
60177
60316
|
};
|
|
60178
60317
|
function files(dir, rel = "") {
|
|
60179
60318
|
const out = [];
|
|
60180
|
-
for (const name of
|
|
60319
|
+
for (const name of readdirSync9(join29(dir, rel)).sort()) {
|
|
60181
60320
|
if (name === "__pycache__" || name.startsWith(".") || name.endsWith(".pyc") || rel === "" && (name === HERMES_HABITS_MARKER || name === HERMES_ROOTS_FILE))
|
|
60182
60321
|
continue;
|
|
60183
60322
|
const r = rel ? `${rel}/${name}` : name;
|
|
60184
|
-
if (kind(
|
|
60323
|
+
if (kind(join29(dir, r)) === "dir") out.push(...files(dir, r));
|
|
60185
60324
|
else out.push(r);
|
|
60186
60325
|
}
|
|
60187
60326
|
return out;
|
|
@@ -60190,7 +60329,7 @@ function pluginHash(dir) {
|
|
|
60190
60329
|
const h = createHash11("sha256");
|
|
60191
60330
|
for (const f of files(dir)) {
|
|
60192
60331
|
h.update(`${f}\0`);
|
|
60193
|
-
h.update(
|
|
60332
|
+
h.update(readFileSync25(join29(dir, f)));
|
|
60194
60333
|
h.update("\0");
|
|
60195
60334
|
}
|
|
60196
60335
|
return h.digest("hex").slice(0, 16);
|
|
@@ -60201,7 +60340,7 @@ function pluginState(dir, shipped) {
|
|
|
60201
60340
|
if (k !== "dir") return "foreign";
|
|
60202
60341
|
let marker;
|
|
60203
60342
|
try {
|
|
60204
|
-
marker =
|
|
60343
|
+
marker = readFileSync25(join29(dir, HERMES_MARKER), "utf8").trim();
|
|
60205
60344
|
} catch {
|
|
60206
60345
|
return "foreign";
|
|
60207
60346
|
}
|
|
@@ -60240,35 +60379,35 @@ async function installHermes(deps2) {
|
|
|
60240
60379
|
`${dest} exists and is not Open Artifacts bus's; left it untouched`
|
|
60241
60380
|
);
|
|
60242
60381
|
if (state !== "current") {
|
|
60243
|
-
const keepHabits = state === "stale" && kind(
|
|
60244
|
-
const keepRoots = state === "stale" && kind(
|
|
60245
|
-
const plugins2 =
|
|
60246
|
-
|
|
60247
|
-
const staging =
|
|
60248
|
-
const own2 = `${process.pid}-${
|
|
60382
|
+
const keepHabits = state === "stale" && kind(join29(dest, HERMES_HABITS_MARKER)) === "file";
|
|
60383
|
+
const keepRoots = state === "stale" && kind(join29(dest, HERMES_ROOTS_FILE)) === "file" ? readFileSync25(join29(dest, HERMES_ROOTS_FILE)) : void 0;
|
|
60384
|
+
const plugins2 = join29(dest, "..");
|
|
60385
|
+
mkdirSync13(plugins2, { recursive: true });
|
|
60386
|
+
const staging = join29(plugins2, "..", HERMES_STAGING);
|
|
60387
|
+
const own2 = `${process.pid}-${randomBytes6(4).toString("hex")}`;
|
|
60249
60388
|
const st = lstatSync13(staging, { throwIfNoEntry: false });
|
|
60250
60389
|
if (st !== void 0 && !st.isDirectory())
|
|
60251
60390
|
throw new Error(
|
|
60252
60391
|
`${staging} is not a plain folder; remove it and run the install again`
|
|
60253
60392
|
);
|
|
60254
|
-
|
|
60393
|
+
mkdirSync13(staging, { recursive: true });
|
|
60255
60394
|
sweepStaging(staging, own2, deps2.staging);
|
|
60256
|
-
const tmp =
|
|
60395
|
+
const tmp = join29(staging, own2);
|
|
60257
60396
|
try {
|
|
60258
|
-
|
|
60397
|
+
mkdirSync13(tmp, { recursive: true });
|
|
60259
60398
|
for (const f of files(shipped)) {
|
|
60260
|
-
|
|
60261
|
-
cpSync2(
|
|
60399
|
+
mkdirSync13(join29(tmp, f, ".."), { recursive: true });
|
|
60400
|
+
cpSync2(join29(shipped, f), join29(tmp, f));
|
|
60262
60401
|
}
|
|
60263
60402
|
writeFileSync16(
|
|
60264
|
-
|
|
60403
|
+
join29(tmp, HERMES_MARKER),
|
|
60265
60404
|
`managed by the Open Artifacts bus installer: edits are replaced on reinstall. ${pluginHash(shipped)}
|
|
60266
60405
|
`
|
|
60267
60406
|
);
|
|
60268
60407
|
if (keepHabits)
|
|
60269
|
-
writeFileSync16(
|
|
60408
|
+
writeFileSync16(join29(tmp, HERMES_HABITS_MARKER), HABITS_MARKER_TEXT);
|
|
60270
60409
|
if (keepRoots !== void 0)
|
|
60271
|
-
writeFileSync16(
|
|
60410
|
+
writeFileSync16(join29(tmp, HERMES_ROOTS_FILE), keepRoots, { mode: 384 });
|
|
60272
60411
|
if (state === "stale") rmSync13(dest, { recursive: true, force: true });
|
|
60273
60412
|
renameSync17(tmp, dest);
|
|
60274
60413
|
} catch (e) {
|
|
@@ -60325,39 +60464,39 @@ async function hermesEnabled(deps2) {
|
|
|
60325
60464
|
|
|
60326
60465
|
// src/steps/openclaw.ts
|
|
60327
60466
|
import {
|
|
60328
|
-
existsSync as
|
|
60467
|
+
existsSync as existsSync11,
|
|
60329
60468
|
lstatSync as lstatSync15,
|
|
60330
|
-
readdirSync as
|
|
60331
|
-
readFileSync as
|
|
60469
|
+
readdirSync as readdirSync11,
|
|
60470
|
+
readFileSync as readFileSync27,
|
|
60332
60471
|
realpathSync as realpathSync13,
|
|
60333
60472
|
rmSync as rmSync15
|
|
60334
60473
|
} from "node:fs";
|
|
60335
|
-
import { join as
|
|
60474
|
+
import { join as join31, resolve as resolve9 } from "node:path";
|
|
60336
60475
|
import { fileURLToPath as fileURLToPath5 } from "node:url";
|
|
60337
60476
|
|
|
60338
60477
|
// src/steps/skill.ts
|
|
60339
60478
|
import {
|
|
60340
|
-
chmodSync as
|
|
60341
|
-
existsSync as
|
|
60479
|
+
chmodSync as chmodSync19,
|
|
60480
|
+
existsSync as existsSync10,
|
|
60342
60481
|
lstatSync as lstatSync14,
|
|
60343
|
-
mkdirSync as
|
|
60344
|
-
readdirSync as
|
|
60345
|
-
readFileSync as
|
|
60482
|
+
mkdirSync as mkdirSync14,
|
|
60483
|
+
readdirSync as readdirSync10,
|
|
60484
|
+
readFileSync as readFileSync26,
|
|
60346
60485
|
readlinkSync as readlinkSync4,
|
|
60347
60486
|
realpathSync as realpathSync12,
|
|
60348
60487
|
renameSync as renameSync18,
|
|
60349
60488
|
rmdirSync as rmdirSync2,
|
|
60350
60489
|
rmSync as rmSync14,
|
|
60351
|
-
statSync as
|
|
60490
|
+
statSync as statSync9,
|
|
60352
60491
|
writeFileSync as writeFileSync17
|
|
60353
60492
|
} from "node:fs";
|
|
60354
|
-
import { dirname as dirname13, join as
|
|
60493
|
+
import { dirname as dirname13, join as join30, resolve as resolve8 } from "node:path";
|
|
60355
60494
|
var SKILL_MARKER = "<!-- managed by the Open Artifacts bus installer: edits are replaced on reinstall. -->";
|
|
60356
60495
|
var CODEX_BEGIN = "<!-- BEGIN Open Artifacts skill (managed): edits inside are replaced on reinstall. -->";
|
|
60357
60496
|
var CODEX_END = "<!-- END Open Artifacts skill -->";
|
|
60358
60497
|
var CODEX_SKILLS_MIN_VERSION = "0.76.0";
|
|
60359
60498
|
var MAX_SKILL_BYTES = 256 * 1024;
|
|
60360
|
-
var codexSkillFile = (deps2, folder) =>
|
|
60499
|
+
var codexSkillFile = (deps2, folder) => join30(codexHome2(deps2.home, env(deps2)), "skills", folder, "SKILL.md");
|
|
60361
60500
|
var codexHasSkills = (version2) => version2 !== void 0 && (compareVersions(version2, CODEX_SKILLS_MIN_VERSION) ?? -1) >= 0;
|
|
60362
60501
|
var blankLine = (l) => l?.replace(/\r$/, "") === "";
|
|
60363
60502
|
var withoutCodexBlock = (text3) => {
|
|
@@ -60379,8 +60518,8 @@ var withoutCodexBlock = (text3) => {
|
|
|
60379
60518
|
return removed ? lines.join("\n") : void 0;
|
|
60380
60519
|
};
|
|
60381
60520
|
var dropCodexBlock = (agentsPath, notes) => {
|
|
60382
|
-
if (brokenLink(agentsPath) || !
|
|
60383
|
-
const text3 =
|
|
60521
|
+
if (brokenLink(agentsPath) || !existsSync10(agentsPath)) return false;
|
|
60522
|
+
const text3 = readFileSync26(agentsPath, "utf8");
|
|
60384
60523
|
if (codexBroken(text3)) {
|
|
60385
60524
|
notes.push(
|
|
60386
60525
|
`Left ${agentsPath} alone: its Open Artifacts block has no END marker. Fix or remove the block, then rerun the install.`
|
|
@@ -60395,17 +60534,17 @@ var dropCodexBlock = (agentsPath, notes) => {
|
|
|
60395
60534
|
var env = (deps2) => deps2.env ?? {};
|
|
60396
60535
|
var skillDir = (deps2, h) => {
|
|
60397
60536
|
const e = env(deps2);
|
|
60398
|
-
const opencode = e.OPENCODE_CONFIG_DIR ??
|
|
60399
|
-
const agents =
|
|
60537
|
+
const opencode = e.OPENCODE_CONFIG_DIR ?? join30(e.XDG_CONFIG_HOME ?? join30(deps2.home, ".config"), "opencode");
|
|
60538
|
+
const agents = join30(deps2.home, ".agents", "skills");
|
|
60400
60539
|
return {
|
|
60401
|
-
claude:
|
|
60402
|
-
opencode:
|
|
60540
|
+
claude: join30(e.CLAUDE_CONFIG_DIR ?? join30(deps2.home, ".claude"), "skills"),
|
|
60541
|
+
opencode: join30(opencode, "skills"),
|
|
60403
60542
|
pi: agents,
|
|
60404
60543
|
omp: agents,
|
|
60405
|
-
codex:
|
|
60406
|
-
hermes:
|
|
60544
|
+
codex: join30(codexHome2(deps2.home, e), "AGENTS.md"),
|
|
60545
|
+
hermes: join30(hermesHome(deps2.home, e), "skills"),
|
|
60407
60546
|
// OpenClaw's managed skills folder, in its state dir.
|
|
60408
|
-
openclaw:
|
|
60547
|
+
openclaw: join30(openclawStateDir(deps2.home, e), "skills")
|
|
60409
60548
|
}[h];
|
|
60410
60549
|
};
|
|
60411
60550
|
var skillFolder = (text3) => {
|
|
@@ -60451,7 +60590,7 @@ var lstatOk = (path) => {
|
|
|
60451
60590
|
};
|
|
60452
60591
|
var brokenLink = (path) => {
|
|
60453
60592
|
try {
|
|
60454
|
-
return lstatSync14(path).isSymbolicLink() && !
|
|
60593
|
+
return lstatSync14(path).isSymbolicLink() && !existsSync10(path);
|
|
60455
60594
|
} catch {
|
|
60456
60595
|
return false;
|
|
60457
60596
|
}
|
|
@@ -60501,16 +60640,16 @@ var targetOf = (path) => {
|
|
|
60501
60640
|
};
|
|
60502
60641
|
var seq = 0;
|
|
60503
60642
|
var writeAtomic = (path, text3) => {
|
|
60504
|
-
|
|
60643
|
+
mkdirSync14(dirname13(path), { recursive: true });
|
|
60505
60644
|
const tmp = `${path}.oa-${process.pid}-${seq++}.tmp`;
|
|
60506
60645
|
try {
|
|
60507
60646
|
let mode;
|
|
60508
60647
|
try {
|
|
60509
|
-
mode =
|
|
60648
|
+
mode = statSync9(path).mode & 4095;
|
|
60510
60649
|
} catch {
|
|
60511
60650
|
}
|
|
60512
60651
|
writeFileSync17(tmp, text3);
|
|
60513
|
-
if (mode !== void 0)
|
|
60652
|
+
if (mode !== void 0) chmodSync19(tmp, mode);
|
|
60514
60653
|
renameSync18(tmp, path);
|
|
60515
60654
|
} catch (e) {
|
|
60516
60655
|
try {
|
|
@@ -60574,7 +60713,7 @@ var codexSkillsShared = (deps2) => {
|
|
|
60574
60713
|
};
|
|
60575
60714
|
var ourSkillFile = (path, folder) => {
|
|
60576
60715
|
try {
|
|
60577
|
-
return isOurs(
|
|
60716
|
+
return isOurs(readFileSync26(path, "utf8"), folder);
|
|
60578
60717
|
} catch {
|
|
60579
60718
|
return false;
|
|
60580
60719
|
}
|
|
@@ -60584,7 +60723,7 @@ var installCodex = (deps2, folder, text3, written, notes) => {
|
|
|
60584
60723
|
const filePath = codexSkillFile(deps2, folder);
|
|
60585
60724
|
let before;
|
|
60586
60725
|
try {
|
|
60587
|
-
before =
|
|
60726
|
+
before = existsSync10(targetOf(agentsPath)) ? readFileSync26(targetOf(agentsPath), "utf8") : "";
|
|
60588
60727
|
} catch (e) {
|
|
60589
60728
|
notes.push(
|
|
60590
60729
|
`Left ${agentsPath} alone: could not read it (${e instanceof Error ? e.message : String(e)}).`
|
|
@@ -60613,7 +60752,7 @@ var installCodex = (deps2, folder, text3, written, notes) => {
|
|
|
60613
60752
|
}
|
|
60614
60753
|
const writing2 = targetOf(filePath);
|
|
60615
60754
|
try {
|
|
60616
|
-
if (
|
|
60755
|
+
if (existsSync10(writing2) && !ourSkillFile(writing2, folder)) {
|
|
60617
60756
|
notes.push(
|
|
60618
60757
|
`Left ${writing2} alone: it has no Open Artifacts marker, so it is not ours to replace.`
|
|
60619
60758
|
);
|
|
@@ -60694,14 +60833,14 @@ async function installSkill(deps2, origin, harnesses) {
|
|
|
60694
60833
|
continue;
|
|
60695
60834
|
}
|
|
60696
60835
|
const base3 = skillDir(deps2, h);
|
|
60697
|
-
const path =
|
|
60836
|
+
const path = join30(base3, folder, "SKILL.md");
|
|
60698
60837
|
if (brokenLink(path)) {
|
|
60699
60838
|
notes.push(`Left ${path} alone: it is a broken symlink.`);
|
|
60700
60839
|
continue;
|
|
60701
60840
|
}
|
|
60702
60841
|
const writing = targetOf(path);
|
|
60703
60842
|
try {
|
|
60704
|
-
if (
|
|
60843
|
+
if (existsSync10(writing) && !ourSkillFile(writing, folder)) {
|
|
60705
60844
|
notes.push(
|
|
60706
60845
|
`Left ${writing} alone: it has no Open Artifacts marker, so it is not ours to replace.`
|
|
60707
60846
|
);
|
|
@@ -60735,24 +60874,24 @@ var uninstallSkill = (deps2, harnesses = [
|
|
|
60735
60874
|
const scan2 = (base3) => {
|
|
60736
60875
|
let entries;
|
|
60737
60876
|
try {
|
|
60738
|
-
if (!
|
|
60739
|
-
entries =
|
|
60877
|
+
if (!existsSync10(base3)) return;
|
|
60878
|
+
entries = readdirSync10(base3);
|
|
60740
60879
|
} catch (e) {
|
|
60741
60880
|
fail3(base3, e);
|
|
60742
60881
|
return;
|
|
60743
60882
|
}
|
|
60744
60883
|
for (const entry of entries) {
|
|
60745
|
-
const dir =
|
|
60746
|
-
const file2 =
|
|
60884
|
+
const dir = join30(base3, entry);
|
|
60885
|
+
const file2 = join30(dir, "SKILL.md");
|
|
60747
60886
|
try {
|
|
60748
60887
|
const st = lstatSync14(dir);
|
|
60749
60888
|
if (st.isSymbolicLink()) {
|
|
60750
|
-
if (
|
|
60889
|
+
if (existsSync10(file2))
|
|
60751
60890
|
notes.push(`Left ${dir} alone: it is a symlinked folder.`);
|
|
60752
60891
|
continue;
|
|
60753
60892
|
}
|
|
60754
60893
|
if (!st.isDirectory() || !lstatOk(file2)) continue;
|
|
60755
|
-
if (!isOurs(
|
|
60894
|
+
if (!isOurs(readFileSync26(targetOf(file2), "utf8"), entry)) {
|
|
60756
60895
|
notes.push(
|
|
60757
60896
|
`Left ${file2} alone: it is not an Open Artifacts skill file.`
|
|
60758
60897
|
);
|
|
@@ -60779,7 +60918,7 @@ var uninstallSkill = (deps2, harnesses = [
|
|
|
60779
60918
|
} catch (e) {
|
|
60780
60919
|
fail3(base3, e);
|
|
60781
60920
|
}
|
|
60782
|
-
scan2(
|
|
60921
|
+
scan2(join30(dirname13(base3), "skills"));
|
|
60783
60922
|
continue;
|
|
60784
60923
|
}
|
|
60785
60924
|
scan2(base3);
|
|
@@ -60791,9 +60930,9 @@ var codexSkillState = (deps2) => {
|
|
|
60791
60930
|
shared: codexSkillsShared(deps2)
|
|
60792
60931
|
};
|
|
60793
60932
|
try {
|
|
60794
|
-
const dir =
|
|
60795
|
-
for (const entry of
|
|
60796
|
-
const file2 =
|
|
60933
|
+
const dir = join30(dirname13(skillDir(deps2, "codex")), "skills");
|
|
60934
|
+
for (const entry of readdirSync10(dir)) {
|
|
60935
|
+
const file2 = join30(dir, entry, "SKILL.md");
|
|
60797
60936
|
if (ourSkillFile(file2, entry)) {
|
|
60798
60937
|
out.file = file2;
|
|
60799
60938
|
break;
|
|
@@ -60803,7 +60942,7 @@ var codexSkillState = (deps2) => {
|
|
|
60803
60942
|
}
|
|
60804
60943
|
try {
|
|
60805
60944
|
const agents = skillDir(deps2, "codex");
|
|
60806
|
-
if (withoutCodexBlock(
|
|
60945
|
+
if (withoutCodexBlock(readFileSync26(agents, "utf8")) !== void 0)
|
|
60807
60946
|
out.block = agents;
|
|
60808
60947
|
} catch {
|
|
60809
60948
|
}
|
|
@@ -60817,12 +60956,12 @@ var savedSkill = (deps2, h, folder) => {
|
|
|
60817
60956
|
const base3 = skillDir(deps2, h);
|
|
60818
60957
|
let entries;
|
|
60819
60958
|
try {
|
|
60820
|
-
entries = folder ? [folder] :
|
|
60959
|
+
entries = folder ? [folder] : readdirSync10(base3);
|
|
60821
60960
|
} catch {
|
|
60822
60961
|
return void 0;
|
|
60823
60962
|
}
|
|
60824
60963
|
for (const entry of entries) {
|
|
60825
|
-
const file2 =
|
|
60964
|
+
const file2 = join30(base3, entry, "SKILL.md");
|
|
60826
60965
|
if (ourSkillFile(targetOf(file2), entry)) return file2;
|
|
60827
60966
|
}
|
|
60828
60967
|
return void 0;
|
|
@@ -60853,21 +60992,21 @@ function openclawStateDir(home2, env2) {
|
|
|
60853
60992
|
return resolve9(
|
|
60854
60993
|
override.startsWith("~") ? override.replace(/^~(?=$|[\\/])/, h) : override
|
|
60855
60994
|
);
|
|
60856
|
-
const next =
|
|
60857
|
-
if (env2.OPENCLAW_TEST_FAST === "1" ||
|
|
60858
|
-
const legacy =
|
|
60859
|
-
return
|
|
60995
|
+
const next = join31(h, ".openclaw");
|
|
60996
|
+
if (env2.OPENCLAW_TEST_FAST === "1" || existsSync11(next)) return next;
|
|
60997
|
+
const legacy = join31(h, ".clawdbot");
|
|
60998
|
+
return existsSync11(legacy) ? legacy : next;
|
|
60860
60999
|
}
|
|
60861
|
-
var openclawPluginDir = (home2, env2) =>
|
|
61000
|
+
var openclawPluginDir = (home2, env2) => join31(openclawStateDir(home2, env2), "extensions", OPENCLAW_PLUGIN_ID);
|
|
60862
61001
|
function openclawPluginDirs(home2, env2) {
|
|
60863
61002
|
const h = openclawHome(home2, env2);
|
|
60864
|
-
const states = [
|
|
61003
|
+
const states = [join31(h, ".openclaw"), join31(h, ".clawdbot")];
|
|
60865
61004
|
try {
|
|
60866
|
-
for (const name of
|
|
60867
|
-
if (name.startsWith(".openclaw-")) states.push(
|
|
61005
|
+
for (const name of readdirSync11(h).sort())
|
|
61006
|
+
if (name.startsWith(".openclaw-")) states.push(join31(h, name));
|
|
60868
61007
|
} catch {
|
|
60869
61008
|
}
|
|
60870
|
-
const out = states.map((s) =>
|
|
61009
|
+
const out = states.map((s) => join31(s, "extensions", OPENCLAW_PLUGIN_ID));
|
|
60871
61010
|
const active = openclawPluginDir(home2, env2);
|
|
60872
61011
|
if (!out.includes(active)) out.push(active);
|
|
60873
61012
|
return out;
|
|
@@ -60887,7 +61026,7 @@ var kind2 = (path) => {
|
|
|
60887
61026
|
var openclawManifestIsOurs = (dir) => {
|
|
60888
61027
|
try {
|
|
60889
61028
|
const m = JSON.parse(
|
|
60890
|
-
|
|
61029
|
+
readFileSync27(join31(dir, "openclaw.plugin.json"), "utf8")
|
|
60891
61030
|
);
|
|
60892
61031
|
return m?.id === OPENCLAW_PLUGIN_ID;
|
|
60893
61032
|
} catch {
|
|
@@ -60908,7 +61047,7 @@ function openclawPluginState(dir, shipped) {
|
|
|
60908
61047
|
if (k !== "dir") return "foreign";
|
|
60909
61048
|
let marker;
|
|
60910
61049
|
try {
|
|
60911
|
-
marker =
|
|
61050
|
+
marker = readFileSync27(join31(dir, OPENCLAW_MARKER), "utf8").trim();
|
|
60912
61051
|
} catch {
|
|
60913
61052
|
return sameAsShipped(dir, shipped) ? "stale" : "foreign";
|
|
60914
61053
|
}
|
|
@@ -60921,7 +61060,7 @@ function openclawPluginState(dir, shipped) {
|
|
|
60921
61060
|
return "stale";
|
|
60922
61061
|
}
|
|
60923
61062
|
}
|
|
60924
|
-
var installFile = (deps2) =>
|
|
61063
|
+
var installFile = (deps2) => join31(deps2.busHome ?? join31(deps2.home, ".oa-bus"), "install.json");
|
|
60925
61064
|
var recordedStateDir = (deps2) => {
|
|
60926
61065
|
const r = readInstallFile(installFile(deps2)).openclaw;
|
|
60927
61066
|
const d = r?.stateDir;
|
|
@@ -60999,7 +61138,7 @@ async function installOpenclaw(deps2, notes, optedOut) {
|
|
|
60999
61138
|
return "absent";
|
|
61000
61139
|
}
|
|
61001
61140
|
const shipped = deps2.assets.openclaw;
|
|
61002
|
-
if (shipped === void 0 || !
|
|
61141
|
+
if (shipped === void 0 || !existsSync11(join31(shipped, "openclaw.plugin.json")))
|
|
61003
61142
|
throw new Error("the OpenClaw plugin is missing from this install");
|
|
61004
61143
|
const dest = openclawPluginDir(deps2.home, deps2.env ?? {});
|
|
61005
61144
|
const state = openclawPluginState(dest, shipped);
|
|
@@ -61007,7 +61146,7 @@ async function installOpenclaw(deps2, notes, optedOut) {
|
|
|
61007
61146
|
throw new Error(
|
|
61008
61147
|
`${dest} exists and is not Open Artifacts bus's; left it untouched`
|
|
61009
61148
|
);
|
|
61010
|
-
const habitsFile =
|
|
61149
|
+
const habitsFile = join31(dest, OPENCLAW_HABITS_MARKER);
|
|
61011
61150
|
const dropHabitsIfOptedOut = () => {
|
|
61012
61151
|
if (optedOut && kind2(dest) === "dir") rmSync15(habitsFile, { force: true });
|
|
61013
61152
|
};
|
|
@@ -61028,7 +61167,7 @@ async function installOpenclaw(deps2, notes, optedOut) {
|
|
|
61028
61167
|
INSTALL_TIMEOUT_MS
|
|
61029
61168
|
);
|
|
61030
61169
|
const restore2 = () => {
|
|
61031
|
-
if (keepHabits && kind2(dest) === "dir" && kind2(
|
|
61170
|
+
if (keepHabits && kind2(dest) === "dir" && kind2(join31(dest, OPENCLAW_MARKER)) === "file")
|
|
61032
61171
|
writeAtomic(habitsFile, HABITS_MARKER_TEXT);
|
|
61033
61172
|
};
|
|
61034
61173
|
if (r.code !== 0) {
|
|
@@ -61040,7 +61179,7 @@ async function installOpenclaw(deps2, notes, optedOut) {
|
|
|
61040
61179
|
`\`openclaw plugins install\` finished, but ${dest} is not there`
|
|
61041
61180
|
);
|
|
61042
61181
|
writeAtomic(
|
|
61043
|
-
|
|
61182
|
+
join31(dest, OPENCLAW_MARKER),
|
|
61044
61183
|
`managed by the Open Artifacts bus installer: edits are replaced on reinstall. ${pluginHash(shipped)}
|
|
61045
61184
|
`
|
|
61046
61185
|
);
|
|
@@ -61103,7 +61242,7 @@ var OPENCLAW_PLUGIN = (() => {
|
|
|
61103
61242
|
const packaged = fileURLToPath5(
|
|
61104
61243
|
new URL("../assets/openclaw", import.meta.url)
|
|
61105
61244
|
);
|
|
61106
|
-
if (
|
|
61245
|
+
if (existsSync11(packaged)) return packaged;
|
|
61107
61246
|
return fileURLToPath5(
|
|
61108
61247
|
new URL("../../../bus-adapter-openclaw/dist", import.meta.url)
|
|
61109
61248
|
);
|
|
@@ -61137,21 +61276,21 @@ var habitsBlock = () => [
|
|
|
61137
61276
|
];
|
|
61138
61277
|
var piAgentDir = (home2, env2) => {
|
|
61139
61278
|
const d = env2.PI_CODING_AGENT_DIR;
|
|
61140
|
-
if (!d) return
|
|
61279
|
+
if (!d) return join32(home2, ".pi", "agent");
|
|
61141
61280
|
if (d === "~") return home2;
|
|
61142
|
-
return resolve10(d.startsWith("~/") ?
|
|
61281
|
+
return resolve10(d.startsWith("~/") ? join32(home2, d.slice(2)) : d);
|
|
61143
61282
|
};
|
|
61144
61283
|
function habitsFiles(deps2, h) {
|
|
61145
61284
|
const env2 = deps2.env ?? {};
|
|
61146
61285
|
const pair = (dir) => {
|
|
61147
|
-
const override =
|
|
61148
|
-
const plain3 =
|
|
61149
|
-
return
|
|
61286
|
+
const override = join32(dir, "AGENTS.override.md");
|
|
61287
|
+
const plain3 = join32(dir, "AGENTS.md");
|
|
61288
|
+
return existsSync12(override) ? [override, plain3] : [plain3, override];
|
|
61150
61289
|
};
|
|
61151
61290
|
switch (h) {
|
|
61152
61291
|
case "claude":
|
|
61153
61292
|
return [
|
|
61154
|
-
|
|
61293
|
+
join32(env2.CLAUDE_CONFIG_DIR ?? join32(deps2.home, ".claude"), "CLAUDE.md")
|
|
61155
61294
|
];
|
|
61156
61295
|
case "codex":
|
|
61157
61296
|
return pair(codexHome2(deps2.home, env2));
|
|
@@ -61159,8 +61298,8 @@ function habitsFiles(deps2, h) {
|
|
|
61159
61298
|
return pair(piAgentDir(deps2.home, env2));
|
|
61160
61299
|
case "opencode":
|
|
61161
61300
|
return [
|
|
61162
|
-
|
|
61163
|
-
env2.OPENCODE_CONFIG_DIR ??
|
|
61301
|
+
join32(
|
|
61302
|
+
env2.OPENCODE_CONFIG_DIR ?? join32(env2.XDG_CONFIG_HOME ?? join32(deps2.home, ".config"), "opencode"),
|
|
61164
61303
|
"AGENTS.md"
|
|
61165
61304
|
)
|
|
61166
61305
|
];
|
|
@@ -61241,7 +61380,7 @@ function linkInfo(deps2, path) {
|
|
|
61241
61380
|
}
|
|
61242
61381
|
}
|
|
61243
61382
|
var record6 = (busHome2) => {
|
|
61244
|
-
const raw = busHome2 ? readInstallFile(
|
|
61383
|
+
const raw = busHome2 ? readInstallFile(join32(busHome2, "install.json")).habits : void 0;
|
|
61245
61384
|
const h = typeof raw === "object" && raw !== null ? raw : {};
|
|
61246
61385
|
return {
|
|
61247
61386
|
optedOut: h.optedOut === true,
|
|
@@ -61261,7 +61400,7 @@ var pluginDirsOf = (v) => {
|
|
|
61261
61400
|
var saveRecord = (busHome2, patch) => {
|
|
61262
61401
|
if (!busHome2) return;
|
|
61263
61402
|
const cur = record6(busHome2);
|
|
61264
|
-
updateInstallFile(
|
|
61403
|
+
updateInstallFile(join32(busHome2, "install.json"), {
|
|
61265
61404
|
habits: { ...cur, ...patch }
|
|
61266
61405
|
});
|
|
61267
61406
|
};
|
|
@@ -61269,8 +61408,8 @@ function habitsFileState(deps2, h) {
|
|
|
61269
61408
|
const path = habitsTarget(deps2, h);
|
|
61270
61409
|
try {
|
|
61271
61410
|
if (brokenLink(path)) return { state: "broken", path };
|
|
61272
|
-
if (!
|
|
61273
|
-
return { ...blockState(
|
|
61411
|
+
if (!existsSync12(path)) return { state: "absent", path };
|
|
61412
|
+
return { ...blockState(readFileSync28(targetOf(path), "utf8")), path };
|
|
61274
61413
|
} catch {
|
|
61275
61414
|
return { state: "broken", path };
|
|
61276
61415
|
}
|
|
@@ -61297,8 +61436,8 @@ function writeHabits(deps2, harnesses, opts = {}) {
|
|
|
61297
61436
|
}
|
|
61298
61437
|
const real3 = targetOf(path);
|
|
61299
61438
|
try {
|
|
61300
|
-
const exists3 =
|
|
61301
|
-
const before = exists3 ?
|
|
61439
|
+
const exists3 = existsSync12(real3);
|
|
61440
|
+
const before = exists3 ? readFileSync28(real3, "utf8") : "";
|
|
61302
61441
|
const fresh = blockState(before).state === "absent";
|
|
61303
61442
|
const after = withHabits(before, habitsBlock());
|
|
61304
61443
|
if (after !== before) writeAtomic(real3, after);
|
|
@@ -61327,9 +61466,9 @@ function removeHabits(deps2, harnesses = HABITS_HARNESSES) {
|
|
|
61327
61466
|
if (seen2.has(path)) continue;
|
|
61328
61467
|
seen2.add(path);
|
|
61329
61468
|
try {
|
|
61330
|
-
if (brokenLink(path) || !
|
|
61469
|
+
if (brokenLink(path) || !existsSync12(path)) continue;
|
|
61331
61470
|
const real3 = targetOf(path);
|
|
61332
|
-
const before =
|
|
61471
|
+
const before = readFileSync28(real3, "utf8");
|
|
61333
61472
|
if (blockState(before).state === "absent") continue;
|
|
61334
61473
|
const rec = kept[path];
|
|
61335
61474
|
const after = withHabits(before, null, rec?.added);
|
|
@@ -61348,7 +61487,7 @@ function removeHabits(deps2, harnesses = HABITS_HARNESSES) {
|
|
|
61348
61487
|
const p = setPluginHabits(deps2, PLUGIN_HARNESSES, false);
|
|
61349
61488
|
files2.push(...p.markers);
|
|
61350
61489
|
notes.push(...p.notes);
|
|
61351
|
-
if (deps2.busHome &&
|
|
61490
|
+
if (deps2.busHome && existsSync12(join32(deps2.busHome, "install.json")))
|
|
61352
61491
|
saveRecord(deps2.busHome, { files: kept });
|
|
61353
61492
|
return {
|
|
61354
61493
|
files: files2,
|
|
@@ -61366,8 +61505,8 @@ function habitsOn(deps2) {
|
|
|
61366
61505
|
if (seen2.has(path)) continue;
|
|
61367
61506
|
seen2.add(path);
|
|
61368
61507
|
try {
|
|
61369
|
-
if (brokenLink(path) || !
|
|
61370
|
-
const s = blockState(
|
|
61508
|
+
if (brokenLink(path) || !existsSync12(path)) continue;
|
|
61509
|
+
const s = blockState(readFileSync28(targetOf(path), "utf8")).state;
|
|
61371
61510
|
if (s === "current" || s === "changed") out.push(path);
|
|
61372
61511
|
} catch {
|
|
61373
61512
|
}
|
|
@@ -61397,7 +61536,7 @@ var PLUGIN_HARNESSES = [
|
|
|
61397
61536
|
];
|
|
61398
61537
|
var pluginPaths = (deps2, p) => {
|
|
61399
61538
|
const dir = p.dir(deps2.home, deps2.env ?? {});
|
|
61400
|
-
return { dir, marker:
|
|
61539
|
+
return { dir, marker: join32(dir, p.marker) };
|
|
61401
61540
|
};
|
|
61402
61541
|
var pluginOurs = (dir, p) => {
|
|
61403
61542
|
try {
|
|
@@ -61432,11 +61571,11 @@ function setPluginHabits(deps2, plugins2, on) {
|
|
|
61432
61571
|
for (const p of plugins2) {
|
|
61433
61572
|
if (on) {
|
|
61434
61573
|
const dir = pluginPaths(deps2, p).dir;
|
|
61435
|
-
const marker =
|
|
61574
|
+
const marker = join32(dir, p.marker);
|
|
61436
61575
|
try {
|
|
61437
61576
|
if (isLink(dir) || !pluginOurs(dir, p)) {
|
|
61438
61577
|
notes.push(
|
|
61439
|
-
`Left the ${p.label} plugin alone: ${isLink(dir) ? `${dir} is a symlink.` :
|
|
61578
|
+
`Left the ${p.label} plugin alone: ${isLink(dir) ? `${dir} is a symlink.` : existsSync12(dir) ? `${dir} wasn't installed by ${BUS_CMD}` : `nothing installed at ${dir}.`}`
|
|
61440
61579
|
);
|
|
61441
61580
|
continue;
|
|
61442
61581
|
}
|
|
@@ -61477,7 +61616,7 @@ function setPluginHabits(deps2, plugins2, on) {
|
|
|
61477
61616
|
else notes.push(scan2.note);
|
|
61478
61617
|
}
|
|
61479
61618
|
for (const dir of dirs) {
|
|
61480
|
-
const marker =
|
|
61619
|
+
const marker = join32(dir, p.marker);
|
|
61481
61620
|
const d = probe(dir);
|
|
61482
61621
|
if (d.k === "absent") continue;
|
|
61483
61622
|
if (d.k === "error") {
|
|
@@ -61529,7 +61668,7 @@ function setPluginHabits(deps2, plugins2, on) {
|
|
|
61529
61668
|
done.add(dir);
|
|
61530
61669
|
if (!changed.includes(p)) changed.push(p);
|
|
61531
61670
|
}
|
|
61532
|
-
if (deps2.busHome &&
|
|
61671
|
+
if (deps2.busHome && existsSync12(join32(deps2.busHome, "install.json"))) {
|
|
61533
61672
|
const { pluginDirs } = record6(deps2.busHome);
|
|
61534
61673
|
const had = pluginDirs[p.name];
|
|
61535
61674
|
if (had !== void 0) {
|
|
@@ -61576,8 +61715,8 @@ var habitsQuestionLines = (q) => [
|
|
|
61576
61715
|
];
|
|
61577
61716
|
|
|
61578
61717
|
// src/steps/opencode-proof.ts
|
|
61579
|
-
import { existsSync as
|
|
61580
|
-
import { dirname as dirname14, isAbsolute as isAbsolute12, join as
|
|
61718
|
+
import { existsSync as existsSync13, readFileSync as readFileSync29, rmSync as rmSync17 } from "node:fs";
|
|
61719
|
+
import { dirname as dirname14, isAbsolute as isAbsolute12, join as join33, resolve as resolve11 } from "node:path";
|
|
61581
61720
|
init_src();
|
|
61582
61721
|
var OPENCODE_ENTRY_FILE = "opencode-mcp-entry.json";
|
|
61583
61722
|
var isRecord5 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
@@ -61619,7 +61758,7 @@ function tokenFileOf(e) {
|
|
|
61619
61758
|
var REMOTE_ONLY = /* @__PURE__ */ new Set(["type", "url", "headers", "oauth"]);
|
|
61620
61759
|
function resolveTokenFile(x, configFile, home2) {
|
|
61621
61760
|
if (x === "~") return home2;
|
|
61622
|
-
if (x.startsWith("~/")) return
|
|
61761
|
+
if (x.startsWith("~/")) return join33(home2, x.slice(2));
|
|
61623
61762
|
return isAbsolute12(x) ? x : resolve11(dirname14(configFile), x);
|
|
61624
61763
|
}
|
|
61625
61764
|
var proxyEntry = (io, origin, tokenFile, entry) => {
|
|
@@ -61659,7 +61798,7 @@ function ourEntry2(e, origin) {
|
|
|
61659
61798
|
}
|
|
61660
61799
|
function readMoved2(path) {
|
|
61661
61800
|
try {
|
|
61662
|
-
const v = JSON.parse(
|
|
61801
|
+
const v = JSON.parse(readFileSync29(path, "utf8"));
|
|
61663
61802
|
if (isRecord5(v) && typeof v.file === "string" && Array.isArray(v.path) && typeof v.origin === "string" && isRecord5(v.config))
|
|
61664
61803
|
return v;
|
|
61665
61804
|
} catch {
|
|
@@ -61732,7 +61871,7 @@ function restoreEntry2(io) {
|
|
|
61732
61871
|
const m = readMoved2(io.moved);
|
|
61733
61872
|
if (!m) return false;
|
|
61734
61873
|
let put2 = false;
|
|
61735
|
-
if (
|
|
61874
|
+
if (existsSync13(m.file)) {
|
|
61736
61875
|
const text3 = io.read(m.file);
|
|
61737
61876
|
const now = jsoncValue(text3, m.path);
|
|
61738
61877
|
if (isRecord5(now) && ourEntry2(now, m.origin)) {
|
|
@@ -61757,7 +61896,7 @@ function proxyProgramMissing2(entry, origin, which2) {
|
|
|
61757
61896
|
if (origin !== void 0 && c[i + 2] !== origin) return void 0;
|
|
61758
61897
|
for (const part of c.slice(0, i)) {
|
|
61759
61898
|
if (typeof part !== "string") continue;
|
|
61760
|
-
if (isAbsolute12(part) ? !
|
|
61899
|
+
if (isAbsolute12(part) ? !existsSync13(part) : !which2(part)) return part;
|
|
61761
61900
|
}
|
|
61762
61901
|
return void 0;
|
|
61763
61902
|
}
|
|
@@ -61790,15 +61929,15 @@ function skippedNotes(files2, read2, origin) {
|
|
|
61790
61929
|
}
|
|
61791
61930
|
|
|
61792
61931
|
// src/steps/pi-proof.ts
|
|
61793
|
-
import { existsSync as
|
|
61932
|
+
import { existsSync as existsSync14, readFileSync as readFileSync30, rmSync as rmSync18 } from "node:fs";
|
|
61794
61933
|
var PI_ENTRY_FILE = "pi-mcp-entry.json";
|
|
61795
61934
|
var OMP_ORIGIN_FILE = "omp-mcp-origin.json";
|
|
61796
61935
|
var PI_MIN_VERSION = "1.5.0";
|
|
61797
61936
|
var isRecord6 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
61798
61937
|
var BOM2 = "\uFEFF";
|
|
61799
61938
|
function readConfig2(file2) {
|
|
61800
|
-
if (!
|
|
61801
|
-
const raw =
|
|
61939
|
+
if (!existsSync14(file2)) return null;
|
|
61940
|
+
const raw = readFileSync30(file2, "utf8");
|
|
61802
61941
|
const bom = raw.startsWith(BOM2);
|
|
61803
61942
|
const text3 = bom ? raw.slice(1) : raw;
|
|
61804
61943
|
const parsed = JSON.parse(text3);
|
|
@@ -61832,7 +61971,7 @@ function findEntry(servers4, origin) {
|
|
|
61832
61971
|
}
|
|
61833
61972
|
function readMoved3(path) {
|
|
61834
61973
|
try {
|
|
61835
|
-
const v = JSON.parse(
|
|
61974
|
+
const v = JSON.parse(readFileSync30(path, "utf8"));
|
|
61836
61975
|
if (isRecord6(v) && typeof v.name === "string" && typeof v.index === "number" && isRecord6(v.config))
|
|
61837
61976
|
return {
|
|
61838
61977
|
name: v.name,
|
|
@@ -61902,8 +62041,8 @@ var HARNESSES = [
|
|
|
61902
62041
|
"openclaw"
|
|
61903
62042
|
];
|
|
61904
62043
|
var readAssets = () => ({
|
|
61905
|
-
pi:
|
|
61906
|
-
opencodePlugin:
|
|
62044
|
+
pi: readFileSync31(PI_EXTENSION, "utf8"),
|
|
62045
|
+
opencodePlugin: readFileSync31(OPENCODE_TUI_PLUGIN, "utf8"),
|
|
61907
62046
|
// A folder, not text: the plugin is several Python files.
|
|
61908
62047
|
hermes: HERMES_PLUGIN,
|
|
61909
62048
|
// Built from packages/bus-adapter-openclaw (the CLI's bundle step does it).
|
|
@@ -61912,44 +62051,44 @@ var readAssets = () => ({
|
|
|
61912
62051
|
var movedHome = (deps2) => {
|
|
61913
62052
|
if (deps2.busHome === void 0) return void 0;
|
|
61914
62053
|
const ob = resolve12(deps2.busHome);
|
|
61915
|
-
return ob ===
|
|
62054
|
+
return ob === join34(deps2.home, ".oa-bus") ? void 0 : ob;
|
|
61916
62055
|
};
|
|
61917
62056
|
var homeLine = (ob) => `process.env.OA_BUS_HOME ||= ${JSON.stringify(ob)};`;
|
|
61918
62057
|
var withHome = (text3, ob) => ob === void 0 ? text3 : `${homeLine(ob)}
|
|
61919
62058
|
${text3}`;
|
|
61920
62059
|
var paths = (deps2) => {
|
|
61921
62060
|
const env2 = deps2.env ?? {};
|
|
61922
|
-
const opencode = env2.OPENCODE_CONFIG_DIR ??
|
|
61923
|
-
const busDir = deps2.busHome ??
|
|
62061
|
+
const opencode = env2.OPENCODE_CONFIG_DIR ?? join34(env2.XDG_CONFIG_HOME ?? join34(deps2.home, ".config"), "opencode");
|
|
62062
|
+
const busDir = deps2.busHome ?? join34(deps2.home, ".oa-bus");
|
|
61924
62063
|
return {
|
|
61925
62064
|
claude: claudeConfigFile(deps2.home, env2),
|
|
61926
62065
|
// OpenCode reads both; edit the one the user has, else create .json.
|
|
61927
62066
|
opencodeConfigs: [
|
|
61928
|
-
|
|
61929
|
-
|
|
62067
|
+
join34(opencode, "opencode.json"),
|
|
62068
|
+
join34(opencode, "opencode.jsonc")
|
|
61930
62069
|
],
|
|
61931
|
-
opencodeCli:
|
|
61932
|
-
record:
|
|
62070
|
+
opencodeCli: join34(opencode, "cli.json"),
|
|
62071
|
+
record: join34(busDir, "install.json"),
|
|
61933
62072
|
// #1856: where install keeps the OpenCode entry it replaced with the proxy.
|
|
61934
|
-
opencodeEntry:
|
|
62073
|
+
opencodeEntry: join34(busDir, OPENCODE_ENTRY_FILE),
|
|
61935
62074
|
// #1856: Pi's own MCP config, and where install keeps the entry it moved.
|
|
61936
|
-
piMcp:
|
|
61937
|
-
agentDirEnv(deps2.home, env2) ??
|
|
62075
|
+
piMcp: join34(
|
|
62076
|
+
agentDirEnv(deps2.home, env2) ?? join34(deps2.home, ".pi/agent"),
|
|
61938
62077
|
"mcp.json"
|
|
61939
62078
|
),
|
|
61940
|
-
piEntry:
|
|
61941
|
-
ompOrigin:
|
|
62079
|
+
piEntry: join34(busDir, PI_ENTRY_FILE),
|
|
62080
|
+
ompOrigin: join34(busDir, OMP_ORIGIN_FILE),
|
|
61942
62081
|
// OpenCode registers the folder that holds tui.js.
|
|
61943
|
-
opencodePlugin:
|
|
61944
|
-
pi:
|
|
61945
|
-
agentDirEnv(deps2.home, env2) ??
|
|
62082
|
+
opencodePlugin: join34(busDir, "integrations/opencode", NAME),
|
|
62083
|
+
pi: join34(
|
|
62084
|
+
agentDirEnv(deps2.home, env2) ?? join34(deps2.home, ".pi/agent"),
|
|
61946
62085
|
"extensions/oa-bus.ts"
|
|
61947
62086
|
),
|
|
61948
|
-
omp:
|
|
62087
|
+
omp: join34(ompAgentDir(deps2.home, env2), "extensions/oa-bus.ts"),
|
|
61949
62088
|
codex: codexConfig(deps2.home, env2),
|
|
61950
62089
|
codexBin: codexBinFile(busDir),
|
|
61951
62090
|
// #1856: where install keeps the Codex entry it swapped for the proxy.
|
|
61952
|
-
codexEntry:
|
|
62091
|
+
codexEntry: join34(busDir, CODEX_PROXY_ENTRY_FILE),
|
|
61953
62092
|
busDir
|
|
61954
62093
|
};
|
|
61955
62094
|
};
|
|
@@ -61957,9 +62096,9 @@ function agentDirEnv(home2, env2) {
|
|
|
61957
62096
|
const dir = env2.PI_CODING_AGENT_DIR;
|
|
61958
62097
|
if (!dir) return void 0;
|
|
61959
62098
|
if (dir === "~") return home2;
|
|
61960
|
-
return resolve12(dir.startsWith("~/") ?
|
|
62099
|
+
return resolve12(dir.startsWith("~/") ? join34(home2, dir.slice(2)) : dir);
|
|
61961
62100
|
}
|
|
61962
|
-
var ompRoot = (home2, env2) =>
|
|
62101
|
+
var ompRoot = (home2, env2) => join34(home2, env2.PI_CONFIG_DIR || ".omp");
|
|
61963
62102
|
function ompProfile(env2) {
|
|
61964
62103
|
const name = (env2.OMP_PROFILE !== void 0 ? env2.OMP_PROFILE : env2.PI_PROFILE)?.trim();
|
|
61965
62104
|
if (!name || name === "default" || name.endsWith(".")) return void 0;
|
|
@@ -61968,19 +62107,19 @@ function ompProfile(env2) {
|
|
|
61968
62107
|
function ompAgentDir(home2, env2) {
|
|
61969
62108
|
const root = ompRoot(home2, env2);
|
|
61970
62109
|
const profile = ompProfile(env2);
|
|
61971
|
-
if (profile) return
|
|
62110
|
+
if (profile) return join34(root, "profiles", profile, "agent");
|
|
61972
62111
|
const piProfile = ompProfile({ PI_PROFILE: env2.PI_PROFILE });
|
|
61973
62112
|
const dir = agentDirEnv(home2, env2);
|
|
61974
|
-
if (dir && !(piProfile && dir ===
|
|
62113
|
+
if (dir && !(piProfile && dir === join34(root, "profiles", piProfile, "agent")))
|
|
61975
62114
|
return dir;
|
|
61976
|
-
return
|
|
62115
|
+
return join34(root, "agent");
|
|
61977
62116
|
}
|
|
61978
|
-
var hasOmp = (deps2) => deps2.which("omp") || present2(ompRoot(deps2.home, deps2.env ?? {})) || present2(
|
|
62117
|
+
var hasOmp = (deps2) => deps2.which("omp") || present2(ompRoot(deps2.home, deps2.env ?? {})) || present2(join34(deps2.home, ".bun/bin/omp"));
|
|
61979
62118
|
var sharedFile = (deps2) => paths(deps2).omp === paths(deps2).pi;
|
|
61980
62119
|
function readDoc(path) {
|
|
61981
62120
|
let text3;
|
|
61982
62121
|
try {
|
|
61983
|
-
text3 =
|
|
62122
|
+
text3 = readFileSync31(path, "utf8");
|
|
61984
62123
|
} catch (e) {
|
|
61985
62124
|
if (e.code === "ENOENT") return {};
|
|
61986
62125
|
throw e;
|
|
@@ -62005,7 +62144,7 @@ function target(path) {
|
|
|
62005
62144
|
let p = path;
|
|
62006
62145
|
for (let hops = 0; hops < 40; hops++) {
|
|
62007
62146
|
if (!present2(p) || !lstatSync17(p).isSymbolicLink()) {
|
|
62008
|
-
if (p !== path && !
|
|
62147
|
+
if (p !== path && !existsSync15(dirname15(p)))
|
|
62009
62148
|
throw new Error(
|
|
62010
62149
|
`${path} is a dangling symlink to ${p}; left it untouched`
|
|
62011
62150
|
);
|
|
@@ -62017,17 +62156,17 @@ function target(path) {
|
|
|
62017
62156
|
}
|
|
62018
62157
|
function writeAtomic2(path, data, mode) {
|
|
62019
62158
|
const dest = target(path);
|
|
62020
|
-
|
|
62159
|
+
mkdirSync15(dirname15(dest), { recursive: true });
|
|
62021
62160
|
let m = mode ?? 420;
|
|
62022
62161
|
if (mode === void 0)
|
|
62023
62162
|
try {
|
|
62024
|
-
m =
|
|
62163
|
+
m = statSync10(dest).mode & 511;
|
|
62025
62164
|
} catch {
|
|
62026
62165
|
}
|
|
62027
|
-
const tmp = `${dest}.${process.pid}.${
|
|
62166
|
+
const tmp = `${dest}.${process.pid}.${randomBytes7(4).toString("hex")}.tmp`;
|
|
62028
62167
|
try {
|
|
62029
62168
|
writeFileSync18(tmp, data, { mode: m, flag: "wx" });
|
|
62030
|
-
|
|
62169
|
+
chmodSync20(tmp, m);
|
|
62031
62170
|
renameSync19(tmp, dest);
|
|
62032
62171
|
} catch (e) {
|
|
62033
62172
|
rmSync19(tmp, { force: true });
|
|
@@ -62037,7 +62176,7 @@ function writeAtomic2(path, data, mode) {
|
|
|
62037
62176
|
function readJsonc(path) {
|
|
62038
62177
|
let text3;
|
|
62039
62178
|
try {
|
|
62040
|
-
text3 =
|
|
62179
|
+
text3 = readFileSync31(path, "utf8");
|
|
62041
62180
|
} catch (e) {
|
|
62042
62181
|
if (e.code === "ENOENT") return "";
|
|
62043
62182
|
throw e;
|
|
@@ -62054,7 +62193,7 @@ function saveText(path, before, next, ok) {
|
|
|
62054
62193
|
}
|
|
62055
62194
|
function readRecord2(path) {
|
|
62056
62195
|
try {
|
|
62057
|
-
const v = JSON.parse(
|
|
62196
|
+
const v = JSON.parse(readFileSync31(path, "utf8"));
|
|
62058
62197
|
const c = v?.created;
|
|
62059
62198
|
if (typeof c === "object" && c !== null) return c;
|
|
62060
62199
|
} catch {
|
|
@@ -62065,7 +62204,7 @@ function writeRecord2(path, before, created) {
|
|
|
62065
62204
|
if (isDeepStrictEqual(before, created)) return;
|
|
62066
62205
|
let rest = {};
|
|
62067
62206
|
try {
|
|
62068
|
-
const v = JSON.parse(
|
|
62207
|
+
const v = JSON.parse(readFileSync31(path, "utf8"));
|
|
62069
62208
|
if (typeof v === "object" && v !== null && !Array.isArray(v))
|
|
62070
62209
|
rest = v;
|
|
62071
62210
|
} catch {
|
|
@@ -62262,7 +62401,7 @@ var install = {
|
|
|
62262
62401
|
if (!deps2.which("claude")) return "absent";
|
|
62263
62402
|
await run4(deps2, "claude", ["mcp", "remove", "--scope", "user", NAME]);
|
|
62264
62403
|
const moved = movedHome(deps2);
|
|
62265
|
-
const
|
|
62404
|
+
const add2 = await run4(deps2, "claude", [
|
|
62266
62405
|
"mcp",
|
|
62267
62406
|
"add",
|
|
62268
62407
|
"--scope",
|
|
@@ -62275,7 +62414,7 @@ var install = {
|
|
|
62275
62414
|
"mcp",
|
|
62276
62415
|
"claude"
|
|
62277
62416
|
]);
|
|
62278
|
-
if (
|
|
62417
|
+
if (add2.code === 0) {
|
|
62279
62418
|
claudeProof(deps2, notes);
|
|
62280
62419
|
return "done";
|
|
62281
62420
|
}
|
|
@@ -62292,7 +62431,7 @@ var install = {
|
|
|
62292
62431
|
})
|
|
62293
62432
|
);
|
|
62294
62433
|
notes.push(
|
|
62295
|
-
`claude mcp add failed (${firstLine3(
|
|
62434
|
+
`claude mcp add failed (${firstLine3(add2.stderr)}); wrote ${path} directly`
|
|
62296
62435
|
);
|
|
62297
62436
|
claudeProof(deps2, notes);
|
|
62298
62437
|
return "done";
|
|
@@ -62320,7 +62459,7 @@ var install = {
|
|
|
62320
62459
|
target(configPath);
|
|
62321
62460
|
target(p.opencodeCli);
|
|
62322
62461
|
const record7 = readRecord2(p.record);
|
|
62323
|
-
const
|
|
62462
|
+
const add2 = (file2, made) => {
|
|
62324
62463
|
const all = [...record7[file2] ?? [], ...made];
|
|
62325
62464
|
return all.filter(
|
|
62326
62465
|
(x, i) => all.findIndex((y) => isDeepStrictEqual(x, y)) === i
|
|
@@ -62330,15 +62469,15 @@ var install = {
|
|
|
62330
62469
|
const madeConfig = missing(config2, [["mcp"], ["mcp", "servers"]]);
|
|
62331
62470
|
const madeCli = missing(cli, [["plugins"]]);
|
|
62332
62471
|
if (madeConfig.length > 0)
|
|
62333
|
-
created[configPath] =
|
|
62472
|
+
created[configPath] = add2(configPath, madeConfig);
|
|
62334
62473
|
if (madeCli.length > 0)
|
|
62335
|
-
created[p.opencodeCli] =
|
|
62474
|
+
created[p.opencodeCli] = add2(p.opencodeCli, madeCli);
|
|
62336
62475
|
writeRecord2(p.record, record7, created);
|
|
62337
|
-
const pluginFile =
|
|
62476
|
+
const pluginFile = join34(p.opencodePlugin, "tui.js");
|
|
62338
62477
|
const pluginText = withHome(deps2.assets.opencodePlugin, movedHome(deps2));
|
|
62339
62478
|
let pluginBefore;
|
|
62340
62479
|
try {
|
|
62341
|
-
pluginBefore =
|
|
62480
|
+
pluginBefore = readFileSync31(pluginFile, "utf8");
|
|
62342
62481
|
} catch {
|
|
62343
62482
|
}
|
|
62344
62483
|
const touched = { changed: pluginBefore !== pluginText };
|
|
@@ -62395,7 +62534,7 @@ var install = {
|
|
|
62395
62534
|
if (next !== text3) {
|
|
62396
62535
|
const bak = `${p.codex}.oa-bus.bak`;
|
|
62397
62536
|
if (text3 !== "" && !present2(bak))
|
|
62398
|
-
writeAtomic2(bak, text3,
|
|
62537
|
+
writeAtomic2(bak, text3, statSync10(dest).mode & 511);
|
|
62399
62538
|
writeAtomic2(p.codex, next);
|
|
62400
62539
|
}
|
|
62401
62540
|
const bin = findCodexBin({ path: deps2.env?.PATH, app: deps2.codexApp });
|
|
@@ -62403,7 +62542,7 @@ var install = {
|
|
|
62403
62542
|
const pin = codexBinPin(bin);
|
|
62404
62543
|
let had = "";
|
|
62405
62544
|
try {
|
|
62406
|
-
had =
|
|
62545
|
+
had = readFileSync31(p.codexBin, "utf8");
|
|
62407
62546
|
} catch {
|
|
62408
62547
|
}
|
|
62409
62548
|
if (had !== pin) writeAtomic2(p.codexBin, pin, 384);
|
|
@@ -62487,7 +62626,7 @@ var uninstall = {
|
|
|
62487
62626
|
const left = { ...record7 };
|
|
62488
62627
|
for (const { file: file2 } of edits) delete left[file2];
|
|
62489
62628
|
writeRecord2(p.record, record7, left);
|
|
62490
|
-
const hadPlugin =
|
|
62629
|
+
const hadPlugin = existsSync15(p.opencodePlugin);
|
|
62491
62630
|
rmSync19(p.opencodePlugin, { recursive: true, force: true });
|
|
62492
62631
|
if (!saved.some(Boolean) && !hadPlugin && !restored) return "none";
|
|
62493
62632
|
if (deps2.which("opencode")) await restartOpencode(deps2, notes, true);
|
|
@@ -62505,16 +62644,16 @@ var uninstall = {
|
|
|
62505
62644
|
throw new Error("kept the extension, the entry is still moved");
|
|
62506
62645
|
}
|
|
62507
62646
|
const path = paths(deps2).pi;
|
|
62508
|
-
if (!
|
|
62647
|
+
if (!existsSync15(path)) return restored ? "done" : "none";
|
|
62509
62648
|
rmSync19(path, { force: true });
|
|
62510
62649
|
return "done";
|
|
62511
62650
|
},
|
|
62512
62651
|
async omp(deps2, _notes, done) {
|
|
62513
62652
|
rmSync19(paths(deps2).ompOrigin, { force: true });
|
|
62514
62653
|
if (sharedFile(deps2) && done.includes("pi")) return "done";
|
|
62515
|
-
if (sharedFile(deps2) &&
|
|
62654
|
+
if (sharedFile(deps2) && existsSync15(paths(deps2).piEntry)) return "none";
|
|
62516
62655
|
const path = paths(deps2).omp;
|
|
62517
|
-
if (!
|
|
62656
|
+
if (!existsSync15(path)) return "none";
|
|
62518
62657
|
rmSync19(path, { force: true });
|
|
62519
62658
|
return "done";
|
|
62520
62659
|
},
|
|
@@ -62610,7 +62749,7 @@ function opencodeProxyProblem(deps2) {
|
|
|
62610
62749
|
const p = paths(deps2);
|
|
62611
62750
|
for (const f of p.opencodeConfigs.filter(present2))
|
|
62612
62751
|
try {
|
|
62613
|
-
for (const { name, entry } of proxyEntries(
|
|
62752
|
+
for (const { name, entry } of proxyEntries(readFileSync31(f, "utf8"))) {
|
|
62614
62753
|
const missing2 = proxyProgramMissing2(entry, void 0, deps2.which);
|
|
62615
62754
|
if (missing2 !== void 0) return { name, missing: missing2 };
|
|
62616
62755
|
}
|
|
@@ -62629,8 +62768,8 @@ function checkAdapters(deps2) {
|
|
|
62629
62768
|
};
|
|
62630
62769
|
const homeOf = (env2) => typeof env2 === "object" && env2 !== null ? env2.OA_BUS_HOME : void 0;
|
|
62631
62770
|
const homed = (file2) => {
|
|
62632
|
-
if (!
|
|
62633
|
-
const first =
|
|
62771
|
+
if (!existsSync15(file2)) return false;
|
|
62772
|
+
const first = readFileSync31(file2, "utf8").split("\n", 1)[0] ?? "";
|
|
62634
62773
|
const ob = movedHome(deps2);
|
|
62635
62774
|
return ob === void 0 ? !first.startsWith("process.env.OA_BUS_HOME ||=") : first === homeLine(ob);
|
|
62636
62775
|
};
|
|
@@ -62646,13 +62785,13 @@ function checkAdapters(deps2) {
|
|
|
62646
62785
|
opencode: state(
|
|
62647
62786
|
"opencode",
|
|
62648
62787
|
() => p.opencodeConfigs.filter(present2).some((f) => {
|
|
62649
|
-
const d = parseJsonc(
|
|
62788
|
+
const d = parseJsonc(readFileSync31(f, "utf8"), f);
|
|
62650
62789
|
const e = servers3(d)?.[NAME] ?? d.mcp?.[NAME];
|
|
62651
62790
|
return e !== void 0 && homeOf(e.environment) === movedHome(deps2);
|
|
62652
62791
|
}) && listed(
|
|
62653
|
-
parseJsonc(
|
|
62792
|
+
parseJsonc(readFileSync31(p.opencodeCli, "utf8"), p.opencodeCli),
|
|
62654
62793
|
p.opencodePlugin
|
|
62655
|
-
) && homed(
|
|
62794
|
+
) && homed(join34(p.opencodePlugin, "tui.js"))
|
|
62656
62795
|
),
|
|
62657
62796
|
pi: state("pi", () => homed(p.pi)),
|
|
62658
62797
|
omp: state("omp", () => homed(p.omp)),
|
|
@@ -62746,24 +62885,24 @@ function recordClaudeProof(deps2) {
|
|
|
62746
62885
|
// src/steps/path-shim.ts
|
|
62747
62886
|
import {
|
|
62748
62887
|
accessSync as accessSync2,
|
|
62749
|
-
chmodSync as
|
|
62888
|
+
chmodSync as chmodSync21,
|
|
62750
62889
|
constants as constants6,
|
|
62751
62890
|
lstatSync as lstatSync18,
|
|
62752
|
-
mkdirSync as
|
|
62753
|
-
readFileSync as
|
|
62891
|
+
mkdirSync as mkdirSync16,
|
|
62892
|
+
readFileSync as readFileSync32,
|
|
62754
62893
|
readlinkSync as readlinkSync6,
|
|
62755
62894
|
renameSync as renameSync20,
|
|
62756
62895
|
rmSync as rmSync20,
|
|
62757
62896
|
writeFileSync as writeFileSync19
|
|
62758
62897
|
} from "node:fs";
|
|
62759
|
-
import { delimiter as delimiter3, dirname as dirname16, join as
|
|
62898
|
+
import { delimiter as delimiter3, dirname as dirname16, join as join35, resolve as resolve13, sep as sep5 } from "node:path";
|
|
62760
62899
|
var SHIM_MARKER = "# oa-bus shim: written by oa-bus install";
|
|
62761
62900
|
var HOME_PREFIX = "# oa-bus home: ";
|
|
62762
62901
|
var NAME2 = "oa-bus";
|
|
62763
62902
|
var LOCAL_HINT = 'export PATH="$HOME/.local/bin:$PATH"';
|
|
62764
62903
|
var isWindows = (platform) => platform.startsWith("win32");
|
|
62765
62904
|
var pathDirs = (p) => (p ?? "").split(delimiter3).filter((d) => d !== "").map((d) => resolve13(d));
|
|
62766
|
-
var candidates2 = (o) => o.platform.startsWith("darwin") ? [
|
|
62905
|
+
var candidates2 = (o) => o.platform.startsWith("darwin") ? [join35(o.userHome, ".local", "bin"), join35(o.userHome, "bin")] : [join35(o.userHome, ".local", "bin")];
|
|
62767
62906
|
var shQuote2 = (v) => `'${v.replaceAll("'", `'\\''`)}'`;
|
|
62768
62907
|
function shimText(o) {
|
|
62769
62908
|
const moved = resolve13(o.busHome) !== resolve13(o.userHome, ".oa-bus");
|
|
@@ -62794,7 +62933,7 @@ function ownerOf(file2, busHome2) {
|
|
|
62794
62933
|
}
|
|
62795
62934
|
if (!st.isFile() || st.size > 4096) return { ours: false };
|
|
62796
62935
|
try {
|
|
62797
|
-
const lines =
|
|
62936
|
+
const lines = readFileSync32(file2, "utf8").split("\n");
|
|
62798
62937
|
if (lines[1] !== SHIM_MARKER) return { ours: false };
|
|
62799
62938
|
const h = lines[2]?.startsWith(HOME_PREFIX) ? lines[2].slice(HOME_PREFIX.length) : void 0;
|
|
62800
62939
|
return { ours: true, home: h };
|
|
@@ -62808,7 +62947,7 @@ function writeShim(path, text3) {
|
|
|
62808
62947
|
rmSync20(tmp, { force: true });
|
|
62809
62948
|
try {
|
|
62810
62949
|
writeFileSync19(tmp, text3, { mode: 493, flag: "wx" });
|
|
62811
|
-
|
|
62950
|
+
chmodSync21(tmp, 493);
|
|
62812
62951
|
renameSync20(tmp, path);
|
|
62813
62952
|
} catch (e) {
|
|
62814
62953
|
rmSync20(tmp, { force: true });
|
|
@@ -62820,16 +62959,16 @@ function installShim(o) {
|
|
|
62820
62959
|
const onPath = new Set(pathDirs(o.env.PATH));
|
|
62821
62960
|
const list = candidates2(o);
|
|
62822
62961
|
const dir = list.find((d) => onPath.has(d)) ?? list[0];
|
|
62823
|
-
const path =
|
|
62962
|
+
const path = join35(dir, NAME2);
|
|
62824
62963
|
const owner = ownerOf(path, o.busHome);
|
|
62825
62964
|
if (owner && !owner.ours) return { kind: "foreign", path };
|
|
62826
62965
|
if (owner?.ours && !sameHome(owner, o.busHome))
|
|
62827
62966
|
return { kind: "other-home", path, home: owner.home };
|
|
62828
|
-
|
|
62967
|
+
mkdirSync16(dir, { recursive: true });
|
|
62829
62968
|
const text3 = shimText(o);
|
|
62830
62969
|
writeShim(path, text3);
|
|
62831
62970
|
for (const d of list) {
|
|
62832
|
-
const other =
|
|
62971
|
+
const other = join35(d, NAME2);
|
|
62833
62972
|
if (d !== dir && sameHome(ownerOf(other, o.busHome), o.busHome))
|
|
62834
62973
|
writeShim(other, text3);
|
|
62835
62974
|
}
|
|
@@ -62845,7 +62984,7 @@ function removeShim(o) {
|
|
|
62845
62984
|
if (isWindows(o.platform)) return void 0;
|
|
62846
62985
|
let removed;
|
|
62847
62986
|
for (const dir of candidates2({ ...o, env: {} })) {
|
|
62848
|
-
const file2 =
|
|
62987
|
+
const file2 = join35(dir, NAME2);
|
|
62849
62988
|
const owner = ownerOf(file2, o.busHome);
|
|
62850
62989
|
if (!owner?.ours) continue;
|
|
62851
62990
|
if (owner.home !== void 0 && owner.home !== resolve13(o.busHome)) continue;
|
|
@@ -62868,13 +63007,13 @@ function shimState(o) {
|
|
|
62868
63007
|
(d) => !(d.endsWith(`${sep5}node_modules${sep5}.bin`) && d.split(sep5).includes("_npx"))
|
|
62869
63008
|
);
|
|
62870
63009
|
for (const dir of dirs) {
|
|
62871
|
-
const file2 =
|
|
63010
|
+
const file2 = join35(dir, NAME2);
|
|
62872
63011
|
if (!executable2(file2)) continue;
|
|
62873
63012
|
const owner = ownerOf(file2, o.busHome);
|
|
62874
63013
|
return owner?.ours && (owner.home === void 0 || owner.home === resolve13(o.busHome)) ? { kind: "ours", path: file2 } : { kind: "other", path: file2 };
|
|
62875
63014
|
}
|
|
62876
63015
|
for (const dir of candidates2(o)) {
|
|
62877
|
-
const file2 =
|
|
63016
|
+
const file2 = join35(dir, NAME2);
|
|
62878
63017
|
const owner = ownerOf(file2, o.busHome);
|
|
62879
63018
|
if (owner?.ours && (owner.home === void 0 || owner.home === resolve13(o.busHome)))
|
|
62880
63019
|
return { kind: "off-path", path: file2, hint: LOCAL_HINT };
|
|
@@ -62926,6 +63065,345 @@ function useBusCmd(ctx) {
|
|
|
62926
63065
|
ctx.copy = copyFor(ctx, cmd);
|
|
62927
63066
|
}
|
|
62928
63067
|
|
|
63068
|
+
// src/commands/add.ts
|
|
63069
|
+
init_src2();
|
|
63070
|
+
|
|
63071
|
+
// src/commands/login.ts
|
|
63072
|
+
import { randomBytes as randomBytes8 } from "node:crypto";
|
|
63073
|
+
import {
|
|
63074
|
+
chmodSync as chmodSync22,
|
|
63075
|
+
closeSync as closeSync10,
|
|
63076
|
+
mkdirSync as mkdirSync17,
|
|
63077
|
+
openSync as openSync10,
|
|
63078
|
+
renameSync as renameSync21,
|
|
63079
|
+
rmSync as rmSync21,
|
|
63080
|
+
unlinkSync as unlinkSync4,
|
|
63081
|
+
writeSync as writeSync5
|
|
63082
|
+
} from "node:fs";
|
|
63083
|
+
import { join as join36 } from "node:path";
|
|
63084
|
+
init_src();
|
|
63085
|
+
|
|
63086
|
+
// src/machine-label.ts
|
|
63087
|
+
import { hostname as osHostname } from "node:os";
|
|
63088
|
+
var shortHost = (h) => h.trim().split(".")[0] ?? "";
|
|
63089
|
+
async function defaultMachineLabel(d) {
|
|
63090
|
+
if ((d.platform ?? process.platform) === "darwin") {
|
|
63091
|
+
for (const key2 of ["ComputerName", "LocalHostName"]) {
|
|
63092
|
+
try {
|
|
63093
|
+
const r = await d.exec("scutil", ["--get", key2]);
|
|
63094
|
+
const v = r.stdout.trim();
|
|
63095
|
+
if (r.code === 0 && v) return v;
|
|
63096
|
+
} catch {
|
|
63097
|
+
}
|
|
63098
|
+
}
|
|
63099
|
+
}
|
|
63100
|
+
return shortHost((d.hostname ?? osHostname)());
|
|
63101
|
+
}
|
|
63102
|
+
|
|
63103
|
+
// src/commands/login.ts
|
|
63104
|
+
var LoginFailed = class extends Error {
|
|
63105
|
+
constructor(kind4, message, detail = {}) {
|
|
63106
|
+
super(message);
|
|
63107
|
+
this.kind = kind4;
|
|
63108
|
+
this.detail = detail;
|
|
63109
|
+
}
|
|
63110
|
+
kind;
|
|
63111
|
+
detail;
|
|
63112
|
+
};
|
|
63113
|
+
var CODE_TIMEOUT_MS = 1e4;
|
|
63114
|
+
function errorTail(e) {
|
|
63115
|
+
const err = e;
|
|
63116
|
+
if (err?.name === "TimeoutError" || err?.name === "AbortError")
|
|
63117
|
+
return "timeout";
|
|
63118
|
+
return err?.cause?.code ?? err?.code ?? "network error";
|
|
63119
|
+
}
|
|
63120
|
+
var RedirectRefused = class extends Error {
|
|
63121
|
+
};
|
|
63122
|
+
var POLL_MAX_BACKOFF_MS = 3e4;
|
|
63123
|
+
var normalizeHub = (hub) => hub.replace(/\/+$/, "");
|
|
63124
|
+
function checkVerificationUri(uri, hub) {
|
|
63125
|
+
if (!verificationUriMatches(uri, hub))
|
|
63126
|
+
throw new Error(
|
|
63127
|
+
"bus/device returned a verification_uri that is not the instance's approval page"
|
|
63128
|
+
);
|
|
63129
|
+
return uri;
|
|
63130
|
+
}
|
|
63131
|
+
function writeMachineFile(home2, body) {
|
|
63132
|
+
mkdirSync17(home2, { recursive: true, mode: 448 });
|
|
63133
|
+
chmodSync22(home2, 448);
|
|
63134
|
+
const tmp = join36(home2, `.machine.json.${randomBytes8(8).toString("hex")}.tmp`);
|
|
63135
|
+
const fd = openSync10(tmp, "wx", 384);
|
|
63136
|
+
try {
|
|
63137
|
+
writeSync5(fd, body);
|
|
63138
|
+
} catch (e) {
|
|
63139
|
+
closeSync10(fd);
|
|
63140
|
+
unlinkSync4(tmp);
|
|
63141
|
+
throw e;
|
|
63142
|
+
}
|
|
63143
|
+
closeSync10(fd);
|
|
63144
|
+
try {
|
|
63145
|
+
chmodSync22(tmp, 384);
|
|
63146
|
+
renameSync21(tmp, join36(home2, "machine.json"));
|
|
63147
|
+
} catch (e) {
|
|
63148
|
+
unlinkSync4(tmp);
|
|
63149
|
+
throw e;
|
|
63150
|
+
}
|
|
63151
|
+
}
|
|
63152
|
+
async function post(hub, fetch2, path, body, signal, noRedirect) {
|
|
63153
|
+
const res = await fetch2(`${hub}${path}`, {
|
|
63154
|
+
method: "POST",
|
|
63155
|
+
headers: { "content-type": "application/json" },
|
|
63156
|
+
body: JSON.stringify(body),
|
|
63157
|
+
...signal ? { signal } : {},
|
|
63158
|
+
...noRedirect ? { redirect: "manual" } : {}
|
|
63159
|
+
});
|
|
63160
|
+
if (noRedirect && (res.type === "opaqueredirect" || res.status >= 300 && res.status < 400))
|
|
63161
|
+
throw new RedirectRefused(
|
|
63162
|
+
"the address redirected somewhere else; nothing was saved"
|
|
63163
|
+
);
|
|
63164
|
+
return res;
|
|
63165
|
+
}
|
|
63166
|
+
async function requestCode(args, hub, label2) {
|
|
63167
|
+
const waits = args.codeRetryMs ?? [];
|
|
63168
|
+
const total = waits.length + 1;
|
|
63169
|
+
const body = DeviceCodeRequestSchema.parse({ machine_label: label2 });
|
|
63170
|
+
for (let attempt2 = 1; ; attempt2++) {
|
|
63171
|
+
let error62;
|
|
63172
|
+
try {
|
|
63173
|
+
const res = await post(
|
|
63174
|
+
hub,
|
|
63175
|
+
args.fetch,
|
|
63176
|
+
BUS_ROUTES.device,
|
|
63177
|
+
body,
|
|
63178
|
+
AbortSignal.timeout(CODE_TIMEOUT_MS),
|
|
63179
|
+
args.noRedirect
|
|
63180
|
+
);
|
|
63181
|
+
if (res.status < 500 || total === 1) return res;
|
|
63182
|
+
error62 = `HTTP ${res.status}`;
|
|
63183
|
+
} catch (e) {
|
|
63184
|
+
if (e instanceof RedirectRefused || total === 1) throw e;
|
|
63185
|
+
error62 = errorTail(e);
|
|
63186
|
+
}
|
|
63187
|
+
const waitMs = waits[attempt2 - 1];
|
|
63188
|
+
if (waitMs === void 0)
|
|
63189
|
+
throw new LoginFailed(
|
|
63190
|
+
"unreachable",
|
|
63191
|
+
`could not reach ${hub} after ${total} attempts: ${error62}`,
|
|
63192
|
+
{ attempts: total, error: error62 }
|
|
63193
|
+
);
|
|
63194
|
+
args.events?.retrying?.({ attempt: attempt2, total, waitMs, error: error62 });
|
|
63195
|
+
await args.sleep(waitMs);
|
|
63196
|
+
}
|
|
63197
|
+
}
|
|
63198
|
+
async function login(args) {
|
|
63199
|
+
const done = markLoginActive(args.home);
|
|
63200
|
+
try {
|
|
63201
|
+
return await loginInner(args);
|
|
63202
|
+
} finally {
|
|
63203
|
+
done();
|
|
63204
|
+
}
|
|
63205
|
+
}
|
|
63206
|
+
async function loginInner(args) {
|
|
63207
|
+
const print = args.print ?? realDeps.print;
|
|
63208
|
+
const hub = normalizeHub(args.hub);
|
|
63209
|
+
const label2 = newMachineLabel(
|
|
63210
|
+
args.label ?? await defaultMachineLabel({
|
|
63211
|
+
exec: args.exec ?? realDeps.exec,
|
|
63212
|
+
platform: args.platform
|
|
63213
|
+
})
|
|
63214
|
+
);
|
|
63215
|
+
const codeRes = await requestCode(args, hub, label2);
|
|
63216
|
+
if (!codeRes.ok) {
|
|
63217
|
+
throw new Error(
|
|
63218
|
+
`bus/device failed: ${codeRes.status} ${(await codeRes.text()).slice(0, 200)}`
|
|
63219
|
+
);
|
|
63220
|
+
}
|
|
63221
|
+
const device = DeviceCodeResponseSchema.parse(await codeRes.json());
|
|
63222
|
+
const url2 = checkVerificationUri(device.verification_uri, hub);
|
|
63223
|
+
const events = args.events;
|
|
63224
|
+
if (!events?.code)
|
|
63225
|
+
print(
|
|
63226
|
+
`Open ${url2} and type this code to approve this machine: ${device.user_code}`
|
|
63227
|
+
);
|
|
63228
|
+
const opened = args.noOpen ? false : await args.openBrowser(url2);
|
|
63229
|
+
events?.code?.({
|
|
63230
|
+
url: url2,
|
|
63231
|
+
userCode: device.user_code,
|
|
63232
|
+
expiresIn: device.expires_in,
|
|
63233
|
+
opened,
|
|
63234
|
+
noOpen: Boolean(args.noOpen)
|
|
63235
|
+
});
|
|
63236
|
+
const deadline = args.now() + device.expires_in * 1e3;
|
|
63237
|
+
const baseMs = device.interval * 1e3;
|
|
63238
|
+
const maxPolls = Math.ceil(device.expires_in / device.interval) * 2;
|
|
63239
|
+
let waitMs = baseMs;
|
|
63240
|
+
for (let n = 0; n < maxPolls && args.now() < deadline; n++) {
|
|
63241
|
+
await args.sleep(waitMs);
|
|
63242
|
+
let res;
|
|
63243
|
+
try {
|
|
63244
|
+
res = await post(
|
|
63245
|
+
hub,
|
|
63246
|
+
args.fetch,
|
|
63247
|
+
BUS_ROUTES.deviceToken,
|
|
63248
|
+
DeviceTokenRequestSchema.parse({ device_code: device.device_code }),
|
|
63249
|
+
void 0,
|
|
63250
|
+
args.noRedirect
|
|
63251
|
+
);
|
|
63252
|
+
} catch (e) {
|
|
63253
|
+
if (e instanceof RedirectRefused) throw e;
|
|
63254
|
+
events?.poll?.(false);
|
|
63255
|
+
continue;
|
|
63256
|
+
}
|
|
63257
|
+
if (res.status === 429) {
|
|
63258
|
+
waitMs = Math.min(waitMs * 2, POLL_MAX_BACKOFF_MS);
|
|
63259
|
+
continue;
|
|
63260
|
+
}
|
|
63261
|
+
if (res.status >= 500) {
|
|
63262
|
+
events?.poll?.(false);
|
|
63263
|
+
continue;
|
|
63264
|
+
}
|
|
63265
|
+
events?.poll?.(true);
|
|
63266
|
+
waitMs = baseMs;
|
|
63267
|
+
if (!res.ok) {
|
|
63268
|
+
throw new Error(
|
|
63269
|
+
`bus/device/token failed: ${res.status} ${(await res.text()).slice(0, 200)}`
|
|
63270
|
+
);
|
|
63271
|
+
}
|
|
63272
|
+
const poll = DeviceTokenResponseSchema.parse(await res.json());
|
|
63273
|
+
switch (poll.status) {
|
|
63274
|
+
case "pending":
|
|
63275
|
+
continue;
|
|
63276
|
+
case "denied":
|
|
63277
|
+
throw new LoginFailed(
|
|
63278
|
+
"denied",
|
|
63279
|
+
"login denied: the approval was rejected"
|
|
63280
|
+
);
|
|
63281
|
+
case "expired":
|
|
63282
|
+
throw new LoginFailed(
|
|
63283
|
+
"expired",
|
|
63284
|
+
"device code expired; run the same command again",
|
|
63285
|
+
{ userCode: device.user_code }
|
|
63286
|
+
);
|
|
63287
|
+
case "approved": {
|
|
63288
|
+
if (args.save)
|
|
63289
|
+
args.save({ hub, label: label2, machineToken: poll.machine_token });
|
|
63290
|
+
else {
|
|
63291
|
+
writeMachineFile(
|
|
63292
|
+
args.home,
|
|
63293
|
+
`${JSON.stringify({ hub, label: label2, machine_token: poll.machine_token }, null, 2)}
|
|
63294
|
+
`
|
|
63295
|
+
);
|
|
63296
|
+
rmSync21(join36(args.home, "revoked"), { force: true });
|
|
63297
|
+
}
|
|
63298
|
+
if (!events?.code) print(`Approved this machine as ${label2}.`);
|
|
63299
|
+
return {
|
|
63300
|
+
machineToken: poll.machine_token,
|
|
63301
|
+
label: label2,
|
|
63302
|
+
hub,
|
|
63303
|
+
home: args.home
|
|
63304
|
+
};
|
|
63305
|
+
}
|
|
63306
|
+
}
|
|
63307
|
+
}
|
|
63308
|
+
throw new LoginFailed(
|
|
63309
|
+
"expired",
|
|
63310
|
+
"device approval timed out; run the same command again",
|
|
63311
|
+
{ userCode: device.user_code }
|
|
63312
|
+
);
|
|
63313
|
+
}
|
|
63314
|
+
|
|
63315
|
+
// src/commands/add.ts
|
|
63316
|
+
var LOOPBACK3 = /* @__PURE__ */ new Set(["localhost", "127.0.0.1", "[::1]"]);
|
|
63317
|
+
var SHOWN_MAX = 120;
|
|
63318
|
+
var HIDDEN = /[\p{Cc}\p{Cf}\u2028\u2029]/gu;
|
|
63319
|
+
function showAddress(address) {
|
|
63320
|
+
return stripTerminalControls(address).replace(HIDDEN, "");
|
|
63321
|
+
}
|
|
63322
|
+
var SaveFailed = class extends Error {
|
|
63323
|
+
};
|
|
63324
|
+
function parseAddress(raw) {
|
|
63325
|
+
let u;
|
|
63326
|
+
try {
|
|
63327
|
+
u = new URL(raw.trim());
|
|
63328
|
+
} catch {
|
|
63329
|
+
return { refused: "that is not an address" };
|
|
63330
|
+
}
|
|
63331
|
+
const loopbackHttp = u.protocol === "http:" && LOOPBACK3.has(u.hostname);
|
|
63332
|
+
if (u.protocol !== "https:" && !loopbackHttp)
|
|
63333
|
+
return { refused: "the address must start with https://" };
|
|
63334
|
+
if (u.username || u.password)
|
|
63335
|
+
return { refused: "the address must not hold a user name or password" };
|
|
63336
|
+
if (u.search || u.hash)
|
|
63337
|
+
return { refused: "the address must have no query or fragment" };
|
|
63338
|
+
const hub = canonicalAddress(u.href);
|
|
63339
|
+
if (!hub) return { refused: "that is not an address" };
|
|
63340
|
+
if (showAddress(hub).length > SHOWN_MAX)
|
|
63341
|
+
return { refused: "the address is too long to show in full" };
|
|
63342
|
+
return { hub, host: u.host };
|
|
63343
|
+
}
|
|
63344
|
+
async function add(opts, ctx) {
|
|
63345
|
+
const refuse2 = (msg) => {
|
|
63346
|
+
sayErr(ctx, `Not added: ${msg}`);
|
|
63347
|
+
return 1;
|
|
63348
|
+
};
|
|
63349
|
+
if (!ctx.stdinIsTTY || !ctx.stdout.isTTY)
|
|
63350
|
+
return refuse2(
|
|
63351
|
+
"add needs a real terminal; run it yourself, not from a script or an agent."
|
|
63352
|
+
);
|
|
63353
|
+
const parsed = parseAddress(opts.address);
|
|
63354
|
+
if ("refused" in parsed) return refuse2(parsed.refused);
|
|
63355
|
+
const name = opts.name ?? suggestName(parsed.hub, ctx.home);
|
|
63356
|
+
const bad2 = nameProblem(name) ?? addProblem(name, parsed.hub, ctx.home);
|
|
63357
|
+
if (bad2) return refuse2(bad2);
|
|
63358
|
+
say(ctx, `Adding the instance at ${showAddress(parsed.hub)}`);
|
|
63359
|
+
if (/[^\x00-\x7f]/.test(opts.address))
|
|
63360
|
+
say(
|
|
63361
|
+
ctx,
|
|
63362
|
+
"The address has non-ASCII characters; it is shown in its ASCII (xn--) form."
|
|
63363
|
+
);
|
|
63364
|
+
say(ctx, `It will be called ${name} on this machine.`, "");
|
|
63365
|
+
try {
|
|
63366
|
+
await login({
|
|
63367
|
+
hub: parsed.hub,
|
|
63368
|
+
home: ctx.home,
|
|
63369
|
+
exec: ctx.exec,
|
|
63370
|
+
noOpen: opts.noOpen,
|
|
63371
|
+
noRedirect: true,
|
|
63372
|
+
fetch: ctx.fetch,
|
|
63373
|
+
openBrowser: ctx.openBrowser,
|
|
63374
|
+
sleep: ctx.sleep,
|
|
63375
|
+
now: ctx.now,
|
|
63376
|
+
print: ctx.print,
|
|
63377
|
+
save: (r) => {
|
|
63378
|
+
try {
|
|
63379
|
+
saveInstance(
|
|
63380
|
+
{
|
|
63381
|
+
name,
|
|
63382
|
+
hub: r.hub,
|
|
63383
|
+
machine_id: "",
|
|
63384
|
+
label: r.label,
|
|
63385
|
+
machine_token: r.machineToken
|
|
63386
|
+
},
|
|
63387
|
+
ctx.home
|
|
63388
|
+
);
|
|
63389
|
+
} catch (e) {
|
|
63390
|
+
throw new SaveFailed(e.message);
|
|
63391
|
+
}
|
|
63392
|
+
}
|
|
63393
|
+
});
|
|
63394
|
+
} catch (e) {
|
|
63395
|
+
if (e instanceof RedirectRefused || e instanceof LoginFailed)
|
|
63396
|
+
return refuse2(e.message);
|
|
63397
|
+
if (e instanceof SaveFailed)
|
|
63398
|
+
return refuse2(
|
|
63399
|
+
`the hub approved this machine but the key was not saved: ${e.message}`
|
|
63400
|
+
);
|
|
63401
|
+
throw e;
|
|
63402
|
+
}
|
|
63403
|
+
say(ctx, `Added ${name}.`);
|
|
63404
|
+
return 0;
|
|
63405
|
+
}
|
|
63406
|
+
|
|
62929
63407
|
// src/commands/auto-update.ts
|
|
62930
63408
|
async function autoUpdate(opts, ctx) {
|
|
62931
63409
|
const c = ctx.copy;
|
|
@@ -62952,21 +63430,21 @@ async function autoUpdate(opts, ctx) {
|
|
|
62952
63430
|
}
|
|
62953
63431
|
|
|
62954
63432
|
// src/commands/daemon.ts
|
|
62955
|
-
import { existsSync as
|
|
62956
|
-
import { join as
|
|
63433
|
+
import { existsSync as existsSync16 } from "node:fs";
|
|
63434
|
+
import { join as join39 } from "node:path";
|
|
62957
63435
|
import { fileURLToPath as fileURLToPath6 } from "node:url";
|
|
62958
63436
|
|
|
62959
63437
|
// src/machine.ts
|
|
62960
|
-
import { readFileSync as
|
|
62961
|
-
import { join as
|
|
63438
|
+
import { readFileSync as readFileSync33, statSync as statSync11 } from "node:fs";
|
|
63439
|
+
import { join as join37 } from "node:path";
|
|
62962
63440
|
init_src();
|
|
62963
63441
|
function readMachine(home2) {
|
|
62964
|
-
const file2 =
|
|
63442
|
+
const file2 = join37(home2, "machine.json");
|
|
62965
63443
|
let text3;
|
|
62966
63444
|
let mode;
|
|
62967
63445
|
try {
|
|
62968
|
-
mode =
|
|
62969
|
-
text3 =
|
|
63446
|
+
mode = statSync11(file2).mode;
|
|
63447
|
+
text3 = readFileSync33(file2, "utf8");
|
|
62970
63448
|
} catch (e) {
|
|
62971
63449
|
return e.code === "ENOENT" ? { state: "missing" } : { state: "bad" };
|
|
62972
63450
|
}
|
|
@@ -62994,8 +63472,8 @@ var originOf2 = (hub) => {
|
|
|
62994
63472
|
};
|
|
62995
63473
|
|
|
62996
63474
|
// src/steps/claude-proof-check.ts
|
|
62997
|
-
import { readFileSync as
|
|
62998
|
-
import { join as
|
|
63475
|
+
import { readFileSync as readFileSync34 } from "node:fs";
|
|
63476
|
+
import { join as join38 } from "node:path";
|
|
62999
63477
|
var PROOF_EVENT = "claude_proof_applied";
|
|
63000
63478
|
var DAY_MS = 864e5;
|
|
63001
63479
|
var safeText = (s, max = 80) => {
|
|
@@ -63019,10 +63497,10 @@ function claudeProofChecks(ctx, hub) {
|
|
|
63019
63497
|
} catch {
|
|
63020
63498
|
return [];
|
|
63021
63499
|
}
|
|
63022
|
-
const rec = readRecord(
|
|
63500
|
+
const rec = readRecord(join38(ctx.home, "install.json"));
|
|
63023
63501
|
const file2 = rec.config ?? claudeConfigFile(ctx.userHome, ctx.env);
|
|
63024
63502
|
const r = proofReport(file2, origin, {
|
|
63025
|
-
projectFile:
|
|
63503
|
+
projectFile: join38(ctx.cwd, ".mcp.json"),
|
|
63026
63504
|
cwd: ctx.cwd,
|
|
63027
63505
|
recorded: rec.proofs,
|
|
63028
63506
|
...isDefaultHome2(ctx.home, ctx.userHome) ? {} : { busHome: ctx.home }
|
|
@@ -63128,7 +63606,7 @@ function claudeProofChecks(ctx, hub) {
|
|
|
63128
63606
|
function lastAutoFix(ctx) {
|
|
63129
63607
|
let text3;
|
|
63130
63608
|
try {
|
|
63131
|
-
text3 =
|
|
63609
|
+
text3 = readFileSync34(join38(ctx.home, "logs", "events.log"), "utf8");
|
|
63132
63610
|
} catch {
|
|
63133
63611
|
return void 0;
|
|
63134
63612
|
}
|
|
@@ -63154,12 +63632,12 @@ var lasting = (e) => [...START_ERROR_CODES, "EACCES", "EPERM"].includes(
|
|
|
63154
63632
|
);
|
|
63155
63633
|
async function daemon(ctx, run5 = runDaemon, signals = process) {
|
|
63156
63634
|
const m = readMachine(ctx.home);
|
|
63157
|
-
if (
|
|
63635
|
+
if (existsSync16(join39(ctx.home, "revoked")) && (m.state !== "ok" || m.revoked)) {
|
|
63158
63636
|
sayErr(ctx, ctx.copy.revoked());
|
|
63159
63637
|
return 0;
|
|
63160
63638
|
}
|
|
63161
|
-
const events = createEventLog(
|
|
63162
|
-
const config2 = readRecord(
|
|
63639
|
+
const events = createEventLog(join39(ctx.home, "logs", "events.log"));
|
|
63640
|
+
const config2 = readRecord(join39(ctx.home, "install.json")).config;
|
|
63163
63641
|
if (m.state === "ok" && config2 !== void 0 && wiredTo(ctx))
|
|
63164
63642
|
reapplyClaudeProof(
|
|
63165
63643
|
{
|
|
@@ -63212,36 +63690,36 @@ async function daemon(ctx, run5 = runDaemon, signals = process) {
|
|
|
63212
63690
|
}
|
|
63213
63691
|
|
|
63214
63692
|
// src/commands/doctor.ts
|
|
63215
|
-
import { readFileSync as
|
|
63216
|
-
import { join as
|
|
63693
|
+
import { readFileSync as readFileSync39 } from "node:fs";
|
|
63694
|
+
import { join as join46 } from "node:path";
|
|
63217
63695
|
|
|
63218
63696
|
// src/steps/claude-plugins.ts
|
|
63219
|
-
import { readFileSync as
|
|
63220
|
-
import { join as
|
|
63697
|
+
import { readFileSync as readFileSync36 } from "node:fs";
|
|
63698
|
+
import { join as join41 } from "node:path";
|
|
63221
63699
|
|
|
63222
63700
|
// src/steps/output-style.ts
|
|
63223
63701
|
import {
|
|
63224
63702
|
lstatSync as lstatSync19,
|
|
63225
|
-
readdirSync as
|
|
63226
|
-
readFileSync as
|
|
63703
|
+
readdirSync as readdirSync12,
|
|
63704
|
+
readFileSync as readFileSync35,
|
|
63227
63705
|
rmdirSync as rmdirSync3,
|
|
63228
|
-
rmSync as
|
|
63706
|
+
rmSync as rmSync22
|
|
63229
63707
|
} from "node:fs";
|
|
63230
|
-
import { dirname as dirname17, join as
|
|
63708
|
+
import { dirname as dirname17, join as join40 } from "node:path";
|
|
63231
63709
|
var OUTPUT_STYLE_FILE = "artifacts-teammate.md";
|
|
63232
63710
|
var OUTPUT_STYLE_MARKER = "<!-- managed by the Open Artifacts bus installer: edits are replaced on reinstall. -->";
|
|
63233
63711
|
var OUTPUT_STYLE_NAME = "Artifacts Teammate";
|
|
63234
63712
|
var OUTPUT_STYLE_PLUGIN_NAME = "open-artifacts:Artifacts Teammate";
|
|
63235
63713
|
var isOurName = (v) => v === OUTPUT_STYLE_NAME || v === OUTPUT_STYLE_PLUGIN_NAME;
|
|
63236
|
-
var claudeSettingsFile = (w) =>
|
|
63714
|
+
var claudeSettingsFile = (w) => join40(w.env?.CLAUDE_CONFIG_DIR ?? join40(w.home, ".claude"), "settings.json");
|
|
63237
63715
|
var readRecord3 = (busHome2) => {
|
|
63238
63716
|
if (!busHome2) return void 0;
|
|
63239
|
-
const r = readInstallFile(
|
|
63717
|
+
const r = readInstallFile(join40(busHome2, "install.json")).outputStyle;
|
|
63240
63718
|
return typeof r === "object" && r !== null ? r : void 0;
|
|
63241
63719
|
};
|
|
63242
|
-
var writeRecord3 = (busHome2, r) => updateInstallFile(
|
|
63243
|
-
var styleDir = (w) =>
|
|
63244
|
-
var outputStyleFile = (w) =>
|
|
63720
|
+
var writeRecord3 = (busHome2, r) => updateInstallFile(join40(busHome2, "install.json"), { outputStyle: r });
|
|
63721
|
+
var styleDir = (w) => join40(w.env?.CLAUDE_CONFIG_DIR ?? join40(w.home, ".claude"), "output-styles");
|
|
63722
|
+
var outputStyleFile = (w) => join40(styleDir(w), OUTPUT_STYLE_FILE);
|
|
63245
63723
|
var isOurs2 = (text3) => {
|
|
63246
63724
|
const m = /^---\n[\s\S]*?\n---\n/.exec(text3.replace(/\r\n/g, "\n"));
|
|
63247
63725
|
return m !== null && text3.replace(/\r\n/g, "\n").slice(m[0].length).split("\n", 1)[0] === OUTPUT_STYLE_MARKER;
|
|
@@ -63265,7 +63743,7 @@ var readSettings = (path) => {
|
|
|
63265
63743
|
if (isLink2(path)) return { ok: false, why: "it is a symlink" };
|
|
63266
63744
|
if (!exists(path)) return { ok: true, text: void 0, style: void 0 };
|
|
63267
63745
|
try {
|
|
63268
|
-
const text3 =
|
|
63746
|
+
const text3 = readFileSync35(path, "utf8");
|
|
63269
63747
|
parseJsonc(text3, path);
|
|
63270
63748
|
return { ok: true, text: text3, style: jsoncValue(text3, ["outputStyle"]) };
|
|
63271
63749
|
} catch {
|
|
@@ -63326,10 +63804,10 @@ function selectOutputStyle(deps2) {
|
|
|
63326
63804
|
);
|
|
63327
63805
|
} else {
|
|
63328
63806
|
try {
|
|
63329
|
-
if (exists(path) && isOurs2(
|
|
63330
|
-
|
|
63807
|
+
if (exists(path) && isOurs2(readFileSync35(path, "utf8"))) {
|
|
63808
|
+
rmSync22(path);
|
|
63331
63809
|
removed = true;
|
|
63332
|
-
if (
|
|
63810
|
+
if (readdirSync12(dir).length === 0) rmdirSync3(dir);
|
|
63333
63811
|
} else if (exists(path)) {
|
|
63334
63812
|
out.notes.push(
|
|
63335
63813
|
`Kept ${path}: it has no Open Artifacts marker, so it may be yours.
|
|
@@ -63376,7 +63854,7 @@ function turnOff(deps2, out) {
|
|
|
63376
63854
|
const was = rec?.set ? rec.before : void 0;
|
|
63377
63855
|
const next = was?.state === "null" ? setJsoncValue(cur.text, ["outputStyle"], null) : was?.state === "empty" ? setJsoncValue(cur.text, ["outputStyle"], was.value) : removeJsoncValue(cur.text, ["outputStyle"]);
|
|
63378
63856
|
if (rec?.set && rec.createdFile && (cur.text === createdText() || cur.text === createdText(OUTPUT_STYLE_NAME)))
|
|
63379
|
-
|
|
63857
|
+
rmSync22(path);
|
|
63380
63858
|
else writeAtomic(path, next);
|
|
63381
63859
|
}
|
|
63382
63860
|
if (busHome2 && rec) writeRecord3(busHome2, void 0);
|
|
@@ -63398,15 +63876,15 @@ function uninstallOutputStyle(deps2) {
|
|
|
63398
63876
|
);
|
|
63399
63877
|
} else if (!exists(path)) {
|
|
63400
63878
|
gone = true;
|
|
63401
|
-
} else if (!isOurs2(
|
|
63879
|
+
} else if (!isOurs2(readFileSync35(path, "utf8"))) {
|
|
63402
63880
|
out.notes.push(
|
|
63403
63881
|
`Left ${path} alone: it has no Open Artifacts marker, so it is not ours to replace.`
|
|
63404
63882
|
);
|
|
63405
63883
|
} else {
|
|
63406
|
-
|
|
63884
|
+
rmSync22(path);
|
|
63407
63885
|
out.written.push(path);
|
|
63408
63886
|
gone = true;
|
|
63409
|
-
if (
|
|
63887
|
+
if (readdirSync12(dir).length === 0) rmdirSync3(dir);
|
|
63410
63888
|
}
|
|
63411
63889
|
} catch (e) {
|
|
63412
63890
|
out.notes.push(
|
|
@@ -63439,7 +63917,7 @@ var outputStyleState = (deps2) => {
|
|
|
63439
63917
|
const path = outputStyleFile(deps2);
|
|
63440
63918
|
try {
|
|
63441
63919
|
if (isLink2(dirname17(path)) || isLink2(path)) return void 0;
|
|
63442
|
-
if (!isOurs2(
|
|
63920
|
+
if (!isOurs2(readFileSync35(path, "utf8"))) return void 0;
|
|
63443
63921
|
const s = readSettings(claudeSettingsFile(deps2));
|
|
63444
63922
|
return { path, on: s.ok && s.style === OUTPUT_STYLE_NAME };
|
|
63445
63923
|
} catch {
|
|
@@ -63459,10 +63937,10 @@ var SPARSE = [".claude-plugin", "plugins", "packages/claude-code-shortcuts"];
|
|
|
63459
63937
|
var CALL_MS = 12e4;
|
|
63460
63938
|
var MCP_LIST_MS = 2e4;
|
|
63461
63939
|
var readRecord4 = (busHome2) => {
|
|
63462
|
-
const r = readInstallFile(
|
|
63940
|
+
const r = readInstallFile(join41(busHome2, "install.json")).claudePlugins;
|
|
63463
63941
|
return typeof r === "object" && r !== null ? r : void 0;
|
|
63464
63942
|
};
|
|
63465
|
-
var writeRecord4 = (busHome2, r) => updateInstallFile(
|
|
63943
|
+
var writeRecord4 = (busHome2, r) => updateInstallFile(join41(busHome2, "install.json"), { claudePlugins: r });
|
|
63466
63944
|
var cmpVersion = (a, b) => {
|
|
63467
63945
|
const pa = a.split(".").map(Number);
|
|
63468
63946
|
const pb = b.split(".").map(Number);
|
|
@@ -63908,7 +64386,7 @@ async function claudePluginsState(deps2) {
|
|
|
63908
64386
|
}
|
|
63909
64387
|
function readShortcutOptions(deps2) {
|
|
63910
64388
|
try {
|
|
63911
|
-
const text3 =
|
|
64389
|
+
const text3 = readFileSync36(claudeSettingsFile(deps2), "utf8");
|
|
63912
64390
|
const o = JSON.parse(text3);
|
|
63913
64391
|
const opts = o.pluginConfigs?.[SHORTCUTS_PLUGIN]?.options;
|
|
63914
64392
|
const str3 = (v) => typeof v === "string" && v ? v : void 0;
|
|
@@ -63926,8 +64404,8 @@ function readInstanceUrl(deps2) {
|
|
|
63926
64404
|
}
|
|
63927
64405
|
|
|
63928
64406
|
// src/steps/claude-sessions.ts
|
|
63929
|
-
import { readFileSync as
|
|
63930
|
-
import { join as
|
|
64407
|
+
import { readFileSync as readFileSync37 } from "node:fs";
|
|
64408
|
+
import { join as join42 } from "node:path";
|
|
63931
64409
|
var UNBOUND_EVENT = "mcp_proof_unbound";
|
|
63932
64410
|
var DAY_MS2 = 864e5;
|
|
63933
64411
|
function hubOrigin(hub) {
|
|
@@ -63955,7 +64433,7 @@ function helperFailures(ctx) {
|
|
|
63955
64433
|
const out = /* @__PURE__ */ new Map();
|
|
63956
64434
|
let text3;
|
|
63957
64435
|
try {
|
|
63958
|
-
text3 =
|
|
64436
|
+
text3 = readFileSync37(join42(ctx.home, "logs", "events.log"), "utf8");
|
|
63959
64437
|
} catch {
|
|
63960
64438
|
return out;
|
|
63961
64439
|
}
|
|
@@ -63973,7 +64451,7 @@ function helperFailures(ctx) {
|
|
|
63973
64451
|
var when = (at) => at.slice(0, 16).replace("T", " ");
|
|
63974
64452
|
var read = (path) => {
|
|
63975
64453
|
try {
|
|
63976
|
-
return JSON.parse(
|
|
64454
|
+
return JSON.parse(readFileSync37(path, "utf8"));
|
|
63977
64455
|
} catch {
|
|
63978
64456
|
return void 0;
|
|
63979
64457
|
}
|
|
@@ -64001,7 +64479,7 @@ function entryApplies(ctx, origin, cwd) {
|
|
|
64001
64479
|
const p = isObj2(doc.projects) ? doc.projects[cwd] : void 0;
|
|
64002
64480
|
if (isObj2(p) && matching(p.mcpServers, origin).length > 0) return true;
|
|
64003
64481
|
}
|
|
64004
|
-
const proj = read(
|
|
64482
|
+
const proj = read(join42(cwd, ".mcp.json"));
|
|
64005
64483
|
return isObj2(proj) && matching(proj.mcpServers, origin).length > 0;
|
|
64006
64484
|
}
|
|
64007
64485
|
function sessionChecks(ctx, st, hub) {
|
|
@@ -64083,7 +64561,7 @@ var sseCheck = (ctx, name) => ({
|
|
|
64083
64561
|
|
|
64084
64562
|
// src/commands/habits.ts
|
|
64085
64563
|
init_src();
|
|
64086
|
-
import { join as
|
|
64564
|
+
import { join as join43 } from "node:path";
|
|
64087
64565
|
var pluginOn = (p) => `Habits on in the ${p.label} plugin.`;
|
|
64088
64566
|
var pluginOff = (p) => `Habits off in the ${p.label} plugin.`;
|
|
64089
64567
|
var deps = (ctx) => ({
|
|
@@ -64202,7 +64680,7 @@ async function habitsAfterInstall(ctx, json4) {
|
|
|
64202
64680
|
})),
|
|
64203
64681
|
// A plugin has no block to compare: its marker is there ("current") or not.
|
|
64204
64682
|
...plugins2.map((p) => ({
|
|
64205
|
-
path:
|
|
64683
|
+
path: join43(p.dir(ctx.userHome, ctx.env), p.marker),
|
|
64206
64684
|
label: `the ${p.label} plugin`,
|
|
64207
64685
|
s: {
|
|
64208
64686
|
state: pluginHabitsState(deps(ctx), p) === "on" ? "current" : "absent"
|
|
@@ -64247,7 +64725,7 @@ async function habitsAfterInstall(ctx, json4) {
|
|
|
64247
64725
|
const pl = setPluginHabits(
|
|
64248
64726
|
deps(ctx),
|
|
64249
64727
|
plugins2.filter(
|
|
64250
|
-
(p) => asked.includes(
|
|
64728
|
+
(p) => asked.includes(join43(p.dir(ctx.userHome, ctx.env), p.marker))
|
|
64251
64729
|
),
|
|
64252
64730
|
true
|
|
64253
64731
|
);
|
|
@@ -64308,239 +64786,13 @@ function habitsLine(ctx) {
|
|
|
64308
64786
|
return void 0;
|
|
64309
64787
|
}
|
|
64310
64788
|
|
|
64311
|
-
// src/commands/login.ts
|
|
64312
|
-
import { randomBytes as randomBytes7 } from "node:crypto";
|
|
64313
|
-
import {
|
|
64314
|
-
chmodSync as chmodSync21,
|
|
64315
|
-
closeSync as closeSync9,
|
|
64316
|
-
mkdirSync as mkdirSync16,
|
|
64317
|
-
openSync as openSync9,
|
|
64318
|
-
renameSync as renameSync21,
|
|
64319
|
-
rmSync as rmSync22,
|
|
64320
|
-
unlinkSync as unlinkSync3,
|
|
64321
|
-
writeSync as writeSync4
|
|
64322
|
-
} from "node:fs";
|
|
64323
|
-
import { join as join42 } from "node:path";
|
|
64324
|
-
init_src();
|
|
64325
|
-
|
|
64326
|
-
// src/machine-label.ts
|
|
64327
|
-
import { hostname as osHostname } from "node:os";
|
|
64328
|
-
var shortHost = (h) => h.trim().split(".")[0] ?? "";
|
|
64329
|
-
async function defaultMachineLabel(d) {
|
|
64330
|
-
if ((d.platform ?? process.platform) === "darwin") {
|
|
64331
|
-
for (const key2 of ["ComputerName", "LocalHostName"]) {
|
|
64332
|
-
try {
|
|
64333
|
-
const r = await d.exec("scutil", ["--get", key2]);
|
|
64334
|
-
const v = r.stdout.trim();
|
|
64335
|
-
if (r.code === 0 && v) return v;
|
|
64336
|
-
} catch {
|
|
64337
|
-
}
|
|
64338
|
-
}
|
|
64339
|
-
}
|
|
64340
|
-
return shortHost((d.hostname ?? osHostname)());
|
|
64341
|
-
}
|
|
64342
|
-
|
|
64343
|
-
// src/commands/login.ts
|
|
64344
|
-
var LoginFailed = class extends Error {
|
|
64345
|
-
constructor(kind4, message, detail = {}) {
|
|
64346
|
-
super(message);
|
|
64347
|
-
this.kind = kind4;
|
|
64348
|
-
this.detail = detail;
|
|
64349
|
-
}
|
|
64350
|
-
kind;
|
|
64351
|
-
detail;
|
|
64352
|
-
};
|
|
64353
|
-
var CODE_TIMEOUT_MS = 1e4;
|
|
64354
|
-
function errorTail(e) {
|
|
64355
|
-
const err = e;
|
|
64356
|
-
if (err?.name === "TimeoutError" || err?.name === "AbortError")
|
|
64357
|
-
return "timeout";
|
|
64358
|
-
return err?.cause?.code ?? err?.code ?? "network error";
|
|
64359
|
-
}
|
|
64360
|
-
var POLL_MAX_BACKOFF_MS = 3e4;
|
|
64361
|
-
var normalizeHub = (hub) => hub.replace(/\/+$/, "");
|
|
64362
|
-
function checkVerificationUri(uri, hub) {
|
|
64363
|
-
if (!verificationUriMatches(uri, hub))
|
|
64364
|
-
throw new Error(
|
|
64365
|
-
"bus/device returned a verification_uri that is not the instance's approval page"
|
|
64366
|
-
);
|
|
64367
|
-
return uri;
|
|
64368
|
-
}
|
|
64369
|
-
function writeMachineFile(home2, body) {
|
|
64370
|
-
mkdirSync16(home2, { recursive: true, mode: 448 });
|
|
64371
|
-
chmodSync21(home2, 448);
|
|
64372
|
-
const tmp = join42(home2, `.machine.json.${randomBytes7(8).toString("hex")}.tmp`);
|
|
64373
|
-
const fd = openSync9(tmp, "wx", 384);
|
|
64374
|
-
try {
|
|
64375
|
-
writeSync4(fd, body);
|
|
64376
|
-
} catch (e) {
|
|
64377
|
-
closeSync9(fd);
|
|
64378
|
-
unlinkSync3(tmp);
|
|
64379
|
-
throw e;
|
|
64380
|
-
}
|
|
64381
|
-
closeSync9(fd);
|
|
64382
|
-
try {
|
|
64383
|
-
chmodSync21(tmp, 384);
|
|
64384
|
-
renameSync21(tmp, join42(home2, "machine.json"));
|
|
64385
|
-
} catch (e) {
|
|
64386
|
-
unlinkSync3(tmp);
|
|
64387
|
-
throw e;
|
|
64388
|
-
}
|
|
64389
|
-
}
|
|
64390
|
-
var post = (hub, fetch2, path, body, signal) => fetch2(`${hub}${path}`, {
|
|
64391
|
-
method: "POST",
|
|
64392
|
-
headers: { "content-type": "application/json" },
|
|
64393
|
-
body: JSON.stringify(body),
|
|
64394
|
-
...signal ? { signal } : {}
|
|
64395
|
-
});
|
|
64396
|
-
async function requestCode(args, hub, label2) {
|
|
64397
|
-
const waits = args.codeRetryMs ?? [];
|
|
64398
|
-
const total = waits.length + 1;
|
|
64399
|
-
const body = DeviceCodeRequestSchema.parse({ machine_label: label2 });
|
|
64400
|
-
for (let attempt2 = 1; ; attempt2++) {
|
|
64401
|
-
let error62;
|
|
64402
|
-
try {
|
|
64403
|
-
const res = await post(
|
|
64404
|
-
hub,
|
|
64405
|
-
args.fetch,
|
|
64406
|
-
BUS_ROUTES.device,
|
|
64407
|
-
body,
|
|
64408
|
-
AbortSignal.timeout(CODE_TIMEOUT_MS)
|
|
64409
|
-
);
|
|
64410
|
-
if (res.status < 500 || total === 1) return res;
|
|
64411
|
-
error62 = `HTTP ${res.status}`;
|
|
64412
|
-
} catch (e) {
|
|
64413
|
-
if (total === 1) throw e;
|
|
64414
|
-
error62 = errorTail(e);
|
|
64415
|
-
}
|
|
64416
|
-
const waitMs = waits[attempt2 - 1];
|
|
64417
|
-
if (waitMs === void 0)
|
|
64418
|
-
throw new LoginFailed(
|
|
64419
|
-
"unreachable",
|
|
64420
|
-
`could not reach ${hub} after ${total} attempts: ${error62}`,
|
|
64421
|
-
{ attempts: total, error: error62 }
|
|
64422
|
-
);
|
|
64423
|
-
args.events?.retrying?.({ attempt: attempt2, total, waitMs, error: error62 });
|
|
64424
|
-
await args.sleep(waitMs);
|
|
64425
|
-
}
|
|
64426
|
-
}
|
|
64427
|
-
async function login(args) {
|
|
64428
|
-
const done = markLoginActive(args.home);
|
|
64429
|
-
try {
|
|
64430
|
-
return await loginInner(args);
|
|
64431
|
-
} finally {
|
|
64432
|
-
done();
|
|
64433
|
-
}
|
|
64434
|
-
}
|
|
64435
|
-
async function loginInner(args) {
|
|
64436
|
-
const print = args.print ?? realDeps.print;
|
|
64437
|
-
const hub = normalizeHub(args.hub);
|
|
64438
|
-
const label2 = newMachineLabel(
|
|
64439
|
-
args.label ?? await defaultMachineLabel({
|
|
64440
|
-
exec: args.exec ?? realDeps.exec,
|
|
64441
|
-
platform: args.platform
|
|
64442
|
-
})
|
|
64443
|
-
);
|
|
64444
|
-
const codeRes = await requestCode(args, hub, label2);
|
|
64445
|
-
if (!codeRes.ok) {
|
|
64446
|
-
throw new Error(
|
|
64447
|
-
`bus/device failed: ${codeRes.status} ${(await codeRes.text()).slice(0, 200)}`
|
|
64448
|
-
);
|
|
64449
|
-
}
|
|
64450
|
-
const device = DeviceCodeResponseSchema.parse(await codeRes.json());
|
|
64451
|
-
const url2 = checkVerificationUri(device.verification_uri, hub);
|
|
64452
|
-
const events = args.events;
|
|
64453
|
-
if (!events?.code)
|
|
64454
|
-
print(
|
|
64455
|
-
`Open ${url2} and type this code to approve this machine: ${device.user_code}`
|
|
64456
|
-
);
|
|
64457
|
-
const opened = args.noOpen ? false : await args.openBrowser(url2);
|
|
64458
|
-
events?.code?.({
|
|
64459
|
-
url: url2,
|
|
64460
|
-
userCode: device.user_code,
|
|
64461
|
-
expiresIn: device.expires_in,
|
|
64462
|
-
opened,
|
|
64463
|
-
noOpen: Boolean(args.noOpen)
|
|
64464
|
-
});
|
|
64465
|
-
const deadline = args.now() + device.expires_in * 1e3;
|
|
64466
|
-
const baseMs = device.interval * 1e3;
|
|
64467
|
-
const maxPolls = Math.ceil(device.expires_in / device.interval) * 2;
|
|
64468
|
-
let waitMs = baseMs;
|
|
64469
|
-
for (let n = 0; n < maxPolls && args.now() < deadline; n++) {
|
|
64470
|
-
await args.sleep(waitMs);
|
|
64471
|
-
let res;
|
|
64472
|
-
try {
|
|
64473
|
-
res = await post(
|
|
64474
|
-
hub,
|
|
64475
|
-
args.fetch,
|
|
64476
|
-
BUS_ROUTES.deviceToken,
|
|
64477
|
-
DeviceTokenRequestSchema.parse({ device_code: device.device_code })
|
|
64478
|
-
);
|
|
64479
|
-
} catch {
|
|
64480
|
-
events?.poll?.(false);
|
|
64481
|
-
continue;
|
|
64482
|
-
}
|
|
64483
|
-
if (res.status === 429) {
|
|
64484
|
-
waitMs = Math.min(waitMs * 2, POLL_MAX_BACKOFF_MS);
|
|
64485
|
-
continue;
|
|
64486
|
-
}
|
|
64487
|
-
if (res.status >= 500) {
|
|
64488
|
-
events?.poll?.(false);
|
|
64489
|
-
continue;
|
|
64490
|
-
}
|
|
64491
|
-
events?.poll?.(true);
|
|
64492
|
-
waitMs = baseMs;
|
|
64493
|
-
if (!res.ok) {
|
|
64494
|
-
throw new Error(
|
|
64495
|
-
`bus/device/token failed: ${res.status} ${(await res.text()).slice(0, 200)}`
|
|
64496
|
-
);
|
|
64497
|
-
}
|
|
64498
|
-
const poll = DeviceTokenResponseSchema.parse(await res.json());
|
|
64499
|
-
switch (poll.status) {
|
|
64500
|
-
case "pending":
|
|
64501
|
-
continue;
|
|
64502
|
-
case "denied":
|
|
64503
|
-
throw new LoginFailed(
|
|
64504
|
-
"denied",
|
|
64505
|
-
"login denied: the approval was rejected"
|
|
64506
|
-
);
|
|
64507
|
-
case "expired":
|
|
64508
|
-
throw new LoginFailed(
|
|
64509
|
-
"expired",
|
|
64510
|
-
"device code expired; run the same command again",
|
|
64511
|
-
{ userCode: device.user_code }
|
|
64512
|
-
);
|
|
64513
|
-
case "approved": {
|
|
64514
|
-
writeMachineFile(
|
|
64515
|
-
args.home,
|
|
64516
|
-
`${JSON.stringify({ hub, label: label2, machine_token: poll.machine_token }, null, 2)}
|
|
64517
|
-
`
|
|
64518
|
-
);
|
|
64519
|
-
rmSync22(join42(args.home, "revoked"), { force: true });
|
|
64520
|
-
if (!events?.code) print(`Approved this machine as ${label2}.`);
|
|
64521
|
-
return {
|
|
64522
|
-
machineToken: poll.machine_token,
|
|
64523
|
-
label: label2,
|
|
64524
|
-
hub,
|
|
64525
|
-
home: args.home
|
|
64526
|
-
};
|
|
64527
|
-
}
|
|
64528
|
-
}
|
|
64529
|
-
}
|
|
64530
|
-
throw new LoginFailed(
|
|
64531
|
-
"expired",
|
|
64532
|
-
"device approval timed out; run the same command again",
|
|
64533
|
-
{ userCode: device.user_code }
|
|
64534
|
-
);
|
|
64535
|
-
}
|
|
64536
|
-
|
|
64537
64789
|
// src/commands/status.ts
|
|
64538
64790
|
init_src2();
|
|
64539
64791
|
init_src();
|
|
64540
64792
|
|
|
64541
64793
|
// src/commands/install.ts
|
|
64542
64794
|
init_src3();
|
|
64543
|
-
import { dirname as dirname18, join as
|
|
64795
|
+
import { dirname as dirname18, join as join45 } from "node:path";
|
|
64544
64796
|
init_src2();
|
|
64545
64797
|
|
|
64546
64798
|
// src/live.ts
|
|
@@ -64592,20 +64844,20 @@ function spinner(ctx) {
|
|
|
64592
64844
|
// src/steps/leftovers.ts
|
|
64593
64845
|
import {
|
|
64594
64846
|
lstatSync as lstatSync20,
|
|
64595
|
-
readdirSync as
|
|
64596
|
-
readFileSync as
|
|
64847
|
+
readdirSync as readdirSync13,
|
|
64848
|
+
readFileSync as readFileSync38,
|
|
64597
64849
|
rmdirSync as rmdirSync4,
|
|
64598
64850
|
rmSync as rmSync23
|
|
64599
64851
|
} from "node:fs";
|
|
64600
|
-
import { join as
|
|
64852
|
+
import { join as join44 } from "node:path";
|
|
64601
64853
|
function leftoverTargets(deps2) {
|
|
64602
64854
|
const env2 = deps2.env ?? {};
|
|
64603
64855
|
const p = paths(deps2);
|
|
64604
|
-
const piDir = agentDirEnv(deps2.home, env2) ??
|
|
64856
|
+
const piDir = agentDirEnv(deps2.home, env2) ?? join44(deps2.home, ".pi/agent");
|
|
64605
64857
|
const skill2 = (h) => skillDir({ home: deps2.home, env: env2 }, h);
|
|
64606
64858
|
return {
|
|
64607
64859
|
files: [
|
|
64608
|
-
|
|
64860
|
+
join44(codexHome2(deps2.home, env2), "AGENTS.md"),
|
|
64609
64861
|
p.codex,
|
|
64610
64862
|
...p.opencodeConfigs,
|
|
64611
64863
|
p.opencodeCli
|
|
@@ -64614,10 +64866,10 @@ function leftoverTargets(deps2) {
|
|
|
64614
64866
|
skill2("claude"),
|
|
64615
64867
|
skill2("pi"),
|
|
64616
64868
|
skill2("hermes"),
|
|
64617
|
-
|
|
64618
|
-
|
|
64619
|
-
|
|
64620
|
-
|
|
64869
|
+
join44(hermesHome(deps2.home, env2), "plugins"),
|
|
64870
|
+
join44(deps2.home, ".local", "bin"),
|
|
64871
|
+
join44(ompAgentDir(deps2.home, env2), "extensions"),
|
|
64872
|
+
join44(piDir, "extensions"),
|
|
64621
64873
|
skill2("opencode"),
|
|
64622
64874
|
skill2("openclaw")
|
|
64623
64875
|
]
|
|
@@ -64661,7 +64913,7 @@ function emptyFile(path) {
|
|
|
64661
64913
|
const st = lstatSync20(path);
|
|
64662
64914
|
if (!st.isFile()) return false;
|
|
64663
64915
|
if (st.size === 0) return true;
|
|
64664
|
-
const doc = JSON.parse(
|
|
64916
|
+
const doc = JSON.parse(readFileSync38(path, "utf8"));
|
|
64665
64917
|
return typeof doc === "object" && doc !== null && !Array.isArray(doc) && Object.keys(doc).length === 0;
|
|
64666
64918
|
} catch {
|
|
64667
64919
|
return false;
|
|
@@ -64678,7 +64930,7 @@ function removeMade(made) {
|
|
|
64678
64930
|
for (const path of made.filter((x) => !gone.includes(x)).sort((a, b) => b.length - a.length)) {
|
|
64679
64931
|
try {
|
|
64680
64932
|
if (!lstatSync20(path).isDirectory()) continue;
|
|
64681
|
-
if (
|
|
64933
|
+
if (readdirSync13(path).length > 0) continue;
|
|
64682
64934
|
rmdirSync4(path);
|
|
64683
64935
|
gone.push(path);
|
|
64684
64936
|
} catch {
|
|
@@ -64762,7 +65014,7 @@ async function loginStep(ctx, opts) {
|
|
|
64762
65014
|
ctx,
|
|
64763
65015
|
c.approved(result.label),
|
|
64764
65016
|
c.tokenSaved(
|
|
64765
|
-
tilde(ctx,
|
|
65017
|
+
tilde(ctx, join45(ctx.home, "machine.json")),
|
|
64766
65018
|
result.machineToken
|
|
64767
65019
|
),
|
|
64768
65020
|
c.connected(originOf2(result.hub)),
|
|
@@ -64891,7 +65143,7 @@ function shownSocket(ctx) {
|
|
|
64891
65143
|
const real3 = `${canonicalHome(ctx.home)}/`;
|
|
64892
65144
|
return tilde(
|
|
64893
65145
|
ctx,
|
|
64894
|
-
path.startsWith(real3) ?
|
|
65146
|
+
path.startsWith(real3) ? join45(ctx.home, path.slice(real3.length)) : path
|
|
64895
65147
|
);
|
|
64896
65148
|
}
|
|
64897
65149
|
async function waitForDaemon(ctx) {
|
|
@@ -65143,7 +65395,7 @@ async function installRun(opts, realCtx2) {
|
|
|
65143
65395
|
return results.every((r) => r.state === "done") ? 0 : 1;
|
|
65144
65396
|
}
|
|
65145
65397
|
const ok = await runSteps(steps, ctx, {
|
|
65146
|
-
path:
|
|
65398
|
+
path: join45(ctx.home, "install.json"),
|
|
65147
65399
|
now: ctx.now
|
|
65148
65400
|
});
|
|
65149
65401
|
if (ok && second) say(ctx, "", c.secondBus(ctx.home));
|
|
@@ -65338,7 +65590,7 @@ async function healthz(ctx, hub) {
|
|
|
65338
65590
|
function claudeIsolates(path) {
|
|
65339
65591
|
let text3;
|
|
65340
65592
|
try {
|
|
65341
|
-
text3 =
|
|
65593
|
+
text3 = readFileSync39(path, "utf8");
|
|
65342
65594
|
} catch {
|
|
65343
65595
|
return void 0;
|
|
65344
65596
|
}
|
|
@@ -65414,7 +65666,7 @@ async function doctor(ctx) {
|
|
|
65414
65666
|
const node2 = ctx.nodeVersion.replace(/^v/, "");
|
|
65415
65667
|
if (Number(node2.split(".")[0]) >= MIN_NODE) pass(c.nodeOk(node2));
|
|
65416
65668
|
else fail3(c.nodeOld(node2));
|
|
65417
|
-
const machineFile = tilde(ctx,
|
|
65669
|
+
const machineFile = tilde(ctx, join46(ctx.home, "machine.json"));
|
|
65418
65670
|
const m = readMachine(ctx.home);
|
|
65419
65671
|
if (m.state !== "ok") fail3(c.noCredentials(machineFile));
|
|
65420
65672
|
else if (m.revoked) fail3(c.revokedCheck());
|
|
@@ -65503,8 +65755,8 @@ async function doctor(ctx) {
|
|
|
65503
65755
|
pass(c.wired(h, version2));
|
|
65504
65756
|
else fail3(c.notWired(h));
|
|
65505
65757
|
if (h === "claude") {
|
|
65506
|
-
const settings =
|
|
65507
|
-
ctx.env.CLAUDE_CONFIG_DIR ??
|
|
65758
|
+
const settings = join46(
|
|
65759
|
+
ctx.env.CLAUDE_CONFIG_DIR ?? join46(ctx.userHome, ".claude"),
|
|
65508
65760
|
"settings.json"
|
|
65509
65761
|
);
|
|
65510
65762
|
const isolates = claudeIsolates(settings);
|
|
@@ -65631,7 +65883,7 @@ async function doctor(ctx) {
|
|
|
65631
65883
|
}
|
|
65632
65884
|
|
|
65633
65885
|
// src/commands/global.ts
|
|
65634
|
-
import { realpathSync as realpathSync15, statSync as
|
|
65886
|
+
import { realpathSync as realpathSync15, statSync as statSync12 } from "node:fs";
|
|
65635
65887
|
import { resolve as resolve14 } from "node:path";
|
|
65636
65888
|
function shown3(ctx, path) {
|
|
65637
65889
|
const t = tilde(ctx, path);
|
|
@@ -65665,7 +65917,7 @@ async function global(opts, ctx) {
|
|
|
65665
65917
|
} catch {
|
|
65666
65918
|
}
|
|
65667
65919
|
if (opts.sub === "add") {
|
|
65668
|
-
if (!real3 || !
|
|
65920
|
+
if (!real3 || !statSync12(real3).isDirectory()) {
|
|
65669
65921
|
sayErr(ctx, c.globalNotDir(shown3(ctx, real3 ?? given)));
|
|
65670
65922
|
return 1;
|
|
65671
65923
|
}
|
|
@@ -65690,12 +65942,12 @@ async function global(opts, ctx) {
|
|
|
65690
65942
|
}
|
|
65691
65943
|
|
|
65692
65944
|
// src/commands/leads.ts
|
|
65693
|
-
import { readFileSync as
|
|
65694
|
-
import { join as
|
|
65945
|
+
import { readFileSync as readFileSync40 } from "node:fs";
|
|
65946
|
+
import { join as join47 } from "node:path";
|
|
65695
65947
|
function hubOrigin2(ctx) {
|
|
65696
65948
|
try {
|
|
65697
65949
|
const raw = JSON.parse(
|
|
65698
|
-
|
|
65950
|
+
readFileSync40(join47(ctx.home, "machine.json"), "utf8")
|
|
65699
65951
|
);
|
|
65700
65952
|
return typeof raw?.hub === "string" ? new URL(raw.hub).origin : void 0;
|
|
65701
65953
|
} catch {
|
|
@@ -65753,14 +66005,14 @@ async function leads(opts, ctx) {
|
|
|
65753
66005
|
}
|
|
65754
66006
|
|
|
65755
66007
|
// src/commands/link.ts
|
|
65756
|
-
import { statSync as
|
|
66008
|
+
import { statSync as statSync13 } from "node:fs";
|
|
65757
66009
|
import { resolve as resolve15 } from "node:path";
|
|
65758
66010
|
init_src();
|
|
65759
66011
|
function side(ctx, dir) {
|
|
65760
66012
|
const given = resolve15(ctx.cwd, dir);
|
|
65761
66013
|
try {
|
|
65762
66014
|
const real3 = canonicalPath(given);
|
|
65763
|
-
if (!
|
|
66015
|
+
if (!statSync13(real3).isDirectory()) return void 0;
|
|
65764
66016
|
const ns = resolveNamespace(real3, {
|
|
65765
66017
|
globalFile: globalFile(ctx.home),
|
|
65766
66018
|
namespacesFile: namespacesFile(ctx.home),
|
|
@@ -65849,14 +66101,14 @@ async function link(opts, ctx) {
|
|
|
65849
66101
|
|
|
65850
66102
|
// src/commands/logs.ts
|
|
65851
66103
|
import {
|
|
65852
|
-
closeSync as
|
|
66104
|
+
closeSync as closeSync11,
|
|
65853
66105
|
constants as constants7,
|
|
65854
66106
|
fstatSync as fstatSync5,
|
|
65855
66107
|
lstatSync as lstatSync21,
|
|
65856
|
-
openSync as
|
|
65857
|
-
readFileSync as
|
|
66108
|
+
openSync as openSync11,
|
|
66109
|
+
readFileSync as readFileSync41
|
|
65858
66110
|
} from "node:fs";
|
|
65859
|
-
import { dirname as dirname19, join as
|
|
66111
|
+
import { dirname as dirname19, join as join48 } from "node:path";
|
|
65860
66112
|
var TAIL = 50;
|
|
65861
66113
|
var checkDir = (dir) => {
|
|
65862
66114
|
let fd;
|
|
@@ -65868,7 +66120,7 @@ var checkDir = (dir) => {
|
|
|
65868
66120
|
return { ok: false, why: "it is not owned by you" };
|
|
65869
66121
|
if ((ls.mode & 63) !== 0)
|
|
65870
66122
|
return { ok: false, why: "it is open to other users (want mode 0700)" };
|
|
65871
|
-
fd =
|
|
66123
|
+
fd = openSync11(
|
|
65872
66124
|
dir,
|
|
65873
66125
|
constants7.O_RDONLY | constants7.O_DIRECTORY | constants7.O_NOFOLLOW
|
|
65874
66126
|
);
|
|
@@ -65879,13 +66131,13 @@ var checkDir = (dir) => {
|
|
|
65879
66131
|
} catch (e) {
|
|
65880
66132
|
return e.code === "ENOENT" ? { ok: false, why: "missing" } : { ok: false, why: "it cannot be opened safely" };
|
|
65881
66133
|
} finally {
|
|
65882
|
-
if (fd !== void 0)
|
|
66134
|
+
if (fd !== void 0) closeSync11(fd);
|
|
65883
66135
|
}
|
|
65884
66136
|
};
|
|
65885
66137
|
var tail = (path, dir) => {
|
|
65886
66138
|
let fd;
|
|
65887
66139
|
try {
|
|
65888
|
-
fd =
|
|
66140
|
+
fd = openSync11(
|
|
65889
66141
|
path,
|
|
65890
66142
|
constants7.O_RDONLY | constants7.O_NOFOLLOW | constants7.O_NONBLOCK
|
|
65891
66143
|
);
|
|
@@ -65893,17 +66145,17 @@ var tail = (path, dir) => {
|
|
|
65893
66145
|
const after = lstatSync21(dirname19(path));
|
|
65894
66146
|
if (after.isSymbolicLink() || after.dev !== dir.dev || after.ino !== dir.ino)
|
|
65895
66147
|
return "skipped";
|
|
65896
|
-
return
|
|
66148
|
+
return readFileSync41(fd, "utf8").replace(/\n$/, "").split("\n").slice(-TAIL);
|
|
65897
66149
|
} catch (e) {
|
|
65898
66150
|
return e.code === "ELOOP" ? "skipped" : void 0;
|
|
65899
66151
|
} finally {
|
|
65900
|
-
if (fd !== void 0)
|
|
66152
|
+
if (fd !== void 0) closeSync11(fd);
|
|
65901
66153
|
}
|
|
65902
66154
|
};
|
|
65903
66155
|
async function logs(ctx) {
|
|
65904
|
-
const logDir =
|
|
65905
|
-
const path =
|
|
65906
|
-
const eventsPath =
|
|
66156
|
+
const logDir = join48(ctx.home, "logs");
|
|
66157
|
+
const path = join48(logDir, "daemon.log");
|
|
66158
|
+
const eventsPath = join48(logDir, "events.log");
|
|
65907
66159
|
const dir = checkDir(logDir);
|
|
65908
66160
|
if (!dir.ok && dir.why !== "missing") {
|
|
65909
66161
|
say(ctx, `Not reading ${tilde(ctx, logDir)}: ${dir.why}.`);
|
|
@@ -65944,9 +66196,9 @@ async function mcp(harness, ctx, load2 = (h) => MCP_SERVER[h]()) {
|
|
|
65944
66196
|
// src/commands/mcp-proof.ts
|
|
65945
66197
|
init_src3();
|
|
65946
66198
|
import { execFileSync as execFileSync7 } from "node:child_process";
|
|
65947
|
-
import { createHash as createHash12, randomBytes as
|
|
65948
|
-
import { readFileSync as
|
|
65949
|
-
import { basename as basename9, join as
|
|
66199
|
+
import { createHash as createHash12, randomBytes as randomBytes9 } from "node:crypto";
|
|
66200
|
+
import { readFileSync as readFileSync42, readlinkSync as readlinkSync7 } from "node:fs";
|
|
66201
|
+
import { basename as basename9, join as join49 } from "node:path";
|
|
65950
66202
|
init_src2();
|
|
65951
66203
|
init_src();
|
|
65952
66204
|
var LOG_WAIT_MS = 300;
|
|
@@ -65959,14 +66211,14 @@ function parsePs(out) {
|
|
|
65959
66211
|
}
|
|
65960
66212
|
function readProc(pid) {
|
|
65961
66213
|
try {
|
|
65962
|
-
const stat =
|
|
66214
|
+
const stat = readFileSync42(`/proc/${pid}/stat`, "utf8");
|
|
65963
66215
|
const ppid = Number(stat.slice(stat.lastIndexOf(")") + 1).split(/\s+/)[2]);
|
|
65964
66216
|
let exe = "";
|
|
65965
66217
|
try {
|
|
65966
66218
|
exe = readlinkSync7(`/proc/${pid}/exe`);
|
|
65967
66219
|
} catch {
|
|
65968
66220
|
}
|
|
65969
|
-
const comm =
|
|
66221
|
+
const comm = readFileSync42(`/proc/${pid}/comm`, "utf8").trim();
|
|
65970
66222
|
return { ppid, name: isClaude(exe) ? exe : comm };
|
|
65971
66223
|
} catch {
|
|
65972
66224
|
}
|
|
@@ -65994,7 +66246,7 @@ function findClaude(from, proc) {
|
|
|
65994
66246
|
function tokenOf(file2) {
|
|
65995
66247
|
if (!file2) return void 0;
|
|
65996
66248
|
try {
|
|
65997
|
-
return
|
|
66249
|
+
return readFileSync42(file2, "utf8").trim() || void 0;
|
|
65998
66250
|
} catch {
|
|
65999
66251
|
return void 0;
|
|
66000
66252
|
}
|
|
@@ -66002,7 +66254,7 @@ function tokenOf(file2) {
|
|
|
66002
66254
|
async function mcpProof(opts, ctx, deps2 = {
|
|
66003
66255
|
proc: readProc,
|
|
66004
66256
|
link: (pid, hash2) => daemonLinkProof({ path: daemonSocketPath(ctx.home), pid, hash: hash2 }),
|
|
66005
|
-
random: () =>
|
|
66257
|
+
random: () => randomBytes9(32),
|
|
66006
66258
|
ppid: process.ppid
|
|
66007
66259
|
}) {
|
|
66008
66260
|
const headers = {};
|
|
@@ -66028,7 +66280,7 @@ async function mcpProof(opts, ctx, deps2 = {
|
|
|
66028
66280
|
say(ctx, JSON.stringify(headers));
|
|
66029
66281
|
if (why2 !== void 0)
|
|
66030
66282
|
try {
|
|
66031
|
-
const events = createEventLog(
|
|
66283
|
+
const events = createEventLog(join49(ctx.home, "logs", "events.log"));
|
|
66032
66284
|
events(UNBOUND_EVENT, { reason: why2 });
|
|
66033
66285
|
await Promise.race([
|
|
66034
66286
|
events.flush(),
|
|
@@ -66040,8 +66292,8 @@ async function mcpProof(opts, ctx, deps2 = {
|
|
|
66040
66292
|
}
|
|
66041
66293
|
|
|
66042
66294
|
// src/commands/namespace.ts
|
|
66043
|
-
import { realpathSync as realpathSync16, statSync as
|
|
66044
|
-
import { join as
|
|
66295
|
+
import { realpathSync as realpathSync16, statSync as statSync14 } from "node:fs";
|
|
66296
|
+
import { join as join50, resolve as resolve16 } from "node:path";
|
|
66045
66297
|
init_src();
|
|
66046
66298
|
function shown4(ctx, path) {
|
|
66047
66299
|
const t = tilde(ctx, path);
|
|
@@ -66091,11 +66343,11 @@ async function namespace(opts, ctx) {
|
|
|
66091
66343
|
say(ctx, c.nsRevoked(shown4(ctx, real3 ?? given)));
|
|
66092
66344
|
return 0;
|
|
66093
66345
|
}
|
|
66094
|
-
if (!real3 || !
|
|
66346
|
+
if (!real3 || !statSync14(real3).isDirectory()) {
|
|
66095
66347
|
sayErr(ctx, c.nsNotDir(shown4(ctx, real3 ?? given)));
|
|
66096
66348
|
return 1;
|
|
66097
66349
|
}
|
|
66098
|
-
const cfgFile =
|
|
66350
|
+
const cfgFile = join50(real3, CONFIG_FILE);
|
|
66099
66351
|
const own2 = readOwnFile(cfgFile, process.getuid?.(), {
|
|
66100
66352
|
allowGroupWrite: true
|
|
66101
66353
|
});
|
|
@@ -66251,12 +66503,12 @@ async function skill(opts, ctx) {
|
|
|
66251
66503
|
}
|
|
66252
66504
|
|
|
66253
66505
|
// src/commands/uninstall.ts
|
|
66254
|
-
import { join as
|
|
66506
|
+
import { join as join52 } from "node:path";
|
|
66255
66507
|
|
|
66256
66508
|
// src/steps/purge.ts
|
|
66257
66509
|
init_src3();
|
|
66258
|
-
import { lstatSync as lstatSync22, readdirSync as
|
|
66259
|
-
import { join as
|
|
66510
|
+
import { lstatSync as lstatSync22, readdirSync as readdirSync14, rmdirSync as rmdirSync5, rmSync as rmSync24 } from "node:fs";
|
|
66511
|
+
import { join as join51 } from "node:path";
|
|
66260
66512
|
var FILES = [
|
|
66261
66513
|
"machine.json",
|
|
66262
66514
|
"install.json",
|
|
@@ -66326,14 +66578,14 @@ var rmdirIfEmpty = (path) => {
|
|
|
66326
66578
|
};
|
|
66327
66579
|
function purgeShort(dir, removed) {
|
|
66328
66580
|
if (kind3(dir) !== "dir" || unsafeSocketDir(dir)) return;
|
|
66329
|
-
const ret =
|
|
66581
|
+
const ret = join51(dir, "claude-return");
|
|
66330
66582
|
for (const [d, ours2] of [
|
|
66331
66583
|
[ret, (_n, p) => kind3(p) === "socket"],
|
|
66332
66584
|
[dir, (n) => /^daemon\.sock(\.keep-\d+)?$/.test(n)]
|
|
66333
66585
|
]) {
|
|
66334
66586
|
if (kind3(d) !== "dir") continue;
|
|
66335
|
-
for (const name of
|
|
66336
|
-
const path =
|
|
66587
|
+
for (const name of readdirSync14(d)) {
|
|
66588
|
+
const path = join51(d, name);
|
|
66337
66589
|
const k = kind3(path);
|
|
66338
66590
|
if (k === void 0 || k === "dir" || !ours2(name, path)) continue;
|
|
66339
66591
|
remove2(path, k);
|
|
@@ -66346,7 +66598,7 @@ function purgeShort(dir, removed) {
|
|
|
66346
66598
|
function purge(home2, opts) {
|
|
66347
66599
|
let entries;
|
|
66348
66600
|
try {
|
|
66349
|
-
entries =
|
|
66601
|
+
entries = readdirSync14(home2);
|
|
66350
66602
|
} catch {
|
|
66351
66603
|
return { removed: [], leftDir: false };
|
|
66352
66604
|
}
|
|
@@ -66358,21 +66610,21 @@ function purge(home2, opts) {
|
|
|
66358
66610
|
...FILES,
|
|
66359
66611
|
...entries.filter((n) => TEMP.some((re) => re.test(n)))
|
|
66360
66612
|
]) {
|
|
66361
|
-
const path =
|
|
66613
|
+
const path = join51(home2, name);
|
|
66362
66614
|
const k = kind3(path);
|
|
66363
66615
|
if (k === void 0 || k === "dir") continue;
|
|
66364
66616
|
remove2(path, k);
|
|
66365
66617
|
removed.push(name);
|
|
66366
66618
|
}
|
|
66367
66619
|
for (const folder of FOLDERS) {
|
|
66368
|
-
const dir =
|
|
66620
|
+
const dir = join51(home2, folder.path);
|
|
66369
66621
|
if (kind3(dir) !== "dir") continue;
|
|
66370
|
-
for (const name of
|
|
66371
|
-
const path =
|
|
66622
|
+
for (const name of readdirSync14(dir)) {
|
|
66623
|
+
const path = join51(dir, name);
|
|
66372
66624
|
const k = kind3(path);
|
|
66373
66625
|
if (k === void 0 || !folder.ours(name, path)) continue;
|
|
66374
66626
|
remove2(path, k);
|
|
66375
|
-
removed.push(
|
|
66627
|
+
removed.push(join51(folder.path, name));
|
|
66376
66628
|
}
|
|
66377
66629
|
if (rmdirIfEmpty(dir)) removed.push(folder.path);
|
|
66378
66630
|
}
|
|
@@ -66463,7 +66715,7 @@ async function unwire(ctx) {
|
|
|
66463
66715
|
say(
|
|
66464
66716
|
ctx,
|
|
66465
66717
|
c.hermesNoCli(
|
|
66466
|
-
tilde(ctx,
|
|
66718
|
+
tilde(ctx, join52(hermesHome(ctx.userHome, ctx.env), "config.yaml"))
|
|
66467
66719
|
)
|
|
66468
66720
|
);
|
|
66469
66721
|
if (r.openclawNoCli) say(ctx, c.openclawNoCli());
|
|
@@ -66497,7 +66749,7 @@ async function uninstall2(opts, ctx) {
|
|
|
66497
66749
|
say(ctx, c.daemonStillRunning(removed.running));
|
|
66498
66750
|
if (wiredTo(ctx)) await unwire(ctx);
|
|
66499
66751
|
if (!opts.purge) {
|
|
66500
|
-
say(ctx, "", c.kept(tilde(ctx,
|
|
66752
|
+
say(ctx, "", c.kept(tilde(ctx, join52(ctx.home, "machine.json"))));
|
|
66501
66753
|
return 0;
|
|
66502
66754
|
}
|
|
66503
66755
|
const home2 = tilde(ctx, ctx.home);
|
|
@@ -66507,9 +66759,9 @@ async function uninstall2(opts, ctx) {
|
|
|
66507
66759
|
return 1;
|
|
66508
66760
|
} catch {
|
|
66509
66761
|
}
|
|
66510
|
-
const made = readMade(
|
|
66762
|
+
const made = readMade(join52(ctx.home, "install.json"));
|
|
66511
66763
|
const out = purge(ctx.home, {
|
|
66512
|
-
isDefault: ctx.home ===
|
|
66764
|
+
isDefault: ctx.home === join52(ctx.userHome, ".oa-bus")
|
|
66513
66765
|
});
|
|
66514
66766
|
if ("refused" in out) {
|
|
66515
66767
|
sayErr(ctx, c.purgeRefused(home2));
|
|
@@ -66597,6 +66849,7 @@ import { parseArgs } from "node:util";
|
|
|
66597
66849
|
var COMMANDS = /* @__PURE__ */ new Set([
|
|
66598
66850
|
"install",
|
|
66599
66851
|
"login",
|
|
66852
|
+
"add",
|
|
66600
66853
|
"skill",
|
|
66601
66854
|
"daemon",
|
|
66602
66855
|
"mcp",
|
|
@@ -66636,6 +66889,7 @@ var FLAGS = {
|
|
|
66636
66889
|
"json"
|
|
66637
66890
|
],
|
|
66638
66891
|
login: ["instance", "no-open"],
|
|
66892
|
+
add: ["name", "no-open"],
|
|
66639
66893
|
skill: ["instance", "check", "json"],
|
|
66640
66894
|
daemon: ["instance"],
|
|
66641
66895
|
uninstall: ["purge"],
|
|
@@ -66654,6 +66908,7 @@ function parse7(argv) {
|
|
|
66654
66908
|
tokens: true,
|
|
66655
66909
|
options: {
|
|
66656
66910
|
instance: { type: "string" },
|
|
66911
|
+
name: { type: "string" },
|
|
66657
66912
|
home: { type: "string" },
|
|
66658
66913
|
"token-file": { type: "string" },
|
|
66659
66914
|
"token-env": { type: "string" },
|
|
@@ -66679,9 +66934,11 @@ function parse7(argv) {
|
|
|
66679
66934
|
const cmd = head ?? "install";
|
|
66680
66935
|
if (!COMMANDS.has(cmd)) throw new Error(`unknown command: ${cmd}`);
|
|
66681
66936
|
const tokenFile = values["token-file"];
|
|
66682
|
-
const takes = cmd === "mcp" ? 1 : cmd === "global" ? rest[0] === "list" ? 1 : 2 : 0;
|
|
66937
|
+
const takes = cmd === "mcp" || cmd === "add" ? 1 : cmd === "global" ? rest[0] === "list" ? 1 : 2 : 0;
|
|
66683
66938
|
if (cmd === "mcp" && rest.length === 0)
|
|
66684
66939
|
throw new Error(`usage: ${BUS_CMD} mcp <claude|opencode|codex|pi>`);
|
|
66940
|
+
if (cmd === "add" && rest.length === 0)
|
|
66941
|
+
throw new Error(`usage: ${BUS_CMD} add <address> [--name <name>]`);
|
|
66685
66942
|
if (cmd === "global" && rest.length < takes) throw new Error(GLOBAL_USAGE);
|
|
66686
66943
|
if (cmd === "namespace") {
|
|
66687
66944
|
const sub = rest[0];
|
|
@@ -66711,7 +66968,7 @@ function parse7(argv) {
|
|
|
66711
66968
|
}
|
|
66712
66969
|
const extra = cmd === "namespace" || cmd === "link" || cmd === "unlink" || cmd === "leads" || cmd === "auto-update" ? void 0 : rest[takes];
|
|
66713
66970
|
if (extra !== void 0) throw new Error(`unexpected argument: ${extra}`);
|
|
66714
|
-
for (const name of ["home", "instance"])
|
|
66971
|
+
for (const name of ["home", "instance", "name"])
|
|
66715
66972
|
if (values[name] === "") throw new Error(`--${name} needs a value`);
|
|
66716
66973
|
for (const t of tokens2) {
|
|
66717
66974
|
if (t.kind !== "option" || COMMON.has(t.name)) continue;
|
|
@@ -66748,6 +67005,13 @@ function route(cmd, values, positionals) {
|
|
|
66748
67005
|
switch (cmd) {
|
|
66749
67006
|
case "login":
|
|
66750
67007
|
return { cmd, hub: values.instance, noOpen: values["no-open"] };
|
|
67008
|
+
case "add":
|
|
67009
|
+
return {
|
|
67010
|
+
cmd,
|
|
67011
|
+
address: positionals[0],
|
|
67012
|
+
...values.name ? { name: values.name } : {},
|
|
67013
|
+
noOpen: values["no-open"]
|
|
67014
|
+
};
|
|
66751
67015
|
case "skill":
|
|
66752
67016
|
return {
|
|
66753
67017
|
cmd,
|
|
@@ -66833,6 +67097,7 @@ function habitsMode(v) {
|
|
|
66833
67097
|
// src/main.ts
|
|
66834
67098
|
var TERMINAL = /* @__PURE__ */ new Set([
|
|
66835
67099
|
"login",
|
|
67100
|
+
"add",
|
|
66836
67101
|
"skill",
|
|
66837
67102
|
"status",
|
|
66838
67103
|
"logs",
|
|
@@ -66899,6 +67164,8 @@ async function dispatch(cmd, ctx) {
|
|
|
66899
67164
|
if (pid !== void 0) say(ctx, ctx.copy.daemonOldToken(pid));
|
|
66900
67165
|
return 0;
|
|
66901
67166
|
}
|
|
67167
|
+
case "add":
|
|
67168
|
+
return add(cmd, ctx);
|
|
66902
67169
|
case "skill":
|
|
66903
67170
|
return skill(cmd, ctx);
|
|
66904
67171
|
case "daemon":
|