@open-artifacts/bus 0.162.0 → 0.162.1
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 +221 -90
- package/package.json +1 -1
package/assets/oa-bus.ts
CHANGED
|
@@ -11,7 +11,7 @@ import { StringDecoder } from "node:string_decoder";
|
|
|
11
11
|
type Json = Record<string, unknown>;
|
|
12
12
|
|
|
13
13
|
/** The IPC marker (CONTRACT.md): the package version, stamped by the CLI's bundler. */
|
|
14
|
-
const CLIENT_VERSION = "0.162.
|
|
14
|
+
const CLIENT_VERSION = "0.162.1";
|
|
15
15
|
|
|
16
16
|
type Frame = Json & { type: string; id: string };
|
|
17
17
|
type Ctx = {
|
package/assets/openclaw/index.js
CHANGED
|
@@ -27724,7 +27724,7 @@ var base2 = { v: external_exports.literal(V), id: external_exports.string().min(
|
|
|
27724
27724
|
var late = { late: external_exports.array(external_exports.string().min(1)).optional() };
|
|
27725
27725
|
var isWellFormed2 = (s) => s.isWellFormed();
|
|
27726
27726
|
var WELL_FORMED = { message: "text is not well-formed unicode" };
|
|
27727
|
-
var CLIENT_VERSION = true ? "0.162.
|
|
27727
|
+
var CLIENT_VERSION = true ? "0.162.1" : "0.0.0";
|
|
27728
27728
|
var clientVersion = {
|
|
27729
27729
|
client_version: external_exports.string().min(1).max(64).optional()
|
|
27730
27730
|
};
|
package/dist/index.js
CHANGED
|
@@ -21787,7 +21787,7 @@ var init_frames = __esm({
|
|
|
21787
21787
|
late = { late: external_exports.array(external_exports.string().min(1)).optional() };
|
|
21788
21788
|
isWellFormed2 = (s) => s.isWellFormed();
|
|
21789
21789
|
WELL_FORMED = { message: "text is not well-formed unicode" };
|
|
21790
|
-
CLIENT_VERSION = true ? "0.162.
|
|
21790
|
+
CLIENT_VERSION = true ? "0.162.1" : "0.0.0";
|
|
21791
21791
|
clientVersion = {
|
|
21792
21792
|
client_version: external_exports.string().min(1).max(64).optional()
|
|
21793
21793
|
};
|
|
@@ -40977,6 +40977,8 @@ function openState(dir, deps2, ref) {
|
|
|
40977
40977
|
var CODEX_TOOL_NAMESPACE = "mcp__oa_bus";
|
|
40978
40978
|
var CODEX_REFUSALS = {
|
|
40979
40979
|
notCodex: "it is not running under Codex.",
|
|
40980
|
+
/** `ps` timed out or could not run: unknown, not "not Codex". Retryable. */
|
|
40981
|
+
procUnknown: "the bus could not check the process in time. Call the tool again.",
|
|
40980
40982
|
restarted: "Codex restarted. Call the tool again.",
|
|
40981
40983
|
notLoaded: "Codex does not have this thread loaded.",
|
|
40982
40984
|
callNotFound: "this call is not an open Open Artifacts bus call in the thread. Call the tool again.",
|
|
@@ -41066,7 +41068,8 @@ function codexAttestor(deps2 = {}) {
|
|
|
41066
41068
|
const home2 = deps2.home ?? codexHome();
|
|
41067
41069
|
const thread = cx.thread_id;
|
|
41068
41070
|
const p = cx.ppid;
|
|
41069
|
-
const rows = procs([hello.pid, p])
|
|
41071
|
+
const rows = procs([hello.pid, p]);
|
|
41072
|
+
if (!rows) return no(CODEX_REFUSALS.procUnknown);
|
|
41070
41073
|
const proc = rows.get(p);
|
|
41071
41074
|
if (!proc || rows.get(hello.pid)?.ppid !== p)
|
|
41072
41075
|
return no(CODEX_REFUSALS.notCodex);
|
|
@@ -41192,19 +41195,21 @@ function codexAttestor(deps2 = {}) {
|
|
|
41192
41195
|
};
|
|
41193
41196
|
const restore2 = ({ thread, pid, start }) => {
|
|
41194
41197
|
const home2 = deps2.home ?? codexHome();
|
|
41195
|
-
const
|
|
41198
|
+
const rows = procs([pid]);
|
|
41199
|
+
if (!rows) return { unknown: true };
|
|
41200
|
+
const proc = rows.get(pid);
|
|
41196
41201
|
if (!proc || basename2(proc.comm) !== "codex" || proc.start !== start)
|
|
41197
|
-
return
|
|
41202
|
+
return { dropped: "other_process" };
|
|
41198
41203
|
const was = pinned.get(pid);
|
|
41199
|
-
if (was !== void 0 && was !== start) return
|
|
41204
|
+
if (was !== void 0 && was !== start) return { dropped: "other_process" };
|
|
41200
41205
|
const row = threadRow(home2, thread);
|
|
41201
41206
|
const rollout = row?.rollout_path ?? globRollout(home2, thread);
|
|
41202
|
-
if (!rollout || !plainFile(rollout)) return
|
|
41207
|
+
if (!rollout || !plainFile(rollout)) return { dropped: "no_rollout" };
|
|
41203
41208
|
const meta3 = metaOf2(rollout, thread);
|
|
41204
41209
|
if (!meta3 || typeof meta3.cwd !== "string" || !isAbsolute(meta3.cwd))
|
|
41205
|
-
return
|
|
41210
|
+
return { dropped: "no_rollout" };
|
|
41206
41211
|
if (isSubagent(row ? row.source : meta3.source) || isSubagent(meta3.source) || SPAWNED_SOURCES.has(String(meta3.thread_source)))
|
|
41207
|
-
return
|
|
41212
|
+
return { dropped: "subagent" };
|
|
41208
41213
|
const had = was !== void 0;
|
|
41209
41214
|
pinned.set(pid, start);
|
|
41210
41215
|
proofs.set(`${pid}\0${start}\0${thread}`, { cwd: meta3.cwd, rollout });
|
|
@@ -41213,7 +41218,7 @@ function codexAttestor(deps2 = {}) {
|
|
|
41213
41218
|
lapsed.delete(`${pid}\0${start}\0${thread}`);
|
|
41214
41219
|
if (!had && ![...proofs.keys()].some((k) => k.startsWith(`${pid}\0`)))
|
|
41215
41220
|
pinned.delete(pid);
|
|
41216
|
-
return
|
|
41221
|
+
return { dropped: "no_lock" };
|
|
41217
41222
|
};
|
|
41218
41223
|
const isUserThread = (home2, thread) => {
|
|
41219
41224
|
const row = threadRow(home2, thread);
|
|
@@ -41667,7 +41672,7 @@ function lockHoldersLinux(files2, procRoot = "/proc") {
|
|
|
41667
41672
|
try {
|
|
41668
41673
|
const st = statSync4(join6(dir, fd), { bigint: true });
|
|
41669
41674
|
for (const f of want.get(`${st.dev}:${st.ino}`) ?? [])
|
|
41670
|
-
if (!seen2.has(f)) {
|
|
41675
|
+
if (!seen2.has(f) && fdHoldsLock(procRoot, pid, fd, st)) {
|
|
41671
41676
|
seen2.add(f);
|
|
41672
41677
|
pairs.push({ pid, file: f });
|
|
41673
41678
|
}
|
|
@@ -41675,39 +41680,26 @@ function lockHoldersLinux(files2, procRoot = "/proc") {
|
|
|
41675
41680
|
}
|
|
41676
41681
|
}
|
|
41677
41682
|
const locked = holdingLinux(pairs, procRoot);
|
|
41678
|
-
const lockers = lockerPids(procRoot);
|
|
41679
41683
|
const out = new Map(files2.map((f) => [f, []]));
|
|
41680
41684
|
pairs.forEach((p, i) => {
|
|
41681
41685
|
if (locked[i]) out.get(p.file)?.push(p.pid);
|
|
41682
41686
|
});
|
|
41683
|
-
for (const [f, list] of out) {
|
|
41684
|
-
let key2;
|
|
41685
|
-
try {
|
|
41686
|
-
const st = statSync4(f, { bigint: true });
|
|
41687
|
-
const { major, minor } = devParts(st.dev);
|
|
41688
|
-
key2 = `${major}:${minor}:${st.ino}`;
|
|
41689
|
-
} catch {
|
|
41690
|
-
}
|
|
41691
|
-
const first = (pid) => key2 && lockers.get(key2)?.has(pid) ? 0 : 1;
|
|
41692
|
-
list.sort((a, b) => first(a) - first(b));
|
|
41693
|
-
}
|
|
41694
41687
|
return out;
|
|
41695
41688
|
}
|
|
41696
|
-
function
|
|
41697
|
-
const out = /* @__PURE__ */ new Map();
|
|
41689
|
+
function fdHoldsLock(procRoot, pid, fd, st) {
|
|
41698
41690
|
try {
|
|
41699
|
-
|
|
41700
|
-
|
|
41701
|
-
|
|
41702
|
-
|
|
41703
|
-
|
|
41704
|
-
if (
|
|
41705
|
-
|
|
41706
|
-
|
|
41707
|
-
}
|
|
41691
|
+
const { major, minor } = devParts(st.dev);
|
|
41692
|
+
const want = `${major}:${minor}:${st.ino}`;
|
|
41693
|
+
return readFileSync5(join6(procRoot, String(pid), "fdinfo", fd), "utf8").split("\n").some((l) => {
|
|
41694
|
+
if (!l.startsWith("lock:")) return false;
|
|
41695
|
+
const [maj, min, ino] = (l.trim().split(/\s+/)[6] ?? "").split(":");
|
|
41696
|
+
if (!maj || !min || !ino) return false;
|
|
41697
|
+
if (!/^[0-9a-f]+$/i.test(maj + min) || !/^\d+$/.test(ino)) return false;
|
|
41698
|
+
return `${BigInt(`0x${maj}`)}:${BigInt(`0x${min}`)}:${ino}` === want;
|
|
41699
|
+
});
|
|
41708
41700
|
} catch {
|
|
41701
|
+
return false;
|
|
41709
41702
|
}
|
|
41710
|
-
return out;
|
|
41711
41703
|
}
|
|
41712
41704
|
|
|
41713
41705
|
// ../bus-daemon/src/liveness/claude.ts
|
|
@@ -46462,7 +46454,7 @@ var PiTransport = class {
|
|
|
46462
46454
|
// ../bus-daemon/src/event-log.ts
|
|
46463
46455
|
init_src2();
|
|
46464
46456
|
import { constants as constants5 } from "node:fs";
|
|
46465
|
-
import {
|
|
46457
|
+
import { lstat, mkdir, open as open2, rename } from "node:fs/promises";
|
|
46466
46458
|
import { dirname as dirname9 } from "node:path";
|
|
46467
46459
|
var EVENT_LOG_MAX_BYTES = 1e6;
|
|
46468
46460
|
var FIELDS = /* @__PURE__ */ new Set([
|
|
@@ -46496,34 +46488,76 @@ function createEventLog(file2, opts = {}) {
|
|
|
46496
46488
|
const now = opts.now ?? (() => /* @__PURE__ */ new Date());
|
|
46497
46489
|
let chain = Promise.resolve();
|
|
46498
46490
|
let size;
|
|
46491
|
+
const checkDir2 = async (dir) => {
|
|
46492
|
+
const ls = await lstat(dir).catch(() => void 0);
|
|
46493
|
+
if (ls && ls.isSymbolicLink()) throw new Error("folder is a symlink");
|
|
46494
|
+
if (ls && !ls.isDirectory()) throw new Error("not a folder");
|
|
46495
|
+
if (!ls) await mkdir(dir, { recursive: true, mode: 448 });
|
|
46496
|
+
const dh = await open2(
|
|
46497
|
+
dir,
|
|
46498
|
+
constants5.O_RDONLY | constants5.O_DIRECTORY | constants5.O_NOFOLLOW
|
|
46499
|
+
);
|
|
46500
|
+
try {
|
|
46501
|
+
const st = await dh.stat();
|
|
46502
|
+
if (typeof process.getuid === "function" && st.uid !== process.getuid())
|
|
46503
|
+
throw new Error("folder is not yours");
|
|
46504
|
+
const again = await lstat(dir);
|
|
46505
|
+
if (again.isSymbolicLink() || again.dev !== st.dev || again.ino !== st.ino)
|
|
46506
|
+
throw new Error("folder changed");
|
|
46507
|
+
await dh.chmod(448);
|
|
46508
|
+
return { dev: st.dev, ino: st.ino };
|
|
46509
|
+
} finally {
|
|
46510
|
+
await dh.close();
|
|
46511
|
+
}
|
|
46512
|
+
};
|
|
46513
|
+
const sameDir2 = async (dir, id) => {
|
|
46514
|
+
const st = await lstat(dir);
|
|
46515
|
+
if (st.isSymbolicLink() || st.dev !== id.dev || st.ino !== id.ino)
|
|
46516
|
+
throw new Error("folder changed");
|
|
46517
|
+
};
|
|
46518
|
+
const openChecked = async (f, flags) => {
|
|
46519
|
+
const fh = await open2(
|
|
46520
|
+
f,
|
|
46521
|
+
flags | constants5.O_NOFOLLOW | constants5.O_NONBLOCK,
|
|
46522
|
+
384
|
|
46523
|
+
);
|
|
46524
|
+
try {
|
|
46525
|
+
if (!(await fh.stat()).isFile()) throw new Error("not a regular file");
|
|
46526
|
+
await fh.chmod(384);
|
|
46527
|
+
return fh;
|
|
46528
|
+
} catch (e) {
|
|
46529
|
+
await fh.close();
|
|
46530
|
+
throw e;
|
|
46531
|
+
}
|
|
46532
|
+
};
|
|
46499
46533
|
const write = async (line) => {
|
|
46500
46534
|
try {
|
|
46535
|
+
const dir = dirname9(file2);
|
|
46536
|
+
const id = await checkDir2(dir);
|
|
46501
46537
|
if (size === void 0) {
|
|
46502
|
-
const dir = dirname9(file2);
|
|
46503
|
-
const ds = await lstat(dir).catch(() => void 0);
|
|
46504
|
-
if (ds && !ds.isDirectory()) throw new Error("not a folder");
|
|
46505
|
-
await mkdir(dir, { recursive: true, mode: 448 });
|
|
46506
|
-
await chmod(dir, 448);
|
|
46507
46538
|
size = 0;
|
|
46508
46539
|
for (const f of [file2, `${file2}.1`]) {
|
|
46509
46540
|
const st = await lstat(f).catch(() => void 0);
|
|
46510
46541
|
if (!st) continue;
|
|
46511
|
-
|
|
46512
|
-
|
|
46513
|
-
|
|
46542
|
+
const fh2 = await openChecked(f, constants5.O_RDONLY);
|
|
46543
|
+
try {
|
|
46544
|
+
if (f === file2) size = (await fh2.stat()).size;
|
|
46545
|
+
} finally {
|
|
46546
|
+
await fh2.close();
|
|
46547
|
+
}
|
|
46514
46548
|
}
|
|
46515
46549
|
}
|
|
46516
46550
|
if (size > 0 && size + Buffer.byteLength(line) > max) {
|
|
46551
|
+
await sameDir2(dir, id);
|
|
46517
46552
|
await rename(file2, `${file2}.1`);
|
|
46518
46553
|
size = 0;
|
|
46519
46554
|
}
|
|
46520
|
-
const fh = await
|
|
46555
|
+
const fh = await openChecked(
|
|
46521
46556
|
file2,
|
|
46522
|
-
constants5.O_WRONLY | constants5.O_APPEND | constants5.O_CREAT
|
|
46523
|
-
384
|
|
46557
|
+
constants5.O_WRONLY | constants5.O_APPEND | constants5.O_CREAT
|
|
46524
46558
|
);
|
|
46525
46559
|
try {
|
|
46526
|
-
|
|
46560
|
+
await sameDir2(dir, id);
|
|
46527
46561
|
await fh.write(line);
|
|
46528
46562
|
} finally {
|
|
46529
46563
|
await fh.close();
|
|
@@ -48039,6 +48073,7 @@ async function runDaemon(deps2 = {}) {
|
|
|
48039
48073
|
socketWatch.unref();
|
|
48040
48074
|
const codexAgentsFile = cx.agentsFile ?? join18(home(), "codex-agents.json");
|
|
48041
48075
|
let codexSaved;
|
|
48076
|
+
const restorePending = /* @__PURE__ */ new Map();
|
|
48042
48077
|
const persistCodex = () => {
|
|
48043
48078
|
const rows = [];
|
|
48044
48079
|
for (const a of agents.all()) {
|
|
@@ -48054,6 +48089,8 @@ async function runDaemon(deps2 = {}) {
|
|
|
48054
48089
|
busName: a.busName
|
|
48055
48090
|
});
|
|
48056
48091
|
}
|
|
48092
|
+
for (const [ref, r] of restorePending)
|
|
48093
|
+
if (!rows.some((x) => x.ref === ref)) rows.push(r);
|
|
48057
48094
|
const text3 = JSON.stringify(rows);
|
|
48058
48095
|
if (codexSaved === void 0 ? rows.length === 0 : text3 === codexSaved)
|
|
48059
48096
|
return;
|
|
@@ -48066,44 +48103,99 @@ async function runDaemon(deps2 = {}) {
|
|
|
48066
48103
|
);
|
|
48067
48104
|
}
|
|
48068
48105
|
};
|
|
48106
|
+
const restoreTimers = /* @__PURE__ */ new Set();
|
|
48107
|
+
const RESTORE_TRIES = 5;
|
|
48069
48108
|
const restoreCodex = () => {
|
|
48070
48109
|
if (deps2.attest) return;
|
|
48071
|
-
|
|
48072
|
-
|
|
48073
|
-
|
|
48074
|
-
|
|
48075
|
-
|
|
48076
|
-
|
|
48110
|
+
const attempt = (rows, tries) => {
|
|
48111
|
+
const again = [];
|
|
48112
|
+
for (const r of rows) {
|
|
48113
|
+
if (agents.byRef(r.ref)) {
|
|
48114
|
+
restorePending.delete(r.ref);
|
|
48115
|
+
continue;
|
|
48116
|
+
}
|
|
48117
|
+
const drop = (reason2) => ev("codex_restore_dropped", { thread: r.ref, pid: r.pid, reason: reason2 });
|
|
48118
|
+
let res;
|
|
48119
|
+
try {
|
|
48120
|
+
res = codexCheck.restore({
|
|
48121
|
+
thread: r.ref,
|
|
48122
|
+
pid: r.pid,
|
|
48123
|
+
start: r.procStart
|
|
48124
|
+
});
|
|
48125
|
+
} catch {
|
|
48126
|
+
}
|
|
48127
|
+
if (!res) {
|
|
48128
|
+
drop("error");
|
|
48129
|
+
continue;
|
|
48130
|
+
}
|
|
48131
|
+
if ("unknown" in res) {
|
|
48132
|
+
if (tries + 1 < RESTORE_TRIES) {
|
|
48133
|
+
again.push(r);
|
|
48134
|
+
restorePending.set(r.ref, r);
|
|
48135
|
+
} else {
|
|
48136
|
+
restorePending.delete(r.ref);
|
|
48137
|
+
drop("ps_unknown");
|
|
48138
|
+
}
|
|
48139
|
+
continue;
|
|
48140
|
+
}
|
|
48141
|
+
restorePending.delete(r.ref);
|
|
48142
|
+
if ("dropped" in res) {
|
|
48143
|
+
drop(res.dropped);
|
|
48144
|
+
continue;
|
|
48145
|
+
}
|
|
48146
|
+
const proven = res;
|
|
48147
|
+
let ns;
|
|
48148
|
+
try {
|
|
48149
|
+
ns = resolveNs(proven.cwd, true);
|
|
48150
|
+
} catch {
|
|
48151
|
+
drop("no_namespace");
|
|
48152
|
+
continue;
|
|
48153
|
+
}
|
|
48154
|
+
if (!WireNamespaceSchema.safeParse(ns.namespace).success) {
|
|
48155
|
+
drop("no_namespace");
|
|
48156
|
+
continue;
|
|
48157
|
+
}
|
|
48158
|
+
agents.up({
|
|
48159
|
+
ref: r.ref,
|
|
48160
|
+
kind: "codex",
|
|
48161
|
+
proposedName: r.proposedName,
|
|
48162
|
+
busName: r.busName,
|
|
48163
|
+
namespace: ns.namespace,
|
|
48164
|
+
namespaceSource: ns.source,
|
|
48165
|
+
global: ns.global,
|
|
48077
48166
|
pid: r.pid,
|
|
48078
|
-
|
|
48167
|
+
procStart: r.procStart,
|
|
48168
|
+
cwd: proven.cwd,
|
|
48169
|
+
live: true,
|
|
48170
|
+
...r.sentName !== void 0 ? { sentName: r.sentName } : {}
|
|
48079
48171
|
});
|
|
48080
|
-
|
|
48081
|
-
|
|
48082
|
-
|
|
48083
|
-
|
|
48084
|
-
|
|
48085
|
-
|
|
48086
|
-
|
|
48087
|
-
|
|
48088
|
-
|
|
48089
|
-
|
|
48090
|
-
|
|
48091
|
-
|
|
48092
|
-
|
|
48093
|
-
|
|
48094
|
-
|
|
48095
|
-
|
|
48096
|
-
|
|
48097
|
-
|
|
48098
|
-
|
|
48099
|
-
|
|
48100
|
-
|
|
48101
|
-
|
|
48102
|
-
|
|
48103
|
-
|
|
48104
|
-
|
|
48105
|
-
|
|
48106
|
-
|
|
48172
|
+
seenAt.set(r.ref, ++seenSeq);
|
|
48173
|
+
ev("codex_restored", { thread: r.ref, pid: r.pid });
|
|
48174
|
+
const rec = agents.byRef(r.ref);
|
|
48175
|
+
if (tries > 0 && rec?.live && hub.open) {
|
|
48176
|
+
announceUp(rec);
|
|
48177
|
+
tellOwed(r.ref);
|
|
48178
|
+
}
|
|
48179
|
+
if (debug)
|
|
48180
|
+
log(`restored codex thread ${r.ref.slice(0, 8)} pid ${r.pid}`);
|
|
48181
|
+
}
|
|
48182
|
+
if (again.length === 0) return;
|
|
48183
|
+
for (const r of again)
|
|
48184
|
+
if (tries === 0)
|
|
48185
|
+
ev("codex_restore_retry", {
|
|
48186
|
+
thread: r.ref,
|
|
48187
|
+
pid: r.pid,
|
|
48188
|
+
reason: "ps_unknown"
|
|
48189
|
+
});
|
|
48190
|
+
const delay = (deps2.restoreRetryMs ?? 1e3) * 2 ** tries;
|
|
48191
|
+
const t = setTimeout(() => {
|
|
48192
|
+
restoreTimers.delete(t);
|
|
48193
|
+
attempt(again, tries + 1);
|
|
48194
|
+
}, delay);
|
|
48195
|
+
t.unref();
|
|
48196
|
+
restoreTimers.add(t);
|
|
48197
|
+
};
|
|
48198
|
+
attempt(readCodexAgents(codexAgentsFile), 0);
|
|
48107
48199
|
};
|
|
48108
48200
|
const awayFile = cx.awayFile ?? join18(home(), "codex-away.json");
|
|
48109
48201
|
const awayNow = deps2.bindingNow ?? Date.now;
|
|
@@ -48373,6 +48465,7 @@ async function runDaemon(deps2 = {}) {
|
|
|
48373
48465
|
outbox.stop();
|
|
48374
48466
|
resends.stop();
|
|
48375
48467
|
for (const t of limited.values()) clearTimeout(t);
|
|
48468
|
+
for (const t of restoreTimers) clearTimeout(t);
|
|
48376
48469
|
hub.stop();
|
|
48377
48470
|
receipts.release();
|
|
48378
48471
|
await new Promise((r) => setImmediate(r));
|
|
@@ -50035,7 +50128,7 @@ var noService = {
|
|
|
50035
50128
|
remove: async () => ({}),
|
|
50036
50129
|
cli: () => ["oa-bus"]
|
|
50037
50130
|
};
|
|
50038
|
-
var VERSION = true ? "0.162.
|
|
50131
|
+
var VERSION = true ? "0.162.1" : JSON.parse(
|
|
50039
50132
|
readFileSync16(new URL("../package.json", import.meta.url), "utf8")
|
|
50040
50133
|
).version;
|
|
50041
50134
|
var which = (cmd) => {
|
|
@@ -57045,12 +57138,37 @@ import {
|
|
|
57045
57138
|
closeSync as closeSync9,
|
|
57046
57139
|
constants as constants6,
|
|
57047
57140
|
fstatSync as fstatSync5,
|
|
57141
|
+
lstatSync as lstatSync18,
|
|
57048
57142
|
openSync as openSync9,
|
|
57049
57143
|
readFileSync as readFileSync32
|
|
57050
57144
|
} from "node:fs";
|
|
57051
|
-
import { join as join38 } from "node:path";
|
|
57145
|
+
import { dirname as dirname18, join as join38 } from "node:path";
|
|
57052
57146
|
var TAIL = 50;
|
|
57053
|
-
var
|
|
57147
|
+
var checkDir = (dir) => {
|
|
57148
|
+
let fd;
|
|
57149
|
+
try {
|
|
57150
|
+
const ls = lstatSync18(dir);
|
|
57151
|
+
if (ls.isSymbolicLink()) return { ok: false, why: "it is a symlink" };
|
|
57152
|
+
if (!ls.isDirectory()) return { ok: false, why: "it is not a folder" };
|
|
57153
|
+
if (typeof process.getuid === "function" && ls.uid !== process.getuid())
|
|
57154
|
+
return { ok: false, why: "it is not owned by you" };
|
|
57155
|
+
if ((ls.mode & 63) !== 0)
|
|
57156
|
+
return { ok: false, why: "it is open to other users (want mode 0700)" };
|
|
57157
|
+
fd = openSync9(
|
|
57158
|
+
dir,
|
|
57159
|
+
constants6.O_RDONLY | constants6.O_DIRECTORY | constants6.O_NOFOLLOW
|
|
57160
|
+
);
|
|
57161
|
+
const fs = fstatSync5(fd);
|
|
57162
|
+
if (fs.dev !== ls.dev || fs.ino !== ls.ino)
|
|
57163
|
+
return { ok: false, why: "it changed while it was checked" };
|
|
57164
|
+
return { ok: true, dev: fs.dev, ino: fs.ino };
|
|
57165
|
+
} catch (e) {
|
|
57166
|
+
return e.code === "ENOENT" ? { ok: false, why: "missing" } : { ok: false, why: "it cannot be opened safely" };
|
|
57167
|
+
} finally {
|
|
57168
|
+
if (fd !== void 0) closeSync9(fd);
|
|
57169
|
+
}
|
|
57170
|
+
};
|
|
57171
|
+
var tail = (path, dir) => {
|
|
57054
57172
|
let fd;
|
|
57055
57173
|
try {
|
|
57056
57174
|
fd = openSync9(
|
|
@@ -57058,6 +57176,9 @@ var tail = (path) => {
|
|
|
57058
57176
|
constants6.O_RDONLY | constants6.O_NOFOLLOW | constants6.O_NONBLOCK
|
|
57059
57177
|
);
|
|
57060
57178
|
if (!fstatSync5(fd).isFile()) return "skipped";
|
|
57179
|
+
const after = lstatSync18(dirname18(path));
|
|
57180
|
+
if (after.isSymbolicLink() || after.dev !== dir.dev || after.ino !== dir.ino)
|
|
57181
|
+
return "skipped";
|
|
57061
57182
|
return readFileSync32(fd, "utf8").replace(/\n$/, "").split("\n").slice(-TAIL);
|
|
57062
57183
|
} catch (e) {
|
|
57063
57184
|
return e.code === "ELOOP" ? "skipped" : void 0;
|
|
@@ -57066,11 +57187,21 @@ var tail = (path) => {
|
|
|
57066
57187
|
}
|
|
57067
57188
|
};
|
|
57068
57189
|
async function logs(ctx) {
|
|
57069
|
-
const
|
|
57070
|
-
const
|
|
57190
|
+
const logDir = join38(ctx.home, "logs");
|
|
57191
|
+
const path = join38(logDir, "daemon.log");
|
|
57192
|
+
const eventsPath = join38(logDir, "events.log");
|
|
57193
|
+
const dir = checkDir(logDir);
|
|
57194
|
+
if (!dir.ok && dir.why !== "missing") {
|
|
57195
|
+
say(ctx, `Not reading ${tilde(ctx, logDir)}: ${dir.why}.`);
|
|
57196
|
+
return 1;
|
|
57197
|
+
}
|
|
57198
|
+
if (!dir.ok) {
|
|
57199
|
+
say(ctx, ctx.copy.noLog(tilde(ctx, path)));
|
|
57200
|
+
return 1;
|
|
57201
|
+
}
|
|
57071
57202
|
const show2 = (p, t) => t === "skipped" ? [`skipped ${tilde(ctx, p)}: not a regular file`] : t;
|
|
57072
|
-
const daemon2 = tail(path);
|
|
57073
|
-
const events = tail(eventsPath);
|
|
57203
|
+
const daemon2 = tail(path, dir);
|
|
57204
|
+
const events = tail(eventsPath, dir);
|
|
57074
57205
|
if (!daemon2 && !events) {
|
|
57075
57206
|
say(ctx, ctx.copy.noLog(tilde(ctx, path)));
|
|
57076
57207
|
return 1;
|
|
@@ -57309,7 +57440,7 @@ import { join as join41 } from "node:path";
|
|
|
57309
57440
|
|
|
57310
57441
|
// src/steps/purge.ts
|
|
57311
57442
|
init_src3();
|
|
57312
|
-
import { lstatSync as
|
|
57443
|
+
import { lstatSync as lstatSync19, readdirSync as readdirSync11, rmdirSync as rmdirSync5, rmSync as rmSync18 } from "node:fs";
|
|
57313
57444
|
import { join as join40 } from "node:path";
|
|
57314
57445
|
var FILES = [
|
|
57315
57446
|
"machine.json",
|
|
@@ -57343,7 +57474,7 @@ var FOLDERS = [
|
|
|
57343
57474
|
];
|
|
57344
57475
|
function kind3(path) {
|
|
57345
57476
|
try {
|
|
57346
|
-
const st =
|
|
57477
|
+
const st = lstatSync19(path);
|
|
57347
57478
|
return st.isDirectory() ? "dir" : st.isSocket() ? "socket" : "other";
|
|
57348
57479
|
} catch {
|
|
57349
57480
|
return void 0;
|