tamperward 2.29.19 → 2.29.20
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/dist/cli/index.js +35 -9
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -11638,14 +11638,31 @@ function watcherTelemetry(log) {
|
|
|
11638
11638
|
return { state: "degraded", health, reason: health.last_error ?? "observer reported an error" };
|
|
11639
11639
|
return { state: "healthy", health };
|
|
11640
11640
|
}
|
|
11641
|
-
function watchTree(dir, cb, onState, onError) {
|
|
11641
|
+
function watchTree(dir, cb, onState, onError, watchFn = watch) {
|
|
11642
|
+
const describe2 = (e) => e instanceof Error ? e.message : String(e);
|
|
11642
11643
|
if (process.env.TAMPERWARD_WATCH_NO_RECURSIVE !== "1") {
|
|
11643
11644
|
try {
|
|
11644
|
-
|
|
11645
|
+
let recursiveClosed = false;
|
|
11646
|
+
const closeRecursive = () => {
|
|
11647
|
+
if (recursiveClosed) return;
|
|
11648
|
+
recursiveClosed = true;
|
|
11649
|
+
w.close();
|
|
11650
|
+
};
|
|
11651
|
+
const w = watchFn(dir, { recursive: true }, (kind, fname) => {
|
|
11645
11652
|
if (fname) cb(kind, String(fname));
|
|
11646
11653
|
});
|
|
11654
|
+
w.on("error", (e) => {
|
|
11655
|
+
if (recursiveClosed) return;
|
|
11656
|
+
recursiveClosed = true;
|
|
11657
|
+
try {
|
|
11658
|
+
w.close();
|
|
11659
|
+
} catch {
|
|
11660
|
+
}
|
|
11661
|
+
onState("recursive", 0);
|
|
11662
|
+
onError(`recursive watch on ${dir}: ${describe2(e)}`);
|
|
11663
|
+
});
|
|
11647
11664
|
onState("recursive", 1);
|
|
11648
|
-
return { close:
|
|
11665
|
+
return { close: closeRecursive };
|
|
11649
11666
|
} catch {
|
|
11650
11667
|
}
|
|
11651
11668
|
}
|
|
@@ -11656,7 +11673,7 @@ function watchTree(dir, cb, onState, onError) {
|
|
|
11656
11673
|
if (closed || watchers.has(rel) || SKIP2.test(rel + "/")) return;
|
|
11657
11674
|
let w;
|
|
11658
11675
|
try {
|
|
11659
|
-
w =
|
|
11676
|
+
w = watchFn(rel ? join12(dir, rel) : dir, (kind, fname) => {
|
|
11660
11677
|
if (closed || !fname) return;
|
|
11661
11678
|
const child = rel ? `${rel}/${String(fname)}` : String(fname);
|
|
11662
11679
|
cb(kind, child);
|
|
@@ -11666,11 +11683,19 @@ function watchTree(dir, cb, onState, onError) {
|
|
|
11666
11683
|
}
|
|
11667
11684
|
});
|
|
11668
11685
|
} catch (e) {
|
|
11669
|
-
onError(
|
|
11670
|
-
`watch directory ${rel || "."}: ${e instanceof Error ? e.message : String(e)}`
|
|
11671
|
-
);
|
|
11686
|
+
onError(`watch directory ${rel || "."}: ${describe2(e)}`);
|
|
11672
11687
|
return;
|
|
11673
11688
|
}
|
|
11689
|
+
w.on("error", (e) => {
|
|
11690
|
+
if (closed || watchers.get(rel) !== w) return;
|
|
11691
|
+
watchers.delete(rel);
|
|
11692
|
+
try {
|
|
11693
|
+
w.close();
|
|
11694
|
+
} catch {
|
|
11695
|
+
}
|
|
11696
|
+
onError(`watch directory ${rel || "."}: ${describe2(e)}`);
|
|
11697
|
+
onState("fallback", watchers.size);
|
|
11698
|
+
});
|
|
11674
11699
|
watchers.set(rel, w);
|
|
11675
11700
|
onState("fallback", watchers.size);
|
|
11676
11701
|
};
|
|
@@ -11704,7 +11729,7 @@ function watchTree(dir, cb, onState, onError) {
|
|
|
11704
11729
|
}
|
|
11705
11730
|
};
|
|
11706
11731
|
}
|
|
11707
|
-
function startWatcher(dir, log, policy) {
|
|
11732
|
+
function startWatcher(dir, log, policy, watchFn = watch) {
|
|
11708
11733
|
try {
|
|
11709
11734
|
mkdirSync4(join12(log, ".."), { recursive: true });
|
|
11710
11735
|
} catch {
|
|
@@ -11784,7 +11809,8 @@ function startWatcher(dir, log, policy) {
|
|
|
11784
11809
|
health.watched_dirs = watchedDirs;
|
|
11785
11810
|
persistHealth();
|
|
11786
11811
|
},
|
|
11787
|
-
(detail) => degrade(detail)
|
|
11812
|
+
(detail) => degrade(detail),
|
|
11813
|
+
watchFn
|
|
11788
11814
|
);
|
|
11789
11815
|
let closed = false;
|
|
11790
11816
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tamperward",
|
|
3
|
-
"version": "2.29.
|
|
3
|
+
"version": "2.29.20",
|
|
4
4
|
"description": "The deterministic agent-integrity gate. One ruleset, evaluated on the actual diff/commands as a verdict, enforced everywhere a change can be made.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "hexrift",
|