@open-artifacts/bus 0.241.0 → 0.242.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 +488 -341
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -32905,7 +32905,7 @@ var init_frames = __esm({
|
|
|
32905
32905
|
late = { late: external_exports.array(external_exports.string().min(1)).optional() };
|
|
32906
32906
|
isWellFormed2 = (s) => s.isWellFormed();
|
|
32907
32907
|
WELL_FORMED = { message: "text is not well-formed unicode" };
|
|
32908
|
-
CLIENT_VERSION = true ? "0.
|
|
32908
|
+
CLIENT_VERSION = true ? "0.242.0" : "0.0.0";
|
|
32909
32909
|
clientVersion = {
|
|
32910
32910
|
client_version: external_exports.string().min(1).max(64).optional()
|
|
32911
32911
|
};
|
|
@@ -44690,7 +44690,7 @@ import {
|
|
|
44690
44690
|
lstatSync as lstatSync10,
|
|
44691
44691
|
realpathSync as realpathSync10,
|
|
44692
44692
|
unlinkSync as unlinkSync4,
|
|
44693
|
-
writeFileSync as
|
|
44693
|
+
writeFileSync as writeFileSync14
|
|
44694
44694
|
} from "node:fs";
|
|
44695
44695
|
import { basename as basename7, isAbsolute as isAbsolute8, join as join27 } from "node:path";
|
|
44696
44696
|
|
|
@@ -44778,6 +44778,157 @@ var AgentTable = class {
|
|
|
44778
44778
|
}
|
|
44779
44779
|
};
|
|
44780
44780
|
|
|
44781
|
+
// ../bus-daemon/src/announced.ts
|
|
44782
|
+
init_src();
|
|
44783
|
+
init_zod();
|
|
44784
|
+
import { renameSync as renameSync2, rmSync as rmSync2, writeFileSync } from "node:fs";
|
|
44785
|
+
|
|
44786
|
+
// ../bus-daemon/src/own-file.ts
|
|
44787
|
+
import {
|
|
44788
|
+
closeSync,
|
|
44789
|
+
constants,
|
|
44790
|
+
fstatSync,
|
|
44791
|
+
openSync,
|
|
44792
|
+
readFileSync as readFileSync2
|
|
44793
|
+
} from "node:fs";
|
|
44794
|
+
import { userInfo } from "node:os";
|
|
44795
|
+
function isPrivateGroup(gid, user, read2 = () => readFileSync2("/etc/group", "utf8"), readPasswd = () => readFileSync2("/etc/passwd", "utf8")) {
|
|
44796
|
+
let text3;
|
|
44797
|
+
let passwd;
|
|
44798
|
+
try {
|
|
44799
|
+
text3 = read2();
|
|
44800
|
+
passwd = readPasswd();
|
|
44801
|
+
} catch {
|
|
44802
|
+
return false;
|
|
44803
|
+
}
|
|
44804
|
+
for (const line of passwd.split("\n")) {
|
|
44805
|
+
const f = line.split(":");
|
|
44806
|
+
if (f[3] === String(gid) && f[0] !== user) return false;
|
|
44807
|
+
}
|
|
44808
|
+
for (const line of text3.split("\n")) {
|
|
44809
|
+
const [name, , id, members2] = line.split(":");
|
|
44810
|
+
if (id === String(gid))
|
|
44811
|
+
return name === user && (members2 ?? "").trim() === "";
|
|
44812
|
+
}
|
|
44813
|
+
return false;
|
|
44814
|
+
}
|
|
44815
|
+
var ownGroup = () => ({
|
|
44816
|
+
gid: process.getgid?.(),
|
|
44817
|
+
isPrivate: (gid) => {
|
|
44818
|
+
if (process.platform !== "linux") return false;
|
|
44819
|
+
try {
|
|
44820
|
+
return isPrivateGroup(gid, userInfo().username);
|
|
44821
|
+
} catch {
|
|
44822
|
+
return false;
|
|
44823
|
+
}
|
|
44824
|
+
}
|
|
44825
|
+
});
|
|
44826
|
+
function readOwnFile(file2, uid = process.getuid?.(), opts = {}) {
|
|
44827
|
+
let fd;
|
|
44828
|
+
try {
|
|
44829
|
+
fd = openSync(
|
|
44830
|
+
file2,
|
|
44831
|
+
constants.O_RDONLY | (constants.O_NOFOLLOW ?? 0) | (constants.O_NONBLOCK ?? 0)
|
|
44832
|
+
);
|
|
44833
|
+
} catch (e) {
|
|
44834
|
+
const code2 = e.code;
|
|
44835
|
+
if (code2 === "ENOENT" || code2 === "ENOTDIR") return { state: "none" };
|
|
44836
|
+
return {
|
|
44837
|
+
state: "unsafe",
|
|
44838
|
+
why: code2 === "ELOOP" ? "is a symlink" : `cannot be read (${code2})`
|
|
44839
|
+
};
|
|
44840
|
+
}
|
|
44841
|
+
try {
|
|
44842
|
+
const st = fstatSync(fd);
|
|
44843
|
+
if (!st.isFile()) return { state: "unsafe", why: "is not a regular file" };
|
|
44844
|
+
if (uid !== void 0 && st.uid !== uid)
|
|
44845
|
+
return { state: "unsafe", why: "belongs to another user" };
|
|
44846
|
+
if (opts.maxBytes !== void 0 && st.size > opts.maxBytes)
|
|
44847
|
+
return { state: "unsafe", why: "is too large" };
|
|
44848
|
+
if (opts.allowGroupWrite) {
|
|
44849
|
+
if (st.mode & 2)
|
|
44850
|
+
return { state: "unsafe", why: "is writable by everyone" };
|
|
44851
|
+
let note;
|
|
44852
|
+
if (st.mode & 16) {
|
|
44853
|
+
const g = opts.group ?? ownGroup();
|
|
44854
|
+
if (st.gid !== g.gid || !g.isPrivate(st.gid))
|
|
44855
|
+
return {
|
|
44856
|
+
state: "unsafe",
|
|
44857
|
+
why: "is writable by a group others share"
|
|
44858
|
+
};
|
|
44859
|
+
note = "is writable by its group";
|
|
44860
|
+
}
|
|
44861
|
+
return {
|
|
44862
|
+
state: "ok",
|
|
44863
|
+
text: readFileSync2(fd, "utf8"),
|
|
44864
|
+
...note ? { note } : {}
|
|
44865
|
+
};
|
|
44866
|
+
}
|
|
44867
|
+
if (st.mode & 18)
|
|
44868
|
+
return { state: "unsafe", why: "is writable by others" };
|
|
44869
|
+
return { state: "ok", text: readFileSync2(fd, "utf8") };
|
|
44870
|
+
} catch (e) {
|
|
44871
|
+
return {
|
|
44872
|
+
state: "unsafe",
|
|
44873
|
+
why: `cannot be read (${e.code ?? String(e)})`
|
|
44874
|
+
};
|
|
44875
|
+
} finally {
|
|
44876
|
+
closeSync(fd);
|
|
44877
|
+
}
|
|
44878
|
+
}
|
|
44879
|
+
|
|
44880
|
+
// ../bus-daemon/src/announced.ts
|
|
44881
|
+
var ANNOUNCED_MAX = 256;
|
|
44882
|
+
var EntrySchema = external_exports.strictObject({
|
|
44883
|
+
ref: AgentRefSchema,
|
|
44884
|
+
/** The harness kind, so a restored close keeps its row's kind (status, roster). */
|
|
44885
|
+
kind: external_exports.string().regex(/^[a-z][a-z0-9-]{0,31}$/),
|
|
44886
|
+
/** #2793: the instance (lane) it was registered on; absent means main. */
|
|
44887
|
+
instance: external_exports.string().regex(/^[a-z0-9-]{1,32}$/).optional()
|
|
44888
|
+
});
|
|
44889
|
+
var FileSchema = external_exports.strictObject({
|
|
44890
|
+
v: external_exports.literal(1),
|
|
44891
|
+
refs: external_exports.array(external_exports.unknown())
|
|
44892
|
+
});
|
|
44893
|
+
function readAnnounced(file2, uid = process.getuid?.(), log = () => {
|
|
44894
|
+
}) {
|
|
44895
|
+
try {
|
|
44896
|
+
const f = readOwnFile(file2, uid);
|
|
44897
|
+
if (f.state === "unsafe") log(`ignoring ${file2}: ${f.why}`);
|
|
44898
|
+
if (f.state !== "ok") return [];
|
|
44899
|
+
const top = FileSchema.safeParse(JSON.parse(f.text));
|
|
44900
|
+
if (!top.success) {
|
|
44901
|
+
log(`ignoring ${file2}: not the expected shape`);
|
|
44902
|
+
return [];
|
|
44903
|
+
}
|
|
44904
|
+
const out = [];
|
|
44905
|
+
for (const raw of top.data.refs) {
|
|
44906
|
+
if (out.length >= ANNOUNCED_MAX) break;
|
|
44907
|
+
const one3 = EntrySchema.safeParse(raw);
|
|
44908
|
+
if (one3.success) out.push(one3.data);
|
|
44909
|
+
}
|
|
44910
|
+
return out;
|
|
44911
|
+
} catch (e) {
|
|
44912
|
+
log(`ignoring ${file2}: ${e instanceof Error ? e.message : String(e)}`);
|
|
44913
|
+
return [];
|
|
44914
|
+
}
|
|
44915
|
+
}
|
|
44916
|
+
function writeAnnounced(file2, refs) {
|
|
44917
|
+
const tmp = `${file2}.${process.pid}.tmp`;
|
|
44918
|
+
rmSync2(tmp, { force: true });
|
|
44919
|
+
try {
|
|
44920
|
+
writeFileSync(
|
|
44921
|
+
tmp,
|
|
44922
|
+
JSON.stringify({ v: 1, refs: refs.slice(-ANNOUNCED_MAX) }),
|
|
44923
|
+
{ mode: 384, flag: "wx" }
|
|
44924
|
+
);
|
|
44925
|
+
renameSync2(tmp, file2);
|
|
44926
|
+
} catch (e) {
|
|
44927
|
+
rmSync2(tmp, { force: true });
|
|
44928
|
+
throw e;
|
|
44929
|
+
}
|
|
44930
|
+
}
|
|
44931
|
+
|
|
44781
44932
|
// ../bus-daemon/src/attest.ts
|
|
44782
44933
|
init_src3();
|
|
44783
44934
|
init_src2();
|
|
@@ -44788,12 +44939,12 @@ import { basename as basename3, isAbsolute as isAbsolute2 } from "node:path";
|
|
|
44788
44939
|
init_src2();
|
|
44789
44940
|
import { execFileSync as execFileSync2 } from "node:child_process";
|
|
44790
44941
|
import {
|
|
44791
|
-
closeSync,
|
|
44792
|
-
fstatSync,
|
|
44942
|
+
closeSync as closeSync2,
|
|
44943
|
+
fstatSync as fstatSync2,
|
|
44793
44944
|
lstatSync as lstatSync3,
|
|
44794
|
-
openSync,
|
|
44945
|
+
openSync as openSync2,
|
|
44795
44946
|
readdirSync as readdirSync2,
|
|
44796
|
-
readFileSync as
|
|
44947
|
+
readFileSync as readFileSync5,
|
|
44797
44948
|
readSync,
|
|
44798
44949
|
realpathSync as realpathSync2,
|
|
44799
44950
|
statSync as statSync4
|
|
@@ -44802,7 +44953,7 @@ import { homedir as homedir2 } from "node:os";
|
|
|
44802
44953
|
import { basename as basename2, isAbsolute, join as join5 } from "node:path";
|
|
44803
44954
|
|
|
44804
44955
|
// ../bus-daemon/src/presence/opencode.ts
|
|
44805
|
-
import { readdirSync, readFileSync as
|
|
44956
|
+
import { readdirSync, readFileSync as readFileSync4, statSync as statSync3 } from "node:fs";
|
|
44806
44957
|
import { join as join4 } from "node:path";
|
|
44807
44958
|
|
|
44808
44959
|
// ../bus-daemon/src/config.ts
|
|
@@ -44813,7 +44964,7 @@ import {
|
|
|
44813
44964
|
chmodSync as chmodSync2,
|
|
44814
44965
|
existsSync as existsSync2,
|
|
44815
44966
|
mkdirSync as mkdirSync3,
|
|
44816
|
-
readFileSync as
|
|
44967
|
+
readFileSync as readFileSync3,
|
|
44817
44968
|
statSync as statSync2
|
|
44818
44969
|
} from "node:fs";
|
|
44819
44970
|
import { join as join3 } from "node:path";
|
|
@@ -44823,7 +44974,7 @@ function procBusHome(pid) {
|
|
|
44823
44974
|
if (process.platform !== "linux") return null;
|
|
44824
44975
|
let env2;
|
|
44825
44976
|
try {
|
|
44826
|
-
env2 =
|
|
44977
|
+
env2 = readFileSync3(`/proc/${pid}/environ`, "utf8");
|
|
44827
44978
|
} catch {
|
|
44828
44979
|
return null;
|
|
44829
44980
|
}
|
|
@@ -44913,7 +45064,7 @@ function revokedFor(token, h = home()) {
|
|
|
44913
45064
|
function markerHolds(file2, token) {
|
|
44914
45065
|
if (!existsSync2(file2)) return false;
|
|
44915
45066
|
try {
|
|
44916
|
-
const m = JSON.parse(
|
|
45067
|
+
const m = JSON.parse(readFileSync3(file2, "utf8"));
|
|
44917
45068
|
if (typeof m.token_sha256 === "string")
|
|
44918
45069
|
return m.token_sha256 === tokenHash(token);
|
|
44919
45070
|
} catch {
|
|
@@ -44922,7 +45073,7 @@ function markerHolds(file2, token) {
|
|
|
44922
45073
|
}
|
|
44923
45074
|
function savedToken(h = home()) {
|
|
44924
45075
|
try {
|
|
44925
|
-
const r = JSON.parse(
|
|
45076
|
+
const r = JSON.parse(readFileSync3(join3(h, "machine.json"), "utf8"));
|
|
44926
45077
|
return typeof r.machine_token === "string" ? r.machine_token : void 0;
|
|
44927
45078
|
} catch {
|
|
44928
45079
|
return void 0;
|
|
@@ -44938,7 +45089,7 @@ function readConfig(h = home()) {
|
|
|
44938
45089
|
`${file2} is readable by other users: run \`chmod 600 ${file2}\``
|
|
44939
45090
|
);
|
|
44940
45091
|
}
|
|
44941
|
-
text3 =
|
|
45092
|
+
text3 = readFileSync3(file2, "utf8");
|
|
44942
45093
|
} catch (e) {
|
|
44943
45094
|
const code2 = e.code;
|
|
44944
45095
|
if (code2 === "ENOENT") throw notLoggedIn();
|
|
@@ -45004,7 +45155,7 @@ function openSessions(dir, deps2) {
|
|
|
45004
45155
|
let mtime;
|
|
45005
45156
|
try {
|
|
45006
45157
|
mtime = statSync3(join4(dir, fn)).mtimeMs / 1e3;
|
|
45007
|
-
data = JSON.parse(
|
|
45158
|
+
data = JSON.parse(readFileSync4(join4(dir, fn), "utf8"));
|
|
45008
45159
|
} catch {
|
|
45009
45160
|
continue;
|
|
45010
45161
|
}
|
|
@@ -45039,7 +45190,7 @@ function openState(dir, deps2, ref) {
|
|
|
45039
45190
|
let mtime;
|
|
45040
45191
|
try {
|
|
45041
45192
|
mtime = statSync3(join4(dir, fn)).mtimeMs / 1e3;
|
|
45042
|
-
data = JSON.parse(
|
|
45193
|
+
data = JSON.parse(readFileSync4(join4(dir, fn), "utf8"));
|
|
45043
45194
|
} catch (e) {
|
|
45044
45195
|
if (e.code !== "ENOENT") unknown2 = true;
|
|
45045
45196
|
continue;
|
|
@@ -45082,7 +45233,7 @@ var CODEX_PROXY_ENTRY_FILE = "codex-mcp-entry.json";
|
|
|
45082
45233
|
function codexProxyNamespaces(busHome2) {
|
|
45083
45234
|
try {
|
|
45084
45235
|
const v = JSON.parse(
|
|
45085
|
-
|
|
45236
|
+
readFileSync5(`${busHome2}/${CODEX_PROXY_ENTRY_FILE}`, "utf8")
|
|
45086
45237
|
);
|
|
45087
45238
|
const name = v?.name;
|
|
45088
45239
|
if (typeof name !== "string" || name === "") return [];
|
|
@@ -45361,12 +45512,12 @@ function codexAttestor(deps2 = {}) {
|
|
|
45361
45512
|
function advance(scan2, namespaces = [CODEX_TOOL_NAMESPACE]) {
|
|
45362
45513
|
let fd;
|
|
45363
45514
|
try {
|
|
45364
|
-
fd =
|
|
45515
|
+
fd = openSync2(scan2.rollout, "r");
|
|
45365
45516
|
} catch {
|
|
45366
45517
|
return;
|
|
45367
45518
|
}
|
|
45368
45519
|
try {
|
|
45369
|
-
const size =
|
|
45520
|
+
const size = fstatSync2(fd).size;
|
|
45370
45521
|
if (scan2.offset > size) {
|
|
45371
45522
|
scan2.offset = -1;
|
|
45372
45523
|
Object.assign(scan2, seen());
|
|
@@ -45381,7 +45532,7 @@ function advance(scan2, namespaces = [CODEX_TOOL_NAMESPACE]) {
|
|
|
45381
45532
|
return false;
|
|
45382
45533
|
});
|
|
45383
45534
|
} finally {
|
|
45384
|
-
|
|
45535
|
+
closeSync2(fd);
|
|
45385
45536
|
}
|
|
45386
45537
|
}
|
|
45387
45538
|
function readLines(fd, from, size, skipFirst, visit3, cap = LINE_CAP) {
|
|
@@ -45554,13 +45705,13 @@ function globRollout(home2, thread) {
|
|
|
45554
45705
|
function sessionMeta(path, thread) {
|
|
45555
45706
|
let fd;
|
|
45556
45707
|
try {
|
|
45557
|
-
fd =
|
|
45708
|
+
fd = openSync2(path, "r");
|
|
45558
45709
|
} catch {
|
|
45559
45710
|
return void 0;
|
|
45560
45711
|
}
|
|
45561
45712
|
try {
|
|
45562
45713
|
let first;
|
|
45563
|
-
const size = Math.min(
|
|
45714
|
+
const size = Math.min(fstatSync2(fd).size, META_CAP + 1);
|
|
45564
45715
|
readLines(
|
|
45565
45716
|
fd,
|
|
45566
45717
|
0,
|
|
@@ -45581,7 +45732,7 @@ function sessionMeta(path, thread) {
|
|
|
45581
45732
|
} catch {
|
|
45582
45733
|
return void 0;
|
|
45583
45734
|
} finally {
|
|
45584
|
-
|
|
45735
|
+
closeSync2(fd);
|
|
45585
45736
|
}
|
|
45586
45737
|
}
|
|
45587
45738
|
var exitedOne = (e) => {
|
|
@@ -45700,7 +45851,7 @@ function holdingLinux(pairs, procRoot = "/proc") {
|
|
|
45700
45851
|
let locks;
|
|
45701
45852
|
try {
|
|
45702
45853
|
locks = new Set(
|
|
45703
|
-
|
|
45854
|
+
readFileSync5(join5(procRoot, "locks"), "utf8").split("\n").flatMap((l) => {
|
|
45704
45855
|
const [maj, min, ino] = (l.trim().split(/\s+/)[5] ?? "").split(":");
|
|
45705
45856
|
if (!maj || !min || !ino) return [];
|
|
45706
45857
|
if (!/^[0-9a-f]+$/i.test(maj + min) || !/^\d+$/.test(ino)) return [];
|
|
@@ -45787,7 +45938,7 @@ function fdHoldsLock(procRoot, pid, fd, st) {
|
|
|
45787
45938
|
try {
|
|
45788
45939
|
const { major, minor } = devParts(st.dev);
|
|
45789
45940
|
const want = `${major}:${minor}:${st.ino}`;
|
|
45790
|
-
return
|
|
45941
|
+
return readFileSync5(join5(procRoot, String(pid), "fdinfo", fd), "utf8").split("\n").some((l) => {
|
|
45791
45942
|
if (!l.startsWith("lock:")) return false;
|
|
45792
45943
|
const f = l.trim().split(/\s+/);
|
|
45793
45944
|
if (!REAL_LOCKS.has(f[2] ?? "")) return false;
|
|
@@ -45805,7 +45956,7 @@ function fdHoldsLock(procRoot, pid, fd, st) {
|
|
|
45805
45956
|
init_src3();
|
|
45806
45957
|
init_src();
|
|
45807
45958
|
import { createHash as createHash4 } from "node:crypto";
|
|
45808
|
-
import { readdirSync as readdirSync3, readFileSync as
|
|
45959
|
+
import { readdirSync as readdirSync3, readFileSync as readFileSync6 } from "node:fs";
|
|
45809
45960
|
import { join as join6 } from "node:path";
|
|
45810
45961
|
var sha256Of = (s) => createHash4("sha256").update(s).digest("hex");
|
|
45811
45962
|
function scanSessions(dir) {
|
|
@@ -45822,7 +45973,7 @@ function scanSessions(dir) {
|
|
|
45822
45973
|
if (!m) continue;
|
|
45823
45974
|
let rec;
|
|
45824
45975
|
try {
|
|
45825
|
-
rec = JSON.parse(
|
|
45976
|
+
rec = JSON.parse(readFileSync6(join6(dir, fn), "utf8"));
|
|
45826
45977
|
} catch {
|
|
45827
45978
|
unreadable.add(Number(m[1]));
|
|
45828
45979
|
continue;
|
|
@@ -45907,7 +46058,7 @@ function claudeTargetState(ref, pid, deps2) {
|
|
|
45907
46058
|
if (f.socketPath === "") return "unreachable";
|
|
45908
46059
|
try {
|
|
45909
46060
|
const key2 = JSON.parse(
|
|
45910
|
-
|
|
46061
|
+
readFileSync6(
|
|
45911
46062
|
join6(deps2.dir, `${pid}.${(deps2.sha256 ?? sha256Of)(f.socketPath)}.key`),
|
|
45912
46063
|
"utf8"
|
|
45913
46064
|
)
|
|
@@ -45961,7 +46112,7 @@ function isRunning(pid) {
|
|
|
45961
46112
|
// ../bus-daemon/src/presence/attached.ts
|
|
45962
46113
|
init_src2();
|
|
45963
46114
|
import { execFileSync as execFileSync3, spawnSync } from "node:child_process";
|
|
45964
|
-
import { readdirSync as readdirSync4, readFileSync as
|
|
46115
|
+
import { readdirSync as readdirSync4, readFileSync as readFileSync7, readlinkSync } from "node:fs";
|
|
45965
46116
|
var READ_TIMEOUT_MS = 1500;
|
|
45966
46117
|
var exePath = (exe) => exe === null ? null : exe.replace(/ \(deleted\)$/, "");
|
|
45967
46118
|
function attachedTo(service, deps2) {
|
|
@@ -46053,8 +46204,8 @@ function socketInodes(pid) {
|
|
|
46053
46204
|
function tcpRows() {
|
|
46054
46205
|
try {
|
|
46055
46206
|
return [
|
|
46056
|
-
...parseProcNetTcp(
|
|
46057
|
-
...parseProcNetTcp(
|
|
46207
|
+
...parseProcNetTcp(readFileSync7("/proc/net/tcp", "utf8")),
|
|
46208
|
+
...parseProcNetTcp(readFileSync7("/proc/net/tcp6", "utf8"))
|
|
46058
46209
|
];
|
|
46059
46210
|
} catch {
|
|
46060
46211
|
return null;
|
|
@@ -46100,6 +46251,33 @@ function lsofEstablished(text3) {
|
|
|
46100
46251
|
}
|
|
46101
46252
|
return out;
|
|
46102
46253
|
}
|
|
46254
|
+
function exeFromLsof(text3) {
|
|
46255
|
+
let fd = "";
|
|
46256
|
+
for (const line of text3.split("\n")) {
|
|
46257
|
+
if (line.startsWith("f")) {
|
|
46258
|
+
fd = line.slice(1).trim();
|
|
46259
|
+
continue;
|
|
46260
|
+
}
|
|
46261
|
+
if (!line.startsWith("n")) continue;
|
|
46262
|
+
const path = line.slice(1).trim();
|
|
46263
|
+
if (fd === "cwd" || !path.startsWith("/")) continue;
|
|
46264
|
+
return path;
|
|
46265
|
+
}
|
|
46266
|
+
return null;
|
|
46267
|
+
}
|
|
46268
|
+
function macExeOf(pid, runLsof = spawnSync) {
|
|
46269
|
+
const r = runLsof(
|
|
46270
|
+
systemTool("lsof"),
|
|
46271
|
+
["-a", "-d", "txt", "-Ffn", "-p", String(pid)],
|
|
46272
|
+
{
|
|
46273
|
+
encoding: "utf8",
|
|
46274
|
+
timeout: READ_TIMEOUT_MS,
|
|
46275
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
46276
|
+
}
|
|
46277
|
+
);
|
|
46278
|
+
if (r.error !== void 0 || r.signal !== null) return null;
|
|
46279
|
+
return exeFromLsof(r.stdout ?? "");
|
|
46280
|
+
}
|
|
46103
46281
|
var defaultAttachDeps = {
|
|
46104
46282
|
exeOf(pid) {
|
|
46105
46283
|
if (process.platform === "linux") {
|
|
@@ -46109,8 +46287,7 @@ var defaultAttachDeps = {
|
|
|
46109
46287
|
return null;
|
|
46110
46288
|
}
|
|
46111
46289
|
}
|
|
46112
|
-
|
|
46113
|
-
return out?.startsWith("/") ? out : null;
|
|
46290
|
+
return macExeOf(pid);
|
|
46114
46291
|
},
|
|
46115
46292
|
ppidOf(pid) {
|
|
46116
46293
|
const out = run2("ps", ["-o", "ppid=", "-p", String(pid)])?.trim();
|
|
@@ -46249,119 +46426,23 @@ import {
|
|
|
46249
46426
|
existsSync as existsSync3,
|
|
46250
46427
|
readdirSync as readdirSync5,
|
|
46251
46428
|
readFileSync as readFileSync8,
|
|
46252
|
-
renameSync as
|
|
46253
|
-
rmSync as
|
|
46254
|
-
writeFileSync
|
|
46429
|
+
renameSync as renameSync3,
|
|
46430
|
+
rmSync as rmSync3,
|
|
46431
|
+
writeFileSync as writeFileSync2
|
|
46255
46432
|
} from "node:fs";
|
|
46256
46433
|
import { homedir as homedir3 } from "node:os";
|
|
46257
46434
|
import { join as join7 } from "node:path";
|
|
46258
46435
|
import { createInterface } from "node:readline";
|
|
46259
|
-
|
|
46260
|
-
// ../bus-daemon/src/own-file.ts
|
|
46261
|
-
import {
|
|
46262
|
-
closeSync as closeSync2,
|
|
46263
|
-
constants,
|
|
46264
|
-
fstatSync as fstatSync2,
|
|
46265
|
-
openSync as openSync2,
|
|
46266
|
-
readFileSync as readFileSync7
|
|
46267
|
-
} from "node:fs";
|
|
46268
|
-
import { userInfo } from "node:os";
|
|
46269
|
-
function isPrivateGroup(gid, user, read2 = () => readFileSync7("/etc/group", "utf8"), readPasswd = () => readFileSync7("/etc/passwd", "utf8")) {
|
|
46270
|
-
let text3;
|
|
46271
|
-
let passwd;
|
|
46272
|
-
try {
|
|
46273
|
-
text3 = read2();
|
|
46274
|
-
passwd = readPasswd();
|
|
46275
|
-
} catch {
|
|
46276
|
-
return false;
|
|
46277
|
-
}
|
|
46278
|
-
for (const line of passwd.split("\n")) {
|
|
46279
|
-
const f = line.split(":");
|
|
46280
|
-
if (f[3] === String(gid) && f[0] !== user) return false;
|
|
46281
|
-
}
|
|
46282
|
-
for (const line of text3.split("\n")) {
|
|
46283
|
-
const [name, , id, members2] = line.split(":");
|
|
46284
|
-
if (id === String(gid))
|
|
46285
|
-
return name === user && (members2 ?? "").trim() === "";
|
|
46286
|
-
}
|
|
46287
|
-
return false;
|
|
46288
|
-
}
|
|
46289
|
-
var ownGroup = () => ({
|
|
46290
|
-
gid: process.getgid?.(),
|
|
46291
|
-
isPrivate: (gid) => {
|
|
46292
|
-
if (process.platform !== "linux") return false;
|
|
46293
|
-
try {
|
|
46294
|
-
return isPrivateGroup(gid, userInfo().username);
|
|
46295
|
-
} catch {
|
|
46296
|
-
return false;
|
|
46297
|
-
}
|
|
46298
|
-
}
|
|
46299
|
-
});
|
|
46300
|
-
function readOwnFile(file2, uid = process.getuid?.(), opts = {}) {
|
|
46301
|
-
let fd;
|
|
46302
|
-
try {
|
|
46303
|
-
fd = openSync2(
|
|
46304
|
-
file2,
|
|
46305
|
-
constants.O_RDONLY | (constants.O_NOFOLLOW ?? 0) | (constants.O_NONBLOCK ?? 0)
|
|
46306
|
-
);
|
|
46307
|
-
} catch (e) {
|
|
46308
|
-
const code2 = e.code;
|
|
46309
|
-
if (code2 === "ENOENT" || code2 === "ENOTDIR") return { state: "none" };
|
|
46310
|
-
return {
|
|
46311
|
-
state: "unsafe",
|
|
46312
|
-
why: code2 === "ELOOP" ? "is a symlink" : `cannot be read (${code2})`
|
|
46313
|
-
};
|
|
46314
|
-
}
|
|
46315
|
-
try {
|
|
46316
|
-
const st = fstatSync2(fd);
|
|
46317
|
-
if (!st.isFile()) return { state: "unsafe", why: "is not a regular file" };
|
|
46318
|
-
if (uid !== void 0 && st.uid !== uid)
|
|
46319
|
-
return { state: "unsafe", why: "belongs to another user" };
|
|
46320
|
-
if (opts.maxBytes !== void 0 && st.size > opts.maxBytes)
|
|
46321
|
-
return { state: "unsafe", why: "is too large" };
|
|
46322
|
-
if (opts.allowGroupWrite) {
|
|
46323
|
-
if (st.mode & 2)
|
|
46324
|
-
return { state: "unsafe", why: "is writable by everyone" };
|
|
46325
|
-
let note;
|
|
46326
|
-
if (st.mode & 16) {
|
|
46327
|
-
const g = opts.group ?? ownGroup();
|
|
46328
|
-
if (st.gid !== g.gid || !g.isPrivate(st.gid))
|
|
46329
|
-
return {
|
|
46330
|
-
state: "unsafe",
|
|
46331
|
-
why: "is writable by a group others share"
|
|
46332
|
-
};
|
|
46333
|
-
note = "is writable by its group";
|
|
46334
|
-
}
|
|
46335
|
-
return {
|
|
46336
|
-
state: "ok",
|
|
46337
|
-
text: readFileSync7(fd, "utf8"),
|
|
46338
|
-
...note ? { note } : {}
|
|
46339
|
-
};
|
|
46340
|
-
}
|
|
46341
|
-
if (st.mode & 18)
|
|
46342
|
-
return { state: "unsafe", why: "is writable by others" };
|
|
46343
|
-
return { state: "ok", text: readFileSync7(fd, "utf8") };
|
|
46344
|
-
} catch (e) {
|
|
46345
|
-
return {
|
|
46346
|
-
state: "unsafe",
|
|
46347
|
-
why: `cannot be read (${e.code ?? String(e)})`
|
|
46348
|
-
};
|
|
46349
|
-
} finally {
|
|
46350
|
-
closeSync2(fd);
|
|
46351
|
-
}
|
|
46352
|
-
}
|
|
46353
|
-
|
|
46354
|
-
// ../bus-daemon/src/claude-guests.ts
|
|
46355
46436
|
var CLAUDE_GUESTS_MAX = 64;
|
|
46356
46437
|
var CLAUDE_STASH_MAX = 64;
|
|
46357
|
-
var
|
|
46438
|
+
var EntrySchema2 = external_exports.strictObject({
|
|
46358
46439
|
pid: external_exports.number().int().positive(),
|
|
46359
46440
|
procStart: external_exports.string().min(1).max(100),
|
|
46360
46441
|
instance: external_exports.string().regex(/^[a-z0-9-]{1,32}$/),
|
|
46361
46442
|
/** The opaque ref this guest has on that instance only; random, never derived from the session. */
|
|
46362
46443
|
ref: external_exports.string().regex(/^[A-Za-z0-9_-]{16,64}$/).optional()
|
|
46363
46444
|
});
|
|
46364
|
-
var
|
|
46445
|
+
var FileSchema2 = external_exports.strictObject({
|
|
46365
46446
|
v: external_exports.literal(1),
|
|
46366
46447
|
guests: external_exports.array(external_exports.unknown())
|
|
46367
46448
|
});
|
|
@@ -46371,7 +46452,7 @@ function readClaudeGuests(file2, uid = process.getuid?.(), log = () => {
|
|
|
46371
46452
|
const f = readOwnFile(file2, uid);
|
|
46372
46453
|
if (f.state === "unsafe") log(`ignoring ${file2}: ${f.why}`);
|
|
46373
46454
|
if (f.state !== "ok") return [];
|
|
46374
|
-
const top =
|
|
46455
|
+
const top = FileSchema2.safeParse(JSON.parse(f.text));
|
|
46375
46456
|
if (!top.success) {
|
|
46376
46457
|
log(`ignoring ${file2}: not the expected shape`);
|
|
46377
46458
|
return [];
|
|
@@ -46379,7 +46460,7 @@ function readClaudeGuests(file2, uid = process.getuid?.(), log = () => {
|
|
|
46379
46460
|
const out = [];
|
|
46380
46461
|
for (const raw of top.data.guests) {
|
|
46381
46462
|
if (out.length >= CLAUDE_GUESTS_MAX) break;
|
|
46382
|
-
const one3 =
|
|
46463
|
+
const one3 = EntrySchema2.safeParse(raw);
|
|
46383
46464
|
if (one3.success) out.push(one3.data);
|
|
46384
46465
|
}
|
|
46385
46466
|
return out;
|
|
@@ -46390,16 +46471,16 @@ function readClaudeGuests(file2, uid = process.getuid?.(), log = () => {
|
|
|
46390
46471
|
}
|
|
46391
46472
|
function writeClaudeGuests(file2, guests) {
|
|
46392
46473
|
const tmp = `${file2}.${process.pid}.tmp`;
|
|
46393
|
-
|
|
46474
|
+
rmSync3(tmp, { force: true });
|
|
46394
46475
|
try {
|
|
46395
|
-
|
|
46476
|
+
writeFileSync2(
|
|
46396
46477
|
tmp,
|
|
46397
46478
|
JSON.stringify({ v: 1, guests: guests.slice(0, CLAUDE_GUESTS_MAX) }),
|
|
46398
46479
|
{ mode: 384, flag: "wx" }
|
|
46399
46480
|
);
|
|
46400
|
-
|
|
46481
|
+
renameSync3(tmp, file2);
|
|
46401
46482
|
} catch (e) {
|
|
46402
|
-
|
|
46483
|
+
rmSync3(tmp, { force: true });
|
|
46403
46484
|
throw e;
|
|
46404
46485
|
}
|
|
46405
46486
|
}
|
|
@@ -46522,16 +46603,16 @@ async function usedToolOf(transcript, prefixes) {
|
|
|
46522
46603
|
|
|
46523
46604
|
// ../bus-daemon/src/claude-links.ts
|
|
46524
46605
|
init_zod();
|
|
46525
|
-
import { renameSync as
|
|
46606
|
+
import { renameSync as renameSync4, rmSync as rmSync4, writeFileSync as writeFileSync3 } from "node:fs";
|
|
46526
46607
|
var CLAUDE_LINKS_MAX = 64;
|
|
46527
|
-
var
|
|
46608
|
+
var EntrySchema3 = external_exports.strictObject({
|
|
46528
46609
|
pid: external_exports.number().int().positive(),
|
|
46529
46610
|
procStart: external_exports.string().min(1).max(100),
|
|
46530
46611
|
hashes: external_exports.array(external_exports.string().regex(/^[0-9a-f]{64}$/)).min(1),
|
|
46531
46612
|
/** #2793 S4: the instance the hashes are for; absent means main. */
|
|
46532
46613
|
instance: external_exports.string().regex(/^[a-z0-9-]{1,32}$/).optional()
|
|
46533
46614
|
});
|
|
46534
|
-
var
|
|
46615
|
+
var FileSchema3 = external_exports.strictObject({
|
|
46535
46616
|
v: external_exports.literal(1),
|
|
46536
46617
|
links: external_exports.array(external_exports.unknown())
|
|
46537
46618
|
});
|
|
@@ -46541,7 +46622,7 @@ function readClaudeLinks(file2, uid = process.getuid?.(), log = () => {
|
|
|
46541
46622
|
const f = readOwnFile(file2, uid);
|
|
46542
46623
|
if (f.state === "unsafe") log(`ignoring ${file2}: ${f.why}`);
|
|
46543
46624
|
if (f.state !== "ok") return [];
|
|
46544
|
-
const top =
|
|
46625
|
+
const top = FileSchema3.safeParse(JSON.parse(f.text));
|
|
46545
46626
|
if (!top.success) {
|
|
46546
46627
|
log(`ignoring ${file2}: not the expected shape`);
|
|
46547
46628
|
return [];
|
|
@@ -46549,7 +46630,7 @@ function readClaudeLinks(file2, uid = process.getuid?.(), log = () => {
|
|
|
46549
46630
|
const out = [];
|
|
46550
46631
|
for (const raw of top.data.links) {
|
|
46551
46632
|
if (out.length >= CLAUDE_LINKS_MAX) break;
|
|
46552
|
-
const one3 =
|
|
46633
|
+
const one3 = EntrySchema3.safeParse(raw);
|
|
46553
46634
|
if (one3.success)
|
|
46554
46635
|
out.push({
|
|
46555
46636
|
...one3.data,
|
|
@@ -46564,16 +46645,16 @@ function readClaudeLinks(file2, uid = process.getuid?.(), log = () => {
|
|
|
46564
46645
|
}
|
|
46565
46646
|
function writeClaudeLinks(file2, links) {
|
|
46566
46647
|
const tmp = `${file2}.${process.pid}.tmp`;
|
|
46567
|
-
|
|
46648
|
+
rmSync4(tmp, { force: true });
|
|
46568
46649
|
try {
|
|
46569
|
-
|
|
46650
|
+
writeFileSync3(
|
|
46570
46651
|
tmp,
|
|
46571
46652
|
JSON.stringify({ v: 1, links: links.slice(0, CLAUDE_LINKS_MAX) }),
|
|
46572
46653
|
{ mode: 384, flag: "wx" }
|
|
46573
46654
|
);
|
|
46574
|
-
|
|
46655
|
+
renameSync4(tmp, file2);
|
|
46575
46656
|
} catch (e) {
|
|
46576
|
-
|
|
46657
|
+
rmSync4(tmp, { force: true });
|
|
46577
46658
|
throw e;
|
|
46578
46659
|
}
|
|
46579
46660
|
}
|
|
@@ -46581,7 +46662,7 @@ function writeClaudeLinks(file2, links) {
|
|
|
46581
46662
|
// ../bus-daemon/src/codex-agents.ts
|
|
46582
46663
|
init_src();
|
|
46583
46664
|
init_zod();
|
|
46584
|
-
import { chmodSync as chmodSync3, renameSync as
|
|
46665
|
+
import { chmodSync as chmodSync3, renameSync as renameSync5, writeFileSync as writeFileSync4 } from "node:fs";
|
|
46585
46666
|
var CodexAgentSchema = external_exports.strictObject({
|
|
46586
46667
|
/** Joined into the thread's lock path: a real ref, never `../`. */
|
|
46587
46668
|
ref: AgentRefSchema,
|
|
@@ -46592,7 +46673,7 @@ var CodexAgentSchema = external_exports.strictObject({
|
|
|
46592
46673
|
sentName: external_exports.string().max(200).optional(),
|
|
46593
46674
|
busName: external_exports.string().min(1).max(200)
|
|
46594
46675
|
});
|
|
46595
|
-
var
|
|
46676
|
+
var FileSchema4 = external_exports.strictObject({
|
|
46596
46677
|
v: external_exports.literal(1),
|
|
46597
46678
|
agents: external_exports.array(external_exports.unknown())
|
|
46598
46679
|
});
|
|
@@ -46600,7 +46681,7 @@ function readCodexAgents(file2, uid = process.getuid?.()) {
|
|
|
46600
46681
|
try {
|
|
46601
46682
|
const f = readOwnFile(file2, uid);
|
|
46602
46683
|
if (f.state !== "ok") return [];
|
|
46603
|
-
const top =
|
|
46684
|
+
const top = FileSchema4.safeParse(JSON.parse(f.text));
|
|
46604
46685
|
if (!top.success) return [];
|
|
46605
46686
|
const seen2 = /* @__PURE__ */ new Set();
|
|
46606
46687
|
const out = [];
|
|
@@ -46618,15 +46699,15 @@ function readCodexAgents(file2, uid = process.getuid?.()) {
|
|
|
46618
46699
|
}
|
|
46619
46700
|
function writeCodexAgents(file2, agents) {
|
|
46620
46701
|
const tmp = `${file2}.${process.pid}.tmp`;
|
|
46621
|
-
|
|
46702
|
+
writeFileSync4(tmp, JSON.stringify({ v: 1, agents }), { mode: 384 });
|
|
46622
46703
|
chmodSync3(tmp, 384);
|
|
46623
|
-
|
|
46704
|
+
renameSync5(tmp, file2);
|
|
46624
46705
|
}
|
|
46625
46706
|
|
|
46626
46707
|
// ../bus-daemon/src/codex-away.ts
|
|
46627
46708
|
init_src();
|
|
46628
46709
|
init_zod();
|
|
46629
|
-
import { chmodSync as chmodSync4, renameSync as
|
|
46710
|
+
import { chmodSync as chmodSync4, renameSync as renameSync6, writeFileSync as writeFileSync5 } from "node:fs";
|
|
46630
46711
|
var AWAY_IDLE_MS = 24 * 36e5;
|
|
46631
46712
|
var AWAY_MAX = 64;
|
|
46632
46713
|
var CodexAwaySchema = external_exports.strictObject({
|
|
@@ -46636,7 +46717,7 @@ var CodexAwaySchema = external_exports.strictObject({
|
|
|
46636
46717
|
/** When the thread was last live (ms), to the hour. */
|
|
46637
46718
|
lastLive: external_exports.number().int().nonnegative()
|
|
46638
46719
|
});
|
|
46639
|
-
var
|
|
46720
|
+
var FileSchema5 = external_exports.strictObject({
|
|
46640
46721
|
v: external_exports.literal(1),
|
|
46641
46722
|
rows: external_exports.array(external_exports.unknown())
|
|
46642
46723
|
});
|
|
@@ -46647,7 +46728,7 @@ function readCodexAway(file2, now, uid = process.getuid?.()) {
|
|
|
46647
46728
|
try {
|
|
46648
46729
|
const f = readOwnFile(file2, uid);
|
|
46649
46730
|
if (f.state !== "ok") return [];
|
|
46650
|
-
const top =
|
|
46731
|
+
const top = FileSchema5.safeParse(JSON.parse(f.text));
|
|
46651
46732
|
if (!top.success) return [];
|
|
46652
46733
|
const seen2 = /* @__PURE__ */ new Set();
|
|
46653
46734
|
const out = [];
|
|
@@ -46664,9 +46745,9 @@ function readCodexAway(file2, now, uid = process.getuid?.()) {
|
|
|
46664
46745
|
}
|
|
46665
46746
|
function writeCodexAway(file2, rows) {
|
|
46666
46747
|
const tmp = `${file2}.${process.pid}.tmp`;
|
|
46667
|
-
|
|
46748
|
+
writeFileSync5(tmp, JSON.stringify({ v: 1, rows }), { mode: 384 });
|
|
46668
46749
|
chmodSync4(tmp, 384);
|
|
46669
|
-
|
|
46750
|
+
renameSync6(tmp, file2);
|
|
46670
46751
|
}
|
|
46671
46752
|
|
|
46672
46753
|
// ../bus-daemon/src/codex-names.ts
|
|
@@ -46740,8 +46821,8 @@ import {
|
|
|
46740
46821
|
openSync as openSync4,
|
|
46741
46822
|
readFileSync as readFileSync9,
|
|
46742
46823
|
readSync as readSync3,
|
|
46743
|
-
renameSync as
|
|
46744
|
-
writeFileSync as
|
|
46824
|
+
renameSync as renameSync7,
|
|
46825
|
+
writeFileSync as writeFileSync6
|
|
46745
46826
|
} from "node:fs";
|
|
46746
46827
|
import { dirname as dirname3, join as join9 } from "node:path";
|
|
46747
46828
|
var NOTICE_WATCH_MS = 6 * 60 * 60 * 1e3;
|
|
@@ -47159,11 +47240,11 @@ var TakenWatch = class {
|
|
|
47159
47240
|
#save() {
|
|
47160
47241
|
const tmp = `${this.opts.file}.${process.pid}.tmp`;
|
|
47161
47242
|
try {
|
|
47162
|
-
|
|
47243
|
+
writeFileSync6(tmp, JSON.stringify(Object.fromEntries(this.#recs)), {
|
|
47163
47244
|
mode: 384
|
|
47164
47245
|
});
|
|
47165
47246
|
chmodSync5(tmp, 384);
|
|
47166
|
-
|
|
47247
|
+
renameSync7(tmp, this.opts.file);
|
|
47167
47248
|
return true;
|
|
47168
47249
|
} catch (e) {
|
|
47169
47250
|
this.opts.log?.(
|
|
@@ -47188,7 +47269,7 @@ import {
|
|
|
47188
47269
|
mkdirSync as mkdirSync4,
|
|
47189
47270
|
openSync as openSync5,
|
|
47190
47271
|
realpathSync as realpathSync3,
|
|
47191
|
-
renameSync as
|
|
47272
|
+
renameSync as renameSync8,
|
|
47192
47273
|
statSync as statSync5,
|
|
47193
47274
|
unlinkSync,
|
|
47194
47275
|
writeSync
|
|
@@ -47275,7 +47356,7 @@ function writeGlobalDirs(dirs, h = home()) {
|
|
|
47275
47356
|
closeSync5(fd);
|
|
47276
47357
|
try {
|
|
47277
47358
|
chmodSync6(tmp, 384);
|
|
47278
|
-
|
|
47359
|
+
renameSync8(tmp, globalFile(h));
|
|
47279
47360
|
} catch (e) {
|
|
47280
47361
|
unlinkSync(tmp);
|
|
47281
47362
|
throw e;
|
|
@@ -47303,7 +47384,7 @@ import {
|
|
|
47303
47384
|
closeSync as closeSync7,
|
|
47304
47385
|
mkdirSync as mkdirSync6,
|
|
47305
47386
|
openSync as openSync7,
|
|
47306
|
-
renameSync as
|
|
47387
|
+
renameSync as renameSync9,
|
|
47307
47388
|
unlinkSync as unlinkSync3,
|
|
47308
47389
|
writeSync as writeSync3
|
|
47309
47390
|
} from "node:fs";
|
|
@@ -47649,7 +47730,7 @@ function writePrivate(h, name, body) {
|
|
|
47649
47730
|
closeSync7(fd);
|
|
47650
47731
|
try {
|
|
47651
47732
|
chmodSync8(tmp, 384);
|
|
47652
|
-
|
|
47733
|
+
renameSync9(tmp, join12(h, name));
|
|
47653
47734
|
} catch (e) {
|
|
47654
47735
|
unlinkSync3(tmp);
|
|
47655
47736
|
throw e;
|
|
@@ -49799,9 +49880,9 @@ init_src();
|
|
|
49799
49880
|
import {
|
|
49800
49881
|
chmodSync as chmodSync9,
|
|
49801
49882
|
readFileSync as readFileSync11,
|
|
49802
|
-
renameSync as
|
|
49803
|
-
rmSync as
|
|
49804
|
-
writeFileSync as
|
|
49883
|
+
renameSync as renameSync10,
|
|
49884
|
+
rmSync as rmSync5,
|
|
49885
|
+
writeFileSync as writeFileSync7
|
|
49805
49886
|
} from "node:fs";
|
|
49806
49887
|
var metaOf = ({
|
|
49807
49888
|
at: _,
|
|
@@ -50090,13 +50171,13 @@ var SentStore = class {
|
|
|
50090
50171
|
if (!this.file) return;
|
|
50091
50172
|
const tmp = `${this.file}.${process.pid}.tmp`;
|
|
50092
50173
|
try {
|
|
50093
|
-
|
|
50094
|
-
|
|
50174
|
+
rmSync5(tmp, { force: true });
|
|
50175
|
+
writeFileSync7(tmp, JSON.stringify(Object.fromEntries(this.#all)), {
|
|
50095
50176
|
mode: 384,
|
|
50096
50177
|
flag: "wx"
|
|
50097
50178
|
});
|
|
50098
50179
|
chmodSync9(tmp, 384);
|
|
50099
|
-
|
|
50180
|
+
renameSync10(tmp, this.file);
|
|
50100
50181
|
} catch (e) {
|
|
50101
50182
|
this.#log?.(
|
|
50102
50183
|
`sent file write failed: ${e instanceof Error ? e.message : String(e)}`
|
|
@@ -50292,16 +50373,16 @@ import {
|
|
|
50292
50373
|
lstatSync as lstatSync6,
|
|
50293
50374
|
mkdirSync as mkdirSync7,
|
|
50294
50375
|
readFileSync as readFileSync13,
|
|
50295
|
-
renameSync as
|
|
50296
|
-
rmSync as
|
|
50297
|
-
writeFileSync as
|
|
50376
|
+
renameSync as renameSync12,
|
|
50377
|
+
rmSync as rmSync6,
|
|
50378
|
+
writeFileSync as writeFileSync9
|
|
50298
50379
|
} from "node:fs";
|
|
50299
50380
|
import { createServer as createServer2 } from "node:net";
|
|
50300
50381
|
import { dirname as dirname9, join as join16 } from "node:path";
|
|
50301
50382
|
import { createInterface as createInterface2 } from "node:readline";
|
|
50302
50383
|
|
|
50303
50384
|
// ../bus-daemon/src/transports/held.ts
|
|
50304
|
-
import { chmodSync as chmodSync10, readFileSync as readFileSync12, renameSync as
|
|
50385
|
+
import { chmodSync as chmodSync10, readFileSync as readFileSync12, renameSync as renameSync11, writeFileSync as writeFileSync8 } from "node:fs";
|
|
50305
50386
|
var HeldStore = class {
|
|
50306
50387
|
constructor(file2, opts = {}) {
|
|
50307
50388
|
this.file = file2;
|
|
@@ -50343,9 +50424,9 @@ var HeldStore = class {
|
|
|
50343
50424
|
}
|
|
50344
50425
|
#write(all) {
|
|
50345
50426
|
const tmp = `${this.file}.${process.pid}.tmp`;
|
|
50346
|
-
|
|
50427
|
+
writeFileSync8(tmp, JSON.stringify(all), { mode: 384 });
|
|
50347
50428
|
chmodSync10(tmp, 384);
|
|
50348
|
-
|
|
50429
|
+
renameSync11(tmp, this.file);
|
|
50349
50430
|
}
|
|
50350
50431
|
};
|
|
50351
50432
|
|
|
@@ -50700,7 +50781,7 @@ var ClaudeTransport = class {
|
|
|
50700
50781
|
mkdirSync7(this.opts.socketsDir, { recursive: true, mode: 448 });
|
|
50701
50782
|
chmodSync11(this.opts.socketsDir, 448);
|
|
50702
50783
|
}
|
|
50703
|
-
|
|
50784
|
+
rmSync6(path, { force: true });
|
|
50704
50785
|
this.#paths.set(key2, path);
|
|
50705
50786
|
const conns = /* @__PURE__ */ new Set();
|
|
50706
50787
|
const sink = {
|
|
@@ -50770,9 +50851,9 @@ var ClaudeTransport = class {
|
|
|
50770
50851
|
const out = /* @__PURE__ */ Object.create(null);
|
|
50771
50852
|
for (const [k, v] of keep) out[k] = v;
|
|
50772
50853
|
const tmp = `${file2}.${process.pid}.tmp`;
|
|
50773
|
-
|
|
50854
|
+
writeFileSync9(tmp, JSON.stringify(out), { mode: 384 });
|
|
50774
50855
|
chmodSync11(tmp, 384);
|
|
50775
|
-
|
|
50856
|
+
renameSync12(tmp, file2);
|
|
50776
50857
|
return out;
|
|
50777
50858
|
} catch (e) {
|
|
50778
50859
|
this.opts.log?.(
|
|
@@ -50844,7 +50925,7 @@ var ClaudeTransport = class {
|
|
|
50844
50925
|
async function shut(sink) {
|
|
50845
50926
|
for (const c of sink.conns) c.destroy();
|
|
50846
50927
|
await new Promise((r) => sink.server.close(() => r()));
|
|
50847
|
-
|
|
50928
|
+
rmSync6(sink.path, { force: true });
|
|
50848
50929
|
}
|
|
50849
50930
|
|
|
50850
50931
|
// ../bus-daemon/src/transports/codex.ts
|
|
@@ -51567,10 +51648,10 @@ import {
|
|
|
51567
51648
|
readFileSync as readFileSync15,
|
|
51568
51649
|
readlinkSync as readlinkSync2,
|
|
51569
51650
|
realpathSync as realpathSync7,
|
|
51570
|
-
renameSync as
|
|
51571
|
-
rmSync as
|
|
51651
|
+
renameSync as renameSync13,
|
|
51652
|
+
rmSync as rmSync7,
|
|
51572
51653
|
symlinkSync,
|
|
51573
|
-
writeFileSync as
|
|
51654
|
+
writeFileSync as writeFileSync10
|
|
51574
51655
|
} from "node:fs";
|
|
51575
51656
|
import { join as join20, relative as relative3, sep as sep3 } from "node:path";
|
|
51576
51657
|
var SAFE_VERSION = /^[0-9A-Za-z][0-9A-Za-z._+-]{0,63}$/;
|
|
@@ -51636,12 +51717,12 @@ function writeState(home2, state) {
|
|
|
51636
51717
|
else next[k] = state[k];
|
|
51637
51718
|
const tmp = `${stateFile(home2)}.${process.pid}.tmp`;
|
|
51638
51719
|
try {
|
|
51639
|
-
|
|
51720
|
+
writeFileSync10(tmp, `${JSON.stringify(next, null, 2)}
|
|
51640
51721
|
`, { mode: 384 });
|
|
51641
51722
|
chmodSync12(tmp, 384);
|
|
51642
|
-
|
|
51723
|
+
renameSync13(tmp, stateFile(home2));
|
|
51643
51724
|
} catch (e) {
|
|
51644
|
-
|
|
51725
|
+
rmSync7(tmp, { force: true });
|
|
51645
51726
|
throw e;
|
|
51646
51727
|
}
|
|
51647
51728
|
}
|
|
@@ -51665,8 +51746,8 @@ function migrate(home2, now = Date.now) {
|
|
|
51665
51746
|
v ??= `unknown-${now()}`;
|
|
51666
51747
|
ensureVersions(home2);
|
|
51667
51748
|
if (lstat2(versionDir(home2, v)))
|
|
51668
|
-
|
|
51669
|
-
|
|
51749
|
+
rmSync7(versionDir(home2, v), { recursive: true, force: true });
|
|
51750
|
+
renameSync13(bin, versionDir(home2, v));
|
|
51670
51751
|
chmodSync12(versionDir(home2, v), 448);
|
|
51671
51752
|
return v;
|
|
51672
51753
|
}
|
|
@@ -51675,7 +51756,7 @@ function stage(home2, version2, fill) {
|
|
|
51675
51756
|
ensureVersions(home2);
|
|
51676
51757
|
const dest = versionDir(home2, version2);
|
|
51677
51758
|
const tmp = join20(versionsDir(home2), `.stage.${process.pid}`);
|
|
51678
|
-
|
|
51759
|
+
rmSync7(tmp, { recursive: true, force: true });
|
|
51679
51760
|
mkdirSync8(tmp, { mode: 448 });
|
|
51680
51761
|
try {
|
|
51681
51762
|
fill(tmp);
|
|
@@ -51683,13 +51764,13 @@ function stage(home2, version2, fill) {
|
|
|
51683
51764
|
mustBeSafe(tmp);
|
|
51684
51765
|
if (lstat2(dest)) {
|
|
51685
51766
|
const old = join20(versionsDir(home2), `.old.${process.pid}`);
|
|
51686
|
-
|
|
51687
|
-
|
|
51688
|
-
|
|
51689
|
-
|
|
51690
|
-
} else
|
|
51767
|
+
rmSync7(old, { recursive: true, force: true });
|
|
51768
|
+
renameSync13(dest, old);
|
|
51769
|
+
renameSync13(tmp, dest);
|
|
51770
|
+
rmSync7(old, { recursive: true, force: true });
|
|
51771
|
+
} else renameSync13(tmp, dest);
|
|
51691
51772
|
} catch (e) {
|
|
51692
|
-
|
|
51773
|
+
rmSync7(tmp, { recursive: true, force: true });
|
|
51693
51774
|
throw e;
|
|
51694
51775
|
}
|
|
51695
51776
|
return dest;
|
|
@@ -51701,7 +51782,7 @@ function swap(home2, version2) {
|
|
|
51701
51782
|
mustBeSafe(target2);
|
|
51702
51783
|
const bin = binPath(home2);
|
|
51703
51784
|
const tmp = `${bin}.${process.pid}.new`;
|
|
51704
|
-
|
|
51785
|
+
rmSync7(tmp, { recursive: true, force: true });
|
|
51705
51786
|
try {
|
|
51706
51787
|
symlinkSync(
|
|
51707
51788
|
join20("versions", version2),
|
|
@@ -51709,10 +51790,10 @@ function swap(home2, version2) {
|
|
|
51709
51790
|
process.platform === "win32" ? "junction" : void 0
|
|
51710
51791
|
);
|
|
51711
51792
|
if (process.platform === "win32")
|
|
51712
|
-
|
|
51713
|
-
|
|
51793
|
+
rmSync7(bin, { recursive: true, force: true });
|
|
51794
|
+
renameSync13(tmp, bin);
|
|
51714
51795
|
} catch (e) {
|
|
51715
|
-
|
|
51796
|
+
rmSync7(tmp, { recursive: true, force: true });
|
|
51716
51797
|
throw e;
|
|
51717
51798
|
}
|
|
51718
51799
|
}
|
|
@@ -51733,10 +51814,10 @@ function inUse(versionPath, alive3 = pidAlive) {
|
|
|
51733
51814
|
if (!/^\d+$/.test(n)) continue;
|
|
51734
51815
|
const f = join20(dir, n);
|
|
51735
51816
|
const k = lstat2(f);
|
|
51736
|
-
if (k?.isSymbolicLink())
|
|
51817
|
+
if (k?.isSymbolicLink()) rmSync7(f, { force: true });
|
|
51737
51818
|
else if (!k?.isFile()) continue;
|
|
51738
51819
|
else if (alive3(Number(n))) live = true;
|
|
51739
|
-
else
|
|
51820
|
+
else rmSync7(f, { force: true });
|
|
51740
51821
|
}
|
|
51741
51822
|
return live;
|
|
51742
51823
|
}
|
|
@@ -51751,8 +51832,8 @@ function markLive(entryFile, home2, pid = process.pid) {
|
|
|
51751
51832
|
const vdir = join20(root, v);
|
|
51752
51833
|
mkdirSync8(liveDir(vdir), { recursive: true, mode: 448 });
|
|
51753
51834
|
const marker = join20(liveDir(vdir), String(pid));
|
|
51754
|
-
|
|
51755
|
-
process.once("exit", () =>
|
|
51835
|
+
writeFileSync10(marker, "", { mode: 384 });
|
|
51836
|
+
process.once("exit", () => rmSync7(marker, { force: true }));
|
|
51756
51837
|
return marker;
|
|
51757
51838
|
} catch {
|
|
51758
51839
|
return void 0;
|
|
@@ -51769,14 +51850,14 @@ function prune(home2, keep, opts = {}) {
|
|
|
51769
51850
|
const st = lstat2(join20(dir, name));
|
|
51770
51851
|
if (!st) continue;
|
|
51771
51852
|
if (st.isSymbolicLink()) {
|
|
51772
|
-
|
|
51853
|
+
rmSync7(join20(dir, name), { force: true });
|
|
51773
51854
|
removed.push(name);
|
|
51774
51855
|
continue;
|
|
51775
51856
|
}
|
|
51776
51857
|
if (!st.isDirectory()) continue;
|
|
51777
51858
|
const m = /^\.(stage|old)\.(\d+)$/.exec(name);
|
|
51778
51859
|
if (m ? alive3(Number(m[2])) : inUse(join20(dir, name), alive3)) continue;
|
|
51779
|
-
|
|
51860
|
+
rmSync7(join20(dir, name), { recursive: true, force: true });
|
|
51780
51861
|
removed.push(name);
|
|
51781
51862
|
}
|
|
51782
51863
|
return removed;
|
|
@@ -51844,7 +51925,7 @@ function treeMatches(dir, manifest) {
|
|
|
51844
51925
|
}
|
|
51845
51926
|
|
|
51846
51927
|
// ../bus-daemon/src/update/login-flag.ts
|
|
51847
|
-
import { readFileSync as readFileSync16, rmSync as
|
|
51928
|
+
import { readFileSync as readFileSync16, rmSync as rmSync8, writeFileSync as writeFileSync11 } from "node:fs";
|
|
51848
51929
|
import { join as join21 } from "node:path";
|
|
51849
51930
|
var loginFlagFile = (home2) => join21(home2, "login.active");
|
|
51850
51931
|
var LOGIN_FLAG_MAX_MS = 15 * 6e4;
|
|
@@ -51858,7 +51939,7 @@ var alive2 = (pid) => {
|
|
|
51858
51939
|
};
|
|
51859
51940
|
function markLoginActive(home2, now = Date.now) {
|
|
51860
51941
|
try {
|
|
51861
|
-
|
|
51942
|
+
writeFileSync11(loginFlagFile(home2), `${process.pid} ${now()}
|
|
51862
51943
|
`, {
|
|
51863
51944
|
mode: 384
|
|
51864
51945
|
});
|
|
@@ -51866,7 +51947,7 @@ function markLoginActive(home2, now = Date.now) {
|
|
|
51866
51947
|
return () => {
|
|
51867
51948
|
};
|
|
51868
51949
|
}
|
|
51869
|
-
return () =>
|
|
51950
|
+
return () => rmSync8(loginFlagFile(home2), { force: true });
|
|
51870
51951
|
}
|
|
51871
51952
|
function loginActive(home2, now = Date.now, isAlive = alive2) {
|
|
51872
51953
|
try {
|
|
@@ -52003,9 +52084,9 @@ function label(s, now) {
|
|
|
52003
52084
|
import {
|
|
52004
52085
|
chmodSync as chmodSync13,
|
|
52005
52086
|
readFileSync as readFileSync17,
|
|
52006
|
-
renameSync as
|
|
52007
|
-
rmSync as
|
|
52008
|
-
writeFileSync as
|
|
52087
|
+
renameSync as renameSync14,
|
|
52088
|
+
rmSync as rmSync9,
|
|
52089
|
+
writeFileSync as writeFileSync12
|
|
52009
52090
|
} from "node:fs";
|
|
52010
52091
|
import { join as join22 } from "node:path";
|
|
52011
52092
|
var MAX_REPORTS = 50;
|
|
@@ -52034,12 +52115,12 @@ function queueReport(home2, r) {
|
|
|
52034
52115
|
const tmp = `${reportFile(home2)}.${process.pid}.tmp`;
|
|
52035
52116
|
try {
|
|
52036
52117
|
const list = [...readReports(home2), r].slice(-MAX_REPORTS);
|
|
52037
|
-
|
|
52118
|
+
writeFileSync12(tmp, `${JSON.stringify(list)}
|
|
52038
52119
|
`, { mode: 384 });
|
|
52039
52120
|
chmodSync13(tmp, 384);
|
|
52040
|
-
|
|
52121
|
+
renameSync14(tmp, reportFile(home2));
|
|
52041
52122
|
} catch {
|
|
52042
|
-
|
|
52123
|
+
rmSync9(tmp, { force: true });
|
|
52043
52124
|
}
|
|
52044
52125
|
}
|
|
52045
52126
|
function removeReports(home2, sent) {
|
|
@@ -52053,12 +52134,12 @@ function removeReports(home2, sent) {
|
|
|
52053
52134
|
);
|
|
52054
52135
|
if (i >= 0) left.splice(i, 1);
|
|
52055
52136
|
}
|
|
52056
|
-
|
|
52137
|
+
writeFileSync12(tmp, `${JSON.stringify(left)}
|
|
52057
52138
|
`, { mode: 384 });
|
|
52058
52139
|
chmodSync13(tmp, 384);
|
|
52059
|
-
|
|
52140
|
+
renameSync14(tmp, reportFile(home2));
|
|
52060
52141
|
} catch {
|
|
52061
|
-
|
|
52142
|
+
rmSync9(tmp, { force: true });
|
|
52062
52143
|
}
|
|
52063
52144
|
}
|
|
52064
52145
|
function readRescueVersion(home2) {
|
|
@@ -52079,9 +52160,9 @@ import {
|
|
|
52079
52160
|
chmodSync as chmodSync14,
|
|
52080
52161
|
lstatSync as lstatSync8,
|
|
52081
52162
|
readFileSync as readFileSync18,
|
|
52082
|
-
renameSync as
|
|
52083
|
-
rmSync as
|
|
52084
|
-
writeFileSync as
|
|
52163
|
+
renameSync as renameSync15,
|
|
52164
|
+
rmSync as rmSync10,
|
|
52165
|
+
writeFileSync as writeFileSync13
|
|
52085
52166
|
} from "node:fs";
|
|
52086
52167
|
import { join as join23 } from "node:path";
|
|
52087
52168
|
function load(home2) {
|
|
@@ -52174,12 +52255,12 @@ function readPolicy(home2) {
|
|
|
52174
52255
|
function put(home2, next) {
|
|
52175
52256
|
const tmp = `${stateFile(home2)}.${process.pid}.policy.tmp`;
|
|
52176
52257
|
try {
|
|
52177
|
-
|
|
52258
|
+
writeFileSync13(tmp, `${JSON.stringify(next, null, 2)}
|
|
52178
52259
|
`, { mode: 384 });
|
|
52179
52260
|
chmodSync14(tmp, 384);
|
|
52180
|
-
|
|
52261
|
+
renameSync15(tmp, stateFile(home2));
|
|
52181
52262
|
} catch (e) {
|
|
52182
|
-
|
|
52263
|
+
rmSync10(tmp, { force: true });
|
|
52183
52264
|
throw e;
|
|
52184
52265
|
}
|
|
52185
52266
|
}
|
|
@@ -52290,13 +52371,13 @@ function requestInstall(home2, version2, at) {
|
|
|
52290
52371
|
`;
|
|
52291
52372
|
for (let i = 0; i < 2; i++) {
|
|
52292
52373
|
try {
|
|
52293
|
-
|
|
52374
|
+
writeFileSync13(requestFile(home2), body, { mode: 384, flag: "wx" });
|
|
52294
52375
|
return true;
|
|
52295
52376
|
} catch (e) {
|
|
52296
52377
|
if (e.code !== "EEXIST") throw e;
|
|
52297
52378
|
const waiting = readInstallRequest(home2);
|
|
52298
52379
|
if (waiting && Math.abs(at - waiting.at) < REQUEST_STALE_MS) return false;
|
|
52299
|
-
|
|
52380
|
+
rmSync10(requestFile(home2), { force: true });
|
|
52300
52381
|
}
|
|
52301
52382
|
}
|
|
52302
52383
|
return false;
|
|
@@ -52332,7 +52413,7 @@ function readInstallRequest(home2) {
|
|
|
52332
52413
|
function takeInstallRequest(home2) {
|
|
52333
52414
|
const taken = `${requestFile(home2)}.taken.${process.pid}`;
|
|
52334
52415
|
try {
|
|
52335
|
-
|
|
52416
|
+
renameSync15(requestFile(home2), taken);
|
|
52336
52417
|
} catch {
|
|
52337
52418
|
return void 0;
|
|
52338
52419
|
}
|
|
@@ -52342,11 +52423,11 @@ function takeInstallRequest(home2) {
|
|
|
52342
52423
|
} catch {
|
|
52343
52424
|
return void 0;
|
|
52344
52425
|
} finally {
|
|
52345
|
-
|
|
52426
|
+
rmSync10(taken, { force: true });
|
|
52346
52427
|
}
|
|
52347
52428
|
}
|
|
52348
52429
|
function clearInstallRequest(home2) {
|
|
52349
|
-
|
|
52430
|
+
rmSync10(requestFile(home2), { force: true });
|
|
52350
52431
|
}
|
|
52351
52432
|
var releaseAttempt = (home2) => editPolicy(home2, (s) => {
|
|
52352
52433
|
if (s.pending && s.pending.attempts > 0) s.pending.attempts -= 1;
|
|
@@ -52507,7 +52588,7 @@ import {
|
|
|
52507
52588
|
copyFileSync,
|
|
52508
52589
|
existsSync as existsSync7,
|
|
52509
52590
|
readFileSync as readFileSync19,
|
|
52510
|
-
rmSync as
|
|
52591
|
+
rmSync as rmSync11
|
|
52511
52592
|
} from "node:fs";
|
|
52512
52593
|
import { join as join25 } from "node:path";
|
|
52513
52594
|
|
|
@@ -53515,7 +53596,7 @@ var Updater = class {
|
|
|
53515
53596
|
if (version2 === this.d.running || version2 === s.current || version2 === s.previous)
|
|
53516
53597
|
return;
|
|
53517
53598
|
if (isSafeVersion(version2))
|
|
53518
|
-
|
|
53599
|
+
rmSync11(versionDir(this.d.home, version2), {
|
|
53519
53600
|
recursive: true,
|
|
53520
53601
|
force: true
|
|
53521
53602
|
});
|
|
@@ -53597,7 +53678,7 @@ var Updater = class {
|
|
|
53597
53678
|
reason: "staged_changed",
|
|
53598
53679
|
at: now
|
|
53599
53680
|
});
|
|
53600
|
-
|
|
53681
|
+
rmSync11(versionDir(home2, version2), { recursive: true, force: true });
|
|
53601
53682
|
clearStaged(home2);
|
|
53602
53683
|
return { kind: "proof_refused", code: "staged_changed" };
|
|
53603
53684
|
}
|
|
@@ -54089,7 +54170,27 @@ async function runDaemon(deps2 = {}) {
|
|
|
54089
54170
|
closed: agents.closedRefs().filter(mine)
|
|
54090
54171
|
};
|
|
54091
54172
|
};
|
|
54173
|
+
const announcedFile = deps2.announcedFile ?? join27(home(), "announced.json");
|
|
54174
|
+
let announcedWritten;
|
|
54175
|
+
const persistAnnounced = () => {
|
|
54176
|
+
const rows = agents.all().map((a) => ({
|
|
54177
|
+
ref: a.ref,
|
|
54178
|
+
kind: a.kind,
|
|
54179
|
+
...a.instance !== void 0 && a.instance !== MAIN_INSTANCE ? { instance: a.instance } : {}
|
|
54180
|
+
}));
|
|
54181
|
+
const text3 = JSON.stringify(rows);
|
|
54182
|
+
if (text3 === announcedWritten) return;
|
|
54183
|
+
try {
|
|
54184
|
+
writeAnnounced(announcedFile, rows);
|
|
54185
|
+
announcedWritten = text3;
|
|
54186
|
+
} catch (e) {
|
|
54187
|
+
log(
|
|
54188
|
+
`could not save ${announcedFile}: ${e instanceof Error ? e.message : e}`
|
|
54189
|
+
);
|
|
54190
|
+
}
|
|
54191
|
+
};
|
|
54092
54192
|
const announceSessions = () => {
|
|
54193
|
+
persistAnnounced();
|
|
54093
54194
|
for (const ref of limited.keys())
|
|
54094
54195
|
if (!agents.byRef(ref)?.live) clearLimited(ref);
|
|
54095
54196
|
for (const m of [renameFrames, renameHeldUntil])
|
|
@@ -54105,6 +54206,7 @@ async function runDaemon(deps2 = {}) {
|
|
|
54105
54206
|
const limited = /* @__PURE__ */ new Map();
|
|
54106
54207
|
const caps = /* @__PURE__ */ new Map();
|
|
54107
54208
|
const announceUp = (rec) => {
|
|
54209
|
+
persistAnnounced();
|
|
54108
54210
|
const lane = laneOfRef(rec.ref);
|
|
54109
54211
|
if (!lane) return false;
|
|
54110
54212
|
if (rec.replaces !== void 0 && !lane.helloed) return false;
|
|
@@ -55392,7 +55494,7 @@ async function runDaemon(deps2 = {}) {
|
|
|
55392
55494
|
linkDown(lane);
|
|
55393
55495
|
lane.hub.stop();
|
|
55394
55496
|
try {
|
|
55395
|
-
|
|
55497
|
+
writeFileSync14(
|
|
55396
55498
|
revokedMarkerFile(lane),
|
|
55397
55499
|
revokedMarker(lane.cfg.machine_token),
|
|
55398
55500
|
{ mode: 384 }
|
|
@@ -55416,7 +55518,7 @@ async function runDaemon(deps2 = {}) {
|
|
|
55416
55518
|
log(`this machine was revoked; run \`${BUS_CMD} install\``);
|
|
55417
55519
|
process.exitCode = 1;
|
|
55418
55520
|
try {
|
|
55419
|
-
|
|
55521
|
+
writeFileSync14(
|
|
55420
55522
|
deps2.revokedFile ?? join27(home(), "revoked"),
|
|
55421
55523
|
revokedMarker(cfg.machine_token),
|
|
55422
55524
|
{ mode: 384 }
|
|
@@ -56464,8 +56566,26 @@ async function runDaemon(deps2 = {}) {
|
|
|
56464
56566
|
);
|
|
56465
56567
|
}
|
|
56466
56568
|
};
|
|
56569
|
+
const savedAnnounced = readAnnounced(announcedFile, void 0, log);
|
|
56467
56570
|
restoreCodex();
|
|
56468
56571
|
sync();
|
|
56572
|
+
for (const e of savedAnnounced) {
|
|
56573
|
+
if (agents.byRef(e.ref) !== void 0) continue;
|
|
56574
|
+
agents.up({
|
|
56575
|
+
ref: e.ref,
|
|
56576
|
+
kind: e.kind,
|
|
56577
|
+
proposedName: "",
|
|
56578
|
+
busName: "",
|
|
56579
|
+
namespace: "",
|
|
56580
|
+
global: false,
|
|
56581
|
+
instance: e.instance ?? MAIN_INSTANCE,
|
|
56582
|
+
pid: 0,
|
|
56583
|
+
cwd: "",
|
|
56584
|
+
live: false,
|
|
56585
|
+
closedBy: "liveness"
|
|
56586
|
+
});
|
|
56587
|
+
}
|
|
56588
|
+
persistAnnounced();
|
|
56469
56589
|
const watcher = setInterval(sync, cl.syncMs ?? 2e3);
|
|
56470
56590
|
watcher.unref();
|
|
56471
56591
|
const retry = setInterval(() => {
|
|
@@ -57820,9 +57940,9 @@ import {
|
|
|
57820
57940
|
readdirSync as readdirSync9,
|
|
57821
57941
|
readFileSync as readFileSync22,
|
|
57822
57942
|
realpathSync as realpathSync11,
|
|
57823
|
-
renameSync as
|
|
57824
|
-
rmSync as
|
|
57825
|
-
writeFileSync as
|
|
57943
|
+
renameSync as renameSync18,
|
|
57944
|
+
rmSync as rmSync13,
|
|
57945
|
+
writeFileSync as writeFileSync17
|
|
57826
57946
|
} from "node:fs";
|
|
57827
57947
|
import { tmpdir } from "node:os";
|
|
57828
57948
|
import {
|
|
@@ -58850,8 +58970,8 @@ function upsert(path, text3, doc, entry) {
|
|
|
58850
58970
|
);
|
|
58851
58971
|
const eol2 = eolOf(lines);
|
|
58852
58972
|
const ended = lines.at(-1)?.text === "" && lines.length > 1;
|
|
58853
|
-
const
|
|
58854
|
-
next = `${text3}${
|
|
58973
|
+
const sep8 = text3 === "" ? "" : ended ? blank(lines.at(-2)) ? "" : eol2 : eol2 + eol2;
|
|
58974
|
+
next = `${text3}${sep8}${block.join(eol2)}${eol2}`;
|
|
58855
58975
|
}
|
|
58856
58976
|
return checked(path, doc, next, entry);
|
|
58857
58977
|
}
|
|
@@ -58887,9 +59007,9 @@ async function readCodexVersion(o) {
|
|
|
58887
59007
|
import {
|
|
58888
59008
|
chmodSync as chmodSync16,
|
|
58889
59009
|
mkdirSync as mkdirSync10,
|
|
58890
|
-
renameSync as
|
|
58891
|
-
rmSync as
|
|
58892
|
-
writeFileSync as
|
|
59010
|
+
renameSync as renameSync16,
|
|
59011
|
+
rmSync as rmSync12,
|
|
59012
|
+
writeFileSync as writeFileSync15
|
|
58893
59013
|
} from "node:fs";
|
|
58894
59014
|
import { join as join29 } from "node:path";
|
|
58895
59015
|
var RESCUE_VERSION = 1;
|
|
@@ -59001,11 +59121,11 @@ function writeRescue(home2, launcher) {
|
|
|
59001
59121
|
const path = join29(home2, name);
|
|
59002
59122
|
const tmp = `${path}.${process.pid}.tmp`;
|
|
59003
59123
|
try {
|
|
59004
|
-
|
|
59124
|
+
writeFileSync15(tmp, text3, { mode: 448 });
|
|
59005
59125
|
chmodSync16(tmp, 448);
|
|
59006
|
-
|
|
59126
|
+
renameSync16(tmp, path);
|
|
59007
59127
|
} catch (e) {
|
|
59008
|
-
|
|
59128
|
+
rmSync12(tmp, { force: true });
|
|
59009
59129
|
throw e;
|
|
59010
59130
|
}
|
|
59011
59131
|
};
|
|
@@ -59019,8 +59139,8 @@ import {
|
|
|
59019
59139
|
chmodSync as chmodSync17,
|
|
59020
59140
|
mkdirSync as mkdirSync11,
|
|
59021
59141
|
readFileSync as readFileSync21,
|
|
59022
|
-
renameSync as
|
|
59023
|
-
writeFileSync as
|
|
59142
|
+
renameSync as renameSync17,
|
|
59143
|
+
writeFileSync as writeFileSync16
|
|
59024
59144
|
} from "node:fs";
|
|
59025
59145
|
import { dirname as dirname13 } from "node:path";
|
|
59026
59146
|
function readInstallFile(path) {
|
|
@@ -59036,10 +59156,10 @@ function updateInstallFile(path, patch) {
|
|
|
59036
59156
|
const next = { ...readInstallFile(path), ...patch };
|
|
59037
59157
|
mkdirSync11(dirname13(path), { recursive: true, mode: 448 });
|
|
59038
59158
|
const tmp = `${path}.${process.pid}.tmp`;
|
|
59039
|
-
|
|
59159
|
+
writeFileSync16(tmp, `${JSON.stringify(next, null, 2)}
|
|
59040
59160
|
`, { mode: 384 });
|
|
59041
59161
|
chmodSync17(tmp, 384);
|
|
59042
|
-
|
|
59162
|
+
renameSync17(tmp, path);
|
|
59043
59163
|
}
|
|
59044
59164
|
async function runSteps(steps, ctx, record7) {
|
|
59045
59165
|
for (const step2 of steps) {
|
|
@@ -59231,14 +59351,14 @@ function installCli(home2, src, node2) {
|
|
|
59231
59351
|
for (const name of ["dist", "assets", "package.json"])
|
|
59232
59352
|
if (existsSync9(join30(pkg, name)))
|
|
59233
59353
|
cpSync(join30(pkg, name), join30(tmp, name), { recursive: true });
|
|
59234
|
-
} else
|
|
59354
|
+
} else writeFileSync17(join30(tmp, entryName(src)), shim(src));
|
|
59235
59355
|
chmodSync18(tmp, 448);
|
|
59236
59356
|
if (node2 !== void 0) {
|
|
59237
|
-
|
|
59357
|
+
writeFileSync17(join30(tmp, "node"), launcherText(node2), { mode: 448 });
|
|
59238
59358
|
chmodSync18(join30(tmp, "node"), 448);
|
|
59239
59359
|
}
|
|
59240
59360
|
if (!existsSync9(join30(tmp, "package.json")))
|
|
59241
|
-
|
|
59361
|
+
writeFileSync17(join30(tmp, "package.json"), '{ "type": "module" }\n');
|
|
59242
59362
|
},
|
|
59243
59363
|
// Without the rescue shim (win32, or no launcher) a failed update could
|
|
59244
59364
|
// not be undone: such an install never arms auto-update (#2552).
|
|
@@ -59259,10 +59379,10 @@ function writeReplacing(path, text3) {
|
|
|
59259
59379
|
mkdirSync12(dirname14(path), { recursive: true });
|
|
59260
59380
|
const tmp = `${path}.${process.pid}.tmp`;
|
|
59261
59381
|
try {
|
|
59262
|
-
|
|
59263
|
-
|
|
59382
|
+
writeFileSync17(tmp, text3, { mode: 420 });
|
|
59383
|
+
renameSync18(tmp, path);
|
|
59264
59384
|
} catch (e) {
|
|
59265
|
-
|
|
59385
|
+
rmSync13(tmp, { force: true });
|
|
59266
59386
|
throw e;
|
|
59267
59387
|
}
|
|
59268
59388
|
}
|
|
@@ -59368,7 +59488,7 @@ function systemService(d) {
|
|
|
59368
59488
|
return "started";
|
|
59369
59489
|
await d.sleep(1e3);
|
|
59370
59490
|
}
|
|
59371
|
-
|
|
59491
|
+
rmSync13(f, { force: true });
|
|
59372
59492
|
return "failed";
|
|
59373
59493
|
}
|
|
59374
59494
|
async function startSystemd(f, u) {
|
|
@@ -59382,7 +59502,7 @@ function systemService(d) {
|
|
|
59382
59502
|
]) {
|
|
59383
59503
|
if ((await systemctl(...args)).code === 0) continue;
|
|
59384
59504
|
if (args[0] !== "daemon-reload") await systemctl("disable", unit);
|
|
59385
|
-
|
|
59505
|
+
rmSync13(f, { force: true });
|
|
59386
59506
|
if (args[0] !== "daemon-reload") await systemctl("daemon-reload");
|
|
59387
59507
|
return "failed";
|
|
59388
59508
|
}
|
|
@@ -59443,7 +59563,7 @@ function systemService(d) {
|
|
|
59443
59563
|
const old = recorded();
|
|
59444
59564
|
if (!skipped && old && old !== f) {
|
|
59445
59565
|
if (manager === "systemd") await systemctl("disable", names2().unit);
|
|
59446
|
-
|
|
59566
|
+
rmSync13(old, { force: true });
|
|
59447
59567
|
}
|
|
59448
59568
|
const started = skipped ? "failed" : manager === "launchd" ? await startLaunchd(f, unit) : manager === "systemd" ? await startSystemd(f, unit) : "failed";
|
|
59449
59569
|
if (started === "started") {
|
|
@@ -59488,7 +59608,7 @@ function systemService(d) {
|
|
|
59488
59608
|
if (manager === "launchd")
|
|
59489
59609
|
await d.exec("launchctl", ["bootout", `${domain2}/${label2}`]);
|
|
59490
59610
|
else await systemctl("disable", "--now", unit);
|
|
59491
|
-
|
|
59611
|
+
rmSync13(f, { force: true });
|
|
59492
59612
|
if (manager === "systemd") await systemctl("daemon-reload");
|
|
59493
59613
|
const left = await quiet();
|
|
59494
59614
|
if (left !== void 0) return { unit: manager, running: left };
|
|
@@ -59599,7 +59719,7 @@ var noService = {
|
|
|
59599
59719
|
remove: async () => ({}),
|
|
59600
59720
|
cli: () => ["oa-bus"]
|
|
59601
59721
|
};
|
|
59602
|
-
var VERSION = true ? "0.
|
|
59722
|
+
var VERSION = true ? "0.242.0" : JSON.parse(
|
|
59603
59723
|
readFileSync23(new URL("../package.json", import.meta.url), "utf8")
|
|
59604
59724
|
).version;
|
|
59605
59725
|
var which = (cmd) => {
|
|
@@ -59785,10 +59905,10 @@ import {
|
|
|
59785
59905
|
mkdirSync as mkdirSync15,
|
|
59786
59906
|
readFileSync as readFileSync32,
|
|
59787
59907
|
readlinkSync as readlinkSync5,
|
|
59788
|
-
renameSync as
|
|
59789
|
-
rmSync as
|
|
59908
|
+
renameSync as renameSync21,
|
|
59909
|
+
rmSync as rmSync21,
|
|
59790
59910
|
statSync as statSync9,
|
|
59791
|
-
writeFileSync as
|
|
59911
|
+
writeFileSync as writeFileSync20
|
|
59792
59912
|
} from "node:fs";
|
|
59793
59913
|
import { dirname as dirname18, isAbsolute as isAbsolute14, join as join37, relative as relative7, resolve as resolve13 } from "node:path";
|
|
59794
59914
|
import { isDeepStrictEqual } from "node:util";
|
|
@@ -60338,11 +60458,11 @@ function parseTree(text3, errors = [], options = ParseOptions.DEFAULT) {
|
|
|
60338
60458
|
onValue({ type: getNodeType(value), offset, length, parent: currentParent, value });
|
|
60339
60459
|
ensurePropertyComplete(offset + length);
|
|
60340
60460
|
},
|
|
60341
|
-
onSeparator: (
|
|
60461
|
+
onSeparator: (sep8, offset, length) => {
|
|
60342
60462
|
if (currentParent.type === "property") {
|
|
60343
|
-
if (
|
|
60463
|
+
if (sep8 === ":") {
|
|
60344
60464
|
currentParent.colonOffset = offset;
|
|
60345
|
-
} else if (
|
|
60465
|
+
} else if (sep8 === ",") {
|
|
60346
60466
|
ensurePropertyComplete(offset);
|
|
60347
60467
|
}
|
|
60348
60468
|
}
|
|
@@ -61370,7 +61490,7 @@ function addInstanceProof(io, target2, busBin, busHome2) {
|
|
|
61370
61490
|
// src/steps/codex-proof.ts
|
|
61371
61491
|
init_src3();
|
|
61372
61492
|
init_src();
|
|
61373
|
-
import { existsSync as existsSync10, readFileSync as readFileSync25, rmSync as
|
|
61493
|
+
import { existsSync as existsSync10, readFileSync as readFileSync25, rmSync as rmSync14 } from "node:fs";
|
|
61374
61494
|
import { isAbsolute as isAbsolute11 } from "node:path";
|
|
61375
61495
|
var CODEX_MIN_VERSION = "0.123.0";
|
|
61376
61496
|
var PROXY_CMD = "mcp-proxy";
|
|
@@ -61670,7 +61790,7 @@ ${m.lines.join("\n")}
|
|
|
61670
61790
|
put2 = true;
|
|
61671
61791
|
}
|
|
61672
61792
|
}
|
|
61673
|
-
|
|
61793
|
+
rmSync14(io.moved, { force: true });
|
|
61674
61794
|
return put2;
|
|
61675
61795
|
}
|
|
61676
61796
|
function linesOf(text3) {
|
|
@@ -61701,7 +61821,7 @@ import {
|
|
|
61701
61821
|
lstatSync as lstatSync17,
|
|
61702
61822
|
readFileSync as readFileSync29,
|
|
61703
61823
|
realpathSync as realpathSync15,
|
|
61704
|
-
rmSync as
|
|
61824
|
+
rmSync as rmSync18
|
|
61705
61825
|
} from "node:fs";
|
|
61706
61826
|
import { join as join35, resolve as resolve11, sep as sep5 } from "node:path";
|
|
61707
61827
|
|
|
@@ -61715,10 +61835,10 @@ import {
|
|
|
61715
61835
|
readFileSync as readFileSync26,
|
|
61716
61836
|
readlinkSync as readlinkSync3,
|
|
61717
61837
|
realpathSync as realpathSync12,
|
|
61718
|
-
renameSync as
|
|
61838
|
+
renameSync as renameSync19,
|
|
61719
61839
|
rmdirSync,
|
|
61720
|
-
rmSync as
|
|
61721
|
-
writeFileSync as
|
|
61840
|
+
rmSync as rmSync15,
|
|
61841
|
+
writeFileSync as writeFileSync18
|
|
61722
61842
|
} from "node:fs";
|
|
61723
61843
|
import {
|
|
61724
61844
|
basename as basename9,
|
|
@@ -61780,7 +61900,7 @@ function sweepStaging(staging, own2, o = {}) {
|
|
|
61780
61900
|
const m = STAGE_NAME.exec(name);
|
|
61781
61901
|
if (m ? old || !alive3(Number(m[1])) : old) {
|
|
61782
61902
|
try {
|
|
61783
|
-
|
|
61903
|
+
rmSync15(path, { recursive: true, force: true });
|
|
61784
61904
|
} catch {
|
|
61785
61905
|
}
|
|
61786
61906
|
}
|
|
@@ -61973,19 +62093,19 @@ async function installHermes(deps2) {
|
|
|
61973
62093
|
mkdirSync13(join32(tmp, f, ".."), { recursive: true });
|
|
61974
62094
|
cpSync2(join32(shipped, f), join32(tmp, f));
|
|
61975
62095
|
}
|
|
61976
|
-
|
|
62096
|
+
writeFileSync18(
|
|
61977
62097
|
join32(tmp, HERMES_MARKER),
|
|
61978
62098
|
`managed by the Open Artifacts bus installer: edits are replaced on reinstall. ${pluginHash(shipped)}
|
|
61979
62099
|
`
|
|
61980
62100
|
);
|
|
61981
62101
|
if (keepHabits)
|
|
61982
|
-
|
|
62102
|
+
writeFileSync18(join32(tmp, HERMES_HABITS_MARKER), HABITS_MARKER_TEXT);
|
|
61983
62103
|
if (keepRoots !== void 0)
|
|
61984
|
-
|
|
61985
|
-
if (state === "stale")
|
|
61986
|
-
|
|
62104
|
+
writeFileSync18(join32(tmp, HERMES_ROOTS_FILE), keepRoots, { mode: 384 });
|
|
62105
|
+
if (state === "stale") rmSync15(dest, { recursive: true, force: true });
|
|
62106
|
+
renameSync19(tmp, dest);
|
|
61987
62107
|
} catch (e) {
|
|
61988
|
-
|
|
62108
|
+
rmSync15(tmp, { recursive: true, force: true });
|
|
61989
62109
|
throw e;
|
|
61990
62110
|
} finally {
|
|
61991
62111
|
try {
|
|
@@ -62020,7 +62140,7 @@ async function uninstallHermes(deps2, notes) {
|
|
|
62020
62140
|
`\`hermes plugins disable ${HERMES_PLUGIN_NAME}\` failed (${firstLine(r.stderr) || firstLine(r.stdout) || `exit ${r.code}`}); left the plugin folder, rerun once Hermes works`
|
|
62021
62141
|
);
|
|
62022
62142
|
} else notes.push(HERMES_NO_CLI);
|
|
62023
|
-
|
|
62143
|
+
rmSync15(dest, { recursive: true, force: true });
|
|
62024
62144
|
return "done";
|
|
62025
62145
|
}
|
|
62026
62146
|
async function hermesEnabled(deps2) {
|
|
@@ -62043,7 +62163,7 @@ import {
|
|
|
62043
62163
|
readdirSync as readdirSync12,
|
|
62044
62164
|
readFileSync as readFileSync28,
|
|
62045
62165
|
realpathSync as realpathSync14,
|
|
62046
|
-
rmSync as
|
|
62166
|
+
rmSync as rmSync17
|
|
62047
62167
|
} from "node:fs";
|
|
62048
62168
|
import { join as join34, resolve as resolve10 } from "node:path";
|
|
62049
62169
|
import { fileURLToPath as fileURLToPath5 } from "node:url";
|
|
@@ -62058,11 +62178,11 @@ import {
|
|
|
62058
62178
|
readFileSync as readFileSync27,
|
|
62059
62179
|
readlinkSync as readlinkSync4,
|
|
62060
62180
|
realpathSync as realpathSync13,
|
|
62061
|
-
renameSync as
|
|
62181
|
+
renameSync as renameSync20,
|
|
62062
62182
|
rmdirSync as rmdirSync2,
|
|
62063
|
-
rmSync as
|
|
62183
|
+
rmSync as rmSync16,
|
|
62064
62184
|
statSync as statSync8,
|
|
62065
|
-
writeFileSync as
|
|
62185
|
+
writeFileSync as writeFileSync19
|
|
62066
62186
|
} from "node:fs";
|
|
62067
62187
|
import { dirname as dirname16, join as join33, resolve as resolve9 } from "node:path";
|
|
62068
62188
|
var SKILL_MARKER = "<!-- managed by the Open Artifacts bus installer: edits are replaced on reinstall. -->";
|
|
@@ -62222,12 +62342,12 @@ var writeAtomic = (path, text3) => {
|
|
|
62222
62342
|
mode = statSync8(path).mode & 4095;
|
|
62223
62343
|
} catch {
|
|
62224
62344
|
}
|
|
62225
|
-
|
|
62345
|
+
writeFileSync19(tmp, text3);
|
|
62226
62346
|
if (mode !== void 0) chmodSync19(tmp, mode);
|
|
62227
|
-
|
|
62347
|
+
renameSync20(tmp, path);
|
|
62228
62348
|
} catch (e) {
|
|
62229
62349
|
try {
|
|
62230
|
-
|
|
62350
|
+
rmSync16(tmp, { force: true });
|
|
62231
62351
|
} catch {
|
|
62232
62352
|
}
|
|
62233
62353
|
throw e;
|
|
@@ -62365,7 +62485,7 @@ var installCodex = (deps2, folder, text3, written, notes) => {
|
|
|
62365
62485
|
written.push(agentsPath);
|
|
62366
62486
|
if (ourFile && !shared) {
|
|
62367
62487
|
try {
|
|
62368
|
-
|
|
62488
|
+
rmSync16(targetOf(filePath), { force: true });
|
|
62369
62489
|
try {
|
|
62370
62490
|
rmdirSync2(dirname16(filePath));
|
|
62371
62491
|
} catch {
|
|
@@ -62471,7 +62591,7 @@ var uninstallSkill = (deps2, harnesses = [
|
|
|
62471
62591
|
);
|
|
62472
62592
|
continue;
|
|
62473
62593
|
}
|
|
62474
|
-
|
|
62594
|
+
rmSync16(targetOf(file2), { force: true });
|
|
62475
62595
|
try {
|
|
62476
62596
|
rmdirSync2(dir);
|
|
62477
62597
|
} catch {
|
|
@@ -62722,7 +62842,7 @@ async function installOpenclaw(deps2, notes, optedOut) {
|
|
|
62722
62842
|
);
|
|
62723
62843
|
const habitsFile = join34(dest, OPENCLAW_HABITS_MARKER);
|
|
62724
62844
|
const dropHabitsIfOptedOut = () => {
|
|
62725
|
-
if (optedOut && kind2(dest) === "dir")
|
|
62845
|
+
if (optedOut && kind2(dest) === "dir") rmSync17(habitsFile, { force: true });
|
|
62726
62846
|
};
|
|
62727
62847
|
if (state === "current") {
|
|
62728
62848
|
rememberInstall(deps2);
|
|
@@ -62758,7 +62878,7 @@ async function installOpenclaw(deps2, notes, optedOut) {
|
|
|
62758
62878
|
`
|
|
62759
62879
|
);
|
|
62760
62880
|
rememberInstall(deps2);
|
|
62761
|
-
|
|
62881
|
+
rmSync17(habitsFile, { force: true });
|
|
62762
62882
|
restore2();
|
|
62763
62883
|
}
|
|
62764
62884
|
const en = await exec2(deps2, ["plugins", "enable", OPENCLAW_PLUGIN_ID]);
|
|
@@ -62808,7 +62928,7 @@ async function uninstallOpenclaw(deps2, notes) {
|
|
|
62808
62928
|
`\`openclaw plugins uninstall ${OPENCLAW_PLUGIN_ID}\` failed (${why(r)}); left the plugin folder, rerun once OpenClaw works`
|
|
62809
62929
|
);
|
|
62810
62930
|
} else notes.push(OPENCLAW_NO_CLI);
|
|
62811
|
-
|
|
62931
|
+
rmSync17(dest, { recursive: true, force: true });
|
|
62812
62932
|
forgetInstall(deps2);
|
|
62813
62933
|
return "done";
|
|
62814
62934
|
}
|
|
@@ -62899,10 +63019,10 @@ function blockState(existing) {
|
|
|
62899
63019
|
var separatorFor = (existing) => {
|
|
62900
63020
|
if (existing === "") return "";
|
|
62901
63021
|
const eol2 = existing.includes("\r\n") ? "\r\n" : "\n";
|
|
62902
|
-
let
|
|
62903
|
-
if (!existing.endsWith("\n"))
|
|
62904
|
-
if (!/\n\r?\n$/.test(existing +
|
|
62905
|
-
return
|
|
63022
|
+
let sep8 = "";
|
|
63023
|
+
if (!existing.endsWith("\n")) sep8 += eol2;
|
|
63024
|
+
if (!/\n\r?\n$/.test(existing + sep8)) sep8 += eol2;
|
|
63025
|
+
return sep8;
|
|
62906
63026
|
};
|
|
62907
63027
|
function withHabits(existing, block, added) {
|
|
62908
63028
|
const lines = existing.split("\n");
|
|
@@ -62973,6 +63093,7 @@ var pluginDirsOf = (v) => {
|
|
|
62973
63093
|
out[name] = list.filter((d) => typeof d === "string");
|
|
62974
63094
|
return out;
|
|
62975
63095
|
};
|
|
63096
|
+
var projectRecord = (busHome2) => record6(busHome2).project;
|
|
62976
63097
|
var saveRecord = (busHome2, patch) => {
|
|
62977
63098
|
if (!busHome2) return;
|
|
62978
63099
|
const cur = record6(busHome2);
|
|
@@ -63095,7 +63216,7 @@ function removeProjectHabits(deps2, only) {
|
|
|
63095
63216
|
continue;
|
|
63096
63217
|
}
|
|
63097
63218
|
const after = withHabits(before, null, rec?.added);
|
|
63098
|
-
if (rec?.created && after.trim() === "")
|
|
63219
|
+
if (rec?.created && after.trim() === "") rmSync18(path, { force: true });
|
|
63099
63220
|
else writeAtomic(path, after);
|
|
63100
63221
|
delete kept[path];
|
|
63101
63222
|
cleaned.add(path);
|
|
@@ -63195,7 +63316,7 @@ function removeHabits(deps2, harnesses = HABITS_HARNESSES) {
|
|
|
63195
63316
|
const rec = kept[path];
|
|
63196
63317
|
const after = withHabits(before, null, rec?.added);
|
|
63197
63318
|
if (rec?.created && !isLink(path) && after.trim() === "")
|
|
63198
|
-
|
|
63319
|
+
rmSync18(real3, { force: true });
|
|
63199
63320
|
else writeAtomic(real3, after);
|
|
63200
63321
|
delete kept[path];
|
|
63201
63322
|
files2.push(path);
|
|
@@ -63373,7 +63494,7 @@ function setPluginHabits(deps2, plugins2, on) {
|
|
|
63373
63494
|
continue;
|
|
63374
63495
|
}
|
|
63375
63496
|
try {
|
|
63376
|
-
|
|
63497
|
+
rmSync18(marker, { force: true });
|
|
63377
63498
|
} catch (e) {
|
|
63378
63499
|
left(
|
|
63379
63500
|
`Could not remove ${marker} (${reason(e)}): ${p.label} habits are still on there. Delete it, then rerun.`
|
|
@@ -63452,7 +63573,7 @@ var habitsQuestionLines = (q) => [
|
|
|
63452
63573
|
];
|
|
63453
63574
|
|
|
63454
63575
|
// src/steps/opencode-proof.ts
|
|
63455
|
-
import { existsSync as existsSync14, readFileSync as readFileSync30, rmSync as
|
|
63576
|
+
import { existsSync as existsSync14, readFileSync as readFileSync30, rmSync as rmSync19 } from "node:fs";
|
|
63456
63577
|
import { dirname as dirname17, isAbsolute as isAbsolute13, join as join36, resolve as resolve12 } from "node:path";
|
|
63457
63578
|
init_src();
|
|
63458
63579
|
var OPENCODE_ENTRY_FILE = "opencode-mcp-entry.json";
|
|
@@ -63621,7 +63742,7 @@ function restoreEntry2(io) {
|
|
|
63621
63742
|
put2 = true;
|
|
63622
63743
|
}
|
|
63623
63744
|
}
|
|
63624
|
-
|
|
63745
|
+
rmSync19(io.moved, { force: true });
|
|
63625
63746
|
return put2;
|
|
63626
63747
|
}
|
|
63627
63748
|
function proxyProgramMissing2(entry, origin, which2) {
|
|
@@ -63666,7 +63787,7 @@ function skippedNotes(files2, read2, origin) {
|
|
|
63666
63787
|
}
|
|
63667
63788
|
|
|
63668
63789
|
// src/steps/pi-proof.ts
|
|
63669
|
-
import { existsSync as existsSync15, readFileSync as readFileSync31, rmSync as
|
|
63790
|
+
import { existsSync as existsSync15, readFileSync as readFileSync31, rmSync as rmSync20 } from "node:fs";
|
|
63670
63791
|
var PI_ENTRY_FILE = "pi-mcp-entry.json";
|
|
63671
63792
|
var OMP_ORIGIN_FILE = "omp-mcp-origin.json";
|
|
63672
63793
|
var PI_MIN_VERSION = "1.5.0";
|
|
@@ -63761,7 +63882,7 @@ function restoreEntry3(io) {
|
|
|
63761
63882
|
);
|
|
63762
63883
|
put2 = true;
|
|
63763
63884
|
}
|
|
63764
|
-
|
|
63885
|
+
rmSync20(io.moved, { force: true });
|
|
63765
63886
|
return put2;
|
|
63766
63887
|
}
|
|
63767
63888
|
|
|
@@ -63902,11 +64023,11 @@ function writeAtomic2(path, data, mode) {
|
|
|
63902
64023
|
}
|
|
63903
64024
|
const tmp = `${dest}.${process.pid}.${randomBytes8(4).toString("hex")}.tmp`;
|
|
63904
64025
|
try {
|
|
63905
|
-
|
|
64026
|
+
writeFileSync20(tmp, data, { mode: m, flag: "wx" });
|
|
63906
64027
|
chmodSync20(tmp, m);
|
|
63907
|
-
|
|
64028
|
+
renameSync21(tmp, dest);
|
|
63908
64029
|
} catch (e) {
|
|
63909
|
-
|
|
64030
|
+
rmSync21(tmp, { force: true });
|
|
63910
64031
|
throw e;
|
|
63911
64032
|
}
|
|
63912
64033
|
}
|
|
@@ -64305,7 +64426,7 @@ var install = {
|
|
|
64305
64426
|
}
|
|
64306
64427
|
if (had !== pin) writeAtomic2(p.codexBin, pin, 384);
|
|
64307
64428
|
} else {
|
|
64308
|
-
|
|
64429
|
+
rmSync21(p.codexBin, { force: true });
|
|
64309
64430
|
notes.push(CODEX_NO_BIN);
|
|
64310
64431
|
}
|
|
64311
64432
|
await codexEntryStep(deps2, notes);
|
|
@@ -64385,7 +64506,7 @@ var uninstall = {
|
|
|
64385
64506
|
for (const { file: file2 } of edits) delete left[file2];
|
|
64386
64507
|
writeRecord2(p.record, record7, left);
|
|
64387
64508
|
const hadPlugin = existsSync16(p.opencodePlugin);
|
|
64388
|
-
|
|
64509
|
+
rmSync21(p.opencodePlugin, { recursive: true, force: true });
|
|
64389
64510
|
if (!saved.some(Boolean) && !hadPlugin && !restored) return "none";
|
|
64390
64511
|
if (deps2.which("opencode")) await restartOpencode(deps2, notes, true);
|
|
64391
64512
|
return saved.some(Boolean) || restored ? "done" : "folder";
|
|
@@ -64403,16 +64524,16 @@ var uninstall = {
|
|
|
64403
64524
|
}
|
|
64404
64525
|
const path = paths(deps2).pi;
|
|
64405
64526
|
if (!existsSync16(path)) return restored ? "done" : "none";
|
|
64406
|
-
|
|
64527
|
+
rmSync21(path, { force: true });
|
|
64407
64528
|
return "done";
|
|
64408
64529
|
},
|
|
64409
64530
|
async omp(deps2, _notes, done) {
|
|
64410
|
-
|
|
64531
|
+
rmSync21(paths(deps2).ompOrigin, { force: true });
|
|
64411
64532
|
if (sharedFile(deps2) && done.includes("pi")) return "done";
|
|
64412
64533
|
if (sharedFile(deps2) && existsSync16(paths(deps2).piEntry)) return "none";
|
|
64413
64534
|
const path = paths(deps2).omp;
|
|
64414
64535
|
if (!existsSync16(path)) return "none";
|
|
64415
|
-
|
|
64536
|
+
rmSync21(path, { force: true });
|
|
64416
64537
|
return "done";
|
|
64417
64538
|
},
|
|
64418
64539
|
async codex(deps2, notes) {
|
|
@@ -64435,7 +64556,7 @@ var uninstall = {
|
|
|
64435
64556
|
}
|
|
64436
64557
|
}
|
|
64437
64558
|
const pinned = present2(p.codexBin);
|
|
64438
|
-
|
|
64559
|
+
rmSync21(p.codexBin, { force: true });
|
|
64439
64560
|
return saved || pinned ? "done" : "none";
|
|
64440
64561
|
},
|
|
64441
64562
|
async hermes(deps2, notes) {
|
|
@@ -64649,9 +64770,9 @@ import {
|
|
|
64649
64770
|
mkdirSync as mkdirSync16,
|
|
64650
64771
|
readFileSync as readFileSync33,
|
|
64651
64772
|
readlinkSync as readlinkSync6,
|
|
64652
|
-
renameSync as
|
|
64653
|
-
rmSync as
|
|
64654
|
-
writeFileSync as
|
|
64773
|
+
renameSync as renameSync22,
|
|
64774
|
+
rmSync as rmSync22,
|
|
64775
|
+
writeFileSync as writeFileSync21
|
|
64655
64776
|
} from "node:fs";
|
|
64656
64777
|
import { delimiter as delimiter3, dirname as dirname19, join as join38, resolve as resolve14, sep as sep6 } from "node:path";
|
|
64657
64778
|
var SHIM_MARKER = "# oa-bus shim: written by oa-bus install";
|
|
@@ -64702,13 +64823,13 @@ function ownerOf(file2, busHome2) {
|
|
|
64702
64823
|
var sameHome = (owner, busHome2) => owner?.ours === true && (owner.home === void 0 || owner.home === resolve14(busHome2));
|
|
64703
64824
|
function writeShim(path, text3) {
|
|
64704
64825
|
const tmp = `${path}.${process.pid}.tmp`;
|
|
64705
|
-
|
|
64826
|
+
rmSync22(tmp, { force: true });
|
|
64706
64827
|
try {
|
|
64707
|
-
|
|
64828
|
+
writeFileSync21(tmp, text3, { mode: 493, flag: "wx" });
|
|
64708
64829
|
chmodSync21(tmp, 493);
|
|
64709
|
-
|
|
64830
|
+
renameSync22(tmp, path);
|
|
64710
64831
|
} catch (e) {
|
|
64711
|
-
|
|
64832
|
+
rmSync22(tmp, { force: true });
|
|
64712
64833
|
throw e;
|
|
64713
64834
|
}
|
|
64714
64835
|
}
|
|
@@ -64746,7 +64867,7 @@ function removeShim(o) {
|
|
|
64746
64867
|
const owner = ownerOf(file2, o.busHome);
|
|
64747
64868
|
if (!owner?.ours) continue;
|
|
64748
64869
|
if (owner.home !== void 0 && owner.home !== resolve14(o.busHome)) continue;
|
|
64749
|
-
|
|
64870
|
+
rmSync22(file2, { force: true });
|
|
64750
64871
|
removed = file2;
|
|
64751
64872
|
}
|
|
64752
64873
|
return removed;
|
|
@@ -64840,8 +64961,8 @@ import {
|
|
|
64840
64961
|
closeSync as closeSync10,
|
|
64841
64962
|
mkdirSync as mkdirSync17,
|
|
64842
64963
|
openSync as openSync10,
|
|
64843
|
-
renameSync as
|
|
64844
|
-
rmSync as
|
|
64964
|
+
renameSync as renameSync23,
|
|
64965
|
+
rmSync as rmSync23,
|
|
64845
64966
|
unlinkSync as unlinkSync5,
|
|
64846
64967
|
writeSync as writeSync5
|
|
64847
64968
|
} from "node:fs";
|
|
@@ -64908,7 +65029,7 @@ function writeMachineFile(home2, body) {
|
|
|
64908
65029
|
closeSync10(fd);
|
|
64909
65030
|
try {
|
|
64910
65031
|
chmodSync22(tmp, 384);
|
|
64911
|
-
|
|
65032
|
+
renameSync23(tmp, join40(home2, "machine.json"));
|
|
64912
65033
|
} catch (e) {
|
|
64913
65034
|
unlinkSync5(tmp);
|
|
64914
65035
|
throw e;
|
|
@@ -65058,7 +65179,7 @@ async function loginInner(args) {
|
|
|
65058
65179
|
`${JSON.stringify({ hub, label: label2, machine_token: poll.machine_token }, null, 2)}
|
|
65059
65180
|
`
|
|
65060
65181
|
);
|
|
65061
|
-
|
|
65182
|
+
rmSync23(join40(args.home, "revoked"), { force: true });
|
|
65062
65183
|
}
|
|
65063
65184
|
if (!events?.code) print(`Approved this machine as ${label2}.`);
|
|
65064
65185
|
return {
|
|
@@ -65522,7 +65643,7 @@ import {
|
|
|
65522
65643
|
readdirSync as readdirSync13,
|
|
65523
65644
|
readFileSync as readFileSync36,
|
|
65524
65645
|
rmdirSync as rmdirSync3,
|
|
65525
|
-
rmSync as
|
|
65646
|
+
rmSync as rmSync24
|
|
65526
65647
|
} from "node:fs";
|
|
65527
65648
|
import { dirname as dirname20, join as join44 } from "node:path";
|
|
65528
65649
|
var OUTPUT_STYLE_FILE = "artifacts-teammate.md";
|
|
@@ -65624,7 +65745,7 @@ function selectOutputStyle(deps2) {
|
|
|
65624
65745
|
} else {
|
|
65625
65746
|
try {
|
|
65626
65747
|
if (exists(path) && isOurs2(readFileSync36(path, "utf8"))) {
|
|
65627
|
-
|
|
65748
|
+
rmSync24(path);
|
|
65628
65749
|
removed = true;
|
|
65629
65750
|
if (readdirSync13(dir).length === 0) rmdirSync3(dir);
|
|
65630
65751
|
} else if (exists(path)) {
|
|
@@ -65673,7 +65794,7 @@ function turnOff(deps2, out) {
|
|
|
65673
65794
|
const was = rec?.set ? rec.before : void 0;
|
|
65674
65795
|
const next = was?.state === "null" ? setJsoncValue(cur.text, ["outputStyle"], null) : was?.state === "empty" ? setJsoncValue(cur.text, ["outputStyle"], was.value) : removeJsoncValue(cur.text, ["outputStyle"]);
|
|
65675
65796
|
if (rec?.set && rec.createdFile && (cur.text === createdText() || cur.text === createdText(OUTPUT_STYLE_NAME)))
|
|
65676
|
-
|
|
65797
|
+
rmSync24(path);
|
|
65677
65798
|
else writeAtomic(path, next);
|
|
65678
65799
|
}
|
|
65679
65800
|
if (busHome2 && rec) writeRecord3(busHome2, void 0);
|
|
@@ -65700,7 +65821,7 @@ function uninstallOutputStyle(deps2) {
|
|
|
65700
65821
|
`Left ${path} alone: it has no Open Artifacts marker, so it is not ours to replace.`
|
|
65701
65822
|
);
|
|
65702
65823
|
} else {
|
|
65703
|
-
|
|
65824
|
+
rmSync24(path);
|
|
65704
65825
|
out.written.push(path);
|
|
65705
65826
|
gone = true;
|
|
65706
65827
|
if (readdirSync13(dir).length === 0) rmdirSync3(dir);
|
|
@@ -66384,8 +66505,8 @@ var sseCheck = (ctx, name) => ({
|
|
|
66384
66505
|
|
|
66385
66506
|
// src/commands/habits.ts
|
|
66386
66507
|
init_src();
|
|
66387
|
-
import { mkdirSync as mkdirSync18, readFileSync as readFileSync39, realpathSync as realpathSync16, writeFileSync as
|
|
66388
|
-
import { dirname as dirname21, join as join47, resolve as resolve15 } from "node:path";
|
|
66508
|
+
import { mkdirSync as mkdirSync18, readFileSync as readFileSync39, realpathSync as realpathSync16, writeFileSync as writeFileSync22 } from "node:fs";
|
|
66509
|
+
import { dirname as dirname21, join as join47, resolve as resolve15, sep as sep7 } from "node:path";
|
|
66389
66510
|
var pluginOn = (p) => `Habits on in the ${p.label} plugin.`;
|
|
66390
66511
|
var pluginOff = (p) => `Habits off in the ${p.label} plugin.`;
|
|
66391
66512
|
var deps = (ctx) => ({
|
|
@@ -66601,15 +66722,15 @@ async function projectIo(ctx) {
|
|
|
66601
66722
|
}
|
|
66602
66723
|
const lines = text3.split("\n");
|
|
66603
66724
|
if (lines.includes(line)) return false;
|
|
66604
|
-
const
|
|
66605
|
-
|
|
66725
|
+
const sep8 = text3 === "" || text3.endsWith("\n") ? "" : "\n";
|
|
66726
|
+
writeFileSync22(excludeFile, `${text3}${sep8}${line}
|
|
66606
66727
|
`);
|
|
66607
66728
|
return true;
|
|
66608
66729
|
},
|
|
66609
66730
|
unexclude: (line) => {
|
|
66610
66731
|
try {
|
|
66611
66732
|
const lines = readFileSync39(excludeFile, "utf8").split("\n");
|
|
66612
|
-
|
|
66733
|
+
writeFileSync22(excludeFile, lines.filter((l) => l !== line).join("\n"));
|
|
66613
66734
|
} catch {
|
|
66614
66735
|
}
|
|
66615
66736
|
}
|
|
@@ -66911,6 +67032,28 @@ async function habitsCommand(mode, ctx) {
|
|
|
66911
67032
|
}
|
|
66912
67033
|
return mode === "yes" ? turnOn2(ctx) : turnOff2(ctx);
|
|
66913
67034
|
}
|
|
67035
|
+
var projectHere = (ctx) => {
|
|
67036
|
+
const base3 = realpathOr(ctx.cwd);
|
|
67037
|
+
const atOrBelow = (p) => {
|
|
67038
|
+
const dir = realpathOr(dirname21(p));
|
|
67039
|
+
return dir === base3 || base3.startsWith(`${dir}${sep7}`);
|
|
67040
|
+
};
|
|
67041
|
+
const rec = projectRecord(deps(ctx).busHome);
|
|
67042
|
+
const files2 = Object.keys(rec.files).filter(atOrBelow);
|
|
67043
|
+
const changed = files2.some((f) => {
|
|
67044
|
+
try {
|
|
67045
|
+
return blockState(readFileSync39(f, "utf8")).state === "changed";
|
|
67046
|
+
} catch {
|
|
67047
|
+
return false;
|
|
67048
|
+
}
|
|
67049
|
+
});
|
|
67050
|
+
const declined = Object.keys(readDeclined(ctx.home)).some((root) => {
|
|
67051
|
+
const dir = realpathOr(root);
|
|
67052
|
+
return dir === base3 || base3.startsWith(`${dir}${sep7}`);
|
|
67053
|
+
});
|
|
67054
|
+
return { files: files2, changed, declined };
|
|
67055
|
+
};
|
|
67056
|
+
var habitsWhere = (ctx, files2) => `on in this project, ${shown2(ctx, files2)}`;
|
|
66914
67057
|
function habitsLine(ctx) {
|
|
66915
67058
|
const { targets, plugins: plugins2 } = wired(ctx);
|
|
66916
67059
|
if (habitsOptedOut(ctx.home)) return "Habits: off (you opted out)";
|
|
@@ -66920,6 +67063,10 @@ function habitsLine(ctx) {
|
|
|
66920
67063
|
);
|
|
66921
67064
|
const states = used.map((p) => pluginStateText(ctx, p));
|
|
66922
67065
|
const tail2 = states.length > 0 ? `; ${states.join("; ")}` : "";
|
|
67066
|
+
const here = projectHere(ctx);
|
|
67067
|
+
if (here.files.length > 0)
|
|
67068
|
+
return here.changed ? `Habits: out of date in this project, ${shown2(ctx, here.files)}. Run ${ctx.busCmd} install to update them${tail2}` : `Habits: ${habitsWhere(ctx, here.files)}${tail2}`;
|
|
67069
|
+
if (here.declined) return `Habits: off in this project${tail2}`;
|
|
66923
67070
|
if (on.length > 0) return `Habits: on in ${shown2(ctx, on)}${tail2}`;
|
|
66924
67071
|
if (used.some((p) => pluginHabitsState(deps(ctx), p) === "on"))
|
|
66925
67072
|
return `Habits: ${states.join("; ")}`;
|
|
@@ -67135,7 +67282,7 @@ import {
|
|
|
67135
67282
|
readdirSync as readdirSync14,
|
|
67136
67283
|
readFileSync as readFileSync40,
|
|
67137
67284
|
rmdirSync as rmdirSync4,
|
|
67138
|
-
rmSync as
|
|
67285
|
+
rmSync as rmSync25
|
|
67139
67286
|
} from "node:fs";
|
|
67140
67287
|
import { join as join49 } from "node:path";
|
|
67141
67288
|
function leftoverTargets(deps2) {
|
|
@@ -67212,7 +67359,7 @@ function removeMade(made) {
|
|
|
67212
67359
|
const gone = [];
|
|
67213
67360
|
for (const path of made) {
|
|
67214
67361
|
if (!emptyFile(path)) continue;
|
|
67215
|
-
|
|
67362
|
+
rmSync25(path, { force: true });
|
|
67216
67363
|
gone.push(path);
|
|
67217
67364
|
}
|
|
67218
67365
|
for (const path of made.filter((x) => !gone.includes(x)).sort((a, b) => b.length - a.length)) {
|
|
@@ -68761,7 +68908,7 @@ import { join as join56 } from "node:path";
|
|
|
68761
68908
|
|
|
68762
68909
|
// src/steps/purge.ts
|
|
68763
68910
|
init_src3();
|
|
68764
|
-
import { lstatSync as lstatSync23, readdirSync as readdirSync15, rmdirSync as rmdirSync5, rmSync as
|
|
68911
|
+
import { lstatSync as lstatSync23, readdirSync as readdirSync15, rmdirSync as rmdirSync5, rmSync as rmSync26 } from "node:fs";
|
|
68765
68912
|
import { join as join55 } from "node:path";
|
|
68766
68913
|
var FILES = [
|
|
68767
68914
|
"machine.json",
|
|
@@ -68821,7 +68968,7 @@ function kind3(path) {
|
|
|
68821
68968
|
return void 0;
|
|
68822
68969
|
}
|
|
68823
68970
|
}
|
|
68824
|
-
var remove2 = (path, k) =>
|
|
68971
|
+
var remove2 = (path, k) => rmSync26(path, { recursive: k === "dir", force: true });
|
|
68825
68972
|
var rmdirIfEmpty = (path) => {
|
|
68826
68973
|
try {
|
|
68827
68974
|
rmdirSync5(path);
|
|
@@ -69116,8 +69263,8 @@ import {
|
|
|
69116
69263
|
copyFileSync as copyFileSync2,
|
|
69117
69264
|
existsSync as existsSync20,
|
|
69118
69265
|
mkdirSync as mkdirSync19,
|
|
69119
|
-
rmSync as
|
|
69120
|
-
writeFileSync as
|
|
69266
|
+
rmSync as rmSync27,
|
|
69267
|
+
writeFileSync as writeFileSync23
|
|
69121
69268
|
} from "node:fs";
|
|
69122
69269
|
import { join as join57 } from "node:path";
|
|
69123
69270
|
var realUpgradeDeps = (ctx) => ({
|
|
@@ -69249,7 +69396,7 @@ async function upgrade(ctx, opts, deps2 = realUpgradeDeps(ctx)) {
|
|
|
69249
69396
|
const marker = join57(dest, ".live", String(process.pid));
|
|
69250
69397
|
try {
|
|
69251
69398
|
mkdirSync19(join57(dest, ".live"), { recursive: true, mode: 448 });
|
|
69252
|
-
|
|
69399
|
+
writeFileSync23(marker, "", { mode: 384 });
|
|
69253
69400
|
} catch {
|
|
69254
69401
|
}
|
|
69255
69402
|
deps2.beforeInstall?.(dest);
|
|
@@ -69265,7 +69412,7 @@ async function upgrade(ctx, opts, deps2 = realUpgradeDeps(ctx)) {
|
|
|
69265
69412
|
args.push("--no-service");
|
|
69266
69413
|
setPending(ctx.home, { from: runBase, to: target2, startedAt: ctx.now() });
|
|
69267
69414
|
const code2 = deps2.runInstaller(entry, args);
|
|
69268
|
-
|
|
69415
|
+
rmSync27(marker, { force: true });
|
|
69269
69416
|
if (code2 !== 0) {
|
|
69270
69417
|
clearPending(ctx.home);
|
|
69271
69418
|
sayErr(ctx, c.upgradeInstallFailed(target2, code2));
|